@outerlayer/cli 0.36.0-next.20261031112440 → 0.36.0-next.20261031231928
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/{build-KM6UILOZ.js → build-XZGB4JPQ.js} +5 -5
- package/dist/{build-disk-GCEB5EJC.js → build-disk-YLQT3UHL.js} +4 -4
- package/dist/build-info.json +1 -1
- package/dist/{builder-NRPJGNXU.js → builder-TS3QFXN4.js} +3 -3
- package/dist/{caller-XHNAY4E2.js → caller-VHISEQAD.js} +6 -6
- package/dist/{check-MENIW2MN.js → check-LUQM6DGK.js} +19 -19
- package/dist/{chunk-FRDYAKH3.js → chunk-453B2ZHX.js} +2 -2
- package/dist/{chunk-4PH4DVV4.js → chunk-46OBCATR.js} +4 -0
- package/dist/{chunk-MMDGO77D.js → chunk-4NMAJYYE.js} +1 -1
- package/dist/{chunk-PJZKKFQO.js → chunk-6O33JZ3X.js} +2 -2
- package/dist/{chunk-LZ7PAU55.js → chunk-7EPIOSLO.js} +1 -1
- package/dist/{chunk-6T2JWCSZ.js → chunk-AHEIZCCA.js} +5 -5
- package/dist/{chunk-TV5ITSVY.js → chunk-CIUD3436.js} +1 -1
- package/dist/{chunk-VJYNMGCE.js → chunk-CVQ4YBBE.js} +2 -2
- package/dist/{chunk-K2YG2HZN.js → chunk-GQVOK4ZO.js} +13 -13
- package/dist/{chunk-3QLHEGXK.js → chunk-H3S5LJI2.js} +3 -3
- package/dist/{chunk-4AMSCAHT.js → chunk-HDTFRHY6.js} +6 -6
- package/dist/{chunk-AVJWMOEY.js → chunk-IGHAPIKZ.js} +1 -1
- package/dist/{chunk-MVSC7GCE.js → chunk-IP7F4CQH.js} +2 -2
- package/dist/{chunk-OPF6OJAT.js → chunk-IVH7WDOO.js} +4 -4
- package/dist/{chunk-H3MLZ4EA.js → chunk-KB5B6ZT5.js} +1 -1
- package/dist/{chunk-3YRJUX6J.js → chunk-LXYWSGEW.js} +1 -1
- package/dist/{chunk-25GQP6NR.js → chunk-NIZ7FXUX.js} +288 -112
- package/dist/{chunk-34YFGWHR.js → chunk-NRTRPGCW.js} +1 -1
- package/dist/{chunk-7SO2VHTQ.js → chunk-OUPQTA7N.js} +2 -2
- package/dist/{chunk-LESWXCKZ.js → chunk-RUK7QHSH.js} +4 -4
- package/dist/{chunk-5AJZGYWC.js → chunk-SK7ZXQIV.js} +1 -1
- package/dist/{chunk-S6OD32NC.js → chunk-T3SRWWPX.js} +1 -0
- package/dist/{chunk-VG2NIWR4.js → chunk-XZ7NIGVA.js} +1 -1
- package/dist/{chunk-BFF6AJXM.js → chunk-ZJ4Y2BOI.js} +4 -4
- package/dist/{cli-TAFO3WOQ.js → cli-I7ZLMEL6.js} +69 -69
- package/dist/{command-TRSFSBT5.js → command-TDJDBIXU.js} +15 -15
- package/dist/{config-YCQV3OQK.js → config-FF3E73ZE.js} +5 -5
- package/dist/{container-start-UY2YVY3L.js → container-start-DNGL4XJ3.js} +16 -16
- package/dist/{demo-record-cmd-NUGDPXWS.js → demo-record-cmd-Y57UWBCX.js} +3 -3
- package/dist/{demo-voice-cmd-QAH7KPVO.js → demo-voice-cmd-QFVATHAQ.js} +2 -2
- package/dist/{docker-2247NBIK.js → docker-6QIZVYF3.js} +3 -3
- package/dist/{doctor-VVFPHFS4.js → doctor-LXVJQKME.js} +16 -16
- package/dist/{emit-demo-cmd-V7CP333I.js → emit-demo-cmd-ZYMLB5R5.js} +2 -2
- package/dist/{exec-client-UHL7WPDO.js → exec-client-FGGPQSYQ.js} +1 -1
- package/dist/{find-unit-FEYD4IHC.js → find-unit-EX5ETHGL.js} +7 -7
- package/dist/{governing-source-6ANJ4HQI.js → governing-source-3LUGSBRW.js} +2 -2
- package/dist/{host-checks-TX22YEFD.js → host-checks-7NCEW7FR.js} +14 -14
- package/dist/index.js +1 -1
- package/dist/{init-36AY3ZQZ.js → init-AQJEIH57.js} +14 -14
- package/dist/{init-IYL3YXEM.js → init-U4AM3APJ.js} +14 -14
- package/dist/{init-cmd-JK2OGQU5.js → init-cmd-SP4YMVKT.js} +2 -2
- package/dist/{loop-U72FDFQR.js → loop-NKJRLAGI.js} +18 -18
- package/dist/{machine-S2TYJJPP.js → machine-VV4LYWZQ.js} +14 -14
- package/dist/{runner-env-OPRWKIKI.js → runner-env-LWKAYARL.js} +7 -7
- package/dist/{runner-identity-OY75LG6G.js → runner-identity-WUAQLGRY.js} +3 -3
- package/dist/{runner-key-6WN67PRU.js → runner-key-4JXOPPUJ.js} +14 -14
- package/dist/{spec-cmd-253AGRFF.js → spec-cmd-6LT5JJKG.js} +1 -1
- package/dist/{status-WCQG6SX4.js → status-OADVUMST.js} +14 -14
- package/dist/{update-steps-BOKCWGQ6.js → update-steps-GRF3BQ5M.js} +15 -15
- package/dist/{work-claim-cmd-2A6D5EYO.js → work-claim-cmd-2OO73LEV.js} +7 -7
- package/dist/{work-cmd-JZUBXXJN.js → work-cmd-YOWM4KZU.js} +1 -1
- package/dist/{work-comment-cmd-L4R6ZXLO.js → work-comment-cmd-7AKCM2JN.js} +2 -2
- package/dist/{work-demo-cmd-YNPN2PHQ.js → work-demo-cmd-DHJDR7BB.js} +1 -1
- package/dist/{work-logs-cmd-CSQJB5MD.js → work-logs-cmd-62PZKGUU.js} +1 -1
- package/dist/{work-open-pr-cmd-Y7YNI2PF.js → work-open-pr-cmd-DMDHGKEJ.js} +1 -1
- package/dist/{work-proofs-cmd-RPVVD2SC.js → work-proofs-cmd-UQPQF7CK.js} +2 -2
- package/dist/{work-proofs-record-ULCY5QEP.js → work-proofs-record-SRL7DRXV.js} +5 -5
- package/dist/{work-stop-cmd-LF4OTNPL.js → work-stop-cmd-NYPQKSHC.js} +1 -1
- package/package.json +1 -1
|
@@ -8,24 +8,24 @@ import { senderPidfile } from './chunk-5UBNSGK3.js';
|
|
|
8
8
|
import { installScrubContext } from './chunk-XTVVKNRP.js';
|
|
9
9
|
import { readsJobState, READ_JOB_STATE_FORMATS, jobStateFormatOf } from './chunk-ZVB57WI6.js';
|
|
10
10
|
import { runnerImageVersion } from './chunk-ALEUIS35.js';
|
|
11
|
-
import { hasStoredCredential, AGENT_COMMANDS, storeClaudeCredential, credentialFromStdin, isAgentName } from './chunk-
|
|
11
|
+
import { hasStoredCredential, AGENT_COMMANDS, storeClaudeCredential, credentialFromStdin, isAgentName } from './chunk-NRTRPGCW.js';
|
|
12
12
|
import { receiveFiles } from './chunk-NN33FYXG.js';
|
|
13
|
-
import { readDefaultBranchFiles, readDefaultBranchHead, cloneRepository, buildRepositoryImage, fetchCommit, readBranchHead, diffBetween, prepareImageBuild, KEY_PREFIX, TAG_HOST, SHARED_OWNER, SHARED_NAME, universalBase, metadataFromLabels, writeRecord } from './chunk-
|
|
14
|
-
import { FETCHED_DIR, toolsDockerfile, FETCHED_FFMPEG, FETCHED_GH, FETCHED_TINI, FETCHED_HEADLESS_SHELL, FETCHED_PLAYWRIGHT_FFMPEG, FETCHED_VOICE_DIR } from './chunk-
|
|
13
|
+
import { readDefaultBranchFiles, readDefaultBranchHead, cloneRepository, buildRepositoryImage, fetchCommit, readBranchHead, diffBetween, prepareImageBuild, KEY_PREFIX, TAG_HOST, SHARED_OWNER, SHARED_NAME, universalBase, metadataFromLabels, writeRecord } from './chunk-RUK7QHSH.js';
|
|
14
|
+
import { FETCHED_DIR, toolsDockerfile, FETCHED_FFMPEG, FETCHED_GH, FETCHED_TINI, FETCHED_HEADLESS_SHELL, FETCHED_PLAYWRIGHT_FFMPEG, FETCHED_VOICE_DIR } from './chunk-KB5B6ZT5.js';
|
|
15
15
|
import { currentCliBuild } from './chunk-OGFGZQA3.js';
|
|
16
|
-
import { vmExecArgs, runExec, execCapture, waitForAgent } from './chunk-
|
|
17
|
-
import { describeCallFailure, shortClaim, retrySend, commandWithShim, logStamp, createRunnerLog, formatDuration, removeKeptContext, formatClock, stageGovernedContext, keptContextTree, removeStagedContext, WORKFLOW_PERMISSION_REASON, refusalCode, resolveGoverningSource, prefetchGovernedContext, controlPlaneTokenFailure, keepStagedContext, pinnedSourceOf, shimScript } from './chunk-
|
|
16
|
+
import { vmExecArgs, runExec, execCapture, waitForAgent } from './chunk-46OBCATR.js';
|
|
17
|
+
import { describeCallFailure, shortClaim, retrySend, commandWithShim, logStamp, createRunnerLog, formatDuration, removeKeptContext, formatClock, stageGovernedContext, keptContextTree, removeStagedContext, WORKFLOW_PERMISSION_REASON, refusalCode, resolveGoverningSource, prefetchGovernedContext, controlPlaneTokenFailure, keepStagedContext, pinnedSourceOf, shimScript } from './chunk-7EPIOSLO.js';
|
|
18
18
|
import { HELPER_PATH, HELPER_RECORD, DOCKERD_LOG } from './chunk-55PYF6S2.js';
|
|
19
19
|
import { isSameProcess, startTimeOf } from './chunk-JBJTC3UU.js';
|
|
20
20
|
import { socketPathProblem, vsockLinks, linkVsockSockets, GUEST_CID, LEASE_LINK } from './chunk-UZGQT6OF.js';
|
|
21
21
|
import { writeDockerClientConfig } from './chunk-MKSZHT6S.js';
|
|
22
|
-
import { claimCalls, spoolHomeFor, itemCalls, claimItem, leftByRunnerKey } from './chunk-
|
|
23
|
-
import { runnerCredentialProblem, builtinKind, keyRunnerFactory, optionalEgress, isBuiltinContainer, isBuiltinProcess, isBuiltinVm, egressSummary, DEFAULT_CHECK_TIME_LIMIT_MINUTES, DEFAULT_SETUP_MINUTES, allowHostProblem, systemClock, emptyEgressCounts, hostAllowed, imageBuildOf, DEFAULT_SAVED_STATE_MAX_BYTES } from './chunk-
|
|
24
|
-
import { formatBytes, volumeBytes, allocatedBytes, DEFAULT_CACHE_DISK, DEFAULT_BUILD_DISK } from './chunk-
|
|
25
|
-
import { writeJobFile, readJobFile, spawnRun, RUNNER_LABEL, BUILD_LABEL, NETWORK_HELPER_MEMORY, createDockerHost, builderSpec, containerExecArgs, childEnvironment, readDu, withAnswerProtocol, judgeCommand, MAX_REPORT_BYTES, readJobFileChecked, NETWORK_READY_FILE, networkHelperName, runnerLabelValue, prepareRunArgs, containerRunArgs, JUDGE_MAX_TURNS, parseSize, homeCopyRunArgs, networkHelperRunArgs, JUDGE_DIR, HASH_ARGV, parseProgramHash, identityScript, identityArgs, parseIdentity, mountableHome, homeCopyScript, homeCopyArgs, COMMAND_DIR, JUDGE_PROGRAM, MAX_ITEMS_BYTES, JUDGE_ITEMS, JUDGE_REPORT, identityRunArgs, SAVED_STATE_LABEL } from './chunk-
|
|
26
|
-
import { universalImagePending, RecipeError, writeSanitizedRecipe, classifyProperties, DOCKER_FEATURE } from './chunk-
|
|
27
|
-
import { firecrackerArch, MICROVM_ARCHES, FIRECRACKER_VERSION, hostHelperPinned, builderDiskPinned, guestAssetsPinned, GUEST_HELPER_SHA256, GUEST_ASSETS_BASE_URL, GUEST_KERNEL_SHA256, JAILER_BINARY_SHA256, FIRECRACKER_BINARY_SHA256, FIRECRACKER_SHA256, GUEST_ASSETS_VERSION, BUILDER_DISK_VERSION, networkHelperPinned, NETWORK_HELPER_SHA256, universalImagePinned, UNIVERSAL_IMAGE, FFMPEG_STATIC, FFMPEG_BUILD_TAG, GH_SHA256, GH_VERSION, TINI_SHA256, TINI_VERSION, HEADLESS_SHELL, HEADLESS_SHELL_BASE_URL, PLAYWRIGHT_FFMPEG, PLAYWRIGHT_FFMPEG_BASE_URL, VOICE_PACK_FILES, BUILDER_DISK_SHA256, BUILDER_DISK_BASE_URL, DEFAULT_BASE_IMAGE, CLAUDE_CODE_VERSION } from './chunk-
|
|
28
|
-
import { postJson, WorkCommandError, getJson, isSignatureRefusal } from './chunk-
|
|
22
|
+
import { claimCalls, spoolHomeFor, itemCalls, claimItem, leftByRunnerKey } from './chunk-LXYWSGEW.js';
|
|
23
|
+
import { runnerCredentialProblem, builtinKind, keyRunnerFactory, optionalEgress, isBuiltinContainer, isBuiltinProcess, isBuiltinVm, egressSummary, DEFAULT_CHECK_TIME_LIMIT_MINUTES, DEFAULT_SETUP_MINUTES, allowHostProblem, systemClock, emptyEgressCounts, hostAllowed, imageBuildOf, DEFAULT_SAVED_STATE_MAX_BYTES } from './chunk-H3S5LJI2.js';
|
|
24
|
+
import { formatBytes, volumeBytes, allocatedBytes, DEFAULT_CACHE_DISK, DEFAULT_BUILD_DISK, freeBytes } from './chunk-IGHAPIKZ.js';
|
|
25
|
+
import { writeJobFile, readJobFile, spawnRun, RUNNER_LABEL, BUILD_LABEL, NETWORK_HELPER_MEMORY, createDockerHost, builderSpec, containerExecArgs, childEnvironment, readDu, withAnswerProtocol, judgeCommand, MAX_REPORT_BYTES, readJobFileChecked, NETWORK_READY_FILE, networkHelperName, runnerLabelValue, prepareRunArgs, containerRunArgs, JUDGE_MAX_TURNS, parseSize, homeCopyRunArgs, networkHelperRunArgs, JUDGE_DIR, HASH_ARGV, parseProgramHash, identityScript, identityArgs, parseIdentity, mountableHome, homeCopyScript, homeCopyArgs, COMMAND_DIR, JUDGE_PROGRAM, MAX_ITEMS_BYTES, JUDGE_ITEMS, JUDGE_REPORT, identityRunArgs, SAVED_STATE_LABEL } from './chunk-6O33JZ3X.js';
|
|
26
|
+
import { universalImagePending, RecipeError, writeSanitizedRecipe, classifyProperties, DOCKER_FEATURE } from './chunk-CIUD3436.js';
|
|
27
|
+
import { firecrackerArch, MICROVM_ARCHES, FIRECRACKER_VERSION, hostHelperPinned, builderDiskPinned, guestAssetsPinned, GUEST_HELPER_SHA256, GUEST_ASSETS_BASE_URL, GUEST_KERNEL_SHA256, JAILER_BINARY_SHA256, FIRECRACKER_BINARY_SHA256, FIRECRACKER_SHA256, GUEST_ASSETS_VERSION, BUILDER_DISK_VERSION, networkHelperPinned, NETWORK_HELPER_SHA256, universalImagePinned, UNIVERSAL_IMAGE, FFMPEG_STATIC, FFMPEG_BUILD_TAG, GH_SHA256, GH_VERSION, TINI_SHA256, TINI_VERSION, HEADLESS_SHELL, HEADLESS_SHELL_BASE_URL, PLAYWRIGHT_FFMPEG, PLAYWRIGHT_FFMPEG_BASE_URL, VOICE_PACK_FILES, BUILDER_DISK_SHA256, BUILDER_DISK_BASE_URL, DEFAULT_BASE_IMAGE, CLAUDE_CODE_VERSION } from './chunk-OUPQTA7N.js';
|
|
28
|
+
import { postJson, WorkCommandError, getJson, isSignatureRefusal } from './chunk-T3SRWWPX.js';
|
|
29
29
|
import { sanitizeTerminal, planArtifactUpload } from './chunk-3PQTOKML.js';
|
|
30
30
|
import { readCloudConfig } from './chunk-HWVMRETT.js';
|
|
31
31
|
import { signerFor } from './chunk-4DJZSNVT.js';
|
|
@@ -673,6 +673,40 @@ function createContainerHost(deps = {}) {
|
|
|
673
673
|
}
|
|
674
674
|
};
|
|
675
675
|
}
|
|
676
|
+
var CANNOT_CLONE = /* @__PURE__ */ new Set(["ENOTSUP", "EOPNOTSUPP", "EXDEV", "EINVAL", "ENOSYS"]);
|
|
677
|
+
var MAX_STDERR_BYTES = 2e3;
|
|
678
|
+
var reflink = (from, to) => copyFileSync(from, to, constants.COPYFILE_EXCL | constants.COPYFILE_FICLONE_FORCE);
|
|
679
|
+
function sparseCopy(from, to, start) {
|
|
680
|
+
return new Promise((resolve2, reject) => {
|
|
681
|
+
const child = start("cp", ["--sparse=always", "--", from, to], { stdio: ["ignore", "ignore", "pipe"] });
|
|
682
|
+
let stderr = "";
|
|
683
|
+
child.stderr.on("data", (chunk) => void (stderr = (stderr + chunk.toString()).slice(0, MAX_STDERR_BYTES)));
|
|
684
|
+
child.on("error", (err) => reject(new Error(`cp could not start: ${err.message}`)));
|
|
685
|
+
child.on("close", (status) => {
|
|
686
|
+
if (status === 0) return resolve2();
|
|
687
|
+
const line2 = stderr.split("\n").find((text2) => text2.trim() !== "")?.trim() ?? "";
|
|
688
|
+
reject(new Error(`copying the disk failed (cp exit ${status}${line2 === "" ? "" : `: ${line2}`})`));
|
|
689
|
+
});
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
async function copyDiskFile(from, to, deps = {}) {
|
|
693
|
+
const partial = `${to}.partial`;
|
|
694
|
+
rmSync(partial, { force: true });
|
|
695
|
+
try {
|
|
696
|
+
try {
|
|
697
|
+
(deps.clone ?? reflink)(from, partial);
|
|
698
|
+
} catch (err) {
|
|
699
|
+
if (!CANNOT_CLONE.has(err.code ?? "")) throw err;
|
|
700
|
+
rmSync(partial, { force: true });
|
|
701
|
+
await sparseCopy(from, partial, deps.spawn ?? spawn);
|
|
702
|
+
}
|
|
703
|
+
renameSync(partial, to);
|
|
704
|
+
} catch (err) {
|
|
705
|
+
rmSync(partial, { force: true });
|
|
706
|
+
throw err;
|
|
707
|
+
}
|
|
708
|
+
chmodSync(to, RUNNER_FILE_MODE);
|
|
709
|
+
}
|
|
676
710
|
|
|
677
711
|
// src/runner/microvm/disks.ts
|
|
678
712
|
function fillRootDisk() {
|
|
@@ -838,16 +872,20 @@ async function ensureRootfs(input) {
|
|
|
838
872
|
return path;
|
|
839
873
|
}
|
|
840
874
|
async function createBuildDisk(input) {
|
|
841
|
-
const template = join(diskTemplatesDir(input.runnerDir), `${input.bytes}.ext4`);
|
|
842
|
-
if (!existsSync(template)) {
|
|
843
|
-
const { uid, gid } = ids();
|
|
844
|
-
await madeAtomically(template, (temp) => input.host.makeTemplate({ bytes: input.bytes, dest: temp, uid: Number(uid), gid: Number(gid), memoryBytes: input.memoryBytes }));
|
|
845
|
-
}
|
|
846
875
|
mkdirSync(dirname(input.dest), { recursive: true });
|
|
847
|
-
if (input.
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
876
|
+
if (input.source !== void 0) {
|
|
877
|
+
await (input.host.copyDisk ?? copyDiskFile)(input.source, input.dest);
|
|
878
|
+
} else {
|
|
879
|
+
const template = join(diskTemplatesDir(input.runnerDir), `${input.bytes}.ext4`);
|
|
880
|
+
if (!existsSync(template)) {
|
|
881
|
+
const { uid, gid } = ids();
|
|
882
|
+
await madeAtomically(template, (temp) => input.host.makeTemplate({ bytes: input.bytes, dest: temp, uid: Number(uid), gid: Number(gid), memoryBytes: input.memoryBytes }));
|
|
883
|
+
}
|
|
884
|
+
if (input.host.copyTemplate) input.host.copyTemplate(template, input.dest);
|
|
885
|
+
else {
|
|
886
|
+
const copied = spawnSync("cp", ["--sparse=always", template, input.dest], { encoding: "utf8" });
|
|
887
|
+
if (copied.status !== 0) throw new Error(`copying the empty build disk failed: ${firstLine(copied.stderr)}`);
|
|
888
|
+
}
|
|
851
889
|
}
|
|
852
890
|
chmodSync(input.dest, RUNNER_FILE_MODE);
|
|
853
891
|
truncateSync(input.dest, input.bytes);
|
|
@@ -1172,6 +1210,7 @@ function helperSocketPath(unitName) {
|
|
|
1172
1210
|
}
|
|
1173
1211
|
var START_TIMEOUT_MS = 12e4;
|
|
1174
1212
|
var DISCARD_TIMEOUT_MS = 11 * 6e4;
|
|
1213
|
+
var COPY_TIMEOUT_MS = 11 * 6e4;
|
|
1175
1214
|
var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
|
|
1176
1215
|
var MAX_REPLY_BYTES = 1024 * 1024;
|
|
1177
1216
|
function ask(socketPath, request, timeoutMs) {
|
|
@@ -1232,6 +1271,10 @@ function helperClient(socketPath, options = {}) {
|
|
|
1232
1271
|
async discard(build) {
|
|
1233
1272
|
const reply = await ask(socketPath, { v: 1, op: "discard", build }, DISCARD_TIMEOUT_MS);
|
|
1234
1273
|
return { freedBytes: typeof reply.freedBytes === "number" ? reply.freedBytes : 0 };
|
|
1274
|
+
},
|
|
1275
|
+
async copy(build) {
|
|
1276
|
+
const reply = await ask(socketPath, { v: 1, op: "copy", build }, COPY_TIMEOUT_MS);
|
|
1277
|
+
return { copiedBytes: typeof reply.copiedBytes === "number" ? reply.copiedBytes : 0 };
|
|
1235
1278
|
}
|
|
1236
1279
|
};
|
|
1237
1280
|
}
|
|
@@ -1309,6 +1352,7 @@ function createMicroVmPorts(over = {}) {
|
|
|
1309
1352
|
// src/runner/verdict.ts
|
|
1310
1353
|
var VERDICT_SETTLE_MS = 5 * 6e4;
|
|
1311
1354
|
var VERDICT_READ_EVERY_MS = 3e4;
|
|
1355
|
+
var WORK_ITEM_READ_TIMEOUT_MS = 3e4;
|
|
1312
1356
|
var REASON_MAX = 200;
|
|
1313
1357
|
var FAILING_IDS_MAX = 5;
|
|
1314
1358
|
function text(value) {
|
|
@@ -1345,7 +1389,7 @@ function parseEvaluation(value, checks) {
|
|
|
1345
1389
|
return { verdict, sentence: text(raw.sentence), waitingOn: raw.waitingOn, open };
|
|
1346
1390
|
}
|
|
1347
1391
|
async function readWorkItem(config, item, fetchImpl) {
|
|
1348
|
-
const { data } = await getJson(config.url, `/v1/work-items/${item}`, config.apiKey, config.appId, fetchImpl, await signerFor(config.configPath));
|
|
1392
|
+
const { data } = await getJson(config.url, `/v1/work-items/${item}`, config.apiKey, config.appId, fetchImpl, await signerFor(config.configPath), { timeoutMs: WORK_ITEM_READ_TIMEOUT_MS });
|
|
1349
1393
|
return data;
|
|
1350
1394
|
}
|
|
1351
1395
|
function declaredPullRequest(workItem, repository) {
|
|
@@ -2560,7 +2604,7 @@ function writeRecord2(dir, record) {
|
|
|
2560
2604
|
function isRecord(value) {
|
|
2561
2605
|
if (typeof value !== "object" || value === null) return false;
|
|
2562
2606
|
const r = value;
|
|
2563
|
-
return typeof r.id === "string" && (r.kind === "volume" || r.kind === "tar") && typeof r.savedAt === "string" && Number.isFinite(Date.parse(r.savedAt)) && typeof r.bytes === "number" && typeof r.baseKey === "string" && typeof r.key === "string" && typeof r.fileHashes === "object" && r.fileHashes !== null && typeof r.complete === "boolean";
|
|
2607
|
+
return typeof r.id === "string" && (r.kind === "volume" || r.kind === "tar" || r.kind === "disk") && typeof r.savedAt === "string" && Number.isFinite(Date.parse(r.savedAt)) && typeof r.bytes === "number" && typeof r.baseKey === "string" && typeof r.key === "string" && typeof r.fileHashes === "object" && r.fileHashes !== null && typeof r.complete === "boolean";
|
|
2564
2608
|
}
|
|
2565
2609
|
function readRecords(dir) {
|
|
2566
2610
|
let names;
|
|
@@ -2584,6 +2628,46 @@ function deleteRecord(dir, id) {
|
|
|
2584
2628
|
rmSync(join(dir, `${id}.json`), { force: true });
|
|
2585
2629
|
}
|
|
2586
2630
|
|
|
2631
|
+
// src/runner/saved-state/remove.ts
|
|
2632
|
+
async function removeSavedState(record, deps) {
|
|
2633
|
+
if (record.kind === "volume" && record.volume !== void 0) {
|
|
2634
|
+
const result = await deps.removeVolume(record.volume);
|
|
2635
|
+
if (result !== void 0 && result.status !== 0) {
|
|
2636
|
+
const line2 = (result.stderr ?? "").trim().split("\n").filter((text2) => text2.trim() !== "").at(-1);
|
|
2637
|
+
throw new Error(`Docker could not remove volume ${record.volume} (exit ${result.status}${line2 === void 0 ? "" : `: ${line2}`})`);
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
if ((record.kind === "tar" || record.kind === "disk") && record.path !== void 0) {
|
|
2641
|
+
rmSync(`${record.path}.partial`, { force: true });
|
|
2642
|
+
rmSync(record.path, { force: true });
|
|
2643
|
+
}
|
|
2644
|
+
deleteRecord(deps.dir, record.id);
|
|
2645
|
+
}
|
|
2646
|
+
async function removeOldestUntil(input) {
|
|
2647
|
+
const removed = [];
|
|
2648
|
+
for (const record of oldestFirst(input.records)) {
|
|
2649
|
+
if (input.enough()) break;
|
|
2650
|
+
try {
|
|
2651
|
+
await removeSavedState(record, input.deps);
|
|
2652
|
+
removed.push(record);
|
|
2653
|
+
input.log(`removed saved state ${record.id} from ${record.savedAt}`);
|
|
2654
|
+
} catch (err) {
|
|
2655
|
+
input.log(`could not remove saved state ${record.id}: ${describeCallFailure(err)}`);
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
return removed;
|
|
2659
|
+
}
|
|
2660
|
+
async function removeSuperseded(input) {
|
|
2661
|
+
for (const old of input.records.filter((record) => record.complete && record.key === input.made.key && record.id !== input.made.id && Date.parse(record.savedAt) < Date.parse(input.made.savedAt))) {
|
|
2662
|
+
try {
|
|
2663
|
+
await removeSavedState(old, input.deps);
|
|
2664
|
+
input.log(`removed saved state ${old.id}, saved state ${input.made.id} replaces it`);
|
|
2665
|
+
} catch (err) {
|
|
2666
|
+
input.log(`could not remove saved state ${old.id}: ${describeCallFailure(err)}`);
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2587
2671
|
// src/runner/saved-state/plan.ts
|
|
2588
2672
|
function savedStateBase(report) {
|
|
2589
2673
|
const digest = report.recipe === "default" ? report.base?.digest : void 0;
|
|
@@ -2628,6 +2712,15 @@ async function planSavedState(input) {
|
|
|
2628
2712
|
diskBytes: parseSize(config.build?.disk ?? DEFAULT_BUILD_DISK) ?? 0
|
|
2629
2713
|
});
|
|
2630
2714
|
const found = lookup(readRecords(savedStatesDir(root)), key, input.now.getTime());
|
|
2715
|
+
if (found.kind !== "none" && found.record.kind === "tar") {
|
|
2716
|
+
try {
|
|
2717
|
+
await removeSavedState(found.record, { dir: savedStatesDir(root), removeVolume: async () => void 0 });
|
|
2718
|
+
log(`saved state ${found.record.id} is a tar file, which this runner no longer restores; removed it; starting from a fresh disk`);
|
|
2719
|
+
} catch (err) {
|
|
2720
|
+
log(`saved state ${found.record.id} is a tar file, which this runner no longer restores, and it could not be removed: ${describeCallFailure(err)}; starting from a fresh disk`);
|
|
2721
|
+
}
|
|
2722
|
+
return { key, keyCommits };
|
|
2723
|
+
}
|
|
2631
2724
|
if (found.kind === "usable" && input.allowRestore) {
|
|
2632
2725
|
log(`starting from saved state ${found.record.id}, saved ${formatDuration(found.ageMs)} ago`);
|
|
2633
2726
|
return { key, keyCommits, restore: { record: found.record, ageMs: found.ageMs } };
|
|
@@ -2645,44 +2738,6 @@ function unread(reason, log) {
|
|
|
2645
2738
|
log(`this build starts from no saved state and saves none: ${reason}`);
|
|
2646
2739
|
return { keyCommits: {}, noSave: `its key files could not be read: ${reason}` };
|
|
2647
2740
|
}
|
|
2648
|
-
async function removeSavedState(record, deps) {
|
|
2649
|
-
if (record.kind === "volume" && record.volume !== void 0) {
|
|
2650
|
-
const result = await deps.removeVolume(record.volume);
|
|
2651
|
-
if (result !== void 0 && result.status !== 0) {
|
|
2652
|
-
const line2 = (result.stderr ?? "").trim().split("\n").filter((text2) => text2.trim() !== "").at(-1);
|
|
2653
|
-
throw new Error(`Docker could not remove volume ${record.volume} (exit ${result.status}${line2 === void 0 ? "" : `: ${line2}`})`);
|
|
2654
|
-
}
|
|
2655
|
-
}
|
|
2656
|
-
if (record.kind === "tar" && record.path !== void 0) {
|
|
2657
|
-
rmSync(`${record.path}.partial`, { force: true });
|
|
2658
|
-
rmSync(record.path, { force: true });
|
|
2659
|
-
}
|
|
2660
|
-
deleteRecord(deps.dir, record.id);
|
|
2661
|
-
}
|
|
2662
|
-
async function removeOldestUntil(input) {
|
|
2663
|
-
const removed = [];
|
|
2664
|
-
for (const record of oldestFirst(input.records)) {
|
|
2665
|
-
if (input.enough()) break;
|
|
2666
|
-
try {
|
|
2667
|
-
await removeSavedState(record, input.deps);
|
|
2668
|
-
removed.push(record);
|
|
2669
|
-
input.log(`removed saved state ${record.id} from ${record.savedAt}`);
|
|
2670
|
-
} catch (err) {
|
|
2671
|
-
input.log(`could not remove saved state ${record.id}: ${describeCallFailure(err)}`);
|
|
2672
|
-
}
|
|
2673
|
-
}
|
|
2674
|
-
return removed;
|
|
2675
|
-
}
|
|
2676
|
-
async function removeSuperseded(input) {
|
|
2677
|
-
for (const old of input.records.filter((record) => record.complete && record.key === input.made.key && record.id !== input.made.id && Date.parse(record.savedAt) < Date.parse(input.made.savedAt))) {
|
|
2678
|
-
try {
|
|
2679
|
-
await removeSavedState(old, input.deps);
|
|
2680
|
-
input.log(`removed saved state ${old.id}, saved state ${input.made.id} replaces it`);
|
|
2681
|
-
} catch (err) {
|
|
2682
|
-
input.log(`could not remove saved state ${old.id}: ${describeCallFailure(err)}`);
|
|
2683
|
-
}
|
|
2684
|
-
}
|
|
2685
|
-
}
|
|
2686
2741
|
|
|
2687
2742
|
// src/runner/saved-state/provision.ts
|
|
2688
2743
|
var isRetryFresh = (value) => typeof value === "object" && value !== null && "retryFresh" in value;
|
|
@@ -2738,17 +2793,103 @@ async function discardUnusableState(input) {
|
|
|
2738
2793
|
function settleFailedSteps(steps, on) {
|
|
2739
2794
|
return steps.restoreFailed === true ? on.giveUp(steps.reason) : on.bail(steps.reason, steps.aborted === true);
|
|
2740
2795
|
}
|
|
2796
|
+
var FREEZE_DEADLINE_SECONDS = 12 * 60;
|
|
2797
|
+
function freezeScript() {
|
|
2798
|
+
return [
|
|
2799
|
+
"deadline=$1",
|
|
2800
|
+
`exec 3< <(exec setsid bash -c 'main=$1; end=$((SECONDS + $2)); echo ready; exec >/dev/null; while kill -0 "$main" 2>/dev/null && [ "$SECONDS" -lt "$end" ]; do sleep 1; done; fsfreeze -u /build 2>/dev/null' watcher "$$" "$deadline" </dev/null 2>/dev/null)`,
|
|
2801
|
+
"watcher=$!",
|
|
2802
|
+
'read -r -t 30 -u 3 ready && [ "$ready" = ready ] || exit 6',
|
|
2803
|
+
"exec 3<&-",
|
|
2804
|
+
'fsfreeze -f /build || { kill "$watcher" 2>/dev/null; exit 3; }',
|
|
2805
|
+
"echo frozen",
|
|
2806
|
+
// A line `thaw` is the runner's request. The end of the input, or the deadline, is a thaw the runner did not ask for.
|
|
2807
|
+
'if read -r -t "$deadline" line && [ "$line" = thaw ]; then',
|
|
2808
|
+
' if fsfreeze -u /build; then kill "$watcher" 2>/dev/null; echo thawed; exit 0; fi',
|
|
2809
|
+
" exit 4",
|
|
2810
|
+
"fi",
|
|
2811
|
+
"fsfreeze -u /build 2>/dev/null",
|
|
2812
|
+
'kill "$watcher" 2>/dev/null',
|
|
2813
|
+
"echo thawed early",
|
|
2814
|
+
"exit 5"
|
|
2815
|
+
].join("\n");
|
|
2816
|
+
}
|
|
2741
2817
|
var failureText = (status, stderr) => {
|
|
2742
2818
|
const line2 = stderr.trim().split("\n").at(-1) ?? "";
|
|
2743
2819
|
return `exit ${status}${line2 === "" ? "" : `: ${line2}`}`;
|
|
2744
2820
|
};
|
|
2745
|
-
async function
|
|
2821
|
+
async function freezeGuest(guest, deadlineSeconds = FREEZE_DEADLINE_SECONDS) {
|
|
2822
|
+
const stdin = new PassThrough();
|
|
2823
|
+
const lines = [];
|
|
2824
|
+
let pending = "";
|
|
2825
|
+
let stderr = "";
|
|
2826
|
+
let thawRequested = false;
|
|
2827
|
+
let thawedBeforeAsked = false;
|
|
2828
|
+
let thawedAfterAsked = false;
|
|
2829
|
+
let notify = () => void 0;
|
|
2830
|
+
const onLine = (line2) => {
|
|
2831
|
+
lines.push(line2);
|
|
2832
|
+
if (line2.startsWith("thawed")) {
|
|
2833
|
+
if (line2 === "thawed early" || !thawRequested) thawedBeforeAsked = true;
|
|
2834
|
+
else thawedAfterAsked = true;
|
|
2835
|
+
}
|
|
2836
|
+
notify();
|
|
2837
|
+
};
|
|
2838
|
+
const ended = guest.stream(["bash", "-c", freezeScript(), "freeze", String(deadlineSeconds)], {
|
|
2839
|
+
stdin,
|
|
2840
|
+
onStdout: (chunk) => {
|
|
2841
|
+
pending += chunk.toString();
|
|
2842
|
+
for (let end = pending.indexOf("\n"); end !== -1; end = pending.indexOf("\n")) {
|
|
2843
|
+
onLine(pending.slice(0, end).trim());
|
|
2844
|
+
pending = pending.slice(end + 1);
|
|
2845
|
+
}
|
|
2846
|
+
},
|
|
2847
|
+
onStderr: (chunk) => void (stderr = (stderr + chunk.toString()).slice(-400))
|
|
2848
|
+
}).then(
|
|
2849
|
+
(result) => ({ done: true, status: result.status }),
|
|
2850
|
+
(err) => ({ done: true, error: describeCallFailure(err) })
|
|
2851
|
+
);
|
|
2852
|
+
const frozen = new Promise((resolve2) => {
|
|
2853
|
+
notify = () => {
|
|
2854
|
+
if (lines.includes("frozen")) resolve2("frozen");
|
|
2855
|
+
};
|
|
2856
|
+
});
|
|
2857
|
+
const first = await Promise.race([frozen, ended]);
|
|
2858
|
+
if (first !== "frozen") {
|
|
2859
|
+
stdin.end();
|
|
2860
|
+
return { ok: false, reason: "error" in first ? `the guest could not freeze /build: ${first.error}` : `the guest could not freeze /build (${failureText(first.status, stderr)})` };
|
|
2861
|
+
}
|
|
2862
|
+
return {
|
|
2863
|
+
ok: true,
|
|
2864
|
+
session: {
|
|
2865
|
+
async thaw() {
|
|
2866
|
+
thawRequested = true;
|
|
2867
|
+
stdin.end("thaw\n");
|
|
2868
|
+
const result = await ended;
|
|
2869
|
+
if ("error" in result) return { ok: false, reason: `the freeze command's connection failed: ${result.error}` };
|
|
2870
|
+
if (thawedBeforeAsked) return { ok: false, reason: "the freeze command thawed /build before the runner asked" };
|
|
2871
|
+
if (!thawedAfterAsked) return { ok: false, reason: `the freeze command did not say it thawed /build (${failureText(result.status, stderr)})` };
|
|
2872
|
+
if (result.status !== 0) return { ok: false, reason: `the freeze command ended badly after it thawed /build (${failureText(result.status, stderr)})` };
|
|
2873
|
+
return { ok: true };
|
|
2874
|
+
}
|
|
2875
|
+
}
|
|
2876
|
+
};
|
|
2877
|
+
}
|
|
2878
|
+
|
|
2879
|
+
// src/runner/saved-state/microvm.ts
|
|
2880
|
+
var HELPER_COPY_NAME = "saved-state.ext4";
|
|
2881
|
+
var failureText2 = (status, stderr) => {
|
|
2882
|
+
const line2 = stderr.trim().split("\n").at(-1) ?? "";
|
|
2883
|
+
return `exit ${status}${line2 === "" ? "" : `: ${line2}`}`;
|
|
2884
|
+
};
|
|
2885
|
+
async function saveMicroVmDiskState(input) {
|
|
2746
2886
|
const id = randomBytes(6).toString("hex");
|
|
2747
|
-
const path = join(input.dir, `${id}.
|
|
2887
|
+
const path = join(input.dir, `${id}.ext4`);
|
|
2748
2888
|
const partial = `${path}.partial`;
|
|
2889
|
+
const helperCopy = join(input.buildDir, HELPER_COPY_NAME);
|
|
2749
2890
|
const record = {
|
|
2750
2891
|
id,
|
|
2751
|
-
kind: "
|
|
2892
|
+
kind: "disk",
|
|
2752
2893
|
path,
|
|
2753
2894
|
savedAt: input.now.toISOString(),
|
|
2754
2895
|
bytes: 0,
|
|
@@ -2759,52 +2900,64 @@ async function saveMicroVmState(input) {
|
|
|
2759
2900
|
complete: false
|
|
2760
2901
|
};
|
|
2761
2902
|
const discard = (reason) => {
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2903
|
+
for (const file of [partial, path, helperCopy]) {
|
|
2904
|
+
try {
|
|
2905
|
+
rmSync(file, { force: true });
|
|
2906
|
+
} catch {
|
|
2907
|
+
}
|
|
2908
|
+
}
|
|
2909
|
+
try {
|
|
2910
|
+
deleteRecord(input.dir, id);
|
|
2911
|
+
} catch {
|
|
2912
|
+
}
|
|
2765
2913
|
return { ok: false, reason };
|
|
2766
2914
|
};
|
|
2915
|
+
let session;
|
|
2767
2916
|
try {
|
|
2917
|
+
const { savedStateMax } = input.limits;
|
|
2918
|
+
if (savedStateMax === "off") return { ok: false, reason: "runner.housekeeping.savedStateMax is off" };
|
|
2768
2919
|
const stopped = await input.guest.run(["/bin/sh", "-c", guestStopScript()]);
|
|
2769
|
-
if (stopped.status !== 0) return { ok: false, reason: `the guest's processes could not be stopped (${
|
|
2920
|
+
if (stopped.status !== 0) return { ok: false, reason: `the guest's processes could not be stopped (${failureText2(stopped.status, stopped.stderr)})` };
|
|
2770
2921
|
const flushed = await input.guest.run(["sync", "-f", "/build"]);
|
|
2771
|
-
if (flushed.status !== 0) return { ok: false, reason: `the build disk could not be flushed (${
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2922
|
+
if (flushed.status !== 0) return { ok: false, reason: `the build disk could not be flushed (${failureText2(flushed.status, flushed.stderr)})` };
|
|
2923
|
+
const allocated = allocatedBytes(input.buildDisk);
|
|
2924
|
+
if (allocated > savedStateMax) {
|
|
2925
|
+
return { ok: false, reason: `the build disk holds ${formatBytes(allocated)}, more than the ${formatBytes(savedStateMax)} of runner.housekeeping.savedStateMax` };
|
|
2926
|
+
}
|
|
2927
|
+
const free = input.limits.freeBytes(input.dir);
|
|
2928
|
+
if (free !== void 0 && free - allocated < input.limits.minFreeDisk) {
|
|
2929
|
+
return { ok: false, reason: `a copy of ${formatBytes(allocated)} would leave ${formatBytes(Math.max(0, free - allocated))} free, less than the ${formatBytes(input.limits.minFreeDisk)} of runner.housekeeping.minFreeDisk` };
|
|
2930
|
+
}
|
|
2931
|
+
const frozen = await (input.freeze ?? ((guest) => freezeGuest(guest)))(input.guest);
|
|
2932
|
+
if (!frozen.ok) return { ok: false, reason: frozen.reason };
|
|
2933
|
+
session = frozen.session;
|
|
2934
|
+
let copyFailure;
|
|
2777
2935
|
try {
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2936
|
+
mkdirSync(input.dir, { recursive: true, mode: 448 });
|
|
2937
|
+
writeRecord2(input.dir, record);
|
|
2938
|
+
if (input.helper !== void 0) {
|
|
2939
|
+
await input.helper.copy(input.buildId);
|
|
2940
|
+
renameSync(helperCopy, path);
|
|
2941
|
+
} else {
|
|
2942
|
+
await (input.copyDisk ?? copyDiskFile)(input.buildDisk, partial);
|
|
2943
|
+
renameSync(partial, path);
|
|
2944
|
+
}
|
|
2945
|
+
} catch (err) {
|
|
2946
|
+
copyFailure = err instanceof HelperRefusal && err.code === "bad-request" ? `${err.message}; run \`outerlayer runner install --service --replace\` to install the root helper that goes with this release` : `the build disk could not be copied: ${describeCallFailure(err)}`;
|
|
2947
|
+
}
|
|
2948
|
+
session = void 0;
|
|
2949
|
+
const thawed = await frozen.session.thaw();
|
|
2950
|
+
if (copyFailure !== void 0) return discard(copyFailure);
|
|
2951
|
+
if (!thawed.ok) return discard(thawed.reason);
|
|
2952
|
+
chmodSync(path, RUNNER_FILE_MODE);
|
|
2953
|
+
const done = { ...record, bytes: statSync(path).blocks * 512, complete: true };
|
|
2788
2954
|
writeRecord2(input.dir, done);
|
|
2789
2955
|
return { ok: true, record: done };
|
|
2790
2956
|
} catch (err) {
|
|
2957
|
+
if (session !== void 0) await session.thaw().catch(() => void 0);
|
|
2791
2958
|
return discard(`the state could not be saved: ${describeCallFailure(err)}`);
|
|
2792
2959
|
}
|
|
2793
2960
|
}
|
|
2794
|
-
async function restoreMicroVmState(input) {
|
|
2795
|
-
const { path } = input.record;
|
|
2796
|
-
if (path === void 0 || !existsSync(path)) return { ok: false, reason: "the saved tar file is gone" };
|
|
2797
|
-
try {
|
|
2798
|
-
let stderr = "";
|
|
2799
|
-
const result = await input.guest.stream(["tar", "-x", "--numeric-owner", "-C", "/build"], {
|
|
2800
|
-
stdin: createReadStream(path),
|
|
2801
|
-
onStderr: (chunk) => void (stderr = (stderr + chunk.toString()).slice(-400))
|
|
2802
|
-
});
|
|
2803
|
-
return result.status === 0 ? { ok: true } : { ok: false, reason: `tar could not unpack the saved state (${failureText(result.status, stderr)})` };
|
|
2804
|
-
} catch (err) {
|
|
2805
|
-
return { ok: false, reason: `the saved state could not be unpacked: ${describeCallFailure(err)}` };
|
|
2806
|
-
}
|
|
2807
|
-
}
|
|
2808
2961
|
var EVAL_INPUT_NAME = "eval-input";
|
|
2809
2962
|
var TRANSCRIPT_ROOT = "/build/home/.claude/projects";
|
|
2810
2963
|
var MAX_TRANSCRIPT_BYTES = 7 * 1024 * 1024;
|
|
@@ -3554,7 +3707,18 @@ async function provisionMicroVmOnce(input, allowRestore) {
|
|
|
3554
3707
|
if (helper === void 0 && config.managed === true) return bail(MANAGED_UNJAILED_REASON);
|
|
3555
3708
|
try {
|
|
3556
3709
|
if (helper === void 0) linkVsockSockets({ buildDir: buildDir2, vsockPath: state.vsockPath, links: served });
|
|
3557
|
-
|
|
3710
|
+
const restore = plan.restore?.record;
|
|
3711
|
+
if (restore !== void 0 && (restore.kind !== "disk" || restore.path === void 0)) return giveUpState(`the saved state is a ${restore.kind}, not a disk this runner can copy; provisioning the build again from a fresh disk`);
|
|
3712
|
+
const restoreStartedAt = Date.now();
|
|
3713
|
+
try {
|
|
3714
|
+
await createBuildDisk({ host: vm.rootfs, runnerDir: runnerDirPath, bytes: limits2.diskBytes, dest: state.buildDisk, memoryBytes: limits2.memoryBytes, source: restore?.path });
|
|
3715
|
+
} catch (err) {
|
|
3716
|
+
if (restore !== void 0) return giveUpState(`the saved disk could not be copied: ${describeCallFailure(err)}`);
|
|
3717
|
+
throw err;
|
|
3718
|
+
}
|
|
3719
|
+
if (restore?.path !== void 0) {
|
|
3720
|
+
tagged(`restored saved state ${restore.id}: ${formatBytes(allocatedBytes(restore.path))} allocated, copied in ${formatDuration(Date.now() - restoreStartedAt)}`);
|
|
3721
|
+
}
|
|
3558
3722
|
writeFileSync(
|
|
3559
3723
|
configPath,
|
|
3560
3724
|
JSON.stringify(
|
|
@@ -3670,8 +3834,6 @@ async function provisionMicroVmOnce(input, allowRestore) {
|
|
|
3670
3834
|
if (plan.restore !== void 0) {
|
|
3671
3835
|
const changed = userIdChangedReason(plan.restore.record.agentUid, agentUid);
|
|
3672
3836
|
if (changed !== void 0) return giveUpState(changed);
|
|
3673
|
-
const restored = await restoreMicroVmState({ guest, record: plan.restore.record });
|
|
3674
|
-
if (!restored.ok) return giveUpState(restored.reason);
|
|
3675
3837
|
}
|
|
3676
3838
|
const tools = await asRoot(runtime, state, ["cat", "/opt/outerlayer/tools.json"]);
|
|
3677
3839
|
const agentVersion = agentVersionOf(tools.status === 0 ? tools.stdout : "");
|
|
@@ -3685,7 +3847,20 @@ async function provisionMicroVmOnce(input, allowRestore) {
|
|
|
3685
3847
|
if (failure3 !== void 0) return bail(failure3);
|
|
3686
3848
|
}
|
|
3687
3849
|
const saveState = () => saveAndPrune({
|
|
3688
|
-
save: () =>
|
|
3850
|
+
save: () => saveMicroVmDiskState({
|
|
3851
|
+
guest,
|
|
3852
|
+
dir: savedStatesPath,
|
|
3853
|
+
buildId,
|
|
3854
|
+
buildDisk: state.buildDisk,
|
|
3855
|
+
buildDir: buildDir2,
|
|
3856
|
+
helper,
|
|
3857
|
+
limits: { savedStateMax: savedStateMaxOf(config), minFreeDisk: config.housekeeping?.minFreeDisk ?? 0, freeBytes },
|
|
3858
|
+
...vm.rootfs.copyDisk === void 0 ? {} : { copyDisk: vm.rootfs.copyDisk.bind(vm.rootfs) },
|
|
3859
|
+
key: plan.key,
|
|
3860
|
+
agentUid,
|
|
3861
|
+
now: clockOf(input.now)(),
|
|
3862
|
+
log: tagged
|
|
3863
|
+
}),
|
|
3689
3864
|
dir: savedStatesPath,
|
|
3690
3865
|
removeVolume: async () => void 0,
|
|
3691
3866
|
log: tagged
|
|
@@ -6478,6 +6653,7 @@ function readCpuUsec(cgroupPath) {
|
|
|
6478
6653
|
return null;
|
|
6479
6654
|
}
|
|
6480
6655
|
}
|
|
6656
|
+
var RENEW_TIMEOUT_MS = 3e4;
|
|
6481
6657
|
async function renewLease(config, item, fetchImpl) {
|
|
6482
6658
|
try {
|
|
6483
6659
|
await postJson(
|
|
@@ -6487,7 +6663,7 @@ async function renewLease(config, item, fetchImpl) {
|
|
|
6487
6663
|
config.appId,
|
|
6488
6664
|
{ host: config.host, seconds: LEASE_SECONDS },
|
|
6489
6665
|
fetchImpl,
|
|
6490
|
-
|
|
6666
|
+
RENEW_TIMEOUT_MS,
|
|
6491
6667
|
await signerFor(config.configPath)
|
|
6492
6668
|
);
|
|
6493
6669
|
return "renewed";
|
|
@@ -7781,13 +7957,13 @@ function removeStaleBuilderCaches(options, nowMs) {
|
|
|
7781
7957
|
return freed;
|
|
7782
7958
|
}
|
|
7783
7959
|
var E2FSCK_TIMEOUT_MS = 6e5;
|
|
7784
|
-
var
|
|
7960
|
+
var MAX_STDERR_BYTES2 = 8192;
|
|
7785
7961
|
var SBIN = "/usr/sbin:/sbin";
|
|
7786
7962
|
function e2fsckRunner(run = runWithSpawn(), env = process.env) {
|
|
7787
7963
|
return async (file, args) => {
|
|
7788
7964
|
const result = await run(file, args, { ...env, PATH: `${env.PATH ?? "/usr/bin:/bin"}:${SBIN}` }, E2FSCK_TIMEOUT_MS);
|
|
7789
7965
|
if (result.error !== void 0) throw result.error;
|
|
7790
|
-
return { status: result.status, stderr: result.stderr.slice(0,
|
|
7966
|
+
return { status: result.status, stderr: result.stderr.slice(0, MAX_STDERR_BYTES2) };
|
|
7791
7967
|
};
|
|
7792
7968
|
}
|
|
7793
7969
|
function firstLine6(text2) {
|
|
@@ -8470,7 +8646,7 @@ function helperArgs(input) {
|
|
|
8470
8646
|
}
|
|
8471
8647
|
var SAVE_SCRIPT = `set -e; cp -a ${SAVED_FOLDERS.map((name) => `/from/${name}`).join(" ")} /to/; du -sk /to | cut -f1`;
|
|
8472
8648
|
var RESTORE_SCRIPT = `set -e; cp -a ${SAVED_FOLDERS.map((name) => `/from/${name}`).join(" ")} /to/`;
|
|
8473
|
-
function
|
|
8649
|
+
function failureText3(result) {
|
|
8474
8650
|
const line2 = result.stderr.trim().split("\n").at(-1) ?? "";
|
|
8475
8651
|
return `exit ${result.status}${line2 === "" ? "" : `: ${line2}`}`;
|
|
8476
8652
|
}
|
|
@@ -8493,7 +8669,7 @@ async function saveContainerState(input) {
|
|
|
8493
8669
|
const discard = async (reason) => {
|
|
8494
8670
|
const removed = await host.removeVolume(volume).catch((err) => ({ status: -1, stderr: describeCallFailure(err) }));
|
|
8495
8671
|
if (removed.status !== 0) {
|
|
8496
|
-
input.log(`the volume ${volume} could not be removed (${
|
|
8672
|
+
input.log(`the volume ${volume} could not be removed (${failureText3({ status: removed.status, stderr: removed.stderr })}); its record stays so a later pass retries`);
|
|
8497
8673
|
return { ok: false, reason };
|
|
8498
8674
|
}
|
|
8499
8675
|
deleteRecord(input.dir, id);
|
|
@@ -8502,15 +8678,15 @@ async function saveContainerState(input) {
|
|
|
8502
8678
|
try {
|
|
8503
8679
|
const noEnv = { literals: {}, passed: {} };
|
|
8504
8680
|
const stopped = await host.exec({ container: input.container, user: input.agentUser, env: noEnv, argv: ["sh", "-c", stopProcessesScript()] });
|
|
8505
|
-
if (stopped.status !== 0) return { ok: false, reason: `the build's processes could not be stopped (${
|
|
8681
|
+
if (stopped.status !== 0) return { ok: false, reason: `the build's processes could not be stopped (${failureText3(stopped)})` };
|
|
8506
8682
|
input.log(`${stopped.stdout.trim() || "stopped 0"} process${stopped.stdout.trim() === "stopped 1" ? "" : "es"} before saving the state`);
|
|
8507
8683
|
const flushed = await host.exec({ container: input.container, user: input.agentUser, env: noEnv, argv: ["sync"] });
|
|
8508
|
-
if (flushed.status !== 0) return { ok: false, reason: `the build's disk could not be flushed (${
|
|
8684
|
+
if (flushed.status !== 0) return { ok: false, reason: `the build's disk could not be flushed (${failureText3(flushed)})` };
|
|
8509
8685
|
writeRecord2(input.dir, record);
|
|
8510
8686
|
const created = await host.createVolume(volume, { [SAVED_STATE_LABEL]: id, [RUNNER_LABEL]: input.runnerId });
|
|
8511
|
-
if (created.status !== 0) return await discard(`the volume for the saved state could not be made (${
|
|
8687
|
+
if (created.status !== 0) return await discard(`the volume for the saved state could not be made (${failureText3(created)})`);
|
|
8512
8688
|
const copied = await host.run(helperArgs({ image: input.image, from: input.buildVolume, to: volume, script: SAVE_SCRIPT, runnerId: input.runnerId }), { logPath: input.logPath });
|
|
8513
|
-
if (copied.status !== 0) return await discard(`the copy into the saved state failed (${
|
|
8689
|
+
if (copied.status !== 0) return await discard(`the copy into the saved state failed (${failureText3(copied)})`);
|
|
8514
8690
|
const kilobytes = Number(copied.stdout.trim().split("\n").at(-1));
|
|
8515
8691
|
const done = { ...record, bytes: Number.isFinite(kilobytes) ? kilobytes * 1024 : 0, complete: true };
|
|
8516
8692
|
writeRecord2(input.dir, done);
|
|
@@ -8522,7 +8698,7 @@ async function saveContainerState(input) {
|
|
|
8522
8698
|
async function restoreContainerState(input) {
|
|
8523
8699
|
try {
|
|
8524
8700
|
const copied = await input.host.run(helperArgs({ image: input.image, from: input.savedVolume, to: input.targetVolume, script: RESTORE_SCRIPT, runnerId: input.runnerId }), { logPath: input.logPath });
|
|
8525
|
-
if (copied.status !== 0) return { ok: false, reason: `the saved volume could not be copied (${
|
|
8701
|
+
if (copied.status !== 0) return { ok: false, reason: `the saved volume could not be copied (${failureText3(copied)})` };
|
|
8526
8702
|
return { ok: true };
|
|
8527
8703
|
} catch (err) {
|
|
8528
8704
|
return { ok: false, reason: `the saved volume could not be copied: ${describeCallFailure(err)}` };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import { DEFAULT_UNIT_NAME } from './chunk-
|
|
3
|
+
import { DEFAULT_UNIT_NAME } from './chunk-IP7F4CQH.js';
|
|
4
4
|
import { RUNNER_FILE_MODE } from './chunk-WT7J2627.js';
|
|
5
5
|
import { claudeEnvPath, withoutCredentialLines, parseRunnerEnv } from './chunk-GANAOCHR.js';
|
|
6
6
|
import { existsSync, readFileSync, writeFileSync, renameSync, rmSync } from 'fs';
|
|
@@ -51,10 +51,10 @@ function networkHelperPinned(arch, hashes = NETWORK_HELPER_SHA256) {
|
|
|
51
51
|
var JAILER_BINARY_SHA256 = {
|
|
52
52
|
x86_64: "65ef226e96f0ceda55ba643f445801ef2cc0ea667ef67cad8ac4f406c9c8434f"
|
|
53
53
|
};
|
|
54
|
-
var HOST_HELPER_ASSETS_VERSION = "
|
|
54
|
+
var HOST_HELPER_ASSETS_VERSION = "17";
|
|
55
55
|
var HOST_HELPER_BASE_URL = `https://github.com/outerlayerai/guest-assets/releases/download/guest-${HOST_HELPER_ASSETS_VERSION}`;
|
|
56
56
|
var HOST_HELPER_SHA256 = {
|
|
57
|
-
x86_64: "
|
|
57
|
+
x86_64: "0cd70e76a462212ed334b90edefb3dc1e4c584f93af7d990dbc801b67884f29f"
|
|
58
58
|
};
|
|
59
59
|
var HOST_HELPER_SLICE_SINCE = 15;
|
|
60
60
|
function hostHelperSupportsSlice(version = HOST_HELPER_ASSETS_VERSION) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import { toolsDockerfile } from './chunk-
|
|
3
|
+
import { toolsDockerfile } from './chunk-KB5B6ZT5.js';
|
|
4
4
|
import { claimPidFile, RunnerAlreadyRunningError, releasePidFile } from './chunk-WAZJPDR2.js';
|
|
5
5
|
import { startTimeOf } from './chunk-JBJTC3UU.js';
|
|
6
|
-
import { runnerLabelValue } from './chunk-
|
|
7
|
-
import { RecipeError, locateRecipe, readRecipe, assertBuildable, writeSanitizedRecipe, classifyProperties, SANITIZED_NAME } from './chunk-
|
|
8
|
-
import { UNIVERSAL_IMAGE_DIGEST, UNIVERSAL_IMAGE_REPOSITORY, UNIVERSAL_IMAGE_SOURCE, CLAUDE_CODE_VERSION, NODE_IMAGE, UNIVERSAL_IMAGE, MEDIA_PINS, TINI_VERSION, GH_VERSION } from './chunk-
|
|
6
|
+
import { runnerLabelValue } from './chunk-6O33JZ3X.js';
|
|
7
|
+
import { RecipeError, locateRecipe, readRecipe, assertBuildable, writeSanitizedRecipe, classifyProperties, SANITIZED_NAME } from './chunk-CIUD3436.js';
|
|
8
|
+
import { UNIVERSAL_IMAGE_DIGEST, UNIVERSAL_IMAGE_REPOSITORY, UNIVERSAL_IMAGE_SOURCE, CLAUDE_CODE_VERSION, NODE_IMAGE, UNIVERSAL_IMAGE, MEDIA_PINS, TINI_VERSION, GH_VERSION } from './chunk-OUPQTA7N.js';
|
|
9
9
|
import { RUNNER_DIR_MODE, RUNNER_FILE_MODE, repoCacheDir, imagesDir, imageBuildLogsDir, attemptStamp, orgStore, rootfsPathFor } from './chunk-WT7J2627.js';
|
|
10
10
|
import { withGitConfig, tokenHeader } from './chunk-GANAOCHR.js';
|
|
11
11
|
import { mkdirSync, rmSync, writeFileSync, existsSync, mkdtempSync, cpSync, readFileSync, readdirSync, lstatSync, readlinkSync } from 'fs';
|
|
@@ -3,7 +3,7 @@ import { createRequire } from 'node:module';
|
|
|
3
3
|
import { readNewestDemo } from './chunk-ER6KQCVJ.js';
|
|
4
4
|
import { runEmitArtifact } from './chunk-PDQWXH3F.js';
|
|
5
5
|
import { VoiceDownloadError, downloadPinned, sha256OfFile } from './chunk-2PGI6RDE.js';
|
|
6
|
-
import { VOICE_PACK_FILES, VOICE_PACK_VERSION } from './chunk-
|
|
6
|
+
import { VOICE_PACK_FILES, VOICE_PACK_VERSION } from './chunk-OUPQTA7N.js';
|
|
7
7
|
import { detectActiveSession } from './chunk-IP7BIBXJ.js';
|
|
8
8
|
import { autoConnect } from './chunk-LHFG5YUG.js';
|
|
9
9
|
import { C } from './chunk-2AM6Z5BP.js';
|