@pluno/product-agent-web 0.1.262 → 0.1.263

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,7 +37,7 @@ function Fp(t, e, n, i) {
37
37
  function $p(t) {
38
38
  return Lr(t) > 0.5 ? [24, 24, 27] : [250, 250, 249];
39
39
  }
40
- const Hp = "0.1.262", ri = {
40
+ const Hp = "0.1.263", ri = {
41
41
  version: Hp
42
42
  }, ye = (t) => typeof t == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(t) ? t : null;
43
43
  function Ad(t) {
@@ -340,15 +340,15 @@ function Go(t, e, n, i) {
340
340
  const c = r.sessionId ? e.sessions[r.sessionId] : void 0, l = c?.execution?.user_message_ids ?? [], u = ["queued", "thinking", "steering"].includes(c?.execution?.phase ?? "idle"), d = t.interactions.openings[a], h = d && (d.sessionId === r.sessionId || d.sessionId === null) ? { ...d, sessionId: r.sessionId } : { sessionId: r.sessionId, generation: ++o, openedAt: i, awaitingBaseline: r.sessionId !== null && !c?.execution, ignoredTurns: l, turns: {}, shown: {} };
341
341
  if (h.awaitingBaseline && c?.execution) {
342
342
  const y = l.filter((g) => {
343
- const w = e.submissions[g];
344
- return w?.conversationScopeId === a && w.submittedAt >= h.openedAt;
343
+ const b = e.submissions[g];
344
+ return b?.conversationScopeId === a && b.submittedAt >= h.openedAt;
345
345
  });
346
346
  h.awaitingBaseline = !1, h.ignoredTurns = l.filter((g) => !y.includes(g));
347
347
  }
348
348
  const f = {};
349
349
  for (const [y, g] of Object.entries(h.turns)) {
350
- const w = u && l.includes(y), b = w && !g.active ? i : g.startedAt;
351
- f[y] = { ...g, startedAt: b, active: w, notifications: !g.notificationsSuppressed && (g.notifications || w && i - b >= 1e4) };
350
+ const b = u && l.includes(y), w = b && !g.active ? i : g.startedAt;
351
+ f[y] = { ...g, startedAt: w, active: b, notifications: !g.notificationsSuppressed && (g.notifications || b && i - w >= 1e4) };
352
352
  }
353
353
  if (u)
354
354
  for (const y of l) !h.ignoredTurns.includes(y) && !f[y] && (f[y] = { startedAt: i, active: !0, notifications: !1, tab_grouping: (t.interactions.crossTabTurns[r.sessionId] ?? []).includes(y) });
@@ -644,14 +644,14 @@ function fn(t, e, n) {
644
644
  collapsed: !1
645
645
  });
646
646
  }
647
- const d = o?.execution, h = a.filter((E) => !E.cancelled && E.delivery !== "failed"), f = h.filter((E) => E.delivery !== "accepted" && E.executionVersion === null), y = h.filter((E) => E.delivery === "accepted" && E.executionVersion === null), g = h[h.length - 1], w = f.length > 0, b = g !== void 0 && y.includes(g);
648
- let I = w ? "submitting" : b ? "awaiting_execution" : d?.phase ?? "idle";
649
- const x = Object.entries(t.stops).filter(([E]) => E === n || s !== null && e.selections[E]?.sessionId === s).map(([, E]) => E).find((E) => (!a.length || E.userMessageIds.includes(a[a.length - 1].userMessageId) || !w && !b && Tt(d).some((N) => E.userMessageIds.includes(N))) && (!d || d.version <= E.executionVersion || ["thinking", "steering", "queued", "stopping"].includes(d.phase) || a.some((N) => N.cancelled && N.executionVersion === null && E.userMessageIds.includes(N.userMessageId)))), m = d && ["thinking", "steering", "queued", "stopping"].includes(d.phase) || a.some((E) => E.delivery === "accepted" && E.executionVersion === null && x?.userMessageIds.includes(E.userMessageId));
650
- x && m && !w && (!d || !["thinking", "steering", "queued", "stopping"].includes(d.phase) || Tt(d).every((E) => x.userMessageIds.includes(E))) && (I = "stopping"), x && !m && !w && a.some((E) => E.cancelled && E.executionVersion === null && x.userMessageIds.includes(E.userMessageId)) && (I = a.some((E) => x.userMessageIds.includes(E.userMessageId) && ["sending", "uncertain"].includes(E.delivery)) ? "stopping" : "stopped");
651
- const _ = ["thinking", "steering", "queued"].includes(I), S = t.stops[n] ?? x, k = S?.userMessageIds.filter((E) => !["completed", "failed"].includes(o?.executionByUserMessage[E]?.phase ?? "")) ?? [], T = k.some((E) => {
647
+ const d = o?.execution, h = a.filter((E) => !E.cancelled && E.delivery !== "failed"), f = h.filter((E) => E.delivery !== "accepted" && E.executionVersion === null), y = h.filter((E) => E.delivery === "accepted" && E.executionVersion === null), g = h[h.length - 1], b = f.length > 0, w = g !== void 0 && y.includes(g);
648
+ let S = b ? "submitting" : w ? "awaiting_execution" : d?.phase ?? "idle";
649
+ const x = Object.entries(t.stops).filter(([E]) => E === n || s !== null && e.selections[E]?.sessionId === s).map(([, E]) => E).find((E) => (!a.length || E.userMessageIds.includes(a[a.length - 1].userMessageId) || !b && !w && Tt(d).some((N) => E.userMessageIds.includes(N))) && (!d || d.version <= E.executionVersion || ["thinking", "steering", "queued", "stopping"].includes(d.phase) || a.some((N) => N.cancelled && N.executionVersion === null && E.userMessageIds.includes(N.userMessageId)))), m = d && ["thinking", "steering", "queued", "stopping"].includes(d.phase) || a.some((E) => E.delivery === "accepted" && E.executionVersion === null && x?.userMessageIds.includes(E.userMessageId));
650
+ x && m && !b && (!d || !["thinking", "steering", "queued", "stopping"].includes(d.phase) || Tt(d).every((E) => x.userMessageIds.includes(E))) && (S = "stopping"), x && !m && !b && a.some((E) => E.cancelled && E.executionVersion === null && x.userMessageIds.includes(E.userMessageId)) && (S = a.some((E) => x.userMessageIds.includes(E.userMessageId) && ["sending", "uncertain"].includes(E.delivery)) ? "stopping" : "stopped");
651
+ const _ = ["thinking", "steering", "queued"].includes(S), I = t.stops[n] ?? x, k = I?.userMessageIds.filter((E) => !["completed", "failed"].includes(o?.executionByUserMessage[E]?.phase ?? "")) ?? [], T = k.some((E) => {
652
652
  const N = a.find((ue) => ue.userMessageId === E);
653
653
  return !Object.values(t.operations).some((ue) => ue.command.type === "run.stop" && ue.command.payload.expectedUserMessageId === E && ue.phase === "done") && (N?.executionVersion === null && ["sending", "uncertain", "accepted"].includes(N.delivery) || !!(d && Tt(d).includes(E) && ["thinking", "steering", "queued", "stopping"].includes(d.phase)));
654
- }), q = d?.user_message_ids ?? [], U = w || b ? g?.userMessageId ?? null : q[q.length - 1] ?? null, P = u.find((E) => E.userMessageId === U), z = _ ? [...P?.activityIds ?? []].reverse().find((E) => l[E] === "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.
654
+ }), q = d?.user_message_ids ?? [], U = b || w ? g?.userMessageId ?? null : q[q.length - 1] ?? null, P = u.find((E) => E.userMessageId === U), z = _ ? [...P?.activityIds ?? []].reverse().find((E) => l[E] === "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.
655
655
  (!o?.execution || o.execution.phase === "idle" && o.execution.user_message_ids.length === 0) && Object.values(t.operations).some((E) => E.conversationScopeId === n && E.phase === "done" && ["runtime.warmup", "attachment.prepare"].includes(E.command.type) && !E.command.payload.sessionId && E.result?.sessionId === s);
656
656
  return Ke({
657
657
  historyRefreshFailure: o?.historyRefreshFailure ?? null,
@@ -668,9 +668,9 @@ function fn(t, e, n) {
668
668
  removedItems: o?.removedItems ?? {},
669
669
  streamStates: l,
670
670
  preparation: o?.preparation ?? null,
671
- stop: S ? { ...S, userMessageIds: k, pending: T } : null,
671
+ stop: I ? { ...I, userMessageIds: k, pending: T } : null,
672
672
  segments: u.map((E, N) => ({ ...E, collapsed: _ ? E.userMessageId !== U : N < u.length - 1 || E.activityIds.length > 0 })),
673
- activity: { phase: I, activeItemId: z, userMessageId: U, executionKey: JSON.stringify([...Tt(d)].sort()) },
673
+ activity: { phase: S, activeItemId: z, userMessageId: U, executionKey: JSON.stringify([...Tt(d)].sort()) },
674
674
  // Staging transfers the immutable input to the core. Waiting for backend acceptance leaves
675
675
  // the same submitted text in the optimistic transcript and composer during delivery.
676
676
  receipts: i.filter((E) => !E.cancelled && e.clients[E.clientScopeId] === n).map((E) => ({ viewId: E.viewId, userMessageId: E.userMessageId, acceptedRendererRevision: E.rendererRevision }))
@@ -766,7 +766,7 @@ function dh(t, e, n) {
766
766
  if (!n.sessionId || !u || u.sessionId !== n.sessionId || !Md(t, n.conversationScopeId, c) || t.features.refreshRequired && !u.shown[c] || i.profile === "main_web_chat" && !t.interactions.bridgeReady && !u.shown[c]) continue;
767
767
  const d = Di(t, c), h = t.interactions.preferencePrompts[c], f = t.interactions.deviceFacts[c], y = `preference:${c}`, g = d === null;
768
768
  if (d === !1 || t.features.desiredPreferences[c] === !1 || g && h.snoozedUntil && Date.parse(h.snoozedUntil) > a || !g && (f.permission !== "missing" || f.snoozedUntil && Date.parse(f.snoozedUntil) > a)) continue;
769
- const w = Object.values(t.interactions.devicePending).some((x) => x.feature === c), b = r([y, `preferenceSnooze:${c}`, `preferenceAcknowledge:${c}`]), I = b.error ?? t.interactions.deviceErrors[c] ?? (u.shown[c] && t.interactions.bridgeError ? { code: "connection_interrupted", message: t.interactions.bridgeError, retryable: !0 } : null);
769
+ const b = Object.values(t.interactions.devicePending).some((x) => x.feature === c), w = r([y, `preferenceSnooze:${c}`, `preferenceAcknowledge:${c}`]), S = w.error ?? t.interactions.deviceErrors[c] ?? (u.shown[c] && t.interactions.bridgeError ? { code: "connection_interrupted", message: t.interactions.bridgeError, retryable: !0 } : null);
770
770
  o.push({
771
771
  id: y,
772
772
  category: g ? "preference" : "permission",
@@ -777,8 +777,8 @@ function dh(t, e, n) {
777
777
  sourceVersion: u.generation,
778
778
  decisionRevision: h.revision,
779
779
  actions: g ? ["enable", "not_now", "dont_enable"] : ["allow", "not_now"],
780
- status: w ? "pending" : I ? "error" : b.status,
781
- error: I,
780
+ status: b ? "pending" : S ? "error" : w.status,
781
+ error: S,
782
782
  payload: { feature: c, openingGeneration: u.generation },
783
783
  nextEligibleAt: g ? h.snoozedUntil : f.snoozedUntil
784
784
  });
@@ -850,8 +850,8 @@ function uh(t, e, n, i) {
850
850
  if (e.type === "stage7.act") {
851
851
  const u = s.interactions.actions[e.requestId];
852
852
  if (u) {
853
- const g = s.interactions.welcome[e.interactionId], w = g?.category === "morning_report" ? g.tasks[e.taskIndex ?? 0] : g?.text;
854
- if (u.interactionId !== e.interactionId || u.action !== e.action || u.expectedRevision !== e.expectedRevision || u.sourceVersion !== (e.sourceVersion ?? null) || u.clientScopeId !== e.clientScopeId || u.taskIndex !== (e.taskIndex ?? null) || (u.operation.kind === "run" || u.operation.kind === "edit") && u.operation.text !== w) throw new Error("Action request changed.");
853
+ const g = s.interactions.welcome[e.interactionId], b = g?.category === "morning_report" ? g.tasks[e.taskIndex ?? 0] : g?.text;
854
+ if (u.interactionId !== e.interactionId || u.action !== e.action || u.expectedRevision !== e.expectedRevision || u.sourceVersion !== (e.sourceVersion ?? null) || u.clientScopeId !== e.clientScopeId || u.taskIndex !== (e.taskIndex ?? null) || (u.operation.kind === "run" || u.operation.kind === "edit") && u.operation.text !== b) throw new Error("Action request changed.");
855
855
  return { state: s, effects: o, command: null };
856
856
  }
857
857
  if (e.action === "feedback") {
@@ -877,8 +877,8 @@ function uh(t, e, n, i) {
877
877
  const g = d.payload.feature;
878
878
  if (g !== "notifications" && g !== "tab_grouping") throw new Error("Missing preference feature.");
879
879
  if (s = { ...s, interactions: { ...s.interactions, promptActions: { ...s.interactions.promptActions, [e.requestId]: { scope: i.clients[e.clientScopeId], openingGeneration: d.sourceVersion, expectedRevision: e.expectedRevision, feature: g, action: e.action } } } }, d.category === "permission") return { state: s, effects: o, command: { type: "stage7.permission", authority: a, now: e.now, requestId: e.requestId, feature: g, action: e.action, settings: !1 } };
880
- const w = e.action === "not_now" ? { kind: "preferenceSnooze", feature: g, expectedRevision: e.expectedRevision } : { kind: "preference", feature: g, enabled: e.action === "enable" };
881
- return { state: s, effects: o, command: { type: "stage7.mutate", authority: a, now: e.now, requestId: e.requestId, mutation: w } };
880
+ const b = e.action === "not_now" ? { kind: "preferenceSnooze", feature: g, expectedRevision: e.expectedRevision } : { kind: "preference", feature: g, enabled: e.action === "enable" };
881
+ return { state: s, effects: o, command: { type: "stage7.mutate", authority: a, now: e.now, requestId: e.requestId, mutation: b } };
882
882
  }
883
883
  if (["not_now", "never", "snooze"].includes(e.action)) {
884
884
  const g = d.category === "morning_report" ? { kind: "decision", category: "morning_report", action: "snooze", promptKey: d.id, expectedRevision: e.expectedRevision } : { kind: "decision", category: "proactive_suggestion", action: e.action, promptKey: s.interactions.welcome[d.id].sourceSuggestionId ?? d.id, expectedRevision: e.expectedRevision };
@@ -899,7 +899,7 @@ function uh(t, e, n, i) {
899
899
  f = { kind: "saveSharing", interactionId: d.id, expectedRevision: e.expectedRevision };
900
900
  } else if (e.action === "copy" || e.action === "share") {
901
901
  if (h?.payload.kind !== "sharing") throw new Error("Missing sharing source.");
902
- const g = Object.values(s.interactions.actions).find((w) => w.interactionId === d.id && w.step === "perform" && w.status === "error" && (w.operation.kind === "copy" || w.operation.kind === "share"));
902
+ const g = Object.values(s.interactions.actions).find((b) => b.interactionId === d.id && b.step === "perform" && b.status === "error" && (b.operation.kind === "copy" || b.operation.kind === "share"));
903
903
  if (g && g.error?.code !== "interaction_not_started") throw new Error("The previous sharing action has an uncertain outcome.");
904
904
  f = { kind: e.action, interactionId: d.id, variant: h.payload.variant, ...e.sharePlatform ? { platform: e.sharePlatform } : {} };
905
905
  } else if (e.action === "connect") {
@@ -913,15 +913,15 @@ function uh(t, e, n, i) {
913
913
  if (g?.status === "error" && g.error?.code !== "interaction_not_started") throw new Error("Reconcile the previous action before trying again.");
914
914
  if (e.action !== "edit") {
915
915
  if (a.profile.startsWith("extension_") && !e.origin) throw new Error("Task submission requires the current page origin.");
916
- const I = Dd(s.account, "send_message", e.origin ?? null);
917
- if (!I.allowed) throw new Error(`Task submission unavailable: ${I.reason}.`);
916
+ const S = Dd(s.account, "send_message", e.origin ?? null);
917
+ if (!S.allowed) throw new Error(`Task submission unavailable: ${S.reason}.`);
918
918
  }
919
- const w = s.interactions.welcome[d.id], b = w.category === "morning_report" ? w.tasks[e.taskIndex ?? 0] : w.text;
920
- if (!b) throw new Error("Missing selected task.");
919
+ const b = s.interactions.welcome[d.id], w = b.category === "morning_report" ? b.tasks[e.taskIndex ?? 0] : b.text;
920
+ if (!w) throw new Error("Missing selected task.");
921
921
  f = {
922
922
  kind: e.action === "edit" ? "edit" : "run",
923
923
  interactionId: d.id,
924
- text: b,
924
+ text: w,
925
925
  clientScopeId: e.clientScopeId,
926
926
  conversationScopeId: i.clients[e.clientScopeId],
927
927
  submissionId: e.requestId
@@ -1010,14 +1010,14 @@ function ph(t, e, n, i) {
1010
1010
  if (y.fingerprint !== g) throw new Error("Request ID was reused with a different payload.");
1011
1011
  return { state: s, effects: o };
1012
1012
  }
1013
- const w = l(h), b = (s.appearanceEpochs[h] ?? 0) + 1, I = { ...s.pending };
1014
- for (const [x, m] of Object.entries(I)) {
1013
+ const b = l(h), w = (s.appearanceEpochs[h] ?? 0) + 1, S = { ...s.pending };
1014
+ for (const [x, m] of Object.entries(S)) {
1015
1015
  if (m.mode !== "query" || !c(m.operation, h)) continue;
1016
- delete I[x];
1017
- const _ = r("query", m.requestId, b);
1018
- I[_] = { ...m, effectId: _, status: "queued" };
1016
+ delete S[x];
1017
+ const _ = r("query", m.requestId, w);
1018
+ S[_] = { ...m, effectId: _, status: "queued" };
1019
1019
  }
1020
- I[f] = {
1020
+ S[f] = {
1021
1021
  requestId: n.requestId,
1022
1022
  effectId: f,
1023
1023
  fingerprint: g,
@@ -1026,10 +1026,10 @@ function ph(t, e, n, i) {
1026
1026
  operation: d,
1027
1027
  startedAt: n.now,
1028
1028
  mode: "mutation",
1029
- status: w ? "queued" : "pending",
1029
+ status: b ? "queued" : "pending",
1030
1030
  error: null,
1031
1031
  result: null
1032
- }, a({ pending: I, appearanceEpochs: { ...s.appearanceEpochs, [h]: b } }), w || o.push({ kind: "stage7.mutate", id: f, input: { authority: e, requestId: n.requestId, mutation: d } });
1032
+ }, a({ pending: S, appearanceEpochs: { ...s.appearanceEpochs, [h]: w } }), b || o.push({ kind: "stage7.mutate", id: f, input: { authority: e, requestId: n.requestId, mutation: d } });
1033
1033
  } else if (n.type === "effect.completed" || n.type === "effect.failed") {
1034
1034
  const d = s.pending[n.effectId];
1035
1035
  if (!d || d.status !== "pending" || !("origin" in d.operation)) return { state: s, effects: o };
@@ -1040,19 +1040,19 @@ function ph(t, e, n, i) {
1040
1040
  const y = { ...s.pending }, g = { ...s.queries };
1041
1041
  if (d.mode === "query") {
1042
1042
  delete y[n.effectId];
1043
- const w = g[d.key];
1044
- w?.requestId === d.requestId && (g[d.key] = n.type === "effect.failed" ? { ...w, status: "error", error: n.error, requestId: null } : { ...w, status: "ready", data: f, error: null, requestId: null, updatedAt: n.output.completedAt });
1043
+ const b = g[d.key];
1044
+ b?.requestId === d.requestId && (g[d.key] = n.type === "effect.failed" ? { ...b, status: "error", error: n.error, requestId: null } : { ...b, status: "ready", data: f, error: null, requestId: null, updatedAt: n.output.completedAt });
1045
1045
  } else if (y[n.effectId] = { ...d, status: f ? "done" : "error", result: f, error: n.type === "effect.failed" ? n.error : null }, f && n.type === "effect.completed") {
1046
- for (const [w, b] of Object.entries(s.appearanceQueries))
1047
- b.origin === h && (g[w] = { ...g[w], status: "ready", data: f, requestId: null, error: null, updatedAt: n.output.completedAt });
1048
- for (const [w, b] of Object.entries(y)) b.mode === "query" && c(b.operation, h) && delete y[w];
1046
+ for (const [b, w] of Object.entries(s.appearanceQueries))
1047
+ w.origin === h && (g[b] = { ...g[b], status: "ready", data: f, requestId: null, error: null, updatedAt: n.output.completedAt });
1048
+ for (const [b, w] of Object.entries(y)) w.mode === "query" && c(w.operation, h) && delete y[b];
1049
1049
  } else if (n.type === "effect.failed")
1050
- for (const [w, b] of Object.entries(y)) b.mode === "mutation" && b.status === "queued" && c(b.operation, h) && (y[w] = { ...b, status: "error", error: { code: "appearance_write_cancelled", message: "Refresh appearance before saving again.", retryable: !1 } });
1050
+ for (const [b, w] of Object.entries(y)) w.mode === "mutation" && w.status === "queued" && c(w.operation, h) && (y[b] = { ...w, status: "error", error: { code: "appearance_write_cancelled", message: "Refresh appearance before saving again.", retryable: !1 } });
1051
1051
  if (a({ pending: y, queries: g }), d.mode === "mutation") {
1052
- const w = Object.values(s.pending).find((b) => b.mode === "mutation" && b.status === "queued" && c(b.operation, h));
1053
- if (w && (w.operation.kind === "sampleStyle" || w.operation.kind === "saveStyle" || w.operation.kind === "scribble" || w.operation.kind === "deleteStyle"))
1054
- a({ pending: { ...s.pending, [w.effectId]: { ...w, status: "pending" } } }), o.push({ kind: "stage7.mutate", id: w.effectId, input: { authority: e, requestId: w.requestId, mutation: w.operation } });
1055
- else for (const [b, I] of Object.entries(s.pending)) I.mode === "query" && I.status === "queued" && c(I.operation, h) && u(b);
1052
+ const b = Object.values(s.pending).find((w) => w.mode === "mutation" && w.status === "queued" && c(w.operation, h));
1053
+ if (b && (b.operation.kind === "sampleStyle" || b.operation.kind === "saveStyle" || b.operation.kind === "scribble" || b.operation.kind === "deleteStyle"))
1054
+ a({ pending: { ...s.pending, [b.effectId]: { ...b, status: "pending" } } }), o.push({ kind: "stage7.mutate", id: b.effectId, input: { authority: e, requestId: b.requestId, mutation: b.operation } });
1055
+ else for (const [w, S] of Object.entries(s.pending)) S.mode === "query" && S.status === "queued" && c(S.operation, h) && u(w);
1056
1056
  }
1057
1057
  }
1058
1058
  return { state: s, effects: o };
@@ -1175,8 +1175,8 @@ function Gr(t, e, n) {
1175
1175
  if (e.type === "stage7.retire") return { state: { account: Kr(), features: Vr(e.now), interactions: Wr() }, effects: s };
1176
1176
  "now" in e && o({ now: e.now });
1177
1177
  const c = (m, _) => {
1178
- const S = { ...i.features.contextObservers }, k = S[m];
1179
- if (_ === null ? delete S[m] : S[m] = Nt(r, { kind: "originContext", clientScopeId: m, origin: _, pageUrl: "" }), o({ contextObservers: S }), !k || Object.values(S).includes(k)) return;
1178
+ const I = { ...i.features.contextObservers }, k = I[m];
1179
+ if (_ === null ? delete I[m] : I[m] = Nt(r, { kind: "originContext", clientScopeId: m, origin: _, pageUrl: "" }), o({ contextObservers: I }), !k || Object.values(I).includes(k)) return;
1180
1180
  const T = { ...i.features.queries }, q = { ...i.features.polls }, U = { ...i.features.contextReads }, P = { ...i.features.originContextQueries }, z = { ...i.features.pending }, B = P[k]?.origin, E = { ...i.features.contextRunOrigins };
1181
1181
  for (const [N, Y] of Object.entries(E)) Y === B && delete E[N];
1182
1182
  delete T[k], delete q[k], delete U[k], delete P[k];
@@ -1199,15 +1199,15 @@ function Gr(t, e, n) {
1199
1199
  const _ = Gr(m.state, m.command, n);
1200
1200
  return { state: _.state, effects: [...m.effects, ..._.effects] };
1201
1201
  }
1202
- const u = (m, _, S) => {
1202
+ const u = (m, _, I) => {
1203
1203
  const k = m === "notifications" ? "canRequestNotificationPermission" : "canGroupSessionTabs";
1204
1204
  if (!He(r.profile, k) || Di(i, m) !== !0 || i.features.desiredPreferences[m] === !1 || Object.values(i.interactions.devicePending).some((U) => U.feature === m && (_ === "check" || U.action !== "check"))) return;
1205
- const T = Pn(r, "device", S), q = { ...i.interactions.deviceErrors };
1206
- delete q[m], a({ deviceErrors: q, devicePending: { ...i.interactions.devicePending, [T]: { feature: m, requestId: S, generation: r.generation, desired: !0, action: _ } } }), s.push({ kind: "stage7.device", id: T, input: { authority: r, requestId: S, feature: m, action: _, now: i.features.now } });
1205
+ const T = Pn(r, "device", I), q = { ...i.interactions.deviceErrors };
1206
+ delete q[m], a({ deviceErrors: q, devicePending: { ...i.interactions.devicePending, [T]: { feature: m, requestId: I, generation: r.generation, desired: !0, action: _ } } }), s.push({ kind: "stage7.device", id: T, input: { authority: r, requestId: I, feature: m, action: _, now: i.features.now } });
1207
1207
  }, d = (m, _) => {
1208
- const S = _ ? i.interactions.promptActions[_.replace(/:ack$/, "")] : void 0, k = { ...i.interactions.openings };
1208
+ const I = _ ? i.interactions.promptActions[_.replace(/:ack$/, "")] : void 0, k = { ...i.interactions.openings };
1209
1209
  for (const [T, q] of Object.entries(k)) {
1210
- if (S?.scope === T && S.openingGeneration === q.generation && ["enable", "allow"].includes(S.action)) continue;
1210
+ if (I?.scope === T && I.openingGeneration === q.generation && ["enable", "allow"].includes(I.action)) continue;
1211
1211
  const U = { ...q.shown };
1212
1212
  delete U[m], k[T] = {
1213
1213
  ...q,
@@ -1218,25 +1218,25 @@ function Gr(t, e, n) {
1218
1218
  a({ openings: k });
1219
1219
  }, h = (m, _ = null) => {
1220
1220
  if (m.kind === "preferences" && i.account.preferences && m.value.preferencesVersion > i.account.preferences.preferencesVersion)
1221
- for (const S of ["notifications", "tab_grouping"]) {
1222
- const k = S === "notifications" ? "taskNotificationsEnabled" : "tabGroupingEnabled";
1223
- m.value[k] !== i.account.preferences[k] && d(S, _);
1221
+ for (const I of ["notifications", "tab_grouping"]) {
1222
+ const k = I === "notifications" ? "taskNotificationsEnabled" : "tabGroupingEnabled";
1223
+ m.value[k] !== i.account.preferences[k] && d(I, _);
1224
1224
  }
1225
1225
  if (m.kind === "preferencePrompts" || m.kind === "preferencePrompt")
1226
- for (const S of ["notifications", "tab_grouping"]) {
1227
- const k = m.kind === "preferencePrompts" ? m.value[S] : m.feature === S ? m.value : null;
1228
- k && k.revision > i.interactions.preferencePrompts[S].revision && d(S, k.requestId);
1226
+ for (const I of ["notifications", "tab_grouping"]) {
1227
+ const k = m.kind === "preferencePrompts" ? m.value[I] : m.feature === I ? m.value : null;
1228
+ k && k.revision > i.interactions.preferencePrompts[I].revision && d(I, k.requestId);
1229
1229
  }
1230
1230
  m.kind === "preferences" && (i = { ...i, account: hh(i.account, m.value) }), m.kind === "preferencePrompts" && (i = { ...i, interactions: nl(i.interactions, m.value) }), m.kind === "preferencePrompt" && (i = { ...i, interactions: nl(i.interactions, { ...i.interactions.preferencePrompts, [m.feature]: m.value }) }), m.kind === "decisions" && (i = { ...i, interactions: Qo(i.interactions, m.decisions) }), m.kind === "decision" && (i = { ...i, interactions: Qo(i.interactions, [m.value]) });
1231
1231
  }, f = (m, _) => {
1232
- const S = i.interactions.deviceFacts[m];
1233
- _.revision <= S.revision || (Di(i, m) === !0 && (_.permission === "granted" && S.permission !== "granted" || _.snoozedUntil && _.snoozedUntil !== S.snoozedUntil) && d(m, null), a({ deviceFacts: { ...i.interactions.deviceFacts, [m]: _ } }));
1234
- }, y = (m, _, S = !1) => {
1232
+ const I = i.interactions.deviceFacts[m];
1233
+ _.revision <= I.revision || (Di(i, m) === !0 && (_.permission === "granted" && I.permission !== "granted" || _.snoozedUntil && _.snoozedUntil !== I.snoozedUntil) && d(m, null), a({ deviceFacts: { ...i.interactions.deviceFacts, [m]: _ } }));
1234
+ }, y = (m, _, I = !1) => {
1235
1235
  ji(r, m);
1236
1236
  const k = Nt(r, m), T = Pn(r, "query", _);
1237
1237
  if (m.kind === "originContext") {
1238
1238
  const z = i.features.queries[k], B = i.features.contextReads[k];
1239
- if (o({ originContextQueries: { ...i.features.originContextQueries, [k]: m } }), !S && (z?.status === "ready" || z?.status === "error") && B && (i.features.now - B.settledAt < 3e4 || z.error && !z.error.retryable && z.error.code !== "runtime_error")) return;
1239
+ if (o({ originContextQueries: { ...i.features.originContextQueries, [k]: 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;
1240
1240
  }
1241
1241
  const q = i.features.pending[T];
1242
1242
  if (q && q.fingerprint !== JSON.stringify(m)) throw new Error("Query request ID changed payload.");
@@ -1254,12 +1254,12 @@ function Gr(t, e, n) {
1254
1254
  error: null,
1255
1255
  result: null
1256
1256
  } } }), m.kind === "account" && (i = { ...i, account: { ...i.account, query: ei(i.account.query, { key: k, requestId: Et(_), mode: "replace" }) } }), s.push({ kind: "stage7.query", id: T, input: { authority: r, requestId: _, query: m } });
1257
- }, g = (m, _, S = !1) => {
1257
+ }, g = (m, _, I = !1) => {
1258
1258
  if (ji(r, m), m.kind === "report" && !i.account.query.data?.user?.isSuperuser) throw new Error("Chat reporting requires superuser access.");
1259
1259
  const k = Pn(r, "mutate", _), T = JSON.stringify(m), q = i.features.pending[k];
1260
1260
  if (q) {
1261
1261
  if (q.fingerprint !== T) throw new Error("Request ID was reused with a different payload.");
1262
- if (!S || q.status !== "error") return;
1262
+ if (!I || q.status !== "error") return;
1263
1263
  if (!["decision", "preferenceSnooze", "preferenceAcknowledge"].includes(m.kind)) throw new Error("This operation cannot be replayed automatically.");
1264
1264
  if (["conflict", "409"].includes(q.error?.code ?? "")) throw new Error("Refresh the conflicting decision before making another choice.");
1265
1265
  }
@@ -1288,24 +1288,24 @@ function Gr(t, e, n) {
1288
1288
  o({ queries: { ...i.features.queries, [P]: ei(z, { key: P, requestId: Et(_), mode: "replace" }) } });
1289
1289
  }
1290
1290
  o({ pending: { ...i.features.pending, [k]: { requestId: _, effectId: k, fingerprint: T, key: sl(m), generation: r.generation, operation: m, mode: "mutation", status: "pending", error: null, result: null } } }), s.push({ kind: "stage7.mutate", id: k, input: { authority: r, requestId: _, mutation: m } });
1291
- }, w = (m) => {
1291
+ }, b = (m) => {
1292
1292
  if (!(!He(r.profile, "canManagePreferences") || i.features.refreshBatch)) {
1293
1293
  for (const _ of Object.values(i.features.pending))
1294
1294
  _.mode === "mutation" && _.operation.kind === "preferenceAcknowledge" && _.status === "error" && !["conflict", "409"].includes(_.error?.code ?? "") && g(_.operation, _.requestId, !0);
1295
1295
  for (const _ of ["account", "preferences", "preferencePrompts", "decisions"])
1296
- Object.values(i.features.pending).some((S) => S.mode === "query" && S.status === "pending" && S.operation.kind === _) || y({ kind: _ }, `${m}:${_}`);
1296
+ Object.values(i.features.pending).some((I) => I.mode === "query" && I.status === "pending" && I.operation.kind === _) || y({ kind: _ }, `${m}:${_}`);
1297
1297
  o({ refreshAt: null, refreshBatch: { pending: Object.values(i.features.pending).filter((_) => _.mode === "query" && _.status === "pending" && ["account", "preferences", "preferencePrompts", "decisions"].includes(_.operation.kind)).map((_) => _.effectId), failed: !1 } });
1298
1298
  }
1299
- }, b = (m, _) => {
1300
- const S = i.features.refreshBatch;
1301
- if (S?.pending.includes(m)) {
1302
- const k = S.pending.filter((q) => q !== m), T = S.failed || _;
1299
+ }, w = (m, _) => {
1300
+ const I = i.features.refreshBatch;
1301
+ if (I?.pending.includes(m)) {
1302
+ const k = I.pending.filter((q) => q !== m), T = I.failed || _;
1303
1303
  if (k.length) o({ refreshBatch: { pending: k, failed: T } });
1304
1304
  else {
1305
1305
  const q = T ? i.features.failures + 1 : 0;
1306
1306
  o({ refreshBatch: null, failures: q, refreshAt: i.features.now + Math.min(6e4 * 2 ** q, 9e5) });
1307
1307
  const U = i.features.refreshQueuedRequestId;
1308
- U && (o({ refreshQueuedRequestId: null }), w(U));
1308
+ U && (o({ refreshQueuedRequestId: null }), b(U));
1309
1309
  }
1310
1310
  }
1311
1311
  };
@@ -1313,20 +1313,20 @@ function Gr(t, e, n) {
1313
1313
  case "stage7.account_refusal": {
1314
1314
  const m = Wi(void 0, e.code);
1315
1315
  if (m.allowed) return { state: i, effects: s };
1316
- const _ = { ...i.features.queries }, S = { ...i.features.pending }, k = [];
1317
- for (const [T, q] of Object.entries(S)) {
1316
+ const _ = { ...i.features.queries }, I = { ...i.features.pending }, k = [];
1317
+ for (const [T, q] of Object.entries(I)) {
1318
1318
  if (q.operation.kind !== "account" || q.status === "done" || q.status === "error") continue;
1319
1319
  const U = { code: e.code, message: "The backend refused account access. Refresh account status before retrying.", retryable: !0 };
1320
- S[T] = { ...q, status: "error", error: U }, k.push(T);
1320
+ I[T] = { ...q, status: "error", error: U }, k.push(T);
1321
1321
  const P = _[q.key];
1322
1322
  P && (_[q.key] = gs(P, { key: q.key, requestId: Et(q.requestId), error: U }));
1323
1323
  }
1324
- i = { ...i, features: { ...i.features, pending: S, queries: _ }, account: {
1324
+ i = { ...i, features: { ...i.features, pending: I, queries: _ }, account: {
1325
1325
  ...i.account,
1326
1326
  refusal: m,
1327
1327
  query: { ...i.account.query, requestId: null, status: i.account.query.data ? "ready" : "not_requested" }
1328
1328
  } };
1329
- for (const T of k) b(T, !0);
1329
+ for (const T of k) w(T, !0);
1330
1330
  break;
1331
1331
  }
1332
1332
  case "stage7.context_observe":
@@ -1354,7 +1354,7 @@ function Gr(t, e, n) {
1354
1354
  const m = Object.values(i.features.pending).some((_) => _.mode === "query" && _.status === "pending" && ["account", "preferences", "preferencePrompts", "decisions"].includes(_.operation.kind));
1355
1355
  o({ refreshRequired: !0, refreshQueuedRequestId: m ? `after:${e.requestId}` : i.features.refreshQueuedRequestId });
1356
1356
  }
1357
- w(e.requestId);
1357
+ b(e.requestId);
1358
1358
  }
1359
1359
  break;
1360
1360
  case "stage7.observe_work":
@@ -1365,7 +1365,7 @@ function Gr(t, e, n) {
1365
1365
  break;
1366
1366
  case "stage7.restore_prompt_openings": {
1367
1367
  if (!r.profile.startsWith("extension_")) throw new Error("Prompt restoration requires an extension opening checkpoint.");
1368
- const m = new Set(Object.values(n.directory.clients)), _ = Object.fromEntries(Object.entries(e.checkpoint.openings).filter(([S, k]) => m.has(S) && n.directory.selections[S]?.sessionId === k.sessionId));
1368
+ const m = new Set(Object.values(n.directory.clients)), _ = Object.fromEntries(Object.entries(e.checkpoint.openings).filter(([I, k]) => m.has(I) && n.directory.selections[I]?.sessionId === k.sessionId));
1369
1369
  a({ ...e.checkpoint, openings: _, openingGeneration: Math.max(i.interactions.openingGeneration, e.checkpoint.openingGeneration) });
1370
1370
  break;
1371
1371
  }
@@ -1379,16 +1379,16 @@ function Gr(t, e, n) {
1379
1379
  case "stage7.prompt_shown": {
1380
1380
  const m = n.directory.clients[e.clientScopeId], _ = i.interactions.openings[m];
1381
1381
  if (!_ || _.generation !== e.openingGeneration) break;
1382
- const S = Md(i, m, e.feature);
1383
- S && a({ openings: { ...i.interactions.openings, [m]: { ..._, shown: { ..._.shown, [e.feature]: S } } } });
1382
+ const I = Md(i, m, e.feature);
1383
+ I && a({ openings: { ...i.interactions.openings, [m]: { ..._, shown: { ..._.shown, [e.feature]: I } } } });
1384
1384
  break;
1385
1385
  }
1386
1386
  case "stage7.cross_tab": {
1387
1387
  a({ crossTabTurns: { ...i.interactions.crossTabTurns, [e.sessionId]: [.../* @__PURE__ */ new Set([...i.interactions.crossTabTurns[e.sessionId] ?? [], e.userMessageId])] } });
1388
1388
  const m = { ...i.interactions.openings };
1389
- for (const [_, S] of Object.entries(m)) {
1390
- const k = S.turns[e.userMessageId];
1391
- S.sessionId === e.sessionId && k && !k.tab_groupingSuppressed && (m[_] = { ...S, turns: { ...S.turns, [e.userMessageId]: { ...k, tab_grouping: !0 } } });
1389
+ for (const [_, I] of Object.entries(m)) {
1390
+ const k = I.turns[e.userMessageId];
1391
+ I.sessionId === e.sessionId && k && !k.tab_groupingSuppressed && (m[_] = { ...I, turns: { ...I.turns, [e.userMessageId]: { ...k, tab_grouping: !0 } } });
1392
1392
  }
1393
1393
  a({ openings: m });
1394
1394
  break;
@@ -1410,14 +1410,14 @@ function Gr(t, e, n) {
1410
1410
  case "stage7.device_hints": {
1411
1411
  if (r.profile !== "main_web_chat") throw new Error("Main-web hints unavailable.");
1412
1412
  const m = { ...i.interactions.deviceHints };
1413
- for (const [_, S] of Object.entries(e.hints)) m[_] = m[_] === !0 || S;
1413
+ for (const [_, I] of Object.entries(e.hints)) m[_] = m[_] === !0 || I;
1414
1414
  a({ deviceHints: m });
1415
1415
  break;
1416
1416
  }
1417
1417
  case "stage7.local_sharing": {
1418
1418
  const m = { ...i.interactions.localSharing };
1419
- for (const [_, S] of Object.entries(e.decisions))
1420
- (!m[_] || S.revision > m[_].revision) && (m[_] = S);
1419
+ for (const [_, I] of Object.entries(e.decisions))
1420
+ (!m[_] || I.revision > m[_].revision) && (m[_] = I);
1421
1421
  a({ localSharing: m, localSharingReady: !0 });
1422
1422
  break;
1423
1423
  }
@@ -1425,10 +1425,10 @@ function Gr(t, e, n) {
1425
1425
  const m = { ...i.interactions.sources };
1426
1426
  for (const _ of e.sources) {
1427
1427
  if (!Number.isSafeInteger(_.version) || _.version < 0) throw new Error("Invalid source version.");
1428
- const S = JSON.stringify([_.conversation_id, _.id]), k = m[S];
1428
+ const I = JSON.stringify([_.conversation_id, _.id]), k = m[I];
1429
1429
  if (!(k && k.version >= _.version)) {
1430
1430
  if (k && k.payload.kind !== _.payload.kind) throw new Error("Interaction source changed category.");
1431
- m[S] = {
1431
+ m[I] = {
1432
1432
  ..._,
1433
1433
  lifecycle: k?.lifecycle === "completed" ? "completed" : _.lifecycle,
1434
1434
  payload: k?.payload.kind === "sharing" && _.payload.kind === "sharing" ? { ..._.payload, variant: k.payload.variant } : _.payload
@@ -1444,8 +1444,8 @@ function Gr(t, e, n) {
1444
1444
  break;
1445
1445
  case "stage7.morning": {
1446
1446
  if (!e.text?.trim()) {
1447
- const S = { ...i.interactions.welcome };
1448
- delete S[e.id], a({ welcome: S });
1447
+ const I = { ...i.interactions.welcome };
1448
+ delete I[e.id], a({ welcome: I });
1449
1449
  break;
1450
1450
  }
1451
1451
  const m = e.signupAgeDays, _ = e.retained === !0 || e.localHour >= 5 && e.lastShownDate !== e.localDate && (m === 1 || m === 3 || m === 5 || m >= 7 && m % 7 === 0);
@@ -1469,40 +1469,40 @@ function Gr(t, e, n) {
1469
1469
  if (e.effectId !== i.features.timerId) break;
1470
1470
  if (o({ timerId: null, timerDeadline: null, schedulerError: e.type === "effect.failed" ? e.error : null }), e.type === "effect.completed") {
1471
1471
  o({ now: e.output.now }), i = Go(i, n.conversation, n.directory, e.output.now);
1472
- for (const [S, k] of Object.entries(i.features.polls)) {
1472
+ for (const [I, k] of Object.entries(i.features.polls)) {
1473
1473
  if (k.deadline > e.output.now) continue;
1474
- Object.values(i.features.pending).some((q) => q.mode === "query" && q.key === S && q.status === "pending") || y(k.query.kind === "originContext" ? { ...k.query, trigger: "poll" } : k.query, `poll:${S}:${e.output.now}`, !0);
1474
+ Object.values(i.features.pending).some((q) => q.mode === "query" && q.key === I && q.status === "pending") || y(k.query.kind === "originContext" ? { ...k.query, trigger: "poll" } : k.query, `poll:${I}:${e.output.now}`, !0);
1475
1475
  const T = { ...i.features.polls };
1476
- delete T[S], o({ polls: T });
1476
+ delete T[I], o({ polls: T });
1477
1477
  }
1478
- i.features.refreshAt !== null && e.output.now >= i.features.refreshAt && w(`timer:${e.output.now}`);
1478
+ i.features.refreshAt !== null && e.output.now >= i.features.refreshAt && b(`timer:${e.output.now}`);
1479
1479
  }
1480
1480
  break;
1481
1481
  }
1482
1482
  if (e.effectKind === "stage7.device") {
1483
- const S = i.interactions.devicePending[e.effectId];
1484
- if (!S) break;
1483
+ const I = i.interactions.devicePending[e.effectId];
1484
+ if (!I) break;
1485
1485
  const k = { ...i.interactions.devicePending };
1486
1486
  if (delete k[e.effectId], a({ devicePending: k }), e.type === "effect.completed") {
1487
- if (S.action !== "check" && i.interactions.promptActions[S.requestId] && !i.features.pending[Pn(r, "mutate", `${S.requestId}:ack`)]) {
1488
- const T = i.interactions.promptActions[S.requestId];
1489
- d(T.feature, S.requestId), g({
1487
+ if (I.action !== "check" && i.interactions.promptActions[I.requestId] && !i.features.pending[Pn(r, "mutate", `${I.requestId}:ack`)]) {
1488
+ const T = i.interactions.promptActions[I.requestId];
1489
+ d(T.feature, I.requestId), g({
1490
1490
  kind: "preferenceAcknowledge",
1491
1491
  feature: T.feature,
1492
1492
  action: T.action,
1493
1493
  expectedRevision: T.expectedRevision
1494
- }, `${S.requestId}:ack`);
1494
+ }, `${I.requestId}:ack`);
1495
1495
  }
1496
- f(S.feature, e.output.fact);
1497
- } else Di(i, S.feature) === !0 && i.features.desiredPreferences[S.feature] !== !1 && a({ deviceErrors: { ...i.interactions.deviceErrors, [S.feature]: e.error } });
1496
+ f(I.feature, e.output.fact);
1497
+ } else Di(i, I.feature) === !0 && i.features.desiredPreferences[I.feature] !== !1 && a({ deviceErrors: { ...i.interactions.deviceErrors, [I.feature]: e.error } });
1498
1498
  break;
1499
1499
  }
1500
1500
  const m = i.features.pending[e.effectId];
1501
1501
  if (!m || m.status !== "pending" || m.generation !== r.generation) break;
1502
1502
  const _ = e.type === "effect.failed";
1503
1503
  if (o({ pending: { ...i.features.pending, [e.effectId]: { ...m, status: _ ? "error" : "done", error: _ ? e.error : null, result: _ ? null : e.output.data } } }), m.mode === "query") {
1504
- const S = { ...i.features.pending };
1505
- delete S[e.effectId], o({ pending: S });
1504
+ const I = { ...i.features.pending };
1505
+ delete I[e.effectId], o({ pending: I });
1506
1506
  const k = i.features.queries[m.key];
1507
1507
  if (!k || k.requestId !== m.requestId) break;
1508
1508
  if (["originContext", "userContext", "contextRun"].includes(m.operation.kind)) {
@@ -1521,33 +1521,33 @@ function Gr(t, e, n) {
1521
1521
  } else if (!_)
1522
1522
  o({ now: e.output.completedAt }), h(e.output.data, m.requestId);
1523
1523
  else if (["conflict", "409"].includes(e.error.code)) {
1524
- const S = m.operation.kind === "decision" ? "decisions" : m.operation.kind === "preferenceSnooze" || m.operation.kind === "preferenceAcknowledge" ? "preferencePrompts" : "preferences";
1525
- y({ kind: S }, `conflict:${m.requestId}`);
1524
+ const I = m.operation.kind === "decision" ? "decisions" : m.operation.kind === "preferenceSnooze" || m.operation.kind === "preferenceAcknowledge" ? "preferencePrompts" : "preferences";
1525
+ y({ kind: I }, `conflict:${m.requestId}`);
1526
1526
  }
1527
1527
  if (m.mode === "mutation" && m.operation.kind === "decision") {
1528
- const S = { ...i.interactions.actions };
1529
- for (const [k, T] of Object.entries(S))
1530
- T.step === "persist" && m.requestId === `sharing:${k}` && (T.operation.kind === "copy" || T.operation.kind === "share") && (S[k] = { ...T, status: _ ? "error" : "done", error: _ ? e.error : null });
1531
- a({ actions: S });
1528
+ const I = { ...i.interactions.actions };
1529
+ for (const [k, T] of Object.entries(I))
1530
+ T.step === "persist" && m.requestId === `sharing:${k}` && (T.operation.kind === "copy" || T.operation.kind === "share") && (I[k] = { ...T, status: _ ? "error" : "done", error: _ ? e.error : null });
1531
+ a({ actions: I });
1532
1532
  }
1533
1533
  if (!_ && m.mode === "mutation" && m.operation.kind === "preference" && i.interactions.promptActions[m.requestId]) {
1534
- const S = i.interactions.promptActions[m.requestId];
1535
- d(S.feature, m.requestId), g({
1534
+ const I = i.interactions.promptActions[m.requestId];
1535
+ d(I.feature, m.requestId), g({
1536
1536
  kind: "preferenceAcknowledge",
1537
- feature: S.feature,
1538
- action: S.action,
1539
- expectedRevision: S.expectedRevision
1537
+ feature: I.feature,
1538
+ action: I.action,
1539
+ expectedRevision: I.expectedRevision
1540
1540
  }, `${m.requestId}:ack`);
1541
1541
  }
1542
- if (b(e.effectId, _), m.operation.kind === "generatePrompts") {
1543
- const S = { kind: "starterPrompts", ...m.operation.page, includeUserSuggestions: m.operation.includeUserSuggestions ?? !1 }, k = Nt(r, S), T = i.features.queries[k];
1542
+ if (w(e.effectId, _), m.operation.kind === "generatePrompts") {
1543
+ const I = { kind: "starterPrompts", ...m.operation.page, includeUserSuggestions: m.operation.includeUserSuggestions ?? !1 }, k = Nt(r, I), T = i.features.queries[k];
1544
1544
  T?.requestId === m.requestId && o({ queries: { ...i.features.queries, [k]: _ ? gs(T, { key: k, requestId: Et(m.requestId), error: e.error }) : Jo(T, { key: k, requestId: Et(m.requestId), data: e.output.data, cursor: null, updatedAt: e.output.completedAt }) } });
1545
1545
  }
1546
1546
  if (!_ && e.output.data.kind === "originContext") {
1547
- const S = e.output.data, k = m.operation.kind === "originContext" || m.operation.kind === "refreshContext" ? m.operation.origin : null;
1547
+ const I = e.output.data, k = m.operation.kind === "originContext" || m.operation.kind === "refreshContext" ? m.operation.origin : null;
1548
1548
  if (k) {
1549
- if (S.value.runId && ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(S.value.status))
1550
- o({ contextRunOrigins: { ...i.features.contextRunOrigins, [S.value.runId]: k } });
1549
+ if (I.value.runId && ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status))
1550
+ o({ contextRunOrigins: { ...i.features.contextRunOrigins, [I.value.runId]: k } });
1551
1551
  else {
1552
1552
  const T = { ...i.features.contextRunOrigins };
1553
1553
  for (const [q, U] of Object.entries(T)) U === k && delete T[q];
@@ -1557,19 +1557,19 @@ function Gr(t, e, n) {
1557
1557
  const T = { ...i.features.queries }, q = { ...i.features.pending }, U = { ...i.features.contextReads }, P = { ...i.features.polls };
1558
1558
  for (const [z, B] of Object.entries(i.features.originContextQueries))
1559
1559
  if (B.origin === k) {
1560
- T[z] = { ...T[z], data: S, status: "ready", error: null, requestId: null, updatedAt: e.output.completedAt }, U[z] = { settledAt: e.output.completedAt, failures: 0 }, delete P[z];
1560
+ T[z] = { ...T[z], data: I, status: "ready", error: null, requestId: null, updatedAt: e.output.completedAt }, U[z] = { settledAt: e.output.completedAt, failures: 0 }, delete P[z];
1561
1561
  for (const [E, N] of Object.entries(q)) N.mode === "query" && N.key === z && delete q[E];
1562
- ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(S.value.status) && (P[z] = { query: { ...B, kind: "originContext", trigger: "poll" }, deadline: i.features.now + 5e3 });
1562
+ ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status) && (P[z] = { query: { ...B, kind: "originContext", trigger: "poll" }, deadline: i.features.now + 5e3 });
1563
1563
  }
1564
1564
  o({ queries: T, pending: q, contextReads: U, polls: P });
1565
1565
  }
1566
1566
  }
1567
1567
  }
1568
1568
  if (!_ && e.output.data.kind === "contextRun" && !["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(e.output.data.value.status)) {
1569
- const S = e.output.data.value.runId, k = S ? i.features.contextRunOrigins[S] : null;
1570
- if (k && S) {
1569
+ const I = e.output.data.value.runId, k = I ? i.features.contextRunOrigins[I] : null;
1570
+ if (k && I) {
1571
1571
  const T = { ...i.features.contextRunOrigins };
1572
- delete T[S], o({ contextRunOrigins: T });
1572
+ delete T[I], o({ contextRunOrigins: T });
1573
1573
  for (const [q, U] of Object.entries(i.features.originContextQueries)) {
1574
1574
  if (U.origin !== k) continue;
1575
1575
  const P = { ...i.features.pending };
@@ -1579,44 +1579,44 @@ function Gr(t, e, n) {
1579
1579
  }
1580
1580
  }
1581
1581
  if (!_ && ["originContext", "userContext", "contextRun"].includes(e.output.data.kind)) {
1582
- const S = e.output.data;
1583
- if (S.kind === "originContext" || S.kind === "userContext" || S.kind === "contextRun") {
1584
- const k = S.kind === "originContext" ? m.mode === "query" && m.operation.kind === "originContext" && Object.values(i.features.contextObservers).includes(m.key) ? m.operation : null : S.kind === "userContext" ? { kind: "userContext" } : S.value.runId ? { kind: "contextRun", runId: S.value.runId } : null;
1585
- if (k && ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(S.value.status)) {
1582
+ const I = e.output.data;
1583
+ if (I.kind === "originContext" || I.kind === "userContext" || I.kind === "contextRun") {
1584
+ const k = I.kind === "originContext" ? m.mode === "query" && m.operation.kind === "originContext" && Object.values(i.features.contextObservers).includes(m.key) ? m.operation : null : I.kind === "userContext" ? { kind: "userContext" } : I.value.runId ? { kind: "contextRun", runId: I.value.runId } : null;
1585
+ if (k && ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status)) {
1586
1586
  const T = Nt(r, k);
1587
1587
  o({ polls: { ...i.features.polls, [T]: { query: k, deadline: i.features.now + 5e3 } } });
1588
1588
  }
1589
1589
  }
1590
1590
  }
1591
1591
  if (!_ && m.operation.kind === "stopContext")
1592
- for (const [S, k] of Object.entries(i.features.originContextQueries)) {
1593
- const T = i.features.queries[S]?.data;
1592
+ for (const [I, k] of Object.entries(i.features.originContextQueries)) {
1593
+ const T = i.features.queries[I]?.data;
1594
1594
  if (T?.kind === "originContext" && T.value.runId === m.operation.runId) {
1595
1595
  const q = { ...i.features.pending };
1596
- for (const [U, P] of Object.entries(q)) P.mode === "query" && P.key === S && delete q[U];
1597
- o({ pending: q }), y({ ...k, kind: "originContext" }, `context-stop:${m.requestId}:${S}`, !0);
1596
+ for (const [U, P] of Object.entries(q)) P.mode === "query" && P.key === I && delete q[U];
1597
+ o({ pending: q }), y({ ...k, kind: "originContext" }, `context-stop:${m.requestId}:${I}`, !0);
1598
1598
  }
1599
1599
  }
1600
1600
  if (_ && m.mode === "query" && ["originContext", "userContext", "contextRun"].includes(m.operation.kind) && e.error.retryable && (i.features.contextReads[m.key]?.failures ?? 0) <= 3) {
1601
- const S = m.operation, k = Nt(r, S);
1602
- o({ polls: { ...i.features.polls, [k]: { query: S, deadline: i.features.now + 5e3 * (i.features.contextReads[m.key]?.failures ?? 1) } } });
1601
+ const I = m.operation, k = Nt(r, I);
1602
+ o({ polls: { ...i.features.polls, [k]: { query: I, deadline: i.features.now + 5e3 * (i.features.contextReads[m.key]?.failures ?? 1) } } });
1603
1603
  }
1604
1604
  if (m.operation.kind === "preference") {
1605
- const S = m.operation.feature, k = i.features.queuedPreferences[S];
1605
+ const I = m.operation.feature, k = i.features.queuedPreferences[I];
1606
1606
  if (k) {
1607
1607
  const T = { ...i.features.queuedPreferences };
1608
- delete T[S], o({ queuedPreferences: T }), g({ kind: "preference", feature: S, enabled: k.enabled }, k.requestId);
1608
+ delete T[I], o({ queuedPreferences: T }), g({ kind: "preference", feature: I, enabled: k.enabled }, k.requestId);
1609
1609
  } else {
1610
1610
  const T = { ...i.features.desiredPreferences };
1611
- delete T[S], o({ desiredPreferences: T });
1611
+ delete T[I], o({ desiredPreferences: T });
1612
1612
  }
1613
1613
  }
1614
- if (!_ && e.output.data.kind === "preferences") for (const S of ["notifications", "tab_grouping"]) u(S, "check", `preference:${m.requestId}:${S}`);
1615
- i.features.refreshRequired && !i.features.refreshBatch && !i.features.refreshQueuedRequestId && ["account", "preferences", "preferencePrompts", "decisions"].every((S) => Object.values(i.features.queries).some((k) => k.data?.kind === S && k.status === "ready")) && o({ refreshRequired: !1 });
1614
+ if (!_ && e.output.data.kind === "preferences") for (const I of ["notifications", "tab_grouping"]) u(I, "check", `preference:${m.requestId}:${I}`);
1615
+ i.features.refreshRequired && !i.features.refreshBatch && !i.features.refreshQueuedRequestId && ["account", "preferences", "preferencePrompts", "decisions"].every((I) => Object.values(i.features.queries).some((k) => k.data?.kind === I && k.status === "ready")) && o({ refreshRequired: !1 });
1616
1616
  break;
1617
1617
  }
1618
1618
  }
1619
- const I = [
1619
+ const S = [
1620
1620
  i.features.refreshAt,
1621
1621
  ...Object.values(i.interactions.openings).flatMap((m) => Object.values(m.turns).filter((_) => _.active && !_.notifications && !_.notificationsSuppressed).map((_) => _.startedAt + 1e4)),
1622
1622
  ...Object.values(i.interactions.welcome).map((m) => m.eligible ? m.expiresAt ?? null : null),
@@ -1625,7 +1625,7 @@ function Gr(t, e, n) {
1625
1625
  ...Object.values(i.interactions.decisions).map((m) => m.nextEligibleAt ? Date.parse(m.nextEligibleAt) : null),
1626
1626
  ...Object.values(i.interactions.preferencePrompts).map((m) => m.snoozedUntil ? Date.parse(m.snoozedUntil) : null),
1627
1627
  ...Object.values(i.interactions.deviceFacts).map((m) => m.snoozedUntil ? Date.parse(m.snoozedUntil) : null)
1628
- ].filter((m) => m !== null && m > i.features.now), x = I.length ? Math.min(...I) : null;
1628
+ ].filter((m) => m !== null && m > i.features.now), x = S.length ? Math.min(...S) : null;
1629
1629
  if (x !== i.features.timerDeadline && !i.features.schedulerError) {
1630
1630
  const m = i.features.timerRevision + 1, _ = x === null ? null : Pn(r, "wait", `${m}:${x}`);
1631
1631
  o({ timerId: _, timerDeadline: x, timerRevision: m }), x !== null && _ && s.push({ kind: "stage7.wait", id: _, input: { authority: r, deadline: x } });
@@ -1995,10 +1995,10 @@ function $d(t, e, n) {
1995
1995
  h(Object.assign(new Error("Context observation retired."), { code: "observation_released", retryable: !1 }));
1996
1996
  return;
1997
1997
  }
1998
- const g = Object.values(y.features.pending).find((w) => w.requestId === o);
1998
+ const g = Object.values(y.features.pending).find((b) => b.requestId === o);
1999
1999
  if (!g && e.type === "stage7.query") {
2000
- const w = Jr(y, e.query);
2001
- w?.status === "error" ? h(w.error) : w?.status === "ready" && w.data && h(null, w.data);
2000
+ const b = Jr(y, e.query);
2001
+ b?.status === "error" ? h(b.error) : b?.status === "ready" && b.data && h(null, b.data);
2002
2002
  }
2003
2003
  g?.status === "error" ? h(g.error) : g?.status === "done" && h(null, g.result);
2004
2004
  };
@@ -2021,19 +2021,19 @@ async function Ih(t, e, n = crypto.randomUUID()) {
2021
2021
  if (!c) return;
2022
2022
  const g = t.engine.getState().slices;
2023
2023
  if (JSON.stringify(g.account.authority) !== JSON.stringify(i)) return h(new Error("Feature authority retired."));
2024
- const w = g.interactions.actions[o];
2025
- if (w) {
2026
- w.status === "error" ? h(w.error) : w.status === "done" && h();
2027
- return;
2028
- }
2029
- const b = Object.values(g.features.pending).find((x) => x.requestId === o);
2024
+ const b = g.interactions.actions[o];
2030
2025
  if (b) {
2031
2026
  b.status === "error" ? h(b.error) : b.status === "done" && h();
2032
2027
  return;
2033
2028
  }
2029
+ const w = Object.values(g.features.pending).find((x) => x.requestId === o);
2030
+ if (w) {
2031
+ w.status === "error" ? h(w.error) : w.status === "done" && h();
2032
+ return;
2033
+ }
2034
2034
  if (Object.values(g.interactions.devicePending).some((x) => x.requestId === o)) return;
2035
- const I = e.interactionId === "preference:notifications" ? "notifications" : e.interactionId === "preference:tab_grouping" ? "tab_grouping" : null;
2036
- h(I ? g.interactions.deviceErrors[I] : void 0);
2035
+ const S = e.interactionId === "preference:notifications" ? "notifications" : e.interactionId === "preference:tab_grouping" ? "tab_grouping" : null;
2036
+ h(S ? g.interactions.deviceErrors[S] : void 0);
2037
2037
  };
2038
2038
  u = t.engine.subscribe(f), d = t.onDispose(() => h(new Error("Feature runtime disposed.")));
2039
2039
  const y = s ? { type: "stage7.retry_action", authority: i, now: Date.now(), requestId: o } : { type: "stage7.act", authority: i, now: Date.now(), requestId: o, ...e, sourceVersion: e.expectedSourceVersion ?? null };
@@ -2191,28 +2191,38 @@ function Zr(t, e) {
2191
2191
  const n = e.clients[t.clientScopeId];
2192
2192
  return n === t.conversationScopeId || n === void 0 && t.sessionId !== null && (e.memberships[t.sessionId]?.members.length ?? 0) > 0;
2193
2193
  }
2194
- function ea(t, e) {
2195
- if (t.authorityId !== (e.authorityId ?? "") || t.generation !== e.generation)
2196
- return Ld(e.authorityId ?? void 0, e.generation);
2197
- const n = Object.fromEntries(Object.entries(t.pendingRestoration).filter(([s]) => !e.clients[s]));
2198
- let i = Object.keys(n).length === Object.keys(t.pendingRestoration).length ? t : { ...t, pendingRestoration: n };
2199
- for (const s of Object.values(t.submissions)) {
2200
- if (i.pendingRestoration[s.clientScopeId] === s.conversationScopeId) continue;
2201
- s.delivery !== "accepted" && !s.cancelled && !Zr(s, e) && (i = { ...i, submissions: { ...i.submissions, [s.userMessageId]: { ...s, cancelled: !0, cancellationReason: s.cancellationReason ?? "owner_lost" } } });
2202
- const o = e.selections[s.conversationScopeId]?.sessionId;
2203
- o && !i.submissions[s.userMessageId].cancelled && s.sessionId === null && (i = Xr(i, i.submissions[s.userMessageId], o));
2204
- }
2205
- for (const [s, o] of Object.entries(i.requests)) {
2206
- if ((e.memberships[o.sessionId]?.members.length ?? 0) > 0) continue;
2207
- const a = { ...i.requests };
2208
- delete a[s];
2209
- const r = i.sessions[o.sessionId], c = r.queries[o.lane];
2210
- i = { ...i, requests: a, sessions: { ...i.sessions, [r.sessionId]: {
2211
- ...r,
2212
- queries: { ...r.queries, [o.lane]: { ...c, requestId: null, status: c.data === null ? "not_requested" : "ready" } }
2194
+ function ea(t, e, n = !1) {
2195
+ if (t.authorityId !== (e.authorityId ?? "") || t.generation !== e.generation) {
2196
+ const o = Ld(e.authorityId ?? void 0, e.generation);
2197
+ if (!n || t.authorityId) return o;
2198
+ const a = Object.fromEntries(Object.entries(t.submissions).filter(([r, c]) => c.sessionId === null && !c.cancelled && t.deliveries[r]?.acceptance === "unissued" && e.clients[c.clientScopeId] === c.conversationScopeId));
2199
+ return {
2200
+ ...o,
2201
+ submissions: a,
2202
+ submissionOrder: t.submissionOrder.filter((r) => r in a),
2203
+ deliveries: Object.fromEntries(Object.keys(a).map((r) => [r, t.deliveries[r]])),
2204
+ effectsEnabled: t.effectsEnabled
2205
+ };
2206
+ }
2207
+ const i = Object.fromEntries(Object.entries(t.pendingRestoration).filter(([o]) => !e.clients[o]));
2208
+ let s = Object.keys(i).length === Object.keys(t.pendingRestoration).length ? t : { ...t, pendingRestoration: i };
2209
+ for (const o of Object.values(t.submissions)) {
2210
+ if (s.pendingRestoration[o.clientScopeId] === o.conversationScopeId) continue;
2211
+ o.delivery !== "accepted" && !o.cancelled && !Zr(o, e) && (s = { ...s, submissions: { ...s.submissions, [o.userMessageId]: { ...o, cancelled: !0, cancellationReason: o.cancellationReason ?? "owner_lost" } } });
2212
+ const a = e.selections[o.conversationScopeId]?.sessionId;
2213
+ a && !s.submissions[o.userMessageId].cancelled && o.sessionId === null && (s = Xr(s, s.submissions[o.userMessageId], a));
2214
+ }
2215
+ for (const [o, a] of Object.entries(s.requests)) {
2216
+ if ((e.memberships[a.sessionId]?.members.length ?? 0) > 0) continue;
2217
+ const r = { ...s.requests };
2218
+ delete r[o];
2219
+ const c = s.sessions[a.sessionId], l = c.queries[a.lane];
2220
+ s = { ...s, requests: r, sessions: { ...s.sessions, [c.sessionId]: {
2221
+ ...c,
2222
+ queries: { ...c.queries, [a.lane]: { ...l, requestId: null, status: l.data === null ? "not_requested" : "ready" } }
2213
2223
  } } };
2214
2224
  }
2215
- return Ke(i);
2225
+ return Ke(s);
2216
2226
  }
2217
2227
  function ys(t) {
2218
2228
  return JSON.stringify(t, (e, n) => n && typeof n == "object" && !Array.isArray(n) ? Object.fromEntries(Object.entries(n).sort(([i], [s]) => i.localeCompare(s))) : n);
@@ -2257,23 +2267,23 @@ function Ah(t, e, n, i) {
2257
2267
  else {
2258
2268
  const y = st(e.output.snapshot);
2259
2269
  r.lane === "current" && (c = { ...c, preparation: null });
2260
- const g = c.queries.history, w = r.lane === "current" && (g.status === "not_requested" || y.next_cursor !== null && !c.items[y.next_cursor]);
2270
+ const g = c.queries.history, b = r.lane === "current" && (g.status === "not_requested" || y.next_cursor !== null && !c.items[y.next_cursor]);
2261
2271
  if (y.conversation_id !== r.sessionId) throw new Error("Snapshot belongs to another conversation.");
2262
- for (const b of y.removed_items) c = tr(c, b);
2263
- for (const b of y.items) c = Qr(c, b);
2264
- for (const b of y.streams) c = Hd(c, b);
2272
+ for (const w of y.removed_items) c = tr(c, w);
2273
+ for (const w of y.items) c = Qr(c, w);
2274
+ for (const w of y.streams) c = Hd(c, w);
2265
2275
  if (c = Yr(c, y.execution), c = tr(c, {
2266
2276
  type: "conversation.follow_ups.updated",
2267
2277
  conversation_id: y.conversation_id,
2268
2278
  version: y.follow_ups_version,
2269
2279
  follow_ups: y.follow_ups
2270
- }), y.interactions.some((b) => b.conversation_id !== y.conversation_id)) throw new Error("Interaction belongs to another conversation.");
2280
+ }), y.interactions.some((w) => w.conversation_id !== y.conversation_id)) throw new Error("Interaction belongs to another conversation.");
2271
2281
  if (a = { authorityId: t.authorityId, generation: t.generation, sessionId: r.sessionId, sources: y.interactions }, y.execution.version === c.execution?.version)
2272
- for (const b of r.acceptedUserMessageIds) {
2273
- const I = f[b];
2274
- I.executionVersion === null && (f = {
2282
+ for (const w of r.acceptedUserMessageIds) {
2283
+ const S = f[w];
2284
+ S.executionVersion === null && (f = {
2275
2285
  ...f,
2276
- [b]: { ...I, executionVersion: y.execution.version }
2286
+ [w]: { ...S, executionVersion: y.execution.version }
2277
2287
  });
2278
2288
  }
2279
2289
  if (c = { ...c, queries: { ...c.queries, [r.lane]: {
@@ -2284,15 +2294,15 @@ function Ah(t, e, n, i) {
2284
2294
  data: Object.keys(c.items),
2285
2295
  cursor: y.next_cursor,
2286
2296
  updatedAt: e.output.updatedAt
2287
- } } }, w) {
2288
- for (const [b, I] of Object.entries(h))
2289
- I.sessionId === r.sessionId && I.lane === "history" && delete h[b];
2297
+ } } }, b) {
2298
+ for (const [w, S] of Object.entries(h))
2299
+ S.sessionId === r.sessionId && S.lane === "history" && delete h[w];
2290
2300
  c = { ...c, queries: { ...c.queries, history: { ...c.queries.current, key: g.key } } };
2291
2301
  }
2292
2302
  }
2293
2303
  s = { ...t, requests: h, submissions: f, sessions: { ...t.sessions, [c.sessionId]: c } };
2294
2304
  } else {
2295
- if (e.authorityId !== t.authorityId || e.generation !== t.generation || !n.authorityId) return { state: t, effects: o };
2305
+ if (e.authorityId !== t.authorityId || e.generation !== t.generation || !n.authorityId && !["conversation.submission_stage", "conversation.submission_delivery", "conversation.stop"].includes(e.type)) return { state: t, effects: o };
2296
2306
  switch (e.type) {
2297
2307
  case "conversation.proactive_edit": {
2298
2308
  if (!Object.values(n.clients).includes(e.conversationScopeId)) return { state: t, effects: o };
@@ -2315,24 +2325,24 @@ function Ah(t, e, n, i) {
2315
2325
  }
2316
2326
  case "conversation.submission_stage": {
2317
2327
  if (n.clients[e.clientScopeId] !== e.conversationScopeId) throw new Error("Submission selection has changed.");
2318
- const { type: r, authorityId: c, generation: l, prepareContext: u, ...d } = e, h = t.submissions[e.userMessageId];
2319
- if (h) {
2320
- const { contextPreparation: I, requestedModel: x, sessionId: m, delivery: _, cancelled: S, cancellationReason: k, error: T, executionVersion: q, ...U } = h;
2321
- if (ys(U) !== ys(d)) throw new Error("User-message identity cannot be reused with different input.");
2328
+ const { type: r, authorityId: c, generation: l, prepareContext: u, waitForAuthentication: d, ...h } = e, f = t.submissions[e.userMessageId];
2329
+ if (f) {
2330
+ const { contextPreparation: x, requestedModel: m, sessionId: _, delivery: I, cancelled: k, cancellationReason: T, error: q, executionVersion: U, ...P } = f;
2331
+ if (ys(P) !== ys(h)) throw new Error("User-message identity cannot be reused with different input.");
2322
2332
  return { state: t, effects: o };
2323
2333
  }
2324
- const f = n.selections[e.conversationScopeId], y = Object.values(t.submissions).find((I) => I.conversationScopeId === e.conversationScopeId && !I.cancelled && I.sessionId !== null), g = i.scopes[e.clientScopeId], w = {
2325
- ...st(d),
2334
+ const y = n.selections[e.conversationScopeId], g = Object.values(t.submissions).find((x) => x.conversationScopeId === e.conversationScopeId && !x.cancelled && x.sessionId !== null), b = i.scopes[e.clientScopeId], w = {
2335
+ ...st(h),
2326
2336
  ...u ? { contextPreparation: null } : {},
2327
2337
  // Extension staging can await page context after the picker has already changed.
2328
- requestedModel: g?.submissions[e.userMessageId] ? g.submissions[e.userMessageId].requestedModel ?? null : g ? Aa(g) ?? null : null,
2329
- sessionId: f.sessionId ?? y?.sessionId ?? null,
2330
- delivery: "staged",
2338
+ requestedModel: b?.submissions[e.userMessageId] ? b.submissions[e.userMessageId].requestedModel ?? null : b ? Aa(b) ?? null : null,
2339
+ sessionId: y.sessionId ?? g?.sessionId ?? null,
2340
+ delivery: d ? "failed" : "staged",
2331
2341
  cancelled: !1,
2332
- error: null,
2342
+ error: d ? { code: d, message: d === "unauthorized" ? "Open the Pluno login link, then return to Pluno." : "Pluno is reconnecting. Try again in a moment.", retryable: !1 } : null,
2333
2343
  executionVersion: null
2334
- }, b = { ...t.proactiveQuestions };
2335
- delete b[e.conversationScopeId], s = { ...t, proactiveQuestions: b, submissions: { ...t.submissions, [e.userMessageId]: w }, submissionOrder: [...t.submissionOrder, e.userMessageId] };
2344
+ }, S = { ...t.proactiveQuestions };
2345
+ delete S[e.conversationScopeId], s = { ...t, proactiveQuestions: S, submissions: { ...t.submissions, [e.userMessageId]: w }, submissionOrder: [...t.submissionOrder, e.userMessageId] };
2336
2346
  break;
2337
2347
  }
2338
2348
  case "conversation.submission_accepted": {
@@ -2349,7 +2359,7 @@ function Ah(t, e, n, i) {
2349
2359
  }
2350
2360
  case "conversation.stop": {
2351
2361
  if (n.clients[e.clientScopeId] !== e.conversationScopeId) return { state: t, effects: o };
2352
- const r = n.selections[e.conversationScopeId].sessionId, c = r ? t.sessions[r]?.execution : null, l = Object.values(t.submissions).filter((g) => (r ? g.sessionId === r : g.conversationScopeId === e.conversationScopeId) && (!e.userMessageIds || e.userMessageIds.includes(g.userMessageId))), u = l.filter((g) => !g.cancelled && (g.delivery !== "failed" || t.deliveries[g.userMessageId]?.phase === "paused") && (g.delivery !== "accepted" || g.executionVersion === null)), d = u.length > 0, h = c && ["queued", "thinking", "steering", "stopping"].includes(c.phase) && (!e.userMessageIds || Tt(c).some((g) => e.userMessageIds.includes(g)));
2362
+ const r = n.selections[e.conversationScopeId].sessionId, c = r ? t.sessions[r]?.execution : null, l = Object.values(t.submissions).filter((g) => (r ? g.sessionId === r : g.conversationScopeId === e.conversationScopeId) && (!e.userMessageIds || e.userMessageIds.includes(g.userMessageId))), u = l.filter((g) => !g.cancelled && (g.delivery !== "failed" || t.deliveries[g.userMessageId]?.phase === "paused" || e.userMessageIds?.includes(g.userMessageId) && t.deliveries[g.userMessageId]?.acceptance === "unissued") && (g.delivery !== "accepted" || g.executionVersion === null)), d = u.length > 0, h = c && ["queued", "thinking", "steering", "stopping"].includes(c.phase) && (!e.userMessageIds || Tt(c).some((g) => e.userMessageIds.includes(g)));
2353
2363
  if (!d && !h && (c || !e.userMessageIds?.length)) return { state: t, effects: o };
2354
2364
  const f = Array.from(new Set(e.userMessageIds ?? [...u.map((g) => g.userMessageId), ...h ? Tt(c) : []])), y = { ...t.submissions };
2355
2365
  for (const g of l)
@@ -2500,7 +2510,7 @@ function al(t, e) {
2500
2510
  function ia(t) {
2501
2511
  let e = t;
2502
2512
  const n = [];
2503
- if (!t.effectsEnabled) return { state: t, effects: n };
2513
+ if (!t.effectsEnabled || !t.authorityId) return { state: t, effects: n };
2504
2514
  const i = { authorityId: t.authorityId, generation: t.generation }, s = () => (e = { ...e, requestSequence: e.requestSequence + 1 }, `conversation:${e.generation}:${e.requestSequence}`), o = [...t.submissionOrder].sort((r, c) => (t.deliveries[r]?.queuePosition ?? 0) - (t.deliveries[c]?.queuePosition ?? 0));
2505
2515
  for (const r of o) {
2506
2516
  const c = e.submissions[r];
@@ -2608,10 +2618,10 @@ function Th(t, e, n, i) {
2608
2618
  const h = t.deliveries[u], f = t.submissions[u];
2609
2619
  let y = { ...h, phase: "waiting", effectId: null };
2610
2620
  if (e.type === "effect.failed") {
2611
- const g = e.error.details?.acceptance === "unissued" && h.acceptance !== "accepted" ? "unissued" : e.error.details?.acceptance === "rejected" ? "rejected" : h.acceptance, w = e.error.details?.allocation === "unissued" ? "unissued" : h.allocation, b = e.effectKind === "conversation.command" && h.step === "send" && g === "unissued" || e.effectKind === "conversation.upload" && e.error.details?.allocation === "unissued", I = e.effectKind === "conversation.prepare" || b ? "failed" : g === "uncertain" || w === "uncertain" || e.error.retryable ? "uncertain" : "failed";
2612
- y = { ...y, phase: I, acceptance: g, allocation: w }, !f.cancelled && f.delivery !== "accepted" && (s = { ...s, submissions: {
2621
+ const g = e.error.details?.acceptance === "unissued" && h.acceptance !== "accepted" ? "unissued" : e.error.details?.acceptance === "rejected" ? "rejected" : h.acceptance, b = e.error.details?.allocation === "unissued" ? "unissued" : h.allocation, w = e.effectKind === "conversation.command" && h.step === "send" && g === "unissued" || e.effectKind === "conversation.upload" && e.error.details?.allocation === "unissued", S = e.effectKind === "conversation.prepare" || w ? "failed" : g === "uncertain" || b === "uncertain" || e.error.retryable ? "uncertain" : "failed";
2622
+ y = { ...y, phase: S, acceptance: g, allocation: b }, !f.cancelled && f.delivery !== "accepted" && (s = { ...s, submissions: {
2613
2623
  ...s.submissions,
2614
- [u]: { ...f, delivery: I, error: e.error }
2624
+ [u]: { ...f, delivery: S, error: e.error }
2615
2625
  } });
2616
2626
  } else if (e.effectKind === "conversation.prepare")
2617
2627
  f.cancelled ? y = { ...y, phase: "failed" } : (y = { ...y, prepared: !0 }, s = { ...s, submissions: { ...s.submissions, [u]: {
@@ -2623,15 +2633,15 @@ function Th(t, e, n, i) {
2623
2633
  error: { code: "message_delivery_failed", message: "Pluno could not send this message. Try it again.", retryable: !0 }
2624
2634
  } } }));
2625
2635
  else if (e.effectKind === "conversation.upload") {
2626
- const g = st(e.output), w = f.attachments[h.uploads.length];
2627
- if (g.attachment.id !== w.sourceId || g.attachment.size_bytes !== w.sizeBytes || f.sessionId !== null && f.sessionId !== g.sessionId)
2636
+ const g = st(e.output), b = f.attachments[h.uploads.length];
2637
+ if (g.attachment.id !== b.sourceId || g.attachment.size_bytes !== b.sizeBytes || f.sessionId !== null && f.sessionId !== g.sessionId)
2628
2638
  throw new Error("Upload does not match the captured attachment or conversation.");
2629
2639
  y = { ...y, allocation: "resolved", uploads: [...h.uploads, g.attachment] };
2630
- const b = Object.fromEntries(Object.entries(s.submissions).map(([I, x]) => [
2631
- I,
2632
- x.conversationScopeId === f.conversationScopeId && (I === u || !x.cancelled && !f.cancelled) ? { ...x, sessionId: g.sessionId } : x
2640
+ const w = Object.fromEntries(Object.entries(s.submissions).map(([S, x]) => [
2641
+ S,
2642
+ x.conversationScopeId === f.conversationScopeId && (S === u || !x.cancelled && !f.cancelled) ? { ...x, sessionId: g.sessionId } : x
2633
2643
  ]));
2634
- s = { ...s, submissions: b };
2644
+ s = { ...s, submissions: w };
2635
2645
  } else if (e.effectKind === "conversation.receipt")
2636
2646
  if (e.output === null)
2637
2647
  y = { ...y, phase: f.cancelled ? "uncertain" : "paused" }, f.cancelled || (s = { ...s, submissions: { ...s.submissions, [u]: {
@@ -2687,44 +2697,56 @@ function Th(t, e, n, i) {
2687
2697
  }
2688
2698
  }
2689
2699
  } else if (e.authorityId === t.authorityId && e.generation === t.generation && n.authorityId) {
2690
- if (e.type === "conversation.enable_effects" && (s = { ...t, effectsEnabled: !0 }), e.type === "conversation.restore_delivery") {
2691
- const u = st(e.checkpoint);
2692
- if (u.schema !== 1 || u.authorityId !== t.authorityId || t.submissionOrder.length || Object.keys(t.operations).length)
2700
+ if (e.type === "conversation.enable_effects" && (s = { ...t, effectsEnabled: !0 }), e.type === "conversation.authentication_restored" && (s = { ...t, submissions: Object.fromEntries(Object.entries(t.submissions).map(([u, d]) => [
2701
+ u,
2702
+ !d.cancelled && d.delivery === "failed" && ["unauthorized", "401", "auth_reconnecting"].includes(d.error?.code ?? "") ? { ...d, error: { code: "message_delivery_failed", message: "Pluno is connected. Retry this message to send it.", retryable: !0 } } : d
2703
+ ])) }), e.type === "conversation.restore_delivery") {
2704
+ const u = st(e.checkpoint), d = t.submissionOrder.every((x) => t.deliveries[x]?.acceptance === "unissued" && t.submissions[x].delivery === "failed" && ["unauthorized", "auth_reconnecting"].includes(t.submissions[x].error?.code ?? ""));
2705
+ if (u.schema !== 1 || u.authorityId !== t.authorityId || !d || Object.keys(t.operations).length)
2693
2706
  throw new Error("Delivery restoration requires an empty engine with the same authenticated authority.");
2694
- const { schema: d, authorityId: h, ...f } = u, y = st(e.pendingRestoration ?? {}), g = (w) => !n.clients[w.clientScopeId] && y[w.clientScopeId] === w.conversationScopeId;
2707
+ const h = { ...t.submissions, ...u.submissions };
2708
+ for (const [x, m] of Object.entries(t.submissions))
2709
+ m.cancelled && (h[x] = { ...h[x], cancelled: !0, cancellationReason: m.cancellationReason });
2710
+ const f = {
2711
+ ...u,
2712
+ submissions: h,
2713
+ stops: { ...u.stops, ...t.stops },
2714
+ deliveries: { ...t.deliveries, ...u.deliveries },
2715
+ submissionOrder: [.../* @__PURE__ */ new Set([...u.submissionOrder, ...t.submissionOrder])]
2716
+ }, { schema: y, authorityId: g, ...b } = f, w = st(e.pendingRestoration ?? {}), S = (x) => !n.clients[x.clientScopeId] && w[x.clientScopeId] === x.conversationScopeId;
2695
2717
  s = {
2696
2718
  ...t,
2697
- ...f,
2698
- pendingRestoration: y,
2699
- requestSequence: Math.max(t.requestSequence, u.requestSequence),
2719
+ ...b,
2720
+ pendingRestoration: w,
2721
+ requestSequence: Math.max(t.requestSequence, f.requestSequence),
2700
2722
  effectsEnabled: !0,
2701
- submissions: Object.fromEntries(Object.entries(u.submissions).map(([w, b]) => [w, {
2702
- ...b,
2723
+ submissions: Object.fromEntries(Object.entries(f.submissions).map(([x, m]) => [x, {
2724
+ ...m,
2703
2725
  executionVersion: null,
2704
- cancelled: b.cancelled || !g(b) && !Zr(b, n),
2705
- ...!b.cancelled && !g(b) && !Zr(b, n) ? { cancellationReason: "owner_lost" } : {},
2706
- delivery: (b.contextPreparation === null || !u.deliveries[w]) && !b.cancelled && b.delivery !== "accepted" ? "failed" : b.delivery === "sending" ? "uncertain" : b.delivery,
2707
- error: b.contextPreparation === null && !b.cancelled ? { code: "context_preparation_interrupted", message: "Page context preparation was interrupted. Please send this message again.", retryable: !1 } : !u.deliveries[w] && b.delivery !== "accepted" && !b.cancelled ? { code: "submission_interrupted", message: "Message preparation was interrupted. Retry this message.", retryable: !0 } : b.error
2726
+ cancelled: m.cancelled || !S(m) && !Zr(m, n),
2727
+ ...!m.cancelled && !S(m) && !Zr(m, n) ? { cancellationReason: "owner_lost" } : {},
2728
+ delivery: (m.contextPreparation === null || !f.deliveries[x]) && !m.cancelled && m.delivery !== "accepted" ? "failed" : m.delivery === "sending" ? "uncertain" : m.delivery,
2729
+ error: m.contextPreparation === null && !m.cancelled && !["unauthorized", "auth_reconnecting"].includes(m.error?.code ?? "") ? { code: "context_preparation_interrupted", message: "Page context preparation was interrupted. Please send this message again.", retryable: !1 } : !f.deliveries[x] && m.delivery !== "accepted" && !m.cancelled ? { code: "submission_interrupted", message: "Message preparation was interrupted. Retry this message.", retryable: !0 } : m.error
2708
2730
  }])),
2709
- deliveries: Object.fromEntries(Object.entries(u.submissions).map(([w, b], I) => {
2710
- const x = u.deliveries[w], m = b.contextPreparation === null, _ = b.delivery === "accepted" ? "accepted" : x?.acceptance ?? (x && (x.step === "send" || x.step === "receipt") ? "uncertain" : "unissued");
2711
- return [w, {
2712
- ...rl(b, I),
2713
- ...x,
2714
- acceptance: _,
2715
- allocation: b.sessionId !== null ? "resolved" : x?.allocation ?? (x?.step === "upload" ? "uncertain" : "unissued"),
2731
+ deliveries: Object.fromEntries(Object.entries(f.submissions).map(([x, m], _) => {
2732
+ const I = f.deliveries[x], k = m.contextPreparation === null, T = m.delivery === "accepted" ? "accepted" : I?.acceptance ?? (I && (I.step === "send" || I.step === "receipt") ? "uncertain" : "unissued");
2733
+ return [x, {
2734
+ ...rl(m, _),
2735
+ ...I,
2736
+ acceptance: T,
2737
+ allocation: m.sessionId !== null ? "resolved" : I?.allocation ?? (I?.step === "upload" ? "uncertain" : "unissued"),
2716
2738
  effectId: null,
2717
2739
  // Readiness is authority-local and must be re-established after restart. Captured input stays immutable.
2718
- step: _ === "uncertain" && x?.step === "send" && x.phase !== "done" ? "receipt" : x?.step ?? null,
2719
- prepared: _ === "accepted",
2720
- queuePosition: x?.queuePosition ?? I,
2721
- phase: _ === "accepted" ? "done" : m || !x ? "failed" : ["running", "waiting"].includes(x.phase) ? "uncertain" : x.phase
2740
+ step: T === "uncertain" && I?.step === "send" && I.phase !== "done" ? "receipt" : I?.step ?? null,
2741
+ prepared: T === "accepted",
2742
+ queuePosition: I?.queuePosition ?? _,
2743
+ phase: T === "accepted" ? "done" : k || !I ? "failed" : ["running", "waiting"].includes(I.phase) ? "uncertain" : I.phase
2722
2744
  }];
2723
2745
  })),
2724
- operations: Object.fromEntries(Object.entries(u.operations).map(([w, b]) => [w, {
2725
- ...b,
2746
+ operations: Object.fromEntries(Object.entries(f.operations).map(([x, m]) => [x, {
2747
+ ...m,
2726
2748
  effectId: null,
2727
- phase: ["running", "waiting"].includes(b.phase) ? "uncertain" : b.phase
2749
+ phase: ["running", "waiting"].includes(m.phase) ? "uncertain" : m.phase
2728
2750
  }]))
2729
2751
  };
2730
2752
  }
@@ -2789,7 +2811,7 @@ function Th(t, e, n, i) {
2789
2811
  if (!d) {
2790
2812
  const h = u.type === "chat.retry_last_user_message" ? Object.fromEntries(Object.entries(t.stops).flatMap(([f, y]) => {
2791
2813
  if (n.selections[f]?.sessionId !== u.payload.sessionId) return [[f, y]];
2792
- const g = y.userMessageIds.filter((w) => w !== u.payload.clientMessageId);
2814
+ const g = y.userMessageIds.filter((b) => b !== u.payload.clientMessageId);
2793
2815
  return g.length ? [[f, { ...y, userMessageIds: g }]] : [];
2794
2816
  })) : t.stops;
2795
2817
  s = { ...t, stops: h, effectsEnabled: !0, operations: {
@@ -2809,7 +2831,7 @@ function Th(t, e, n, i) {
2809
2831
  ...r,
2810
2832
  effectsEnabled: !0,
2811
2833
  requestSequence: r.requestSequence + 1,
2812
- deliveries: { ...r.deliveries, [e.userMessageId]: rl(r.submissions[e.userMessageId], r.requestSequence + 1) }
2834
+ deliveries: { ...r.deliveries, [e.userMessageId]: { ...rl(r.submissions[e.userMessageId], r.requestSequence + 1), ...e.waitForAuthentication ? { phase: "failed" } : {} } }
2813
2835
  });
2814
2836
  for (const [u, d] of Object.entries(r.submissions)) {
2815
2837
  const h = r.deliveries[u];
@@ -2968,14 +2990,14 @@ function Lh(t) {
2968
2990
  const g = { authorityId: t.authorityId, requestSequence: Math.max(a.requestSequence, y?.requestSequence ?? 0), cancelled: { ...y?.cancelled }, operations: { ...y?.operations }, stops: { ...y?.stops } };
2969
2991
  if (r) {
2970
2992
  n = a, a.requestSequence >= (y?.requestSequence ?? 0) && (g.cancelled = {}, g.operations = {}, g.stops = {});
2971
- for (const [w] of l) delete g.cancelled[w];
2972
- for (const [w, b] of Object.entries(a.stops)) g.stops[w]?.requestId === b.requestId && delete g.stops[w];
2973
- for (const [w, b] of c)
2974
- JSON.stringify(g.operations[w]?.command) === JSON.stringify(b.command) && delete g.operations[w];
2993
+ for (const [b] of l) delete g.cancelled[b];
2994
+ for (const [b, w] of Object.entries(a.stops)) g.stops[b]?.requestId === w.requestId && delete g.stops[b];
2995
+ for (const [b, w] of c)
2996
+ JSON.stringify(g.operations[b]?.command) === JSON.stringify(w.command) && delete g.operations[b];
2975
2997
  } else {
2976
- for (const [w, b] of l) n?.submissions[w]?.cancelled || (g.cancelled[w] = { ...b, context: {}, contextPreparation: { pageContent: "", sessionTabs: [] } });
2977
- for (const [w, b] of Object.entries(a.stops)) n?.stops[w]?.requestId !== b.requestId && (g.stops[w] = b);
2978
- for (const [w, b] of c) b.phase !== "done" && b.phase !== "failed" && JSON.stringify(n?.operations[w]?.command) !== JSON.stringify(b.command) && (g.operations[w] = { ...b, effectId: null, phase: "uncertain", result: null, error: null });
2998
+ for (const [b, w] of l) n?.submissions[b]?.cancelled || (g.cancelled[b] = { ...w, context: {}, contextPreparation: { pageContent: "", sessionTabs: [] } });
2999
+ for (const [b, w] of Object.entries(a.stops)) n?.stops[b]?.requestId !== w.requestId && (g.stops[b] = w);
3000
+ for (const [b, w] of c) w.phase !== "done" && w.phase !== "failed" && JSON.stringify(n?.operations[b]?.command) !== JSON.stringify(w.command) && (g.operations[b] = { ...w, effectId: null, phase: "uncertain", result: null, error: null });
2979
3001
  }
2980
3002
  if (!(!y && !Object.keys(g.cancelled).length && !Object.keys(g.operations).length && !Object.keys(g.stops).length) && !(JSON.stringify(y?.cancelled ?? {}) === JSON.stringify(g.cancelled) && JSON.stringify(y?.operations ?? {}) === JSON.stringify(g.operations) && JSON.stringify(y?.stops ?? {}) === JSON.stringify(g.stops))) {
2981
3003
  if (!t.isCurrent()) throw new Error("Cancellation authority was retired.");
@@ -3348,8 +3370,8 @@ function Jh(t) {
3348
3370
  };
3349
3371
  u.measure("warmup_wait", () => new Promise((f, y) => {
3350
3372
  const g = () => {
3351
- const w = c.engine.getState().slices, b = w.conversation.submissions[r.submission.userMessageId], I = w.conversation.operations[l.command.request_id];
3352
- !Je(t) || !b || b.cancelled || w.directory.clients[b.clientScopeId] !== b.conversationScopeId ? y(new Error("Warmup wait was retired.")) : (b.sessionId !== null || !I || !["waiting", "running", "uncertain"].includes(I.phase)) && f();
3373
+ const b = c.engine.getState().slices, w = b.conversation.submissions[r.submission.userMessageId], S = b.conversation.operations[l.command.request_id];
3374
+ !Je(t) || !w || w.cancelled || b.directory.clients[w.clientScopeId] !== w.conversationScopeId ? y(new Error("Warmup wait was retired.")) : (w.sessionId !== null || !S || !["waiting", "running", "uncertain"].includes(S.phase)) && f();
3353
3375
  };
3354
3376
  d = c.engine.subscribe(g), h = c.onDispose(() => y(new Error("Warmup wait was retired."))), g();
3355
3377
  })).catch(() => {
@@ -3515,12 +3537,12 @@ function Jh(t) {
3515
3537
  u();
3516
3538
  try {
3517
3539
  const f = [];
3518
- for (let b = 0; b < Math.max(1, r.refreshItemIds.length); b += 200) {
3540
+ for (let w = 0; w < Math.max(1, r.refreshItemIds.length); w += 200) {
3519
3541
  if (tt(t, r), !t.runtime().engine.getState().slices.directory.memberships[r.sessionId]?.members.length) throw new Error("Conversation observation was retired.");
3520
- const I = await t.http.request(
3542
+ const S = await t.http.request(
3521
3543
  `/${encodeURIComponent(r.sessionId)}/snapshot`,
3522
3544
  {},
3523
- { context: { ...s(), ...t.snapshotContext?.(r.sessionId) }, retry_preparation: r.retryPreparation === !0, limit: 100, before: r.before, refresh_item_ids: r.refreshItemIds.slice(b, b + 200) },
3545
+ { context: { ...s(), ...t.snapshotContext?.(r.sessionId) }, retry_preparation: r.retryPreparation === !0, limit: 100, before: r.before, refresh_item_ids: r.refreshItemIds.slice(w, w + 200) },
3524
3546
  "POST",
3525
3547
  "conversations",
3526
3548
  { readOnly: !0, signal: l.signal, diagnostic: {
@@ -3534,23 +3556,23 @@ function Jh(t) {
3534
3556
  const m = Mn(x);
3535
3557
  throw Object.assign(m, { details: { ...m.details, successfulRequests: f.length } });
3536
3558
  });
3537
- if (tt(t, r), I.conversation_id !== r.sessionId) throw new Error("Snapshot conversation identity mismatch.");
3538
- if (f.push(I), !I.projection_ready) break;
3559
+ if (tt(t, r), S.conversation_id !== r.sessionId) throw new Error("Snapshot conversation identity mismatch.");
3560
+ if (f.push(S), !S.projection_ready) break;
3539
3561
  }
3540
3562
  const y = f[0];
3541
3563
  if (r.before !== null && y.next_cursor === r.before)
3542
3564
  throw Object.assign(new Error("Conversation history cursor did not advance."), { code: "invalid_history_cursor" });
3543
- const g = f.reduce((b, I) => I.execution.version > b.version ? I.execution : b, y.execution), w = f.reduce((b, I) => I.follow_ups_version > b.follow_ups_version ? I : b, y);
3565
+ const g = f.reduce((w, S) => S.execution.version > w.version ? S.execution : w, y.execution), b = f.reduce((w, S) => S.follow_ups_version > w.follow_ups_version ? S : w, y);
3544
3566
  return { snapshot: {
3545
3567
  ...y,
3546
3568
  execution: g,
3547
- items: f.flatMap((b) => b.items),
3548
- streams: f.flatMap((b) => b.streams),
3549
- removed_items: f.flatMap((b) => b.removed_items),
3550
- interactions: f.flatMap((b) => b.interactions),
3551
- follow_ups: w.follow_ups,
3552
- follow_ups_version: w.follow_ups_version,
3553
- projection_ready: f.every((b) => b.projection_ready)
3569
+ items: f.flatMap((w) => w.items),
3570
+ streams: f.flatMap((w) => w.streams),
3571
+ removed_items: f.flatMap((w) => w.removed_items),
3572
+ interactions: f.flatMap((w) => w.interactions),
3573
+ follow_ups: b.follow_ups,
3574
+ follow_ups_version: b.follow_ups_version,
3575
+ projection_ready: f.every((w) => w.projection_ready)
3554
3576
  }, updatedAt: t.now() };
3555
3577
  } finally {
3556
3578
  d(), h();
@@ -3830,7 +3852,7 @@ function sg(t, e, n, i) {
3830
3852
  function ir(t, e, n, i) {
3831
3853
  const s = /* @__PURE__ */ new Map();
3832
3854
  for (const _ of t.segments)
3833
- for (const S of [..._.activityIds, ..._.outcomeIds]) s.set(S, _.userMessageId);
3855
+ for (const I of [..._.activityIds, ..._.outcomeIds]) s.set(I, _.userMessageId);
3834
3856
  const o = t.items.map((_) => sg(
3835
3857
  _,
3836
3858
  s.get(_.id) ?? null,
@@ -3843,15 +3865,15 @@ function ir(t, e, n, i) {
3843
3865
  content: _.content,
3844
3866
  // There is no canonical timestamp before acceptance. Keep identity stable without fabricating one.
3845
3867
  createdAt: "",
3846
- retryable: _.delivery === "failed" && ["delivery", "preparation"].includes(Ud(t, _.userMessageId)?.type ?? ""),
3847
- attachments: _.attachments.map((S) => ({
3848
- id: S.sourceId,
3849
- name: S.name,
3850
- mimeType: S.mimeType,
3851
- sizeBytes: S.sizeBytes
3868
+ retryable: _.delivery === "failed" && !["unauthorized", "401", "auth_reconnecting"].includes(_.error?.code ?? "") && ["delivery", "preparation"].includes(Ud(t, _.userMessageId)?.type ?? ""),
3869
+ attachments: _.attachments.map((I) => ({
3870
+ id: I.sourceId,
3871
+ name: I.name,
3872
+ mimeType: I.mimeType,
3873
+ sizeBytes: I.sizeBytes
3852
3874
  }))
3853
3875
  });
3854
- const a = t.segments.flatMap((_) => o.filter((S) => S.id === _.userMessageId || _.activityIds.includes(S.id) || _.outcomeIds.includes(S.id)));
3876
+ const a = t.segments.flatMap((_) => o.filter((I) => I.id === _.userMessageId || _.activityIds.includes(I.id) || _.outcomeIds.includes(I.id)));
3855
3877
  t.proactiveQuestion && a.push({
3856
3878
  id: t.proactiveQuestion.id,
3857
3879
  role: "assistant",
@@ -3861,27 +3883,27 @@ function ir(t, e, n, i) {
3861
3883
  loading: !1
3862
3884
  });
3863
3885
  const r = t.activity.phase, c = t.submissions.filter((_) => !_.cancelled && !["accepted", "failed"].includes(_.delivery)), l = t.submissions[t.submissions.length - 1], u = [...t.items].reverse().find((_) => _.type === "user_message"), d = ["queued", "thinking", "steering", "awaiting_execution"].includes(r), h = l?.delivery === "failed" && (d && t.activity.userMessageId != null && t.activity.userMessageId !== l.userMessageId || u !== void 0 && u.id !== l.userMessageId && Date.parse(u.created_at) > l.submittedAt), f = new Map(t.submissions.filter((_) => (_ !== l || h) && !_.cancelled && _.delivery === "failed" && _.error).map((_) => [_.userMessageId, _])), y = a.flatMap((_) => {
3864
- const S = _.role === "user" ? f.get(_.id) : void 0;
3865
- return S?.error ? [_, {
3866
- id: `submission-error:${S.userMessageId}`,
3886
+ const I = _.role === "user" ? f.get(_.id) : void 0;
3887
+ return I?.error ? [_, {
3888
+ id: `submission-error:${I.userMessageId}`,
3867
3889
  role: "system",
3868
3890
  dataType: "run_error",
3869
- respondsToUserMessageId: S.userMessageId,
3870
- content: S.error.message,
3891
+ respondsToUserMessageId: I.userMessageId,
3892
+ content: I.error.message,
3871
3893
  createdAt: "",
3872
3894
  loading: !1,
3873
- ...typeof S.error.details?.securitySettingsUrl == "string" ? { securitySettingsUrl: S.error.details.securitySettingsUrl } : {}
3895
+ ...typeof I.error.details?.securitySettingsUrl == "string" ? { securitySettingsUrl: I.error.details.securitySettingsUrl } : {}
3874
3896
  }] : [_];
3875
- }), g = e?.error != null && t.historyRefreshFailure != null && t.historyRefreshFailure.consecutiveFailures < 4, w = g ? null : e?.error ?? null, b = l?.delivery === "failed" && !l.cancelled && !h ? l.error : w, I = {
3897
+ }), g = e?.error != null && t.historyRefreshFailure != null && t.historyRefreshFailure.consecutiveFailures < 4, b = g ? null : e?.error ?? null, w = l?.delivery === "failed" && !l.cancelled && !h ? l.error : b, S = {
3876
3898
  isRetrying: t.isRetrying ?? !1,
3877
- historyRefreshFailure: b === e?.error ? t.historyRefreshFailure ?? null : null,
3899
+ historyRefreshFailure: w === e?.error ? t.historyRefreshFailure ?? null : null,
3878
3900
  conversationDiagnostics: {
3879
- ...b ? { errorMessageFingerprint: qa(Fn(b.message)) } : {},
3880
- ...l && b && b === l.error && !h ? { failedClientMessageId: l.userMessageId } : {},
3881
- ...typeof b?.details?.requestId == "string" ? { errorRequestId: b.details.requestId } : {},
3882
- ...eo(b?.details?.errorNormalization) ? { errorNormalization: b.details.errorNormalization } : {},
3901
+ ...w ? { errorMessageFingerprint: qa(Fn(w.message)) } : {},
3902
+ ...l && w && w === l.error && !h ? { failedClientMessageId: l.userMessageId } : {},
3903
+ ...typeof w?.details?.requestId == "string" ? { errorRequestId: w.details.requestId } : {},
3904
+ ...eo(w?.details?.errorNormalization) ? { errorNormalization: w.details.errorNormalization } : {},
3883
3905
  ...i ? { owner: i } : {},
3884
- ...Hn(b?.details?.httpRequest) ? { httpRequest: b.details.httpRequest } : {},
3906
+ ...Hn(w?.details?.httpRequest) ? { httpRequest: w.details.httpRequest } : {},
3885
3907
  queryStatus: e?.status ?? null,
3886
3908
  queryRequestId: e?.requestId ?? null,
3887
3909
  queryUpdatedAt: e?.updatedAt ?? null
@@ -3909,14 +3931,14 @@ function ir(t, e, n, i) {
3909
3931
  turnPhase: r === "submitting" ? "sending" : ["queued", "awaiting_execution"].includes(r) ? "starting" : ["thinking", "steering"].includes(r) ? "thinking" : null,
3910
3932
  isThinking: d,
3911
3933
  taskStatus: r === "completed" ? "completed" : r === "failed" ? "failed" : r === "stopped" || r === "stopping" ? "stopped" : d || r === "submitting" ? "working" : null,
3912
- lastError: b?.message ?? null,
3913
- lastErrorCode: b?.code ?? null,
3914
- lastErrorSecuritySettingsUrl: typeof b?.details?.securitySettingsUrl == "string" ? b.details.securitySettingsUrl : null
3934
+ lastError: w?.message ?? null,
3935
+ lastErrorCode: w?.code ?? null,
3936
+ lastErrorSecuritySettingsUrl: typeof w?.details?.securitySettingsUrl == "string" ? w.details.securitySettingsUrl : null
3915
3937
  };
3916
- let x = I;
3917
- for (const _ of t.optimistic.filter((S) => S.cancelled && !t.stop?.userMessageIds.includes(S.userMessageId))) {
3918
- const S = ul(x, "", "stopped", [_.userMessageId], hl(_.cancellationReason));
3919
- x = { ...x, messages: S.messages, segments: S.segments };
3938
+ let x = S;
3939
+ for (const _ of t.optimistic.filter((I) => I.cancelled && !t.stop?.userMessageIds.includes(I.userMessageId))) {
3940
+ const I = ul(x, "", "stopped", [_.userMessageId], hl(_.cancellationReason));
3941
+ x = { ...x, messages: I.messages, segments: I.segments };
3920
3942
  }
3921
3943
  if (!t.stop) return x;
3922
3944
  const m = ul(
@@ -3926,7 +3948,7 @@ function ir(t, e, n, i) {
3926
3948
  t.stop.userMessageIds,
3927
3949
  hl(t.stop.reason ?? "user_requested")
3928
3950
  );
3929
- return { ...I, messages: m.messages, segments: m.segments };
3951
+ return { ...S, messages: m.messages, segments: m.segments };
3930
3952
  }
3931
3953
  function hl(t) {
3932
3954
  switch (t) {
@@ -6644,11 +6666,11 @@ class cu {
6644
6666
  let g = i;
6645
6667
  if (o === "conversations" && e === "/commands" && this.auth.role !== "session_surface" && this.options.executorConnection) {
6646
6668
  if (y = this.options.executorConnection(), !y) throw new L("Reconnecting the browser before continuing.", "executor_not_ready");
6647
- const I = i;
6648
- g = { ...I, context: { ...I.context, connection_id: y } };
6669
+ const S = i;
6670
+ g = { ...S, context: { ...S.context, connection_id: y } };
6649
6671
  }
6650
- const w = () => this.requestOnce(e, n, g, s, o, a.signal, a.diagnostic, ++u), b = await (a.timing ? a.timing.measure("http_request", w) : w());
6651
- return c(), b;
6672
+ const b = () => this.requestOnce(e, n, g, s, o, a.signal, a.diagnostic, ++u), w = await (a.timing ? a.timing.measure("http_request", b) : b());
6673
+ return c(), w;
6652
6674
  } catch (g) {
6653
6675
  if (c(!1), this.requests.signal.aborted || a.signal?.aborted) throw g;
6654
6676
  if (g instanceof L && g.code === "executor_not_ready" && y && d === 0 && this.options.restoreExecutor) {
@@ -6667,21 +6689,21 @@ class cu {
6667
6689
  this.requests.signal.throwIfAborted(), a?.throwIfAborted();
6668
6690
  const h = new AbortController(), f = { trigger: null }, y = (P) => {
6669
6691
  h.signal.aborted || (f.trigger = P, h.abort());
6670
- }, g = () => y("transport_disposed"), w = () => y(["owner_disposed", "authority_retired", "observation_released", "request_replaced"].includes(a?.reason) ? a.reason : "caller_cancelled");
6671
- this.requests.signal.addEventListener("abort", g, { once: !0 }), a?.addEventListener("abort", w, { once: !0 });
6672
- const b = o === "conversations" && /^\/[^/]+\/snapshot$/.test(e) && s === "POST", I = /^\/conversations(?:\/[^/]+)?$/.test(e) && (s ?? (i === void 0 ? "GET" : "POST")) === "GET", x = setTimeout(() => y("deadline"), I ? 6e4 : b ? 3e4 : 15e3), m = nf(), _ = Date.now();
6673
- let S = null, k = !1, T = null, q = null, U = null;
6692
+ }, g = () => y("transport_disposed"), b = () => y(["owner_disposed", "authority_retired", "observation_released", "request_replaced"].includes(a?.reason) ? a.reason : "caller_cancelled");
6693
+ this.requests.signal.addEventListener("abort", g, { once: !0 }), a?.addEventListener("abort", b, { once: !0 });
6694
+ const w = o === "conversations" && /^\/[^/]+\/snapshot$/.test(e) && s === "POST", S = /^\/conversations(?:\/[^/]+)?$/.test(e) && (s ?? (i === void 0 ? "GET" : "POST")) === "GET", x = setTimeout(() => y("deadline"), S ? 6e4 : w ? 3e4 : 15e3), m = nf(), _ = Date.now();
6695
+ let I = null, k = !1, T = null, q = null, U = null;
6674
6696
  try {
6675
6697
  const P = await Promise.resolve(fetch(u, {
6676
6698
  method: s ?? (i === void 0 ? "GET" : "POST"),
6677
6699
  cache: "no-store",
6678
6700
  signal: h.signal,
6679
- headers: { "x-product-agent-auth-request-id": m, authorization: l || o === "conversations" ? `Bearer ${this.auth.token}` : this.auth.token, "content-type": "application/json", ...b ? { "x-request-id": m } : {} },
6701
+ headers: { "x-product-agent-auth-request-id": m, authorization: l || o === "conversations" ? `Bearer ${this.auth.token}` : this.auth.token, "content-type": "application/json", ...w ? { "x-request-id": m } : {} },
6680
6702
  ...i === void 0 ? {} : { body: JSON.stringify(i) }
6681
6703
  })).catch((z) => {
6682
6704
  throw k = !0, z;
6683
6705
  });
6684
- if (S = Date.now(), T = P.status, q = _l(P.headers.get("x-request-id")), U = _l(P.headers.get("x-cloud-trace-context")), !P.ok) {
6706
+ if (I = Date.now(), T = P.status, q = _l(P.headers.get("x-request-id")), U = _l(P.headers.get("x-cloud-trace-context")), !P.ok) {
6685
6707
  const z = P.status === 401 ? "unauthorized" : P.status === 426 ? "update_required" : String(P.status), B = (await P.json().catch(() => null))?.detail;
6686
6708
  if (l && P.status === 403 && (o === "conversations" && /^\/[^/]+\/snapshot$/.test(e) || (!o || o === "embed") && /^\/conversations\/[^/]+$/.test(e)) && ["Conversation unavailable", "Integration mismatch", "Embedded origin mismatch"].includes(B))
6687
6709
  throw new L("Conversation unavailable", "conversation_access_denied");
@@ -6704,12 +6726,12 @@ class cu {
6704
6726
  const z = f.trigger ?? ((P instanceof Error || P instanceof DOMException) && P.name === "AbortError" ? "unexpected_abort" : null), B = {
6705
6727
  requestId: m,
6706
6728
  method: s ?? (i === void 0 ? "GET" : "POST"),
6707
- route: b ? "/api/product-agent/conversations/:sessionId/snapshot" : e === "/commands" ? "/api/product-agent/:namespace/commands" : "/api/product-agent/:namespace/:operation",
6729
+ route: w ? "/api/product-agent/conversations/:sessionId/snapshot" : e === "/commands" ? "/api/product-agent/:namespace/commands" : "/api/product-agent/:namespace/:operation",
6708
6730
  status: T,
6709
6731
  abortTrigger: z,
6710
6732
  category: z === "deadline" ? "request_timed_out" : z === "unexpected_abort" ? "connection_interrupted" : z ? "request_cancelled" : P instanceof L ? P.code : k ? "connection_interrupted" : "invalid_response",
6711
- responseHeadersMs: S === null ? null : Math.max(0, S - _),
6712
- responseBodyMs: S === null ? null : Math.max(0, Date.now() - S),
6733
+ responseHeadersMs: I === null ? null : Math.max(0, I - _),
6734
+ responseBodyMs: I === null ? null : Math.max(0, Date.now() - I),
6713
6735
  owner: z === "deadline" ? "http_deadline" : z === "transport_disposed" ? "http_transport" : z && z !== "unexpected_abort" ? "conversation_query" : T === null ? "browser" : "http_response",
6714
6736
  elapsedMs: Math.max(0, Date.now() - _),
6715
6737
  attempt: c,
@@ -6734,13 +6756,13 @@ class cu {
6734
6756
  );
6735
6757
  }
6736
6758
  throw P instanceof L && E ? new L(P.message, P.code, P.outcomeUnknown, { ...P.detail, ...E }, P.backendRefusal) : E ? new L(
6737
- k ? "The connection was interrupted. Please try again." : b ? "The conversation response could not be read. Please try again." : "The response could not be read. Please try again.",
6759
+ k ? "The connection was interrupted. Please try again." : w ? "The conversation response could not be read. Please try again." : "The response could not be read. Please try again.",
6738
6760
  "connection_interrupted",
6739
6761
  !0,
6740
6762
  E
6741
6763
  ) : P;
6742
6764
  } finally {
6743
- clearTimeout(x), this.requests.signal.removeEventListener("abort", g), a?.removeEventListener("abort", w);
6765
+ clearTimeout(x), this.requests.signal.removeEventListener("abort", g), a?.removeEventListener("abort", b);
6744
6766
  }
6745
6767
  }
6746
6768
  }
@@ -7120,19 +7142,23 @@ class lf {
7120
7142
  }
7121
7143
  async restore(e) {
7122
7144
  const n = this.state();
7123
- if (!this.current() || Object.keys(n.clients).length || Object.keys(n.selections).length) return !1;
7145
+ if (!this.current()) return !1;
7124
7146
  const i = await this.options.persistence.read();
7125
7147
  if (!cf(i) || i.authorityId !== this.options.authority.authorityId || i.browserSessionId !== this.options.persistence.sessionId()) return !1;
7126
7148
  const s = new Set(await this.options.persistence.liveClients());
7127
7149
  if (!this.current() || this.state().clients !== n.clients) return !1;
7128
- const o = i.bindings.filter((c) => s.has(c.clientScopeId));
7150
+ const o = i.bindings.filter((c) => {
7151
+ if (!s.has(c.clientScopeId) || n.clients[c.clientScopeId]) return !1;
7152
+ const l = n.selections[c.conversationScopeId];
7153
+ return !l || l.sessionId === c.sessionId && l.provisionalId === c.provisionalId;
7154
+ });
7129
7155
  if (e !== void 0 && o.some((c) => c.sessionId !== e)) return !1;
7130
7156
  const a = [], r = new Set(o.map((c) => c.sessionId));
7131
7157
  for (const c of r) {
7132
7158
  const l = o.filter((f) => f.sessionId === c), u = c === null ? l[0] : l.find((f) => f.clientScopeId === i.mains[c]) ?? this.choose(l), d = [u, ...l.filter((f) => f !== u)], h = /* @__PURE__ */ new Set();
7133
7159
  for (const f of d) {
7134
7160
  const y = { ...this.options.authority, clientScopeId: f.clientScopeId, conversationScopeId: f.conversationScopeId, replacement: null };
7135
- f.provisionalId !== null && !h.has(f.conversationScopeId) ? (a.push({ ...y, type: "directory.provisional", provisionalId: f.provisionalId }), c !== null && (a.push({
7161
+ f.provisionalId !== null && !h.has(f.conversationScopeId) && !n.selections[f.conversationScopeId]?.sessionId ? (a.push({ ...y, type: "directory.provisional", provisionalId: f.provisionalId }), c !== null && (a.push({
7136
7162
  ...this.options.authority,
7137
7163
  type: "directory.accepted",
7138
7164
  conversationScopeId: f.conversationScopeId,
@@ -7812,7 +7838,14 @@ function Bn(t, e, n) {
7812
7838
  const s = [];
7813
7839
  if (e.type === "directory.authority_replace") {
7814
7840
  if (e.expectedGeneration !== t.generation || e.generation <= t.generation) return { state: t, effects: s };
7815
- i = { ...lu(), authorityId: e.authorityId, generation: e.generation };
7841
+ const o = e.adoptLocalSubmissions && !t.authorityId ? Object.fromEntries(Object.entries(t.clients).filter(([, a]) => t.selections[a]?.sessionId === null)) : {};
7842
+ i = {
7843
+ ...lu(),
7844
+ authorityId: e.authorityId,
7845
+ generation: e.generation,
7846
+ clients: o,
7847
+ selections: Object.fromEntries(Object.values(o).map((a) => [a, t.selections[a]]))
7848
+ };
7816
7849
  } else if (e.type === "effect.completed" || e.type === "effect.failed") {
7817
7850
  const o = t.requests[e.effectId];
7818
7851
  if (!o || o.kind !== e.effectKind) return { state: t, effects: s };
@@ -7828,8 +7861,8 @@ function Bn(t, e, n) {
7828
7861
  for (const g of e.output.entries) {
7829
7862
  if (typeof g.is_active != "boolean") continue;
7830
7863
  u[g.conversation_id] = g.is_active;
7831
- const w = c.startedAtActivityRevisionBySessionId[g.conversation_id];
7832
- w !== void 0 && h[g.conversation_id] === w && (delete d[g.conversation_id], delete h[g.conversation_id]);
7864
+ const b = c.startedAtActivityRevisionBySessionId[g.conversation_id];
7865
+ b !== void 0 && h[g.conversation_id] === b && (delete d[g.conversation_id], delete h[g.conversation_id]);
7833
7866
  }
7834
7867
  i = { ...i, durableActivityBySessionId: u, activityBySessionId: d, activityRevisionBySessionId: h };
7835
7868
  const f = Object.fromEntries(Object.entries(i.optimisticEntries).filter(([, g]) => g.sessionId === null || !l.includes(g.sessionId)));
@@ -7861,7 +7894,7 @@ function Bn(t, e, n) {
7861
7894
  i = { ...i, mutations: { ...i.mutations, [o.input.sessionId]: r } };
7862
7895
  }
7863
7896
  } else {
7864
- if (e.authorityId !== t.authorityId || e.generation !== t.generation)
7897
+ if (e.authorityId !== (t.authorityId ?? "") || e.generation !== t.generation)
7865
7898
  return { state: t, effects: s };
7866
7899
  if (e.type === "directory.metadata_received")
7867
7900
  i = cr(t, e.metadata, !0);
@@ -7899,6 +7932,7 @@ function Bn(t, e, n) {
7899
7932
  activityRevision: t.activityRevision + 1
7900
7933
  };
7901
7934
  else if (e.type === "directory.query" || e.type === "directory.mutate") {
7935
+ if (!t.authorityId) return { state: t, effects: s };
7902
7936
  if (Object.values(t.requests).some((c) => c.input.requestId === e.requestId))
7903
7937
  throw new Error("Directory request ID is already in flight.");
7904
7938
  const o = `${t.generation}:${t.requestSequence + 1}`, a = { authorityId: e.authorityId, generation: e.generation, requestId: e.requestId };
@@ -8266,7 +8300,7 @@ class qf {
8266
8300
  return { state: l.state === o.slices.activeUsers ? o : Object.freeze({ revision: o.revision + 1, slices: Object.freeze({ ...o.slices, activeUsers: l.state }) }), effects: l.effects };
8267
8301
  }
8268
8302
  if (Cf(r)) {
8269
- const l = Bn(o.slices.directory, r, o.slices.conversation), u = ia(ea(o.slices.conversation, l.state)), d = ta(o.slices.conversation, u.state, l.state, l.state.clients !== o.slices.directory.clients), h = d.state, f = Tl(o.slices.conversation, h, l.state);
8303
+ const l = Bn(o.slices.directory, r, o.slices.conversation), u = ia(ea(o.slices.conversation, l.state, r.type === "directory.authority_replace" && r.adoptLocalSubmissions === !0)), d = ta(o.slices.conversation, u.state, l.state, l.state.clients !== o.slices.directory.clients), h = d.state, f = Tl(o.slices.conversation, h, l.state);
8270
8304
  return { state: f === o.slices.directory && h === o.slices.conversation ? o : Object.freeze({
8271
8305
  revision: o.revision + 1,
8272
8306
  slices: Object.freeze({ ...o.slices, directory: f, conversation: h })
@@ -8275,8 +8309,8 @@ class qf {
8275
8309
  if (Af(r)) {
8276
8310
  const l = Th(o.slices.conversation, r, o.slices.directory, o.slices.modelSelection);
8277
8311
  let u = o.slices.directory;
8278
- for (const [I, x] of Object.entries(l.state.operations)) {
8279
- if (!["runtime.warmup", "attachment.prepare"].includes(x.command.type) || !x.conversationScopeId || x.phase !== "done" || o.slices.conversation.operations[I]?.phase === "done") continue;
8312
+ for (const [S, x] of Object.entries(l.state.operations)) {
8313
+ if (!["runtime.warmup", "attachment.prepare"].includes(x.command.type) || !x.conversationScopeId || x.phase !== "done" || o.slices.conversation.operations[S]?.phase === "done") continue;
8280
8314
  const m = x.result, _ = u.selections[x.conversationScopeId];
8281
8315
  m?.sessionId && _?.provisionalId && _.sessionId === null && Object.values(u.clients).includes(x.conversationScopeId) && (u = Bn(u, {
8282
8316
  authorityId: l.state.authorityId,
@@ -8287,25 +8321,25 @@ class qf {
8287
8321
  sessionId: m.sessionId
8288
8322
  }).state);
8289
8323
  }
8290
- const d = Object.values(l.state.submissions).find((I) => I.delivery === "accepted" && o.slices.conversation.submissions[I.userMessageId]?.delivery !== "accepted");
8324
+ const d = Object.values(l.state.submissions).find((S) => S.delivery === "accepted" && o.slices.conversation.submissions[S.userMessageId]?.delivery !== "accepted");
8291
8325
  if (d) {
8292
- const I = u.selections[d.conversationScopeId];
8293
- !d.cancelled && I?.provisionalId && (u = Bn(u, {
8326
+ const S = u.selections[d.conversationScopeId];
8327
+ !d.cancelled && S?.provisionalId && (u = Bn(u, {
8294
8328
  type: "directory.accepted",
8295
8329
  authorityId: l.state.authorityId,
8296
8330
  generation: l.state.generation,
8297
8331
  conversationScopeId: d.conversationScopeId,
8298
- provisionalId: I.provisionalId,
8332
+ provisionalId: S.provisionalId,
8299
8333
  sessionId: d.sessionId
8300
8334
  }).state);
8301
8335
  }
8302
8336
  u = Tl(o.slices.conversation, l.state, u);
8303
8337
  const h = ia(ea(l.state, u)), f = ta(l.state, h.state, u);
8304
8338
  let y = o.slices;
8305
- const g = [], w = l.interactionSources, b = y.account.authority;
8306
- if (w && b && b.authorityId === w.authorityId && b.generation === w.generation) {
8307
- const I = Gr(y, { type: "stage7.sources", authority: b, now: y.features.now, sources: w.sources }, { conversation: f.state, directory: u });
8308
- y = Ke(st({ account: I.state.account, features: I.state.features, interactions: I.state.interactions })), g.push(...I.effects);
8339
+ const g = [], b = l.interactionSources, w = y.account.authority;
8340
+ if (b && w && w.authorityId === b.authorityId && w.generation === b.generation) {
8341
+ const S = Gr(y, { type: "stage7.sources", authority: w, now: y.features.now, sources: b.sources }, { conversation: f.state, directory: u });
8342
+ y = Ke(st({ account: S.state.account, features: S.state.features, interactions: S.state.interactions })), g.push(...S.effects);
8309
8343
  }
8310
8344
  return { state: f.state === o.slices.conversation && u === o.slices.directory && y === o.slices ? o : Object.freeze({
8311
8345
  revision: o.revision + 1,
@@ -9276,7 +9310,7 @@ class $a {
9276
9310
  this.conversationObservation?.dispose(), this.conversationUnsubscribe?.();
9277
9311
  const n = this.directoryAuthority, i = () => e === this.conversationAdapterGeneration;
9278
9312
  this.operationTimingReporter = Dh((g) => {
9279
- i() && !this.clientRuntime.isDisposed && this.reportHealthSignal("operation_timing", { timings: g.map((w) => ({ ...w, entrySurface: this.options.entrySurface })) });
9313
+ i() && !this.clientRuntime.isDisposed && this.reportHealthSignal("operation_timing", { timings: g.map((b) => ({ ...b, entrySurface: this.options.entrySurface })) });
9280
9314
  });
9281
9315
  const s = `pa.conversation.delivery:${this.modelClientScopeId}:${n.authorityId}`, o = `${s}:cancellations`;
9282
9316
  this.authenticatedUserId && this.options.restorePersistedState === !1 && sessionStorage.removeItem(o);
@@ -9296,59 +9330,59 @@ class $a {
9296
9330
  isCurrent: i,
9297
9331
  http: this.directoryHttp,
9298
9332
  now: () => Date.now(),
9299
- prepareSubmission: async ({ submission: g, sources: w }) => {
9300
- const b = mt(this.operationTimingReporter, {
9333
+ prepareSubmission: async ({ submission: g, sources: b }) => {
9334
+ const w = mt(this.operationTimingReporter, {
9301
9335
  operation: "send",
9302
9336
  layer: "sdk",
9303
9337
  requestId: g.requestId,
9304
9338
  clientMessageId: g.userMessageId,
9305
9339
  sessionId: g.sessionId
9306
9340
  });
9307
- let I = g.contextPreparation ?? { pageContent: "", sessionTabs: [] };
9341
+ let S = g.contextPreparation ?? { pageContent: "", sessionTabs: [] };
9308
9342
  if (g.contextPreparation === null) {
9309
- await b.measure("first_frame", () => new Promise((m) => {
9343
+ await w.measure("first_frame", () => new Promise((m) => {
9310
9344
  if (document.visibilityState !== "visible") {
9311
9345
  setTimeout(m, 0);
9312
9346
  return;
9313
9347
  }
9314
9348
  const _ = () => {
9315
- cancelAnimationFrame(k), document.removeEventListener("visibilitychange", S), setTimeout(m, 0);
9316
- }, S = () => {
9349
+ cancelAnimationFrame(k), document.removeEventListener("visibilitychange", I), setTimeout(m, 0);
9350
+ }, I = () => {
9317
9351
  document.visibilityState !== "visible" && _();
9318
9352
  }, k = requestAnimationFrame(_);
9319
- document.addEventListener("visibilitychange", S);
9353
+ document.addEventListener("visibilitychange", I);
9320
9354
  }));
9321
9355
  const x = g.context.page;
9322
9356
  if (Ct().url !== x.url) throw Object.assign(new Error("The page changed before preparation completed. Send this message again."), { code: "context_preparation_interrupted", retryable: !1 });
9323
- I = { pageContent: await b.measure("page_capture", async () => Ha()), sessionTabs: [] };
9357
+ S = { pageContent: await w.measure("page_capture", async () => Ha()), sessionTabs: [] };
9324
9358
  }
9325
- if (await b.measure("authentication", () => this.waitForAuthentication()), !i() || n !== this.directoryAuthority || this.clientRuntime.isDisposed) throw new Error("Submission authority was retired.");
9326
- for (const x of w)
9359
+ if (await w.measure("authentication", () => this.waitForAuthentication()), !i() || n !== this.directoryAuthority || this.clientRuntime.isDisposed) throw new Error("Submission authority was retired.");
9360
+ for (const x of b)
9327
9361
  if (!x.uploaded && (await this.attachmentPersistence.get(x.sourceId)?.catch(() => {
9328
9362
  throw Object.assign(new Error("Attachment files could not be stored. Attach the files again and send a new message."), { code: "attachment_source_unavailable", retryable: !1 });
9329
9363
  }), !await ql(x.sourceId)))
9330
9364
  throw Object.assign(new Error("Attachment files are unavailable. Attach the files again and send a new message."), { code: "attachment_source_unavailable", retryable: !1 });
9331
- return b.mark("context_ready"), { ...I, now: Date.now() };
9365
+ return w.mark("context_ready"), { ...S, now: Date.now() };
9332
9366
  },
9333
9367
  connectionId: () => this.socket instanceof Ae ? this.socket.connectionId : null,
9334
9368
  prepareUpload: this.options.prepareAttachmentUpload ?? (this.options.productVariant === "customer_embedded" ? (g) => this.prepareEmbedAttachmentUpload(g, i) : void 0),
9335
- onUploaded: async (g, w, b) => {
9369
+ onUploaded: async (g, b, w) => {
9336
9370
  await pu(g, {
9337
- sessionId: w,
9338
- sandboxPath: b.sandbox_path ?? void 0,
9339
- storageKey: b.storage_key ?? void 0,
9340
- fileUrl: b.file_url ? new URL(b.file_url, this.options.backendUrl).toString() : void 0,
9371
+ sessionId: b,
9372
+ sandboxPath: w.sandbox_path ?? void 0,
9373
+ storageKey: w.storage_key ?? void 0,
9374
+ fileUrl: w.file_url ? new URL(w.file_url, this.options.backendUrl).toString() : void 0,
9341
9375
  lastUsedAt: Date.now()
9342
- }).catch((I) => Be("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
9376
+ }).catch((S) => Be("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
9343
9377
  attachmentId: g,
9344
- message: I instanceof Error ? I.message : String(I)
9378
+ message: S instanceof Error ? S.message : String(S)
9345
9379
  }));
9346
9380
  },
9347
9381
  persistUpload: this.options.persistAttachmentUpload,
9348
9382
  readAttachment: async (g) => {
9349
- const w = (await ql(g))?.blob;
9350
- if (!w) throw Object.assign(new Error("Attachment files are unavailable. Attach the files again and send a new message."), { code: "attachment_source_unavailable", retryable: !1 });
9351
- return w;
9383
+ const b = (await ql(g))?.blob;
9384
+ if (!b) throw Object.assign(new Error("Attachment files are unavailable. Attach the files again and send a new message."), { code: "attachment_source_unavailable", retryable: !1 });
9385
+ return b;
9352
9386
  },
9353
9387
  saveCancellation: (g) => r.save(g),
9354
9388
  saveDelivery: async (g) => {
@@ -9359,34 +9393,34 @@ class $a {
9359
9393
  i() && this.reportOperationTiming(g);
9360
9394
  },
9361
9395
  onCommand: (g) => Jn("client_event", g.type, fr({ ...g.payload, type: g.type })),
9362
- onError: (g, w) => {
9363
- if (this.options.productVariant === "customer_embedded" && w.operation === "conversation.snapshot" && g instanceof L && g.code === "conversation_access_denied") {
9364
- w.sessionId === this.getState().sessionId && this.startNewSession({ notifyTransport: !1 });
9396
+ onError: (g, b) => {
9397
+ if (this.options.productVariant === "customer_embedded" && b.operation === "conversation.snapshot" && g instanceof L && g.code === "conversation_access_denied") {
9398
+ b.sessionId === this.getState().sessionId && this.startNewSession({ notifyTransport: !1 });
9365
9399
  return;
9366
9400
  }
9367
- Be("web-sdk.conversation", "Conversation operation failed", { ...w, ...Dn(g) }), g instanceof L && g.backendRefusal && w.operation.startsWith("chat.") ? this.applyAccountSubmissionError(g.code) : this.handleDirectoryTransportError(g);
9401
+ Be("web-sdk.conversation", "Conversation operation failed", { ...b, ...Dn(g) }), g instanceof L && g.backendRefusal && b.operation.startsWith("chat.") ? this.applyAccountSubmissionError(g.code) : this.handleDirectoryTransportError(g);
9368
9402
  }
9369
9403
  })
9370
9404
  });
9371
9405
  const c = this.clientRuntime.engine.getState().slices.conversation, l = this.options.restorePersistedState === !1 || !this.authenticatedUserId ? null : nr(s);
9372
9406
  if (this.authenticatedUserId && !c.submissionOrder.length && !Object.keys(c.operations).length) {
9373
- const g = this.queuedClientEvents.filter((I) => I.type === "chat.user_message"), w = l ? JSON.parse(l) : g.length ? Vh(c, g.map((I) => {
9374
- const { type: x, ...m } = I, _ = this.clientRuntime.engine.getState().slices.directory, S = _.clients[this.modelClientScopeId];
9407
+ const g = this.queuedClientEvents.filter((S) => S.type === "chat.user_message"), b = l ? JSON.parse(l) : g.length ? Vh(c, g.map((S) => {
9408
+ const { type: x, ...m } = S, _ = this.clientRuntime.engine.getState().slices.directory, I = _.clients[this.modelClientScopeId];
9375
9409
  return {
9376
- command: { type: x, request_id: I.clientMessageId, payload: JSON.parse(JSON.stringify(m)) },
9377
- requestedModel: I.model ?? null,
9410
+ command: { type: x, request_id: S.clientMessageId, payload: JSON.parse(JSON.stringify(m)) },
9411
+ requestedModel: S.model ?? null,
9378
9412
  clientScopeId: this.modelClientScopeId,
9379
- conversationScopeId: S,
9413
+ conversationScopeId: I,
9380
9414
  viewId: `sdk:${this.modelClientScopeId}`,
9381
- sessionId: I.sessionId ?? _.selections[S]?.sessionId ?? null,
9415
+ sessionId: S.sessionId ?? _.selections[I]?.sessionId ?? null,
9382
9416
  entrySurface: this.options.entrySurface,
9383
9417
  submittedAt: Date.now()
9384
9418
  };
9385
- })) : null, b = this.options.restorePersistedState === !1 || !a ? w : await r.restore(
9386
- w ?? Ra(c, this.clientRuntime.engine.getState().slices.directory)
9419
+ })) : null, w = this.options.restorePersistedState === !1 || !a ? b : await r.restore(
9420
+ b ?? Ra(c, this.clientRuntime.engine.getState().slices.directory)
9387
9421
  );
9388
9422
  if (!i()) return;
9389
- b && (w || Object.keys(b.operations).length || Object.keys(b.stops).length) && await this.clientRuntime.engine.dispatch({ ...n, type: "conversation.restore_delivery", checkpoint: b });
9423
+ w && (b || Object.keys(w.operations).length || Object.keys(w.stops).length) && await this.clientRuntime.engine.dispatch({ ...n, type: "conversation.restore_delivery", checkpoint: w });
9390
9424
  }
9391
9425
  if (this.authenticatedUserId && (this.queuedClientEvents = this.queuedClientEvents.filter((g) => !["chat.user_message", "chat.retry_last_user_message", "run.stop", "runtime.warmup", "session.reset", "attachment.upload_completed"].includes(g.type))), On(this.options.clientId, this.queuedClientEvents), !i()) return;
9392
9426
  this.conversationObservation = new Qh({
@@ -9396,16 +9430,16 @@ class $a {
9396
9430
  isCurrent: i,
9397
9431
  enabled: () => !!this.token && !this.authenticationFailure && !this.refreshingDefaultCredentials && this.state.status !== "closed",
9398
9432
  socket: {
9399
- retain: async (g, w) => {
9400
- const b = this.socket;
9401
- b instanceof Ae && await b.directoryRooms.retain(g, w).catch((I) => {
9402
- if (this.socket === b) throw I;
9433
+ retain: async (g, b) => {
9434
+ const w = this.socket;
9435
+ w instanceof Ae && await w.directoryRooms.retain(g, b).catch((S) => {
9436
+ if (this.socket === w) throw S;
9403
9437
  });
9404
9438
  },
9405
- release: async (g, w) => {
9406
- const b = this.socket;
9407
- b instanceof Ae && await b.directoryRooms.release(g, w).catch((I) => {
9408
- if (this.socket === b) throw I;
9439
+ release: async (g, b) => {
9440
+ const w = this.socket;
9441
+ w instanceof Ae && await w.directoryRooms.release(g, b).catch((S) => {
9442
+ if (this.socket === w) throw S;
9409
9443
  });
9410
9444
  }
9411
9445
  },
@@ -9415,52 +9449,52 @@ class $a {
9415
9449
  } },
9416
9450
  onError: (g) => this.handleDirectoryTransportError(g)
9417
9451
  });
9418
- const u = (g, w) => {
9452
+ const u = (g, b) => {
9419
9453
  if (this.firstResponseTimersByClientMessageId.size) {
9420
- for (const b of g)
9421
- (b.dataType === "run_status" || b.dataType === "run_error") && this.clearFirstResponseTimer(b.respondsToUserMessageId ?? null);
9422
- for (const b of g)
9423
- if (b.content.trim() && (b.role === "assistant" || b.dataType === "commentary_history" || b.dataType === "tool_summary")) {
9424
- const I = w ? this.clientRuntime.engine.getState().slices.conversation.sessions[w] : void 0;
9425
- for (const x of b.respondsToUserMessageId ? ah(I, b.respondsToUserMessageId) : [])
9426
- this.clearFirstResponseTimer(x, !0, w);
9454
+ for (const w of g)
9455
+ (w.dataType === "run_status" || w.dataType === "run_error") && this.clearFirstResponseTimer(w.respondsToUserMessageId ?? null);
9456
+ for (const w of g)
9457
+ if (w.content.trim() && (w.role === "assistant" || w.dataType === "commentary_history" || w.dataType === "tool_summary")) {
9458
+ const S = b ? this.clientRuntime.engine.getState().slices.conversation.sessions[b] : void 0;
9459
+ for (const x of w.respondsToUserMessageId ? ah(S, w.respondsToUserMessageId) : [])
9460
+ this.clearFirstResponseTimer(x, !0, b);
9427
9461
  }
9428
9462
  }
9429
9463
  };
9430
9464
  let d = new Map(this.getState().messages.map((g) => [g.id, g])), h = this.clientRuntime.engine.getState().slices.conversation, f = this.clientRuntime.engine.getState().slices.directory.selections, y = this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId];
9431
9465
  this.conversationUnsubscribe = this.clientRuntime.engine.subscribe(() => {
9432
- const g = this.clientRuntime.engine.getState().slices, w = h;
9433
- h = g.conversation, Nh(w, g.conversation, this.operationTimingReporter, "sdk");
9434
- const b = y !== g.directory.clients[this.modelClientScopeId];
9466
+ const g = this.clientRuntime.engine.getState().slices, b = h;
9467
+ h = g.conversation, Nh(b, g.conversation, this.operationTimingReporter, "sdk");
9468
+ const w = y !== g.directory.clients[this.modelClientScopeId];
9435
9469
  y = g.directory.clients[this.modelClientScopeId], f !== g.directory.selections && (f = g.directory.selections, this.directoryScope.persist());
9436
9470
  for (const x of Object.values(g.conversation.submissions)) {
9437
- if (x.delivery === "accepted" && w.submissions[x.userMessageId]?.delivery !== "accepted") {
9471
+ if (x.delivery === "accepted" && b.submissions[x.userMessageId]?.delivery !== "accepted") {
9438
9472
  const m = this.firstResponseTimersByClientMessageId.get(x.userMessageId);
9439
9473
  m && (m.sessionId = x.sessionId), this.emit("ack", { clientMessageId: x.userMessageId, sessionId: x.sessionId });
9440
9474
  const _ = x.sessionId;
9441
- _ && this.getState().sessionId === _ && this.directoryHttp.request(`/sessions/${encodeURIComponent(_)}/history`, { limit: 200 }).then((S) => {
9442
- i() && this.getState().sessionId === _ && this.state.status !== "closed" && gr(this.clientRuntime, this.modelClientScopeId, _, S.turns);
9443
- }).catch((S) => {
9444
- i() && this.getState().sessionId === _ && this.handleDirectoryTransportError(S);
9475
+ _ && this.getState().sessionId === _ && this.directoryHttp.request(`/sessions/${encodeURIComponent(_)}/history`, { limit: 200 }).then((I) => {
9476
+ i() && this.getState().sessionId === _ && this.state.status !== "closed" && gr(this.clientRuntime, this.modelClientScopeId, _, I.turns);
9477
+ }).catch((I) => {
9478
+ i() && this.getState().sessionId === _ && this.handleDirectoryTransportError(I);
9445
9479
  });
9446
9480
  }
9447
9481
  (x.cancelled || x.delivery === "failed") && this.clearFirstResponseTimer(x.userMessageId);
9448
9482
  }
9449
9483
  for (const [x, m] of Object.entries(g.directory.clients)) {
9450
9484
  if (!x.startsWith(`background:${this.modelClientScopeId}:`)) continue;
9451
- const _ = fn(g.conversation, g.directory, m), S = _.sessionId ? g.conversation.sessions[_.sessionId] : void 0;
9452
- if (this.firstResponseTimersByClientMessageId.size && (u(ir(_, S?.queries.current, this.options.backendUrl).messages, _.sessionId), ["failed", "stopped"].includes(_.activity.phase)))
9453
- for (const T of Tt(S?.execution)) this.clearFirstResponseTimer(T);
9454
- const k = _.activity.phase === "completed" && Tt(S?.execution).some((T) => this.firstResponseTimersByClientMessageId.has(T));
9455
- (b && _.sessionId === this.getState().sessionId || !k && ["completed", "failed", "stopped"].includes(_.activity.phase)) && this.directoryScope.detach(x);
9485
+ const _ = fn(g.conversation, g.directory, m), I = _.sessionId ? g.conversation.sessions[_.sessionId] : void 0;
9486
+ if (this.firstResponseTimersByClientMessageId.size && (u(ir(_, I?.queries.current, this.options.backendUrl).messages, _.sessionId), ["failed", "stopped"].includes(_.activity.phase)))
9487
+ for (const T of Tt(I?.execution)) this.clearFirstResponseTimer(T);
9488
+ const k = _.activity.phase === "completed" && Tt(I?.execution).some((T) => this.firstResponseTimersByClientMessageId.has(T));
9489
+ (w && _.sessionId === this.getState().sessionId || !k && ["completed", "failed", "stopped"].includes(_.activity.phase)) && this.directoryScope.detach(x);
9456
9490
  }
9457
- const I = this.getState();
9458
- u(I.messages, I.sessionId);
9459
- for (const x of I.messages) {
9491
+ const S = this.getState();
9492
+ u(S.messages, S.sessionId);
9493
+ for (const x of S.messages) {
9460
9494
  const m = d.get(x.id);
9461
9495
  (!m || m.content !== x.content || m.loading !== x.loading) && this.emit("message", x), x.content.trim() && x.content !== m?.content && (x.role === "assistant" || x.dataType === "commentary_history") && x.content.startsWith(m?.content ?? "") && this.emit("delta", x.content.slice(m?.content.length ?? 0));
9462
9496
  }
9463
- d = new Map(I.messages.map((x) => [x.id, x])), this.rebuildRuntimeInteractions(), this.emit("state", I);
9497
+ d = new Map(S.messages.map((x) => [x.id, x])), this.rebuildRuntimeInteractions(), this.emit("state", S);
9464
9498
  }), this.conversationObservation.wake();
9465
9499
  }
9466
9500
  async initializeDirectory() {
@@ -9820,7 +9854,7 @@ class $a {
9820
9854
  if (this.clientRuntime.isDisposed) return null;
9821
9855
  const i = e.trim(), s = n.attachments ?? [];
9822
9856
  if (!i && !s.length) return null;
9823
- if (this.options.productVariant === "customer_embedded" && (s.forEach(Cu), s.reduce((w, b) => w + b.sizeBytes, 0) > yu))
9857
+ if (this.options.productVariant === "customer_embedded" && (s.forEach(Cu), s.reduce((b, w) => b + w.sizeBytes, 0) > yu))
9824
9858
  throw new Error("Embedded attachments must total at most 50 MB per message");
9825
9859
  const o = n.clientMessageId ?? De(), a = mt(this.operationTimingReporter, {
9826
9860
  operation: "send",
@@ -9834,7 +9868,7 @@ class $a {
9834
9868
  if (n.initiatedBy || this.startFirstResponseTimer(o, n.submittedAt), l || await a.measure("authentication", () => this.waitForAuthentication()), this.clientRuntime.isDisposed || c !== this.submissionIntentRevision || l && l !== this.authenticatedUserId) return null;
9835
9869
  hr(this.clientRuntime, this.modelClientScopeId, o, r ?? null);
9836
9870
  const u = this.clientRuntime.engine.getState().slices.conversation.submissions[o];
9837
- if (u && (u.content !== i || JSON.stringify(u.attachments.map((w) => w.sourceId)) !== JSON.stringify(s.map((w) => w.id ?? w.storageKey ?? w.sandboxPath)))) throw new Error("User-message identity cannot be reused with different input.");
9871
+ if (u && (u.content !== i || JSON.stringify(u.attachments.map((b) => b.sourceId)) !== JSON.stringify(s.map((b) => b.id ?? b.storageKey ?? b.sandboxPath)))) throw new Error("User-message identity cannot be reused with different input.");
9838
9872
  const d = Ct(), h = !u && !n.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== d.url, y = this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId];
9839
9873
  if (!y) throw new Error("Conversation selection is not initialized.");
9840
9874
  u || await this.clientRuntime.engine.dispatch({
@@ -9848,19 +9882,19 @@ class $a {
9848
9882
  viewId: `sdk:${this.modelClientScopeId}`,
9849
9883
  rendererRevision: n.submittedAt ?? ++this.composerRevision,
9850
9884
  content: i,
9851
- attachments: s.map((w) => ({
9852
- sourceId: w.id ?? w.storageKey ?? w.sandboxPath,
9853
- name: w.name,
9854
- mimeType: w.mimeType,
9855
- sizeBytes: w.sizeBytes,
9856
- ...w.storageKey || w.sandboxPath ? { uploaded: {
9857
- id: w.id ?? null,
9858
- name: w.name,
9859
- mime_type: w.mimeType,
9860
- size_bytes: w.sizeBytes,
9861
- storage_key: w.storageKey ?? null,
9862
- sandbox_path: w.sandboxPath ?? null,
9863
- file_url: w.fileUrl ?? null
9885
+ attachments: s.map((b) => ({
9886
+ sourceId: b.id ?? b.storageKey ?? b.sandboxPath,
9887
+ name: b.name,
9888
+ mimeType: b.mimeType,
9889
+ sizeBytes: b.sizeBytes,
9890
+ ...b.storageKey || b.sandboxPath ? { uploaded: {
9891
+ id: b.id ?? null,
9892
+ name: b.name,
9893
+ mime_type: b.mimeType,
9894
+ size_bytes: b.sizeBytes,
9895
+ storage_key: b.storageKey ?? null,
9896
+ sandbox_path: b.sandboxPath ?? null,
9897
+ file_url: b.fileUrl ?? null
9864
9898
  } } : {}
9865
9899
  })),
9866
9900
  context: JSON.parse(JSON.stringify({
@@ -9873,19 +9907,19 @@ class $a {
9873
9907
  submittedAt: n.submittedAt ?? Date.now()
9874
9908
  });
9875
9909
  const g = this.directoryAuthority;
9876
- return this.clientRuntime.isDisposed ? null : new Promise((w, b) => {
9877
- let I = null, x = null;
9910
+ return this.clientRuntime.isDisposed ? null : new Promise((b, w) => {
9911
+ let S = null, x = null;
9878
9912
  const m = () => {
9879
9913
  const _ = this.clientRuntime.engine.getState().slices.conversation.submissions[o];
9880
9914
  if (!(_ && !_.cancelled && _.delivery !== "accepted" && _.delivery !== "failed"))
9881
- if (I?.(), x?.(), _?.delivery === "failed" && !_.cancelled) b(new Error(_.error?.message ?? "Message delivery failed."));
9915
+ if (S?.(), x?.(), _?.delivery === "failed" && !_.cancelled) w(new Error(_.error?.message ?? "Message delivery failed."));
9882
9916
  else {
9883
- const S = _?.invocation === "user" && _.contextPreparation?.pageContent ? _.context.page?.url : null;
9884
- _?.delivery === "accepted" && !_.cancelled && typeof S == "string" && c === this.submissionIntentRevision && g === this.directoryAuthority && this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId] === y && (this.lastUserMessagePageUrl = S), w(_?.delivery === "accepted" && !_.cancelled ? o : null);
9917
+ const I = _?.invocation === "user" && _.contextPreparation?.pageContent ? _.context.page?.url : null;
9918
+ _?.delivery === "accepted" && !_.cancelled && typeof I == "string" && c === this.submissionIntentRevision && g === this.directoryAuthority && this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId] === y && (this.lastUserMessagePageUrl = I), b(_?.delivery === "accepted" && !_.cancelled ? o : null);
9885
9919
  }
9886
9920
  };
9887
- I = this.clientRuntime.engine.subscribe(m), x = this.clientRuntime.onDispose(() => {
9888
- I?.(), w(null);
9921
+ S = this.clientRuntime.engine.subscribe(m), x = this.clientRuntime.onDispose(() => {
9922
+ S?.(), b(null);
9889
9923
  }), m();
9890
9924
  });
9891
9925
  }
@@ -9985,21 +10019,21 @@ class $a {
9985
10019
  }), new Promise((l, u) => {
9986
10020
  let d, h;
9987
10021
  const f = () => {
9988
- const y = this.clientRuntime.engine.getState().slices, g = y.conversation.operations[c], w = y.directory.authorityId !== a.authorityId || y.directory.clients[this.modelClientScopeId] !== r;
9989
- if (!w && g && !["done", "failed"].includes(g.phase)) return;
9990
- if (d?.(), h?.(), w || !g || g.phase === "failed") {
10022
+ const y = this.clientRuntime.engine.getState().slices, g = y.conversation.operations[c], b = y.directory.authorityId !== a.authorityId || y.directory.clients[this.modelClientScopeId] !== r;
10023
+ if (!b && g && !["done", "failed"].includes(g.phase)) return;
10024
+ if (d?.(), h?.(), b || !g || g.phase === "failed") {
9991
10025
  u(new Error(g?.error?.message ?? "Attachment preparation was cancelled."));
9992
10026
  return;
9993
10027
  }
9994
- const I = g.result.attachment;
10028
+ const S = g.result.attachment;
9995
10029
  l(xu({
9996
- id: I.id,
9997
- name: I.name,
9998
- mimeType: I.mime_type,
9999
- sizeBytes: I.size_bytes,
10000
- storageKey: I.storage_key,
10001
- sandboxPath: I.sandbox_path,
10002
- fileUrl: I.file_url
10030
+ id: S.id,
10031
+ name: S.name,
10032
+ mimeType: S.mime_type,
10033
+ sizeBytes: S.size_bytes,
10034
+ storageKey: S.storage_key,
10035
+ sandboxPath: S.sandbox_path,
10036
+ fileUrl: S.file_url
10003
10037
  }, this.options.backendUrl));
10004
10038
  };
10005
10039
  d = this.clientRuntime.engine.subscribe(f), h = this.clientRuntime.onDispose(() => {
@@ -10284,8 +10318,8 @@ class $a {
10284
10318
  now: Date.now(),
10285
10319
  feature: y,
10286
10320
  fact: { permission: g.permissionGranted ? "granted" : g.permissionNeeded ? "missing" : "unknown", revision: Math.max(Date.now(), this.clientRuntime.engine.getState().slices.interactions.deviceFacts[y].revision + 1), snoozedUntil: g.snoozedUntil ?? null }
10287
- }), y === "tab_grouping" && g.sessionId === h && h) for (const w of g.crossTabUserMessageIds ?? [])
10288
- await this.clientRuntime.engine.dispatch({ type: "stage7.cross_tab", authority: d, now: Date.now(), sessionId: h, userMessageId: w });
10321
+ }), y === "tab_grouping" && g.sessionId === h && h) for (const b of g.crossTabUserMessageIds ?? [])
10322
+ await this.clientRuntime.engine.dispatch({ type: "stage7.cross_tab", authority: d, now: Date.now(), sessionId: h, userMessageId: b });
10289
10323
  return g;
10290
10324
  }
10291
10325
  })).then(async (y) => {
@@ -10329,14 +10363,14 @@ class $a {
10329
10363
  "stage7.device": async ({ feature: u, action: d, requestId: h }) => {
10330
10364
  const f = this.options.runtimeAdapters?.featurePermissions;
10331
10365
  if (!f) return { fact: { permission: "unsupported", revision: Date.now(), snoozedUntil: null }, completedAt: Date.now() };
10332
- const y = this.clientRuntime.engine.getState().slices.interactions, g = y.promptActions[h], w = g?.expectedRevision ?? y.preferencePrompts[u].revision;
10333
- d === "allow" && await f.enable(u, { requestId: h, expectedRevision: w, action: g?.action === "enable" ? "enable" : "allow" }), d === "not_now" && await f.dismiss(u, { requestId: h, expectedRevision: w, action: "not_now" });
10334
- const b = await f.getState(u, this.getState().sessionId);
10335
- if (!b.bridgeReady) throw new Error("The Pluno extension is reconnecting. Try again.");
10366
+ const y = this.clientRuntime.engine.getState().slices.interactions, g = y.promptActions[h], b = g?.expectedRevision ?? y.preferencePrompts[u].revision;
10367
+ d === "allow" && await f.enable(u, { requestId: h, expectedRevision: b, action: g?.action === "enable" ? "enable" : "allow" }), d === "not_now" && await f.dismiss(u, { requestId: h, expectedRevision: b, action: "not_now" });
10368
+ const w = await f.getState(u, this.getState().sessionId);
10369
+ if (!w.bridgeReady) throw new Error("The Pluno extension is reconnecting. Try again.");
10336
10370
  return { fact: {
10337
- permission: b.permissionGranted === !0 ? "granted" : b.permissionNeeded ? "missing" : "unknown",
10371
+ permission: w.permissionGranted === !0 ? "granted" : w.permissionNeeded ? "missing" : "unknown",
10338
10372
  revision: Math.max(Date.now(), this.clientRuntime.engine.getState().slices.interactions.deviceFacts[u].revision + 1),
10339
- snoozedUntil: b.snoozedUntil ?? null
10373
+ snoozedUntil: w.snoozedUntil ?? null
10340
10374
  }, completedAt: Date.now() };
10341
10375
  },
10342
10376
  "stage7.platform": async (u) => {
@@ -10423,9 +10457,9 @@ class $a {
10423
10457
  reportHealthSignal(e, n = {}) {
10424
10458
  let i = this.getState();
10425
10459
  if (e === "first_response_slow" && n.sessionId && n.sessionId !== i.sessionId) {
10426
- const { conversation: y, directory: g } = this.clientRuntime.engine.getState().slices, w = Object.values(g.clients).find((b) => g.selections[b]?.sessionId === n.sessionId);
10427
- w && (i = { ...i, ...ir(
10428
- fn(y, g, w),
10460
+ const { conversation: y, directory: g } = this.clientRuntime.engine.getState().slices, b = Object.values(g.clients).find((w) => g.selections[w]?.sessionId === n.sessionId);
10461
+ b && (i = { ...i, ...ir(
10462
+ fn(y, g, b),
10429
10463
  y.sessions[n.sessionId]?.queries.current,
10430
10464
  this.options.backendUrl
10431
10465
  ) });
@@ -10716,7 +10750,7 @@ class $a {
10716
10750
  if (h.type === "run.stop" && f.selections[y]?.sessionId === h.payload.sessionId) {
10717
10751
  if (d) continue;
10718
10752
  d = !0;
10719
- const g = r.filter((w) => w.type === "run.stop" && w.payload.sessionId === h.payload.sessionId).map((w) => String(w.payload.expectedUserMessageId));
10753
+ const g = r.filter((b) => b.type === "run.stop" && b.payload.sessionId === h.payload.sessionId).map((b) => String(b.payload.expectedUserMessageId));
10720
10754
  await this.clientRuntime.engine.dispatch({
10721
10755
  ...u,
10722
10756
  type: "conversation.stop",
@@ -11207,38 +11241,38 @@ function Fm() {
11207
11241
  });
11208
11242
  }, n = window.fetch, i = XMLHttpRequest.prototype.open, s = XMLHttpRequest.prototype.setRequestHeader, o = XMLHttpRequest.prototype.send, a = function(f, y) {
11209
11243
  const g = Date.now();
11210
- let w;
11244
+ let b;
11211
11245
  try {
11212
- w = n.call(this, f, y);
11213
- } catch (b) {
11214
- throw b;
11246
+ b = n.call(this, f, y);
11247
+ } catch (w) {
11248
+ throw w;
11215
11249
  }
11216
11250
  try {
11217
- const b = f instanceof Request ? f : null, I = Fy(f, b), x = Au(y?.headers ?? b?.headers);
11218
- if (!Yn(I, x, y?.body)) {
11251
+ const w = f instanceof Request ? f : null, S = Fy(f, w), x = Au(y?.headers ?? w?.headers);
11252
+ if (!Yn(S, x, y?.body)) {
11219
11253
  const _ = {
11220
11254
  requestId: Sr("fetch"),
11221
- url: Qt(I, br),
11222
- method: (y?.method ?? b?.method ?? "GET").toUpperCase(),
11255
+ url: Qt(S, br),
11256
+ method: (y?.method ?? w?.method ?? "GET").toUpperCase(),
11223
11257
  requestHeaders: x,
11224
11258
  requestBody: Wl(y?.body),
11225
11259
  resourceType: "fetch",
11226
11260
  startedAt: new Date(g).toISOString()
11227
11261
  };
11228
- w.then(
11229
- (S) => {
11230
- $y(S, _, g, e).catch(() => {
11262
+ b.then(
11263
+ (I) => {
11264
+ $y(I, _, g, e).catch(() => {
11231
11265
  e({
11232
11266
  ..._,
11233
- responseStatus: S.status,
11267
+ responseStatus: I.status,
11234
11268
  durationMs: Date.now() - g
11235
11269
  });
11236
11270
  });
11237
11271
  },
11238
- (S) => {
11272
+ (I) => {
11239
11273
  e({
11240
11274
  ..._,
11241
- errorText: Qt(S instanceof Error ? S.message : String(S)),
11275
+ errorText: Qt(I instanceof Error ? I.message : String(I)),
11242
11276
  durationMs: Date.now() - g
11243
11277
  });
11244
11278
  }
@@ -11246,9 +11280,9 @@ function Fm() {
11246
11280
  }
11247
11281
  } catch {
11248
11282
  }
11249
- return w;
11250
- }, r = function(f, y, g, w, b) {
11251
- const I = i.call(this, f, y, g ?? !0, w ?? void 0, b ?? void 0), x = typeof y == "string" ? y : y.toString();
11283
+ return b;
11284
+ }, r = function(f, y, g, b, w) {
11285
+ const S = i.call(this, f, y, g ?? !0, b ?? void 0, w ?? void 0), x = typeof y == "string" ? y : y.toString();
11252
11286
  return vr.set(this, {
11253
11287
  requestId: Sr("xhr"),
11254
11288
  method: String(f ?? "GET").toUpperCase(),
@@ -11257,10 +11291,10 @@ function Fm() {
11257
11291
  startedAtMs: Date.now(),
11258
11292
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
11259
11293
  excluded: Yn(x)
11260
- }), I;
11294
+ }), S;
11261
11295
  }, c = function(f, y) {
11262
- const g = s.call(this, f, y), w = vr.get(this);
11263
- return w && Object.keys(w.requestHeaders).length < Fa && (w.requestHeaders[f] = Wa(f, y), w.excluded = w.excluded || Yn(w.url, w.requestHeaders)), g;
11296
+ const g = s.call(this, f, y), b = vr.get(this);
11297
+ return b && Object.keys(b.requestHeaders).length < Fa && (b.requestHeaders[f] = Wa(f, y), b.excluded = b.excluded || Yn(b.url, b.requestHeaders)), g;
11264
11298
  }, l = function(f) {
11265
11299
  try {
11266
11300
  const y = vr.get(this);
@@ -11626,9 +11660,9 @@ function ly() {
11626
11660
  function Ha() {
11627
11661
  if (!document.body)
11628
11662
  return "";
11629
- const t = [], e = [], n = (g, w) => {
11630
- const b = oi(w);
11631
- !b || e.includes(b) || (t.push([g, b]), e.push(b));
11663
+ const t = [], e = [], n = (g, b) => {
11664
+ const w = oi(b);
11665
+ !w || e.includes(w) || (t.push([g, w]), e.push(w));
11632
11666
  };
11633
11667
  n("Selected text", window.getSelection()?.toString() ?? "");
11634
11668
  const i = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", s = Array.from(document.querySelectorAll(i)).filter(
@@ -11638,8 +11672,8 @@ function Ha() {
11638
11672
  n("Active overlay", Ir(Fi(g), e));
11639
11673
  const o = dy(), a = o ? Ir(Fi(o), e) : "";
11640
11674
  n("Main page content", a), n("Additional visible page text", Ir(Fi(document.body), e));
11641
- const r = t.map(([g, w]) => `${g}:
11642
- ${w}`).join(`
11675
+ const r = t.map(([g, b]) => `${g}:
11676
+ ${b}`).join(`
11643
11677
 
11644
11678
  `).trim().slice(0, 12e3), c = uy(s, o).trim(), l = `Simplified DOM outline:
11645
11679
  `, u = `
@@ -11761,8 +11795,8 @@ function uy(t, e) {
11761
11795
  }, g = (x) => {
11762
11796
  const m = x.getAttribute("data-testid") || x.getAttribute("data-test") || x.getAttribute("data-qa") || x.getAttribute("data-cy") || "";
11763
11797
  return `${x.tagName.toLowerCase()}|${y(x)}|${m}`;
11764
- }, w = (x, m, _) => {
11765
- const S = (k, T) => {
11798
+ }, b = (x, m, _) => {
11799
+ const I = (k, T) => {
11766
11800
  const q = k.tagName.toLowerCase(), U = window.getComputedStyle(k), P = u.has(k);
11767
11801
  if (f >= 1e3 && !P || _.has(k) || o.has(q) || k.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || U.display === "none" || U.visibility === "hidden")
11768
11802
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
@@ -11784,13 +11818,13 @@ function uy(t, e) {
11784
11818
  $.has(F) || (de.push([`… ${ue.get(F) ?? 0} similar siblings omitted`]), $.add(F));
11785
11819
  continue;
11786
11820
  }
11787
- const Ee = S(W, T);
11821
+ const Ee = I(W, T);
11788
11822
  Me.push(Ee), de.push(Ee.lines);
11789
11823
  }
11790
11824
  const ce = [];
11791
11825
  if (k.shadowRoot)
11792
11826
  for (const W of Array.from(k.shadowRoot.children))
11793
- W instanceof HTMLElement && ce.push(S(W, T + 1));
11827
+ W instanceof HTMLElement && ce.push(I(W, T + 1));
11794
11828
  const Te = [...Me, ...ce], We = B.length > 0 || E || Te.some((W) => W.hasUsefulContent), ge = oi(
11795
11829
  [B, ...Te.map((W) => W.textPreview)].filter(Boolean).join(" ")
11796
11830
  ).slice(0, 180), Ie = k.hasAttribute("contenteditable") && (B.length > 0 || !k.querySelector("[contenteditable]")), me = l.some((W) => k.hasAttribute(W)) || !!z || Ie, ot = (k.getClientRects().length > 0 || U.display === "contents") && (n.has(q) || me || P) && (We || P) && (!s.has(q) || We || me || P), Q = ot ? 1 : 0, le = [];
@@ -11818,18 +11852,18 @@ function uy(t, e) {
11818
11852
  containsTextElement: i.has(q) || Te.some((W) => W.containsTextElement)
11819
11853
  };
11820
11854
  };
11821
- return [`--- ${m} ---`, ...S(x, 0).lines].join(`
11855
+ return [`--- ${m} ---`, ...I(x, 0).lines].join(`
11822
11856
  `);
11823
- }, b = [], I = oi(window.getSelection()?.toString() ?? "");
11824
- I && b.push(`--- selected text ---
11825
- ${JSON.stringify(I)}`), d.length > 0 && b.push(hy(d, n, c, a));
11857
+ }, w = [], S = oi(window.getSelection()?.toString() ?? "");
11858
+ S && w.push(`--- selected text ---
11859
+ ${JSON.stringify(S)}`), d.length > 0 && w.push(hy(d, n, c, a));
11826
11860
  for (const x of t.slice(0, 3))
11827
- b.push(w(x, "active overlay DOM", /* @__PURE__ */ new Set()));
11828
- if (e && b.push(w(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
11861
+ w.push(b(x, "active overlay DOM", /* @__PURE__ */ new Set()));
11862
+ if (e && w.push(b(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
11829
11863
  const x = e || t.length ? "other visible DOM" : "visible DOM";
11830
- b.push(w(document.body, x, h));
11864
+ w.push(b(document.body, x, h));
11831
11865
  }
11832
- return b.join(`
11866
+ return w.join(`
11833
11867
 
11834
11868
  `);
11835
11869
  }
@@ -12952,9 +12986,9 @@ function Tb(t, e, n, i) {
12952
12986
  const s = /* @__PURE__ */ new Map(), o = [], a = [];
12953
12987
  let r = 0, c = 0, l = 0, u = crypto.randomUUID(), d = i.getState();
12954
12988
  e.dataset.executionKey = d.activity?.executionKey ?? "";
12955
- let h = d.user?.id, f = null, y = "", g = "", w = "";
12956
- const b = e.ownerDocument.defaultView;
12957
- let I, x, m = /* @__PURE__ */ new Map(), _ = d.sessionId, S = d.selectionKey;
12989
+ let h = d.user?.id, f = null, y = "", g = "", b = "";
12990
+ const w = e.ownerDocument.defaultView;
12991
+ let S, x, m = /* @__PURE__ */ new Map(), _ = d.sessionId, I = d.selectionKey;
12958
12992
  const k = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Map();
12959
12993
  let q = null, U = null, P = null, z = 0, B = null, E = null, N = null;
12960
12994
  const Y = () => JSON.stringify([
@@ -12963,28 +12997,28 @@ function Tb(t, e, n, i) {
12963
12997
  Array.from(e.querySelectorAll('[data-message-role="user"]')).slice(-1)[0]?.dataset.messageKey,
12964
12998
  Array.from(e.querySelectorAll('[data-message-role="user"]')).slice(-1)[0]?.dataset.entryKey
12965
12999
  ]), ue = (Q) => {
12966
- const le = b.getComputedStyle(Q);
13000
+ const le = w.getComputedStyle(Q);
12967
13001
  return Q.getClientRects().length > 0 && le.visibility !== "hidden" && le.opacity !== "0" && le.pointerEvents !== "none" && !Q.matches(":disabled") && Q.getAttribute("aria-disabled") !== "true" && !Q.closest("[inert]");
12968
13002
  };
12969
13003
  function Pe() {
12970
- U !== null && b.clearTimeout(U), U = null, P = null;
13004
+ U !== null && w.clearTimeout(U), U = null, P = null;
12971
13005
  }
12972
13006
  function be(Q = !1) {
12973
- Pe(), E = null, N !== null && b.clearTimeout(N), N = null, I = void 0, x = void 0, m.clear(), T.clear(), q !== null && b.clearTimeout(q), q = null, Q && k.clear();
13007
+ Pe(), E = null, N !== null && w.clearTimeout(N), N = null, S = void 0, x = void 0, m.clear(), T.clear(), q !== null && w.clearTimeout(q), q = null, Q && k.clear();
12974
13008
  }
12975
13009
  function $() {
12976
13010
  if (Bs(e) !== "none") {
12977
13011
  be(!0);
12978
13012
  return;
12979
13013
  }
12980
- const Q = e.querySelector(".pluno-pa-widget__panel") ?? e, le = b.getComputedStyle(Q);
13014
+ const Q = e.querySelector(".pluno-pa-widget__panel") ?? e, le = w.getComputedStyle(Q);
12981
13015
  if (d.isLoadingSession || e.ownerDocument.hidden || !Q.getClientRects().length || le.visibility === "hidden" || le.display === "none" || le.opacity === "0") {
12982
13016
  be();
12983
13017
  return;
12984
13018
  }
12985
13019
  const ie = (O, H) => Array.from(e.querySelectorAll(O)).flatMap((V) => V.getAttribute(H) ? [V.getAttribute(H)] : []), W = ".pluno-pa-widget__tool-group--active, .tool-group--active, .pluno-pa-widget__thinking-marker, .thinking-marker, [data-thinking-status]", F = [];
12986
13020
  for (const O of Array.from(e.querySelectorAll(`${W}, [data-message-role="user"]`))) {
12987
- const H = b.getComputedStyle(O);
13021
+ const H = w.getComputedStyle(O);
12988
13022
  !O.getClientRects().length || H.visibility === "hidden" || H.opacity === "0" || O.parentElement?.closest(W) || F.push(O.dataset.messageRole === "user" ? "user" : "thinking");
12989
13023
  }
12990
13024
  let Se = 0;
@@ -13000,11 +13034,11 @@ function Tb(t, e, n, i) {
13000
13034
  for (let rt = 0; rt < _e.length; rt += 1)
13001
13035
  K = Math.imul(K ^ _e.charCodeAt(rt), 16777619) >>> 0;
13002
13036
  }
13003
- const he = b.performance.now();
13004
- K !== P && (P = K, z = he), Se = he - z, U !== null && b.clearTimeout(U), U = Se < 3e5 ? b.setTimeout($, 3e5 - Se) : null;
13037
+ const he = w.performance.now();
13038
+ K !== P && (P = K, z = he), Se = he - z, U !== null && w.clearTimeout(U), U = Se < 3e5 ? w.setTimeout($, 3e5 - Se) : null;
13005
13039
  } else
13006
13040
  Pe(), k.delete("thinking-without-progress");
13007
- const Oe = Array.from(e.querySelectorAll(".pluno-pa-widget__thinking-marker, .thinking-marker, [data-thinking-status]")).some((O) => O.getClientRects().length > 0 && b.getComputedStyle(O).visibility !== "hidden" && b.getComputedStyle(O).opacity !== "0"), Ee = d.isThinking || d.turnPhase != null || d.pendingMessageStatus != null || Oe;
13041
+ const Oe = Array.from(e.querySelectorAll(".pluno-pa-widget__thinking-marker, .thinking-marker, [data-thinking-status]")).some((O) => O.getClientRects().length > 0 && w.getComputedStyle(O).visibility !== "hidden" && w.getComputedStyle(O).opacity !== "0"), Ee = d.isThinking || d.turnPhase != null || d.pendingMessageStatus != null || Oe;
13008
13042
  (!Ee || E && E.responseKey !== Y()) && (E = null);
13009
13043
  const xe = {
13010
13044
  executionKey: d.activity?.executionKey,
@@ -13014,7 +13048,7 @@ function Tb(t, e, n, i) {
13014
13048
  enabledStopControlCount: Array.from(e.querySelectorAll(
13015
13049
  'button[aria-label="Stop"], button[aria-label="Stop generating"]'
13016
13050
  )).filter(ue).length,
13017
- stopPendingMs: E ? b.performance.now() - E.at : 0,
13051
+ stopPendingMs: E ? w.performance.now() - E.at : 0,
13018
13052
  thinkingSequence: F,
13019
13053
  thinkingIdleMs: Se,
13020
13054
  messageKeys: Array.from(e.querySelectorAll("[data-message-key], [data-entry-key][data-message-role]")).flatMap((O) => O.dataset.messageKey ?? O.dataset.entryKey ?? []),
@@ -13029,21 +13063,21 @@ function Tb(t, e, n, i) {
13029
13063
  runtimeItemCount: d.messages.filter(
13030
13064
  (O) => (O.role === "user" || O.role === "assistant") && O.phase !== "commentary" && !O.scheduledCheckInAt && !O.id.startsWith("local-") && !O.id.startsWith("optimistic-user-message:")
13031
13065
  ).length
13032
- }, Xe = e.matches("[data-selected-session-id]") ? e : e.querySelector("[data-selected-session-id]"), R = !Xe || (Xe.dataset.selectedSessionId || null) === d.sessionId, D = R && I ? {
13033
- ...I,
13034
- terminalResponseKeys: I.terminalResponseKeys.filter((O) => {
13066
+ }, Xe = e.matches("[data-selected-session-id]") ? e : e.querySelector("[data-selected-session-id]"), R = !Xe || (Xe.dataset.selectedSessionId || null) === d.sessionId, D = R && S ? {
13067
+ ...S,
13068
+ terminalResponseKeys: S.terminalResponseKeys.filter((O) => {
13035
13069
  const H = m.get(O), V = H ? d.removedItems?.[H] : void 0;
13036
13070
  return !V || xe.canonicalItemKeys.includes(H) || !xe.canonicalItemKeys.includes(V);
13037
13071
  })
13038
13072
  } : void 0, se = fm(xe, D), G = new Set(se.map((O) => O.code));
13039
13073
  for (const O of T.keys()) G.has(O) || T.delete(O);
13040
- const oe = b.performance.now();
13074
+ const oe = w.performance.now();
13041
13075
  for (const { code: O } of se) {
13042
13076
  if (k.has(O)) continue;
13043
13077
  const H = T.get(O) ?? { monotonicMs: oe, occurredAt: Date.now() };
13044
13078
  if (oe - H.monotonicMs >= 250) {
13045
13079
  k.add(O), T.delete(O);
13046
- const V = Gp(xe, I, e);
13080
+ const V = Gp(xe, S, e);
13047
13081
  V.before && (V.before.context = x);
13048
13082
  const K = Math.floor(oe - H.monotonicMs);
13049
13083
  V.current.context = {
@@ -13054,7 +13088,7 @@ function Tb(t, e, n, i) {
13054
13088
  } else
13055
13089
  T.set(O, H);
13056
13090
  }
13057
- se.length === 0 && R && (I = xe, x = zr(e, d, { renderSource: "observer" }), m = new Map(Array.from(e.querySelectorAll("[data-terminal-response-key][data-canonical-item-key]")).map((O) => [O.dataset.terminalResponseKey, O.dataset.canonicalItemKey]))), q !== null && b.clearTimeout(q), q = T.size ? b.setTimeout(() => {
13091
+ se.length === 0 && R && (S = xe, x = zr(e, d, { renderSource: "observer" }), m = new Map(Array.from(e.querySelectorAll("[data-terminal-response-key][data-canonical-item-key]")).map((O) => [O.dataset.terminalResponseKey, O.dataset.canonicalItemKey]))), q !== null && w.clearTimeout(q), q = T.size ? w.setTimeout(() => {
13058
13092
  q = null, $();
13059
13093
  }, Math.max(1, 250 - (oe - Math.min(...Array.from(T.values(), (O) => O.monotonicMs))))) : null;
13060
13094
  }
@@ -13082,7 +13116,7 @@ function Tb(t, e, n, i) {
13082
13116
  };
13083
13117
  if (Q === "paint" && i.reportResponseVisibility) {
13084
13118
  const G = e.querySelector(".pluno-pa-widget__panel") ?? e, oe = (_e) => {
13085
- const rt = b.getComputedStyle(_e);
13119
+ const rt = w.getComputedStyle(_e);
13086
13120
  return _e.getClientRects().length > 0 && rt.visibility !== "hidden" && rt.display !== "none" && rt.opacity !== "0";
13087
13121
  }, O = oe(G) && oe(e), H = !e.ownerDocument.hidden, V = new Set(Array.from(e.querySelectorAll("[data-canonical-item-key]")).filter(oe).map((_e) => _e.dataset.canonicalItemKey)), K = O && H && !d.isLoadingSession ? [...d.messages].reverse().find((_e) => (_e.role === "assistant" || _e.dataType === "commentary_history" || _e.dataType === "tool_summary") && V.has(_e.id)) : void 0, he = O && H && !d.isLoadingSession && !!d.assistantDraft.trim() && Array.from(e.querySelectorAll("[data-message-key], [data-entry-key]")).some((_e) => oe(_e) && (_e.dataset.messageKey === `assistant:${d.assistantDraftItemId}` || _e.dataset.entryKey === d.assistantDraftItemId)), re = {
13088
13122
  sessionId: d.sessionId,
@@ -13092,7 +13126,7 @@ function Tb(t, e, n, i) {
13092
13126
  documentVisible: H,
13093
13127
  loading: d.isLoadingSession
13094
13128
  }, _t = JSON.stringify(re);
13095
- _t !== w && (w = _t, i.reportResponseVisibility({ ...re, observedAt: (/* @__PURE__ */ new Date()).toISOString() }));
13129
+ _t !== b && (b = _t, i.reportResponseVisibility({ ...re, observedAt: (/* @__PURE__ */ new Date()).toISOString() }));
13096
13130
  }
13097
13131
  const Ee = [...d.messages].reverse().find((G) => G.role === "user" && (!d.activeResponseUserMessageId || G.id === d.activeResponseUserMessageId)), xe = d.activity?.phase === "submitting" || d.turnPhase === "sending" || d.pendingMessageStatus === "sending", Xe = d.activity?.phase === "stopping";
13098
13132
  if (Ee && i.reportOperationTiming) {
@@ -13120,7 +13154,7 @@ function Tb(t, e, n, i) {
13120
13154
  const D = {
13121
13155
  sequence: ++l,
13122
13156
  occurred_at: (/* @__PURE__ */ new Date()).toISOString(),
13123
- monotonic_ms: Math.round(b.performance.now()),
13157
+ monotonic_ms: Math.round(w.performance.now()),
13124
13158
  kind: Q,
13125
13159
  action: le,
13126
13160
  ...Oe
@@ -13129,12 +13163,12 @@ function Tb(t, e, n, i) {
13129
13163
  o.shift(), r -= a.shift(), c += 1;
13130
13164
  }
13131
13165
  function Me() {
13132
- f === null && (f = b.requestAnimationFrame(() => {
13166
+ f === null && (f = w.requestAnimationFrame(() => {
13133
13167
  f = null, de("paint"), $();
13134
13168
  }));
13135
13169
  }
13136
13170
  const ce = i.on("state", (Q) => {
13137
- Q.user?.id !== h || Q.sessionId !== _ || Q.selectionKey !== S ? (be(!0), _ = Q.sessionId, S = Q.selectionKey) : Q.isLoadingSession && be(), Q.user?.id !== h && (s.clear(), o.length = 0, a.length = 0, r = 0, c = 0, l = 0, u = crypto.randomUUID(), y = "", g = "", w = "", h = Q.user?.id), d = Q, e.dataset.executionKey = d.activity?.executionKey ?? "", de("runtime"), Me();
13171
+ Q.user?.id !== h || Q.sessionId !== _ || Q.selectionKey !== I ? (be(!0), _ = Q.sessionId, I = Q.selectionKey) : Q.isLoadingSession && be(), Q.user?.id !== h && (s.clear(), o.length = 0, a.length = 0, r = 0, c = 0, l = 0, u = crypto.randomUUID(), y = "", g = "", b = "", h = Q.user?.id), d = Q, e.dataset.executionKey = d.activity?.executionKey ?? "", de("runtime"), Me();
13138
13172
  }), Te = new MutationObserver(Me);
13139
13173
  Te.observe(e, {
13140
13174
  subtree: !0,
@@ -13145,7 +13179,7 @@ function Tb(t, e, n, i) {
13145
13179
  });
13146
13180
  const We = (Q) => {
13147
13181
  const le = Q.target?.closest?.("button"), ie = le?.getAttribute("aria-label") ?? le?.getAttribute("title"), W = ie === "New chat" ? "new_chat" : ie === "Send" || ie === "Send message" ? "send" : ie === "Stop" || ie === "Stop generating" ? "stop" : ie === "Retry" || ie === "Retry message" ? "retry" : null;
13148
- de("click", W), W === "stop" && le && ue(le) && (E = { at: b.performance.now(), responseKey: Y() }, N !== null && b.clearTimeout(N), N = b.setTimeout($, 1e3)), W === "new_chat" && be(!0);
13182
+ de("click", W), W === "stop" && le && ue(le) && (E = { at: w.performance.now(), responseKey: Y() }, N !== null && w.clearTimeout(N), N = w.setTimeout($, 1e3)), W === "new_chat" && be(!0);
13149
13183
  }, ge = () => de("submit"), Ie = () => de("focus");
13150
13184
  e.addEventListener("click", We, !0), e.addEventListener("submit", ge, !0), e.addEventListener("focusin", Ie, !0), e.addEventListener("input", Me, !0);
13151
13185
  const me = () => {
@@ -13162,7 +13196,7 @@ function Tb(t, e, n, i) {
13162
13196
  records: o.map((Q) => ({ ...Q, item_keys: [...Q.item_keys] }))
13163
13197
  }),
13164
13198
  dispose: () => {
13165
- ce(), Te.disconnect(), be(!0), f !== null && b.cancelAnimationFrame(f), e.removeEventListener("click", We, !0), e.removeEventListener("submit", ge, !0), e.removeEventListener("focusin", Ie, !0), e.removeEventListener("input", Me, !0), e.ownerDocument.removeEventListener("visibilitychange", me), t.__plunoUiFlightRecorder === ot && delete t.__plunoUiFlightRecorder;
13199
+ ce(), Te.disconnect(), be(!0), f !== null && w.cancelAnimationFrame(f), e.removeEventListener("click", We, !0), e.removeEventListener("submit", ge, !0), e.removeEventListener("focusin", Ie, !0), e.removeEventListener("input", Me, !0), e.ownerDocument.removeEventListener("visibilitychange", me), t.__plunoUiFlightRecorder === ot && delete t.__plunoUiFlightRecorder;
13166
13200
  }
13167
13201
  };
13168
13202
  return t.__plunoUiFlightRecorder = ot, de("runtime"), Me(), ot;
@@ -13345,7 +13379,7 @@ async function lw(t = {}) {
13345
13379
  fontFamily: e.fontFamily,
13346
13380
  scribbleStyle: e.scribbleStyle
13347
13381
  });
13348
- const w = e.mountTarget ?? await N_(), b = w.ownerDocument, I = r.querySelector(
13382
+ const b = e.mountTarget ?? await N_(), w = b.ownerDocument, S = r.querySelector(
13349
13383
  ".pluno-pa-widget__launcher"
13350
13384
  ), x = r.querySelector(
13351
13385
  ".pluno-pa-widget__launcher-drag-handle"
@@ -13353,7 +13387,7 @@ async function lw(t = {}) {
13353
13387
  ".pluno-pa-widget__launcher-input"
13354
13388
  ), _ = r.querySelector(
13355
13389
  ".pluno-pa-widget__status--launcher"
13356
- ), S = r.querySelector(
13390
+ ), I = r.querySelector(
13357
13391
  ".pluno-pa-widget__launcher-minimize"
13358
13392
  ), k = r.querySelector(".pluno-pa-widget__panel"), T = r.querySelector(
13359
13393
  ".pluno-pa-widget__panel-drag-handle"
@@ -13452,7 +13486,7 @@ async function lw(t = {}) {
13452
13486
  ), he = r.querySelector(
13453
13487
  ".pluno-pa-widget__proactive-suggestion-feedback-status"
13454
13488
  );
13455
- if (!I || !m || !k || !P || !z || !B || !E || !ue || !Pe || !be || !$ || !de || !Me || !Te || !We || !ge || !Ie || !me || !ot || !Q || !le || !ie || !W || !F || !Se)
13489
+ if (!S || !m || !k || !P || !z || !B || !E || !ue || !Pe || !be || !$ || !de || !Me || !Te || !We || !ge || !Ie || !me || !ot || !Q || !le || !ie || !W || !F || !Se)
13456
13490
  throw new Error("Failed to mount Pluno widget");
13457
13491
  if (e.movableLauncher && !x)
13458
13492
  throw new Error("Failed to mount Pluno widget drag handle");
@@ -13467,7 +13501,7 @@ async function lw(t = {}) {
13467
13501
  r.classList.toggle(
13468
13502
  "pluno-pa-widget--proactive-suggestion-below",
13469
13503
  ww(
13470
- I.getBoundingClientRect(),
13504
+ S.getBoundingClientRect(),
13471
13505
  xe.getBoundingClientRect().height
13472
13506
  )
13473
13507
  );
@@ -13514,10 +13548,10 @@ async function lw(t = {}) {
13514
13548
  let vt = 0, en = 0, sc = 0;
13515
13549
  const qt = /* @__PURE__ */ new Map();
13516
13550
  let tn = null, jt = null;
13517
- const ho = (p) => p === $ ? "widget_composer" : p === m ? "widget_launcher" : p && a.contains(p) ? "widget_control" : p === b.body ? "body" : p === b.documentElement ? "document" : p ? "host_page" : "none", _n = (p, v, C = {}) => {
13518
- const A = xs(b), j = C.skipIfAlreadyFocused === !0 && A === p;
13551
+ const ho = (p) => p === $ ? "widget_composer" : p === m ? "widget_launcher" : p && a.contains(p) ? "widget_control" : p === w.body ? "body" : p === w.documentElement ? "document" : p ? "host_page" : "none", _n = (p, v, C = {}) => {
13552
+ const A = xs(w), j = C.skipIfAlreadyFocused === !0 && A === p;
13519
13553
  j || (C.preventScroll ? p.focus({ preventScroll: !0 }) : p.focus());
13520
- const X = xs(b);
13554
+ const X = xs(w);
13521
13555
  return nt(
13522
13556
  "web-sdk.widget.focus",
13523
13557
  "Programmatic widget focus",
@@ -13644,7 +13678,7 @@ async function lw(t = {}) {
13644
13678
  const cc = (p) => {
13645
13679
  de.open && !p.composedPath().includes(de) && (de.open = !1);
13646
13680
  };
13647
- b.addEventListener("pointerdown", cc, !0);
13681
+ w.addEventListener("pointerdown", cc, !0);
13648
13682
  for (const p of ce)
13649
13683
  p.addEventListener("click", () => {
13650
13684
  const v = Ns.find((A) => A.value === p.dataset.model);
@@ -13659,9 +13693,9 @@ async function lw(t = {}) {
13659
13693
  hi = !1, Wn();
13660
13694
  });
13661
13695
  });
13662
- w.appendChild(o);
13696
+ b.appendChild(o);
13663
13697
  const Ji = e.manageTaskPageTitle && e.productVariant === "personal" && e.entrySurface === "main_web_chat" ? new um(
13664
- pm(b)
13698
+ pm(w)
13665
13699
  ) : null;
13666
13700
  nt(
13667
13701
  "web-sdk.widget",
@@ -13771,9 +13805,9 @@ async function lw(t = {}) {
13771
13805
  const p = Ve.data?.nextCursor ?? null;
13772
13806
  Ve.status === "loading_more" || !p || me.scrollHeight - me.scrollTop - me.clientHeight <= 24 && M.loadMoreSessionHistory();
13773
13807
  }, mc = () => {
13774
- Ue || typeof document > "u" || (Sd(a, e.accentColor), o.isConnected || (e.mountTarget?.isConnected ? e.mountTarget.appendChild(o) : e.mountTarget || b.body?.appendChild(o)));
13808
+ Ue || typeof document > "u" || (Sd(a, e.accentColor), o.isConnected || (e.mountTarget?.isConnected ? e.mountTarget.appendChild(o) : e.mountTarget || w.body?.appendChild(o)));
13775
13809
  }, yc = new MutationObserver(mc);
13776
- yc.observe(b.documentElement, {
13810
+ yc.observe(w.documentElement, {
13777
13811
  childList: !0,
13778
13812
  subtree: !0
13779
13813
  }), mc();
@@ -13801,10 +13835,10 @@ async function lw(t = {}) {
13801
13835
  }, mi = (p, v = !0, C = "external_request") => {
13802
13836
  const A = r.classList.contains("pluno-pa-widget--minimized");
13803
13837
  if (xd(e, p), p === "shown") {
13804
- r.classList.remove("pluno-pa-widget--minimized"), I.removeAttribute("tabindex"), I.removeAttribute("role"), I.removeAttribute("aria-label"), !r.classList.contains("pluno-pa-widget--open") && !r.classList.contains("pluno-pa-widget--closing") && yi(!1), v && es("shown", C);
13838
+ r.classList.remove("pluno-pa-widget--minimized"), S.removeAttribute("tabindex"), S.removeAttribute("role"), S.removeAttribute("aria-label"), !r.classList.contains("pluno-pa-widget--open") && !r.classList.contains("pluno-pa-widget--closing") && yi(!1), v && es("shown", C);
13805
13839
  return;
13806
13840
  }
13807
- It !== null && (window.clearTimeout(It), It = null), r.classList.remove("pluno-pa-widget--open"), r.classList.remove("pluno-pa-widget--closing"), r.classList.add("pluno-pa-widget--minimized"), I.hidden = !1, I.setAttribute("role", "button"), I.setAttribute("aria-label", "Open Pluno"), k.hidden = !0, P.hidden = !0, I.tabIndex = 0, $.value = "", at(), hn(
13841
+ It !== null && (window.clearTimeout(It), It = null), r.classList.remove("pluno-pa-widget--open"), r.classList.remove("pluno-pa-widget--closing"), r.classList.add("pluno-pa-widget--minimized"), S.hidden = !1, S.setAttribute("role", "button"), S.setAttribute("aria-label", "Open Pluno"), k.hidden = !0, P.hidden = !0, S.tabIndex = 0, $.value = "", at(), hn(
13808
13842
  r,
13809
13843
  Ar(
13810
13844
  r,
@@ -13824,7 +13858,7 @@ async function lw(t = {}) {
13824
13858
  bottom: r.style.bottom
13825
13859
  },
13826
13860
  rootRect: qr(r),
13827
- launcherRect: qr(I),
13861
+ launcherRect: qr(S),
13828
13862
  panelRect: qr(k),
13829
13863
  viewport: Ye(),
13830
13864
  panelHidden: k.hidden,
@@ -13895,7 +13929,7 @@ async function lw(t = {}) {
13895
13929
  };
13896
13930
  window.addEventListener("resize", bc), e.movableLauncher && x ? (yi(), wc = hw({
13897
13931
  root: r,
13898
- launcher: I,
13932
+ launcher: S,
13899
13933
  launcherDragHandle: x,
13900
13934
  getPosition: () => fi(),
13901
13935
  setPosition: (p) => {
@@ -14035,7 +14069,7 @@ async function lw(t = {}) {
14035
14069
  openPanelPosition: pe,
14036
14070
  visibleLauncherPosition: ee
14037
14071
  }), dt(!0, "open"), St(), !X && e.layout === "floating" && M.recordWidgetLifecycle("opened", j), !v) {
14038
- r.classList.add("pluno-pa-widget--open"), X || vo(), I.hidden = !0, p && ($.value = p, Oi($)), Xn(F, () => Ft.enabled), rn = F.scrollTop, C && (_n($, "panel_open_immediate"), $.setSelectionRange($.value.length, $.value.length)), Ge(), es("shown", j), e.onPanelOpenChange?.(!0, j);
14072
+ r.classList.add("pluno-pa-widget--open"), X || vo(), S.hidden = !0, p && ($.value = p, Oi($)), Xn(F, () => Ft.enabled), rn = F.scrollTop, C && (_n($, "panel_open_immediate"), $.setSelectionRange($.value.length, $.value.length)), Ge(), es("shown", j), e.onPanelOpenChange?.(!0, j);
14039
14073
  return;
14040
14074
  }
14041
14075
  const kt = Date.now();
@@ -14043,20 +14077,20 @@ async function lw(t = {}) {
14043
14077
  r.classList.add("pluno-pa-widget--open"), X || vo(), p && ($.value = p, Oi($)), Xn(F, () => Ft.enabled), rn = F.scrollTop, C && (_n($, "panel_open_animation", {
14044
14078
  scheduledAt: kt
14045
14079
  }), $.setSelectionRange($.value.length, $.value.length)), Ge(), es("shown", j), e.onPanelOpenChange?.(!0, j), It = window.setTimeout(() => {
14046
- I.hidden = !0, Xn(F, () => Ft.enabled), rn = F.scrollTop;
14080
+ S.hidden = !0, Xn(F, () => Ft.enabled), rn = F.scrollTop;
14047
14081
  }, 220);
14048
14082
  });
14049
14083
  }, Eo = (p = "external_request") => {
14050
14084
  const v = r.classList.contains("pluno-pa-widget--open") || !k.hidden && !r.classList.contains("pluno-pa-widget--closing");
14051
- It !== null && (window.clearTimeout(It), It = null), I.hidden = !1, d && (yi(!1), Sn("Closing launcher at stored position")), r.classList.remove("pluno-pa-widget--open"), r.classList.add("pluno-pa-widget--closing"), at(), Ge(), v && e.layout === "floating" && M.recordWidgetLifecycle("closed", p), e.onPanelOpenChange?.(!1, p), It = window.setTimeout(() => {
14085
+ It !== null && (window.clearTimeout(It), It = null), S.hidden = !1, d && (yi(!1), Sn("Closing launcher at stored position")), r.classList.remove("pluno-pa-widget--open"), r.classList.add("pluno-pa-widget--closing"), at(), Ge(), v && e.layout === "floating" && M.recordWidgetLifecycle("closed", p), e.onPanelOpenChange?.(!1, p), It = window.setTimeout(() => {
14052
14086
  k.hidden = !0, P.hidden = !0, y = null, r.classList.remove("pluno-pa-widget--closing");
14053
14087
  }, 220);
14054
14088
  };
14055
- I.addEventListener("submit", (p) => {
14089
+ S.addEventListener("submit", (p) => {
14056
14090
  p.preventDefault(), Mt(m.value, !0, !0, !0, "launcher_input"), m.value = "";
14057
14091
  }), x?.addEventListener("click", (p) => {
14058
14092
  p.preventDefault(), p.stopPropagation();
14059
- }), I.addEventListener("click", (p) => {
14093
+ }), S.addEventListener("click", (p) => {
14060
14094
  p.target === m && !x || (Mt(m.value, !0, !0, !0, "launcher_click"), m.value = "");
14061
14095
  });
14062
14096
  const xc = () => {
@@ -14094,7 +14128,7 @@ async function lw(t = {}) {
14094
14128
  v = j instanceof ShadowRoot ? j.host : null;
14095
14129
  }
14096
14130
  return null;
14097
- }, Ao = () => xs(b), xp = (p) => {
14131
+ }, Ao = () => xs(w), xp = (p) => {
14098
14132
  if (!p.isConnected || !p.matches(ed))
14099
14133
  return !1;
14100
14134
  if (!(p instanceof HTMLElement))
@@ -14153,15 +14187,15 @@ async function lw(t = {}) {
14153
14187
  const v = kc(p);
14154
14188
  v && (_i = Date.now(), Ht !== null && (p.stopImmediatePropagation(), an = null, ze !== null && (window.clearTimeout(ze), ze = null), Ge(), p.type === "focus" && v === m && xc()));
14155
14189
  };
14156
- b.defaultView?.addEventListener(
14190
+ w.defaultView?.addEventListener(
14157
14191
  "pointerdown",
14158
14192
  Ec,
14159
14193
  !0
14160
- ), b.defaultView?.addEventListener(
14194
+ ), w.defaultView?.addEventListener(
14161
14195
  "focus",
14162
14196
  ss,
14163
14197
  !0
14164
- ), b.defaultView?.addEventListener(
14198
+ ), w.defaultView?.addEventListener(
14165
14199
  "focusin",
14166
14200
  ss,
14167
14201
  !0
@@ -14189,11 +14223,11 @@ async function lw(t = {}) {
14189
14223
  j(p.relatedTarget) || window.setTimeout(() => {
14190
14224
  Ht === null && C.isConnected && j(Ao());
14191
14225
  }, 0);
14192
- }), I.addEventListener("keydown", (p) => {
14226
+ }), S.addEventListener("keydown", (p) => {
14193
14227
  !r.classList.contains("pluno-pa-widget--minimized") || p.key !== "Enter" && p.key !== " " || (p.preventDefault(), Mt("", !0, !0, !0, "minimized_launcher"));
14194
- }), S?.addEventListener("pointerdown", (p) => {
14228
+ }), I?.addEventListener("pointerdown", (p) => {
14195
14229
  p.stopPropagation();
14196
- }), S?.addEventListener("click", (p) => {
14230
+ }), I?.addEventListener("click", (p) => {
14197
14231
  p.preventDefault(), p.stopPropagation(), mi("minimized", !0, "minimize_button");
14198
14232
  }), P.addEventListener("click", () => Eo("close_button")), F.addEventListener("wheel", (p) => {
14199
14233
  Zi(p.deltaY < 0 ? "up" : null);
@@ -14411,11 +14445,11 @@ async function lw(t = {}) {
14411
14445
  const Dc = (p) => {
14412
14446
  r.classList.contains("pluno-pa-widget--drag-over") && !p.composedPath().includes(r) && cn();
14413
14447
  };
14414
- b.addEventListener(
14448
+ w.addEventListener(
14415
14449
  "dragover",
14416
14450
  Dc,
14417
14451
  !0
14418
- ), b.addEventListener("drop", cn, !0), b.addEventListener("dragend", cn, !0), b.defaultView?.addEventListener("blur", cn), r.addEventListener("drop", (p) => {
14452
+ ), w.addEventListener("drop", cn, !0), w.addEventListener("dragend", cn, !0), w.defaultView?.addEventListener("blur", cn), r.addEventListener("drop", (p) => {
14419
14453
  const v = p.dataTransfer;
14420
14454
  !e.attachmentsEnabled || !ks(v) || e.loginRequired || An() || (p.preventDefault(), p.stopPropagation(), cn(), Do(v.files).catch((C) => {
14421
14455
  as(
@@ -14474,7 +14508,7 @@ async function lw(t = {}) {
14474
14508
  }, Uc = (p) => {
14475
14509
  if (!Lc || k.hidden || r.classList.contains("pluno-pa-widget--closing"))
14476
14510
  return;
14477
- const v = a.activeElement ?? b.activeElement, C = Sb(p, v);
14511
+ const v = a.activeElement ?? w.activeElement, C = Sb(p, v);
14478
14512
  if (!C || $.disabled || $.readOnly)
14479
14513
  return;
14480
14514
  p.preventDefault();
@@ -14486,11 +14520,11 @@ async function lw(t = {}) {
14486
14520
  );
14487
14521
  $.value = A.value, $.dispatchEvent(new Event("input", { bubbles: !0 })), Ib($), $.setSelectionRange(A.caret, A.caret);
14488
14522
  };
14489
- b.addEventListener(
14523
+ w.addEventListener(
14490
14524
  "pointerdown",
14491
14525
  Nc,
14492
14526
  !0
14493
- ), b.addEventListener(
14527
+ ), w.addEventListener(
14494
14528
  "keydown",
14495
14529
  Uc
14496
14530
  ), r.addEventListener("copy", (p) => {
@@ -14810,9 +14844,9 @@ async function lw(t = {}) {
14810
14844
  Math.min(Gc, 2147483647)
14811
14845
  )), X ? (rn = F.scrollTop, St()) : j && ud(p) && mp();
14812
14846
  }, Kc = () => {
14813
- b.getSelection()?.isCollapsed !== !1 && m_(ds) && Ce(M.getState());
14847
+ w.getSelection()?.isCollapsed !== !1 && m_(ds) && Ce(M.getState());
14814
14848
  };
14815
- b.addEventListener(
14849
+ w.addEventListener(
14816
14850
  "selectionchange",
14817
14851
  Kc
14818
14852
  );
@@ -14894,33 +14928,33 @@ async function lw(t = {}) {
14894
14928
  mi("minimized", !1);
14895
14929
  },
14896
14930
  destroy: () => {
14897
- Ue || (Op(), Dp.dispose(), Lp(), Ge(), Ue = !0, ic(), Pp(), Mp(), yc.disconnect(), b.removeEventListener(
14931
+ Ue || (Op(), Dp.dispose(), Lp(), Ge(), Ue = !0, ic(), Pp(), Mp(), yc.disconnect(), w.removeEventListener(
14898
14932
  "selectionchange",
14899
14933
  Kc
14900
- ), b.removeEventListener("pointerdown", cc, !0), b.removeEventListener(
14934
+ ), w.removeEventListener("pointerdown", cc, !0), w.removeEventListener(
14901
14935
  "pointerdown",
14902
14936
  Nc,
14903
14937
  !0
14904
- ), b.removeEventListener(
14938
+ ), w.removeEventListener(
14905
14939
  "keydown",
14906
14940
  Uc
14907
- ), Cc?.disconnect(), Rc?.disconnect(), kp(), b.defaultView?.removeEventListener(
14941
+ ), Cc?.disconnect(), Rc?.disconnect(), kp(), w.defaultView?.removeEventListener(
14908
14942
  "pointerdown",
14909
14943
  Ec,
14910
14944
  !0
14911
- ), b.defaultView?.removeEventListener(
14945
+ ), w.defaultView?.removeEventListener(
14912
14946
  "focus",
14913
14947
  ss,
14914
14948
  !0
14915
- ), b.defaultView?.removeEventListener(
14949
+ ), w.defaultView?.removeEventListener(
14916
14950
  "focusin",
14917
14951
  ss,
14918
14952
  !0
14919
- ), b.removeEventListener(
14953
+ ), w.removeEventListener(
14920
14954
  "dragover",
14921
14955
  Dc,
14922
14956
  !0
14923
- ), b.removeEventListener("drop", cn, !0), b.removeEventListener("dragend", cn, !0), b.defaultView?.removeEventListener(
14957
+ ), w.removeEventListener("drop", cn, !0), w.removeEventListener("dragend", cn, !0), w.defaultView?.removeEventListener(
14924
14958
  "blur",
14925
14959
  cn
14926
14960
  ), window.removeEventListener("resize", bc), wc(), vp(), Ip(), jt !== null && window.clearTimeout(jt), lt !== null && (window.clearTimeout(lt), lt = null), fp(), vn !== null && (window.clearTimeout(vn), vn = null), sn !== null && (window.clearTimeout(sn), sn = null), Ji?.clear(), rc && M.destroy(), go?.release(), o.remove());
@@ -14933,7 +14967,7 @@ async function lw(t = {}) {
14933
14967
  return;
14934
14968
  } catch {
14935
14969
  }
14936
- const v = xs(b), C = v instanceof HTMLElement ? v : null, A = document.createElement("textarea");
14970
+ const v = xs(w), C = v instanceof HTMLElement ? v : null, A = document.createElement("textarea");
14937
14971
  A.value = p, A.readOnly = !0, A.setAttribute("aria-hidden", "true"), A.style.position = "fixed", A.style.left = "-9999px", A.style.opacity = "0", document.body.appendChild(A);
14938
14972
  try {
14939
14973
  if (A.select(), A.setSelectionRange(0, p.length), !document.execCommand("copy"))
@@ -15035,35 +15069,35 @@ function hw({
15035
15069
  let a = null, r = null, c = null, l = !1, u = null;
15036
15070
  const d = () => {
15037
15071
  a = null, r = null, c = null, l = !1, t.classList.remove("pluno-pa-widget--dragging");
15038
- }, h = (I) => {
15039
- t.classList.contains("pluno-pa-widget--open") || t.classList.contains("pluno-pa-widget--closing") || (I.preventDefault(), I.stopPropagation(), a = I.pointerId, r = { x: I.clientX, y: I.clientY }, c = i(), l = !1, e.setPointerCapture?.(I.pointerId));
15040
- }, f = (I) => {
15041
- if (a !== I.pointerId || !r || !c)
15072
+ }, h = (S) => {
15073
+ t.classList.contains("pluno-pa-widget--open") || t.classList.contains("pluno-pa-widget--closing") || (S.preventDefault(), S.stopPropagation(), a = S.pointerId, r = { x: S.clientX, y: S.clientY }, c = i(), l = !1, e.setPointerCapture?.(S.pointerId));
15074
+ }, f = (S) => {
15075
+ if (a !== S.pointerId || !r || !c)
15042
15076
  return;
15043
- I.preventDefault();
15044
- const x = I.clientX - r.x, m = I.clientY - r.y;
15077
+ S.preventDefault();
15078
+ const x = S.clientX - r.x, m = S.clientY - r.y;
15045
15079
  !l && Math.hypot(x, m) < Qs || (l = !0, t.classList.add("pluno-pa-widget--dragging"), s({ x: c.x + x, y: c.y + m }));
15046
- }, y = (I) => {
15047
- a === I.pointerId && (I.preventDefault(), I.stopPropagation(), l && (u = { x: I.clientX, y: I.clientY }, o()), d());
15048
- }, g = (I) => {
15049
- a === I.pointerId && (I.preventDefault(), d());
15050
- }, w = (I) => {
15080
+ }, y = (S) => {
15081
+ a === S.pointerId && (S.preventDefault(), S.stopPropagation(), l && (u = { x: S.clientX, y: S.clientY }, o()), d());
15082
+ }, g = (S) => {
15083
+ a === S.pointerId && (S.preventDefault(), d());
15084
+ }, b = (S) => {
15051
15085
  if (!u)
15052
15086
  return;
15053
15087
  const x = Math.hypot(
15054
- I.clientX - u.x,
15055
- I.clientY - u.y
15088
+ S.clientX - u.x,
15089
+ S.clientY - u.y
15056
15090
  ) <= Qs;
15057
- u = null, x && (I.preventDefault(), I.stopPropagation());
15058
- }, b = (I) => {
15091
+ u = null, x && (S.preventDefault(), S.stopPropagation());
15092
+ }, w = (S) => {
15059
15093
  if (t.classList.contains("pluno-pa-widget--open") || t.classList.contains("pluno-pa-widget--closing"))
15060
15094
  return;
15061
- const x = I.shiftKey ? Qa : Ja, m = i();
15095
+ const x = S.shiftKey ? Qa : Ja, m = i();
15062
15096
  let _ = null;
15063
- I.key === "ArrowUp" ? _ = { x: m.x, y: m.y - x } : I.key === "ArrowDown" ? _ = { x: m.x, y: m.y + x } : I.key === "ArrowLeft" ? _ = { x: m.x - x, y: m.y } : I.key === "ArrowRight" && (_ = { x: m.x + x, y: m.y }), _ && (I.preventDefault(), I.stopPropagation(), s(_), o());
15097
+ S.key === "ArrowUp" ? _ = { x: m.x, y: m.y - x } : S.key === "ArrowDown" ? _ = { x: m.x, y: m.y + x } : S.key === "ArrowLeft" ? _ = { x: m.x - x, y: m.y } : S.key === "ArrowRight" && (_ = { x: m.x + x, y: m.y }), _ && (S.preventDefault(), S.stopPropagation(), s(_), o());
15064
15098
  };
15065
- return e.addEventListener("pointerdown", h), e.addEventListener("pointermove", f), e.addEventListener("pointerup", y), e.addEventListener("pointercancel", g), e.addEventListener("click", w, !0), n.addEventListener("keydown", b), () => {
15066
- e.removeEventListener("pointerdown", h), e.removeEventListener("pointermove", f), e.removeEventListener("pointerup", y), e.removeEventListener("pointercancel", g), e.removeEventListener("click", w, !0), n.removeEventListener("keydown", b);
15099
+ return e.addEventListener("pointerdown", h), e.addEventListener("pointermove", f), e.addEventListener("pointerup", y), e.addEventListener("pointercancel", g), e.addEventListener("click", b, !0), n.addEventListener("keydown", w), () => {
15100
+ e.removeEventListener("pointerdown", h), e.removeEventListener("pointermove", f), e.removeEventListener("pointerup", y), e.removeEventListener("pointercancel", g), e.removeEventListener("click", b, !0), n.removeEventListener("keydown", w);
15067
15101
  };
15068
15102
  }
15069
15103
  function gw({
@@ -15082,16 +15116,16 @@ function gw({
15082
15116
  if (o !== g.pointerId || !a || !r)
15083
15117
  return;
15084
15118
  g.preventDefault(), g.stopPropagation();
15085
- const w = g.clientX - a.x, b = g.clientY - a.y;
15086
- !c && Math.hypot(w, b) < Qs || (c = !0, t.classList.add("pluno-pa-widget--panel-dragging"), i({ x: r.x + w, y: r.y + b }));
15119
+ const b = g.clientX - a.x, w = g.clientY - a.y;
15120
+ !c && Math.hypot(b, w) < Qs || (c = !0, t.classList.add("pluno-pa-widget--panel-dragging"), i({ x: r.x + b, y: r.y + w }));
15087
15121
  }, h = (g) => {
15088
15122
  o === g.pointerId && (g.preventDefault(), g.stopPropagation(), c && s(), l());
15089
15123
  }, f = (g) => {
15090
15124
  o === g.pointerId && (g.preventDefault(), l());
15091
15125
  }, y = (g) => {
15092
- const w = g.shiftKey ? Qa : Ja, b = n();
15093
- let I = null;
15094
- g.key === "ArrowUp" ? I = { x: b.x, y: b.y - w } : g.key === "ArrowDown" ? I = { x: b.x, y: b.y + w } : g.key === "ArrowLeft" ? I = { x: b.x - w, y: b.y } : g.key === "ArrowRight" && (I = { x: b.x + w, y: b.y }), I && (g.preventDefault(), g.stopPropagation(), i(I), s());
15126
+ const b = g.shiftKey ? Qa : Ja, w = n();
15127
+ let S = null;
15128
+ g.key === "ArrowUp" ? S = { x: w.x, y: w.y - b } : g.key === "ArrowDown" ? S = { x: w.x, y: w.y + b } : g.key === "ArrowLeft" ? S = { x: w.x - b, y: w.y } : g.key === "ArrowRight" && (S = { x: w.x + b, y: w.y }), S && (g.preventDefault(), g.stopPropagation(), i(S), s());
15095
15129
  };
15096
15130
  return e.addEventListener("pointerdown", u), e.addEventListener("pointermove", d), e.addEventListener("pointerup", h), e.addEventListener("pointercancel", f), e.addEventListener("keydown", y), () => {
15097
15131
  e.removeEventListener("pointerdown", u), e.removeEventListener("pointermove", d), e.removeEventListener("pointerup", h), e.removeEventListener("pointercancel", f), e.removeEventListener("keydown", y);
@@ -15107,31 +15141,31 @@ function fw({
15107
15141
  let o = null, a = null, r = null, c = null, l = !1;
15108
15142
  const u = () => {
15109
15143
  o = null, a = null, r = null, c = null, l = !1, t.classList.remove("pluno-pa-widget--resizing");
15110
- }, d = (w) => {
15111
- const b = w.currentTarget, I = b.dataset.resizeDirection;
15112
- !t.classList.contains("pluno-pa-widget--open") || !ad(I) || (w.preventDefault(), w.stopPropagation(), o = w.pointerId, a = I, r = { x: w.clientX, y: w.clientY }, c = n(), l = !1, b.setPointerCapture?.(w.pointerId));
15113
- }, h = (w) => {
15114
- if (o !== w.pointerId || !a || !r || !c)
15144
+ }, d = (b) => {
15145
+ const w = b.currentTarget, S = w.dataset.resizeDirection;
15146
+ !t.classList.contains("pluno-pa-widget--open") || !ad(S) || (b.preventDefault(), b.stopPropagation(), o = b.pointerId, a = S, r = { x: b.clientX, y: b.clientY }, c = n(), l = !1, w.setPointerCapture?.(b.pointerId));
15147
+ }, h = (b) => {
15148
+ if (o !== b.pointerId || !a || !r || !c)
15115
15149
  return;
15116
- w.preventDefault(), w.stopPropagation();
15117
- const b = w.clientX - r.x, I = w.clientY - r.y;
15118
- !l && Math.hypot(b, I) < Qs || (l = !0, t.classList.add("pluno-pa-widget--resizing"), i(
15119
- cd(c, a, b, I)
15150
+ b.preventDefault(), b.stopPropagation();
15151
+ const w = b.clientX - r.x, S = b.clientY - r.y;
15152
+ !l && Math.hypot(w, S) < Qs || (l = !0, t.classList.add("pluno-pa-widget--resizing"), i(
15153
+ cd(c, a, w, S)
15120
15154
  ));
15121
- }, f = (w) => {
15122
- o === w.pointerId && (w.preventDefault(), w.stopPropagation(), l && s(), u());
15123
- }, y = (w) => {
15124
- o === w.pointerId && (w.preventDefault(), u());
15125
- }, g = (w) => {
15126
- const I = w.currentTarget.dataset.resizeDirection, x = w.shiftKey ? Qa : Ja, m = n();
15127
- let _ = 0, S = 0;
15128
- ad(I) && (w.key === "ArrowLeft" ? _ = -x : w.key === "ArrowRight" ? _ = x : w.key === "ArrowUp" ? S = -x : w.key === "ArrowDown" && (S = x), !(_ === 0 && S === 0) && (w.preventDefault(), w.stopPropagation(), i(cd(m, I, _, S)), s()));
15155
+ }, f = (b) => {
15156
+ o === b.pointerId && (b.preventDefault(), b.stopPropagation(), l && s(), u());
15157
+ }, y = (b) => {
15158
+ o === b.pointerId && (b.preventDefault(), u());
15159
+ }, g = (b) => {
15160
+ const S = b.currentTarget.dataset.resizeDirection, x = b.shiftKey ? Qa : Ja, m = n();
15161
+ let _ = 0, I = 0;
15162
+ ad(S) && (b.key === "ArrowLeft" ? _ = -x : b.key === "ArrowRight" ? _ = x : b.key === "ArrowUp" ? I = -x : b.key === "ArrowDown" && (I = x), !(_ === 0 && I === 0) && (b.preventDefault(), b.stopPropagation(), i(cd(m, S, _, I)), s()));
15129
15163
  };
15130
- for (const w of e)
15131
- w.addEventListener("pointerdown", d), w.addEventListener("pointermove", h), w.addEventListener("pointerup", f), w.addEventListener("pointercancel", y), w.addEventListener("keydown", g);
15164
+ for (const b of e)
15165
+ b.addEventListener("pointerdown", d), b.addEventListener("pointermove", h), b.addEventListener("pointerup", f), b.addEventListener("pointercancel", y), b.addEventListener("keydown", g);
15132
15166
  return () => {
15133
- for (const w of e)
15134
- w.removeEventListener("pointerdown", d), w.removeEventListener("pointermove", h), w.removeEventListener("pointerup", f), w.removeEventListener("pointercancel", y), w.removeEventListener("keydown", g);
15167
+ for (const b of e)
15168
+ b.removeEventListener("pointerdown", d), b.removeEventListener("pointermove", h), b.removeEventListener("pointerup", f), b.removeEventListener("pointercancel", y), b.removeEventListener("keydown", g);
15135
15169
  };
15136
15170
  }
15137
15171
  function ad(t) {
@@ -15745,19 +15779,19 @@ function Dw() {
15745
15779
  f.className = "pluno-pa-widget__model-more";
15746
15780
  const y = document.createElement("summary"), g = document.createElement("span");
15747
15781
  g.textContent = "More";
15748
- const w = Sa(12);
15749
- w.classList.add("pluno-pa-widget__model-more-chevron"), y.append(g, w), f.appendChild(y);
15782
+ const b = Sa(12);
15783
+ b.classList.add("pluno-pa-widget__model-more-chevron"), y.append(g, b), f.appendChild(y);
15750
15784
  for (const m of Nu) {
15751
15785
  const _ = gd(m);
15752
15786
  _.classList.add("pluno-pa-widget__model-more-option"), f.appendChild(_);
15753
15787
  }
15754
15788
  h.appendChild(f), l.appendChild(h), c.appendChild(l);
15755
- const b = document.createElement("div");
15756
- b.className = "pluno-pa-widget__composer-meta";
15757
- const I = document.createElement("a");
15758
- I.className = "pluno-pa-widget__powered-by", I.href = "https://pluno.ai", I.target = "_blank", I.rel = "noopener noreferrer", I.textContent = "Powered by Pluno.ai.", b.appendChild(I);
15789
+ const w = document.createElement("div");
15790
+ w.className = "pluno-pa-widget__composer-meta";
15791
+ const S = document.createElement("a");
15792
+ S.className = "pluno-pa-widget__powered-by", S.href = "https://pluno.ai", S.target = "_blank", S.rel = "noopener noreferrer", S.textContent = "Powered by Pluno.ai.", w.appendChild(S);
15759
15793
  const x = document.createElement("span");
15760
- return x.className = "pluno-pa-widget__ai-disclaimer", x.textContent = "AI can make mistakes. Verify outputs.", b.appendChild(x), c.appendChild(b), t.appendChild(c), t;
15794
+ return x.className = "pluno-pa-widget__ai-disclaimer", x.textContent = "AI can make mistakes. Verify outputs.", w.appendChild(x), c.appendChild(w), t.appendChild(c), t;
15761
15795
  }
15762
15796
  function gd(t) {
15763
15797
  const e = document.createElement("button");
@@ -15956,42 +15990,42 @@ function Uw(t, e) {
15956
15990
  });
15957
15991
  const g = J(o, "clipPath", { id: i.boltClip });
15958
15992
  J(g, "path", { d: Gs });
15959
- const w = J(s, "g", {
15993
+ const b = J(s, "g", {
15960
15994
  filter: gt(i.softDropShadow)
15961
15995
  });
15962
- J(w, "path", {
15996
+ J(b, "path", {
15963
15997
  d: Gs,
15964
15998
  fill: gt(i.boltEdge)
15965
15999
  });
15966
- const b = "M546 166 C522 166 505 180 499 204 L397 606 C390 630 406 646 432 646 L526 646 C568 646 590 672 581 712 L512 1001 C510 1010 518 1014 524 1006 L875 475 C886 458 878 449 855 449 L814 449 C764 449 745 415 769 374 L884 200 C894 181 883 161 858 161 Z";
15967
- J(w, "path", {
15968
- d: b,
16000
+ const w = "M546 166 C522 166 505 180 499 204 L397 606 C390 630 406 646 432 646 L526 646 C568 646 590 672 581 712 L512 1001 C510 1010 518 1014 524 1006 L875 475 C886 458 878 449 855 449 L814 449 C764 449 745 415 769 374 L884 200 C894 181 883 161 858 161 Z";
16001
+ J(b, "path", {
16002
+ d: w,
15969
16003
  fill: gt(i.boltFill),
15970
16004
  filter: gt(i.innerDepth)
15971
- }), J(w, "path", {
15972
- d: b,
16005
+ }), J(b, "path", {
16006
+ d: w,
15973
16007
  fill: gt(i.boltGlow),
15974
16008
  opacity: "0.74"
15975
16009
  });
15976
- const I = J(w, "g", {
16010
+ const S = J(b, "g", {
15977
16011
  "clip-path": gt(i.boltClip),
15978
16012
  opacity: "0.42"
15979
16013
  });
15980
- J(I, "path", {
16014
+ J(S, "path", {
15981
16015
  d: "M523 181 C505 189 496 206 489 232 L400 594 C397 606 400 619 411 626",
15982
16016
  fill: "none",
15983
16017
  stroke: n.highlight,
15984
16018
  "stroke-width": "22",
15985
16019
  "stroke-linecap": "round",
15986
16020
  opacity: "0.65"
15987
- }), J(I, "path", {
16021
+ }), J(S, "path", {
15988
16022
  d: "M556 685 L501 994",
15989
16023
  fill: "none",
15990
16024
  stroke: n.highlight,
15991
16025
  "stroke-width": "20",
15992
16026
  "stroke-linecap": "round",
15993
16027
  opacity: "0.55"
15994
- }), J(I, "path", {
16028
+ }), J(S, "path", {
15995
16029
  d: "M858 160 C882 166 893 181 883 204",
15996
16030
  fill: "none",
15997
16031
  stroke: n.inner,
@@ -16738,7 +16772,7 @@ function wd(t, e) {
16738
16772
  const i = n[1], s = e ? "Finding example tasks..." : " ";
16739
16773
  i.textContent !== s && (i.textContent = s), i.classList.toggle("pluno-pa-widget__starter-placeholder--loading", e), i.parentElement.setAttribute("aria-hidden", String(!e));
16740
16774
  }
16741
- function c_(t, e, n, i, s, o, a, r, c, l, u, d, h, f, y, g, w, b, I, x, m, _, S, k, T, q) {
16775
+ function c_(t, e, n, i, s, o, a, r, c, l, u, d, h, f, y, g, b, w, S, x, m, _, I, k, T, q) {
16742
16776
  const U = ih(o), P = __(o), z = Array.isArray(o.activeScheduledFollowUps) ? o.activeScheduledFollowUps : null, B = /* @__PURE__ */ new Map();
16743
16777
  if (z !== null)
16744
16778
  for (const R of z) {
@@ -16810,7 +16844,7 @@ function c_(t, e, n, i, s, o, a, r, c, l, u, d, h, f, y, g, w, b, I, x, m, _, S,
16810
16844
  const R = q?.morning, D = JSON.stringify([
16811
16845
  o.sessionId,
16812
16846
  o.user?.id,
16813
- I,
16847
+ S,
16814
16848
  R,
16815
16849
  o.starterPrompts,
16816
16850
  g()
@@ -16820,24 +16854,24 @@ function c_(t, e, n, i, s, o, a, r, c, l, u, d, h, f, y, g, w, b, I, x, m, _, S,
16820
16854
  return;
16821
16855
  }
16822
16856
  const G = document.createElement("div");
16823
- G.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter" + (I ? " pluno-pa-widget__empty-state--morning-report" : "");
16857
+ G.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter" + (S ? " pluno-pa-widget__empty-state--morning-report" : "");
16824
16858
  const oe = document.createElement("div");
16825
16859
  oe.className = "pluno-pa-widget__empty-hero";
16826
16860
  const O = Bt(
16827
16861
  "pluno-pa-widget__character--empty",
16828
16862
  g()
16829
16863
  );
16830
- if (oe.appendChild(O), G.appendChild(oe), I) {
16864
+ if (oe.appendChild(O), G.appendChild(oe), S) {
16831
16865
  const K = document.createElement("h2");
16832
- K.className = "pluno-pa-widget__empty pluno-pa-widget__morning-report-title", K.textContent = I.opening, G.appendChild(K);
16866
+ K.className = "pluno-pa-widget__empty pluno-pa-widget__morning-report-title", K.textContent = S.opening, G.appendChild(K);
16833
16867
  } else
16834
16868
  G.appendChild(Ju());
16835
- const H = I?.prompts ?? o.starterPrompts, V = document.createElement("div");
16869
+ const H = S?.prompts ?? o.starterPrompts, V = document.createElement("div");
16836
16870
  if (V.className = H.length > 0 ? "pluno-pa-widget__starter-prompts" : "pluno-pa-widget__starter-prompts pluno-pa-widget__starter-prompts--empty", H.length === 0 && !o.starterPromptsLoading && V.setAttribute("aria-hidden", "true"), H.length > 0)
16837
16871
  for (const [K, he] of H.entries()) {
16838
16872
  const re = document.createElement("button");
16839
16873
  re.type = "button", re.className = "pluno-pa-widget__starter-prompt", re.textContent = he, re.disabled = R?.status === "pending", re.addEventListener("click", () => {
16840
- w(he, K);
16874
+ b(he, K);
16841
16875
  }), V.appendChild(re);
16842
16876
  }
16843
16877
  else
@@ -16845,7 +16879,7 @@ function c_(t, e, n, i, s, o, a, r, c, l, u, d, h, f, y, g, w, b, I, x, m, _, S,
16845
16879
  const he = document.createElement("div");
16846
16880
  he.className = "pluno-pa-widget__starter-placeholder", K === 1 && he.setAttribute("role", "status"), he.textContent = " ", V.appendChild(he);
16847
16881
  }
16848
- if (G.appendChild(V), wd(G, o.starterPromptsLoading), I) {
16882
+ if (G.appendChild(V), wd(G, o.starterPromptsLoading), S) {
16849
16883
  const K = document.createElement("button");
16850
16884
  if (K.type = "button", K.className = "pluno-pa-widget__morning-report-snooze", K.textContent = "Snooze morning report", K.disabled = R?.status === "pending", K.addEventListener("click", x), G.appendChild(K), R && "error" in R.payload && R.payload.error) {
16851
16885
  const he = document.createElement("p");
@@ -16985,7 +17019,7 @@ function c_(t, e, n, i, s, o, a, r, c, l, u, d, h, f, y, g, w, b, I, x, m, _, S,
16985
17019
  );
16986
17020
  if (O.querySelector("[data-submission-retry]")?.remove(), D.role === "user" && D.retryable) {
16987
17021
  const H = document.createElement("button");
16988
- H.type = "button", H.className = "pluno-pa-widget__error-retry", H.dataset.submissionRetry = D.id, H.textContent = "Retry this message", H.addEventListener("click", () => b(D.id)), O.appendChild(H);
17022
+ H.type = "button", H.className = "pluno-pa-widget__error-retry", H.dataset.submissionRetry = D.id, H.textContent = "Retry this message", H.addEventListener("click", () => w(D.id)), O.appendChild(H);
16989
17023
  }
16990
17024
  ce(O), ge = O, Ie = null, D.role;
16991
17025
  }
@@ -17026,8 +17060,8 @@ function c_(t, e, n, i, s, o, a, r, c, l, u, d, h, f, y, g, w, b, I, x, m, _, S,
17026
17060
  for (const O of U.actions) {
17027
17061
  const H = document.createElement("button");
17028
17062
  H.type = "button", H.className = "pluno-pa-widget__error-retry";
17029
- const V = S?.has(O) === !0 || O === "retry_history" && o.conversationDiagnostics?.queryRequestId != null || O === "retry_message" && o.isRetrying;
17030
- H.disabled = V, H.setAttribute("aria-busy", String(V)), H.textContent = O === "new_chat" ? V ? "Starting new chat" : "Start new chat" : V ? "Trying" : "Try again", V && H.prepend(wn()), H.addEventListener("click", () => k(O, O === "retry_history" ? m : O === "retry_message" ? b : _)), G.appendChild(H);
17063
+ const V = I?.has(O) === !0 || O === "retry_history" && o.conversationDiagnostics?.queryRequestId != null || O === "retry_message" && o.isRetrying;
17064
+ H.disabled = V, H.setAttribute("aria-busy", String(V)), H.textContent = O === "new_chat" ? V ? "Starting new chat" : "Start new chat" : V ? "Trying" : "Try again", V && H.prepend(wn()), H.addEventListener("click", () => k(O, O === "retry_history" ? m : O === "retry_message" ? w : _)), G.appendChild(H);
17031
17065
  }
17032
17066
  se.appendChild(G), ce(se), ge = null, Ie = se;
17033
17067
  }
@@ -17418,7 +17452,7 @@ function C_(t, e, n, i, s, o, a, r = !0) {
17418
17452
  const m = document.createElement("article"), _ = Bt(
17419
17453
  "pluno-pa-widget__character--tool-group",
17420
17454
  a
17421
- ), S = JSON.stringify(a), k = document.createElement("div");
17455
+ ), I = JSON.stringify(a), k = document.createElement("div");
17422
17456
  k.className = "pluno-pa-widget__tool-active-content";
17423
17457
  const T = lo(), q = document.createElement("details"), U = document.createElement("summary");
17424
17458
  U.className = "pluno-pa-widget__tool-summary";
@@ -17433,7 +17467,7 @@ function C_(t, e, n, i, s, o, a, r = !0) {
17433
17467
  }), u = {
17434
17468
  node: m,
17435
17469
  character: _,
17436
- characterSignature: S,
17470
+ characterSignature: I,
17437
17471
  activeContent: k,
17438
17472
  thinkingStatus: T,
17439
17473
  details: q,
@@ -17467,9 +17501,9 @@ function C_(t, e, n, i, s, o, a, r = !0) {
17467
17501
  }
17468
17502
  const g = d.details;
17469
17503
  g.open = n.has(l) || !n.has(`closed:${l}`) && !r, f.classList.toggle("pluno-pa-widget__tool-group--open", g.open);
17470
- const w = t[t.length - 1], b = Zs(
17471
- w.content
17472
- ).trim(), I = w.phase === "commentary", x = b ? I ? b : lp(b) : c ? "Steered" : "Thinking...";
17504
+ const b = t[t.length - 1], w = Zs(
17505
+ b.content
17506
+ ).trim(), S = b.phase === "commentary", x = w ? S ? w : lp(w) : c ? "Steered" : "Thinking...";
17473
17507
  return f.dataset.collapsedActivityTitle = x, d.summaryTitle.replaceChildren(), d.summaryTitle.classList.add(
17474
17508
  "pluno-pa-widget__tool-summary-markdown"
17475
17509
  ), tc(
@@ -17640,8 +17674,8 @@ function M_(t, e) {
17640
17674
  break;
17641
17675
  const h = document.createElement("tr");
17642
17676
  n.forEach((f, y) => {
17643
- const g = document.createElement("td"), w = s[y];
17644
- w && g.classList.add(`pluno-pa-widget__table-cell--${w}`), mn(g, d[y] ?? ""), h.appendChild(g);
17677
+ const g = document.createElement("td"), b = s[y];
17678
+ b && g.classList.add(`pluno-pa-widget__table-cell--${b}`), mn(g, d[y] ?? ""), h.appendChild(g);
17645
17679
  }), l.appendChild(h), u += 1;
17646
17680
  }
17647
17681
  return a.appendChild(l), o.appendChild(a), { element: o, nextIndex: u };