@catalyst-cloud/cli 0.16.3 → 0.16.6

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.
@@ -8,22 +8,24 @@ import { runnerAdmission, issueRunnerOrgKey, verifyRunnerRoutes } from "./onboar
8
8
  import { verifyOnboardRoutes } from "./onboard-capabilities.js";
9
9
  import { liveTeamKey, onboardTeamAdmission } from "./onboard-capacity.js";
10
10
  import { runnerVmCapabilities } from "./onboard-runner-probes.js";
11
+ import { installDarwinThoughtsCustody } from "./onboard-runner-custody.js";
12
+ import { canonicalDarwinThoughtsJson, parseDarwinThoughtsAuthority } from "../vendor/self-host/darwin-thoughts-custody/verifier.mjs";
11
13
  import { readExistingOnboardJson, readOnboardTeamInventory, selectedOnboardTeam, } from "./onboard-existing.js";
12
14
  import { onboardStateRoot, } from "./onboard.js";
13
15
  // "Run Catalyst's work on this machine": the self-hosted host from catalyst-cloud's deploy/self-host
14
16
  // (a supervisor and a deadline watchdog under Compose), enrolled with the person's own owner or
15
- // admin login. Never the operator token. Missing host images are pulled anonymously with an empty
16
- // disposable Docker config. Customer delivery uses public GHCR pins, without registry credentials.
17
+ // admin login. Never the operator token. Native Linux pulls missing images anonymously with an
18
+ // empty disposable Docker config; Darwin custody receives only already-cached pinned images.
17
19
  /** The Compose project name the vendored file declares. */
18
20
  export const RUNNER_PROJECT = "catalyst-host";
19
21
  export const RUNNER_SESSION_NETWORK = "catalyst-session-v1";
20
- /** Public multi-architecture images: host images from main 0b5495e144 (run 36999325814),
21
- * runner from main 48b5876e56 (run 37057503445). Explicit environment image values override
22
+ /** Public multi-architecture images from main 3d657787e8: host run 38043266620,
23
+ * runner run 38042751509. Explicit environment image values override
22
24
  * these pins; the runner also preserves a saved image before choosing its default. */
23
25
  export const RUNNER_HOST_IMAGES = {
24
- supervisor: "ghcr.io/coalesce-labs/catalyst-supervisor@sha256:fff1582e3ef763eae6728f195a8e3834383955ee03d39bcfe567f4a7361a8982",
25
- watchdog: "ghcr.io/coalesce-labs/catalyst-deadline-watchdog@sha256:b64e38f9ee34240d1e3d256e954eb8de20e2d3e51ed873019d350aa60be639c1",
26
- runner: "ghcr.io/coalesce-labs/catalyst-runner@sha256:50eeb256b4693fc42c81458bdfc887137a0df757260601f2a869738578d00782",
26
+ supervisor: "ghcr.io/coalesce-labs/catalyst-supervisor@sha256:a0a8f383b5869eddc8346b7d07fd98d92fe1cd4cfc57956cbbe9dc42d79a4727",
27
+ watchdog: "ghcr.io/coalesce-labs/catalyst-deadline-watchdog@sha256:a5999dbf229ac432b83c2ed3fe43fa251366baceb73af2f57590890a6a758f0d",
28
+ runner: "ghcr.io/coalesce-labs/catalyst-runner@sha256:88c6143f6c95f92fca9ca385f3c5145389e6d6d0532398c52d225d0edfcf2ea8",
27
29
  };
28
30
  const IMAGE_REF = /^[a-z0-9][a-z0-9._:/-]{0,255}@sha256:[0-9a-f]{64}$/;
29
31
  const HOST_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/;
@@ -33,6 +35,37 @@ const JOIN_TOKENS = "/api/v1/hosts/join-tokens";
33
35
  const CAPACITY = "/api/v1/me/runner-capacity";
34
36
  const RUNNER_UID = "10001:10001";
35
37
  const DIRS = ["slots", "thoughts", "locks"];
