@outerlayer/cli 0.37.0 → 0.38.0-next.20261105131925

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 (165) hide show
  1. package/README.md +13 -5
  2. package/dist/{agent-setup-DUE6IXPP.js → agent-setup-RXMEQ7PA.js} +18 -18
  3. package/dist/{agent-subcommand-C625JDSN.js → agent-subcommand-KPQGEOPQ.js} +3 -3
  4. package/dist/{bridge-UHNGV6DM.js → bridge-F4BNXRM2.js} +6 -6
  5. package/dist/{build-ALG3MYX2.js → build-ZH5MAZNM.js} +12 -12
  6. package/dist/{build-disk-JU2QHE64.js → build-disk-GPCMOIZV.js} +10 -10
  7. package/dist/build-info.json +1 -1
  8. package/dist/{builder-4LK2FDCX.js → builder-ZMVXHOEJ.js} +9 -9
  9. package/dist/caller-J7FR4VBJ.js +23 -0
  10. package/dist/{check-PJ5FLDTD.js → check-HXGQQAJS.js} +53 -53
  11. package/dist/{chunk-RXWFZB3P.js → chunk-2C3XLYO5.js} +1 -1
  12. package/dist/{chunk-A75ZPAOP.js → chunk-2FDWTE6F.js} +5 -5
  13. package/dist/{chunk-NBGBMZE4.js → chunk-2RKPEUGK.js} +1 -1
  14. package/dist/{chunk-3LT6REKE.js → chunk-35RIDLSD.js} +2 -2
  15. package/dist/{chunk-BNYBHWYH.js → chunk-3B5H5MGB.js} +1 -1
  16. package/dist/{chunk-4U57GP2X.js → chunk-3J7F3VGZ.js} +2 -2
  17. package/dist/{chunk-N3FPRSUZ.js → chunk-3PR7BPMG.js} +5 -5
  18. package/dist/{chunk-P3KL3ZJF.js → chunk-45UZPTDQ.js} +1 -1
  19. package/dist/{chunk-L2PT4NRI.js → chunk-5M3KXOPY.js} +1 -1
  20. package/dist/{chunk-FBZE3LGM.js → chunk-64D2YZK5.js} +1 -1
  21. package/dist/{chunk-HN76DIHX.js → chunk-6XYKZH3K.js} +5 -5
  22. package/dist/{chunk-Q2JDKHOR.js → chunk-7476RWW6.js} +34 -26
  23. package/dist/{chunk-KE5NFPP2.js → chunk-AWRRWWA7.js} +8 -8
  24. package/dist/{chunk-ZRITZJ36.js → chunk-BMYIPXBG.js} +4 -4
  25. package/dist/{chunk-LNTZH3UL.js → chunk-CUAV3727.js} +4 -4
  26. package/dist/{chunk-JNGKTJ7L.js → chunk-D5JJQRW7.js} +7 -7
  27. package/dist/{chunk-GBCQ3KHH.js → chunk-DOKFFSOZ.js} +3 -3
  28. package/dist/{chunk-FV52S3JR.js → chunk-DP6ZOSCR.js} +2 -2
  29. package/dist/{chunk-XMIUPI5N.js → chunk-EKRLMOWS.js} +5 -5
  30. package/dist/{chunk-2LXO2YIW.js → chunk-EVFZUFCO.js} +5 -5
  31. package/dist/{chunk-NSDQESOY.js → chunk-FRQPX2QR.js} +1 -1
  32. package/dist/{chunk-QK43VKE4.js → chunk-GEW4TNCL.js} +7 -7
  33. package/dist/{chunk-6BS4DDCY.js → chunk-GMRIR2MF.js} +7 -7
  34. package/dist/{chunk-P2UH4EBF.js → chunk-GTJ2WSYI.js} +420 -277
  35. package/dist/{chunk-77RLQS5V.js → chunk-GYUHWK2N.js} +9 -9
  36. package/dist/{chunk-62RPMJXQ.js → chunk-GZETHU2Z.js} +3 -3
  37. package/dist/{chunk-KCNL7KX2.js → chunk-H6H5GCM6.js} +7 -7
  38. package/dist/{chunk-TCWYLSE3.js → chunk-HI5RBFL3.js} +1 -1
  39. package/dist/{chunk-IJU6DMQA.js → chunk-HOCVTWV2.js} +1 -1
  40. package/dist/{chunk-VTJ5MGGC.js → chunk-HU3POMM4.js} +6 -6
  41. package/dist/{chunk-EDEBGBPL.js → chunk-HVUS5WRU.js} +4 -4
  42. package/dist/{chunk-PNZN656P.js → chunk-IG7SBYJY.js} +1 -1
  43. package/dist/{chunk-6MWBZHBW.js → chunk-IJN3GP4M.js} +1 -1
  44. package/dist/{chunk-4A7D2HWQ.js → chunk-IYG543BV.js} +3 -3
  45. package/dist/{chunk-UZNSGMUZ.js → chunk-IYUJFAQD.js} +1 -1
  46. package/dist/{chunk-NSX2KF4L.js → chunk-J56SR6X4.js} +1 -1
  47. package/dist/{chunk-RFCAK6OI.js → chunk-J7MMYBBV.js} +6 -6
  48. package/dist/{chunk-WCJCGFVQ.js → chunk-JCEJARDB.js} +1 -1
  49. package/dist/{chunk-MITBH4LH.js → chunk-K7BI4TLM.js} +3 -3
  50. package/dist/{chunk-IHPJFMSV.js → chunk-K7KQCOSM.js} +8 -8
  51. package/dist/{chunk-4TDBM3PK.js → chunk-KFJIOCZS.js} +3 -3
  52. package/dist/{chunk-G62P3EFL.js → chunk-KXCTWOPU.js} +3 -3
  53. package/dist/{chunk-2KFLMNQU.js → chunk-KXKVMSHC.js} +1 -1
  54. package/dist/{chunk-LVZ3UV7T.js → chunk-L25GQH45.js} +1 -1
  55. package/dist/{chunk-XPIFUWWY.js → chunk-LFHJZDES.js} +15 -15
  56. package/dist/{chunk-OLZVQCDX.js → chunk-LMT72G74.js} +1 -1
  57. package/dist/{chunk-JO2FOEZE.js → chunk-M4WTELYI.js} +4 -4
  58. package/dist/{chunk-YLJXRXPX.js → chunk-MB7IX6DO.js} +1 -1
  59. package/dist/{chunk-XGJXLITW.js → chunk-MPGTKJOM.js} +4 -4
  60. package/dist/{chunk-OG6RJXQ3.js → chunk-MY6T3N3A.js} +1 -1
  61. package/dist/{chunk-GF4O3M23.js → chunk-OVRLLZPJ.js} +1 -1
  62. package/dist/{chunk-R2IPYS6A.js → chunk-PMBG7IYE.js} +8 -8
  63. package/dist/{chunk-ZQNYV4OZ.js → chunk-QAFR65VC.js} +216 -48
  64. package/dist/{chunk-Q6FXWSN3.js → chunk-QDM23DTW.js} +7 -7
  65. package/dist/{chunk-P4YTEF6T.js → chunk-RM3K57Q7.js} +1 -1
  66. package/dist/{chunk-G43WGW64.js → chunk-SKV6FO37.js} +4 -4
  67. package/dist/{chunk-DQZ7XFCI.js → chunk-SSSPZ3TB.js} +1 -1
  68. package/dist/{chunk-2QFRAMJX.js → chunk-SUMRSD2Q.js} +1 -1
  69. package/dist/{chunk-ZEHCE7ZE.js → chunk-TE6GQJRW.js} +1 -1
  70. package/dist/{chunk-MZ2OOMOT.js → chunk-U63SE2NJ.js} +1 -1
  71. package/dist/{chunk-LUQWY7BX.js → chunk-VG524OUD.js} +5 -5
  72. package/dist/{chunk-FYPVUT27.js → chunk-VUSYGNNN.js} +1 -1
  73. package/dist/{chunk-GQA54433.js → chunk-VV2VLQWG.js} +2 -2
  74. package/dist/{chunk-E2DJ6TWB.js → chunk-W7LJQ2GU.js} +3 -4
  75. package/dist/{chunk-ZHOPDD7U.js → chunk-XN4A275V.js} +5 -5
  76. package/dist/{chunk-KSSHEWPV.js → chunk-XUXDUOJI.js} +857 -524
  77. package/dist/{chunk-VV3Y32EV.js → chunk-Y2HVISUN.js} +1 -1
  78. package/dist/{chunk-HOTRWPVM.js → chunk-Y5ZKDLNX.js} +4 -4
  79. package/dist/{chunk-THL7WJ3F.js → chunk-YU6XPJ5I.js} +2 -2
  80. package/dist/{chunk-JAHR4LAD.js → chunk-ZEEQB7VM.js} +4 -4
  81. package/dist/{claude-launcher-HW5YVYWR.js → claude-launcher-3O5W5ENW.js} +6 -6
  82. package/dist/{cli-K62CS6XW.js → cli-6LEVGWVU.js} +140 -140
  83. package/dist/{command-EG54FHMR.js → command-HRXMLFOT.js} +47 -47
  84. package/dist/{config-CZJINZN5.js → config-J4NNZ2XO.js} +11 -11
  85. package/dist/{connect-cmd-4ZEF4WNR.js → connect-cmd-GVIUKK3R.js} +10 -10
  86. package/dist/{container-start-JBYD2XG4.js → container-start-JNTWQOMK.js} +45 -45
  87. package/dist/{context-cleanup-7QZQJXID.js → context-cleanup-7V2ARBSC.js} +3 -3
  88. package/dist/{context-show-cmd-JYV7RKMC.js → context-show-cmd-73E36KAV.js} +11 -11
  89. package/dist/{control-plane-launch-HLFLGLW6.js → control-plane-launch-L744RJ4A.js} +13 -13
  90. package/dist/{demo-record-cmd-MDPZD53Q.js → demo-record-cmd-KGH3WGLY.js} +7 -7
  91. package/dist/{demo-voice-cmd-4JEXQP4I.js → demo-voice-cmd-CHCS7TQF.js} +17 -17
  92. package/dist/{dist-NEH3H3EL.js → dist-U6EGOQD5.js} +1 -1
  93. package/dist/{docker-F4S3PBPD.js → docker-CAMJXBAJ.js} +9 -9
  94. package/dist/{doctor-MXWODPPL.js → doctor-2Z224QH4.js} +47 -47
  95. package/dist/{emit-artifact-cmd-QDYKKQT5.js → emit-artifact-cmd-CGY656UZ.js} +16 -16
  96. package/dist/{emit-cmd-ANJGKYSQ.js → emit-cmd-AG7HL3YI.js} +6 -6
  97. package/dist/{emit-criteria-cmd-OCLNKIL4.js → emit-criteria-cmd-3HYUUSDK.js} +13 -13
  98. package/dist/{emit-demo-cmd-RO3OXK4U.js → emit-demo-cmd-GHDL7ZGH.js} +17 -17
  99. package/dist/{emit-finding-cmd-M4OKFZPF.js → emit-finding-cmd-KPHWY6ZU.js} +13 -13
  100. package/dist/{emit-result-cmd-CUTNYSOQ.js → emit-result-cmd-WOJEHOXH.js} +15 -15
  101. package/dist/{emit-step-cmd-SY54AQYM.js → emit-step-cmd-QTNJBTZN.js} +13 -13
  102. package/dist/{exec-client-3ZVMZRZD.js → exec-client-IPPD3NF4.js} +7 -7
  103. package/dist/find-unit-N3OJBFS5.js +24 -0
  104. package/dist/{findings-cmd-246XYZSE.js → findings-cmd-LVYAXHQG.js} +13 -13
  105. package/dist/{fleet-readiness-SOSSKSII.js → fleet-readiness-F46LOKJ6.js} +12 -12
  106. package/dist/{governing-source-2UXHLXCS.js → governing-source-4XYZYZCD.js} +18 -18
  107. package/dist/{guest-init-ZNSEHMXA.js → guest-init-CFJM25V5.js} +8 -8
  108. package/dist/{hook-fast-27GO6BM2.js → hook-fast-RNST4WJH.js} +1 -1
  109. package/dist/{hook-install-5OS6ZH4B.js → hook-install-G3FUCXBE.js} +3 -3
  110. package/dist/host-checks-TXG6OTBM.js +79 -0
  111. package/dist/{host-key-ZRJ4CGFC.js → host-key-QUBI74MS.js} +7 -7
  112. package/dist/{image-tag-WQB5HVLI.js → image-tag-5Z2NKCHC.js} +7 -7
  113. package/dist/index.js +4 -4
  114. package/dist/{init-GH74PR4K.js → init-NCBQ2DOK.js} +43 -43
  115. package/dist/init-YENLMMJU.js +79 -0
  116. package/dist/{init-agent-54VT3S3Z.js → init-agent-CNHQT7YK.js} +43 -43
  117. package/dist/{init-cmd-AIUYATFU.js → init-cmd-I3BH7SXO.js} +24 -24
  118. package/dist/{init-update-BIHC42CB.js → init-update-WYM5WSM7.js} +21 -21
  119. package/dist/{install-cmd-YMPTGHE4.js → install-cmd-3NOHEA6E.js} +9 -9
  120. package/dist/{layout-DBSSMC4R.js → layout-RPYMSWCY.js} +3 -3
  121. package/dist/{logs-HIXNEXBT.js → logs-2OR2R52N.js} +6 -6
  122. package/dist/loop-TIX5JGHS.js +90 -0
  123. package/dist/machine-62FUJBEK.js +79 -0
  124. package/dist/{machine-skills-QEAB6375.js → machine-skills-RP2Y5F32.js} +3 -3
  125. package/dist/{mcp-install-cmd-ZL2TJUIK.js → mcp-install-cmd-IZYHXHXG.js} +3 -3
  126. package/dist/{mcp-serve-cmd-4EGVZBCK.js → mcp-serve-cmd-HAIJVRR7.js} +8 -8
  127. package/dist/{paths-AGOA7QX6.js → paths-6AMRSXZK.js} +6 -6
  128. package/dist/pending-C4XQUKWA.js +18 -0
  129. package/dist/{pidfile-H2DZIODT.js → pidfile-3BILBCEO.js} +7 -7
  130. package/dist/{record-UHMPQIUU.js → record-MV6WJGZT.js} +7 -7
  131. package/dist/{relay-MS7QJ53J.js → relay-CO5I2WOV.js} +4 -4
  132. package/dist/{relay-protocol-7LG6NHYA.js → relay-protocol-S2JGOYZZ.js} +4 -4
  133. package/dist/{runner-agents-QJCL4MO3.js → runner-agents-FQ4FODZN.js} +3 -3
  134. package/dist/{runner-env-YPIZG3VG.js → runner-env-72OTIZV2.js} +13 -13
  135. package/dist/{runner-identity-RPRUONRJ.js → runner-identity-IVP2GW33.js} +9 -9
  136. package/dist/{runner-key-PNZTLOK5.js → runner-key-E3ORW6RS.js} +43 -43
  137. package/dist/{session-sender-B526LNJ6.js → session-sender-PWYFVWN6.js} +16 -16
  138. package/dist/{spec-cmd-6TZVHED2.js → spec-cmd-2WKI4V2T.js} +14 -14
  139. package/dist/{starter-pack-6TS4PJYJ.js → starter-pack-W6S3L76K.js} +4 -4
  140. package/dist/{state-ALHXVNOS.js → state-C3FRODOO.js} +7 -7
  141. package/dist/{status-X7IK4XQU.js → status-3RD4MERA.js} +43 -43
  142. package/dist/{sync-cmd-NMWPCIFU.js → sync-cmd-TIDWKW4E.js} +15 -15
  143. package/dist/update-steps-4AI2DSYF.js +80 -0
  144. package/dist/{watch-INJRAQRE.js → watch-IA6UDVSF.js} +15 -15
  145. package/dist/{work-claim-cmd-YE4MVGZH.js → work-claim-cmd-VBRJO6FU.js} +20 -20
  146. package/dist/{work-cmd-6JUZHKXN.js → work-cmd-2LXE27RX.js} +13 -13
  147. package/dist/{work-comment-cmd-KK7H6F67.js → work-comment-cmd-ER53OPLH.js} +15 -15
  148. package/dist/{work-demo-cmd-32PXKPZK.js → work-demo-cmd-CSXUA7KH.js} +13 -13
  149. package/dist/{work-logs-cmd-QYSBE2SP.js → work-logs-cmd-ECF7ZLHO.js} +13 -13
  150. package/dist/{work-open-pr-cmd-PSATZ2BK.js → work-open-pr-cmd-SUJEYZ6C.js} +14 -14
  151. package/dist/{work-pr-cmd-BEYPR7TL.js → work-pr-cmd-FCNFYWUR.js} +13 -13
  152. package/dist/{work-proofs-cmd-Y7WZNTI3.js → work-proofs-cmd-6DV35Y2W.js} +15 -15
  153. package/dist/{work-proofs-record-5DCQQT23.js → work-proofs-record-7YI27TFT.js} +21 -21
  154. package/dist/{work-stop-cmd-MUSKJC5M.js → work-stop-cmd-PBC7SJ7M.js} +13 -13
  155. package/package.json +1 -1
  156. package/skill-pack/maintained/outerlayer-build/SKILL.md +2 -1
  157. package/skill-pack/maintained/outerlayer-build/references/agent-briefs.md +2 -1
  158. package/dist/caller-JQC4VW36.js +0 -23
  159. package/dist/find-unit-5ALT2LU3.js +0 -24
  160. package/dist/host-checks-RK5TC3TX.js +0 -79
  161. package/dist/init-CSWMBTTM.js +0 -79
  162. package/dist/loop-P7NDQS3G.js +0 -90
  163. package/dist/machine-UEW4P7I6.js +0 -79
  164. package/dist/pending-625SL7WI.js +0 -18
  165. package/dist/update-steps-R7AQAO6R.js +0 -80
