@outerlayer/cli 0.36.0-next.20261103024917 → 0.36.0-next.20261103102716

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.
Files changed (178) hide show
  1. package/README.md +6 -1
  2. package/dist/agent-setup-DZZZH3SE.js +40 -0
  3. package/dist/{agent-subcommand-LABZ7CVN.js → agent-subcommand-WRHH6SRD.js} +5 -5
  4. package/dist/{bridge-WVWJBVTG.js → bridge-GZSZQGLI.js} +8 -7
  5. package/dist/{build-TB4QKVBG.js → build-UKZ5RPRR.js} +14 -13
  6. package/dist/{build-disk-27ZTD2EH.js → build-disk-3HOXULLP.js} +12 -11
  7. package/dist/build-info.json +1 -1
  8. package/dist/{builder-DN2S6EVU.js → builder-QEK4GIRY.js} +11 -10
  9. package/dist/caller-WSMJJSFL.js +23 -0
  10. package/dist/{check-MNFIC7TT.js → check-QLJ2O7VO.js} +61 -60
  11. package/dist/{chunk-ORU76DHF.js → chunk-2JWLK2TU.js} +1 -1
  12. package/dist/{chunk-IVAX5RVX.js → chunk-2QIK3JRV.js} +1 -1
  13. package/dist/{chunk-HWIV4MF6.js → chunk-2SBNZ4EC.js} +1 -1
  14. package/dist/{chunk-SSVG2IOD.js → chunk-2W5C47AE.js} +1 -1
  15. package/dist/{chunk-4XYEPTZP.js → chunk-3XEYA3QF.js} +3 -3
  16. package/dist/{chunk-NTOHZMPN.js → chunk-42X6CTBI.js} +4 -4
  17. package/dist/{chunk-VNYAJEKO.js → chunk-4MLH5MDB.js} +5 -5
  18. package/dist/{chunk-XL6DG5LC.js → chunk-4MN4BBKZ.js} +7 -7
  19. package/dist/{chunk-EI22245K.js → chunk-54ERDQ3O.js} +77 -9
  20. package/dist/{chunk-6DOYJN44.js → chunk-54PQNYA7.js} +3 -3
  21. package/dist/{chunk-EYUJCGF2.js → chunk-6J3QWXTA.js} +4 -4
  22. package/dist/{chunk-UCUZJ5W5.js → chunk-6UI4ELNA.js} +62 -53
  23. package/dist/{chunk-QTU6GW2M.js → chunk-7UYXSF62.js} +8 -227
  24. package/dist/{chunk-CAGZNACH.js → chunk-A64EXQUL.js} +31 -30
  25. package/dist/{chunk-3L6XOE4K.js → chunk-B5VKRKLJ.js} +1 -1
  26. package/dist/{chunk-DRGGJH2V.js → chunk-BEJJJZXF.js} +4 -4
  27. package/dist/{chunk-37B2SIAT.js → chunk-BTGNFRRT.js} +7 -7
  28. package/dist/{chunk-CJNZ2FIW.js → chunk-BZQ3S24G.js} +1 -1
  29. package/dist/{chunk-LLCRQWH5.js → chunk-CDTBXABP.js} +2 -2
  30. package/dist/{chunk-UZ5SDO7Y.js → chunk-DEZSNJSE.js} +1 -1
  31. package/dist/{chunk-AUZAQL7C.js → chunk-DWYQKLCL.js} +1 -1
  32. package/dist/{chunk-R3JSLSMG.js → chunk-EHS3HEB6.js} +4 -4
  33. package/dist/{chunk-JZDTDGRO.js → chunk-EUWTGCK5.js} +1 -1
  34. package/dist/{chunk-33OQSCE2.js → chunk-FLQL6ZIG.js} +1 -1
  35. package/dist/{chunk-A76SNTAM.js → chunk-GPBTTHK3.js} +1 -1
  36. package/dist/{chunk-LFUEODDW.js → chunk-H4G26OZC.js} +8 -8
  37. package/dist/{chunk-GIAODP2B.js → chunk-HO4DPX5N.js} +1 -1
  38. package/dist/{chunk-HBE75JAU.js → chunk-HQBKKYYQ.js} +5 -5
  39. package/dist/{chunk-VJKHQSSS.js → chunk-HR4PJLOO.js} +1 -1
  40. package/dist/{chunk-OE5JWY3T.js → chunk-HX6B34ZF.js} +17 -17
  41. package/dist/chunk-IEDO26G4.js +243 -0
  42. package/dist/{chunk-PUPUOQ6Y.js → chunk-IEVARJ6G.js} +2 -2
  43. package/dist/{chunk-EQ5M2WWA.js → chunk-J4NJWTNO.js} +5 -5
  44. package/dist/{chunk-WFRYPYPT.js → chunk-JD5EVW6Y.js} +1 -1
  45. package/dist/{chunk-JYFZC776.js → chunk-JMM3L5RG.js} +5 -5
  46. package/dist/{chunk-Q7BECZIF.js → chunk-K26KMWU4.js} +10 -10
  47. package/dist/{chunk-UJISSEJG.js → chunk-K373UCEV.js} +1 -1
  48. package/dist/{chunk-MDJ6ILXG.js → chunk-KHJPRTOW.js} +1 -1
  49. package/dist/{chunk-GANI63IL.js → chunk-L3SHPR2M.js} +1 -1
  50. package/dist/{chunk-P63MQNDV.js → chunk-LDKF6B2R.js} +174 -8
  51. package/dist/{chunk-VQ4KQGLY.js → chunk-LV4IDDD3.js} +8 -13
  52. package/dist/{chunk-QPIWCDVK.js → chunk-LXXP5HRJ.js} +4 -4
  53. package/dist/{chunk-PVUBF24F.js → chunk-MPVTZLOM.js} +5 -4
  54. package/dist/{chunk-AU3QZKC4.js → chunk-N3SO5VCM.js} +8 -8
  55. package/dist/{chunk-HLJQONDG.js → chunk-NMMGRG5V.js} +6 -6
  56. package/dist/{chunk-RW6TM4OU.js → chunk-NOLS2G2W.js} +1 -1
  57. package/dist/{chunk-M6FMJXYO.js → chunk-NQYTUVZR.js} +1 -1
  58. package/dist/{chunk-CDDWYP73.js → chunk-OGG5ELXF.js} +5 -4
  59. package/dist/{chunk-DPTBQIF6.js → chunk-OPEZVPF7.js} +3 -3
  60. package/dist/{chunk-UWYU46GF.js → chunk-OV4XTV5M.js} +2 -2
  61. package/dist/{chunk-BGTQHUGU.js → chunk-P4Q6M6PI.js} +1 -1
  62. package/dist/{chunk-UHVYFXW6.js → chunk-PDRWRFB2.js} +4 -4
  63. package/dist/{chunk-UNWCM4FR.js → chunk-PYK6GCCU.js} +6 -6
  64. package/dist/{chunk-LLZ2CX4M.js → chunk-QJKW4MKH.js} +6 -1
  65. package/dist/{chunk-RKU2CRQN.js → chunk-QKLCIJEU.js} +349 -318
  66. package/dist/{chunk-XEZO7VQH.js → chunk-QVOU2QUR.js} +2 -2
  67. package/dist/{chunk-6ILOTKYR.js → chunk-RGKJ5J72.js} +5 -5
  68. package/dist/{chunk-OL6URNWQ.js → chunk-RKV3UQCG.js} +9 -8
  69. package/dist/{chunk-EA67BJCF.js → chunk-SYKEQT63.js} +6 -6
  70. package/dist/{chunk-66GYPUUN.js → chunk-T5I2H7TJ.js} +1 -1
  71. package/dist/{chunk-AXOO6FNA.js → chunk-TWGSXBZM.js} +3 -3
  72. package/dist/{chunk-7VUTGCGH.js → chunk-U6EACUUG.js} +1 -1
  73. package/dist/{chunk-4QE6PSGN.js → chunk-U6HCTKPH.js} +7 -7
  74. package/dist/{chunk-EDZ2OZYI.js → chunk-U7MLC45I.js} +6 -6
  75. package/dist/{chunk-GXCU5HTU.js → chunk-UZSMDU4U.js} +3 -3
  76. package/dist/{chunk-DNUA6244.js → chunk-VMPVQE4D.js} +2 -2
  77. package/dist/{chunk-YTERTIGW.js → chunk-VST3BWL4.js} +9 -9
  78. package/dist/{chunk-3JVLRIX3.js → chunk-WAGHPZP2.js} +1 -1
  79. package/dist/{chunk-PN4LWT5F.js → chunk-WNQGSAUE.js} +1 -1
  80. package/dist/{chunk-FINJC6BS.js → chunk-WZOWXDDM.js} +20 -14
  81. package/dist/{chunk-ZSEAA74Q.js → chunk-XSGWMQJF.js} +3 -3
  82. package/dist/{chunk-ASR6TU43.js → chunk-YCBVYTFI.js} +1 -1
  83. package/dist/{chunk-6V6ONATO.js → chunk-YEZGNCSK.js} +2 -2
  84. package/dist/{chunk-RCEK22S2.js → chunk-YWCK4EOT.js} +3 -3
  85. package/dist/{chunk-NJKCJVJL.js → chunk-ZE2JJQPC.js} +1 -1
  86. package/dist/{chunk-GQHT6N47.js → chunk-ZZ4WIQRF.js} +6 -5
  87. package/dist/{claude-launcher-5UGFLCYJ.js → claude-launcher-CPSCSL6U.js} +9 -9
  88. package/dist/{cli-AVPIE2LZ.js → cli-4M74XOWW.js} +192 -161
  89. package/dist/{command-4CPHPV55.js → command-RY76GIQG.js} +54 -53
  90. package/dist/{config-ODIFTWTQ.js → config-23EBIGW4.js} +13 -12
  91. package/dist/{connect-cmd-BMA6JWN5.js → connect-cmd-GEBIOBQQ.js} +12 -11
  92. package/dist/{container-start-AQIO47FJ.js → container-start-SUBTHQME.js} +59 -54
  93. package/dist/{context-cleanup-7XUQDCJ5.js → context-cleanup-I7FLIV5A.js} +5 -5
  94. package/dist/{context-show-cmd-FN6RY7JN.js → context-show-cmd-CSPMSRHX.js} +13 -12
  95. package/dist/{control-plane-launch-7FWJACHT.js → control-plane-launch-KC7NUNYQ.js} +16 -15
  96. package/dist/{demo-record-cmd-LRQMMMPB.js → demo-record-cmd-ZW6U2LAV.js} +9 -8
  97. package/dist/{demo-voice-cmd-ORYSHARJ.js → demo-voice-cmd-IDW3QX3E.js} +22 -21
  98. package/dist/{dist-AIMCXBLZ.js → dist-LOBYZWOU.js} +1 -1
  99. package/dist/docker-2VHMWLNK.js +20 -0
  100. package/dist/{doctor-X663FFNY.js → doctor-GEG64FBO.js} +54 -53
  101. package/dist/{emit-artifact-cmd-KMGO53PL.js → emit-artifact-cmd-2ZHPNLPG.js} +21 -20
  102. package/dist/{emit-cmd-OGNFGQF6.js → emit-cmd-UN7HGZC5.js} +8 -8
  103. package/dist/{emit-criteria-cmd-2KDA4LPJ.js → emit-criteria-cmd-TUXGD7CW.js} +15 -14
  104. package/dist/{emit-demo-cmd-26URBRX2.js → emit-demo-cmd-4YMYB556.js} +22 -21
  105. package/dist/{emit-finding-cmd-GM4G3ZGU.js → emit-finding-cmd-O2NN22XF.js} +15 -14
  106. package/dist/{emit-result-cmd-SXS6AJP3.js → emit-result-cmd-VRITADX2.js} +20 -19
  107. package/dist/{emit-step-cmd-TDO3NFV3.js → emit-step-cmd-LGNBZTWJ.js} +15 -14
  108. package/dist/{exec-client-DBSWP3AQ.js → exec-client-NXTXAVHI.js} +9 -8
  109. package/dist/find-unit-RYYTX2O5.js +24 -0
  110. package/dist/{findings-cmd-ED52QLP2.js → findings-cmd-RJD7KTSW.js} +15 -14
  111. package/dist/{fleet-readiness-X7YICYMA.js → fleet-readiness-RIO2SWC7.js} +15 -14
  112. package/dist/{governing-source-R7F6GZLO.js → governing-source-IR3KUGQF.js} +21 -20
  113. package/dist/guest-init-FLSL5RI7.js +20 -0
  114. package/dist/{hook-fast-Q6HOUK64.js → hook-fast-HYRZAY5K.js} +4 -4
  115. package/dist/{hook-install-LHVMFLO6.js → hook-install-CSHKOLWT.js} +5 -5
  116. package/dist/{hook-wrap-fast-FCZEUJKT.js → hook-wrap-fast-ITUBSHEF.js} +3 -3
  117. package/dist/host-checks-OB45XC67.js +79 -0
  118. package/dist/host-key-CPAEQSNU.js +18 -0
  119. package/dist/{image-tag-BHAEZYXN.js → image-tag-MAMFM4SO.js} +9 -8
  120. package/dist/index.js +6 -6
  121. package/dist/{init-IOOA3TJA.js → init-G34M5Y4W.js} +50 -49
  122. package/dist/init-HHD2NNWY.js +79 -0
  123. package/dist/{init-cmd-3TLX7N3E.js → init-cmd-GDT27DWD.js} +30 -29
  124. package/dist/{init-update-F3JZ2GEW.js → init-update-TQH2Q7IZ.js} +24 -23
  125. package/dist/install-cmd-PVQ5M5NM.js +21 -0
  126. package/dist/{layout-3YKZWTPE.js → layout-2DF7ON2F.js} +5 -5
  127. package/dist/{logs-HHNF6ABR.js → logs-BM644OOJ.js} +8 -7
  128. package/dist/loop-6MSKJN52.js +90 -0
  129. package/dist/machine-LGD4UVCI.js +79 -0
  130. package/dist/{machine-skills-4UHKD4HT.js → machine-skills-O7XAZYLN.js} +5 -5
  131. package/dist/{mcp-install-cmd-SQV4UZD6.js → mcp-install-cmd-METCXTTR.js} +5 -5
  132. package/dist/{mcp-serve-cmd-RKM4BLX3.js → mcp-serve-cmd-CTKBLSM6.js} +10 -9
  133. package/dist/{paths-WQUQWBL6.js → paths-VIBBLJ2W.js} +8 -7
  134. package/dist/pending-RXJKH4AC.js +18 -0
  135. package/dist/{pidfile-P6WZBOR4.js → pidfile-PAX5XHQJ.js} +9 -8
  136. package/dist/{record-WMING5ZQ.js → record-QPXOUL6F.js} +9 -8
  137. package/dist/{relay-NCWAF6NQ.js → relay-KASDMV3R.js} +6 -5
  138. package/dist/{relay-protocol-Y3HGIACN.js → relay-protocol-7HSCZC5H.js} +6 -5
  139. package/dist/runner-agents-WUMCXVS2.js +14 -0
  140. package/dist/runner-env-R2C5LYCX.js +24 -0
  141. package/dist/{runner-identity-ZCXCKYYO.js → runner-identity-UDPLWT7I.js} +11 -10
  142. package/dist/{runner-key-2ECLBGUH.js → runner-key-Z2IQ5TS7.js} +49 -48
  143. package/dist/{session-sender-JIWCOKW4.js → session-sender-4QKSVX5Z.js} +21 -20
  144. package/dist/{shell-function-H75JWHLA.js → shell-function-FTY7SSAJ.js} +2 -2
  145. package/dist/{spec-cmd-TQ6VCLCS.js → spec-cmd-TON4PYGQ.js} +16 -15
  146. package/dist/{starter-pack-3BXEKGIH.js → starter-pack-LAPDUG6E.js} +6 -6
  147. package/dist/state-OTWJW4O7.js +18 -0
  148. package/dist/{status-TFHPMLOA.js → status-ROMTDMFO.js} +49 -48
  149. package/dist/{statusline-fast-BTJSU3MB.js → statusline-fast-7V7U4SI4.js} +3 -3
  150. package/dist/{sync-cmd-TKGTFHFZ.js → sync-cmd-FLNYVXAE.js} +20 -19
  151. package/dist/update-steps-A5OSPYAS.js +80 -0
  152. package/dist/{watch-GMLQW3S7.js → watch-4V7FZI5R.js} +20 -19
  153. package/dist/{work-claim-cmd-I6VVJZHK.js → work-claim-cmd-5EYXVPKH.js} +22 -21
  154. package/dist/{work-cmd-UOLSKQ5A.js → work-cmd-RUOTA5K7.js} +15 -14
  155. package/dist/{work-comment-cmd-FMAHDTN4.js → work-comment-cmd-7UM3O3EL.js} +18 -17
  156. package/dist/{work-demo-cmd-BIONKBZM.js → work-demo-cmd-K4NRR2AK.js} +15 -14
  157. package/dist/{work-logs-cmd-IXHGQ443.js → work-logs-cmd-QW7PNI6V.js} +15 -14
  158. package/dist/{work-open-pr-cmd-E7KGEH42.js → work-open-pr-cmd-Y6MTWQG5.js} +16 -15
  159. package/dist/{work-pr-cmd-GWYKEMBY.js → work-pr-cmd-WUIMC7XB.js} +15 -14
  160. package/dist/{work-proofs-cmd-LY7OLWXH.js → work-proofs-cmd-5LMTROA6.js} +17 -16
  161. package/dist/{work-proofs-record-IPP6XUOF.js → work-proofs-record-3JGUT2F5.js} +26 -25
  162. package/dist/{work-stop-cmd-DJWAZRM3.js → work-stop-cmd-R5F5VRUM.js} +15 -14
  163. package/package.json +1 -1
  164. package/dist/agent-setup-7WC4BHY4.js +0 -39
  165. package/dist/caller-ZDANV7YK.js +0 -22
  166. package/dist/docker-POAJWLZ5.js +0 -19
  167. package/dist/find-unit-4EP7BW2F.js +0 -23
  168. package/dist/guest-init-4YXOOA6P.js +0 -19
  169. package/dist/host-checks-VUDUPDL2.js +0 -78
  170. package/dist/host-key-2OWJL2HZ.js +0 -17
  171. package/dist/init-MXVIYHXE.js +0 -78
  172. package/dist/install-cmd-4PDNS3MC.js +0 -20
  173. package/dist/loop-N3C4AOPY.js +0 -89
  174. package/dist/machine-JYGGT4TB.js +0 -78
  175. package/dist/pending-WSR6KRTI.js +0 -17
  176. package/dist/runner-env-NXNGYKU4.js +0 -23
  177. package/dist/state-ZOM5PUYK.js +0 -17
  178. package/dist/update-steps-BWIZEAAM.js +0 -79