38
+ const CUSTODY_KEYS = [
39
+ "CATALYST_THOUGHTS_CUSTODY_AUTHORITY",
40
+ "CATALYST_THOUGHTS_CUSTODY_REQUESTS_DIR",
41
+ "CATALYST_THOUGHTS_CUSTODY_RESPONSES_DIR",
42
+ ];
43
+ /** A persisted authority selects bindings, never substitutes for a fresh native proof. */
44
+ function persistedCustody(dir, values) {
45
+ const present = CUSTODY_KEYS.map(key => values?.[key] ?? "");
46
+ if (present.every(value => !value))
47
+ return "absent";
48
+ if (present.some(value => !value))
49
+ return "invalid";
50
+ try {
51
+ const authority = parseDarwinThoughtsAuthority(JSON.parse(present[0]));
52
+ return canonicalDarwinThoughtsJson(authority) === present[0] &&
53
+ authority.thoughtsRoot === join(dir, "thoughts") && authority.locksRoot === join(dir, "locks") &&
54
+ authority.requestsRoot === present[1] && authority.responsesRoot === present[2] &&
55
+ authority.requestsRoot === join(dir, "..", "darwin-thoughts-requests") &&
56
+ authority.responsesRoot === join(dir, "..", "darwin-thoughts-responses")
57
+ ? "installed" : "invalid";
58
+ }
59
+ catch {
60
+ return "invalid";
61
+ }
62
+ }
63
+ const DISK_POLICY_KEYS = [
64
+ "CATALYST_SLOTS",
65
+ "CATALYST_SLOT_DISK_MODE", "CATALYST_SLOT_DISK_BUDGET_GIB", "CATALYST_DISK_BUDGET_GIB",
66
+ "CATALYST_WORKSPACE_STORAGE", "CATALYST_WORKSPACE_RETENTION_HOURS",
67
+ "CATALYST_HOST_FREE_FLOOR_GIB", "CATALYST_HOST_DISK_SAMPLE_DIR", "CATALYST_HOST_DISK_SAMPLE_FILE",
68
+ ];
36
69
  function isUnenrolled(value) {
37
70
  return value !== null && "unenrolled" in value;
38
71
  }
@@ -70,27 +103,38 @@ export function dockerRunnerEngine(deps = {}) {
70
103
  return { code: 1, stdout: "" };
71
104
  }
72
105
  };
73
- const compose = (dir) => [
74
- "compose",
75
- "--project-name",
76
- RUNNER_PROJECT,
77
- "--file",
78
- join(dir, "compose.yaml"),
79
- "--env-file",
80
- join(dir, ".env"),
81
- ];
82
- const supervisorShell = (dir, script) => [
83
- ...compose(dir),
84
- "run",
85
- "--rm",
86
- "-T",
87
- "--no-deps",
88
- "--entrypoint",
89
- "sh",
90
- "supervisor",
91
- "-c",
92
- script,
93
- ];
106
+ const compose = (dir) => {
107
+ const custody = persistedCustody(dir, readEnvFile(join(dir, ".env")));
108
+ if (custody === "invalid")
109
+ return null;
110
+ return [
111
+ "compose",
112
+ "--project-name",
113
+ RUNNER_PROJECT,
114
+ "--file",
115
+ join(dir, "compose.yaml"),
116
+ ...(custody === "installed" ? ["--file", join(dir, "compose.darwin-thoughts.yaml")] : []),
117
+ "--env-file",
118
+ join(dir, ".env"),
119
+ ];
120
+ };
121
+ const supervisorShell = (dir, script) => {
122
+ const files = compose(dir);
123
+ if (!files)
124
+ return null;
125
+ return [
126
+ ...files,
127
+ "run",
128
+ "--rm",
129
+ "-T",
130
+ "--no-deps",
131
+ "--entrypoint",
132
+ "sh",
133
+ "supervisor",
134
+ "-c",
135
+ script,
136
+ ];
137
+ };
94
138
  let nativeLocal = false;
