@tablation/crew 0.130.7 → 0.131.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +210 -16
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -13508,6 +13508,14 @@ git -C "$m" rev-parse --verify --quiet "refs/heads/$base^{commit}" >/dev/null ||
|
|
|
13508
13508
|
git -C "$m" cat-file -e "refs/heads/$base:$path" 2>/dev/null || exit 4
|
|
13509
13509
|
git -C "$m" show "refs/heads/$base:$path"
|
|
13510
13510
|
`;
|
|
13511
|
+
var LIST_SCRIPT = `
|
|
13512
|
+
set -e
|
|
13513
|
+
export GIT_TERMINAL_PROMPT=0
|
|
13514
|
+
m=${VOLUME_ROOT}/"$1"; base="$2"
|
|
13515
|
+
git config --global --add safe.directory '*'
|
|
13516
|
+
git -C "$m" rev-parse --verify --quiet "refs/heads/$base^{commit}" >/dev/null || { echo "the mirror has no branch $base" >&2; exit 3; }
|
|
13517
|
+
git -C "$m" ls-tree -r --name-only "refs/heads/$base"
|
|
13518
|
+
`;
|
|
13511
13519
|
var SandboxCache = class {
|
|
13512
13520
|
s;
|
|
13513
13521
|
exec;
|
|
@@ -13618,6 +13626,11 @@ var SandboxCache = class {
|
|
|
13618
13626
|
throw e;
|
|
13619
13627
|
}
|
|
13620
13628
|
}
|
|
13629
|
+
/** Every file path at the tip of `base` in the mirror (CREW-3010). Throws when the mirror or branch is absent. */
|
|
13630
|
+
async listFiles(repo, base) {
|
|
13631
|
+
const { stdout } = await this.helper(this.s.helperImage, LIST_SCRIPT, [mirrorRelPath(repo), base]);
|
|
13632
|
+
return stdout.split("\n").filter(Boolean);
|
|
13633
|
+
}
|
|
13621
13634
|
/** Mirrors in the volume with their last refresh; empty when the volume does not exist. */
|
|
13622
13635
|
async list() {
|
|
13623
13636
|
try {
|
|
@@ -18241,6 +18254,91 @@ function flagWizardAnswers(f, env) {
|
|
|
18241
18254
|
};
|
|
18242
18255
|
}
|
|
18243
18256
|
|
|
18257
|
+
// src/diagnostics.ts
|
|
18258
|
+
import { execFile as execFile3 } from "child_process";
|
|
18259
|
+
var BUNDLE_BUDGET_MS = 3e4;
|
|
18260
|
+
var JOURNAL_LINES = 200;
|
|
18261
|
+
var MAX_SECTION_BYTES = 256 * 1024;
|
|
18262
|
+
var REDACTED = "[redacted]";
|
|
18263
|
+
var SENSITIVE_KEY_RE = /token|key|secret|password|authorization/i;
|
|
18264
|
+
var SK_RE = /\bsk_[A-Za-z0-9_-]{4,}/g;
|
|
18265
|
+
var BEARER_RE = /\b(bearer)\s+[A-Za-z0-9._~+/=-]{4,}/gi;
|
|
18266
|
+
var AUTH_HEADER_RE = /\b(authorization)(["']?\s*[:=]\s*["']?)[^\s"',}]+(?:\s+[^\s"',}]+)?/gi;
|
|
18267
|
+
var KV_RE = /\b([A-Za-z0-9_.-]*(?:token|key|secret|password)[A-Za-z0-9_.-]*)(["']?\s*[:=]\s*["']?)[^\s"',}&]+/gi;
|
|
18268
|
+
function redactText(s) {
|
|
18269
|
+
return s.replace(AUTH_HEADER_RE, (_m, k, sep2) => `${k}${sep2}${REDACTED}`).replace(BEARER_RE, (_m, b) => `${b} ${REDACTED}`).replace(SK_RE, REDACTED).replace(KV_RE, (m, k, sep2) => m.endsWith(REDACTED) ? m : `${k}${sep2}${REDACTED}`);
|
|
18270
|
+
}
|
|
18271
|
+
function redactValue(v) {
|
|
18272
|
+
if (typeof v === "string") return redactText(v);
|
|
18273
|
+
if (Array.isArray(v)) return v.map(redactValue);
|
|
18274
|
+
if (v && typeof v === "object") {
|
|
18275
|
+
return Object.fromEntries(Object.entries(v).map(([k, x]) => [
|
|
18276
|
+
k,
|
|
18277
|
+
SENSITIVE_KEY_RE.test(k) && x !== null && x !== void 0 && x !== "" ? REDACTED : redactValue(x)
|
|
18278
|
+
]));
|
|
18279
|
+
}
|
|
18280
|
+
return v;
|
|
18281
|
+
}
|
|
18282
|
+
var defaultExec = (bin, args, timeoutMs) => new Promise((resolve8, reject) => {
|
|
18283
|
+
execFile3(bin, args, { timeout: timeoutMs, maxBuffer: 4 * 1024 * 1024 }, (e, stdout) => {
|
|
18284
|
+
if (e && e.code === "ENOENT") return reject(new Error(`${bin} is not installed`));
|
|
18285
|
+
if (e && e.killed) return reject(new Error(`${bin} timed out`));
|
|
18286
|
+
resolve8({ stdout: String(stdout), code: typeof e?.code === "number" ? e.code : 0 });
|
|
18287
|
+
});
|
|
18288
|
+
});
|
|
18289
|
+
var clip = (s) => s.length > MAX_SECTION_BYTES ? `${s.slice(0, MAX_SECTION_BYTES)}
|
|
18290
|
+
[truncated]` : s;
|
|
18291
|
+
async function collectDiagnostics(d) {
|
|
18292
|
+
const exec = d.exec ?? defaultExec;
|
|
18293
|
+
const budget = d.budgetMs ?? BUNDLE_BUDGET_MS;
|
|
18294
|
+
const now = d.now ?? Date.now;
|
|
18295
|
+
const started = now();
|
|
18296
|
+
const left = () => Math.max(1, budget - (now() - started));
|
|
18297
|
+
const ctl = d.userScope ? ["systemctl", "--user"] : ["systemctl"];
|
|
18298
|
+
const jctl = d.userScope ? ["--user"] : [];
|
|
18299
|
+
const units = d.unitStems.flatMap((s) => [`${s}.service`, `${s}.timer`]);
|
|
18300
|
+
const sections = {
|
|
18301
|
+
doctor: async () => {
|
|
18302
|
+
const doc = await d.doctor();
|
|
18303
|
+
if (!doc) throw new Error("could not produce the doctor report");
|
|
18304
|
+
return doc;
|
|
18305
|
+
},
|
|
18306
|
+
units: async () => {
|
|
18307
|
+
if (!units.length) throw new Error("no systemd units on this host");
|
|
18308
|
+
const out = {};
|
|
18309
|
+
for (const u of units) {
|
|
18310
|
+
const r = await exec(ctl[0], [...ctl.slice(1), "show", u, "--no-pager", "--property=LoadState,ActiveState,SubState,Result,ExecMainStatus,ActiveEnterTimestamp"], left());
|
|
18311
|
+
out[u] = Object.fromEntries(r.stdout.split("\n").filter((l) => l.includes("=")).map((l) => [l.slice(0, l.indexOf("=")), l.slice(l.indexOf("=") + 1)]));
|
|
18312
|
+
}
|
|
18313
|
+
return out;
|
|
18314
|
+
},
|
|
18315
|
+
journal: async () => {
|
|
18316
|
+
if (!units.length) throw new Error("no systemd units on this host");
|
|
18317
|
+
const r = await exec("journalctl", [...jctl, ...units.flatMap((u) => ["-u", u]), "-n", String(JOURNAL_LINES), "--no-pager", "-o", "short-iso"], left());
|
|
18318
|
+
return { lines: clip(r.stdout).split("\n").filter((l) => l.length) };
|
|
18319
|
+
},
|
|
18320
|
+
tunnel: async () => Object.fromEntries(d.workspaceIds.map((w) => [w, readPersistedTunnel(d.stateDir, w) ?? null])),
|
|
18321
|
+
sandbox: async () => {
|
|
18322
|
+
if (d.runner !== "sandbox") return { runner: d.runner };
|
|
18323
|
+
const r = await exec("openshell", ["sandbox", "list"], left());
|
|
18324
|
+
return { runner: d.runner, list: clip(r.stdout).split("\n").filter((l) => l.length), exitCode: r.code };
|
|
18325
|
+
}
|
|
18326
|
+
};
|
|
18327
|
+
const deadline = new Promise((resolve8) => {
|
|
18328
|
+
setTimeout(() => resolve8("timeout"), budget).unref();
|
|
18329
|
+
});
|
|
18330
|
+
const entries = await Promise.all(Object.entries(sections).map(async ([name, run3]) => {
|
|
18331
|
+
try {
|
|
18332
|
+
const out = await Promise.race([run3(), deadline]);
|
|
18333
|
+
if (out === "timeout") return [name, { ok: false, error: `timed out after ${Math.round(budget / 1e3)}s` }];
|
|
18334
|
+
return [name, { ok: true, data: redactValue(out) }];
|
|
18335
|
+
} catch (e) {
|
|
18336
|
+
return [name, { ok: false, error: redactText(e.message) }];
|
|
18337
|
+
}
|
|
18338
|
+
}));
|
|
18339
|
+
return { collectedAt: new Date(started).toISOString(), budgetMs: budget, sections: Object.fromEntries(entries) };
|
|
18340
|
+
}
|
|
18341
|
+
|
|
18244
18342
|
// src/release-run.ts
|
|
18245
18343
|
import { readFileSync as readFileSync37, writeFileSync as writeFileSync31, existsSync as existsSync38, copyFileSync, mkdirSync as mkdirSync28, mkdtempSync as mkdtempSync3, rmSync as rmSync19 } from "fs";
|
|
18246
18344
|
import { dirname as dirname24, join as join43 } from "path";
|
|
@@ -20072,6 +20170,20 @@ async function readMirrorContract(cache, repo, base) {
|
|
|
20072
20170
|
}
|
|
20073
20171
|
return null;
|
|
20074
20172
|
}
|
|
20173
|
+
async function readMirrorWarmFiles(cache, repo, base, patterns) {
|
|
20174
|
+
if (patterns.length === 0) return {};
|
|
20175
|
+
const res = patterns.map(globToRegExp);
|
|
20176
|
+
const out = {};
|
|
20177
|
+
let total = 0;
|
|
20178
|
+
for (const path of (await cache.listFiles(repo, base)).filter((f) => res.some((re) => re.test(f))).sort()) {
|
|
20179
|
+
const content = await cache.showFile(repo, base, path);
|
|
20180
|
+
if (content === null) continue;
|
|
20181
|
+
total += content.length;
|
|
20182
|
+
if (total > WARM_MAX_BYTES) throw new Error(`sandbox.warm files exceed ${WARM_MAX_BYTES} bytes`);
|
|
20183
|
+
out[path] = content;
|
|
20184
|
+
}
|
|
20185
|
+
return out;
|
|
20186
|
+
}
|
|
20075
20187
|
function noCheckoutReleaseNote(repo, mode) {
|
|
20076
20188
|
if (mode === "external") {
|
|
20077
20189
|
return `${repo}: no checkout on this ship; release.mode "external" repositories are handed off by a ship with a checkout`;
|
|
@@ -20087,13 +20199,25 @@ function firstReport(key) {
|
|
|
20087
20199
|
reported.add(key);
|
|
20088
20200
|
return true;
|
|
20089
20201
|
}
|
|
20202
|
+
function judgeServable(o) {
|
|
20203
|
+
if (o.platforms.some(o.satisfied)) return true;
|
|
20204
|
+
return o.tolerateUnmirrored && o.unreadable.some((n) => o.unmirrored.has(n));
|
|
20205
|
+
}
|
|
20206
|
+
function explainRefusal(readable, unreadable) {
|
|
20207
|
+
const parts = [
|
|
20208
|
+
...readable.map((r) => `${r.name} requires ${r.platform}`),
|
|
20209
|
+
...unreadable.map((e) => `${e.repo}'s contract could not be read (${e.detail.split("\n")[0]})`)
|
|
20210
|
+
];
|
|
20211
|
+
if (readable.length === 0) parts.unshift("no repository contract could be read");
|
|
20212
|
+
return parts.join(", ");
|
|
20213
|
+
}
|
|
20090
20214
|
|
|
20091
20215
|
// src/release-sandbox.ts
|
|
20092
|
-
import { execFile as
|
|
20216
|
+
import { execFile as execFile4 } from "child_process";
|
|
20093
20217
|
import { mkdirSync as mkdirSync30, writeFileSync as writeFileSync32 } from "fs";
|
|
20094
20218
|
import { dirname as dirname26 } from "path";
|
|
20095
20219
|
import { promisify as promisify3 } from "util";
|
|
20096
|
-
var execFileP3 = promisify3(
|
|
20220
|
+
var execFileP3 = promisify3(execFile4);
|
|
20097
20221
|
var RELEASE_CLONE_DEPTH = 50;
|
|
20098
20222
|
var FORGE_TOKEN_VAR = "CREW_FORGE_TOKEN";
|
|
20099
20223
|
var FORGE_USER_VAR = "CREW_FORGE_USER";
|
|
@@ -24684,7 +24808,7 @@ import {
|
|
|
24684
24808
|
import { createConnection } from "net";
|
|
24685
24809
|
import { createServer as createServer2 } from "http";
|
|
24686
24810
|
import { basename as basename14, dirname as dirname33, join as join53 } from "path";
|
|
24687
|
-
import { execFile as
|
|
24811
|
+
import { execFile as execFile5, spawn as spawn12 } from "child_process";
|
|
24688
24812
|
|
|
24689
24813
|
// src/periscope-control.ts
|
|
24690
24814
|
import { spawn as spawn11 } from "child_process";
|
|
@@ -25225,7 +25349,8 @@ async function route(deps, method, url, req, abort) {
|
|
|
25225
25349
|
const doc = await deps.doctor();
|
|
25226
25350
|
return doc ? reply2(200, doc) : err2(502, "could not produce the doctor report");
|
|
25227
25351
|
}
|
|
25228
|
-
|
|
25352
|
+
if (p === "/diagnostics" && get2 && deps.diagnostics) return reply2(200, await deps.diagnostics());
|
|
25353
|
+
const known = ["/status", "/events", "/streams", "/pause", "/resume", "/release/pause", "/release/resume", "/doctor", ...deps.diagnostics ? ["/diagnostics"] : []];
|
|
25229
25354
|
if (known.includes(p) || p.startsWith("/streams/") || sched) return err2(405, "method not allowed");
|
|
25230
25355
|
return err2(404, "not found");
|
|
25231
25356
|
}
|
|
@@ -25336,7 +25461,7 @@ function schedulerHandler(control, run3 = runDetached) {
|
|
|
25336
25461
|
}
|
|
25337
25462
|
function crewJson(args, timeoutMs = 6e4) {
|
|
25338
25463
|
return new Promise((resolve8) => {
|
|
25339
|
-
|
|
25464
|
+
execFile5(process.execPath, [process.argv[1] ?? "", ...args], { timeout: timeoutMs, maxBuffer: 16 * 1024 * 1024 }, (_e, stdout) => {
|
|
25340
25465
|
try {
|
|
25341
25466
|
const v = JSON.parse(String(stdout));
|
|
25342
25467
|
resolve8(v && typeof v === "object" && !Array.isArray(v) ? v : null);
|
|
@@ -25943,7 +26068,7 @@ function usage(problem, requested = false) {
|
|
|
25943
26068
|
crew shell-init [--shell zsh|bash|fish] print the periscope shell function (install: eval "$(crew shell-init)")
|
|
25944
26069
|
crew worktree [route] NNN cut (or refresh) this run's worktree for a ticket from the remote; prints its path
|
|
25945
26070
|
crew unassign [route] NNN hand back a session's ticket \u2014 clears assignee, next cycle picks it up
|
|
25946
|
-
crew sandbox cache [--prune|--reset] [--json] list the sandbox cache volume's mirrors; --prune drops unserved repositories, --reset recreates the volume
|
|
26071
|
+
crew sandbox cache [--refresh|--prune|--reset] [--json] list the sandbox cache volume's mirrors; --refresh runs the daemon's cache pass once (creates missing mirrors), --prune drops unserved repositories, --reset recreates the volume
|
|
25947
26072
|
crew sync [route] fast-forward the checkout and its worktrees from the remote
|
|
25948
26073
|
crew pause|resume [route] [R|release] pause everything, one role, or releases only (merge/deploy/release; passengers keeps running).
|
|
25949
26074
|
resume with no argument clears only the whole-crew pause; a role or release pause needs its own resume
|
|
@@ -26825,6 +26950,9 @@ ${changed2.map((c) => ` - ${c}
|
|
|
26825
26950
|
`).join("")}` : "fix: nothing changed\n");
|
|
26826
26951
|
}
|
|
26827
26952
|
async function resolvedRepos(c) {
|
|
26953
|
+
return (await resolveRoute(c)).settled;
|
|
26954
|
+
}
|
|
26955
|
+
async function resolveRoute(c) {
|
|
26828
26956
|
const { settled, errors } = await settleRepos(reposOf(c), (t) => t.name, (t) => resolveOneRepo(c, t));
|
|
26829
26957
|
for (const e of errors) {
|
|
26830
26958
|
try {
|
|
@@ -26834,17 +26962,31 @@ ${changed2.map((c) => ` - ${c}
|
|
|
26834
26962
|
}
|
|
26835
26963
|
const refused = new Set(errors.map((e) => e.repo));
|
|
26836
26964
|
for (const t of reposOf(c)) if (!refused.has(t.name)) clearShipAttention(state, repoContractRefusedKey(t.name));
|
|
26837
|
-
return settled;
|
|
26965
|
+
return { settled, errors };
|
|
26838
26966
|
}
|
|
26839
26967
|
async function sandboxReposOf(routes) {
|
|
26840
26968
|
const out = /* @__PURE__ */ new Map();
|
|
26841
26969
|
for (const c of routes) {
|
|
26842
26970
|
const { settled } = await settleRepos(reposOf(c), (t) => t.name, (t) => resolveOneRepo(c, t));
|
|
26843
26971
|
for (const r of settled) if (r.config.sandbox && !out.has(r.name)) {
|
|
26972
|
+
const patterns = r.config.sandbox.warm ?? [];
|
|
26973
|
+
const base = r.config.branch.base;
|
|
26844
26974
|
let warm = {};
|
|
26975
|
+
const target = reposOf(c).find((t) => t.name === r.name);
|
|
26976
|
+
const noCheckout = lacksCheckout(cfg.ship, r.dir);
|
|
26977
|
+
const mirror = target && noCheckout ? mirrorRepoOfTarget(target) : null;
|
|
26978
|
+
const settings = cfg.ship.runner === "sandbox" ? cacheSettingsOf(cfg.ship.sandbox) : null;
|
|
26979
|
+
const source = mirror ? `the mirror of ${mirror.host}/${mirror.path} at ${base}` : `${r.dir} at ${r.config.branch.remote}/${base}`;
|
|
26980
|
+
let failure = "";
|
|
26845
26981
|
try {
|
|
26846
|
-
warm =
|
|
26847
|
-
|
|
26982
|
+
if (mirror && settings) warm = await readMirrorWarmFiles(new SandboxCache(settings), mirror, base, patterns);
|
|
26983
|
+
else if (!noCheckout) warm = readWarmFiles(r.dir, `${r.config.branch.remote}/${base}`, patterns);
|
|
26984
|
+
else failure = "no checkout and no mirror to read";
|
|
26985
|
+
} catch (e) {
|
|
26986
|
+
failure = e instanceof Error ? e.message.split("\n")[0] : String(e);
|
|
26987
|
+
}
|
|
26988
|
+
if (patterns.length > 0 && Object.keys(warm).length === 0 && firstReport(`warm-empty:${r.name}:${failure}`)) {
|
|
26989
|
+
emit.emit(`${r.name}: sandbox.warm declares ${patterns.join(", ")} but no file could be read from ${source}${failure ? ` (${failure})` : ""}; the image is built without warm files`);
|
|
26848
26990
|
}
|
|
26849
26991
|
out.set(r.name, { name: r.name, decl: intelFlavor(r.config.hooks.intel) === "serena" ? { ...r.config.sandbox, intel: "serena" } : r.config.sandbox, warm, ...wantsCodeBridge(r.config.hooks.intel) ? { bridge: readBridgeBundle() } : {} });
|
|
26850
26992
|
}
|
|
@@ -26890,11 +27032,35 @@ ${changed2.map((c) => ` - ${c}
|
|
|
26890
27032
|
parent: resolvePath(r.dir, ".."),
|
|
26891
27033
|
prefix: r.config.worktrees.prefix
|
|
26892
27034
|
}));
|
|
26893
|
-
async function anyRepoServable(c) {
|
|
26894
|
-
|
|
27035
|
+
async function anyRepoServable(c, tolerateUnmirrored = false) {
|
|
27036
|
+
const { settled, errors } = await resolveRoute(c);
|
|
27037
|
+
return judgeServable({
|
|
27038
|
+
platforms: settled.map((r) => r.config.platform),
|
|
27039
|
+
satisfied: (p) => satisfies(cfg.ship.platform, p),
|
|
27040
|
+
unreadable: errors.map((e) => e.repo),
|
|
27041
|
+
tolerateUnmirrored,
|
|
27042
|
+
unmirrored: tolerateUnmirrored && errors.length > 0 ? await unmirroredTargets(c) : /* @__PURE__ */ new Set()
|
|
27043
|
+
});
|
|
27044
|
+
}
|
|
27045
|
+
async function unmirroredTargets(c) {
|
|
27046
|
+
const settings = cfg.ship.runner === "sandbox" ? cacheSettingsOf(cfg.ship.sandbox) : null;
|
|
27047
|
+
if (!settings) return /* @__PURE__ */ new Set();
|
|
27048
|
+
try {
|
|
27049
|
+
const have = new Set((await new SandboxCache(settings).list()).map((m) => `${m.repo.host}/${m.repo.path}`));
|
|
27050
|
+
const out = /* @__PURE__ */ new Set();
|
|
27051
|
+
for (const t of reposOf(c)) {
|
|
27052
|
+
if (!lacksCheckout(cfg.ship, t.dir)) continue;
|
|
27053
|
+
const m = mirrorRepoOfTarget(t);
|
|
27054
|
+
if (m && !have.has(`${m.host}/${m.path}`)) out.add(t.name);
|
|
27055
|
+
}
|
|
27056
|
+
return out;
|
|
27057
|
+
} catch {
|
|
27058
|
+
return /* @__PURE__ */ new Set();
|
|
27059
|
+
}
|
|
26895
27060
|
}
|
|
26896
27061
|
async function explainUnservable(c) {
|
|
26897
|
-
|
|
27062
|
+
const { settled, errors } = await resolveRoute(c);
|
|
27063
|
+
return explainRefusal(settled.map((r) => ({ name: r.name, platform: String(r.config.platform) })), errors);
|
|
26898
27064
|
}
|
|
26899
27065
|
async function environmentFor(c, ticket) {
|
|
26900
27066
|
const tracker = new Tracker(c, cfg.ship);
|
|
@@ -28073,13 +28239,22 @@ ${cu.tail.trimEnd()}
|
|
|
28073
28239
|
process.stderr.write("crew: daemon does not support --dry-run \u2014 it only ever performs real cycles.\n");
|
|
28074
28240
|
process.exit(2);
|
|
28075
28241
|
}
|
|
28076
|
-
|
|
28242
|
+
requireArmed("run the daemon loop");
|
|
28243
|
+
const sandboxCachePass = cfg.ship.runner === "sandbox" ? buildSandboxCachePass(route2, cfg.ship, state, emit) : void 0;
|
|
28244
|
+
if (sandboxCachePass && (await unmirroredTargets(route2)).size > 0) {
|
|
28245
|
+
emit.emit("sandbox cache: some served repositories have no mirror yet; refreshing before reading their contracts");
|
|
28246
|
+
try {
|
|
28247
|
+
await sandboxCachePass();
|
|
28248
|
+
} catch (e) {
|
|
28249
|
+
emit.warn(`sandbox cache refresh failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
28250
|
+
}
|
|
28251
|
+
}
|
|
28252
|
+
if (!await anyRepoServable(route2, true)) {
|
|
28077
28253
|
emit.error(
|
|
28078
28254
|
`refusing this route \u2014 this ship is ${cfg.ship.platform}, but ${await explainUnservable(route2)}`
|
|
28079
28255
|
);
|
|
28080
28256
|
process.exit(1);
|
|
28081
28257
|
}
|
|
28082
|
-
requireArmed("run the daemon loop");
|
|
28083
28258
|
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join56(CREW_HOME, "src"), join56(CREW_HOME, "dist"), join56(CREW_HOME, "bin")];
|
|
28084
28259
|
const configPaths = daemonConfigPaths(cfg);
|
|
28085
28260
|
watchPaths.push(...configPaths);
|
|
@@ -28141,12 +28316,19 @@ ${cu.tail.trimEnd()}
|
|
|
28141
28316
|
periscopeMcp: controlRoutes.some((r) => r.enabled && r.hostPeriscopes) ? (req, res, ticket) => handlePeriscopeMcp(periscopeMcpDeps(), req, res, ticket) : void 0,
|
|
28142
28317
|
status: () => crewJson(["status", route2.route, "--json"]),
|
|
28143
28318
|
doctor: () => crewJson(["doctor", route2.route, "--json", "--offline"]),
|
|
28319
|
+
diagnostics: () => collectDiagnostics({
|
|
28320
|
+
stateDir: cfg.ship.stateDir,
|
|
28321
|
+
workspaceIds: [...new Set(controlRoutes.map((r) => r.resolved.workspaceId))],
|
|
28322
|
+
runner: cfg.ship.runner ?? "host",
|
|
28323
|
+
unitStems: detectSystemd() ? ["run", "release", "passengers"].map((j) => labelFor(CREW_HOME, j)) : [],
|
|
28324
|
+
userScope: process.getuid?.() !== 0,
|
|
28325
|
+
doctor: () => crewJson(["doctor", route2.route, "--json", "--offline"])
|
|
28326
|
+
}),
|
|
28144
28327
|
scheduler: schedulerHandler(planDaemonControl(CREW_HOME, hostPlatform(), detectSystemd())),
|
|
28145
28328
|
log: (m) => emit.warn(m)
|
|
28146
28329
|
});
|
|
28147
28330
|
if (controlServer) emit.emit(`control API listening on ${controlServer.path}`);
|
|
28148
28331
|
const inFlight = /* @__PURE__ */ new Set();
|
|
28149
|
-
const sandboxCachePass = cfg.ship.runner === "sandbox" ? buildSandboxCachePass(route2, cfg.ship, state, emit) : void 0;
|
|
28150
28332
|
let sandboxBuilding = false;
|
|
28151
28333
|
const stopReason = await runDaemonLoop({
|
|
28152
28334
|
inFlight,
|
|
@@ -29795,6 +29977,17 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
29795
29977
|
`);
|
|
29796
29978
|
break;
|
|
29797
29979
|
}
|
|
29980
|
+
let refreshFailed = false;
|
|
29981
|
+
if (flag("refresh")) {
|
|
29982
|
+
for (const r of cfg.routes) {
|
|
29983
|
+
const pass = buildSandboxCachePass(r, cfg.ship, state, emit);
|
|
29984
|
+
for (const out of await pass?.() ?? []) {
|
|
29985
|
+
if (!out.ok) refreshFailed = true;
|
|
29986
|
+
process.stdout.write(`${out.ok ? "refreshed" : "FAILED "} ${out.repo.host}/${out.repo.path}${out.ok ? "" : ` (${out.detail})`}
|
|
29987
|
+
`);
|
|
29988
|
+
}
|
|
29989
|
+
}
|
|
29990
|
+
}
|
|
29798
29991
|
const dropped = flag("prune") ? await cache.prune(served) : [];
|
|
29799
29992
|
const mirrors = await cache.list();
|
|
29800
29993
|
const open = openShipAttention(new State(cfg.ship.stateDir));
|
|
@@ -29817,6 +30010,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
29817
30010
|
for (const f of failures) process.stdout.write(`${f.repo} REFRESH FAILING (last failed ${f.lastFailedAt}): ${f.message}
|
|
29818
30011
|
`);
|
|
29819
30012
|
}
|
|
30013
|
+
if (refreshFailed) process.exitCode = 1;
|
|
29820
30014
|
} catch (e) {
|
|
29821
30015
|
process.stderr.write(`crew sandbox cache: ${e instanceof Error ? e.message : String(e)}
|
|
29822
30016
|
`);
|
|
@@ -29829,7 +30023,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
29829
30023
|
"crew sandbox policy --route ROUTE --role ROLE [--repo NAME] [--json]",
|
|
29830
30024
|
"crew sandbox build [REPO] [--route ROUTE] [--json]",
|
|
29831
30025
|
"crew sandbox images [--route ROUTE] [--json]",
|
|
29832
|
-
"crew sandbox cache [--prune|--reset] [--json]",
|
|
30026
|
+
"crew sandbox cache [--refresh|--prune|--reset] [--json]",
|
|
29833
30027
|
""
|
|
29834
30028
|
].join("\n"));
|
|
29835
30029
|
process.exit(2);
|
package/package.json
CHANGED