@foldrun/core 17.0.0 → 17.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -456,6 +456,14 @@ export declare const ENTRY: string;
456
456
  /** Which build target of the runner image (see DOCKERFILE). */
457
457
  export type RunnerVariant = "full" | "slim";
458
458
  export declare function runnerImageTag(variant?: RunnerVariant): string;
459
+ /**
460
+ * `npm pack` an installed, already built core into `dest`, running none of
461
+ * its scripts. Its `prepare` (npm run build: clear dist/, then tsc) used to
462
+ * run on every pack, and in an install with no TypeScript — every CLI from
463
+ * npm — it failed half way: each container step failed with "npm pack
464
+ * failed", and the first one deleted the install's own dist/.
465
+ */
466
+ export declare function packInstalledCore(pkgDir: string, dest: string): void;
459
467
  /**
460
468
  * Build the runner image if this exact (core version, driver, dockerfile)
461
469
  * has not been built before. `npm pack` of the installed core, so the image
@@ -1197,6 +1197,11 @@ export const DOCKERFILE = runnerDockerfile();
1197
1197
  export const ENTRY = `#!/bin/sh
1198
1198
  set +e
1199
1199
  ${ROOT_SHELL_GUARD_SH}
1200
+ # docker cp keeps the host's owner: from a non-root host (a laptop) the job
1201
+ # files arrive as uid 501, and root without CAP_DAC_OVERRIDE cannot read its
1202
+ # own 0600 root-env.sh. Root's first, before any of them is read; the agent
1203
+ # gets the folder below as before.
1204
+ chown -R 0:0 /opt/runner/job 2>/dev/null || true
1200
1205
  # The runtime cache, when one is mounted. NOT recursive: a warm cache is tens
1201
1206
  # of thousands of files and its contents are already agent-owned from the step
1202
1207
  # that built them — only the mount point itself arrives owned by root. Before
@@ -1244,6 +1249,35 @@ export function runnerImageTag(variant = "full") {
1244
1249
  }
1245
1250
  return `foldrun-runner:${hash.digest("hex").slice(0, 12)}${variant === "slim" ? "-slim" : ""}`;
1246
1251
  }
1252
+ /**
1253
+ * `npm pack` an installed, already built core into `dest`, running none of
1254
+ * its scripts. Its `prepare` (npm run build: clear dist/, then tsc) used to
1255
+ * run on every pack, and in an install with no TypeScript — every CLI from
1256
+ * npm — it failed half way: each container step failed with "npm pack
1257
+ * failed", and the first one deleted the install's own dist/.
1258
+ */
1259
+ export function packInstalledCore(pkgDir, dest) {
1260
+ const out = path.dirname(dest);
1261
+ // A copy with no scripts, because npm 10 (Node 22's) runs `prepare` on a
1262
+ // pack even with --ignore-scripts; npm 11 does not. The copy leaves out
1263
+ // node_modules, which a pack never takes anyway.
1264
+ const copy = fs.mkdtempSync(path.join(out, ".core-pack-"));
1265
+ try {
1266
+ fs.cpSync(pkgDir, copy, { recursive: true, filter: (src) => path.basename(src) !== "node_modules" });
1267
+ const manifest = path.join(copy, "package.json");
1268
+ const pkg = JSON.parse(fs.readFileSync(manifest, "utf8"));
1269
+ delete pkg.scripts;
1270
+ fs.writeFileSync(manifest, JSON.stringify(pkg, null, 2) + "\n");
1271
+ const pack = spawnSync("npm", ["pack", copy, "--pack-destination", out, "--ignore-scripts"], { encoding: "utf8" });
1272
+ if (pack.status !== 0)
1273
+ throw new Error(`npm pack failed:\n${pack.stderr}`);
1274
+ const tarball = pack.stdout.trim().split("\n").at(-1);
1275
+ fs.renameSync(path.join(out, tarball), dest);
1276
+ }
1277
+ finally {
1278
+ fs.rmSync(copy, { recursive: true, force: true });
1279
+ }
1280
+ }
1247
1281
  /**
1248
1282
  * Build the runner image if this exact (core version, driver, dockerfile)
1249
1283
  * has not been built before. `npm pack` of the installed core, so the image
@@ -1290,13 +1324,7 @@ export function ensureRunnerImage(opts = {}) {
1290
1324
  return { tag, log };
1291
1325
  const build = fs.mkdtempSync(path.join(os.tmpdir(), "foldrun-runner-build-"));
1292
1326
  try {
1293
- const pack = spawnSync("npm", ["pack", corePackageDir(), "--pack-destination", build], {
1294
- encoding: "utf8",
1295
- });
1296
- if (pack.status !== 0)
1297
- throw new Error(`npm pack failed:\n${pack.stderr}`);
1298
- const tarball = pack.stdout.trim().split("\n").at(-1);
1299
- fs.renameSync(path.join(build, tarball), path.join(build, "foldrun-core.tgz"));
1327
+ packInstalledCore(corePackageDir(), path.join(build, "foldrun-core.tgz"));
1300
1328
  fs.writeFileSync(path.join(build, "driver.mjs"), DRIVER);
1301
1329
  fs.writeFileSync(path.join(build, "entry.sh"), ENTRY);
1302
1330
  // The same text the tag hashed (runnerImageTag), base and all.
@@ -1190,7 +1190,11 @@ export function modelProcessError(err, where) {
1190
1190
  return new Error(`${head} — the model process failed`);
1191
1191
  }
1192
1192
  export function sdkEnv(base, extra = {}) {
1193
- return { ...(base ?? process.env), ...extra, ENABLE_CLAUDEAI_MCP_SERVERS: "false" };
1193
+ // No telemetry, error reports, update checks or feature-flag fetches from
1194
+ // the model process: none of it is the step, and it held back the SDK's
1195
+ // start by ~0.85 s a step on an open network (FOL-49: init median 1.4 s →
1196
+ // 0.56 s, 9 runs each); behind the egress filter those hosts are refused.
1197
+ return { ...(base ?? process.env), ...extra, ENABLE_CLAUDEAI_MCP_SERVERS: "false", CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1" };
1194
1198
  }
1195
1199
  /** The text of a tool result, whichever shape it came in: a string, or a
1196
1200
  * list of content blocks of which only the text ones say anything. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foldrun/core",
3
- "version": "17.0.0",
3
+ "version": "17.0.1",
4
4
  "description": "Agents are just folders. The format, the runner, the checks.",
5
5
  "license": "FSL-1.1-ALv2",
6
6
  "type": "module",
@@ -1404,6 +1404,11 @@ export const DOCKERFILE = runnerDockerfile();
1404
1404
  export const ENTRY = `#!/bin/sh
1405
1405
  set +e
1406
1406
  ${ROOT_SHELL_GUARD_SH}
1407
+ # docker cp keeps the host's owner: from a non-root host (a laptop) the job
1408
+ # files arrive as uid 501, and root without CAP_DAC_OVERRIDE cannot read its
1409
+ # own 0600 root-env.sh. Root's first, before any of them is read; the agent
1410
+ # gets the folder below as before.
1411
+ chown -R 0:0 /opt/runner/job 2>/dev/null || true
1407
1412
  # The runtime cache, when one is mounted. NOT recursive: a warm cache is tens
1408
1413
  # of thousands of files and its contents are already agent-owned from the step
1409
1414
  # that built them — only the mount point itself arrives owned by root. Before
@@ -1454,6 +1459,34 @@ export function runnerImageTag(variant: RunnerVariant = "full"): string {
1454
1459
  return `foldrun-runner:${hash.digest("hex").slice(0, 12)}${variant === "slim" ? "-slim" : ""}`;
1455
1460
  }
1456
1461
 
1462
+ /**
1463
+ * `npm pack` an installed, already built core into `dest`, running none of
1464
+ * its scripts. Its `prepare` (npm run build: clear dist/, then tsc) used to
1465
+ * run on every pack, and in an install with no TypeScript — every CLI from
1466
+ * npm — it failed half way: each container step failed with "npm pack
1467
+ * failed", and the first one deleted the install's own dist/.
1468
+ */
1469
+ export function packInstalledCore(pkgDir: string, dest: string): void {
1470
+ const out = path.dirname(dest);
1471
+ // A copy with no scripts, because npm 10 (Node 22's) runs `prepare` on a
1472
+ // pack even with --ignore-scripts; npm 11 does not. The copy leaves out
1473
+ // node_modules, which a pack never takes anyway.
1474
+ const copy = fs.mkdtempSync(path.join(out, ".core-pack-"));
1475
+ try {
1476
+ fs.cpSync(pkgDir, copy, { recursive: true, filter: (src) => path.basename(src) !== "node_modules" });
1477
+ const manifest = path.join(copy, "package.json");
1478
+ const pkg = JSON.parse(fs.readFileSync(manifest, "utf8")) as Record<string, unknown>;
1479
+ delete pkg.scripts;
1480
+ fs.writeFileSync(manifest, JSON.stringify(pkg, null, 2) + "\n");
1481
+ const pack = spawnSync("npm", ["pack", copy, "--pack-destination", out, "--ignore-scripts"], { encoding: "utf8" });
1482
+ if (pack.status !== 0) throw new Error(`npm pack failed:\n${pack.stderr}`);
1483
+ const tarball = pack.stdout.trim().split("\n").at(-1)!;
1484
+ fs.renameSync(path.join(out, tarball), dest);
1485
+ } finally {
1486
+ fs.rmSync(copy, { recursive: true, force: true });
1487
+ }
1488
+ }
1489
+
1457
1490
  /**
1458
1491
  * Build the runner image if this exact (core version, driver, dockerfile)
1459
1492
  * has not been built before. `npm pack` of the installed core, so the image
@@ -1504,12 +1537,7 @@ export function ensureRunnerImage(
1504
1537
 
1505
1538
  const build = fs.mkdtempSync(path.join(os.tmpdir(), "foldrun-runner-build-"));
1506
1539
  try {
1507
- const pack = spawnSync("npm", ["pack", corePackageDir(), "--pack-destination", build], {
1508
- encoding: "utf8",
1509
- });
1510
- if (pack.status !== 0) throw new Error(`npm pack failed:\n${pack.stderr}`);
1511
- const tarball = pack.stdout.trim().split("\n").at(-1)!;
1512
- fs.renameSync(path.join(build, tarball), path.join(build, "foldrun-core.tgz"));
1540
+ packInstalledCore(corePackageDir(), path.join(build, "foldrun-core.tgz"));
1513
1541
  fs.writeFileSync(path.join(build, "driver.mjs"), DRIVER);
1514
1542
  fs.writeFileSync(path.join(build, "entry.sh"), ENTRY);
1515
1543
  // The same text the tag hashed (runnerImageTag), base and all.
package/src/step-exec.ts CHANGED
@@ -1400,7 +1400,11 @@ export function modelProcessError(err: unknown, where: string): Error {
1400
1400
  }
1401
1401
 
1402
1402
  export function sdkEnv(base: Record<string, string | undefined> | undefined, extra: Record<string, string> = {}): Record<string, string | undefined> {
1403
- return { ...(base ?? process.env), ...extra, ENABLE_CLAUDEAI_MCP_SERVERS: "false" };
1403
+ // No telemetry, error reports, update checks or feature-flag fetches from
1404
+ // the model process: none of it is the step, and it held back the SDK's
1405
+ // start by ~0.85 s a step on an open network (FOL-49: init median 1.4 s →
1406
+ // 0.56 s, 9 runs each); behind the egress filter those hosts are refused.
1407
+ return { ...(base ?? process.env), ...extra, ENABLE_CLAUDEAI_MCP_SERVERS: "false", CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1" };
1404
1408
  }
1405
1409
 
1406
1410
  /** The text of a tool result, whichever shape it came in: a string, or a