@catalyst-cloud/cli 0.16.31 → 0.16.32

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.16.32
4
+
5
+ The 15-minute release check now moves a self-hosted machine to a newer runner release at set times of day, 03:00, 11:00, 16:00 and 22:00 in the machine's time zone, instead of whenever a release is approved. `catalyst update policy windows 06:00,18:00 --time-zone America/Chicago` sets your own times, `catalyst update policy windows default` goes back to these, and `catalyst update policy` lists them. `catalyst runner update` and `catalyst update` still apply a release at once. A machine that an earlier CLI moved onto the current release now records what it needs to take the next release in place, so it no longer waits for one more release first.
6
+
3
7
  ## 0.16.31
4
8
 
5
9
  New: `catalyst update` is one release check for everything Catalyst installed on this machine. `catalyst update --check` lists each component (the runner images, the CLI, the Cloud and Dev skills, the Claude plugin form of the Cloud skills, the local replica and each registered project's SDK) with its installed and approved versions, and `catalyst update` moves them to the approved release. `catalyst update policy <component> on|off` holds or releases one component. `catalyst runner update --check` and `catalyst runner auto-update on|off` still work and now cover the same components. The CLI updates itself without breaking the command that is running. If that update fails, the report says so, keeps you on the version you have, and tries again at the next release check. Copied skills never move back to an older version. A running local replica comes back on the new CLI with its synced data. When it cannot, `catalyst replica status` says why and where the data is kept. The Claude plugin moves only to the approved version, and after a move the report tells you to run `/reload-plugins` or restart Claude Code. `catalyst update --json` has a new field, `approvedSkills`, naming the version, repository and full commit each skills pack was approved at. It is `null` when no approval applies.
package/README.md CHANGED
@@ -305,7 +305,7 @@ The skill files themselves are written by whichever install command you ran, in
305
305
 
306
306
  ## Updating
307
307
 
308
- `catalyst update --check` lists each installed component beside the version your workspace approved, says which one is behind and why, and changes nothing. Add `--project <absolute path>` to include a project's SDK; the report gives the one command that moves it, `catalyst update sdk --project <path>`. A project's files change only when you run that command, or after you turn its SDK updates on with `catalyst update policy sdk on --project <path>`. `catalyst update` moves the runner images, the CLI, the Cloud skills (copied on this machine or installed as the Claude plugin), and a running local replica to the approved versions. The new CLI is installed beside the old one, and your `catalyst` command runs it from then on, at the same path. A running replica restarts on it and keeps its synced data; a stopped one stays stopped. The Claude plugin moves through Claude Code, and only when its marketplace serves the approved version; run `/reload-plugins` or restart Claude Code afterwards. When the release check cannot find the `claude` command, it changes nothing and prints the one command that moves the plugin. The development skills are not on the approved release yet: the report lists their version as unknown and gives no command for them, so update them the way you installed them. On a machine whose runner checks for releases every 15 minutes (`catalyst runner auto-update on`), that check moves the same components by itself. Otherwise they move when you run `catalyst update`. Each component is on by default; turn one off with `catalyst update policy <component> off` (for example `cli`), and `catalyst update policy` lists every setting. If you turned the installer's daily update off, the CLI and both skills packs start held, and `catalyst update policy cli on` turns the CLI back on. Add `--json` for a machine-readable report.
308
+ `catalyst update --check` lists each installed component beside the version your workspace approved, says which one is behind and why, and changes nothing. Add `--project <absolute path>` to include a project's SDK; the report gives the one command that moves it, `catalyst update sdk --project <path>`. A project's files change only when you run that command, or after you turn its SDK updates on with `catalyst update policy sdk on --project <path>`. `catalyst update` moves the runner images, the CLI, the Cloud skills (copied on this machine or installed as the Claude plugin), and a running local replica to the approved versions. The new CLI is installed beside the old one, and your `catalyst` command runs it from then on, at the same path. A running replica restarts on it and keeps its synced data; a stopped one stays stopped. The Claude plugin moves through Claude Code, and only when its marketplace serves the approved version; run `/reload-plugins` or restart Claude Code afterwards. When the release check cannot find the `claude` command, it changes nothing and prints the one command that moves the plugin. The development skills are not on the approved release yet: the report lists their version as unknown and gives no command for them, so update them the way you installed them. On a machine whose runner checks for releases every 15 minutes (`catalyst runner auto-update on`), that check moves the same components by itself. Otherwise they move when you run `catalyst update`. That check moves the runner images to a newer release only at set times of day, 03:00, 11:00, 16:00 and 22:00 in the machine's time zone, so a busy machine is not restarted every time a release is approved. `catalyst update policy windows 06:00,18:00 --time-zone America/Chicago` sets your own times, `catalyst update policy windows default` goes back to these, and `catalyst runner update` or `catalyst update` applies a waiting release at once. Each component is on by default; turn one off with `catalyst update policy <component> off` (for example `cli`), and `catalyst update policy` lists every setting. If you turned the installer's daily update off, the CLI and both skills packs start held, and `catalyst update policy cli on` turns the CLI back on. Add `--json` for a machine-readable report.
309
309
 
310
310
  A CLI older than `catalyst update` cannot move itself: install it once with `npm install -g @catalyst-cloud/cli@latest && catalyst login`. The re-login rewrites the CLI path the skills spawn, so they stop running the old bundle. To run one command against the latest publish without installing, use `npx -p @catalyst-cloud/cli@latest catalyst login`. The next `catalyst` run prints a one-line notice:
311
311
 
package/dist/args.js CHANGED
@@ -33,6 +33,7 @@ export const FLAG_TABLES = {
33
33
  check: { value: false, help: "read the approved release and list every component against it, without changing anything" },
34
34
  project: { value: true, help: "also check this project's SDK (an absolute path); with policy sdk, the project the setting is for" },
35
35
  dir: { value: true, help: "the runner directory (default: the one setup created)" },
36
+ "time-zone": { value: true, help: "policy windows: the time zone the window times are in (default: this machine's)" },
36
37
  },
37
38
  login: {
38
39
  "start-replica": {
@@ -580,7 +581,7 @@ export const FLAG_TABLES = {
580
581
  export const VERB_USAGE = {
581
582
  hosts: "hosts [list] | hosts remove <name-or-id> [--yes] | hosts rename <name-or-id> <new-name> [--json]",
582
583
  runner: "runner [status] | runner stop | runner start | runner uninstall [--yes] [--delete-checkouts] | runner update [--check] [--dir <runner directory>] [--fleet] | runner auto-update [status|on|off] [--json]",
583
- update: "update [--check] [--project <absolute path>] [--dir <runner directory>] | update sdk --project <absolute path> | update policy [<component> on|off] | update policy sdk on|off --project <absolute path> [--json] (components: runner, supervisor, watchdog, cli, skills-cloud, skills-dev, replica)",
584
+ update: "update [--check] [--project <absolute path>] [--dir <runner directory>] | update sdk --project <absolute path> | update policy [<component> on|off] | update policy sdk on|off --project <absolute path> | update policy windows <HH:MM,...>|default [--time-zone <zone>] [--json] (components: runner, supervisor, watchdog, cli, skills-cloud, skills-dev, replica)",
584
585
  setup: "setup [onboard options] (sets up Catalyst step by step; same as catalyst onboard) | setup --engine <file> --engine-sha256 <hex> [-- <install options>] (run by install.sh; install.sh --help lists the options)",
585
586
  login: "login [--base-url <url>] [--start-replica] (keyless; or --key <personal-key> / CATALYST_CLOUD_TOKEN)",
586
587
  onboard: "onboard [--team <ID|key>] [--repo <owner/name>]... [--coding-account <slot>] [--resume-from <step>] [--only <step>] [--local-sync] [--remove-local-data] [--runner|--no-runner] [--no-color] [--yes] [--dry-run] [--json] | onboard --headless [--key-file <path>] [--team ...] [--repo ...]... [--coding-account ...] [--runner yes|no] [--remove-local-data] [--json]",
@@ -10,7 +10,7 @@ export const CAPABILITIES = [
10
10
  { verb: "runner update|auto-update", does: "move this machine's self-hosted runner to the release Catalyst approved, and check for one every 15 minutes", needs: "member", routes: [], since: "0.16.16" },
11
11
  { verb: "update", does: "list every installed component against the release Catalyst approved, move the runner images to it, and name the command for the rest", needs: "member", routes: [], since: "0.16.31" },
12
12
  { verb: "update sdk", does: "move one project's Catalyst SDK to the approved versions with its own package manager, when the person asks", needs: "member", routes: [], since: "0.16.31" },
13
- { verb: "update policy", does: "turn automatic updates off or on for one installed component, or set a project's SDK to notify only", needs: "member", routes: [], since: "0.16.31" },
13
+ { verb: "update policy", does: "turn automatic updates off or on for one installed component, set a project's SDK to notify only, or set the times of day runner releases apply", needs: "member", routes: [], since: "0.16.31" },
14
14
  { verb: "runner status|stop|start", does: "stop this machine's self-hosted runner taking work, or start it again with the same registration", needs: "member", routes: [], since: "0.16.27" },
15
15
  { verb: "runner uninstall", does: "remove this machine's self-hosted runner and revoke its registration and runner key", needs: "admin", routes: [], since: "0.16.27" },
16
16
  // CTC-4680: plain `catalyst setup` runs the onboard flow, so install.sh may hand off to it. install.sh
package/dist/cli.js CHANGED
@@ -92,7 +92,7 @@ export function usageText() {
92
92
  " catalyst hosts [list] | hosts remove <name-or-id> [--yes] | hosts rename <name-or-id> <new-name>",
93
93
  " catalyst runner [status] | runner stop | runner start | runner uninstall [--yes] [--delete-checkouts] (this machine's self-hosted runner)",
94
94
  " catalyst runner update [--check] | runner auto-update [status|on|off] (move this machine's runner to the approved release)",
95
- " catalyst update [--check] [--project <path>] | update policy [<component> on|off] (every installed component against the approved release)",
95
+ " catalyst update [--check] [--project <path>] | update policy [<component> on|off] | update policy windows <HH:MM,...>|default (every installed component against the approved release)",
96
96
  " catalyst mcp add|list|remove (vault references only) | mcp status <name> (a server's state, grants and last 50 tool calls)",
97
97
  " catalyst contract [--refresh] [--path <a.b.c>]",
98
98
  " catalyst query <issues|issue <id>|pulls|pull <id>|projects|cycles|search <terms>|changes --since <cursor|head>>",
@@ -7,6 +7,7 @@ import { dockerFleetUpdateEngine, runFleetUpdate } from "./runner-update-fleet.j
7
7
  import { runUpdate, sharedReleaseRead, updateReportJson, updateReportLines } from "./update.js";
8
8
  import { effectivePolicy, readUpdatePolicy, setComponentPolicy } from "./update-policy.js";
9
9
  import { resolveClaude } from "./update-plugin.js";
10
+ import { defaultWindows, windowBounds } from "./update-windows.js";
10
11
  import { cmdRunnerLifecycle, RUNNER_LIFECYCLE_ACTIONS } from "./runner.js";
11
12
  const USAGE = "catalyst runner [status] | stop | start | uninstall [--yes] [--delete-checkouts] | runner update [--check] [--dir <runner directory>] [--fleet] | runner auto-update [status|on|off]";
12
13
  const UPDATE_FLAGS = ["check", "auto", "dir", "fleet"];
@@ -110,6 +111,8 @@ export async function cmdRunner(args, ctx, deps = {}) {
110
111
  };
111
112
  // An owner's image hold stops this command's image work too, including the schedule's (CTC-6708).
112
113
  const hold = check ? null : imageHold(ctx);
114
+ // The schedule's run takes a newer release only in an update window; an owner's run applies at
115
+ // once (CTC-6709, update-windows.ts).
113
116
  if (hold !== null) {
114
117
  const retained = { outcome: "retained", detail: hold, generation: readReleaseState(dir()).generation, exitCode: hold === "owner_setting" ? 0 : 1 };
115
118
  // Unreadable settings move nothing; a hold leaves the other components to the release check.
@@ -117,7 +120,7 @@ export async function cmdRunner(args, ctx, deps = {}) {
117
120
  }
118
121
  const result = fleet
119
122
  ? await runFleetUpdate(deps.fleetEngine ?? dockerFleetUpdateEngine({ env: ctx.env }), { dir: dir(), check })
120
- : await runRunnerUpdate(engine, { dir: dir(), check });
123
+ : await runRunnerUpdate(engine, { dir: dir(), check, ...(auto && !check ? { window: windowBounds(ctx.now().getTime(), readUpdatePolicy(ctx.home).windows ?? defaultWindows()) } : {}) });
121
124
  // `runner update --check` also lists every installed component against the approved release, as
122
125
  // `catalyst update --check` does. The image fields stay where scripts already read them.
123
126
  if (check && !fleet && !auto) {
@@ -119,7 +119,7 @@ export function decideRelease(appliedGeneration, read) {
119
119
  return { action: "update", release };
120
120
  }
121
121
  export function readReleaseState(dir) {
122
- const empty = { version: 1, generation: null, releaseId: null, appliedAtMs: null, previous: null, journal: null, pendingRemoval: [], last: null };
122
+ const empty = { version: 1, generation: null, releaseId: null, appliedAtMs: null, previous: null, journal: null, pendingRemoval: [], windowSettledMs: null, last: null };
123
123
  try {
124
124
  const parsed = JSON.parse(readFileSync(join(dir, RELEASE_STATE_FILE), "utf8"));
125
125
  if (!isRecord(parsed) || parsed.version !== 1)
@@ -136,6 +136,7 @@ export function readReleaseState(dir) {
136
136
  pendingRemoval: Array.isArray(parsed.pendingRemoval)
137
137
  ? parsed.pendingRemoval.filter((ref) => typeof ref === "string").slice(0, PENDING_REMOVAL_KEPT)
138
138
  : [],
139
+ windowSettledMs: posInt(parsed.windowSettledMs) ? parsed.windowSettledMs : null,
139
140
  last: isRecord(parsed.last) ? parsed.last : null,
140
141
  };
141
142
  }
@@ -172,6 +173,9 @@ export function rewriteEnvText(text, values) {
172
173
  }
173
174
  return lines.join("\n");
174
175
  }
176
+ /** Outcomes that settle a window: nothing was pending, or the machine restarted onto (or tried) a
177
+ * release. A busy deferral or a passing refusal leaves the window open for the next check. */
178
+ const SETTLES_WINDOW = new Set(["current", "recorded", "updated", "rolled_back", "failed"]);
175
179
  /** One serialized update run. A second concurrent run returns `retained` with `update_running`. */
176
180
  export async function runRunnerUpdate(engine, options) {
177
181
  const { dir } = options;
@@ -188,7 +192,8 @@ export async function runRunnerUpdate(engine, options) {
188
192
  const result = await update(engine, options, now);
189
193
  if (!options.check) {
190
194
  const state = readReleaseState(dir);
191
- writeReleaseState(dir, { ...state, last: { atMs: now(), outcome: result.outcome, detail: result.detail, generation: result.generation } });
195
+ const windowSettledMs = options.window && SETTLES_WINDOW.has(result.outcome) ? options.window.lastOpenedMs : state.windowSettledMs;
196
+ writeReleaseState(dir, { ...state, windowSettledMs, last: { atMs: now(), outcome: result.outcome, detail: result.detail, generation: result.generation } });
192
197
  }
193
198
  return result;
194
199
  }
@@ -232,6 +237,13 @@ async function update(engine, options, now) {
232
237
  ? done("current", "not_newer")
233
238
  : done("retained", decision.reason, { exitCode: decision.reason === "credential_refused" || decision.reason === "no_credential" ? 1 : 0 });
234
239
  const { release } = decision;
240
+ const tagged = { releaseId: release.releaseId };
241
+ // A newer release on the schedule waits for a window no run has settled. A machine that has
242
+ // settled none yet (its first run on this CLI) takes it now, and drift on the applied generation
243
+ // is put right at once, as before.
244
+ const { window } = options;
245
+ if (window && !options.check && decision.action === "update" && state.windowSettledMs !== null && window.lastOpenedMs <= state.windowSettledMs)
246
+ return done("waiting_window", `next_window:${new Date(window.nextOpensMs).toISOString()}`, tagged);
235
247
  const target = Object.fromEntries(RELEASE_COMPONENTS.map((c) => [c, release.images[c].reference]));
236
248
  const envText = readFileSync(envPath, "utf8");
237
249
  const env = readEnvFile(envPath) ?? {};
@@ -241,10 +253,15 @@ async function update(engine, options, now) {
241
253
  // (no log read). A match is current; any drift is moved back below like any other update.
242
254
  if (decision.action === "verify" && changed.length === 0) {
243
255
  const live = await engine.services(dir, signal);
244
- if (live?.supervisor?.running && live.supervisor.image === target.supervisor && live.watchdog?.image === target.watchdog)
256
+ if (live?.supervisor?.running && live.supervisor.image === target.supervisor && live.watchdog?.image === target.watchdog) {
257
+ // A CLI before 0.16.31 applied this release without recording its journal format. Its
258
+ // supervisor is the one running, so record the format now: the next release can then go in
259
+ // place instead of waiting for one more applied generation.
260
+ if (!options.check && state.journal === null && release.journalFormat !== null)
261
+ writeReleaseState(dir, { ...state, journal: { format: release.journalFormat, supervisor: target.supervisor } });
245
262
  return done("current", "not_newer");
263
+ }
246
264
  }
247
- const tagged = { releaseId: release.releaseId };
248
265
  const record = (outcome, detail, previous, unremoved = []) => {
249
266
  const journal = release.journalFormat === null ? null : { format: release.journalFormat, supervisor: target.supervisor };
250
267
  const pendingRemoval = [...new Set([...state.pendingRemoval, ...unremoved])].slice(-PENDING_REMOVAL_KEPT);
@@ -550,6 +567,7 @@ const OUTCOME_TEXT = {
550
567
  updated: "The runner moved to the approved release.",
551
568
  planned: "Checked the approved release; nothing was changed.",
552
569
  deferred_busy: "A phase is running here, so the update waits for the next check.",
570
+ waiting_window: "An approved release waits for this machine's next update window.",
553
571
  retained: "Kept the current images.",
554
572
  rolled_back: "The new supervisor did not become ready, so the previous images were restored.",
555
573
  failed: "The update could not finish. Look at the runner with docker compose ps.",
@@ -10,8 +10,9 @@ import { UsageError } from "./errors.js";
10
10
  import { dockerRunnerUpdateEngine, runnerDir } from "./runner-update.js";
11
11
  import { policyLines, readEffectivePolicy, runUpdate, updateReportJson, updateReportLines } from "./update.js";
12
12
  import { applySdkUpdate } from "./update-sdk.js";
13
- import { canonicalProject, effectivePolicy, isUpdateComponent, readUpdatePolicy, setComponentPolicy, setProjectSdkPolicy, UPDATE_COMPONENTS, } from "./update-policy.js";
14
- const USAGE = "catalyst update [--check] [--project <absolute path>] [--dir <runner directory>] [--json] | update sdk --project <absolute path> | update policy [<component> on|off] | update policy sdk on|off --project <absolute path>";
13
+ import { DEFAULT_WINDOW_TIMES, isTimeZone, normalizeWindowTimes } from "./update-windows.js";
14
+ import { canonicalProject, effectivePolicy, isUpdateComponent, readUpdatePolicy, setComponentPolicy, setProjectSdkPolicy, setWindowPolicy, UPDATE_COMPONENTS, } from "./update-policy.js";
15
+ const USAGE = "catalyst update [--check] [--project <absolute path>] [--dir <runner directory>] [--json] | update sdk --project <absolute path> | update policy [<component> on|off] | update policy sdk on|off --project <absolute path> | update policy windows <HH:MM,...>|default [--time-zone <zone>]";
15
16
  /** How each component reads in a sentence. */
16
17
  const SENTENCE_NAMES = {
17
18
  runner: "runner",
@@ -40,12 +41,17 @@ function cmdPolicy(parts, args, ctx) {
40
41
  ctx.stdout(JSON.stringify({
41
42
  components: UPDATE_COMPONENTS.map((id) => ({ id, ...effectivePolicy(policy, id) })),
42
43
  projects: policy.projects.map((p) => ({ path: p.path, sdk: p.sdk, source: p.source })),
44
+ windows: { times: policy.windows?.times ?? [...DEFAULT_WINDOW_TIMES], timeZone: policy.windows?.timeZone ?? null, source: policy.windows ? "owner" : "default" },
43
45
  }));
44
46
  else
45
47
  for (const line of policyLines(policy))
46
48
  ctx.stdout(line);
47
49
  return 0;
48
50
  }
51
+ if (parts[1] === "windows")
52
+ return cmdWindows(parts, args, ctx);
53
+ if (args.flags["time-zone"] !== undefined)
54
+ throw new UsageError("--time-zone goes with update policy windows");
49
55
  const [, name, value] = parts;
50
56
  if (parts.length !== 3 || (value !== "on" && value !== "off") || name === undefined)
51
57
  throw new UsageError(USAGE);
@@ -74,6 +80,35 @@ function cmdPolicy(parts, args, ctx) {
74
80
  ctx.stdout(`Automatic ${SENTENCE_NAMES[name]} updates are ${value}. Other components keep their settings.`);
75
81
  return 0;
76
82
  }
83
+ /** `update policy windows 03:00,11:00|default [--time-zone <zone>]`: when the schedule may take a
84
+ * newer runner release. `default` goes back to the four default times in the machine's zone. */
85
+ function cmdWindows(parts, args, ctx) {
86
+ const value = parts[2];
87
+ if (parts.length !== 3 || value === undefined)
88
+ throw new UsageError(USAGE);
89
+ const zone = flagString(args, "time-zone");
90
+ if (value === "default") {
91
+ if (zone !== undefined)
92
+ throw new UsageError("update policy windows default uses this machine's time zone; leave out --time-zone");
93
+ setWindowPolicy(ctx.home, null);
94
+ }
95
+ else {
96
+ const times = normalizeWindowTimes(value.split(","));
97
+ if (times === null)
98
+ throw new UsageError("update windows are 24-hour times separated by commas, for example 03:00,11:00,16:00,22:00");
99
+ if (zone !== undefined && !isTimeZone(zone))
100
+ throw new UsageError(`unknown time zone: ${zone}. Use a name such as America/Chicago`);
101
+ setWindowPolicy(ctx.home, { times, timeZone: zone ?? null });
102
+ }
103
+ const saved = readUpdatePolicy(ctx.home).windows;
104
+ const times = saved?.times ?? [...DEFAULT_WINDOW_TIMES];
105
+ const timeZone = saved?.timeZone ?? null;
106
+ if (args.json)
107
+ ctx.stdout(JSON.stringify({ windows: { times, timeZone, source: saved ? "owner" : "default" } }));
108
+ else
109
+ ctx.stdout(`Runner releases now apply at ${times.join(", ")} (${timeZone ?? "this machine's time zone"}). catalyst runner update still applies one at once.`);
110
+ return 0;
111
+ }
77
112
  async function cmdSdk(parts, args, ctx, deps) {
78
113
  if (parts.length !== 1)
79
114
  throw new UsageError(USAGE);
@@ -15,6 +15,7 @@ import { isAbsolute, join } from "node:path";
15
15
  import { configDirFor } from "./config.js";
16
16
  import { CliError, UsageError } from "./errors.js";
17
17
  import { isRecord, writePrivateAtomic } from "./runner-update.js";
18
+ import { isTimeZone, normalizeWindowTimes } from "./update-windows.js";
18
19
  export const UPDATE_POLICY_FILE = "updates.json";
19
20
  const LOCK_STALE_MS = 30_000;
20
21
  const LOCK_WAIT_MS = 5_000;
@@ -77,6 +78,15 @@ function parsePolicy(input) {
77
78
  policy.projects.push({ path: value.path, sdk: value.sdk, source: value.source, dev: value.dev, ino: value.ino });
78
79
  }
79
80
  }
81
+ if (input.windows !== undefined) {
82
+ if (!isRecord(input.windows) || !Array.isArray(input.windows.times))
83
+ return null;
84
+ const times = input.windows.times.every((t) => typeof t === "string") ? normalizeWindowTimes(input.windows.times) : null;
85
+ const zone = input.windows.timeZone;
86
+ if (times === null || !(zone === null || (typeof zone === "string" && isTimeZone(zone))))
87
+ return null;
88
+ policy.windows = { times, timeZone: zone };
89
+ }
80
90
  return policy;
81
91
  }
82
92
  /** The components an installer's daily update kept current: the CLI and both skills packs. */
@@ -192,3 +202,12 @@ export function setProjectSdkPolicy(home, path, sdk) {
192
202
  });
193
203
  return saved ?? { ...project, sdk, source: "owner" };
194
204
  }
205
+ /** Save the owner's update windows, or go back to the defaults with null. */
206
+ export function setWindowPolicy(home, windows) {
207
+ return updateUpdatePolicy(home, (policy) => {
208
+ if (windows === null)
209
+ delete policy.windows;
210
+ else
211
+ policy.windows = windows;
212
+ });
213
+ }
@@ -0,0 +1,81 @@
1
+ // update-windows.ts — the set times of day a self-hosted machine takes a new release (CTC-6709).
2
+ // The 15-minute schedule checks often so an owner sees the approved release quickly, but a busy
3
+ // machine restarting its supervisor every time a release lands would interrupt its owner's day as
4
+ // often as releases ship. So the schedule applies a newer release only once a window has opened
5
+ // since the last window a run settled, and an owner's own `catalyst runner update` applies at once.
6
+ // Windows are wall-clock times in the machine's time zone, or the zone its owner saved.
7
+ /** Four windows a day, spread so a release approved at any time waits at most about eight hours. */
8
+ export const DEFAULT_WINDOW_TIMES = ["03:00", "11:00", "16:00", "22:00"];
9
+ const TIME = /^([01][0-9]|2[0-3]):([0-5][0-9])$/;
10
+ export function defaultWindows() {
11
+ return { times: [...DEFAULT_WINDOW_TIMES], timeZone: null };
12
+ }
13
+ export function isWindowTime(value) {
14
+ return TIME.test(value);
15
+ }
16
+ /** Whether this runtime knows the zone. `Intl` throws a RangeError for one it does not. */
17
+ export function isTimeZone(value) {
18
+ try {
19
+ new Intl.DateTimeFormat("en-US", { timeZone: value });
20
+ return value.length > 0;
21
+ }
22
+ catch {
23
+ return false;
24
+ }
25
+ }
26
+ export function machineTimeZone() {
27
+ return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
28
+ }
29
+ /** Sorted, distinct `HH:MM` times, or null when any entry is not one or there are none. */
30
+ export function normalizeWindowTimes(values) {
31
+ if (values.length === 0 || values.length > 24 || !values.every(isWindowTime))
32
+ return null;
33
+ return [...new Set(values)].sort();
34
+ }
35
+ /** The zone's wall clock at an instant, as the parts a window time is compared with. */
36
+ function wallClock(ms, timeZone) {
37
+ const parts = new Intl.DateTimeFormat("en-US", {
38
+ timeZone,
39
+ hourCycle: "h23",
40
+ year: "numeric",
41
+ month: "2-digit",
42
+ day: "2-digit",
43
+ hour: "2-digit",
44
+ minute: "2-digit",
45
+ }).formatToParts(new Date(ms));
46
+ const get = (type) => Number(parts.find((p) => p.type === type)?.value);
47
+ return { year: get("year"), month: get("month"), day: get("day"), hour: get("hour"), minute: get("minute") };
48
+ }
49
+ /** The zone's offset from UTC at an instant, in milliseconds, to the minute. */
50
+ function offsetMs(ms, timeZone) {
51
+ const w = wallClock(ms, timeZone);
52
+ return Date.UTC(w.year, w.month - 1, w.day, w.hour, w.minute) - Math.floor(ms / 60_000) * 60_000;
53
+ }
54
+ /** The instant a wall-clock time falls on in the zone. A time a clock change skips or repeats lands within an hour of it. */
55
+ function instantOf(year, month, day, hour, minute, timeZone) {
56
+ const asUtc = Date.UTC(year, month - 1, day, hour, minute);
57
+ const first = asUtc - offsetMs(asUtc, timeZone);
58
+ return asUtc - offsetMs(first, timeZone);
59
+ }
60
+ /** The window before and after `nowMs`. */
61
+ export function windowBounds(nowMs, windows) {
62
+ const timeZone = windows.timeZone ?? machineTimeZone();
63
+ const times = normalizeWindowTimes(windows.times) ?? [...DEFAULT_WINDOW_TIMES];
64
+ const today = wallClock(nowMs, timeZone);
65
+ const candidates = [];
66
+ // Two calendar days either side of today's date in the zone. Stepping by date, not by 24 hours,
67
+ // keeps a 23- or 25-hour day around a clock change from skipping a date or reading one twice.
68
+ for (let shift = -2; shift <= 2; shift++) {
69
+ const date = new Date(Date.UTC(today.year, today.month - 1, today.day + shift));
70
+ for (const time of times) {
71
+ const [hour, minute] = time.split(":").map(Number);
72
+ candidates.push(instantOf(date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate(), hour, minute, timeZone));
73
+ }
74
+ }
75
+ candidates.sort((a, b) => a - b);
76
+ const lastOpenedMs = candidates.filter((ms) => ms <= nowMs).pop();
77
+ const nextOpensMs = candidates.find((ms) => ms > nowMs);
78
+ if (lastOpenedMs === undefined || nextOpensMs === undefined)
79
+ throw new Error(`no update window around ${new Date(nowMs).toISOString()} in ${timeZone}`);
80
+ return { lastOpenedMs, nextOpensMs, timeZone };
81
+ }
package/dist/update.js CHANGED
@@ -27,6 +27,7 @@ import { applyCloudPluginUpdate, CLOUD_PLUGIN_COMMAND } from "./update-plugin.js
27
27
  import { onboardStatePath, readOnboardJournal } from "./onboard.js";
28
28
  import { effectivePolicy, projectIdentityHolds, readUpdatePolicy, UPDATE_COMPONENTS, withMigratedHolds, } from "./update-policy.js";
29
29
  import { applySdkUpdate, inspectSdkProject } from "./update-sdk.js";
30
+ import { DEFAULT_WINDOW_TIMES } from "./update-windows.js";
30
31
  import { decideRelease, isRecord, parseDesiredRelease, RELEASE_COMPONENTS, runRunnerUpdate, } from "./runner-update.js";
31
32
  export const COMPONENT_LABELS = {
32
33
  runner: "Runner",
@@ -248,7 +249,7 @@ function applyImageResult(rows, result) {
248
249
  row.installed = row.approved;
249
250
  row.installedReference = row.approvedReference ?? row.installedReference ?? null;
250
251
  }
251
- else if (result.outcome === "deferred_busy" || result.outcome === "retained") {
252
+ else if (result.outcome === "deferred_busy" || result.outcome === "waiting_window" || result.outcome === "retained") {
252
253
  if (row.status === "update_available") {
253
254
  row.status = "pending";
254
255
  row.reason = result.detail;
@@ -582,5 +583,7 @@ export function policyLines(policy) {
582
583
  lines.push("SDK projects: none registered");
583
584
  for (const project of policy.projects)
584
585
  lines.push(`${cell(`SDK ${project.path}`, 19)}${cell(project.sdk === "auto" ? "on" : "off", 5)}(${project.source}${project.sdk === "notify" ? ", notify only" : ""})`);
586
+ const windows = policy.windows;
587
+ lines.push(`Runner releases apply at ${(windows?.times ?? DEFAULT_WINDOW_TIMES).join(", ")} (${windows?.timeZone ?? "this machine's time zone"}; ${windows ? "owner" : "default"})`);
585
588
  return lines;
586
589
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@catalyst-cloud/cli",
3
- "version": "0.16.31",
3
+ "version": "0.16.32",
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",
@@ -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.31 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.32 — 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.31 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.32 — 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.31 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.32 — written in this repository for customer accounts -->
8
8
 
9
9
  # Onboard me
10
10
 
@@ -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.31 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.32 — 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.31 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.32 — 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.31 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.32 — 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.31 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.32 — 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.31 — written in this repository for customer accounts -->
7
+ <!-- vendored-from: @catalyst-cloud/catalyst-skills@0.16.32 — written in this repository for customer accounts -->
8
8
 
9
9
  # What's happening
10
10