@@ -1,50 +1,51 @@
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-A76SNTAM.js';
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 { hasStoredCredential, AGENT_COMMANDS, storeAgentCredential, credentialFromStdin, isAgentName } from './chunk-VQ4KQGLY.js';
7
- import { upgradedStarterText } from './chunk-VNYAJEKO.js';
8
- import { HELPER_PATH, HELPER_RECORD, DOCKERD_LOG } from './chunk-AXOO6FNA.js';
9
- import { senderPidfile } from './chunk-R3JSLSMG.js';
10
- import { installScrubContext } from './chunk-Q7BECZIF.js';
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-JZDTDGRO.js';
13
- import { claimCalls, spoolHomeFor, itemCalls, claimItem, leftByRunnerKey } from './chunk-DNUA6244.js';
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-XL6DG5LC.js';
16
- import { FETCHED_DIR, toolsDockerfile, FETCHED_FFMPEG, FETCHED_GH, FETCHED_TINI, FETCHED_HEADLESS_SHELL, FETCHED_PLAYWRIGHT_FFMPEG, FETCHED_VOICE_DIR } from './chunk-CDDWYP73.js';
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-3JVLRIX3.js';
20
- import { socketPathProblem, vsockLinks, linkVsockSockets, GUEST_CID, LEASE_LINK } from './chunk-PVUBF24F.js';
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-AU3QZKC4.js';
22
- import { writeDockerClientConfig } from './chunk-33OQSCE2.js';
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-EYUJCGF2.js';
24
- import { formatBytes, volumeBytes, allocatedBytes, DEFAULT_BUILD_DISK, DEFAULT_CACHE_DISK, freeBytes } from './chunk-PUPUOQ6Y.js';
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, 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-UCUZJ5W5.js';
26
- import { universalImagePending, RecipeError, writeSanitizedRecipe, classifyProperties, DOCKER_FEATURE } from './chunk-ASR6TU43.js';
27
- import { postJson, WorkCommandError, getJson, isSignatureRefusal } from './chunk-LFUEODDW.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-N3SO5VCM.js';
23
+ import { postJson, WorkCommandError, getJson, isSignatureRefusal } from './chunk-H4G26OZC.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-MDJ6ILXG.js';
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-GANI63IL.js';
32
- import { CHECKOUT_DIR, JOB_MOUNT, buildEnvironment, parseIsolation, containerLocalAddress, destinationEnvironment, withHooksPath, startBuildServices, headerVariables, authorEnvironment, sharedUserEnvironment, withTunnelRecord, commitIdentityRecord, repositoriesOf, RELAY_PORT, repositoryPath, lifecycleWorkdir, CHECK_ITEMS_FILE, proxyEnvironment, checkEnvironment, withMiseVariables, checkoutPath, EVAL_INPUT_DIR, isMiseVariableAllowed, BUILD_HOME, primaryOf } from './chunk-P63MQNDV.js';
33
- import { sharedSkillNames, skillConflictMessage } from './chunk-4XYEPTZP.js';
34
- import { versionAtLeast, MINIMUM_CLAUDE_VERSION } from './chunk-UWYU46GF.js';
35
- import { firecrackerArch, MICROVM_ARCHES, FIRECRACKER_VERSION, hostHelperPinned, builderDiskPinned, guestAssetsPinned, runnerAgentNamed, credentialForms, orList, credentialShapes, credentialAgent, agentCredential, RUNNER_WORDED_REASONS, UNKNOWN_TRACKING_REASON, UNKNOWN_TRANSPORT_REASON, 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, currentAgentCredential, removedAgentCredentialValues, managedAgentCredential, RELAY_USER, realFdStorePort, networkHelperPinned, NETWORK_HELPER_SHA256, universalImagePinned, builtInNames, UNIVERSAL_IMAGE, MAX_MALFORMED_SESSIONS, MALFORMED_REASON, JOIN_WAIT_MS, 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, MAX_OPEN_STREAMS, STREAM_RESET_RATE, STREAM_RESET_BURST, STREAM_WINDOW, SESSION_WINDOW, targetOfPath, agentVersionOf, AGENT_CREDENTIAL_MISSING, buildAgent, fdName, RELAY_ID, DOCKER_DESKTOP_REASON } from './chunk-QTU6GW2M.js';
36
- import { defaultAgents, parsePolicy, AGENTS_SKILLS_BASE, OUTERLAYER_SKILLS_BASE, resolvePackRoot, legacyAgent, orderSessions, extractFacts, sessionsToTimeline } from './chunk-EI22245K.js';
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, carried6to4, EVAL_INPUT_DIR, isMiseVariableAllowed, primaryOf } 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-FINJC6BS.js';
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';
44
45
  import { join, dirname, isAbsolute, delimiter, sep, basename, relative, resolve } from 'path';
45
46
  import { Readable, Transform, Duplex, PassThrough } from 'stream';
46
- import { spawn, spawnSync } from 'child_process';
47
47
  import { createServer, createConnection, connect, isIP } from 'net';
48
+ import { spawn, spawnSync } from 'child_process';
48
49
  import { availableParallelism, networkInterfaces, tmpdir } from 'os';
49
50
  import { once } from 'events';
50
51
  import { createServer as createServer$1, request } from 'http';
