@tangle-network/agent-app 0.60.25 → 0.60.27
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/assistant/index.js +1 -1
- package/dist/{chunk-KC2DUXKM.js → chunk-KIJ64S54.js} +2 -2
- package/dist/chunk-KIJ64S54.js.map +1 -0
- package/dist/{chunk-35TMEOFA.js → chunk-TSHEYSTY.js} +191 -62
- package/dist/chunk-TSHEYSTY.js.map +1 -0
- package/dist/signoff/cli.js +1 -1
- package/dist/signoff/index.d.ts +1 -0
- package/dist/signoff/index.js +7 -1
- package/dist/signoff/types.d.ts +4 -0
- package/dist/signoff/worker-defaults.d.ts +56 -0
- package/dist/web-react/index.js +1 -1
- package/dist/web-react/interaction-card-support.d.ts +3 -1
- package/package.json +1 -1
- package/dist/chunk-35TMEOFA.js.map +0 -1
- package/dist/chunk-KC2DUXKM.js.map +0 -1
|
@@ -1,6 +1,105 @@
|
|
|
1
|
+
// src/signoff/worker-defaults.ts
|
|
2
|
+
import { spawnSync } from "child_process";
|
|
3
|
+
import { existsSync } from "fs";
|
|
4
|
+
import { createRequire } from "module";
|
|
5
|
+
import { basename, dirname, join } from "path";
|
|
6
|
+
var WORKER_DEFAULTS_STEP = "worker defaults";
|
|
7
|
+
var WORKER_COMPATIBILITY_DATE_FLOOR = "2026-09-01";
|
|
8
|
+
var WRANGLER_CONFIG_NAME = /^wrangler[.-]?[\w.-]*\.(toml|json|jsonc)$/;
|
|
9
|
+
function trackedWorkerConfigs(repoRoot) {
|
|
10
|
+
const listed = spawnSync("git", ["ls-files", "-z"], { cwd: repoRoot, encoding: "utf8" });
|
|
11
|
+
if (listed.status !== 0) throw new Error(`signoff: git ls-files failed in ${repoRoot}: ${listed.stderr}`);
|
|
12
|
+
return listed.stdout.split("\0").filter((path) => path !== "" && WRANGLER_CONFIG_NAME.test(basename(path))).sort();
|
|
13
|
+
}
|
|
14
|
+
function problemsFor(config) {
|
|
15
|
+
const problems = [];
|
|
16
|
+
const observability = config.observability;
|
|
17
|
+
const isFullSample = (settings) => (settings?.head_sampling_rate ?? 1) === 1;
|
|
18
|
+
if (observability?.enabled !== true) problems.push("observability.enabled must be true");
|
|
19
|
+
if (!isFullSample(observability)) {
|
|
20
|
+
problems.push(`observability.head_sampling_rate must be 1 (is ${observability?.head_sampling_rate})`);
|
|
21
|
+
}
|
|
22
|
+
if (observability?.logs?.enabled === false) problems.push("observability.logs.enabled must not be false");
|
|
23
|
+
if (!isFullSample(observability?.logs)) {
|
|
24
|
+
problems.push(`observability.logs.head_sampling_rate must be 1 (is ${observability?.logs?.head_sampling_rate})`);
|
|
25
|
+
}
|
|
26
|
+
if (observability?.logs?.invocation_logs === false) {
|
|
27
|
+
problems.push("observability.logs.invocation_logs must not be false");
|
|
28
|
+
}
|
|
29
|
+
if (observability?.traces?.enabled !== true) problems.push("observability.traces.enabled must be true");
|
|
30
|
+
if (!isFullSample(observability?.traces)) {
|
|
31
|
+
problems.push(`observability.traces.head_sampling_rate must be 1 (is ${observability?.traces?.head_sampling_rate})`);
|
|
32
|
+
}
|
|
33
|
+
if (config.upload_source_maps !== true) problems.push("upload_source_maps must be true");
|
|
34
|
+
if (!config.compatibility_flags?.includes("nodejs_compat")) {
|
|
35
|
+
problems.push('compatibility_flags must include "nodejs_compat"');
|
|
36
|
+
}
|
|
37
|
+
const date = config.compatibility_date;
|
|
38
|
+
if (date === void 0 || date < WORKER_COMPATIBILITY_DATE_FLOOR) {
|
|
39
|
+
problems.push(`compatibility_date must be ${WORKER_COMPATIBILITY_DATE_FLOOR} or later (is ${date ?? "unset"})`);
|
|
40
|
+
}
|
|
41
|
+
return problems;
|
|
42
|
+
}
|
|
43
|
+
function quietly(read) {
|
|
44
|
+
const saved = { WRANGLER_LOG: process.env.WRANGLER_LOG, CLOUDFLARE_ENV: process.env.CLOUDFLARE_ENV };
|
|
45
|
+
process.env.WRANGLER_LOG = "error";
|
|
46
|
+
delete process.env.CLOUDFLARE_ENV;
|
|
47
|
+
try {
|
|
48
|
+
return read();
|
|
49
|
+
} finally {
|
|
50
|
+
for (const [key, value] of Object.entries(saved)) {
|
|
51
|
+
if (value === void 0) delete process.env[key];
|
|
52
|
+
else process.env[key] = value;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function loadWrangler(configDir) {
|
|
57
|
+
try {
|
|
58
|
+
return createRequire(join(configDir, "package.json"))("wrangler");
|
|
59
|
+
} catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function checkWorkerDefaults(repoRoot, configs) {
|
|
64
|
+
const findings = [];
|
|
65
|
+
const checked = [];
|
|
66
|
+
for (const config of configs ?? trackedWorkerConfigs(repoRoot)) {
|
|
67
|
+
const path = join(repoRoot, config);
|
|
68
|
+
if (!existsSync(path)) {
|
|
69
|
+
findings.push({ config, env: null, problem: "declared Worker config does not exist" });
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const wrangler = loadWrangler(dirname(path));
|
|
73
|
+
if (!wrangler) {
|
|
74
|
+
findings.push({ config, env: null, problem: "wrangler is not installed where this config can resolve it" });
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const envNames = Object.keys(quietly(() => wrangler.experimental_readRawConfig({ config: path })).rawConfig.env ?? {});
|
|
78
|
+
const envs = [null, ...envNames];
|
|
79
|
+
checked.push({ config, envs });
|
|
80
|
+
for (const env of envs) {
|
|
81
|
+
const resolved = quietly(() => wrangler.unstable_readConfig({ config: path, ...env ? { env } : {} }));
|
|
82
|
+
for (const problem of problemsFor(resolved)) findings.push({ config, env, problem });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return { checked, findings };
|
|
86
|
+
}
|
|
87
|
+
function formatWorkerDefaults(result) {
|
|
88
|
+
if (result.checked.length === 0 && result.findings.length === 0) return "no Wrangler config tracked; nothing to check\n";
|
|
89
|
+
const lines = result.checked.map(
|
|
90
|
+
({ config, envs }) => `checked ${config} (${envs.map((env) => env ?? "top level").join(", ")})`
|
|
91
|
+
);
|
|
92
|
+
for (const finding of result.findings) {
|
|
93
|
+
lines.push(`FAIL ${finding.config}${finding.env ? ` [env.${finding.env}]` : ""}: ${finding.problem}`);
|
|
94
|
+
}
|
|
95
|
+
if (result.findings.length > 0) lines.push("Required keys: https://github.com/tangle-network/agent-app/blob/main/docs/worker-defaults.md");
|
|
96
|
+
return `${lines.join("\n")}
|
|
97
|
+
`;
|
|
98
|
+
}
|
|
99
|
+
|
|
1
100
|
// src/signoff/config.ts
|
|
2
|
-
import { existsSync, readFileSync } from "fs";
|
|
3
|
-
import { join, resolve } from "path";
|
|
101
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
102
|
+
import { join as join2, resolve } from "path";
|
|
4
103
|
import { pathToFileURL } from "url";
|
|
5
104
|
import { z } from "zod";
|
|
6
105
|
var SIGNOFF_CONFIG_FILES = ["signoff.config.mjs", "signoff.config.js"];
|
|
@@ -33,7 +132,8 @@ var configSchema = z.object({
|
|
|
33
132
|
nodeVersion: z.string().min(1).optional(),
|
|
34
133
|
carryFiles: z.array(z.string()).optional(),
|
|
35
134
|
cacheDir: z.string().optional(),
|
|
36
|
-
storeGenerations: z.number().int().positive().optional()
|
|
135
|
+
storeGenerations: z.number().int().positive().optional(),
|
|
136
|
+
workerConfigs: z.array(z.string().min(1)).optional()
|
|
37
137
|
});
|
|
38
138
|
function describeIssues(error, where) {
|
|
39
139
|
const lines = error.issues.map((issue) => ` ${issue.path.join(".") || "(root)"}: ${issue.message}`);
|
|
@@ -43,6 +143,9 @@ ${lines.join("\n")}`;
|
|
|
43
143
|
function parseSignoffConfig(value, where) {
|
|
44
144
|
const result = configSchema.safeParse(value);
|
|
45
145
|
if (!result.success) throw new Error(describeIssues(result.error, where));
|
|
146
|
+
if (result.data.steps.some((step) => step.name === WORKER_DEFAULTS_STEP)) {
|
|
147
|
+
throw new Error(`signoff: ${where} declares a step named "${WORKER_DEFAULTS_STEP}", which the gate runs itself`);
|
|
148
|
+
}
|
|
46
149
|
return result.data;
|
|
47
150
|
}
|
|
48
151
|
var DERIVED_STEPS = [
|
|
@@ -77,15 +180,15 @@ async function loadSignoffConfig(options) {
|
|
|
77
180
|
const { repoRoot, configPath } = options;
|
|
78
181
|
if (configPath !== void 0) {
|
|
79
182
|
const abs = resolve(repoRoot, configPath);
|
|
80
|
-
if (!
|
|
183
|
+
if (!existsSync2(abs)) throw new Error(`signoff: no config at ${abs}`);
|
|
81
184
|
return { config: await importConfig(abs), origin: { kind: "file", path: abs } };
|
|
82
185
|
}
|
|
83
186
|
for (const candidate of SIGNOFF_CONFIG_FILES) {
|
|
84
|
-
const abs =
|
|
85
|
-
if (
|
|
187
|
+
const abs = join2(repoRoot, candidate);
|
|
188
|
+
if (existsSync2(abs)) return { config: await importConfig(abs), origin: { kind: "file", path: abs } };
|
|
86
189
|
}
|
|
87
|
-
const pkgPath =
|
|
88
|
-
if (!
|
|
190
|
+
const pkgPath = join2(repoRoot, "package.json");
|
|
191
|
+
if (!existsSync2(pkgPath)) {
|
|
89
192
|
throw new Error(`signoff: ${repoRoot} has no package.json, no signoff.config.mjs, and nothing to derive from.`);
|
|
90
193
|
}
|
|
91
194
|
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
@@ -103,19 +206,19 @@ async function importConfig(abs) {
|
|
|
103
206
|
}
|
|
104
207
|
|
|
105
208
|
// src/signoff/run.ts
|
|
106
|
-
import { spawnSync as
|
|
107
|
-
import { existsSync as
|
|
209
|
+
import { spawnSync as spawnSync3 } from "child_process";
|
|
210
|
+
import { existsSync as existsSync7 } from "fs";
|
|
108
211
|
import { availableParallelism, homedir } from "os";
|
|
109
|
-
import { basename, join as
|
|
212
|
+
import { basename as basename2, join as join7, resolve as resolve3 } from "path";
|
|
110
213
|
|
|
111
214
|
// src/signoff/node-version.ts
|
|
112
|
-
import { existsSync as
|
|
113
|
-
import { join as
|
|
215
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
|
|
216
|
+
import { join as join4 } from "path";
|
|
114
217
|
|
|
115
218
|
// src/signoff/workflow-pin.ts
|
|
116
|
-
import { existsSync as
|
|
117
|
-
import { join as
|
|
118
|
-
var WORKFLOW_DIR =
|
|
219
|
+
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync2 } from "fs";
|
|
220
|
+
import { join as join3 } from "path";
|
|
221
|
+
var WORKFLOW_DIR = join3(".github", "workflows");
|
|
119
222
|
function scalarValue(raw) {
|
|
120
223
|
const withoutComment = raw.replace(/\s+#.*$/, "").trim();
|
|
121
224
|
const quoted = /^(['"])(.*)\1$/.exec(withoutComment);
|
|
@@ -165,8 +268,8 @@ function pinsInWorkflow(repoRoot, file, source) {
|
|
|
165
268
|
pins.push({ file, value, via: "node-version" });
|
|
166
269
|
continue;
|
|
167
270
|
}
|
|
168
|
-
const target =
|
|
169
|
-
if (!
|
|
271
|
+
const target = join3(repoRoot, value);
|
|
272
|
+
if (!existsSync3(target)) {
|
|
170
273
|
throw new Error(
|
|
171
274
|
`signoff: ${file} reads its Node pin from "${value}" (node-version-file) and that file does not exist. The workflow this gate replaces cannot itself run, so there is nothing to verify against.`
|
|
172
275
|
);
|
|
@@ -177,12 +280,12 @@ function pinsInWorkflow(repoRoot, file, source) {
|
|
|
177
280
|
return pins;
|
|
178
281
|
}
|
|
179
282
|
function scanMergeGateNodePins(repoRoot) {
|
|
180
|
-
const dir =
|
|
181
|
-
if (!
|
|
283
|
+
const dir = join3(repoRoot, WORKFLOW_DIR);
|
|
284
|
+
if (!existsSync3(dir)) return [];
|
|
182
285
|
const pins = [];
|
|
183
286
|
const files = readdirSync(dir).filter((name) => name.endsWith(".yml") || name.endsWith(".yaml")).sort();
|
|
184
287
|
for (const name of files) {
|
|
185
|
-
const source = readFileSync2(
|
|
288
|
+
const source = readFileSync2(join3(dir, name), "utf8");
|
|
186
289
|
if (!triggersOnPullRequest(source)) continue;
|
|
187
290
|
pins.push(...pinsInWorkflow(repoRoot, `${WORKFLOW_DIR}/${name}`, source));
|
|
188
291
|
}
|
|
@@ -232,8 +335,8 @@ function resolveNodeRequirement(repoRoot, configured) {
|
|
|
232
335
|
return { major, declared: configured.trim(), source: "signoff config `nodeVersion`" };
|
|
233
336
|
}
|
|
234
337
|
let fromNvmrc = null;
|
|
235
|
-
const nvmrc =
|
|
236
|
-
if (
|
|
338
|
+
const nvmrc = join4(repoRoot, ".nvmrc");
|
|
339
|
+
if (existsSync4(nvmrc)) {
|
|
237
340
|
const raw = readFileSync3(nvmrc, "utf8").trim();
|
|
238
341
|
const major = majorOf(raw);
|
|
239
342
|
if (major !== null) fromNvmrc = { major, declared: raw, source: ".nvmrc" };
|
|
@@ -258,8 +361,8 @@ function assertNodeVersion(requirement, running = process.version) {
|
|
|
258
361
|
}
|
|
259
362
|
function assertNodeTypesVersion(repoRoot, requirement) {
|
|
260
363
|
if (!requirement) return;
|
|
261
|
-
const packagePath =
|
|
262
|
-
if (!
|
|
364
|
+
const packagePath = join4(repoRoot, "package.json");
|
|
365
|
+
if (!existsSync4(packagePath)) return;
|
|
263
366
|
const manifest = JSON.parse(readFileSync3(packagePath, "utf8"));
|
|
264
367
|
const declared = manifest.devDependencies?.["@types/node"] ?? manifest.dependencies?.["@types/node"] ?? manifest.optionalDependencies?.["@types/node"];
|
|
265
368
|
if (!declared) return;
|
|
@@ -269,8 +372,8 @@ function assertNodeTypesVersion(repoRoot, requirement) {
|
|
|
269
372
|
`signoff: this repo pins Node ${requirement.declared} but declares @types/node ${declared}. Use the latest @types/node ${requirement.major}.x release.`
|
|
270
373
|
);
|
|
271
374
|
}
|
|
272
|
-
const installedPath =
|
|
273
|
-
if (!
|
|
375
|
+
const installedPath = join4(repoRoot, "node_modules", "@types", "node", "package.json");
|
|
376
|
+
if (!existsSync4(installedPath)) {
|
|
274
377
|
throw new Error(`signoff: @types/node is declared but missing after install in ${repoRoot}.`);
|
|
275
378
|
}
|
|
276
379
|
const installed = JSON.parse(readFileSync3(installedPath, "utf8"));
|
|
@@ -557,8 +660,8 @@ function planAttempts(step, seedBase, overrideRuns) {
|
|
|
557
660
|
|
|
558
661
|
// src/signoff/store.ts
|
|
559
662
|
import { createHash as createHash2 } from "crypto";
|
|
560
|
-
import { existsSync as
|
|
561
|
-
import { join as
|
|
663
|
+
import { existsSync as existsSync5, mkdirSync, readFileSync as readFileSync4, readdirSync as readdirSync2, rmSync, statSync, utimesSync, writeFileSync } from "fs";
|
|
664
|
+
import { join as join5, relative, sep } from "path";
|
|
562
665
|
var MANIFEST_FILES = [
|
|
563
666
|
"pnpm-lock.yaml",
|
|
564
667
|
"pnpm-workspace.yaml",
|
|
@@ -574,9 +677,9 @@ function collectManifests(dir, root, out) {
|
|
|
574
677
|
for (const entry of readdirSync2(dir, { withFileTypes: true })) {
|
|
575
678
|
if (entry.isDirectory()) {
|
|
576
679
|
if (SKIP_DIRS.has(entry.name)) continue;
|
|
577
|
-
collectManifests(
|
|
680
|
+
collectManifests(join5(dir, entry.name), root, out);
|
|
578
681
|
} else if (MANIFEST_FILES.includes(entry.name)) {
|
|
579
|
-
out.push(relative(root,
|
|
682
|
+
out.push(relative(root, join5(dir, entry.name)).split(sep).join("/"));
|
|
580
683
|
}
|
|
581
684
|
}
|
|
582
685
|
}
|
|
@@ -590,15 +693,15 @@ function manifestCacheKey(treePath, files) {
|
|
|
590
693
|
for (const rel of files) {
|
|
591
694
|
hash.update(rel);
|
|
592
695
|
hash.update("\0");
|
|
593
|
-
hash.update(createHash2("sha256").update(readFileSync4(
|
|
696
|
+
hash.update(createHash2("sha256").update(readFileSync4(join5(treePath, rel))).digest("hex"));
|
|
594
697
|
hash.update("\n");
|
|
595
698
|
}
|
|
596
699
|
return hash.digest("hex");
|
|
597
700
|
}
|
|
598
701
|
function pruneStores(storesRoot, keep) {
|
|
599
|
-
if (!
|
|
702
|
+
if (!existsSync5(storesRoot)) return [];
|
|
600
703
|
const entries = readdirSync2(storesRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => {
|
|
601
|
-
const full =
|
|
704
|
+
const full = join5(storesRoot, entry.name);
|
|
602
705
|
return { full, mtimeMs: statSync(full).mtimeMs };
|
|
603
706
|
}).sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
604
707
|
const pruned = [];
|
|
@@ -617,10 +720,10 @@ function resolveStore(options) {
|
|
|
617
720
|
);
|
|
618
721
|
}
|
|
619
722
|
const cacheKey = manifestCacheKey(treePath, files);
|
|
620
|
-
const storesRoot =
|
|
621
|
-
const storeDir =
|
|
622
|
-
const marker =
|
|
623
|
-
const hit =
|
|
723
|
+
const storesRoot = join5(cacheDir, "stores");
|
|
724
|
+
const storeDir = join5(storesRoot, cacheKey);
|
|
725
|
+
const marker = join5(storeDir, ".signoff-store.json");
|
|
726
|
+
const hit = existsSync5(storeDir) && readdirSync2(storeDir).some((entry) => entry !== ".signoff-store.json");
|
|
624
727
|
mkdirSync(storeDir, { recursive: true });
|
|
625
728
|
writeFileSync(marker, `${JSON.stringify({ cacheKey, keyedOn: files, usedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2)}
|
|
626
729
|
`);
|
|
@@ -630,12 +733,12 @@ function resolveStore(options) {
|
|
|
630
733
|
}
|
|
631
734
|
|
|
632
735
|
// src/signoff/workspace.ts
|
|
633
|
-
import { spawnSync } from "child_process";
|
|
736
|
+
import { spawnSync as spawnSync2 } from "child_process";
|
|
634
737
|
import { createHash as createHash3 } from "crypto";
|
|
635
|
-
import { copyFileSync, existsSync as
|
|
636
|
-
import { dirname, isAbsolute, join as
|
|
738
|
+
import { copyFileSync, existsSync as existsSync6, mkdirSync as mkdirSync2, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
739
|
+
import { dirname as dirname2, isAbsolute, join as join6, resolve as resolve2 } from "path";
|
|
637
740
|
function git(args, cwd) {
|
|
638
|
-
const result =
|
|
741
|
+
const result = spawnSync2("git", args, { cwd, encoding: "utf8", maxBuffer: 256 * 1024 * 1024 });
|
|
639
742
|
if (result.error) throw new Error(`signoff: git ${args.join(" ")} failed to start: ${result.error.message}`);
|
|
640
743
|
if (result.status !== 0) {
|
|
641
744
|
throw new Error(`signoff: git ${args.join(" ")} exited ${result.status}
|
|
@@ -655,8 +758,8 @@ function materializeCleanTree(options) {
|
|
|
655
758
|
const head = git(["rev-parse", "HEAD"], root).trim();
|
|
656
759
|
const branch = git(["rev-parse", "--abbrev-ref", "HEAD"], root).trim();
|
|
657
760
|
git(["worktree", "prune"], root);
|
|
658
|
-
mkdirSync2(
|
|
659
|
-
if (
|
|
761
|
+
mkdirSync2(dirname2(dest), { recursive: true });
|
|
762
|
+
if (existsSync6(dest)) rmSync2(dest, { recursive: true, force: true });
|
|
660
763
|
git(["worktree", "add", "--detach", "--quiet", dest, head], root);
|
|
661
764
|
let diffSha256 = null;
|
|
662
765
|
let untrackedFiles = [];
|
|
@@ -664,29 +767,29 @@ function materializeCleanTree(options) {
|
|
|
664
767
|
const patch = git(["diff", "HEAD", "--binary", "--no-color", "--no-ext-diff"], root);
|
|
665
768
|
if (patch.length > 0) {
|
|
666
769
|
diffSha256 = createHash3("sha256").update(patch).digest("hex");
|
|
667
|
-
const patchFile =
|
|
770
|
+
const patchFile = join6(dirname2(dest), `${dest.split("/").pop() ?? "tree"}.patch`);
|
|
668
771
|
writeFileSync2(patchFile, patch);
|
|
669
772
|
git(["apply", "--binary", "--whitespace=nowarn", patchFile], dest);
|
|
670
773
|
rmSync2(patchFile, { force: true });
|
|
671
774
|
}
|
|
672
775
|
untrackedFiles = zsplit(git(["ls-files", "--others", "--exclude-standard", "-z"], root));
|
|
673
776
|
for (const rel of untrackedFiles) {
|
|
674
|
-
const target =
|
|
675
|
-
mkdirSync2(
|
|
676
|
-
copyFileSync(
|
|
777
|
+
const target = join6(dest, rel);
|
|
778
|
+
mkdirSync2(dirname2(target), { recursive: true });
|
|
779
|
+
copyFileSync(join6(root, rel), target);
|
|
677
780
|
}
|
|
678
781
|
}
|
|
679
782
|
const carried = [];
|
|
680
783
|
for (const rel of carryFiles) {
|
|
681
784
|
if (isAbsolute(rel)) throw new Error(`signoff: carryFiles must be repo-relative; got "${rel}"`);
|
|
682
785
|
const from = resolve2(root, rel);
|
|
683
|
-
if (!
|
|
786
|
+
if (!existsSync6(from)) {
|
|
684
787
|
throw new Error(
|
|
685
788
|
`signoff: carryFiles names "${rel}", which does not exist at ${from}. Remove it from the config or create the file \u2014 installing without it would resolve against a different registry than the one you think you are verifying.`
|
|
686
789
|
);
|
|
687
790
|
}
|
|
688
|
-
const target =
|
|
689
|
-
mkdirSync2(
|
|
791
|
+
const target = join6(dest, rel);
|
|
792
|
+
mkdirSync2(dirname2(target), { recursive: true });
|
|
690
793
|
copyFileSync(from, target);
|
|
691
794
|
carried.push(rel);
|
|
692
795
|
}
|
|
@@ -707,9 +810,9 @@ function removeCleanTree(tree) {
|
|
|
707
810
|
}
|
|
708
811
|
|
|
709
812
|
// src/signoff/run.ts
|
|
710
|
-
var DEFAULT_CACHE_DIR =
|
|
813
|
+
var DEFAULT_CACHE_DIR = join7(homedir(), ".cache", "agent-app-signoff");
|
|
711
814
|
function hostFacts(treePath, requirement) {
|
|
712
|
-
const pm =
|
|
815
|
+
const pm = spawnSync3("pnpm", ["--version"], { cwd: treePath, encoding: "utf8" });
|
|
713
816
|
return {
|
|
714
817
|
node: process.version,
|
|
715
818
|
nodePinned: requirement?.declared ?? null,
|
|
@@ -751,7 +854,7 @@ async function runSignoff(options = {}) {
|
|
|
751
854
|
const repoRoot = repoRootOf(repoDir);
|
|
752
855
|
const source = options.source ?? "working-tree";
|
|
753
856
|
let cacheDir = resolve3(options.cacheDir ?? DEFAULT_CACHE_DIR);
|
|
754
|
-
const treePath = () =>
|
|
857
|
+
const treePath = () => join7(cacheDir, "trees", `${basename2(repoRoot)}-${process.pid}`);
|
|
755
858
|
let tree = null;
|
|
756
859
|
try {
|
|
757
860
|
tree = materializeCleanTree({ repoDir: repoRoot, dest: treePath(), source });
|
|
@@ -771,7 +874,7 @@ async function runSignoff(options = {}) {
|
|
|
771
874
|
const store = resolveStore({ treePath: tree.path, cacheDir, generations: config.storeGenerations });
|
|
772
875
|
options.onEvent?.({ kind: "store", storeDir: store.storeDir, cacheHit: store.hit, cacheKey: store.cacheKey });
|
|
773
876
|
const installSpec = config.install ?? {};
|
|
774
|
-
const installCwd =
|
|
877
|
+
const installCwd = join7(tree.path, installSpec.cwd ?? ".");
|
|
775
878
|
const installCommand = withStoreDir(
|
|
776
879
|
installSpec.run ?? "pnpm install --frozen-lockfile",
|
|
777
880
|
installSpec.storeDirFlag,
|
|
@@ -815,9 +918,9 @@ async function runSignoff(options = {}) {
|
|
|
815
918
|
origin,
|
|
816
919
|
host,
|
|
817
920
|
install,
|
|
818
|
-
steps: config.steps.map(
|
|
819
|
-
(
|
|
820
|
-
name
|
|
921
|
+
steps: [...config.steps.map((step) => step.name), WORKER_DEFAULTS_STEP].map(
|
|
922
|
+
(name) => ({
|
|
923
|
+
name,
|
|
821
924
|
status: "skipped",
|
|
822
925
|
attempts: [],
|
|
823
926
|
durationMs: 0,
|
|
@@ -833,6 +936,7 @@ async function runSignoff(options = {}) {
|
|
|
833
936
|
});
|
|
834
937
|
}
|
|
835
938
|
assertNodeTypesVersion(tree.path, nodeRequirement);
|
|
939
|
+
const workerDefaults = runWorkerDefaults(tree.path, config.workerConfigs, options);
|
|
836
940
|
const treeRoot = tree.path;
|
|
837
941
|
const outcomes = await runGraph({
|
|
838
942
|
nodes: config.steps,
|
|
@@ -844,7 +948,7 @@ async function runSignoff(options = {}) {
|
|
|
844
948
|
options.onEvent?.({ kind: "step-start", name: step.name, command: plan.command, seed: plan.seed });
|
|
845
949
|
const result = await runCommand({
|
|
846
950
|
command: plan.command,
|
|
847
|
-
cwd:
|
|
951
|
+
cwd: join7(treeRoot, step.cwd ?? "."),
|
|
848
952
|
env: buildEnv(sharedEnv, [step.env]),
|
|
849
953
|
timeoutMs: step.timeoutMs,
|
|
850
954
|
signal
|
|
@@ -860,7 +964,7 @@ async function runSignoff(options = {}) {
|
|
|
860
964
|
return { ok: true, value: attempts };
|
|
861
965
|
}
|
|
862
966
|
});
|
|
863
|
-
const steps = outcomes.map(toStepResult);
|
|
967
|
+
const steps = [...outcomes.map(toStepResult), workerDefaults];
|
|
864
968
|
return finish({
|
|
865
969
|
ok: steps.every((step) => step.status === "passed"),
|
|
866
970
|
startedAt,
|
|
@@ -877,9 +981,31 @@ async function runSignoff(options = {}) {
|
|
|
877
981
|
options
|
|
878
982
|
});
|
|
879
983
|
} finally {
|
|
880
|
-
if (tree && !options.keepWorkspace &&
|
|
984
|
+
if (tree && !options.keepWorkspace && existsSync7(tree.path)) removeCleanTree(tree);
|
|
881
985
|
}
|
|
882
986
|
}
|
|
987
|
+
function runWorkerDefaults(treeRoot, workerConfigs, options) {
|
|
988
|
+
const command = `agent-app-signoff ${WORKER_DEFAULTS_STEP}`;
|
|
989
|
+
options.onEvent?.({ kind: "step-start", name: WORKER_DEFAULTS_STEP, command, seed: null });
|
|
990
|
+
const started = Date.now();
|
|
991
|
+
let output;
|
|
992
|
+
let ok;
|
|
993
|
+
try {
|
|
994
|
+
const result = checkWorkerDefaults(treeRoot, workerConfigs);
|
|
995
|
+
output = formatWorkerDefaults(result);
|
|
996
|
+
ok = result.findings.length === 0;
|
|
997
|
+
} catch (error) {
|
|
998
|
+
output = `${error instanceof Error ? error.stack ?? error.message : String(error)}
|
|
999
|
+
`;
|
|
1000
|
+
ok = false;
|
|
1001
|
+
}
|
|
1002
|
+
const durationMs = Date.now() - started;
|
|
1003
|
+
const attempts = [
|
|
1004
|
+
{ command, seed: null, exitCode: ok ? 0 : 1, signal: null, durationMs, timedOut: false, output, outputTruncated: false }
|
|
1005
|
+
];
|
|
1006
|
+
emitStepEnd(options, WORKER_DEFAULTS_STEP, ok ? "passed" : "failed", attempts);
|
|
1007
|
+
return { name: WORKER_DEFAULTS_STEP, status: ok ? "passed" : "failed", attempts, durationMs, startedAtMs: null, finishedAtMs: null };
|
|
1008
|
+
}
|
|
883
1009
|
function emitStepEnd(options, name, status, attempts) {
|
|
884
1010
|
options.onEvent?.({
|
|
885
1011
|
kind: "step-end",
|
|
@@ -1050,9 +1176,12 @@ function formatSignoffLine(report) {
|
|
|
1050
1176
|
}
|
|
1051
1177
|
|
|
1052
1178
|
export {
|
|
1179
|
+
WORKER_COMPATIBILITY_DATE_FLOOR,
|
|
1180
|
+
checkWorkerDefaults,
|
|
1181
|
+
formatWorkerDefaults,
|
|
1053
1182
|
loadSignoffConfig,
|
|
1054
1183
|
runSignoff,
|
|
1055
1184
|
formatSignoffReport,
|
|
1056
1185
|
formatSignoffLine
|
|
1057
1186
|
};
|
|
1058
|
-
//# sourceMappingURL=chunk-
|
|
1187
|
+
//# sourceMappingURL=chunk-TSHEYSTY.js.map
|