95
139
  const endpoint = async (signal) => {
96
140
  // Reject conflicting selectors rather than infer precedence across Docker/Compose versions.
@@ -157,17 +201,37 @@ export function dockerRunnerEngine(deps = {}) {
157
201
  const labels = config?.Labels;
158
202
  const dir = labels?.["com.docker.compose.project.working_dir"];
159
203
  if (config?.Image !== supervisorImage || labels?.["com.docker.compose.project"] !== RUNNER_PROJECT ||
160
- labels?.["com.docker.compose.service"] !== "supervisor" || typeof dir !== "string" || !isAbsolute(dir) ||
161
- labels?.["com.docker.compose.project.config_files"] !== join(dir, "compose.yaml"))
204
+ labels?.["com.docker.compose.service"] !== "supervisor" || typeof dir !== "string" || !isAbsolute(dir))
162
205
  return "unverified";
163
206
  const inHome = relative(realpathSync(home), realpathSync(dir));
164
207
  if (inHome === ".." || inHome.startsWith("../") || isAbsolute(inHome) || !lstatSync(dir).isDirectory())
165
208
  return "unverified";
209
+ const saved = readEnvFile(join(dir, ".env"));
210
+ const custody = persistedCustody(dir, saved);
211
+ if (custody === "invalid")
212
+ return "unverified";
213
+ const files = [join(dir, "compose.yaml"), ...(custody === "installed" ? [join(dir, "compose.darwin-thoughts.yaml")] : [])];
214
+ if (labels?.["com.docker.compose.project.config_files"] !== files.join(","))
215
+ return "unverified";
166
216
  for (const path of [join(dir, "compose.yaml"), join(dir, ".env")]) {
167
217
  const stat = lstatSync(path);
168
218
  if (!stat.isFile() || stat.uid !== process.getuid?.() || (stat.mode & 0o022) !== 0)
169
219
  return "unverified";
170
220
  }
221
+ if (custody === "installed") {
222
+ for (const path of [join(dir, ".env"), join(dir, "compose.darwin-thoughts.yaml")]) {
223
+ const stat = lstatSync(path);
224
+ if (!stat.isFile() || stat.nlink !== 1 || stat.uid !== process.getuid?.() ||
225
+ (stat.mode & 0o7777) !== 0o600)
226
+ return "unverified";
227
+ }
228
+ for (const key of CUSTODY_KEYS.slice(1)) {
229
+ const stat = lstatSync(saved[key]);
230
+ if (!stat.isDirectory() || stat.uid !== process.getuid?.() ||
231
+ (stat.mode & 0o7777) !== 0o700)
232
+ return "unverified";
233
+ }
234
+ }
171
235
  if (!Array.isArray(config.Env) || !config.Env.every((entry) => typeof entry === "string"))
172
236
  return "unverified";
173
237
  const names = config.Env.filter((entry) => entry.startsWith("CATALYST_HOST_NAME="));
@@ -255,6 +319,9 @@ export function dockerRunnerEngine(deps = {}) {
255
319
  return runnerVmCapabilities({ paths: DIRS.map(sub => join(dir, sub)), image, baseUrl,
256
320
  exec: docker, env, signal });
257
321
  },
322
+ async nativeThoughtsCustody(input, signal) {
323
+ return installDarwinThoughtsCustody({ ...input, deadlineMs: Date.now() + 30_000 }, signal);
324
+ },
258
325
  async socketGid() {
259
326
  if (!nativeLocal)
260
327
  return null;
@@ -266,8 +333,11 @@ export function dockerRunnerEngine(deps = {}) {
266
333
  }
267
334
  },
268
335
  async claimDirs(dir, paths, signal) {
336
+ const files = compose(dir);
337
+ if (!files)
338
+ return false;
269
339
  const args = [
270
- ...compose(dir),
340
+ ...files,
271
341
  "run",
272
342
  "--rm",
273
343
  "-T",
@@ -287,13 +357,19 @@ export function dockerRunnerEngine(deps = {}) {
287
357
  0);
288
358
  },
289
359
  async hasVolumeFile(dir, variable, signal) {
290
- return ((await docker(supervisorShell(dir, `test -s "$${variable}"`), {
360
+ const args = supervisorShell(dir, `test -s "$${variable}"`);
361
+ if (!args)
362
+ return false;
363
+ return ((await docker(args, {
291
364
  cwd: dir,
292
365
  signal,
293
366
  timeoutMs: 120_000,
294
367
  })).code === 0);
295
368
  },
296
369
  async enrollment(dir, signal) {
370
+ const files = compose(dir);
371
+ if (!files)
372
+ return null;
297
373
  const script = `(() => { const {readFileSync}=require("node:fs");
298
374
  try { const state=JSON.parse(readFileSync(process.env.CATALYST_HOST_CREDENTIAL_FILE,"utf8"));
299
375
  if (state.version!==1 || typeof state.secret!=="string" || !/^[A-Za-z0-9_-]{32,256}$/.test(state.secret)) process.exit(1);
@@ -307,7 +383,7 @@ export function dockerRunnerEngine(deps = {}) {
307
383
  if (!e) process.exit(1);
308
384
  process.stdout.write(JSON.stringify({hostId:e.hostId,tenant:e.tenant,team:e.team,enrollmentKind:e.enrollmentKind}));
309
385
  } catch { process.exit(1); } })();`;
310
- const read = await docker([...compose(dir), "run", "--rm", "-T", "--no-deps", "--entrypoint", "bun", "supervisor", "-e", script], { cwd: dir, signal, timeoutMs: 120_000 });
386
+ const read = await docker([...files, "run", "--rm", "-T", "--no-deps", "--entrypoint", "bun", "supervisor", "-e", script], { cwd: dir, signal, timeoutMs: 120_000 });
311
387
  if (read.code !== 0)
312
388
  return null;
313
389
  try {
@@ -324,6 +400,9 @@ export function dockerRunnerEngine(deps = {}) {
324
400
  }
325
401
  },
326
402
  async orgKeyStatus(dir, account, baseUrl, candidate, signal) {
403
+ const files = compose(dir);
404
+ if (!files)
405
+ return "unavailable";
327
406
  // Only a status leaves the container. No stored key or provider response is printed.
328
407
  const script = `(async () => {
329
408
  const {readFileSync,lstatSync}=require("node:fs");
@@ -352,7 +431,7 @@ export function dockerRunnerEngine(deps = {}) {
352
431
  return status(proposed && proposed!==stored ? "different" : "valid");
353
432
  } catch { return status("unavailable"); }
354
433
  })().catch(()=>process.stdout.write("unavailable"));`;
355
- const read = await docker([...compose(dir), "run", "--rm", "-T", "--no-deps", "--entrypoint", "bun", "supervisor", "-e", script, baseUrl, account], { cwd: dir, input: candidate ? `${candidate}\n` : undefined, signal, timeoutMs: 120_000 });
434
+ const read = await docker([...files, "run", "--rm", "-T", "--no-deps", "--entrypoint", "bun", "supervisor", "-e", script, baseUrl, account], { cwd: dir, input: candidate ? `${candidate}\n` : undefined, signal, timeoutMs: 120_000 });
356
435
  const status = read.stdout.trim();
357
436
  return read.code === 0 && ["valid", "different", "missing", "invalid", "unavailable"].includes(status)
358
437
  ? status : "unavailable";
@@ -361,7 +440,10 @@ export function dockerRunnerEngine(deps = {}) {
361
440
  if (variable !== "CATALYST_ORG_KEY_FILE")
362
441
  return false;
363
442
  const script = `umask 077 && tmp=$(mktemp "$${variable}.onboard.XXXXXX") && trap 'rm -f "$tmp"' EXIT && cat > "$tmp" && test -s "$tmp" && chmod 600 "$tmp" && mv -f "$tmp" "$${variable}"`;
364
- return ((await docker(supervisorShell(dir, script), {
443
+ const args = supervisorShell(dir, script);
444
+ if (!args)
445
+ return false;
446
+ return ((await docker(args, {
365
447
  cwd: dir,
366
448
  input: `${value}\n`,
367
449
  signal,
@@ -369,11 +451,17 @@ export function dockerRunnerEngine(deps = {}) {
369
451
  })).code === 0);
370
452
  },
371
453
  async composeUp(dir, signal) {
372
- return ((await docker([...compose(dir), "up", "--detach"], { cwd: dir, signal, timeoutMs: 600_000 }))
454
+ const files = compose(dir);
455
+ if (!files)
456
+ return false;
457
+ return ((await docker([...files, "up", "--detach"], { cwd: dir, signal, timeoutMs: 600_000 }))
373
458
  .code === 0);
374
459
  },
375
460
  async composeRunning(dir, signal) {
376
- const read = await docker([...compose(dir), "ps", "--status", "running", "--services"], { cwd: dir, signal });
461
+ const files = compose(dir);
462
+ if (!files)
463
+ return false;
464
+ const read = await docker([...files, "ps", "--status", "running", "--services"], { cwd: dir, signal });
377
465
  return (read.code === 0 &&
378
466
  read.stdout.split("\n").some((line) => line.trim() === "supervisor"));
379
467
  },
@@ -473,6 +561,7 @@ export function onboardRunnerAdapter(input = {}) {
473
561
  let mayAct = false;
474
562
  let acted = false;
475
563
  let chosenName;
564
+ let receivedCustody;
476
565
  const selected = { selected: true };
477
566
  async function decide(journal) {
478
567
  if (decided !== undefined)
@@ -576,7 +665,7 @@ export function onboardRunnerAdapter(input = {}) {
576
665
  return { account, baseUrl: normalizeBaseUrl(cfg.baseUrl), teamKey, teamId, cloud, dir, info, images,
577
666
  ...(installation && installation !== "missing" ? { installedName: installation.hostName } : {}) };
578
667
  }
579
- async function desiredEnv(p, joinToken) {
668
+ async function desiredEnv(p, ctx, joinToken) {
580
669
  const saved = readEnvFile(join(p.dir, ".env")) ?? {};
581
670
  const name = p.installedName || saved.CATALYST_HOST_NAME || chosenName || (input.hostName ?? runnerDefaultHostName)();
582
671
  const gid = p.info.vm ? 0 : await engine.socketGid();
@@ -594,7 +683,14 @@ export function onboardRunnerAdapter(input = {}) {
594
683
  CATALYST_SLOTS_DIR: join(p.dir, "slots"),
595
684
  CATALYST_THOUGHTS_DIR: join(p.dir, "thoughts"),
596
685
  CATALYST_POOL_LOCK_DIR: join(p.dir, "locks"),
686
+ ...(p.info.vm && receivedCustody?.dir === p.dir ? {
687
+ CATALYST_THOUGHTS_CUSTODY_AUTHORITY: receivedCustody.result.envAuthority,
688
+ CATALYST_THOUGHTS_CUSTODY_REQUESTS_DIR: receivedCustody.result.requestsRoot,
689
+ CATALYST_THOUGHTS_CUSTODY_RESPONSES_DIR: receivedCustody.result.responsesRoot,
690
+ } : {}),
597
691
  CATALYST_SESSION_EGRESS_DIR: p.info.vm ? join(p.dir, "session-egress") : NATIVE_EGRESS_DIR,
692
+ // Saved policy stays in merged(). An explicit value in this run overrides it.
693
+ ...Object.fromEntries(DISK_POLICY_KEYS.flatMap(key => ctx.env[key] === undefined ? [] : [[key, ctx.env[key]]])),
598
694
  };
599
695
  }
600
696
  /** The step owns its own keys only; a person's tuning (CATALYST_SLOTS and the rest) is kept. */
@@ -665,10 +761,12 @@ export function onboardRunnerAdapter(input = {}) {
665
761
  if (!("dir" in p))
666
762
  return p;
667
763
  const saved = readEnvFile(join(p.dir, ".env"));
668
- const want = await desiredEnv(p);
764
+ const want = await desiredEnv(p, ctx);
669
765
  if (!want)
670
766
  return waiting("runner_docker_socket_unreadable", selected);
671
767
  const name = want.CATALYST_HOST_NAME;
768
+ if (p.info.vm && persistedCustody(p.dir, saved) !== "installed")
769
+ return mayAct && !afterAct ? { state: "pending" } : waiting(mayAct ? "runner_thoughts_custody_unavailable" : "runner_needs_runner_flag", { ...selected, hostName: name });
672
770
  let enrolled = null;
673
771
  const live = (hosts) => hosts?.find((host) => host.hostId === enrolled?.hostId && host.team === p.teamKey && !host.revoked);
674
772
  let hosts = await listHosts(ctx, p, signal);
@@ -688,7 +786,16 @@ export function onboardRunnerAdapter(input = {}) {
688
786
  host.team !== p.teamKey))
689
787
  return waiting("runner_enrolled_for_other_team", { ...selected, hostName: name });
690
788
  const running = await engine.composeRunning(p.dir, signal);
691
- const changed = !saved || Object.entries(want).some(([key, value]) => saved[key] !== value);
789
+ let composeMatches = false;
790
+ try {
791
+ composeMatches = readFileSync(join(p.dir, "compose.yaml")).equals(readFileSync(join(packageRoot(), "vendor", "self-host", "compose.yaml")));
792
+ if (p.info.vm)
793
+ composeMatches = composeMatches && readFileSync(join(p.dir, "compose.darwin-thoughts.yaml")).equals(readFileSync(join(packageRoot(), "vendor", "self-host", "compose.darwin-thoughts.yaml")));
794
+ }
795
+ catch {
796
+ /* A missing or unreadable compose needs an explicitly authorized repair. */
797
+ }
798
+ const changed = !saved || !composeMatches || Object.entries(want).some(([key, value]) => saved[key] !== value);
692
799
  const hostEvidence = { ...selected, hostName: name };
693
800
  const pending = () => mayAct ? { state: "pending" } : waiting("runner_needs_runner_flag", hostEvidence);
694
801
  if (!running || changed)
@@ -763,15 +870,20 @@ export function onboardRunnerAdapter(input = {}) {
763
870
  mkdirSync(p.dir, { recursive: true, mode: 0o700 });
764
871
  if (lstatSync(p.dir).isSymbolicLink())
765
872
  throw new Error("runner_directory_unsafe");
766
- chmodSync(p.dir, 0o700);
873
+ if (!p.info.vm)
874
+ chmodSync(p.dir, 0o700);
767
875
  for (const sub of DIRS) {
768
876
  mkdirSync(join(p.dir, sub), { recursive: true, mode: 0o700 });
769
877
  // On native Linux the runner uid owns these after the first run; leave them alone.
770
- if (statSync(join(p.dir, sub)).uid === process.getuid?.())
878
+ // The native Darwin installer must receive existing thoughts custody without adoption.
879
+ if ((!p.info.vm || sub === "slots") && statSync(join(p.dir, sub)).uid === process.getuid?.())
771
880
  chmodSync(join(p.dir, sub), 0o700);
772
881
  }
773
882
  // Mounted read-only into the supervisor (uid 10001), which reads the egress attestation.
774
883
  mkdirSync(join(p.dir, "session-egress"), { recursive: true, mode: 0o755 });
884
+ // The canonical compose binds host-native disk samples read-only. A custom sample
885
+ // directory belongs to its operator; only create the install's default directory.
886
+ mkdirSync(join(p.dir, "host-disk"), { recursive: true, mode: 0o755 });
775
887
  const compose = readFileSync(join(packageRoot(), "vendor", "self-host", "compose.yaml"));
776
888
  let current = null;
777
889
  try {
@@ -797,7 +909,7 @@ export function onboardRunnerAdapter(input = {}) {
797
909
  return waiting("runner_name_required", selected);
798
910
  chosenName = name;
799
911
  }
800
- let want = await desiredEnv(p);
912
+ let want = await desiredEnv(p, ctx);
801
913
  if (!want)
802
914
  return waiting("runner_docker_socket_unreadable", selected);
803
915
  const writeEnv = (values) => {
@@ -815,7 +927,7 @@ export function onboardRunnerAdapter(input = {}) {
815
927
  if (!writeEnv(want))
816
928
  return { state: "failed", reason: "runner_directory_unavailable", evidence: selected };
817
929
  for (const ref of Object.values(p.images)) {
818
- if (!(await engine.imageArch(ref, signal))) {
930
+ if (!(await engine.imageArch(ref, signal)) && !p.info.vm) {
819
931
  await engine.pull(ref, signal);
820
932
  }
821
933
  const arch = await engine.imageArch(ref, signal);
@@ -828,6 +940,30 @@ export function onboardRunnerAdapter(input = {}) {
828
940
  const capability = await engine.vmCapabilities(p.dir, p.images.supervisor, p.baseUrl, signal);
829
941
  if (capability !== "ready")
830
942
  return waiting(capability, selected);
943
+ try {
944
+ if (!engine.nativeThoughtsCustody)
945
+ return waiting("runner_thoughts_custody_unavailable", selected);
946
+ const result = await engine.nativeThoughtsCustody({ dir: p.dir,
947
+ supervisorImage: p.images.supervisor, runnerImage: p.images.runner }, signal);
948
+ if (signal?.aborted)
949
+ return waiting("interrupted", selected);
950
+ const values = {
951
+ CATALYST_THOUGHTS_CUSTODY_AUTHORITY: result.envAuthority,
952
+ CATALYST_THOUGHTS_CUSTODY_REQUESTS_DIR: result.requestsRoot,
953
+ CATALYST_THOUGHTS_CUSTODY_RESPONSES_DIR: result.responsesRoot,
954
+ };
955
+ if (persistedCustody(p.dir, values) !== "installed" ||
956
+ canonicalDarwinThoughtsJson(result.authority) !== result.envAuthority)
957
+ return waiting("runner_thoughts_custody_unavailable", selected);
958
+ writePrivate(join(p.dir, "compose.darwin-thoughts.yaml"), readFileSync(join(packageRoot(), "vendor", "self-host", "compose.darwin-thoughts.yaml"), "utf8"));
959
+ receivedCustody = { dir: p.dir, result };
960
+ want = (await desiredEnv(p, ctx));
961
+ if (!writeEnv(want))
962
+ return { state: "failed", reason: "runner_directory_unavailable", evidence: selected };
963
+ }
964
+ catch {
965
+ return waiting(signal?.aborted ? "interrupted" : "runner_thoughts_custody_unavailable", selected);
966
+ }
831
967
  }
832
968
  const network = await engine.network(RUNNER_SESSION_NETWORK, signal);
833
969
  if (network === "misshaped")
@@ -870,7 +1006,7 @@ export function onboardRunnerAdapter(input = {}) {
870
1006
  const token = await mintJoinToken(ctx, p, name, signal);
871
1007
  if (typeof token !== "string")
872
1008
  return token;
873
- want = (await desiredEnv(p, token));
1009
+ want = (await desiredEnv(p, ctx, token));
874
1010
  if (!writeEnv(want))
875
1011
  return { state: "failed", reason: "runner_directory_unavailable", evidence: selected };
876
1012
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@catalyst-cloud/cli",
3
- "version": "0.16.3",
3
+ "version": "0.16.6",
4
4
  "description": "Set up Catalyst Cloud, check your tickets and manage your account from the command line.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -53,16 +53,16 @@
53
53
  "prepublishOnly": "node scripts/release-train-check.mjs --publish cli"
54
54
  },
55
55
  "dependencies": {
56
- "@catalyst-cloud/sdk": "0.16.1",
56
+ "@catalyst-cloud/sdk": "0.16.3",
57
57
  "@clack/prompts": "1.8.1",
58
58
  "fast-string-width": "3.0.2",
59
59
  "fast-wrap-ansi": "0.2.2",
60
60
  "smol-toml": "^1.7.1",
61
61
  "yaml": "^2.9.0",
62
- "@catalyst-cloud/sdk-replica-node": "0.16.1"
62
+ "@catalyst-cloud/sdk-replica-node": "0.16.3"
63
63
  },
64
64
  "devDependencies": {
65
- "@catalyst-cloud/schema": "0.16.0",
65
+ "@catalyst-cloud/schema": "0.16.2",
66
66
  "@types/node": "^26.3.0",
67
67
  "@vitest/coverage-v8": "^4.1.11",
68
68
  "typescript": "^7.0.2",
@@ -4,7 +4,7 @@ description: >-
4
4
  Catalyst's GitHub: show a ticket's pull request with its checks, reviews and review threads, say whether it is mergeable under this repository's policy, and explain what a PR accumulates as the ticket moves (the branch, the draft, the rewrite, the force-pushes, the labels, the queue). Use when someone asks "show me the PR", "what are the checks saying", "why hasn't it merged", "what does the queue need", "what does that label mean", or wants the branch and merge conventions Catalyst follows.
5
5
  allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
6
6
  ---
7
- <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.3 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.6 — written in this repository for customer accounts -->
8
8
 
9
9
  # Catalyst's GitHub
10
10
 
@@ -4,7 +4,7 @@ description: >-
4
4
  Catalyst's view of Linear on the customer's own cloud account. Reads a ticket with its comments, relations, labels, linked pull requests and agent sessions inline, from the cloud API by default, with local replica reads available as an explicit opt-in, always naming the source; searches tickets, PRs, projects and initiatives; writes comments, card moves, labels and new tickets through the account's agent proxy as the app actor, with every route, stage id, label id and marker read from the account's contract. Knows what a ticket accumulates as Catalyst works it (phase-outcome comments, the document per phase, the agent session, the labels, the single blocks relation, the bookkeeping marker, the eyes acknowledgement). Use when a person says "show me the ticket", "what did Catalyst write on it", "comment on it", "move it", "label it" or "file a ticket". Not for raising a decision for a human (what-needs-me) and not for pull requests (catalyst-github).
5
5
  allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
6
6
  ---
7
- <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.3 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.6 — written in this repository for customer accounts -->
8
8
 
9
9
  # Catalyst Linear
10
10
 
@@ -4,7 +4,7 @@ description: >-
4
4
  Set up Catalyst Cloud and say whether setup is working. Walks a person from nothing to their first ticket running, one step at a time: the coding account, the project, the integrations and connected accounts, each repository's settings file, then one real ticket moving. Also logs this machine in, reads the readiness verdict with who can fix each failure, and checks the optional local replica. Use when someone says "set me up", "onboard me", "I just signed up", "get me started", "what do I do first", "log me in", "which account is this machine on", "am I set up", "what is missing", "why does nothing happen" or "is the replica running", when a login expired, or when a skill script exits 2 saying this machine is not connected. Does every step a key can do through the catalyst CLI, hands over the exact page for the steps only a browser can do, and never claims a step it did not watch succeed.
5
5
  allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
6
6
  ---
7
- <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.3 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.6 — written in this repository for customer accounts -->
8
8
 
9
9
  # Onboard me
10
10
 
@@ -55,6 +55,7 @@ Scripts are run, never read; each prints `--help`.
55
55
  | logging in, a refused or expired login, which account this is, the Linear identity | `references/connecting-this-machine.md` |
56
56
  | anything reports not ready, a check id, or who fixes something | `references/reading-ready.md` |
57
57
  | the coding account or the `host` part, or before saying work can run | `references/what-a-phase-needs.md`; a credential to replace, `references/replacing-a-credential.md` |
58
+ | preserving an existing paused Darwin runner during owner-managed replacement | `references/preserving-runner-replacement.md` |
58
59
  | which steps a command does and which need a browser, or confirming a page that said it worked | `references/what-the-browser-owns.md` |
59
60
  | the repository's `.catalyst/catalyst.toml` and its approval; its AGENTS.md block and agent layout | `references/declaring-a-repository.md`; `references/repository-agent-setup.md` |
60
61
  | the replica or event cache | `references/local-sync.md` |
@@ -0,0 +1,26 @@
1
+ # Preserving a paused Darwin runner during replacement
2
+
3
+ An installation owner can replace a known paused supervisor through the existing `catalyst onboard --runner` path while retaining the installation directory and named volumes. This is an owner-managed recovery for the standard Darwin state layout. The CLI does not automatically upgrade an existing container whose image differs from its desired image.
4
+
5
+ Before changing the container, the installation owner must independently receive its full container ID, selected local daemon, paused state, Compose project/service labels, working directory and exact configuration-file list. Receive the owned Compose and private `.env` files without printing their contents. Match the retained host identity and team to the existing enrollment. Verify the named `catalyst-host_host-credential` and `catalyst-host_supervisor-state` volumes and their actual mounts. Keep the original files privately for operator recovery.
6
+
7
+ The working directory must be the actual operator's `~/.local/state/catalyst/runner`. Keep the same OS operator, home, Docker selector, directory, Compose project, host name, team and volumes. Any saved machine-path mapping or state-directory environment selector must still resolve to that same standard directory. Do not relocate state or replace the login. Custom state layouts and an existing native producer configured for another supervisor pin require a separate repair; the producer refuses a changed pin instead of rekeying or adopting it.
8
+
9
+ The new supervisor, watchdog and runner images must first be qualified and cached on that same daemon. Supply all three exact digest pins explicitly, including the runner pin: ordinary setup preserves a saved runner image. A runner must carry the Darwin thoughts custody capability required by the native installer. Qualification and cached bytes are prerequisites, not consequences of removing the old container.
10
+
11
+ Once those prerequisites are received, the installation owner removes only the independently verified paused supervisor by its full container ID. Keep the directory, `.env`, Compose files, native thoughts and locks, credential volume and supervisor-state volume. Do not run Compose down, remove volumes, change ownership or broaden permissions.
12
+
13
+ Resume the existing onboarding context with the same team and repository inputs and an explicit `--runner` in this invocation:
14
+
15
+ ```sh
16
+ CATALYST_SUPERVISOR_IMAGE="$QUALIFIED_SUPERVISOR_IMAGE" \
17
+ CATALYST_WATCHDOG_IMAGE="$QUALIFIED_WATCHDOG_IMAGE" \
18
+ CATALYST_RUNNER_IMAGE="$QUALIFIED_RUNNER_IMAGE" \
19
+ catalyst onboard --runner --only runner
20
+ ```
21
+
22
+ The CLI's actual installation port now observes no supervisor container. It selects the same standard state directory and keeps the saved host name, join token and tuning. Cached target receiving and a successful fresh native custody exchange precede the credential and admission steps and supervisor activation. The retained enrolled credential identifies the existing host; this recovery does not require a new enrollment or org key. Native thoughts and lock ownership and modes remain unchanged.
23
+
24
+ A cache miss or native custody refusal leaves the retained credentials and enrollment intact and does not activate the supervisor. Setup may already have refreshed Compose and `.env` with the selected target configuration. Keep the operator's original-file receipt until the replacement is accepted. A refusal must be repaired by its owner; do not substitute an old image, create a new producer key or erase the retained state.
25
+
26
+ Accept the recovery only after the installation owner receives the exact new supervisor image, original credential and volume identities, loaded native producer, fresh custody exchange, preserved native modes, and a real successful work attempt with publication. Source tests alone do not prove a native installation.
@@ -4,7 +4,7 @@ description: >-
4
4
  Own one Catalyst Cloud project end to end until it closes. Use when the person says "run this project for me", "own this until it ships", "keep this moving", or hands you a project id or a set of tickets to drive. Subscribes to the account's event stream for the scope through the catalyst CLI, reacts to each change in the same turn, makes tickets ready and moves them to dispatch, parks what should stop, chases stalls, escalates inward, and keeps one status summary current. Writes to Linear as the app actor; never polls.
5
5
  allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
6
6
  ---
7
- <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.3 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.6 — written in this repository for customer accounts -->
8
8
 
9
9
  # Run this project
10
10
 
@@ -4,7 +4,7 @@ description: >-
4
4
  Get a stuck Catalyst Cloud ticket moving again. Use when the person asks "why is this parked and can you release it?", "unpark this", "get things flowing again", "the outage is over, retry what failed", or hands you a ticket that is not moving. Reads why nothing runs and what holds the ticket through the catalyst CLI, decides whether the recorded cause is fixed, previews the release, releases every governor holding the ticket the right way (or one failure class across a team), and raises an ask only for what a person has to do. Never releases a cause it cannot show changed without saying so.
5
5
  allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
6
6
  ---
7
- <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.3 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.6 — written in this repository for customer accounts -->
8
8
 
9
9
  # Unstick
10
10
 
@@ -4,7 +4,7 @@ description: >-
4
4
  The human's decision inbox on Catalyst Cloud, and the one way an agent raises a decision on their behalf. Use when the person asks "what needs me?", "what am I blocking?", or when active work is gated on a choice only they can make. Lists open asks ranked by how much open work each one holds, files an ask through the cloud's ask route with the account's own template, and records the answer so the held work releases. Never answers as the human, never duplicates an open ask.
5
5
  allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
6
6
  ---
7
- <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.3 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.6 — written in this repository for customer accounts -->
8
8
 
9
9
  # What needs me
10
10
 
@@ -4,7 +4,7 @@ description: >-
4
4
  What environment variable names does this repository need, and where does each one come from? Scans the repository offline (no login, no network) and lists the names in three groups (build/test, deploy-only, bindings), each with where it was found, what uses it, and where a local value would come from. Never reads a value or prints one. Also checks the environment variable table in `.catalyst/catalyst.toml` offline. Use when someone asks "what does catalyst.env.json mean", "what env vars does this repo need", "why does the container need this", or before reviewing or writing the declaration.
5
5
  allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
6
6
  ---
7
- <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.3 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.6 — written in this repository for customer accounts -->
8
8
 
9
9
  # What this repository needs
10
10
 
@@ -4,7 +4,7 @@ description: >-
4
4
  Use for "what's happening?", "what machines do we have?", "how much capacity do we have?", "where are we?", "why is that stuck?", "what closed?", "what's next?", "how does this work?", "why did it do that?", "how does it prioritise?" and "what does this setting do, where is it set?" in Catalyst Cloud, or asks for something to be done rather than known. Reads the contract via catalyst CLI. Read-only: route work/decisions, never answer as the human.
5
5
  allowed-tools: Bash(catalyst:*) Bash(npx -p @catalyst-cloud/cli catalyst:*)
6
6
  ---
7
- <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.3 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.6 — written in this repository for customer accounts -->
8
8
 
9
9
  # What's happening
10
10
 
@@ -0,0 +1,18 @@
1
+ # Installed Darwin custody channels. Include with compose.yaml only after native producer setup.
2
+ # The signing key and producer configuration remain on the native host, outside every mount.
3
+ services:
4
+ supervisor:
5
+ environment:
6
+ CATALYST_THOUGHTS_CUSTODY_AUTHORITY: ${CATALYST_THOUGHTS_CUSTODY_AUTHORITY:?set installed Darwin authority}
7
+ volumes:
8
+ - type: bind
9
+ source: ${CATALYST_THOUGHTS_CUSTODY_REQUESTS_DIR:?set installed Darwin requests root}
10
+ target: ${CATALYST_THOUGHTS_CUSTODY_REQUESTS_DIR:?set installed Darwin requests root}
11
+ bind:
12
+ create_host_path: false
13
+ - type: bind
14
+ source: ${CATALYST_THOUGHTS_CUSTODY_RESPONSES_DIR:?set installed Darwin responses root}
15
+ target: ${CATALYST_THOUGHTS_CUSTODY_RESPONSES_DIR:?set installed Darwin responses root}
16
+ read_only: true
17
+ bind:
18
+ create_host_path: false