@tablation/crew 0.130.6 → 0.131.0
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 +842 -628
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6412,7 +6412,10 @@ function repoFindings(o) {
|
|
|
6412
6412
|
if (o.base.failed) {
|
|
6413
6413
|
problems.push({ severity: "blocker", kind: "base_unsafe", ...at, message: `${o.repo}: ${o.base.message}` });
|
|
6414
6414
|
} else if (o.base.message) passed++;
|
|
6415
|
-
for (const
|
|
6415
|
+
for (const g of o.sandboxGaps ?? []) {
|
|
6416
|
+
problems.push({ severity: "attention", kind: "hook_missing", ...at, hook: g.hook, command: g.command, message: g.message, remedy: g.remedy });
|
|
6417
|
+
}
|
|
6418
|
+
for (const hook2 of o.sandboxGaps ? [] : HOOK_NAMES2) {
|
|
6416
6419
|
const script = o.hooks[hook2];
|
|
6417
6420
|
const command2 = script ? hookCommand(script) : null;
|
|
6418
6421
|
if (!command2) continue;
|
|
@@ -6473,18 +6476,9 @@ function attentionProblems(items, already) {
|
|
|
6473
6476
|
return items.filter((i) => !seen.has(i.key)).map((i) => ({ severity: "attention", kind: i.kind, message: i.message }));
|
|
6474
6477
|
}
|
|
6475
6478
|
|
|
6476
|
-
// src/sandbox-image.ts
|
|
6477
|
-
import { createHash as createHash7 } from "crypto";
|
|
6478
|
-
import { spawn as spawn5 } from "child_process";
|
|
6479
|
-
import { execFileSync as execFileSync9 } from "child_process";
|
|
6480
|
-
import { existsSync as existsSync29, mkdirSync as mkdirSync19, readFileSync as readFileSync28, renameSync as renameSync3, writeFileSync as writeFileSync20, rmSync as rmSync15 } from "fs";
|
|
6481
|
-
import { dirname as dirname15, join as join32 } from "path";
|
|
6482
|
-
import { fileURLToPath } from "url";
|
|
6483
|
-
import { tmpdir as tmpdir3 } from "os";
|
|
6484
|
-
|
|
6485
6479
|
// src/passenger-containers.ts
|
|
6486
|
-
import { execFileSync as
|
|
6487
|
-
import { createHash as
|
|
6480
|
+
import { execFileSync as execFileSync9 } from "child_process";
|
|
6481
|
+
import { createHash as createHash7 } from "crypto";
|
|
6488
6482
|
|
|
6489
6483
|
// src/sandbox-cache.ts
|
|
6490
6484
|
import { execFile as execFile2 } from "child_process";
|
|
@@ -6492,19 +6486,19 @@ import { promisify as promisify2 } from "util";
|
|
|
6492
6486
|
|
|
6493
6487
|
// src/deprovision-host.ts
|
|
6494
6488
|
import { spawnSync as spawnSync7 } from "child_process";
|
|
6495
|
-
import { existsSync as
|
|
6489
|
+
import { existsSync as existsSync29, readdirSync as readdirSync11 } from "fs";
|
|
6496
6490
|
|
|
6497
6491
|
// src/interrupted.ts
|
|
6498
|
-
import { existsSync as
|
|
6499
|
-
import { join as
|
|
6492
|
+
import { existsSync as existsSync27, readdirSync as readdirSync9, readFileSync as readFileSync28 } from "fs";
|
|
6493
|
+
import { join as join31 } from "path";
|
|
6500
6494
|
|
|
6501
6495
|
// src/agent.ts
|
|
6502
6496
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
6503
|
-
import { readFileSync as
|
|
6497
|
+
import { readFileSync as readFileSync27, existsSync as existsSync26, statSync as statSync8, mkdirSync as mkdirSync19, writeFileSync as writeFileSync20, createWriteStream, openSync as openSync4, closeSync as closeSync4, readSync } from "fs";
|
|
6504
6498
|
import { StringDecoder } from "string_decoder";
|
|
6505
6499
|
import { finished } from "stream/promises";
|
|
6506
|
-
import { join as
|
|
6507
|
-
import { createHash as
|
|
6500
|
+
import { join as join30, dirname as dirname15, basename as basename9 } from "path";
|
|
6501
|
+
import { createHash as createHash6, randomUUID } from "crypto";
|
|
6508
6502
|
|
|
6509
6503
|
// src/state.ts
|
|
6510
6504
|
import { readFileSync as readFileSync19, writeFileSync as writeFileSync14, existsSync as existsSync18, mkdirSync as mkdirSync13, rmSync as rmSync10, statSync as statSync7, readdirSync as readdirSync5 } from "fs";
|
|
@@ -10825,159 +10819,491 @@ var HandoffTranscriptTracker = class {
|
|
|
10825
10819
|
}
|
|
10826
10820
|
};
|
|
10827
10821
|
|
|
10828
|
-
// src/
|
|
10829
|
-
|
|
10822
|
+
// src/sandbox-image.ts
|
|
10823
|
+
import { createHash as createHash4 } from "crypto";
|
|
10824
|
+
import { spawn as spawn3 } from "child_process";
|
|
10825
|
+
import { execFileSync as execFileSync7 } from "child_process";
|
|
10826
|
+
import { existsSync as existsSync23, mkdirSync as mkdirSync17, readFileSync as readFileSync24, renameSync as renameSync3, writeFileSync as writeFileSync18, rmSync as rmSync14 } from "fs";
|
|
10827
|
+
import { dirname as dirname13, join as join26 } from "path";
|
|
10828
|
+
import { fileURLToPath } from "url";
|
|
10829
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
10830
|
+
var SANDBOX_BASE_IMAGE = "nvcr.io/nvidia/base/ubuntu:24.04";
|
|
10831
|
+
var SANDBOX_OPENSHELL_VERSION = "0.1.6";
|
|
10832
|
+
var SANDBOX_CLAUDE_VERSION = "2.1.309";
|
|
10833
|
+
var SANDBOX_CLAUDE_DIST = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases";
|
|
10834
|
+
var SANDBOX_CLAUDE_SHA256 = {
|
|
10835
|
+
x86_64: { platform: "linux-x64", sha256: "4d704a8aecbe038affa3000f498ae17c1b4f753add8facb8764120affc99b658" },
|
|
10836
|
+
aarch64: { platform: "linux-arm64", sha256: "9796dd26899337f687739a0b39a7353b639f062a3436a7b941fcf19a1b757a9b" }
|
|
10830
10837
|
};
|
|
10831
|
-
var
|
|
10832
|
-
var
|
|
10833
|
-
var
|
|
10834
|
-
function
|
|
10835
|
-
const
|
|
10836
|
-
for (const
|
|
10837
|
-
|
|
10838
|
-
if (name && !names.includes(name)) names.push(name);
|
|
10838
|
+
var SANDBOX_UID = 1e3;
|
|
10839
|
+
var CREW_PREFIX = "/opt/crew";
|
|
10840
|
+
var SANDBOX_BRIDGE_PATH = `${CREW_PREFIX}/bin/intel-bridge`;
|
|
10841
|
+
function readBridgeBundle() {
|
|
10842
|
+
const here = dirname13(fileURLToPath(import.meta.url));
|
|
10843
|
+
for (const p of [join26(here, "sandbox-intel-bridge.cjs"), join26(here, "..", "dist", "sandbox-intel-bridge.cjs")]) {
|
|
10844
|
+
if (existsSync23(p)) return readFileSync24(p, "utf8");
|
|
10839
10845
|
}
|
|
10840
|
-
return
|
|
10841
|
-
}
|
|
10842
|
-
function expandSkillMarkers(text2, lookup2, opts = {}) {
|
|
10843
|
-
const maxDepth = opts.maxDepth ?? MAX_INCLUDE_DEPTH;
|
|
10844
|
-
const maxBytes = opts.maxBytes ?? MAX_INCLUDED_BYTES;
|
|
10845
|
-
const warnings = [];
|
|
10846
|
-
let included = 0;
|
|
10847
|
-
const expand2 = (source, chain) => source.replace(MARKER, (literal, rawName) => {
|
|
10848
|
-
const name = rawName.trim();
|
|
10849
|
-
if (!name) return literal;
|
|
10850
|
-
if (chain.includes(name)) {
|
|
10851
|
-
warnings.push(`skill include "${name}" left literal: it includes itself (${[...chain, name].join(" \u2192 ")})`);
|
|
10852
|
-
return literal;
|
|
10853
|
-
}
|
|
10854
|
-
if (chain.length >= maxDepth) {
|
|
10855
|
-
warnings.push(`skill include "${name}" left literal: nested deeper than ${maxDepth} levels`);
|
|
10856
|
-
return literal;
|
|
10857
|
-
}
|
|
10858
|
-
const body = lookup2(name);
|
|
10859
|
-
if (body === void 0) throw new SkillIncludeError(`no skill named "${name}" for the include ${literal}`);
|
|
10860
|
-
const trimmed = body.replace(/^\n+/, "").replace(/\n+$/, "");
|
|
10861
|
-
const bytes = Buffer.byteLength(trimmed, "utf8");
|
|
10862
|
-
if (included + bytes > maxBytes) {
|
|
10863
|
-
warnings.push(`skill include "${name}" left literal: it would exceed the ${maxBytes}-byte include budget`);
|
|
10864
|
-
return literal;
|
|
10865
|
-
}
|
|
10866
|
-
included += bytes;
|
|
10867
|
-
return expand2(trimmed, [...chain, name]);
|
|
10868
|
-
});
|
|
10869
|
-
return { text: expand2(text2, []), warnings };
|
|
10870
|
-
}
|
|
10871
|
-
|
|
10872
|
-
// src/skills.ts
|
|
10873
|
-
import { readFileSync as readFileSync25, readdirSync as readdirSync8, existsSync as existsSync24 } from "fs";
|
|
10874
|
-
import { join as join27 } from "path";
|
|
10875
|
-
import { parse as parseYaml } from "yaml";
|
|
10876
|
-
import { TablationClient as TablationClient3, StaleWriteError as StaleWriteError3, TablationApiError as TablationApiError2 } from "@tablation/client";
|
|
10877
|
-
|
|
10878
|
-
// src/prompt-additions.ts
|
|
10879
|
-
var PROMPT_ADDITIONS_SEPARATOR = "---\n\nAdditional instructions from this workspace. Where they conflict with anything above, these take precedence.";
|
|
10880
|
-
function appendAdditions(text2, additions) {
|
|
10881
|
-
if (typeof additions !== "string" || additions.trim() === "") return text2;
|
|
10882
|
-
return `${text2}
|
|
10883
|
-
|
|
10884
|
-
${PROMPT_ADDITIONS_SEPARATOR}
|
|
10885
|
-
|
|
10886
|
-
${additions}`;
|
|
10846
|
+
return void 0;
|
|
10887
10847
|
}
|
|
10888
|
-
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
|
|
10892
|
-
|
|
10893
|
-
var
|
|
10894
|
-
|
|
10895
|
-
|
|
10896
|
-
|
|
10897
|
-
|
|
10898
|
-
|
|
10899
|
-
}
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
var
|
|
10848
|
+
var SANDBOX_UV_VERSION = "0.13.6";
|
|
10849
|
+
var SANDBOX_SERENA_VERSION = "2.1.0";
|
|
10850
|
+
var SERENA_IMAGE_HOME = `${CREW_PREFIX}/serena`;
|
|
10851
|
+
var SERENA_LANGUAGE_SERVERS_ENV = "CREW_SERENA_LANGUAGE_SERVERS";
|
|
10852
|
+
var SANDBOX_RETRY_AFTER_MS = 60 * 60 * 1e3;
|
|
10853
|
+
var KEEP_TAGS = 2;
|
|
10854
|
+
var CREDENTIAL_HELPER = `#!/bin/sh
|
|
10855
|
+
# git credential helper: answers from the environment the runner passes in, so
|
|
10856
|
+
# no token is ever written into an image layer.
|
|
10857
|
+
[ "$1" = get ] || exit 0
|
|
10858
|
+
[ -n "$CREW_FORGE_TOKEN" ] || exit 0
|
|
10859
|
+
echo "username=\${CREW_FORGE_USER:-x-access-token}"
|
|
10860
|
+
echo "password=$CREW_FORGE_TOKEN"
|
|
10861
|
+
`;
|
|
10862
|
+
var MCP_CONFIG = `${JSON.stringify({ mcpServers: {} }, null, 2)}
|
|
10863
|
+
`;
|
|
10864
|
+
var hash = (parts) => createHash4("sha256").update(JSON.stringify(parts)).digest("hex").slice(0, 12);
|
|
10865
|
+
var slug = (s) => s.toLowerCase().replace(/[^a-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "") || "repo";
|
|
10866
|
+
var run2 = (cmd) => `RUN ["/bin/bash", "-c", ${JSON.stringify(`set -euo pipefail; ${cmd}`)}]`;
|
|
10867
|
+
var CREW_ENV = {
|
|
10868
|
+
CREW_SANDBOX: "1",
|
|
10869
|
+
CREW_CACHE_DIR: `${CREW_PREFIX}/cache`,
|
|
10870
|
+
XDG_CACHE_HOME: `${CREW_PREFIX}/cache`,
|
|
10871
|
+
npm_config_cache: `${CREW_PREFIX}/cache/npm`,
|
|
10872
|
+
npm_config_store_dir: `${CREW_PREFIX}/pnpm-store`,
|
|
10873
|
+
// pnpm 11 ignores npm_config_store_dir and reads only this spelling (CREW-2973): without it `pnpm fetch`
|
|
10874
|
+
// at build time fills the builder's home store, and a run's offline install finds /opt/crew/pnpm-store empty.
|
|
10875
|
+
pnpm_config_store_dir: `${CREW_PREFIX}/pnpm-store`,
|
|
10876
|
+
PNPM_HOME: `${CREW_PREFIX}/pnpm`,
|
|
10877
|
+
// A run cannot reach the download host, so an in-run update attempt is only noise.
|
|
10878
|
+
DISABLE_AUTOUPDATER: "1"
|
|
10903
10879
|
};
|
|
10904
|
-
function
|
|
10905
|
-
const
|
|
10906
|
-
|
|
10907
|
-
|
|
10908
|
-
|
|
10909
|
-
|
|
10910
|
-
return
|
|
10880
|
+
function sandboxEnvExports() {
|
|
10881
|
+
const vars = {
|
|
10882
|
+
...CREW_ENV,
|
|
10883
|
+
[SERENA_LANGUAGE_SERVERS_ENV]: `${SERENA_IMAGE_HOME}/language_servers`,
|
|
10884
|
+
UV_PYTHON_INSTALL_DIR: `${CREW_PREFIX}/uv/python`
|
|
10885
|
+
};
|
|
10886
|
+
return Object.entries(vars).map(([k, v]) => `${k}=${v}; export ${k}; `).join("");
|
|
10911
10887
|
}
|
|
10912
|
-
|
|
10913
|
-
const
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
|
|
10918
|
-
|
|
10919
|
-
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
try {
|
|
10923
|
-
const row = await client2.records.get(route2.resolved.models.crew, seatId);
|
|
10924
|
-
return row.agent_id ?? void 0;
|
|
10925
|
-
} catch {
|
|
10926
|
-
return void 0;
|
|
10927
|
-
}
|
|
10888
|
+
function claudeInstallCommand() {
|
|
10889
|
+
const cases = Object.entries(SANDBOX_CLAUDE_SHA256).map(([arch, { platform: platform2, sha256: sha2562 }]) => `${arch}) p=${platform2}; sum=${sha2562};;`).join(" ");
|
|
10890
|
+
return [
|
|
10891
|
+
`case "$(uname -m)" in ${cases} *) echo "no pinned Claude Code binary for $(uname -m)" >&2; exit 1;; esac`,
|
|
10892
|
+
`mkdir -p ${CREW_PREFIX}/bin`,
|
|
10893
|
+
`curl -fsSL --retry 3 -o ${CREW_PREFIX}/bin/claude "${SANDBOX_CLAUDE_DIST}/${SANDBOX_CLAUDE_VERSION}/$p/claude"`,
|
|
10894
|
+
`echo "$sum ${CREW_PREFIX}/bin/claude" | sha256sum -c -`,
|
|
10895
|
+
`chmod 0755 ${CREW_PREFIX}/bin/claude`,
|
|
10896
|
+
`${CREW_PREFIX}/bin/claude --version | grep -F "${SANDBOX_CLAUDE_VERSION}"`
|
|
10897
|
+
].join("; ");
|
|
10928
10898
|
}
|
|
10929
|
-
|
|
10930
|
-
|
|
10931
|
-
|
|
10932
|
-
|
|
10933
|
-
|
|
10934
|
-
|
|
10935
|
-
|
|
10936
|
-
|
|
10937
|
-
let row;
|
|
10938
|
-
let agentsModelId;
|
|
10939
|
-
try {
|
|
10940
|
-
const agentsModel = await client2.dataModels.get("agents", route2.resolved.workspaceId);
|
|
10941
|
-
agentsModelId = agentsModel.id;
|
|
10942
|
-
row = await client2.records.get(agentsModelId, agentId);
|
|
10943
|
-
} catch {
|
|
10944
|
-
return {};
|
|
10945
|
-
}
|
|
10946
|
-
const additions = typeof row.prompt_additions === "string" && row.prompt_additions.trim() !== "" ? row.prompt_additions : void 0;
|
|
10947
|
-
const divergedPrompt = await divergedRowPrompt(route2, role, row, agentId, agentsModelId, opts);
|
|
10948
|
-
return { divergedPrompt, additions };
|
|
10899
|
+
function serenaInstallCommand() {
|
|
10900
|
+
return [
|
|
10901
|
+
`python3 -m venv ${CREW_PREFIX}/uv-venv`,
|
|
10902
|
+
`${CREW_PREFIX}/uv-venv/bin/pip install --no-cache-dir uv==${SANDBOX_UV_VERSION}`,
|
|
10903
|
+
`ln -sf ${CREW_PREFIX}/uv-venv/bin/uv ${CREW_PREFIX}/bin/uv`,
|
|
10904
|
+
`UV_TOOL_DIR=${CREW_PREFIX}/uv/tools UV_TOOL_BIN_DIR=${CREW_PREFIX}/bin UV_PYTHON_INSTALL_DIR=${CREW_PREFIX}/uv/python UV_CACHE_DIR=${CREW_PREFIX}/cache/uv ${CREW_PREFIX}/bin/uv tool install -p 3.13 serena-agent==${SANDBOX_SERENA_VERSION}`,
|
|
10905
|
+
`${CREW_PREFIX}/bin/serena --help >/dev/null`
|
|
10906
|
+
].join("; ");
|
|
10949
10907
|
}
|
|
10950
|
-
function
|
|
10951
|
-
return
|
|
10908
|
+
function serenaWarmCommand() {
|
|
10909
|
+
return [
|
|
10910
|
+
`mkdir -p ${SERENA_IMAGE_HOME}`,
|
|
10911
|
+
`SERENA_HOME=${SERENA_IMAGE_HOME} serena project index ${WARM_DIR}`
|
|
10912
|
+
].join("; ");
|
|
10952
10913
|
}
|
|
10953
|
-
|
|
10954
|
-
|
|
10955
|
-
|
|
10956
|
-
|
|
10957
|
-
|
|
10958
|
-
|
|
10959
|
-
|
|
10960
|
-
if (lastSynced !== void 0 && lastSynced === row.prompt) return void 0;
|
|
10961
|
-
}
|
|
10962
|
-
return row.prompt;
|
|
10914
|
+
function baseLayer() {
|
|
10915
|
+
const dockerfile = [
|
|
10916
|
+
`FROM ${SANDBOX_BASE_IMAGE}`,
|
|
10917
|
+
`LABEL io.crew.sandbox.layer="base" io.crew.sandbox.openshell="${SANDBOX_OPENSHELL_VERSION}"`,
|
|
10918
|
+
""
|
|
10919
|
+
].join("\n");
|
|
10920
|
+
return { name: "base", tag: `crew-sandbox-base:${hash({ SANDBOX_BASE_IMAGE, SANDBOX_OPENSHELL_VERSION })}`, dockerfile, files: {} };
|
|
10963
10921
|
}
|
|
10964
|
-
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
10969
|
-
|
|
10922
|
+
var APT_HTTPS_COMMAND = "sed -i -E 's#http://([a-z0-9.-]*\\.)?ubuntu\\.com#https://\\1ubuntu.com#g' /etc/apt/sources.list.d/ubuntu.sources 2>/dev/null || true";
|
|
10923
|
+
var CA_BUNDLE_FILE = "ca-certificates.crt";
|
|
10924
|
+
var HOST_CA_BUNDLES = ["/etc/ssl/certs/ca-certificates.crt", "/etc/pki/tls/certs/ca-bundle.crt", "/etc/ssl/cert.pem"];
|
|
10925
|
+
function readHostCaBundle(paths = HOST_CA_BUNDLES) {
|
|
10926
|
+
for (const path of paths) {
|
|
10927
|
+
try {
|
|
10928
|
+
return readFileSync24(path, "utf8");
|
|
10929
|
+
} catch {
|
|
10930
|
+
}
|
|
10970
10931
|
}
|
|
10932
|
+
return "";
|
|
10971
10933
|
}
|
|
10972
|
-
function
|
|
10973
|
-
const
|
|
10974
|
-
|
|
10934
|
+
function crewLayer(base, intel, bridge) {
|
|
10935
|
+
const files = { "credential-helper": CREDENTIAL_HELPER, "mcp.json": MCP_CONFIG, ...bridge ? { "intel-bridge": bridge } : {} };
|
|
10936
|
+
const env = Object.entries(CREW_ENV).map(([k, v]) => `${k}=${v}`).join(" ");
|
|
10937
|
+
const dockerfile = [
|
|
10938
|
+
`FROM ${base.tag}`,
|
|
10939
|
+
"USER root",
|
|
10940
|
+
`COPY ${CA_BUNDLE_FILE} /etc/ssl/certs/ca-certificates.crt`,
|
|
10941
|
+
run2(APT_HTTPS_COMMAND),
|
|
10942
|
+
run2(`apt-get update && apt-get install -y --no-install-recommends ca-certificates curl git${intel ? " python3 python3-venv nodejs" : ""} && rm -rf /var/lib/apt/lists/*`),
|
|
10943
|
+
`COPY credential-helper ${CREW_PREFIX}/bin/credential-helper`,
|
|
10944
|
+
`COPY mcp.json ${CREW_PREFIX}/mcp/mcp.json`,
|
|
10945
|
+
...bridge ? [`COPY intel-bridge ${SANDBOX_BRIDGE_PATH}`] : [],
|
|
10946
|
+
run2(claudeInstallCommand()),
|
|
10947
|
+
...intel ? [run2(`mkdir -p ${CREW_PREFIX}/cache && ${serenaInstallCommand()}`)] : [],
|
|
10948
|
+
run2(`chmod 0755 ${CREW_PREFIX}/bin/credential-helper && git config --system credential.helper ${CREW_PREFIX}/bin/credential-helper`),
|
|
10949
|
+
run2(`mkdir -p ${CREW_PREFIX}/cache ${CREW_PREFIX}/pnpm-store ${CREW_PREFIX}/pnpm /sandbox && chown -R ${SANDBOX_UID}:${SANDBOX_UID} ${CREW_PREFIX} /sandbox`),
|
|
10950
|
+
...intel ? [`ENV ${SERENA_LANGUAGE_SERVERS_ENV}=${SERENA_IMAGE_HOME}/language_servers UV_PYTHON_INSTALL_DIR=${CREW_PREFIX}/uv/python`] : [],
|
|
10951
|
+
`ENV ${env} PATH=${CREW_PREFIX}/pnpm:${CREW_PREFIX}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin`,
|
|
10952
|
+
`LABEL io.crew.sandbox.layer="crew" io.crew.sandbox.claude="${SANDBOX_CLAUDE_VERSION}"`,
|
|
10953
|
+
""
|
|
10954
|
+
].join("\n");
|
|
10955
|
+
return { name: "crew", tag: `crew-sandbox-crew:${hash({ base: base.tag, dockerfile, files })}`, dockerfile, files, caBundleFile: CA_BUNDLE_FILE };
|
|
10975
10956
|
}
|
|
10976
|
-
|
|
10977
|
-
|
|
10978
|
-
|
|
10979
|
-
|
|
10980
|
-
|
|
10957
|
+
var WARM_DIR = "/tmp/crew-warm";
|
|
10958
|
+
var WARM_MAX_BYTES = 64 * 1024 * 1024;
|
|
10959
|
+
var globToRegExp = (glob) => new RegExp(`^${glob.split("*").map((p) => p.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join("[^/]*")}$`);
|
|
10960
|
+
function readWarmFiles(dir, ref, patterns) {
|
|
10961
|
+
if (patterns.length === 0) return {};
|
|
10962
|
+
const git2 = (args) => execFileSync7("git", ["-C", dir, ...args], { encoding: "utf8", maxBuffer: WARM_MAX_BYTES, stdio: ["ignore", "pipe", "pipe"] });
|
|
10963
|
+
const all = git2(["ls-tree", "-r", "--name-only", ref]).split("\n").filter(Boolean);
|
|
10964
|
+
const res = patterns.map(globToRegExp);
|
|
10965
|
+
const out = {};
|
|
10966
|
+
let total = 0;
|
|
10967
|
+
for (const path of all.filter((f) => res.some((re) => re.test(f))).sort()) {
|
|
10968
|
+
const content = git2(["show", `${ref}:${path}`]);
|
|
10969
|
+
total += content.length;
|
|
10970
|
+
if (total > WARM_MAX_BYTES) throw new Error(`sandbox.warm files exceed ${WARM_MAX_BYTES} bytes`);
|
|
10971
|
+
out[path] = content;
|
|
10972
|
+
}
|
|
10973
|
+
return out;
|
|
10974
|
+
}
|
|
10975
|
+
function repoLayer(repo, decl, crew, warm) {
|
|
10976
|
+
const env = Object.entries(CREW_ENV).map(([k, v]) => `${k}=${v}`).join(" ");
|
|
10977
|
+
const lines2 = [];
|
|
10978
|
+
if (decl.image) {
|
|
10979
|
+
lines2.push(
|
|
10980
|
+
`FROM ${crew.tag} AS crew`,
|
|
10981
|
+
`FROM ${decl.image}`,
|
|
10982
|
+
"USER root",
|
|
10983
|
+
`COPY --from=crew ${CREW_PREFIX} ${CREW_PREFIX}`,
|
|
10984
|
+
`ENV ${env} PATH=${CREW_PREFIX}/pnpm:${CREW_PREFIX}/bin:$PATH`
|
|
10985
|
+
);
|
|
10986
|
+
} else {
|
|
10987
|
+
lines2.push(`FROM ${crew.tag}`, "USER root");
|
|
10988
|
+
}
|
|
10989
|
+
if (decl.packages.length > 0) {
|
|
10990
|
+
lines2.push(run2(APT_HTTPS_COMMAND));
|
|
10991
|
+
lines2.push(run2(`apt-get update && apt-get install -y --no-install-recommends ${decl.packages.join(" ")} && rm -rf /var/lib/apt/lists/*`));
|
|
10992
|
+
}
|
|
10993
|
+
lines2.push(
|
|
10994
|
+
run2(`mkdir -p /sandbox && chown -R ${SANDBOX_UID}:${SANDBOX_UID} /sandbox ${CREW_PREFIX}`),
|
|
10995
|
+
`USER ${SANDBOX_UID}`,
|
|
10996
|
+
"WORKDIR /sandbox"
|
|
10997
|
+
);
|
|
10998
|
+
const files = {};
|
|
10999
|
+
const warming = Object.keys(warm).length > 0;
|
|
11000
|
+
if (warming) {
|
|
11001
|
+
for (const [path, content] of Object.entries(warm)) files[`warm/${path}`] = content;
|
|
11002
|
+
lines2.push(`COPY --chown=${SANDBOX_UID}:${SANDBOX_UID} warm/ ${WARM_DIR}/`, `WORKDIR ${WARM_DIR}`);
|
|
11003
|
+
}
|
|
11004
|
+
for (const step of decl.setup) lines2.push(run2(step));
|
|
11005
|
+
if (warming && decl.intel) lines2.push(run2(serenaWarmCommand()));
|
|
11006
|
+
if (warming) lines2.push("WORKDIR /sandbox", run2(`rm -rf ${WARM_DIR}`));
|
|
11007
|
+
lines2.push(`LABEL io.crew.sandbox.layer="repo" io.crew.sandbox.repo=${JSON.stringify(repo)}`, "");
|
|
11008
|
+
const dockerfile = lines2.join("\n");
|
|
11009
|
+
return { name: "repo", tag: `crew-sandbox/${slug(repo)}:${hash({ crew: crew.tag, dockerfile, files })}`, dockerfile, files };
|
|
11010
|
+
}
|
|
11011
|
+
function planSandbox(repo, decl, warm = {}, bridge) {
|
|
11012
|
+
const base = baseLayer();
|
|
11013
|
+
const crew = crewLayer(base, decl.intel, bridge);
|
|
11014
|
+
const layer = repoLayer(repo, decl, crew, warm);
|
|
11015
|
+
return { repo, tag: layer.tag, claude: SANDBOX_CLAUDE_VERSION, layers: [base, crew, layer] };
|
|
11016
|
+
}
|
|
11017
|
+
var SHIP_SANDBOX_KEY = "@ship";
|
|
11018
|
+
var shipSandboxRef = () => ({ name: SHIP_SANDBOX_KEY, decl: { packages: [], setup: [] } });
|
|
11019
|
+
var sandboxStatePath = (stateDir) => join26(stateDir, "sandbox-images.json");
|
|
11020
|
+
function readSandboxState(stateDir) {
|
|
11021
|
+
try {
|
|
11022
|
+
const v = JSON.parse(readFileSync24(sandboxStatePath(stateDir), "utf8"));
|
|
11023
|
+
return v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
11024
|
+
} catch {
|
|
11025
|
+
return {};
|
|
11026
|
+
}
|
|
11027
|
+
}
|
|
11028
|
+
function writeSandboxState(stateDir, state) {
|
|
11029
|
+
mkdirSync17(stateDir, { recursive: true });
|
|
11030
|
+
const file = sandboxStatePath(stateDir);
|
|
11031
|
+
writeFileSync18(`${file}.tmp`, `${JSON.stringify(state, null, 2)}
|
|
11032
|
+
`);
|
|
11033
|
+
renameSync3(`${file}.tmp`, file);
|
|
11034
|
+
}
|
|
11035
|
+
function sandboxImageFor(state, repo) {
|
|
11036
|
+
return state[repo]?.tags[0]?.tag ?? null;
|
|
11037
|
+
}
|
|
11038
|
+
function sandboxImageForRun(state, repo, declares) {
|
|
11039
|
+
return (declares && repo ? sandboxImageFor(state, repo) : null) ?? sandboxImageFor(state, SHIP_SANDBOX_KEY);
|
|
11040
|
+
}
|
|
11041
|
+
function sandboxImageStatus(state, plan) {
|
|
11042
|
+
const s = state[plan.repo];
|
|
11043
|
+
const current = s?.tags[0];
|
|
11044
|
+
if (s?.failure && s.failure.tag === plan.tag) {
|
|
11045
|
+
return { status: "failed", detail: `last build of ${plan.tag} failed at ${s.failure.at}; log ${s.failure.logPath}${current ? `; running ${current.tag}` : ""}` };
|
|
11046
|
+
}
|
|
11047
|
+
if (!current) return { status: "missing", detail: `no image built yet (wants ${plan.tag}); run \`crew sandbox build\`` };
|
|
11048
|
+
if (current.tag !== plan.tag) return { status: "stale", detail: `running ${current.tag} (claude ${current.claude ?? "unknown"}), declaration now builds ${plan.tag} (claude ${plan.claude})` };
|
|
11049
|
+
return { status: "ok", detail: `${current.tag} built ${current.builtAt}, claude ${current.claude ?? "unknown"}` };
|
|
11050
|
+
}
|
|
11051
|
+
var spawnBuildRunner = (engine = "docker") => (args, logPath) => new Promise((resolve8) => {
|
|
11052
|
+
const child = spawn3(engine, args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
11053
|
+
const chunks = [];
|
|
11054
|
+
child.stdout.on("data", (d) => chunks.push(d));
|
|
11055
|
+
child.stderr.on("data", (d) => chunks.push(d));
|
|
11056
|
+
const done = (code, extra = "") => {
|
|
11057
|
+
writeFileSync18(logPath, `$ ${engine} ${args.join(" ")}
|
|
11058
|
+
${Buffer.concat(chunks).toString("utf8")}${extra}`, { flag: "a" });
|
|
11059
|
+
resolve8(code);
|
|
11060
|
+
};
|
|
11061
|
+
child.on("error", (e) => done(127, `${e.message}
|
|
11062
|
+
`));
|
|
11063
|
+
child.on("close", (code) => done(code ?? 1));
|
|
11064
|
+
});
|
|
11065
|
+
var engineHasImage = (engine = "docker", exec = realExec) => (tag) => {
|
|
11066
|
+
try {
|
|
11067
|
+
exec(engine, ["image", "inspect", tag], { timeoutMs: 2e4 });
|
|
11068
|
+
return true;
|
|
11069
|
+
} catch {
|
|
11070
|
+
return false;
|
|
11071
|
+
}
|
|
11072
|
+
};
|
|
11073
|
+
var engineRemoveImage = (engine = "docker", exec = realExec) => (tag) => {
|
|
11074
|
+
try {
|
|
11075
|
+
exec(engine, ["image", "rm", tag], { timeoutMs: 6e4 });
|
|
11076
|
+
} catch {
|
|
11077
|
+
}
|
|
11078
|
+
};
|
|
11079
|
+
var sandboxLogDir = (stateDir) => join26(stateDir, "sandbox-logs");
|
|
11080
|
+
async function buildSandboxImage(plan, deps) {
|
|
11081
|
+
const now = deps.now ?? (() => /* @__PURE__ */ new Date());
|
|
11082
|
+
const state = readSandboxState(deps.stateDir);
|
|
11083
|
+
const entry = state[plan.repo] ?? { tags: [] };
|
|
11084
|
+
if (entry.tags[0]?.tag === plan.tag && deps.hasImage(plan.tag)) {
|
|
11085
|
+
return { kind: "reused", tag: plan.tag };
|
|
11086
|
+
}
|
|
11087
|
+
const logDir = sandboxLogDir(deps.stateDir);
|
|
11088
|
+
mkdirSync17(logDir, { recursive: true });
|
|
11089
|
+
const logPath = join26(logDir, `${slug(plan.repo)}-${now().toISOString().replace(/[:.]/g, "-")}.log`);
|
|
11090
|
+
const builtLayers = [];
|
|
11091
|
+
for (const layer of plan.layers) {
|
|
11092
|
+
if (deps.hasImage(layer.tag)) continue;
|
|
11093
|
+
const ctx = join26(tmpdir2(), `crew-sandbox-${hash([layer.tag, process.pid, Date.now()])}`);
|
|
11094
|
+
mkdirSync17(ctx, { recursive: true });
|
|
11095
|
+
try {
|
|
11096
|
+
writeFileSync18(join26(ctx, "Dockerfile"), layer.dockerfile);
|
|
11097
|
+
for (const [name, content] of Object.entries(layer.files)) {
|
|
11098
|
+
mkdirSync17(dirname13(join26(ctx, name)), { recursive: true });
|
|
11099
|
+
writeFileSync18(join26(ctx, name), content);
|
|
11100
|
+
}
|
|
11101
|
+
if (layer.caBundleFile) writeFileSync18(join26(ctx, layer.caBundleFile), (deps.caBundle ?? readHostCaBundle)());
|
|
11102
|
+
const code = await deps.run(["build", "--tag", layer.tag, "--file", join26(ctx, "Dockerfile"), ctx], logPath);
|
|
11103
|
+
if (code !== 0) {
|
|
11104
|
+
state[plan.repo] = { ...entry, failure: { tag: plan.tag, at: now().toISOString(), logPath } };
|
|
11105
|
+
writeSandboxState(deps.stateDir, state);
|
|
11106
|
+
return { kind: "failed", tag: plan.tag, logPath, layer: layer.name };
|
|
11107
|
+
}
|
|
11108
|
+
builtLayers.push(layer.name);
|
|
11109
|
+
} finally {
|
|
11110
|
+
rmSync14(ctx, { recursive: true, force: true });
|
|
11111
|
+
}
|
|
11112
|
+
}
|
|
11113
|
+
const tags = [{ tag: plan.tag, builtAt: now().toISOString(), claude: plan.claude }, ...entry.tags.filter((t) => t.tag !== plan.tag)];
|
|
11114
|
+
const dropped = tags.slice(KEEP_TAGS);
|
|
11115
|
+
state[plan.repo] = { tags: tags.slice(0, KEEP_TAGS) };
|
|
11116
|
+
writeSandboxState(deps.stateDir, state);
|
|
11117
|
+
for (const t of dropped) deps.removeImage(t.tag);
|
|
11118
|
+
return { kind: "built", tag: plan.tag, builtLayers };
|
|
11119
|
+
}
|
|
11120
|
+
var sandboxFailedKey = (repo) => `sandbox_build_failed:${repo}`;
|
|
11121
|
+
function sandboxFailedItem(repo, tag, layer, logPath, nowIso = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
11122
|
+
return {
|
|
11123
|
+
kind: "sandbox_build_failed",
|
|
11124
|
+
key: sandboxFailedKey(repo),
|
|
11125
|
+
since: nowIso,
|
|
11126
|
+
message: `${repo}: sandbox image ${tag} failed to build at the ${layer} layer (log: ${logPath}); sandboxes keep running the previous image. Retries automatically after the declaration changes or in an hour; \`crew sandbox build\` forces it`
|
|
11127
|
+
};
|
|
11128
|
+
}
|
|
11129
|
+
async function sandboxBuildTick(repos, deps, force = false) {
|
|
11130
|
+
const nowMs = (deps.now ?? (() => /* @__PURE__ */ new Date()))().getTime();
|
|
11131
|
+
for (const r of repos) {
|
|
11132
|
+
const plan = planSandbox(r.name, r.decl, r.warm, r.bridge);
|
|
11133
|
+
const state = readSandboxState(deps.stateDir)[r.name];
|
|
11134
|
+
const upToDate = state?.tags[0]?.tag === plan.tag && deps.hasImage(plan.tag);
|
|
11135
|
+
if (upToDate) {
|
|
11136
|
+
deps.clear(sandboxFailedKey(r.name));
|
|
11137
|
+
continue;
|
|
11138
|
+
}
|
|
11139
|
+
if (!force && state?.failure?.tag === plan.tag && nowMs - Date.parse(state.failure.at) < SANDBOX_RETRY_AFTER_MS) continue;
|
|
11140
|
+
deps.log(`sandbox image for ${r.name}: building ${plan.tag}`);
|
|
11141
|
+
const out = await buildSandboxImage(plan, deps);
|
|
11142
|
+
if (out.kind === "failed") {
|
|
11143
|
+
deps.raise(sandboxFailedItem(r.name, out.tag, out.layer, out.logPath));
|
|
11144
|
+
deps.log(`sandbox image for ${r.name}: build failed at the ${out.layer} layer, log ${out.logPath}`);
|
|
11145
|
+
} else {
|
|
11146
|
+
deps.clear(sandboxFailedKey(r.name));
|
|
11147
|
+
deps.log(`sandbox image for ${r.name}: ${out.kind === "built" ? `built ${out.tag}` : `${out.tag} already built`}`);
|
|
11148
|
+
}
|
|
11149
|
+
return r.name;
|
|
11150
|
+
}
|
|
11151
|
+
return null;
|
|
11152
|
+
}
|
|
11153
|
+
|
|
11154
|
+
// src/skill-include.ts
|
|
11155
|
+
var SkillIncludeError = class extends Error {
|
|
11156
|
+
};
|
|
11157
|
+
var MAX_INCLUDE_DEPTH = 3;
|
|
11158
|
+
var MAX_INCLUDED_BYTES = 2e5;
|
|
11159
|
+
var MARKER = /\{\{[ \t]*skill:[ \t]*([^{}\r\n]*?)[ \t]*\}\}/g;
|
|
11160
|
+
function skillMarkerNames(text2) {
|
|
11161
|
+
const names = [];
|
|
11162
|
+
for (const m of text2.matchAll(MARKER)) {
|
|
11163
|
+
const name = m[1].trim();
|
|
11164
|
+
if (name && !names.includes(name)) names.push(name);
|
|
11165
|
+
}
|
|
11166
|
+
return names;
|
|
11167
|
+
}
|
|
11168
|
+
function expandSkillMarkers(text2, lookup2, opts = {}) {
|
|
11169
|
+
const maxDepth = opts.maxDepth ?? MAX_INCLUDE_DEPTH;
|
|
11170
|
+
const maxBytes = opts.maxBytes ?? MAX_INCLUDED_BYTES;
|
|
11171
|
+
const warnings = [];
|
|
11172
|
+
let included = 0;
|
|
11173
|
+
const expand2 = (source, chain) => source.replace(MARKER, (literal, rawName) => {
|
|
11174
|
+
const name = rawName.trim();
|
|
11175
|
+
if (!name) return literal;
|
|
11176
|
+
if (chain.includes(name)) {
|
|
11177
|
+
warnings.push(`skill include "${name}" left literal: it includes itself (${[...chain, name].join(" \u2192 ")})`);
|
|
11178
|
+
return literal;
|
|
11179
|
+
}
|
|
11180
|
+
if (chain.length >= maxDepth) {
|
|
11181
|
+
warnings.push(`skill include "${name}" left literal: nested deeper than ${maxDepth} levels`);
|
|
11182
|
+
return literal;
|
|
11183
|
+
}
|
|
11184
|
+
const body = lookup2(name);
|
|
11185
|
+
if (body === void 0) throw new SkillIncludeError(`no skill named "${name}" for the include ${literal}`);
|
|
11186
|
+
const trimmed = body.replace(/^\n+/, "").replace(/\n+$/, "");
|
|
11187
|
+
const bytes = Buffer.byteLength(trimmed, "utf8");
|
|
11188
|
+
if (included + bytes > maxBytes) {
|
|
11189
|
+
warnings.push(`skill include "${name}" left literal: it would exceed the ${maxBytes}-byte include budget`);
|
|
11190
|
+
return literal;
|
|
11191
|
+
}
|
|
11192
|
+
included += bytes;
|
|
11193
|
+
return expand2(trimmed, [...chain, name]);
|
|
11194
|
+
});
|
|
11195
|
+
return { text: expand2(text2, []), warnings };
|
|
11196
|
+
}
|
|
11197
|
+
|
|
11198
|
+
// src/skills.ts
|
|
11199
|
+
import { readFileSync as readFileSync26, readdirSync as readdirSync8, existsSync as existsSync25 } from "fs";
|
|
11200
|
+
import { join as join28 } from "path";
|
|
11201
|
+
import { parse as parseYaml } from "yaml";
|
|
11202
|
+
import { TablationClient as TablationClient3, StaleWriteError as StaleWriteError3, TablationApiError as TablationApiError2 } from "@tablation/client";
|
|
11203
|
+
|
|
11204
|
+
// src/prompt-additions.ts
|
|
11205
|
+
var PROMPT_ADDITIONS_SEPARATOR = "---\n\nAdditional instructions from this workspace. Where they conflict with anything above, these take precedence.";
|
|
11206
|
+
function appendAdditions(text2, additions) {
|
|
11207
|
+
if (typeof additions !== "string" || additions.trim() === "") return text2;
|
|
11208
|
+
return `${text2}
|
|
11209
|
+
|
|
11210
|
+
${PROMPT_ADDITIONS_SEPARATOR}
|
|
11211
|
+
|
|
11212
|
+
${additions}`;
|
|
11213
|
+
}
|
|
11214
|
+
|
|
11215
|
+
// src/agents.ts
|
|
11216
|
+
import { readFileSync as readFileSync25, existsSync as existsSync24 } from "fs";
|
|
11217
|
+
import { join as join27 } from "path";
|
|
11218
|
+
import { TablationClient as TablationClient2, StaleWriteError as StaleWriteError2, TablationApiError } from "@tablation/client";
|
|
11219
|
+
var PERSONA_NAME = {
|
|
11220
|
+
dev: "Developer",
|
|
11221
|
+
design: "Design",
|
|
11222
|
+
qa: "QA",
|
|
11223
|
+
triage: "Triage",
|
|
11224
|
+
pair: "Pair"
|
|
11225
|
+
};
|
|
11226
|
+
var CREW_AGENT_FIELD_NAME = "Agent";
|
|
11227
|
+
var CREW_AGENT_COLUMN = "agent_id";
|
|
11228
|
+
var AgentsSyncError = class extends Error {
|
|
11229
|
+
};
|
|
11230
|
+
function personaDefaultPrompt(promptsDir, role) {
|
|
11231
|
+
const briefPath = join27(promptsDir, "personas", `lane-${role}.md`);
|
|
11232
|
+
if (!existsSync24(briefPath)) throw new AgentsSyncError(`no brief at ${briefPath}`);
|
|
11233
|
+
if (SELF_CONTAINED_ROLES.has(role)) return readFileSync25(briefPath, "utf8");
|
|
11234
|
+
const commonPath = join27(promptsDir, "personas", "common.md");
|
|
11235
|
+
if (!existsSync24(commonPath)) return readFileSync25(briefPath, "utf8");
|
|
11236
|
+
return `${readFileSync25(commonPath, "utf8")}${readFileSync25(briefPath, "utf8")}`;
|
|
11237
|
+
}
|
|
11238
|
+
async function resolveAgentId(route2, role, opts) {
|
|
11239
|
+
const cached = route2.resolved?.agentPersonas?.[role]?.agentId;
|
|
11240
|
+
if (cached) return cached;
|
|
11241
|
+
const seatId = route2.resolved?.seats?.[role];
|
|
11242
|
+
if (!seatId || !route2.resolved) return void 0;
|
|
11243
|
+
const client2 = new TablationClient2({
|
|
11244
|
+
baseUrl: `${route2.baseUrl}/api`,
|
|
11245
|
+
apiKey: resolveApiKey(route2),
|
|
11246
|
+
headers: { "User-Agent": opts.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0" }
|
|
11247
|
+
});
|
|
11248
|
+
try {
|
|
11249
|
+
const row = await client2.records.get(route2.resolved.models.crew, seatId);
|
|
11250
|
+
return row.agent_id ?? void 0;
|
|
11251
|
+
} catch {
|
|
11252
|
+
return void 0;
|
|
11253
|
+
}
|
|
11254
|
+
}
|
|
11255
|
+
async function fetchPersonaPrompt(route2, role, opts) {
|
|
11256
|
+
const agentId = await resolveAgentId(route2, role, opts);
|
|
11257
|
+
if (!agentId || !route2.resolved) return {};
|
|
11258
|
+
const client2 = new TablationClient2({
|
|
11259
|
+
baseUrl: `${route2.baseUrl}/api`,
|
|
11260
|
+
apiKey: resolveApiKey(route2),
|
|
11261
|
+
headers: { "User-Agent": opts.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0" }
|
|
11262
|
+
});
|
|
11263
|
+
let row;
|
|
11264
|
+
let agentsModelId;
|
|
11265
|
+
try {
|
|
11266
|
+
const agentsModel = await client2.dataModels.get("agents", route2.resolved.workspaceId);
|
|
11267
|
+
agentsModelId = agentsModel.id;
|
|
11268
|
+
row = await client2.records.get(agentsModelId, agentId);
|
|
11269
|
+
} catch {
|
|
11270
|
+
return {};
|
|
11271
|
+
}
|
|
11272
|
+
const additions = typeof row.prompt_additions === "string" && row.prompt_additions.trim() !== "" ? row.prompt_additions : void 0;
|
|
11273
|
+
const divergedPrompt = await divergedRowPrompt(route2, role, row, agentId, agentsModelId, opts);
|
|
11274
|
+
return { divergedPrompt, additions };
|
|
11275
|
+
}
|
|
11276
|
+
function personaPromptOptions(p) {
|
|
11277
|
+
return { divergedPrompt: p.divergedPrompt, personaAdditions: p.additions };
|
|
11278
|
+
}
|
|
11279
|
+
async function divergedRowPrompt(route2, role, row, agentId, agentsModelId, opts) {
|
|
11280
|
+
if (!route2.resolved) return void 0;
|
|
11281
|
+
const defaultPrompt = personaDefaultPrompt(route2.promptsDir, role);
|
|
11282
|
+
if (row.prompt === defaultPrompt) return void 0;
|
|
11283
|
+
const cached = route2.resolved.agentPersonas?.[role];
|
|
11284
|
+
if (cached?.agentId === agentId && cached.historyId) {
|
|
11285
|
+
const lastSynced = await fetchLastSyncedPrompt(route2, agentsModelId, agentId, cached.historyId, opts.userAgent);
|
|
11286
|
+
if (lastSynced !== void 0 && lastSynced === row.prompt) return void 0;
|
|
11287
|
+
}
|
|
11288
|
+
return row.prompt;
|
|
11289
|
+
}
|
|
11290
|
+
async function fetchLastSyncedPrompt(route2, agentsModelId, recordId, historyId, userAgent) {
|
|
11291
|
+
try {
|
|
11292
|
+
const entries = await fetchHistoryEntries(route2, agentsModelId, recordId, userAgent);
|
|
11293
|
+
return entries.find((e) => e.history_id === historyId)?.prompt;
|
|
11294
|
+
} catch {
|
|
11295
|
+
return void 0;
|
|
11296
|
+
}
|
|
11297
|
+
}
|
|
11298
|
+
function choiceValue(v) {
|
|
11299
|
+
const raw = typeof v === "string" ? v : v && typeof v === "object" ? v.value ?? v.key : void 0;
|
|
11300
|
+
return typeof raw === "string" && raw.trim() ? raw.trim().toLowerCase() : void 0;
|
|
11301
|
+
}
|
|
11302
|
+
async function fetchSeatPersona(route2, role, opts) {
|
|
11303
|
+
const agentId = await resolveAgentId(route2, role, opts);
|
|
11304
|
+
if (!agentId || !route2.resolved) return void 0;
|
|
11305
|
+
const client2 = new TablationClient2({
|
|
11306
|
+
baseUrl: `${route2.baseUrl}/api`,
|
|
10981
11307
|
apiKey: resolveApiKey(route2),
|
|
10982
11308
|
headers: { "User-Agent": opts.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0" }
|
|
10983
11309
|
});
|
|
@@ -11354,7 +11680,7 @@ function describeCrewLink(o) {
|
|
|
11354
11680
|
var SkillSyncError = class extends Error {
|
|
11355
11681
|
};
|
|
11356
11682
|
function parseSkillFile(path) {
|
|
11357
|
-
const text2 =
|
|
11683
|
+
const text2 = readFileSync26(path, "utf8");
|
|
11358
11684
|
const match = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/.exec(text2);
|
|
11359
11685
|
if (!match) throw new SkillSyncError(`${path}: missing YAML frontmatter (expected a leading --- block)`);
|
|
11360
11686
|
const frontmatter = match[1];
|
|
@@ -11367,9 +11693,9 @@ function parseSkillFile(path) {
|
|
|
11367
11693
|
return { name: meta.name, description: meta.description, prompt: body, file: path };
|
|
11368
11694
|
}
|
|
11369
11695
|
function listLocalSkills(promptsDir) {
|
|
11370
|
-
const dir =
|
|
11371
|
-
if (!
|
|
11372
|
-
return readdirSync8(dir).filter((f) => f.endsWith(".md")).map((f) => parseSkillFile(
|
|
11696
|
+
const dir = join28(promptsDir, "skills");
|
|
11697
|
+
if (!existsSync25(dir)) return [];
|
|
11698
|
+
return readdirSync8(dir).filter((f) => f.endsWith(".md")).map((f) => parseSkillFile(join28(dir, f)));
|
|
11373
11699
|
}
|
|
11374
11700
|
async function syncSkills(route2, opts) {
|
|
11375
11701
|
if (!route2.resolved) {
|
|
@@ -11553,11 +11879,11 @@ function skillMarkerWarnings(promptsDir, personaPrompts) {
|
|
|
11553
11879
|
}
|
|
11554
11880
|
|
|
11555
11881
|
// src/runner.ts
|
|
11556
|
-
import { spawn as
|
|
11557
|
-
import { mkdtempSync, mkdirSync as
|
|
11558
|
-
import { createHash as
|
|
11559
|
-
import { tmpdir as
|
|
11560
|
-
import { basename as basename8, dirname as
|
|
11882
|
+
import { spawn as spawn4, execFile, execFileSync as execFileSync8 } from "child_process";
|
|
11883
|
+
import { mkdtempSync, mkdirSync as mkdirSync18, writeFileSync as writeFileSync19, rmSync as rmSync15 } from "fs";
|
|
11884
|
+
import { createHash as createHash5 } from "crypto";
|
|
11885
|
+
import { tmpdir as tmpdir3 } from "os";
|
|
11886
|
+
import { basename as basename8, dirname as dirname14, join as join29 } from "path";
|
|
11561
11887
|
import { promisify } from "util";
|
|
11562
11888
|
|
|
11563
11889
|
// src/run-limit.ts
|
|
@@ -11621,7 +11947,7 @@ var SANDBOX_PROMPT_PATH = "/sandbox/prompt.txt";
|
|
|
11621
11947
|
var HostRunner = class {
|
|
11622
11948
|
kind = "host";
|
|
11623
11949
|
start(plan, o) {
|
|
11624
|
-
const child =
|
|
11950
|
+
const child = spawn4(plan.bin, plan.args, {
|
|
11625
11951
|
cwd: plan.cwd,
|
|
11626
11952
|
env: o.env,
|
|
11627
11953
|
stdio: ["pipe", o.streamFd, "inherit"],
|
|
@@ -11651,7 +11977,7 @@ function shQuote2(s) {
|
|
|
11651
11977
|
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
11652
11978
|
}
|
|
11653
11979
|
function sandboxName(plan, now = Date.now()) {
|
|
11654
|
-
const h =
|
|
11980
|
+
const h = createHash5("sha256").update([plan.route, plan.role, plan.ticket ?? ""].join("\0")).digest();
|
|
11655
11981
|
const tag = (h.readUInt32BE(0) % 36 ** 6).toString(36).padStart(6, "0");
|
|
11656
11982
|
return `crew-${tag}${now.toString(36).slice(-8).padStart(8, "0")}`;
|
|
11657
11983
|
}
|
|
@@ -11692,8 +12018,8 @@ var SandboxRunner = class {
|
|
|
11692
12018
|
throw new Error(`cannot generate the sandbox policy: ${e.message}`);
|
|
11693
12019
|
}
|
|
11694
12020
|
policyFile = policyPathFor(plan.streamPath);
|
|
11695
|
-
|
|
11696
|
-
|
|
12021
|
+
mkdirSync18(dirname14(policyFile), { recursive: true });
|
|
12022
|
+
writeFileSync19(policyFile, generated.yaml, { mode: 384 });
|
|
11697
12023
|
}
|
|
11698
12024
|
const create2 = ["sandbox", "create", "--name", name, "--detach"];
|
|
11699
12025
|
if (policyFile) create2.push("--policy", policyFile);
|
|
@@ -11740,18 +12066,18 @@ var SandboxRunner = class {
|
|
|
11740
12066
|
const harness = cfg.agentBin ?? basename8(plan.bin);
|
|
11741
12067
|
const viaUpload = Buffer.byteLength(plan.prompt) > SANDBOX_STDIN_LIMIT;
|
|
11742
12068
|
if (viaUpload) {
|
|
11743
|
-
const tmp = mkdtempSync(
|
|
12069
|
+
const tmp = mkdtempSync(join29(tmpdir3(), "crew-prompt-"));
|
|
11744
12070
|
try {
|
|
11745
|
-
const file =
|
|
11746
|
-
|
|
12071
|
+
const file = join29(tmp, "prompt.txt");
|
|
12072
|
+
writeFileSync19(file, plan.prompt, { mode: 384 });
|
|
11747
12073
|
await this.os(["sandbox", "upload", name, file, SANDBOX_PROMPT_PATH]);
|
|
11748
12074
|
} finally {
|
|
11749
|
-
|
|
12075
|
+
rmSync15(tmp, { recursive: true, force: true });
|
|
11750
12076
|
}
|
|
11751
12077
|
}
|
|
11752
12078
|
const withStubs = `${sandboxEnvExports()}PATH=${shQuote2(SANDBOX_STUB_DIR)}:"$PATH"; export PATH; `;
|
|
11753
12079
|
const command2 = viaUpload ? ["sh", "-c", `${withStubs}exec ${[harness, ...plan.args].map(shQuote2).join(" ")} < ${SANDBOX_PROMPT_PATH}`] : ["sh", "-c", `${withStubs}exec "$@"`, "sh", harness, ...plan.args];
|
|
11754
|
-
const child =
|
|
12080
|
+
const child = spawn4(cfg.bin, ["sandbox", "exec", "-n", name, "--no-login-shell", "--workdir", cfg.workDir, "--", ...command2], {
|
|
11755
12081
|
env: process.env,
|
|
11756
12082
|
stdio: ["pipe", o.streamFd, "inherit"],
|
|
11757
12083
|
detached: true
|
|
@@ -11806,7 +12132,7 @@ var SandboxRunner = class {
|
|
|
11806
12132
|
var describeExecError = describe;
|
|
11807
12133
|
function gitOrigin(cwd) {
|
|
11808
12134
|
try {
|
|
11809
|
-
return
|
|
12135
|
+
return execFileSync8("git", ["-C", cwd, "remote", "get-url", "origin"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
11810
12136
|
} catch {
|
|
11811
12137
|
return null;
|
|
11812
12138
|
}
|
|
@@ -11818,7 +12144,7 @@ function runnerOfSidecar(sc) {
|
|
|
11818
12144
|
return sc.runner === "sandbox" ? new SandboxRunner(sc.sandboxBin ? { bin: sc.sandboxBin } : {}) : new HostRunner();
|
|
11819
12145
|
}
|
|
11820
12146
|
var PROBE_CREATE_TIMEOUT_MS = 12e4;
|
|
11821
|
-
function checkSandboxRunner(cfg = {}, run3 = (b, a, t) =>
|
|
12147
|
+
function checkSandboxRunner(cfg = {}, run3 = (b, a, t) => execFileSync8(b, a, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: t ?? 15e3 })) {
|
|
11822
12148
|
const bin = cfg.bin ?? DEFAULT_SANDBOX_CONFIG.bin;
|
|
11823
12149
|
let version;
|
|
11824
12150
|
try {
|
|
@@ -11934,7 +12260,7 @@ var ALLOWANCE_REFUSAL_MARKER = "AI_ALLOWANCE_EXCEEDED";
|
|
|
11934
12260
|
function streamShowsAllowanceRefusal(streamPath) {
|
|
11935
12261
|
let raw;
|
|
11936
12262
|
try {
|
|
11937
|
-
raw =
|
|
12263
|
+
raw = readFileSync27(streamPath, "utf8");
|
|
11938
12264
|
} catch {
|
|
11939
12265
|
return false;
|
|
11940
12266
|
}
|
|
@@ -11957,7 +12283,7 @@ function streamShowsAllowanceRefusal(streamPath) {
|
|
|
11957
12283
|
}
|
|
11958
12284
|
return false;
|
|
11959
12285
|
}
|
|
11960
|
-
var digestPathFor = (stateDir, routeLabel, role, runId) =>
|
|
12286
|
+
var digestPathFor = (stateDir, routeLabel, role, runId) => join30(stateDir, `digest-${routeLabel}-${role}${runId ? `-${runId}` : ""}.md`);
|
|
11961
12287
|
function codeBridgeFor(o, harness) {
|
|
11962
12288
|
if (!o.ticket) return void 0;
|
|
11963
12289
|
const number = /(\d+)$/.exec(o.ticket)?.[1];
|
|
@@ -11984,7 +12310,7 @@ function codeBridgeFor(o, harness) {
|
|
|
11984
12310
|
"--clone",
|
|
11985
12311
|
o.ship.sandbox?.workDir ?? DEFAULT_SANDBOX_WORKDIR,
|
|
11986
12312
|
"--state-dir",
|
|
11987
|
-
|
|
12313
|
+
dirname15(SANDBOX_INTEL_DIR),
|
|
11988
12314
|
"--ticket",
|
|
11989
12315
|
number,
|
|
11990
12316
|
...seed ? ["--seed-cache", seed] : []
|
|
@@ -11997,33 +12323,33 @@ function codeBridgeFor(o, harness) {
|
|
|
11997
12323
|
bridge.settingsFile = `${SANDBOX_INTEL_DIR}/gemini-settings.json`;
|
|
11998
12324
|
bridge.files = [{ path: bridge.settingsFile, content: text2 }];
|
|
11999
12325
|
} else {
|
|
12000
|
-
const file =
|
|
12001
|
-
|
|
12002
|
-
|
|
12326
|
+
const file = join30(intelDir(o.stateDir, o.route.route, number), "gemini-settings.json");
|
|
12327
|
+
mkdirSync19(dirname15(file), { recursive: true });
|
|
12328
|
+
writeFileSync20(file, text2);
|
|
12003
12329
|
bridge.settingsFile = file;
|
|
12004
12330
|
}
|
|
12005
12331
|
}
|
|
12006
12332
|
return bridge;
|
|
12007
12333
|
}
|
|
12008
12334
|
function planAgentRun(o) {
|
|
12009
|
-
const briefPath =
|
|
12010
|
-
if (!
|
|
12335
|
+
const briefPath = join30(o.route.promptsDir, "personas", `lane-${o.role}.md`);
|
|
12336
|
+
if (!existsSync26(briefPath)) {
|
|
12011
12337
|
throw new AgentError(`no brief at ${briefPath} \u2014 refusing to run an unscoped session`);
|
|
12012
12338
|
}
|
|
12013
|
-
const commonPath =
|
|
12014
|
-
const usesCommon = !SELF_CONTAINED_ROLES.has(o.role) &&
|
|
12339
|
+
const commonPath = join30(o.route.promptsDir, "personas", "common.md");
|
|
12340
|
+
const usesCommon = !SELF_CONTAINED_ROLES.has(o.role) && existsSync26(commonPath);
|
|
12015
12341
|
const now = o.now ?? (() => Date.now());
|
|
12016
12342
|
const routeLabel = routeSlug(o.route.route);
|
|
12017
12343
|
const ownDigest = o.runId ? digestPathFor(o.stateDir, routeLabel, o.role, o.runId) : void 0;
|
|
12018
|
-
const digestPath2 = ownDigest &&
|
|
12344
|
+
const digestPath2 = ownDigest && existsSync26(ownDigest) ? ownDigest : digestPathFor(o.stateDir, routeLabel, o.role);
|
|
12019
12345
|
let digest;
|
|
12020
12346
|
let ageSeconds;
|
|
12021
|
-
if (
|
|
12347
|
+
if (existsSync26(digestPath2)) {
|
|
12022
12348
|
ageSeconds = Math.floor((now() - statSync8(digestPath2).mtimeMs) / 1e3);
|
|
12023
|
-
if (ageSeconds <= DIGEST_MAX_AGE_SECONDS) digest =
|
|
12349
|
+
if (ageSeconds <= DIGEST_MAX_AGE_SECONDS) digest = readFileSync27(digestPath2, "utf8");
|
|
12024
12350
|
}
|
|
12025
|
-
const common = usesCommon ?
|
|
12026
|
-
const brief =
|
|
12351
|
+
const common = usesCommon ? readFileSync27(commonPath, "utf8") : "";
|
|
12352
|
+
const brief = readFileSync27(briefPath, "utf8");
|
|
12027
12353
|
const effectiveCommon = o.divergedPrompt ? "" : common;
|
|
12028
12354
|
const effectiveBrief = appendAdditions(o.divergedPrompt ?? brief, o.personaAdditions);
|
|
12029
12355
|
const localSkills = new Map(listLocalSkills(o.route.promptsDir).map((s) => [s.name, s.prompt]));
|
|
@@ -12045,8 +12371,8 @@ function planAgentRun(o) {
|
|
|
12045
12371
|
brief: expanded.text,
|
|
12046
12372
|
digest
|
|
12047
12373
|
});
|
|
12048
|
-
const promptSha =
|
|
12049
|
-
const streamsDir =
|
|
12374
|
+
const promptSha = createHash6("sha256").update(expanded.text).digest("hex");
|
|
12375
|
+
const streamsDir = join30(o.stateDir, "streams");
|
|
12050
12376
|
const base = `${routeLabel}-${o.role}-${o.cycle}${o.runId ? `-${o.runId}` : ""}`;
|
|
12051
12377
|
const seat = resolveSeat(o.ship, o.route, o.role, o.agentPersona ?? (o.agentModel ? { model: o.agentModel } : {}), o.repo);
|
|
12052
12378
|
const { model } = seat;
|
|
@@ -12149,8 +12475,8 @@ function planAgentRun(o) {
|
|
|
12149
12475
|
digestAttached: digest !== void 0,
|
|
12150
12476
|
digestAgeSeconds: ageSeconds,
|
|
12151
12477
|
model,
|
|
12152
|
-
streamPath:
|
|
12153
|
-
eventsPath:
|
|
12478
|
+
streamPath: join30(streamsDir, `${base}.jsonl`),
|
|
12479
|
+
eventsPath: join30(streamsDir, `${base}.events.jsonl`),
|
|
12154
12480
|
ticket: o.ticket,
|
|
12155
12481
|
ticketRecordId: o.ticketRecordId ?? null,
|
|
12156
12482
|
repo: o.repo ?? null,
|
|
@@ -12182,7 +12508,7 @@ function describePlan(p) {
|
|
|
12182
12508
|
var pidPathFor = (streamPath) => `${streamPath}.pid`;
|
|
12183
12509
|
function readRunSidecar(streamPath) {
|
|
12184
12510
|
try {
|
|
12185
|
-
const sc = JSON.parse(
|
|
12511
|
+
const sc = JSON.parse(readFileSync27(pidPathFor(streamPath), "utf8"));
|
|
12186
12512
|
return typeof sc.pid === "number" && typeof sc.spawnedAt === "string" && typeof sc.role === "string" ? sc : null;
|
|
12187
12513
|
} catch {
|
|
12188
12514
|
return null;
|
|
@@ -12230,7 +12556,7 @@ async function killForDeadline(kill, pid, emit, role, ticket, spawnedAt, limitMi
|
|
|
12230
12556
|
var withoutKey = ({ apiKey: _apiKey, ...rest }) => rest;
|
|
12231
12557
|
function openSink(path) {
|
|
12232
12558
|
try {
|
|
12233
|
-
|
|
12559
|
+
mkdirSync19(dirname15(path), { recursive: true });
|
|
12234
12560
|
return createWriteStream(path, { flags: "a" });
|
|
12235
12561
|
} catch {
|
|
12236
12562
|
return void 0;
|
|
@@ -12416,7 +12742,7 @@ var RunObserver = class {
|
|
|
12416
12742
|
};
|
|
12417
12743
|
function writeRunMeta(id, startedAt, liveTicket, extra) {
|
|
12418
12744
|
try {
|
|
12419
|
-
|
|
12745
|
+
writeFileSync20(`${id.streamPath}.meta.json`, JSON.stringify({
|
|
12420
12746
|
route: id.route,
|
|
12421
12747
|
role: id.role,
|
|
12422
12748
|
hint: id.ticket,
|
|
@@ -12607,7 +12933,7 @@ function spawnAgent(plan, emit, hintMoved) {
|
|
|
12607
12933
|
const id = identityOf(plan, adapter.harness);
|
|
12608
12934
|
let streamFd;
|
|
12609
12935
|
try {
|
|
12610
|
-
|
|
12936
|
+
mkdirSync19(dirname15(plan.streamPath), { recursive: true });
|
|
12611
12937
|
streamFd = openSync4(plan.streamPath, "a");
|
|
12612
12938
|
} catch (e) {
|
|
12613
12939
|
void endSink(eventsSink);
|
|
@@ -12666,7 +12992,7 @@ function spawnAgent(plan, emit, hintMoved) {
|
|
|
12666
12992
|
...plan.workspaceRunId ? { workspaceRunId: plan.workspaceRunId } : {}
|
|
12667
12993
|
};
|
|
12668
12994
|
try {
|
|
12669
|
-
|
|
12995
|
+
writeFileSync20(pidPathFor(plan.streamPath), JSON.stringify(sidecar));
|
|
12670
12996
|
} catch {
|
|
12671
12997
|
}
|
|
12672
12998
|
}
|
|
@@ -12780,21 +13106,21 @@ var pidAlive = (pid) => {
|
|
|
12780
13106
|
};
|
|
12781
13107
|
function runFinished(streamPath) {
|
|
12782
13108
|
const path = `${streamPath}.meta.json`;
|
|
12783
|
-
if (!
|
|
13109
|
+
if (!existsSync27(path)) return false;
|
|
12784
13110
|
try {
|
|
12785
|
-
return JSON.parse(
|
|
13111
|
+
return JSON.parse(readFileSync28(path, "utf8")).running !== true;
|
|
12786
13112
|
} catch {
|
|
12787
13113
|
return true;
|
|
12788
13114
|
}
|
|
12789
13115
|
}
|
|
12790
13116
|
function orphanedStreams(o) {
|
|
12791
|
-
const dir =
|
|
12792
|
-
if (!
|
|
13117
|
+
const dir = join31(o.stateDir, "streams");
|
|
13118
|
+
if (!existsSync27(dir)) return [];
|
|
12793
13119
|
const ownerAlive = o.isOwnerAlive ?? pidAlive;
|
|
12794
13120
|
const out = [];
|
|
12795
13121
|
for (const name of readdirSync9(dir)) {
|
|
12796
13122
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
12797
|
-
const streamPath =
|
|
13123
|
+
const streamPath = join31(dir, name);
|
|
12798
13124
|
if (runFinished(streamPath)) continue;
|
|
12799
13125
|
const sidecar = readRunSidecar(streamPath);
|
|
12800
13126
|
if (!sidecar || sidecar.route !== o.routeLabel) continue;
|
|
@@ -12847,15 +13173,15 @@ async function reconcileRuns(o) {
|
|
|
12847
13173
|
}
|
|
12848
13174
|
|
|
12849
13175
|
// src/live-runs.ts
|
|
12850
|
-
import { existsSync as
|
|
12851
|
-
import { join as
|
|
13176
|
+
import { existsSync as existsSync28, readdirSync as readdirSync10, statSync as statSync9 } from "fs";
|
|
13177
|
+
import { join as join32 } from "path";
|
|
12852
13178
|
function liveRuns(stateDir, isAlive = runIsAlive) {
|
|
12853
|
-
const dir =
|
|
12854
|
-
if (!
|
|
13179
|
+
const dir = join32(stateDir, "streams");
|
|
13180
|
+
if (!existsSync28(dir)) return [];
|
|
12855
13181
|
const out = [];
|
|
12856
13182
|
for (const name of readdirSync10(dir)) {
|
|
12857
13183
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
12858
|
-
const streamPath =
|
|
13184
|
+
const streamPath = join32(dir, name);
|
|
12859
13185
|
if (runFinished(streamPath)) continue;
|
|
12860
13186
|
const sidecar = readRunSidecar(streamPath);
|
|
12861
13187
|
if (!sidecar || !isAlive(sidecar)) continue;
|
|
@@ -12865,12 +13191,12 @@ function liveRuns(stateDir, isAlive = runIsAlive) {
|
|
|
12865
13191
|
}
|
|
12866
13192
|
function runActivity(stateDir, isAlive = runIsAlive) {
|
|
12867
13193
|
const activeRuns = liveRuns(stateDir, isAlive).length;
|
|
12868
|
-
const dir =
|
|
13194
|
+
const dir = join32(stateDir, "streams");
|
|
12869
13195
|
let newest = 0;
|
|
12870
|
-
if (
|
|
13196
|
+
if (existsSync28(dir)) {
|
|
12871
13197
|
for (const name of readdirSync10(dir)) {
|
|
12872
13198
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
12873
|
-
const streamPath =
|
|
13199
|
+
const streamPath = join32(dir, name);
|
|
12874
13200
|
if (!runFinished(streamPath)) continue;
|
|
12875
13201
|
try {
|
|
12876
13202
|
newest = Math.max(newest, statSync9(`${streamPath}.meta.json`).mtimeMs);
|
|
@@ -12965,7 +13291,7 @@ function realDeprovisionDeps(cfg, emit, crewHome, getStore) {
|
|
|
12965
13291
|
if (host === "windows") return [];
|
|
12966
13292
|
const ctx = installContext();
|
|
12967
13293
|
const systemd = detectSystemd();
|
|
12968
|
-
return ["run", "release", "passengers"].flatMap((job) => planInstall(cfg.ship, crewHome, host, systemd, job, ctx).unitPaths).filter((p) =>
|
|
13294
|
+
return ["run", "release", "passengers"].flatMap((job) => planInstall(cfg.ship, crewHome, host, systemd, job, ctx).unitPaths).filter((p) => existsSync29(p));
|
|
12969
13295
|
};
|
|
12970
13296
|
return {
|
|
12971
13297
|
liveRuns: () => liveRuns(stateDir).map((r) => ({ role: r.role, route: r.route, pid: r.pid, ticketRecordId: r.ticketRecordId ?? void 0, streamPath: r.streamPath })),
|
|
@@ -13026,7 +13352,7 @@ function realDeprovisionDeps(cfg, emit, crewHome, getStore) {
|
|
|
13026
13352
|
},
|
|
13027
13353
|
remaining() {
|
|
13028
13354
|
const left = [];
|
|
13029
|
-
if (
|
|
13355
|
+
if (existsSync29(cfg.configFile)) left.push(`config ${cfg.configFile}`);
|
|
13030
13356
|
for (const h of forgeHosts()) if (hasForgeToken(cfg.ship.forges, h, stateDir)) left.push(`forge token for ${h}`);
|
|
13031
13357
|
try {
|
|
13032
13358
|
for (const k of readdirSync11(keysDir(stateDir))) left.push(`seat key ${k}`);
|
|
@@ -13049,7 +13375,7 @@ function realDeprovisionDeps(cfg, emit, crewHome, getStore) {
|
|
|
13049
13375
|
|
|
13050
13376
|
// src/sandbox-cache.ts
|
|
13051
13377
|
var execFileP2 = promisify2(execFile2);
|
|
13052
|
-
var
|
|
13378
|
+
var realExec2 = (bin, args, o) => execFileP2(bin, args, { env: o?.env ?? process.env, maxBuffer: 16 * 1024 * 1024 });
|
|
13053
13379
|
var OPENSHELL_ATTACHABLE_LABEL = "openshell.ai/sandbox-attachable=true";
|
|
13054
13380
|
var OPENSHELL_WORKSPACE_LABEL = "openshell.ai/sandbox-attachable-workspace";
|
|
13055
13381
|
var VOLUME_ROOT = "/cache";
|
|
@@ -13185,7 +13511,7 @@ git -C "$m" show "refs/heads/$base:$path"
|
|
|
13185
13511
|
var SandboxCache = class {
|
|
13186
13512
|
s;
|
|
13187
13513
|
exec;
|
|
13188
|
-
constructor(s, exec =
|
|
13514
|
+
constructor(s, exec = realExec2) {
|
|
13189
13515
|
this.s = s;
|
|
13190
13516
|
this.exec = exec;
|
|
13191
13517
|
}
|
|
@@ -13381,9 +13707,9 @@ function makeCachePass(o) {
|
|
|
13381
13707
|
}
|
|
13382
13708
|
|
|
13383
13709
|
// src/passenger-containers.ts
|
|
13384
|
-
var
|
|
13710
|
+
var realExec = (cmd, args, opts) => {
|
|
13385
13711
|
try {
|
|
13386
|
-
return
|
|
13712
|
+
return execFileSync9(cmd, args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: opts?.timeoutMs });
|
|
13387
13713
|
} catch (e) {
|
|
13388
13714
|
const err3 = e;
|
|
13389
13715
|
const why = [err3.stderr, err3.stdout].map((x) => (x ?? "").trim()).filter(Boolean).join(" / ");
|
|
@@ -13391,7 +13717,7 @@ var realExec2 = (cmd, args, opts) => {
|
|
|
13391
13717
|
}
|
|
13392
13718
|
};
|
|
13393
13719
|
var DOCKER_INFO_TIMEOUT_MS = 1e4;
|
|
13394
|
-
function dockerAvailable(exec =
|
|
13720
|
+
function dockerAvailable(exec = realExec) {
|
|
13395
13721
|
try {
|
|
13396
13722
|
exec("docker", ["info"], { timeoutMs: DOCKER_INFO_TIMEOUT_MS });
|
|
13397
13723
|
return true;
|
|
@@ -13403,7 +13729,7 @@ var PASSENGER_IMAGE_REPO = "tablation/crew-passenger-mcp";
|
|
|
13403
13729
|
function passengerImageRef(cfg) {
|
|
13404
13730
|
return process.env.CREW_PASSENGER_IMAGE || cfg.ship.passengerImage || `${PASSENGER_IMAGE_REPO}:${crewVersion(cfg.crewHome)}`;
|
|
13405
13731
|
}
|
|
13406
|
-
function imagePresent(image, exec =
|
|
13732
|
+
function imagePresent(image, exec = realExec) {
|
|
13407
13733
|
try {
|
|
13408
13734
|
exec("docker", ["image", "inspect", image]);
|
|
13409
13735
|
return true;
|
|
@@ -13411,19 +13737,19 @@ function imagePresent(image, exec = realExec2) {
|
|
|
13411
13737
|
return false;
|
|
13412
13738
|
}
|
|
13413
13739
|
}
|
|
13414
|
-
function ensureImage(image, exec =
|
|
13740
|
+
function ensureImage(image, exec = realExec) {
|
|
13415
13741
|
if (!imagePresent(image, exec)) exec("docker", ["pull", image]);
|
|
13416
13742
|
}
|
|
13417
13743
|
function containerNameFor(workspaceId) {
|
|
13418
13744
|
return `crew-passenger-${workspaceId}`;
|
|
13419
13745
|
}
|
|
13420
13746
|
function portFor(workspaceId, base = 28765, span = 1e3) {
|
|
13421
|
-
const digest =
|
|
13747
|
+
const digest = createHash7("sha256").update(workspaceId).digest();
|
|
13422
13748
|
return base + digest.readUInt32BE(0) % span;
|
|
13423
13749
|
}
|
|
13424
13750
|
function mountsDigest(mounts, image) {
|
|
13425
13751
|
const sorted2 = [...mounts].sort((a, b) => a.containerPath.localeCompare(b.containerPath));
|
|
13426
|
-
return
|
|
13752
|
+
return createHash7("sha256").update(JSON.stringify({ mounts: sorted2, image })).digest("hex").slice(0, 16);
|
|
13427
13753
|
}
|
|
13428
13754
|
function planContainers(cfg) {
|
|
13429
13755
|
const byWorkspace = /* @__PURE__ */ new Map();
|
|
@@ -13449,7 +13775,7 @@ function planContainers(cfg) {
|
|
|
13449
13775
|
};
|
|
13450
13776
|
});
|
|
13451
13777
|
}
|
|
13452
|
-
function listPassengerContainers(exec =
|
|
13778
|
+
function listPassengerContainers(exec = realExec) {
|
|
13453
13779
|
const out = exec("docker", ["ps", "-a", "--filter", "name=crew-passenger-", "--format", "{{.Names}} {{.State}}"]);
|
|
13454
13780
|
return out.split("\n").map((l) => l.trim()).filter(Boolean).map((line) => {
|
|
13455
13781
|
const [name, state] = line.split(" ");
|
|
@@ -13465,13 +13791,13 @@ function currentMountsHash(name, exec) {
|
|
|
13465
13791
|
return void 0;
|
|
13466
13792
|
}
|
|
13467
13793
|
}
|
|
13468
|
-
function stopContainer(name, exec =
|
|
13794
|
+
function stopContainer(name, exec = realExec) {
|
|
13469
13795
|
try {
|
|
13470
13796
|
exec("docker", ["rm", "-f", name]);
|
|
13471
13797
|
} catch {
|
|
13472
13798
|
}
|
|
13473
13799
|
}
|
|
13474
|
-
function startContainer(plan, tablationApiBaseUrl, sync, exec =
|
|
13800
|
+
function startContainer(plan, tablationApiBaseUrl, sync, exec = realExec) {
|
|
13475
13801
|
const args = [
|
|
13476
13802
|
"run",
|
|
13477
13803
|
"-d",
|
|
@@ -13504,7 +13830,7 @@ function startContainer(plan, tablationApiBaseUrl, sync, exec = realExec2) {
|
|
|
13504
13830
|
args.push(plan.image);
|
|
13505
13831
|
exec("docker", args);
|
|
13506
13832
|
}
|
|
13507
|
-
function syncPassengerContainers(cfg, tablationApiBaseUrl, exec =
|
|
13833
|
+
function syncPassengerContainers(cfg, tablationApiBaseUrl, exec = realExec, syncEndpoints = /* @__PURE__ */ new Map()) {
|
|
13508
13834
|
const plans = planContainers(cfg);
|
|
13509
13835
|
const plannedByName = new Map(plans.map((p) => [p.containerName, p]));
|
|
13510
13836
|
const existing = listPassengerContainers(exec);
|
|
@@ -13517,403 +13843,110 @@ function syncPassengerContainers(cfg, tablationApiBaseUrl, exec = realExec2, syn
|
|
|
13517
13843
|
if (!ensured.has(plan.image)) {
|
|
13518
13844
|
ensureImage(plan.image, exec);
|
|
13519
13845
|
ensured.add(plan.image);
|
|
13520
|
-
}
|
|
13521
|
-
startContainer(plan, tablationApiBaseUrl, sync, exec);
|
|
13522
|
-
};
|
|
13523
|
-
for (const plan of plans) {
|
|
13524
|
-
const sync = syncEndpoints.get(plan.workspaceId);
|
|
13525
|
-
const current = existingByName.get(plan.containerName);
|
|
13526
|
-
if (!current) {
|
|
13527
|
-
start(plan, sync);
|
|
13528
|
-
started.push(plan.containerName);
|
|
13529
|
-
} else if (!current.running) {
|
|
13530
|
-
stopContainer(plan.containerName, exec);
|
|
13531
|
-
start(plan, sync);
|
|
13532
|
-
started.push(plan.containerName);
|
|
13533
|
-
} else if (currentMountsHash(plan.containerName, exec) !== plan.mountsHash) {
|
|
13534
|
-
stopContainer(plan.containerName, exec);
|
|
13535
|
-
start(plan, sync);
|
|
13536
|
-
recreated.push(plan.containerName);
|
|
13537
|
-
}
|
|
13538
|
-
}
|
|
13539
|
-
for (const { name } of existing) {
|
|
13540
|
-
if (!plannedByName.has(name)) {
|
|
13541
|
-
stopContainer(name, exec);
|
|
13542
|
-
stopped.push(name);
|
|
13543
|
-
}
|
|
13544
|
-
}
|
|
13545
|
-
return { started, recreated, stopped };
|
|
13546
|
-
}
|
|
13547
|
-
function passengerCheckoutSyncSpecs(cfg, workspaceId, onRefused) {
|
|
13548
|
-
const specs = [];
|
|
13549
|
-
for (const route2 of cfg.routes) {
|
|
13550
|
-
if (!route2.enabled || !route2.hostPassengers || !route2.resolved?.workspaceId) continue;
|
|
13551
|
-
if (workspaceId && route2.resolved.workspaceId !== workspaceId) continue;
|
|
13552
|
-
const routeWorkspaceId = route2.resolved.workspaceId;
|
|
13553
|
-
const mirrorArea = passengerMirrorArea(cfg.ship);
|
|
13554
|
-
const cache = mirrorArea ? cacheSettingsOf(cfg.ship.sandbox) : null;
|
|
13555
|
-
const ordinaryByName = new Map(reposOf(route2).map((t) => [t.name, t]));
|
|
13556
|
-
for (const target of passengerCheckoutTargets(route2, mirrorArea)) {
|
|
13557
|
-
const ordinary = ordinaryByName.get(target.name);
|
|
13558
|
-
const override = route2.repoOverrides[target.name];
|
|
13559
|
-
let refused = false;
|
|
13560
|
-
const declared = ordinary ? loadRepoConfigTolerant(ordinary.dir, (e) => {
|
|
13561
|
-
refused = true;
|
|
13562
|
-
onRefused?.(target.name, e);
|
|
13563
|
-
}) : null;
|
|
13564
|
-
if (refused) continue;
|
|
13565
|
-
const effective = resolveRepoConfig(
|
|
13566
|
-
declared,
|
|
13567
|
-
{ branch: { ...route2.branch, ...override?.branch } },
|
|
13568
|
-
ordinary?.dir ?? target.dir
|
|
13569
|
-
);
|
|
13570
|
-
specs.push({
|
|
13571
|
-
name: target.name,
|
|
13572
|
-
workspaceId: routeWorkspaceId,
|
|
13573
|
-
dir: target.dir,
|
|
13574
|
-
remote: target.remote,
|
|
13575
|
-
gitRemoteName: effective.branch.remote,
|
|
13576
|
-
base: effective.branch.base,
|
|
13577
|
-
originUrl: ordinary ? originUrlOf(ordinary.dir, effective.branch.remote) : null,
|
|
13578
|
-
cloneScheme: cfg.ship.cloneScheme,
|
|
13579
|
-
...target.forgeHost ? { forgeHost: target.forgeHost } : {},
|
|
13580
|
-
...cache ? { mirror: { cache } } : {}
|
|
13581
|
-
});
|
|
13582
|
-
}
|
|
13583
|
-
}
|
|
13584
|
-
return specs;
|
|
13585
|
-
}
|
|
13586
|
-
function syncAllPassengerCheckouts(cfg, onRefused) {
|
|
13587
|
-
return passengerCheckoutSyncSpecs(cfg, void 0, onRefused).filter((spec) => !spec.mirror).map((spec) => ({
|
|
13588
|
-
name: spec.name,
|
|
13589
|
-
workspaceId: spec.workspaceId,
|
|
13590
|
-
outcome: syncPassengerCheckout(spec.dir, spec.remote, spec.gitRemoteName, spec.base, { originUrl: spec.originUrl, scheme: spec.cloneScheme, host: spec.forgeHost })
|
|
13591
|
-
}));
|
|
13592
|
-
}
|
|
13593
|
-
|
|
13594
|
-
// src/sandbox-image.ts
|
|
13595
|
-
var SANDBOX_BASE_IMAGE = "nvcr.io/nvidia/base/ubuntu:24.04";
|
|
13596
|
-
var SANDBOX_OPENSHELL_VERSION = "0.1.6";
|
|
13597
|
-
var SANDBOX_CLAUDE_VERSION = "2.1.309";
|
|
13598
|
-
var SANDBOX_CLAUDE_DIST = "https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases";
|
|
13599
|
-
var SANDBOX_CLAUDE_SHA256 = {
|
|
13600
|
-
x86_64: { platform: "linux-x64", sha256: "4d704a8aecbe038affa3000f498ae17c1b4f753add8facb8764120affc99b658" },
|
|
13601
|
-
aarch64: { platform: "linux-arm64", sha256: "9796dd26899337f687739a0b39a7353b639f062a3436a7b941fcf19a1b757a9b" }
|
|
13602
|
-
};
|
|
13603
|
-
var SANDBOX_UID = 1e3;
|
|
13604
|
-
var CREW_PREFIX = "/opt/crew";
|
|
13605
|
-
var SANDBOX_BRIDGE_PATH = `${CREW_PREFIX}/bin/intel-bridge`;
|
|
13606
|
-
function readBridgeBundle() {
|
|
13607
|
-
const here = dirname15(fileURLToPath(import.meta.url));
|
|
13608
|
-
for (const p of [join32(here, "sandbox-intel-bridge.cjs"), join32(here, "..", "dist", "sandbox-intel-bridge.cjs")]) {
|
|
13609
|
-
if (existsSync29(p)) return readFileSync28(p, "utf8");
|
|
13610
|
-
}
|
|
13611
|
-
return void 0;
|
|
13612
|
-
}
|
|
13613
|
-
var SANDBOX_UV_VERSION = "0.13.6";
|
|
13614
|
-
var SANDBOX_SERENA_VERSION = "2.1.0";
|
|
13615
|
-
var SERENA_IMAGE_HOME = `${CREW_PREFIX}/serena`;
|
|
13616
|
-
var SERENA_LANGUAGE_SERVERS_ENV = "CREW_SERENA_LANGUAGE_SERVERS";
|
|
13617
|
-
var SANDBOX_RETRY_AFTER_MS = 60 * 60 * 1e3;
|
|
13618
|
-
var KEEP_TAGS = 2;
|
|
13619
|
-
var CREDENTIAL_HELPER = `#!/bin/sh
|
|
13620
|
-
# git credential helper: answers from the environment the runner passes in, so
|
|
13621
|
-
# no token is ever written into an image layer.
|
|
13622
|
-
[ "$1" = get ] || exit 0
|
|
13623
|
-
[ -n "$CREW_FORGE_TOKEN" ] || exit 0
|
|
13624
|
-
echo "username=\${CREW_FORGE_USER:-x-access-token}"
|
|
13625
|
-
echo "password=$CREW_FORGE_TOKEN"
|
|
13626
|
-
`;
|
|
13627
|
-
var MCP_CONFIG = `${JSON.stringify({ mcpServers: {} }, null, 2)}
|
|
13628
|
-
`;
|
|
13629
|
-
var hash = (parts) => createHash7("sha256").update(JSON.stringify(parts)).digest("hex").slice(0, 12);
|
|
13630
|
-
var slug = (s) => s.toLowerCase().replace(/[^a-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "") || "repo";
|
|
13631
|
-
var run2 = (cmd) => `RUN ["/bin/bash", "-c", ${JSON.stringify(`set -euo pipefail; ${cmd}`)}]`;
|
|
13632
|
-
var CREW_ENV = {
|
|
13633
|
-
CREW_SANDBOX: "1",
|
|
13634
|
-
CREW_CACHE_DIR: `${CREW_PREFIX}/cache`,
|
|
13635
|
-
XDG_CACHE_HOME: `${CREW_PREFIX}/cache`,
|
|
13636
|
-
npm_config_cache: `${CREW_PREFIX}/cache/npm`,
|
|
13637
|
-
npm_config_store_dir: `${CREW_PREFIX}/pnpm-store`,
|
|
13638
|
-
// pnpm 11 ignores npm_config_store_dir and reads only this spelling (CREW-2973): without it `pnpm fetch`
|
|
13639
|
-
// at build time fills the builder's home store, and a run's offline install finds /opt/crew/pnpm-store empty.
|
|
13640
|
-
pnpm_config_store_dir: `${CREW_PREFIX}/pnpm-store`,
|
|
13641
|
-
PNPM_HOME: `${CREW_PREFIX}/pnpm`,
|
|
13642
|
-
// A run cannot reach the download host, so an in-run update attempt is only noise.
|
|
13643
|
-
DISABLE_AUTOUPDATER: "1"
|
|
13644
|
-
};
|
|
13645
|
-
function sandboxEnvExports() {
|
|
13646
|
-
const vars = {
|
|
13647
|
-
...CREW_ENV,
|
|
13648
|
-
[SERENA_LANGUAGE_SERVERS_ENV]: `${SERENA_IMAGE_HOME}/language_servers`,
|
|
13649
|
-
UV_PYTHON_INSTALL_DIR: `${CREW_PREFIX}/uv/python`
|
|
13650
|
-
};
|
|
13651
|
-
return Object.entries(vars).map(([k, v]) => `${k}=${v}; export ${k}; `).join("");
|
|
13652
|
-
}
|
|
13653
|
-
function claudeInstallCommand() {
|
|
13654
|
-
const cases = Object.entries(SANDBOX_CLAUDE_SHA256).map(([arch, { platform: platform2, sha256: sha2562 }]) => `${arch}) p=${platform2}; sum=${sha2562};;`).join(" ");
|
|
13655
|
-
return [
|
|
13656
|
-
`case "$(uname -m)" in ${cases} *) echo "no pinned Claude Code binary for $(uname -m)" >&2; exit 1;; esac`,
|
|
13657
|
-
`mkdir -p ${CREW_PREFIX}/bin`,
|
|
13658
|
-
`curl -fsSL --retry 3 -o ${CREW_PREFIX}/bin/claude "${SANDBOX_CLAUDE_DIST}/${SANDBOX_CLAUDE_VERSION}/$p/claude"`,
|
|
13659
|
-
`echo "$sum ${CREW_PREFIX}/bin/claude" | sha256sum -c -`,
|
|
13660
|
-
`chmod 0755 ${CREW_PREFIX}/bin/claude`,
|
|
13661
|
-
`${CREW_PREFIX}/bin/claude --version | grep -F "${SANDBOX_CLAUDE_VERSION}"`
|
|
13662
|
-
].join("; ");
|
|
13663
|
-
}
|
|
13664
|
-
function serenaInstallCommand() {
|
|
13665
|
-
return [
|
|
13666
|
-
`python3 -m venv ${CREW_PREFIX}/uv-venv`,
|
|
13667
|
-
`${CREW_PREFIX}/uv-venv/bin/pip install --no-cache-dir uv==${SANDBOX_UV_VERSION}`,
|
|
13668
|
-
`ln -sf ${CREW_PREFIX}/uv-venv/bin/uv ${CREW_PREFIX}/bin/uv`,
|
|
13669
|
-
`UV_TOOL_DIR=${CREW_PREFIX}/uv/tools UV_TOOL_BIN_DIR=${CREW_PREFIX}/bin UV_PYTHON_INSTALL_DIR=${CREW_PREFIX}/uv/python UV_CACHE_DIR=${CREW_PREFIX}/cache/uv ${CREW_PREFIX}/bin/uv tool install -p 3.13 serena-agent==${SANDBOX_SERENA_VERSION}`,
|
|
13670
|
-
`${CREW_PREFIX}/bin/serena --help >/dev/null`
|
|
13671
|
-
].join("; ");
|
|
13672
|
-
}
|
|
13673
|
-
function serenaWarmCommand() {
|
|
13674
|
-
return [
|
|
13675
|
-
`mkdir -p ${SERENA_IMAGE_HOME}`,
|
|
13676
|
-
`SERENA_HOME=${SERENA_IMAGE_HOME} serena project index ${WARM_DIR}`
|
|
13677
|
-
].join("; ");
|
|
13678
|
-
}
|
|
13679
|
-
function baseLayer() {
|
|
13680
|
-
const dockerfile = [
|
|
13681
|
-
`FROM ${SANDBOX_BASE_IMAGE}`,
|
|
13682
|
-
`LABEL io.crew.sandbox.layer="base" io.crew.sandbox.openshell="${SANDBOX_OPENSHELL_VERSION}"`,
|
|
13683
|
-
""
|
|
13684
|
-
].join("\n");
|
|
13685
|
-
return { name: "base", tag: `crew-sandbox-base:${hash({ SANDBOX_BASE_IMAGE, SANDBOX_OPENSHELL_VERSION })}`, dockerfile, files: {} };
|
|
13686
|
-
}
|
|
13687
|
-
var APT_HTTPS_COMMAND = "sed -i -E 's#http://([a-z0-9.-]*\\.)?ubuntu\\.com#https://\\1ubuntu.com#g' /etc/apt/sources.list.d/ubuntu.sources 2>/dev/null || true";
|
|
13688
|
-
var CA_BUNDLE_FILE = "ca-certificates.crt";
|
|
13689
|
-
var HOST_CA_BUNDLES = ["/etc/ssl/certs/ca-certificates.crt", "/etc/pki/tls/certs/ca-bundle.crt", "/etc/ssl/cert.pem"];
|
|
13690
|
-
function readHostCaBundle(paths = HOST_CA_BUNDLES) {
|
|
13691
|
-
for (const path of paths) {
|
|
13692
|
-
try {
|
|
13693
|
-
return readFileSync28(path, "utf8");
|
|
13694
|
-
} catch {
|
|
13695
|
-
}
|
|
13696
|
-
}
|
|
13697
|
-
return "";
|
|
13698
|
-
}
|
|
13699
|
-
function crewLayer(base, intel, bridge) {
|
|
13700
|
-
const files = { "credential-helper": CREDENTIAL_HELPER, "mcp.json": MCP_CONFIG, ...bridge ? { "intel-bridge": bridge } : {} };
|
|
13701
|
-
const env = Object.entries(CREW_ENV).map(([k, v]) => `${k}=${v}`).join(" ");
|
|
13702
|
-
const dockerfile = [
|
|
13703
|
-
`FROM ${base.tag}`,
|
|
13704
|
-
"USER root",
|
|
13705
|
-
`COPY ${CA_BUNDLE_FILE} /etc/ssl/certs/ca-certificates.crt`,
|
|
13706
|
-
run2(APT_HTTPS_COMMAND),
|
|
13707
|
-
run2(`apt-get update && apt-get install -y --no-install-recommends ca-certificates curl git${intel ? " python3 python3-venv nodejs" : ""} && rm -rf /var/lib/apt/lists/*`),
|
|
13708
|
-
`COPY credential-helper ${CREW_PREFIX}/bin/credential-helper`,
|
|
13709
|
-
`COPY mcp.json ${CREW_PREFIX}/mcp/mcp.json`,
|
|
13710
|
-
...bridge ? [`COPY intel-bridge ${SANDBOX_BRIDGE_PATH}`] : [],
|
|
13711
|
-
run2(claudeInstallCommand()),
|
|
13712
|
-
...intel ? [run2(`mkdir -p ${CREW_PREFIX}/cache && ${serenaInstallCommand()}`)] : [],
|
|
13713
|
-
run2(`chmod 0755 ${CREW_PREFIX}/bin/credential-helper && git config --system credential.helper ${CREW_PREFIX}/bin/credential-helper`),
|
|
13714
|
-
run2(`mkdir -p ${CREW_PREFIX}/cache ${CREW_PREFIX}/pnpm-store ${CREW_PREFIX}/pnpm /sandbox && chown -R ${SANDBOX_UID}:${SANDBOX_UID} ${CREW_PREFIX} /sandbox`),
|
|
13715
|
-
...intel ? [`ENV ${SERENA_LANGUAGE_SERVERS_ENV}=${SERENA_IMAGE_HOME}/language_servers UV_PYTHON_INSTALL_DIR=${CREW_PREFIX}/uv/python`] : [],
|
|
13716
|
-
`ENV ${env} PATH=${CREW_PREFIX}/pnpm:${CREW_PREFIX}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin`,
|
|
13717
|
-
`LABEL io.crew.sandbox.layer="crew" io.crew.sandbox.claude="${SANDBOX_CLAUDE_VERSION}"`,
|
|
13718
|
-
""
|
|
13719
|
-
].join("\n");
|
|
13720
|
-
return { name: "crew", tag: `crew-sandbox-crew:${hash({ base: base.tag, dockerfile, files })}`, dockerfile, files, caBundleFile: CA_BUNDLE_FILE };
|
|
13721
|
-
}
|
|
13722
|
-
var WARM_DIR = "/tmp/crew-warm";
|
|
13723
|
-
var WARM_MAX_BYTES = 64 * 1024 * 1024;
|
|
13724
|
-
var globToRegExp = (glob) => new RegExp(`^${glob.split("*").map((p) => p.replace(/[.+?^${}()|[\]\\]/g, "\\$&")).join("[^/]*")}$`);
|
|
13725
|
-
function readWarmFiles(dir, ref, patterns) {
|
|
13726
|
-
if (patterns.length === 0) return {};
|
|
13727
|
-
const git2 = (args) => execFileSync9("git", ["-C", dir, ...args], { encoding: "utf8", maxBuffer: WARM_MAX_BYTES, stdio: ["ignore", "pipe", "pipe"] });
|
|
13728
|
-
const all = git2(["ls-tree", "-r", "--name-only", ref]).split("\n").filter(Boolean);
|
|
13729
|
-
const res = patterns.map(globToRegExp);
|
|
13730
|
-
const out = {};
|
|
13731
|
-
let total = 0;
|
|
13732
|
-
for (const path of all.filter((f) => res.some((re) => re.test(f))).sort()) {
|
|
13733
|
-
const content = git2(["show", `${ref}:${path}`]);
|
|
13734
|
-
total += content.length;
|
|
13735
|
-
if (total > WARM_MAX_BYTES) throw new Error(`sandbox.warm files exceed ${WARM_MAX_BYTES} bytes`);
|
|
13736
|
-
out[path] = content;
|
|
13737
|
-
}
|
|
13738
|
-
return out;
|
|
13739
|
-
}
|
|
13740
|
-
function repoLayer(repo, decl, crew, warm) {
|
|
13741
|
-
const env = Object.entries(CREW_ENV).map(([k, v]) => `${k}=${v}`).join(" ");
|
|
13742
|
-
const lines2 = [];
|
|
13743
|
-
if (decl.image) {
|
|
13744
|
-
lines2.push(
|
|
13745
|
-
`FROM ${crew.tag} AS crew`,
|
|
13746
|
-
`FROM ${decl.image}`,
|
|
13747
|
-
"USER root",
|
|
13748
|
-
`COPY --from=crew ${CREW_PREFIX} ${CREW_PREFIX}`,
|
|
13749
|
-
`ENV ${env} PATH=${CREW_PREFIX}/pnpm:${CREW_PREFIX}/bin:$PATH`
|
|
13750
|
-
);
|
|
13751
|
-
} else {
|
|
13752
|
-
lines2.push(`FROM ${crew.tag}`, "USER root");
|
|
13753
|
-
}
|
|
13754
|
-
if (decl.packages.length > 0) {
|
|
13755
|
-
lines2.push(run2(APT_HTTPS_COMMAND));
|
|
13756
|
-
lines2.push(run2(`apt-get update && apt-get install -y --no-install-recommends ${decl.packages.join(" ")} && rm -rf /var/lib/apt/lists/*`));
|
|
13846
|
+
}
|
|
13847
|
+
startContainer(plan, tablationApiBaseUrl, sync, exec);
|
|
13848
|
+
};
|
|
13849
|
+
for (const plan of plans) {
|
|
13850
|
+
const sync = syncEndpoints.get(plan.workspaceId);
|
|
13851
|
+
const current = existingByName.get(plan.containerName);
|
|
13852
|
+
if (!current) {
|
|
13853
|
+
start(plan, sync);
|
|
13854
|
+
started.push(plan.containerName);
|
|
13855
|
+
} else if (!current.running) {
|
|
13856
|
+
stopContainer(plan.containerName, exec);
|
|
13857
|
+
start(plan, sync);
|
|
13858
|
+
started.push(plan.containerName);
|
|
13859
|
+
} else if (currentMountsHash(plan.containerName, exec) !== plan.mountsHash) {
|
|
13860
|
+
stopContainer(plan.containerName, exec);
|
|
13861
|
+
start(plan, sync);
|
|
13862
|
+
recreated.push(plan.containerName);
|
|
13863
|
+
}
|
|
13757
13864
|
}
|
|
13758
|
-
|
|
13759
|
-
|
|
13760
|
-
|
|
13761
|
-
|
|
13762
|
-
|
|
13763
|
-
const files = {};
|
|
13764
|
-
const warming = Object.keys(warm).length > 0;
|
|
13765
|
-
if (warming) {
|
|
13766
|
-
for (const [path, content] of Object.entries(warm)) files[`warm/${path}`] = content;
|
|
13767
|
-
lines2.push(`COPY --chown=${SANDBOX_UID}:${SANDBOX_UID} warm/ ${WARM_DIR}/`, `WORKDIR ${WARM_DIR}`);
|
|
13865
|
+
for (const { name } of existing) {
|
|
13866
|
+
if (!plannedByName.has(name)) {
|
|
13867
|
+
stopContainer(name, exec);
|
|
13868
|
+
stopped.push(name);
|
|
13869
|
+
}
|
|
13768
13870
|
}
|
|
13769
|
-
|
|
13770
|
-
if (warming && decl.intel) lines2.push(run2(serenaWarmCommand()));
|
|
13771
|
-
if (warming) lines2.push("WORKDIR /sandbox", run2(`rm -rf ${WARM_DIR}`));
|
|
13772
|
-
lines2.push(`LABEL io.crew.sandbox.layer="repo" io.crew.sandbox.repo=${JSON.stringify(repo)}`, "");
|
|
13773
|
-
const dockerfile = lines2.join("\n");
|
|
13774
|
-
return { name: "repo", tag: `crew-sandbox/${slug(repo)}:${hash({ crew: crew.tag, dockerfile, files })}`, dockerfile, files };
|
|
13775
|
-
}
|
|
13776
|
-
function planSandbox(repo, decl, warm = {}, bridge) {
|
|
13777
|
-
const base = baseLayer();
|
|
13778
|
-
const crew = crewLayer(base, decl.intel, bridge);
|
|
13779
|
-
const layer = repoLayer(repo, decl, crew, warm);
|
|
13780
|
-
return { repo, tag: layer.tag, claude: SANDBOX_CLAUDE_VERSION, layers: [base, crew, layer] };
|
|
13871
|
+
return { started, recreated, stopped };
|
|
13781
13872
|
}
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13786
|
-
|
|
13787
|
-
const
|
|
13788
|
-
|
|
13789
|
-
|
|
13790
|
-
|
|
13873
|
+
function passengerCheckoutSyncSpecs(cfg, workspaceId, onRefused) {
|
|
13874
|
+
const specs = [];
|
|
13875
|
+
for (const route2 of cfg.routes) {
|
|
13876
|
+
if (!route2.enabled || !route2.hostPassengers || !route2.resolved?.workspaceId) continue;
|
|
13877
|
+
if (workspaceId && route2.resolved.workspaceId !== workspaceId) continue;
|
|
13878
|
+
const routeWorkspaceId = route2.resolved.workspaceId;
|
|
13879
|
+
const mirrorArea = passengerMirrorArea(cfg.ship);
|
|
13880
|
+
const cache = mirrorArea ? cacheSettingsOf(cfg.ship.sandbox) : null;
|
|
13881
|
+
const ordinaryByName = new Map(reposOf(route2).map((t) => [t.name, t]));
|
|
13882
|
+
for (const target of passengerCheckoutTargets(route2, mirrorArea)) {
|
|
13883
|
+
const ordinary = ordinaryByName.get(target.name);
|
|
13884
|
+
const override = route2.repoOverrides[target.name];
|
|
13885
|
+
let refused = false;
|
|
13886
|
+
const declared = ordinary ? loadRepoConfigTolerant(ordinary.dir, (e) => {
|
|
13887
|
+
refused = true;
|
|
13888
|
+
onRefused?.(target.name, e);
|
|
13889
|
+
}) : null;
|
|
13890
|
+
if (refused) continue;
|
|
13891
|
+
const effective = resolveRepoConfig(
|
|
13892
|
+
declared,
|
|
13893
|
+
{ branch: { ...route2.branch, ...override?.branch } },
|
|
13894
|
+
ordinary?.dir ?? target.dir
|
|
13895
|
+
);
|
|
13896
|
+
specs.push({
|
|
13897
|
+
name: target.name,
|
|
13898
|
+
workspaceId: routeWorkspaceId,
|
|
13899
|
+
dir: target.dir,
|
|
13900
|
+
remote: target.remote,
|
|
13901
|
+
gitRemoteName: effective.branch.remote,
|
|
13902
|
+
base: effective.branch.base,
|
|
13903
|
+
originUrl: ordinary ? originUrlOf(ordinary.dir, effective.branch.remote) : null,
|
|
13904
|
+
cloneScheme: cfg.ship.cloneScheme,
|
|
13905
|
+
...target.forgeHost ? { forgeHost: target.forgeHost } : {},
|
|
13906
|
+
...cache ? { mirror: { cache } } : {}
|
|
13907
|
+
});
|
|
13908
|
+
}
|
|
13791
13909
|
}
|
|
13910
|
+
return specs;
|
|
13792
13911
|
}
|
|
13793
|
-
function
|
|
13794
|
-
|
|
13795
|
-
|
|
13796
|
-
|
|
13797
|
-
|
|
13798
|
-
|
|
13799
|
-
}
|
|
13800
|
-
function sandboxImageFor(state, repo) {
|
|
13801
|
-
return state[repo]?.tags[0]?.tag ?? null;
|
|
13802
|
-
}
|
|
13803
|
-
function sandboxImageForRun(state, repo, declares) {
|
|
13804
|
-
return (declares && repo ? sandboxImageFor(state, repo) : null) ?? sandboxImageFor(state, SHIP_SANDBOX_KEY);
|
|
13805
|
-
}
|
|
13806
|
-
function sandboxImageStatus(state, plan) {
|
|
13807
|
-
const s = state[plan.repo];
|
|
13808
|
-
const current = s?.tags[0];
|
|
13809
|
-
if (s?.failure && s.failure.tag === plan.tag) {
|
|
13810
|
-
return { status: "failed", detail: `last build of ${plan.tag} failed at ${s.failure.at}; log ${s.failure.logPath}${current ? `; running ${current.tag}` : ""}` };
|
|
13811
|
-
}
|
|
13812
|
-
if (!current) return { status: "missing", detail: `no image built yet (wants ${plan.tag}); run \`crew sandbox build\`` };
|
|
13813
|
-
if (current.tag !== plan.tag) return { status: "stale", detail: `running ${current.tag} (claude ${current.claude ?? "unknown"}), declaration now builds ${plan.tag} (claude ${plan.claude})` };
|
|
13814
|
-
return { status: "ok", detail: `${current.tag} built ${current.builtAt}, claude ${current.claude ?? "unknown"}` };
|
|
13912
|
+
function syncAllPassengerCheckouts(cfg, onRefused) {
|
|
13913
|
+
return passengerCheckoutSyncSpecs(cfg, void 0, onRefused).filter((spec) => !spec.mirror).map((spec) => ({
|
|
13914
|
+
name: spec.name,
|
|
13915
|
+
workspaceId: spec.workspaceId,
|
|
13916
|
+
outcome: syncPassengerCheckout(spec.dir, spec.remote, spec.gitRemoteName, spec.base, { originUrl: spec.originUrl, scheme: spec.cloneScheme, host: spec.forgeHost })
|
|
13917
|
+
}));
|
|
13815
13918
|
}
|
|
13816
|
-
|
|
13817
|
-
|
|
13818
|
-
|
|
13819
|
-
child.stdout.on("data", (d) => chunks.push(d));
|
|
13820
|
-
child.stderr.on("data", (d) => chunks.push(d));
|
|
13821
|
-
const done = (code, extra = "") => {
|
|
13822
|
-
writeFileSync20(logPath, `$ ${engine} ${args.join(" ")}
|
|
13823
|
-
${Buffer.concat(chunks).toString("utf8")}${extra}`, { flag: "a" });
|
|
13824
|
-
resolve8(code);
|
|
13825
|
-
};
|
|
13826
|
-
child.on("error", (e) => done(127, `${e.message}
|
|
13827
|
-
`));
|
|
13828
|
-
child.on("close", (code) => done(code ?? 1));
|
|
13829
|
-
});
|
|
13830
|
-
var engineHasImage = (engine = "docker", exec = realExec2) => (tag) => {
|
|
13919
|
+
|
|
13920
|
+
// src/sandbox-hooks.ts
|
|
13921
|
+
var imageHasBinary = (engine = "docker", exec = realExec) => (image, bin) => {
|
|
13831
13922
|
try {
|
|
13832
|
-
exec(engine, ["
|
|
13923
|
+
exec(engine, ["run", "--rm", "--entrypoint", "sh", image, "-c", `command -v ${bin}`], { timeoutMs: 6e4 });
|
|
13833
13924
|
return true;
|
|
13834
13925
|
} catch {
|
|
13835
13926
|
return false;
|
|
13836
13927
|
}
|
|
13837
13928
|
};
|
|
13838
|
-
|
|
13839
|
-
|
|
13840
|
-
|
|
13841
|
-
|
|
13842
|
-
|
|
13843
|
-
|
|
13844
|
-
var sandboxLogDir = (stateDir) => join32(stateDir, "sandbox-logs");
|
|
13845
|
-
async function buildSandboxImage(plan, deps) {
|
|
13846
|
-
const now = deps.now ?? (() => /* @__PURE__ */ new Date());
|
|
13847
|
-
const state = readSandboxState(deps.stateDir);
|
|
13848
|
-
const entry = state[plan.repo] ?? { tags: [] };
|
|
13849
|
-
if (entry.tags[0]?.tag === plan.tag && deps.hasImage(plan.tag)) {
|
|
13850
|
-
return { kind: "reused", tag: plan.tag };
|
|
13851
|
-
}
|
|
13852
|
-
const logDir = sandboxLogDir(deps.stateDir);
|
|
13853
|
-
mkdirSync19(logDir, { recursive: true });
|
|
13854
|
-
const logPath = join32(logDir, `${slug(plan.repo)}-${now().toISOString().replace(/[:.]/g, "-")}.log`);
|
|
13855
|
-
const builtLayers = [];
|
|
13856
|
-
for (const layer of plan.layers) {
|
|
13857
|
-
if (deps.hasImage(layer.tag)) continue;
|
|
13858
|
-
const ctx = join32(tmpdir3(), `crew-sandbox-${hash([layer.tag, process.pid, Date.now()])}`);
|
|
13859
|
-
mkdirSync19(ctx, { recursive: true });
|
|
13860
|
-
try {
|
|
13861
|
-
writeFileSync20(join32(ctx, "Dockerfile"), layer.dockerfile);
|
|
13862
|
-
for (const [name, content] of Object.entries(layer.files)) {
|
|
13863
|
-
mkdirSync19(dirname15(join32(ctx, name)), { recursive: true });
|
|
13864
|
-
writeFileSync20(join32(ctx, name), content);
|
|
13865
|
-
}
|
|
13866
|
-
if (layer.caBundleFile) writeFileSync20(join32(ctx, layer.caBundleFile), (deps.caBundle ?? readHostCaBundle)());
|
|
13867
|
-
const code = await deps.run(["build", "--tag", layer.tag, "--file", join32(ctx, "Dockerfile"), ctx], logPath);
|
|
13868
|
-
if (code !== 0) {
|
|
13869
|
-
state[plan.repo] = { ...entry, failure: { tag: plan.tag, at: now().toISOString(), logPath } };
|
|
13870
|
-
writeSandboxState(deps.stateDir, state);
|
|
13871
|
-
return { kind: "failed", tag: plan.tag, logPath, layer: layer.name };
|
|
13872
|
-
}
|
|
13873
|
-
builtLayers.push(layer.name);
|
|
13874
|
-
} finally {
|
|
13875
|
-
rmSync15(ctx, { recursive: true, force: true });
|
|
13876
|
-
}
|
|
13877
|
-
}
|
|
13878
|
-
const tags = [{ tag: plan.tag, builtAt: now().toISOString(), claude: plan.claude }, ...entry.tags.filter((t) => t.tag !== plan.tag)];
|
|
13879
|
-
const dropped = tags.slice(KEEP_TAGS);
|
|
13880
|
-
state[plan.repo] = { tags: tags.slice(0, KEEP_TAGS) };
|
|
13881
|
-
writeSandboxState(deps.stateDir, state);
|
|
13882
|
-
for (const t of dropped) deps.removeImage(t.tag);
|
|
13883
|
-
return { kind: "built", tag: plan.tag, builtLayers };
|
|
13884
|
-
}
|
|
13885
|
-
var sandboxFailedKey = (repo) => `sandbox_build_failed:${repo}`;
|
|
13886
|
-
function sandboxFailedItem(repo, tag, layer, logPath, nowIso = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
13887
|
-
return {
|
|
13888
|
-
kind: "sandbox_build_failed",
|
|
13889
|
-
key: sandboxFailedKey(repo),
|
|
13890
|
-
since: nowIso,
|
|
13891
|
-
message: `${repo}: sandbox image ${tag} failed to build at the ${layer} layer (log: ${logPath}); sandboxes keep running the previous image. Retries automatically after the declaration changes or in an hour; \`crew sandbox build\` forces it`
|
|
13929
|
+
function sandboxHookGaps(o) {
|
|
13930
|
+
if (!o.image) return [];
|
|
13931
|
+
const seen = /* @__PURE__ */ new Map();
|
|
13932
|
+
const has = (bin) => {
|
|
13933
|
+
if (!seen.has(bin)) seen.set(bin, o.hasBinary(o.image, bin));
|
|
13934
|
+
return seen.get(bin);
|
|
13892
13935
|
};
|
|
13893
|
-
|
|
13894
|
-
|
|
13895
|
-
|
|
13896
|
-
|
|
13897
|
-
|
|
13898
|
-
const
|
|
13899
|
-
|
|
13900
|
-
|
|
13901
|
-
|
|
13902
|
-
|
|
13903
|
-
|
|
13904
|
-
|
|
13905
|
-
deps.log(`sandbox image for ${r.name}: building ${plan.tag}`);
|
|
13906
|
-
const out = await buildSandboxImage(plan, deps);
|
|
13907
|
-
if (out.kind === "failed") {
|
|
13908
|
-
deps.raise(sandboxFailedItem(r.name, out.tag, out.layer, out.logPath));
|
|
13909
|
-
deps.log(`sandbox image for ${r.name}: build failed at the ${out.layer} layer, log ${out.logPath}`);
|
|
13910
|
-
} else {
|
|
13911
|
-
deps.clear(sandboxFailedKey(r.name));
|
|
13912
|
-
deps.log(`sandbox image for ${r.name}: ${out.kind === "built" ? `built ${out.tag}` : `${out.tag} already built`}`);
|
|
13913
|
-
}
|
|
13914
|
-
return r.name;
|
|
13936
|
+
const gaps = [];
|
|
13937
|
+
for (const hook2 of ["setup", "test", "build", "deploy"]) {
|
|
13938
|
+
const script = o.hooks[hook2];
|
|
13939
|
+
const command2 = script ? hookCommand(script) : null;
|
|
13940
|
+
if (!command2 || has(command2)) continue;
|
|
13941
|
+
const remedy = o.declares ? `add the package that provides \`${command2}\` to sandbox.packages or sandbox.setup in ${o.repo}'s .crew.yaml, then \`crew sandbox build ${o.repo}\`` : `${o.repo} declares no sandbox: section, so it runs in the ship's crew image; add a sandbox: section to its .crew.yaml providing \`${command2}\``;
|
|
13942
|
+
gaps.push({
|
|
13943
|
+
hook: hook2,
|
|
13944
|
+
command: command2,
|
|
13945
|
+
remedy,
|
|
13946
|
+
message: `${o.route}/${o.repo}: the ${hook2} hook runs \`${command2}\`, which is not in its sandbox image ${o.image} \u2014 ${remedy}`
|
|
13947
|
+
});
|
|
13915
13948
|
}
|
|
13916
|
-
return
|
|
13949
|
+
return gaps;
|
|
13917
13950
|
}
|
|
13918
13951
|
|
|
13919
13952
|
// src/doctor-checks.ts
|
|
@@ -18208,6 +18241,91 @@ function flagWizardAnswers(f, env) {
|
|
|
18208
18241
|
};
|
|
18209
18242
|
}
|
|
18210
18243
|
|
|
18244
|
+
// src/diagnostics.ts
|
|
18245
|
+
import { execFile as execFile3 } from "child_process";
|
|
18246
|
+
var BUNDLE_BUDGET_MS = 3e4;
|
|
18247
|
+
var JOURNAL_LINES = 200;
|
|
18248
|
+
var MAX_SECTION_BYTES = 256 * 1024;
|
|
18249
|
+
var REDACTED = "[redacted]";
|
|
18250
|
+
var SENSITIVE_KEY_RE = /token|key|secret|password|authorization/i;
|
|
18251
|
+
var SK_RE = /\bsk_[A-Za-z0-9_-]{4,}/g;
|
|
18252
|
+
var BEARER_RE = /\b(bearer)\s+[A-Za-z0-9._~+/=-]{4,}/gi;
|
|
18253
|
+
var AUTH_HEADER_RE = /\b(authorization)(["']?\s*[:=]\s*["']?)[^\s"',}]+(?:\s+[^\s"',}]+)?/gi;
|
|
18254
|
+
var KV_RE = /\b([A-Za-z0-9_.-]*(?:token|key|secret|password)[A-Za-z0-9_.-]*)(["']?\s*[:=]\s*["']?)[^\s"',}&]+/gi;
|
|
18255
|
+
function redactText(s) {
|
|
18256
|
+
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}`);
|
|
18257
|
+
}
|
|
18258
|
+
function redactValue(v) {
|
|
18259
|
+
if (typeof v === "string") return redactText(v);
|
|
18260
|
+
if (Array.isArray(v)) return v.map(redactValue);
|
|
18261
|
+
if (v && typeof v === "object") {
|
|
18262
|
+
return Object.fromEntries(Object.entries(v).map(([k, x]) => [
|
|
18263
|
+
k,
|
|
18264
|
+
SENSITIVE_KEY_RE.test(k) && x !== null && x !== void 0 && x !== "" ? REDACTED : redactValue(x)
|
|
18265
|
+
]));
|
|
18266
|
+
}
|
|
18267
|
+
return v;
|
|
18268
|
+
}
|
|
18269
|
+
var defaultExec = (bin, args, timeoutMs) => new Promise((resolve8, reject) => {
|
|
18270
|
+
execFile3(bin, args, { timeout: timeoutMs, maxBuffer: 4 * 1024 * 1024 }, (e, stdout) => {
|
|
18271
|
+
if (e && e.code === "ENOENT") return reject(new Error(`${bin} is not installed`));
|
|
18272
|
+
if (e && e.killed) return reject(new Error(`${bin} timed out`));
|
|
18273
|
+
resolve8({ stdout: String(stdout), code: typeof e?.code === "number" ? e.code : 0 });
|
|
18274
|
+
});
|
|
18275
|
+
});
|
|
18276
|
+
var clip = (s) => s.length > MAX_SECTION_BYTES ? `${s.slice(0, MAX_SECTION_BYTES)}
|
|
18277
|
+
[truncated]` : s;
|
|
18278
|
+
async function collectDiagnostics(d) {
|
|
18279
|
+
const exec = d.exec ?? defaultExec;
|
|
18280
|
+
const budget = d.budgetMs ?? BUNDLE_BUDGET_MS;
|
|
18281
|
+
const now = d.now ?? Date.now;
|
|
18282
|
+
const started = now();
|
|
18283
|
+
const left = () => Math.max(1, budget - (now() - started));
|
|
18284
|
+
const ctl = d.userScope ? ["systemctl", "--user"] : ["systemctl"];
|
|
18285
|
+
const jctl = d.userScope ? ["--user"] : [];
|
|
18286
|
+
const units = d.unitStems.flatMap((s) => [`${s}.service`, `${s}.timer`]);
|
|
18287
|
+
const sections = {
|
|
18288
|
+
doctor: async () => {
|
|
18289
|
+
const doc = await d.doctor();
|
|
18290
|
+
if (!doc) throw new Error("could not produce the doctor report");
|
|
18291
|
+
return doc;
|
|
18292
|
+
},
|
|
18293
|
+
units: async () => {
|
|
18294
|
+
if (!units.length) throw new Error("no systemd units on this host");
|
|
18295
|
+
const out = {};
|
|
18296
|
+
for (const u of units) {
|
|
18297
|
+
const r = await exec(ctl[0], [...ctl.slice(1), "show", u, "--no-pager", "--property=LoadState,ActiveState,SubState,Result,ExecMainStatus,ActiveEnterTimestamp"], left());
|
|
18298
|
+
out[u] = Object.fromEntries(r.stdout.split("\n").filter((l) => l.includes("=")).map((l) => [l.slice(0, l.indexOf("=")), l.slice(l.indexOf("=") + 1)]));
|
|
18299
|
+
}
|
|
18300
|
+
return out;
|
|
18301
|
+
},
|
|
18302
|
+
journal: async () => {
|
|
18303
|
+
if (!units.length) throw new Error("no systemd units on this host");
|
|
18304
|
+
const r = await exec("journalctl", [...jctl, ...units.flatMap((u) => ["-u", u]), "-n", String(JOURNAL_LINES), "--no-pager", "-o", "short-iso"], left());
|
|
18305
|
+
return { lines: clip(r.stdout).split("\n").filter((l) => l.length) };
|
|
18306
|
+
},
|
|
18307
|
+
tunnel: async () => Object.fromEntries(d.workspaceIds.map((w) => [w, readPersistedTunnel(d.stateDir, w) ?? null])),
|
|
18308
|
+
sandbox: async () => {
|
|
18309
|
+
if (d.runner !== "sandbox") return { runner: d.runner };
|
|
18310
|
+
const r = await exec("openshell", ["sandbox", "list"], left());
|
|
18311
|
+
return { runner: d.runner, list: clip(r.stdout).split("\n").filter((l) => l.length), exitCode: r.code };
|
|
18312
|
+
}
|
|
18313
|
+
};
|
|
18314
|
+
const deadline = new Promise((resolve8) => {
|
|
18315
|
+
setTimeout(() => resolve8("timeout"), budget).unref();
|
|
18316
|
+
});
|
|
18317
|
+
const entries = await Promise.all(Object.entries(sections).map(async ([name, run3]) => {
|
|
18318
|
+
try {
|
|
18319
|
+
const out = await Promise.race([run3(), deadline]);
|
|
18320
|
+
if (out === "timeout") return [name, { ok: false, error: `timed out after ${Math.round(budget / 1e3)}s` }];
|
|
18321
|
+
return [name, { ok: true, data: redactValue(out) }];
|
|
18322
|
+
} catch (e) {
|
|
18323
|
+
return [name, { ok: false, error: redactText(e.message) }];
|
|
18324
|
+
}
|
|
18325
|
+
}));
|
|
18326
|
+
return { collectedAt: new Date(started).toISOString(), budgetMs: budget, sections: Object.fromEntries(entries) };
|
|
18327
|
+
}
|
|
18328
|
+
|
|
18211
18329
|
// src/release-run.ts
|
|
18212
18330
|
import { readFileSync as readFileSync37, writeFileSync as writeFileSync31, existsSync as existsSync38, copyFileSync, mkdirSync as mkdirSync28, mkdtempSync as mkdtempSync3, rmSync as rmSync19 } from "fs";
|
|
18213
18331
|
import { dirname as dirname24, join as join43 } from "path";
|
|
@@ -20054,13 +20172,25 @@ function firstReport(key) {
|
|
|
20054
20172
|
reported.add(key);
|
|
20055
20173
|
return true;
|
|
20056
20174
|
}
|
|
20175
|
+
function judgeServable(o) {
|
|
20176
|
+
if (o.platforms.some(o.satisfied)) return true;
|
|
20177
|
+
return o.tolerateUnmirrored && o.unreadable.some((n) => o.unmirrored.has(n));
|
|
20178
|
+
}
|
|
20179
|
+
function explainRefusal(readable, unreadable) {
|
|
20180
|
+
const parts = [
|
|
20181
|
+
...readable.map((r) => `${r.name} requires ${r.platform}`),
|
|
20182
|
+
...unreadable.map((e) => `${e.repo}'s contract could not be read (${e.detail.split("\n")[0]})`)
|
|
20183
|
+
];
|
|
20184
|
+
if (readable.length === 0) parts.unshift("no repository contract could be read");
|
|
20185
|
+
return parts.join(", ");
|
|
20186
|
+
}
|
|
20057
20187
|
|
|
20058
20188
|
// src/release-sandbox.ts
|
|
20059
|
-
import { execFile as
|
|
20189
|
+
import { execFile as execFile4 } from "child_process";
|
|
20060
20190
|
import { mkdirSync as mkdirSync30, writeFileSync as writeFileSync32 } from "fs";
|
|
20061
20191
|
import { dirname as dirname26 } from "path";
|
|
20062
20192
|
import { promisify as promisify3 } from "util";
|
|
20063
|
-
var execFileP3 = promisify3(
|
|
20193
|
+
var execFileP3 = promisify3(execFile4);
|
|
20064
20194
|
var RELEASE_CLONE_DEPTH = 50;
|
|
20065
20195
|
var FORGE_TOKEN_VAR = "CREW_FORGE_TOKEN";
|
|
20066
20196
|
var FORGE_USER_VAR = "CREW_FORGE_USER";
|
|
@@ -24651,7 +24781,7 @@ import {
|
|
|
24651
24781
|
import { createConnection } from "net";
|
|
24652
24782
|
import { createServer as createServer2 } from "http";
|
|
24653
24783
|
import { basename as basename14, dirname as dirname33, join as join53 } from "path";
|
|
24654
|
-
import { execFile as
|
|
24784
|
+
import { execFile as execFile5, spawn as spawn12 } from "child_process";
|
|
24655
24785
|
|
|
24656
24786
|
// src/periscope-control.ts
|
|
24657
24787
|
import { spawn as spawn11 } from "child_process";
|
|
@@ -25192,7 +25322,8 @@ async function route(deps, method, url, req, abort) {
|
|
|
25192
25322
|
const doc = await deps.doctor();
|
|
25193
25323
|
return doc ? reply2(200, doc) : err2(502, "could not produce the doctor report");
|
|
25194
25324
|
}
|
|
25195
|
-
|
|
25325
|
+
if (p === "/diagnostics" && get2 && deps.diagnostics) return reply2(200, await deps.diagnostics());
|
|
25326
|
+
const known = ["/status", "/events", "/streams", "/pause", "/resume", "/release/pause", "/release/resume", "/doctor", ...deps.diagnostics ? ["/diagnostics"] : []];
|
|
25196
25327
|
if (known.includes(p) || p.startsWith("/streams/") || sched) return err2(405, "method not allowed");
|
|
25197
25328
|
return err2(404, "not found");
|
|
25198
25329
|
}
|
|
@@ -25303,7 +25434,7 @@ function schedulerHandler(control, run3 = runDetached) {
|
|
|
25303
25434
|
}
|
|
25304
25435
|
function crewJson(args, timeoutMs = 6e4) {
|
|
25305
25436
|
return new Promise((resolve8) => {
|
|
25306
|
-
|
|
25437
|
+
execFile5(process.execPath, [process.argv[1] ?? "", ...args], { timeout: timeoutMs, maxBuffer: 16 * 1024 * 1024 }, (_e, stdout) => {
|
|
25307
25438
|
try {
|
|
25308
25439
|
const v = JSON.parse(String(stdout));
|
|
25309
25440
|
resolve8(v && typeof v === "object" && !Array.isArray(v) ? v : null);
|
|
@@ -25910,7 +26041,7 @@ function usage(problem, requested = false) {
|
|
|
25910
26041
|
crew shell-init [--shell zsh|bash|fish] print the periscope shell function (install: eval "$(crew shell-init)")
|
|
25911
26042
|
crew worktree [route] NNN cut (or refresh) this run's worktree for a ticket from the remote; prints its path
|
|
25912
26043
|
crew unassign [route] NNN hand back a session's ticket \u2014 clears assignee, next cycle picks it up
|
|
25913
|
-
crew sandbox cache [--prune|--reset] [--json] list the sandbox cache volume's mirrors; --prune drops unserved repositories, --reset recreates the volume
|
|
26044
|
+
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
|
|
25914
26045
|
crew sync [route] fast-forward the checkout and its worktrees from the remote
|
|
25915
26046
|
crew pause|resume [route] [R|release] pause everything, one role, or releases only (merge/deploy/release; passengers keeps running).
|
|
25916
26047
|
resume with no argument clears only the whole-crew pause; a role or release pause needs its own resume
|
|
@@ -26792,6 +26923,9 @@ ${changed2.map((c) => ` - ${c}
|
|
|
26792
26923
|
`).join("")}` : "fix: nothing changed\n");
|
|
26793
26924
|
}
|
|
26794
26925
|
async function resolvedRepos(c) {
|
|
26926
|
+
return (await resolveRoute(c)).settled;
|
|
26927
|
+
}
|
|
26928
|
+
async function resolveRoute(c) {
|
|
26795
26929
|
const { settled, errors } = await settleRepos(reposOf(c), (t) => t.name, (t) => resolveOneRepo(c, t));
|
|
26796
26930
|
for (const e of errors) {
|
|
26797
26931
|
try {
|
|
@@ -26801,7 +26935,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
26801
26935
|
}
|
|
26802
26936
|
const refused = new Set(errors.map((e) => e.repo));
|
|
26803
26937
|
for (const t of reposOf(c)) if (!refused.has(t.name)) clearShipAttention(state, repoContractRefusedKey(t.name));
|
|
26804
|
-
return settled;
|
|
26938
|
+
return { settled, errors };
|
|
26805
26939
|
}
|
|
26806
26940
|
async function sandboxReposOf(routes) {
|
|
26807
26941
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -26857,11 +26991,35 @@ ${changed2.map((c) => ` - ${c}
|
|
|
26857
26991
|
parent: resolvePath(r.dir, ".."),
|
|
26858
26992
|
prefix: r.config.worktrees.prefix
|
|
26859
26993
|
}));
|
|
26860
|
-
async function anyRepoServable(c) {
|
|
26861
|
-
|
|
26994
|
+
async function anyRepoServable(c, tolerateUnmirrored = false) {
|
|
26995
|
+
const { settled, errors } = await resolveRoute(c);
|
|
26996
|
+
return judgeServable({
|
|
26997
|
+
platforms: settled.map((r) => r.config.platform),
|
|
26998
|
+
satisfied: (p) => satisfies(cfg.ship.platform, p),
|
|
26999
|
+
unreadable: errors.map((e) => e.repo),
|
|
27000
|
+
tolerateUnmirrored,
|
|
27001
|
+
unmirrored: tolerateUnmirrored && errors.length > 0 ? await unmirroredTargets(c) : /* @__PURE__ */ new Set()
|
|
27002
|
+
});
|
|
27003
|
+
}
|
|
27004
|
+
async function unmirroredTargets(c) {
|
|
27005
|
+
const settings = cfg.ship.runner === "sandbox" ? cacheSettingsOf(cfg.ship.sandbox) : null;
|
|
27006
|
+
if (!settings) return /* @__PURE__ */ new Set();
|
|
27007
|
+
try {
|
|
27008
|
+
const have = new Set((await new SandboxCache(settings).list()).map((m) => `${m.repo.host}/${m.repo.path}`));
|
|
27009
|
+
const out = /* @__PURE__ */ new Set();
|
|
27010
|
+
for (const t of reposOf(c)) {
|
|
27011
|
+
if (!lacksCheckout(cfg.ship, t.dir)) continue;
|
|
27012
|
+
const m = mirrorRepoOfTarget(t);
|
|
27013
|
+
if (m && !have.has(`${m.host}/${m.path}`)) out.add(t.name);
|
|
27014
|
+
}
|
|
27015
|
+
return out;
|
|
27016
|
+
} catch {
|
|
27017
|
+
return /* @__PURE__ */ new Set();
|
|
27018
|
+
}
|
|
26862
27019
|
}
|
|
26863
27020
|
async function explainUnservable(c) {
|
|
26864
|
-
|
|
27021
|
+
const { settled, errors } = await resolveRoute(c);
|
|
27022
|
+
return explainRefusal(settled.map((r) => ({ name: r.name, platform: String(r.config.platform) })), errors);
|
|
26865
27023
|
}
|
|
26866
27024
|
async function environmentFor(c, ticket) {
|
|
26867
27025
|
const tracker = new Tracker(c, cfg.ship);
|
|
@@ -28040,13 +28198,22 @@ ${cu.tail.trimEnd()}
|
|
|
28040
28198
|
process.stderr.write("crew: daemon does not support --dry-run \u2014 it only ever performs real cycles.\n");
|
|
28041
28199
|
process.exit(2);
|
|
28042
28200
|
}
|
|
28043
|
-
|
|
28201
|
+
requireArmed("run the daemon loop");
|
|
28202
|
+
const sandboxCachePass = cfg.ship.runner === "sandbox" ? buildSandboxCachePass(route2, cfg.ship, state, emit) : void 0;
|
|
28203
|
+
if (sandboxCachePass && (await unmirroredTargets(route2)).size > 0) {
|
|
28204
|
+
emit.emit("sandbox cache: some served repositories have no mirror yet; refreshing before reading their contracts");
|
|
28205
|
+
try {
|
|
28206
|
+
await sandboxCachePass();
|
|
28207
|
+
} catch (e) {
|
|
28208
|
+
emit.warn(`sandbox cache refresh failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
28209
|
+
}
|
|
28210
|
+
}
|
|
28211
|
+
if (!await anyRepoServable(route2, true)) {
|
|
28044
28212
|
emit.error(
|
|
28045
28213
|
`refusing this route \u2014 this ship is ${cfg.ship.platform}, but ${await explainUnservable(route2)}`
|
|
28046
28214
|
);
|
|
28047
28215
|
process.exit(1);
|
|
28048
28216
|
}
|
|
28049
|
-
requireArmed("run the daemon loop");
|
|
28050
28217
|
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join56(CREW_HOME, "src"), join56(CREW_HOME, "dist"), join56(CREW_HOME, "bin")];
|
|
28051
28218
|
const configPaths = daemonConfigPaths(cfg);
|
|
28052
28219
|
watchPaths.push(...configPaths);
|
|
@@ -28108,12 +28275,19 @@ ${cu.tail.trimEnd()}
|
|
|
28108
28275
|
periscopeMcp: controlRoutes.some((r) => r.enabled && r.hostPeriscopes) ? (req, res, ticket) => handlePeriscopeMcp(periscopeMcpDeps(), req, res, ticket) : void 0,
|
|
28109
28276
|
status: () => crewJson(["status", route2.route, "--json"]),
|
|
28110
28277
|
doctor: () => crewJson(["doctor", route2.route, "--json", "--offline"]),
|
|
28278
|
+
diagnostics: () => collectDiagnostics({
|
|
28279
|
+
stateDir: cfg.ship.stateDir,
|
|
28280
|
+
workspaceIds: [...new Set(controlRoutes.map((r) => r.resolved.workspaceId))],
|
|
28281
|
+
runner: cfg.ship.runner ?? "host",
|
|
28282
|
+
unitStems: detectSystemd() ? ["run", "release", "passengers"].map((j) => labelFor(CREW_HOME, j)) : [],
|
|
28283
|
+
userScope: process.getuid?.() !== 0,
|
|
28284
|
+
doctor: () => crewJson(["doctor", route2.route, "--json", "--offline"])
|
|
28285
|
+
}),
|
|
28111
28286
|
scheduler: schedulerHandler(planDaemonControl(CREW_HOME, hostPlatform(), detectSystemd())),
|
|
28112
28287
|
log: (m) => emit.warn(m)
|
|
28113
28288
|
});
|
|
28114
28289
|
if (controlServer) emit.emit(`control API listening on ${controlServer.path}`);
|
|
28115
28290
|
const inFlight = /* @__PURE__ */ new Set();
|
|
28116
|
-
const sandboxCachePass = cfg.ship.runner === "sandbox" ? buildSandboxCachePass(route2, cfg.ship, state, emit) : void 0;
|
|
28117
28291
|
let sandboxBuilding = false;
|
|
28118
28292
|
const stopReason = await runDaemonLoop({
|
|
28119
28293
|
inFlight,
|
|
@@ -29762,6 +29936,17 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
29762
29936
|
`);
|
|
29763
29937
|
break;
|
|
29764
29938
|
}
|
|
29939
|
+
let refreshFailed = false;
|
|
29940
|
+
if (flag("refresh")) {
|
|
29941
|
+
for (const r of cfg.routes) {
|
|
29942
|
+
const pass = buildSandboxCachePass(r, cfg.ship, state, emit);
|
|
29943
|
+
for (const out of await pass?.() ?? []) {
|
|
29944
|
+
if (!out.ok) refreshFailed = true;
|
|
29945
|
+
process.stdout.write(`${out.ok ? "refreshed" : "FAILED "} ${out.repo.host}/${out.repo.path}${out.ok ? "" : ` (${out.detail})`}
|
|
29946
|
+
`);
|
|
29947
|
+
}
|
|
29948
|
+
}
|
|
29949
|
+
}
|
|
29765
29950
|
const dropped = flag("prune") ? await cache.prune(served) : [];
|
|
29766
29951
|
const mirrors = await cache.list();
|
|
29767
29952
|
const open = openShipAttention(new State(cfg.ship.stateDir));
|
|
@@ -29784,6 +29969,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
29784
29969
|
for (const f of failures) process.stdout.write(`${f.repo} REFRESH FAILING (last failed ${f.lastFailedAt}): ${f.message}
|
|
29785
29970
|
`);
|
|
29786
29971
|
}
|
|
29972
|
+
if (refreshFailed) process.exitCode = 1;
|
|
29787
29973
|
} catch (e) {
|
|
29788
29974
|
process.stderr.write(`crew sandbox cache: ${e instanceof Error ? e.message : String(e)}
|
|
29789
29975
|
`);
|
|
@@ -29796,7 +29982,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
29796
29982
|
"crew sandbox policy --route ROUTE --role ROLE [--repo NAME] [--json]",
|
|
29797
29983
|
"crew sandbox build [REPO] [--route ROUTE] [--json]",
|
|
29798
29984
|
"crew sandbox images [--route ROUTE] [--json]",
|
|
29799
|
-
"crew sandbox cache [--prune|--reset] [--json]",
|
|
29985
|
+
"crew sandbox cache [--refresh|--prune|--reset] [--json]",
|
|
29800
29986
|
""
|
|
29801
29987
|
].join("\n"));
|
|
29802
29988
|
process.exit(2);
|
|
@@ -31318,6 +31504,15 @@ watermark: ${state.watermark()}
|
|
|
31318
31504
|
base: doctorBaseReport(r, r.config.branch.base, baseHealth),
|
|
31319
31505
|
hooks: r.config.hooks,
|
|
31320
31506
|
onPath: (cmd) => !!findOnPath(cmd, doctorSchedulerPath),
|
|
31507
|
+
// CREW-3007: on a sandbox ship the hooks run in the image, so the host PATH is not asked.
|
|
31508
|
+
sandboxGaps: cfg.ship.runner === "sandbox" ? sandboxHookGaps({
|
|
31509
|
+
route: c.route,
|
|
31510
|
+
repo: r.name,
|
|
31511
|
+
hooks: r.config.hooks,
|
|
31512
|
+
declares: Boolean(r.config.sandbox),
|
|
31513
|
+
image: sandboxImageForRun(readSandboxState(cfg.ship.stateDir), r.name, Boolean(r.config.sandbox)),
|
|
31514
|
+
hasBinary: imageHasBinary()
|
|
31515
|
+
}) : void 0,
|
|
31321
31516
|
mapFile: mapFilePath(r.config.hooks.map) ? inspectMapFile(r.dir, mapFilePath(r.config.hooks.map)) : void 0,
|
|
31322
31517
|
intelSyntax: r.config.hooks.intel && !intelFlavor(r.config.hooks.intel) ? checkHookSyntax(r.config.hooks.intel, r.config.shell) : void 0,
|
|
31323
31518
|
intelFlavor: intelFlavor(r.config.hooks.intel) ? { name: intelFlavor(r.config.hooks.intel), missing: [
|
|
@@ -31793,11 +31988,30 @@ crew manifest: ${seats2.length ? seats2.map((c) => c.name).join(", ") : "non
|
|
|
31793
31988
|
continue;
|
|
31794
31989
|
}
|
|
31795
31990
|
for (const r of repos) {
|
|
31991
|
+
const gaps = cfg.ship.runner === "sandbox" ? sandboxHookGaps({
|
|
31992
|
+
route: c.route,
|
|
31993
|
+
repo: r.name,
|
|
31994
|
+
hooks: r.config.hooks,
|
|
31995
|
+
declares: Boolean(r.config.sandbox),
|
|
31996
|
+
image: sandboxImageForRun(readSandboxState(cfg.ship.stateDir), r.name, Boolean(r.config.sandbox)),
|
|
31997
|
+
hasBinary: imageHasBinary()
|
|
31998
|
+
}) : [];
|
|
31796
31999
|
for (const name of ["setup", "test", "build", "deploy"]) {
|
|
31797
32000
|
const script = r.config.hooks[name];
|
|
31798
32001
|
const cmd = script ? hookCommand(script) : null;
|
|
31799
32002
|
if (!cmd) continue;
|
|
31800
32003
|
const key = `hook_missing:${c.route}/${r.name}/${name}`;
|
|
32004
|
+
if (cfg.ship.runner === "sandbox") {
|
|
32005
|
+
const gap = gaps.find((g) => g.hook === name);
|
|
32006
|
+
if (!gap) {
|
|
32007
|
+
clearShipAttention(state, key);
|
|
32008
|
+
continue;
|
|
32009
|
+
}
|
|
32010
|
+
process.stdout.write(`hook ${c.route}/${r.name} ${name}: \`${cmd}\` NOT FOUND in the sandbox image
|
|
32011
|
+
`);
|
|
32012
|
+
await raiseShipAttention({ state, emit, route: c, ship: cfg.ship }, { kind: "hook_missing", key, message: gap.message, since: (/* @__PURE__ */ new Date()).toISOString() });
|
|
32013
|
+
continue;
|
|
32014
|
+
}
|
|
31801
32015
|
if (findOnPath(cmd, schedulerPath)) {
|
|
31802
32016
|
clearShipAttention(state, key);
|
|
31803
32017
|
continue;
|