@outerlayer/cli 0.38.0-next.20261112043334 → 0.38.0-next.20261112060830
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/README.md +3 -1
- package/dist/{build-FNUOBMFG.js → build-F6G4J2FW.js} +2 -2
- package/dist/{build-disk-4PCVGMAT.js → build-disk-AC32UE6Q.js} +2 -2
- package/dist/build-info.json +1 -1
- package/dist/{builder-JG2DHKSN.js → builder-BXWJDPFD.js} +1 -1
- package/dist/{caller-A2K7SLSL.js → caller-2CWKZUMK.js} +4 -4
- package/dist/{check-6JV4M2U6.js → check-Y37I4WJY.js} +13 -13
- package/dist/{chunk-6M3GJTGE.js → chunk-4QBKDMMR.js} +2 -2
- package/dist/{chunk-A4NWDCWS.js → chunk-4VJAUAUZ.js} +1 -1
- package/dist/{chunk-WG5OBUIZ.js → chunk-5BNJCTX3.js} +2 -2
- package/dist/{chunk-EUHUIIGT.js → chunk-AE5RNDFC.js} +2 -2
- package/dist/{chunk-2PJO6QS2.js → chunk-AY37L45W.js} +3 -3
- package/dist/{chunk-5AVYYNGU.js → chunk-C4ODIVBE.js} +1 -1
- package/dist/{chunk-KRYTOYH5.js → chunk-D2HVKCAP.js} +10 -10
- package/dist/{chunk-LM2MCACJ.js → chunk-E3AFLETW.js} +4 -4
- package/dist/{chunk-C5NJHYLO.js → chunk-FOXLLZL2.js} +3 -3
- package/dist/{chunk-OAPWDSBW.js → chunk-K4BL5PKW.js} +1 -1
- package/dist/{chunk-37WGI6GZ.js → chunk-NWFGPL72.js} +4 -4
- package/dist/{chunk-ERG3WCEC.js → chunk-QZSYYHWU.js} +2 -0
- package/dist/{chunk-RTMIEV5N.js → chunk-SUQYLS7Z.js} +2 -2
- package/dist/{chunk-BBIFZCCB.js → chunk-TE6II3DH.js} +163 -73
- package/dist/{chunk-RCK2MJRG.js → chunk-WNKNY3ON.js} +1 -1
- package/dist/{chunk-3C23ZPWR.js → chunk-XWPDXQYX.js} +1 -1
- package/dist/{cli-7MJFFRYI.js → cli-6YLSLHV5.js} +59 -52
- package/dist/{command-XLJ75AS5.js → command-COOL6ZO7.js} +9 -9
- package/dist/{config-5KMNGNK5.js → config-BVXXJ42A.js} +3 -3
- package/dist/{container-start-F6T3JPRM.js → container-start-45KGI3FK.js} +10 -10
- package/dist/{docker-T7A6GZDD.js → docker-AN3FVXDR.js} +1 -1
- package/dist/{doctor-F7TCZO3O.js → doctor-ZJBJNHGD.js} +10 -10
- package/dist/{find-unit-3QYPTK6A.js → find-unit-Q4PYWSZK.js} +5 -5
- package/dist/{host-checks-VWWXDWV2.js → host-checks-GH3ZZU25.js} +8 -8
- package/dist/index.js +1 -1
- package/dist/{init-OIHCYS4S.js → init-FL7HNYBZ.js} +8 -8
- package/dist/{init-W4X47BR5.js → init-RWEVJLEY.js} +8 -8
- package/dist/{init-agent-QQF3VGIJ.js → init-agent-453OBSZF.js} +8 -8
- package/dist/{init-cmd-QXAL75UY.js → init-cmd-7KXNQUBQ.js} +1 -1
- package/dist/{loop-U5AUIWQG.js → loop-OFKJO3OD.js} +12 -12
- package/dist/{machine-6DFKQ3LQ.js → machine-BUYUGQZV.js} +8 -8
- package/dist/{relay-V7LX2WR6.js → relay-EWL5ENEI.js} +19 -4
- package/dist/{runner-env-3QPJQ2H2.js → runner-env-D5KKKJTW.js} +5 -5
- package/dist/{runner-identity-GTWFQEIN.js → runner-identity-5WSI6HPW.js} +1 -1
- package/dist/{runner-key-WZXU64C7.js → runner-key-M5L3Q7AF.js} +8 -8
- package/dist/{status-QBQAN35R.js → status-7EUPBDYS.js} +8 -8
- package/dist/{update-steps-QRRCMRL4.js → update-steps-MMOH7GAJ.js} +9 -9
- package/dist/{work-claim-cmd-QDNRGX2N.js → work-claim-cmd-RDRFNBL3.js} +3 -3
- package/dist/{work-proofs-cmd-DSDVAM6V.js → work-proofs-cmd-CD5YQDSS.js} +1 -1
- package/dist/{work-proofs-record-AC5UQ2ME.js → work-proofs-record-PR3UHFMU.js} +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { itemsSentence, criteriaOf, hostItemsOf, loadCitationFinder, testFileMat
|
|
|
4
4
|
import { RUNNER_PROTOCOL } from './chunk-KVWFAAAQ.js';
|
|
5
5
|
import { sha256OfFile, downloadPinned, VoiceDownloadError } from './chunk-2PGI6RDE.js';
|
|
6
6
|
import { zodProblem } from './chunk-I3LTIAOR.js';
|
|
7
|
-
import { hasStoredCredential, storedCredentialVariables, storeAgentCredential, isAgentName, credentialFromStdin } from './chunk-
|
|
7
|
+
import { hasStoredCredential, storedCredentialVariables, storeAgentCredential, isAgentName, credentialFromStdin } from './chunk-4VJAUAUZ.js';
|
|
8
8
|
import { upgradedStarterText } from './chunk-4T2NBVC4.js';
|
|
9
9
|
import { HELPER_PATH, HELPER_RECORD, DOCKERD_LOG } from './chunk-DZFIRKDZ.js';
|
|
10
10
|
import { writeDockerClientConfig } from './chunk-N6BNN6ZD.js';
|
|
@@ -12,9 +12,9 @@ import { senderPidfile } from './chunk-ECNWHXIO.js';
|
|
|
12
12
|
import { installScrubContext } from './chunk-3T7PXUHN.js';
|
|
13
13
|
import { readsJobState, READ_JOB_STATE_FORMATS, jobStateFormatOf } from './chunk-ZVB57WI6.js';
|
|
14
14
|
import { runnerImageVersion } from './chunk-UXARYJQ4.js';
|
|
15
|
-
import { claimCalls, spoolHomeFor, itemCalls, claimItem, leftByRunnerKey, configForJob } from './chunk-
|
|
15
|
+
import { claimCalls, spoolHomeFor, itemCalls, claimItem, leftByRunnerKey, configForJob } from './chunk-WNKNY3ON.js';
|
|
16
16
|
import { receiveFiles } from './chunk-NN33FYXG.js';
|
|
17
|
-
import { readDefaultBranchFiles, readDefaultBranchHead, buildRepositoryImage, readRepositoryRecipe, fetchCommit, readBranchHead, diffBetween, prepareImageBuild, KEY_PREFIX, TAG_HOST, SHARED_OWNER, SHARED_NAME, universalBase, metadataFromLabels, writeRecord } from './chunk-
|
|
17
|
+
import { readDefaultBranchFiles, readDefaultBranchHead, buildRepositoryImage, readRepositoryRecipe, fetchCommit, readBranchHead, diffBetween, prepareImageBuild, KEY_PREFIX, TAG_HOST, SHARED_OWNER, SHARED_NAME, universalBase, metadataFromLabels, writeRecord } from './chunk-C4ODIVBE.js';
|
|
18
18
|
import { FETCHED_DIR, toolsDockerfile, FETCHED_FFMPEG, FETCHED_GH, FETCHED_TINI, FETCHED_HEADLESS_SHELL, FETCHED_PLAYWRIGHT_FFMPEG, FETCHED_VOICE_DIR } from './chunk-NO4N4D32.js';
|
|
19
19
|
import { isSameProcess, startTimeOf } from './chunk-JBJTC3UU.js';
|
|
20
20
|
import { currentCliBuild } from './chunk-OGFGZQA3.js';
|
|
@@ -22,9 +22,9 @@ import { vmExecArgs, runExec, execCapture, waitForAgent } from './chunk-BBRXFXBB
|
|
|
22
22
|
import { socketPathProblem, vsockLinks, linkVsockSockets, GUEST_CID, LEASE_LINK } from './chunk-NRDFBOKE.js';
|
|
23
23
|
import { describeCallFailure, shortClaim, retrySend, commandWithShim, logStamp, createRunnerLog, formatDuration, removeKeptContext, formatClock, stageGovernedContext, keptContextTree, removeStagedContext, WORKFLOW_PERMISSION_REASON, refusalCode, SELF_GOVERNED, resolveGoverningSource, prefetchGovernedContext, controlPlaneTokenFailure, keepStagedContext, pinnedSourceOf, shimScript } from './chunk-SFN7K33S.js';
|
|
24
24
|
import { postJson, WorkCommandError, isSignatureRefusal, getJson } from './chunk-DNXYI22V.js';
|
|
25
|
-
import { isBuiltinContainer, isBuiltinVm, isBuiltinSandbox, keyRunnerFactory, runnerCredentialProblem, builtinKind, readOnlyOption, optionalEgress, egressSummary, DEFAULT_WORKSPACE_KEEP_DAYS, readOnlyRemoteOf, DEFAULT_CHECK_TIME_LIMIT_MINUTES, DEFAULT_SETUP_MINUTES, allowHostProblem, systemClock, emptyEgressCounts, hostAllowed, sandboxTimeLimitMinutes, networkOf, imageBuildOf, sandboxSizeOf, DEFAULT_SAVED_STATE_MAX_BYTES } from './chunk-
|
|
26
|
-
import { formatBytes, volumeBytes, allocatedBytes, DEFAULT_BUILD_DISK, DEFAULT_CACHE_DISK, freeBytes } from './chunk-
|
|
27
|
-
import { said, firstLine, writeJobFile, readJobFile, spawnRun, RUNNER_LABEL, BUILD_LABEL,
|
|
25
|
+
import { isBuiltinContainer, isBuiltinVm, isBuiltinSandbox, keyRunnerFactory, runnerCredentialProblem, builtinKind, readOnlyOption, optionalEgress, egressSummary, DEFAULT_WORKSPACE_KEEP_DAYS, readOnlyRemoteOf, DEFAULT_CHECK_TIME_LIMIT_MINUTES, DEFAULT_SETUP_MINUTES, allowHostProblem, systemClock, emptyEgressCounts, hostAllowed, sandboxTimeLimitMinutes, networkOf, imageBuildOf, sandboxSizeOf, DEFAULT_SAVED_STATE_MAX_BYTES } from './chunk-AE5RNDFC.js';
|
|
26
|
+
import { formatBytes, volumeBytes, allocatedBytes, DEFAULT_BUILD_DISK, DEFAULT_CACHE_DISK, freeBytes } from './chunk-XWPDXQYX.js';
|
|
27
|
+
import { said, NETWORK_HELPER_MEMORY, firstLine, writeJobFile, readJobFile, spawnRun, RUNNER_LABEL, BUILD_LABEL, createDockerHost, builderSpec, childEnvironment, containerExecArgs, readDu, NETWORK_READY_FILE, withAnswerProtocol, JUDGE_TREE, MAX_REPORT_BYTES, runnerLabelValue, parseSize, readJobFileChecked, networkHelperName, prepareRunArgs, containerRunArgs, judgeCommand, JUDGE_DIR, WORKSPACE_LABEL, homeCopyRunArgs, networkHelperRunArgs, JUDGE_MAX_TURNS, JUDGE_ITEMS, answerFileName, hashJudgeProgram, identityScript, identityArgs, parseIdentity, mountableHome, homeCopyScript, homeCopyArgs, COMMAND_DIR, judgeProgramRecord, MAX_ITEMS_BYTES, JUDGE_REPORT, identityRunArgs, SAVED_STATE_LABEL } from './chunk-QZSYYHWU.js';
|
|
28
28
|
import { universalImagePending, RecipeError, writeSanitizedRecipe, classifyProperties, DOCKER_FEATURE } from './chunk-FUZEOWF4.js';
|
|
29
29
|
import { sanitizeTerminal, planArtifactUpload } from './chunk-26BFN6DH.js';
|
|
30
30
|
import { sharedSkillNames, skillConflictMessage } from './chunk-I62FX622.js';
|
|
@@ -1437,6 +1437,7 @@ function createSandboxPorts(opts, hostEnv) {
|
|
|
1437
1437
|
creating: opts?.creating ?? /* @__PURE__ */ new Set(),
|
|
1438
1438
|
resuming: opts?.resuming ?? /* @__PURE__ */ new Set(),
|
|
1439
1439
|
joinSecrets: opts?.joinSecrets ?? /* @__PURE__ */ new Map(),
|
|
1440
|
+
networkHelper: opts?.networkHelper ?? ((options) => ensureNetworkHelper(options)),
|
|
1440
1441
|
sleep: opts?.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms)))
|
|
1441
1442
|
};
|
|
1442
1443
|
}
|
|
@@ -3493,6 +3494,67 @@ function superviseRelay(input) {
|
|
|
3493
3494
|
}
|
|
3494
3495
|
};
|
|
3495
3496
|
}
|
|
3497
|
+
var NETWORK_READY_ATTEMPTS = 60;
|
|
3498
|
+
var NETWORK_READY_PAUSE_MS = 500;
|
|
3499
|
+
var LOG_LINES = 20;
|
|
3500
|
+
async function helperReason(runtime, name) {
|
|
3501
|
+
const logs = await runtime.host.logs(name, LOG_LINES);
|
|
3502
|
+
const lines = `${logs.stdout}
|
|
3503
|
+
${logs.stderr}`.split("\n").map((line2) => line2.trim());
|
|
3504
|
+
return lines.filter((line2) => line2.startsWith("net: ")).at(-1) ?? lines.filter((line2) => line2 !== "").at(-1) ?? "";
|
|
3505
|
+
}
|
|
3506
|
+
async function waitForNetwork(runtime, name) {
|
|
3507
|
+
for (let attempt = 0; attempt < NETWORK_READY_ATTEMPTS; attempt++) {
|
|
3508
|
+
const probe = await runtime.host.exec({ container: name, user: "0:0", env: { literals: {}, passed: {} }, argv: ["cat", NETWORK_READY_FILE] });
|
|
3509
|
+
if (probe.status === 0) return void 0;
|
|
3510
|
+
const state = await runtime.host.state(name);
|
|
3511
|
+
if (state === "stopped" || state === "missing") {
|
|
3512
|
+
return `the build's network helper container stopped before its network was ready${said(await helperReason(runtime, name))}`;
|
|
3513
|
+
}
|
|
3514
|
+
await runtime.sleep(NETWORK_READY_PAUSE_MS);
|
|
3515
|
+
}
|
|
3516
|
+
return `the build's network helper container was not ready within ${NETWORK_READY_ATTEMPTS * NETWORK_READY_PAUSE_MS / 1e3} seconds${said(await helperReason(runtime, name))}`;
|
|
3517
|
+
}
|
|
3518
|
+
async function startNetworkHelper(runtime, input, logPath) {
|
|
3519
|
+
const started = await runtime.host.run(networkHelperRunArgs(input), { logPath });
|
|
3520
|
+
if (started.status !== 0) {
|
|
3521
|
+
return `starting the build's network helper container failed (exit ${started.status})${said(started.stderr)}`;
|
|
3522
|
+
}
|
|
3523
|
+
return waitForNetwork(runtime, input.name);
|
|
3524
|
+
}
|
|
3525
|
+
async function ensureNetworkReady(runtime, state) {
|
|
3526
|
+
if (state.network === void 0) return void 0;
|
|
3527
|
+
const current = await runtime.host.state(state.network);
|
|
3528
|
+
if (current === "running") return void 0;
|
|
3529
|
+
if (current === "missing") return `the build's network helper container ${state.network} is gone`;
|
|
3530
|
+
const started = await runtime.host.start(state.network);
|
|
3531
|
+
if (started.status !== 0) {
|
|
3532
|
+
return `starting the build's network helper container again failed (exit ${started.status})${said(started.stderr)}`;
|
|
3533
|
+
}
|
|
3534
|
+
return waitForNetwork(runtime, state.network);
|
|
3535
|
+
}
|
|
3536
|
+
async function stoppedHelperReason(runtime, name) {
|
|
3537
|
+
if (await runtime.host.oomKilled(name)) return `the build's network helper container ran out of memory (${NETWORK_HELPER_MEMORY})`;
|
|
3538
|
+
return `the build's network helper container stopped${said(await helperReason(runtime, name))}`;
|
|
3539
|
+
}
|
|
3540
|
+
async function removeNetworkHelper(runtime, state) {
|
|
3541
|
+
if (state.network === void 0) return void 0;
|
|
3542
|
+
const removed = await runtime.host.remove(state.network);
|
|
3543
|
+
if (removed.status !== 0 && !/no such container/i.test(removed.stderr)) return `container ${state.network} was not removed: ${removed.stderr.trim()}`;
|
|
3544
|
+
return void 0;
|
|
3545
|
+
}
|
|
3546
|
+
function kernelHasIpv6(exists = existsSync, platform = process.platform) {
|
|
3547
|
+
return platform !== "linux" || exists("/proc/sys/net/ipv6");
|
|
3548
|
+
}
|
|
3549
|
+
function helperArchOf(engineArch) {
|
|
3550
|
+
if (engineArch === "amd64") return "x86_64";
|
|
3551
|
+
if (engineArch === "arm64") return "aarch64";
|
|
3552
|
+
return engineArch;
|
|
3553
|
+
}
|
|
3554
|
+
async function engineNetworkHelper(host, runnerDir2, ensure = ensureNetworkHelper) {
|
|
3555
|
+
const engine = await host.architecture();
|
|
3556
|
+
return ensure({ runnerDir: runnerDir2, ...engine === null ? {} : { arch: helperArchOf(engine) } });
|
|
3557
|
+
}
|
|
3496
3558
|
|
|
3497
3559
|
// src/runner/record-proofs.ts
|
|
3498
3560
|
var RECORD_PROOFS_ARGV = ["outerlayer", "work", "proofs", "--record", "--comment"];
|
|
@@ -4121,6 +4183,12 @@ var SKILL_PACK_DIR = `${SANDBOX_DIR}/skill-pack`;
|
|
|
4121
4183
|
var SECRET_FILE = `${SANDBOX_DIR}/join-secret`;
|
|
4122
4184
|
var CONTAINER_SECRET_FILE = "/run/outerlayer-relay/join-secret";
|
|
4123
4185
|
var JOIN_WS_PORT = 7077;
|
|
4186
|
+
var HELPER_FILE = `${SANDBOX_DIR}/outerlayer-guest`;
|
|
4187
|
+
var JOIN_DIR = `${SANDBOX_DIR}/join`;
|
|
4188
|
+
var CONTAINER_JOIN_DIR = "/run/outerlayer-join";
|
|
4189
|
+
var CONTAINER_JOIN_SOCKET = `${CONTAINER_JOIN_DIR}/join.sock`;
|
|
4190
|
+
var CONTAINER_PROXY_SOCKET = `${CONTAINER_JOIN_DIR}/proxy.sock`;
|
|
4191
|
+
var RELAY_IDS = "60100:60100";
|
|
4124
4192
|
var SANDBOX_RESERVE_MIB = 512;
|
|
4125
4193
|
var RELAY_ATTEMPTS = 40;
|
|
4126
4194
|
var RELAY_WAIT_MS = 500;
|
|
@@ -4211,14 +4279,56 @@ function daemonSetupLine() {
|
|
|
4211
4279
|
function hostMountLine(volume) {
|
|
4212
4280
|
return `sudo mkdir -p ${HOST_BUILD_DIR} && { mountpoint -q ${HOST_BUILD_DIR} || sudo mount --bind "$(sudo docker volume inspect -f '{{.Mountpoint}}' ${quote(volume)})" ${HOST_BUILD_DIR}; }`;
|
|
4213
4281
|
}
|
|
4214
|
-
function removeBuildContainersLine(keep) {
|
|
4215
|
-
const others = keep
|
|
4282
|
+
function removeBuildContainersLine(...keep) {
|
|
4283
|
+
const others = keep.map((name) => ` | grep -v ${quote(` ${name}$`)}`).join("");
|
|
4216
4284
|
return `ids=$(sudo docker ps -a --format '{{.ID}} {{.Names}}' | grep -v ' buildx_buildkit_'${others} | cut -d' ' -f1); [ -z "$ids" ] || sudo docker rm -f $ids`;
|
|
4217
4285
|
}
|
|
4286
|
+
function joinForwarderName(container) {
|
|
4287
|
+
return `${container}-join`;
|
|
4288
|
+
}
|
|
4289
|
+
function networkContainersOf(state) {
|
|
4290
|
+
return state.network === void 0 ? [] : [state.network, joinForwarderName(state.container)];
|
|
4291
|
+
}
|
|
4292
|
+
var FORWARDER_SCRIPT = `const net=require("net");for(const pair of process.argv.slice(1)){const cut=pair.indexOf("=");const at=pair.lastIndexOf(":",cut);const path=pair.slice(cut+1);net.createServer((c)=>{const u=net.connect(path);const end=()=>{c.destroy();u.destroy()};c.on("error",end);u.on("error",end);c.on("close",end);u.on("close",end);c.pipe(u);u.pipe(c)}).listen(Number(pair.slice(at+1,cut)),pair.slice(0,at))}`;
|
|
4293
|
+
function joinForwarderRunArgs(input) {
|
|
4294
|
+
return [
|
|
4295
|
+
"--detach",
|
|
4296
|
+
"--name",
|
|
4297
|
+
input.name,
|
|
4298
|
+
"--label",
|
|
4299
|
+
`${BUILD_LABEL}=${input.buildId}`,
|
|
4300
|
+
"--label",
|
|
4301
|
+
`${RUNNER_LABEL}=${input.runnerId}`,
|
|
4302
|
+
"--network",
|
|
4303
|
+
"host",
|
|
4304
|
+
"--cap-drop",
|
|
4305
|
+
"ALL",
|
|
4306
|
+
"--security-opt",
|
|
4307
|
+
"no-new-privileges",
|
|
4308
|
+
"--read-only",
|
|
4309
|
+
"--user",
|
|
4310
|
+
RELAY_IDS,
|
|
4311
|
+
"--memory",
|
|
4312
|
+
"128m",
|
|
4313
|
+
"--memory-swap",
|
|
4314
|
+
"128m",
|
|
4315
|
+
"--pids-limit",
|
|
4316
|
+
"64",
|
|
4317
|
+
"--mount",
|
|
4318
|
+
`type=bind,src=${JOIN_DIR},dst=${CONTAINER_JOIN_DIR}`,
|
|
4319
|
+
"--entrypoint",
|
|
4320
|
+
"/opt/outerlayer/bin/node",
|
|
4321
|
+
input.image,
|
|
4322
|
+
"-e",
|
|
4323
|
+
FORWARDER_SCRIPT,
|
|
4324
|
+
`0.0.0.0:${JOIN_WS_PORT}=${CONTAINER_JOIN_SOCKET}`,
|
|
4325
|
+
`127.0.0.1:${RELAY_PORT}=${CONTAINER_PROXY_SOCKET}`
|
|
4326
|
+
];
|
|
4327
|
+
}
|
|
4218
4328
|
function sandboxRunArgs(args, opts = {}) {
|
|
4219
4329
|
const out = [...args];
|
|
4220
4330
|
const network = out.indexOf("--network");
|
|
4221
|
-
if (network !== -1) out[network + 1] = "host";
|
|
4331
|
+
if (network !== -1 && opts.joined !== true) out[network + 1] = "host";
|
|
4222
4332
|
const entrypoint = out.indexOf("--entrypoint");
|
|
4223
4333
|
out.splice(
|
|
4224
4334
|
entrypoint,
|
|
@@ -4228,12 +4338,42 @@ function sandboxRunArgs(args, opts = {}) {
|
|
|
4228
4338
|
...opts.skillPack === true ? ["--mount", `type=bind,src=${SKILL_PACK_DIR},dst=/opt/outerlayer/cli/skill-pack,readonly`] : [],
|
|
4229
4339
|
"--mount",
|
|
4230
4340
|
`type=bind,src=${SECRET_FILE},dst=${CONTAINER_SECRET_FILE},readonly`,
|
|
4341
|
+
...opts.joined === true ? ["--mount", `type=bind,src=${JOIN_DIR},dst=${CONTAINER_JOIN_DIR}`] : [],
|
|
4231
4342
|
...opts.dockerGroup === void 0 ? [] : ["--mount", `type=bind,src=${DOCKER_SOCKET},dst=${DOCKER_SOCKET}`, "--group-add", opts.dockerGroup],
|
|
4232
4343
|
...Object.entries(toolProxyEnvironment()).flatMap(([name, value]) => ["--env", `${name}=${value}`])
|
|
4233
4344
|
);
|
|
4234
|
-
out.push("--join-ws", String(JOIN_WS_PORT), "--join-secret-file", CONTAINER_SECRET_FILE);
|
|
4345
|
+
out.push("--join-ws", opts.joined === true ? CONTAINER_JOIN_SOCKET : String(JOIN_WS_PORT), "--join-secret-file", CONTAINER_SECRET_FILE);
|
|
4346
|
+
if (opts.joined === true) out.push("--listen-socket", CONTAINER_PROXY_SOCKET);
|
|
4235
4347
|
return out;
|
|
4236
4348
|
}
|
|
4349
|
+
function noHelperLine(why) {
|
|
4350
|
+
return `${why}, so the build's container is on the sandbox's own network: a program that ignores proxy settings has no network`;
|
|
4351
|
+
}
|
|
4352
|
+
async function startSandboxNetwork(input) {
|
|
4353
|
+
const { sandboxed, sandboxClient, sandbox, build } = input;
|
|
4354
|
+
const tun = await commandIn(sandboxClient, sandbox, "test -c /dev/net/tun");
|
|
4355
|
+
if (tun.exitCode !== 0) return { none: "this sandbox's kernel gives no TUN device" };
|
|
4356
|
+
let helper;
|
|
4357
|
+
try {
|
|
4358
|
+
helper = await engineNetworkHelper(sandboxed.host, input.runnerDir, (options) => input.runtime.sandbox.networkHelper(options));
|
|
4359
|
+
} catch (err) {
|
|
4360
|
+
return { none: err instanceof AssetError ? err.message : `the network helper could not be had: ${describeCallFailure(err)}` };
|
|
4361
|
+
}
|
|
4362
|
+
try {
|
|
4363
|
+
await sandboxClient.upload(sandbox, HELPER_FILE, readFileSync(helper.path));
|
|
4364
|
+
} catch (err) {
|
|
4365
|
+
return { failed: `putting the network helper in the sandbox failed: ${err instanceof SandboxError ? describeSandboxError(err) : describeCallFailure(err)}` };
|
|
4366
|
+
}
|
|
4367
|
+
const placed = await commandIn(sandboxClient, sandbox, `chmod 755 ${HELPER_FILE} && mkdir -p ${JOIN_DIR} && sudo chown ${RELAY_IDS} ${JOIN_DIR} && sudo chmod 700 ${JOIN_DIR}`);
|
|
4368
|
+
if (placed.exitCode !== 0) return { failed: `preparing the network helper in the sandbox failed (exit ${placed.exitCode ?? "none"})${said(placed.stderr)}` };
|
|
4369
|
+
const ipv6 = (await commandIn(sandboxClient, sandbox, "test -e /proc/sys/net/ipv6")).exitCode === 0;
|
|
4370
|
+
const name = networkHelperName(build.container);
|
|
4371
|
+
const notReady = await startNetworkHelper(sandboxed, { name, buildId: build.buildId, runnerId: build.runnerId, image: build.image, limits: build.limits, ipv6, helperFile: HELPER_FILE }, input.logPath);
|
|
4372
|
+
if (notReady !== void 0) return { failed: notReady };
|
|
4373
|
+
const forwarder = await sandboxed.host.run(joinForwarderRunArgs({ name: joinForwarderName(build.container), buildId: build.buildId, runnerId: build.runnerId, image: build.image }), { logPath: input.logPath });
|
|
4374
|
+
if (forwarder.status !== 0) return { failed: `starting the build's join forwarder failed (exit ${forwarder.status})${said(forwarder.stderr)}` };
|
|
4375
|
+
return { helper: name };
|
|
4376
|
+
}
|
|
4237
4377
|
var RELAY_PROBE = `const s=require("net").connect(3128,"127.0.0.1");s.on("connect",()=>process.exit(0));s.on("error",()=>process.exit(1));setTimeout(()=>process.exit(1),2000)`;
|
|
4238
4378
|
async function waitForRelay(runtime, container) {
|
|
4239
4379
|
for (let attempt = 0; attempt < RELAY_ATTEMPTS; attempt++) {
|
|
@@ -4601,7 +4741,12 @@ async function provisionSandboxOnce(input, itemDiskFailed) {
|
|
|
4601
4741
|
const agentUser = resolved.user;
|
|
4602
4742
|
input.save(state, environment);
|
|
4603
4743
|
if (input.aborted()) return bail("", true);
|
|
4604
|
-
const
|
|
4744
|
+
const network = await startSandboxNetwork({ runtime, sandboxed, sandboxClient, sandbox, runnerDir: runnerDir(config.configPath), build: { buildId, runnerId, container, image, limits: limits2 }, logPath });
|
|
4745
|
+
if ("failed" in network) return bail(network.failed);
|
|
4746
|
+
if ("none" in network) log.line(`${tag} ${noHelperLine(network.none)}`);
|
|
4747
|
+
else containerState.network = network.helper;
|
|
4748
|
+
const runArgs = containerRunArgs({ ...runInput, home: containerState.home, network: containerState.network }, runtime.agents);
|
|
4749
|
+
const started = await host.run(sandboxRunArgs(runArgs, { skillPack: skillPack !== void 0, dockerGroup, joined: containerState.network !== void 0 }), { logPath });
|
|
4605
4750
|
if (started.status !== 0) return dockerFailed("starting the build's container", started);
|
|
4606
4751
|
joinRelay(runtime, sandbox, { buildId, container }, services.streams, joinSecret, (line2) => log.line(`${tag} ${line2}`));
|
|
4607
4752
|
if (input.aborted()) return bail("", true);
|
|
@@ -4726,6 +4871,12 @@ async function rejoinOf(runtime, own) {
|
|
|
4726
4871
|
async function startSandboxContainerAgain(runtime, own, rejoin, jobDir, log) {
|
|
4727
4872
|
const state = own.container;
|
|
4728
4873
|
const { sandbox, sandboxed } = rejoin;
|
|
4874
|
+
const notReady = await ensureNetworkReady(sandboxed, state);
|
|
4875
|
+
if (notReady !== void 0) throw new Error(notReady);
|
|
4876
|
+
if (state.network !== void 0) {
|
|
4877
|
+
const forwarding = await sandboxed.host.start(joinForwarderName(state.container));
|
|
4878
|
+
if (forwarding.status !== 0) throw new Error(`the build's join forwarder could not be started again (exit ${forwarding.status})`);
|
|
4879
|
+
}
|
|
4729
4880
|
const started = await sandboxed.host.start(state.container);
|
|
4730
4881
|
if (started.status !== 0) throw new Error(`the build's container could not be started again (exit ${started.status})`);
|
|
4731
4882
|
if (!await waitForRelay(sandboxed, state.container)) throw new Error("the relay in the build's container did not start again");
|
|
@@ -4744,7 +4895,7 @@ function sandboxJudgeEnvironment(input) {
|
|
|
4744
4895
|
const rejoin = await rejoinOf(runtime, own);
|
|
4745
4896
|
const { sandbox, sandboxed } = rejoin;
|
|
4746
4897
|
await leaveRelay(runtime, state.buildId);
|
|
4747
|
-
const removed = await client(runtime).command(sandbox, removeBuildContainersLine(state.container));
|
|
4898
|
+
const removed = await client(runtime).command(sandbox, removeBuildContainersLine(state.container, ...networkContainersOf(state)));
|
|
4748
4899
|
if (removed.exitCode !== 0) throw new Error(`the containers the build started could not be removed (exit ${removed.exitCode ?? "none"})`);
|
|
4749
4900
|
await sandboxed.host.stop(state.container);
|
|
4750
4901
|
state.stopped = true;
|
|
@@ -12161,67 +12312,6 @@ function createCpuAllocator(cores) {
|
|
|
12161
12312
|
}
|
|
12162
12313
|
};
|
|
12163
12314
|
}
|
|
12164
|
-
var NETWORK_READY_ATTEMPTS = 60;
|
|
12165
|
-
var NETWORK_READY_PAUSE_MS = 500;
|
|
12166
|
-
var LOG_LINES = 20;
|
|
12167
|
-
async function helperReason(runtime, name) {
|
|
12168
|
-
const logs = await runtime.host.logs(name, LOG_LINES);
|
|
12169
|
-
const lines = `${logs.stdout}
|
|
12170
|
-
${logs.stderr}`.split("\n").map((line2) => line2.trim());
|
|
12171
|
-
return lines.filter((line2) => line2.startsWith("net: ")).at(-1) ?? lines.filter((line2) => line2 !== "").at(-1) ?? "";
|
|
12172
|
-
}
|
|
12173
|
-
async function waitForNetwork(runtime, name) {
|
|
12174
|
-
for (let attempt = 0; attempt < NETWORK_READY_ATTEMPTS; attempt++) {
|
|
12175
|
-
const probe = await runtime.host.exec({ container: name, user: "0:0", env: { literals: {}, passed: {} }, argv: ["cat", NETWORK_READY_FILE] });
|
|
12176
|
-
if (probe.status === 0) return void 0;
|
|
12177
|
-
const state = await runtime.host.state(name);
|
|
12178
|
-
if (state === "stopped" || state === "missing") {
|
|
12179
|
-
return `the build's network helper container stopped before its network was ready${said(await helperReason(runtime, name))}`;
|
|
12180
|
-
}
|
|
12181
|
-
await runtime.sleep(NETWORK_READY_PAUSE_MS);
|
|
12182
|
-
}
|
|
12183
|
-
return `the build's network helper container was not ready within ${NETWORK_READY_ATTEMPTS * NETWORK_READY_PAUSE_MS / 1e3} seconds${said(await helperReason(runtime, name))}`;
|
|
12184
|
-
}
|
|
12185
|
-
async function startNetworkHelper(runtime, input, logPath) {
|
|
12186
|
-
const started = await runtime.host.run(networkHelperRunArgs(input), { logPath });
|
|
12187
|
-
if (started.status !== 0) {
|
|
12188
|
-
return `starting the build's network helper container failed (exit ${started.status})${said(started.stderr)}`;
|
|
12189
|
-
}
|
|
12190
|
-
return waitForNetwork(runtime, input.name);
|
|
12191
|
-
}
|
|
12192
|
-
async function ensureNetworkReady(runtime, state) {
|
|
12193
|
-
if (state.network === void 0) return void 0;
|
|
12194
|
-
const current = await runtime.host.state(state.network);
|
|
12195
|
-
if (current === "running") return void 0;
|
|
12196
|
-
if (current === "missing") return `the build's network helper container ${state.network} is gone`;
|
|
12197
|
-
const started = await runtime.host.start(state.network);
|
|
12198
|
-
if (started.status !== 0) {
|
|
12199
|
-
return `starting the build's network helper container again failed (exit ${started.status})${said(started.stderr)}`;
|
|
12200
|
-
}
|
|
12201
|
-
return waitForNetwork(runtime, state.network);
|
|
12202
|
-
}
|
|
12203
|
-
async function stoppedHelperReason(runtime, name) {
|
|
12204
|
-
if (await runtime.host.oomKilled(name)) return `the build's network helper container ran out of memory (${NETWORK_HELPER_MEMORY})`;
|
|
12205
|
-
return `the build's network helper container stopped${said(await helperReason(runtime, name))}`;
|
|
12206
|
-
}
|
|
12207
|
-
async function removeNetworkHelper(runtime, state) {
|
|
12208
|
-
if (state.network === void 0) return void 0;
|
|
12209
|
-
const removed = await runtime.host.remove(state.network);
|
|
12210
|
-
if (removed.status !== 0 && !/no such container/i.test(removed.stderr)) return `container ${state.network} was not removed: ${removed.stderr.trim()}`;
|
|
12211
|
-
return void 0;
|
|
12212
|
-
}
|
|
12213
|
-
function kernelHasIpv6(exists = existsSync, platform = process.platform) {
|
|
12214
|
-
return platform !== "linux" || exists("/proc/sys/net/ipv6");
|
|
12215
|
-
}
|
|
12216
|
-
function helperArchOf(engineArch) {
|
|
12217
|
-
if (engineArch === "amd64") return "x86_64";
|
|
12218
|
-
if (engineArch === "arm64") return "aarch64";
|
|
12219
|
-
return engineArch;
|
|
12220
|
-
}
|
|
12221
|
-
async function engineNetworkHelper(host, runnerDir2, ensure = ensureNetworkHelper) {
|
|
12222
|
-
const engine = await host.architecture();
|
|
12223
|
-
return ensure({ runnerDir: runnerDir2, ...engine === null ? {} : { arch: helperArchOf(engine) } });
|
|
12224
|
-
}
|
|
12225
12315
|
|
|
12226
12316
|
// src/runner/container/hooks.ts
|
|
12227
12317
|
var MIN_ENGINE_MAJOR = 26;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import { keyRunnerFactory, RunnerConfigError } from './chunk-
|
|
3
|
+
import { keyRunnerFactory, RunnerConfigError } from './chunk-AE5RNDFC.js';
|
|
4
4
|
import { orgHomeDir } from './chunk-JIANCWJ3.js';
|
|
5
5
|
|
|
6
6
|
createRequire(import.meta.url);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import { parseSize, BUILD_LABEL, RUNNER_LABEL, runnerLabelValue } from './chunk-
|
|
3
|
+
import { parseSize, BUILD_LABEL, RUNNER_LABEL, runnerLabelValue } from './chunk-QZSYYHWU.js';
|
|
4
4
|
import { buildsDir, storeScopes, rootfsDir, orgStoreIn, runnerDir, imagesDir, builderCacheDiskPath } from './chunk-JIANCWJ3.js';
|
|
5
5
|
import { spawnSync } from 'child_process';
|
|
6
6
|
import { statfsSync, statSync, existsSync, readdirSync } from 'fs';
|