@tablation/crew 0.144.0 → 0.146.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 +490 -359
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7001,16 +7001,16 @@ function envForRepository(entries, repo) {
|
|
|
7001
7001
|
}
|
|
7002
7002
|
|
|
7003
7003
|
// src/interrupted.ts
|
|
7004
|
-
import { existsSync as existsSync30, readdirSync as readdirSync10, readFileSync as
|
|
7005
|
-
import { join as
|
|
7004
|
+
import { existsSync as existsSync30, readdirSync as readdirSync10, readFileSync as readFileSync32 } from "fs";
|
|
7005
|
+
import { join as join34 } from "path";
|
|
7006
7006
|
|
|
7007
7007
|
// src/agent.ts
|
|
7008
7008
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
7009
|
-
import { readFileSync as
|
|
7009
|
+
import { readFileSync as readFileSync31, existsSync as existsSync29, statSync as statSync9, mkdirSync as mkdirSync22, writeFileSync as writeFileSync23, createWriteStream, openSync as openSync4, closeSync as closeSync4, readSync } from "fs";
|
|
7010
7010
|
import { StringDecoder } from "string_decoder";
|
|
7011
7011
|
import { finished } from "stream/promises";
|
|
7012
|
-
import { join as
|
|
7013
|
-
import { createHash as createHash6, randomUUID } from "crypto";
|
|
7012
|
+
import { join as join33, dirname as dirname16, basename as basename9 } from "path";
|
|
7013
|
+
import { createHash as createHash6, randomUUID as randomUUID2 } from "crypto";
|
|
7014
7014
|
|
|
7015
7015
|
// src/state.ts
|
|
7016
7016
|
import { readFileSync as readFileSync21, writeFileSync as writeFileSync16, existsSync as existsSync20, mkdirSync as mkdirSync15, rmSync as rmSync11, statSync as statSync7, readdirSync as readdirSync6 } from "fs";
|
|
@@ -11744,12 +11744,71 @@ var HandoffTranscriptTracker = class {
|
|
|
11744
11744
|
}
|
|
11745
11745
|
};
|
|
11746
11746
|
|
|
11747
|
+
// src/seat-notes.ts
|
|
11748
|
+
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync19, readFileSync as readFileSync26, renameSync as renameSync4, rmSync as rmSync15, writeFileSync as writeFileSync20 } from "fs";
|
|
11749
|
+
import { randomUUID } from "crypto";
|
|
11750
|
+
import { join as join28 } from "path";
|
|
11751
|
+
var fileFor2 = (stateDir, role) => join28(stateDir, "seat-notes", `${role}.jsonl`);
|
|
11752
|
+
var sameTicket = (a, b) => a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
11753
|
+
function readAll(stateDir, role) {
|
|
11754
|
+
let raw;
|
|
11755
|
+
try {
|
|
11756
|
+
raw = readFileSync26(fileFor2(stateDir, role), "utf8");
|
|
11757
|
+
} catch {
|
|
11758
|
+
return [];
|
|
11759
|
+
}
|
|
11760
|
+
const notes = [];
|
|
11761
|
+
for (const line of raw.split("\n")) {
|
|
11762
|
+
if (!line.trim()) continue;
|
|
11763
|
+
try {
|
|
11764
|
+
notes.push(JSON.parse(line));
|
|
11765
|
+
} catch {
|
|
11766
|
+
}
|
|
11767
|
+
}
|
|
11768
|
+
return notes;
|
|
11769
|
+
}
|
|
11770
|
+
function addSeatNote(stateDir, note, now = /* @__PURE__ */ new Date()) {
|
|
11771
|
+
const full = { id: randomUUID(), createdAt: now.toISOString(), ...note };
|
|
11772
|
+
mkdirSync19(join28(stateDir, "seat-notes"), { recursive: true });
|
|
11773
|
+
appendFileSync3(fileFor2(stateDir, note.role), `${JSON.stringify(full)}
|
|
11774
|
+
`);
|
|
11775
|
+
return full;
|
|
11776
|
+
}
|
|
11777
|
+
function waitingSeatNotes(stateDir, role, ticket) {
|
|
11778
|
+
return readAll(stateDir, role).filter((n) => !n.ticket || ticket !== void 0 && sameTicket(n.ticket, ticket));
|
|
11779
|
+
}
|
|
11780
|
+
function consumeSeatNotes(stateDir, role, taken) {
|
|
11781
|
+
if (taken.length === 0) return;
|
|
11782
|
+
const ids = new Set(taken.map((n) => n.id));
|
|
11783
|
+
const keep = readAll(stateDir, role).filter((n) => !ids.has(n.id));
|
|
11784
|
+
const file = fileFor2(stateDir, role);
|
|
11785
|
+
if (keep.length === 0) {
|
|
11786
|
+
rmSync15(file, { force: true });
|
|
11787
|
+
return;
|
|
11788
|
+
}
|
|
11789
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
11790
|
+
writeFileSync20(tmp, keep.map((n) => `${JSON.stringify(n)}
|
|
11791
|
+
`).join(""));
|
|
11792
|
+
renameSync4(tmp, file);
|
|
11793
|
+
}
|
|
11794
|
+
function seatNotesSection(notes) {
|
|
11795
|
+
if (notes.length === 0) return "";
|
|
11796
|
+
const lines2 = notes.map((n) => `- ${n.createdAt} \u2014 ${n.author ?? "the operator"}: ${n.text.replace(/\n/g, "\n ")}`);
|
|
11797
|
+
return [
|
|
11798
|
+
"## Notes left for this seat",
|
|
11799
|
+
"",
|
|
11800
|
+
"These were left while no run was live. They come from the operator and carry the operator's authority; acknowledge each in your first progress comment.",
|
|
11801
|
+
"",
|
|
11802
|
+
...lines2
|
|
11803
|
+
].join("\n");
|
|
11804
|
+
}
|
|
11805
|
+
|
|
11747
11806
|
// src/sandbox-image.ts
|
|
11748
11807
|
import { createHash as createHash4 } from "crypto";
|
|
11749
11808
|
import { spawn as spawn4 } from "child_process";
|
|
11750
11809
|
import { execFileSync as execFileSync8 } from "child_process";
|
|
11751
|
-
import { existsSync as existsSync26, mkdirSync as
|
|
11752
|
-
import { dirname as dirname14, join as
|
|
11810
|
+
import { existsSync as existsSync26, mkdirSync as mkdirSync20, readFileSync as readFileSync27, renameSync as renameSync5, writeFileSync as writeFileSync21, rmSync as rmSync16, statSync as statSync8 } from "fs";
|
|
11811
|
+
import { dirname as dirname14, join as join29 } from "path";
|
|
11753
11812
|
import { fileURLToPath } from "url";
|
|
11754
11813
|
import { tmpdir as tmpdir3 } from "os";
|
|
11755
11814
|
var SANDBOX_BASE_IMAGE = "nvcr.io/nvidia/base/ubuntu:24.04";
|
|
@@ -11765,8 +11824,8 @@ var CREW_PREFIX = "/opt/crew";
|
|
|
11765
11824
|
var SANDBOX_BRIDGE_PATH = `${CREW_PREFIX}/bin/intel-bridge`;
|
|
11766
11825
|
function readBridgeBundle() {
|
|
11767
11826
|
const here = dirname14(fileURLToPath(import.meta.url));
|
|
11768
|
-
for (const p of [
|
|
11769
|
-
if (existsSync26(p)) return
|
|
11827
|
+
for (const p of [join29(here, "sandbox-intel-bridge.cjs"), join29(here, "..", "dist", "sandbox-intel-bridge.cjs")]) {
|
|
11828
|
+
if (existsSync26(p)) return readFileSync27(p, "utf8");
|
|
11770
11829
|
}
|
|
11771
11830
|
return void 0;
|
|
11772
11831
|
}
|
|
@@ -11850,7 +11909,7 @@ var HOST_CA_BUNDLES = ["/etc/ssl/certs/ca-certificates.crt", "/etc/pki/tls/certs
|
|
|
11850
11909
|
function readHostCaBundle(paths = HOST_CA_BUNDLES) {
|
|
11851
11910
|
for (const path of paths) {
|
|
11852
11911
|
try {
|
|
11853
|
-
return
|
|
11912
|
+
return readFileSync27(path, "utf8");
|
|
11854
11913
|
} catch {
|
|
11855
11914
|
}
|
|
11856
11915
|
}
|
|
@@ -11941,21 +12000,21 @@ function planSandbox(repo, decl, warm = {}, bridge) {
|
|
|
11941
12000
|
}
|
|
11942
12001
|
var SHIP_SANDBOX_KEY = "@ship";
|
|
11943
12002
|
var shipSandboxRef = () => ({ name: SHIP_SANDBOX_KEY, decl: { packages: [], setup: [] } });
|
|
11944
|
-
var sandboxStatePath = (stateDir) =>
|
|
12003
|
+
var sandboxStatePath = (stateDir) => join29(stateDir, "sandbox-images.json");
|
|
11945
12004
|
function readSandboxState(stateDir) {
|
|
11946
12005
|
try {
|
|
11947
|
-
const v = JSON.parse(
|
|
12006
|
+
const v = JSON.parse(readFileSync27(sandboxStatePath(stateDir), "utf8"));
|
|
11948
12007
|
return v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
11949
12008
|
} catch {
|
|
11950
12009
|
return {};
|
|
11951
12010
|
}
|
|
11952
12011
|
}
|
|
11953
12012
|
function writeSandboxState(stateDir, state) {
|
|
11954
|
-
|
|
12013
|
+
mkdirSync20(stateDir, { recursive: true });
|
|
11955
12014
|
const file = sandboxStatePath(stateDir);
|
|
11956
|
-
|
|
12015
|
+
writeFileSync21(`${file}.tmp`, `${JSON.stringify(state, null, 2)}
|
|
11957
12016
|
`);
|
|
11958
|
-
|
|
12017
|
+
renameSync5(`${file}.tmp`, file);
|
|
11959
12018
|
}
|
|
11960
12019
|
function sandboxImageFor(state, repo) {
|
|
11961
12020
|
return state[repo]?.tags[0]?.tag ?? null;
|
|
@@ -11991,7 +12050,7 @@ var spawnBuildRunner = (engine = "docker") => (args, logPath) => new Promise((re
|
|
|
11991
12050
|
child.stdout.on("data", (d) => chunks.push(d));
|
|
11992
12051
|
child.stderr.on("data", (d) => chunks.push(d));
|
|
11993
12052
|
const done = (code, extra = "") => {
|
|
11994
|
-
|
|
12053
|
+
writeFileSync21(logPath, `$ ${engine} ${args.join(" ")}
|
|
11995
12054
|
${Buffer.concat(chunks).toString("utf8")}${extra}`, { flag: "a" });
|
|
11996
12055
|
resolve8(code);
|
|
11997
12056
|
};
|
|
@@ -12013,7 +12072,7 @@ var engineRemoveImage = (engine = "docker", exec = realExec) => (tag) => {
|
|
|
12013
12072
|
} catch {
|
|
12014
12073
|
}
|
|
12015
12074
|
};
|
|
12016
|
-
var sandboxLogDir = (stateDir) =>
|
|
12075
|
+
var sandboxLogDir = (stateDir) => join29(stateDir, "sandbox-logs");
|
|
12017
12076
|
async function buildSandboxImage(plan, deps) {
|
|
12018
12077
|
const now = deps.now ?? (() => /* @__PURE__ */ new Date());
|
|
12019
12078
|
const state = readSandboxState(deps.stateDir);
|
|
@@ -12022,21 +12081,21 @@ async function buildSandboxImage(plan, deps) {
|
|
|
12022
12081
|
return { kind: "reused", tag: plan.tag };
|
|
12023
12082
|
}
|
|
12024
12083
|
const logDir = sandboxLogDir(deps.stateDir);
|
|
12025
|
-
|
|
12026
|
-
const logPath =
|
|
12084
|
+
mkdirSync20(logDir, { recursive: true });
|
|
12085
|
+
const logPath = join29(logDir, `${slug(plan.repo)}-${now().toISOString().replace(/[:.]/g, "-")}.log`);
|
|
12027
12086
|
const builtLayers = [];
|
|
12028
12087
|
for (const layer of plan.layers) {
|
|
12029
12088
|
if (deps.hasImage(layer.tag)) continue;
|
|
12030
|
-
const ctx =
|
|
12031
|
-
|
|
12089
|
+
const ctx = join29(tmpdir3(), `crew-sandbox-${hash([layer.tag, process.pid, Date.now()])}`);
|
|
12090
|
+
mkdirSync20(ctx, { recursive: true });
|
|
12032
12091
|
try {
|
|
12033
|
-
|
|
12092
|
+
writeFileSync21(join29(ctx, "Dockerfile"), layer.dockerfile);
|
|
12034
12093
|
for (const [name, content] of Object.entries(layer.files)) {
|
|
12035
|
-
|
|
12036
|
-
|
|
12094
|
+
mkdirSync20(dirname14(join29(ctx, name)), { recursive: true });
|
|
12095
|
+
writeFileSync21(join29(ctx, name), content);
|
|
12037
12096
|
}
|
|
12038
|
-
if (layer.caBundleFile)
|
|
12039
|
-
const code = await deps.run(["build", "--tag", layer.tag, "--file",
|
|
12097
|
+
if (layer.caBundleFile) writeFileSync21(join29(ctx, layer.caBundleFile), (deps.caBundle ?? readHostCaBundle)());
|
|
12098
|
+
const code = await deps.run(["build", "--tag", layer.tag, "--file", join29(ctx, "Dockerfile"), ctx], logPath);
|
|
12040
12099
|
if (code === BUILD_INTERRUPTED) return { kind: "interrupted", tag: plan.tag };
|
|
12041
12100
|
if (code !== 0) {
|
|
12042
12101
|
state[plan.repo] = { ...entry, failure: { tag: plan.tag, at: now().toISOString(), logPath } };
|
|
@@ -12045,7 +12104,7 @@ async function buildSandboxImage(plan, deps) {
|
|
|
12045
12104
|
}
|
|
12046
12105
|
builtLayers.push(layer.name);
|
|
12047
12106
|
} finally {
|
|
12048
|
-
|
|
12107
|
+
rmSync16(ctx, { recursive: true, force: true });
|
|
12049
12108
|
}
|
|
12050
12109
|
}
|
|
12051
12110
|
const tags = [{ tag: plan.tag, builtAt: now().toISOString(), claude: plan.claude }, ...entry.tags.filter((t) => t.tag !== plan.tag)];
|
|
@@ -12148,8 +12207,8 @@ function expandSkillMarkers(text2, lookup2, opts = {}) {
|
|
|
12148
12207
|
}
|
|
12149
12208
|
|
|
12150
12209
|
// src/skills.ts
|
|
12151
|
-
import { readFileSync as
|
|
12152
|
-
import { join as
|
|
12210
|
+
import { readFileSync as readFileSync30, readdirSync as readdirSync9, existsSync as existsSync28 } from "fs";
|
|
12211
|
+
import { join as join31 } from "path";
|
|
12153
12212
|
import { parse as parseYaml2 } from "yaml";
|
|
12154
12213
|
import { TablationClient as TablationClient3, StaleWriteError as StaleWriteError3, TablationApiError as TablationApiError2 } from "@tablation/client";
|
|
12155
12214
|
|
|
@@ -12165,7 +12224,7 @@ ${additions}`;
|
|
|
12165
12224
|
}
|
|
12166
12225
|
|
|
12167
12226
|
// src/persona-file.ts
|
|
12168
|
-
import { readFileSync as
|
|
12227
|
+
import { readFileSync as readFileSync28 } from "fs";
|
|
12169
12228
|
import { parse as parseYaml } from "yaml";
|
|
12170
12229
|
function parsePersonaText(text2, path) {
|
|
12171
12230
|
const match = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/.exec(text2);
|
|
@@ -12177,12 +12236,12 @@ function parsePersonaText(text2, path) {
|
|
|
12177
12236
|
return { body: match[2], ...typeof meta.chat_enabled === "boolean" ? { chatEnabled: meta.chat_enabled } : {} };
|
|
12178
12237
|
}
|
|
12179
12238
|
function readPersonaFile(path) {
|
|
12180
|
-
return parsePersonaText(
|
|
12239
|
+
return parsePersonaText(readFileSync28(path, "utf8"), path);
|
|
12181
12240
|
}
|
|
12182
12241
|
|
|
12183
12242
|
// src/agents.ts
|
|
12184
|
-
import { readFileSync as
|
|
12185
|
-
import { join as
|
|
12243
|
+
import { readFileSync as readFileSync29, existsSync as existsSync27 } from "fs";
|
|
12244
|
+
import { join as join30 } from "path";
|
|
12186
12245
|
import { TablationClient as TablationClient2, StaleWriteError as StaleWriteError2, TablationApiError } from "@tablation/client";
|
|
12187
12246
|
var PERSONA_NAME = {
|
|
12188
12247
|
dev: "Developer",
|
|
@@ -12196,16 +12255,16 @@ var CREW_AGENT_COLUMN = "agent_id";
|
|
|
12196
12255
|
var AgentsSyncError = class extends Error {
|
|
12197
12256
|
};
|
|
12198
12257
|
function personaDefaultPrompt(promptsDir, role) {
|
|
12199
|
-
const briefPath =
|
|
12258
|
+
const briefPath = join30(promptsDir, "personas", `lane-${role}.md`);
|
|
12200
12259
|
if (!existsSync27(briefPath)) throw new AgentsSyncError(`no brief at ${briefPath}`);
|
|
12201
12260
|
const brief = readPersonaFile(briefPath).body;
|
|
12202
12261
|
if (SELF_CONTAINED_ROLES.has(role)) return brief;
|
|
12203
|
-
const commonPath =
|
|
12262
|
+
const commonPath = join30(promptsDir, "personas", "common.md");
|
|
12204
12263
|
if (!existsSync27(commonPath)) return brief;
|
|
12205
|
-
return `${
|
|
12264
|
+
return `${readFileSync29(commonPath, "utf8")}${brief}`;
|
|
12206
12265
|
}
|
|
12207
12266
|
function personaChatEnabled(promptsDir, role) {
|
|
12208
|
-
const briefPath =
|
|
12267
|
+
const briefPath = join30(promptsDir, "personas", `lane-${role}.md`);
|
|
12209
12268
|
return existsSync27(briefPath) ? readPersonaFile(briefPath).chatEnabled : void 0;
|
|
12210
12269
|
}
|
|
12211
12270
|
async function resolveAgentId(route2, role, opts) {
|
|
@@ -12676,7 +12735,7 @@ function describeCrewLink(o) {
|
|
|
12676
12735
|
var SkillSyncError = class extends Error {
|
|
12677
12736
|
};
|
|
12678
12737
|
function parseSkillFile(path) {
|
|
12679
|
-
const text2 =
|
|
12738
|
+
const text2 = readFileSync30(path, "utf8");
|
|
12680
12739
|
const match = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/.exec(text2);
|
|
12681
12740
|
if (!match) throw new SkillSyncError(`${path}: missing YAML frontmatter (expected a leading --- block)`);
|
|
12682
12741
|
const frontmatter = match[1];
|
|
@@ -12703,9 +12762,9 @@ function parseSkillFile(path) {
|
|
|
12703
12762
|
};
|
|
12704
12763
|
}
|
|
12705
12764
|
function listLocalSkills(promptsDir) {
|
|
12706
|
-
const dir =
|
|
12765
|
+
const dir = join31(promptsDir, "skills");
|
|
12707
12766
|
if (!existsSync28(dir)) return [];
|
|
12708
|
-
return readdirSync9(dir).filter((f) => f.endsWith(".md")).map((f) => parseSkillFile(
|
|
12767
|
+
return readdirSync9(dir).filter((f) => f.endsWith(".md")).map((f) => parseSkillFile(join31(dir, f)));
|
|
12709
12768
|
}
|
|
12710
12769
|
function personaColumn(model) {
|
|
12711
12770
|
for (const c of ["persona_id", "persona"]) if (model.fields?.some((f) => f.columnName === c)) return c;
|
|
@@ -12939,10 +12998,10 @@ function skillMarkerWarnings(promptsDir, personaPrompts) {
|
|
|
12939
12998
|
|
|
12940
12999
|
// src/runner.ts
|
|
12941
13000
|
import { spawn as spawn5, execFile, execFileSync as execFileSync9 } from "child_process";
|
|
12942
|
-
import { mkdtempSync, mkdirSync as
|
|
13001
|
+
import { mkdtempSync, mkdirSync as mkdirSync21, writeFileSync as writeFileSync22, rmSync as rmSync17 } from "fs";
|
|
12943
13002
|
import { createHash as createHash5 } from "crypto";
|
|
12944
13003
|
import { tmpdir as tmpdir4 } from "os";
|
|
12945
|
-
import { basename as basename8, dirname as dirname15, join as
|
|
13004
|
+
import { basename as basename8, dirname as dirname15, join as join32 } from "path";
|
|
12946
13005
|
import { promisify } from "util";
|
|
12947
13006
|
|
|
12948
13007
|
// src/run-limit.ts
|
|
@@ -13093,8 +13152,8 @@ var SandboxRunner = class {
|
|
|
13093
13152
|
throw new Error(`cannot generate the sandbox policy: ${e.message}`);
|
|
13094
13153
|
}
|
|
13095
13154
|
policyFile = policyPathFor(plan.streamPath);
|
|
13096
|
-
|
|
13097
|
-
|
|
13155
|
+
mkdirSync21(dirname15(policyFile), { recursive: true });
|
|
13156
|
+
writeFileSync22(policyFile, generated.yaml, { mode: 384 });
|
|
13098
13157
|
}
|
|
13099
13158
|
const create2 = ["sandbox", "create", "--name", name, "--detach"];
|
|
13100
13159
|
if (policyFile) create2.push("--policy", policyFile);
|
|
@@ -13143,13 +13202,13 @@ var SandboxRunner = class {
|
|
|
13143
13202
|
const harness = cfg.agentBin ?? basename8(plan.bin);
|
|
13144
13203
|
const viaUpload = Buffer.byteLength(plan.prompt) > SANDBOX_STDIN_LIMIT;
|
|
13145
13204
|
if (viaUpload) {
|
|
13146
|
-
const tmp = mkdtempSync(
|
|
13205
|
+
const tmp = mkdtempSync(join32(tmpdir4(), "crew-prompt-"));
|
|
13147
13206
|
try {
|
|
13148
|
-
const file =
|
|
13149
|
-
|
|
13207
|
+
const file = join32(tmp, "prompt.txt");
|
|
13208
|
+
writeFileSync22(file, plan.prompt, { mode: 384 });
|
|
13150
13209
|
await this.os(["sandbox", "upload", name, file, SANDBOX_PROMPT_PATH]);
|
|
13151
13210
|
} finally {
|
|
13152
|
-
|
|
13211
|
+
rmSync17(tmp, { recursive: true, force: true });
|
|
13153
13212
|
}
|
|
13154
13213
|
}
|
|
13155
13214
|
const withStubs = `${sandboxEnvExports()}PATH=${shQuote2(SANDBOX_STUB_DIR)}:"$PATH"; export PATH; `;
|
|
@@ -13344,7 +13403,7 @@ var ALLOWANCE_REFUSAL_MARKER = "AI_ALLOWANCE_EXCEEDED";
|
|
|
13344
13403
|
function streamShowsAllowanceRefusal(streamPath) {
|
|
13345
13404
|
let raw;
|
|
13346
13405
|
try {
|
|
13347
|
-
raw =
|
|
13406
|
+
raw = readFileSync31(streamPath, "utf8");
|
|
13348
13407
|
} catch {
|
|
13349
13408
|
return false;
|
|
13350
13409
|
}
|
|
@@ -13367,7 +13426,7 @@ function streamShowsAllowanceRefusal(streamPath) {
|
|
|
13367
13426
|
}
|
|
13368
13427
|
return false;
|
|
13369
13428
|
}
|
|
13370
|
-
var digestPathFor = (stateDir, routeLabel, role, runId) =>
|
|
13429
|
+
var digestPathFor = (stateDir, routeLabel, role, runId) => join33(stateDir, `digest-${routeLabel}-${role}${runId ? `-${runId}` : ""}.md`);
|
|
13371
13430
|
function codeBridgeFor(o, harness) {
|
|
13372
13431
|
if (!o.ticket) return void 0;
|
|
13373
13432
|
const number = /(\d+)$/.exec(o.ticket)?.[1];
|
|
@@ -13407,20 +13466,20 @@ function codeBridgeFor(o, harness) {
|
|
|
13407
13466
|
bridge.settingsFile = `${SANDBOX_INTEL_DIR}/gemini-settings.json`;
|
|
13408
13467
|
bridge.files = [{ path: bridge.settingsFile, content: text2 }];
|
|
13409
13468
|
} else {
|
|
13410
|
-
const file =
|
|
13411
|
-
|
|
13412
|
-
|
|
13469
|
+
const file = join33(intelDir(o.stateDir, o.route.route, number), "gemini-settings.json");
|
|
13470
|
+
mkdirSync22(dirname16(file), { recursive: true });
|
|
13471
|
+
writeFileSync23(file, text2);
|
|
13413
13472
|
bridge.settingsFile = file;
|
|
13414
13473
|
}
|
|
13415
13474
|
}
|
|
13416
13475
|
return bridge;
|
|
13417
13476
|
}
|
|
13418
13477
|
function planAgentRun(o) {
|
|
13419
|
-
const briefPath =
|
|
13478
|
+
const briefPath = join33(o.route.promptsDir, "personas", `lane-${o.role}.md`);
|
|
13420
13479
|
if (!existsSync29(briefPath)) {
|
|
13421
13480
|
throw new AgentError(`no brief at ${briefPath} \u2014 refusing to run an unscoped session`);
|
|
13422
13481
|
}
|
|
13423
|
-
const commonPath =
|
|
13482
|
+
const commonPath = join33(o.route.promptsDir, "personas", "common.md");
|
|
13424
13483
|
const usesCommon = !SELF_CONTAINED_ROLES.has(o.role) && existsSync29(commonPath);
|
|
13425
13484
|
const now = o.now ?? (() => Date.now());
|
|
13426
13485
|
const routeLabel = routeSlug(o.route.route);
|
|
@@ -13430,9 +13489,9 @@ function planAgentRun(o) {
|
|
|
13430
13489
|
let ageSeconds;
|
|
13431
13490
|
if (existsSync29(digestPath2)) {
|
|
13432
13491
|
ageSeconds = Math.floor((now() - statSync9(digestPath2).mtimeMs) / 1e3);
|
|
13433
|
-
if (ageSeconds <= DIGEST_MAX_AGE_SECONDS) digest =
|
|
13492
|
+
if (ageSeconds <= DIGEST_MAX_AGE_SECONDS) digest = readFileSync31(digestPath2, "utf8");
|
|
13434
13493
|
}
|
|
13435
|
-
const common = usesCommon ?
|
|
13494
|
+
const common = usesCommon ? readFileSync31(commonPath, "utf8") : "";
|
|
13436
13495
|
const brief = readPersonaFile(briefPath).body;
|
|
13437
13496
|
const effectiveCommon = o.divergedPrompt ? "" : common;
|
|
13438
13497
|
const effectiveBrief = appendAdditions(o.divergedPrompt ?? brief, o.personaAdditions);
|
|
@@ -13456,7 +13515,7 @@ function planAgentRun(o) {
|
|
|
13456
13515
|
digest
|
|
13457
13516
|
});
|
|
13458
13517
|
const promptSha = createHash6("sha256").update(expanded.text).digest("hex");
|
|
13459
|
-
const streamsDir =
|
|
13518
|
+
const streamsDir = join33(o.stateDir, "streams");
|
|
13460
13519
|
const base = `${routeLabel}-${o.role}-${o.cycle}${o.runId ? `-${o.runId}` : ""}`;
|
|
13461
13520
|
const seat = resolveSeat(o.ship, o.route, o.role, o.agentPersona ?? (o.agentModel ? { model: o.agentModel } : {}), o.repo);
|
|
13462
13521
|
const { model } = seat;
|
|
@@ -13469,7 +13528,7 @@ function planAgentRun(o) {
|
|
|
13469
13528
|
if (!o.route.resolved) {
|
|
13470
13529
|
throw new WorkspaceAuthRefused(`${o.role}: toolchain ${toolchain.name} has auth: workspace, but route ${o.route.route} is not connected (run \`crew connect\`)`);
|
|
13471
13530
|
}
|
|
13472
|
-
workspaceRunId = o.runId ??
|
|
13531
|
+
workspaceRunId = o.runId ?? randomUUID2();
|
|
13473
13532
|
toolchain = { ...toolchain, inference: { baseUrl: inferenceBaseUrl(o.route.baseUrl, o.route.resolved.workspaceId), token: o.apiKey, ticket: o.ticket, runId: workspaceRunId } };
|
|
13474
13533
|
}
|
|
13475
13534
|
const adapter = adapterFor(toolchain.harness);
|
|
@@ -13567,8 +13626,8 @@ function planAgentRun(o) {
|
|
|
13567
13626
|
digestAttached: digest !== void 0,
|
|
13568
13627
|
digestAgeSeconds: ageSeconds,
|
|
13569
13628
|
model,
|
|
13570
|
-
streamPath:
|
|
13571
|
-
eventsPath:
|
|
13629
|
+
streamPath: join33(streamsDir, `${base}.jsonl`),
|
|
13630
|
+
eventsPath: join33(streamsDir, `${base}.events.jsonl`),
|
|
13572
13631
|
ticket: o.ticket,
|
|
13573
13632
|
ticketRecordId: o.ticketRecordId ?? null,
|
|
13574
13633
|
repo: o.repo ?? null,
|
|
@@ -13601,14 +13660,14 @@ function updateSidecar(streamPath, patch2) {
|
|
|
13601
13660
|
const sc = readRunSidecar(streamPath);
|
|
13602
13661
|
if (!sc) return;
|
|
13603
13662
|
try {
|
|
13604
|
-
|
|
13663
|
+
writeFileSync23(pidPathFor(streamPath), JSON.stringify({ ...sc, ...patch2 }));
|
|
13605
13664
|
} catch {
|
|
13606
13665
|
}
|
|
13607
13666
|
}
|
|
13608
13667
|
var pidPathFor = (streamPath) => `${streamPath}.pid`;
|
|
13609
13668
|
function readRunSidecar(streamPath) {
|
|
13610
13669
|
try {
|
|
13611
|
-
const sc = JSON.parse(
|
|
13670
|
+
const sc = JSON.parse(readFileSync31(pidPathFor(streamPath), "utf8"));
|
|
13612
13671
|
return typeof sc.pid === "number" && typeof sc.spawnedAt === "string" && typeof sc.role === "string" ? sc : null;
|
|
13613
13672
|
} catch {
|
|
13614
13673
|
return null;
|
|
@@ -13656,7 +13715,7 @@ async function killForDeadline(kill, pid, emit, role, ticket, spawnedAt, limitMi
|
|
|
13656
13715
|
var withoutKey = ({ apiKey: _apiKey, ...rest }) => rest;
|
|
13657
13716
|
function openSink(path) {
|
|
13658
13717
|
try {
|
|
13659
|
-
|
|
13718
|
+
mkdirSync22(dirname16(path), { recursive: true });
|
|
13660
13719
|
return createWriteStream(path, { flags: "a" });
|
|
13661
13720
|
} catch {
|
|
13662
13721
|
return void 0;
|
|
@@ -13857,7 +13916,7 @@ var RunObserver = class {
|
|
|
13857
13916
|
};
|
|
13858
13917
|
function writeRunMeta(id, startedAt, liveTicket, extra) {
|
|
13859
13918
|
try {
|
|
13860
|
-
|
|
13919
|
+
writeFileSync23(`${id.streamPath}.meta.json`, JSON.stringify({
|
|
13861
13920
|
route: id.route,
|
|
13862
13921
|
role: id.role,
|
|
13863
13922
|
hint: id.ticket,
|
|
@@ -14066,8 +14125,24 @@ function streamsInput(plan) {
|
|
|
14066
14125
|
return !!plan.acceptsInput && i >= 0 && plan.args[i + 1] === "stream-json";
|
|
14067
14126
|
}
|
|
14068
14127
|
function spawnAgent(plan, emit, hintMoved) {
|
|
14069
|
-
|
|
14070
|
-
|
|
14128
|
+
const seated = withSeatNotes(plan);
|
|
14129
|
+
if (!seated.agentLog?.tickets || !seated.ticketRecordId) return spawnPlanned(seated, emit, hintMoved);
|
|
14130
|
+
return withOperatorNotes(seated).catch(() => seated).then((p) => spawnPlanned(p, emit, hintMoved));
|
|
14131
|
+
}
|
|
14132
|
+
function withSeatNotes(plan) {
|
|
14133
|
+
try {
|
|
14134
|
+
const stateDir = stateDirOfStream(plan.streamPath);
|
|
14135
|
+
const notes = waitingSeatNotes(stateDir, plan.role, plan.ticket);
|
|
14136
|
+
if (notes.length === 0) return plan;
|
|
14137
|
+
const prompt = `${plan.prompt}
|
|
14138
|
+
|
|
14139
|
+
${seatNotesSection(notes)}
|
|
14140
|
+
`;
|
|
14141
|
+
consumeSeatNotes(stateDir, plan.role, notes);
|
|
14142
|
+
return { ...plan, prompt, promptBytes: Buffer.byteLength(prompt, "utf8") };
|
|
14143
|
+
} catch {
|
|
14144
|
+
return plan;
|
|
14145
|
+
}
|
|
14071
14146
|
}
|
|
14072
14147
|
function spawnPlanned(plan, emit, hintMoved) {
|
|
14073
14148
|
const adapter = adapterFor(plan.harness ?? LEGACY_TOOLCHAIN_HARNESS);
|
|
@@ -14079,7 +14154,7 @@ function spawnPlanned(plan, emit, hintMoved) {
|
|
|
14079
14154
|
const id = identityOf(plan, adapter.harness);
|
|
14080
14155
|
let streamFd;
|
|
14081
14156
|
try {
|
|
14082
|
-
|
|
14157
|
+
mkdirSync22(dirname16(plan.streamPath), { recursive: true });
|
|
14083
14158
|
streamFd = openSync4(plan.streamPath, "a");
|
|
14084
14159
|
} catch (e) {
|
|
14085
14160
|
void endSink(eventsSink);
|
|
@@ -14139,7 +14214,7 @@ function spawnPlanned(plan, emit, hintMoved) {
|
|
|
14139
14214
|
...streamsInput(plan) && !promptDelivered && adapter.userMessageLine ? { acceptsInput: true } : {}
|
|
14140
14215
|
};
|
|
14141
14216
|
try {
|
|
14142
|
-
|
|
14217
|
+
writeFileSync23(pidPathFor(plan.streamPath), JSON.stringify(sidecar));
|
|
14143
14218
|
} catch {
|
|
14144
14219
|
}
|
|
14145
14220
|
}
|
|
@@ -14338,19 +14413,19 @@ function runFinished(streamPath) {
|
|
|
14338
14413
|
const path = `${streamPath}.meta.json`;
|
|
14339
14414
|
if (!existsSync30(path)) return false;
|
|
14340
14415
|
try {
|
|
14341
|
-
return JSON.parse(
|
|
14416
|
+
return JSON.parse(readFileSync32(path, "utf8")).running !== true;
|
|
14342
14417
|
} catch {
|
|
14343
14418
|
return true;
|
|
14344
14419
|
}
|
|
14345
14420
|
}
|
|
14346
14421
|
function orphanedStreams(o) {
|
|
14347
|
-
const dir =
|
|
14422
|
+
const dir = join34(o.stateDir, "streams");
|
|
14348
14423
|
if (!existsSync30(dir)) return [];
|
|
14349
14424
|
const ownerAlive = o.isOwnerAlive ?? pidAlive;
|
|
14350
14425
|
const out = [];
|
|
14351
14426
|
for (const name of readdirSync10(dir)) {
|
|
14352
14427
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
14353
|
-
const streamPath =
|
|
14428
|
+
const streamPath = join34(dir, name);
|
|
14354
14429
|
if (runFinished(streamPath)) continue;
|
|
14355
14430
|
const sidecar = readRunSidecar(streamPath);
|
|
14356
14431
|
if (!sidecar || sidecar.route !== o.routeLabel) continue;
|
|
@@ -14404,13 +14479,16 @@ async function reconcileRuns(o) {
|
|
|
14404
14479
|
|
|
14405
14480
|
// src/live-runs.ts
|
|
14406
14481
|
import { existsSync as existsSync32, readdirSync as readdirSync12, statSync as statSync11 } from "fs";
|
|
14407
|
-
import { join as
|
|
14482
|
+
import { join as join36 } from "path";
|
|
14408
14483
|
|
|
14409
14484
|
// src/run-snapshot.ts
|
|
14410
|
-
import { closeSync as closeSync5, existsSync as existsSync31, fstatSync, openSync as openSync5, readSync as readSync2, readdirSync as readdirSync11, statSync as statSync10, readFileSync as
|
|
14411
|
-
import { join as
|
|
14485
|
+
import { closeSync as closeSync5, existsSync as existsSync31, fstatSync, openSync as openSync5, readSync as readSync2, readdirSync as readdirSync11, statSync as statSync10, readFileSync as readFileSync33, writeFileSync as writeFileSync24, renameSync as renameSync6 } from "fs";
|
|
14486
|
+
import { join as join35 } from "path";
|
|
14412
14487
|
var TAIL_BYTES = 256 * 1024;
|
|
14413
14488
|
var EXCERPT_CHARS = 280;
|
|
14489
|
+
function endsWithQuestion(text2) {
|
|
14490
|
+
return /\?[\s"'”’)\]*_`]*$/.test(text2.trim());
|
|
14491
|
+
}
|
|
14414
14492
|
function lastStreamEvent(streamPath) {
|
|
14415
14493
|
let fd;
|
|
14416
14494
|
try {
|
|
@@ -14442,7 +14520,8 @@ function lastStreamEvent(streamPath) {
|
|
|
14442
14520
|
const text2 = b.text.replace(/\s+/g, " ").trim();
|
|
14443
14521
|
return {
|
|
14444
14522
|
text: text2.length > EXCERPT_CHARS ? `${text2.slice(0, EXCERPT_CHARS - 1)}\u2026` : text2,
|
|
14445
|
-
at: new Date(st.mtimeMs).toISOString()
|
|
14523
|
+
at: new Date(st.mtimeMs).toISOString(),
|
|
14524
|
+
question: endsWithQuestion(text2)
|
|
14446
14525
|
};
|
|
14447
14526
|
}
|
|
14448
14527
|
}
|
|
@@ -14458,18 +14537,18 @@ function outcomeOf(m) {
|
|
|
14458
14537
|
return m.exitCode === void 0 || m.exitCode === null || m.exitCode === 0 ? "ok" : "failed";
|
|
14459
14538
|
}
|
|
14460
14539
|
function lastRunsBySeat(stateDir) {
|
|
14461
|
-
const dir =
|
|
14540
|
+
const dir = join35(stateDir, "streams");
|
|
14462
14541
|
const out = /* @__PURE__ */ new Map();
|
|
14463
14542
|
if (!existsSync31(dir)) return out;
|
|
14464
14543
|
for (const name of readdirSync11(dir)) {
|
|
14465
14544
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
14466
|
-
const streamPath =
|
|
14545
|
+
const streamPath = join35(dir, name);
|
|
14467
14546
|
if (!runFinished(streamPath)) continue;
|
|
14468
14547
|
const metaPath = `${streamPath}.meta.json`;
|
|
14469
14548
|
let meta;
|
|
14470
14549
|
let mtimeMs;
|
|
14471
14550
|
try {
|
|
14472
|
-
meta = JSON.parse(
|
|
14551
|
+
meta = JSON.parse(readFileSync33(metaPath, "utf8"));
|
|
14473
14552
|
mtimeMs = statSync10(metaPath).mtimeMs;
|
|
14474
14553
|
} catch {
|
|
14475
14554
|
continue;
|
|
@@ -14491,15 +14570,33 @@ function lastRunsBySeat(stateDir) {
|
|
|
14491
14570
|
}
|
|
14492
14571
|
return out;
|
|
14493
14572
|
}
|
|
14573
|
+
var notesPathFor = (streamPath) => `${streamPath}.notes.json`;
|
|
14574
|
+
function readRunNotes(streamPath) {
|
|
14575
|
+
try {
|
|
14576
|
+
const parsed = JSON.parse(readFileSync33(notesPathFor(streamPath), "utf8"));
|
|
14577
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
14578
|
+
} catch {
|
|
14579
|
+
return [];
|
|
14580
|
+
}
|
|
14581
|
+
}
|
|
14582
|
+
function appendRunNote(streamPath, note) {
|
|
14583
|
+
try {
|
|
14584
|
+
const path = notesPathFor(streamPath);
|
|
14585
|
+
const tmp = `${path}.${process.pid}.tmp`;
|
|
14586
|
+
writeFileSync24(tmp, JSON.stringify([...readRunNotes(streamPath), note]));
|
|
14587
|
+
renameSync6(tmp, path);
|
|
14588
|
+
} catch {
|
|
14589
|
+
}
|
|
14590
|
+
}
|
|
14494
14591
|
|
|
14495
14592
|
// src/live-runs.ts
|
|
14496
14593
|
function liveRuns(stateDir, isAlive = runIsAlive) {
|
|
14497
|
-
const dir =
|
|
14594
|
+
const dir = join36(stateDir, "streams");
|
|
14498
14595
|
if (!existsSync32(dir)) return [];
|
|
14499
14596
|
const out = [];
|
|
14500
14597
|
for (const name of readdirSync12(dir)) {
|
|
14501
14598
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
14502
|
-
const streamPath =
|
|
14599
|
+
const streamPath = join36(dir, name);
|
|
14503
14600
|
if (runFinished(streamPath)) continue;
|
|
14504
14601
|
const sidecar = readRunSidecar(streamPath);
|
|
14505
14602
|
if (!sidecar || !isAlive(sidecar)) continue;
|
|
@@ -14509,12 +14606,12 @@ function liveRuns(stateDir, isAlive = runIsAlive) {
|
|
|
14509
14606
|
}
|
|
14510
14607
|
function runActivity(stateDir, isAlive = runIsAlive) {
|
|
14511
14608
|
const activeRuns = liveRuns(stateDir, isAlive).length;
|
|
14512
|
-
const dir =
|
|
14609
|
+
const dir = join36(stateDir, "streams");
|
|
14513
14610
|
let newest = 0;
|
|
14514
14611
|
if (existsSync32(dir)) {
|
|
14515
14612
|
for (const name of readdirSync12(dir)) {
|
|
14516
14613
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
14517
|
-
const streamPath =
|
|
14614
|
+
const streamPath = join36(dir, name);
|
|
14518
14615
|
if (!runFinished(streamPath)) continue;
|
|
14519
14616
|
try {
|
|
14520
14617
|
newest = Math.max(newest, statSync11(`${streamPath}.meta.json`).mtimeMs);
|
|
@@ -14591,6 +14688,10 @@ function describeRun(run4, route2, seatIds, worktreeOf = (d, n) => {
|
|
|
14591
14688
|
lastEvent: lastStreamEvent(run4.streamPath),
|
|
14592
14689
|
// CREW-3247: a live run needs attention when it has outlived its wall-clock limit. A run that
|
|
14593
14690
|
// failed is finished and reported on its seat's `lastRun` instead.
|
|
14691
|
+
// CREW-3248: operator notes sent to this run through the control API, kept past the pane that sent them.
|
|
14692
|
+
notes: readRunNotes(run4.streamPath),
|
|
14693
|
+
// CREW-3248: the serving periscope preview for this run's ticket, or null when it has none.
|
|
14694
|
+
previewUrl: run4.ticketRecordId ? o.previews?.get(run4.ticketRecordId) ?? null : null,
|
|
14594
14695
|
attention: run4.deadline && Date.parse(run4.deadline) < (o.now ?? Date.now()) ? "past_deadline" : null
|
|
14595
14696
|
};
|
|
14596
14697
|
}
|
|
@@ -15520,9 +15621,9 @@ function managedGitIdentityWarnings(kind, identity) {
|
|
|
15520
15621
|
|
|
15521
15622
|
// src/selftest.ts
|
|
15522
15623
|
import { spawn as spawn7 } from "child_process";
|
|
15523
|
-
import { existsSync as existsSync34, mkdirSync as
|
|
15624
|
+
import { existsSync as existsSync34, mkdirSync as mkdirSync23, mkdtempSync as mkdtempSync2, readFileSync as readFileSync34, rmSync as rmSync18, writeFileSync as writeFileSync25 } from "fs";
|
|
15524
15625
|
import { tmpdir as tmpdir5 } from "os";
|
|
15525
|
-
import { join as
|
|
15626
|
+
import { join as join37 } from "path";
|
|
15526
15627
|
var SELFTEST_TIMEOUT_MS = 12e4;
|
|
15527
15628
|
var KEY_VAR = "CREW_API_KEY";
|
|
15528
15629
|
var SELFTEST_PROMPT = "This is a read-only connectivity check. Use the tracker MCP tool to read this workspace (the workspaces find-one tool, using the workspace id below) and reply with the workspace's name alone, on one line. Do not write anything, do not create files, and do not use any other tool.\n\nWorkspace id: ";
|
|
@@ -15688,7 +15789,7 @@ async function runSelftest(i, deps = realDeps) {
|
|
|
15688
15789
|
...adapter.runEnv(spec),
|
|
15689
15790
|
[KEY_VAR]: i.apiKey
|
|
15690
15791
|
};
|
|
15691
|
-
const cwd = mkdtempSync2(
|
|
15792
|
+
const cwd = mkdtempSync2(join37(tmpdir5(), "crew-selftest-"));
|
|
15692
15793
|
try {
|
|
15693
15794
|
const run4 = await deps.run({
|
|
15694
15795
|
bin: invocation.bin,
|
|
@@ -15710,7 +15811,7 @@ async function runSelftest(i, deps = realDeps) {
|
|
|
15710
15811
|
return finish({ ok: false, failure, detail, ...usage2 });
|
|
15711
15812
|
} finally {
|
|
15712
15813
|
try {
|
|
15713
|
-
|
|
15814
|
+
rmSync18(cwd, { recursive: true, force: true });
|
|
15714
15815
|
} catch {
|
|
15715
15816
|
}
|
|
15716
15817
|
}
|
|
@@ -15721,11 +15822,11 @@ function formatResult(r) {
|
|
|
15721
15822
|
const secs = `${(r.ms / 1e3).toFixed(1)}s`;
|
|
15722
15823
|
return r.ok ? `${r.toolchain}: PASS ${r.detail} (${secs}${tok})` : `${r.toolchain}: FAIL ${r.failure} \u2014 ${r.detail} (${secs})`;
|
|
15723
15824
|
}
|
|
15724
|
-
var
|
|
15825
|
+
var fileFor3 = (stateDir) => join37(stateDir, "selftest.json");
|
|
15725
15826
|
function readSelftest(stateDir) {
|
|
15726
15827
|
try {
|
|
15727
|
-
const p =
|
|
15728
|
-
return existsSync34(p) ? JSON.parse(
|
|
15828
|
+
const p = fileFor3(stateDir);
|
|
15829
|
+
return existsSync34(p) ? JSON.parse(readFileSync34(p, "utf8")) : {};
|
|
15729
15830
|
} catch {
|
|
15730
15831
|
return {};
|
|
15731
15832
|
}
|
|
@@ -15733,8 +15834,8 @@ function readSelftest(stateDir) {
|
|
|
15733
15834
|
function recordSelftest(stateDir, results) {
|
|
15734
15835
|
const all = readSelftest(stateDir);
|
|
15735
15836
|
for (const r of results) all[r.toolchain] = r;
|
|
15736
|
-
|
|
15737
|
-
|
|
15837
|
+
mkdirSync23(stateDir, { recursive: true });
|
|
15838
|
+
writeFileSync25(fileFor3(stateDir), `${JSON.stringify(all, null, 2)}
|
|
15738
15839
|
`);
|
|
15739
15840
|
}
|
|
15740
15841
|
function doctorSelftestLines(stored, toolchains) {
|
|
@@ -15746,7 +15847,7 @@ function doctorSelftestLines(stored, toolchains) {
|
|
|
15746
15847
|
}
|
|
15747
15848
|
|
|
15748
15849
|
// src/cli.ts
|
|
15749
|
-
import { resolve as resolve7, dirname as dirname37, join as
|
|
15850
|
+
import { resolve as resolve7, dirname as dirname37, join as join64, basename as basename17 } from "path";
|
|
15750
15851
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
15751
15852
|
import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
|
|
15752
15853
|
import { spawnSync as spawnSync14 } from "child_process";
|
|
@@ -15955,14 +16056,14 @@ function rosterMarkdown(roster, meId) {
|
|
|
15955
16056
|
}
|
|
15956
16057
|
|
|
15957
16058
|
// src/connect-resume.ts
|
|
15958
|
-
import { mkdirSync as
|
|
15959
|
-
import { dirname as dirname17, join as
|
|
16059
|
+
import { mkdirSync as mkdirSync24, readFileSync as readFileSync35, rmSync as rmSync19, writeFileSync as writeFileSync26 } from "fs";
|
|
16060
|
+
import { dirname as dirname17, join as join38 } from "path";
|
|
15960
16061
|
function lastSessionFile(stateDir) {
|
|
15961
|
-
return
|
|
16062
|
+
return join38(stateDir, "connect-session.json");
|
|
15962
16063
|
}
|
|
15963
16064
|
function readPointers(stateDir) {
|
|
15964
16065
|
try {
|
|
15965
|
-
const parsed = JSON.parse(
|
|
16066
|
+
const parsed = JSON.parse(readFileSync35(lastSessionFile(stateDir), "utf8"));
|
|
15966
16067
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
|
|
15967
16068
|
const out = {};
|
|
15968
16069
|
for (const [host, v] of Object.entries(parsed)) {
|
|
@@ -15976,8 +16077,8 @@ function readPointers(stateDir) {
|
|
|
15976
16077
|
}
|
|
15977
16078
|
function writePointers(stateDir, pointers) {
|
|
15978
16079
|
const file = lastSessionFile(stateDir);
|
|
15979
|
-
|
|
15980
|
-
|
|
16080
|
+
mkdirSync24(dirname17(file), { recursive: true });
|
|
16081
|
+
writeFileSync26(file, `${JSON.stringify(pointers, null, 2)}
|
|
15981
16082
|
`, { mode: 384 });
|
|
15982
16083
|
}
|
|
15983
16084
|
function rememberSession(stateDir, host, workspaceSlug) {
|
|
@@ -15994,7 +16095,7 @@ function forgetWorkspace(stateDir, host, workspaceSlug) {
|
|
|
15994
16095
|
const { [host]: _old, ...rest } = all;
|
|
15995
16096
|
const next = left.length ? { ...rest, [host]: left } : rest;
|
|
15996
16097
|
if (Object.keys(next).length) writePointers(stateDir, next);
|
|
15997
|
-
else
|
|
16098
|
+
else rmSync19(lastSessionFile(stateDir), { force: true });
|
|
15998
16099
|
} catch {
|
|
15999
16100
|
}
|
|
16000
16101
|
}
|
|
@@ -16034,7 +16135,7 @@ function forgetSession(stateDir, host) {
|
|
|
16034
16135
|
try {
|
|
16035
16136
|
const { [host]: _gone, ...rest } = readPointers(stateDir);
|
|
16036
16137
|
if (Object.keys(rest).length) writePointers(stateDir, rest);
|
|
16037
|
-
else
|
|
16138
|
+
else rmSync19(lastSessionFile(stateDir), { force: true });
|
|
16038
16139
|
} catch {
|
|
16039
16140
|
}
|
|
16040
16141
|
}
|
|
@@ -16062,15 +16163,15 @@ async function signOutSessions(o) {
|
|
|
16062
16163
|
}
|
|
16063
16164
|
|
|
16064
16165
|
// src/reset.ts
|
|
16065
|
-
import { existsSync as existsSync35, mkdirSync as
|
|
16066
|
-
import { dirname as dirname18, join as
|
|
16166
|
+
import { existsSync as existsSync35, mkdirSync as mkdirSync25, readFileSync as readFileSync36, readdirSync as readdirSync14, rmSync as rmSync20, statSync as statSync12, writeFileSync as writeFileSync27 } from "fs";
|
|
16167
|
+
import { dirname as dirname18, join as join39 } from "path";
|
|
16067
16168
|
import { hostFromUrl as hostFromUrl3 } from "@tablation/client";
|
|
16068
16169
|
function clonedCheckoutsFile(stateDir) {
|
|
16069
|
-
return
|
|
16170
|
+
return join39(stateDir, "cloned-checkouts.json");
|
|
16070
16171
|
}
|
|
16071
16172
|
function readClonedCheckouts(stateDir) {
|
|
16072
16173
|
try {
|
|
16073
|
-
const parsed = JSON.parse(
|
|
16174
|
+
const parsed = JSON.parse(readFileSync36(clonedCheckoutsFile(stateDir), "utf8"));
|
|
16074
16175
|
return Array.isArray(parsed) ? parsed.filter((d) => typeof d === "string") : [];
|
|
16075
16176
|
} catch {
|
|
16076
16177
|
return [];
|
|
@@ -16080,8 +16181,8 @@ function recordClonedCheckout(stateDir, dir) {
|
|
|
16080
16181
|
const known = readClonedCheckouts(stateDir);
|
|
16081
16182
|
if (known.includes(dir)) return;
|
|
16082
16183
|
const file = clonedCheckoutsFile(stateDir);
|
|
16083
|
-
|
|
16084
|
-
|
|
16184
|
+
mkdirSync25(dirname18(file), { recursive: true });
|
|
16185
|
+
writeFileSync27(file, `${JSON.stringify([...known, dir], null, 2)}
|
|
16085
16186
|
`);
|
|
16086
16187
|
}
|
|
16087
16188
|
var mark = (dryRun) => dryRun ? "would-remove" : "removed";
|
|
@@ -16136,7 +16237,7 @@ async function runReset(o, fx) {
|
|
|
16136
16237
|
if (o.beforeState) steps.push(...await o.beforeState());
|
|
16137
16238
|
steps.push(...o.wipeState ? wipeStateDir(o.stateDir, o.dryRun) : removeState(o.stateDir, o.dryRun));
|
|
16138
16239
|
if (existsSync35(o.configFile)) {
|
|
16139
|
-
if (!o.dryRun)
|
|
16240
|
+
if (!o.dryRun) rmSync20(o.configFile, { force: true });
|
|
16140
16241
|
steps.push({ step: "config", target: o.configFile, action: mark(o.dryRun) });
|
|
16141
16242
|
} else {
|
|
16142
16243
|
steps.push({ step: "config", target: o.configFile, action: "absent" });
|
|
@@ -16152,21 +16253,21 @@ function removeCheckout(dir, dryRun, fx) {
|
|
|
16152
16253
|
if (linkedWorktrees.length) {
|
|
16153
16254
|
return { step: "checkout", target: dir, action: "kept", detail: `has linked worktrees (${linkedWorktrees.join(", ")}); remove them first` };
|
|
16154
16255
|
}
|
|
16155
|
-
if (!dryRun)
|
|
16256
|
+
if (!dryRun) rmSync20(dir, { recursive: true, force: true });
|
|
16156
16257
|
return { step: "checkout", target: dir, action: mark(dryRun) };
|
|
16157
16258
|
}
|
|
16158
16259
|
function removeState(stateDir, dryRun) {
|
|
16159
16260
|
const out = [];
|
|
16160
|
-
const targets = [
|
|
16261
|
+
const targets = [join39(stateDir, "resolved"), join39(stateDir, "keys"), clonedCheckoutsFile(stateDir), join39(stateDir, "connect-session.json"), join39(stateDir, "reload-requested"), join39(stateDir, "daemon.started")];
|
|
16161
16262
|
try {
|
|
16162
16263
|
for (const name of readdirSync14(stateDir)) {
|
|
16163
|
-
if (name.startsWith(".") && statSync12(
|
|
16264
|
+
if (name.startsWith(".") && statSync12(join39(stateDir, name)).isFile()) targets.push(join39(stateDir, name));
|
|
16164
16265
|
}
|
|
16165
16266
|
} catch {
|
|
16166
16267
|
}
|
|
16167
16268
|
for (const t of targets) {
|
|
16168
16269
|
if (!existsSync35(t)) continue;
|
|
16169
|
-
if (!dryRun)
|
|
16270
|
+
if (!dryRun) rmSync20(t, { recursive: true, force: true });
|
|
16170
16271
|
out.push({ step: "state", target: t, action: mark(dryRun) });
|
|
16171
16272
|
}
|
|
16172
16273
|
if (!out.length) out.push({ step: "state", target: stateDir, action: "absent", detail: "nothing to remove" });
|
|
@@ -16180,7 +16281,7 @@ function wipeStateDir(stateDir, dryRun) {
|
|
|
16180
16281
|
return [{ step: "state", target: stateDir, action: "absent", detail: "no state directory" }];
|
|
16181
16282
|
}
|
|
16182
16283
|
if (!names.length) return [{ step: "state", target: stateDir, action: "absent", detail: "already empty" }];
|
|
16183
|
-
if (!dryRun) for (const n of names)
|
|
16284
|
+
if (!dryRun) for (const n of names) rmSync20(join39(stateDir, n), { recursive: true, force: true });
|
|
16184
16285
|
return [{ step: "state", target: stateDir, action: mark(dryRun), detail: `${names.length} entr${names.length === 1 ? "y" : "ies"}` }];
|
|
16185
16286
|
}
|
|
16186
16287
|
function describeResetStep(s) {
|
|
@@ -16262,9 +16363,9 @@ async function runDeprovision(o, fx, deps) {
|
|
|
16262
16363
|
}
|
|
16263
16364
|
|
|
16264
16365
|
// src/pool-member.ts
|
|
16265
|
-
import { mkdirSync as
|
|
16366
|
+
import { mkdirSync as mkdirSync26, readFileSync as readFileSync37, renameSync as renameSync7, writeFileSync as writeFileSync28 } from "fs";
|
|
16266
16367
|
import { homedir as homedir8 } from "os";
|
|
16267
|
-
import { dirname as dirname19, join as
|
|
16368
|
+
import { dirname as dirname19, join as join40 } from "path";
|
|
16268
16369
|
var POOL_EXIT = { ok: 0, failed: 1, credential: 2 };
|
|
16269
16370
|
function backoffMs(attempt) {
|
|
16270
16371
|
return Math.min(6e4, 5e3 * 2 ** Math.max(0, attempt));
|
|
@@ -16506,24 +16607,24 @@ async function runPoolMember(deps) {
|
|
|
16506
16607
|
}
|
|
16507
16608
|
}
|
|
16508
16609
|
function defaultMemberDir(env = process.env) {
|
|
16509
|
-
return env.CREW_POOL_DIR ??
|
|
16610
|
+
return env.CREW_POOL_DIR ?? join40(env.XDG_STATE_HOME ?? join40(homedir8(), ".local", "state"), "crew-pool-member");
|
|
16510
16611
|
}
|
|
16511
16612
|
function fileMemberStore(dir) {
|
|
16512
|
-
const file =
|
|
16613
|
+
const file = join40(dir, "member.json");
|
|
16513
16614
|
return {
|
|
16514
16615
|
read() {
|
|
16515
16616
|
try {
|
|
16516
|
-
return JSON.parse(
|
|
16617
|
+
return JSON.parse(readFileSync37(file, "utf8"));
|
|
16517
16618
|
} catch {
|
|
16518
16619
|
return {};
|
|
16519
16620
|
}
|
|
16520
16621
|
},
|
|
16521
16622
|
write(f) {
|
|
16522
|
-
|
|
16623
|
+
mkdirSync26(dirname19(file), { recursive: true, mode: 448 });
|
|
16523
16624
|
const tmp = `${file}.tmp`;
|
|
16524
|
-
|
|
16625
|
+
writeFileSync28(tmp, `${JSON.stringify(f)}
|
|
16525
16626
|
`, { mode: 384 });
|
|
16526
|
-
|
|
16627
|
+
renameSync7(tmp, file);
|
|
16527
16628
|
}
|
|
16528
16629
|
};
|
|
16529
16630
|
}
|
|
@@ -16579,10 +16680,10 @@ import { hostname as hostname3 } from "os";
|
|
|
16579
16680
|
// src/machine-id.ts
|
|
16580
16681
|
import { execFileSync as execFileSync12 } from "child_process";
|
|
16581
16682
|
import { createHash as createHash8 } from "crypto";
|
|
16582
|
-
import { existsSync as existsSync36, mkdirSync as
|
|
16583
|
-
import { dirname as dirname20, join as
|
|
16683
|
+
import { existsSync as existsSync36, mkdirSync as mkdirSync27, readFileSync as readFileSync38, writeFileSync as writeFileSync29 } from "fs";
|
|
16684
|
+
import { dirname as dirname20, join as join41 } from "path";
|
|
16584
16685
|
function machineIdPathFor(stateDir) {
|
|
16585
|
-
return
|
|
16686
|
+
return join41(stateDir, "machine-id");
|
|
16586
16687
|
}
|
|
16587
16688
|
var sha256 = (s) => createHash8("sha256").update(s).digest("hex");
|
|
16588
16689
|
function readRawMachineId(platform2 = process.platform) {
|
|
@@ -16596,7 +16697,7 @@ function readRawMachineId(platform2 = process.platform) {
|
|
|
16596
16697
|
}
|
|
16597
16698
|
for (const p of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
|
|
16598
16699
|
if (existsSync36(p)) {
|
|
16599
|
-
const id =
|
|
16700
|
+
const id = readFileSync38(p, "utf8").trim();
|
|
16600
16701
|
if (id) return id;
|
|
16601
16702
|
}
|
|
16602
16703
|
}
|
|
@@ -16608,14 +16709,14 @@ function ensureMachineId(stateDir, opts = {}) {
|
|
|
16608
16709
|
if (opts.override?.trim()) return sha256(opts.override.trim());
|
|
16609
16710
|
const path = machineIdPathFor(stateDir);
|
|
16610
16711
|
if (existsSync36(path)) {
|
|
16611
|
-
const cached =
|
|
16712
|
+
const cached = readFileSync38(path, "utf8").trim();
|
|
16612
16713
|
if (/^[0-9a-f]{64}$/.test(cached)) return cached;
|
|
16613
16714
|
}
|
|
16614
16715
|
const raw = (opts.read ?? readRawMachineId)();
|
|
16615
16716
|
if (!raw) return void 0;
|
|
16616
16717
|
const hashed = sha256(raw);
|
|
16617
|
-
|
|
16618
|
-
|
|
16718
|
+
mkdirSync27(dirname20(path), { recursive: true });
|
|
16719
|
+
writeFileSync29(path, `${hashed}
|
|
16619
16720
|
`, { mode: 384 });
|
|
16620
16721
|
return hashed;
|
|
16621
16722
|
}
|
|
@@ -16628,7 +16729,7 @@ function matchShipRows(ships, shipName2, machineId) {
|
|
|
16628
16729
|
|
|
16629
16730
|
// src/provision.ts
|
|
16630
16731
|
import { spawnSync as spawnSync9 } from "child_process";
|
|
16631
|
-
import { existsSync as existsSync37, readFileSync as
|
|
16732
|
+
import { existsSync as existsSync37, readFileSync as readFileSync39, writeFileSync as writeFileSync30 } from "fs";
|
|
16632
16733
|
import { hostname as hostname2 } from "os";
|
|
16633
16734
|
import { parseDocument as parseDocument3, isMap as isMap2, isScalar } from "yaml";
|
|
16634
16735
|
|
|
@@ -16637,7 +16738,7 @@ import { parseDocument as parseDocument2 } from "yaml";
|
|
|
16637
16738
|
|
|
16638
16739
|
// src/repos-cmd.ts
|
|
16639
16740
|
import { homedir as homedir9 } from "os";
|
|
16640
|
-
import { basename as basename10, join as
|
|
16741
|
+
import { basename as basename10, join as join42, resolve as resolve4 } from "path";
|
|
16641
16742
|
import { isMap, isSeq, parseDocument, stringify as stringify2 } from "yaml";
|
|
16642
16743
|
var ReposError = class extends Error {
|
|
16643
16744
|
};
|
|
@@ -16915,7 +17016,7 @@ function planRepoClone(i) {
|
|
|
16915
17016
|
}
|
|
16916
17017
|
const ship = doc.get("ship", true);
|
|
16917
17018
|
const basePath = String(m.get("reposBasePath") ?? (isMap(ship) ? ship.get("reposBasePath") : void 0) ?? "~/Crew");
|
|
16918
|
-
const target = i.dir ? expandDir(i.dir, i.base) :
|
|
17019
|
+
const target = i.dir ? expandDir(i.dir, i.base) : join42(expandDir(basePath, i.base), i.route.split("/")[0], name);
|
|
16919
17020
|
const add = planRepoAdd({ text: i.text, base: i.base, route: i.route, path: target, origin: remote, resolved: i.resolved, name, isCheckout: i.isCheckout });
|
|
16920
17021
|
const forgeHost = i.resolved?.repoForgeHosts?.[id];
|
|
16921
17022
|
return { ...add, remote, target, ...forgeHost ? { forgeHost } : {} };
|
|
@@ -17254,13 +17355,13 @@ function realProvisionDeps(crewHome) {
|
|
|
17254
17355
|
enableRoute(route2) {
|
|
17255
17356
|
const file = configFile();
|
|
17256
17357
|
if (!file) return false;
|
|
17257
|
-
const text2 =
|
|
17358
|
+
const text2 = readFileSync39(file, "utf8");
|
|
17258
17359
|
const doc = parseDocument3(text2);
|
|
17259
17360
|
const routes = doc.get("routes");
|
|
17260
17361
|
const entry = routes?.items?.find((r) => r.get("route") === route2);
|
|
17261
17362
|
if (!entry) throw new Error(`route ${route2} is not in ${file}`);
|
|
17262
17363
|
if (entry.get("enabled") === true) return false;
|
|
17263
|
-
|
|
17364
|
+
writeFileSync30(file, planEnable(text2, route2));
|
|
17264
17365
|
return true;
|
|
17265
17366
|
},
|
|
17266
17367
|
installState() {
|
|
@@ -17280,7 +17381,7 @@ function realProvisionDeps(crewHome) {
|
|
|
17280
17381
|
continue;
|
|
17281
17382
|
}
|
|
17282
17383
|
for (const p of plan.unitPaths) {
|
|
17283
|
-
if (!existsSync37(p) ||
|
|
17384
|
+
if (!existsSync37(p) || readFileSync39(p, "utf8") !== plan.unitContent[p]) unitsStale = true;
|
|
17284
17385
|
}
|
|
17285
17386
|
}
|
|
17286
17387
|
const label = labelFor(crewHome, "run");
|
|
@@ -17304,18 +17405,18 @@ function realProvisionDeps(crewHome) {
|
|
|
17304
17405
|
setShipSetting(key, value2) {
|
|
17305
17406
|
const file = configFile();
|
|
17306
17407
|
if (!file) return false;
|
|
17307
|
-
const doc = parseDocument3(
|
|
17408
|
+
const doc = parseDocument3(readFileSync39(file, "utf8"));
|
|
17308
17409
|
if (doc.getIn(["ship", key]) === value2) return false;
|
|
17309
17410
|
doc.setIn(["ship", key], value2);
|
|
17310
|
-
|
|
17411
|
+
writeFileSync30(file, doc.toString());
|
|
17311
17412
|
return true;
|
|
17312
17413
|
},
|
|
17313
17414
|
applyManagedDefaults() {
|
|
17314
17415
|
const file = configFile();
|
|
17315
17416
|
if (!file) return [];
|
|
17316
|
-
const doc = parseDocument3(
|
|
17417
|
+
const doc = parseDocument3(readFileSync39(file, "utf8"));
|
|
17317
17418
|
const wrote = applyManagedDefaultsToDoc(doc);
|
|
17318
|
-
if (wrote.length)
|
|
17419
|
+
if (wrote.length) writeFileSync30(file, doc.toString());
|
|
17319
17420
|
return wrote;
|
|
17320
17421
|
},
|
|
17321
17422
|
ensureGitIdentity(name, email) {
|
|
@@ -18473,8 +18574,8 @@ function diskFullStop(state) {
|
|
|
18473
18574
|
}
|
|
18474
18575
|
|
|
18475
18576
|
// src/poll.ts
|
|
18476
|
-
import { writeFileSync as
|
|
18477
|
-
import { join as
|
|
18577
|
+
import { writeFileSync as writeFileSync31 } from "fs";
|
|
18578
|
+
import { join as join43 } from "path";
|
|
18478
18579
|
|
|
18479
18580
|
// src/stalled.ts
|
|
18480
18581
|
var STALLED_AFTER_CYCLES = 30;
|
|
@@ -18790,7 +18891,7 @@ async function decideCycle(o) {
|
|
|
18790
18891
|
}
|
|
18791
18892
|
return decision;
|
|
18792
18893
|
}
|
|
18793
|
-
var digestPath = (stateDir, route2, role, runId) =>
|
|
18894
|
+
var digestPath = (stateDir, route2, role, runId) => join43(stateDir, `digest-${route2}-${role}${runId ? `-${runId}` : ""}.md`);
|
|
18794
18895
|
function otherRunsRemoved(tickets, own) {
|
|
18795
18896
|
if (!own) return tickets;
|
|
18796
18897
|
return tickets.filter((t) => t.id === own.ticket.id || !own.inFlight(t.id));
|
|
@@ -18876,7 +18977,7 @@ function writeDigest(o, d, role, stateDir, runId, own) {
|
|
|
18876
18977
|
|
|
18877
18978
|
${body}` : body;
|
|
18878
18979
|
const path = digestPath(stateDir, routeSlug(o.route.route), role, runId);
|
|
18879
|
-
|
|
18980
|
+
writeFileSync31(path, text2);
|
|
18880
18981
|
o.emit.emit(`queue digest written for ${role} (${Buffer.byteLength(text2)} bytes)`, {
|
|
18881
18982
|
data: { role, bytes: Buffer.byteLength(text2) }
|
|
18882
18983
|
});
|
|
@@ -18999,7 +19100,7 @@ async function claimStillHeld(tracker, t, buildingStatus, affinity) {
|
|
|
18999
19100
|
}
|
|
19000
19101
|
|
|
19001
19102
|
// src/repo-refresh.ts
|
|
19002
|
-
import { existsSync as existsSync40, mkdirSync as
|
|
19103
|
+
import { existsSync as existsSync40, mkdirSync as mkdirSync28, readFileSync as readFileSync40, writeFileSync as writeFileSync32 } from "fs";
|
|
19003
19104
|
import { dirname as dirname22 } from "path";
|
|
19004
19105
|
var REFRESH_COOLDOWN_MS = 2 * 6e4;
|
|
19005
19106
|
var UNSERVABLE_PASSES_BEFORE_ATTENTION = 3;
|
|
@@ -19030,10 +19131,10 @@ function applyRepoRows(resolved, rows) {
|
|
|
19030
19131
|
function persistRepoRows(stateDir, routeName, rows) {
|
|
19031
19132
|
const path = resolvedPathFor(stateDir, routeName);
|
|
19032
19133
|
if (!existsSync40(path)) return;
|
|
19033
|
-
const raw = JSON.parse(
|
|
19134
|
+
const raw = JSON.parse(readFileSync40(path, "utf8"));
|
|
19034
19135
|
applyRepoRows(raw, rows);
|
|
19035
|
-
|
|
19036
|
-
|
|
19136
|
+
mkdirSync28(dirname22(path), { recursive: true });
|
|
19137
|
+
writeFileSync32(path, `${JSON.stringify(raw, null, 2)}
|
|
19037
19138
|
`);
|
|
19038
19139
|
}
|
|
19039
19140
|
async function refreshUnknownRepos(o) {
|
|
@@ -19509,7 +19610,7 @@ Ship ${shipName2} found: ${problem}. The release refuses to squash a ref nobody
|
|
|
19509
19610
|
var localRefSkipReported = (ticket, problem, events) => events.some((e) => e.record_id === ticket.id && e.event_type === "local_ref_skip" && (e.message ?? "").includes(problem));
|
|
19510
19611
|
|
|
19511
19612
|
// src/platform-gate.ts
|
|
19512
|
-
import { join as
|
|
19613
|
+
import { join as join44 } from "path";
|
|
19513
19614
|
function platformAdmitters(dir, baseRef, ship, tickets, locate) {
|
|
19514
19615
|
const out = [];
|
|
19515
19616
|
for (const t of tickets) {
|
|
@@ -19521,7 +19622,7 @@ function platformAdmitters(dir, baseRef, ship, tickets, locate) {
|
|
|
19521
19622
|
const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
|
|
19522
19623
|
if (text2 === null) continue;
|
|
19523
19624
|
try {
|
|
19524
|
-
const { platform: platform2 } = parseRepoConfig(text2,
|
|
19625
|
+
const { platform: platform2 } = parseRepoConfig(text2, join44(dir, file));
|
|
19525
19626
|
if (satisfies(ship, platform2)) out.push({ issueId: t.issue_id, branch, platform: platform2 });
|
|
19526
19627
|
} catch (e) {
|
|
19527
19628
|
if (e instanceof RepoConfigError) continue;
|
|
@@ -19537,8 +19638,8 @@ function platformStuckNote(repo, required, ship, issueIds) {
|
|
|
19537
19638
|
}
|
|
19538
19639
|
|
|
19539
19640
|
// src/connect-wizard.ts
|
|
19540
|
-
import { delimiter, dirname as dirname23, join as
|
|
19541
|
-
import { accessSync as accessSync3, constants as constants3, existsSync as existsSync41, mkdirSync as
|
|
19641
|
+
import { delimiter, dirname as dirname23, join as join45 } from "path";
|
|
19642
|
+
import { accessSync as accessSync3, constants as constants3, existsSync as existsSync41, mkdirSync as mkdirSync29, writeFileSync as writeFileSync33 } from "fs";
|
|
19542
19643
|
import { stringify as stringify3 } from "yaml";
|
|
19543
19644
|
var HOST_PASSENGERS_DOCS_URL = "https://crew.tablation.dev/host-passengers";
|
|
19544
19645
|
function shouldRunWizard(opts) {
|
|
@@ -19560,7 +19661,7 @@ function defaultIsExecutable(p) {
|
|
|
19560
19661
|
function findOnPath2(name, pathEnv, isExecutable = defaultIsExecutable) {
|
|
19561
19662
|
for (const dir of pathEnv.split(delimiter)) {
|
|
19562
19663
|
if (!dir) continue;
|
|
19563
|
-
const candidate =
|
|
19664
|
+
const candidate = join45(dir, name);
|
|
19564
19665
|
if (isExecutable(candidate)) return candidate;
|
|
19565
19666
|
}
|
|
19566
19667
|
return void 0;
|
|
@@ -19621,9 +19722,9 @@ routes:
|
|
|
19621
19722
|
${routeBlock}`;
|
|
19622
19723
|
}
|
|
19623
19724
|
function writeNewConfig(path, text2) {
|
|
19624
|
-
|
|
19725
|
+
mkdirSync29(dirname23(path), { recursive: true });
|
|
19625
19726
|
try {
|
|
19626
|
-
|
|
19727
|
+
writeFileSync33(path, text2, { mode: 384, flag: "wx" });
|
|
19627
19728
|
return true;
|
|
19628
19729
|
} catch (e) {
|
|
19629
19730
|
if (e.code === "EEXIST") return false;
|
|
@@ -19657,7 +19758,7 @@ Wrote ${o.configPath}.
|
|
|
19657
19758
|
// src/connect-json.ts
|
|
19658
19759
|
import { accessSync as accessSync4, constants as constants4 } from "fs";
|
|
19659
19760
|
import { homedir as homedir10 } from "os";
|
|
19660
|
-
import { dirname as dirname24, join as
|
|
19761
|
+
import { dirname as dirname24, join as join46 } from "path";
|
|
19661
19762
|
import { delimiter as delimiter2 } from "path";
|
|
19662
19763
|
var CHOICE_EXIT_CODE = 3;
|
|
19663
19764
|
function createEmitter(json2, write) {
|
|
@@ -19696,12 +19797,12 @@ function agentBinSearchDirs(home, pathEnv, extraPath) {
|
|
|
19696
19797
|
const dirs = [
|
|
19697
19798
|
...pathEnv.split(delimiter2),
|
|
19698
19799
|
...(extraPath ?? "").split(delimiter2),
|
|
19699
|
-
|
|
19700
|
-
|
|
19800
|
+
join46(home, ".local/bin"),
|
|
19801
|
+
join46(home, ".claude/local"),
|
|
19701
19802
|
"/opt/homebrew/bin",
|
|
19702
19803
|
"/usr/local/bin",
|
|
19703
|
-
|
|
19704
|
-
|
|
19804
|
+
join46(home, ".npm-global/bin"),
|
|
19805
|
+
join46(home, ".volta/bin")
|
|
19705
19806
|
];
|
|
19706
19807
|
return [...new Set(dirs.filter(Boolean))];
|
|
19707
19808
|
}
|
|
@@ -19822,8 +19923,8 @@ async function collectDiagnostics(d) {
|
|
|
19822
19923
|
}
|
|
19823
19924
|
|
|
19824
19925
|
// src/release-run.ts
|
|
19825
|
-
import { readFileSync as
|
|
19826
|
-
import { dirname as dirname25, join as
|
|
19926
|
+
import { readFileSync as readFileSync41, writeFileSync as writeFileSync34, existsSync as existsSync42, copyFileSync, mkdirSync as mkdirSync30, mkdtempSync as mkdtempSync3, rmSync as rmSync21 } from "fs";
|
|
19927
|
+
import { dirname as dirname25, join as join47 } from "path";
|
|
19827
19928
|
import { tmpdir as tmpdir6, hostname as hostname4 } from "os";
|
|
19828
19929
|
|
|
19829
19930
|
// src/release.ts
|
|
@@ -20613,13 +20714,13 @@ async function bump(o, size) {
|
|
|
20613
20714
|
}
|
|
20614
20715
|
return printed;
|
|
20615
20716
|
}
|
|
20616
|
-
const files = o.repo.release.versionFiles.map((f) =>
|
|
20717
|
+
const files = o.repo.release.versionFiles.map((f) => join47(o.cwd, f));
|
|
20617
20718
|
const first = files[0];
|
|
20618
20719
|
if (!existsAt(first, existsSync42)) {
|
|
20619
20720
|
o.emit.error(`no ${o.repo.release.versionFiles[0]} to read a version from`);
|
|
20620
20721
|
return null;
|
|
20621
20722
|
}
|
|
20622
|
-
const firstText = readTextAt(first, (p) =>
|
|
20723
|
+
const firstText = readTextAt(first, (p) => readFileSync41(p, "utf8"));
|
|
20623
20724
|
const problem = versionFileProblem(o.repo.release.versionFiles[0], firstText);
|
|
20624
20725
|
if (problem) {
|
|
20625
20726
|
o.emit.error(problem);
|
|
@@ -20638,27 +20739,27 @@ async function bump(o, size) {
|
|
|
20638
20739
|
return version;
|
|
20639
20740
|
}
|
|
20640
20741
|
for (const f of files) {
|
|
20641
|
-
const src = readTextAt(f, (p) =>
|
|
20742
|
+
const src = readTextAt(f, (p) => readFileSync41(p, "utf8"));
|
|
20642
20743
|
const out = src.replace(/("version"\s*:\s*")[^"]*(")/, `$1${version}$2`);
|
|
20643
20744
|
if (out === src) {
|
|
20644
20745
|
o.emit.error(`no version field in ${f}`);
|
|
20645
20746
|
return null;
|
|
20646
20747
|
}
|
|
20647
|
-
writeTextAt(f, out,
|
|
20748
|
+
writeTextAt(f, out, writeFileSync34);
|
|
20648
20749
|
}
|
|
20649
20750
|
return version;
|
|
20650
20751
|
}
|
|
20651
20752
|
function writeChangelog(o, version, entries) {
|
|
20652
20753
|
const file = o.repo.release.changelog;
|
|
20653
20754
|
if (!file || entries.length === 0) return;
|
|
20654
|
-
const path =
|
|
20755
|
+
const path = join47(o.cwd, file);
|
|
20655
20756
|
const section = renderChangelogSection(version, (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), entries);
|
|
20656
20757
|
if (o.dryRun) {
|
|
20657
20758
|
o.emit.emit(`would prepend ${entries.length} entr(ies) to ${file}`);
|
|
20658
20759
|
return;
|
|
20659
20760
|
}
|
|
20660
|
-
const existing = existsAt(path, existsSync42) ? readTextAt(path, (p) =>
|
|
20661
|
-
writeTextAt(path, insertChangelogSection(existing, section),
|
|
20761
|
+
const existing = existsAt(path, existsSync42) ? readTextAt(path, (p) => readFileSync41(p, "utf8")) : "# Changelog\n";
|
|
20762
|
+
writeTextAt(path, insertChangelogSection(existing, section), writeFileSync34);
|
|
20662
20763
|
}
|
|
20663
20764
|
async function confirm(o, expected) {
|
|
20664
20765
|
if (!o.repo.hooks.released) return void 0;
|
|
@@ -20741,7 +20842,7 @@ function closeReleaseCheckout(cwd, root, dir, branch, run4 = gitOk) {
|
|
|
20741
20842
|
run4(cwd, ["worktree", "remove", "--force", dir]);
|
|
20742
20843
|
} finally {
|
|
20743
20844
|
try {
|
|
20744
|
-
|
|
20845
|
+
rmSync21(root, { recursive: true, force: true });
|
|
20745
20846
|
} finally {
|
|
20746
20847
|
run4(cwd, ["worktree", "prune"]);
|
|
20747
20848
|
run4(cwd, ["branch", "-D", branch]);
|
|
@@ -20751,8 +20852,8 @@ function closeReleaseCheckout(cwd, root, dir, branch, run4 = gitOk) {
|
|
|
20751
20852
|
function openReleaseCheckout(o) {
|
|
20752
20853
|
const { remote, base } = o.repo.branch;
|
|
20753
20854
|
const branch = `crew/release-${Date.now()}`;
|
|
20754
|
-
const root = mkdtempSync3(
|
|
20755
|
-
const dir =
|
|
20855
|
+
const root = mkdtempSync3(join47(tmpdir6(), "crew-release-"));
|
|
20856
|
+
const dir = join47(root, "checkout");
|
|
20756
20857
|
o.emit.emit(`release checkout: ${dir}`, { step: "release" });
|
|
20757
20858
|
const close = () => closeReleaseCheckout(o.cwd, root, dir, branch);
|
|
20758
20859
|
try {
|
|
@@ -20762,10 +20863,10 @@ function openReleaseCheckout(o) {
|
|
|
20762
20863
|
throw e;
|
|
20763
20864
|
}
|
|
20764
20865
|
for (const f of o.repo.worktrees.copy) {
|
|
20765
|
-
const src =
|
|
20866
|
+
const src = join47(o.cwd, f);
|
|
20766
20867
|
if (!existsSync42(src)) continue;
|
|
20767
|
-
|
|
20768
|
-
copyFileSync(src,
|
|
20868
|
+
mkdirSync30(dirname25(join47(dir, f)), { recursive: true });
|
|
20869
|
+
copyFileSync(src, join47(dir, f));
|
|
20769
20870
|
}
|
|
20770
20871
|
return { dir, branch, close };
|
|
20771
20872
|
}
|
|
@@ -21584,15 +21685,15 @@ async function runCommentDeliveryPass(deps) {
|
|
|
21584
21685
|
}
|
|
21585
21686
|
|
|
21586
21687
|
// src/launchd-start.ts
|
|
21587
|
-
import { readFileSync as
|
|
21688
|
+
import { readFileSync as readFileSync48 } from "fs";
|
|
21588
21689
|
import { spawnSync as spawnSync12 } from "child_process";
|
|
21589
21690
|
|
|
21590
21691
|
// src/daemon-liveness.ts
|
|
21591
|
-
import { existsSync as existsSync49, readFileSync as
|
|
21692
|
+
import { existsSync as existsSync49, readFileSync as readFileSync47 } from "fs";
|
|
21592
21693
|
|
|
21593
21694
|
// src/daemon.ts
|
|
21594
|
-
import { existsSync as existsSync48, mkdirSync as
|
|
21595
|
-
import { join as
|
|
21695
|
+
import { existsSync as existsSync48, mkdirSync as mkdirSync36, readFileSync as readFileSync46, readdirSync as readdirSync15, rmSync as rmSync23, statSync as statSync14, writeFileSync as writeFileSync38 } from "fs";
|
|
21696
|
+
import { join as join52 } from "path";
|
|
21596
21697
|
import { randomBytes } from "crypto";
|
|
21597
21698
|
|
|
21598
21699
|
// src/fleet.ts
|
|
@@ -21682,27 +21783,27 @@ function nextRoles(decision, ran) {
|
|
|
21682
21783
|
}
|
|
21683
21784
|
|
|
21684
21785
|
// src/noop-runs.ts
|
|
21685
|
-
import { existsSync as existsSync43, mkdirSync as
|
|
21686
|
-
import { join as
|
|
21786
|
+
import { existsSync as existsSync43, mkdirSync as mkdirSync31, readFileSync as readFileSync42, renameSync as renameSync8, writeFileSync as writeFileSync35 } from "fs";
|
|
21787
|
+
import { join as join48 } from "path";
|
|
21687
21788
|
var NOOP_DELAYS_MS = [5, 15, 60].map((m) => m * 6e4);
|
|
21688
21789
|
var DEFAULT_NOOP_REPEATS = 3;
|
|
21689
21790
|
var NOOP_BOUNCED_MARKER = calloutHeader("WARNING", "Runs Changed Nothing");
|
|
21690
|
-
var noopRunsPath = (stateDir) =>
|
|
21791
|
+
var noopRunsPath = (stateDir) => join48(stateDir, "noop-runs.json");
|
|
21691
21792
|
var noopRunsKey = (issueId) => `noop_runs:${issueId}`;
|
|
21692
21793
|
function readNoopRuns(stateDir) {
|
|
21693
21794
|
try {
|
|
21694
|
-
const v = JSON.parse(
|
|
21795
|
+
const v = JSON.parse(readFileSync42(noopRunsPath(stateDir), "utf8"));
|
|
21695
21796
|
return v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
21696
21797
|
} catch {
|
|
21697
21798
|
return {};
|
|
21698
21799
|
}
|
|
21699
21800
|
}
|
|
21700
21801
|
function writeNoopRuns(stateDir, state) {
|
|
21701
|
-
|
|
21802
|
+
mkdirSync31(stateDir, { recursive: true });
|
|
21702
21803
|
const file = noopRunsPath(stateDir);
|
|
21703
|
-
|
|
21804
|
+
writeFileSync35(`${file}.tmp`, `${JSON.stringify(state, null, 2)}
|
|
21704
21805
|
`);
|
|
21705
|
-
|
|
21806
|
+
renameSync8(`${file}.tmp`, file);
|
|
21706
21807
|
}
|
|
21707
21808
|
function noopBackedOff(stateDir, recordId, now = Date.now()) {
|
|
21708
21809
|
const e = readNoopRuns(stateDir)[recordId];
|
|
@@ -21777,7 +21878,7 @@ async function settleNoopRun(o) {
|
|
|
21777
21878
|
}
|
|
21778
21879
|
|
|
21779
21880
|
// src/ship-name.ts
|
|
21780
|
-
import { existsSync as existsSync44, mkdirSync as
|
|
21881
|
+
import { existsSync as existsSync44, mkdirSync as mkdirSync32, readFileSync as readFileSync43, renameSync as renameSync9, writeFileSync as writeFileSync36 } from "fs";
|
|
21781
21882
|
import { dirname as dirname26 } from "path";
|
|
21782
21883
|
import { parseDocument as parseDocument4 } from "yaml";
|
|
21783
21884
|
var ShipNameError = class extends Error {
|
|
@@ -21841,7 +21942,7 @@ async function syncRouteName(i) {
|
|
|
21841
21942
|
function readSyncedName(resolvedFile) {
|
|
21842
21943
|
if (!existsSync44(resolvedFile)) return void 0;
|
|
21843
21944
|
try {
|
|
21844
|
-
const v = JSON.parse(
|
|
21945
|
+
const v = JSON.parse(readFileSync43(resolvedFile, "utf8")).shipName;
|
|
21845
21946
|
return typeof v === "string" ? v : void 0;
|
|
21846
21947
|
} catch {
|
|
21847
21948
|
return void 0;
|
|
@@ -21851,22 +21952,22 @@ function writeSyncedName(resolvedFile, name) {
|
|
|
21851
21952
|
if (!existsSync44(resolvedFile)) return;
|
|
21852
21953
|
let raw;
|
|
21853
21954
|
try {
|
|
21854
|
-
raw = JSON.parse(
|
|
21955
|
+
raw = JSON.parse(readFileSync43(resolvedFile, "utf8"));
|
|
21855
21956
|
} catch {
|
|
21856
21957
|
return;
|
|
21857
21958
|
}
|
|
21858
21959
|
if (raw.shipName === name) return;
|
|
21859
21960
|
raw.shipName = name;
|
|
21860
|
-
|
|
21961
|
+
mkdirSync32(dirname26(resolvedFile), { recursive: true });
|
|
21861
21962
|
const tmp = `${resolvedFile}.tmp${process.pid}`;
|
|
21862
|
-
|
|
21963
|
+
writeFileSync36(tmp, `${JSON.stringify(raw, null, 2)}
|
|
21863
21964
|
`);
|
|
21864
|
-
|
|
21965
|
+
renameSync9(tmp, resolvedFile);
|
|
21865
21966
|
}
|
|
21866
21967
|
async function reconcileShipName(i) {
|
|
21867
21968
|
let local = i.ship.name;
|
|
21868
21969
|
try {
|
|
21869
|
-
local = shipNameOfYaml(
|
|
21970
|
+
local = shipNameOfYaml(readFileSync43(i.configFile, "utf8")) ?? local;
|
|
21870
21971
|
} catch {
|
|
21871
21972
|
}
|
|
21872
21973
|
const resolvedFile = resolvedPathFor(i.stateDir, i.route);
|
|
@@ -21890,8 +21991,8 @@ async function reconcileShipName(i) {
|
|
|
21890
21991
|
}
|
|
21891
21992
|
if (result.status !== "ok") return result;
|
|
21892
21993
|
if (result.action === "adopt" || result.action === "row-wins") {
|
|
21893
|
-
const text2 =
|
|
21894
|
-
|
|
21994
|
+
const text2 = readFileSync43(i.configFile, "utf8");
|
|
21995
|
+
writeFileSync36(i.configFile, setShipNameInYaml(text2, result.name));
|
|
21895
21996
|
i.ship.name = result.name;
|
|
21896
21997
|
if (result.action === "row-wins") {
|
|
21897
21998
|
i.emit?.warn(
|
|
@@ -21939,7 +22040,7 @@ async function reconcileRouteShipName(o) {
|
|
|
21939
22040
|
import { existsSync as existsSync45 } from "fs";
|
|
21940
22041
|
|
|
21941
22042
|
// src/passenger-mirror.ts
|
|
21942
|
-
import { mkdirSync as
|
|
22043
|
+
import { mkdirSync as mkdirSync33 } from "fs";
|
|
21943
22044
|
import { dirname as dirname27 } from "path";
|
|
21944
22045
|
function mirrorRepoOf(spec) {
|
|
21945
22046
|
const fromOrigin = spec.originUrl ? parseRemote(spec.originUrl) : null;
|
|
@@ -21959,8 +22060,8 @@ async function materializeMirrorCheckouts(specs, cacheFor = (s) => new SandboxCa
|
|
|
21959
22060
|
}
|
|
21960
22061
|
try {
|
|
21961
22062
|
const parent = dirname27(spec.dir);
|
|
21962
|
-
|
|
21963
|
-
|
|
22063
|
+
mkdirSync33(parent, { recursive: true });
|
|
22064
|
+
mkdirSync33(spec.dir, { recursive: true });
|
|
21964
22065
|
const r = await cacheFor(spec).materialize(repo, spec.base, parent, spec.name);
|
|
21965
22066
|
out.push({ ...base, action: r.changed ? "updated" : "unchanged", detail: r.tip });
|
|
21966
22067
|
} catch (e) {
|
|
@@ -22058,18 +22159,18 @@ function explainRefusal(readable, unreadable) {
|
|
|
22058
22159
|
|
|
22059
22160
|
// src/ssh-keys.ts
|
|
22060
22161
|
import { execFileSync as execFileSync13 } from "child_process";
|
|
22061
|
-
import { existsSync as existsSync46, mkdirSync as
|
|
22062
|
-
import { dirname as dirname28, join as
|
|
22162
|
+
import { existsSync as existsSync46, mkdirSync as mkdirSync34, readFileSync as readFileSync44, chmodSync as chmodSync3 } from "fs";
|
|
22163
|
+
import { dirname as dirname28, join as join49 } from "path";
|
|
22063
22164
|
var SshKeyError = class extends Error {
|
|
22064
22165
|
};
|
|
22065
22166
|
function shipSshKeyPathFor(stateDir) {
|
|
22066
|
-
return
|
|
22167
|
+
return join49(stateDir, "ssh", "id_ed25519");
|
|
22067
22168
|
}
|
|
22068
22169
|
function ensureShipSshKeypair(stateDir) {
|
|
22069
22170
|
const privateKeyPath = shipSshKeyPathFor(stateDir);
|
|
22070
22171
|
const publicKeyPath = `${privateKeyPath}.pub`;
|
|
22071
22172
|
if (!existsSync46(privateKeyPath)) {
|
|
22072
|
-
|
|
22173
|
+
mkdirSync34(dirname28(privateKeyPath), { recursive: true });
|
|
22073
22174
|
try {
|
|
22074
22175
|
execFileSync13("ssh-keygen", [
|
|
22075
22176
|
"-t",
|
|
@@ -22092,7 +22193,7 @@ function ensureShipSshKeypair(stateDir) {
|
|
|
22092
22193
|
if (!existsSync46(publicKeyPath)) {
|
|
22093
22194
|
throw new SshKeyError(`${privateKeyPath} exists but ${publicKeyPath} does not \u2014 regenerate or restore it`);
|
|
22094
22195
|
}
|
|
22095
|
-
const publicKey =
|
|
22196
|
+
const publicKey = readFileSync44(publicKeyPath, "utf8").trim();
|
|
22096
22197
|
return { privateKeyPath, publicKeyPath, publicKey };
|
|
22097
22198
|
}
|
|
22098
22199
|
function sshKeygenAvailable() {
|
|
@@ -22107,7 +22208,7 @@ function sshKeygenAvailable() {
|
|
|
22107
22208
|
// src/periscope-idle.ts
|
|
22108
22209
|
import { execFileSync as execFileSync14 } from "child_process";
|
|
22109
22210
|
import { statSync as statSync13 } from "fs";
|
|
22110
|
-
import { join as
|
|
22211
|
+
import { join as join50 } from "path";
|
|
22111
22212
|
var MAX_SCANNED_FILES = 2e4;
|
|
22112
22213
|
function newestWorktreeMtime(root) {
|
|
22113
22214
|
const a = newestTrackedMtime(root);
|
|
@@ -22132,7 +22233,7 @@ function newestTrackedMtime(root) {
|
|
|
22132
22233
|
if (!rel) continue;
|
|
22133
22234
|
if (++scanned > MAX_SCANNED_FILES) break;
|
|
22134
22235
|
try {
|
|
22135
|
-
const m = statSync13(
|
|
22236
|
+
const m = statSync13(join50(root, rel)).mtimeMs;
|
|
22136
22237
|
if (newest === null || m > newest) newest = m;
|
|
22137
22238
|
} catch {
|
|
22138
22239
|
}
|
|
@@ -22206,8 +22307,8 @@ async function runPeriscopeIdlePass(d) {
|
|
|
22206
22307
|
}
|
|
22207
22308
|
|
|
22208
22309
|
// src/periscope-cmd.ts
|
|
22209
|
-
import { existsSync as existsSync47, mkdirSync as
|
|
22210
|
-
import { join as
|
|
22310
|
+
import { existsSync as existsSync47, mkdirSync as mkdirSync35, readFileSync as readFileSync45, rmSync as rmSync22, writeFileSync as writeFileSync37 } from "fs";
|
|
22311
|
+
import { join as join51 } from "path";
|
|
22211
22312
|
var PeriscopeError = class extends Error {
|
|
22212
22313
|
};
|
|
22213
22314
|
var LivePeriscopeError = class extends PeriscopeError {
|
|
@@ -22217,22 +22318,22 @@ var LivePeriscopeError = class extends PeriscopeError {
|
|
|
22217
22318
|
this.data = { refused: "live_periscope_exists", ...live2 };
|
|
22218
22319
|
}
|
|
22219
22320
|
};
|
|
22220
|
-
var priorDir = (stateDir) =>
|
|
22221
|
-
var priorPath = (stateDir, ticketRecordId) =>
|
|
22321
|
+
var priorDir = (stateDir) => join51(stateDir, "periscope-priors");
|
|
22322
|
+
var priorPath = (stateDir, ticketRecordId) => join51(priorDir(stateDir), `${ticketRecordId}.json`);
|
|
22222
22323
|
function removePeriscopePrior(stateDir, ticketRecordId) {
|
|
22223
|
-
|
|
22324
|
+
rmSync22(priorPath(stateDir, ticketRecordId), { force: true });
|
|
22224
22325
|
}
|
|
22225
22326
|
function writePeriscopePrior(stateDir, ticketRecordId, prior) {
|
|
22226
22327
|
try {
|
|
22227
|
-
|
|
22228
|
-
|
|
22328
|
+
mkdirSync35(priorDir(stateDir), { recursive: true });
|
|
22329
|
+
writeFileSync37(priorPath(stateDir, ticketRecordId), JSON.stringify(prior));
|
|
22229
22330
|
} catch {
|
|
22230
22331
|
}
|
|
22231
22332
|
}
|
|
22232
22333
|
function readPeriscopePrior(stateDir, ticketRecordId) {
|
|
22233
22334
|
try {
|
|
22234
22335
|
const p = priorPath(stateDir, ticketRecordId);
|
|
22235
|
-
return existsSync47(p) ? JSON.parse(
|
|
22336
|
+
return existsSync47(p) ? JSON.parse(readFileSync45(p, "utf8")) : void 0;
|
|
22236
22337
|
} catch {
|
|
22237
22338
|
return void 0;
|
|
22238
22339
|
}
|
|
@@ -22802,7 +22903,7 @@ function latestMtime(path) {
|
|
|
22802
22903
|
if (!stat2.isDirectory()) return 0;
|
|
22803
22904
|
let latest = stat2.mtimeMs;
|
|
22804
22905
|
for (const entry of readdirSync15(path, { withFileTypes: true })) {
|
|
22805
|
-
latest = Math.max(latest, latestMtime(
|
|
22906
|
+
latest = Math.max(latest, latestMtime(join52(path, entry.name)));
|
|
22806
22907
|
}
|
|
22807
22908
|
return latest;
|
|
22808
22909
|
}
|
|
@@ -22814,7 +22915,7 @@ function makeStaleChecker(paths, opts = {}) {
|
|
|
22814
22915
|
return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 && existsSync48(opts.reloadSentinel);
|
|
22815
22916
|
}
|
|
22816
22917
|
function reloadSentinelFor(stateDir) {
|
|
22817
|
-
return
|
|
22918
|
+
return join52(stateDir, "reload-requested");
|
|
22818
22919
|
}
|
|
22819
22920
|
function readReloadRequestedAt(stateDir) {
|
|
22820
22921
|
try {
|
|
@@ -22824,17 +22925,17 @@ function readReloadRequestedAt(stateDir) {
|
|
|
22824
22925
|
}
|
|
22825
22926
|
}
|
|
22826
22927
|
function daemonStampFor(stateDir) {
|
|
22827
|
-
return
|
|
22928
|
+
return join52(stateDir, "daemon.started");
|
|
22828
22929
|
}
|
|
22829
22930
|
function noteDaemonStarted(stateDir, now = Date.now()) {
|
|
22830
|
-
|
|
22831
|
-
|
|
22832
|
-
|
|
22931
|
+
mkdirSync36(stateDir, { recursive: true });
|
|
22932
|
+
rmSync23(reloadSentinelFor(stateDir), { force: true });
|
|
22933
|
+
writeFileSync38(daemonStampFor(stateDir), `${JSON.stringify({ pid: process.pid, startedAt: now })}
|
|
22833
22934
|
`);
|
|
22834
22935
|
}
|
|
22835
22936
|
function readDaemonStarted(stateDir) {
|
|
22836
22937
|
try {
|
|
22837
|
-
const v = JSON.parse(
|
|
22938
|
+
const v = JSON.parse(readFileSync46(daemonStampFor(stateDir), "utf8")).startedAt;
|
|
22838
22939
|
return typeof v === "number" ? v : null;
|
|
22839
22940
|
} catch {
|
|
22840
22941
|
return null;
|
|
@@ -23691,7 +23792,7 @@ function parseSystemctlShow(text2) {
|
|
|
23691
23792
|
}
|
|
23692
23793
|
function lastLogLine(path, read = (p) => {
|
|
23693
23794
|
try {
|
|
23694
|
-
return
|
|
23795
|
+
return readFileSync47(p, "utf8");
|
|
23695
23796
|
} catch {
|
|
23696
23797
|
return null;
|
|
23697
23798
|
}
|
|
@@ -23768,7 +23869,7 @@ function daemonProblem(d, route2) {
|
|
|
23768
23869
|
}
|
|
23769
23870
|
function readDaemonStamp(stateDir) {
|
|
23770
23871
|
try {
|
|
23771
|
-
const v = JSON.parse(
|
|
23872
|
+
const v = JSON.parse(readFileSync47(daemonStampFor(stateDir), "utf8"));
|
|
23772
23873
|
if (typeof v.startedAt !== "number") return null;
|
|
23773
23874
|
return typeof v.pid === "number" ? { pid: v.pid, startedAt: v.startedAt } : { startedAt: v.startedAt };
|
|
23774
23875
|
} catch {
|
|
@@ -23797,7 +23898,7 @@ function defaultSleep2(ms3) {
|
|
|
23797
23898
|
}
|
|
23798
23899
|
function defaultReadLog(path) {
|
|
23799
23900
|
try {
|
|
23800
|
-
return
|
|
23901
|
+
return readFileSync48(path, "utf8");
|
|
23801
23902
|
} catch {
|
|
23802
23903
|
return null;
|
|
23803
23904
|
}
|
|
@@ -23864,15 +23965,15 @@ function startLaunchdDaemon(o) {
|
|
|
23864
23965
|
}
|
|
23865
23966
|
|
|
23866
23967
|
// src/daemon-start-failure.ts
|
|
23867
|
-
import { existsSync as existsSync50, mkdirSync as
|
|
23868
|
-
import { dirname as dirname29, join as
|
|
23968
|
+
import { existsSync as existsSync50, mkdirSync as mkdirSync37, readFileSync as readFileSync49, unlinkSync as unlinkSync4, writeFileSync as writeFileSync39 } from "fs";
|
|
23969
|
+
import { dirname as dirname29, join as join53 } from "path";
|
|
23869
23970
|
var DAEMON_START_FAILED_KEY = "daemon_start_failed";
|
|
23870
23971
|
var START_FAILURE_BACKOFF_MS = 6e4;
|
|
23871
23972
|
var BACKOFF_AFTER_FAILURES = 2;
|
|
23872
|
-
var
|
|
23973
|
+
var fileFor4 = (stateDir) => join53(stateDir, ".daemon-start-failure.json");
|
|
23873
23974
|
function readStartFailure(stateDir) {
|
|
23874
23975
|
try {
|
|
23875
|
-
const parsed = JSON.parse(
|
|
23976
|
+
const parsed = JSON.parse(readFileSync49(fileFor4(stateDir), "utf8"));
|
|
23876
23977
|
return typeof parsed.reason === "string" && typeof parsed.count === "number" ? { reason: parsed.reason, count: parsed.count, firstAt: String(parsed.firstAt), lastAt: String(parsed.lastAt) } : null;
|
|
23877
23978
|
} catch {
|
|
23878
23979
|
return null;
|
|
@@ -23888,8 +23989,8 @@ function noteStartFailure(stateDir, reason, nowMs = Date.now()) {
|
|
|
23888
23989
|
firstAt: same ? previous.firstAt : nowIso,
|
|
23889
23990
|
lastAt: nowIso
|
|
23890
23991
|
};
|
|
23891
|
-
|
|
23892
|
-
|
|
23992
|
+
mkdirSync37(stateDir, { recursive: true });
|
|
23993
|
+
writeFileSync39(fileFor4(stateDir), JSON.stringify(record));
|
|
23893
23994
|
return record;
|
|
23894
23995
|
}
|
|
23895
23996
|
function startFailureDelayMs(count) {
|
|
@@ -23903,9 +24004,9 @@ function startFailureItem(record, o = {}) {
|
|
|
23903
24004
|
return { kind: "daemon_start_failed", key: DAEMON_START_FAILED_KEY, message: parts.join(". ").replace(/\.\./g, "."), since: record.firstAt };
|
|
23904
24005
|
}
|
|
23905
24006
|
function clearStartFailure(state, stateDir) {
|
|
23906
|
-
if (existsSync50(
|
|
24007
|
+
if (existsSync50(fileFor4(stateDir))) {
|
|
23907
24008
|
try {
|
|
23908
|
-
unlinkSync4(
|
|
24009
|
+
unlinkSync4(fileFor4(stateDir));
|
|
23909
24010
|
} catch {
|
|
23910
24011
|
}
|
|
23911
24012
|
}
|
|
@@ -23930,7 +24031,7 @@ async function reportStartFailure(o) {
|
|
|
23930
24031
|
return delay;
|
|
23931
24032
|
}
|
|
23932
24033
|
function fallbackStateDir(configFile) {
|
|
23933
|
-
return
|
|
24034
|
+
return join53(dirname29(configFile), "state");
|
|
23934
24035
|
}
|
|
23935
24036
|
|
|
23936
24037
|
// src/projects-cmd.ts
|
|
@@ -24044,7 +24145,7 @@ function runForge(a, io) {
|
|
|
24044
24145
|
|
|
24045
24146
|
// src/release-sandbox.ts
|
|
24046
24147
|
import { execFile as execFile5 } from "child_process";
|
|
24047
|
-
import { mkdirSync as
|
|
24148
|
+
import { mkdirSync as mkdirSync38, writeFileSync as writeFileSync40 } from "fs";
|
|
24048
24149
|
import { dirname as dirname30 } from "path";
|
|
24049
24150
|
import { promisify as promisify4 } from "util";
|
|
24050
24151
|
var execFileP4 = promisify4(execFile5);
|
|
@@ -24091,8 +24192,8 @@ async function openReleaseSandbox(o) {
|
|
|
24091
24192
|
if (!policyFile) {
|
|
24092
24193
|
generated = generateSandboxPolicy({ mirrorDir: cfg.mirrorDir, workDir: cfg.workDir, ...o.policy });
|
|
24093
24194
|
policyFile = o.policyFile;
|
|
24094
|
-
|
|
24095
|
-
|
|
24195
|
+
mkdirSync38(dirname30(policyFile), { recursive: true });
|
|
24196
|
+
writeFileSync40(policyFile, generated.yaml, { mode: 384 });
|
|
24096
24197
|
}
|
|
24097
24198
|
const secrets = { ...process.env };
|
|
24098
24199
|
const secretKeys = [];
|
|
@@ -25176,13 +25277,13 @@ function describeCapability(i) {
|
|
|
25176
25277
|
}
|
|
25177
25278
|
|
|
25178
25279
|
// src/persona-avatars.ts
|
|
25179
|
-
import { existsSync as existsSync52, readFileSync as
|
|
25180
|
-
import { join as
|
|
25280
|
+
import { existsSync as existsSync52, readFileSync as readFileSync50 } from "fs";
|
|
25281
|
+
import { join as join54 } from "path";
|
|
25181
25282
|
var IMAGE_TYPES = { png: "image/png", svg: "image/svg+xml" };
|
|
25182
25283
|
function personaAvatarFile(promptsDir, role) {
|
|
25183
25284
|
for (const ext of ["png", "svg"]) {
|
|
25184
25285
|
const name = `lane-${role}.${ext}`;
|
|
25185
|
-
const path =
|
|
25286
|
+
const path = join54(promptsDir, "personas", name);
|
|
25186
25287
|
if (existsSync52(path)) return { path, mimeType: IMAGE_TYPES[ext], name };
|
|
25187
25288
|
}
|
|
25188
25289
|
return void 0;
|
|
@@ -25197,7 +25298,7 @@ async function syncPersonaAvatars(route2, agentPersonas, opts) {
|
|
|
25197
25298
|
if (!file || !agentId) continue;
|
|
25198
25299
|
try {
|
|
25199
25300
|
const form = new FormData();
|
|
25200
|
-
form.append("file", new Blob([
|
|
25301
|
+
form.append("file", new Blob([readFileSync50(file.path)], { type: file.mimeType }), file.name);
|
|
25201
25302
|
const res = await fetch(`${base}/${agentId}/avatar`, {
|
|
25202
25303
|
method: "PUT",
|
|
25203
25304
|
headers: { Authorization: `Bearer ${resolveApiKey(route2)}`, "User-Agent": opts.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0" },
|
|
@@ -25238,14 +25339,14 @@ function avatarFailures(raw) {
|
|
|
25238
25339
|
}
|
|
25239
25340
|
function routeAvatarFailures(stateDir, route2) {
|
|
25240
25341
|
try {
|
|
25241
|
-
return avatarFailures(JSON.parse(
|
|
25342
|
+
return avatarFailures(JSON.parse(readFileSync50(resolvedPathFor(stateDir, route2), "utf8")));
|
|
25242
25343
|
} catch {
|
|
25243
25344
|
return [];
|
|
25244
25345
|
}
|
|
25245
25346
|
}
|
|
25246
25347
|
|
|
25247
25348
|
// src/agents-sync-run.ts
|
|
25248
|
-
import { existsSync as existsSync53, mkdirSync as
|
|
25349
|
+
import { existsSync as existsSync53, mkdirSync as mkdirSync39, readFileSync as readFileSync51, writeFileSync as writeFileSync41 } from "fs";
|
|
25249
25350
|
import { dirname as dirname31 } from "path";
|
|
25250
25351
|
async function runAgentsSync(target, o) {
|
|
25251
25352
|
const dryRun = o.dryRun ?? false;
|
|
@@ -25291,13 +25392,13 @@ async function runAgentsSync(target, o) {
|
|
|
25291
25392
|
}
|
|
25292
25393
|
if (!dryRun) {
|
|
25293
25394
|
const resolvedPath = resolvedPathFor(o.stateDir, target.route);
|
|
25294
|
-
const raw = existsSync53(resolvedPath) ? JSON.parse(
|
|
25395
|
+
const raw = existsSync53(resolvedPath) ? JSON.parse(readFileSync51(resolvedPath, "utf8")) : {};
|
|
25295
25396
|
raw.agentPersonas = personaResult.agentPersonas;
|
|
25296
25397
|
if (skillResult) raw.agentSkills = skillResult.agentSkills;
|
|
25297
25398
|
if (!readOnly) raw.avatarSyncFailures = avatarFailures2;
|
|
25298
25399
|
if (personaResult.releaseAgentId) raw.releaseAgentId = personaResult.releaseAgentId;
|
|
25299
|
-
|
|
25300
|
-
|
|
25400
|
+
mkdirSync39(dirname31(resolvedPath), { recursive: true });
|
|
25401
|
+
writeFileSync41(resolvedPath, `${JSON.stringify(raw, null, 2)}
|
|
25301
25402
|
`);
|
|
25302
25403
|
if (target.resolved) {
|
|
25303
25404
|
target.resolved.agentPersonas = personaResult.agentPersonas;
|
|
@@ -25434,7 +25535,7 @@ async function showLogEntry(route2, entryId, opts = {}) {
|
|
|
25434
25535
|
|
|
25435
25536
|
// src/repos-check.ts
|
|
25436
25537
|
import { spawnSync as spawnSync13 } from "child_process";
|
|
25437
|
-
import { readFileSync as
|
|
25538
|
+
import { readFileSync as readFileSync52 } from "fs";
|
|
25438
25539
|
import { basename as basename12 } from "path";
|
|
25439
25540
|
var POSIX_SHELL = /^(?:ba|z|da|k|a|mk)?sh$|^fish$/;
|
|
25440
25541
|
function checkHookSyntax(script, shell) {
|
|
@@ -25475,7 +25576,7 @@ function checkRepoSpec(dir, opts = {}) {
|
|
|
25475
25576
|
}
|
|
25476
25577
|
let parsed;
|
|
25477
25578
|
try {
|
|
25478
|
-
parsed = parseRepoConfig(
|
|
25579
|
+
parsed = parseRepoConfig(readFileSync52(file, "utf8"), file);
|
|
25479
25580
|
} catch (e) {
|
|
25480
25581
|
if (!(e instanceof RepoConfigError)) throw e;
|
|
25481
25582
|
return { ...empty, file, error: e.message, exitCode: 1 };
|
|
@@ -25939,7 +26040,7 @@ ${run4.err}` });
|
|
|
25939
26040
|
}
|
|
25940
26041
|
|
|
25941
26042
|
// src/sample-ticket.ts
|
|
25942
|
-
import { basename as basename13, dirname as dirname32, join as
|
|
26043
|
+
import { basename as basename13, dirname as dirname32, join as join55 } from "path";
|
|
25943
26044
|
var SAMPLE_REPO = "crew-sample";
|
|
25944
26045
|
var SAMPLE_REMOTE = `local/${SAMPLE_REPO}`;
|
|
25945
26046
|
var SAMPLE_MARKER = "sample: true";
|
|
@@ -25962,8 +26063,8 @@ has something safe to work on: its test and build hooks always pass, it has no
|
|
|
25962
26063
|
remote, and \`crew sample-ticket --remove\` deletes it.
|
|
25963
26064
|
`;
|
|
25964
26065
|
function sampleDir(existing, reposBase, workspace) {
|
|
25965
|
-
if (existing.length > 0) return
|
|
25966
|
-
return
|
|
26066
|
+
if (existing.length > 0) return join55(dirname32(existing[0]), SAMPLE_REPO);
|
|
26067
|
+
return join55(reposBase, workspace, SAMPLE_REPO);
|
|
25967
26068
|
}
|
|
25968
26069
|
var SAMPLE_TITLE = "Sample: add a documented `greet` function with a test";
|
|
25969
26070
|
function sampleDescription() {
|
|
@@ -26007,8 +26108,8 @@ function planSampleTicket(i) {
|
|
|
26007
26108
|
}
|
|
26008
26109
|
|
|
26009
26110
|
// src/worktree-sweep.ts
|
|
26010
|
-
import { existsSync as existsSync54, readFileSync as
|
|
26011
|
-
import { basename as basename14, dirname as dirname33, join as
|
|
26111
|
+
import { existsSync as existsSync54, readFileSync as readFileSync53, readdirSync as readdirSync16 } from "fs";
|
|
26112
|
+
import { basename as basename14, dirname as dirname33, join as join56, resolve as resolve5 } from "path";
|
|
26012
26113
|
function planWorktreeSweep(target, tickets, contract) {
|
|
26013
26114
|
const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
|
|
26014
26115
|
const verified = contract.statuses.verified;
|
|
@@ -26085,7 +26186,7 @@ function siblingWorktreeDirs(target) {
|
|
|
26085
26186
|
for (const name of names) {
|
|
26086
26187
|
if (!name.startsWith(stem)) continue;
|
|
26087
26188
|
const m = DIR_NUMBER_SUFFIXED.exec(name);
|
|
26088
|
-
const path =
|
|
26189
|
+
const path = join56(parent, name);
|
|
26089
26190
|
if (m && !registered.has(resolve5(path))) out.push({ path, number: m[1] });
|
|
26090
26191
|
}
|
|
26091
26192
|
return out;
|
|
@@ -26207,7 +26308,7 @@ function isHandBackMerge(path, base) {
|
|
|
26207
26308
|
if (!msgPath) return false;
|
|
26208
26309
|
let first;
|
|
26209
26310
|
try {
|
|
26210
|
-
first =
|
|
26311
|
+
first = readFileSync53(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
|
|
26211
26312
|
} catch {
|
|
26212
26313
|
return false;
|
|
26213
26314
|
}
|
|
@@ -26312,14 +26413,14 @@ function applyRemoteBranchCleanup(cwd, remote, branches2, dryRun, log) {
|
|
|
26312
26413
|
}
|
|
26313
26414
|
|
|
26314
26415
|
// src/stream-sweep.ts
|
|
26315
|
-
import { existsSync as existsSync55, readdirSync as readdirSync17, rmSync as
|
|
26316
|
-
import { join as
|
|
26416
|
+
import { existsSync as existsSync55, readdirSync as readdirSync17, rmSync as rmSync24, statSync as statSync16 } from "fs";
|
|
26417
|
+
import { join as join57 } from "path";
|
|
26317
26418
|
var DAY_MS2 = 24 * 60 * 60 * 1e3;
|
|
26318
26419
|
function planStreamSweep(stateDir, retentionDays, now = Date.now()) {
|
|
26319
|
-
const dir =
|
|
26420
|
+
const dir = join57(stateDir, "streams");
|
|
26320
26421
|
if (!existsSync55(dir)) return [];
|
|
26321
26422
|
const cutoff = now - retentionDays * DAY_MS2;
|
|
26322
|
-
return readdirSync17(dir).map((name) =>
|
|
26423
|
+
return readdirSync17(dir).map((name) => join57(dir, name)).filter((path) => {
|
|
26323
26424
|
try {
|
|
26324
26425
|
return statSync16(path).mtimeMs < cutoff;
|
|
26325
26426
|
} catch {
|
|
@@ -26335,7 +26436,7 @@ function applyStreamSweep(paths, dryRun, log) {
|
|
|
26335
26436
|
continue;
|
|
26336
26437
|
}
|
|
26337
26438
|
try {
|
|
26338
|
-
|
|
26439
|
+
rmSync24(path, { force: true });
|
|
26339
26440
|
removed++;
|
|
26340
26441
|
log.emit(`removed stream artifact ${path}`, { step: "worktree" });
|
|
26341
26442
|
} catch (e) {
|
|
@@ -26347,7 +26448,7 @@ function applyStreamSweep(paths, dryRun, log) {
|
|
|
26347
26448
|
function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
|
|
26348
26449
|
if (!existsSync55(stateDir)) return [];
|
|
26349
26450
|
const cutoff = now - retentionDays * DAY_MS2;
|
|
26350
|
-
return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) =>
|
|
26451
|
+
return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join57(stateDir, name)).filter((path) => {
|
|
26351
26452
|
try {
|
|
26352
26453
|
return statSync16(path).mtimeMs < cutoff;
|
|
26353
26454
|
} catch {
|
|
@@ -26357,7 +26458,7 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
|
|
|
26357
26458
|
}
|
|
26358
26459
|
|
|
26359
26460
|
// src/cli.ts
|
|
26360
|
-
import { realpathSync as realpathSync3, readFileSync as
|
|
26461
|
+
import { realpathSync as realpathSync3, readFileSync as readFileSync56, existsSync as existsSync60, mkdirSync as mkdirSync43, writeFileSync as writeFileSync44, rmSync as rmSync27, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync10, statSync as statSync19, readdirSync as readdirSync22 } from "fs";
|
|
26361
26462
|
import { createInterface } from "readline/promises";
|
|
26362
26463
|
|
|
26363
26464
|
// src/periscope-resume.ts
|
|
@@ -26434,9 +26535,9 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
|
26434
26535
|
|
|
26435
26536
|
// src/bundle-staleness.ts
|
|
26436
26537
|
import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
|
|
26437
|
-
import { join as
|
|
26538
|
+
import { join as join58 } from "path";
|
|
26438
26539
|
function builtVersion() {
|
|
26439
|
-
return true ? "0.
|
|
26540
|
+
return true ? "0.146.0" : null;
|
|
26440
26541
|
}
|
|
26441
26542
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
26442
26543
|
function newestMtime(path) {
|
|
@@ -26449,17 +26550,17 @@ function newestMtime(path) {
|
|
|
26449
26550
|
if (stat2.isFile()) return stat2.mtimeMs;
|
|
26450
26551
|
if (!stat2.isDirectory()) return 0;
|
|
26451
26552
|
let latest = stat2.mtimeMs;
|
|
26452
|
-
for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(
|
|
26553
|
+
for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join58(path, e.name)));
|
|
26453
26554
|
return latest;
|
|
26454
26555
|
}
|
|
26455
26556
|
function bundleStaleness(i) {
|
|
26456
26557
|
if (i.built === null || i.compiled) return null;
|
|
26457
|
-
const src =
|
|
26558
|
+
const src = join58(i.home, "src");
|
|
26458
26559
|
if (!existsSync56(src)) return null;
|
|
26459
26560
|
if (i.built !== i.current) {
|
|
26460
26561
|
return { kind: "version", builtVersion: i.built, message: `running a bundle built from ${i.built} (package.json names ${i.current}); ${REBUILD_HINT}` };
|
|
26461
26562
|
}
|
|
26462
|
-
const bundle = statSafe(
|
|
26563
|
+
const bundle = statSafe(join58(i.home, "dist", "cli.js"));
|
|
26463
26564
|
if (bundle === null) return null;
|
|
26464
26565
|
if (newestMtime(src) > bundle) {
|
|
26465
26566
|
return { kind: "source", builtVersion: i.built, message: `running a bundle older than the source in src/ (both ${i.current}); ${REBUILD_HINT}` };
|
|
@@ -26626,8 +26727,8 @@ async function unregisterEndpoint(workspaceId, info, d) {
|
|
|
26626
26727
|
import { createServer as createHttpServer } from "http";
|
|
26627
26728
|
import { spawn as spawn9 } from "child_process";
|
|
26628
26729
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
26629
|
-
import { existsSync as existsSync57, mkdirSync as
|
|
26630
|
-
import { join as
|
|
26730
|
+
import { existsSync as existsSync57, mkdirSync as mkdirSync40, readFileSync as readFileSync54, writeFileSync as writeFileSync42, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
|
|
26731
|
+
import { join as join59 } from "path";
|
|
26631
26732
|
|
|
26632
26733
|
// src/secret-compare.ts
|
|
26633
26734
|
import { timingSafeEqual } from "crypto";
|
|
@@ -26720,21 +26821,21 @@ var defaultSpawn2 = (cmd, args, env) => {
|
|
|
26720
26821
|
return child;
|
|
26721
26822
|
};
|
|
26722
26823
|
function syncDaemonStatePath(stateDir, workspaceId) {
|
|
26723
|
-
return
|
|
26824
|
+
return join59(stateDir, "passengers", `${workspaceId}-sync.json`);
|
|
26724
26825
|
}
|
|
26725
26826
|
function readPersistedSyncDaemon(stateDir, workspaceId) {
|
|
26726
26827
|
const path = syncDaemonStatePath(stateDir, workspaceId);
|
|
26727
26828
|
if (!existsSync57(path)) return void 0;
|
|
26728
26829
|
try {
|
|
26729
|
-
return JSON.parse(
|
|
26830
|
+
return JSON.parse(readFileSync54(path, "utf8"));
|
|
26730
26831
|
} catch {
|
|
26731
26832
|
return void 0;
|
|
26732
26833
|
}
|
|
26733
26834
|
}
|
|
26734
26835
|
function writePersistedSyncDaemon(stateDir, state) {
|
|
26735
26836
|
const path = syncDaemonStatePath(stateDir, state.workspaceId);
|
|
26736
|
-
|
|
26737
|
-
|
|
26837
|
+
mkdirSync40(join59(stateDir, "passengers"), { recursive: true });
|
|
26838
|
+
writeFileSync42(path, `${JSON.stringify(state, null, 2)}
|
|
26738
26839
|
`);
|
|
26739
26840
|
}
|
|
26740
26841
|
function removePersistedSyncDaemon(stateDir, workspaceId) {
|
|
@@ -26754,7 +26855,7 @@ function waitForExit(pid, alive, timeoutMs = 5e3) {
|
|
|
26754
26855
|
}
|
|
26755
26856
|
}
|
|
26756
26857
|
function readAllPersistedSyncWorkspaceIds(stateDir) {
|
|
26757
|
-
const dir =
|
|
26858
|
+
const dir = join59(stateDir, "passengers");
|
|
26758
26859
|
if (!existsSync57(dir)) return [];
|
|
26759
26860
|
const suffix = "-sync.json";
|
|
26760
26861
|
return readdirSync19(dir).filter((f) => f.endsWith(suffix)).map((f) => f.slice(0, -suffix.length));
|
|
@@ -26813,7 +26914,7 @@ function syncPassengerSyncDaemons(plans, cfg, stateDir, deps = {}) {
|
|
|
26813
26914
|
|
|
26814
26915
|
// src/periscope-proxy.ts
|
|
26815
26916
|
import { spawn as spawn10 } from "child_process";
|
|
26816
|
-
import { appendFileSync as
|
|
26917
|
+
import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync41 } from "fs";
|
|
26817
26918
|
import { createServer, request as httpRequest } from "http";
|
|
26818
26919
|
import { request as httpsRequest } from "https";
|
|
26819
26920
|
import { connect as netConnect } from "net";
|
|
@@ -26932,8 +27033,8 @@ function parsePointedBody(raw) {
|
|
|
26932
27033
|
return entry;
|
|
26933
27034
|
}
|
|
26934
27035
|
function appendPointed(file, entry, now = /* @__PURE__ */ new Date()) {
|
|
26935
|
-
|
|
26936
|
-
|
|
27036
|
+
mkdirSync41(dirname34(file), { recursive: true });
|
|
27037
|
+
appendFileSync4(file, `${JSON.stringify({ ...entry, at: now.toISOString() })}
|
|
26937
27038
|
`);
|
|
26938
27039
|
}
|
|
26939
27040
|
var CSP_DIRECTIVES = /* @__PURE__ */ new Set(["default-src", "script-src", "script-src-elem", "connect-src"]);
|
|
@@ -27221,7 +27322,7 @@ async function startWorktreeIntel(d) {
|
|
|
27221
27322
|
}
|
|
27222
27323
|
|
|
27223
27324
|
// src/contract-refusal.ts
|
|
27224
|
-
import { join as
|
|
27325
|
+
import { join as join60 } from "path";
|
|
27225
27326
|
function contractFixers(dir, baseRef, tickets, locate) {
|
|
27226
27327
|
const out = [];
|
|
27227
27328
|
for (const t of tickets) {
|
|
@@ -27233,7 +27334,7 @@ function contractFixers(dir, baseRef, tickets, locate) {
|
|
|
27233
27334
|
const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
|
|
27234
27335
|
if (text2 === null) continue;
|
|
27235
27336
|
try {
|
|
27236
|
-
parseRepoConfig(text2,
|
|
27337
|
+
parseRepoConfig(text2, join60(dir, file));
|
|
27237
27338
|
} catch (e) {
|
|
27238
27339
|
if (e instanceof RepoConfigError) continue;
|
|
27239
27340
|
throw e;
|
|
@@ -27253,13 +27354,13 @@ import {
|
|
|
27253
27354
|
openSync as openSync7,
|
|
27254
27355
|
readSync as readSync4,
|
|
27255
27356
|
readdirSync as readdirSync20,
|
|
27256
|
-
rmSync as
|
|
27357
|
+
rmSync as rmSync25,
|
|
27257
27358
|
statSync as statSync18,
|
|
27258
27359
|
watch
|
|
27259
27360
|
} from "fs";
|
|
27260
27361
|
import { createConnection } from "net";
|
|
27261
27362
|
import { createServer as createServer2 } from "http";
|
|
27262
|
-
import { basename as basename15, dirname as dirname35, join as
|
|
27363
|
+
import { basename as basename15, dirname as dirname35, join as join61 } from "path";
|
|
27263
27364
|
import { execFile as execFile6, spawn as spawn12 } from "child_process";
|
|
27264
27365
|
|
|
27265
27366
|
// src/periscope-control.ts
|
|
@@ -27496,7 +27597,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
|
|
|
27496
27597
|
// src/control-api.ts
|
|
27497
27598
|
var PAUSABLE = ["dev", "design", "qa"];
|
|
27498
27599
|
var CONTROL_SOCKET_NAME = "control.sock";
|
|
27499
|
-
var controlSocketFor = (stateDir) =>
|
|
27600
|
+
var controlSocketFor = (stateDir) => join61(stateDir, CONTROL_SOCKET_NAME);
|
|
27500
27601
|
var MAX_SOCKET_PATH = 100;
|
|
27501
27602
|
var MAX_TAIL_BYTES = 1024 * 1024;
|
|
27502
27603
|
var MAX_WAIT_SECONDS = 30;
|
|
@@ -27583,7 +27684,7 @@ function candidates(live2, rotated) {
|
|
|
27583
27684
|
const out = [live2];
|
|
27584
27685
|
if (!rotated) return out;
|
|
27585
27686
|
try {
|
|
27586
|
-
for (const n of readdirSync20(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(
|
|
27687
|
+
for (const n of readdirSync20(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join61(dirname35(live2), n));
|
|
27587
27688
|
} catch {
|
|
27588
27689
|
}
|
|
27589
27690
|
return out;
|
|
@@ -27749,6 +27850,7 @@ async function tailReply(path, q2, rotated, abort) {
|
|
|
27749
27850
|
return reply2(200, r);
|
|
27750
27851
|
}
|
|
27751
27852
|
var NOTE_MAX_CHARS = 4e3;
|
|
27853
|
+
var SEAT_ROLES = ["dev", "design", "qa", "triage", "pair"];
|
|
27752
27854
|
async function postRunMessage(deps, run4, body) {
|
|
27753
27855
|
if (!RUN_NAME_RE.test(run4) || run4.includes("..")) return err2(400, "not a run name");
|
|
27754
27856
|
const live2 = liveRuns(deps.stateDir).find((r) => basename15(r.streamPath, ".jsonl") === run4.replace(/\.jsonl$/, ""));
|
|
@@ -27766,11 +27868,37 @@ async function postRunMessage(deps, run4, body) {
|
|
|
27766
27868
|
const acceptsInput = input.accepts();
|
|
27767
27869
|
const state = acceptsInput ? await input.deliver(recorded, body.author || void 0) : "carried_forward";
|
|
27768
27870
|
if (!acceptsInput) await markMessage(input.target, rowId, recorded.id, "carried_forward");
|
|
27871
|
+
appendRunNote(live2.streamPath, {
|
|
27872
|
+
id: recorded.id,
|
|
27873
|
+
text: text2,
|
|
27874
|
+
author: body.author || null,
|
|
27875
|
+
at: recorded.occurredAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
27876
|
+
state: state === "delivered" ? "delivered" : "carried_forward"
|
|
27877
|
+
});
|
|
27769
27878
|
return reply2(200, { cycleId: recorded.id, state, acceptsInput });
|
|
27770
27879
|
} catch (e) {
|
|
27771
27880
|
return err2(409, `the platform did not take the note: ${e.message}. ${carry}`);
|
|
27772
27881
|
}
|
|
27773
27882
|
}
|
|
27883
|
+
function postSeatNote(deps, role, body) {
|
|
27884
|
+
if (!SEAT_ROLES.includes(role)) return err2(400, `role must be one of ${SEAT_ROLES.join(", ")}`);
|
|
27885
|
+
if (!body) return err2(400, "body must be a small JSON object");
|
|
27886
|
+
const text2 = typeof body.text === "string" ? body.text.trim() : "";
|
|
27887
|
+
if (!text2 || text2.length > NOTE_MAX_CHARS) return err2(400, `text must be a string of 1 to ${NOTE_MAX_CHARS} characters`);
|
|
27888
|
+
if (body.author !== void 0 && typeof body.author !== "string") return err2(400, "author must be a string");
|
|
27889
|
+
if (body.ticket !== void 0 && (typeof body.ticket !== "string" || !body.ticket.trim() || body.ticket.length > 64)) return err2(400, "ticket must be a ticket tag");
|
|
27890
|
+
try {
|
|
27891
|
+
const note = addSeatNote(deps.stateDir, {
|
|
27892
|
+
role,
|
|
27893
|
+
text: text2,
|
|
27894
|
+
...body.ticket ? { ticket: body.ticket.trim() } : {},
|
|
27895
|
+
...body.author ? { author: body.author.trim() } : {}
|
|
27896
|
+
});
|
|
27897
|
+
return reply2(200, { id: note.id, state: "carried_forward", carriedForward: true });
|
|
27898
|
+
} catch (e) {
|
|
27899
|
+
return err2(500, `could not store the note: ${e.message}`);
|
|
27900
|
+
}
|
|
27901
|
+
}
|
|
27774
27902
|
async function route(deps, method, url, req, abort) {
|
|
27775
27903
|
const p = url.pathname.replace(/\/+$/, "") || "/";
|
|
27776
27904
|
const get2 = method === "GET";
|
|
@@ -27806,12 +27934,14 @@ async function route(deps, method, url, req, abort) {
|
|
|
27806
27934
|
if (p.startsWith("/streams/") && get2) {
|
|
27807
27935
|
const run4 = decodeURIComponent(p.slice("/streams/".length));
|
|
27808
27936
|
if (!RUN_NAME_RE.test(run4) || run4.includes("..") || /\.(pid|meta\.json|events\.jsonl)$/.test(run4)) return err2(400, "not a run name");
|
|
27809
|
-
const file =
|
|
27937
|
+
const file = join61(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
|
|
27810
27938
|
if (!existsSync58(file)) return err2(404, "no such run");
|
|
27811
27939
|
return tailReply(file, url.searchParams, false, abort);
|
|
27812
27940
|
}
|
|
27813
27941
|
const note = /^\/streams\/([^/]+)\/messages$/.exec(p);
|
|
27814
27942
|
if (note && post3) return postRunMessage(deps, decodeURIComponent(note[1]), await readJsonBody(req));
|
|
27943
|
+
const seatNote = /^\/seats\/([^/]+)\/notes$/.exec(p);
|
|
27944
|
+
if (seatNote && post3) return postSeatNote(deps, decodeURIComponent(seatNote[1]), await readJsonBody(req));
|
|
27815
27945
|
if ((p === "/pause" || p === "/resume") && post3) {
|
|
27816
27946
|
const body = await readJsonBody(req);
|
|
27817
27947
|
if (!body) return err2(400, "body must be a small JSON object");
|
|
@@ -27836,7 +27966,7 @@ async function route(deps, method, url, req, abort) {
|
|
|
27836
27966
|
}
|
|
27837
27967
|
if (p === "/diagnostics" && get2 && deps.diagnostics) return reply2(200, await deps.diagnostics());
|
|
27838
27968
|
const known = ["/status", "/events", "/streams", "/pause", "/resume", "/release/pause", "/release/resume", "/doctor", ...deps.diagnostics ? ["/diagnostics"] : []];
|
|
27839
|
-
if (known.includes(p) || p.startsWith("/streams/") || sched) return err2(405, "method not allowed");
|
|
27969
|
+
if (known.includes(p) || p.startsWith("/streams/") || seatNote || sched) return err2(405, "method not allowed");
|
|
27840
27970
|
return err2(404, "not found");
|
|
27841
27971
|
}
|
|
27842
27972
|
function send2(res, r) {
|
|
@@ -27872,7 +28002,7 @@ async function startControlServer(deps) {
|
|
|
27872
28002
|
log(`control API not started: socket path is too long for a unix socket (${path})`);
|
|
27873
28003
|
return null;
|
|
27874
28004
|
}
|
|
27875
|
-
if (await socketIsStale(path))
|
|
28005
|
+
if (await socketIsStale(path)) rmSync25(path, { force: true });
|
|
27876
28006
|
else if (existsSync58(path)) {
|
|
27877
28007
|
log(`control API not started: ${path} is in use by another process`);
|
|
27878
28008
|
return null;
|
|
@@ -27919,7 +28049,7 @@ async function startControlServer(deps) {
|
|
|
27919
28049
|
path,
|
|
27920
28050
|
close: () => new Promise((done) => {
|
|
27921
28051
|
server.close(() => {
|
|
27922
|
-
|
|
28052
|
+
rmSync25(path, { force: true });
|
|
27923
28053
|
done();
|
|
27924
28054
|
});
|
|
27925
28055
|
})
|
|
@@ -27959,53 +28089,53 @@ function crewJson(args, timeoutMs = 6e4) {
|
|
|
27959
28089
|
|
|
27960
28090
|
// src/periscope-mcp.ts
|
|
27961
28091
|
import { lstat, mkdir, readdir, readFile, readlink, realpath, rm, stat, writeFile } from "fs/promises";
|
|
27962
|
-
import { basename as basename16, dirname as dirname36, isAbsolute as isAbsolute5, join as
|
|
28092
|
+
import { basename as basename16, dirname as dirname36, isAbsolute as isAbsolute5, join as join63, relative as relative2, resolve as resolve6, sep } from "path";
|
|
27963
28093
|
import { z } from "zod";
|
|
27964
28094
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
27965
28095
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
27966
28096
|
|
|
27967
28097
|
// src/periscope-endpoints.ts
|
|
27968
28098
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
27969
|
-
import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as
|
|
27970
|
-
import { join as
|
|
27971
|
-
var secretDir = (stateDir) =>
|
|
27972
|
-
var secretFile = (stateDir, id) =>
|
|
27973
|
-
var endpointDir = (stateDir) =>
|
|
27974
|
-
var endpointFile = (stateDir, id) =>
|
|
28099
|
+
import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync42, readdirSync as readdirSync21, readFileSync as readFileSync55, rmSync as rmSync26, writeFileSync as writeFileSync43 } from "fs";
|
|
28100
|
+
import { join as join62 } from "path";
|
|
28101
|
+
var secretDir = (stateDir) => join62(stateDir, "periscope-mcp");
|
|
28102
|
+
var secretFile = (stateDir, id) => join62(secretDir(stateDir), `${id}.json`);
|
|
28103
|
+
var endpointDir = (stateDir) => join62(stateDir, "periscope-endpoints");
|
|
28104
|
+
var endpointFile = (stateDir, id) => join62(endpointDir(stateDir), `${id}.json`);
|
|
27975
28105
|
function mintPeriscopeSecret(stateDir, ticketRecordId) {
|
|
27976
|
-
|
|
28106
|
+
mkdirSync42(secretDir(stateDir), { recursive: true, mode: 448 });
|
|
27977
28107
|
const secret = randomBytes3(32).toString("base64url");
|
|
27978
28108
|
const file = secretFile(stateDir, ticketRecordId);
|
|
27979
|
-
|
|
28109
|
+
writeFileSync43(file, `${JSON.stringify({ secret })}
|
|
27980
28110
|
`, { mode: 384 });
|
|
27981
28111
|
chmodSync5(file, 384);
|
|
27982
28112
|
return secret;
|
|
27983
28113
|
}
|
|
27984
28114
|
function readPeriscopeSecret(stateDir, ticketRecordId) {
|
|
27985
28115
|
try {
|
|
27986
|
-
const v = JSON.parse(
|
|
28116
|
+
const v = JSON.parse(readFileSync55(secretFile(stateDir, ticketRecordId), "utf8"));
|
|
27987
28117
|
return typeof v.secret === "string" && v.secret ? v.secret : void 0;
|
|
27988
28118
|
} catch {
|
|
27989
28119
|
return void 0;
|
|
27990
28120
|
}
|
|
27991
28121
|
}
|
|
27992
28122
|
function removePeriscopeSecret(stateDir, ticketRecordId) {
|
|
27993
|
-
|
|
28123
|
+
rmSync26(secretFile(stateDir, ticketRecordId), { force: true });
|
|
27994
28124
|
}
|
|
27995
28125
|
function readPeriscopeEndpoint(stateDir, ticketRecordId) {
|
|
27996
28126
|
try {
|
|
27997
|
-
return JSON.parse(
|
|
28127
|
+
return JSON.parse(readFileSync55(endpointFile(stateDir, ticketRecordId), "utf8"));
|
|
27998
28128
|
} catch {
|
|
27999
28129
|
return void 0;
|
|
28000
28130
|
}
|
|
28001
28131
|
}
|
|
28002
28132
|
function writePeriscopeEndpoint(stateDir, rec) {
|
|
28003
|
-
|
|
28004
|
-
|
|
28133
|
+
mkdirSync42(endpointDir(stateDir), { recursive: true });
|
|
28134
|
+
writeFileSync43(endpointFile(stateDir, rec.ticketRecordId), `${JSON.stringify(rec, null, 2)}
|
|
28005
28135
|
`);
|
|
28006
28136
|
}
|
|
28007
28137
|
function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
|
|
28008
|
-
|
|
28138
|
+
rmSync26(endpointFile(stateDir, ticketRecordId), { force: true });
|
|
28009
28139
|
}
|
|
28010
28140
|
function listPeriscopeEndpoints(stateDir) {
|
|
28011
28141
|
const dir = endpointDir(stateDir);
|
|
@@ -28112,13 +28242,13 @@ async function resolveInWorktree(root, requested) {
|
|
|
28112
28242
|
let abs;
|
|
28113
28243
|
if (isAbsolute5(requested)) {
|
|
28114
28244
|
abs = resolve6(requested);
|
|
28115
|
-
if (isInside(root, abs)) abs =
|
|
28245
|
+
if (isInside(root, abs)) abs = join63(realRoot, relative2(root, abs));
|
|
28116
28246
|
} else {
|
|
28117
28247
|
abs = resolve6(realRoot, requested);
|
|
28118
28248
|
}
|
|
28119
28249
|
if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
28120
28250
|
const { real, rest } = await realAncestor(abs);
|
|
28121
|
-
const final = rest ?
|
|
28251
|
+
const final = rest ? join63(real, rest) : real;
|
|
28122
28252
|
if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
28123
28253
|
if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
|
|
28124
28254
|
return final;
|
|
@@ -28186,7 +28316,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
28186
28316
|
const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
|
|
28187
28317
|
const lines2 = await Promise.all(entries.map(async (e) => {
|
|
28188
28318
|
if (e.isDirectory()) return `[DIR] ${e.name}`;
|
|
28189
|
-
const size = (await lstat(
|
|
28319
|
+
const size = (await lstat(join63(abs, e.name))).size;
|
|
28190
28320
|
return `[FILE] ${e.name} (${size} bytes)`;
|
|
28191
28321
|
}));
|
|
28192
28322
|
return text(lines2.join("\n") || "(empty)");
|
|
@@ -28252,7 +28382,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
28252
28382
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
|
|
28253
28383
|
}, async ({ path }) => {
|
|
28254
28384
|
const parent = await inTree(dirname36(path) === "" ? "." : dirname36(path));
|
|
28255
|
-
const abs =
|
|
28385
|
+
const abs = join63(parent, basename16(path));
|
|
28256
28386
|
if (basename16(path) === ".git" || abs === parent) return text("path must name a file", true);
|
|
28257
28387
|
const st = await lstat(abs).catch(() => void 0);
|
|
28258
28388
|
if (!st) return text(`${path} does not exist`, true);
|
|
@@ -28747,7 +28877,7 @@ if (command === "provision") {
|
|
|
28747
28877
|
process.exit(outcome.code);
|
|
28748
28878
|
}
|
|
28749
28879
|
if (command === "pool-member") {
|
|
28750
|
-
const pool = poolConfigFrom(argv, process.env, () =>
|
|
28880
|
+
const pool = poolConfigFrom(argv, process.env, () => readFileSync56(0, "utf8"));
|
|
28751
28881
|
if (typeof pool === "string") {
|
|
28752
28882
|
process.stderr.write(`crew pool-member: ${pool}
|
|
28753
28883
|
`);
|
|
@@ -29091,7 +29221,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
29091
29221
|
throw e;
|
|
29092
29222
|
}
|
|
29093
29223
|
if (command === "credential") {
|
|
29094
|
-
const r = runCredential(positional[1],
|
|
29224
|
+
const r = runCredential(positional[1], readFileSync56(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
|
|
29095
29225
|
process.stdout.write(r.out);
|
|
29096
29226
|
process.stderr.write(r.err);
|
|
29097
29227
|
process.exit(r.code);
|
|
@@ -29103,9 +29233,9 @@ if (command === "passenger-sync-daemon") {
|
|
|
29103
29233
|
forges: cfg.ship.forges,
|
|
29104
29234
|
stateDir: cfg.ship.stateDir,
|
|
29105
29235
|
configFile: cfg.configFile,
|
|
29106
|
-
readFile: (p) =>
|
|
29107
|
-
writeFile: (p, t) =>
|
|
29108
|
-
stdin: () =>
|
|
29236
|
+
readFile: (p) => readFileSync56(p, "utf8"),
|
|
29237
|
+
writeFile: (p, t) => writeFileSync44(p, t),
|
|
29238
|
+
stdin: () => readFileSync56(0, "utf8"),
|
|
29109
29239
|
env: process.env
|
|
29110
29240
|
}
|
|
29111
29241
|
);
|
|
@@ -29444,7 +29574,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
29444
29574
|
}
|
|
29445
29575
|
if (host === "linux" && hasSystemd) {
|
|
29446
29576
|
const label = labelFor(CREW_HOME, "run");
|
|
29447
|
-
const staleTimer =
|
|
29577
|
+
const staleTimer = join64(homedir11(), ".config", "systemd", "user", `${label}.timer`);
|
|
29448
29578
|
if (existsSync60(staleTimer)) {
|
|
29449
29579
|
process.stdout.write(
|
|
29450
29580
|
`removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run)" : ""}
|
|
@@ -29527,7 +29657,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
29527
29657
|
for (const a of plan.actions) {
|
|
29528
29658
|
if (a.kind === "enable") {
|
|
29529
29659
|
if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
|
|
29530
|
-
|
|
29660
|
+
writeFileSync44(cfg.configFile, planEnable(readFileSync56(cfg.configFile, "utf8"), a.route));
|
|
29531
29661
|
enabledSound.add(a.route);
|
|
29532
29662
|
changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
|
|
29533
29663
|
} else {
|
|
@@ -29756,7 +29886,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
29756
29886
|
harnessBin: "claude",
|
|
29757
29887
|
...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
|
|
29758
29888
|
},
|
|
29759
|
-
policyFile:
|
|
29889
|
+
policyFile: join64(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
|
|
29760
29890
|
repo: mirror,
|
|
29761
29891
|
origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
|
|
29762
29892
|
base: effective.branch.base,
|
|
@@ -31023,7 +31153,7 @@ ${f.tail.trimEnd()}
|
|
|
31023
31153
|
logFile: cfg.ship.logFile
|
|
31024
31154
|
});
|
|
31025
31155
|
}
|
|
31026
|
-
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [
|
|
31156
|
+
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join64(CREW_HOME, "src"), join64(CREW_HOME, "dist"), join64(CREW_HOME, "bin")];
|
|
31027
31157
|
const configPaths = daemonConfigPaths(cfg);
|
|
31028
31158
|
watchPaths.push(...configPaths);
|
|
31029
31159
|
noteDaemonStarted(cfg.ship.stateDir);
|
|
@@ -31361,10 +31491,10 @@ ${f.tail.trimEnd()}
|
|
|
31361
31491
|
`);
|
|
31362
31492
|
if (!dryRun) {
|
|
31363
31493
|
const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
|
|
31364
|
-
const raw = existsSync60(resolvedPath) ? JSON.parse(
|
|
31494
|
+
const raw = existsSync60(resolvedPath) ? JSON.parse(readFileSync56(resolvedPath, "utf8")) : {};
|
|
31365
31495
|
raw.agentSkills = result.agentSkills;
|
|
31366
|
-
|
|
31367
|
-
|
|
31496
|
+
mkdirSync43(dirOf2(resolvedPath), { recursive: true });
|
|
31497
|
+
writeFileSync44(resolvedPath, `${JSON.stringify(raw, null, 2)}
|
|
31368
31498
|
`);
|
|
31369
31499
|
}
|
|
31370
31500
|
if (result.outcomes.some((o) => o.action === "diverged")) process.exitCode = 1;
|
|
@@ -31387,7 +31517,7 @@ ${f.tail.trimEnd()}
|
|
|
31387
31517
|
throw e;
|
|
31388
31518
|
}
|
|
31389
31519
|
const oldName = cfg.ship.name;
|
|
31390
|
-
|
|
31520
|
+
writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync56(cfg.configFile, "utf8"), newName));
|
|
31391
31521
|
cfg.ship.name = newName;
|
|
31392
31522
|
let renameMachineId;
|
|
31393
31523
|
try {
|
|
@@ -31434,7 +31564,7 @@ ${f.tail.trimEnd()}
|
|
|
31434
31564
|
process.exit(2);
|
|
31435
31565
|
};
|
|
31436
31566
|
if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
|
|
31437
|
-
const configText =
|
|
31567
|
+
const configText = readFileSync56(cfg.configFile, "utf8");
|
|
31438
31568
|
if (sub === "check") {
|
|
31439
31569
|
try {
|
|
31440
31570
|
const routeArg = value("route") ?? positional[2];
|
|
@@ -31475,7 +31605,7 @@ ${f.tail.trimEnd()}
|
|
|
31475
31605
|
}
|
|
31476
31606
|
}, read: (r) => {
|
|
31477
31607
|
try {
|
|
31478
|
-
return
|
|
31608
|
+
return readFileSync56(resolvePath(dir, r), "utf8");
|
|
31479
31609
|
} catch {
|
|
31480
31610
|
return void 0;
|
|
31481
31611
|
}
|
|
@@ -31517,19 +31647,19 @@ ${f.tail.trimEnd()}
|
|
|
31517
31647
|
let cleared;
|
|
31518
31648
|
if (clear2) {
|
|
31519
31649
|
const plan = clearRouteHooks(configText, a.route, a.name);
|
|
31520
|
-
if (plan.removed.length > 0)
|
|
31650
|
+
if (plan.removed.length > 0) writeFileSync44(cfg.configFile, plan.text);
|
|
31521
31651
|
cleared = { file: cfg.configFile, removed: plan.removed };
|
|
31522
31652
|
}
|
|
31523
31653
|
if (write && suggestion.source === null && recipeIds.length === 0 && hookSpecs.length === 0) throw new ReposError(`nothing to write: ${suggestion.notes[0]}`);
|
|
31524
31654
|
if (write === "route") {
|
|
31525
31655
|
const plan = planRouteHooks(configText, a.route, a.name, picked.hooks, { replace: flag("replace") });
|
|
31526
|
-
|
|
31656
|
+
writeFileSync44(cfg.configFile, plan.text);
|
|
31527
31657
|
written = { target: "route", file: cfg.configFile, hooks: plan.written, kept: plan.kept, replaced: plan.replaced };
|
|
31528
31658
|
} else if (write === "repo") {
|
|
31529
31659
|
const have = existingRepoConfig(files);
|
|
31530
31660
|
if (have) throw new ReposError(`${resolvePath(dir, have)} already exists; not overwriting it`);
|
|
31531
31661
|
const file = resolvePath(dir, ".crew.yaml");
|
|
31532
|
-
|
|
31662
|
+
writeFileSync44(file, starterRepoConfig(picked.hooks, picked.release), { flag: "wx" });
|
|
31533
31663
|
written = { target: "repo", file, hooks: Object.keys(picked.hooks), kept: [], replaced: [] };
|
|
31534
31664
|
}
|
|
31535
31665
|
if (flag("json")) {
|
|
@@ -31626,7 +31756,7 @@ ${f.tail.trimEnd()}
|
|
|
31626
31756
|
let resolvedRemotes;
|
|
31627
31757
|
if (existsSync60(resolvedFile)) {
|
|
31628
31758
|
try {
|
|
31629
|
-
resolvedRemotes = JSON.parse(
|
|
31759
|
+
resolvedRemotes = JSON.parse(readFileSync56(resolvedFile, "utf8"));
|
|
31630
31760
|
} catch {
|
|
31631
31761
|
}
|
|
31632
31762
|
}
|
|
@@ -31648,7 +31778,7 @@ ${f.tail.trimEnd()}
|
|
|
31648
31778
|
repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f) => {
|
|
31649
31779
|
try {
|
|
31650
31780
|
const path = resolvePath(d, f);
|
|
31651
|
-
return Object.keys(parseRepoConfig(
|
|
31781
|
+
return Object.keys(parseRepoConfig(readFileSync56(path, "utf8"), path).hooks).length > 0;
|
|
31652
31782
|
} catch {
|
|
31653
31783
|
return false;
|
|
31654
31784
|
}
|
|
@@ -31697,7 +31827,7 @@ ${f.tail.trimEnd()}
|
|
|
31697
31827
|
throw new ReposError(`${e.message}${authHint}
|
|
31698
31828
|
crew.yaml was not changed`);
|
|
31699
31829
|
}
|
|
31700
|
-
|
|
31830
|
+
writeFileSync44(cfg.configFile, plan2.text);
|
|
31701
31831
|
if (plan2.droppedDir) process.stderr.write(`crew repos: dropped dir: ${plan2.droppedDir} from route ${routeName} \u2014 it is not a checkout (the clone base); checkouts now live under repos:
|
|
31702
31832
|
`);
|
|
31703
31833
|
say("attached", { route: routeName, name: plan2.name, dir: plan2.target, mode: plan2.mode }, `cloned and attached ${plan2.target} to ${routeName} as ${plan2.mode === "dir" ? "dir" : `repos.${plan2.name}`} in ${cfg.configFile}`);
|
|
@@ -31757,14 +31887,14 @@ ${f.tail.trimEnd()}
|
|
|
31757
31887
|
process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
|
|
31758
31888
|
`);
|
|
31759
31889
|
if (existsSync60(resolvedFile)) {
|
|
31760
|
-
const raw = JSON.parse(
|
|
31890
|
+
const raw = JSON.parse(readFileSync56(resolvedFile, "utf8"));
|
|
31761
31891
|
raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
|
|
31762
31892
|
raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
|
|
31763
|
-
|
|
31893
|
+
writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
31764
31894
|
`);
|
|
31765
31895
|
}
|
|
31766
31896
|
}
|
|
31767
|
-
|
|
31897
|
+
writeFileSync44(cfg.configFile, plan.text);
|
|
31768
31898
|
process.stdout.write(`added ${top} to ${routeName} as ${plan.mode === "dir" ? "dir" : `repos.${plan.name}`} in ${cfg.configFile}
|
|
31769
31899
|
`);
|
|
31770
31900
|
} catch (e) {
|
|
@@ -32139,7 +32269,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
32139
32269
|
process.exit(2);
|
|
32140
32270
|
}
|
|
32141
32271
|
if (found.shipNameAdopted && !dryRun) {
|
|
32142
|
-
|
|
32272
|
+
writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync56(cfg.configFile, "utf8"), found.shipNameAdopted));
|
|
32143
32273
|
cfg.ship.name = found.shipNameAdopted;
|
|
32144
32274
|
}
|
|
32145
32275
|
if (found.shipRow) {
|
|
@@ -32185,7 +32315,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
32185
32315
|
const hadPreviousFile = existsSync60(resolvedPath);
|
|
32186
32316
|
if (hadPreviousFile) {
|
|
32187
32317
|
try {
|
|
32188
|
-
previous = JSON.parse(
|
|
32318
|
+
previous = JSON.parse(readFileSync56(resolvedPath, "utf8"));
|
|
32189
32319
|
} catch {
|
|
32190
32320
|
}
|
|
32191
32321
|
}
|
|
@@ -32315,12 +32445,12 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
32315
32445
|
process.stderr.write(`(dry run) would write resolved ids to ${resolvedPath}
|
|
32316
32446
|
`);
|
|
32317
32447
|
} else {
|
|
32318
|
-
|
|
32448
|
+
mkdirSync43(dirname37(resolvedPath), { recursive: true });
|
|
32319
32449
|
if (hadPreviousFile) copyFileSync2(resolvedPath, `${resolvedPath}.bak`);
|
|
32320
32450
|
const tmpPath = `${resolvedPath}.tmp${process.pid}`;
|
|
32321
|
-
|
|
32451
|
+
writeFileSync44(tmpPath, `${JSON.stringify(resolved, null, 2)}
|
|
32322
32452
|
`);
|
|
32323
|
-
|
|
32453
|
+
renameSync10(tmpPath, resolvedPath);
|
|
32324
32454
|
process.stderr.write(`Resolved ids written to ${resolvedPath}
|
|
32325
32455
|
`);
|
|
32326
32456
|
}
|
|
@@ -32364,8 +32494,8 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
32364
32494
|
process.stderr.write(`(dry run) would write the minted API key to ${apiKeyFile}
|
|
32365
32495
|
`);
|
|
32366
32496
|
} else {
|
|
32367
|
-
|
|
32368
|
-
|
|
32497
|
+
mkdirSync43(dirname37(apiKeyFile), { recursive: true });
|
|
32498
|
+
writeFileSync44(apiKeyFile, `${apiKeyVar}=${apiKey}
|
|
32369
32499
|
`, { mode: 384 });
|
|
32370
32500
|
process.stderr.write(`API key written to ${apiKeyFile}
|
|
32371
32501
|
`);
|
|
@@ -33080,10 +33210,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
33080
33210
|
startupSeconds: cfg.ship.intelStartupSeconds,
|
|
33081
33211
|
prepare: async (path) => {
|
|
33082
33212
|
for (const f of repoWt.config.worktrees.copy) {
|
|
33083
|
-
const src =
|
|
33084
|
-
if (!existsSync60(src) || existsSync60(
|
|
33085
|
-
|
|
33086
|
-
copyFileSync2(src,
|
|
33213
|
+
const src = join64(repoWt.dir, f);
|
|
33214
|
+
if (!existsSync60(src) || existsSync60(join64(path, f))) continue;
|
|
33215
|
+
mkdirSync43(dirOf2(join64(path, f)), { recursive: true });
|
|
33216
|
+
copyFileSync2(src, join64(path, f));
|
|
33087
33217
|
}
|
|
33088
33218
|
const setup = repoWt.config.hooks.setup;
|
|
33089
33219
|
return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
|
|
@@ -33412,10 +33542,10 @@ ${where.join("\n")}`);
|
|
|
33412
33542
|
},
|
|
33413
33543
|
prepare: async (path) => {
|
|
33414
33544
|
for (const f of repoP.config.worktrees.copy) {
|
|
33415
|
-
const src =
|
|
33545
|
+
const src = join64(repoP.dir, f);
|
|
33416
33546
|
if (!existsSync60(src)) continue;
|
|
33417
|
-
|
|
33418
|
-
copyFileSync2(src,
|
|
33547
|
+
mkdirSync43(dirOf2(join64(path, f)), { recursive: true });
|
|
33548
|
+
copyFileSync2(src, join64(path, f));
|
|
33419
33549
|
}
|
|
33420
33550
|
const setup = repoP.config.hooks.setup;
|
|
33421
33551
|
return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
|
|
@@ -33727,7 +33857,7 @@ ${where.join("\n")}`);
|
|
|
33727
33857
|
};
|
|
33728
33858
|
const droppedRoutes = [];
|
|
33729
33859
|
try {
|
|
33730
|
-
const rawCfg = parseYaml3(
|
|
33860
|
+
const rawCfg = parseYaml3(readFileSync56(cfg.configFile, "utf8"));
|
|
33731
33861
|
for (const r of rawCfg?.routes ?? []) {
|
|
33732
33862
|
if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
|
|
33733
33863
|
try {
|
|
@@ -33791,8 +33921,8 @@ ${where.join("\n")}`);
|
|
|
33791
33921
|
process.stdout.write("crew reload: no daemon unit is running \u2014 nothing to reload (the next run reads crew.yaml fresh)\n");
|
|
33792
33922
|
break;
|
|
33793
33923
|
}
|
|
33794
|
-
|
|
33795
|
-
|
|
33924
|
+
mkdirSync43(cfg.ship.stateDir, { recursive: true });
|
|
33925
|
+
writeFileSync44(sentinel, `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
33796
33926
|
`);
|
|
33797
33927
|
process.stdout.write(
|
|
33798
33928
|
"crew reload: requested \u2014 the daemon relaunches with the new config once its running agents end (it starts no new work meanwhile); if it is busy, `crew reload --now` forces the relaunch and interrupts them\n"
|
|
@@ -33857,7 +33987,7 @@ ${where.join("\n")}`);
|
|
|
33857
33987
|
}
|
|
33858
33988
|
case "log": {
|
|
33859
33989
|
try {
|
|
33860
|
-
const text2 =
|
|
33990
|
+
const text2 = readFileSync56(cfg.ship.logFile, "utf8").split("\n");
|
|
33861
33991
|
process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
|
|
33862
33992
|
`);
|
|
33863
33993
|
} catch {
|
|
@@ -33880,7 +34010,7 @@ ${where.join("\n")}`);
|
|
|
33880
34010
|
};
|
|
33881
34011
|
if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
|
|
33882
34012
|
const tracker = new Tracker(route2, cfg.ship);
|
|
33883
|
-
const configText =
|
|
34013
|
+
const configText = readFileSync56(cfg.configFile, "utf8");
|
|
33884
34014
|
const cfgBase = dirname37(cfg.configFile);
|
|
33885
34015
|
const configured2 = configuredRepos(configText, route2.route, cfgBase);
|
|
33886
34016
|
const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
|
|
@@ -33909,7 +34039,7 @@ ${where.join("\n")}`);
|
|
|
33909
34039
|
}
|
|
33910
34040
|
if (configured2.some((r) => r.dir === dir)) {
|
|
33911
34041
|
try {
|
|
33912
|
-
|
|
34042
|
+
writeFileSync44(cfg.configFile, planRepoRemove(configText, cfgBase, route2.route, dir).text);
|
|
33913
34043
|
} catch (e) {
|
|
33914
34044
|
if (e instanceof ReposError) fail2(e.message);
|
|
33915
34045
|
throw e;
|
|
@@ -33918,28 +34048,28 @@ ${where.join("\n")}`);
|
|
|
33918
34048
|
if (row) {
|
|
33919
34049
|
await tracker.deleteRepoRow(row.id);
|
|
33920
34050
|
if (existsSync60(resolvedFile)) {
|
|
33921
|
-
const raw = JSON.parse(
|
|
34051
|
+
const raw = JSON.parse(readFileSync56(resolvedFile, "utf8"));
|
|
33922
34052
|
if (raw.repoNames) delete raw.repoNames[row.id];
|
|
33923
34053
|
if (raw.repoRemotes) delete raw.repoRemotes[row.id];
|
|
33924
|
-
|
|
34054
|
+
writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
33925
34055
|
`);
|
|
33926
34056
|
}
|
|
33927
34057
|
}
|
|
33928
|
-
if (existsSync60(
|
|
34058
|
+
if (existsSync60(join64(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync27(dir, { recursive: true, force: true });
|
|
33929
34059
|
say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
|
|
33930
34060
|
break;
|
|
33931
34061
|
}
|
|
33932
34062
|
const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
|
|
33933
|
-
const fresh = !existsSync60(
|
|
34063
|
+
const fresh = !existsSync60(join64(dir, ".git"));
|
|
33934
34064
|
if (existsSync60(dir) && fresh && readdirSync22(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
|
|
33935
34065
|
if (dryRun) {
|
|
33936
34066
|
say("dry-run", { dir, newCheckout: fresh, repoRow: row?.id ?? null }, `would ${fresh ? "create" : "reuse"} ${dir}${row ? "" : ", create the Repos row"}, and file one ${tracker.contract.statuses.approved} ticket`);
|
|
33937
34067
|
break;
|
|
33938
34068
|
}
|
|
33939
34069
|
if (fresh) {
|
|
33940
|
-
|
|
33941
|
-
|
|
33942
|
-
|
|
34070
|
+
mkdirSync43(dir, { recursive: true });
|
|
34071
|
+
writeFileSync44(join64(dir, "README.md"), SAMPLE_README);
|
|
34072
|
+
writeFileSync44(join64(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
|
|
33943
34073
|
const g = (...a) => {
|
|
33944
34074
|
const r = spawnSync14("git", a, { cwd: dir, encoding: "utf8" });
|
|
33945
34075
|
if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
|
|
@@ -33958,16 +34088,16 @@ ${where.join("\n")}`);
|
|
|
33958
34088
|
});
|
|
33959
34089
|
repoId = (await tracker.createRepoRow(payload)).id;
|
|
33960
34090
|
if (existsSync60(resolvedFile)) {
|
|
33961
|
-
const raw = JSON.parse(
|
|
34091
|
+
const raw = JSON.parse(readFileSync56(resolvedFile, "utf8"));
|
|
33962
34092
|
raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
|
|
33963
34093
|
raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
|
|
33964
|
-
|
|
34094
|
+
writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
33965
34095
|
`);
|
|
33966
34096
|
}
|
|
33967
34097
|
}
|
|
33968
34098
|
if (!configured2.some((r) => r.dir === dir)) {
|
|
33969
34099
|
try {
|
|
33970
|
-
|
|
34100
|
+
writeFileSync44(cfg.configFile, planRepoAdd({ text: configText, base: cfgBase, route: route2.route, path: dir, name: SAMPLE_REPO }).text);
|
|
33971
34101
|
} catch (e) {
|
|
33972
34102
|
if (e instanceof ReposError) fail2(e.message);
|
|
33973
34103
|
throw e;
|
|
@@ -34117,6 +34247,7 @@ ${where.join("\n")}`);
|
|
|
34117
34247
|
);
|
|
34118
34248
|
const lastRuns = lastRunsBySeat(cfg.ship.stateDir);
|
|
34119
34249
|
const periscopes = await periscopesForStatus(cfg.ship.stateDir);
|
|
34250
|
+
const runPreviews = new Map(periscopes.filter((p) => p.serving).map((p) => [p.ticketRecordId, p.url]));
|
|
34120
34251
|
if (flag("json")) {
|
|
34121
34252
|
const nameSync = await reconcileRouteShipName({ route: route2, ship: cfg.ship, configFile: cfg.configFile, readOnly: true });
|
|
34122
34253
|
const repos = await resolvedRepos(route2);
|
|
@@ -34188,7 +34319,7 @@ ${where.join("\n")}`);
|
|
|
34188
34319
|
seats: seats2
|
|
34189
34320
|
},
|
|
34190
34321
|
// Additive (CREW-2822): every live run on this ship. `version` stays 1.
|
|
34191
|
-
runs: runs.map((x) => describeRun(x, route2, seatIds, void 0, { titles: runTitles })),
|
|
34322
|
+
runs: runs.map((x) => describeRun(x, route2, seatIds, void 0, { titles: runTitles, previews: runPreviews })),
|
|
34192
34323
|
// Additive (CREW-2857): every live periscope on this ship, from its local record. `version` stays 1.
|
|
34193
34324
|
periscopes,
|
|
34194
34325
|
watermark: state.watermark(routeSlug(route2.route)),
|
|
@@ -34525,7 +34656,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
34525
34656
|
const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
|
|
34526
34657
|
const abandons = unitAbandonsAgents(unitPlan, (p) => {
|
|
34527
34658
|
try {
|
|
34528
|
-
return
|
|
34659
|
+
return readFileSync56(p, "utf8");
|
|
34529
34660
|
} catch {
|
|
34530
34661
|
return null;
|
|
34531
34662
|
}
|
|
@@ -34540,7 +34671,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
34540
34671
|
const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
|
|
34541
34672
|
const keeps = unitAbandonsAgents(pPlan, (p) => {
|
|
34542
34673
|
try {
|
|
34543
|
-
return
|
|
34674
|
+
return readFileSync56(p, "utf8");
|
|
34544
34675
|
} catch {
|
|
34545
34676
|
return null;
|
|
34546
34677
|
}
|