spur-board 0.105.1 → 0.105.3
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/dist/cli.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import { t as apiBaseUrl } from "./chunk-Bzb7aI8R.mjs";
|
|
|
3
3
|
import { a as requestTokenEnrollment, c as renderCliError, i as requestSkillReload, l as escapeTerminalControls, n as fetchTokenStatus, o as CliError, r as requestOperation, s as errorExitCode } from "./chunk-D-1P5oeK.mjs";
|
|
4
4
|
import { a as memoryVerdictCache, c as loadClientConfig, d as resolveDaemonAddress, f as tokenInFolder, i as fileVerdictCache, l as loadEnrollmentConfig, n as cliPackageVersion, o as configFile, s as dataDirectory, t as checkCatalog, u as readConfiguredPort } from "./chunk-gi-XmApc.mjs";
|
|
5
5
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
6
|
-
import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
7
|
-
import { homedir, hostname, userInfo } from "node:os";
|
|
6
|
+
import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, ftruncateSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
7
|
+
import { homedir, hostname, tmpdir, userInfo } from "node:os";
|
|
8
8
|
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
9
9
|
import { Command, CommanderError } from "@commander-js/extra-typings";
|
|
10
10
|
import { z } from "zod";
|
|
@@ -681,7 +681,9 @@ function renderUserUnit(paths) {
|
|
|
681
681
|
""
|
|
682
682
|
].join("\n");
|
|
683
683
|
}
|
|
684
|
-
/**
|
|
684
|
+
/** How long a child killed for its timeout may take to exit before it gets SIGKILL. */
|
|
685
|
+
const KILL_GRACE_MS = 1e3;
|
|
686
|
+
/** Runs a command to completion, or until `options.timeoutMs` runs out. */
|
|
685
687
|
async function runCommand(command, args, options = {}) {
|
|
686
688
|
return new Promise((resolveResult, reject) => {
|
|
687
689
|
const child = spawn(command, [...args], {
|
|
@@ -701,12 +703,28 @@ async function runCommand(command, args, options = {}) {
|
|
|
701
703
|
child.stderr?.setEncoding("utf8").on("data", (chunk) => {
|
|
702
704
|
stderr += chunk;
|
|
703
705
|
});
|
|
704
|
-
|
|
706
|
+
let timedOut = false;
|
|
707
|
+
let grace;
|
|
708
|
+
const timer = options.timeoutMs === void 0 ? void 0 : setTimeout(() => {
|
|
709
|
+
timedOut = true;
|
|
710
|
+
child.kill("SIGTERM");
|
|
711
|
+
grace = setTimeout(() => {
|
|
712
|
+
child.kill("SIGKILL");
|
|
713
|
+
}, KILL_GRACE_MS);
|
|
714
|
+
}, options.timeoutMs);
|
|
715
|
+
child.on("error", (error) => {
|
|
716
|
+
clearTimeout(timer);
|
|
717
|
+
clearTimeout(grace);
|
|
718
|
+
reject(error);
|
|
719
|
+
});
|
|
705
720
|
child.on("close", (code) => {
|
|
721
|
+
clearTimeout(timer);
|
|
722
|
+
clearTimeout(grace);
|
|
706
723
|
resolveResult({
|
|
707
724
|
exitCode: code ?? 1,
|
|
708
725
|
stdout,
|
|
709
|
-
stderr
|
|
726
|
+
stderr,
|
|
727
|
+
...timedOut ? { timedOut: true } : {}
|
|
710
728
|
});
|
|
711
729
|
});
|
|
712
730
|
});
|
|
@@ -1171,6 +1189,65 @@ async function installSkills(options = {}) {
|
|
|
1171
1189
|
await Promise.all(skills.map((skill) => requireSource(join(packageRoot, "skills", skill.source))));
|
|
1172
1190
|
return withInstallLock(home, env, () => installIntoHome(home, packageRoot, version, options, env));
|
|
1173
1191
|
}
|
|
1192
|
+
/** Waits between tarball 404s; the last one repeats. No retry starts past the bound. */
|
|
1193
|
+
const TARBALL_DELAYS_MS = [
|
|
1194
|
+
5e3,
|
|
1195
|
+
1e4,
|
|
1196
|
+
2e4,
|
|
1197
|
+
3e4
|
|
1198
|
+
];
|
|
1199
|
+
/**
|
|
1200
|
+
* Downloads `spec` with `npm pack` into a temp dir it removes, retrying a 404 while the next wait
|
|
1201
|
+
* still ends inside the bound. Each attempt gets the remaining budget as its timeout, so the whole
|
|
1202
|
+
* check ends within `waitMs`.
|
|
1203
|
+
*/
|
|
1204
|
+
async function waitForTarball(spec, deps) {
|
|
1205
|
+
const boundMs = deps.waitMs ?? 6e5;
|
|
1206
|
+
const delays = deps.delaysMs ?? TARBALL_DELAYS_MS;
|
|
1207
|
+
const dir = mkdtempSync(join(tmpdir(), "board-update-pack-"));
|
|
1208
|
+
try {
|
|
1209
|
+
const started = deps.now();
|
|
1210
|
+
const deadline = started + boundMs;
|
|
1211
|
+
for (let attempt = 0;; attempt += 1) {
|
|
1212
|
+
const result = await deps.runner("npm", [
|
|
1213
|
+
"pack",
|
|
1214
|
+
spec,
|
|
1215
|
+
"--pack-destination",
|
|
1216
|
+
dir
|
|
1217
|
+
], {
|
|
1218
|
+
env: deps.env,
|
|
1219
|
+
timeoutMs: deadline - deps.now()
|
|
1220
|
+
});
|
|
1221
|
+
const now = deps.now();
|
|
1222
|
+
const failure = (reason, ranPastBound) => ({
|
|
1223
|
+
ok: false,
|
|
1224
|
+
reason,
|
|
1225
|
+
ranPastBound,
|
|
1226
|
+
result,
|
|
1227
|
+
waitedMs: now - started,
|
|
1228
|
+
boundMs
|
|
1229
|
+
});
|
|
1230
|
+
if (result.timedOut === true || now > deadline) return failure("not-served", true);
|
|
1231
|
+
if (result.exitCode === 0) return { ok: true };
|
|
1232
|
+
if (!/\bE404\b/.test(result.stderr)) return failure("failed", false);
|
|
1233
|
+
const wait = delays[Math.min(attempt, delays.length - 1)] ?? 0;
|
|
1234
|
+
if (now + wait >= deadline) return failure("not-served", false);
|
|
1235
|
+
deps.onWait?.({
|
|
1236
|
+
waitMs: wait,
|
|
1237
|
+
waitedMs: now - started,
|
|
1238
|
+
boundMs
|
|
1239
|
+
});
|
|
1240
|
+
await deps.sleep(wait);
|
|
1241
|
+
}
|
|
1242
|
+
} finally {
|
|
1243
|
+
try {
|
|
1244
|
+
rmSync(dir, {
|
|
1245
|
+
recursive: true,
|
|
1246
|
+
force: true
|
|
1247
|
+
});
|
|
1248
|
+
} catch {}
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1174
1251
|
// src/update.ts
|
|
1175
1252
|
const stateSchema = z.object({
|
|
1176
1253
|
schema: z.literal(1),
|
|
@@ -1802,6 +1879,28 @@ function changedField(stdout) {
|
|
|
1802
1879
|
function blockingIds(report) {
|
|
1803
1880
|
return new Set(report.filter((check) => check.blocking).map((check) => check.id));
|
|
1804
1881
|
}
|
|
1882
|
+
/**
|
|
1883
|
+
* Downloads `target` with `npm pack` before anything changes, so a registry that lists a version
|
|
1884
|
+
* but does not serve its tarball yet stops the update while the service still runs
|
|
1885
|
+
* (`waitForTarball`); any other failure, an integrity mismatch included, refuses at once.
|
|
1886
|
+
*/
|
|
1887
|
+
async function confirmTarball(updater, target, npmEnv) {
|
|
1888
|
+
const { ports } = updater;
|
|
1889
|
+
updater.progress("tarball check");
|
|
1890
|
+
const outcome = await waitForTarball(target, {
|
|
1891
|
+
runner: ports.runner,
|
|
1892
|
+
sleep: ports.sleep,
|
|
1893
|
+
now: ports.now,
|
|
1894
|
+
env: npmEnv,
|
|
1895
|
+
onWait: ({ waitMs, waitedMs, boundMs }) => {
|
|
1896
|
+
updater.progress(`tarball wait: ${target} is listed but its tarball is not served yet (E404); retrying in ${String(waitMs / 1e3)} s, waited ${String(Math.floor(waitedMs / 1e3))} s of ${String(boundMs / 1e3)} s`);
|
|
1897
|
+
}
|
|
1898
|
+
});
|
|
1899
|
+
if (outcome.ok) return;
|
|
1900
|
+
const detail = childDetail(outcome.result);
|
|
1901
|
+
if (outcome.reason === "failed") throw config(`${target} cannot be downloaded: ${detail}. Nothing was changed and the service was not stopped.`);
|
|
1902
|
+
throw config(`The registry lists ${target} but did not serve its tarball within ${String(outcome.boundMs / 1e3)} s: ${outcome.ranPastBound ? `npm pack ran past the bound (${detail})` : detail}. Nothing was changed and the service was not stopped; run \`board update\` again later.`);
|
|
1903
|
+
}
|
|
1805
1904
|
/** `board update [version]`: preflight, snapshot, stop, backup, install, then health checks. */
|
|
1806
1905
|
async function updatePackage(options, requested) {
|
|
1807
1906
|
const updater = new Updater(options, "update");
|
|
@@ -1873,6 +1972,7 @@ async function update(updater, options, requested) {
|
|
|
1873
1972
|
...npmArgs
|
|
1874
1973
|
], { env: npmEnv });
|
|
1875
1974
|
if (dryRun.exitCode !== 0) throw config(`${target} cannot be installed with this Node: ${childDetail(dryRun)}`);
|
|
1975
|
+
await confirmTarball(updater, target, npmEnv);
|
|
1876
1976
|
updater.progress("doctor");
|
|
1877
1977
|
let baseline;
|
|
1878
1978
|
try {
|
package/package.json
CHANGED
|
@@ -7,11 +7,11 @@ Use this when the installed package is older than the intended release. `board u
|
|
|
7
7
|
2. Run every `board` command below with the Node and PATH of a live Spur session. The update refuses when this shell's Node, package path or `BOARD_HOME` and `XDG_*` settings differ from the service unit, or when the running daemon uses another data directory or config file, drop-ins and environment files included; its hint quotes both sides. If the service was installed from another environment, ask before running `board service install` from this one.
|
|
8
8
|
3. The update needs a running daemon. If the service is stopped, ask before starting it with `board service restart`.
|
|
9
9
|
4. Tell the operator the installed version and the target, then ask before updating. The service is down for the update.
|
|
10
|
-
5. Run `board update` for the latest release, or `board update <version>` for a named one. Progress lines go to stderr; the JSON result goes to stdout. A result with `changed` as `false` means the version was already installed; stop there.
|
|
10
|
+
5. Run `board update` for the latest release, or `board update <version>` for a named one. Progress lines go to stderr; the JSON result goes to stdout. A result with `changed` as `false` means the version was already installed; stop there. Before it stops the service, the update downloads the target with `npm pack`; while the registry lists the version but answers 404 for its tarball, as just after a release, it waits up to 10 minutes and prints a `tarball wait` line before each retry.
|
|
11
11
|
6. On success, report `from`, `to`, `database.schemaChanged` and each `operator` line. Agent sessions that run `board mcp` must restart to load the new catalog; the skill reinstall already messaged live Spur sessions to read the `spur-board` skill again. Ask the operator to stop and wake the sessions the `sessions.stale` line lists under stop and wake, which keeps their conversations; for sessions it names as still queued, rerun `board doctor --json` in a minute. After a rollback to a version installed before, sessions told about it earlier get no new message and stay listed. Do not restart the service or reinstall the skills again: the update did both.
|
|
12
12
|
7. On exit 4 with `update_rolled_back`, the previous version is running again unless the hint reports a failed restart. Report the hint: it names the failed step and says whether the database was kept, restored, or not changed. At `first poll`, a source did not finish its first complete poll within five minutes. Fix the cause with the operator, then run `board update` again.
|
|
13
13
|
8. On exit 4 with `rollback_failed`, follow `Failed update or rollback` in TROUBLESHOOTING.md: fix the step the hint names, then run `board rollback --yes` again.
|
|
14
|
-
9. On any other exit 4 (`config`) or exit 2 (`usage`), nothing was changed. Report the hint and fix what it names; an older target is refused and points to `board rollback`. When another update or rollback holds the update lock, the hint gives the PID that took it: wait for it and the install it started to finish, and never remove the lock file.
|
|
14
|
+
9. On any other exit 4 (`config`) or exit 2 (`usage`), nothing was changed. Report the hint and fix what it names; an older target is refused and points to `board rollback`. A target whose tarball the registry did not serve within 10 minutes, or whose tarball fails its integrity check, is refused with the service still running; run `board update` again later. When another update or rollback holds the update lock, the hint gives the PID that took it: wait for it and the install it started to finish, and never remove the lock file.
|
|
15
15
|
10. To go back to the version before the last update, first run `board rollback` without `--yes`. Outside a terminal it changes nothing, prints what it would do and the `Lost:` text to stderr, and exits 2. Tell the operator that text: either nothing, or the Board changes and journal events recorded after the update started. Run `board rollback --yes` only after the operator agrees.
|
|
16
16
|
11. Never rewrite settled config or secrets, reissue an operator token, uninstall the service, or revoke a token as part of an update.
|
|
17
17
|
|
|
@@ -11,7 +11,8 @@ shadow mode, use keyed `board submit <task> <sha>`.
|
|
|
11
11
|
Unseen heads answer `pending`: that submit is final; do not resubmit or raise a
|
|
12
12
|
block. Confirm timeout: `projects[].dispatcher.submitConfirmMs`.
|
|
13
13
|
|
|
14
|
-
A new head closes taken turns outside Dev; taken Dev turns
|
|
14
|
+
A new head closes taken turns outside Dev and Done; taken Dev turns and Done
|
|
15
|
+
wrap-up turns survive pushes, and a wrap-up turn closes when its holder ends.
|
|
15
16
|
Right of Dev, red CI, a draft, a conflict, an external comment or an unresolved
|
|
16
17
|
thread where required returns the task to Dev at once, unless a turn is taken; then after its submit or return.
|
|
17
18
|
The Dev turn hands the comments, beside a return's `code` block.
|