@@ -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, `${meta.sessionId}.jsonl`));
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
- const transcript = join(dir, `${parsed.sessionId}.jsonl`);
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 = [`${meta.sessionId}.jsonl`, meta.sessionId];
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}.jsonl` } };
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.jsonl" ] || exit 3; if [ -d "$2" ]; then exec tar -cf - "$2.jsonl" "$2"; else exec tar -cf - "$2.jsonl"; fi';
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", SESSION_PROJECT_DIR, input.sessionId], {
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,20 +376,85 @@ function managedClaudeKeyValuesFor(jobDir) {
367
376
  return key === void 0 ? [] : [key];
368
377
  }
369
378
  function hasClaudeCredential(config, hostEnv, jobDir, agents) {
370
- if (buildAgent(agents)?.adapter.credentials === void 0) return true;
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
  }
382
+ var PROXIED_SLOTS = 16;
383
+ var MAX_NAME_IN_DESTINATION = 40;
384
+ function destinationNameOf(variable) {
385
+ const readable = variable.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, MAX_NAME_IN_DESTINATION).replace(/-+$/g, "");
386
+ return readable === "" ? `var-${variable.slot}` : `var-${variable.slot}-${readable}`;
387
+ }
388
+ function destinationOf(variable) {
389
+ return {
390
+ name: destinationNameOf(variable),
391
+ upstream: new URL(variable.upstream).href,
392
+ header: { name: variable.header.name, value: variable.header.value.replace(/\$\{VALUE\}/g, `\${${variable.name}}`), variables: [variable.name] },
393
+ env: variable.env
394
+ };
395
+ }
396
+ var VARIABLE_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,254}$/;
397
+ function parseProxied(given, malformed) {
398
+ if (given === void 0) return { proxied: [] };
399
+ if (!Array.isArray(given)) return { problem: malformed };
400
+ if (given.length > maxDestinations()) {
401
+ return { problem: `the gateway sent ${given.length} variables for a service; a build holds at most ${maxDestinations()}` };
402
+ }
403
+ const proxied = [];
404
+ const names = /* @__PURE__ */ new Set();
405
+ const slots = /* @__PURE__ */ new Set();
406
+ for (const entry of given) {
407
+ if (typeof entry !== "object" || entry === null) return { problem: malformed };
408
+ const { name, value, slot, upstream, header, env } = entry;
409
+ if (typeof name !== "string" || typeof value !== "string" || typeof upstream !== "string") return { problem: malformed };
410
+ if (typeof slot !== "number" || !Number.isInteger(slot) || slot < 0 || slot >= PROXIED_SLOTS) return { problem: malformed };
411
+ if (typeof header !== "object" || header === null) return { problem: malformed };
412
+ const { name: headerName, value: headerValue } = header;
413
+ if (typeof headerName !== "string" || typeof headerValue !== "string") return { problem: malformed };
414
+ if (env !== void 0 && (typeof env !== "object" || env === null || Array.isArray(env))) return { problem: malformed };
415
+ if (!VARIABLE_NAME.test(name)) return { problem: `the factory's build variable ${JSON.stringify(name)} is not a variable name` };
416
+ if (names.has(name)) return { problem: `the factory's build variable ${name} is listed twice` };
417
+ if (slots.has(slot)) return { problem: `the factory's build variables ${name} and another use the slot ${slot}` };
418
+ names.add(name);
419
+ slots.add(slot);
420
+ if (value.trim().length < MIN_SCRUBBED_LITERAL) {
421
+ return { problem: `the value of the factory's build variable ${name} has fewer than ${MIN_SCRUBBED_LITERAL} characters, so the runner could not remove it from logs and transcripts` };
422
+ }
423
+ if ([...headerValue.matchAll(/\$\{([^}]*)\}/g)].some((match) => match[1] !== "VALUE") || !headerValue.includes("${VALUE}")) {
424
+ return { problem: `the header of the factory's build variable ${name} must name \${VALUE} and no other variable` };
425
+ }
426
+ const variable = { name, value, slot, upstream, header: { name: headerName, value: headerValue }, env: { ...env ?? {} } };
427
+ let reason;
428
+ try {
429
+ const resolved = resolveDestinations(
430
+ [{ name: destinationNameOf(variable), upstream, header: `${headerName}: ${headerValue.replace(/\$\{VALUE\}/g, `\${${name}}`)}`, env: variable.env }],
431
+ [],
432
+ isReservedVariable,
433
+ (key, why) => {
434
+ throw new Error(`${key} ${why}`);
435
+ }
436
+ );
437
+ const host = new URL(resolved[0].upstream).hostname.replace(/^\[|\]$/g, "");
438
+ if (isIP(host) !== 0 && classifyAddress(host) !== void 0) throw new Error(`upstream ${host} is a private address`);
439
+ } catch (err) {
440
+ reason = err instanceof Error ? err.message : "is refused";
441
+ }
442
+ if (reason !== void 0) return { problem: `the service of the factory's build variable ${name}: ${reason}` };
443
+ proxied.push(variable);
444
+ }
445
+ return { proxied };
446
+ }
373
447
 
374
448
  // src/runner/managed-build-settings.ts
375
449
  var FETCH_RETRY_WINDOW_MS2 = 3e4;
376
450
  var GIB = 1024 ** 3;
377
451
  var GB = 1e9;
378
- var VARIABLE_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,254}$/;
452
+ var VARIABLE_NAME2 = /^[A-Za-z_][A-Za-z0-9_]{0,254}$/;
379
453
  var MALFORMED = "the gateway's answer was not a machine, a list of hosts and a list of variables";
380
454
  function parseSettings(data) {
381
455
  const isPositive = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
382
456
  if (typeof data !== "object" || data === null) return { problem: MALFORMED };
383
- const { machine, allowHosts, variables } = data;
457
+ const { machine, allowHosts, variables, proxied } = data;
384
458
  if (typeof machine !== "object" || machine === null) return { problem: MALFORMED };
385
459
  const { size, vcpus, memoryGiB, diskGB } = machine;
386
460
  if (size !== "small" && size !== "large" || !isPositive(vcpus) || !isPositive(memoryGiB) || !isPositive(diskGB)) return { problem: MALFORMED };
@@ -395,13 +469,21 @@ function parseSettings(data) {
395
469
  if (typeof entry !== "object" || entry === null) return { problem: MALFORMED };
396
470
  const { name, value } = entry;
397
471
  if (typeof name !== "string" || name === "" || typeof value !== "string") return { problem: MALFORMED };
398
- if (!VARIABLE_NAME.test(name)) return { problem: `the factory's build variable ${JSON.stringify(name)} is not a variable name` };
472
+ if (!VARIABLE_NAME2.test(name)) return { problem: `the factory's build variable ${JSON.stringify(name)} is not a variable name` };
399
473
  if (value.trim().length < MIN_SCRUBBED_LITERAL) {
400
474
  return { problem: `the value of the factory's build variable ${name} has fewer than ${MIN_SCRUBBED_LITERAL} characters, so the runner could not remove it from logs and transcripts` };
401
475
  }
402
476
  parsed.push({ name, value });
403
477
  }
404
- return { settings: { machine: { size, vcpus, memoryGiB, diskGB }, allowHosts: [...allowHosts], variables: parsed } };
478
+ const sent = parseProxied(proxied, MALFORMED);
479
+ if ("problem" in sent) return { problem: sent.problem };
480
+ const plain3 = new Set(parsed.map((variable) => variable.name));
481
+ for (const variable of sent.proxied) {
482
+ for (const name of [variable.name, ...Object.keys(variable.env)]) {
483
+ if (plain3.has(name)) return { problem: `the gateway listed the factory's build variable ${name} as plain and as sent to a service` };
484
+ }
485
+ }
486
+ return { settings: { machine: { size, vcpus, memoryGiB, diskGB }, allowHosts: [...allowHosts], variables: parsed, proxied: sent.proxied } };
405
487
  }