@@ -1,55 +1,56 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { itemsSentence, criteriaOf, hostItemsOf, loadCitationFinder, testFileMatcher, planCriteria, judgeGroups, failedItems, inCriteriaOrder, testsByCriterion, oneLineReason, criterionInputs, parseJudgeAnswer, judgedItems, MAX_TEST_FILE_BYTES } from './chunk-BNYBHWYH.js';
3
+ import { itemsSentence, criteriaOf, hostItemsOf, loadCitationFinder, testFileMatcher, planCriteria, judgeGroups, failedItems, inCriteriaOrder, testsByCriterion, oneLineReason, criterionInputs, parseJudgeAnswer, judgedItems, MAX_TEST_FILE_BYTES } from './chunk-3B5H5MGB.js';
4
4
  import { sha256OfFile, downloadPinned, VoiceDownloadError } from './chunk-2PGI6RDE.js';
5
5
  import { zodProblem } from './chunk-I3LTIAOR.js';
6
- import { hasStoredCredential, storeAgentCredential, credentialFromStdin, isAgentName } from './chunk-ZHOPDD7U.js';
7
- import { upgradedStarterText } from './chunk-A75ZPAOP.js';
8
- import { HELPER_PATH, HELPER_RECORD, DOCKERD_LOG } from './chunk-G62P3EFL.js';
9
- import { writeDockerClientConfig } from './chunk-OG6RJXQ3.js';
10
- import { senderPidfile } from './chunk-JO2FOEZE.js';
11
- import { installScrubContext } from './chunk-KCNL7KX2.js';
6
+ import { hasStoredCredential, storeAgentCredential, credentialFromStdin, isAgentName } from './chunk-XN4A275V.js';
7
+ import { upgradedStarterText } from './chunk-2FDWTE6F.js';
8
+ import { HELPER_PATH, HELPER_RECORD, DOCKERD_LOG } from './chunk-KXCTWOPU.js';
9
+ import { writeDockerClientConfig } from './chunk-MY6T3N3A.js';
10
+ import { senderPidfile } from './chunk-M4WTELYI.js';
11
+ import { installScrubContext } from './chunk-H6H5GCM6.js';
12
12
  import { readsJobState, READ_JOB_STATE_FORMATS, jobStateFormatOf } from './chunk-ZVB57WI6.js';
