@0perator/operator 0.2.0 → 0.2.1

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.
Files changed (75) hide show
  1. package/README.md +4 -3
  2. package/dist/auth/commands.js +7 -3
  3. package/dist/auth/identity.js +1 -0
  4. package/dist/auth/staff.js +55 -0
  5. package/dist/autonomy/delegate-mode.js +2 -2
  6. package/dist/autonomy/delegate.js +41 -14
  7. package/dist/autonomy/headless.js +7 -4
  8. package/dist/autonomy/index.js +2 -4
  9. package/dist/autonomy/session-factory.js +11 -12
  10. package/dist/autonomy/subagent-model.js +17 -7
  11. package/dist/background/capacity.js +136 -0
  12. package/dist/background/evidence.js +42 -0
  13. package/dist/background/index.js +311 -44
  14. package/dist/background/lane-phase.js +60 -0
  15. package/dist/background/lane-summary.js +151 -0
  16. package/dist/background/notices.js +12 -3
  17. package/dist/background/synthesis.js +25 -0
  18. package/dist/bus/inbox.js +150 -6
  19. package/dist/cli.js +191 -96
  20. package/dist/config/features.js +3 -3
  21. package/dist/config/persona.js +29 -3
  22. package/dist/config/settings.js +261 -20
  23. package/dist/config/staff-prompt.js +12 -0
  24. package/dist/engine/agent.js +51 -40
  25. package/dist/engine/aurora.js +36 -4
  26. package/dist/engine/batch-scheduler.js +4 -13
  27. package/dist/engine/compaction.js +1 -1
  28. package/dist/engine/continuation.js +30 -32
  29. package/dist/engine/decision-points.js +2 -3
  30. package/dist/engine/fanout.js +16 -0
  31. package/dist/engine/loop-guard.js +26 -83
  32. package/dist/engine/messages.js +2 -2
  33. package/dist/engine/moa.js +16 -1
  34. package/dist/engine/native-vision-node.js +72 -0
  35. package/dist/engine/native-vision.js +103 -0
  36. package/dist/engine/verify-gate.js +37 -7
  37. package/dist/gateway-cli.js +14 -3
  38. package/dist/memory/live-progress.js +4 -5
  39. package/dist/moa/codeact-lane.js +98 -0
  40. package/dist/moa/codeact-sandbox.js +409 -0
  41. package/dist/moa/codeact.js +140 -0
  42. package/dist/permissions/artifact-visibility.js +10 -0
  43. package/dist/permissions/tier.js +4 -2
  44. package/dist/products/craft.js +2 -2
  45. package/dist/remote/grants.js +119 -0
  46. package/dist/remote/host.js +33 -5
  47. package/dist/router/models.js +24 -14
  48. package/dist/selfimprove/index.js +8 -6
  49. package/dist/services/preflight.js +35 -91
  50. package/dist/session.js +127 -41
  51. package/dist/skills/install-guard.js +68 -0
  52. package/dist/skills/install.js +67 -0
  53. package/dist/toolchain/manifest.json +13 -13
  54. package/dist/tools/background-result.js +1 -1
  55. package/dist/tools/classes.js +103 -0
  56. package/dist/tools/contract.js +1 -1
  57. package/dist/tools/craft.js +13 -2
  58. package/dist/tools/executor.js +25 -15
  59. package/dist/tools/generation-gateway.js +94 -0
  60. package/dist/tools/registry.js +83 -152
  61. package/dist/ui/App.js +15 -4
  62. package/dist/ui/BgPanel.js +15 -10
  63. package/dist/ui/Header.js +1 -6
  64. package/dist/ui/StatusRule.js +18 -7
  65. package/dist/ui/ToolStep.js +3 -3
  66. package/dist/ui/Transcript.js +36 -14
  67. package/dist/ui/batchLine.js +4 -4
  68. package/dist/ui/editdiff.js +2 -4
  69. package/dist/ui/format.js +4 -20
  70. package/dist/ui/liveTools.js +3 -3
  71. package/dist/ui/opsMode.js +20 -0
  72. package/dist/ui/types.js +0 -2
  73. package/dist/update-check.js +17 -6
  74. package/package.json +1 -1
  75. package/dist/tools/mutating.js +0 -15
package/dist/cli.js CHANGED
@@ -15,6 +15,7 @@ import { shouldPromptPlanExit, resolvePlanExit, PLAN_EXIT_OPTIONS } from "./ui/p
15
15
  import { initialMode, modePolicy, nextMode, parseMode, planToggleTarget } from "./permissions/modes.js";
16
16
  import { FREE_ROW_PRESETS, connectedAccounts, isMainModel, looksLikeSecret, contextLine, contextPickerView, keyStoredLine, mainPickerView, markModelRows, modelLine, modelPickerView, onceEach, pickerAnswer, providerPickerView, rereadConfirmView, wantsContextStep, wantsRereadConfirm } from "./ui/modelPicker.js";
17
17
  import { RemoteHost, toRemoteAgents } from "./remote/host.js";
18
+ import { GrantStore, grantsEnabled } from "./remote/grants.js";
18
19
  import { REMOTE_SAFE_COMMANDS, REMOTE_SAFE_COMMAND_NAMES } from "./remote/safe-commands.js";
19
20
  import { newCode, pairURL } from "./remote/pairing.js";
20
21
  import { qrToTerminal } from "./ui/qr.js";
