@outerlayer/cli 0.36.0-next.20261103032948 → 0.36.0-next.20261103103134
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/agent-setup-DZZZH3SE.js +40 -0
- package/dist/{agent-subcommand-DZWYGCPN.js → agent-subcommand-WRHH6SRD.js} +5 -5
- package/dist/{bridge-RY2CLUYP.js → bridge-GZSZQGLI.js} +8 -7
- package/dist/{build-CV6IUJWD.js → build-UKZ5RPRR.js} +14 -13
- package/dist/{build-disk-ITPCE4ME.js → build-disk-3HOXULLP.js} +12 -11
- package/dist/build-info.json +1 -1
- package/dist/{builder-TP6RBPGB.js → builder-QEK4GIRY.js} +11 -10
- package/dist/caller-WSMJJSFL.js +23 -0
- package/dist/{check-HJ3CKWDZ.js → check-D6NMQ6LP.js} +61 -60
- package/dist/{chunk-ORU76DHF.js → chunk-2JWLK2TU.js} +1 -1
- package/dist/{chunk-IVAX5RVX.js → chunk-2QIK3JRV.js} +1 -1
- package/dist/{chunk-HWIV4MF6.js → chunk-2SBNZ4EC.js} +1 -1
- package/dist/{chunk-ZEILNR5Q.js → chunk-2W5C47AE.js} +1 -1
- package/dist/{chunk-4XYEPTZP.js → chunk-3XEYA3QF.js} +3 -3
- package/dist/{chunk-55RNQFPE.js → chunk-42X6CTBI.js} +4 -4
- package/dist/{chunk-VNYAJEKO.js → chunk-4MLH5MDB.js} +5 -5
- package/dist/{chunk-YEETN7NH.js → chunk-4MN4BBKZ.js} +7 -7
- package/dist/{chunk-ECUP2QQH.js → chunk-52Z7AOZ2.js} +238 -193
- package/dist/{chunk-EI22245K.js → chunk-54ERDQ3O.js} +77 -9
- package/dist/{chunk-6DOYJN44.js → chunk-54PQNYA7.js} +3 -3
- package/dist/{chunk-GK7QN7K6.js → chunk-6J3QWXTA.js} +4 -4
- package/dist/{chunk-ZIRMH464.js → chunk-6UI4ELNA.js} +62 -53
- package/dist/{chunk-QTU6GW2M.js → chunk-7UYXSF62.js} +8 -227
- package/dist/{chunk-CSWT3PDT.js → chunk-B5UBTIIP.js} +5 -5
- package/dist/{chunk-WEHUIYTR.js → chunk-B5VKRKLJ.js} +1 -1
- package/dist/{chunk-TQDYP45H.js → chunk-BEJJJZXF.js} +4 -4
- package/dist/{chunk-CJNZ2FIW.js → chunk-BZQ3S24G.js} +1 -1
- package/dist/{chunk-LWKV36FC.js → chunk-CDTBXABP.js} +2 -2
- package/dist/{chunk-UZ5SDO7Y.js → chunk-DEZSNJSE.js} +1 -1
- package/dist/{chunk-AUZAQL7C.js → chunk-DWYQKLCL.js} +1 -1
- package/dist/{chunk-OR2TAE22.js → chunk-EHS3HEB6.js} +4 -4
- package/dist/{chunk-MHRZVSXP.js → chunk-EUWTGCK5.js} +1 -1
- package/dist/{chunk-DQJCVLYE.js → chunk-FLQL6ZIG.js} +1 -1
- package/dist/{chunk-A76SNTAM.js → chunk-GPBTTHK3.js} +1 -1
- package/dist/{chunk-CGVYMX4N.js → chunk-GWJUEJR4.js} +7 -7
- package/dist/{chunk-EKCOXTS2.js → chunk-HO4DPX5N.js} +1 -1
- package/dist/{chunk-HBE75JAU.js → chunk-HQBKKYYQ.js} +5 -5
- package/dist/{chunk-PEKITBZX.js → chunk-HR4PJLOO.js} +1 -1
- package/dist/{chunk-WNQGSAUE.js → chunk-IDYLPN4X.js} +1 -1
- package/dist/chunk-IEDO26G4.js +243 -0
- package/dist/{chunk-W2ZZ6KQP.js → chunk-IEVARJ6G.js} +2 -2
- package/dist/{chunk-DBXWEZ3L.js → chunk-J4NJWTNO.js} +5 -5
- package/dist/{chunk-WFRYPYPT.js → chunk-JD5EVW6Y.js} +1 -1
- package/dist/{chunk-5SDUOS4G.js → chunk-JMM3L5RG.js} +5 -5
- package/dist/{chunk-RWQ5XKRH.js → chunk-K26KMWU4.js} +10 -10
- package/dist/{chunk-VI233QH2.js → chunk-K373UCEV.js} +1 -1
- package/dist/{chunk-LEQWPWZA.js → chunk-KHJPRTOW.js} +1 -1
- package/dist/{chunk-LPKNESZ5.js → chunk-KVO4MJWS.js} +21 -10
- package/dist/{chunk-AT6RLTDF.js → chunk-L3SHPR2M.js} +1 -1
- package/dist/{chunk-CIG5RZ7Z.js → chunk-LDKF6B2R.js} +4 -3
- package/dist/{chunk-J4M35XQA.js → chunk-LISVY7JZ.js} +8 -8
- package/dist/{chunk-AXGTLADG.js → chunk-LV4IDDD3.js} +8 -13
- package/dist/{chunk-CULBCABP.js → chunk-LXXP5HRJ.js} +4 -4
- package/dist/{chunk-SSYFNK4W.js → chunk-MPVTZLOM.js} +4 -4
- package/dist/{chunk-ARAH3W3L.js → chunk-NDCN3R5C.js} +3 -3
- package/dist/{chunk-A4QJ2E4D.js → chunk-NH4EZRBM.js} +7 -7
- package/dist/{chunk-5OQTDTWB.js → chunk-NMMGRG5V.js} +6 -6
- package/dist/{chunk-RW6TM4OU.js → chunk-NOLS2G2W.js} +1 -1
- package/dist/{chunk-M6FMJXYO.js → chunk-NQYTUVZR.js} +1 -1
- package/dist/{chunk-JXAUDSTQ.js → chunk-OGG5ELXF.js} +5 -4
- package/dist/{chunk-UYPE2MYB.js → chunk-OPEZVPF7.js} +3 -3
- package/dist/{chunk-UWYU46GF.js → chunk-OV4XTV5M.js} +2 -2
- package/dist/{chunk-FQ6ZKZCH.js → chunk-P4Q6M6PI.js} +1 -1
- package/dist/{chunk-B3XUAKJI.js → chunk-PDRWRFB2.js} +4 -4
- package/dist/{chunk-MHIXBZDZ.js → chunk-PYK6GCCU.js} +6 -6
- package/dist/{chunk-LLZ2CX4M.js → chunk-QJKW4MKH.js} +6 -1
- package/dist/{chunk-XEZO7VQH.js → chunk-QVOU2QUR.js} +2 -2
- package/dist/{chunk-GVRD3MBC.js → chunk-R63T46P7.js} +3 -3
- package/dist/{chunk-4EJH2EE4.js → chunk-S7YU25AF.js} +34 -30
- package/dist/{chunk-EE3FR5JP.js → chunk-SYKEQT63.js} +6 -6
- package/dist/{chunk-66GYPUUN.js → chunk-T5I2H7TJ.js} +1 -1
- package/dist/{chunk-3IEVIKMC.js → chunk-TWGSXBZM.js} +3 -3
- package/dist/{chunk-7VUTGCGH.js → chunk-U6EACUUG.js} +1 -1
- package/dist/{chunk-U3SXAKQZ.js → chunk-U7MLC45I.js} +6 -6
- package/dist/{chunk-MMCVDHDX.js → chunk-UZSMDU4U.js} +3 -3
- package/dist/{chunk-SLWDYHO5.js → chunk-VMPVQE4D.js} +2 -2
- package/dist/{chunk-NKT32ZHB.js → chunk-VST3BWL4.js} +9 -9
- package/dist/{chunk-NNTORDVS.js → chunk-WAGHPZP2.js} +1 -1
- package/dist/{chunk-FINJC6BS.js → chunk-WZOWXDDM.js} +20 -14
- package/dist/{chunk-RT7R4COY.js → chunk-XAMTNTOH.js} +9 -8
- package/dist/{chunk-D4MQRI56.js → chunk-XW2KXLZB.js} +17 -17
- package/dist/{chunk-ASR6TU43.js → chunk-YCBVYTFI.js} +1 -1
- package/dist/{chunk-6V6ONATO.js → chunk-YEZGNCSK.js} +2 -2
- package/dist/{chunk-TE3Q6LVL.js → chunk-ZE2JJQPC.js} +1 -1
- package/dist/{chunk-757WX4YX.js → chunk-ZZ4WIQRF.js} +6 -5
- package/dist/{claude-launcher-5I7TNYQJ.js → claude-launcher-CPSCSL6U.js} +9 -9
- package/dist/{cli-4F4XTBBF.js → cli-TZW5XJRE.js} +194 -162
- package/dist/{command-ABIQ63NE.js → command-5VOKN4HI.js} +54 -53
- package/dist/{config-4W4MXVZR.js → config-23EBIGW4.js} +13 -12
- package/dist/{connect-cmd-I7TUU2BM.js → connect-cmd-GEBIOBQQ.js} +12 -11
- package/dist/{container-start-5EFWPLEB.js → container-start-NJGGT4E3.js} +59 -54
- package/dist/{context-cleanup-7XUQDCJ5.js → context-cleanup-I7FLIV5A.js} +5 -5
- package/dist/{context-show-cmd-6U42IUEX.js → context-show-cmd-CSPMSRHX.js} +13 -12
- package/dist/{control-plane-launch-SLIYO4BZ.js → control-plane-launch-KC7NUNYQ.js} +16 -15
- package/dist/{demo-record-cmd-HBFGZHVK.js → demo-record-cmd-ZW6U2LAV.js} +9 -8
- package/dist/{demo-voice-cmd-ZINZNDWR.js → demo-voice-cmd-IDW3QX3E.js} +22 -21
- package/dist/{dist-AIMCXBLZ.js → dist-LOBYZWOU.js} +1 -1
- package/dist/docker-2VHMWLNK.js +20 -0
- package/dist/{doctor-ZTOJ53SA.js → doctor-ZAB6SDWF.js} +54 -53
- package/dist/{emit-artifact-cmd-DNA5R6C2.js → emit-artifact-cmd-2ZHPNLPG.js} +21 -20
- package/dist/{emit-cmd-OGNFGQF6.js → emit-cmd-UN7HGZC5.js} +8 -8
- package/dist/{emit-criteria-cmd-UGLCECVP.js → emit-criteria-cmd-TUXGD7CW.js} +15 -14
- package/dist/{emit-demo-cmd-GBNYC5GU.js → emit-demo-cmd-4YMYB556.js} +22 -21
- package/dist/{emit-finding-cmd-66OOJS5Q.js → emit-finding-cmd-O2NN22XF.js} +15 -14
- package/dist/{emit-result-cmd-3BAYNI6R.js → emit-result-cmd-VRITADX2.js} +20 -19
- package/dist/{emit-step-cmd-S2ZISEQS.js → emit-step-cmd-LGNBZTWJ.js} +15 -14
- package/dist/{exec-client-PISQ53KG.js → exec-client-NXTXAVHI.js} +9 -8
- package/dist/find-unit-RYYTX2O5.js +24 -0
- package/dist/{findings-cmd-BPYW5IMS.js → findings-cmd-RJD7KTSW.js} +15 -14
- package/dist/{fleet-readiness-XNWEAVW7.js → fleet-readiness-RIO2SWC7.js} +15 -14
- package/dist/{governing-source-GS73BIQ3.js → governing-source-CZSYE7QE.js} +21 -20
- package/dist/guest-init-FLSL5RI7.js +20 -0
- package/dist/{hook-fast-IXIYJKAN.js → hook-fast-HYRZAY5K.js} +4 -4
- package/dist/{hook-install-LHVMFLO6.js → hook-install-CSHKOLWT.js} +5 -5
- package/dist/{hook-wrap-fast-FCZEUJKT.js → hook-wrap-fast-ITUBSHEF.js} +3 -3
- package/dist/host-checks-KLMATCMD.js +79 -0
- package/dist/host-key-CPAEQSNU.js +18 -0
- package/dist/{image-tag-U4YQCHRG.js → image-tag-MAMFM4SO.js} +9 -8
- package/dist/index.js +6 -6
- package/dist/init-BB2LERCZ.js +79 -0
- package/dist/{init-WGLH27Q3.js → init-G7D7ABKV.js} +50 -49
- package/dist/{init-cmd-N7MZ3LA3.js → init-cmd-5GHIMFSS.js} +30 -29
- package/dist/{init-update-5RY6XB27.js → init-update-TQH2Q7IZ.js} +24 -23
- package/dist/install-cmd-PVQ5M5NM.js +21 -0
- package/dist/{layout-3YKZWTPE.js → layout-2DF7ON2F.js} +5 -5
- package/dist/{logs-U7QU7KPL.js → logs-BM644OOJ.js} +8 -7
- package/dist/loop-7MAMONQJ.js +90 -0
- package/dist/machine-HDHSI7WF.js +79 -0
- package/dist/{machine-skills-4UHKD4HT.js → machine-skills-O7XAZYLN.js} +5 -5
- package/dist/{mcp-install-cmd-SQV4UZD6.js → mcp-install-cmd-METCXTTR.js} +5 -5
- package/dist/{mcp-serve-cmd-LRNO35OS.js → mcp-serve-cmd-CTKBLSM6.js} +10 -9
- package/dist/{paths-TH2PHIEY.js → paths-VIBBLJ2W.js} +8 -7
- package/dist/pending-RXJKH4AC.js +18 -0
- package/dist/{pidfile-CI7F3737.js → pidfile-PAX5XHQJ.js} +9 -8
- package/dist/{record-OFRT5V22.js → record-QPXOUL6F.js} +9 -8
- package/dist/{relay-NCWAF6NQ.js → relay-KASDMV3R.js} +6 -5
- package/dist/{relay-protocol-Y3HGIACN.js → relay-protocol-7HSCZC5H.js} +6 -5
- package/dist/runner-agents-WUMCXVS2.js +14 -0
- package/dist/runner-env-R2C5LYCX.js +24 -0
- package/dist/{runner-identity-QS26JIKL.js → runner-identity-UDPLWT7I.js} +11 -10
- package/dist/{runner-key-OKTRAUHO.js → runner-key-JGIDJTHH.js} +49 -48
- package/dist/{session-sender-UB6GJWZS.js → session-sender-4QKSVX5Z.js} +21 -20
- package/dist/{shell-function-H75JWHLA.js → shell-function-FTY7SSAJ.js} +2 -2
- package/dist/{spec-cmd-B3Y2JF4M.js → spec-cmd-QAOTQPI6.js} +16 -15
- package/dist/{starter-pack-3BXEKGIH.js → starter-pack-LAPDUG6E.js} +6 -6
- package/dist/state-OTWJW4O7.js +18 -0
- package/dist/{status-MPPZT5KS.js → status-OKZHXEYB.js} +49 -48
- package/dist/{statusline-fast-BTJSU3MB.js → statusline-fast-7V7U4SI4.js} +3 -3
- package/dist/{sync-cmd-YUWBZNQD.js → sync-cmd-FLNYVXAE.js} +20 -19
- package/dist/update-steps-W56ITCKQ.js +80 -0
- package/dist/{watch-GOWRN3BK.js → watch-4V7FZI5R.js} +20 -19
- package/dist/{work-claim-cmd-CHCADUYP.js → work-claim-cmd-E2D4YHCS.js} +22 -21
- package/dist/{work-cmd-WUJXUXHP.js → work-cmd-VD362634.js} +15 -14
- package/dist/{work-comment-cmd-E3GBVCQX.js → work-comment-cmd-EUI5IOQI.js} +18 -17
- package/dist/{work-demo-cmd-YOLKT6ZD.js → work-demo-cmd-MGL3U6ZF.js} +15 -14
- package/dist/{work-logs-cmd-SHWLRI4D.js → work-logs-cmd-QAJG75DG.js} +15 -14
- package/dist/{work-open-pr-cmd-LHMYF4CX.js → work-open-pr-cmd-SXVSMG44.js} +16 -15
- package/dist/{work-pr-cmd-PAYHF664.js → work-pr-cmd-WUIMC7XB.js} +15 -14
- package/dist/{work-proofs-cmd-VRZ5EOTH.js → work-proofs-cmd-AAHTMSCF.js} +17 -16
- package/dist/{work-proofs-record-ECHOY77G.js → work-proofs-record-LLUEXW7I.js} +26 -25
- package/dist/{work-stop-cmd-Z6RMU44Y.js → work-stop-cmd-RZLGWQJ5.js} +15 -14
- package/package.json +1 -1
- package/dist/agent-setup-PCMTLHTT.js +0 -39
- package/dist/caller-6X73FHOM.js +0 -22
- package/dist/docker-5L7BRY2J.js +0 -19
- package/dist/find-unit-QQP7HH3R.js +0 -23
- package/dist/guest-init-7OVIIKLM.js +0 -19
- package/dist/host-checks-XVHIR3EK.js +0 -78
- package/dist/host-key-3FKGWSHL.js +0 -17
- package/dist/init-V6ESW3K6.js +0 -78
- package/dist/install-cmd-6GXTY4UW.js +0 -20
- package/dist/loop-XM24ZVOO.js +0 -89
- package/dist/machine-X2Z5RLVD.js +0 -78
- package/dist/pending-EZKNEM2I.js +0 -17
- package/dist/runner-env-PO3FMLIW.js +0 -23
- package/dist/state-BV5BZMTE.js +0 -17
- package/dist/update-steps-UNOE66M4.js +0 -79
|
@@ -1,43 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import { itemsSentence, criteriaOf, hostItemsOf, loadCitationFinder, testFileMatcher, MAX_TEST_FILE_BYTES, MAX_TEST_FILES, criterionInputs, uncitedIds, planCriteria, parseJudgeAnswer, inCriteriaOrder, oneLineReason, judgedItems, IdScan, firstInPathOrder, isSearchCandidate } from './chunk-
|
|
4
|
-
import { zodProblem } from './chunk-I3LTIAOR.js';
|
|
3
|
+
import { itemsSentence, criteriaOf, hostItemsOf, loadCitationFinder, testFileMatcher, MAX_TEST_FILE_BYTES, MAX_TEST_FILES, criterionInputs, uncitedIds, planCriteria, parseJudgeAnswer, inCriteriaOrder, oneLineReason, judgedItems, IdScan, firstInPathOrder, isSearchCandidate } from './chunk-GPBTTHK3.js';
|
|
5
4
|
import { sha256OfFile, downloadPinned, VoiceDownloadError } from './chunk-2PGI6RDE.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
5
|
+
import { zodProblem } from './chunk-I3LTIAOR.js';
|
|
6
|
+
import { hasStoredCredential, storeAgentCredential, credentialFromStdin, isAgentName } from './chunk-LV4IDDD3.js';
|
|
7
|
+
import { upgradedStarterText } from './chunk-4MLH5MDB.js';
|
|
8
|
+
import { HELPER_PATH, HELPER_RECORD, DOCKERD_LOG } from './chunk-TWGSXBZM.js';
|
|
9
|
+
import { writeDockerClientConfig } from './chunk-FLQL6ZIG.js';
|
|
10
|
+
import { senderPidfile } from './chunk-EHS3HEB6.js';
|
|
11
|
+
import { installScrubContext } from './chunk-K26KMWU4.js';
|
|
11
12
|
import { readsJobState, READ_JOB_STATE_FORMATS, jobStateFormatOf } from './chunk-ZVB57WI6.js';
|
|
12
|
-
import { runnerImageVersion } from './chunk-
|
|
13
|
-
import { claimCalls, spoolHomeFor, itemCalls, claimItem, leftByRunnerKey } from './chunk-
|
|
13
|
+
import { runnerImageVersion } from './chunk-EUWTGCK5.js';
|
|
14
|
+
import { claimCalls, spoolHomeFor, itemCalls, claimItem, leftByRunnerKey } from './chunk-VMPVQE4D.js';
|
|
14
15
|
import { receiveFiles } from './chunk-NN33FYXG.js';
|
|
15
|
-
import { readDefaultBranchFiles, readDefaultBranchHead, buildRepositoryImage, fetchCommit, readBranchHead, diffBetween, prepareImageBuild, KEY_PREFIX, TAG_HOST, SHARED_OWNER, SHARED_NAME, universalBase, metadataFromLabels, writeRecord } from './chunk-
|
|
16
|
-
import { FETCHED_DIR, toolsDockerfile, FETCHED_FFMPEG, FETCHED_GH, FETCHED_TINI, FETCHED_HEADLESS_SHELL, FETCHED_PLAYWRIGHT_FFMPEG, FETCHED_VOICE_DIR } from './chunk-
|
|
16
|
+
import { readDefaultBranchFiles, readDefaultBranchHead, buildRepositoryImage, fetchCommit, readBranchHead, diffBetween, prepareImageBuild, KEY_PREFIX, TAG_HOST, SHARED_OWNER, SHARED_NAME, universalBase, metadataFromLabels, writeRecord } from './chunk-4MN4BBKZ.js';
|
|
17
|
+
import { FETCHED_DIR, toolsDockerfile, FETCHED_FFMPEG, FETCHED_GH, FETCHED_TINI, FETCHED_HEADLESS_SHELL, FETCHED_PLAYWRIGHT_FFMPEG, FETCHED_VOICE_DIR } from './chunk-OGG5ELXF.js';
|
|
17
18
|
import { isSameProcess, startTimeOf } from './chunk-JBJTC3UU.js';
|
|
18
19
|
import { currentCliBuild } from './chunk-OGFGZQA3.js';
|
|
19
|
-
import { vmExecArgs, runExec, execCapture, waitForAgent } from './chunk-
|
|
20
|
-
import { socketPathProblem, vsockLinks, linkVsockSockets, GUEST_CID, LEASE_LINK } from './chunk-
|
|
21
|
-
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-
|
|
22
|
-
import {
|
|
23
|
-
import { runnerCredentialProblem, builtinKind, keyRunnerFactory, optionalEgress, isBuiltinContainer, isBuiltinVm, egressSummary, DEFAULT_WORKSPACE_KEEP_DAYS, 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_BUILD_DISK, DEFAULT_CACHE_DISK, freeBytes } from './chunk-
|
|
25
|
-
import { writeJobFile, readJobFile, spawnRun, RUNNER_LABEL, BUILD_LABEL, NETWORK_HELPER_MEMORY, createDockerHost, builderSpec, containerExecArgs, childEnvironment, readDu, withAnswerProtocol, judgeCommand, MAX_REPORT_BYTES, parseSize, runnerLabelValue, readJobFileChecked, NETWORK_READY_FILE, networkHelperName, prepareRunArgs, containerRunArgs, JUDGE_MAX_TURNS, WORKSPACE_LABEL, homeCopyRunArgs, networkHelperRunArgs, JUDGE_DIR,
|
|
26
|
-
import { universalImagePending, RecipeError, writeSanitizedRecipe, classifyProperties, DOCKER_FEATURE } from './chunk-
|
|
27
|
-
import { postJson, WorkCommandError, getJson, isSignatureRefusal } from './chunk-LPKNESZ5.js';
|
|
20
|
+
import { vmExecArgs, runExec, execCapture, waitForAgent } from './chunk-WAGHPZP2.js';
|
|
21
|
+
import { socketPathProblem, vsockLinks, linkVsockSockets, GUEST_CID, LEASE_LINK } from './chunk-MPVTZLOM.js';
|
|
22
|
+
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-LISVY7JZ.js';
|
|
23
|
+
import { postJson, WorkCommandError, getJson, isSignatureRefusal } from './chunk-KVO4MJWS.js';
|
|
24
|
+
import { runnerCredentialProblem, builtinKind, keyRunnerFactory, optionalEgress, isBuiltinContainer, isBuiltinVm, egressSummary, DEFAULT_WORKSPACE_KEEP_DAYS, DEFAULT_CHECK_TIME_LIMIT_MINUTES, DEFAULT_SETUP_MINUTES, allowHostProblem, systemClock, emptyEgressCounts, hostAllowed, imageBuildOf, DEFAULT_SAVED_STATE_MAX_BYTES } from './chunk-6J3QWXTA.js';
|
|
25
|
+
import { formatBytes, volumeBytes, allocatedBytes, DEFAULT_BUILD_DISK, DEFAULT_CACHE_DISK, freeBytes } from './chunk-IEVARJ6G.js';
|
|
26
|
+
import { firstLine, writeJobFile, readJobFile, spawnRun, RUNNER_LABEL, BUILD_LABEL, said, NETWORK_HELPER_MEMORY, createDockerHost, builderSpec, containerExecArgs, childEnvironment, readDu, withAnswerProtocol, judgeCommand, MAX_REPORT_BYTES, parseSize, runnerLabelValue, readJobFileChecked, NETWORK_READY_FILE, networkHelperName, prepareRunArgs, containerRunArgs, JUDGE_MAX_TURNS, WORKSPACE_LABEL, homeCopyRunArgs, networkHelperRunArgs, JUDGE_DIR, hashJudgeProgram, identityScript, identityArgs, parseIdentity, mountableHome, homeCopyScript, homeCopyArgs, COMMAND_DIR, judgeProgramRecord, MAX_ITEMS_BYTES, JUDGE_ITEMS, JUDGE_REPORT, identityRunArgs, SAVED_STATE_LABEL } from './chunk-6UI4ELNA.js';
|
|
27
|
+
import { universalImagePending, RecipeError, writeSanitizedRecipe, classifyProperties, DOCKER_FEATURE } from './chunk-YCBVYTFI.js';
|
|
28
28
|
import { sanitizeTerminal, planArtifactUpload } from './chunk-F3T5QJ24.js';
|
|
29
|
+
import { sharedSkillNames, skillConflictMessage } from './chunk-3XEYA3QF.js';
|
|
29
30
|
import { readCloudConfig } from './chunk-HWVMRETT.js';
|
|
30
|
-
import { signerFor } from './chunk-
|
|
31
|
-
import { vmAssetsDir, RUNNER_DIR_MODE, RUNNER_FILE_MODE, runnerDir, jobsDir, storeScopes, spoolDir, orgStoreIn, rootfsDir, imagesDir, sessionsDir, builderCacheDiskPath, buildsDir, buildDir, ghConfigDir, runnerDirOfBuild, mirrorDir, orgHomeDir, jobConsolePath, vsockPath, workspacesDir, builderConsolePath, rootfsPathFor, diskTemplatesDir, deliveryDir, SHIM_DIR } from './chunk-
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import { versionAtLeast
|
|
35
|
-
import { firecrackerArch, MICROVM_ARCHES, FIRECRACKER_VERSION, hostHelperPinned, builderDiskPinned, guestAssetsPinned, runnerAgentNamed, credentialForms, orList, credentialShapes,
|
|
36
|
-
import { defaultAgents, parsePolicy, AGENTS_SKILLS_BASE, OUTERLAYER_SKILLS_BASE, resolvePackRoot,
|
|
31
|
+
import { signerFor } from './chunk-KHJPRTOW.js';
|
|
32
|
+
import { vmAssetsDir, RUNNER_DIR_MODE, RUNNER_FILE_MODE, runnerDir, jobsDir, storeScopes, spoolDir, orgStoreIn, rootfsDir, imagesDir, sessionsDir, builderCacheDiskPath, buildsDir, buildDir, ghConfigDir, runnerDirOfBuild, mirrorDir, orgHomeDir, jobConsolePath, vsockPath, workspacesDir, builderConsolePath, rootfsPathFor, diskTemplatesDir, deliveryDir, SHIM_DIR } from './chunk-L3SHPR2M.js';
|
|
33
|
+
import { BUILD_HOME, JOB_MOUNT, buildEnvironment, CHECKOUT_DIR, parseIsolation, containerLocalAddress, destinationEnvironment, withHooksPath, startBuildServices, headerVariables, authorEnvironment, sharedUserEnvironment, withTunnelRecord, commitIdentityRecord, repositoriesOf, RELAY_PORT, repositoryPath, lifecycleWorkdir, CHECK_ITEMS_FILE, proxyEnvironment, checkEnvironment, withMiseVariables, checkoutPath, maxDestinations, resolveDestinations, isReservedVariable, classifyAddress, primaryOf, carried6to4, EVAL_INPUT_DIR, isMiseVariableAllowed } from './chunk-LDKF6B2R.js';
|
|
34
|
+
import { agentCredential, RUNNER_WORDED_REASONS, UNKNOWN_TRACKING_REASON, UNKNOWN_TRANSPORT_REASON, currentAgentCredential, removedAgentCredentialValues, managedAgentCredential, RELAY_USER, realFdStorePort, builtInNames, MAX_MALFORMED_SESSIONS, MALFORMED_REASON, JOIN_WAIT_MS, MAX_OPEN_STREAMS, STREAM_RESET_RATE, STREAM_RESET_BURST, STREAM_WINDOW, SESSION_WINDOW, targetOfPath, AGENT_CREDENTIAL_MISSING, fdName, RELAY_ID, DOCKER_DESKTOP_REASON } from './chunk-7UYXSF62.js';
|
|
35
|
+
import { versionAtLeast } from './chunk-OV4XTV5M.js';
|
|
36
|
+
import { jobAgent, firecrackerArch, MICROVM_ARCHES, FIRECRACKER_VERSION, hostHelperPinned, builderDiskPinned, guestAssetsPinned, runnerAgentNamed, credentialForms, orList, credentialShapes, agentCommands, credentialAgent, GUEST_HELPER_SHA256, GUEST_ASSETS_BASE_URL, GUEST_KERNEL_SHA256, JAILER_BINARY_SHA256, FIRECRACKER_BINARY_SHA256, FIRECRACKER_SHA256, GUEST_ASSETS_VERSION, BUILDER_DISK_VERSION, credentialHandOffKey, strippedVariables, runnerAgents, 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, agentVersionOf } from './chunk-IEDO26G4.js';
|
|
37
|
+
import { sessionFolderIn, legacyAgent, defaultAgents, parsePolicy, AGENTS_SKILLS_BASE, OUTERLAYER_SKILLS_BASE, resolvePackRoot, orderSessions, extractFacts, sessionsToTimeline } from './chunk-54ERDQ3O.js';
|
|
37
38
|
import { MAINTAINED_SKILLS } from './chunk-CDDED64E.js';
|
|
38
39
|
import { resolveVersion } from './chunk-RA3O54FC.js';
|
|
39
40
|
import { homeFromEnv } from './chunk-352DHUTP.js';
|
|
40
|
-
import { scrubText, MIN_SCRUBBED_LITERAL, setCustomScrubbers, setLocalIdentity, setRepoRoot, forkFor, scrubDeep } from './chunk-
|
|
41
|
+
import { scrubText, MIN_SCRUBBED_LITERAL, setCustomScrubbers, setLocalIdentity, setRepoRoot, forkFor, scrubDeep } from './chunk-WZOWXDDM.js';
|
|
41
42
|
import { CheckItemsSchema, downconvertSession } from './chunk-WUKLQWGY.js';
|
|
42
43
|
import { randomUUID, randomBytes, createHash } from 'crypto';
|
|
43
44
|
import { rmSync, mkdirSync, existsSync, readFileSync, mkdtempSync, statSync, appendFileSync, writeFileSync, readdirSync, accessSync, constants, openSync, closeSync, renameSync, rmdirSync, createReadStream, lstatSync, unlinkSync, chmodSync, realpathSync, writeSync, truncateSync, cpSync, fstatSync, readSync, createWriteStream, copyFileSync, linkSync } from 'fs';
|
|
@@ -67,7 +68,6 @@ function itemTag(job) {
|
|
|
67
68
|
return scope === void 0 ? `#${job.item}` : `#${job.item}@${scope}`;
|
|
68
69
|
}
|
|
69
70
|
var RESUME_DIR = "/build/home/.outerlayer/resume";
|
|
70
|
-
var SESSION_PROJECT_DIR = `/build/home/.claude/projects/${CHECKOUT_DIR.replace(/[^A-Za-z0-9]/g, "-")}`;
|
|
71
71
|
var META_FILE = "meta.json";
|
|
72
72
|
var SESSION_ID_VARIABLE = "OUTERLAYER_SESSION_ID";
|
|
73
73
|
var RESUME_SESSION_VARIABLE = "OUTERLAYER_RESUME_SESSION";
|
|
@@ -78,6 +78,12 @@ var REASON_TEXT = {
|
|
|
78
78
|
session_not_loaded: "the saved session could not be loaded",
|
|
79
79
|
build_type_cannot_resume: "this build type cannot resume"
|
|
80
80
|
};
|
|
81
|
+
function sessionFilesOf(sessionId, agents) {
|
|
82
|
+
const agent = jobAgent(void 0, agents);
|
|
83
|
+
const capture = agent?.adapter.capture;
|
|
84
|
+
if (capture === void 0) throw new Error(`${agent?.descriptor.label ?? "the agent list"} keeps no session files`);
|
|
85
|
+
return capture.sessionFiles({ home: BUILD_HOME, cwd: CHECKOUT_DIR, sessionId });
|
|
86
|
+
}
|
|
81
87
|
function keptSessionDir(configPath, organizationId, workItemId) {
|
|
82
88
|
if (!WORK_ITEM_ID.test(workItemId)) throw new Error(`cannot keep a session for the work item ${JSON.stringify(workItemId)}`);
|
|
83
89
|
return join(sessionsDir(configPath, organizationId), workItemId);
|
|
@@ -95,10 +101,11 @@ function scrubFilesUnder(dir, scrub) {
|
|
|
95
101
|
} else throw new Error(`${name} is not a regular file, so it cannot be scrubbed`);
|
|
96
102
|
}
|
|
97
103
|
}
|
|
98
|
-
async function keepSession(input) {
|
|
104
|
+
async function keepSession(input, agents = defaultAgents()) {
|
|
99
105
|
const { dir } = input;
|
|
100
106
|
const meta = input.scrub === void 0 ? input.meta : { ...input.meta, scrubbed: true };
|
|
101
107
|
if (!SESSION_ID.test(meta.sessionId)) throw new Error(`cannot keep the session ${JSON.stringify(meta.sessionId)}`);
|
|
108
|
+
const transcriptName = sessionFilesOf(meta.sessionId, agents).entries[0];
|
|
102
109
|
const parent = dirname(dir);
|
|
103
110
|
mkdirSync(parent, { recursive: true, mode: 448 });
|
|
104
111
|
const tag = randomBytes(4).toString("hex");
|
|
@@ -108,7 +115,7 @@ async function keepSession(input) {
|
|
|
108
115
|
await receiveFiles(input.tar, { into: incoming, roots: [parent] });
|
|
109
116
|
let transcript;
|
|
110
117
|
try {
|
|
111
|
-
transcript = lstatSync(join(incoming,
|
|
118
|
+
transcript = lstatSync(join(incoming, transcriptName));
|
|
112
119
|
} catch {
|
|
113
120
|
transcript = void 0;
|
|
114
121
|
}
|
|
@@ -133,7 +140,7 @@ async function keepSession(input) {
|
|
|
133
140
|
rmSync(incoming, { recursive: true, force: true });
|
|
134
141
|
}
|
|
135
142
|
}
|
|
136
|
-
function readKeptSession(dir) {
|
|
143
|
+
function readKeptSession(dir, agents = defaultAgents()) {
|
|
137
144
|
let parsed;
|
|
138
145
|
try {
|
|
139
146
|
parsed = JSON.parse(readFileSync(join(dir, META_FILE), "utf8"));
|
|
@@ -141,8 +148,9 @@ function readKeptSession(dir) {
|
|
|
141
148
|
return void 0;
|
|
142
149
|
}
|
|
143
150
|
if (typeof parsed.sessionId !== "string" || !SESSION_ID.test(parsed.sessionId) || typeof parsed.claimId !== "string" || typeof parsed.queue !== "string" || typeof parsed.keptAt !== "string") return void 0;
|
|
144
|
-
|
|
151
|
+
let transcript;
|
|
145
152
|
try {
|
|
153
|
+
transcript = join(dir, sessionFilesOf(parsed.sessionId, agents).entries[0]);
|
|
146
154
|
if (!statSync(transcript).isFile()) return void 0;
|
|
147
155
|
} catch {
|
|
148
156
|
return void 0;
|
|
@@ -184,8 +192,8 @@ function filesUnder(root, relative2) {
|
|
|
184
192
|
}
|
|
185
193
|
return stat.isFile() ? [{ path: relative2, type: "0", size: stat.size, mtimeMs: stat.mtimeMs }] : [];
|
|
186
194
|
}
|
|
187
|
-
function packKeptSession(dir, meta) {
|
|
188
|
-
const names =
|
|
195
|
+
function packKeptSession(dir, meta, agents = defaultAgents()) {
|
|
196
|
+
const names = sessionFilesOf(meta.sessionId, agents).entries;
|
|
189
197
|
async function* pack() {
|
|
190
198
|
for (const name of names) {
|
|
191
199
|
let entries;
|
|
@@ -214,24 +222,24 @@ function packKeptSession(dir, meta) {
|
|
|
214
222
|
}
|
|
215
223
|
return Readable.from(pack());
|
|
216
224
|
}
|
|
217
|
-
function resumeDecision(input) {
|
|
225
|
+
function resumeDecision(input, agents = defaultAgents()) {
|
|
218
226
|
if (input.queue !== "amend") return void 0;
|
|
219
|
-
if (!input.builtin) return { resumed: false, reason: "build_type_cannot_resume" };
|
|
227
|
+
if (!input.builtin || jobAgent(void 0, agents)?.adapter.launch?.session === void 0) return { resumed: false, reason: "build_type_cannot_resume" };
|
|
220
228
|
if (input.kept === void 0) return { resumed: false, reason: "no_saved_session" };
|
|
221
229
|
return { resumed: true, fromSessionId: input.kept.sessionId, fromClaimId: input.kept.claimId };
|
|
222
230
|
}
|
|
223
|
-
async function prepareResume(input) {
|
|
231
|
+
async function prepareResume(input, agents = defaultAgents()) {
|
|
224
232
|
const sessionId = (input.newSessionId ?? randomUUID)();
|
|
225
233
|
const fresh = (resume) => ({ sessionId, resume, env: { [SESSION_ID_VARIABLE]: sessionId } });
|
|
226
234
|
if (input.queue !== "amend") return fresh(void 0);
|
|
227
235
|
const dir = keptSessionDir(input.configPath, input.organizationId, input.workItemId);
|
|
228
|
-
let kept = readKeptSession(dir);
|
|
236
|
+
let kept = readKeptSession(dir, agents);
|
|
229
237
|
if (kept !== void 0 && input.requireScrubNote === true && kept.meta.scrubbed !== true) {
|
|
230
238
|
rmSync(dir, { recursive: true, force: true });
|
|
231
239
|
input.log("the saved session was kept before the runner scrubbed sessions, so it is removed");
|
|
232
240
|
kept = void 0;
|
|
233
241
|
}
|
|
234
|
-
const decision = resumeDecision({ queue: input.queue, builtin: input.builtin, kept: kept?.meta });
|
|
242
|
+
const decision = resumeDecision({ queue: input.queue, builtin: input.builtin, kept: kept?.meta }, agents);
|
|
235
243
|
if (!decision.resumed) {
|
|
236
244
|
input.log(`agent job starts fresh because ${REASON_TEXT[decision.reason]}`);
|
|
237
245
|
return fresh(decision);
|
|
@@ -244,12 +252,12 @@ async function prepareResume(input) {
|
|
|
244
252
|
return fresh({ resumed: false, reason: "session_not_loaded" });
|
|
245
253
|
}
|
|
246
254
|
input.log(`agent job continues session ${meta.sessionId.slice(0, 8)} of claim ${shortClaim(meta.claimId)}`);
|
|
247
|
-
return { sessionId, resume: decision, env: { [SESSION_ID_VARIABLE]: sessionId, [RESUME_SESSION_VARIABLE]: `${RESUME_DIR}/${meta.sessionId}
|
|
255
|
+
return { sessionId, resume: decision, env: { [SESSION_ID_VARIABLE]: sessionId, [RESUME_SESSION_VARIABLE]: `${RESUME_DIR}/${sessionFilesOf(meta.sessionId, agents).entries[0]}` } };
|
|
248
256
|
}
|
|
249
|
-
var COPY_OUT_SCRIPT = 'cd "$1" 2>/dev/null && [ -f "$2
|
|
257
|
+
var COPY_OUT_SCRIPT = 'cd "$1" 2>/dev/null && [ -f "$2" ] || exit 3; shift; for entry in "$@"; do if [ -e "$entry" ]; then set -- "$@" "$entry"; fi; shift; done; exec tar -cf - "$@"';
|
|
250
258
|
var SESSION_COPY_MS = 15 * 6e4;
|
|
251
259
|
var MAX_SESSION_COPY_BYTES = 512 * 1024 * 1024;
|
|
252
|
-
async function copyOutSession(input) {
|
|
260
|
+
async function copyOutSession(input, agents = defaultAgents()) {
|
|
253
261
|
if (!SESSION_ID.test(input.sessionId)) return { ok: false, reason: `${JSON.stringify(input.sessionId)} is not a session id` };
|
|
254
262
|
let fd;
|
|
255
263
|
let stderr = "";
|
|
@@ -259,9 +267,10 @@ async function copyOutSession(input) {
|
|
|
259
267
|
const out = fd;
|
|
260
268
|
const maxBytes = input.maxBytes ?? MAX_SESSION_COPY_BYTES;
|
|
261
269
|
const stop = new AbortController();
|
|
270
|
+
const files = sessionFilesOf(input.sessionId, agents);
|
|
262
271
|
let written = 0;
|
|
263
272
|
let overCap = false;
|
|
264
|
-
const result = await input.guest.stream(["/bin/sh", "-c", COPY_OUT_SCRIPT, "sh",
|
|
273
|
+
const result = await input.guest.stream(["/bin/sh", "-c", COPY_OUT_SCRIPT, "sh", files.dir, ...files.entries], {
|
|
265
274
|
onStdout: (chunk) => {
|
|
266
275
|
if (overCap) return;
|
|
267
276
|
if (written + chunk.length > maxBytes) {
|
|
@@ -367,7 +376,7 @@ function managedClaudeKeyValuesFor(jobDir) {
|
|
|
367
376
|
return key === void 0 ? [] : [key];
|
|
368
377
|
}
|
|
369
378
|
function hasClaudeCredential(config, hostEnv, jobDir, agents) {
|
|
370
|
-
if (
|
|
379
|
+
if (jobAgent(void 0, agents)?.adapter.credentials === void 0) return true;
|
|
371
380
|
return config.managed === true ? managedClaudeKeyFor(jobDir) !== void 0 : agentCredential(hostEnv, {}, agents) !== void 0;
|
|
372
381
|
}
|
|
373
382
|
var PROXIED_SLOTS = 16;
|
|
@@ -903,7 +912,7 @@ function converterArgs(dest, memoryBytes, extra, script) {
|
|
|
903
912
|
script
|
|
904
913
|
];
|
|
905
914
|
}
|
|
906
|
-
var
|
|
915
|
+
var firstLine2 = (text2) => text2.trim().split("\n")[0] ?? "";
|
|
907
916
|
function exportInto(container, converter) {
|
|
908
917
|
return new Promise((resolve2, reject) => {
|
|
909
918
|
const exporter = spawn("docker", ["export", container], { stdio: ["ignore", "pipe", "pipe"], env: childEnvironment(process.env) });
|
|
@@ -923,7 +932,7 @@ function exportInto(container, converter) {
|
|
|
923
932
|
exits += 1;
|
|
924
933
|
if (exits < 2) return;
|
|
925
934
|
if (failure3 === void 0) resolve2();
|
|
926
|
-
else reject(new Error(`${failure3}: ${
|
|
935
|
+
else reject(new Error(`${failure3}: ${firstLine2(errors.join("\n"))}`));
|
|
927
936
|
};
|
|
928
937
|
exporter.once("exit", (code) => done("docker export", code));
|
|
929
938
|
writer.once("exit", (code) => done("the converter", code));
|
|
@@ -934,7 +943,7 @@ function createRootfsHost() {
|
|
|
934
943
|
return {
|
|
935
944
|
async convert({ imageId, dest, memoryBytes }) {
|
|
936
945
|
const created = await spawnRun("docker", ["create", imageId, "none"], { env: env() });
|
|
937
|
-
if (created.status !== 0) throw new Error(`docker create ${imageId} failed: ${
|
|
946
|
+
if (created.status !== 0) throw new Error(`docker create ${imageId} failed: ${firstLine2(created.stderr)}`);
|
|
938
947
|
const container = created.stdout.trim();
|
|
939
948
|
try {
|
|
940
949
|
await exportInto(container, converterArgs(dest, memoryBytes, [], converterScript()));
|
|
@@ -947,11 +956,11 @@ function createRootfsHost() {
|
|
|
947
956
|
truncateSync(dest, bytes);
|
|
948
957
|
const path = [process.env.PATH, "/usr/sbin", "/sbin"].filter((entry) => entry !== void 0 && entry !== "").join(":");
|
|
949
958
|
const made = await spawnRun("mke2fs", ["-q", "-F", "-t", "ext4", "-m", "0", "-E", "lazy_itable_init=1,lazy_journal_init=1,nodiscard", dest], { env: { ...env(), PATH: path } });
|
|
950
|
-
if (made.status !== 0) throw new Error(`making the empty build disk failed: ${
|
|
959
|
+
if (made.status !== 0) throw new Error(`making the empty build disk failed: ${firstLine2(made.stderr)}`);
|
|
951
960
|
},
|
|
952
961
|
async imageConfig(imageId) {
|
|
953
962
|
const inspected = await spawnRun("docker", ["image", "inspect", "--format", "{{json .Config}}", imageId], { env: env() });
|
|
954
|
-
if (inspected.status !== 0) throw new Error(`docker image inspect ${imageId} failed: ${
|
|
963
|
+
if (inspected.status !== 0) throw new Error(`docker image inspect ${imageId} failed: ${firstLine2(inspected.stderr)}`);
|
|
955
964
|
return parseImageConfig(inspected.stdout);
|
|
956
965
|
}
|
|
957
966
|
};
|
|
@@ -1005,7 +1014,7 @@ async function createBuildDisk(input) {
|
|
|
1005
1014
|
if (input.host.copyTemplate) input.host.copyTemplate(template, input.dest);
|
|
1006
1015
|
else {
|
|
1007
1016
|
const copied = spawnSync("cp", ["--sparse=always", template, input.dest], { encoding: "utf8" });
|
|
1008
|
-
if (copied.status !== 0) throw new Error(`copying the empty build disk failed: ${
|
|
1017
|
+
if (copied.status !== 0) throw new Error(`copying the empty build disk failed: ${firstLine2(copied.stderr)}`);
|
|
1009
1018
|
}
|
|
1010
1019
|
}
|
|
1011
1020
|
chmodSync(input.dest, RUNNER_FILE_MODE);
|
|
@@ -1835,9 +1844,9 @@ function handedCredential(value, agents) {
|
|
|
1835
1844
|
if (typeof value !== "string") throw new RunnerInitError(`the config on stdin carries a ${key} that is not text.`);
|
|
1836
1845
|
return credentialFromStdin(value, agents);
|
|
1837
1846
|
}
|
|
1838
|
-
function handedAgent(value) {
|
|
1847
|
+
function handedAgent(value, agents) {
|
|
1839
1848
|
if (value === void 0) return void 0;
|
|
1840
|
-
if (!isAgentName(value)) throw new RunnerInitError("the config on stdin names an agent runner init does not know.");
|
|
1849
|
+
if (!isAgentName(value, agents)) throw new RunnerInitError("the config on stdin names an agent runner init does not know.");
|
|
1841
1850
|
return value;
|
|
1842
1851
|
}
|
|
1843
1852
|
function parseStdinConfig(configPath, text2, agents) {
|
|
@@ -1857,7 +1866,7 @@ function parseStdinConfig(configPath, text2, agents) {
|
|
|
1857
1866
|
const carried = config.runner;
|
|
1858
1867
|
const key = credentialHandOffKey(agents);
|
|
1859
1868
|
const credential = handedCredential(config[key], agents);
|
|
1860
|
-
const agent = handedAgent(config.agent);
|
|
1869
|
+
const agent = handedAgent(config.agent, agents);
|
|
1861
1870
|
delete config.runner;
|
|
1862
1871
|
delete config[key];
|
|
1863
1872
|
delete config.agent;
|
|
@@ -1926,7 +1935,7 @@ function writeRunnerInit(prepared, runnerKey) {
|
|
|
1926
1935
|
...carried,
|
|
1927
1936
|
...host === void 0 ? {} : { name: host },
|
|
1928
1937
|
// The agent was named on this command line, so its commands win over any the hand-off carried.
|
|
1929
|
-
...agent === void 0 ? {} : { commands: { ...
|
|
1938
|
+
...agent === void 0 ? {} : { commands: { ...agentCommands(agent, agents) } },
|
|
1930
1939
|
hooks: { provision: hooks, cleanup: hooks }
|
|
1931
1940
|
};
|
|
1932
1941
|
if (host !== void 0) delete config.runner.host;
|
|
@@ -1948,24 +1957,35 @@ function placeholderProblem(queues) {
|
|
|
1948
1957
|
const keys = queues.map((queue) => `runner.commands.${queue}`).join(", ");
|
|
1949
1958
|
return `${keys} ${queues.length === 1 ? "is" : "are"} still the placeholder \`runner init\` wrote, which fails every item. Edit ${queues.length === 1 ? "it" : "them"} to start your agent on item $OUTERLAYER_WORK`;
|
|
1950
1959
|
}
|
|
1951
|
-
var
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1960
|
+
var escapeForPattern = (text2) => text2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1961
|
+
function programPattern(program) {
|
|
1962
|
+
return new RegExp(`(?:^|[;&|(])\\s*(?:(?:exec|env|nohup|time)\\s+)*(?:[A-Za-z_][A-Za-z0-9_]*=\\S*\\s+)*(?:\\S*\\/)?${escapeForPattern(program)}\\s`);
|
|
1963
|
+
}
|
|
1964
|
+
function permissionFlagPattern(flag) {
|
|
1965
|
+
return new RegExp(`${escapeForPattern(flag)}(?:=|\\s+)(?:"([^"]*)"|'([^']*)'|([^\\s;&|()]+))`, "g");
|
|
1966
|
+
}
|
|
1967
|
+
function permissionModeProblems(config, agents = defaultAgents()) {
|
|
1968
|
+
const agent = jobAgent(void 0, agents);
|
|
1969
|
+
const mode = agent?.adapter.headless?.permissionMode;
|
|
1970
|
+
if (agent === void 0 || mode === void 0) return [];
|
|
1971
|
+
const program = programPattern(agent.descriptor.program);
|
|
1955
1972
|
const problems = [];
|
|
1956
1973
|
for (const queue of config.queues) {
|
|
1957
1974
|
const command = config.commands[queue];
|
|
1958
|
-
if (command === void 0 || !
|
|
1959
|
-
for (const match of command.matchAll(
|
|
1975
|
+
if (command === void 0 || !program.test(command)) continue;
|
|
1976
|
+
for (const match of command.matchAll(permissionFlagPattern(mode.flag))) {
|
|
1960
1977
|
const value = match[1] ?? match[2] ?? match[3] ?? "";
|
|
1961
|
-
if (value.includes("$") || value.includes("`") ||
|
|
1978
|
+
if (value.includes("$") || value.includes("`") || mode.accepted.includes(value)) continue;
|
|
1962
1979
|
problems.push({ queue, command, value });
|
|
1963
1980
|
}
|
|
1964
1981
|
}
|
|
1965
1982
|
return problems;
|
|
1966
1983
|
}
|
|
1967
|
-
function permissionModeProblem(problems) {
|
|
1968
|
-
|
|
1984
|
+
function permissionModeProblem(problems, agents = defaultAgents()) {
|
|
1985
|
+
const agent = jobAgent(void 0, agents);
|
|
1986
|
+
const label = agent?.descriptor.label ?? "the agent";
|
|
1987
|
+
const accepted = agent?.adapter.headless?.permissionMode?.accepted ?? [];
|
|
1988
|
+
return problems.map(({ queue, command, value }) => `runner.commands.${queue} is \`${command}\`, and \`${value}\` is not a permission mode ${label} accepts (${accepted.join(", ")}). The command would fail only when a build ran it`).join(". ");
|
|
1969
1989
|
}
|
|
1970
1990
|
var FORMER_AMEND_COMMAND = /(^|["'\s])\/amend(?=["'\s]|$)/g;
|
|
1971
1991
|
function currentSkillCommand(command) {
|
|
@@ -2053,27 +2073,39 @@ async function claimPermissionProblem(config, fetchImpl = fetch) {
|
|
|
2053
2073
|
}
|
|
2054
2074
|
|
|
2055
2075
|
// src/runner/build-skill-check.ts
|
|
2056
|
-
var
|
|
2057
|
-
|
|
2076
|
+
var SHARED_SKILLS = ".agents/skills";
|
|
2077
|
+
function buildSkillPaths(agents = defaultAgents()) {
|
|
2078
|
+
const folders = jobAgent(void 0, agents)?.descriptor.context.repoSkillFolders ?? [];
|
|
2079
|
+
return [SHARED_SKILLS, ...folders].map((folder) => `${folder}/build/SKILL.md`);
|
|
2080
|
+
}
|
|
2081
|
+
buildSkillPaths();
|
|
2082
|
+
var escapeForPattern2 = (text2) => text2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2083
|
+
function buildCommandPattern(agents) {
|
|
2084
|
+
const agent = jobAgent(void 0, agents);
|
|
2085
|
+
if (agent === void 0) return new RegExp(`(?:^|["'])\\/build(?=["'\\s]|$)`);
|
|
2086
|
+
const words = [agent.descriptor.program, ...agent.adapter.headless?.promptFlags ?? []];
|
|
2087
|
+
return new RegExp(`(?:^|["']|(?:^|\\s)(?:${words.map(escapeForPattern2).join("|")})\\s+)\\/build(?=["'\\s]|$)`);
|
|
2088
|
+
}
|
|
2058
2089
|
var BUILD_DIRECTORY_USE = /(?:^|[\s;&|])(?:cd|pushd|--add-dir|--cwd|-C)\s+["']?\/build(?=["'\s;&|]|$)/g;
|
|
2059
|
-
function needsBuildSkill(queue, command) {
|
|
2090
|
+
function needsBuildSkill(queue, command, agents = defaultAgents()) {
|
|
2060
2091
|
if (queue !== "implement" || command === void 0) return false;
|
|
2061
|
-
return
|
|
2092
|
+
return buildCommandPattern(agents).test(currentSkillCommand(command).replace(BUILD_DIRECTORY_USE, " "));
|
|
2062
2093
|
}
|
|
2063
|
-
function missingBuildSkillReason(governed, lookupFailure) {
|
|
2064
|
-
const
|
|
2094
|
+
function missingBuildSkillReason(governed, lookupFailure, agents = defaultAgents()) {
|
|
2095
|
+
const paths = buildSkillPaths(agents);
|
|
2096
|
+
const checked = governed === void 0 ? paths.join(" and ") : `${paths.join(", ")} and the governed context from ${governed.repository}@${governed.commit.slice(0, 7)}`;
|
|
2065
2097
|
const lookup3 = lookupFailure === void 0 ? "" : `, and the lookup of the governing repository failed (${lookupFailure})`;
|
|
2066
2098
|
return `the build has no \`build\` skill, so /build would load nothing${lookup3}: checked ${checked}`;
|
|
2067
2099
|
}
|
|
2068
|
-
function cloneHasBuildSkill(checkout) {
|
|
2069
|
-
return
|
|
2100
|
+
function cloneHasBuildSkill(checkout, agents = defaultAgents()) {
|
|
2101
|
+
return buildSkillPaths(agents).some((path) => existsSync(join(checkout, path)));
|
|
2070
2102
|
}
|
|
2071
|
-
async function decideHostBuildSkill(input) {
|
|
2103
|
+
async function decideHostBuildSkill(input, agents = defaultAgents()) {
|
|
2072
2104
|
const { requireBuildSkill, containerMode, vmMode, workdir, repository } = input;
|
|
2073
|
-
if (!requireBuildSkill || containerMode || vmMode || !existsSync(join(workdir, ".git")) || cloneHasBuildSkill(workdir)) return { kind: "start" };
|
|
2105
|
+
if (!requireBuildSkill || containerMode || vmMode || !existsSync(join(workdir, ".git")) || cloneHasBuildSkill(workdir, agents)) return { kind: "start" };
|
|
2074
2106
|
const governing = repository === void 0 ? void 0 : await input.lookup(repository);
|
|
2075
2107
|
if (governing?.ok === true && governing.source.kind !== "self") return { kind: "warn" };
|
|
2076
|
-
const reason = missingBuildSkillReason(void 0, governing?.ok === false ? governing.reason : void 0);
|
|
2108
|
+
const reason = missingBuildSkillReason(void 0, governing?.ok === false ? governing.reason : void 0, agents);
|
|
2077
2109
|
return { kind: "refuse", reason };
|
|
2078
2110
|
}
|
|
2079
2111
|
var BranchPrepareError = class extends Error {
|
|
@@ -2097,13 +2129,13 @@ function localGit(cwd, args) {
|
|
|
2097
2129
|
}
|
|
2098
2130
|
return Promise.resolve({ status: result.status, stdout: result.stdout.trim(), stderr: result.stderr.trim() });
|
|
2099
2131
|
}
|
|
2100
|
-
function
|
|
2132
|
+
function firstLine3(stderr) {
|
|
2101
2133
|
return (stderr.split("\n")[0] ?? "").replace(/\/\/[^/@\s]+@/g, "//");
|
|
2102
2134
|
}
|
|
2103
2135
|
async function mustGit(git2, cwd, step, args) {
|
|
2104
2136
|
const result = await git2(cwd, args);
|
|
2105
2137
|
if (result.status !== 0) {
|
|
2106
|
-
const detail =
|
|
2138
|
+
const detail = firstLine3(result.stderr);
|
|
2107
2139
|
throw new BranchPrepareError(`${step} failed${detail === "" ? "" : `: ${detail}`}`);
|
|
2108
2140
|
}
|
|
2109
2141
|
return result.stdout;
|
|
@@ -2148,7 +2180,7 @@ async function isMerged(git2, workdir, branch, defaultBranch) {
|
|
|
2148
2180
|
const result = await git2(workdir, ["merge-base", "--is-ancestor", `origin/${branch}`, `origin/${defaultBranch}`]);
|
|
2149
2181
|
if (result.status === 0) return true;
|
|
2150
2182
|
if (result.status === 1) return false;
|
|
2151
|
-
const detail =
|
|
2183
|
+
const detail = firstLine3(result.stderr);
|
|
2152
2184
|
throw new BranchPrepareError(`comparing ${branch} with ${defaultBranch} failed${detail === "" ? "" : `: ${detail}`}`);
|
|
2153
2185
|
}
|
|
2154
2186
|
|
|
@@ -2182,15 +2214,6 @@ function lifecycleFailureReason(step, exitCode) {
|
|
|
2182
2214
|
return `lifecycle command ${step.name} (${step.source}) exited ${exitCode}`;
|
|
2183
2215
|
}
|
|
2184
2216
|
|
|
2185
|
-
// src/runner/command-output.ts
|
|
2186
|
-
function firstLine3(text2) {
|
|
2187
|
-
return text2.trim().split("\n")[0] ?? "";
|
|
2188
|
-
}
|
|
2189
|
-
function said(output) {
|
|
2190
|
-
const line2 = firstLine3(output);
|
|
2191
|
-
return line2 === "" ? "" : `: ${line2}`;
|
|
2192
|
-
}
|
|
2193
|
-
|
|
2194
2217
|
// src/runner/runtimes.ts
|
|
2195
2218
|
var RUNTIMES = ["node", "python", "go", "rust", "ruby", "java"];
|
|
2196
2219
|
var MANIFESTS = {
|
|
@@ -2278,7 +2301,7 @@ var goToolchain = async (context) => {
|
|
|
2278
2301
|
const ran = await context.input.exec(["go", "version"], context.path);
|
|
2279
2302
|
if (ran.status !== 0) return `runtime_install_failed: go version failed in ${context.entry.repository} (exit ${ran.status})${said(ran.stderr)}${refusalNote(context)}`;
|
|
2280
2303
|
const version = /\bgo(\d+\.\d+(?:\.\d+)?\S*)/.exec(ran.stdout)?.[1];
|
|
2281
|
-
line(context, `go ${version ??
|
|
2304
|
+
line(context, `go ${version ?? firstLine(ran.stdout)} from go.mod`);
|
|
2282
2305
|
return void 0;
|
|
2283
2306
|
};
|
|
2284
2307
|
var rustToolchain = async (context) => {
|
|
@@ -2287,7 +2310,7 @@ var rustToolchain = async (context) => {
|
|
|
2287
2310
|
const ran = await context.input.exec(["rustc", "--version"], context.path);
|
|
2288
2311
|
if (ran.status !== 0) return `runtime_install_failed: rustc --version failed in ${context.entry.repository} (exit ${ran.status})${said(ran.stderr)}${refusalNote(context)}`;
|
|
2289
2312
|
const version = /\brustc (\S+)/.exec(ran.stdout)?.[1];
|
|
2290
|
-
line(context, `rust ${version ??
|
|
2313
|
+
line(context, `rust ${version ?? firstLine(ran.stdout)} from ${pin}`);
|
|
2291
2314
|
return void 0;
|
|
2292
2315
|
};
|
|
2293
2316
|
function parseVariables(stdout) {
|
|
@@ -2511,18 +2534,23 @@ function gitErrorLine(text2) {
|
|
|
2511
2534
|
return lines.find((line2) => /^(fatal|error):/.test(line2)) ?? lines.at(-1) ?? "";
|
|
2512
2535
|
}
|
|
2513
2536
|
var STAGED_TREE = `${JOB_MOUNT}/context/tree`;
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
"
|
|
2522
|
-
|
|
2523
|
-
|
|
2537
|
+
function deliverScript(entries) {
|
|
2538
|
+
return [
|
|
2539
|
+
"set -e",
|
|
2540
|
+
'src="$1"; dest="$2"',
|
|
2541
|
+
'if [ -e "$dest" ]; then chmod -R u+w "$dest"; rm -rf "$dest"; fi',
|
|
2542
|
+
'mkdir -p "$dest"',
|
|
2543
|
+
`for entry in ${entries.join(" ")}; do`,
|
|
2544
|
+
' if [ -e "$src/$entry" ]; then cp -R "$src/$entry" "$dest/"; fi',
|
|
2545
|
+
"done",
|
|
2546
|
+
'chmod -R a-w "$dest"'
|
|
2547
|
+
].join("\n");
|
|
2548
|
+
}
|
|
2549
|
+
var SHELL_SAFE_NAME = /^[A-Za-z0-9._-]+$/;
|
|
2524
2550
|
var RECORD_SCRIPT = 'd="$(git rev-parse --git-common-dir)" && mkdir -p "$d/outerlayer" && printf "%s" "$1" > "$d/outerlayer/delivery.json"';
|
|
2525
|
-
|
|
2551
|
+
function writeShimScript(program) {
|
|
2552
|
+
return `mkdir -p "$1" && printf "%s" "$2" > "$1/${program}" && chmod 755 "$1/${program}"`;
|
|
2553
|
+
}
|
|
2526
2554
|
function failure(what, result) {
|
|
2527
2555
|
return `context_delivery_failed: ${what} (exit ${result.status})${said(result.stderr)}`;
|
|
2528
2556
|
}
|
|
@@ -2531,38 +2559,48 @@ async function repositorySkills(input, folder) {
|
|
|
2531
2559
|
if (listed.status !== 0) return /* @__PURE__ */ new Set();
|
|
2532
2560
|
return new Set(listed.stdout.split("\n").map((name) => name.trim()));
|
|
2533
2561
|
}
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2562
|
+
function agentOf(input) {
|
|
2563
|
+
return jobAgent(void 0, input.agents ?? defaultAgents());
|
|
2564
|
+
}
|
|
2565
|
+
async function deliveryRefusal(input, staged, agent) {
|
|
2566
|
+
const { label, versions } = agent.descriptor;
|
|
2567
|
+
if (input.agentVersion !== void 0 && !versionAtLeast(input.agentVersion, versions.minimum)) {
|
|
2568
|
+
return `context_agent_too_old: the build image's ${label} is ${input.agentVersion}, and a governed build needs ${versions.minimum} or later to load its control plane's instructions; rebuild the image`;
|
|
2537
2569
|
}
|
|
2538
|
-
const own = /* @__PURE__ */ new Map(
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
]);
|
|
2542
|
-
const clash = sharedSkillNames(join(staged.dir, "tree")).find((name) => [...own.values()].some((names) => names.has(name)));
|
|
2570
|
+
const own = /* @__PURE__ */ new Map();
|
|
2571
|
+
for (const folder2 of [...agent.descriptor.context.repoSkillFolders, ".agents/skills"]) own.set(folder2, await repositorySkills(input, folder2));
|
|
2572
|
+
const clash = sharedSkillNames(join(staged.dir, "tree"), input.agents).find((name) => [...own.values()].some((names) => names.has(name)));
|
|
2543
2573
|
if (clash === void 0) return void 0;
|
|
2544
|
-
const folder = own.
|
|
2574
|
+
const folder = [...own.keys()].find((candidate) => own.get(candidate).has(clash));
|
|
2545
2575
|
return `context_skill_conflict: ${skillConflictMessage({ skill: clash, folder, repository: input.repository, controlPlane: staged.repository })}, and would replace it in this build; rename or remove it from the repository`;
|
|
2546
2576
|
}
|
|
2547
2577
|
async function checkoutHasBuildSkill(input) {
|
|
2548
|
-
for (const path of
|
|
2578
|
+
for (const path of buildSkillPaths(input.agents)) {
|
|
2549
2579
|
const probe = await input.exec(["test", "-f", path], CHECKOUT_DIR, { quiet: true });
|
|
2550
2580
|
if (probe.status === 0) return true;
|
|
2551
2581
|
if (probe.status !== 1) return { failed: failure(`checking for ${path} failed`, probe) };
|
|
2552
2582
|
}
|
|
2553
2583
|
return false;
|
|
2554
2584
|
}
|
|
2555
|
-
function stagedHasBuildSkill(staged) {
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2585
|
+
function stagedHasBuildSkill(staged, input) {
|
|
2586
|
+
const agent = agentOf(input);
|
|
2587
|
+
const tree = join(staged.dir, "tree");
|
|
2588
|
+
if (agent?.adapter.context?.deliveredSkills(tree).includes("build") !== true) return false;
|
|
2589
|
+
return agent.descriptor.context.repoSkillFolders.some((folder) => existsSync(join(tree, folder, "build", "SKILL.md")));
|
|
2590
|
+
}
|
|
2591
|
+
var NO_AGENT = "context_delivery_failed: the agent list holds no agent to run the build";
|
|
2592
|
+
async function writeShim(input, agent) {
|
|
2593
|
+
const program = agent.descriptor.program;
|
|
2594
|
+
if (!SHELL_SAFE_NAME.test(program)) return { ok: false, reason: `context_delivery_failed: the agent's program name ${JSON.stringify(program)} cannot name a shim` };
|
|
2595
|
+
const shim = await input.exec(["sh", "-c", writeShimScript(program), "shim", SHIM_DIR, shimScript()], "/build/work");
|
|
2596
|
+
if (shim.status !== 0) return { ok: false, reason: failure(`writing the ${program} shim failed`, shim) };
|
|
2561
2597
|
return { ok: true };
|
|
2562
2598
|
}
|
|
2563
|
-
async function deliver(input, staged) {
|
|
2599
|
+
async function deliver(input, staged, entries) {
|
|
2564
2600
|
const dir = deliveryDir(staged.repository, staged.sha);
|
|
2565
|
-
const
|
|
2601
|
+
const unsafe = entries.find((name) => !SHELL_SAFE_NAME.test(name));
|
|
2602
|
+
if (unsafe !== void 0) return { ok: false, reason: `context_delivery_failed: the agent's entry name ${JSON.stringify(unsafe)} cannot be copied` };
|
|
2603
|
+
const copied = await input.exec(["sh", "-c", deliverScript(entries), "deliver", STAGED_TREE, dir], "/build/work");
|
|
2566
2604
|
if (copied.status !== 0) return { ok: false, reason: failure("copying the control plane into the build failed", copied) };
|
|
2567
2605
|
const record = JSON.stringify({ schemaVersion: 1, repository: staged.repository, ref: staged.ref, sha: staged.sha, dir });
|
|
2568
2606
|
const recorded = await input.exec(["sh", "-c", RECORD_SCRIPT, "record", record], CHECKOUT_DIR);
|
|
@@ -2708,26 +2746,33 @@ async function runBuildSteps(input) {
|
|
|
2708
2746
|
const staged = await input.stageContext();
|
|
2709
2747
|
if (staged.kind === "refused") return { ok: false, reason: staged.reason };
|
|
2710
2748
|
let controlPlane;
|
|
2711
|
-
if (input.requireBuildSkill === true && !(staged.kind === "staged" && stagedHasBuildSkill(staged))) {
|
|
2749
|
+
if (input.requireBuildSkill === true && !(staged.kind === "staged" && stagedHasBuildSkill(staged, input))) {
|
|
2712
2750
|
const held3 = await checkoutHasBuildSkill(input);
|
|
2713
2751
|
if (held3 !== true) {
|
|
2714
2752
|
if (staged.kind === "staged") input.removeStagedContext();
|
|
2715
2753
|
if (held3 !== false) return { ok: false, reason: held3.failed };
|
|
2716
|
-
return { ok: false, reason: missingBuildSkillReason(staged.kind === "staged" ? { repository: staged.repository, commit: staged.sha } : void 0) };
|
|
2754
|
+
return { ok: false, reason: missingBuildSkillReason(staged.kind === "staged" ? { repository: staged.repository, commit: staged.sha } : void 0, void 0, input.agents) };
|
|
2717
2755
|
}
|
|
2718
2756
|
}
|
|
2719
|
-
const
|
|
2757
|
+
const agent = agentOf(input);
|
|
2758
|
+
if (agent === void 0) {
|
|
2759
|
+
if (staged.kind === "staged") input.removeStagedContext();
|
|
2760
|
+
return { ok: false, reason: NO_AGENT };
|
|
2761
|
+
}
|
|
2762
|
+
const shimmed = await writeShim(input, agent);
|
|
2720
2763
|
if (!shimmed.ok) {
|
|
2721
2764
|
if (staged.kind === "staged") input.removeStagedContext();
|
|
2722
2765
|
return shimmed;
|
|
2723
2766
|
}
|
|
2724
2767
|
if (staged.kind === "staged") {
|
|
2725
2768
|
try {
|
|
2726
|
-
const
|
|
2769
|
+
const context = agent.adapter.context;
|
|
2770
|
+
if (context === void 0) return { ok: false, reason: `context_delivery_failed: ${agent.descriptor.label} has no context part, so it cannot receive a control plane` };
|
|
2771
|
+
const refusal = await deliveryRefusal(input, staged, agent);
|
|
2727
2772
|
if (refusal !== void 0) return { ok: false, reason: refusal };
|
|
2728
2773
|
const handed = await input.deliverContext?.(staged) ?? { ok: true };
|
|
2729
2774
|
if (!handed.ok) return { ok: false, reason: handed.reason };
|
|
2730
|
-
const delivered = await deliver(input, staged);
|
|
2775
|
+
const delivered = await deliver(input, staged, context.deliveredEntries);
|
|
2731
2776
|
if (!delivered.ok) return delivered;
|
|
2732
2777
|
controlPlane = { repository: staged.repository, commit: staged.sha };
|
|
2733
2778
|
try {
|
|
@@ -2996,10 +3041,11 @@ var DISK_REASON_TEXT = {
|
|
|
2996
3041
|
other_disk_size: "the kept disk was made with another runner.build.disk size",
|
|
2997
3042
|
disk_not_restored: "the kept disk could not be copied",
|
|
2998
3043
|
checkout_not_switched: "the kept checkout could not be switched to the branch",
|
|
2999
|
-
build_type_cannot_restore: "this build type cannot restore a disk"
|
|
3044
|
+
build_type_cannot_restore: "this build type cannot restore a disk",
|
|
3045
|
+
fresh_requested: "a member asked for a fresh disk"
|
|
3000
3046
|
};
|
|
3001
3047
|
function itemDiskDecision(input) {
|
|
3002
|
-
if (input.
|
|
3048
|
+
if (input.fresh === true) return { state: { restored: false, reason: "fresh_requested" } };
|
|
3003
3049
|
if (!input.builtin) return { state: { restored: false, reason: "build_type_cannot_restore" } };
|
|
3004
3050
|
let kept;
|
|
3005
3051
|
try {
|
|
@@ -3008,6 +3054,7 @@ function itemDiskDecision(input) {
|
|
|
3008
3054
|
kept = void 0;
|
|
3009
3055
|
}
|
|
3010
3056
|
if (kept === void 0) return { state: { restored: false, reason: "no_kept_disk" } };
|
|
3057
|
+
if (kept.record.repository !== input.repository) return { state: { restored: false, reason: "no_kept_disk" } };
|
|
3011
3058
|
if (kept.record.imageId !== input.imageId) return { state: { restored: false, reason: "other_image" } };
|
|
3012
3059
|
if (kept.record.diskBytes !== input.diskBytes) return { state: { restored: false, reason: "other_disk_size" } };
|
|
3013
3060
|
if (kept.record.kind !== input.backend) return { state: { restored: false, reason: "disk_not_restored" } };
|
|
@@ -3261,27 +3308,29 @@ async function saveMicroVmDiskState(input) {
|
|
|
3261
3308
|
}
|
|
3262
3309
|
}
|
|
3263
3310
|
var EVAL_INPUT_NAME = "eval-input";
|
|
3264
|
-
|
|
3311
|
+
sessionFolderIn(BUILD_HOME, legacyAgent().descriptor);
|
|
3265
3312
|
var MAX_TRANSCRIPT_BYTES = 7 * 1024 * 1024;
|
|
3266
3313
|
var MAX_TRANSCRIPTS = 500;
|
|
3267
3314
|
var MAX_TOTAL_TRANSCRIPT_BYTES = 64 * 1024 * 1024;
|
|
3268
3315
|
var TRANSCRIPT_COPY_MS = 2 * 60 * 1e3;
|
|
3269
|
-
var BUILD_HOME2 = "/build/home";
|
|
3270
3316
|
function firstLine4(text2) {
|
|
3271
3317
|
return text2.trim().split("\n")[0] ?? "";
|
|
3272
3318
|
}
|
|
3273
|
-
async function copyTranscripts(run, now = Date.now) {
|
|
3319
|
+
async function copyTranscripts(run, now = Date.now, agents = defaultAgents()) {
|
|
3320
|
+
const agent = jobAgent(void 0, agents);
|
|
3321
|
+
if (agent === void 0) return { ok: true, copied: [], missed: [] };
|
|
3322
|
+
const root = sessionFolderIn(BUILD_HOME, agent.descriptor);
|
|
3274
3323
|
const deadline = now() + TRANSCRIPT_COPY_MS;
|
|
3275
3324
|
let listed;
|
|
3276
3325
|
try {
|
|
3277
|
-
listed = await run(["find",
|
|
3326
|
+
listed = await run(["find", root, "-type", "f", "-name", "*.jsonl", "-print0"]);
|
|
3278
3327
|
} catch (err) {
|
|
3279
3328
|
return { ok: false, reason: describeCallFailure(err) };
|
|
3280
3329
|
}
|
|
3281
3330
|
if (listed.status !== 0 && !/No such file or directory/.test(listed.stderr)) {
|
|
3282
3331
|
return { ok: false, reason: `listing the transcripts failed (exit ${listed.status})${firstLine4(listed.stderr) === "" ? "" : `: ${firstLine4(listed.stderr)}`}` };
|
|
3283
3332
|
}
|
|
3284
|
-
const paths = listed.stdout.split("\0").filter((entry) => entry.startsWith(`${
|
|
3333
|
+
const paths = listed.stdout.split("\0").filter((entry) => entry.startsWith(`${root}/`) && !entry.includes("\n") && !entry.slice(root.length + 1).split("/").includes("..")).map((entry) => entry.slice(root.length + 1)).sort();
|
|
3285
3334
|
const copied = [];
|
|
3286
3335
|
const missed = [];
|
|
3287
3336
|
let total = 0;
|
|
@@ -3295,7 +3344,7 @@ async function copyTranscripts(run, now = Date.now) {
|
|
|
3295
3344
|
continue;
|
|
3296
3345
|
}
|
|
3297
3346
|
try {
|
|
3298
|
-
const read = await run(["head", "-c", String(MAX_TRANSCRIPT_BYTES + 1), `${
|
|
3347
|
+
const read = await run(["head", "-c", String(MAX_TRANSCRIPT_BYTES + 1), `${root}/${path}`]);
|
|
3299
3348
|
if (read.status !== 0) missed.push({ path, reason: `reading it failed (exit ${read.status})${firstLine4(read.stderr) === "" ? "" : `: ${firstLine4(read.stderr)}`}` });
|
|
3300
3349
|
else if (Buffer.byteLength(read.stdout) > MAX_TRANSCRIPT_BYTES) missed.push({ path, reason: `it is larger than ${MAX_TRANSCRIPT_BYTES / (1024 * 1024)} MiB` });
|
|
3301
3350
|
else if (total + Buffer.byteLength(read.stdout) > MAX_TOTAL_TRANSCRIPT_BYTES) missed.push({ path, reason: `copying it would take the transcripts past ${MAX_TOTAL_TRANSCRIPT_BYTES / (1024 * 1024)} MiB` });
|
|
@@ -3333,7 +3382,7 @@ function forkRecordOf(job) {
|
|
|
3333
3382
|
}
|
|
3334
3383
|
function scrubbing(scrub, author, work) {
|
|
3335
3384
|
setCustomScrubbers(scrub, () => void 0);
|
|
3336
|
-
setLocalIdentity({ home:
|
|
3385
|
+
setLocalIdentity({ home: BUILD_HOME, ...author?.name === void 0 ? {} : { name: author.name }, ...author?.email === void 0 ? {} : { email: author.email } });
|
|
3337
3386
|
setRepoRoot(CHECKOUT_DIR);
|
|
3338
3387
|
try {
|
|
3339
3388
|
return work();
|
|
@@ -3740,7 +3789,7 @@ async function writeGuestGhConfig(runtime, state, token) {
|
|
|
3740
3789
|
`mv ${GUEST_GH_DIR}/config.yml.partial ${GUEST_GH_DIR}/config.yml`
|
|
3741
3790
|
].join("\n");
|
|
3742
3791
|
const result = await asRoot(runtime, state, ["/bin/sh", "-c", script], ghHostsYml(token));
|
|
3743
|
-
if (result.status !== 0) throw new Error(`writing gh's configuration in the guest failed (exit ${result.status}): ${
|
|
3792
|
+
if (result.status !== 0) throw new Error(`writing gh's configuration in the guest failed (exit ${result.status}): ${firstLine(result.stderr)}`);
|
|
3744
3793
|
}
|
|
3745
3794
|
async function mountGuestHome(runtime, state, agentUser, known) {
|
|
3746
3795
|
let home = known;
|
|
@@ -3765,7 +3814,7 @@ var NO_FOLDER = 3;
|
|
|
3765
3814
|
async function unpackIntoGuest(runtime, state, dir, target2, opts = {}) {
|
|
3766
3815
|
const script = opts.readOnly === true ? `set -e; rm -rf ${target2}; mkdir -p ${target2}; tar -x --no-same-owner -C ${target2}; chmod -R a+rX,a-w ${target2}` : `set -e; mkdir -p ${target2}; tar -x --no-same-owner -C ${target2}; chmod -R a+rX ${target2}`;
|
|
3767
3816
|
const result = await asRoot(runtime, state, ["/bin/sh", "-c", script], tarOf(dir));
|
|
3768
|
-
if (result.status !== 0) throw new Error(`unpacking into ${target2} in the guest failed (exit ${result.status}): ${
|
|
3817
|
+
if (result.status !== 0) throw new Error(`unpacking into ${target2} in the guest failed (exit ${result.status}): ${firstLine(result.stderr)}`);
|
|
3769
3818
|
}
|
|
3770
3819
|
async function deliverCommitHooks(input) {
|
|
3771
3820
|
await unpackIntoGuest(input.runtime, input.state, input.hooksDir, GUEST_HOOKS_DIR);
|
|
@@ -3897,9 +3946,9 @@ async function provisionMicroVmOnce(input, allowRestore, itemDiskFailed) {
|
|
|
3897
3946
|
if (!obtained.ok) return obtained.aborted === true ? { ok: false, reason: obtained.reason, aborted: true } : fail(obtained.reason);
|
|
3898
3947
|
const { report } = obtained.built;
|
|
3899
3948
|
const tagged = taggedLog(log, tag);
|
|
3900
|
-
const itemDisk = input.workItemId === void 0 ? { state: void 0 } : itemDiskFailed !== void 0 ? { state: { restored: false, reason: itemDiskFailed } } : itemDiskDecision({
|
|
3949
|
+
const itemDisk = input.workItemId === void 0 ? { state: void 0 } : itemDiskFailed !== void 0 ? { state: { restored: false, reason: itemDiskFailed } } : itemDiskDecision({ fresh: input.fresh, builtin: true, backend: "disk", configPath: config.configPath, organizationId: input.organizationId, workItemId: input.workItemId, repository, imageId: report.imageId, diskBytes: limits2.diskBytes });
|
|
3901
3950
|
const keptDisk = itemDisk.kept;
|
|
3902
|
-
if (itemDisk.state?.restored === false) tagged(`this
|
|
3951
|
+
if (itemDisk.state?.restored === false) tagged(`this job starts without a kept disk: ${DISK_REASON_TEXT[itemDisk.state.reason]}`);
|
|
3903
3952
|
const plan = keptDisk !== void 0 ? keptDiskPlan() : await planSavedState({
|
|
3904
3953
|
config,
|
|
3905
3954
|
repositories,
|
|
@@ -4179,9 +4228,8 @@ async function provisionMicroVmOnce(input, allowRestore, itemDiskFailed) {
|
|
|
4179
4228
|
const tools = await asRoot(runtime, state, ["cat", "/opt/outerlayer/tools.json"]);
|
|
4180
4229
|
const agentVersion = agentVersionOf(tools.status === 0 ? tools.stdout : "", runtime.agents);
|
|
4181
4230
|
environment.agentVersion = agentVersion;
|
|
4182
|
-
const
|
|
4183
|
-
|
|
4184
|
-
if (hashed !== void 0) state.judgeProgram = { path: JUDGE_PROGRAM, sha256: hashed };
|
|
4231
|
+
const recorded = await judgeProgramRecord((argv) => asRoot(runtime, state, argv), runtime.agents);
|
|
4232
|
+
if (recorded !== void 0) state.judgeProgram = recorded;
|
|
4185
4233
|
input.save(state, environment);
|
|
4186
4234
|
if (report.docker === true) {
|
|
4187
4235
|
const failure3 = await waitForDocker(runtime, state, agentUser, input.now ?? (() => /* @__PURE__ */ new Date()));
|
|
@@ -4219,6 +4267,7 @@ async function provisionMicroVmOnce(input, allowRestore, itemDiskFailed) {
|
|
|
4219
4267
|
repositories,
|
|
4220
4268
|
...governingSource.kind === "governed" ? { governing: { repository: governingSource.repository } } : {},
|
|
4221
4269
|
agentVersion,
|
|
4270
|
+
agents: runtime.agents,
|
|
4222
4271
|
lifecycle: report.apply.lifecycle,
|
|
4223
4272
|
exec: stepExecFor({ vm, vsockPath: state.vsockPath, request, logPath }),
|
|
4224
4273
|
log,
|
|
@@ -4269,11 +4318,11 @@ async function waitForDocker(runtime, state, agentUser, now) {
|
|
|
4269
4318
|
for (; ; ) {
|
|
4270
4319
|
const granted = await asRoot(runtime, state, ["/bin/sh", "-c", grant]);
|
|
4271
4320
|
if (granted.status !== 0) {
|
|
4272
|
-
if (
|
|
4321
|
+
if (firstLine(granted.stderr) !== "") lastError = `giving the agent's group the Docker socket failed: ${firstLine(granted.stderr)}`;
|
|
4273
4322
|
} else {
|
|
4274
4323
|
const answered = await runtime.vm.exec(state.vsockPath, request);
|
|
4275
4324
|
if (answered.status === 0) return writeDockerClientConfig(asRoot.bind(null, runtime, state), agentUser);
|
|
4276
|
-
lastError =
|
|
4325
|
+
lastError = firstLine(answered.stderr) === "" ? "" : `docker info said: ${firstLine(answered.stderr)}`;
|
|
4277
4326
|
}
|
|
4278
4327
|
if (now().getTime() >= deadline) break;
|
|
4279
4328
|
await runtime.sleep(1e3);
|
|
@@ -4349,7 +4398,7 @@ async function startMicroVmCommand(input) {
|
|
|
4349
4398
|
detach: state.commandDir ?? MICROVM_COMMAND_DIR
|
|
4350
4399
|
});
|
|
4351
4400
|
if (started.status !== 0) {
|
|
4352
|
-
const said2 =
|
|
4401
|
+
const said2 = firstLine(started.stderr);
|
|
4353
4402
|
throw new Error(`the guest's exec agent exited ${started.status}${said2 === "" ? "" : `: ${said2}`}`);
|
|
4354
4403
|
}
|
|
4355
4404
|
}
|
|
@@ -4416,7 +4465,7 @@ async function copyHookErrors(runtime, state, jobDir) {
|
|
|
4416
4465
|
}
|
|
4417
4466
|
async function copyTranscriptsFromMicroVm(runtime, state) {
|
|
4418
4467
|
if (!isRunning(runtime, state)) return { ok: false, reason: "the build's microVM is gone" };
|
|
4419
|
-
return copyTranscripts((argv) => asRoot(runtime, state, argv));
|
|
4468
|
+
return copyTranscripts((argv) => asRoot(runtime, state, argv), void 0, runtime.agents);
|
|
4420
4469
|
}
|
|
4421
4470
|
function guestStopScript(paths = { proc: "/proc", record: HELPER_RECORD }) {
|
|
4422
4471
|
return [
|
|
@@ -4473,9 +4522,7 @@ function microVmJudgeEnvironment(input) {
|
|
|
4473
4522
|
},
|
|
4474
4523
|
hashProgram: async () => {
|
|
4475
4524
|
needsVm();
|
|
4476
|
-
|
|
4477
|
-
const sha2562 = ran.status === 0 ? parseProgramHash(ran.stdout) : void 0;
|
|
4478
|
-
return sha2562 === void 0 ? { ok: false, reason: firstLine3(ran.stderr) || `the hash could not be taken (exit ${ran.status})` } : { ok: true, sha256: sha2562 };
|
|
4525
|
+
return await hashJudgeProgram((argv) => asRoot(runtime, state, argv), runtime.agents);
|
|
4479
4526
|
},
|
|
4480
4527
|
prepare: async (files, tree) => {
|
|
4481
4528
|
needsVm();
|
|
@@ -4497,7 +4544,7 @@ function microVmJudgeEnvironment(input) {
|
|
|
4497
4544
|
`chmod 1777 ${dir}`
|
|
4498
4545
|
].join("\n");
|
|
4499
4546
|
const result = await asRoot(runtime, state, ["/bin/sh", "-c", script], tarOf(staging));
|
|
4500
|
-
if (result.status !== 0) throw new Error(`preparing ${dir} in the guest failed (exit ${result.status}): ${
|
|
4547
|
+
if (result.status !== 0) throw new Error(`preparing ${dir} in the guest failed (exit ${result.status}): ${firstLine(result.stderr)}`);
|
|
4501
4548
|
} finally {
|
|
4502
4549
|
rmSync(staging, { recursive: true, force: true });
|
|
4503
4550
|
}
|
|
@@ -4837,7 +4884,7 @@ function sessionGuestOfMicroVm(runtime, state, as) {
|
|
|
4837
4884
|
};
|
|
4838
4885
|
}
|
|
4839
4886
|
async function restoreSessionIntoMicroVm(runtime, state, keptDir, meta) {
|
|
4840
|
-
const restored = await restoreSession({ guest: sessionGuestOfMicroVm(runtime, state, "agent"), tar: packKeptSession(keptDir, meta) });
|
|
4887
|
+
const restored = await restoreSession({ guest: sessionGuestOfMicroVm(runtime, state, "agent"), tar: packKeptSession(keptDir, meta, runtime.agents) });
|
|
4841
4888
|
if (!restored.ok) throw new Error(restored.reason);
|
|
4842
4889
|
}
|
|
4843
4890
|
|
|
@@ -5700,7 +5747,7 @@ var POLL_MS2 = 200;
|
|
|
5700
5747
|
var ASK_AGAIN_MS = 1e3;
|
|
5701
5748
|
var EXIT_REPORT_WAIT_MS = 2e3;
|
|
5702
5749
|
var exitsLogged = /* @__PURE__ */ new Map();
|
|
5703
|
-
var
|
|
5750
|
+
var BUILD_HOME2 = "/build/home";
|
|
5704
5751
|
async function startSender(input) {
|
|
5705
5752
|
const { config, job, jobDir, deps } = input;
|
|
5706
5753
|
const tag = `${itemTag(job)}`;
|
|
@@ -5759,7 +5806,7 @@ async function restartSender(input) {
|
|
|
5759
5806
|
const state = job.container;
|
|
5760
5807
|
if (state !== void 0 && job.itemKey !== void 0) {
|
|
5761
5808
|
const runtime = deps.runtime ?? createContainerRuntime();
|
|
5762
|
-
const pidfile = senderPidfile(
|
|
5809
|
+
const pidfile = senderPidfile(BUILD_HOME2, Number(job.item));
|
|
5763
5810
|
const sleep = deps.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms)));
|
|
5764
5811
|
const running = async () => {
|
|
5765
5812
|
const probe = await runtime.host.exec({ container: state.container, user: state.agentUser ?? ADDED_USER, env: { literals: {}, passed: {} }, argv: ["/bin/sh", "-c", senderAliveScript(pidfile)] });
|
|
@@ -5825,8 +5872,8 @@ async function stopSender(input) {
|
|
|
5825
5872
|
if (sender === void 0) return;
|
|
5826
5873
|
const tag = `${itemTag(job)}`;
|
|
5827
5874
|
const sleep = deps.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms)));
|
|
5828
|
-
const inContainer = job.container === void 0 ? void 0 : { state: job.container, runtime: deps.runtime ?? createContainerRuntime(), pidfile: senderPidfile(
|
|
5829
|
-
const inGuest = job.microvm === void 0 ? void 0 : { state: job.microvm, runtime: deps.runtime ?? createContainerRuntime(), pidfile: senderPidfile(
|
|
5875
|
+
const inContainer = job.container === void 0 ? void 0 : { state: job.container, runtime: deps.runtime ?? createContainerRuntime(), pidfile: senderPidfile(BUILD_HOME2, Number(job.item)) };
|
|
5876
|
+
const inGuest = job.microvm === void 0 ? void 0 : { state: job.microvm, runtime: deps.runtime ?? createContainerRuntime(), pidfile: senderPidfile(BUILD_HOME2, Number(job.item)) };
|
|
5830
5877
|
const signalInside = async (signal) => {
|
|
5831
5878
|
if (inContainer !== void 0) return signalInContainer(inContainer.runtime, inContainer.state, inContainer.pidfile, signal).catch(() => void 0);
|
|
5832
5879
|
if (inGuest !== void 0) return signalInGuest(inGuest.runtime, inGuest.state, inGuest.pidfile, signal).catch(() => void 0);
|
|
@@ -6102,6 +6149,7 @@ function recordOf(input, kind, bytes, volume) {
|
|
|
6102
6149
|
workItemId: input.workItemId,
|
|
6103
6150
|
claimId: input.claimId,
|
|
6104
6151
|
queue: input.queue,
|
|
6152
|
+
...input.repository === void 0 ? {} : { repository: input.repository },
|
|
6105
6153
|
imageId: input.imageId,
|
|
6106
6154
|
diskBytes: input.diskBytes,
|
|
6107
6155
|
kind,
|
|
@@ -6199,16 +6247,19 @@ async function keepContainerDisk(input) {
|
|
|
6199
6247
|
// src/runner/workspace/finish.ts
|
|
6200
6248
|
function noDiskReason(job, config) {
|
|
6201
6249
|
if (job.workItemId === void 0) return "the job names no work item";
|
|
6250
|
+
if (job.reason === "disk_limit_exceeded" || job.reason === "disk_check_failed") return "the build passed its disk limit, so a rerun would start from a full disk";
|
|
6202
6251
|
if (config.managed === true && (job.managedVariables?.length ?? 0) > 0) return "the build held a factory build variable, and the runner cannot remove a value that a command stored in an encoded form";
|
|
6203
6252
|
return void 0;
|
|
6204
6253
|
}
|
|
6205
6254
|
function target(input, imageId, diskBytes) {
|
|
6255
|
+
const primary = primaryOf(repositoriesOf({ repositories: input.job.repositories, repository: input.job.repository, branch: input.job.branch }));
|
|
6206
6256
|
return {
|
|
6207
6257
|
configPath: input.config.configPath,
|
|
6208
6258
|
...input.job.organizationId === void 0 ? {} : { organizationId: input.job.organizationId },
|
|
6209
6259
|
workItemId: input.job.workItemId,
|
|
6210
6260
|
claimId: input.job.claimId,
|
|
6211
6261
|
queue: input.job.queue,
|
|
6262
|
+
...primary === void 0 ? {} : { repository: primary.repository },
|
|
6212
6263
|
imageId,
|
|
6213
6264
|
diskBytes,
|
|
6214
6265
|
now: input.now(),
|
|
@@ -6291,17 +6342,20 @@ async function keepEndedSession(input) {
|
|
|
6291
6342
|
}
|
|
6292
6343
|
const tarPath = join(input.jobDirPath, SESSION_TAR);
|
|
6293
6344
|
try {
|
|
6294
|
-
const copied = await copyOutSession({ guest: found.guest, sessionId: job.sessionId, tarPath });
|
|
6345
|
+
const copied = await copyOutSession({ guest: found.guest, sessionId: job.sessionId, tarPath }, input.runtime.agents);
|
|
6295
6346
|
if (!copied.ok) {
|
|
6296
6347
|
log.error(`${tag} the session was not kept: ${copied.reason} \xB7 continuing`);
|
|
6297
6348
|
return changed;
|
|
6298
6349
|
}
|
|
6299
|
-
await keepSession(
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6350
|
+
await keepSession(
|
|
6351
|
+
{
|
|
6352
|
+
dir: keptSessionDir(input.configPath, job.organizationId, job.workItemId),
|
|
6353
|
+
meta: { sessionId: job.sessionId, claimId: job.claimId, queue: job.queue, keptAt: input.now().toISOString() },
|
|
6354
|
+
tar: createReadStream(tarPath),
|
|
6355
|
+
scrub: input.scrub
|
|
6356
|
+
},
|
|
6357
|
+
input.runtime.agents
|
|
6358
|
+
);
|
|
6305
6359
|
log.line(`${tag} session ${job.sessionId.slice(0, 8)} kept for the next agent job (${formatBytes(statSync(tarPath).size)})`);
|
|
6306
6360
|
job.sessionKept = true;
|
|
6307
6361
|
return true;
|
|
@@ -6317,27 +6371,17 @@ async function keepEndedSession(input) {
|
|
|
6317
6371
|
function firstLine5(text2) {
|
|
6318
6372
|
return text2.trim().split(/\r\n|\r|\n/)[0]?.trim() ?? "";
|
|
6319
6373
|
}
|
|
6320
|
-
function parseOutput(stdout) {
|
|
6321
|
-
try {
|
|
6322
|
-
const parsed = JSON.parse(stdout);
|
|
6323
|
-
if (typeof parsed !== "object" || parsed === null) return void 0;
|
|
6324
|
-
const { subtype, result } = parsed;
|
|
6325
|
-
return { subtype: typeof subtype === "string" ? subtype : void 0, result: typeof result === "string" ? result : "" };
|
|
6326
|
-
} catch {
|
|
6327
|
-
return void 0;
|
|
6328
|
-
}
|
|
6329
|
-
}
|
|
6330
6374
|
var RESULT_LINE = /^result:\s*(pass|fail)\s*$/i;
|
|
6331
6375
|
var UNMET_LINE = /^unmet:\s*(\S+)\s*$/i;
|
|
6332
|
-
function readJudgeReply(run, minutes) {
|
|
6376
|
+
function readJudgeReply(run, minutes, agents = defaultAgents()) {
|
|
6333
6377
|
if (run.kind === "timeout") return { kind: "none", reason: `the judge ran out of time after ${minutes}`, limitKey: true };
|
|
6334
|
-
const output =
|
|
6378
|
+
const output = jobAgent(void 0, agents)?.adapter.headless?.readJudgeOutput(run.stdout);
|
|
6335
6379
|
if (output === void 0) {
|
|
6336
6380
|
const said2 = firstLine5(run.stderr);
|
|
6337
6381
|
return { kind: "none", reason: `the judge exited ${run.status} and printed no result${said2 === "" ? "" : `: ${said2}`}` };
|
|
6338
6382
|
}
|
|
6339
|
-
if (output.
|
|
6340
|
-
const lines = output.
|
|
6383
|
+
if (output.kind === "turn-limit") return { kind: "none", reason: `the judge reached the turn limit of ${JUDGE_MAX_TURNS} turns before it gave a result` };
|
|
6384
|
+
const lines = output.text.split(/\r\n|\r|\n/).map((line2) => line2.trim()).filter((line2) => line2 !== "");
|
|
6341
6385
|
const verdict = RESULT_LINE.exec(lines.at(-1) ?? "")?.[1]?.toLowerCase();
|
|
6342
6386
|
if (verdict === void 0) return { kind: "none", reason: "the judge gave no `result:` line" };
|
|
6343
6387
|
return { kind: "answered", verdict, unmet: new Set(lines.flatMap((line2) => UNMET_LINE.exec(line2)?.[1] ?? [])) };
|
|
@@ -6396,7 +6440,7 @@ ${rows}
|
|
|
6396
6440
|
// src/runner/judge.ts
|
|
6397
6441
|
var LIMIT_KEY_TAIL = " (runner.checks.timeLimitMinutes)";
|
|
6398
6442
|
var MAX_DIFF_BYTES = 4 * 1024 * 1024;
|
|
6399
|
-
var
|
|
6443
|
+
var noAgentProgram = (label) => `the image has no ${label} for the judge`;
|
|
6400
6444
|
var REPORT_CAPTION = "The host's criteria judge, each criterion judged against the test that cites it";
|
|
6401
6445
|
function testFilesIn(root, isTest, limits2 = { files: MAX_TEST_FILES, bytes: MAX_TEST_FILE_BYTES }) {
|
|
6402
6446
|
const files = [];
|
|
@@ -6546,15 +6590,18 @@ async function runJudge(input) {
|
|
|
6546
6590
|
log.line(`${tag} judge done (${formatDuration(now().getTime() - startedMs)})`);
|
|
6547
6591
|
}
|
|
6548
6592
|
async function judgeOne(check) {
|
|
6593
|
+
const agent = jobAgent(void 0, runtime.agents);
|
|
6594
|
+
if (agent?.adapter.headless === void 0) return await fail(check, `${agent?.descriptor.label ?? "the agent list"} has no headless part, so it cannot run the judge`);
|
|
6595
|
+
const missing = noAgentProgram(agent.descriptor.label);
|
|
6549
6596
|
const environment = environmentFor(input);
|
|
6550
|
-
if (environment === void 0) return await fail(check, `${
|
|
6597
|
+
if (environment === void 0) return await fail(check, `${missing}: this build ran outside a container or microVM`);
|
|
6551
6598
|
const expected = (job.container ?? job.microvm)?.judgeProgram;
|
|
6552
|
-
if (expected === void 0) return await fail(check,
|
|
6599
|
+
if (expected === void 0) return await fail(check, missing);
|
|
6553
6600
|
const brief = check.judge.text;
|
|
6554
6601
|
if (brief === void 0) return await fail(check, `the brief ${check.judge.brief} is not in the definitions repository`);
|
|
6555
6602
|
if (tokens === void 0) return await fail(check, "the build's repository tokens are no longer held, so the branch cannot be fetched");
|
|
6556
6603
|
const credential = config.managed === true && managedClaudeKeyFor(jobDir) !== void 0 ? managedAgentCredential(runtime.agents) : agentCredential(runtime.hostEnv, {}, runtime.agents);
|
|
6557
|
-
if (credential === void 0) return await fail(check,
|
|
6604
|
+
if (credential === void 0) return await fail(check, `the host holds no ${agent.descriptor.credentials.label} credential for the judge`);
|
|
6558
6605
|
const branch = job.branch;
|
|
6559
6606
|
if (branch === void 0) return await fail(check, "the build pushed no branch: the claim names none");
|
|
6560
6607
|
const remote = runtime.remoteFor?.(repo) ?? `${runtime.github.gitUrl}/${repo}.git`;
|
|
@@ -6564,7 +6611,7 @@ async function runJudge(input) {
|
|
|
6564
6611
|
return await fail(check, `the build's processes could not be stopped: ${describeCallFailure(err)}`);
|
|
6565
6612
|
}
|
|
6566
6613
|
const hashed = await environment.hashProgram();
|
|
6567
|
-
if (!hashed.ok) return await fail(check, `${
|
|
6614
|
+
if (!hashed.ok) return await fail(check, `${missing}: ${hashed.reason}`);
|
|
6568
6615
|
if (hashed.sha256 !== expected.sha256) return await fail(check, "the judge program changed during the build");
|
|
6569
6616
|
const read = await (deps.readBranch ?? readBranchHead)({ remote, dir: scratch, branch, token: readToken });
|
|
6570
6617
|
if (read.kind === "absent") return await fail(check, `the build pushed no branch: ${branch} does not exist on ${repo}`);
|
|
@@ -6639,7 +6686,7 @@ async function runJudge(input) {
|
|
|
6639
6686
|
await environment.clear?.().catch((err) => log.error(`${tag} what the judge left in its folder could not be removed: ${describeCallFailure(err)}`));
|
|
6640
6687
|
};
|
|
6641
6688
|
const prompt = withAnswerProtocol(brief, check.judge.subjects);
|
|
6642
|
-
const running = environment.run(judgeCommand({ brief: prompt, credential }), { logPath: join(jobDir, "judge.log") });
|
|
6689
|
+
const running = environment.run(judgeCommand({ brief: prompt, credential }, runtime.agents), { logPath: join(jobDir, "judge.log") });
|
|
6643
6690
|
running.catch(() => void 0);
|
|
6644
6691
|
const timer = timeoutAfter(limitMinutes * 6e4, deps.sleep);
|
|
6645
6692
|
let outcome;
|
|
@@ -6673,7 +6720,7 @@ async function runJudge(input) {
|
|
|
6673
6720
|
}
|
|
6674
6721
|
await clear();
|
|
6675
6722
|
const run = outcome === "timeout" ? { kind: "timeout" } : { kind: "exited", status: outcome.status, stdout: outcome.stdout, stderr: outcome.stderr };
|
|
6676
|
-
const reply = readJudgeReply(run, minutes);
|
|
6723
|
+
const reply = readJudgeReply(run, minutes, runtime.agents);
|
|
6677
6724
|
const answer = parseJudgeAnswer(answerText);
|
|
6678
6725
|
if (criteria === void 0) return await finishWhole(check, { reply, answer, report, head, branch });
|
|
6679
6726
|
const judged = (results2) => [
|
|
@@ -10381,9 +10428,9 @@ async function provisionContainerOnce(input, allowRestore, itemDiskFailed) {
|
|
|
10381
10428
|
const { report } = built;
|
|
10382
10429
|
const tagged = taggedLog(log, tag);
|
|
10383
10430
|
const diskBytes = parseSize(config.build?.disk ?? DEFAULT_BUILD_DISK) ?? 0;
|
|
10384
|
-
const itemDisk = input.workItemId === void 0 ? { state: void 0 } : itemDiskFailed !== void 0 ? { state: { restored: false, reason: itemDiskFailed } } : itemDiskDecision({
|
|
10431
|
+
const itemDisk = input.workItemId === void 0 ? { state: void 0 } : itemDiskFailed !== void 0 ? { state: { restored: false, reason: itemDiskFailed } } : itemDiskDecision({ fresh: input.fresh, builtin: true, backend: "volume", configPath: config.configPath, organizationId: input.organizationId, workItemId: input.workItemId, repository, imageId: report.imageId, diskBytes });
|
|
10385
10432
|
const keptDisk = itemDisk.kept;
|
|
10386
|
-
if (itemDisk.state?.restored === false) tagged(`this
|
|
10433
|
+
if (itemDisk.state?.restored === false) tagged(`this job starts without a kept disk: ${DISK_REASON_TEXT[itemDisk.state.reason]}`);
|
|
10387
10434
|
const plan = keptDisk !== void 0 ? keptDiskPlan() : await planSavedState({
|
|
10388
10435
|
config,
|
|
10389
10436
|
repositories,
|
|
@@ -10559,9 +10606,8 @@ async function provisionContainerOnce(input, allowRestore, itemDiskFailed) {
|
|
|
10559
10606
|
const tools = await host.exec({ container: name, user: ADDED_USER, env: NO_ENV, argv: ["cat", "/opt/outerlayer/tools.json"] });
|
|
10560
10607
|
const agentVersion = agentVersionOf(tools.status === 0 ? tools.stdout : "", runtime.agents);
|
|
10561
10608
|
environment.agentVersion = agentVersion;
|
|
10562
|
-
const
|
|
10563
|
-
|
|
10564
|
-
if (hashed !== void 0) state.judgeProgram = { path: JUDGE_PROGRAM, sha256: hashed };
|
|
10609
|
+
const recorded = await judgeProgramRecord((argv) => host.exec({ container: name, user: ADDED_USER, env: NO_ENV, argv }), runtime.agents);
|
|
10610
|
+
if (recorded !== void 0) state.judgeProgram = recorded;
|
|
10565
10611
|
input.save(state, environment);
|
|
10566
10612
|
const exec = async (argv, workdir, opts) => {
|
|
10567
10613
|
const ran = await host.exec({ container: name, user: agentUser, workdir, env: withMiseVariables(env, opts?.variables), argv }, { ...opts?.quiet === true ? {} : { logPath }, ...opts?.timeoutMs === void 0 ? {} : { timeoutMs: opts.timeoutMs } });
|
|
@@ -10592,6 +10638,7 @@ async function provisionContainerOnce(input, allowRestore, itemDiskFailed) {
|
|
|
10592
10638
|
repositories,
|
|
10593
10639
|
...governingSource.kind === "governed" ? { governing: { repository: governingSource.repository } } : {},
|
|
10594
10640
|
agentVersion,
|
|
10641
|
+
agents: runtime.agents,
|
|
10595
10642
|
lifecycle: report.apply.lifecycle,
|
|
10596
10643
|
exec,
|
|
10597
10644
|
log,
|
|
@@ -10876,7 +10923,7 @@ async function copyTranscriptsFromContainer(runtime, state) {
|
|
|
10876
10923
|
} catch (err) {
|
|
10877
10924
|
return { ok: false, reason: describeCallFailure(err) };
|
|
10878
10925
|
}
|
|
10879
|
-
return copyTranscripts((argv) => runtime.host.exec({ container: state.container, user: state.agentUser ?? ADDED_USER, env: NO_ENV, argv }));
|
|
10926
|
+
return copyTranscripts((argv) => runtime.host.exec({ container: state.container, user: state.agentUser ?? ADDED_USER, env: NO_ENV, argv }), void 0, runtime.agents);
|
|
10880
10927
|
}
|
|
10881
10928
|
async function ensureContainerRunning(runtime, state) {
|
|
10882
10929
|
try {
|
|
@@ -10917,7 +10964,7 @@ function sessionGuestOfContainer(runtime, state) {
|
|
|
10917
10964
|
};
|
|
10918
10965
|
}
|
|
10919
10966
|
async function restoreSessionIntoContainer(runtime, state, keptDir, meta) {
|
|
10920
|
-
const restored = await restoreSession({ guest: sessionGuestOfContainer(runtime, state), tar: packKeptSession(keptDir, meta) });
|
|
10967
|
+
const restored = await restoreSession({ guest: sessionGuestOfContainer(runtime, state), tar: packKeptSession(keptDir, meta, runtime.agents) });
|
|
10921
10968
|
if (!restored.ok) throw new Error(restored.reason);
|
|
10922
10969
|
}
|
|
10923
10970
|
var HOOK_ERRORS_IN_CONTAINER = "/build/home/.outerlayer/spool/hook-errors.log";
|
|
@@ -10982,7 +11029,7 @@ function containerJudgeEnvironment(input) {
|
|
|
10982
11029
|
env: NO_ENV,
|
|
10983
11030
|
argv: ["/bin/sh", "-c", `[ -f ${file} ] && [ ! -L ${file} ] && head -c ${maxBytes + 1} ${file}`]
|
|
10984
11031
|
}, { timeoutMs: REPORT_READ_TIMEOUT_MS });
|
|
10985
|
-
if (read.status > 1) throw new Error(`reading the judge's ${name} exited ${read.status}: ${
|
|
11032
|
+
if (read.status > 1) throw new Error(`reading the judge's ${name} exited ${read.status}: ${firstLine(read.stderr)}`);
|
|
10986
11033
|
return read.status === 0 && Buffer.byteLength(read.stdout) <= maxBytes ? read.stdout : void 0;
|
|
10987
11034
|
};
|
|
10988
11035
|
return {
|
|
@@ -11000,9 +11047,7 @@ function containerJudgeEnvironment(input) {
|
|
|
11000
11047
|
if (!delivered.ok) throw new Error(delivered.reason);
|
|
11001
11048
|
},
|
|
11002
11049
|
hashProgram: async () => {
|
|
11003
|
-
|
|
11004
|
-
const sha2562 = ran.status === 0 ? parseProgramHash(ran.stdout) : void 0;
|
|
11005
|
-
return sha2562 === void 0 ? { ok: false, reason: firstLine3(ran.stderr) || `the hash could not be taken (exit ${ran.status})` } : { ok: true, sha256: sha2562 };
|
|
11050
|
+
return await hashJudgeProgram((argv) => runtime.host.exec({ container: state.container, user: ADDED_USER, env: NO_ENV, argv }), runtime.agents);
|
|
11006
11051
|
},
|
|
11007
11052
|
prepare: async (files, tree) => {
|
|
11008
11053
|
if (filesAreCopied(state)) {
|
|
@@ -11035,7 +11080,7 @@ function containerJudgeEnvironment(input) {
|
|
|
11035
11080
|
// host. Every capability is dropped in the container, so root there could not either; the build's user removes its own, and the runner removes the rest.
|
|
11036
11081
|
clear: async () => {
|
|
11037
11082
|
const removed = await runtime.host.exec({ container: state.container, user, env: NO_ENV, argv: ["find", JUDGE_DIR, "-mindepth", "1", "-user", user, "-delete"] });
|
|
11038
|
-
if (removed.status !== 0) throw new Error(`find exited ${removed.status}: ${
|
|
11083
|
+
if (removed.status !== 0) throw new Error(`find exited ${removed.status}: ${firstLine(removed.stderr)}`);
|
|
11039
11084
|
if (!filesAreCopied(state)) return;
|
|
11040
11085
|
const emptied = await clearJudgeFolder(runtime, state, secretsOf(runtime, input.jobDir));
|
|
11041
11086
|
if (!emptied.ok) throw new Error(emptied.reason);
|
|
@@ -11662,4 +11707,4 @@ async function runHostChecks(input) {
|
|
|
11662
11707
|
}
|
|
11663
11708
|
}
|
|
11664
11709
|
|
|
11665
|
-
export { ADOPTED_FETCH_RETRY_WINDOW_MS, ALREADY_RELEASED, AttemptLogBook, EXIT_CODE_FILE, GUEST_USAGE_INTERVAL_MS, HELPER_ENV, KIND_LABEL, LEASE_SECONDS, MAX_CHECK_ITEMS_BYTES, MICROVM_COMMAND_DIR, MIN_ENGINE_MAJOR, PLACEHOLDER_MARKER, RENEW_INTERVAL_SECONDS, RunnerInitError, agentCredentialCheck, appendCommandLog, attemptNote, checksIn, claimPermissionProblem, commandItems, commandLogOffset, containerCommandExec, createContainerRuntime, createHousekeepingDocker, createLeaseChannel, currentSkillCommand, decideHostBuildSkill, deliverCommitHooks, deliverContainerHooks, deliverExecMaven, deliverJobFiles, describeHookEnd, describeMachineDocker, detectMachine, ensureFirecrackerAndJailer, ensureNetworkReady, ensureTunnel, execArgv, execCommandLine, fetchManagedBuildSettings, fetchManagedClaudeKey, filesAreCopied, finishJob,
|
|
11710
|
+
export { ADOPTED_FETCH_RETRY_WINDOW_MS, ALREADY_RELEASED, AttemptLogBook, EXIT_CODE_FILE, GUEST_USAGE_INTERVAL_MS, HELPER_ENV, KIND_LABEL, LEASE_SECONDS, MAX_CHECK_ITEMS_BYTES, MICROVM_COMMAND_DIR, MIN_ENGINE_MAJOR, PLACEHOLDER_MARKER, RENEW_INTERVAL_SECONDS, RunnerInitError, agentCredentialCheck, appendCommandLog, attemptNote, checksIn, claimPermissionProblem, commandItems, commandLogOffset, containerCommandExec, createContainerRuntime, createHousekeepingDocker, createLeaseChannel, currentSkillCommand, decideHostBuildSkill, deliverCommitHooks, deliverContainerHooks, deliverExecMaven, deliverJobFiles, describeHookEnd, describeMachineDocker, detectMachine, ensureFirecrackerAndJailer, ensureNetworkReady, ensureTunnel, execArgv, execCommandLine, fetchManagedBuildSettings, fetchManagedClaudeKey, filesAreCopied, finishJob, foldSample, formerSkillProblem, formerSkillQueues, freeItemDisksUntil, gitRemoteFor, helperFirecrackerNote, helperSocketPath, holdManagedBuildSettings, holdManagedClaudeKey, hookLimitsFor, hostCommandEnvironment, hostEnvironment, housekeepingDockerIfReachable, inTeardown, isContainerTracked, isGroupAlive, isIdle, isJudgeCheck, isMicroVmTracked, isPlaceholderCommand, isReadable, isTimedOut, isTracked, isUnfinished, itemScope, itemTag, jobEnv, judgeProbe, keepGhConfigCurrent, leaseExpiresAtMs, leaseTimeLeftMs, lifecycleFailureReason, lifecycleSteps, listAdoptableJobs, listTrackedJobs, listUnreadableJobs, listenOnBroker, makeRecorder, managedBuildSettingsFor, measureDisk, microVmArchSupported, microVmAssetsPinned, microVmCommandLine, microVmOomKills, missingPermissionFix, missingPermissionOf, needsAgentCredential, needsBuildSkill, needsRenew, outcomeFromExitCode, parseCpuList, permissionModeProblem, permissionModeProblems, placeholderProblem, placeholderQueues, prepareBranch, prepareResume, prepareRunnerInit, probeCommand, probeHelper, probeMicroVmCommand, provisionContainer, provisionEnvironment, provisionMicroVm, reachDockerStep, readConfigObject, readCpuUsec, readDefinitions, readProvisionOut, readRecords, recoverLostJobs, releaseLease, removeOldestUntil, renewLease, resolveHostBuild, restartSender, restoreSessionIntoContainer, restoreSessionIntoMicroVm, retryFailedReleases, runCommand, runHook, runHostChecks, runHousekeeping, runRunnerInit, runWithSpawn, sampleGuest, savedStatesDir, scrubReason, serveLease, setStage, setUpRunnerCgroup, shellQuote, startHostServices, startMicroVmCommand, startSender, startServicesFor, stopOrphanedMicroVms, stoppedHelperReason, stripTerminalControls, supportsContainerBuilds, supportsMicroVmBuilds, sweepImageBuilders, testProofIn, timeoutAfter, unfinishedJobs, usableCpus, vmAlive, withTunnelLog, workdirProblem, writeGuestGhConfig, writeRunnerInit };
|