13
- import { runnerImageVersion } from './chunk-NBGBMZE4.js';
14
- import { claimCalls, spoolHomeFor, itemCalls, claimItem, leftByRunnerKey } from './chunk-GQA54433.js';
13
+ import { runnerImageVersion } from './chunk-2RKPEUGK.js';
14
+ import { claimCalls, spoolHomeFor, itemCalls, claimItem, leftByRunnerKey } from './chunk-VV2VLQWG.js';
15
15
  import { receiveFiles } from './chunk-NN33FYXG.js';
16
- import { readDefaultBranchFiles, readDefaultBranchHead, buildRepositoryImage, fetchCommit, readBranchHead, diffBetween, prepareImageBuild, KEY_PREFIX, TAG_HOST, SHARED_OWNER, SHARED_NAME, universalBase, metadataFromLabels, writeRecord } from './chunk-JNGKTJ7L.js';
17
- import { FETCHED_DIR, toolsDockerfile, FETCHED_FFMPEG, FETCHED_GH, FETCHED_TINI, FETCHED_HEADLESS_SHELL, FETCHED_PLAYWRIGHT_FFMPEG, FETCHED_VOICE_DIR } from './chunk-HOTRWPVM.js';
16
+ import { readDefaultBranchFiles, readDefaultBranchHead, buildRepositoryImage, fetchCommit, readBranchHead, diffBetween, prepareImageBuild, KEY_PREFIX, TAG_HOST, SHARED_OWNER, SHARED_NAME, universalBase, metadataFromLabels, writeRecord } from './chunk-D5JJQRW7.js';
17
+ import { FETCHED_DIR, toolsDockerfile, FETCHED_FFMPEG, FETCHED_GH, FETCHED_TINI, FETCHED_HEADLESS_SHELL, FETCHED_PLAYWRIGHT_FFMPEG, FETCHED_VOICE_DIR } from './chunk-Y5ZKDLNX.js';
18
18
  import { isSameProcess, startTimeOf } from './chunk-JBJTC3UU.js';
19
19
  import { currentCliBuild } from './chunk-OGFGZQA3.js';
