@pluno/product-agent-web 0.1.310 → 0.1.311

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.
@@ -76,7 +76,7 @@ function ih(t, e, n, i) {
76
76
  function sh(t) {
77
77
  return Gr(t) > 0.5 ? [24, 24, 27] : [250, 250, 249];
78
78
  }
79
- const oh = "0.1.310", ci = {
79
+ const oh = "0.1.311", ci = {
80
80
  version: oh
81
81
  }, fe = (t) => typeof t == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(t) ? t : null;
82
82
  function Ld(t) {
@@ -674,15 +674,15 @@ function Eh(t, e) {
674
674
  return n && i >= 0 ? n.slice(0, i + 1) : [e];
675
675
  }
676
676
  function Jt(t, e, n) {
677
- const i = t.submissionOrder.map((C) => t.submissions[C]).filter((C) => C.conversationScopeId === n), s = e.selections[n]?.sessionId ?? i.find((C) => !C.cancelled && C.sessionId !== null)?.sessionId ?? null, o = s ? t.sessions[s] : void 0, a = t.submissionOrder.map((C) => t.submissions[C]).filter((C) => s ? C.sessionId === s || C.sessionId === null && C.conversationScopeId === n : C.conversationScopeId === n), r = Object.values(o?.items ?? {}).sort((C, U) => {
678
- const te = Gt(C.created_at), ne = Gt(U.created_at);
679
- return te < ne ? -1 : te > ne ? 1 : C.id < U.id ? -1 : C.id > U.id ? 1 : 0;
677
+ const i = t.submissionOrder.map((C) => t.submissions[C]).filter((C) => C.conversationScopeId === n), s = e.selections[n]?.sessionId ?? i.find((C) => !C.cancelled && C.sessionId !== null)?.sessionId ?? null, o = s ? t.sessions[s] : void 0, a = t.submissionOrder.map((C) => t.submissions[C]).filter((C) => s ? C.sessionId === s || C.sessionId === null && C.conversationScopeId === n : C.conversationScopeId === n), r = Object.values(o?.items ?? {}).sort((C, z) => {
678
+ const te = Gt(C.created_at), ne = Gt(z.created_at);
679
+ return te < ne ? -1 : te > ne ? 1 : C.id < z.id ? -1 : C.id > z.id ? 1 : 0;
680
680
  }), c = a.filter((C) => (!C.cancelled || C.conversationScopeId === n && (C.sessionId === null || C.sessionId === s || s === null && C === a[a.length - 1])) && !o?.items[C.userMessageId] && !o?.removedItems[C.userMessageId]), l = {};
681
681
  for (const C of r) {
682
- const U = Xs(C);
683
- if (U === null) continue;
682
+ const z = Xs(C);
683
+ if (z === null) continue;
684
684
  const te = o?.streams[C.id];
685
- l[C.id] = te ? te.state === "open" ? "open" : U < te.revision ? "awaiting_content" : te.state : "open";
685
+ l[C.id] = te ? te.state === "open" ? "open" : z < te.revision ? "awaiting_content" : te.state : "open";
686
686
  }
687
687
  const u = [];
688
688
  for (const C of r)
@@ -690,15 +690,15 @@ function Jt(t, e, n) {
690
690
  u.push({ id: C.id, userMessageId: C.id, activityIds: [], outcomeIds: [], collapsed: !1 });
691
691
  else {
692
692
  u.length || u.push({ id: `leading:${C.id}`, userMessageId: null, activityIds: [], outcomeIds: [], collapsed: !1 });
693
- const U = u.length - 1, te = u[U], ne = C.type === "commentary" || C.type === "tool_summary" ? "activityIds" : "outcomeIds";
694
- u[U] = { ...te, [ne]: [...te[ne], C.id] };
693
+ const z = u.length - 1, te = u[z], ne = C.type === "commentary" || C.type === "tool_summary" ? "activityIds" : "outcomeIds";
694
+ u[z] = { ...te, [ne]: [...te[ne], C.id] };
695
695
  }
696
696
  for (const C of c) {
697
- const U = u.findIndex((te) => {
697
+ const z = u.findIndex((te) => {
698
698
  const ne = a.find((we) => we.userMessageId === te.userMessageId), Oe = o?.items[te.userMessageId ?? te.activityIds[0] ?? te.outcomeIds[0]];
699
699
  return (ne?.submittedAt ?? (Oe ? Date.parse(Oe.created_at) : 1 / 0)) > C.submittedAt;
700
700
  });
701
- u.splice(U < 0 ? u.length : U, 0, {
701
+ u.splice(z < 0 ? u.length : z, 0, {
702
702
  id: C.userMessageId,
703
703
  userMessageId: C.userMessageId,
704
704
  activityIds: [],
@@ -708,18 +708,18 @@ function Jt(t, e, n) {
708
708
  }
709
709
  const d = o?.execution, p = a.filter((C) => !C.cancelled && C.delivery !== "failed"), f = p.filter((C) => C.delivery !== "accepted" && C.executionVersion === null), y = p.filter((C) => C.delivery === "accepted" && C.executionVersion === null), g = p[p.length - 1], b = f.length > 0, _ = g !== void 0 && y.includes(g);
710
710
  let S = b ? "submitting" : _ ? "awaiting_execution" : d?.phase ?? "idle";
711
- const x = Object.entries(t.stops).filter(([C]) => C === n || s !== null && e.selections[C]?.sessionId === s).map(([, C]) => C).find((C) => (!a.length || C.userMessageIds.includes(a[a.length - 1].userMessageId) || !b && !_ && Pt(d).some((U) => C.userMessageIds.includes(U))) && (!d || d.version <= C.executionVersion || ["thinking", "steering", "queued", "stopping"].includes(d.phase) || a.some((U) => U.cancelled && U.executionVersion === null && C.userMessageIds.includes(U.userMessageId)))), m = d && ["thinking", "steering", "queued", "stopping"].includes(d.phase) || a.some((C) => C.delivery === "accepted" && C.executionVersion === null && x?.userMessageIds.includes(C.userMessageId));
711
+ const x = Object.entries(t.stops).filter(([C]) => C === n || s !== null && e.selections[C]?.sessionId === s).map(([, C]) => C).find((C) => (!a.length || C.userMessageIds.includes(a[a.length - 1].userMessageId) || !b && !_ && Pt(d).some((z) => C.userMessageIds.includes(z))) && (!d || d.version <= C.executionVersion || ["thinking", "steering", "queued", "stopping"].includes(d.phase) || a.some((z) => z.cancelled && z.executionVersion === null && C.userMessageIds.includes(z.userMessageId)))), m = d && ["thinking", "steering", "queued", "stopping"].includes(d.phase) || a.some((C) => C.delivery === "accepted" && C.executionVersion === null && x?.userMessageIds.includes(C.userMessageId));
712
712
  x && m && !b && (!d || !["thinking", "steering", "queued", "stopping"].includes(d.phase) || Pt(d).every((C) => x.userMessageIds.includes(C))) && (S = "stopping"), x && !m && !b && a.some((C) => C.cancelled && C.executionVersion === null && x.userMessageIds.includes(C.userMessageId)) && (S = a.some((C) => x.userMessageIds.includes(C.userMessageId) && ["sending", "uncertain"].includes(C.delivery)) ? "stopping" : "stopped");
713
713
  const w = ["thinking", "steering", "queued"].includes(S), I = t.stops[n] ?? x, E = I?.userMessageIds.filter((C) => !["completed", "failed"].includes(o?.executionByUserMessage[C]?.phase ?? "")) ?? [], T = E.some((C) => {
714
- const U = a.find((ne) => ne.userMessageId === C);
715
- return !Object.values(t.operations).some((ne) => ne.command.type === "run.stop" && ne.command.payload.expectedUserMessageId === C && ne.phase === "done") && (U?.executionVersion === null && ["sending", "uncertain", "accepted"].includes(U.delivery) || !!(d && Pt(d).includes(C) && ["thinking", "steering", "queued", "stopping"].includes(d.phase)));
716
- }), k = d?.user_message_ids ?? [], M = b || _ ? g?.userMessageId ?? null : k[k.length - 1] ?? null, q = u.find((C) => C.userMessageId === M), z = w ? [...q?.activityIds ?? []].reverse().find((C) => l[C] === "open") ?? null : null, B = s !== null && !!e.selections[n]?.provisionalId && r.length === 0 && a.length === 0 && // The first persisted idle snapshot already has a positive synchronization version.
714
+ const z = a.find((ne) => ne.userMessageId === C);
715
+ return !Object.values(t.operations).some((ne) => ne.command.type === "run.stop" && ne.command.payload.expectedUserMessageId === C && ne.phase === "done") && (z?.executionVersion === null && ["sending", "uncertain", "accepted"].includes(z.delivery) || !!(d && Pt(d).includes(C) && ["thinking", "steering", "queued", "stopping"].includes(d.phase)));
716
+ }), k = d?.user_message_ids ?? [], M = b || _ ? g?.userMessageId ?? null : k[k.length - 1] ?? null, q = u.find((C) => C.userMessageId === M), B = w ? [...q?.activityIds ?? []].reverse().find((C) => l[C] === "open") ?? null : null, U = s !== null && !!e.selections[n]?.provisionalId && r.length === 0 && a.length === 0 && // The first persisted idle snapshot already has a positive synchronization version.
717
717
  (!o?.execution || o.execution.phase === "idle" && o.execution.user_message_ids.length === 0) && Object.values(t.operations).some((C) => C.conversationScopeId === n && C.phase === "done" && ["runtime.warmup", "attachment.prepare"].includes(C.command.type) && !C.command.payload.sessionId && C.result?.sessionId === s);
718
718
  return Ve({
719
719
  historyRefreshFailure: o?.historyRefreshFailure ?? null,
720
720
  selectionKey: n ? JSON.stringify([t.authorityId, t.generation, n]) : void 0,
721
721
  stableSelectionKey: n ? JSON.stringify([t.authorityId, n]) : void 0,
722
- isDraftSession: B,
722
+ isDraftSession: U,
723
723
  proactiveQuestion: t.proactiveQuestions[n] ?? null,
724
724
  sessionId: s,
725
725
  items: r,
@@ -733,8 +733,8 @@ function Jt(t, e, n) {
733
733
  streamStates: l,
734
734
  preparation: o?.preparation ?? null,
735
735
  stop: I ? { ...I, userMessageIds: E, pending: T } : null,
736
- segments: u.map((C, U) => ({ ...C, collapsed: w ? C.userMessageId !== M : U < u.length - 1 || C.activityIds.length > 0 })),
737
- activity: { phase: S, activeItemId: z, userMessageId: M, executionKey: JSON.stringify([...Pt(d)].sort()) },
736
+ segments: u.map((C, z) => ({ ...C, collapsed: w ? C.userMessageId !== M : z < u.length - 1 || C.activityIds.length > 0 })),
737
+ activity: { phase: S, activeItemId: B, userMessageId: M, executionKey: JSON.stringify([...Pt(d)].sort()) },
738
738
  // Staging transfers the immutable input to the core. Waiting for backend acceptance leaves
739
739
  // the same submitted text in the optimistic transcript and composer during delivery.
740
740
  receipts: i.filter((C) => !C.cancelled && e.clients[C.clientScopeId] === n).map((C) => ({ viewId: C.viewId, userMessageId: C.userMessageId, acceptedRendererRevision: C.rendererRevision, durable: t.durableSubmissionIds.includes(C.userMessageId) || C.delivery === "accepted" }))
@@ -1242,11 +1242,11 @@ function ra(t, e, n) {
1242
1242
  const c = (m, w) => {
1243
1243
  const I = { ...i.features.contextObservers }, E = I[m];
1244
1244
  if (w === null ? delete I[m] : I[m] = yt(r, { kind: "originContext", clientScopeId: m, origin: w, pageUrl: "" }), o({ contextObservers: I }), !E || Object.values(I).includes(E)) return;
1245
- const T = { ...i.features.queries }, k = { ...i.features.polls }, M = { ...i.features.contextReads }, q = { ...i.features.originContextQueries }, z = { ...i.features.pending }, B = q[E]?.origin, C = { ...i.features.contextRunOrigins };
1246
- for (const [U, te] of Object.entries(C)) te === B && delete C[U];
1245
+ const T = { ...i.features.queries }, k = { ...i.features.polls }, M = { ...i.features.contextReads }, q = { ...i.features.originContextQueries }, B = { ...i.features.pending }, U = q[E]?.origin, C = { ...i.features.contextRunOrigins };
1246
+ for (const [z, te] of Object.entries(C)) te === U && delete C[z];
1247
1247
  delete T[E], delete k[E], delete M[E], delete q[E];
1248
- for (const [U, te] of Object.entries(z)) te.mode === "query" && te.key === E && delete z[U];
1249
- o({ queries: T, polls: k, contextReads: M, originContextQueries: q, contextRunOrigins: C, pending: z });
1248
+ for (const [z, te] of Object.entries(B)) te.mode === "query" && te.key === E && delete B[z];
1249
+ o({ queries: T, polls: k, contextReads: M, originContextQueries: q, contextRunOrigins: C, pending: B });
1250
1250
  };
1251
1251
  if (e.type === "stage7.account_fallback") return { state: { ...i, account: {
1252
1252
  ...i.account,
@@ -1277,7 +1277,7 @@ function ra(t, e, n) {
1277
1277
  delete M[m], E[T] = {
1278
1278
  ...k,
1279
1279
  shown: M,
1280
- turns: Object.fromEntries(Object.entries(k.turns).map(([q, z]) => [q, { ...z, [m]: !1, [`${m}Suppressed`]: !0 }]))
1280
+ turns: Object.fromEntries(Object.entries(k.turns).map(([q, B]) => [q, { ...B, [m]: !1, [`${m}Suppressed`]: !0 }]))
1281
1281
  };
1282
1282
  }
1283
1283
  a({ openings: E });
@@ -1308,12 +1308,12 @@ function ra(t, e, n) {
1308
1308
  Kn(r, m);
1309
1309
  const E = yt(r, m), T = Mn(r, "query", w);
1310
1310
  if (m.kind === "originContext") {
1311
- const z = i.features.queries[E], B = i.features.contextReads[E];
1312
- if (o({ originContextQueries: { ...i.features.originContextQueries, [E]: m } }), !I && (z?.status === "ready" || z?.status === "error") && B && (i.features.now - B.settledAt < 3e4 || z.error && !z.error.retryable && z.error.code !== "runtime_error")) return;
1311
+ const B = i.features.queries[E], U = i.features.contextReads[E];
1312
+ if (o({ originContextQueries: { ...i.features.originContextQueries, [E]: m } }), !I && (B?.status === "ready" || B?.status === "error") && U && (i.features.now - U.settledAt < 3e4 || B.error && !B.error.retryable && B.error.code !== "runtime_error")) return;
1313
1313
  }
1314
1314
  const k = i.features.pending[T];
1315
1315
  if (k && k.fingerprint !== JSON.stringify(m)) throw new Error("Query request ID changed payload.");
1316
- if (k?.status === "pending" || Object.values(i.features.pending).some((z) => z.mode === "query" && z.key === E && z.status === "pending")) return;
1316
+ if (k?.status === "pending" || Object.values(i.features.pending).some((B) => B.mode === "query" && B.key === E && B.status === "pending")) return;
1317
1317
  const M = i.features.queries[E] ?? Zt(E), q = ni(M, { key: E, requestId: Ct(w), mode: "replace" });
1318
1318
  o({ queries: { ...i.features.queries, [E]: q }, pending: { ...i.features.pending, [T]: {
1319
1319
  requestId: w,
@@ -1339,14 +1339,14 @@ function ra(t, e, n) {
1339
1339
  if (m.kind === "preference" && (o({ desiredPreferences: { ...i.features.desiredPreferences, [m.feature]: m.enabled } }), Object.values(i.features.pending).some((M) => M.status === "pending" && M.operation.kind === "preference" && M.operation.feature === m.feature))) {
1340
1340
  const M = i.features.queuedPreferences[m.feature];
1341
1341
  if (M && M.requestId !== w) {
1342
- const q = Mn(r, "mutate", M.requestId), z = { kind: "preference", feature: m.feature, enabled: M.enabled };
1342
+ const q = Mn(r, "mutate", M.requestId), B = { kind: "preference", feature: m.feature, enabled: M.enabled };
1343
1343
  o({ pending: { ...i.features.pending, [q]: {
1344
1344
  requestId: M.requestId,
1345
1345
  effectId: q,
1346
- fingerprint: JSON.stringify(z),
1347
- key: pl(z),
1346
+ fingerprint: JSON.stringify(B),
1347
+ key: pl(B),
1348
1348
  generation: r.generation,
1349
- operation: z,
1349
+ operation: B,
1350
1350
  mode: "mutation",
1351
1351
  status: "error",
1352
1352
  result: null,
@@ -1357,8 +1357,8 @@ function ra(t, e, n) {
1357
1357
  return;
1358
1358
  }
1359
1359
  if (m.kind === "generatePrompts") {
1360
- const M = { kind: "starterPrompts", ...m.page, includeUserSuggestions: m.includeUserSuggestions ?? !1 }, q = yt(r, M), z = i.features.queries[q] ?? Zt(q);
1361
- o({ queries: { ...i.features.queries, [q]: ni(z, { key: q, requestId: Ct(w), mode: "replace" }) } });
1360
+ const M = { kind: "starterPrompts", ...m.page, includeUserSuggestions: m.includeUserSuggestions ?? !1 }, q = yt(r, M), B = i.features.queries[q] ?? Zt(q);
1361
+ o({ queries: { ...i.features.queries, [q]: ni(B, { key: q, requestId: Ct(w), mode: "replace" }) } });
1362
1362
  }
1363
1363
  o({ pending: { ...i.features.pending, [E]: { requestId: w, effectId: E, fingerprint: T, key: pl(m), generation: r.generation, operation: m, mode: "mutation", status: "pending", error: null, result: null } } }), s.push({ kind: "stage7.mutate", id: E, input: { authority: r, requestId: w, mutation: m } });
1364
1364
  }, b = (m) => {
@@ -1636,11 +1636,11 @@ function ra(t, e, n) {
1636
1636
  }
1637
1637
  if (m.mode === "mutation") {
1638
1638
  const T = { ...i.features.queries }, k = { ...i.features.pending }, M = { ...i.features.contextReads }, q = { ...i.features.polls };
1639
- for (const [z, B] of Object.entries(i.features.originContextQueries))
1640
- if (B.origin === E) {
1641
- T[z] = { ...T[z], data: I, status: "ready", error: null, requestId: null, updatedAt: e.output.completedAt }, M[z] = { settledAt: e.output.completedAt, failures: 0 }, delete q[z];
1642
- for (const [C, U] of Object.entries(k)) U.mode === "query" && U.key === z && delete k[C];
1643
- ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status) && (q[z] = { query: { ...B, kind: "originContext", trigger: "poll" }, deadline: i.features.now + 5e3 });
1639
+ for (const [B, U] of Object.entries(i.features.originContextQueries))
1640
+ if (U.origin === E) {
1641
+ T[B] = { ...T[B], data: I, status: "ready", error: null, requestId: null, updatedAt: e.output.completedAt }, M[B] = { settledAt: e.output.completedAt, failures: 0 }, delete q[B];
1642
+ for (const [C, z] of Object.entries(k)) z.mode === "query" && z.key === B && delete k[C];
1643
+ ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status) && (q[B] = { query: { ...U, kind: "originContext", trigger: "poll" }, deadline: i.features.now + 5e3 });
1644
1644
  }
1645
1645
  o({ queries: T, pending: k, contextReads: M, polls: q });
1646
1646
  }
@@ -1654,7 +1654,7 @@ function ra(t, e, n) {
1654
1654
  for (const [k, M] of Object.entries(i.features.originContextQueries)) {
1655
1655
  if (M.origin !== E) continue;
1656
1656
  const q = { ...i.features.pending };
1657
- for (const [z, B] of Object.entries(q)) B.mode === "query" && B.key === k && delete q[z];
1657
+ for (const [B, U] of Object.entries(q)) U.mode === "query" && U.key === k && delete q[B];
1658
1658
  o({ pending: q }), y({ ...M, kind: "originContext" }, `context-final:${m.requestId}:${k}`, !0);
1659
1659
  }
1660
1660
  }
@@ -2522,8 +2522,8 @@ function Qh(t, e, n, i) {
2522
2522
  if (n.clients[e.clientScopeId] !== e.conversationScopeId) throw new Error("Submission selection has changed.");
2523
2523
  const { type: r, authorityId: c, generation: l, prepareContext: u, reconcileAcceptance: d, waitForAuthentication: p, ...f } = e, y = t.submissions[e.userMessageId];
2524
2524
  if (y) {
2525
- const { contextPreparation: m, requestedModel: w, sessionId: I, delivery: E, cancelled: T, cancellationReason: k, error: M, executionVersion: q, ...z } = y;
2526
- if (Es(z) !== Es(f)) throw new Error("User-message identity cannot be reused with different input.");
2525
+ const { contextPreparation: m, requestedModel: w, sessionId: I, delivery: E, cancelled: T, cancellationReason: k, error: M, executionVersion: q, ...B } = y;
2526
+ if (Es(B) !== Es(f)) throw new Error("User-message identity cannot be reused with different input.");
2527
2527
  return { state: t, effects: o };
2528
2528
  }
2529
2529
  const g = n.selections[e.conversationScopeId], b = Object.values(t.submissions).find((m) => m.conversationScopeId === e.conversationScopeId && !m.cancelled && m.sessionId !== null), _ = i.scopes[e.clientScopeId], S = {
@@ -5868,7 +5868,7 @@ const df = 9e4, uf = /* @__PURE__ */ new Set([
5868
5868
  "tool.started",
5869
5869
  "tool.result"
5870
5870
  ]);
5871
- class N extends Error {
5871
+ class L extends Error {
5872
5872
  constructor(e, n, i = !1, s, o = !1) {
5873
5873
  super(e), this.code = n, this.outcomeUnknown = i, this.detail = s, this.backendRefusal = o, this.code = n === "401" ? "unauthorized" : n;
5874
5874
  }
@@ -5879,7 +5879,7 @@ class N extends Error {
5879
5879
  }
5880
5880
  function Il(t, e) {
5881
5881
  const n = t.result && typeof t.result == "object" ? t.result : void 0, i = typeof n?.message == "string" && n.message.trim() ? n.message : `${e} (${t.code ?? "request_rejected"})`;
5882
- return new N(i, t.code ?? "request_rejected", !1, t.result, !0);
5882
+ return new L(i, t.code ?? "request_rejected", !1, t.result, !0);
5883
5883
  }
5884
5884
  class pf {
5885
5885
  constructor(e) {
@@ -5908,7 +5908,7 @@ class pf {
5908
5908
  }) : this.invalidate(!1, n), this.restoreBackoff();
5909
5909
  }), this.socket.io.on("reconnect", () => this.restoreBackoff()), this.socket.on("connection.ready", (n) => {
5910
5910
  if (n.protocol !== 1 || n.role !== this.options.auth.role || n.display_projection_ready !== !1) {
5911
- this.options.onError(new N("Unsupported Product Agent transport negotiation", "protocol_error")), this.disconnect();
5911
+ this.options.onError(new L("Unsupported Product Agent transport negotiation", "protocol_error")), this.disconnect();
5912
5912
  return;
5913
5913
  }
5914
5914
  this.admitted = n, this.activate();
@@ -5919,14 +5919,14 @@ class pf {
5919
5919
  }), this.socket.on("connect_error", (n) => {
5920
5920
  const i = n.data?.code;
5921
5921
  if (i === "unauthorized" && n.data?.reason === "token_expired" && n.data.retryable === !0) {
5922
- this.options.onError(new N(n.message, i, !1, n.data)), this.disconnect();
5922
+ this.options.onError(new L(n.message, i, !1, n.data)), this.disconnect();
5923
5923
  return;
5924
5924
  }
5925
5925
  if (!i || n.data?.retryable === !0) {
5926
5926
  this.invalidate(!1, "connect_error"), this.options.reconnect === !1 ? this.socket.disconnect() : this.scheduleNamespaceReconnect();
5927
5927
  return;
5928
5928
  }
5929
- (i === "unauthorized" || i === "update_required") && (this.rejectedToken = this.options.auth.token), this.options.onError(new N(n.message, i ?? "connection_error", !1, n.data)), this.rejectedToken === this.options.auth.token && this.disconnect();
5929
+ (i === "unauthorized" || i === "update_required") && (this.rejectedToken = this.options.auth.token), this.options.onError(new L(n.message, i ?? "connection_error", !1, n.data)), this.rejectedToken === this.options.auth.token && this.disconnect();
5930
5930
  }), this.socket.on("conversation.event", (n) => {
5931
5931
  this.ready && n.protocol === 1 && n.session_id && this.bindings.get(n.session_id)?.owners.size && this.options.onEvent("conversation.event", n.event);
5932
5932
  }), this.socket.on("conversation.metadata.updated", (n) => {
@@ -5953,7 +5953,7 @@ class pf {
5953
5953
  const s = this.generation, o = await this.options.onToolCall(n);
5954
5954
  i({ received: o && !!this.ready && s === this.generation });
5955
5955
  }), this.socket.on("executor.replaced", () => {
5956
- this.retired = !0, this.options.onError(new N("Browser executor was replaced", "executor_replaced")), this.disconnect();
5956
+ this.retired = !0, this.options.onError(new L("Browser executor was replaced", "executor_replaced")), this.disconnect();
5957
5957
  });
5958
5958
  }
5959
5959
  options;
@@ -5997,11 +5997,11 @@ class pf {
5997
5997
  return this.ready && this.socket.id ? `pa-sio:${this.socket.id}` : null;
5998
5998
  }
5999
5999
  async restoreExecutor(e) {
6000
- if (this.connectionId !== e) throw new N("Browser connection changed.", "executor_not_ready");
6000
+ if (this.connectionId !== e) throw new L("Browser connection changed.", "executor_not_ready");
6001
6001
  if (this.executorRecovery) return this.executorRecovery;
6002
6002
  const n = this.request("executor.register", {}, this.generation).then(() => {
6003
6003
  }, (i) => {
6004
- throw i instanceof N && (i.outcomeUnknown || i.code === "disconnected") ? new N("Reconnecting the browser before continuing.", "executor_not_ready") : i;
6004
+ throw i instanceof L && (i.outcomeUnknown || i.code === "disconnected") ? new L("Reconnecting the browser before continuing.", "executor_not_ready") : i;
6005
6005
  });
6006
6006
  this.executorRecovery = n;
6007
6007
  try {
@@ -6043,7 +6043,7 @@ class pf {
6043
6043
  beginAttempt() {
6044
6044
  this.clearReadinessTimers(), this.activity = { ...this.activity, lastPacketReceivedAt: null, lastHeartbeatReceivedAt: null, lastHeartbeatQueuedAt: null }, this.active = !0, this.attempt = { connectionAttemptId: crypto.randomUUID(), reconnectAttempt: this.attemptCount++, startedAt: Date.now() }, this.socket.auth = { ...this.options.auth, connection_attempt_id: this.attempt.connectionAttemptId }, this.options.onAttempt?.(this.attempt);
6045
6045
  const e = this.generation, n = (i) => {
6046
- e !== this.generation || !this.active || (this.options.onError(new N("Product Agent readiness timed out", i, !1, {
6046
+ e !== this.generation || !this.active || (this.options.onError(new L("Product Agent readiness timed out", i, !1, {
6047
6047
  retryable: !0,
6048
6048
  ...this.attempt,
6049
6049
  readinessPhase: this.ready ? "bootstrap" : this.admitted ? "activation" : "namespace_ready"
@@ -6057,20 +6057,20 @@ class pf {
6057
6057
  async retain(e, n) {
6058
6058
  let i = this.bindings.get(e);
6059
6059
  if (!i) {
6060
- if (this.bindings.size >= 64) throw new N("Too many conversation subscriptions", "subscription_limit");
6060
+ if (this.bindings.size >= 64) throw new L("Too many conversation subscriptions", "subscription_limit");
6061
6061
  i = { id: crypto.randomUUID(), owners: /* @__PURE__ */ new Set(), joinedGeneration: -1 }, this.bindings.set(e, i);
6062
6062
  }
6063
6063
  if (i.owners.add(n), !this.ready) return;
6064
6064
  const s = this.generation;
6065
6065
  await this.synchronize().catch((o) => {
6066
- throw s !== this.generation || (i.owners.delete(n), o instanceof N && o.outcomeUnknown && this.ready && (i.joinedGeneration = this.generation), this.synchronize().catch((a) => this.options.onError(a))), o;
6066
+ throw s !== this.generation || (i.owners.delete(n), o instanceof L && o.outcomeUnknown && this.ready && (i.joinedGeneration = this.generation), this.synchronize().catch((a) => this.options.onError(a))), o;
6067
6067
  });
6068
6068
  }
6069
6069
  async release(e, n) {
6070
6070
  this.bindings.get(e)?.owners.delete(n), this.ready && await this.synchronize();
6071
6071
  }
6072
6072
  async rpc(e, n) {
6073
- if (!uf.has(e)) throw new N("Operation requires its HTTP adapter", "unsupported_rpc");
6073
+ if (!uf.has(e)) throw new L("Operation requires its HTTP adapter", "unsupported_rpc");
6074
6074
  const i = this.generation, s = JSON.stringify(n);
6075
6075
  return e === "run.stop" && this.uploadingResult ? (this.assertReady(i), this.request("runtime.rpc", { type: e, payload: JSON.parse(s) }, i)) : this.enqueue(async () => {
6076
6076
  if (this.assertReady(i), e === "tool.result") {
@@ -6090,13 +6090,13 @@ class pf {
6090
6090
  this.ready = n, await this.synchronize(!0), e === this.generation && this.ready && (this.options.bootstrapRequired || this.markReady(), this.options.onReady(n));
6091
6091
  } catch (s) {
6092
6092
  if (e === this.generation) {
6093
- const o = Xt(s, "activation_error", "web_transport"), a = s instanceof N ? s : new N(
6093
+ const o = Xt(s, "activation_error", "web_transport"), a = s instanceof L ? s : new L(
6094
6094
  o.message,
6095
6095
  o.code,
6096
6096
  !1,
6097
6097
  { ...o.details, retryable: o.retryable }
6098
6098
  );
6099
- this.activationFailed(new N(
6099
+ this.activationFailed(new L(
6100
6100
  a.message,
6101
6101
  a.code,
6102
6102
  a.outcomeUnknown,
@@ -6123,7 +6123,7 @@ class pf {
6123
6123
  subscription_id: s.id,
6124
6124
  ...this.options.displaySchema === "canonical" ? { display_schema: "canonical" } : {}
6125
6125
  }, n).then(() => !0).catch((a) => {
6126
- if (a instanceof N && !a.outcomeUnknown && a.detail?.retryable !== !0 && this.bindings.get(i) === s && (this.bindings.delete(i), e))
6126
+ if (a instanceof L && !a.outcomeUnknown && a.detail?.retryable !== !0 && this.bindings.get(i) === s && (this.bindings.delete(i), e))
6127
6127
  return this.options.onError(a), !1;
6128
6128
  throw a;
6129
6129
  })) continue;
@@ -6135,7 +6135,7 @@ class pf {
6135
6135
  }
6136
6136
  enqueue(e) {
6137
6137
  if (this.queuedOperations >= 128) {
6138
- const i = new N("Product Agent transport queue is full", "backpressure");
6138
+ const i = new L("Product Agent transport queue is full", "backpressure");
6139
6139
  return this.recoverUncertainDelivery(i, this.generation), Promise.reject(i);
6140
6140
  }
6141
6141
  this.queuedOperations++;
@@ -6146,7 +6146,7 @@ class pf {
6146
6146
  }), n;
6147
6147
  }
6148
6148
  assertReady(e) {
6149
- if (!this.ready || !this.socket.connected || e !== this.generation) throw new N("Transport is not ready", "disconnected");
6149
+ if (!this.ready || !this.socket.connected || e !== this.generation) throw new L("Transport is not ready", "disconnected");
6150
6150
  }
6151
6151
  async uploadResult(e, n, i) {
6152
6152
  const s = crypto.randomUUID();
@@ -6171,38 +6171,38 @@ class pf {
6171
6171
  body: JSON.stringify({ request_id: s, type: "tool.result", payload: e })
6172
6172
  });
6173
6173
  if (d.status >= 500)
6174
- throw new N("Result upload outcome is unknown", "delivery_unknown", !0);
6175
- if (!d.ok) throw new N(`Result upload rejected (${d.status})`, String(d.status), !1, void 0, !0);
6174
+ throw new L("Result upload outcome is unknown", "delivery_unknown", !0);
6175
+ if (!d.ok) throw new L(`Result upload rejected (${d.status})`, String(d.status), !1, void 0, !0);
6176
6176
  const p = await d.json();
6177
6177
  if (n !== this.generation || o.signal.aborted)
6178
- throw new N("Result upload outcome is unknown", "delivery_unknown", !0);
6178
+ throw new L("Result upload outcome is unknown", "delivery_unknown", !0);
6179
6179
  if (p?.request_id !== s || typeof p.ok != "boolean")
6180
- throw new N("Invalid result acknowledgement identity", "invalid_ack", !0);
6180
+ throw new L("Invalid result acknowledgement identity", "invalid_ack", !0);
6181
6181
  if (!p.ok) throw Il(p, "Product Agent result rejected");
6182
6182
  return p.result;
6183
6183
  } catch (l) {
6184
- const u = l instanceof N ? l : new N("Result upload outcome is unknown", "delivery_unknown", !0);
6184
+ const u = l instanceof L ? l : new L("Result upload outcome is unknown", "delivery_unknown", !0);
6185
6185
  throw this.recoverUncertainDelivery(u, n), u;
6186
6186
  } finally {
6187
6187
  clearTimeout(c), this.uploadingResult = !1, this.pending.delete(a);
6188
6188
  }
6189
6189
  }
6190
6190
  request(e, n, i) {
6191
- if (!this.socket.connected || i !== this.generation) return Promise.reject(new N("Transport disconnected", "disconnected"));
6191
+ if (!this.socket.connected || i !== this.generation) return Promise.reject(new L("Transport disconnected", "disconnected"));
6192
6192
  const s = crypto.randomUUID();
6193
6193
  return new Promise((o, a) => {
6194
6194
  const r = (c) => {
6195
6195
  this.pending.delete(r), a(c);
6196
6196
  };
6197
6197
  this.pending.add(r), this.socket.timeout(this.options.requestTimeoutMs ?? 15e3).emit(e, { ...n, request_id: s }, (c, l) => {
6198
- this.pending.delete(r) && (c || i !== this.generation ? a(new N("Delivery outcome is unknown; reconcile without repeating execution", "delivery_unknown", !0)) : l?.request_id !== s || typeof l.ok != "boolean" ? a(new N("Invalid acknowledgement identity", "invalid_ack", !0)) : l.ok ? o(l.result) : a(Il(l, "Product Agent request rejected")));
6198
+ this.pending.delete(r) && (c || i !== this.generation ? a(new L("Delivery outcome is unknown; reconcile without repeating execution", "delivery_unknown", !0)) : l?.request_id !== s || typeof l.ok != "boolean" ? a(new L("Invalid acknowledgement identity", "invalid_ack", !0)) : l.ok ? o(l.result) : a(Il(l, "Product Agent request rejected")));
6199
6199
  });
6200
6200
  }).catch((o) => {
6201
6201
  throw this.recoverUncertainDelivery(o, i), o;
6202
6202
  });
6203
6203
  }
6204
6204
  recoverUncertainDelivery(e, n) {
6205
- e instanceof N && (e.outcomeUnknown || e.code === "backpressure" && !e.backendRefusal) && n === this.generation && this.active && this.recover(e.code === "backpressure" ? "local_backpressure" : "local_delivery_uncertain");
6205
+ e instanceof L && (e.outcomeUnknown || e.code === "backpressure" && !e.backendRefusal) && n === this.generation && this.active && this.recover(e.code === "backpressure" ? "local_backpressure" : "local_delivery_uncertain");
6206
6206
  }
6207
6207
  invalidate(e = !1, n = "local_invalidation") {
6208
6208
  if (this.clearReadinessTimers(), !!this.active) {
@@ -6214,7 +6214,7 @@ class pf {
6214
6214
  lastHeartbeatReceivedAt: this.activity.lastHeartbeatReceivedAt,
6215
6215
  lastHeartbeatQueuedAt: this.activity.lastHeartbeatQueuedAt
6216
6216
  }, this.active = !1, this.generation++, this.ready = null, this.admitted = null, this.activating = !1;
6217
- for (const i of [...this.pending]) i(new N("Connection lost before acknowledgement", "delivery_unknown", !0));
6217
+ for (const i of [...this.pending]) i(new L("Connection lost before acknowledgement", "delivery_unknown", !0));
6218
6218
  this.options.onDisconnect(e, n);
6219
6219
  }
6220
6220
  }
@@ -6561,8 +6561,8 @@ class gf {
6561
6561
  const d = this.subscriptionIdentity();
6562
6562
  if (!d) return;
6563
6563
  await this.options.socket.retain(o, r).catch((f) => {
6564
- const y = f instanceof N && f.code === "409" && f.message === "This conversation is temporarily unavailable. Please try again later.";
6565
- if (f instanceof N && f.backendRefusal && !f.outcomeUnknown && !y && f.detail?.retryable !== !0) {
6564
+ const y = f instanceof L && f.code === "409" && f.message === "This conversation is temporarily unavailable. Please try again later.";
6565
+ if (f instanceof L && f.backendRefusal && !f.outcomeUnknown && !y && f.detail?.retryable !== !0) {
6566
6566
  const g = this.observations.get(o);
6567
6567
  g?.subscription === c && (g.subscriptionDenied = !0), c.stop(), this.report(f);
6568
6568
  }
@@ -6979,7 +6979,7 @@ class wu {
6979
6979
  async request(e, n = {}, i, s, o, a = {}) {
6980
6980
  if (a.skipAuthentication) return this.requestOnce(e, n, i, s, o, a.signal, a.diagnostic);
6981
6981
  const r = this.options.authority?.(), c = (d = !0) => {
6982
- if (r !== this.options.authority?.()) throw new N("Conversation authority was retired.", "authority_retired", !0);
6982
+ if (r !== this.options.authority?.()) throw new L("Conversation authority was retired.", "authority_retired", !0);
6983
6983
  d && (this.requests.signal.throwIfAborted(), a.signal?.throwIfAborted());
6984
6984
  }, l = a.readOnly ?? (s ?? (i === void 0 ? "GET" : "POST")) === "GET";
6985
6985
  let u = 0;
@@ -6994,7 +6994,7 @@ class wu {
6994
6994
  try {
6995
6995
  let g = i;
6996
6996
  if (o === "conversations" && e === "/commands" && this.auth.role !== "session_surface" && this.options.executorConnection) {
6997
- if (y = this.options.executorConnection(), !y) throw new N("Reconnecting the browser before continuing.", "executor_not_ready");
6997
+ if (y = this.options.executorConnection(), !y) throw new L("Reconnecting the browser before continuing.", "executor_not_ready");
6998
6998
  const S = i;
6999
6999
  g = { ...S, context: { ...S.context, connection_id: y } };
7000
7000
  }
@@ -7002,19 +7002,19 @@ class wu {
7002
7002
  return c(), _;
7003
7003
  } catch (g) {
7004
7004
  if (c(!1), this.requests.signal.aborted || a.signal?.aborted) throw g;
7005
- if (g instanceof N && g.code === "executor_not_ready" && y && d === 0 && this.options.restoreExecutor) {
7005
+ if (g instanceof L && g.code === "executor_not_ready" && y && d === 0 && this.options.restoreExecutor) {
7006
7006
  await this.options.restoreExecutor(y), d++, c();
7007
7007
  continue;
7008
7008
  }
7009
- if (!(g instanceof N) || !["unauthorized", "403"].includes(g.code) || !this.options.recoverAuthentication || !l || (await this.options.recoverAuthentication(f, g, l && d === 0), c(), !l || d !== 0)) throw g;
7009
+ if (!(g instanceof L) || !["unauthorized", "403"].includes(g.code) || !this.options.recoverAuthentication || !l || (await this.options.recoverAuthentication(f, g, l && d === 0), c(), !l || d !== 0)) throw g;
7010
7010
  d++;
7011
7011
  }
7012
7012
  }
7013
7013
  }
7014
7014
  async requestOnce(e, n, i, s, o, a, r, c = 1) {
7015
7015
  const l = this.auth.client_kind === "embed", u = new URL(`/api/product-agent/${o ?? (l ? "embed" : "runtime")}${e}`, this.options.backendUrl), d = o === "conversations" ? {} : l ? { client_id: this.auth.client_id, transport_id: this.auth.transport_id } : { community_id: this.auth.community_id, automation_run_id: this.auth.automation_run_id };
7016
- for (const [q, z] of Object.entries({ ...d, ...n }))
7017
- z != null && u.searchParams.set(q, String(z));
7016
+ for (const [q, B] of Object.entries({ ...d, ...n }))
7017
+ B != null && u.searchParams.set(q, String(B));
7018
7018
  this.requests.signal.throwIfAborted(), a?.throwIfAborted();
7019
7019
  const p = new AbortController(), f = { trigger: null }, y = (q) => {
7020
7020
  p.signal.aborted || (f.trigger = q, p.abort());
@@ -7029,39 +7029,47 @@ class wu {
7029
7029
  signal: p.signal,
7030
7030
  headers: { "x-product-agent-auth-request-id": m, authorization: l || o === "conversations" ? `Bearer ${this.auth.token}` : this.auth.token, "content-type": "application/json", ..._ ? { "x-request-id": m } : {} },
7031
7031
  ...i === void 0 ? {} : { body: JSON.stringify(i) }
7032
- })).catch((z) => {
7033
- throw E = !0, z;
7032
+ })).catch((B) => {
7033
+ throw E = !0, B;
7034
7034
  });
7035
7035
  if (I = Date.now(), T = q.status, k = Al(q.headers.get("x-request-id")), M = Al(q.headers.get("x-cloud-trace-context")), !q.ok) {
7036
- const z = q.status === 401 ? "unauthorized" : q.status === 426 ? "update_required" : String(q.status), B = (await q.json().catch(() => null))?.detail;
7037
- if (l && q.status === 403 && (o === "conversations" && /^\/[^/]+\/snapshot$/.test(e) || (!o || o === "embed") && /^\/conversations\/[^/]+$/.test(e)) && ["Conversation unavailable", "Integration mismatch", "Embedded origin mismatch"].includes(B))
7038
- throw new N("Conversation unavailable", "conversation_access_denied");
7039
- if (o === "conversations" && e.endsWith("/snapshot") && q.status === 409 && B === "Display projection is not enabled")
7040
- throw new N("Conversation history is unavailable. Try loading this chat again after the service is ready.", "display_projection_disabled");
7041
- if (o === "conversations" && e === "/commands" && q.status === 409 && (B === "embedded_submission_conflict" || B === "embedded_submission_snapshot_unavailable"))
7042
- throw new N(B === "embedded_submission_conflict" ? "This message conflicts with an earlier submission. Review the conversation before retrying." : "This earlier submission cannot be verified. Review the conversation before retrying.", B, !1, void 0, !0);
7043
- if (o === "conversations" && e === "/commands" && (q.status === 409 && B?.code === "executor_not_ready" && B.retryable === !0 || q.status === 403 && B === "Register the executor before commands"))
7044
- throw new N("Reconnecting the browser before continuing.", "executor_not_ready");
7045
- if (q.status !== 401 && B && typeof B == "object" && (["service_origin_not_allowed", "security_control_enforcement_unavailable"].includes(B.code) || !ts(void 0, B.code).allowed) && typeof B.message == "string")
7046
- throw new N(B.message, B.code, !1, {
7047
- ...typeof B.blockedOrigin == "string" ? { blockedOrigin: B.blockedOrigin } : {},
7048
- ...typeof B.securitySettingsUrl == "string" ? { securitySettingsUrl: B.securitySettingsUrl } : {}
7036
+ const B = q.status === 401 ? "unauthorized" : q.status === 426 ? "update_required" : String(q.status), U = (await q.json().catch(() => null))?.detail;
7037
+ if (q.status === 410 && U?.code === "personal_product_agent_retired" && typeof U.message == "string")
7038
+ throw new L(
7039
+ U.message,
7040
+ U.code,
7041
+ !1,
7042
+ { retryable: !1 },
7043
+ o === "conversations" && e === "/commands"
7044
+ );
7045
+ if (l && q.status === 403 && (o === "conversations" && /^\/[^/]+\/snapshot$/.test(e) || (!o || o === "embed") && /^\/conversations\/[^/]+$/.test(e)) && ["Conversation unavailable", "Integration mismatch", "Embedded origin mismatch"].includes(U))
7046
+ throw new L("Conversation unavailable", "conversation_access_denied");
7047
+ if (o === "conversations" && e.endsWith("/snapshot") && q.status === 409 && U === "Display projection is not enabled")
7048
+ throw new L("Conversation history is unavailable. Try loading this chat again after the service is ready.", "display_projection_disabled");
7049
+ if (o === "conversations" && e === "/commands" && q.status === 409 && (U === "embedded_submission_conflict" || U === "embedded_submission_snapshot_unavailable"))
7050
+ throw new L(U === "embedded_submission_conflict" ? "This message conflicts with an earlier submission. Review the conversation before retrying." : "This earlier submission cannot be verified. Review the conversation before retrying.", U, !1, void 0, !0);
7051
+ if (o === "conversations" && e === "/commands" && (q.status === 409 && U?.code === "executor_not_ready" && U.retryable === !0 || q.status === 403 && U === "Register the executor before commands"))
7052
+ throw new L("Reconnecting the browser before continuing.", "executor_not_ready");
7053
+ if (q.status !== 401 && U && typeof U == "object" && (["service_origin_not_allowed", "security_control_enforcement_unavailable"].includes(U.code) || !ts(void 0, U.code).allowed) && typeof U.message == "string")
7054
+ throw new L(U.message, U.code, !1, {
7055
+ ...typeof U.blockedOrigin == "string" ? { blockedOrigin: U.blockedOrigin } : {},
7056
+ ...typeof U.securitySettingsUrl == "string" ? { securitySettingsUrl: U.securitySettingsUrl } : {}
7049
7057
  }, o === "conversations" && e === "/commands");
7050
- const C = B === "Token expired" ? "token_expired" : B === "Invalid token" ? "invalid_token" : B?.reason, U = q.status === 401 && ["missing_token", "token_expired", "invalid_token", "user_not_found"].includes(C) ? { requestId: m, authTransport: "http", authEndpoint: `${o ?? (l ? "embed" : "runtime")}:${["snapshot", "me", "bootstrap", "commands", "activity", "session-history"].includes(e.split("/").pop()) ? e.split("/").pop() : "other"}`, reason: C, retryable: C === "token_expired" && (B === "Token expired" || B.retryable === !0) } : void 0;
7051
- throw new N(q.status === 401 ? "Your session expired or is invalid. Reconnect to continue." : q.status === 403 ? "You don't have access to this conversation. Check your access and reconnect." : `Product Agent request failed (${q.status})`, z, !1, U);
7058
+ const C = U === "Token expired" ? "token_expired" : U === "Invalid token" ? "invalid_token" : U?.reason, z = q.status === 401 && ["missing_token", "token_expired", "invalid_token", "user_not_found"].includes(C) ? { requestId: m, authTransport: "http", authEndpoint: `${o ?? (l ? "embed" : "runtime")}:${["snapshot", "me", "bootstrap", "commands", "activity", "session-history"].includes(e.split("/").pop()) ? e.split("/").pop() : "other"}`, reason: C, retryable: C === "token_expired" && (U === "Token expired" || U.retryable === !0) } : void 0;
7059
+ throw new L(q.status === 401 ? "Your session expired or is invalid. Reconnect to continue." : q.status === 403 ? "You don't have access to this conversation. Check your access and reconnect." : `Product Agent request failed (${q.status})`, B, !1, z);
7052
7060
  }
7053
7061
  return await q.json();
7054
7062
  } catch (q) {
7055
- const z = f.trigger ?? ((q instanceof Error || q instanceof DOMException) && q.name === "AbortError" ? "unexpected_abort" : null), B = {
7063
+ const B = f.trigger ?? ((q instanceof Error || q instanceof DOMException) && q.name === "AbortError" ? "unexpected_abort" : null), U = {
7056
7064
  requestId: m,
7057
7065
  method: s ?? (i === void 0 ? "GET" : "POST"),
7058
7066
  route: _ ? "/api/product-agent/conversations/:sessionId/snapshot" : e === "/commands" ? "/api/product-agent/:namespace/commands" : "/api/product-agent/:namespace/:operation",
7059
7067
  status: T,
7060
- abortTrigger: z,
7061
- category: z === "deadline" ? "request_timed_out" : z === "unexpected_abort" ? "connection_interrupted" : z ? "request_cancelled" : q instanceof N ? q.code : E ? "connection_interrupted" : "invalid_response",
7068
+ abortTrigger: B,
7069
+ category: B === "deadline" ? "request_timed_out" : B === "unexpected_abort" ? "connection_interrupted" : B ? "request_cancelled" : q instanceof L ? q.code : E ? "connection_interrupted" : "invalid_response",
7062
7070
  responseHeadersMs: I === null ? null : Math.max(0, I - w),
7063
7071
  responseBodyMs: I === null ? null : Math.max(0, Date.now() - I),
7064
- owner: z === "deadline" ? "http_deadline" : z === "transport_disposed" ? "http_transport" : z && z !== "unexpected_abort" ? "conversation_query" : T === null ? "browser" : "http_response",
7072
+ owner: B === "deadline" ? "http_deadline" : B === "transport_disposed" ? "http_transport" : B && B !== "unexpected_abort" ? "conversation_query" : T === null ? "browser" : "http_response",
7065
7073
  elapsedMs: Math.max(0, Date.now() - w),
7066
7074
  attempt: c,
7067
7075
  queryRequestId: fe(r?.queryRequestId),
@@ -7072,19 +7080,19 @@ class wu {
7072
7080
  upstreamRequestId: k,
7073
7081
  upstreamTraceId: M
7074
7082
  };
7075
- wn(B) && Promise.resolve().then(() => this.options.onRequestFailure ? this.options.onRequestFailure(B) : console.warn("Product Agent HTTP request failed", B)).catch(() => {
7083
+ wn(U) && Promise.resolve().then(() => this.options.onRequestFailure ? this.options.onRequestFailure(U) : console.warn("Product Agent HTTP request failed", U)).catch(() => {
7076
7084
  });
7077
- const C = wn(B) ? { httpRequest: B } : void 0;
7078
- if (z !== null) {
7079
- const U = z !== "deadline" && z !== "unexpected_abort";
7080
- throw new N(
7081
- U ? "The request was cancelled." : z === "deadline" ? "The request timed out. Please try again." : "The connection was interrupted. Please try again.",
7082
- U ? "request_cancelled" : z === "deadline" ? "request_timed_out" : "connection_interrupted",
7085
+ const C = wn(U) ? { httpRequest: U } : void 0;
7086
+ if (B !== null) {
7087
+ const z = B !== "deadline" && B !== "unexpected_abort";
7088
+ throw new L(
7089
+ z ? "The request was cancelled." : B === "deadline" ? "The request timed out. Please try again." : "The connection was interrupted. Please try again.",
7090
+ z ? "request_cancelled" : B === "deadline" ? "request_timed_out" : "connection_interrupted",
7083
7091
  !0,
7084
7092
  C
7085
7093
  );
7086
7094
  }
7087
- throw q instanceof N && C ? new N(q.message, q.code, q.outcomeUnknown, { ...q.detail, ...C }, q.backendRefusal) : C ? new N(
7095
+ throw q instanceof L && C ? new L(q.message, q.code, q.outcomeUnknown, { ...q.detail, ...C }, q.backendRefusal) : C ? new L(
7088
7096
  E ? "The connection was interrupted. Please try again." : _ ? "The conversation response could not be read. Please try again." : "The response could not be read. Please try again.",
7089
7097
  "connection_interrupted",
7090
7098
  !0,
@@ -7569,7 +7577,7 @@ class Ee extends EventTarget {
7569
7577
  stage: s,
7570
7578
  httpStatus: /^[45][0-9]{2}$/.test(n.code) ? Number(n.code) : void 0,
7571
7579
  failureKind: n.outcomeUnknown || i.retryable === !0 ? "temporary" : "permanent"
7572
- }), this.fail(new N(n.message, n.code, n.outcomeUnknown, { ...i, stage: s }, n.backendRefusal));
7580
+ }), this.fail(new L(n.message, n.code, n.outcomeUnknown, { ...i, stage: s }, n.backendRefusal));
7573
7581
  }
7574
7582
  }
7575
7583
  }), queueMicrotask(() => {
@@ -7699,17 +7707,17 @@ class Ee extends EventTarget {
7699
7707
  this.queueDiagnostic("auth_timeout", {
7700
7708
  readinessPhase: "bootstrap",
7701
7709
  failureKind: "temporary",
7702
- httpStatus: a instanceof N && /^[45][0-9]{2}$/.test(a.code) ? Number(a.code) : void 0
7710
+ httpStatus: a instanceof L && /^[45][0-9]{2}$/.test(a.code) ? Number(a.code) : void 0
7703
7711
  }), this.transport.recover();
7704
7712
  return;
7705
7713
  }
7706
7714
  if (n.type === "auth.session") {
7707
- const r = a instanceof N ? a : new N("Chat setup failed", "request_failed"), c = this.isInvalidResponse(r);
7715
+ const r = a instanceof L ? a : new L("Chat setup failed", "request_failed"), c = this.isInvalidResponse(r);
7708
7716
  this.queueDiagnostic("auth_rejected", {
7709
7717
  stage: "bootstrap",
7710
7718
  failureKind: "permanent",
7711
7719
  httpStatus: /^[45][0-9]{2}$/.test(r.code) ? Number(r.code) : void 0
7712
- }), this.fail(new N(
7720
+ }), this.fail(new L(
7713
7721
  r.message,
7714
7722
  c ? "invalid_response" : r.code,
7715
7723
  c ? !1 : r.outcomeUnknown,
@@ -7726,7 +7734,7 @@ class Ee extends EventTarget {
7726
7734
  try {
7727
7735
  return await this.transport.rpc(e.type, Object.fromEntries(Object.entries(e).filter(([n]) => n !== "type"))), !0;
7728
7736
  } catch (n) {
7729
- return n instanceof N && n.code === "backpressure" && !n.backendRefusal || this.fail(n, e), n instanceof N && n.backendRefusal;
7737
+ return n instanceof L && n.code === "backpressure" && !n.backendRefusal || this.fail(n, e), n instanceof L && n.backendRefusal;
7730
7738
  }
7731
7739
  }
7732
7740
  receive(e) {
@@ -7745,13 +7753,13 @@ class Ee extends EventTarget {
7745
7753
  }
7746
7754
  buffer(e, n) {
7747
7755
  if (e.length >= 128) {
7748
- this.fail(new N("Product Agent delivery buffer is full", "backpressure")), this.close();
7756
+ this.fail(new L("Product Agent delivery buffer is full", "backpressure")), this.close();
7749
7757
  return;
7750
7758
  }
7751
7759
  e.push(n);
7752
7760
  }
7753
7761
  fail(e, n, i = !1) {
7754
- const s = Xt(e, "request_failed", "web_transport"), o = e instanceof N ? e : new N(
7762
+ const s = Xt(e, "request_failed", "web_transport"), o = e instanceof L ? e : new L(
7755
7763
  s.message,
7756
7764
  s.code,
7757
7765
  !1,
@@ -7776,11 +7784,11 @@ class Ee extends EventTarget {
7776
7784
  return this.httpTransport.request(e, n, i, s);
7777
7785
  }
7778
7786
  isInvalidResponse(e) {
7779
- const n = e instanceof N ? e.detail : void 0;
7787
+ const n = e instanceof L ? e.detail : void 0;
7780
7788
  return !!(n && typeof n == "object" && "httpRequest" in n && wn(n.httpRequest) && n.httpRequest.category === "invalid_response");
7781
7789
  }
7782
7790
  isRetryableRead(e) {
7783
- return this.isInvalidResponse(e) ? !1 : e instanceof TypeError || e instanceof DOMException && e.name === "AbortError" || e instanceof N && ["connection_interrupted", "request_timed_out", "408", "425", "429", "500", "502", "503", "504"].includes(e.code);
7791
+ 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);
7784
7792
  }
7785
7793
  async dispatch(e, n) {
7786
7794
  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 };
@@ -9394,7 +9402,7 @@ function qr(t) {
9394
9402
  if (t instanceof Ze)
9395
9403
  return t.retryable;
9396
9404
  if (t && typeof t == "object") {
9397
- const e = t instanceof N ? t.code : "", n = /^[45][0-9]{2}$/.test(e) ? Number(e) : t.status;
9405
+ const e = t instanceof L ? t.code : "", n = /^[45][0-9]{2}$/.test(e) ? Number(e) : t.status;
9398
9406
  if (typeof n == "number")
9399
9407
  return n === 408 || n === 425 || n === 429 || n >= 500;
9400
9408
  }
@@ -9426,7 +9434,7 @@ class Qa {
9426
9434
  recoverAuthentication: (s, o, a) => this.recoverHttpAuthentication(s, o, a),
9427
9435
  // Public custom transports own their admission contract and do not expose the default Socket.IO lease.
9428
9436
  executorConnection: e.webSocketFactory ? void 0 : () => this.socket instanceof Ee ? this.socket.connectionId : null,
9429
- restoreExecutor: e.webSocketFactory ? void 0 : (s) => this.socket instanceof Ee ? this.socket.restoreExecutor(s) : Promise.reject(new N("Browser is reconnecting.", "executor_not_ready")),
9437
+ restoreExecutor: e.webSocketFactory ? void 0 : (s) => this.socket instanceof Ee ? this.socket.restoreExecutor(s) : Promise.reject(new L("Browser is reconnecting.", "executor_not_ready")),
9430
9438
  auth: {
9431
9439
  protocol: 1,
9432
9440
  token: e.token ?? "",
@@ -9724,11 +9732,11 @@ class Qa {
9724
9732
  },
9725
9733
  onCommand: (g) => Xn("client_event", g.type, Ar({ ...g.payload, type: g.type })),
9726
9734
  onError: (g, b) => {
9727
- if (this.options.productVariant === "customer_embedded" && b.operation === "conversation.snapshot" && g instanceof N && g.code === "conversation_access_denied") {
9735
+ if (this.options.productVariant === "customer_embedded" && b.operation === "conversation.snapshot" && g instanceof L && g.code === "conversation_access_denied") {
9728
9736
  b.sessionId === this.getState().sessionId && this.startNewSession({ notifyTransport: !1 });
9729
9737
  return;
9730
9738
  }
9731
- Be("web-sdk.conversation", "Conversation operation failed", { ...b, ...Ln(g) }), g instanceof N && g.backendRefusal && b.operation.startsWith("chat.") ? this.applyAccountSubmissionError(g.code) : this.handleDirectoryTransportError(g);
9739
+ Be("web-sdk.conversation", "Conversation operation failed", { ...b, ...Ln(g) }), g instanceof L && g.backendRefusal && b.operation.startsWith("chat.") ? this.applyAccountSubmissionError(g.code) : this.handleDirectoryTransportError(g);
9732
9740
  }
9733
9741
  })
9734
9742
  });
@@ -9847,7 +9855,7 @@ class Qa {
9847
9855
  }
9848
9856
  }
9849
9857
  handleDirectoryTransportError(e) {
9850
- if (!(e instanceof N) || this.authenticationFailure || !["unauthorized", "update_required", "service_origin_not_allowed", "security_control_enforcement_unavailable"].includes(e.code) && ts(void 0, e.code).allowed) return;
9858
+ if (!(e instanceof L) || this.authenticationFailure || !["unauthorized", "update_required", "service_origin_not_allowed", "security_control_enforcement_unavailable"].includes(e.code) && ts(void 0, e.code).allowed) return;
9851
9859
  const n = e.detail && typeof e.detail == "object" ? e.detail : {};
9852
9860
  this.handleServerEvent({
9853
9861
  ...n,
@@ -10070,7 +10078,7 @@ class Qa {
10070
10078
  } catch (o) {
10071
10079
  if (i !== this.connectionAttemptId || this.state.status === "closed")
10072
10080
  return;
10073
- if (o instanceof N && (o.code === "unauthorized" || o.code === "update_required")) {
10081
+ if (o instanceof L && (o.code === "unauthorized" || o.code === "update_required")) {
10074
10082
  this.handleDirectoryTransportError(o);
10075
10083
  return;
10076
10084
  }
@@ -10088,7 +10096,7 @@ class Qa {
10088
10096
  );
10089
10097
  return;
10090
10098
  }
10091
- throw this.options.productVariant === "customer_embedded" ? (this.reportTransportDiagnostic("auth_rejected", this.connectionFailureDiagnostic(o, "token_provider")), this.stopAuthentication(new N(a.message, "connection_failed", !1), !0), this.emit("error", a), a) : (this.setState({
10099
+ throw this.options.productVariant === "customer_embedded" ? (this.reportTransportDiagnostic("auth_rejected", this.connectionFailureDiagnostic(o, "token_provider")), this.stopAuthentication(new L(a.message, "connection_failed", !1), !0), this.emit("error", a), a) : (this.setState({
10092
10100
  status: "error",
10093
10101
  lastError: a.message,
10094
10102
  lastErrorCode: "connection_failed"
@@ -11185,7 +11193,7 @@ class Qa {
11185
11193
  return;
11186
11194
  }
11187
11195
  if (e.code === "invalid_response" && e.stage === "bootstrap") {
11188
- this.stopAuthentication(new N(String(e.message), "connection_failed", !1, { stage: "bootstrap" }));
11196
+ this.stopAuthentication(new L(String(e.message), "connection_failed", !1, { stage: "bootstrap" }));
11189
11197
  return;
11190
11198
  }
11191
11199
  if (!this.options.webSocketFactory && (e.code === "unauthorized" || e.code === "401") && e.reason === "invalid_token" && (this.canRefreshInvalidCredential() || this.credentialRecovery !== null)) {
@@ -11194,7 +11202,7 @@ class Qa {
11194
11202
  this.credentialRecovery || this.refreshCredentials(
11195
11203
  n,
11196
11204
  !0,
11197
- new N("", "unauthorized", !1, {
11205
+ new L("", "unauthorized", !1, {
11198
11206
  reason: e.reason,
11199
11207
  authTransport: e.authTransport,
11200
11208
  requestId: e.requestId,
@@ -11211,7 +11219,7 @@ class Qa {
11211
11219
  return;
11212
11220
  }
11213
11221
  if (this.options.productVariant === "customer_embedded" && /^4[0-9]{2}$/.test(String(e.code)) && !["401", "408", "425", "429"].includes(String(e.code)) && e.retryable !== !0 && (e.stage === "executor_registration" || e.stage === "socket_admission" || e.stage === "bootstrap")) {
11214
- this.stopAuthentication(new N(
11222
+ this.stopAuthentication(new L(
11215
11223
  e.code === "403" ? "Chat access is not configured for this page. Contact your app administrator, then try again." : "Chat setup could not be completed. Contact your app administrator, then try again.",
11216
11224
  "connection_failed",
11217
11225
  !1,
@@ -11220,7 +11228,7 @@ class Qa {
11220
11228
  return;
11221
11229
  }
11222
11230
  if (!this.options.webSocketFactory && (e.code === "unauthorized" || e.code === "update_required" || e.code === "executor_replaced")) {
11223
- this.stopAuthentication(new N(String(e.message), String(e.code), !1, { reason: e.reason, authTransport: "socket" }));
11231
+ this.stopAuthentication(new L(String(e.message), String(e.code), !1, { reason: e.reason, authTransport: "socket" }));
11224
11232
  return;
11225
11233
  }
11226
11234
  ["unauthorized", "update_required", "executor_replaced", "connection_failed"].includes(String(e.code)) && this.setState({ status: "error", lastError: String(e.message), lastErrorCode: String(e.code) });
@@ -11376,7 +11384,7 @@ class Qa {
11376
11384
  stage: this.lastRecoveryStage,
11377
11385
  recoveryOutcome: "exhausted",
11378
11386
  failureKind: "temporary"
11379
- }), this.stopAuthentication(new N(
11387
+ }), this.stopAuthentication(new L(
11380
11388
  "Chat could not reconnect. Your conversation and draft are saved here. Try again.",
11381
11389
  "connection_failed",
11382
11390
  !1
@@ -11387,7 +11395,7 @@ class Qa {
11387
11395
  this.embeddedRecoveryTimer !== null && window.clearTimeout(this.embeddedRecoveryTimer), this.embeddedRecoveryTimer = null;
11388
11396
  }
11389
11397
  connectionFailureDiagnostic(e, n) {
11390
- const i = e instanceof Ze ? e.status : e instanceof N && e.code === "unauthorized" ? 401 : e instanceof N && /^[45][0-9]{2}$/.test(e.code) ? Number(e.code) : void 0, s = i !== void 0 && Number.isInteger(i) && i >= 400 && i <= 599 ? i : void 0, a = !(e instanceof N && ["unauthorized", "403", "update_required", "executor_replaced"].includes(e.code)) && qr(e) && s !== 401 && s !== 403;
11398
+ const i = e instanceof Ze ? e.status : e instanceof L && e.code === "unauthorized" ? 401 : e instanceof L && /^[45][0-9]{2}$/.test(e.code) ? Number(e.code) : void 0, s = i !== void 0 && Number.isInteger(i) && i >= 400 && i <= 599 ? i : void 0, a = !(e instanceof L && ["unauthorized", "403", "update_required", "executor_replaced"].includes(e.code)) && qr(e) && s !== 401 && s !== 403;
11391
11399
  return {
11392
11400
  stage: n,
11393
11401
  ...s !== void 0 ? { httpStatus: s } : {},
@@ -11456,7 +11464,7 @@ class Qa {
11456
11464
  ...this.authenticationDiagnostic(e),
11457
11465
  failureKind: "permanent",
11458
11466
  recoveryOutcome: "refused"
11459
- }), e.code === "unauthorized" && (e = new N("Your chat session could not be refreshed. Reload the page to reconnect.", e.code, !1, e.detail)), this.authenticationFailure = e;
11467
+ }), e.code === "unauthorized" && (e = new L("Your chat session could not be refreshed. Reload the page to reconnect.", e.code, !1, e.detail)), this.authenticationFailure = e;
11460
11468
  const i = this.clientRuntime.engine.getState().slices.account.authority;
11461
11469
  i && e.code !== "403" && this.clientRuntime.engine.dispatch({ type: "stage7.retire", authority: i, now: Date.now() }), this.credentialRecovery = null, this.clearEmbeddedRecoveryBudget(), this.rejectedTransportToken = ["unauthorized", "update_required"].includes(e.code) ? this.token : null, this.refreshingDefaultCredentials = !1, this.reconnectTimer !== null && window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null, this.clearSocketPhaseTimers(), this.stopHeartbeat();
11462
11470
  const s = this.socket;
@@ -11482,7 +11490,7 @@ class Qa {
11482
11490
  refreshCredentials(e, n = !1, i) {
11483
11491
  if (this.credentialRecovery) return this.credentialRecovery;
11484
11492
  this.credentialRecoveryFailure = null;
11485
- const s = this.token, o = this.authenticationDiagnostic(i ?? new N(
11493
+ const s = this.token, o = this.authenticationDiagnostic(i ?? new L(
11486
11494
  "",
11487
11495
  "unauthorized",
11488
11496
  !1,
@@ -11494,14 +11502,14 @@ class Qa {
11494
11502
  const r = (async () => {
11495
11503
  const c = await this.acquireToken("connect", { forceRefresh: !0 });
11496
11504
  if (this.socket !== e || this.state.status === "closed" || this.clientRuntime.isDisposed)
11497
- throw new N("Conversation authority was retired.", "authority_retired", !0);
11505
+ throw new L("Conversation authority was retired.", "authority_retired", !0);
11498
11506
  if (!c) throw new Ze("Pluno token provider did not return a token", !1);
11499
- if (n && c === s) throw new N("Credential did not change.", "unauthorized", !1);
11507
+ if (n && c === s) throw new L("Credential did not change.", "unauthorized", !1);
11500
11508
  this.directoryHttp.auth.token = c, a = "bootstrap", this.lastRecoveryStage = a, await this.replaceDefaultTransportCredentials(e), this.reportTransportDiagnostic("auth_refresh_validated", o);
11501
11509
  })().catch((c) => {
11502
11510
  if (this.socket !== e || this.state.status === "closed") throw c;
11503
- if (this.reportTransportDiagnostic("auth_refresh_failed", { ...o, ...this.connectionFailureDiagnostic(c, a) }), this.credentialRecoveryFailure = Bi(c), c instanceof N && ["unauthorized", "403", "update_required"].includes(c.code) || !qr(c)) {
11504
- const l = c instanceof N ? c : new N(c instanceof Ze ? c.message : "Your session could not be refreshed. Try again.", this.options.productVariant === "customer_embedded" ? "connection_failed" : "unauthorized", !1);
11511
+ if (this.reportTransportDiagnostic("auth_refresh_failed", { ...o, ...this.connectionFailureDiagnostic(c, a) }), this.credentialRecoveryFailure = Bi(c), c instanceof L && ["unauthorized", "403", "update_required"].includes(c.code) || !qr(c)) {
11512
+ const l = c instanceof L ? c : new L(c instanceof Ze ? c.message : "Your session could not be refreshed. Try again.", this.options.productVariant === "customer_embedded" ? "connection_failed" : "unauthorized", !1);
11505
11513
  throw this.stopAuthentication(l), l;
11506
11514
  }
11507
11515
  throw this.options.productVariant === "customer_embedded" && this.setState({ status: "reconnecting", lastError: Hl, lastErrorCode: "connection_failed" }), this.scheduleReconnect(), c;
@@ -12135,18 +12143,18 @@ function Py(t, e) {
12135
12143
  if (f >= 1e3 && !q || w.has(E) || o.has(k) || E.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || M.display === "none" || M.visibility === "hidden")
12136
12144
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
12137
12145
  f += 1;
12138
- const z = y(E), B = Mu(E), C = r.has(z) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(k) || k === "a" && E.hasAttribute("href"), U = Array.from(E.children).filter((K) => K instanceof HTMLElement), te = /* @__PURE__ */ new Map();
12139
- for (const K of U) {
12146
+ const B = y(E), U = Mu(E), C = r.has(B) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(k) || k === "a" && E.hasAttribute("href"), z = Array.from(E.children).filter((K) => K instanceof HTMLElement), te = /* @__PURE__ */ new Map();
12147
+ for (const K of z) {
12140
12148
  const ie = g(K);
12141
12149
  te.set(ie, (te.get(ie) ?? 0) + 1);
12142
12150
  }
12143
12151
  const ne = /* @__PURE__ */ new Map(), Oe = /* @__PURE__ */ new Map();
12144
- for (const K of U) {
12152
+ for (const K of z) {
12145
12153
  const ie = g(K), ye = Oe.get(ie) ?? 0;
12146
12154
  Oe.set(ie, ye + 1), (te.get(ie) ?? 0) > 8 && ye >= 6 && !u.has(K) && ne.set(ie, (ne.get(ie) ?? 0) + 1);
12147
12155
  }
12148
12156
  const we = /* @__PURE__ */ new Map(), Ae = /* @__PURE__ */ new Set(), Re = [], F = [];
12149
- for (const K of U) {
12157
+ for (const K of z) {
12150
12158
  const ie = g(K), ye = te.get(ie) ?? 0, G = we.get(ie) ?? 0;
12151
12159
  if (we.set(ie, G + 1), ye > 8 && G >= 6 && !u.has(K)) {
12152
12160
  Ae.has(ie) || (Re.push([`… ${ne.get(ie) ?? 0} similar siblings omitted`]), Ae.add(ie));
@@ -12159,11 +12167,11 @@ function Py(t, e) {
12159
12167
  if (E.shadowRoot)
12160
12168
  for (const K of Array.from(E.shadowRoot.children))
12161
12169
  K instanceof HTMLElement && Z.push(I(K, T + 1));
12162
- const nt = [...F, ...Z], Ge = B.length > 0 || C || nt.some((K) => K.hasUsefulContent), ue = ai(
12163
- [B, ...nt.map((K) => K.textPreview)].filter(Boolean).join(" ")
12164
- ).slice(0, 180), _e = E.hasAttribute("contenteditable") && (B.length > 0 || !E.querySelector("[contenteditable]")), ve = l.some((K) => E.hasAttribute(K)) || !!z || _e, it = (E.getClientRects().length > 0 || M.display === "contents") && (n.has(k) || ve || q) && (Ge || q) && (!s.has(k) || Ge || ve || q), V = it ? 1 : 0, pe = [];
12170
+ const nt = [...F, ...Z], Ge = U.length > 0 || C || nt.some((K) => K.hasUsefulContent), ue = ai(
12171
+ [U, ...nt.map((K) => K.textPreview)].filter(Boolean).join(" ")
12172
+ ).slice(0, 180), _e = E.hasAttribute("contenteditable") && (U.length > 0 || !E.querySelector("[contenteditable]")), ve = l.some((K) => E.hasAttribute(K)) || !!B || _e, it = (E.getClientRects().length > 0 || M.display === "contents") && (n.has(k) || ve || q) && (Ge || q) && (!s.has(k) || Ge || ve || q), V = it ? 1 : 0, pe = [];
12165
12173
  if (it) {
12166
- const K = nt.some((ye) => ye.containsTextElement), ie = i.has(k) && !K ? ue : B;
12174
+ const K = nt.some((ye) => ye.containsTextElement), ie = i.has(k) && !K ? ue : U;
12167
12175
  pe.push(qu(E, c, a, ie.slice(0, 180)));
12168
12176
  }
12169
12177
  for (const K of Re)
@@ -13314,7 +13322,7 @@ function Gb(t, e, n, i) {
13314
13322
  const _ = e.ownerDocument.defaultView;
13315
13323
  let S, x, m = /* @__PURE__ */ new Map(), w = d.sessionId, I = d.selectionKey;
13316
13324
  const E = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Map();
13317
- let k = null, M = null, q = null, z = 0, B = null, C = null, U = null;
13325
+ let k = null, M = null, q = null, B = 0, U = null, C = null, z = null;
13318
13326
  const te = () => JSON.stringify([
13319
13327
  d.sessionId,
13320
13328
  d.assistantDraftRespondsToUserMessageId,
@@ -13328,7 +13336,7 @@ function Gb(t, e, n, i) {
13328
13336
  M !== null && _.clearTimeout(M), M = null, q = null;
13329
13337
  }
13330
13338
  function we(V = !1) {
13331
- Oe(), C = null, U !== null && _.clearTimeout(U), U = null, S = void 0, x = void 0, m.clear(), T.clear(), k !== null && _.clearTimeout(k), k = null, V && E.clear();
13339
+ Oe(), C = null, z !== null && _.clearTimeout(z), z = null, S = void 0, x = void 0, m.clear(), T.clear(), k !== null && _.clearTimeout(k), k = null, V && E.clear();
13332
13340
  }
13333
13341
  function Ae() {
13334
13342
  if (Qs(e) !== "none") {
@@ -13348,7 +13356,7 @@ function Gb(t, e, n, i) {
13348
13356
  let ye = 0;
13349
13357
  if (ie.includes("thinking")) {
13350
13358
  const D = Array.from(e.querySelectorAll('[data-message-role="user"]')), $ = D[D.length - 1], J = $?.dataset.messageKey ?? $?.dataset.entryKey ?? null;
13351
- J !== B && E.delete("thinking-without-progress"), B = J;
13359
+ J !== U && E.delete("thinking-without-progress"), U = J;
13352
13360
  let H = 2166136261;
13353
13361
  for (const se of Array.from(e.querySelectorAll(
13354
13362
  "[data-message-key], [data-entry-key][data-message-role], [data-tool-call-key], [data-event-type]"
@@ -13359,7 +13367,7 @@ function Gb(t, e, n, i) {
13359
13367
  H = Math.imul(H ^ ke.charCodeAt(Je), 16777619) >>> 0;
13360
13368
  }
13361
13369
  const de = _.performance.now();
13362
- H !== q && (q = H, z = de), ye = de - z, M !== null && _.clearTimeout(M), M = ye < 3e5 ? _.setTimeout(Ae, 3e5 - ye) : null;
13370
+ H !== q && (q = H, B = de), ye = de - B, M !== null && _.clearTimeout(M), M = ye < 3e5 ? _.setTimeout(Ae, 3e5 - ye) : null;
13363
13371
  } else
13364
13372
  Oe(), E.delete("thinking-without-progress");
13365
13373
  const G = Array.from(e.querySelectorAll(".pluno-pa-widget__thinking-marker, .thinking-marker, [data-thinking-status]")).some((D) => D.getClientRects().length > 0 && _.getComputedStyle(D).visibility !== "hidden" && _.getComputedStyle(D).opacity !== "0"), Te = d.isThinking || d.turnPhase != null || d.pendingMessageStatus != null || G;
@@ -13387,13 +13395,13 @@ function Gb(t, e, n, i) {
13387
13395
  runtimeItemCount: d.messages.filter(
13388
13396
  (D) => (D.role === "user" || D.role === "assistant") && D.phase !== "commentary" && !D.scheduledCheckInAt && !D.id.startsWith("local-") && !D.id.startsWith("optimistic-user-message:")
13389
13397
  ).length
13390
- }, $e = e.matches("[data-selected-session-id]") ? e : e.querySelector("[data-selected-session-id]"), P = !$e || ($e.dataset.selectedSessionId || null) === d.sessionId, L = P && S ? {
13398
+ }, $e = e.matches("[data-selected-session-id]") ? e : e.querySelector("[data-selected-session-id]"), P = !$e || ($e.dataset.selectedSessionId || null) === d.sessionId, N = P && S ? {
13391
13399
  ...S,
13392
13400
  terminalResponseKeys: S.terminalResponseKeys.filter((D) => {
13393
13401
  const $ = m.get(D), J = $ ? d.removedItems?.[$] : void 0;
13394
13402
  return !J || De.canonicalItemKeys.includes($) || !De.canonicalItemKeys.includes(J);
13395
13403
  })
13396
- } : void 0, ce = Dm(De, L), Y = new Set(ce.map((D) => D.code));
13404
+ } : void 0, ce = Dm(De, N), Y = new Set(ce.map((D) => D.code));
13397
13405
  for (const D of T.keys()) Y.has(D) || T.delete(D);
13398
13406
  const X = _.performance.now();
13399
13407
  for (const { code: D } of ce) {
@@ -13475,15 +13483,15 @@ function Gb(t, e, n, i) {
13475
13483
  const P = JSON.stringify(G);
13476
13484
  if (V === "runtime" && P === y || V === "paint" && P === g) return;
13477
13485
  V === "runtime" && (y = P), V === "paint" && (g = P);
13478
- const L = {
13486
+ const N = {
13479
13487
  sequence: ++l,
13480
13488
  occurred_at: (/* @__PURE__ */ new Date()).toISOString(),
13481
13489
  monotonic_ms: Math.round(_.performance.now()),
13482
13490
  kind: V,
13483
13491
  action: pe,
13484
13492
  ...G
13485
- }, ce = new TextEncoder().encode(JSON.stringify(L)).length;
13486
- for (o.push(L), a.push(ce), r += ce; o.length > Wb || r > Vb; )
13493
+ }, ce = new TextEncoder().encode(JSON.stringify(N)).length;
13494
+ for (o.push(N), a.push(ce), r += ce; o.length > Wb || r > Vb; )
13487
13495
  o.shift(), r -= a.shift(), c += 1;
13488
13496
  }
13489
13497
  function F() {
@@ -13503,7 +13511,7 @@ function Gb(t, e, n, i) {
13503
13511
  });
13504
13512
  const Ge = (V) => {
13505
13513
  const pe = V.target?.closest?.("button"), oe = pe?.getAttribute("aria-label") ?? pe?.getAttribute("title"), K = oe === "New chat" ? "new_chat" : oe === "Send" || oe === "Send message" ? "send" : oe === "Stop" || oe === "Stop generating" ? "stop" : oe === "Retry" || oe === "Retry message" ? "retry" : null;
13506
- Re("click", K), K === "stop" && pe && ne(pe) && (C = { at: _.performance.now(), responseKey: te() }, U !== null && _.clearTimeout(U), U = _.setTimeout(Ae, 1e3)), K === "new_chat" && we(!0);
13514
+ Re("click", K), K === "stop" && pe && ne(pe) && (C = { at: _.performance.now(), responseKey: te() }, z !== null && _.clearTimeout(z), z = _.setTimeout(Ae, 1e3)), K === "new_chat" && we(!0);
13507
13515
  }, ue = () => Re("submit"), _e = () => Re("focus");
13508
13516
  e.addEventListener("click", Ge, !0), e.addEventListener("submit", ue, !0), e.addEventListener("focusin", _e, !0), e.addEventListener("input", F, !0);
13509
13517
  const ve = () => {
@@ -13724,13 +13732,13 @@ async function Cw(t = {}) {
13724
13732
  ".pluno-pa-widget__panel-drag-handle"
13725
13733
  ), q = l.querySelector(
13726
13734
  ".pluno-pa-widget__scribble-spirals--panel"
13727
- ), z = Array.from(
13735
+ ), B = Array.from(
13728
13736
  l.querySelectorAll(".pluno-pa-widget__resize-handle")
13729
- ), B = l.querySelector(
13737
+ ), U = l.querySelector(
13730
13738
  ".pluno-pa-widget__close"
13731
13739
  ), C = l.querySelector(
13732
13740
  ".pluno-pa-widget__composer"
13733
- ), U = l.querySelector(
13741
+ ), z = l.querySelector(
13734
13742
  ".pluno-pa-widget__attachment-error"
13735
13743
  ), te = l.querySelector(
13736
13744
  ".pluno-pa-widget__billing-status"
@@ -13794,7 +13802,7 @@ async function Cw(t = {}) {
13794
13802
  );
13795
13803
  const P = l.querySelector(
13796
13804
  ".pluno-pa-widget__proactive-suggestion"
13797
- ), L = l.querySelector(
13805
+ ), N = l.querySelector(
13798
13806
  ".pluno-pa-widget__proactive-suggestion-query"
13799
13807
  ), ce = l.querySelector(
13800
13808
  ".pluno-pa-widget__proactive-suggestion-run"
@@ -13817,7 +13825,7 @@ async function Cw(t = {}) {
13817
13825
  ), zt = l.querySelector(
13818
13826
  ".pluno-pa-widget__proactive-suggestion-feedback-status"
13819
13827
  );
13820
- if (!m || !I || !k || !B || !C || !U || !te || !we || !Ae || !Re || !F || !Z || !nt || !ue || !_e || !ve || !it || !V || !pe || !oe || !K || !ie || !ye || !G || !Te)
13828
+ if (!m || !I || !k || !U || !C || !z || !te || !we || !Ae || !Re || !F || !Z || !nt || !ue || !_e || !ve || !it || !V || !pe || !oe || !K || !ie || !ye || !G || !Te)
13821
13829
  throw new Error("Failed to mount Pluno widget");
13822
13830
  if (e.movableLauncher && !w)
13823
13831
  throw new Error("Failed to mount Pluno widget drag handle");
@@ -13837,15 +13845,15 @@ async function Cw(t = {}) {
13837
13845
  )
13838
13846
  );
13839
13847
  }, dt = () => {
13840
- if (!P || !L || !J || !H || !de || !se || !zt)
13848
+ if (!P || !N || !J || !H || !de || !se || !zt)
13841
13849
  return;
13842
13850
  const h = e.proactiveSuggestion ?? Je, v = O.getState(), A = h !== null && !Gn && !v.sessionId && !v.isThinking && !v.pendingMessageStatus, R = k.querySelector(
13843
13851
  ".pluno-pa-widget__proactive-suggestion-slot"
13844
13852
  ), j = !k.hidden && !l.classList.contains("pluno-pa-widget--closing"), ee = A && j && R !== null;
13845
- ee ? P.parentElement !== R && R.appendChild(P) : P.parentElement !== l && l.insertBefore(P, B), P.hidden = !A, l.classList.toggle("pluno-pa-widget--proactive-suggestion", A), l.classList.toggle(
13853
+ ee ? P.parentElement !== R && R.appendChild(P) : P.parentElement !== l && l.insertBefore(P, U), P.hidden = !A, l.classList.toggle("pluno-pa-widget--proactive-suggestion", A), l.classList.toggle(
13846
13854
  "pluno-pa-widget--proactive-suggestion-in-panel",
13847
13855
  ee
13848
- ), L.textContent = h?.question ?? "", X && (X.textContent = "Not now"), Y && (Y.textContent = "Edit", Y.setAttribute("aria-label", "Edit")), J.hidden = e.proactiveSuggestion === null || Gn, H.hidden = Je === null;
13856
+ ), N.textContent = h?.question ?? "", X && (X.textContent = "Not now"), Y && (Y.textContent = "Edit", Y.setAttribute("aria-label", "Edit")), J.hidden = e.proactiveSuggestion === null || Gn, H.hidden = Je === null;
13849
13857
  const he = st === "success";
13850
13858
  de.hidden = he, se.hidden = he, se.disabled = st === "submitting" || de.value.trim().length === 0, se.textContent = st === "submitting" ? "Sending…" : "Send feedback", zt.textContent = st === "success" ? "Thanks — this helps improve your suggestions." : st === "error" ? "Couldn’t send feedback. Please try again." : "Tell Pluno what made this suggestion miss the mark.", zt.classList.toggle(
13851
13859
  "pluno-pa-widget__proactive-suggestion-feedback-status--success",
@@ -14168,7 +14176,7 @@ async function Cw(t = {}) {
14168
14176
  l.classList.remove("pluno-pa-widget--minimized"), m.removeAttribute("tabindex"), m.removeAttribute("role"), m.removeAttribute("aria-label"), !l.classList.contains("pluno-pa-widget--open") && !l.classList.contains("pluno-pa-widget--closing") && wi(!1), v && ls("shown", A);
14169
14177
  return;
14170
14178
  }
14171
- kt !== null && (window.clearTimeout(kt), kt = null), l.classList.remove("pluno-pa-widget--open"), l.classList.remove("pluno-pa-widget--closing"), l.classList.add("pluno-pa-widget--minimized"), m.hidden = !1, m.setAttribute("role", "button"), m.setAttribute("aria-label", "Open Pluno"), k.hidden = !0, B.hidden = !0, m.tabIndex = 0, F.value = "", dt(), hn(
14179
+ kt !== null && (window.clearTimeout(kt), kt = null), l.classList.remove("pluno-pa-widget--open"), l.classList.remove("pluno-pa-widget--closing"), l.classList.add("pluno-pa-widget--minimized"), m.hidden = !1, m.setAttribute("role", "button"), m.setAttribute("aria-label", "Open Pluno"), k.hidden = !0, U.hidden = !0, m.tabIndex = 0, F.value = "", dt(), hn(
14172
14180
  l,
14173
14181
  jr(
14174
14182
  l,
@@ -14192,7 +14200,7 @@ async function Cw(t = {}) {
14192
14200
  panelRect: Hr(k),
14193
14201
  viewport: tt(),
14194
14202
  panelHidden: k.hidden,
14195
- closeHidden: B.hidden,
14203
+ closeHidden: U.hidden,
14196
14204
  ...v
14197
14205
  });
14198
14206
  }, wi = (h = !0) => {
@@ -14333,9 +14341,9 @@ async function Cw(t = {}) {
14333
14341
  setPosition: Pp,
14334
14342
  persist: Ye
14335
14343
  }) : () => {
14336
- }, Mp = z.length > 0 ? Mw({
14344
+ }, Mp = B.length > 0 ? Mw({
14337
14345
  root: l,
14338
- handles: z,
14346
+ handles: B,
14339
14347
  getBounds: Cc,
14340
14348
  setBounds: Tp,
14341
14349
  persist: Ye
@@ -14385,7 +14393,7 @@ async function Cw(t = {}) {
14385
14393
  }));
14386
14394
  }, Mt = (h = "", v = !0, A = !0, R = !0, j = "external_request") => {
14387
14395
  const ee = l.classList.contains("pluno-pa-widget--open") || !k.hidden && !l.classList.contains("pluno-pa-widget--closing");
14388
- !ee && R && Tc("panel_open"), jo(), ki && (ki = !1, Wo()), l.classList.contains("pluno-pa-widget--open") || (b = null), kt !== null && (window.clearTimeout(kt), kt = null), bi("shown", !1), k.hidden = !1, B.hidden = !1, Kr(
14396
+ !ee && R && Tc("panel_open"), jo(), ki && (ki = !1, Wo()), l.classList.contains("pluno-pa-widget--open") || (b = null), kt !== null && (window.clearTimeout(kt), kt = null), bi("shown", !1), k.hidden = !1, U.hidden = !1, Kr(
14389
14397
  q,
14390
14398
  Uo()
14391
14399
  ), l.classList.remove("pluno-pa-widget--closing"), dt();
@@ -14413,7 +14421,7 @@ async function Cw(t = {}) {
14413
14421
  }, Fo = (h = "external_request") => {
14414
14422
  const v = l.classList.contains("pluno-pa-widget--open") || !k.hidden && !l.classList.contains("pluno-pa-widget--closing");
14415
14423
  kt !== null && (window.clearTimeout(kt), kt = null), m.hidden = !1, f && (wi(!1), kn("Closing launcher at stored position")), l.classList.remove("pluno-pa-widget--open"), l.classList.add("pluno-pa-widget--closing"), dt(), Ye(), v && e.layout === "floating" && O.recordWidgetLifecycle("closed", h), e.onPanelOpenChange?.(!1, h), kt = window.setTimeout(() => {
14416
- k.hidden = !0, B.hidden = !0, b = null, l.classList.remove("pluno-pa-widget--closing");
14424
+ k.hidden = !0, U.hidden = !0, b = null, l.classList.remove("pluno-pa-widget--closing");
14417
14425
  }, 220);
14418
14426
  };
14419
14427
  m.addEventListener("submit", (h) => {
@@ -14559,7 +14567,7 @@ async function Cw(t = {}) {
14559
14567
  h.stopPropagation();
14560
14568
  }), T?.addEventListener("click", (h) => {
14561
14569
  h.preventDefault(), h.stopPropagation(), bi("minimized", !0, "minimize_button");
14562
- }), B.addEventListener("click", () => Fo("close_button")), G.addEventListener("wheel", (h) => {
14570
+ }), U.addEventListener("click", () => Fo("close_button")), G.addEventListener("wheel", (h) => {
14563
14571
  cs(h.deltaY < 0 ? "up" : null);
14564
14572
  }), G.addEventListener("pointerdown", (h) => {
14565
14573
  Sn = h.target === G ? h.clientY : null;
@@ -14663,8 +14671,8 @@ async function Cw(t = {}) {
14663
14671
  }
14664
14672
  );
14665
14673
  }, ms = (h) => {
14666
- Bt !== null && window.clearTimeout(Bt), U.textContent = h, U.hidden = !1, Bt = window.setTimeout(() => {
14667
- U.textContent = "", U.hidden = !0, Bt = null;
14674
+ Bt !== null && window.clearTimeout(Bt), z.textContent = h, z.hidden = !1, Bt = window.setTimeout(() => {
14675
+ z.textContent = "", z.hidden = !0, Bt = null;
14668
14676
  }, 3e3);
14669
14677
  }, Go = (h, v) => {
14670
14678
  const A = qt.get(h);
@@ -14739,7 +14747,7 @@ async function Cw(t = {}) {
14739
14747
  const cn = () => {
14740
14748
  Ei = 0, l.classList.remove("pluno-pa-widget--drag-over");
14741
14749
  }, zp = () => {
14742
- Bt !== null && (window.clearTimeout(Bt), Bt = null), U.textContent = "", U.hidden = !0;
14750
+ Bt !== null && (window.clearTimeout(Bt), Bt = null), z.textContent = "", z.hidden = !0;
14743
14751
  }, Qo = async (h) => {
14744
14752
  if (!e.attachmentsEnabled || h.length === 0 || e.productVariant === "personal" && Rn())
14745
14753
  return;
@@ -17145,42 +17153,42 @@ function Cd(t, e) {
17145
17153
  i.textContent !== s && (i.textContent = s), i.classList.toggle("pluno-pa-widget__starter-placeholder--loading", e), i.parentElement.setAttribute("aria-hidden", String(!e));
17146
17154
  }
17147
17155
  function E_(t, e, n, i, s, o, a, r, c, l, u, d, p, f, y, g, b, _, S, x, m, w, I, E, T, k) {
17148
- const M = bh(o), q = U_(o), z = Array.isArray(o.activeScheduledFollowUps) ? o.activeScheduledFollowUps : null, B = /* @__PURE__ */ new Map();
17149
- if (z !== null)
17150
- for (const P of z) {
17151
- const L = ri(P.dueAt);
17152
- L && B.set(P.taskId, { dueAt: P.dueAt, label: L });
17156
+ const M = bh(o), q = U_(o), B = Array.isArray(o.activeScheduledFollowUps) ? o.activeScheduledFollowUps : null, U = /* @__PURE__ */ new Map();
17157
+ if (B !== null)
17158
+ for (const P of B) {
17159
+ const N = ri(P.dueAt);
17160
+ N && U.set(P.taskId, { dueAt: P.dueAt, label: N });
17153
17161
  }
17154
17162
  else
17155
17163
  for (const P of q) {
17156
- const L = P.scheduledCheckInAt ? ri(P.scheduledCheckInAt) : null;
17157
- if (!L || !P.scheduledCheckInAt)
17164
+ const N = P.scheduledCheckInAt ? ri(P.scheduledCheckInAt) : null;
17165
+ if (!N || !P.scheduledCheckInAt)
17158
17166
  continue;
17159
17167
  const ce = P.scheduledCheckInId ?? P.id;
17160
- B.set(ce, {
17168
+ U.set(ce, {
17161
17169
  dueAt: P.scheduledCheckInAt,
17162
- label: L
17170
+ label: N
17163
17171
  });
17164
17172
  }
17165
- const C = [...B.values()].sort((P, L) => Date.parse(P.dueAt) - Date.parse(L.dueAt)), U = z_(
17173
+ const C = [...U.values()].sort((P, N) => Date.parse(P.dueAt) - Date.parse(N.dueAt)), z = z_(
17166
17174
  q.filter(
17167
17175
  (P) => !bp(P) && !P.scheduledCheckInAt
17168
17176
  ),
17169
17177
  o.segments
17170
- ), te = new Map((o.segments ?? []).flatMap((P) => P.activityIds.map((L) => [L, P])));
17178
+ ), te = new Map((o.segments ?? []).flatMap((P) => P.activityIds.map((N) => [N, P])));
17171
17179
  t.dataset.selectedSessionId = o.sessionId ?? "", t.dataset.removedItems = JSON.stringify(o.removedItems ?? {}), t.dataset.loadingSession = String(o.isLoadingSession);
17172
17180
  const ne = o.activeResponseUserMessageId;
17173
17181
  if (M.showProgress && o.turnPhase && !o.assistantDraft && ne) {
17174
- const P = U.findIndex(
17182
+ const P = z.findIndex(
17175
17183
  (ce) => ce.role === "user" && ce.id === ne
17176
- ), L = U.some(
17184
+ ), N = z.some(
17177
17185
  (ce) => ce.role !== "user" && ce.respondsToUserMessageId === ne
17178
17186
  );
17179
- P !== -1 && !L && U.splice(P + 1, 0, {
17187
+ P !== -1 && !N && z.splice(P + 1, 0, {
17180
17188
  id: `turn-status:${ne}`,
17181
17189
  role: "system",
17182
17190
  content: "",
17183
- createdAt: U[P].createdAt,
17191
+ createdAt: z[P].createdAt,
17184
17192
  respondsToUserMessageId: ne,
17185
17193
  dataType: "run_status",
17186
17194
  loading: !0
@@ -17190,7 +17198,7 @@ function E_(t, e, n, i, s, o, a, r, c, l, u, d, p, f, y, g, b, _, S, x, m, w, I,
17190
17198
  P === e && we.push(t.querySelector('slot[name="conversation-notices"]') ?? op("conversation-notices")), P.dataset.sessionId = o.sessionId ?? "", we.push(P);
17191
17199
  };
17192
17200
  ac(n, o.isThinking), n.disabled = !1, s.hidden = !r, r && a !== null && ap(s, a);
17193
- const nt = !!k?.cards.length, Ge = nt || U.length > 0 || C.length > 0 || !!o.assistantDraft || o.pendingMessageStatus !== null || o.isThinking;
17201
+ const nt = !!k?.cards.length, Ge = nt || z.length > 0 || C.length > 0 || !!o.assistantDraft || o.pendingMessageStatus !== null || o.isThinking;
17194
17202
  if (i(Ge || !!o.historyPreparation), o.historyPreparation && Ge) {
17195
17203
  const P = document.createElement("div");
17196
17204
  P.className = "pluno-pa-widget__transcript-loading", P.setAttribute("role", "status"), P.append(bn(), document.createTextNode("Preparing this conversation…")), Z(P);
@@ -17198,8 +17206,8 @@ function E_(t, e, n, i, s, o, a, r, c, l, u, d, p, f, y, g, b, _, S, x, m, w, I,
17198
17206
  if (o.isLoadingSession && !Ge) {
17199
17207
  const P = document.createElement("div");
17200
17208
  P.className = "pluno-pa-widget__transcript-loading", P.setAttribute("role", "status");
17201
- const L = document.createElement("span");
17202
- L.textContent = o.historyPreparation ? "Preparing this conversation…" : "Loading chat...", P.append(bn(), L), d.clear(), p.clear(), f.clear(), Z(P), Z(e), Lt(t, we);
17209
+ const N = document.createElement("span");
17210
+ N.textContent = o.historyPreparation ? "Preparing this conversation…" : "Loading chat...", P.append(bn(), N), d.clear(), p.clear(), f.clear(), Z(P), Z(e), Lt(t, we);
17203
17211
  return;
17204
17212
  }
17205
17213
  if (!Ge && o.sessionId && !o.isDraftSession) {
@@ -17212,8 +17220,8 @@ function E_(t, e, n, i, s, o, a, r, c, l, u, d, p, f, y, g, b, _, S, x, m, w, I,
17212
17220
  return;
17213
17221
  }
17214
17222
  }
17215
- if (U.length === 0 && !nt && C.length === 0 && !o.assistantDraft && (!o.lastError || Ji(o.lastErrorCode) === "bottom_notice") && !o.pendingMessageStatus && !o.isThinking) {
17216
- const P = k?.morning, L = JSON.stringify([
17223
+ if (z.length === 0 && !nt && C.length === 0 && !o.assistantDraft && (!o.lastError || Ji(o.lastErrorCode) === "bottom_notice") && !o.pendingMessageStatus && !o.isThinking) {
17224
+ const P = k?.morning, N = JSON.stringify([
17217
17225
  o.sessionId,
17218
17226
  o.user?.id,
17219
17227
  S,
@@ -17221,7 +17229,7 @@ function E_(t, e, n, i, s, o, a, r, c, l, u, d, p, f, y, g, b, _, S, x, m, w, I,
17221
17229
  o.starterPrompts,
17222
17230
  g()
17223
17231
  ]), ce = d.get("welcome");
17224
- if (ce?.renderSignature === L) {
17232
+ if (ce?.renderSignature === N) {
17225
17233
  Cd(ce.node, o.starterPromptsLoading), Z(ce.node), Z(e), Lt(t, we);
17226
17234
  return;
17227
17235
  }
@@ -17258,11 +17266,11 @@ function E_(t, e, n, i, s, o, a, r, c, l, u, d, p, f, y, g, b, _, S, x, m, w, I,
17258
17266
  de.setAttribute("role", "alert"), de.textContent = String(P.payload.error), Y.appendChild(de);
17259
17267
  }
17260
17268
  }
17261
- d.clear(), p.clear(), f.clear(), Z(Y), d.set("welcome", { node: Y, renderSignature: L }), Z(e), Lt(t, we);
17269
+ d.clear(), p.clear(), f.clear(), Z(Y), d.set("welcome", { node: Y, renderSignature: N }), Z(e), Lt(t, we);
17262
17270
  return;
17263
17271
  }
17264
17272
  let ue = null, _e = null, ve = [];
17265
- const it = U.some(Oa), V = U.some(
17273
+ const it = z.some(Oa), V = z.some(
17266
17274
  (P) => P.role === "tool" && P.id === o.activity?.activeItemId
17267
17275
  ), pe = o.turnPhase ? Hb(o.turnPhase) : "Thinking...";
17268
17276
  let oe = !1;
@@ -17271,7 +17279,7 @@ function E_(t, e, n, i, s, o, a, r, c, l, u, d, p, f, y, g, b, _, S, x, m, w, I,
17271
17279
  return oe = !1, !1;
17272
17280
  const P = M.showProgress && ve.some(
17273
17281
  (ce) => ce.id === o.activity?.activeItemId
17274
- ), L = K_(
17282
+ ), N = K_(
17275
17283
  ve,
17276
17284
  P,
17277
17285
  u,
@@ -17281,9 +17289,9 @@ function E_(t, e, n, i, s, o, a, r, c, l, u, d, p, f, y, g, b, _, S, x, m, w, I,
17281
17289
  g(),
17282
17290
  te.get(ve[0].id)?.collapsed ?? !0
17283
17291
  );
17284
- return Z(L), ue = null, _e = L, ve = [], oe = P, !0;
17292
+ return Z(N), ue = null, _e = N, ve = [], oe = P, !0;
17285
17293
  }, ie = (P) => {
17286
- const L = `interaction:${o.sessionId ?? ""}:${P.id}`, ce = JSON.stringify([P, g(), k?.socialPostRewardsUrl]), Y = d.get(L);
17294
+ const N = `interaction:${o.sessionId ?? ""}:${P.id}`, ce = JSON.stringify([P, g(), k?.socialPostRewardsUrl]), Y = d.get(N);
17287
17295
  let X = Y?.renderSignature === ce ? Y.node : void 0;
17288
17296
  if (!X) {
17289
17297
  const D = (J, H) => k.act(P, J, H), $ = P.payload.error ?? null;
@@ -17310,32 +17318,32 @@ function E_(t, e, n, i, s, o, a, r, c, l, u, d, p, f, y, g, b, _, S, x, m, w, I,
17310
17318
  P.status === "pending" ? "connect" : null
17311
17319
  );
17312
17320
  else return;
17313
- d.set(L, { node: X, renderSignature: ce });
17321
+ d.set(N, { node: X, renderSignature: ce });
17314
17322
  }
17315
- Ae.add(L), X.dataset.interactionId = P.id, X.dataset.interactionUserMessageId = P.userMessageId ?? "", Z(X), ue = null, _e = X;
17316
- }, ye = new Set(U.filter((P) => P.role === "user").map((P) => P.id));
17323
+ Ae.add(N), X.dataset.interactionId = P.id, X.dataset.interactionUserMessageId = P.userMessageId ?? "", Z(X), ue = null, _e = X;
17324
+ }, ye = new Set(z.filter((P) => P.role === "user").map((P) => P.id));
17317
17325
  for (const P of k?.cards ?? []) ye.has(P.userMessageId ?? "") || ie(P);
17318
17326
  let G = null;
17319
17327
  const Te = () => {
17320
17328
  for (const P of k?.cards ?? []) G && P.userMessageId === G && ie(P);
17321
17329
  };
17322
- for (let P = 0; P < U.length; P += 1) {
17323
- const L = U[P];
17324
- if (L.role === "user" && (K(), Te(), G = L.id), L.role === "tool") {
17325
- ve.length > 0 && te.get(ve[0].id)?.id !== te.get(L.id)?.id && K(), ve.push(L);
17330
+ for (let P = 0; P < z.length; P += 1) {
17331
+ const N = z[P];
17332
+ if (N.role === "user" && (K(), Te(), G = N.id), N.role === "tool") {
17333
+ ve.length > 0 && te.get(ve[0].id)?.id !== te.get(N.id)?.id && K(), ve.push(N);
17326
17334
  continue;
17327
17335
  }
17328
- if (L.role === "system" && L.dataType === "run_status" && L.steered === !0) {
17336
+ if (N.role === "system" && N.dataType === "run_status" && N.steered === !0) {
17329
17337
  if (!K()) {
17330
17338
  const J = G_(g());
17331
17339
  Z(J), ue = null, _e = J;
17332
17340
  }
17333
17341
  continue;
17334
17342
  }
17335
- if (Oa(L)) {
17343
+ if (Oa(N)) {
17336
17344
  if (!M.showProgress)
17337
17345
  continue;
17338
- const $ = K(), J = mp(L);
17346
+ const $ = K(), J = mp(N);
17339
17347
  if ($) {
17340
17348
  if (!oe) {
17341
17349
  const H = Td(
@@ -17358,73 +17366,73 @@ function E_(t, e, n, i, s, o, a, r, c, l, u, d, p, f, y, g, b, _, S, x, m, w, I,
17358
17366
  }
17359
17367
  continue;
17360
17368
  }
17361
- if (L.role === "system") {
17362
- if (L.dataType === "run_error" || L.dataType === "run_status") {
17363
- const $ = K(), J = U.some(
17364
- (se) => se.role === "tool" && uo(se, L)
17369
+ if (N.role === "system") {
17370
+ if (N.dataType === "run_error" || N.dataType === "run_status") {
17371
+ const $ = K(), J = z.some(
17372
+ (se) => se.role === "tool" && uo(se, N)
17365
17373
  );
17366
17374
  if (!$ && !J) {
17367
17375
  const se = es(g());
17368
17376
  se.classList.add("pluno-pa-widget__terminal-marker"), Z(se);
17369
17377
  }
17370
- const H = document.createElement("div"), de = L.dataType === "run_error";
17371
- if (H.className = de ? "pluno-pa-widget__error" : "pluno-pa-widget__status pluno-pa-widget__run-status", H.dataset.messageKey = rc(L), H.dataset.canonicalItemKey = L.id, H.dataset.messageRole = "system", L.provisional || (H.dataset.terminalResponseKey = L.id), L.runId && (H.dataset.runId = L.runId), H.textContent = po(
17372
- L.content
17373
- ), de && L.securitySettingsUrl) {
17378
+ const H = document.createElement("div"), de = N.dataType === "run_error";
17379
+ if (H.className = de ? "pluno-pa-widget__error" : "pluno-pa-widget__status pluno-pa-widget__run-status", H.dataset.messageKey = rc(N), H.dataset.canonicalItemKey = N.id, H.dataset.messageRole = "system", N.provisional || (H.dataset.terminalResponseKey = N.id), N.runId && (H.dataset.runId = N.runId), H.textContent = po(
17380
+ N.content
17381
+ ), de && N.securitySettingsUrl) {
17374
17382
  const se = document.createElement("a");
17375
- se.className = "pluno-pa-widget__error-retry", se.href = L.securitySettingsUrl, se.target = "_blank", se.rel = "noreferrer", se.textContent = "Security settings", H.appendChild(se);
17383
+ se.className = "pluno-pa-widget__error-retry", se.href = N.securitySettingsUrl, se.target = "_blank", se.rel = "noreferrer", se.textContent = "Security settings", H.appendChild(se);
17376
17384
  }
17377
17385
  Z(H), ue = de ? H : null, _e = de ? null : H;
17378
17386
  }
17379
17387
  continue;
17380
17388
  }
17381
- L.role;
17382
- const ce = K(), Y = po(L.content), X = L.role === "assistant" && U.some(
17383
- ($) => $.role === "tool" && uo($, L)
17389
+ N.role;
17390
+ const ce = K(), Y = po(N.content), X = N.role === "assistant" && z.some(
17391
+ ($) => $.role === "tool" && uo($, N)
17384
17392
  );
17385
- if (L.role === "assistant" && !ce && !X) {
17393
+ if (N.role === "assistant" && !ce && !X) {
17386
17394
  const $ = es(g());
17387
17395
  Z($), ue = null, _e = $;
17388
17396
  }
17389
17397
  const D = R_(
17390
- L,
17398
+ N,
17391
17399
  Y,
17392
17400
  d,
17393
17401
  Ae,
17394
17402
  T
17395
17403
  );
17396
- if (D.querySelector("[data-submission-retry]")?.remove(), L.role === "user" && L.retryable) {
17404
+ if (D.querySelector("[data-submission-retry]")?.remove(), N.role === "user" && N.retryable) {
17397
17405
  const $ = document.createElement("button");
17398
- $.type = "button", $.className = "pluno-pa-widget__error-retry", $.dataset.submissionRetry = L.id, $.textContent = "Retry this message", $.addEventListener("click", () => _(L.id)), D.appendChild($);
17406
+ $.type = "button", $.className = "pluno-pa-widget__error-retry", $.dataset.submissionRetry = N.id, $.textContent = "Retry this message", $.addEventListener("click", () => _(N.id)), D.appendChild($);
17399
17407
  }
17400
- Z(D), ue = D, _e = null, L.role;
17408
+ Z(D), ue = D, _e = null, N.role;
17401
17409
  }
17402
- const De = K(), $e = U[U.length - 1]?.role === "assistant";
17410
+ const De = K(), $e = z[z.length - 1]?.role === "assistant";
17403
17411
  if (M.showProgress && o.turnPhase && !o.assistantDraft && !V && !$e && !it) {
17404
17412
  const P = o.activeResponseUserMessageId ? `response:${o.activeResponseUserMessageId}` : `session:${o.sessionId ?? "pending"}`;
17405
17413
  if (De) {
17406
17414
  if (!oe) {
17407
- const L = Td(
17415
+ const N = Td(
17408
17416
  f,
17409
17417
  F,
17410
17418
  P,
17411
17419
  pe
17412
17420
  );
17413
- Z(L), ue = null, _e = L;
17421
+ Z(N), ue = null, _e = N;
17414
17422
  }
17415
17423
  } else {
17416
- const L = Rd(
17424
+ const N = Rd(
17417
17425
  f,
17418
17426
  F,
17419
17427
  P,
17420
17428
  g(),
17421
17429
  pe
17422
17430
  );
17423
- Z(L), ue = null, _e = L;
17431
+ Z(N), ue = null, _e = N;
17424
17432
  }
17425
17433
  }
17426
17434
  if (o.lastError && Ji(o.lastErrorCode) === "conversation") {
17427
- const ce = U.slice(U.map((D) => D.role).lastIndexOf("user") + 1).some((D) => D.role === "assistant" || D.role === "tool") ? document.createElement("article") : es(g());
17435
+ const ce = z.slice(z.map((D) => D.role).lastIndexOf("user") + 1).some((D) => D.role === "assistant" || D.role === "tool") ? document.createElement("article") : es(g());
17428
17436
  ce.classList.add("pluno-pa-widget__terminal-marker");
17429
17437
  const Y = document.createElement("div");
17430
17438
  Y.className = "pluno-pa-widget__error", o.historyRefreshFailure && (Y.dataset.historyRefreshFailure = JSON.stringify(o.historyRefreshFailure));
@@ -17443,11 +17451,11 @@ function E_(t, e, n, i, s, o, a, r, c, l, u, d, p, f, y, g, b, _, S, x, m, w, I,
17443
17451
  }
17444
17452
  Te();
17445
17453
  for (const P of C) {
17446
- const L = document.createElement("div");
17447
- L.className = "pluno-pa-widget__next-check-in", L.append(
17454
+ const N = document.createElement("div");
17455
+ N.className = "pluno-pa-widget__next-check-in", N.append(
17448
17456
  c_(P.dueAt),
17449
17457
  document.createTextNode(P.label)
17450
- ), Z(L), ue = null, _e = L;
17458
+ ), Z(N), ue = null, _e = N;
17451
17459
  }
17452
17460
  ue?.classList.add(
17453
17461
  "pluno-pa-widget__message--bottom-reserve"
@@ -17838,11 +17846,11 @@ function K_(t, e, n, i, s, o, a, r = !0) {
17838
17846
  M.className = "pluno-pa-widget__tool-summary";
17839
17847
  const q = document.createElement("div");
17840
17848
  q.className = "pluno-pa-widget__tool-summary-title", M.appendChild(q), M.addEventListener("click", () => {
17841
- const B = m.dataset.responseGroupKey ?? l;
17842
- k.open ? (n.delete(B), n.add(`closed:${B}`)) : (n.add(B), n.delete(`closed:${B}`)), o(), q.textContent = k.open ? m.dataset.collapsedActivityTitle ?? "Activities" : "Activities";
17849
+ const U = m.dataset.responseGroupKey ?? l;
17850
+ k.open ? (n.delete(U), n.add(`closed:${U}`)) : (n.add(U), n.delete(`closed:${U}`)), o(), q.textContent = k.open ? m.dataset.collapsedActivityTitle ?? "Activities" : "Activities";
17843
17851
  }), k.appendChild(M);
17844
- const z = document.createElement("div");
17845
- z.className = "pluno-pa-widget__tool-lines", k.addEventListener("toggle", () => {
17852
+ const B = document.createElement("div");
17853
+ B.className = "pluno-pa-widget__tool-lines", k.addEventListener("toggle", () => {
17846
17854
  m.dataset.responseGroupKey, m.classList.toggle("pluno-pa-widget__tool-group--open", k.open), q.textContent = k.open ? "Activities" : m.dataset.collapsedActivityTitle ?? "Activities";
17847
17855
  }), u = {
17848
17856
  node: m,
@@ -17853,7 +17861,7 @@ function K_(t, e, n, i, s, o, a, r = !0) {
17853
17861
  details: k,
17854
17862
  summary: M,
17855
17863
  summaryTitle: q,
17856
- lines: z,
17864
+ lines: B,
17857
17865
  lineNodes: /* @__PURE__ */ new Map()
17858
17866
  }, i.set(l, u);
17859
17867
  }