406
488
  async function fetchManagedBuildSettings(config, item, deps = {}) {
407
489
  const fetchImpl = deps.fetchImpl ?? fetch;
@@ -425,10 +507,11 @@ function dropManagedBuildSettings(jobDir) {
425
507
  held2.delete(jobDir);
426
508
  }
427
509
  function managedBuildSettingValues() {
428
- return [...new Set([...held2.values()].flatMap((settings) => settings.variables.map(({ value }) => value)))];
510
+ return [...new Set([...held2.values()].flatMap((settings) => [...settings.variables, ...settings.proxied ?? []].map(({ value }) => value)))];
429
511
  }
430
512
  function managedBuildSettingValuesFor(jobDir) {
431
- return [...new Set((held2.get(jobDir)?.variables ?? []).map(({ value }) => value))];
513
+ const settings = held2.get(jobDir);
514
+ return [...new Set([...settings?.variables ?? [], ...settings?.proxied ?? []].map(({ value }) => value))];
432
515
  }
433
516
  function managedMachineLimits(settings) {
434
517
  const { vcpus, memoryGiB, diskGB } = settings.machine;
@@ -438,6 +521,34 @@ function withFactoryHosts(runnerHosts, settings) {
438
521
  if (settings === void 0) return runnerHosts;
439
522
  return [.../* @__PURE__ */ new Set([...runnerHosts ?? [], ...settings.allowHosts])];
440
523
  }
524
+
525
+ // src/runner/factory-destinations.ts
526
+ var STAND_IN = "olvar_placeholder-not-a-real-value";
527
+ var FACTORY_INDEX_BASE = 32;
528
+ function heldValue(jobDir, name) {
529
+ const env = /* @__PURE__ */ Object.create(null);
530
+ Object.defineProperty(env, name, { enumerable: true, get: () => managedBuildSettingsFor(jobDir)?.proxied?.find((entry) => entry.name === name)?.value });
531
+ return env;
532
+ }
533
+ function factoryDestinations(jobDir) {
534
+ return (managedBuildSettingsFor(jobDir)?.proxied ?? []).map((variable) => ({
535
+ destination: destinationOf(variable),
536
+ hostEnv: heldValue(jobDir, variable.name),
537
+ index: FACTORY_INDEX_BASE + variable.slot
538
+ }));
539
+ }
540
+ function factoryIndexes(jobDir) {
541
+ return (managedBuildSettingsFor(jobDir)?.proxied ?? []).map((variable) => FACTORY_INDEX_BASE + variable.slot);
542
+ }
543
+ function proxiedEnvironment(jobDir) {
544
+ const env = {};
545
+ for (const variable of managedBuildSettingsFor(jobDir)?.proxied ?? []) {
546
+ env[variable.name] = STAND_IN;
547
+ const local = containerLocalAddress(FACTORY_INDEX_BASE + variable.slot);
548
+ for (const [name, value] of Object.entries(variable.env)) env[name] = value.split("{local}").join(local);
549
+ }
550
+ return env;
551
+ }
441
552
  var AssetError = class extends Error {
442
553
  constructor(file, message) {
443
554
  super(message);
@@ -801,7 +912,7 @@ function converterArgs(dest, memoryBytes, extra, script) {
801
912
  script
802
913
  ];
803
914
  }
804
- var firstLine = (text2) => text2.trim().split("\n")[0] ?? "";
915
+ var firstLine2 = (text2) => text2.trim().split("\n")[0] ?? "";
805
916
  function exportInto(container, converter) {
806
917
  return new Promise((resolve2, reject) => {
807
918
  const exporter = spawn("docker", ["export", container], { stdio: ["ignore", "pipe", "pipe"], env: childEnvironment(process.env) });
@@ -821,7 +932,7 @@ function exportInto(container, converter) {
821
932
  exits += 1;
822
933
  if (exits < 2) return;
823
934
  if (failure3 === void 0) resolve2();
824
- else reject(new Error(`${failure3}: ${firstLine(errors.join("\n"))}`));
935
+ else reject(new Error(`${failure3}: ${firstLine2(errors.join("\n"))}`));
825
936
  };
826
937
  exporter.once("exit", (code) => done("docker export", code));
827
938
  writer.once("exit", (code) => done("the converter", code));
@@ -832,7 +943,7 @@ function createRootfsHost() {
832
943
  return {
833
944
  async convert({ imageId, dest, memoryBytes }) {
834
945
  const created = await spawnRun("docker", ["create", imageId, "none"], { env: env() });
835
- if (created.status !== 0) throw new Error(`docker create ${imageId} failed: ${firstLine(created.stderr)}`);
946
+ if (created.status !== 0) throw new Error(`docker create ${imageId} failed: ${firstLine2(created.stderr)}`);
836
947
  const container = created.stdout.trim();
837
948
  try {
838
949
  await exportInto(container, converterArgs(dest, memoryBytes, [], converterScript()));
@@ -845,11 +956,11 @@ function createRootfsHost() {
845
956
  truncateSync(dest, bytes);
846
957
  const path = [process.env.PATH, "/usr/sbin", "/sbin"].filter((entry) => entry !== void 0 && entry !== "").join(":");
847
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 } });
848
- if (made.status !== 0) throw new Error(`making the empty build disk failed: ${firstLine(made.stderr)}`);
959
+ if (made.status !== 0) throw new Error(`making the empty build disk failed: ${firstLine2(made.stderr)}`);
849
960
  },
850
961
  async imageConfig(imageId) {
851
962
  const inspected = await spawnRun("docker", ["image", "inspect", "--format", "{{json .Config}}", imageId], { env: env() });
852
- if (inspected.status !== 0) throw new Error(`docker image inspect ${imageId} failed: ${firstLine(inspected.stderr)}`);
963
+ if (inspected.status !== 0) throw new Error(`docker image inspect ${imageId} failed: ${firstLine2(inspected.stderr)}`);
853
964
  return parseImageConfig(inspected.stdout);
854
965
  }
855
966
  };
@@ -903,7 +1014,7 @@ async function createBuildDisk(input) {
903
1014
  if (input.host.copyTemplate) input.host.copyTemplate(template, input.dest);
904
1015
  else {
905
1016
  const copied = spawnSync("cp", ["--sparse=always", template, input.dest], { encoding: "utf8" });
906
- if (copied.status !== 0) throw new Error(`copying the empty build disk failed: ${firstLine(copied.stderr)}`);
1017
+ if (copied.status !== 0) throw new Error(`copying the empty build disk failed: ${firstLine2(copied.stderr)}`);
907
1018
  }
908
1019
  }
909
1020
  chmodSync(input.dest, RUNNER_FILE_MODE);
@@ -1733,9 +1844,9 @@ function handedCredential(value, agents) {
1733
1844
  if (typeof value !== "string") throw new RunnerInitError(`the config on stdin carries a ${key} that is not text.`);
1734
1845
  return credentialFromStdin(value, agents);
1735
1846
  }
1736
- function handedAgent(value) {
1847
+ function handedAgent(value, agents) {
1737
1848
  if (value === void 0) return void 0;
1738
- 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.");
1739
1850
  return value;
1740
1851
  }
1741
1852
  function parseStdinConfig(configPath, text2, agents) {
@@ -1755,7 +1866,7 @@ function parseStdinConfig(configPath, text2, agents) {
1755
1866
  const carried = config.runner;
1756
1867
  const key = credentialHandOffKey(agents);
1757
1868
  const credential = handedCredential(config[key], agents);
1758
- const agent = handedAgent(config.agent);
1869
+ const agent = handedAgent(config.agent, agents);
1759
1870
  delete config.runner;
1760
1871
  delete config[key];
1761
1872
  delete config.agent;
@@ -1824,7 +1935,7 @@ function writeRunnerInit(prepared, runnerKey) {
1824
1935
  ...carried,
1825
1936
  ...host === void 0 ? {} : { name: host },
1826
1937
  // The agent was named on this command line, so its commands win over any the hand-off carried.
1827
- ...agent === void 0 ? {} : { commands: { ...AGENT_COMMANDS[agent] } },
1938
+ ...agent === void 0 ? {} : { commands: { ...agentCommands(agent, agents) } },
1828
1939
  hooks: { provision: hooks, cleanup: hooks }
1829
1940
  };
1830
1941
  if (host !== void 0) delete config.runner.host;
@@ -1846,24 +1957,35 @@ function placeholderProblem(queues) {
1846
1957
  const keys = queues.map((queue) => `runner.commands.${queue}`).join(", ");
1847
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`;
1848
1959
  }
1849
- var CLAUDE_PERMISSION_MODES = ["acceptEdits", "auto", "bypassPermissions", "default", "dontAsk", "manual", "plan"];
1850
- var CLAUDE_COMMAND = /(?:^|[;&|(])\s*(?:(?:exec|env|nohup|time)\s+)*(?:[A-Za-z_][A-Za-z0-9_]*=\S*\s+)*(?:\S*\/)?claude\s/;
1851
- var PERMISSION_MODE_FLAG = /--permission-mode(?:=|\s+)(?:"([^"]*)"|'([^']*)'|([^\s;&|()]+))/g;
1852
- function permissionModeProblems(config) {
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);
1853
1972
  const problems = [];
1854
1973
  for (const queue of config.queues) {
1855
1974
  const command = config.commands[queue];
1856
- if (command === void 0 || !CLAUDE_COMMAND.test(command)) continue;
1857
- for (const match of command.matchAll(PERMISSION_MODE_FLAG)) {
1975
+ if (command === void 0 || !program.test(command)) continue;
1976
+ for (const match of command.matchAll(permissionFlagPattern(mode.flag))) {
1858
1977
  const value = match[1] ?? match[2] ?? match[3] ?? "";
1859
- if (value.includes("$") || value.includes("`") || CLAUDE_PERMISSION_MODES.includes(value)) continue;
1978
+ if (value.includes("$") || value.includes("`") || mode.accepted.includes(value)) continue;
1860
1979
  problems.push({ queue, command, value });
1861
1980
  }
1862
1981
  }
1863
1982
  return problems;
1864
1983
  }
1865
- function permissionModeProblem(problems) {
1866
- return problems.map(({ queue, command, value }) => `runner.commands.${queue} is \`${command}\`, and \`${value}\` is not a permission mode Claude Code accepts (${CLAUDE_PERMISSION_MODES.join(", ")}). The command would fail only when a build ran it`).join(". ");
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(". ");
1867
1989
  }
1868
1990
  var FORMER_AMEND_COMMAND = /(^|["'\s])\/amend(?=["'\s]|$)/g;
1869
1991
  function currentSkillCommand(command) {
@@ -1951,27 +2073,39 @@ async function claimPermissionProblem(config, fetchImpl = fetch) {
1951
2073
  }
1952
2074
 
1953
2075
  // src/runner/build-skill-check.ts
1954
- var BUILD_SKILL_PATHS = [".agents/skills/build/SKILL.md", ".claude/skills/build/SKILL.md"];
1955
- var BUILD_COMMAND = /(?:^|["']|(?:^|\s)(?:claude|-p|--print)\s+)\/build(?=["'\s]|$)/;
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
+ }
1956
2089
  var BUILD_DIRECTORY_USE = /(?:^|[\s;&|])(?:cd|pushd|--add-dir|--cwd|-C)\s+["']?\/build(?=["'\s;&|]|$)/g;
1957
- function needsBuildSkill(queue, command) {
2090
+ function needsBuildSkill(queue, command, agents = defaultAgents()) {
1958
2091
  if (queue !== "implement" || command === void 0) return false;
1959
- return BUILD_COMMAND.test(currentSkillCommand(command).replace(BUILD_DIRECTORY_USE, " "));
2092
+ return buildCommandPattern(agents).test(currentSkillCommand(command).replace(BUILD_DIRECTORY_USE, " "));
1960
2093
  }
1961
- function missingBuildSkillReason(governed, lookupFailure) {
1962
- const checked = governed === void 0 ? BUILD_SKILL_PATHS.join(" and ") : `${BUILD_SKILL_PATHS.join(", ")} and the governed context from ${governed.repository}@${governed.commit.slice(0, 7)}`;
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)}`;
1963
2097
  const lookup3 = lookupFailure === void 0 ? "" : `, and the lookup of the governing repository failed (${lookupFailure})`;
1964
2098
  return `the build has no \`build\` skill, so /build would load nothing${lookup3}: checked ${checked}`;
1965
2099
  }
1966
- function cloneHasBuildSkill(checkout) {
1967
- return BUILD_SKILL_PATHS.some((path) => existsSync(join(checkout, path)));
2100
+ function cloneHasBuildSkill(checkout, agents = defaultAgents()) {
2101
+ return buildSkillPaths(agents).some((path) => existsSync(join(checkout, path)));
1968
2102
  }
1969
- async function decideHostBuildSkill(input) {
2103
+ async function decideHostBuildSkill(input, agents = defaultAgents()) {
1970
2104
  const { requireBuildSkill, containerMode, vmMode, workdir, repository } = input;
1971
- 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" };
1972
2106
  const governing = repository === void 0 ? void 0 : await input.lookup(repository);
1973
2107
  if (governing?.ok === true && governing.source.kind !== "self") return { kind: "warn" };
1974
- 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);
1975
2109
  return { kind: "refuse", reason };
1976
2110
  }
1977
2111
  var BranchPrepareError = class extends Error {
@@ -1995,13 +2129,13 @@ function localGit(cwd, args) {
1995
2129
  }
1996
2130
  return Promise.resolve({ status: result.status, stdout: result.stdout.trim(), stderr: result.stderr.trim() });
1997
2131
  }
1998
- function firstLine2(stderr) {
2132
+ function firstLine3(stderr) {
1999
2133
  return (stderr.split("\n")[0] ?? "").replace(/\/\/[^/@\s]+@/g, "//");
2000
2134
  }
2001
2135
  async function mustGit(git2, cwd, step, args) {
2002
2136
  const result = await git2(cwd, args);
2003
2137
  if (result.status !== 0) {
2004
- const detail = firstLine2(result.stderr);
2138
+ const detail = firstLine3(result.stderr);
2005
2139
  throw new BranchPrepareError(`${step} failed${detail === "" ? "" : `: ${detail}`}`);
2006
2140
  }
2007
2141
  return result.stdout;
@@ -2046,7 +2180,7 @@ async function isMerged(git2, workdir, branch, defaultBranch) {
2046
2180
  const result = await git2(workdir, ["merge-base", "--is-ancestor", `origin/${branch}`, `origin/${defaultBranch}`]);
2047
2181
  if (result.status === 0) return true;
2048
2182
  if (result.status === 1) return false;
2049
- const detail = firstLine2(result.stderr);
2183
+ const detail = firstLine3(result.stderr);
2050
2184
  throw new BranchPrepareError(`comparing ${branch} with ${defaultBranch} failed${detail === "" ? "" : `: ${detail}`}`);
2051
2185
  }
2052
2186
 
@@ -2080,15 +2214,6 @@ function lifecycleFailureReason(step, exitCode) {
2080
2214
  return `lifecycle command ${step.name} (${step.source}) exited ${exitCode}`;
2081
2215
  }
2082
2216
 
2083
- // src/runner/command-output.ts
2084
- function firstLine3(text2) {
2085
- return text2.trim().split("\n")[0] ?? "";
2086
- }
2087
- function said(output) {
2088
- const line2 = firstLine3(output);
2089
- return line2 === "" ? "" : `: ${line2}`;
2090
- }
2091
-
2092
2217
  // src/runner/runtimes.ts
2093
2218
  var RUNTIMES = ["node", "python", "go", "rust", "ruby", "java"];
2094
2219
  var MANIFESTS = {
@@ -2176,7 +2301,7 @@ var goToolchain = async (context) => {
2176
2301
  const ran = await context.input.exec(["go", "version"], context.path);
2177
2302
  if (ran.status !== 0) return `runtime_install_failed: go version failed in ${context.entry.repository} (exit ${ran.status})${said(ran.stderr)}${refusalNote(context)}`;
2178
2303
  const version = /\bgo(\d+\.\d+(?:\.\d+)?\S*)/.exec(ran.stdout)?.[1];
2179
- line(context, `go ${version ?? firstLine3(ran.stdout)} from go.mod`);
2304
+ line(context, `go ${version ?? firstLine(ran.stdout)} from go.mod`);
2180
2305
  return void 0;
2181
2306
  };
2182
2307
  var rustToolchain = async (context) => {
@@ -2185,7 +2310,7 @@ var rustToolchain = async (context) => {
2185
2310
  const ran = await context.input.exec(["rustc", "--version"], context.path);
2186
2311
  if (ran.status !== 0) return `runtime_install_failed: rustc --version failed in ${context.entry.repository} (exit ${ran.status})${said(ran.stderr)}${refusalNote(context)}`;
2187
2312
  const version = /\brustc (\S+)/.exec(ran.stdout)?.[1];
2188
- line(context, `rust ${version ?? firstLine3(ran.stdout)} from ${pin}`);
2313
+ line(context, `rust ${version ?? firstLine(ran.stdout)} from ${pin}`);
2189
2314
  return void 0;
2190
2315
  };
2191
2316
  function parseVariables(stdout) {
@@ -2409,18 +2534,23 @@ function gitErrorLine(text2) {
2409
2534
  return lines.find((line2) => /^(fatal|error):/.test(line2)) ?? lines.at(-1) ?? "";
2410
2535
  }
2411
2536
  var STAGED_TREE = `${JOB_MOUNT}/context/tree`;
2412
- var DELIVER_SCRIPT = [
2413
- "set -e",
2414
- 'src="$1"; dest="$2"',
2415
- 'if [ -e "$dest" ]; then chmod -R u+w "$dest"; rm -rf "$dest"; fi',
2416
- 'mkdir -p "$dest"',
2417
- "for entry in AGENTS.md CLAUDE.md settings.json .claude .outerlayer .agents; do",
2418
- ' if [ -e "$src/$entry" ]; then cp -R "$src/$entry" "$dest/"; fi',
2419
- "done",
2420
- 'chmod -R a-w "$dest"'
2421
- ].join("\n");
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._-]+$/;
2422
2550
  var RECORD_SCRIPT = 'd="$(git rev-parse --git-common-dir)" && mkdir -p "$d/outerlayer" && printf "%s" "$1" > "$d/outerlayer/delivery.json"';
2423
- var WRITE_SHIM_SCRIPT = 'mkdir -p "$1" && printf "%s" "$2" > "$1/claude" && chmod 755 "$1/claude"';
2551
+ function writeShimScript(program) {
2552
+ return `mkdir -p "$1" && printf "%s" "$2" > "$1/${program}" && chmod 755 "$1/${program}"`;
2553
+ }
2424
2554
  function failure(what, result) {
2425
2555
  return `context_delivery_failed: ${what} (exit ${result.status})${said(result.stderr)}`;
2426
2556
  }
@@ -2429,38 +2559,48 @@ async function repositorySkills(input, folder) {
2429
2559
  if (listed.status !== 0) return /* @__PURE__ */ new Set();
2430
2560
  return new Set(listed.stdout.split("\n").map((name) => name.trim()));
2431
2561
  }
2432
- async function deliveryRefusal(input, staged) {
2433
- if (input.agentVersion !== void 0 && !versionAtLeast(input.agentVersion)) {
2434
- return `context_agent_too_old: the build image's Claude Code is ${input.agentVersion}, and a governed build needs ${MINIMUM_CLAUDE_VERSION} or later to load its control plane's instructions; rebuild the image`;
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`;
2435
2569
  }
2436
- const own = /* @__PURE__ */ new Map([
2437
- [".claude/skills", await repositorySkills(input, ".claude/skills")],
2438
- [".agents/skills", await repositorySkills(input, ".agents/skills")]
2439
- ]);
2440
- 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)));
2441
2573
  if (clash === void 0) return void 0;
2442
- const folder = own.get(".claude/skills").has(clash) ? ".claude/skills" : ".agents/skills";
2574
+ const folder = [...own.keys()].find((candidate) => own.get(candidate).has(clash));
2443
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`;
2444
2576
  }
2445
2577
  async function checkoutHasBuildSkill(input) {
2446
- for (const path of BUILD_SKILL_PATHS) {
2578
+ for (const path of buildSkillPaths(input.agents)) {
2447
2579
  const probe = await input.exec(["test", "-f", path], CHECKOUT_DIR, { quiet: true });
2448
2580
  if (probe.status === 0) return true;
2449
2581
  if (probe.status !== 1) return { failed: failure(`checking for ${path} failed`, probe) };
2450
2582
  }
2451
2583
  return false;
2452
2584
  }
2453
- function stagedHasBuildSkill(staged) {
2454
- return existsSync(join(staged.dir, "tree", ".claude/skills/build/SKILL.md"));
2455
- }
2456
- async function writeShim(input) {
2457
- const shim = await input.exec(["sh", "-c", WRITE_SHIM_SCRIPT, "shim", SHIM_DIR, shimScript()], "/build/work");
2458
- if (shim.status !== 0) return { ok: false, reason: failure("writing the claude shim failed", shim) };
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) };
2459
2597
  return { ok: true };
2460
2598
  }
2461
- async function deliver(input, staged) {
2599
+ async function deliver(input, staged, entries) {
2462
2600
  const dir = deliveryDir(staged.repository, staged.sha);
2463
- const copied = await input.exec(["sh", "-c", DELIVER_SCRIPT, "deliver", STAGED_TREE, dir], "/build/work");
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");
2464
2604
  if (copied.status !== 0) return { ok: false, reason: failure("copying the control plane into the build failed", copied) };
2465
2605
  const record = JSON.stringify({ schemaVersion: 1, repository: staged.repository, ref: staged.ref, sha: staged.sha, dir });
2466
2606
  const recorded = await input.exec(["sh", "-c", RECORD_SCRIPT, "record", record], CHECKOUT_DIR);
@@ -2606,26 +2746,33 @@ async function runBuildSteps(input) {
2606
2746
  const staged = await input.stageContext();
2607
2747
  if (staged.kind === "refused") return { ok: false, reason: staged.reason };
2608
2748
  let controlPlane;
2609
- if (input.requireBuildSkill === true && !(staged.kind === "staged" && stagedHasBuildSkill(staged))) {
2749
+ if (input.requireBuildSkill === true && !(staged.kind === "staged" && stagedHasBuildSkill(staged, input))) {
2610
2750
  const held3 = await checkoutHasBuildSkill(input);
2611
2751
  if (held3 !== true) {
2612
2752
  if (staged.kind === "staged") input.removeStagedContext();
2613
2753
  if (held3 !== false) return { ok: false, reason: held3.failed };
2614
- 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) };
2615
2755
  }
2616
2756
  }
2617
- const shimmed = await writeShim(input);
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);
2618
2763
  if (!shimmed.ok) {
2619
2764
  if (staged.kind === "staged") input.removeStagedContext();
2620
2765
  return shimmed;
2621
2766
  }
2622
2767
  if (staged.kind === "staged") {
2623
2768
  try {
2624
- const refusal = await deliveryRefusal(input, staged);
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);
2625
2772
  if (refusal !== void 0) return { ok: false, reason: refusal };
2626
2773
  const handed = await input.deliverContext?.(staged) ?? { ok: true };
2627
2774
  if (!handed.ok) return { ok: false, reason: handed.reason };
2628
- const delivered = await deliver(input, staged);
2775
+ const delivered = await deliver(input, staged, context.deliveredEntries);
2629
2776
  if (!delivered.ok) return delivered;
2630
2777
  controlPlane = { repository: staged.repository, commit: staged.sha };
2631
2778
  try {
@@ -3159,27 +3306,29 @@ async function saveMicroVmDiskState(input) {
3159
3306
  }
3160
3307
  }
3161
3308
  var EVAL_INPUT_NAME = "eval-input";
3162
- var TRANSCRIPT_ROOT = "/build/home/.claude/projects";
3309
+ sessionFolderIn(BUILD_HOME, legacyAgent().descriptor);
3163
3310
  var MAX_TRANSCRIPT_BYTES = 7 * 1024 * 1024;
3164
3311
  var MAX_TRANSCRIPTS = 500;
3165
3312
  var MAX_TOTAL_TRANSCRIPT_BYTES = 64 * 1024 * 1024;
3166
3313
  var TRANSCRIPT_COPY_MS = 2 * 60 * 1e3;
3167
- var BUILD_HOME2 = "/build/home";
3168
3314
  function firstLine4(text2) {
3169
3315
  return text2.trim().split("\n")[0] ?? "";
3170
3316
  }
3171
- async function copyTranscripts(run, now = Date.now) {
3317
+ async function copyTranscripts(run, now = Date.now, agents = defaultAgents()) {
3318
+ const agent = jobAgent(void 0, agents);
3319
+ if (agent === void 0) return { ok: true, copied: [], missed: [] };
3320
+ const root = sessionFolderIn(BUILD_HOME, agent.descriptor);
3172
3321
  const deadline = now() + TRANSCRIPT_COPY_MS;
3173
3322
  let listed;
3174
3323
  try {
3175
- listed = await run(["find", TRANSCRIPT_ROOT, "-type", "f", "-name", "*.jsonl", "-print0"]);
3324
+ listed = await run(["find", root, "-type", "f", "-name", "*.jsonl", "-print0"]);
3176
3325
  } catch (err) {
3177
3326
  return { ok: false, reason: describeCallFailure(err) };
3178
3327
  }
3179
3328
  if (listed.status !== 0 && !/No such file or directory/.test(listed.stderr)) {
3180
3329
  return { ok: false, reason: `listing the transcripts failed (exit ${listed.status})${firstLine4(listed.stderr) === "" ? "" : `: ${firstLine4(listed.stderr)}`}` };
3181
3330
  }
3182
- const paths = listed.stdout.split("\0").filter((entry) => entry.startsWith(`${TRANSCRIPT_ROOT}/`) && !entry.includes("\n") && !entry.slice(TRANSCRIPT_ROOT.length + 1).split("/").includes("..")).map((entry) => entry.slice(TRANSCRIPT_ROOT.length + 1)).sort();
3331
+ 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();
3183
3332
  const copied = [];
3184
3333
  const missed = [];
3185
3334
  let total = 0;
@@ -3193,7 +3342,7 @@ async function copyTranscripts(run, now = Date.now) {
3193
3342
  continue;
3194
3343
  }
3195
3344
  try {
3196
- const read = await run(["head", "-c", String(MAX_TRANSCRIPT_BYTES + 1), `${TRANSCRIPT_ROOT}/${path}`]);
3345
+ const read = await run(["head", "-c", String(MAX_TRANSCRIPT_BYTES + 1), `${root}/${path}`]);
3197
3346
  if (read.status !== 0) missed.push({ path, reason: `reading it failed (exit ${read.status})${firstLine4(read.stderr) === "" ? "" : `: ${firstLine4(read.stderr)}`}` });
3198
3347
  else if (Buffer.byteLength(read.stdout) > MAX_TRANSCRIPT_BYTES) missed.push({ path, reason: `it is larger than ${MAX_TRANSCRIPT_BYTES / (1024 * 1024)} MiB` });
3199
3348
  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` });
@@ -3231,7 +3380,7 @@ function forkRecordOf(job) {
3231
3380
  }
3232
3381
  function scrubbing(scrub, author, work) {
3233
3382
  setCustomScrubbers(scrub, () => void 0);
3234
- setLocalIdentity({ home: BUILD_HOME2, ...author?.name === void 0 ? {} : { name: author.name }, ...author?.email === void 0 ? {} : { email: author.email } });
3383
+ setLocalIdentity({ home: BUILD_HOME, ...author?.name === void 0 ? {} : { name: author.name }, ...author?.email === void 0 ? {} : { email: author.email } });
3235
3384
  setRepoRoot(CHECKOUT_DIR);
3236
3385
  try {
3237
3386
  return work();
@@ -3638,7 +3787,7 @@ async function writeGuestGhConfig(runtime, state, token) {
3638
3787
  `mv ${GUEST_GH_DIR}/config.yml.partial ${GUEST_GH_DIR}/config.yml`
3639
3788
  ].join("\n");
3640
3789
  const result = await asRoot(runtime, state, ["/bin/sh", "-c", script], ghHostsYml(token));
3641
- if (result.status !== 0) throw new Error(`writing gh's configuration in the guest failed (exit ${result.status}): ${firstLine3(result.stderr)}`);
3790
+ if (result.status !== 0) throw new Error(`writing gh's configuration in the guest failed (exit ${result.status}): ${firstLine(result.stderr)}`);
3642
3791
  }
3643
3792
  async function mountGuestHome(runtime, state, agentUser, known) {
3644
3793
  let home = known;
@@ -3663,7 +3812,7 @@ var NO_FOLDER = 3;
3663
3812
  async function unpackIntoGuest(runtime, state, dir, target2, opts = {}) {
3664
3813
  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}`;
3665
3814
  const result = await asRoot(runtime, state, ["/bin/sh", "-c", script], tarOf(dir));
3666
- if (result.status !== 0) throw new Error(`unpacking into ${target2} in the guest failed (exit ${result.status}): ${firstLine3(result.stderr)}`);
3815
+ if (result.status !== 0) throw new Error(`unpacking into ${target2} in the guest failed (exit ${result.status}): ${firstLine(result.stderr)}`);
3667
3816
  }
3668
3817
  async function deliverCommitHooks(input) {
3669
3818
  await unpackIntoGuest(input.runtime, input.state, input.hooksDir, GUEST_HOOKS_DIR);
@@ -3835,7 +3984,8 @@ async function provisionMicroVmOnce(input, allowRestore, itemDiskFailed) {
3835
3984
  agents: runtime.agents,
3836
3985
  containerEnv: report.apply.containerEnv,
3837
3986
  builtIns: true,
3838
- factoryVariables: factoryVariablesOf(config, jobDir)
3987
+ factoryVariables: factoryVariablesOf(config, jobDir),
3988
+ proxiedEnvironment: proxiedEnvironment(jobDir)
3839
3989
  };
3840
3990
  const env = buildEnvironment(envInput);
3841
3991
  if (env.skippedTokenVariables.length > 0) {
@@ -3903,7 +4053,7 @@ async function provisionMicroVmOnce(input, allowRestore, itemDiskFailed) {
3903
4053
  } catch (err) {
3904
4054
  return bail(`the tunnel could not start: ${describeCallFailure(err)}`);
3905
4055
  }
3906
- const links = vsockLinks({ destinations: config.build?.destinations?.length ?? 0, builtIns: true }, runtime.agents);
4056
+ const links = vsockLinks({ destinations: config.build?.destinations?.length ?? 0, builtIns: true, factory: factoryIndexes(jobDir) }, runtime.agents);
3907
4057
  const served = input.leaseTimeLeftMs === void 0 ? links : [...links, LEASE_LINK];
3908
4058
  let leaseServer;
3909
4059
  if (input.leaseTimeLeftMs !== void 0) {
@@ -4076,9 +4226,8 @@ async function provisionMicroVmOnce(input, allowRestore, itemDiskFailed) {
4076
4226
  const tools = await asRoot(runtime, state, ["cat", "/opt/outerlayer/tools.json"]);
4077
4227
  const agentVersion = agentVersionOf(tools.status === 0 ? tools.stdout : "", runtime.agents);
4078
4228
  environment.agentVersion = agentVersion;
4079
- const program = await asRoot(runtime, state, [...HASH_ARGV]);
4080
- const hashed = program.status === 0 ? parseProgramHash(program.stdout) : void 0;
4081
- if (hashed !== void 0) state.judgeProgram = { path: JUDGE_PROGRAM, sha256: hashed };
4229
+ const recorded = await judgeProgramRecord((argv) => asRoot(runtime, state, argv), runtime.agents);
4230
+ if (recorded !== void 0) state.judgeProgram = recorded;
4082
4231
  input.save(state, environment);
4083
4232
  if (report.docker === true) {
4084
4233
  const failure3 = await waitForDocker(runtime, state, agentUser, input.now ?? (() => /* @__PURE__ */ new Date()));
@@ -4116,6 +4265,7 @@ async function provisionMicroVmOnce(input, allowRestore, itemDiskFailed) {
4116
4265
  repositories,
4117
4266
  ...governingSource.kind === "governed" ? { governing: { repository: governingSource.repository } } : {},
4118
4267
  agentVersion,
4268
+ agents: runtime.agents,
4119
4269
  lifecycle: report.apply.lifecycle,
4120
4270
  exec: stepExecFor({ vm, vsockPath: state.vsockPath, request, logPath }),
4121
4271
  log,
@@ -4166,11 +4316,11 @@ async function waitForDocker(runtime, state, agentUser, now) {
4166
4316
  for (; ; ) {
4167
4317
  const granted = await asRoot(runtime, state, ["/bin/sh", "-c", grant]);
4168
4318
  if (granted.status !== 0) {
4169
- if (firstLine3(granted.stderr) !== "") lastError = `giving the agent's group the Docker socket failed: ${firstLine3(granted.stderr)}`;
4319
+ if (firstLine(granted.stderr) !== "") lastError = `giving the agent's group the Docker socket failed: ${firstLine(granted.stderr)}`;
4170
4320
  } else {
4171
4321
  const answered = await runtime.vm.exec(state.vsockPath, request);
4172
4322
  if (answered.status === 0) return writeDockerClientConfig(asRoot.bind(null, runtime, state), agentUser);
4173
- lastError = firstLine3(answered.stderr) === "" ? "" : `docker info said: ${firstLine3(answered.stderr)}`;
4323
+ lastError = firstLine(answered.stderr) === "" ? "" : `docker info said: ${firstLine(answered.stderr)}`;
4174
4324
  }
4175
4325
  if (now().getTime() >= deadline) break;
4176
4326
  await runtime.sleep(1e3);
@@ -4197,7 +4347,8 @@ function vmExecFor(input, argv) {
4197
4347
  miseVariables: state.miseVariables,
4198
4348
  builtIns: state.builtIns === true,
4199
4349
  identity: input.job.commitIdentity,
4200
- factoryVariables: factoryVariablesOf(input.config, input.jobDir)
4350
+ factoryVariables: factoryVariablesOf(input.config, input.jobDir),
4351
+ proxiedEnvironment: proxiedEnvironment(input.jobDir)
4201
4352
  });
4202
4353
  const env = withExtraEnv(built, input.extraEnv);
4203
4354
  const options = {
@@ -4234,7 +4385,8 @@ async function startMicroVmCommand(input) {
4234
4385
  miseVariables: state.miseVariables,
4235
4386
  builtIns: state.builtIns === true,
4236
4387
  identity: input.job.commitIdentity,
4237
- factoryVariables: factoryVariablesOf(input.config, input.jobDir)
4388
+ factoryVariables: factoryVariablesOf(input.config, input.jobDir),
4389
+ proxiedEnvironment: proxiedEnvironment(input.jobDir)
4238
4390
  }), input.extraEnv);
4239
4391
  const started = await input.runtime.vm.exec(state.vsockPath, {
4240
4392
  argv: ["/bin/sh", "-c", commandWithShim(input.job, input.cmdline)],
@@ -4244,7 +4396,7 @@ async function startMicroVmCommand(input) {
4244
4396
  detach: state.commandDir ?? MICROVM_COMMAND_DIR
4245
4397
  });
4246
4398
  if (started.status !== 0) {
4247
- const said2 = firstLine3(started.stderr);
4399
+ const said2 = firstLine(started.stderr);
4248
4400
  throw new Error(`the guest's exec agent exited ${started.status}${said2 === "" ? "" : `: ${said2}`}`);
4249
4401
  }
4250
4402
  }
@@ -4286,7 +4438,8 @@ async function runCliInMicroVm(input, argv, logName, goneReason) {
4286
4438
  miseVariables: state.miseVariables,
4287
4439
  builtIns: state.builtIns === true,
4288
4440
  identity: job.commitIdentity,
4289
- factoryVariables: factoryVariablesOf(input.config, input.jobDir)
4441
+ factoryVariables: factoryVariablesOf(input.config, input.jobDir),
4442
+ proxiedEnvironment: proxiedEnvironment(input.jobDir)
4290
4443
  });
4291
4444
  const result = await runtime.vm.exec(state.vsockPath, {
4292
4445
  argv,
@@ -4310,7 +4463,7 @@ async function copyHookErrors(runtime, state, jobDir) {
4310
4463
  }
4311
4464
  async function copyTranscriptsFromMicroVm(runtime, state) {
4312
4465
  if (!isRunning(runtime, state)) return { ok: false, reason: "the build's microVM is gone" };
4313
- return copyTranscripts((argv) => asRoot(runtime, state, argv));
4466
+ return copyTranscripts((argv) => asRoot(runtime, state, argv), void 0, runtime.agents);
4314
4467
  }
4315
4468
  function guestStopScript(paths = { proc: "/proc", record: HELPER_RECORD }) {
4316
4469
  return [
@@ -4367,9 +4520,7 @@ function microVmJudgeEnvironment(input) {
4367
4520
  },
4368
4521
  hashProgram: async () => {
4369
4522
  needsVm();
4370
- const ran = await asRoot(runtime, state, [...HASH_ARGV]);
4371
- const sha2562 = ran.status === 0 ? parseProgramHash(ran.stdout) : void 0;
4372
- return sha2562 === void 0 ? { ok: false, reason: firstLine3(ran.stderr) || `the hash could not be taken (exit ${ran.status})` } : { ok: true, sha256: sha2562 };
4523
+ return await hashJudgeProgram((argv) => asRoot(runtime, state, argv), runtime.agents);
4373
4524
  },
4374
4525
  prepare: async (files, tree) => {
4375
4526
  needsVm();
@@ -4391,7 +4542,7 @@ function microVmJudgeEnvironment(input) {
4391
4542
  `chmod 1777 ${dir}`
4392
4543
  ].join("\n");
4393
4544
  const result = await asRoot(runtime, state, ["/bin/sh", "-c", script], tarOf(staging));
4394
- if (result.status !== 0) throw new Error(`preparing ${dir} in the guest failed (exit ${result.status}): ${firstLine3(result.stderr)}`);
4545
+ if (result.status !== 0) throw new Error(`preparing ${dir} in the guest failed (exit ${result.status}): ${firstLine(result.stderr)}`);
4395
4546
  } finally {
4396
4547
  rmSync(staging, { recursive: true, force: true });
4397
4548
  }
@@ -4485,7 +4636,7 @@ async function startCheckMicroVm(input) {
4485
4636
  return fail(`the tunnel could not start: ${describeCallFailure(err)}`);
4486
4637
  }
4487
4638
  if (abandoned()) return fail(ABANDONED);
4488
- const links = vsockLinks({ destinations: config.build?.destinations?.length ?? 0, builtIns: false });
4639
+ const links = vsockLinks({ destinations: config.build?.destinations?.length ?? 0, builtIns: false, factory: factoryIndexes(jobDir) });
4489
4640
  const configPath = join(buildDir2, "vm.json");
4490
4641
  const helper = await helperFor(runtime, (line2) => log.line(`${tag} ${line2}`), config.managed === true);
4491
4642
  if (helper === void 0 && config.managed === true) return fail(MANAGED_UNJAILED_REASON);
@@ -4558,7 +4709,8 @@ async function startCheckMicroVm(input) {
4558
4709
  hostEnv: runtime.hostEnv,
4559
4710
  containerEnv: built.containerEnv ?? {},
4560
4711
  // The checks of a managed build get its factory's variables, as its command did, and none of the runner's own.
4561
- factoryVariables: factoryVariablesOf(config, jobDir)
4712
+ factoryVariables: factoryVariablesOf(config, jobDir),
4713
+ proxiedEnvironment: proxiedEnvironment(jobDir)
4562
4714
  });
4563
4715
  const evalInput = { dir: join(checksDir, EVAL_INPUT_NAME), delivered: false };
4564
4716
  const deliverEvalInput2 = async () => {
@@ -4730,7 +4882,7 @@ function sessionGuestOfMicroVm(runtime, state, as) {
4730
4882
  };
4731
4883
  }
4732
4884
  async function restoreSessionIntoMicroVm(runtime, state, keptDir, meta) {
4733
- const restored = await restoreSession({ guest: sessionGuestOfMicroVm(runtime, state, "agent"), tar: packKeptSession(keptDir, meta) });
4885
+ const restored = await restoreSession({ guest: sessionGuestOfMicroVm(runtime, state, "agent"), tar: packKeptSession(keptDir, meta, runtime.agents) });
4734
4886
  if (!restored.ok) throw new Error(restored.reason);
4735
4887
  }
4736
4888
 
@@ -4809,123 +4961,6 @@ async function sampleGuest(runtime, state) {
4809
4961
  return void 0;
4810
4962
  }
4811
4963
  }
4812
-
4813
- // src/runner/container/ranges.ts
4814
- var V4 = [
4815
- ["unspecified", "0.0.0.0/8"],
4816
- ["loopback", "127.0.0.0/8"],
4817
- ["private", "10.0.0.0/8"],
4818
- ["private", "172.16.0.0/12"],
4819
- ["private", "192.168.0.0/16"],
4820
- ["protocol-assignments", "192.0.0.0/24"],
4821
- ["benchmarking", "198.18.0.0/15"],
4822
- ["azure-wireserver", "168.63.129.16/32"],
4823
- ["link-local", "169.254.0.0/16"],
4824
- ["shared-address", "100.64.0.0/10"],
4825
- ["multicast", "224.0.0.0/4"],
4826
- ["reserved", "240.0.0.0/4"]
4827
- ];
4828
- var V6 = [
4829
- ["unspecified", "::/128"],
4830
- ["loopback", "::1/128"],
4831
- ["ipv4-mapped", "::ffff:0:0/96"],
4832
- ["nat64", "64:ff9b::/96"],
4833
- // The location of an embedded IPv4 address depends on the translator's prefix length, so the whole prefix is refused.
4834
- ["nat64-local", "64:ff9b:1::/48"],
4835
- ["ipv4-compatible", "::/96"],
4836
- ["link-local", "fe80::/10"],
4837
- ["unique-local", "fc00::/7"],
4838
- ["multicast", "ff00::/8"]
4839
- ];
4840
- var UNPARSEABLE = { name: "unparseable", cidr: "-" };
4841
- function parseV4(text2) {
4842
- const parts = text2.split(".");
4843
- if (parts.length !== 4) return void 0;
4844
- let value = 0;
4845
- for (const part of parts) {
4846
- if (!/^\d{1,3}$/.test(part)) return void 0;
4847
- const octet = Number(part);
4848
- if (octet > 255) return void 0;
4849
- value = value * 256 + octet;
4850
- }
4851
- return value;
4852
- }
4853
- function parseV6(input) {
4854
- const zone = input.indexOf("%");
4855
- let text2 = zone === -1 ? input : input.slice(0, zone);
4856
- const lastColon = text2.lastIndexOf(":");
4857
- const tail = text2.slice(lastColon + 1);
4858
- if (tail.includes(".")) {
4859
- const v4 = parseV4(tail);
4860
- if (v4 === void 0) return void 0;
4861
- text2 = `${text2.slice(0, lastColon + 1)}${(v4 >>> 16).toString(16)}:${(v4 & 65535).toString(16)}`;
4862
- }
4863
- const halves = text2.split("::");
4864
- if (halves.length > 2) return void 0;
4865
- const groups = (part) => {
4866
- if (part === "") return [];
4867
- const found = part.split(":");
4868
- return found.every((g) => /^[0-9a-fA-F]{1,4}$/.test(g)) ? found : void 0;
4869
- };
4870
- const head = groups(halves[0]);
4871
- const rest = groups(halves[1] ?? "");
4872
- if (head === void 0 || rest === void 0) return void 0;
4873
- let words;
4874
- if (halves.length === 2) {
4875
- const missing = 8 - head.length - rest.length;
4876
- if (missing < 1) return void 0;
4877
- words = [...head, ...Array(missing).fill("0"), ...rest];
4878
- } else {
4879
- if (head.length !== 8) return void 0;
4880
- words = head;
4881
- }
4882
- return words.reduce((acc, word) => acc << BigInt(16) | BigInt(parseInt(word, 16)), BigInt(0));
4883
- }
4884
- function build4() {
4885
- return V4.map(([name, cidr]) => {
4886
- const [address, length] = cidr.split("/");
4887
- return { name, cidr, base: parseV4(address), bits: Number(length) };
4888
- });
4889
- }
4890
- function build6() {
4891
- return V6.map(([name, cidr]) => {
4892
- const [address, length] = cidr.split("/");
4893
- return { name, cidr, base: parseV6(address), bits: Number(length) };
4894
- });
4895
- }
4896
- var RANGES_4 = build4();
4897
- var RANGES_6 = build6();
4898
- [...RANGES_4, ...RANGES_6].map(({ name, cidr }) => ({ name, cidr }));
4899
- function carried6to4(address) {
4900
- const v6 = parseV6(address);
4901
- if (v6 === void 0 || v6 >> BigInt(112) !== BigInt(8194)) return void 0;
4902
- const v4 = Number(v6 >> BigInt(80) & BigInt(4294967295));
4903
- return [v4 >>> 24, v4 >>> 16 & 255, v4 >>> 8 & 255, v4 & 255].join(".");
4904
- }
4905
- function classifyAddress(address) {
4906
- const v4 = parseV4(address);
4907
- if (v4 !== void 0) {
4908
- for (const range of RANGES_4) {
4909
- const shift = 32 - range.bits;
4910
- if (Math.floor(v4 / 2 ** shift) === Math.floor(range.base / 2 ** shift)) return { name: range.name, cidr: range.cidr };
4911
- }
4912
- return void 0;
4913
- }
4914
- const v6 = parseV6(address);
4915
- if (v6 === void 0) return UNPARSEABLE;
4916
- const carries = carried6to4(address);
4917
- if (carries !== void 0) {
4918
- const inner = classifyAddress(carries);
4919
- return inner === void 0 ? void 0 : { ...inner, carries };
4920
- }
4921
- for (const range of RANGES_6) {
4922
- const shift = BigInt(128 - range.bits);
4923
- if (v6 >> shift === range.base >> shift) return { name: range.name, cidr: range.cidr };
4924
- }
4925
- return void 0;
4926
- }
4927
-
4928
- // src/runner/container/tunnel.ts
4929
4964
  function isLiteralAddress(text2) {
4930
4965
  return isIP(text2) !== 0;
4931
4966
  }
@@ -5710,7 +5745,7 @@ var POLL_MS2 = 200;
5710
5745
  var ASK_AGAIN_MS = 1e3;
5711
5746
  var EXIT_REPORT_WAIT_MS = 2e3;
5712
5747
  var exitsLogged = /* @__PURE__ */ new Map();
5713
- var BUILD_HOME3 = "/build/home";
5748
+ var BUILD_HOME2 = "/build/home";
5714
5749
  async function startSender(input) {
5715
5750
  const { config, job, jobDir, deps } = input;
5716
5751
  const tag = `${itemTag(job)}`;
@@ -5769,7 +5804,7 @@ async function restartSender(input) {
5769
5804
  const state = job.container;
5770
5805
  if (state !== void 0 && job.itemKey !== void 0) {
5771
5806
  const runtime = deps.runtime ?? createContainerRuntime();
5772
- const pidfile = senderPidfile(BUILD_HOME3, Number(job.item));
5807
+ const pidfile = senderPidfile(BUILD_HOME2, Number(job.item));
5773
5808
  const sleep = deps.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms)));
5774
5809
  const running = async () => {
5775
5810
  const probe = await runtime.host.exec({ container: state.container, user: state.agentUser ?? ADDED_USER, env: { literals: {}, passed: {} }, argv: ["/bin/sh", "-c", senderAliveScript(pidfile)] });
@@ -5835,8 +5870,8 @@ async function stopSender(input) {
5835
5870
  if (sender === void 0) return;
5836
5871
  const tag = `${itemTag(job)}`;
5837
5872
  const sleep = deps.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms)));
5838
- const inContainer = job.container === void 0 ? void 0 : { state: job.container, runtime: deps.runtime ?? createContainerRuntime(), pidfile: senderPidfile(BUILD_HOME3, Number(job.item)) };
5839
- const inGuest = job.microvm === void 0 ? void 0 : { state: job.microvm, runtime: deps.runtime ?? createContainerRuntime(), pidfile: senderPidfile(BUILD_HOME3, Number(job.item)) };
5873
+ const inContainer = job.container === void 0 ? void 0 : { state: job.container, runtime: deps.runtime ?? createContainerRuntime(), pidfile: senderPidfile(BUILD_HOME2, Number(job.item)) };
5874
+ const inGuest = job.microvm === void 0 ? void 0 : { state: job.microvm, runtime: deps.runtime ?? createContainerRuntime(), pidfile: senderPidfile(BUILD_HOME2, Number(job.item)) };
5840
5875
  const signalInside = async (signal) => {
5841
5876
  if (inContainer !== void 0) return signalInContainer(inContainer.runtime, inContainer.state, inContainer.pidfile, signal).catch(() => void 0);
5842
5877
  if (inGuest !== void 0) return signalInGuest(inGuest.runtime, inGuest.state, inGuest.pidfile, signal).catch(() => void 0);
@@ -6301,17 +6336,20 @@ async function keepEndedSession(input) {
6301
6336
  }
6302
6337
  const tarPath = join(input.jobDirPath, SESSION_TAR);
6303
6338
  try {
6304
- const copied = await copyOutSession({ guest: found.guest, sessionId: job.sessionId, tarPath });
6339
+ const copied = await copyOutSession({ guest: found.guest, sessionId: job.sessionId, tarPath }, input.runtime.agents);
6305
6340
  if (!copied.ok) {
6306
6341
  log.error(`${tag} the session was not kept: ${copied.reason} \xB7 continuing`);
6307
6342
  return changed;
6308
6343
  }
6309
- await keepSession({
6310
- dir: keptSessionDir(input.configPath, job.organizationId, job.workItemId),
6311
- meta: { sessionId: job.sessionId, claimId: job.claimId, queue: job.queue, keptAt: input.now().toISOString() },
6312
- tar: createReadStream(tarPath),
6313
- scrub: input.scrub
6314
- });
6344
+ await keepSession(
6345
+ {
6346
+ dir: keptSessionDir(input.configPath, job.organizationId, job.workItemId),
6347
+ meta: { sessionId: job.sessionId, claimId: job.claimId, queue: job.queue, keptAt: input.now().toISOString() },
6348
+ tar: createReadStream(tarPath),
6349
+ scrub: input.scrub
6350
+ },
6351
+ input.runtime.agents
6352
+ );
6315
6353
  log.line(`${tag} session ${job.sessionId.slice(0, 8)} kept for the next agent job (${formatBytes(statSync(tarPath).size)})`);
6316
6354
  job.sessionKept = true;
6317
6355
  return true;
@@ -6327,27 +6365,17 @@ async function keepEndedSession(input) {
6327
6365
  function firstLine5(text2) {
6328
6366
  return text2.trim().split(/\r\n|\r|\n/)[0]?.trim() ?? "";
6329
6367
  }
6330
- function parseOutput(stdout) {
6331
- try {
6332
- const parsed = JSON.parse(stdout);
6333
- if (typeof parsed !== "object" || parsed === null) return void 0;
6334
- const { subtype, result } = parsed;
6335
- return { subtype: typeof subtype === "string" ? subtype : void 0, result: typeof result === "string" ? result : "" };
6336
- } catch {
6337
- return void 0;
6338
- }
6339
- }
6340
6368
  var RESULT_LINE = /^result:\s*(pass|fail)\s*$/i;
6341
6369
  var UNMET_LINE = /^unmet:\s*(\S+)\s*$/i;
6342
- function readJudgeReply(run, minutes) {
6370
+ function readJudgeReply(run, minutes, agents = defaultAgents()) {
6343
6371
  if (run.kind === "timeout") return { kind: "none", reason: `the judge ran out of time after ${minutes}`, limitKey: true };
6344
- const output = parseOutput(run.stdout);
6372
+ const output = jobAgent(void 0, agents)?.adapter.headless?.readJudgeOutput(run.stdout);
6345
6373
  if (output === void 0) {
6346
6374
  const said2 = firstLine5(run.stderr);
6347
6375
  return { kind: "none", reason: `the judge exited ${run.status} and printed no result${said2 === "" ? "" : `: ${said2}`}` };
6348
6376
  }
6349
- if (output.subtype === "error_max_turns") return { kind: "none", reason: `the judge reached the turn limit of ${JUDGE_MAX_TURNS} turns before it gave a result` };
6350
- const lines = output.result.split(/\r\n|\r|\n/).map((line2) => line2.trim()).filter((line2) => line2 !== "");
6377
+ 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` };
6378
+ const lines = output.text.split(/\r\n|\r|\n/).map((line2) => line2.trim()).filter((line2) => line2 !== "");
6351
6379
  const verdict = RESULT_LINE.exec(lines.at(-1) ?? "")?.[1]?.toLowerCase();
6352
6380
  if (verdict === void 0) return { kind: "none", reason: "the judge gave no `result:` line" };
6353
6381
  return { kind: "answered", verdict, unmet: new Set(lines.flatMap((line2) => UNMET_LINE.exec(line2)?.[1] ?? [])) };
@@ -6406,7 +6434,7 @@ ${rows}
6406
6434
  // src/runner/judge.ts
6407
6435
  var LIMIT_KEY_TAIL = " (runner.checks.timeLimitMinutes)";
6408
6436
  var MAX_DIFF_BYTES = 4 * 1024 * 1024;
6409
- var NO_CLAUDE = "the image has no Claude Code for the judge";
6437
+ var noAgentProgram = (label) => `the image has no ${label} for the judge`;
6410
6438
  var REPORT_CAPTION = "The host's criteria judge, each criterion judged against the test that cites it";
6411
6439
  function testFilesIn(root, isTest, limits2 = { files: MAX_TEST_FILES, bytes: MAX_TEST_FILE_BYTES }) {
6412
6440
  const files = [];
@@ -6556,15 +6584,18 @@ async function runJudge(input) {
6556
6584
  log.line(`${tag} judge done (${formatDuration(now().getTime() - startedMs)})`);
6557
6585
  }
6558
6586
  async function judgeOne(check) {
6587
+ const agent = jobAgent(void 0, runtime.agents);
6588
+ 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`);
6589
+ const missing = noAgentProgram(agent.descriptor.label);
6559
6590
  const environment = environmentFor(input);
6560
- if (environment === void 0) return await fail(check, `${NO_CLAUDE}: this build ran outside a container or microVM`);
6591
+ if (environment === void 0) return await fail(check, `${missing}: this build ran outside a container or microVM`);
6561
6592
  const expected = (job.container ?? job.microvm)?.judgeProgram;
6562
- if (expected === void 0) return await fail(check, NO_CLAUDE);
6593
+ if (expected === void 0) return await fail(check, missing);
6563
6594
  const brief = check.judge.text;
6564
6595
  if (brief === void 0) return await fail(check, `the brief ${check.judge.brief} is not in the definitions repository`);
6565
6596
  if (tokens === void 0) return await fail(check, "the build's repository tokens are no longer held, so the branch cannot be fetched");
6566
6597
  const credential = config.managed === true && managedClaudeKeyFor(jobDir) !== void 0 ? managedAgentCredential(runtime.agents) : agentCredential(runtime.hostEnv, {}, runtime.agents);
6567
- if (credential === void 0) return await fail(check, "the host holds no Claude credential for the judge");
6598
+ if (credential === void 0) return await fail(check, `the host holds no ${agent.descriptor.credentials.label} credential for the judge`);
6568
6599
  const branch = job.branch;
6569
6600
  if (branch === void 0) return await fail(check, "the build pushed no branch: the claim names none");
6570
6601
  const remote = runtime.remoteFor?.(repo) ?? `${runtime.github.gitUrl}/${repo}.git`;
@@ -6574,7 +6605,7 @@ async function runJudge(input) {
6574
6605
  return await fail(check, `the build's processes could not be stopped: ${describeCallFailure(err)}`);
6575
6606
  }
6576
6607
  const hashed = await environment.hashProgram();
6577
- if (!hashed.ok) return await fail(check, `${NO_CLAUDE}: ${hashed.reason}`);
6608
+ if (!hashed.ok) return await fail(check, `${missing}: ${hashed.reason}`);
6578
6609
  if (hashed.sha256 !== expected.sha256) return await fail(check, "the judge program changed during the build");
6579
6610
  const read = await (deps.readBranch ?? readBranchHead)({ remote, dir: scratch, branch, token: readToken });
6580
6611
  if (read.kind === "absent") return await fail(check, `the build pushed no branch: ${branch} does not exist on ${repo}`);
@@ -6649,7 +6680,7 @@ async function runJudge(input) {
6649
6680
  await environment.clear?.().catch((err) => log.error(`${tag} what the judge left in its folder could not be removed: ${describeCallFailure(err)}`));
6650
6681
  };
6651
6682
  const prompt = withAnswerProtocol(brief, check.judge.subjects);
6652
- const running = environment.run(judgeCommand({ brief: prompt, credential }), { logPath: join(jobDir, "judge.log") });
6683
+ const running = environment.run(judgeCommand({ brief: prompt, credential }, runtime.agents), { logPath: join(jobDir, "judge.log") });
6653
6684
  running.catch(() => void 0);
6654
6685
  const timer = timeoutAfter(limitMinutes * 6e4, deps.sleep);
6655
6686
  let outcome;
@@ -6683,7 +6714,7 @@ async function runJudge(input) {
6683
6714
  }
6684
6715
  await clear();
6685
6716
  const run = outcome === "timeout" ? { kind: "timeout" } : { kind: "exited", status: outcome.status, stdout: outcome.stdout, stderr: outcome.stderr };
6686
- const reply = readJudgeReply(run, minutes);
6717
+ const reply = readJudgeReply(run, minutes, runtime.agents);
6687
6718
  const answer = parseJudgeAnswer(answerText);
6688
6719
  if (criteria === void 0) return await finishWhole(check, { reply, answer, report, head, branch });
6689
6720
  const judged = (results2) => [
@@ -10569,9 +10600,8 @@ async function provisionContainerOnce(input, allowRestore, itemDiskFailed) {
10569
10600
  const tools = await host.exec({ container: name, user: ADDED_USER, env: NO_ENV, argv: ["cat", "/opt/outerlayer/tools.json"] });
10570
10601
  const agentVersion = agentVersionOf(tools.status === 0 ? tools.stdout : "", runtime.agents);
10571
10602
  environment.agentVersion = agentVersion;
10572
- const program = await host.exec({ container: name, user: ADDED_USER, env: NO_ENV, argv: [...HASH_ARGV] });
10573
- const hashed = program.status === 0 ? parseProgramHash(program.stdout) : void 0;
10574
- if (hashed !== void 0) state.judgeProgram = { path: JUDGE_PROGRAM, sha256: hashed };
10603
+ const recorded = await judgeProgramRecord((argv) => host.exec({ container: name, user: ADDED_USER, env: NO_ENV, argv }), runtime.agents);
10604
+ if (recorded !== void 0) state.judgeProgram = recorded;
10575
10605
  input.save(state, environment);
10576
10606
  const exec = async (argv, workdir, opts) => {
10577
10607
  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 } });
@@ -10602,6 +10632,7 @@ async function provisionContainerOnce(input, allowRestore, itemDiskFailed) {
10602
10632
  repositories,
10603
10633
  ...governingSource.kind === "governed" ? { governing: { repository: governingSource.repository } } : {},
10604
10634
  agentVersion,
10635
+ agents: runtime.agents,
10605
10636
  lifecycle: report.apply.lifecycle,
10606
10637
  exec,
10607
10638
  log,
@@ -10781,6 +10812,8 @@ async function startServicesFor(runtime, config, buildDir2, jobDir, itemKey, bui
10781
10812
  buildDir: buildDir2,
10782
10813
  jobDir,
10783
10814
  destinations: config.build?.destinations ?? [],
10815
+ // A managed build's proxied variables are served for this claim alone.
10816
+ factory: factoryDestinations(settingsDir ?? jobDir),
10784
10817
  // A managed build's tunnel allows the factory's hosts beside the runner's own.
10785
10818
  allowHosts: withFactoryHosts(config.build?.allowHosts, managedBuildSettingsFor(settingsDir ?? jobDir)),
10786
10819
  ...optionalEgress(config),
@@ -10884,7 +10917,7 @@ async function copyTranscriptsFromContainer(runtime, state) {
10884
10917
  } catch (err) {
10885
10918
  return { ok: false, reason: describeCallFailure(err) };
10886
10919
  }
10887
- return copyTranscripts((argv) => runtime.host.exec({ container: state.container, user: state.agentUser ?? ADDED_USER, env: NO_ENV, argv }));
10920
+ return copyTranscripts((argv) => runtime.host.exec({ container: state.container, user: state.agentUser ?? ADDED_USER, env: NO_ENV, argv }), void 0, runtime.agents);
10888
10921
  }
10889
10922
  async function ensureContainerRunning(runtime, state) {
10890
10923
  try {
@@ -10925,7 +10958,7 @@ function sessionGuestOfContainer(runtime, state) {
10925
10958
  };
10926
10959
  }
10927
10960
  async function restoreSessionIntoContainer(runtime, state, keptDir, meta) {
10928
- const restored = await restoreSession({ guest: sessionGuestOfContainer(runtime, state), tar: packKeptSession(keptDir, meta) });
10961
+ const restored = await restoreSession({ guest: sessionGuestOfContainer(runtime, state), tar: packKeptSession(keptDir, meta, runtime.agents) });
10929
10962
  if (!restored.ok) throw new Error(restored.reason);
10930
10963
  }
10931
10964
  var HOOK_ERRORS_IN_CONTAINER = "/build/home/.outerlayer/spool/hook-errors.log";
@@ -10990,7 +11023,7 @@ function containerJudgeEnvironment(input) {
10990
11023
  env: NO_ENV,
10991
11024
  argv: ["/bin/sh", "-c", `[ -f ${file} ] && [ ! -L ${file} ] && head -c ${maxBytes + 1} ${file}`]
10992
11025
  }, { timeoutMs: REPORT_READ_TIMEOUT_MS });
10993
- if (read.status > 1) throw new Error(`reading the judge's ${name} exited ${read.status}: ${firstLine3(read.stderr)}`);
11026
+ if (read.status > 1) throw new Error(`reading the judge's ${name} exited ${read.status}: ${firstLine(read.stderr)}`);
10994
11027
  return read.status === 0 && Buffer.byteLength(read.stdout) <= maxBytes ? read.stdout : void 0;
10995
11028
  };
10996
11029
  return {
@@ -11008,9 +11041,7 @@ function containerJudgeEnvironment(input) {
11008
11041
  if (!delivered.ok) throw new Error(delivered.reason);
11009
11042
  },
11010
11043
  hashProgram: async () => {
11011
- const ran = await runtime.host.exec({ container: state.container, user: ADDED_USER, env: NO_ENV, argv: [...HASH_ARGV] });
11012
- const sha2562 = ran.status === 0 ? parseProgramHash(ran.stdout) : void 0;
11013
- return sha2562 === void 0 ? { ok: false, reason: firstLine3(ran.stderr) || `the hash could not be taken (exit ${ran.status})` } : { ok: true, sha256: sha2562 };
11044
+ return await hashJudgeProgram((argv) => runtime.host.exec({ container: state.container, user: ADDED_USER, env: NO_ENV, argv }), runtime.agents);
11014
11045
  },
11015
11046
  prepare: async (files, tree) => {
11016
11047
  if (filesAreCopied(state)) {
@@ -11043,7 +11074,7 @@ function containerJudgeEnvironment(input) {
11043
11074
  // 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.
11044
11075
  clear: async () => {
11045
11076
  const removed = await runtime.host.exec({ container: state.container, user, env: NO_ENV, argv: ["find", JUDGE_DIR, "-mindepth", "1", "-user", user, "-delete"] });
11046
- if (removed.status !== 0) throw new Error(`find exited ${removed.status}: ${firstLine3(removed.stderr)}`);
11077
+ if (removed.status !== 0) throw new Error(`find exited ${removed.status}: ${firstLine(removed.stderr)}`);
11047
11078
  if (!filesAreCopied(state)) return;
11048
11079
  const emptied = await clearJudgeFolder(runtime, state, secretsOf(runtime, input.jobDir));
11049
11080
  if (!emptied.ok) throw new Error(emptied.reason);
@@ -11670,4 +11701,4 @@ async function runHostChecks(input) {
11670
11701
  }
11671
11702
  }
11672
11703
 
11673
- 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, firstLine3 as firstLine, 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 };
11704
+ 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 };