20
- import { vmExecArgs, runExec, execCapture, waitForAgent } from './chunk-OLZVQCDX.js';
21
- import { socketPathProblem, vsockLinks, linkVsockSockets, GUEST_CID, LEASE_LINK } from './chunk-E2DJ6TWB.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-Q6FXWSN3.js';
23
- import { postJson, WorkCommandError, getJson, isSignatureRefusal } from './chunk-6BS4DDCY.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-G43WGW64.js';
25
- import { formatBytes, volumeBytes, allocatedBytes, DEFAULT_BUILD_DISK, DEFAULT_CACHE_DISK, freeBytes } from './chunk-4U57GP2X.js';
26
- import { firstLine, writeJobFile, readJobFile, spawnRun, RUNNER_LABEL, BUILD_LABEL, said, NETWORK_HELPER_MEMORY, createDockerHost, builderSpec, containerExecArgs, childEnvironment, readDu, withAnswerProtocol, MAX_REPORT_BYTES, parseSize, runnerLabelValue, readJobFileChecked, NETWORK_READY_FILE, networkHelperName, prepareRunArgs, containerRunArgs, judgeCommand, JUDGE_TREE, WORKSPACE_LABEL, homeCopyRunArgs, networkHelperRunArgs, JUDGE_MAX_TURNS, 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-R2IPYS6A.js';
27
- import { universalImagePending, RecipeError, writeSanitizedRecipe, classifyProperties, DOCKER_FEATURE } from './chunk-2KFLMNQU.js';
20
+ import { vmExecArgs, runExec, execCapture, waitForAgent } from './chunk-LMT72G74.js';
21
+ import { socketPathProblem, vsockLinks, linkVsockSockets, GUEST_CID, LEASE_LINK } from './chunk-W7LJQ2GU.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-QDM23DTW.js';
23
+ import { postJson, WorkCommandError, getJson, isSignatureRefusal } from './chunk-GMRIR2MF.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-SKV6FO37.js';
25
+ import { formatBytes, volumeBytes, allocatedBytes, DEFAULT_BUILD_DISK, DEFAULT_CACHE_DISK, freeBytes } from './chunk-3J7F3VGZ.js';
26
+ import { firstLine, writeJobFile, readJobFile, spawnRun, RUNNER_LABEL, BUILD_LABEL, said, NETWORK_HELPER_MEMORY, createDockerHost, builderSpec, containerExecArgs, childEnvironment, readDu, withAnswerProtocol, MAX_REPORT_BYTES, parseSize, runnerLabelValue, readJobFileChecked, NETWORK_READY_FILE, networkHelperName, prepareRunArgs, containerRunArgs, judgeCommand, JUDGE_TREE, WORKSPACE_LABEL, homeCopyRunArgs, networkHelperRunArgs, JUDGE_MAX_TURNS, 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-PMBG7IYE.js';
27
+ import { universalImagePending, RecipeError, writeSanitizedRecipe, classifyProperties, DOCKER_FEATURE } from './chunk-KXKVMSHC.js';
28
28
  import { sanitizeTerminal, planArtifactUpload } from './chunk-VVZIFOAN.js';
29
- import { sharedSkillNames, skillConflictMessage } from './chunk-NSDQESOY.js';
29
+ import { sharedSkillNames, skillConflictMessage } from './chunk-FRQPX2QR.js';
30
30
  import { readCloudConfig } from './chunk-HWVMRETT.js';
31
- import { signerFor } from './chunk-MZ2OOMOT.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-RXWFZB3P.js';
33
- import { BUILD_HOME, JOB_MOUNT, buildEnvironment, CHECKOUT_DIR, parseIsolation, containerLocalAddress, destinationEnvironment, withHooksPath, startBuildServices, headerVariables, authorEnvironment, sharedUserEnvironment, withTunnelRecord, commitIdentityRecord, repositoriesOf, RELAY_PORT, repositoryPath, lifecycleWorkdir, CHECK_ITEMS_FILE, proxyEnvironment, checkEnvironment, withMiseVariables, checkoutPath, maxDestinations, resolveDestinations, isReservedVariable, classifyAddress, primaryOf, carried6to4, EVAL_INPUT_DIR, isMiseVariableAllowed } from './chunk-KSSHEWPV.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-FV52S3JR.js';
31
+ import { signerFor } from './chunk-U63SE2NJ.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-2C3XLYO5.js';
33
+ import { BUILD_HOME, JOB_MOUNT, heldBuildAuthority, IMAGE_BUNDLES, writeTrustFiles, buildEnvironment, trustEnvironment, CHECKOUT_DIR, parseIsolation, containerLocalAddress, destinationEnvironment, withHooksPath, startBuildServices, headerVariables, authorEnvironment, sharedUserEnvironment, withTunnelRecord, commitIdentityRecord, repositoriesOf, RELAY_PORT, repositoryPath, lifecycleWorkdir, CHECK_ITEMS_FILE, parseProxied, readBundleScript, applyTrust, STAND_IN, proxyEnvironment, dropBuildAuthority, hostKeyOf, buildAuthorityFor, checkEnvironment, withMiseVariables, checkoutPath, primaryOf, variablesFor, carried6to4, classifyAddress, EVAL_INPUT_DIR, isMiseVariableAllowed, variableForPath, droppedRequestHeaders, hasDotDotSegment, routeNameOf } from './chunk-XUXDUOJI.js';
34
+ import { agentCredential, RUNNER_WORDED_REASONS, UNKNOWN_TRACKING_REASON, UNKNOWN_TRANSPORT_REASON, RELAY_USER, currentAgentCredential, removedAgentCredentialValues, managedAgentCredential, 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-DP6ZOSCR.js';
35
35
  import { versionAtLeast } from './chunk-OV4XTV5M.js';
36
- import { jobAgent, firecrackerArch, MICROVM_ARCHES, FIRECRACKER_VERSION, hostHelperPinned, builderDiskPinned, guestAssetsPinned, runnerAgentNamed, credentialForms, orList, credentialShapes, agentCommands, defaultCommandLine, 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-P4YTEF6T.js';
37
- import { sessionFolderIn, legacyAgent, defaultAgents, parsePolicy, AGENTS_SKILLS_BASE, OUTERLAYER_SKILLS_BASE, orderSessions, extractFacts, sessionsToTimeline, resolvePackRoot } from './chunk-UZNSGMUZ.js';
36
+ import { jobAgent, firecrackerArch, MICROVM_ARCHES, FIRECRACKER_VERSION, hostHelperPinned, builderDiskPinned, guestAssetsPinned, runnerAgentNamed, credentialForms, orList, credentialShapes, agentCommands, defaultCommandLine, 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-RM3K57Q7.js';
37
+ import { sessionFolderIn, legacyAgent, defaultAgents, parsePolicy, AGENTS_SKILLS_BASE, OUTERLAYER_SKILLS_BASE, orderSessions, extractFacts, sessionsToTimeline, resolvePackRoot } from './chunk-IYUJFAQD.js';
38
38
  import { MAINTAINED_SKILLS } from './chunk-CDDED64E.js';
39
39
  import { resolveVersion } from './chunk-RA3O54FC.js';
40
40
  import { homeFromEnv } from './chunk-352DHUTP.js';
41
- import { scrubText, MIN_SCRUBBED_LITERAL, setCustomScrubbers, setLocalIdentity, setRepoRoot, forkFor, scrubDeep } from './chunk-ZQNYV4OZ.js';
41
+ import { scrubText, MIN_SCRUBBED_LITERAL, setCustomScrubbers, setLocalIdentity, setRepoRoot, forkFor, scrubDeep } from './chunk-QAFR65VC.js';
42
42
  import { CheckItemsSchema, CHECK_ITEM_HREF_MAX_LENGTH, downconvertSession } from './chunk-2JIGPSVF.js';
43
43
  import { randomUUID, randomBytes, createHash } from 'crypto';
44
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';
45
45
  import { join, dirname, isAbsolute, delimiter, sep, basename, relative, resolve } from 'path';
46
- import { Readable, Transform, Duplex, PassThrough } from 'stream';
47
- import { createServer, createConnection, connect, isIP } from 'net';
46
+ import { Readable, PassThrough, Duplex, Transform } from 'stream';
48
47
  import { spawn, spawnSync } from 'child_process';
48
+ import { createServer, createConnection, connect, isIP } from 'net';
49
49
  import { availableParallelism, networkInterfaces, tmpdir } from 'os';
50
50
  import { once } from 'events';
51
- import { createServer as createServer$1, request } from 'http';
51
+ import { createServer as createServer$1, request, Agent } from 'http';
52
52
  import { lookup as lookup$1 } from 'dns/promises';
53
+ import { TLSSocket, createSecureContext, connect as connect$1 } from 'tls';
53
54
  import http2 from 'http2';
54
55
  import { request as request$1 } from 'https';
55
56
  import { pipeline, finished } from 'stream/promises';
@@ -379,77 +380,12 @@ function hasClaudeCredential(config, hostEnv, jobDir, agents) {
379
380
  if (jobAgent(void 0, agents)?.adapter.credentials === void 0) return true;
380
381
  return config.managed === true ? managedClaudeKeyFor(jobDir) !== void 0 : agentCredential(hostEnv, {}, agents) !== void 0;
381
382
  }
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
- }
447
383
 
448
384
  // src/runner/managed-build-settings.ts
449
385
  var FETCH_RETRY_WINDOW_MS2 = 3e4;
450
386
  var GIB = 1024 ** 3;
451
387
  var GB = 1e9;
452
- var VARIABLE_NAME2 = /^[A-Za-z_][A-Za-z0-9_]{0,254}$/;
388
+ var VARIABLE_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,254}$/;
453
389
  var MALFORMED = "the gateway's answer was not a machine, a list of hosts and a list of variables";
454
390
  function parseSettings(data) {
455
391
  const isPositive = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
@@ -469,7 +405,7 @@ function parseSettings(data) {
469
405
  if (typeof entry !== "object" || entry === null) return { problem: MALFORMED };
470
406
  const { name, value } = entry;
471
407
  if (typeof name !== "string" || name === "" || typeof value !== "string") return { problem: MALFORMED };
472
- if (!VARIABLE_NAME2.test(name)) return { problem: `the factory's build variable ${JSON.stringify(name)} is not a variable name` };
408
+ if (!VARIABLE_NAME.test(name)) return { problem: `the factory's build variable ${JSON.stringify(name)} is not a variable name` };
473
409
  if (value.trim().length < MIN_SCRUBBED_LITERAL) {
474
410
  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` };
475
411
  }
@@ -478,10 +414,8 @@ function parseSettings(data) {
478
414
  const sent = parseProxied(proxied, MALFORMED);
479
415
  if ("problem" in sent) return { problem: sent.problem };
480
416
  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
- }
417
+ for (const { name } of sent.proxied) {
418
+ if (plain3.has(name)) return { problem: `the gateway listed the factory's build variable ${name} as plain and as sent to a service` };
485
419
  }
486
420
  return { settings: { machine: { size, vcpus, memoryGiB, diskGB }, allowHosts: [...allowHosts], variables: parsed, proxied: sent.proxied } };
487
421
  }
@@ -505,6 +439,15 @@ function managedBuildSettingsFor(jobDir) {
505
439
  }
506
440
  function dropManagedBuildSettings(jobDir) {
507
441
  held2.delete(jobDir);
442
+ dropBuildAuthority(jobDir);
443
+ }
444
+ function ensureBuildAuthority(jobDir) {
445
+ if (jobDir !== void 0 && (held2.get(jobDir)?.proxied?.length ?? 0) > 0) buildAuthorityFor(jobDir);
446
+ }
447
+ function proxiedEnvironment(jobDir) {
448
+ const env = {};
449
+ for (const variable of held2.get(jobDir)?.proxied ?? []) env[variable.name] = STAND_IN;
450
+ return env;
508
451
  }
509
452
  function managedBuildSettingValues() {
510
453
  return [...new Set([...held2.values()].flatMap((settings) => [...settings.variables, ...settings.proxied ?? []].map(({ value }) => value)))];
@@ -519,35 +462,8 @@ function managedMachineLimits(settings) {
519
462
  }
520
463
  function withFactoryHosts(runnerHosts, settings) {
521
464
  if (settings === void 0) return runnerHosts;
522
- return [.../* @__PURE__ */ new Set([...runnerHosts ?? [], ...settings.allowHosts])];
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;
465
+ const proxiedHosts = (settings.proxied ?? []).map((variable) => hostKeyOf(variable.upstream).host);
466
+ return [.../* @__PURE__ */ new Set([...runnerHosts ?? [], ...settings.allowHosts, ...proxiedHosts])];
551
467
  }
552
468
  var AssetError = class extends Error {
553
469
  constructor(file, message) {
@@ -3554,6 +3470,141 @@ function writeGhConfig(dir, token) {
3554
3470
  replaceFile(join(dir, "hosts.yml"), ghHostsYml(token));
3555
3471
  replaceFile(join(dir, "config.yml"), GH_CONFIG_YML);
3556
3472
  }
3473
+ var DeliveryFailure = class extends Error {
3474
+ };
3475
+ var BLOCK2 = 512;
3476
+ var DELIVERY_TIMEOUT_MS = 5 * 6e4;
3477
+ var RECEIVE_ARGV = ["/opt/outerlayer/bin/node", "/opt/outerlayer/cli/dist/index.js", "receive-files"];
3478
+ var REASON_LINE_MAX = 240;
3479
+ var STEPS = {
3480
+ gh: "the build's gh configuration",
3481
+ "git-hooks": "the commit hooks",
3482
+ context: "the staged context",
3483
+ "eval-input": "the checks' input",
3484
+ inbox: "the comments for the agent"
3485
+ };
3486
+ function field(header, at, length, text2) {
3487
+ header.write(text2, at, length, "latin1");
3488
+ }
3489
+ function octalField(header, at, length, value) {
3490
+ field(header, at, length, `${value.toString(8).padStart(length - 1, "0")}\0`);
3491
+ }
3492
+ function tarHeader2(name, type, mode, size) {
3493
+ const header = Buffer.alloc(BLOCK2);
3494
+ header.write(name, 0, 100, "utf8");
3495
+ octalField(header, 100, 8, mode);
3496
+ octalField(header, 108, 8, 0);
3497
+ octalField(header, 116, 8, 0);
3498
+ octalField(header, 124, 12, size);
3499
+ octalField(header, 136, 12, 0);
3500
+ field(header, 148, 8, " ");
3501
+ header.write(type, 156, 1, "latin1");
3502
+ field(header, 257, 6, "ustar\0");
3503
+ field(header, 263, 2, "00");
3504
+ let sum = 0;
3505
+ for (const byte of header) sum += byte;
3506
+ field(header, 148, 8, `${sum.toString(8).padStart(6, "0")}\0 `);
3507
+ return header;
3508
+ }
3509
+ function padded(data) {
3510
+ const rest = data.length % BLOCK2;
3511
+ return rest === 0 ? data : Buffer.concat([data, Buffer.alloc(BLOCK2 - rest)]);
3512
+ }
3513
+ function paxRecord(key, value) {
3514
+ const body = Buffer.from(` ${key}=${value}
3515
+ `, "utf8");
3516
+ let length = body.length + 1;
3517
+ while (String(length).length + body.length !== length) length = String(length).length + body.length;
3518
+ return Buffer.concat([Buffer.from(String(length), "latin1"), body]);
3519
+ }
3520
+ function packTar(entries) {
3521
+ const blocks = [];
3522
+ for (const entry of entries) {
3523
+ const data = entry.type === "file" ? entry.data ?? Buffer.alloc(0) : Buffer.alloc(0);
3524
+ const name = entry.type === "dir" && !entry.path.endsWith("/") ? `${entry.path}/` : entry.path;
3525
+ if (Buffer.byteLength(name, "utf8") > 100) {
3526
+ const record = paxRecord("path", name);
3527
+ blocks.push(tarHeader2("PaxHeader", "x", 420, record.length), padded(record));
3528
+ }
3529
+ blocks.push(tarHeader2(name, entry.type === "dir" ? "5" : "0", entry.mode, data.length), padded(data));
3530
+ }
3531
+ blocks.push(Buffer.alloc(BLOCK2 * 2));
3532
+ return Buffer.concat(blocks);
3533
+ }
3534
+ function fileMode(hostMode) {
3535
+ return 292 | hostMode & 128 | ((hostMode & 73) === 0 ? 0 : 73);
3536
+ }
3537
+ function packFolder(dir, options = {}) {
3538
+ const entries = options.rootMode === void 0 ? [] : [{ path: "./", type: "dir", mode: options.rootMode }];
3539
+ const walk = (current, prefix) => {
3540
+ for (const name of readdirSync(current).sort()) {
3541
+ const path = join(current, name);
3542
+ const stat = lstatSync(path);
3543
+ const rel = prefix === "" ? name : `${prefix}/${name}`;
3544
+ if (stat.isDirectory()) {
3545
+ entries.push({ path: rel, type: "dir", mode: options.dirModes?.[rel] ?? 493 });
3546
+ walk(path, rel);
3547
+ } else if (stat.isFile()) {
3548
+ entries.push({ path: rel, type: "file", mode: fileMode(stat.mode), data: readFileSync(path) });
3549
+ }
3550
+ }
3551
+ };
3552
+ walk(dir, "");
3553
+ return packTar(entries);
3554
+ }
3555
+ function scrubDelivery(text2, secrets) {
3556
+ let out = text2.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, "").replace(/[\u0000-\u001f\u007f-\u009f]/g, " ");
3557
+ for (const secret of secrets()) if (secret !== "") out = out.split(secret).join("[redacted]");
3558
+ out = out.replace(/\b(?:gh[pousr]_|github_pat_)[A-Za-z0-9_]+/g, "[redacted]");
3559
+ out = out.trim();
3560
+ return out.length > REASON_LINE_MAX ? `${out.slice(0, REASON_LINE_MAX)}...` : out;
3561
+ }
3562
+ async function deliverTar(runtime, state, input) {
3563
+ try {
3564
+ const result = await runtime.host.exec(
3565
+ {
3566
+ container: state.container,
3567
+ user: RELAY_USER,
3568
+ env: { literals: {}, passed: {} },
3569
+ argv: [...RECEIVE_ARGV, "--into", input.into, ...input.replace === true ? ["--replace"] : []],
3570
+ stdin: input.tar
3571
+ },
3572
+ { timeoutMs: DELIVERY_TIMEOUT_MS }
3573
+ );
3574
+ if (result.status === 0) return { ok: true };
3575
+ const line2 = scrubDelivery(result.stderr.trim().split("\n")[0] ?? "", input.secrets);
3576
+ return { ok: false, reason: `${input.step} could not be delivered (exit ${result.status})${line2 === "" ? "" : `: ${line2}`}` };
3577
+ } catch (err) {
3578
+ return { ok: false, reason: `${input.step} could not be delivered: ${scrubDelivery(describeCallFailure(err), input.secrets)}` };
3579
+ }
3580
+ }
3581
+ async function deliverJobFiles(runtime, state, parts, secrets) {
3582
+ for (const part of parts) {
3583
+ const dir = join(state.buildDir, part === "eval-input" ? EVAL_INPUT_NAME : part);
3584
+ if (!existsSync(dir)) continue;
3585
+ let tar;
3586
+ try {
3587
+ tar = packFolder(dir);
3588
+ } catch (err) {
3589
+ return { ok: false, reason: `${STEPS[part]} could not be read on the host: ${scrubDelivery(describeCallFailure(err), secrets)}` };
3590
+ }
3591
+ const delivered = await deliverTar(runtime, state, { step: STEPS[part], tar, into: `${JOB_MOUNT}/${part}`, replace: part === "eval-input", secrets });
3592
+ if (!delivered.ok) return delivered;
3593
+ }
3594
+ return { ok: true };
3595
+ }
3596
+ function deliverGhConfig(runtime, state, secrets) {
3597
+ return deliverJobFiles(runtime, state, ["gh"], secrets);
3598
+ }
3599
+ function deliverEvalInput(runtime, state, secrets) {
3600
+ return deliverJobFiles(runtime, state, ["eval-input"], secrets);
3601
+ }
3602
+ async function deliverJudgeInputs(runtime, state, dir, secrets) {
3603
+ return deliverTar(runtime, state, { step: "the judge's inputs", tar: packFolder(dir, { rootMode: 1023, dirModes: { home: 511, "home/tmp": 511 } }), into: JUDGE_DIR, replace: true, secrets });
3604
+ }
3605
+ function clearJudgeFolder(runtime, state, secrets) {
3606
+ return deliverTar(runtime, state, { step: "clearing the judge's folder", tar: packTar([]), into: JUDGE_DIR, replace: true, secrets });
3607
+ }
3557
3608
  async function serveLease(socketPath, channel, makeServer = createServer, listenOn) {
3558
3609
  const server = makeServer((socket) => channel.accept(socket));
3559
3610
  if (listenOn === void 0) {
@@ -3762,7 +3813,8 @@ function factoryVariablesOf(config, jobDir) {
3762
3813
  if (held3 !== void 0) return held3;
3763
3814
  return config.managed === true ? [] : void 0;
3764
3815
  }
3765
- function execEnvironment(image, env) {
3816
+ function execEnvironment(image, given) {
3817
+ const env = applyTrust(given, image);
3766
3818
  const merged = { ...image, ...env.literals };
3767
3819
  for (const [name, value] of Object.entries(env.passed)) if (value !== void 0) merged[name] = value;
3768
3820
  return merged;
@@ -3832,6 +3884,44 @@ async function unpackIntoGuest(runtime, state, dir, target2, opts = {}) {
3832
3884
  const result = await asRoot(runtime, state, ["/bin/sh", "-c", script], tarOf(dir));
3833
3885
  if (result.status !== 0) throw new Error(`unpacking into ${target2} in the guest failed (exit ${result.status}): ${firstLine(result.stderr)}`);
3834
3886
  }
3887
+ var GUEST_TRUST_DIR = `${JOB_MOUNT}/trust`;
3888
+ var SYSTEM_STORE = {
3889
+ bundles: IMAGE_BUNDLES,
3890
+ merged: `${GUEST_TRUST_DIR}/bundle.crt`,
3891
+ image: `${GUEST_TRUST_DIR}/image-bundle.crt`,
3892
+ helper: HELPER_PATH
3893
+ };
3894
+ function imageBundleScript(paths = SYSTEM_STORE) {
3895
+ return `if [ -f ${paths.image} ]; then cat ${paths.image}; exit 0; fi; ${readBundleScript()}`;
3896
+ }
3897
+ function systemStoreScript(paths = SYSTEM_STORE) {
3898
+ return [
3899
+ "set -e",
3900
+ `store=; for ca in ${paths.bundles.join(" ")}; do if [ -f "$ca" ]; then store=$ca; break; fi; done`,
3901
+ '[ -n "$store" ] || exit 0',
3902
+ 'store=$(readlink -f "$store")',
3903
+ 'if grep -qF " $store " /proc/mounts; then exit 0; fi',
3904
+ `[ -f ${paths.image} ] || cat "$store" > ${paths.image}`,
3905
+ `exec ${paths.helper} mount --bind --options ro --source ${paths.merged} --target "$store"`
3906
+ ].join("\n");
3907
+ }
3908
+ async function installTrust(runtime, state, jobDir) {
3909
+ const authority = heldBuildAuthority(jobDir);
3910
+ if (authority === void 0) return;
3911
+ const bundle = await asRoot(runtime, state, ["/bin/sh", "-c", imageBundleScript()]);
3912
+ const bundleRead = bundle.status === 0 && bundle.stdout.trim() !== "";
3913
+ const dir = join(state.buildDir, "trust");
3914
+ writeTrustFiles(dir, authority, bundleRead ? bundle.stdout : void 0);
3915
+ const unpacked = await asRoot(
3916
+ runtime,
3917
+ state,
3918
+ ["/bin/sh", "-c", `set -e; mkdir -p ${GUEST_TRUST_DIR}; d=$(mktemp -d); tar -x --no-same-owner -C "$d"; for f in "$d"/*; do cat "$f" > ${GUEST_TRUST_DIR}/$(basename "$f"); done; rm -rf "$d"; chmod -R a+rX ${GUEST_TRUST_DIR}`],
3919
+ packFolder(dir)
3920
+ );
3921
+ if (unpacked.status !== 0) throw new Error(`unpacking the trust files into the guest failed (exit ${unpacked.status}): ${firstLine(unpacked.stderr)}`);
3922
+ const added = await asRoot(runtime, state, ["/bin/sh", "-c", systemStoreScript()]);
3923
+ if (added.status !== 0) throw new Error(`adding the build's authority to the guest's system store failed (exit ${added.status}): ${firstLine(added.stderr)}`);
3924
+ }
3835
3925
  async function deliverCommitHooks(input) {
3836
3926
  await unpackIntoGuest(input.runtime, input.state, input.hooksDir, GUEST_HOOKS_DIR);
3837
3927
  }
@@ -3992,6 +4082,7 @@ async function provisionMicroVmOnce(input, allowRestore, itemDiskFailed) {
3992
4082
  ...governingSource.kind === "governed" ? { governing: { repository: governingSource.repository, ref: governingSource.ref, commit: governingSource.sha } } : {},
3993
4083
  ...report.docker === true ? { docker: true } : {}
3994
4084
  };
4085
+ ensureBuildAuthority(jobDir);
3995
4086
  const envInput = {
3996
4087
  config,
3997
4088
  item: item.number,
@@ -4003,7 +4094,8 @@ async function provisionMicroVmOnce(input, allowRestore, itemDiskFailed) {
4003
4094
  containerEnv: report.apply.containerEnv,
4004
4095
  builtIns: true,
4005
4096
  factoryVariables: factoryVariablesOf(config, jobDir),
4006
- proxiedEnvironment: proxiedEnvironment(jobDir)
4097
+ proxiedEnvironment: proxiedEnvironment(jobDir),
4098
+ trustEnvironment: trustEnvironment(jobDir)
4007
4099
  };
4008
4100
  const env = buildEnvironment(envInput);
4009
4101
  if (env.skippedTokenVariables.length > 0) {
@@ -4071,7 +4163,7 @@ async function provisionMicroVmOnce(input, allowRestore, itemDiskFailed) {
4071
4163
  } catch (err) {
4072
4164
  return bail(`the tunnel could not start: ${describeCallFailure(err)}`);
4073
4165
  }
4074
- const links = vsockLinks({ destinations: config.build?.destinations?.length ?? 0, builtIns: true, factory: factoryIndexes(jobDir) }, runtime.agents);
4166
+ const links = vsockLinks({ destinations: config.build?.destinations?.length ?? 0, builtIns: true }, runtime.agents);
4075
4167
  const served = input.leaseTimeLeftMs === void 0 ? links : [...links, LEASE_LINK];
4076
4168
  let leaseServer;
4077
4169
  if (input.leaseTimeLeftMs !== void 0) {
@@ -4235,6 +4327,11 @@ async function provisionMicroVmOnce(input, allowRestore, itemDiskFailed) {
4235
4327
  } catch (err) {
4236
4328
  return bail(describeCallFailure(err));
4237
4329
  }
4330
+ try {
4331
+ await installTrust(runtime, state, jobDir);
4332
+ } catch (err) {
4333
+ return bail(describeCallFailure(err));
4334
+ }
4238
4335
  const agentUid = agentUidOf(await asRoot(runtime, state, ["id", "-u", agentUser]));
4239
4336
  const guest = guestPortFor(runtime, state);
4240
4337
  if (plan.restore !== void 0) {
@@ -4366,9 +4463,10 @@ function vmExecFor(input, argv) {
4366
4463
  builtIns: state.builtIns === true,
4367
4464
  identity: input.job.commitIdentity,
4368
4465
  factoryVariables: factoryVariablesOf(input.config, input.jobDir),
4369
- proxiedEnvironment: proxiedEnvironment(input.jobDir)
4466
+ proxiedEnvironment: proxiedEnvironment(input.jobDir),
4467
+ trustEnvironment: trustEnvironment(input.jobDir)
4370
4468
  });
4371
- const env = withExtraEnv(built, input.extraEnv);
4469
+ const env = applyTrust(withExtraEnv(built, input.extraEnv), state.imageEnv);
4372
4470
  const options = {
4373
4471
  socket: state.vsockPath,
4374
4472
  user: state.agentUser ?? ADDED_USER,
@@ -4404,7 +4502,8 @@ async function startMicroVmCommand(input) {
4404
4502
  builtIns: state.builtIns === true,
4405
4503
  identity: input.job.commitIdentity,
4406
4504
  factoryVariables: factoryVariablesOf(input.config, input.jobDir),
4407
- proxiedEnvironment: proxiedEnvironment(input.jobDir)
4505
+ proxiedEnvironment: proxiedEnvironment(input.jobDir),
4506
+ trustEnvironment: trustEnvironment(input.jobDir)
4408
4507
  }), input.extraEnv);
4409
4508
  const started = await input.runtime.vm.exec(state.vsockPath, {
4410
4509
  argv: ["/bin/sh", "-c", commandWithShim(input.job, input.cmdline)],
@@ -4457,7 +4556,8 @@ async function runCliInMicroVm(input, argv, logName, goneReason) {
4457
4556
  builtIns: state.builtIns === true,
4458
4557
  identity: job.commitIdentity,
4459
4558
  factoryVariables: factoryVariablesOf(input.config, input.jobDir),
4460
- proxiedEnvironment: proxiedEnvironment(input.jobDir)
4559
+ proxiedEnvironment: proxiedEnvironment(input.jobDir),
4560
+ trustEnvironment: trustEnvironment(input.jobDir)
4461
4561
  });
4462
4562
  const result = await runtime.vm.exec(state.vsockPath, {
4463
4563
  argv,
@@ -4654,7 +4754,7 @@ async function startCheckMicroVm(input) {
4654
4754
  return fail(`the tunnel could not start: ${describeCallFailure(err)}`);
4655
4755
  }
4656
4756
  if (abandoned()) return fail(ABANDONED);
4657
- const links = vsockLinks({ destinations: config.build?.destinations?.length ?? 0, builtIns: false, factory: factoryIndexes(jobDir) });
4757
+ const links = vsockLinks({ destinations: config.build?.destinations?.length ?? 0, builtIns: false });
4658
4758
  const configPath = join(buildDir2, "vm.json");
4659
4759
  const helper = await helperFor(runtime, (line2) => log.line(`${tag} ${line2}`), config.managed === true);
4660
4760
  if (helper === void 0 && config.managed === true) return fail(MANAGED_UNJAILED_REASON);
@@ -4714,6 +4814,11 @@ async function startCheckMicroVm(input) {
4714
4814
  return describeCallFailure(err);
4715
4815
  }
4716
4816
  }
4817
+ try {
4818
+ await installTrust(runtime, state, jobDir);
4819
+ } catch (err) {
4820
+ return describeCallFailure(err);
4821
+ }
4717
4822
  if (built.docker === true) return waitForDocker(runtime, state, agentUser, () => /* @__PURE__ */ new Date());
4718
4823
  return void 0;
4719
4824
  };
@@ -4728,7 +4833,8 @@ async function startCheckMicroVm(input) {
4728
4833
  containerEnv: built.containerEnv ?? {},
4729
4834
  // The checks of a managed build get its factory's variables, as its command did, and none of the runner's own.
4730
4835
  factoryVariables: factoryVariablesOf(config, jobDir),
4731
- proxiedEnvironment: proxiedEnvironment(jobDir)
4836
+ proxiedEnvironment: proxiedEnvironment(jobDir),
4837
+ trustEnvironment: trustEnvironment(jobDir)
4732
4838
  });
4733
4839
  const evalInput = { dir: join(checksDir, EVAL_INPUT_NAME), delivered: false };
4734
4840
  const deliverEvalInput2 = async () => {
@@ -4979,6 +5085,151 @@ async function sampleGuest(runtime, state) {
4979
5085
  return void 0;
4980
5086
  }
4981
5087
  }
5088
+ var CONNECTION_HEADERS = /* @__PURE__ */ new Set(["connection", "keep-alive", "proxy-connection", "upgrade"]);
5089
+ var MAX_UPSTREAM_SOCKETS = 6;
5090
+ var KEEP_ALIVE_MS = 6e4;
5091
+ function respond(res, status, body) {
5092
+ if (res.headersSent) {
5093
+ res.destroy();
5094
+ return;
5095
+ }
5096
+ res.writeHead(status, { "Content-Type": "text/plain", "Content-Length": Buffer.byteLength(body), Connection: "close" });
5097
+ res.end(body);
5098
+ }
5099
+ function createDecryptor(deps) {
5100
+ const { decrypt } = deps;
5101
+ const connections = /* @__PURE__ */ new WeakMap();
5102
+ const open = /* @__PURE__ */ new Set();
5103
+ const handle = (req, res) => {
5104
+ const connection = connections.get(req.socket);
5105
+ const target2 = req.url ?? "";
5106
+ if (connection === void 0 || !target2.startsWith("/")) {
5107
+ respond(res, 400, "send an origin-form request path\n");
5108
+ return;
5109
+ }
5110
+ const all = decrypt.variables();
5111
+ const candidates = variablesFor(all, connection.host, connection.port);
5112
+ if (candidates.length === 0) {
5113
+ respond(res, 502, "the runner no longer holds a credential for this host\n");
5114
+ return;
5115
+ }
5116
+ const matched = variableForPath(candidates, target2);
5117
+ const dropped = droppedRequestHeaders();
5118
+ if (matched !== void 0) {
5119
+ if (req.method === "TRACE") return respond(res, 405, "TRACE is not sent to this service\n");
5120
+ if (hasDotDotSegment(target2)) return respond(res, 400, "send a request path without .. segments\n");
5121
+ } else {
5122
+ for (const name of ["authorization", "cookie"]) dropped.delete(name);
5123
+ }
5124
+ const route = matched === void 0 ? void 0 : routeNameOf(all, matched);
5125
+ let finished2 = false;
5126
+ const finish2 = (ok) => {
5127
+ if (finished2 || route === void 0) return;
5128
+ finished2 = true;
5129
+ deps.onFinished(route, ok);
5130
+ };
5131
+ res.on("finish", () => finish2(true));
5132
+ res.on("close", () => finish2(false));
5133
+ const headers = {};
5134
+ for (const [name, value] of Object.entries(req.headers)) {
5135
+ if (!dropped.has(name)) headers[name] = value;
5136
+ }
5137
+ const url = new URL(matched?.upstream ?? candidates[0].upstream);
5138
+ headers.host = url.host;
5139
+ if (matched !== void 0) {
5140
+ delete headers[matched.header.name.toLowerCase()];
5141
+ headers[matched.header.name.toLowerCase()] = matched.header.value.split("${VALUE}").join(matched.value);
5142
+ }
5143
+ let forwarded;
5144
+ try {
5145
+ forwarded = request({ method: req.method, path: target2, headers, agent: connection.agent });
5146
+ } catch {
5147
+ respond(res, 502, "the service cannot be reached: its header value was refused\n");
5148
+ return;
5149
+ }
5150
+ if (route !== void 0) deps.onUsed(route);
5151
+ forwarded.once("response", (answer) => {
5152
+ const forward = {};
5153
+ for (const [name, value] of Object.entries(answer.headers)) {
5154
+ if (!CONNECTION_HEADERS.has(name)) forward[name] = value;
5155
+ }
5156
+ res.writeHead(answer.statusCode ?? 502, forward);
5157
+ answer.on("error", () => res.destroy());
5158
+ answer.on("close", () => {
5159
+ if (!answer.complete) {
5160
+ finish2(false);
5161
+ res.destroy();
5162
+ }
5163
+ });
5164
+ answer.pipe(res);
5165
+ });
5166
+ forwarded.setTimeout(deps.idleTimeoutMs, () => forwarded.destroy());
5167
+ res.on("close", () => forwarded.destroy());
5168
+ forwarded.on("error", (err) => {
5169
+ deps.log?.(`route ${route ?? connection.host} could not reach its service: ${typeof err.code === "string" ? err.code : "unknown"}`);
5170
+ finish2(false);
5171
+ respond(res, 502, `the service ${connection.host} could not be reached
5172
+ `);
5173
+ });
5174
+ const metered = deps.meter();
5175
+ res.once("close", () => metered.destroy());
5176
+ req.pipe(metered).pipe(forwarded);
5177
+ };
5178
+ const server = createServer$1(handle);
5179
+ server.keepAliveTimeout = KEEP_ALIVE_MS;
5180
+ server.requestTimeout = 0;
5181
+ server.on("clientError", (_err, socket) => socket.destroy());
5182
+ return {
5183
+ matches: (host, port) => variablesFor(decrypt.variables(), host, port).length > 0,
5184
+ accept(client, head, target2) {
5185
+ const host = target2.host.toLowerCase();
5186
+ const leaf = decrypt.authority.leafFor(host);
5187
+ let carrier = client;
5188
+ if (head.length > 0) {
5189
+ const inbound = new PassThrough();
5190
+ inbound.write(head);
5191
+ client.pipe(inbound);
5192
+ carrier = Duplex.from({ readable: inbound, writable: client });
5193
+ }
5194
+ const tls = new TLSSocket(carrier, { isServer: true, secureContext: createSecureContext({ key: leaf.keyPem, cert: leaf.certPem }), ALPNProtocols: ["http/1.1"] });
5195
+ const agent = new Agent({ keepAlive: true, maxSockets: MAX_UPSTREAM_SOCKETS });
5196
+ agent.createConnection = () => {
5197
+ const raw = deps.connect({ address: target2.address, port: target2.port });
5198
+ const upstream = connect$1({
5199
+ socket: raw,
5200
+ host: target2.host,
5201
+ ...isIP(target2.host) === 0 ? { servername: target2.host } : {},
5202
+ ...decrypt.upstreamCa === void 0 ? {} : { ca: [decrypt.upstreamCa] },
5203
+ ALPNProtocols: ["http/1.1"]
5204
+ });
5205
+ const timer = setTimeout(() => upstream.destroy(Object.assign(new Error("connect timed out"), { code: "ETIMEDOUT" })), deps.connectTimeoutMs);
5206
+ timer.unref();
5207
+ upstream.once("secureConnect", () => clearTimeout(timer));
5208
+ upstream.once("close", () => {
5209
+ clearTimeout(timer);
5210
+ raw.destroy();
5211
+ });
5212
+ return upstream;
5213
+ };
5214
+ connections.set(tls, { host, port: target2.port, agent });
5215
+ open.add(tls);
5216
+ tls.setTimeout(deps.idleTimeoutMs, () => tls.destroy());
5217
+ tls.on("error", () => tls.destroy());
5218
+ tls.once("close", () => {
5219
+ open.delete(tls);
5220
+ agent.destroy();
5221
+ client.destroy();
5222
+ });
5223
+ server.emit("connection", tls);
5224
+ },
5225
+ close() {
5226
+ for (const tls of open) tls.destroy();
5227
+ server.close();
5228
+ }
5229
+ };
5230
+ }
5231
+
5232
+ // src/runner/container/tunnel.ts
4982
5233
  function isLiteralAddress(text2) {
4983
5234
  return isIP(text2) !== 0;
4984
5235
  }
@@ -5256,6 +5507,22 @@ async function startTunnel(socketPath, opts = {}) {
5256
5507
  return { ok: false, status: 403, body: `refused: ${host} is ${address}${via}, in the ${name} range ${cidr}
5257
5508
  ` };
5258
5509
  }
5510
+ const decryptor = opts.decrypt === void 0 ? void 0 : createDecryptor({
5511
+ decrypt: opts.upstreamCa === void 0 || opts.decrypt.upstreamCa !== void 0 ? opts.decrypt : { ...opts.decrypt, upstreamCa: opts.upstreamCa },
5512
+ connect: openConnection,
5513
+ onUsed: (route) => destinationUsed(route),
5514
+ onFinished: (route, ok) => routeFinished(route, ok),
5515
+ meter: () => limits2.sendBytesPerSecond > 0 ? meter() : new Transform({
5516
+ transform(chunk, _encoding, done) {
5517
+ counts.bytesSent += chunk.length;
5518
+ persistSoon();
5519
+ done(null, chunk);
5520
+ }
5521
+ }),
5522
+ idleTimeoutMs,
5523
+ connectTimeoutMs,
5524
+ log: opts.log
5525
+ });
5259
5526
  const sockets = /* @__PURE__ */ new Set();
5260
5527
  const server = createServer$1((req, res) => {
5261
5528
  void proxyPlain(req, res);
@@ -5295,6 +5562,12 @@ ${body}`);
5295
5562
  reply(client, decision.status, decision.body);
5296
5563
  return;
5297
5564
  }
5565
+ if (decryptor?.matches(target2.host, target2.port) === true) {
5566
+ reached(target2.host);
5567
+ client.write("HTTP/1.1 200 Connection Established\r\n\r\n");
5568
+ decryptor.accept(client, head, { host: target2.host, port: target2.port, address: decision.address });
5569
+ return;
5570
+ }
5298
5571
  const upstream = openConnection({ address: decision.address, port: target2.port });
5299
5572
  upstream.setTimeout(connectTimeoutMs);
5300
5573
  const failed = (err) => {
@@ -5485,6 +5758,7 @@ ${body}`);
5485
5758
  clearTimeout(saveTimer);
5486
5759
  saveTimer = void 0;
5487
5760
  persist();
5761
+ decryptor?.close();
5488
5762
  for (const socket of sockets) socket.destroy();
5489
5763
  for (const tcp of tcpServers) tcp.close();
5490
5764
  server.close(() => resolveClose());
@@ -9439,141 +9713,6 @@ function superviseRelay(input) {
9439
9713
  }
9440
9714
  };
9441
9715
  }
9442
- var DeliveryFailure = class extends Error {
9443
- };
9444
- var BLOCK2 = 512;
9445
- var DELIVERY_TIMEOUT_MS = 5 * 6e4;
9446
- var RECEIVE_ARGV = ["/opt/outerlayer/bin/node", "/opt/outerlayer/cli/dist/index.js", "receive-files"];
9447
- var REASON_LINE_MAX = 240;
9448
- var STEPS = {
9449
- gh: "the build's gh configuration",
9450
- "git-hooks": "the commit hooks",
9451
- context: "the staged context",
9452
- "eval-input": "the checks' input",
9453
- inbox: "the comments for the agent"
9454
- };
9455
- function field(header, at, length, text2) {
9456
- header.write(text2, at, length, "latin1");
9457
- }
9458
- function octalField(header, at, length, value) {
9459
- field(header, at, length, `${value.toString(8).padStart(length - 1, "0")}\0`);
9460
- }
9461
- function tarHeader2(name, type, mode, size) {
9462
- const header = Buffer.alloc(BLOCK2);
9463
- header.write(name, 0, 100, "utf8");
9464
- octalField(header, 100, 8, mode);
9465
- octalField(header, 108, 8, 0);
9466
- octalField(header, 116, 8, 0);
9467
- octalField(header, 124, 12, size);
9468
- octalField(header, 136, 12, 0);
9469
- field(header, 148, 8, " ");
9470
- header.write(type, 156, 1, "latin1");
9471
- field(header, 257, 6, "ustar\0");
9472
- field(header, 263, 2, "00");
9473
- let sum = 0;
9474
- for (const byte of header) sum += byte;
9475
- field(header, 148, 8, `${sum.toString(8).padStart(6, "0")}\0 `);
9476
- return header;
9477
- }
9478
- function padded(data) {
9479
- const rest = data.length % BLOCK2;
9480
- return rest === 0 ? data : Buffer.concat([data, Buffer.alloc(BLOCK2 - rest)]);
9481
- }
9482
- function paxRecord(key, value) {
9483
- const body = Buffer.from(` ${key}=${value}
9484
- `, "utf8");
9485
- let length = body.length + 1;
9486
- while (String(length).length + body.length !== length) length = String(length).length + body.length;
9487
- return Buffer.concat([Buffer.from(String(length), "latin1"), body]);
9488
- }
9489
- function packTar(entries) {
9490
- const blocks = [];
9491
- for (const entry of entries) {
9492
- const data = entry.type === "file" ? entry.data ?? Buffer.alloc(0) : Buffer.alloc(0);
9493
- const name = entry.type === "dir" && !entry.path.endsWith("/") ? `${entry.path}/` : entry.path;
9494
- if (Buffer.byteLength(name, "utf8") > 100) {
9495
- const record = paxRecord("path", name);
9496
- blocks.push(tarHeader2("PaxHeader", "x", 420, record.length), padded(record));
9497
- }
9498
- blocks.push(tarHeader2(name, entry.type === "dir" ? "5" : "0", entry.mode, data.length), padded(data));
9499
- }
9500
- blocks.push(Buffer.alloc(BLOCK2 * 2));
9501
- return Buffer.concat(blocks);
9502
- }
9503
- function fileMode(hostMode) {
9504
- return 292 | hostMode & 128 | ((hostMode & 73) === 0 ? 0 : 73);
9505
- }
9506
- function packFolder(dir, options = {}) {
9507
- const entries = options.rootMode === void 0 ? [] : [{ path: "./", type: "dir", mode: options.rootMode }];
9508
- const walk = (current, prefix) => {
9509
- for (const name of readdirSync(current).sort()) {
9510
- const path = join(current, name);
9511
- const stat = lstatSync(path);
9512
- const rel = prefix === "" ? name : `${prefix}/${name}`;
9513
- if (stat.isDirectory()) {
9514
- entries.push({ path: rel, type: "dir", mode: options.dirModes?.[rel] ?? 493 });
9515
- walk(path, rel);
9516
- } else if (stat.isFile()) {
9517
- entries.push({ path: rel, type: "file", mode: fileMode(stat.mode), data: readFileSync(path) });
9518
- }
9519
- }
9520
- };
9521
- walk(dir, "");
9522
- return packTar(entries);
9523
- }
9524
- function scrubDelivery(text2, secrets) {
9525
- let out = text2.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, "").replace(/[\u0000-\u001f\u007f-\u009f]/g, " ");
9526
- for (const secret of secrets()) if (secret !== "") out = out.split(secret).join("[redacted]");
9527
- out = out.replace(/\b(?:gh[pousr]_|github_pat_)[A-Za-z0-9_]+/g, "[redacted]");
9528
- out = out.trim();
9529
- return out.length > REASON_LINE_MAX ? `${out.slice(0, REASON_LINE_MAX)}...` : out;
9530
- }
9531
- async function deliverTar(runtime, state, input) {
9532
- try {
9533
- const result = await runtime.host.exec(
9534
- {
9535
- container: state.container,
9536
- user: RELAY_USER,
9537
- env: { literals: {}, passed: {} },
9538
- argv: [...RECEIVE_ARGV, "--into", input.into, ...input.replace === true ? ["--replace"] : []],
9539
- stdin: input.tar
9540
- },
9541
- { timeoutMs: DELIVERY_TIMEOUT_MS }
9542
- );
9543
- if (result.status === 0) return { ok: true };
9544
- const line2 = scrubDelivery(result.stderr.trim().split("\n")[0] ?? "", input.secrets);
9545
- return { ok: false, reason: `${input.step} could not be delivered (exit ${result.status})${line2 === "" ? "" : `: ${line2}`}` };
9546
- } catch (err) {
9547
- return { ok: false, reason: `${input.step} could not be delivered: ${scrubDelivery(describeCallFailure(err), input.secrets)}` };
9548
- }
9549
- }
9550
- async function deliverJobFiles(runtime, state, parts, secrets) {
9551
- for (const part of parts) {
9552
- const dir = join(state.buildDir, part === "eval-input" ? EVAL_INPUT_NAME : part);
9553
- if (!existsSync(dir)) continue;
9554
- let tar;
9555
- try {
9556
- tar = packFolder(dir);
9557
- } catch (err) {
9558
- return { ok: false, reason: `${STEPS[part]} could not be read on the host: ${scrubDelivery(describeCallFailure(err), secrets)}` };
9559
- }
9560
- const delivered = await deliverTar(runtime, state, { step: STEPS[part], tar, into: `${JOB_MOUNT}/${part}`, replace: part === "eval-input", secrets });
9561
- if (!delivered.ok) return delivered;
9562
- }
9563
- return { ok: true };
9564
- }
9565
- function deliverGhConfig(runtime, state, secrets) {
9566
- return deliverJobFiles(runtime, state, ["gh"], secrets);
9567
- }
9568
- function deliverEvalInput(runtime, state, secrets) {
9569
- return deliverJobFiles(runtime, state, ["eval-input"], secrets);
9570
- }
9571
- async function deliverJudgeInputs(runtime, state, dir, secrets) {
9572
- return deliverTar(runtime, state, { step: "the judge's inputs", tar: packFolder(dir, { rootMode: 1023, dirModes: { home: 511, "home/tmp": 511 } }), into: JUDGE_DIR, replace: true, secrets });
9573
- }
9574
- function clearJudgeFolder(runtime, state, secrets) {
9575
- return deliverTar(runtime, state, { step: "clearing the judge's folder", tar: packTar([]), into: JUDGE_DIR, replace: true, secrets });
9576
- }
9577
9716
  function gitEnv(extra) {
9578
9717
  const env = {};
9579
9718
  for (const [name, value] of Object.entries(process.env)) if (!name.startsWith("GIT_")) env[name] = value;
@@ -10831,6 +10970,10 @@ async function measureDisk(runtime, state) {
10831
10970
  clearTimeout(timer);
10832
10971
  }
10833
10972
  }
10973
+ function decryptFor(settingsKey) {
10974
+ if (settingsKey === void 0 || (managedBuildSettingsFor(settingsKey)?.proxied?.length ?? 0) === 0) return {};
10975
+ return { decrypt: { authority: buildAuthorityFor(settingsKey), variables: () => managedBuildSettingsFor(settingsKey)?.proxied ?? [] } };
10976
+ }
10834
10977
  async function startServicesFor(runtime, config, buildDir2, jobDir, itemKey, builtIns, gitRemote, serve = "socket", lease, inherit, routeLog, settingsDir) {
10835
10978
  return startBuildServices({
10836
10979
  startTunnel: runtime.startTunnel,
@@ -10838,8 +10981,8 @@ async function startServicesFor(runtime, config, buildDir2, jobDir, itemKey, bui
10838
10981
  buildDir: buildDir2,
10839
10982
  jobDir,
10840
10983
  destinations: config.build?.destinations ?? [],
10841
- // A managed build's proxied variables are served for this claim alone.
10842
- factory: factoryDestinations(settingsDir ?? jobDir),
10984
+ // A managed build's proxied variables are decrypted for this claim alone, with the claim's own authority.
10985
+ ...decryptFor(settingsDir ?? jobDir),
10843
10986
  // A managed build's tunnel allows the factory's hosts beside the runner's own.
10844
10987
  allowHosts: withFactoryHosts(config.build?.allowHosts, managedBuildSettingsFor(settingsDir ?? jobDir)),
10845
10988
  ...optionalEgress(config),
@@ -11737,4 +11880,4 @@ async function runHostChecks(input) {
11737
11880
  }
11738
11881
  }
11739
11882
 
11740
- 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, jobRecordsClaim, judgeProbe, keepGhConfigCurrent, leaseExpiresAtMs, leaseTimeLeftMs, lifecycleFailureReason, lifecycleSteps, listAdoptableJobs, listTrackedJobs, listUnreadableJobs, listenOnBroker, makeRecorder, managedBuildSettingsFor, measureDisk, microVmArchSupported, microVmAssetsPinned, microVmCommandLine, microVmOomKills, missingPermissionFix, missingPermissionOf, modellessProblem, modellessQueues, 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 };
11883
+ 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, installTrust, isContainerTracked, isGroupAlive, isIdle, isJudgeCheck, isMicroVmTracked, isPlaceholderCommand, isReadable, isTimedOut, isTracked, isUnfinished, itemScope, itemTag, jobEnv, jobRecordsClaim, judgeProbe, keepGhConfigCurrent, leaseExpiresAtMs, leaseTimeLeftMs, lifecycleFailureReason, lifecycleSteps, listAdoptableJobs, listTrackedJobs, listUnreadableJobs, listenOnBroker, makeRecorder, managedBuildSettingsFor, measureDisk, microVmArchSupported, microVmAssetsPinned, microVmCommandLine, microVmOomKills, missingPermissionFix, missingPermissionOf, modellessProblem, modellessQueues, 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 };