@@ -28,7 +29,7 @@ import { createDecode, decodeRate, decodeRound, deltasApprox, dueCheck, noteDeco
28
29
  import { isRunawayRepetition } from "./engine/repetition-guard.js";
29
30
  import { createLedger, interruptedLine, ledgerParts, noteCompaction, noteGenEnd, noteGenStart, noteRead, noteRound, noteTools, noteWait } from "./ui/turnLedger.js";
30
31
  import { termCols } from "./ui/term.js";
31
- import { pollBus, pollSent, selfAgent, buildMentorWake, selectReadyWakes } from "./bus/inbox.js";
32
+ import { pollBus, pollSent, selfAgent, buildMentorWake, selectReadyWakes, isAutoReport, wakeRoot } from "./bus/inbox.js";
32
33
  import { isErrorResult } from "./ui/format.js";
33
34
  import { feedFold, foldStep, settleFold, settledFields } from "./ui/fold.js";
34
35
  import { turnScoped } from "./ui/turnScope.js";
@@ -40,16 +41,16 @@ import { seedCalibration } from "./engine/calibration-seed.js";
40
41
  import { AuroraRouter } from "./router/router.js";
41
42
  import { BackgroundAgents } from "./background/index.js";
42
43
  import { clearResumable, pickUpSaved, quitSummary, resumeOnReopen, saveResumable, startSaved } from "./background/resume.js";
43
- import { loadSettings, saveSettings, compactionThreshold, compactionCeilingTokens, compactionMinDecodeTps, rcAutostart, eagerAuthAtBoot, applySeat, setActiveSeat, buildEndpointChain, parseContextArg, nextContextPin } from "./config/settings.js";
44
+ import { loadSettings, saveSettings, settingsLoadProblems, compactionThreshold, compactionCeilingTokens, compactionMinDecodeTps, rcAutostart, eagerAuthAtBoot, applySeat, setActiveSeat, buildEndpointChain, parseContextArg, nextContextPin } from "./config/settings.js";
44
45
  import { resolveSeat } from "./auth/identity.js";
45
46
  import { PermissionPolicy } from "./permissions/index.js";
46
47
  import { caps } from "./ui/capabilities.js";
47
- import { composeSystemPrompt, appendMemory, subagentSystemPrompt } from "./config/persona.js";
48
+ import { composeSystemPrompt, appendMemory, memoryBudgetNote, subagentSystemPrompt } from "./config/persona.js";
48
49
  import { SUBAGENT_ROLES, SUBAGENT_TOOL_DENY, roleCanWrite } from "./engine/grandmaster.js";
49
50
  import { applyToolsBinPath, operatorPath } from "./config/home.js";
50
51
  import { ensureOperatorHome } from "./config/scaffold.js";
51
52
  import { listLocalSkills, skillCommand } from "./config/skills-index.js";
52
- import { modelCtxFor, leanHarnessFor, selectModel, modelRegistry, fmtCtx, shortName, BYO_PRESETS, DEFAULT_MODEL_ID } from "./router/models.js";
53
+ import { modelCtxFor, leanHarnessFor, selectModel, modelRegistry, fmtCtx, shortName, BYO_PRESETS, CHAIN_MODEL_ID } from "./router/models.js";
53
54
  import { fetchPortalModels, offlineNote, portalIdFor } from "./router/portal.js";
54
55
  import { fetchFreeModels } from "./router/free-models.js";
55
56
  import { describeTurnError } from "./engine/net-error.js";
@@ -60,7 +61,10 @@ import { getDiscoveredModels } from "./router/discovery.js";
60
61
  import { disposeShellSession, getAgentTasks, registry } from "./tools/registry.js";
61
62
  import { applySandboxMode } from "./tools/sandbox.js";
62
63
  import { drainJobNotices, getJobNoticeMode, listShellJobs, onJobEvent, parseJobsArgs, pendingJobNotices, renderJobsList, runningJobCount, setJobNoticeMode, stopShellJob } from "./tools/shell-jobs.js";
63
- import { drainAgentNotices, onAgentReport, pendingAgentReports, queueAgentReport, queueAgentNotice, formatStuckNotice } from "./background/notices.js";
64
+ import { drainAgentNotices, onAgentReport, agentReportsDue, queueAgentReport, queueAgentNotice, formatStuckNotice, setReportGate } from "./background/notices.js";
65
+ import { delegateCapacity, liveDelegateRoute } from "./background/capacity.js";
66
+ import { laneSummary } from "./background/lane-summary.js";
67
+ import { missingLine, synthesisState } from "./background/synthesis.js";
64
68
  import { reportLine, deliveredLine } from "./ui/reportLine.js";
65
69
  import { pushCollapsed, popCollapsed, dropCollapsed } from "./ui/expand.js";
66
70
  import { ensureScratchDir } from "./config/scratch.js";
@@ -81,7 +85,7 @@ import { snapshotEphemeralImages } from "./util/screenshots.js";
81
85
  import { isFeatureEnabled } from "./config/features.js";
82
86
  import { classifyActVsAsk, actAskGateDirective } from "./engine/classifier.js";
83
87
  import { resolveMode } from "./classifier/modes.js";
84
- import { subagentModelFor, servingModelFor } from "./autonomy/subagent-model.js";
88
+ import { subagentModelFor, servingModelFor, delegateRouteFor } from "./autonomy/subagent-model.js";
85
89
  import { parseDelegate, delegateStatusLines, delegateGuardOn, setDelegateSettings } from "./autonomy/delegate-mode.js";
86
90
  import { classifierConfig } from "./classifier/config.js";
87
91
  import { throttle } from "./util/throttle.js";
@@ -125,15 +129,16 @@ function ctxBadge(n) {
125
129
  return n >= 1024 ? `${Math.round(n / 1024)}K` : String(n);
126
130
  }
127
131
  // The model the session will actually start on — NOT the raw persisted id. Mirrors Session's startup
128
- // resolution (session.ts: setModel(cfg.activeModel) else DEFAULT_MODEL_ID) so the boot masthead badges the
132
+ // resolution (session.ts: setModel(cfg.activeModel) else CHAIN_MODEL_ID) so the boot masthead badges the
129
133
  // window of the model that answers, not a persisted id that the owner-only gate / missing-endpoint check
130
- // drops back to operator-1m. Pure (selectModel is a pure reducer, no health I/O), so the fast paths stay instant.
134
+ // drops back to the chain row, or a retired id that resolves to its successor. Pure (selectModel is a pure reducer,
135
+ // no health I/O), so the fast paths stay instant.
131
136
  function startupModelId(s, actor) {
132
137
  const id = s.activeModel;
133
- if (!id || id === DEFAULT_MODEL_ID)
134
- return DEFAULT_MODEL_ID;
138
+ if (!id || id === CHAIN_MODEL_ID)
139
+ return CHAIN_MODEL_ID;
135
140
  const isOwner = (actor.tier ?? "admin") === "admin";
136
- return selectModel(modelRegistry(s.models), id, hasByoToken, isOwner).profile ? id : DEFAULT_MODEL_ID;
141
+ return selectModel(modelRegistry(s.models), id, hasByoToken, isOwner).profile?.id ?? CHAIN_MODEL_ID;
137
142
  }
138
143
  // Fast paths that must NOT mount Ink/React (so `operator --version` works with no TTY and returns instantly)
139
144
  // — and must not do ANY identity I/O either. They used to sit BELOW the boot credential load, so even
@@ -158,6 +163,8 @@ if (process.argv[2] === "selfimprove") {
158
163
  }
159
164
  // operator/settings.json (override path via KODE_TSI_SETTINGS), env vars still win — see config/settings.ts.
160
165
  const settings = loadSettings();
166
+ for (const p of settingsLoadProblems())
167
+ process.stderr.write(`[operator] ⚠ settings: ${p}\n`);
161
168
  setDelegateSettings(settings.delegate); // delegate mode's guard, read per tool call by every session in this process
162
169
  // Enterprise first-run: make the operator home's contract explicit BEFORE any module writes into it (0700
163
170
  // root, ignore-everything .gitignore, README, settings.example.json, home.json). Idempotent, never throws.
@@ -481,6 +488,12 @@ let REAPED = { owners: 0, killed: [], skipped: 0 };
481
488
  let UPDATE_CHECK = Promise.resolve(null);
482
489
  let UPDATE_ASKED_AT = 0;
483
490
  let UPDATE_NOW = null;
491
+ // After a sign-in (the TUI's /login, the shell's `operator auth login`): the same check, gated the same way, past the cache.
492
+ async function checkOnSignIn() {
493
+ const { checkAfterSignIn } = await import("./update-check.js");
494
+ const { isSourceCheckout } = await import("./update.js");
495
+ return checkAfterSignIn(VERSION, { env: process.env, tty: !!process.stdin.isTTY && !!process.stdout.isTTY, settings, sourceCheckout: isSourceCheckout() });
496
+ }
484
497
  // Build the endpoint router. ONE model now: Aurora at its native 1M context on :8097 — both `operator`
485
498
  // and `operator+` serve the same single tier (the air/1m/saddle roster collapsed once Aurora ran true
486
499
  // 1,048,576-token context at full speed). No size-based routing decision remains.
@@ -530,6 +543,12 @@ function formatAgentDeepView(a) {
530
543
  lines.push(` task: ${a.task.length > 120 ? a.task.slice(0, 119) + "…" : a.task}`);
531
544
  if (a.model)
532
545
  lines.push(` model: ${a.model}${a.lane ? ` · ${a.lane}` : ""}`);
546
+ if (a.leg)
547
+ lines.push(` backend: ${a.leg}`);
548
+ if (a.status === "working" || a.status === "queued")
549
+ lines.push(` doing: ${laneSummary(a, Date.now())}`);
550
+ if (a.queueReason && a.status === "queued")
551
+ lines.push(` waiting: ${a.queueReason}`);
533
552
  lines.push(` round: ${a.round ?? 0}`);
534
553
  const tokStr = a.tokens != null && a.tokens > 0 ? (a.tokens >= 1000 ? `${(a.tokens / 1000).toFixed(1)}k` : `${a.tokens}`) : "0";
535
554
  lines.push(` tokens: ${tokStr}`);
@@ -675,7 +694,7 @@ function Root() {
675
694
  const [liveTools, setLiveTools] = useState([]); // one row per call in the CURRENT batch,
676
695
  // live: seeded "running" by onToolStart, each flips to done/error independently as onToolResult fires
677
696
  // for it — see ui/liveTools.ts. Cleared once the batch settles (onToolBatch).
678
- const [route, setRoute] = useState("operator-1m");
697
+ const [route, setRoute] = useState(CHAIN_MODEL_ID);
679
698
  const [ctxPct, setCtxPct] = useState(0);
680
699
  const seededRef = useRef(false); // GW-06: oracle cold-start seed fires once per process, on first route
681
700
  const cacheReqsRef = useRef(0); // GW-05: requests since process start — index 1 legitimately misses everything
@@ -756,6 +775,9 @@ function Root() {
756
775
  const [updatePrompt, setUpdatePrompt] = useState(null);
757
776
  const [finder, setFinder] = useState(null); // ctrl+g — the skills and tools finder
758
777
  const alwaysAllowRef = useRef(new Set());
778
+ // Scoped "Always allow" grants from a remote follower (grants.v1, KODE_GRANTS=1). Exact tool + derived target,
779
+ // this process's session or 24 h, revocable; see remote/grants.ts. Separate from the keyboard's per-tool set above.
780
+ const grantsRef = useRef(new GrantStore());
759
781
  // Remembers the email a `/login <email>` sent a 6-digit code to, so the follow-up `/login <code>`
760
782
  // knows which address to verify against — the in-session twin of the shell's email-code login.
761
783
  const pendingLoginEmailRef = useRef(null);
@@ -765,7 +787,7 @@ function Root() {
765
787
  // Pending gated approvals by id. Both the local keystroke and a remote follower's approval_response
766
788
  // route through settleApproval — FIRST answer wins (§7); the map delete makes it idempotent.
767
789
  const pendingApprovals = useRef(new Map());
768
- const settleApproval = useCallback((id, allow, always = false) => {
790
+ const settleApproval = useCallback((id, allow, always = false, grant) => {
769
791
  const resolve = pendingApprovals.current.get(id);
770
792
  if (!resolve)
771
793
  return; // already settled (first-wins)
@@ -774,12 +796,21 @@ function Root() {
774
796
  setApproval((cur) => {
775
797
  if (cur && cur.id === id && allow && always && !cur.ctx?.once)
776
798
  alwaysAllowRef.current.add(cur.name);
799
+ // A grant covers exactly this call's derived target; a signature (ctx.once) prompt is never granted.
800
+ if (cur && cur.id === id && allow && grant && grantsEnabled() && !cur.ctx?.once
801
+ && grantsRef.current.add(cur.name, cur.args, grant.scope, SESSION_ID)) {
802
+ remoteRef.current?.setGrants(grantsRef.current.list());
803
+ }
777
804
  return cur && cur.id === id ? null : cur;
778
805
  });
779
806
  }, []);
780
807
  const approveFn = useCallback((name, args, ctx) => {
781
808
  if (!ctx?.once && alwaysAllowRef.current.has(name))
782
809
  return Promise.resolve(true); // a phone signature line asks every time
810
+ if (!ctx?.once && grantsEnabled() && grantsRef.current.use(name, args, SESSION_ID)) {
811
+ remoteRef.current?.setGrants(grantsRef.current.list()); // the use count moved
812
+ return Promise.resolve(true);
813
+ }
783
814
  const id = "ap_" + Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
784
815
  return new Promise((resolve) => {
785
816
  pendingApprovals.current.set(id, resolve);
@@ -792,19 +823,6 @@ function Root() {
792
823
  const freeRowsRef = useRef([]);
793
824
  const freeStaleRef = useRef(false); // served from the disk cache after a failed read → the rows say " · cached"
794
825
  const sessionRef = useRef(null); // lazy — never reconstruct on re-render
795
- // Aurora loads on demand (owner, 11/03): the first turn that needs a local Aurora starts the launchd gateway, and boot
796
- // never does. The hook is built on first use; it is inert where Aurora is not a launchd job on this box.
797
- const auroraHookRef = useRef(null);
798
- const auroraForTurn = async (signal) => {
799
- if (!auroraHookRef.current) {
800
- const { auroraOnDemand } = await import("./services/preflight.js");
801
- auroraHookRef.current = auroraOnDemand(settings.endpoints.aurora, settings.services?.aurora, buildRouter, () => {
802
- push({ kind: "message", message: { id: nextId(), role: "system", content: "aurora is not loaded — loading it for this turn…" } });
803
- setPhase("loading");
804
- }, (line) => push({ kind: "message", message: { id: nextId(), role: "system", content: line } }));
805
- }
806
- return auroraHookRef.current(signal);
807
- };
808
826
  // MCP opts the foreground session into the fleet MCP tool surface (off by default: local tools
809
827
  // only, no network fan-out at session start). Background agents stay local-only + lean.
810
828
  if (!sessionRef.current) {
@@ -813,7 +831,6 @@ function Root() {
813
831
  thinkMode, // start in the SAME mode the badge shows (settings.ui.reasoning, default "think") — it was only ever the badge that defaulted on
814
832
  router: buildRouter(),
815
833
  applyActiveModel: true, // the persisted /model choice still applies with the shell's chain injected
816
- onDemand: auroraForTurn,
817
834
  memory: buildMemory(settings.memory), // provider composite when configured; bare store (byte-identical) otherwise
818
835
  mcp: settings.mcp,
819
836
  mcpHub: embodimentHub, // scoped chauffeur hub when embodiment is on (undefined otherwise → no change)
@@ -850,11 +867,12 @@ function Root() {
850
867
  // sub-agent can't spawn more (no fork bombs). BackgroundAgents itself is the single source of truth
851
868
  // for the cap (running + queued) — it refuses ("") past it, so there's exactly one number to keep in
852
869
  // sync, not a second constant here that can drift from the manager's own.
853
- spawnAgent: (task, role, name) => {
870
+ spawnSlots: () => (sessionRef.current?.currentModel() === "moa" ? bgRef.current?.freeLanes() : undefined), // a planner fan-out is sized to the free lanes
871
+ spawnAgent: (task, role, name, opts) => {
854
872
  const mgr = bgRef.current;
855
873
  if (!mgr)
856
874
  return "background manager not ready yet — retry in a moment";
857
- const id = mgr.spawn(task, role, name);
875
+ const id = mgr.spawn(task, role, name, undefined, opts);
858
876
  if (!id)
859
877
  return mgr.capacityLine();
860
878
  const a = mgr.list().find((x) => x.id === id);
@@ -871,7 +889,8 @@ function Root() {
871
889
  ? "It runs on YOUR model's only slot: tell the owner the plan, then end the turn so it gets the slot."
872
890
  : "It runs on its own server beside you: keep working on what does not depend on it, and review its work when it reports.") +
873
891
  ` Its report — or a STUCK notice — arrives as a message at the start of a later turn, never mid-turn; do not poll for it. ` +
874
- `bash_output/bash_kill do not work on ${id}; never re-spawn its task while it runs.`;
892
+ `bash_output/bash_kill do not work on ${id}; never re-spawn its task while it runs.` +
893
+ (a?.evidence ? ` WARNING: ${a.evidence}.` : "");
875
894
  },
876
895
  // The reverse channel: message a RUNNING sub-agent mid-flight (steer it / answer its question).
877
896
  messageAgent: (id, text) => {
@@ -942,7 +961,8 @@ function Root() {
942
961
  // and-capability-catalog.md). The model is resolved PER SPAWN (autonomy/subagent-model.ts): the MoA specialist
943
962
  // under /model moa, else the owner's setting, else gpt-oss-20b — never silently another provider (10/31: a
944
963
  // background agent on aurora-code-1 looped 51 rounds while Cortana was the selected model).
945
- const subagentModel = () => subagentModelFor(settings, sessionRef.current?.currentModel());
964
+ const onDelegateRouteRef = useRef(false); // the owner's delegate route answered at the router: sub-agents run there, even under moa
965
+ const subagentModel = () => subagentModelFor(settings, sessionRef.current?.currentModel(), onDelegateRouteRef.current);
946
966
  const bgRef = useRef(null);
947
967
  // Every finished sub-agent's full report, by id (live or retired), for ctrl+o and `/agents <name> report` — the
948
968
  // transcript shows one line per agent (ui/reportLine.ts). collapsedRef is ctrl+o's newest-first stack.
@@ -1003,6 +1023,20 @@ function Root() {
1003
1023
  }, (agent, round, how) => {
1004
1024
  setEntries((prev) => [...prev, { kind: "message", message: { id: nextId(), role: "system", content: `→ ${agent.name ?? agent.id} took it ${how === "round" ? `at round ${round}` : "as a follow-up turn"}` } }]);
1005
1025
  });
1026
+ // Smart slots: the lane count follows the delegate route's live capacity at the router (static cap without one).
1027
+ const registry = modelRegistry(settings.models);
1028
+ const mainModel = () => servingModelFor(settings, sessionRef.current?.currentModel());
1029
+ bgRef.current.setCapacity(delegateCapacity(registry, subagentModel(), mainModel));
1030
+ void liveDelegateRoute(registry, delegateRouteFor(settings), mainModel).then((route) => {
1031
+ if (!route)
1032
+ return;
1033
+ onDelegateRouteRef.current = true;
1034
+ bgRef.current?.setCapacity(route);
1035
+ });
1036
+ setReportGate(() => {
1037
+ const s = synthesisState(bgRef.current?.list() ?? [], Date.now());
1038
+ return { ready: s.ready, missing: missingLine(s.missing) };
1039
+ });
1006
1040
  }
1007
1041
  const bg = bgRef.current;
1008
1042
  // Talking to sub-agents (A3.4): "@Nova <text>" and the conversation switcher on the mode line. `openConv` is the
@@ -1137,8 +1171,8 @@ function Root() {
1137
1171
  useEffect(() => { tracker.start(session.currentModel()); }, [session]);
1138
1172
  useEffect(() => {
1139
1173
  void (async () => {
1140
- // Service lever: bring Aurora (required) and autopilot (optional) up via launchd BEFORE gating on
1141
- // health, so a cold box self-heals instead of dropping the owner at "start it yourself and relaunch".
1174
+ // Service lever: resolve the gateway's published endpoint (Aurora is retired: reported, never started) and bring
1175
+ // the optional companions up via launchd BEFORE gating on health.
1142
1176
  let reports = [];
1143
1177
  try {
1144
1178
  const preflight = await import("./services/preflight.js");
@@ -1147,7 +1181,6 @@ function Root() {
1147
1181
  const auroraCfg = { base: bootBase, ...settings.services?.aurora };
1148
1182
  reports = await preflight.ensureServices({
1149
1183
  aurora: auroraCfg,
1150
- auroraOnDemand: true, // resolve and report Aurora only: the turn that needs it loads it
1151
1184
  autopilot: settings.services?.autopilot,
1152
1185
  vision: settings.services?.vision,
1153
1186
  onProgress: setBootDetail,
@@ -1171,21 +1204,18 @@ function Root() {
1171
1204
  }
1172
1205
  }
1173
1206
  catch { /* preflight is best-effort — fall through to the authoritative health check */ }
1174
- // A local Aurora that is not loaded is not a failed boot: it loads on the first turn that needs it, and a
1175
- // session on another model (moa, cortana) never needs it.
1176
- const primaryOk = reports.find((r) => r.name === "aurora")?.state === "idle" || (await session.health().catch(() => false));
1177
- // No local model is not a failed boot either when a later leg of the same chain answers: the router falls
1178
- // through to it on the first turn (a new user's machine has only the cloud tier). The Aurora row's legs are the
1179
- // shell chain; any other gateway row (operator-flash, the fresh-install default) has its own public leg.
1180
- const laterLegs = session.currentModel() === DEFAULT_MODEL_ID ? buildEndpointChain(settings).map((e) => e.base) : session.endpoints().map((e) => e.base);
1207
+ const primaryOk = await session.health().catch(() => false);
1208
+ // No local model is not a failed boot when a later leg of the same chain answers: the router falls through to it
1209
+ // on the first turn (a new user's machine has only the cloud tier). The chain row's legs are the shell chain; any
1210
+ // other gateway row (operator-flash, the fresh-install default) has its own public leg.
1211
+ const laterLegs = session.currentModel() === CHAIN_MODEL_ID ? buildEndpointChain(settings).map((e) => e.base) : session.endpoints().map((e) => e.base);
1181
1212
  const ok = primaryOk || (await anyReachable(laterLegs.slice(1)).catch(() => false));
1182
1213
  setBoot(ok ? "ready" : "down");
1214
+ const modelNote = session.takeModelNote(); // a persisted retired activeModel runs on its successor: said once
1215
+ if (modelNote)
1216
+ push({ kind: "message", message: { id: nextId(), role: "system", content: modelNote } });
1183
1217
  if (!ok) {
1184
- const a = reports.find((r) => r.name === "aurora");
1185
- // Another model (moa, cortana) failed on its own endpoint: name that one, not Aurora's.
1186
- setBootDetail(session.currentModel() === DEFAULT_MODEL_ID
1187
- ? a?.detail ?? `no response from ${session.healthTarget()}`
1188
- : `${session.currentModel()}: no response from ${session.healthTarget()}`);
1218
+ setBootDetail(`${session.currentModel()}: no response from ${session.healthTarget()}`);
1189
1219
  return;
1190
1220
  }
1191
1221
  // The primary's served window, learned now rather than after the first overflow — AFTER the lever, so the gateway's
@@ -1234,7 +1264,7 @@ function Root() {
1234
1264
  }
1235
1265
  }
1236
1266
  // Confirm, once in scrollback, what the lever did (started = it was down and we brought it up).
1237
- const line = reports.map((r) => `${r.name} ${r.state === "up" ? "✓" : r.state === "started" ? "✓ started" : r.state === "idle" ? "on demand" : "✗"}`).join(" · ");
1267
+ const line = reports.map((r) => `${r.name} ${r.state === "up" ? "✓" : r.state === "started" ? "✓ started" : r.state === "idle" ? "retired, not started" : "✗"}`).join(" · ");
1238
1268
  if (line) {
1239
1269
  // SearXNG is lazy (starts on first web_search), but if a backend is ALREADY reachable — an explicit
1240
1270
  // KODE_SEARXNG_URL, or a container still up from a prior session — show ✓ instead of a misleading
@@ -1629,6 +1659,9 @@ function Root() {
1629
1659
  sys(`↻ loop recovery ${e.attempt}/${e.max}: ${calls} came back refused as repeats — ` +
1630
1660
  `${e.rounds === 1 ? "that round" : `those ${e.rounds} rounds`} became one note of their results; reviewing and continuing`);
1631
1661
  },
1662
+ onAutoReport: (to) => {
1663
+ sys(`↗ this wake turn ended without a report, so its final answer was delivered to ${to.join(", ")} (marked auto-delivered)`);
1664
+ },
1632
1665
  onAutoContinue: (round) => {
1633
1666
  push({ kind: "message", message: { id: nextId(), role: "assistant", content: `↻ still working — auto-continuing past ${round} tool rounds`, reasoning: "" } });
1634
1667
  },
@@ -1896,7 +1929,7 @@ function Root() {
1896
1929
  command: (cmd) => slashRef.current(cmd),
1897
1930
  submit: (text) => submitRef.current(text),
1898
1931
  start: (text, opts) => { void startTurn(text, opts); },
1899
- wakeDue: () => (getJobNoticeMode() === "wake" && pendingJobNotices() > 0) || pendingAgentReports() > 0,
1932
+ wakeDue: () => (getJobNoticeMode() === "wake" && pendingJobNotices() > 0) || agentReportsDue(),
1900
1933
  }), []);
1901
1934
  const sendTurn = useCallback((text, opts) => flow.send(text, opts), [flow]);
1902
1935
  const drainRef = useRef(() => { });
@@ -1923,6 +1956,17 @@ function Root() {
1923
1956
  push({ kind: "message", message: { id: nextId(), role: "system", content: text } });
1924
1957
  remoteRef.current?.system(text);
1925
1958
  }, []);
1959
+ useEffect(() => { for (const p of settingsLoadProblems())
1960
+ sys(`⚠ settings: ${p}`); }, [sys]);
1961
+ // A settings write that fails (locked, unreadable file, disk) is named; the running session keeps the change.
1962
+ const persist = useCallback((patch) => {
1963
+ try {
1964
+ saveSettings(patch);
1965
+ }
1966
+ catch (e) {
1967
+ sys(`⚠ not saved to settings.json: ${e instanceof Error ? e.message : String(e)}`);
1968
+ }
1969
+ }, [sys]);
1926
1970
  // A model turn is running (compacting is the one non-idle state with no next round to apply a setting to).
1927
1971
  const turnRunning = () => statusRef.current !== "idle" && statusRef.current !== "compacting";
1928
1972
  // /think rides in the system prompt (session.ts sysWithThink), so the turn after a toggle re-reads everything past the
@@ -2031,6 +2075,17 @@ function Root() {
2031
2075
  sys(picked.line);
2032
2076
  }, [boot]);
2033
2077
  useEffect(() => { remoteRef.current?.setAgents(toRemoteAgents(bgAgents)); }, [bgAgents, rcActive]);
2078
+ // Say so when a memories file is over its budget: the model is told in its prompt, the owner should be too.
2079
+ useEffect(() => {
2080
+ if (boot !== "ready")
2081
+ return;
2082
+ try {
2083
+ const note = memoryBudgetNote();
2084
+ if (note)
2085
+ sys(note);
2086
+ }
2087
+ catch { /* unreadable memory files are reported elsewhere */ }
2088
+ }, [boot]);
2034
2089
  // Say so when this launch cleaned up after a previous one — silently killing processes would be worse than the orphans.
2035
2090
  useEffect(() => {
2036
2091
  const n = REAPED.killed.length;
@@ -2038,6 +2093,24 @@ function Root() {
2038
2093
  sys(`cleaned up ${n} leftover process${n === 1 ? "" : "es"} from a previous session that did not exit cleanly (${[...new Set(REAPED.killed.map((k) => k.label))].join(", ")}).`);
2039
2094
  }, []);
2040
2095
  // A newer build (update-check.ts): the prompt before the first turn; once the owner has typed or a turn runs, one line.
2096
+ // After a /login the prompt comes up at once, or when the running turn ends.
2097
+ const showUpdatePrompt = (offer) => setUpdatePrompt({
2098
+ current: offer.current, version: offer.version, notes: offer.notes, command: offer.command,
2099
+ resolve: (choice) => {
2100
+ setUpdatePrompt(null);
2101
+ if (choice === "update") {
2102
+ UPDATE_NOW = offer;
2103
+ void teardown.run("quit");
2104
+ exit();
2105
+ return;
2106
+ }
2107
+ if (choice === "skip-version") {
2108
+ void import("./update-check.js").then(({ skipVersion }) => skipVersion(offer.version));
2109
+ sys(`Skipped ${offer.version} · Operator asks again when a newer version is out`);
2110
+ }
2111
+ },
2112
+ });
2113
+ const signInOfferRef = useRef(null);
2041
2114
  useEffect(() => {
2042
2115
  void UPDATE_CHECK.then((offer) => {
2043
2116
  if (!offer)
@@ -2046,24 +2119,24 @@ function Root() {
2046
2119
  sys(`Update available · ${offer.current} → ${offer.version} · run \`${offer.command}\` (release notes: ${offer.notes})`);
2047
2120
  return;
2048
2121
  }
2049
- setUpdatePrompt({
2050
- current: offer.current, version: offer.version, notes: offer.notes, command: offer.command,
2051
- resolve: (choice) => {
2052
- setUpdatePrompt(null);
2053
- if (choice === "update") {
2054
- UPDATE_NOW = offer;
2055
- void teardown.run("quit");
2056
- exit();
2057
- return;
2058
- }
2059
- if (choice === "skip-version") {
2060
- void import("./update-check.js").then(({ skipVersion }) => skipVersion(offer.version));
2061
- sys(`Skipped ${offer.version} · Operator asks again when a newer version is out`);
2062
- }
2063
- },
2064
- });
2122
+ showUpdatePrompt(offer);
2065
2123
  });
2066
2124
  }, []);
2125
+ useEffect(() => {
2126
+ const offer = signInOfferRef.current;
2127
+ if (offer && status === "idle") {
2128
+ signInOfferRef.current = null;
2129
+ showUpdatePrompt(offer);
2130
+ }
2131
+ }, [status]);
2132
+ const offerUpdateAfterSignIn = () => void checkOnSignIn().then((offer) => {
2133
+ if (!offer)
2134
+ return;
2135
+ if (statusRef.current === "idle")
2136
+ showUpdatePrompt(offer);
2137
+ else
2138
+ signInOfferRef.current = offer;
2139
+ });
2067
2140
  // The actual mode switch — policy, plan flag, status badge, and follower-facing capabilities, all in
2068
2141
  // lockstep. Factored out of applyMode so the plan-exit picker below can perform it from a resolve
2069
2142
  // callback without re-entering (and re-gating) applyMode itself.
@@ -2118,11 +2191,11 @@ function Root() {
2118
2191
  // pin) from the next round), persist the choice, light the footer badge, and say what it runs on now.
2119
2192
  const applyContext = useCallback((pin) => {
2120
2193
  session.setContextPin(pin);
2121
- saveSettings({ contextPin: session.contextPin() });
2194
+ persist({ contextPin: session.contextPin() });
2122
2195
  setCtxPin(session.contextPin());
2123
2196
  setCtxPct(session.ctxPct());
2124
2197
  sys(contextLine(session.contextPin(), session.servedContext(), session.ctxPct()) + (turnRunning() ? " · from the next round" : ""));
2125
- }, [sys]);
2198
+ }, [sys, persist]);
2126
2199
  // The /model, context and provider pickers share the one local QuestionPrompt slot. A row resolves by INDEX into the
2127
2200
  // entries it was drawn from (row text can repeat); the empty reply / ctrl+c (DISCUSS) closes the picker without
2128
2201
  // applying anything. The returned redraw re-renders the SAME picker while it is still the one on screen (portal
@@ -2230,8 +2303,10 @@ function Root() {
2230
2303
  sys(`${r.error} — run /model for the list`);
2231
2304
  return undefined;
2232
2305
  }
2306
+ if (r.note)
2307
+ sys(r.note);
2233
2308
  setRoute(s.currentModel());
2234
- saveSettings({ activeModel: s.currentModel() });
2309
+ persist({ activeModel: s.currentModel() });
2235
2310
  const chosen = s.modelRegistry().find((m) => m.id === s.currentModel());
2236
2311
  sys(modelLine(s.currentModel(), chosen, s.ctxPct(), s.turnCount(), cost)); // a free row repeats its caveat here
2237
2312
  // Arm the phase line's forecast of what the next message may re-read on this model (the line above names the cost).
@@ -2313,7 +2388,7 @@ function Root() {
2313
2388
  go();
2314
2389
  return;
2315
2390
  }
2316
- const here = s.currentModel() === DEFAULT_MODEL_ID ? "aurora" : s.currentModel();
2391
+ const here = s.currentModel();
2317
2392
  const est = s.compactionEstimate();
2318
2393
  const v = rereadConfirmView({
2319
2394
  target: a.entry.profile.label, current: here, cost,
@@ -2654,12 +2729,11 @@ function Root() {
2654
2729
  // In-session IO: sys lines for output, the system opener for the browser. No poll dots in the TUI —
2655
2730
  // a single "Waiting for approval…" line is clearer than a growing dot run next to the transcript.
2656
2731
  const inkIO = { log: (m) => sys(m), error: (m) => sys(m), ask: async () => "", openBrowser };
2732
+ const signedIn = (token, who) => { setOperatorToken(token); setAuthUser(who); offerUpdateAfterSignIn(); };
2657
2733
  const runBrowserLogin = async () => {
2658
2734
  const r = await signInWithBrowser(inkIO);
2659
- if (r.ok && r.account && r.token) {
2660
- setOperatorToken(r.token);
2661
- setAuthUser(r.account.email ?? r.account.external_id);
2662
- }
2735
+ if (r.ok && r.account && r.token)
2736
+ signedIn(r.token, r.account.email ?? r.account.external_id);
2663
2737
  else if (!r.ok && r.reason !== "denied")
2664
2738
  sys("try /login <email> to sign in by code instead");
2665
2739
  };
@@ -2685,10 +2759,9 @@ function Root() {
2685
2759
  const v = await signupVerify(email, a);
2686
2760
  if (v.ok) {
2687
2761
  await saveCredentials({ token: v.token, user: v.account.external_id, host: authBase(), issuedAt: Date.now() });
2688
- setOperatorToken(v.token);
2689
- setAuthUser(v.account.email ?? v.account.external_id);
2690
2762
  pendingLoginEmailRef.current = null;
2691
2763
  sys(`✓ signed in as ${v.account.email ?? v.account.external_id}`);
2764
+ signedIn(v.token, v.account.email ?? v.account.external_id);
2692
2765
  }
2693
2766
  else if (v.error === "invalid_code")
2694
2767
  sys("wrong code — /login <code> to try again");
@@ -2726,10 +2799,8 @@ function Root() {
2726
2799
  }
2727
2800
  // Otherwise treat it as a pasted personal access token (trimmed of stray whitespace/dots in sign-in.ts).
2728
2801
  const rtok = await signInWithToken(a, inkIO);
2729
- if (rtok.ok && rtok.account && rtok.token) {
2730
- setOperatorToken(rtok.token);
2731
- setAuthUser(rtok.account.email ?? rtok.account.external_id);
2732
- }
2802
+ if (rtok.ok && rtok.account && rtok.token)
2803
+ signedIn(rtok.token, rtok.account.email ?? rtok.account.external_id);
2733
2804
  else if (!rtok.ok)
2734
2805
  sys("did you mean /login <email>?");
2735
2806
  break;
@@ -2741,17 +2812,17 @@ function Root() {
2741
2812
  if (a === "on") {
2742
2813
  sys("enabling MCP tools…");
2743
2814
  const n = await s.enableMcp();
2744
- saveSettings({ mcp: true });
2815
+ persist({ mcp: true });
2745
2816
  sys(n > 0 ? `MCP on · ${n} fleet tools available (saved — on for new sessions too)` : "MCP on (saved), but no tools were discovered — the MCP gateway may be unreachable; it retries next session");
2746
2817
  }
2747
2818
  else if (a === "off") {
2748
- saveSettings({ mcp: false });
2819
+ persist({ mcp: false });
2749
2820
  sys("MCP off for new sessions (saved) — tools already loaded stay until you restart");
2750
2821
  }
2751
2822
  else if (a === "reload") {
2752
2823
  sys("reloading MCP from disk (base + the extra MCP config)…");
2753
2824
  const n = await s.reloadMcp();
2754
- saveSettings({ mcp: true });
2825
+ persist({ mcp: true });
2755
2826
  sys(n > 0 ? `MCP reloaded · ${n} fleet tools` : "MCP reloaded, but no tools discovered — check mcp_servers.json and the extra MCP config");
2756
2827
  }
2757
2828
  else if (a === "add") {
@@ -2774,7 +2845,7 @@ function Root() {
2774
2845
  env: { POWERTOOLS_ROOT: absRoot },
2775
2846
  });
2776
2847
  const n = await s.reloadMcp();
2777
- saveSettings({ mcp: true });
2848
+ persist({ mcp: true });
2778
2849
  sys(`powertools added · root=${absRoot} · wrote ${written} · ${n} fleet tools (alias: pt)`);
2779
2850
  }
2780
2851
  catch (e) {
@@ -2854,7 +2925,7 @@ function Root() {
2854
2925
  const setGuard = (patch) => {
2855
2926
  settings.delegate = { ...settings.delegate, ...patch };
2856
2927
  setDelegateSettings(settings.delegate);
2857
- saveSettings({ delegate: patch });
2928
+ persist({ delegate: patch });
2858
2929
  };
2859
2930
  const status = () => {
2860
2931
  const team = s.moaTeam();
@@ -2874,7 +2945,7 @@ function Root() {
2874
2945
  }
2875
2946
  const patch = { plannerModel: a.model, ...(executor ? { specialist: { id: executor } } : {}) };
2876
2947
  settings.moa = { ...settings.moa, ...patch };
2877
- saveSettings({ moa: patch });
2948
+ persist({ moa: patch });
2878
2949
  const onMoa = s.currentModel() === "moa";
2879
2950
  sys(`delegate · planner ${a.model} → executor ${s.moaTeam()?.specialist}${onMoa ? (turnRunning() ? " · from the next turn" : "") : " · switching to /model moa"}`);
2880
2951
  if (!onMoa)
@@ -2888,7 +2959,7 @@ function Root() {
2888
2959
  break;
2889
2960
  }
2890
2961
  settings.autonomy = { ...settings.autonomy, subagentModel: a.model };
2891
- saveSettings({ autonomy: { subagentModel: a.model } });
2962
+ persist({ autonomy: { subagentModel: a.model } });
2892
2963
  sys(`delegate · sub-agents (spawn_agent, delegate_task default) run on ${a.model}${s.currentModel() === "moa" ? ` — under /model moa the executor ${s.moaTeam()?.specialist} takes them` : ""}`);
2893
2964
  break;
2894
2965
  }
@@ -2899,7 +2970,7 @@ function Root() {
2899
2970
  else if (a.kind === "off") {
2900
2971
  s.setMoaPlanner("");
2901
2972
  settings.moa = { ...settings.moa, plannerModel: "" };
2902
- saveSettings({ moa: { plannerModel: "" } });
2973
+ persist({ moa: { plannerModel: "" } });
2903
2974
  setGuard({ guard: false, allowPush: false });
2904
2975
  }
2905
2976
  sys(status());
@@ -3067,8 +3138,8 @@ function Root() {
3067
3138
  break;
3068
3139
  }
3069
3140
  case "services": {
3070
- // The lever, on demand: `/services` probes + starts any down launchd service; `/services stop`
3071
- // tears down only the session-scoped SearXNG (Aurora/autopilot are shared and stay up).
3141
+ // The lever, on demand: `/services` probes + starts any down optional launchd service (never Aurora: retired,
3142
+ // reported only); `/services stop` tears down only the session-scoped SearXNG.
3072
3143
  if (arg === "stop") {
3073
3144
  const { stopSessionServices } = await import("./services/preflight.js");
3074
3145
  await stopSessionServices({ searxng: true });
@@ -3238,7 +3309,14 @@ function Root() {
3238
3309
  let lost = false; // an outage is said once; the re-dials behind it are silent until the relay answers
3239
3310
  const rh = new RemoteHost(urls, token, { title: `Operator · ${process.cwd().split("/").pop() || "session"}`, cwd: process.cwd(), host: hostname(), surface: "cli" }, {
3240
3311
  onPrompt: remotePrompt, // follower drives a turn (slash-shaped → the allowlisted command path)
3241
- onApprovalResponse: (id, approve) => settleApproval(id, approve), // first-wins with local
3312
+ onApprovalResponse: (id, approve, grant) => settleApproval(id, approve, false, grant), // first-wins with local
3313
+ onGrantRevoke: (req) => {
3314
+ if ("all" in req)
3315
+ grantsRef.current.revokeAll();
3316
+ else
3317
+ grantsRef.current.revoke(req.id);
3318
+ rh.setGrants(grantsRef.current.list());
3319
+ },
3242
3320
  onAskUserResponse: (id, answer) => settleQuestion(id, answer), // first-wins with local
3243
3321
  onInterrupt: () => s.interrupt(), // follower cancels the turn
3244
3322
  // RC v2 B1: a follower tapped Stop/Steer on a sub-agent row → the SAME BackgroundAgents the local
@@ -3308,7 +3386,14 @@ function Root() {
3308
3386
  let lost = false;
3309
3387
  const rh = new RemoteHost(urls, token, { title: `Operator · ${process.cwd().split("/").pop() || "session"}`, cwd: process.cwd(), host: hostname(), surface: "cli" }, {
3310
3388
  onPrompt: remotePrompt,
3311
- onApprovalResponse: (id, approve) => settleApproval(id, approve),
3389
+ onApprovalResponse: (id, approve, grant) => settleApproval(id, approve, false, grant),
3390
+ onGrantRevoke: (req) => {
3391
+ if ("all" in req)
3392
+ grantsRef.current.revokeAll();
3393
+ else
3394
+ grantsRef.current.revoke(req.id);
3395
+ rh.setGrants(grantsRef.current.list());
3396
+ },
3312
3397
  onAskUserResponse: (id, answer) => settleQuestion(id, answer),
3313
3398
  onInterrupt: () => s.interrupt(),
3314
3399
  onAgentStop: (id) => bgRef.current?.requestStop(id) ?? false, // RC v2 B1 (paired mode)
@@ -3767,11 +3852,15 @@ function Root() {
3767
3852
  // no message is dropped. settings.wakeOnMentor.from narrows which senders may drive a turn (unset = any).
3768
3853
  if (isFeatureEnabled("wakeOnMentor", settings)) {
3769
3854
  const allow = settings.wakeOnMentor?.from;
3770
- const eligible = allow?.length ? incoming.filter((m) => allow.includes(m.from)) : incoming;
3855
+ const eligible = (allow?.length ? incoming.filter((m) => allow.includes(m.from)) : incoming).filter((m) => !isAutoReport(m));
3771
3856
  wakeBuffer.push(...eligible);
3772
3857
  const ready = selectReadyWakes(wakeBuffer, lastWakeBySource, now, WAKE_COOLDOWN_MS);
3773
- const wakeText = ready.length ? buildMentorWake(ready) : null;
3858
+ const rootPolicy = allow?.length ? { roots: settings.wakeOnMentor?.roots ?? [join(homedir(), "work")] } : undefined;
3859
+ const wakeText = ready.length ? buildMentorWake(ready, undefined, rootPolicy) : null;
3774
3860
  if (wakeText) {
3861
+ const dir = wakeRoot(wakeText);
3862
+ if (dir)
3863
+ sys(`↳ wake from ${[...new Set(ready.map((m) => m.from))].join(", ")}: this turn runs in ${dir} (from the brief)`);
3775
3864
  if (statusRef.current === "idle")
3776
3865
  submitRef.current?.(wakeText);
3777
3866
  else
@@ -3793,8 +3882,8 @@ function Root() {
3793
3882
  if (boot === "checking")
3794
3883
  return _jsx(Text, { dimColor: true, children: bootDetail || "connecting to Operator…" });
3795
3884
  if (boot === "down") {
3796
- return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: "red", children: "Can't reach Operator on the configured endpoint." }), bootDetail ? _jsx(Text, { dimColor: true, children: bootDetail }) : null, session.currentModel() === DEFAULT_MODEL_ID
3797
- ? _jsxs(Text, { dimColor: true, children: ["The Operator model is launchd-owned. Recover it with: launchctl kickstart -k gui/$(id -u)/", settings.services?.aurora?.launchdLabel ?? "co.0perator.gateway"] })
3885
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: "red", children: "Can't reach Operator on the configured endpoint." }), bootDetail ? _jsx(Text, { dimColor: true, children: bootDetail }) : null, session.currentModel() === CHAIN_MODEL_ID
3886
+ ? _jsx(Text, { dimColor: true, children: "No leg of the chain answered (the local router's main route, then the cloud tier). Check the router, or sign in for the cloud tier." })
3798
3887
  : _jsxs(Text, { dimColor: true, children: ["Start on another model: set \"activeModel\" in settings.json to one /model lists, then /model ", session.currentModel(), " once it is reachable."] })] }));
3799
3888
  }
3800
3889
  // While a turn runs, show a LIVE line: braille spinner + climbing token count + live tok/s + elapsed
@@ -3855,7 +3944,7 @@ function Root() {
3855
3944
  decode: shownPhase === "thinking" || shownPhase === "writing" || shownPhase === "drafting" ? decodeView() : undefined,
3856
3945
  }
3857
3946
  : null;
3858
- return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, phase: phaseView, fold: liveFold, delegate: delegate, thinkingVerb: stepVerb ?? triage ?? phaseVerb(shownPhase ?? undefined, phaseView?.read), liveTools: liveTools, route: route, ctxPct: ctxPct, ctxWindow: session.currentModel() === "moa" ? (ctxPin ? fmtCtx(ctxPin) : undefined) : fmtCtx(ctxPin ? Math.min(ctxPin, session.servedContext()) : session.servedContext()), version: VERSION, fullscreen: FULLSCREEN, metrics: liveMetrics, sessionTokens: session.sessionTokens() + liveTok, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, shellJobs: shellJobs, mainLane: mainLane, mainServing: servingModelFor(settings, session.currentModel()), maxRunning: bg.limits().running, onBackground: onBackground, tasks: tasks, planNow: planLive ? Date.now() : lastTurnEndRef.current, onSubmit: onSubmit, onQueue: onQueue, onSteer: onSteer, pending: pending, nextSteps: nextSteps ?? undefined, onPickNext: onPickNext, onDismissNext: onDismissNext, agents: bgAgents, onAgentMessage: onAgentMessage, conversations: convs, switcher: { focused: switcher.focused, sel: Math.max(0, convs.findIndex((c) => c.id === switcher.sel)), open: openConv }, onSwitcher: onSwitcher, onFocusSwitcher: onFocusSwitcher, conversationPane: conversationPane, onSendTo: onSendTo, actOffer: active ? actNowOffer(actRef.current, Date.now(), { thinking: thinkMode !== "off" }) : null, onActNow: onActNow, finder: finder, onOpenFinder: onOpenFinder, onEditQueued: popQueued, onDropQueued: onDropQueued, onInterrupt: onInterrupt, onExpand: onExpand, onCycleMode: onCycleMode, onCycleContext: onCycleContext, opMode: opMode, rcConnected: rcConnected, rcActive: rcActive, caffeinated: caffeinated, approval: approval, question: question, modelPicker: modelPicker, secretPrompt: secretPrompt, planExitPicker: planExitPicker, artifactsPicker: artifactsPicker, sessionsPicker: sessionsPicker, update: updatePrompt, onApprovalDecide: (allow, always) => {
3947
+ return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, phase: phaseView, fold: liveFold, delegate: delegate, thinkingVerb: stepVerb ?? triage ?? phaseVerb(shownPhase ?? undefined, phaseView?.read), liveTools: liveTools, route: route, ctxPct: ctxPct, ctxWindow: session.currentModel() === "moa" ? (ctxPin ? fmtCtx(ctxPin) : undefined) : fmtCtx(ctxPin ? Math.min(ctxPin, session.servedContext()) : session.servedContext()), version: VERSION, fullscreen: FULLSCREEN, metrics: liveMetrics, sessionTokens: session.sessionTokens() + liveTok, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, shellJobs: shellJobs, mainLane: mainLane, mainServing: servingModelFor(settings, session.currentModel()), maxRunning: bg.limits().running, lanePool: bg.slotState().line, laneWarnings: bg.evidenceWarnings(), onBackground: onBackground, tasks: tasks, planNow: planLive ? Date.now() : lastTurnEndRef.current, onSubmit: onSubmit, onQueue: onQueue, onSteer: onSteer, pending: pending, nextSteps: nextSteps ?? undefined, onPickNext: onPickNext, onDismissNext: onDismissNext, agents: bgAgents, onAgentMessage: onAgentMessage, conversations: convs, switcher: { focused: switcher.focused, sel: Math.max(0, convs.findIndex((c) => c.id === switcher.sel)), open: openConv }, onSwitcher: onSwitcher, onFocusSwitcher: onFocusSwitcher, conversationPane: conversationPane, onSendTo: onSendTo, actOffer: active ? actNowOffer(actRef.current, Date.now(), { thinking: thinkMode !== "off" }) : null, onActNow: onActNow, finder: finder, onOpenFinder: onOpenFinder, onEditQueued: popQueued, onDropQueued: onDropQueued, onInterrupt: onInterrupt, onExpand: onExpand, onCycleMode: onCycleMode, onCycleContext: onCycleContext, opMode: opMode, rcConnected: rcConnected, rcActive: rcActive, caffeinated: caffeinated, approval: approval, question: question, modelPicker: modelPicker, secretPrompt: secretPrompt, planExitPicker: planExitPicker, artifactsPicker: artifactsPicker, sessionsPicker: sessionsPicker, update: updatePrompt, onApprovalDecide: (allow, always) => {
3859
3948
  const cur = approval;
3860
3949
  if (cur)
3861
3950
  settleApproval(cur.id, allow, always); // first-wins with any remote follower answer
@@ -3866,7 +3955,13 @@ function Root() {
3866
3955
  // (--version/--help fast paths hoisted to the top of the module — they must never touch keychain/network.)
3867
3956
  if (process.argv[2] === "auth") {
3868
3957
  const { runAuth } = await import("./auth/commands.js");
3869
- process.exit(await runAuth(process.argv.slice(3), settings));
3958
+ const code = await runAuth(process.argv.slice(3), settings);
3959
+ if (code === 0 && process.argv[3] === "login") {
3960
+ const offer = await checkOnSignIn();
3961
+ if (offer)
3962
+ console.log(`\n${(await import("./update-check.js")).offerLine(offer)}`);
3963
+ }
3964
+ process.exit(code);
3870
3965
  }
3871
3966
  // `operator audit verify|tail` and `operator doctor` — the enterprise review surface: prove the audit trail is
3872
3967
  // intact, and show exactly what policy/seat/home posture is in force. Plain console, no TTY needed.