reeval 0.22.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/README.md +16 -16
- package/THIRD_PARTY_NOTICES.md +14 -14
- package/dist/{adapter-Di9H2etg.js → adapter-dHdepWKb.js} +7 -7
- package/dist/{adapter-Di9H2etg.js.map → adapter-dHdepWKb.js.map} +1 -1
- package/dist/{agent-B-6GFDqA.js → agent-CZpiwA_r.js} +8 -8
- package/dist/{agent-B-6GFDqA.js.map → agent-CZpiwA_r.js.map} +1 -1
- package/dist/{agents-KBTYhSSh.js → agents-CEapsHV-.js} +26 -19
- package/dist/agents-CEapsHV-.js.map +1 -0
- package/dist/app-files-Dsr3U1Q7.js +10 -0
- package/dist/app-files-Dsr3U1Q7.js.map +1 -0
- package/dist/{assemble-CBMRIhso.js → assemble-DUtbByvj.js} +1 -1
- package/dist/{assemble-DNVBTBp_.js → assemble-Dw1bF13I.js} +34 -20
- package/dist/{assemble-DNVBTBp_.js.map → assemble-Dw1bF13I.js.map} +1 -1
- package/dist/{attach-EbDGKGTO.js → attach-DvYiMu6w.js} +79 -4
- package/dist/attach-DvYiMu6w.js.map +1 -0
- package/dist/{attempt-_dUsblVx.js → attempt-DxR1agFo.js} +2 -2
- package/dist/{attempt-_dUsblVx.js.map → attempt-DxR1agFo.js.map} +1 -1
- package/dist/{attempt-host-DQvynDHk.js → attempt-host-DgeJFSZw.js} +7 -7
- package/dist/{attempt-host-DQvynDHk.js.map → attempt-host-DgeJFSZw.js.map} +1 -1
- package/dist/boat-BBPOc_bs.js +1 -0
- package/dist/boat-CUNgSc75.js +705 -0
- package/dist/boat-CUNgSc75.js.map +1 -0
- package/dist/boat-images-BuFigiEb.js +366 -0
- package/dist/boat-images-BuFigiEb.js.map +1 -0
- package/dist/{bundle-DZstHDeW.js → bundle-yEgI3RsI.js} +105 -37
- package/dist/bundle-yEgI3RsI.js.map +1 -0
- package/dist/{capture-BkbPsfej.js → capture-DdEKVrwk.js} +49 -27
- package/dist/capture-DdEKVrwk.js.map +1 -0
- package/dist/capture-DxxB3d7p.js +1 -0
- package/dist/{cases-CM-MQRQp.js → cases-B7QkvMGE.js} +2 -2
- package/dist/{cases-CM-MQRQp.js.map → cases-B7QkvMGE.js.map} +1 -1
- package/dist/cases-CA7gxxdr.js +1 -0
- package/dist/{cli-BgBBuxxJ.js → cli-Z7aw8k25.js} +531 -169
- package/dist/cli-Z7aw8k25.js.map +1 -0
- package/dist/{cli-spec-B5L9n-DV.js → cli-spec-3zvLC9YW.js} +204 -46
- package/dist/cli-spec-3zvLC9YW.js.map +1 -0
- package/dist/cli.js +6 -2
- package/dist/cli.js.map +1 -1
- package/dist/{client-DMEYR3MA.js → client-kUwtq-vt.js} +3 -3
- package/dist/{client-DMEYR3MA.js.map → client-kUwtq-vt.js.map} +1 -1
- package/dist/cloud-DuHcNQVV.js +131 -0
- package/dist/cloud-DuHcNQVV.js.map +1 -0
- package/dist/cloud-files-BjinrTTe.js +301 -0
- package/dist/cloud-files-BjinrTTe.js.map +1 -0
- package/dist/cloud-owVBaSRt.js +260 -0
- package/dist/cloud-owVBaSRt.js.map +1 -0
- package/dist/cloud-run-C08P_Uap.js +1 -0
- package/dist/cloud-run-DqMkSGYB.js +500 -0
- package/dist/cloud-run-DqMkSGYB.js.map +1 -0
- package/dist/cloud-secrets-Bak83tik.js +337 -0
- package/dist/cloud-secrets-Bak83tik.js.map +1 -0
- package/dist/{command-BKb8eN_X.js → command-Bs6Knfm4.js} +13 -13
- package/dist/{command-BKb8eN_X.js.map → command-Bs6Knfm4.js.map} +1 -1
- package/dist/{command-D_w_kDpI.js → command-CeygdoVe.js} +19 -19
- package/dist/{command-D_w_kDpI.js.map → command-CeygdoVe.js.map} +1 -1
- package/dist/command-CoHN1ibe.js +183 -0
- package/dist/command-CoHN1ibe.js.map +1 -0
- package/dist/{command-Dwlh0Vhu.js → command-CtmSJzPC.js} +18 -18
- package/dist/{command-Dwlh0Vhu.js.map → command-CtmSJzPC.js.map} +1 -1
- package/dist/{command-loXH2jHr.js → command-efTGfUYb.js} +18 -130
- package/dist/command-efTGfUYb.js.map +1 -0
- package/dist/{commands-Dqli45sR.js → commands-B_cAs8nG.js} +1 -1
- package/dist/{commands-Cuf57OYb.js → commands-DR-NolV2.js} +25 -20
- package/dist/{commands-Cuf57OYb.js.map → commands-DR-NolV2.js.map} +1 -1
- package/dist/{config-C0RKt00M.js → config-Bn2OhCN_.js} +45 -30
- package/dist/config-Bn2OhCN_.js.map +1 -0
- package/dist/{context-DrEAtUyg.js → context-Ba7PNMMe.js} +2 -2
- package/dist/{context-DrEAtUyg.js.map → context-Ba7PNMMe.js.map} +1 -1
- package/dist/{cost-C21gGrju.js → cost-Dp-xFGJ1.js} +2 -2
- package/dist/{cost-C21gGrju.js.map → cost-Dp-xFGJ1.js.map} +1 -1
- package/dist/cost-a_rUSdsf.js +1 -0
- package/dist/{cursor-catalog-CRsFxorF.js → cursor-catalog-BYIDSsLn.js} +5 -5
- package/dist/{cursor-catalog-CRsFxorF.js.map → cursor-catalog-BYIDSsLn.js.map} +1 -1
- package/dist/daytona-CWs9j9mt.js +680 -0
- package/dist/daytona-CWs9j9mt.js.map +1 -0
- package/dist/daytona-image-BjVpi3KS.js +1 -0
- package/dist/daytona-image-DmGlFAyq.js +184 -0
- package/dist/daytona-image-DmGlFAyq.js.map +1 -0
- package/dist/db-Bjq6qr6c.js +2 -0
- package/dist/{db-ErnJ-gMD.js → db-D6yQib7M.js} +12 -12
- package/dist/{db-ErnJ-gMD.js.map → db-D6yQib7M.js.map} +1 -1
- package/dist/{default-effort-D70cTG00.js → default-effort-Bpz5ULfC.js} +2 -2
- package/dist/{default-effort-D70cTG00.js.map → default-effort-Bpz5ULfC.js.map} +1 -1
- package/dist/{default-effort-DHzj84dD.js → default-effort-Ck6ViSaI.js} +1 -1
- package/dist/{dist-DeqeCUZe.js → dist-CZtW7eI5.js} +4 -4
- package/dist/{dist-DeqeCUZe.js.map → dist-CZtW7eI5.js.map} +1 -1
- package/dist/docker-Bbi4kmFj.js +1 -0
- package/dist/{docker-CFWzZOEk.js → docker-Dgw4aaRk.js} +4 -4
- package/dist/{docker-CFWzZOEk.js.map → docker-Dgw4aaRk.js.map} +1 -1
- package/dist/{doctor-B7utCSdh.js → doctor-BfS6jswW.js} +34 -29
- package/dist/doctor-BfS6jswW.js.map +1 -0
- package/dist/{environment-C0Gg8kyN.js → environment-BY8lVFFK.js} +139 -54
- package/dist/environment-BY8lVFFK.js.map +1 -0
- package/dist/{errors-C1GBcWE2.js → errors-P8oHhNzy.js} +2 -2
- package/dist/{errors-C1GBcWE2.js.map → errors-P8oHhNzy.js.map} +1 -1
- package/dist/{eval-source-CsW5VIXS.js → eval-source-BB8In3xo.js} +6 -6
- package/dist/{eval-source-CsW5VIXS.js.map → eval-source-BB8In3xo.js.map} +1 -1
- package/dist/{evaluate-BHQyAszQ.js → evaluate-B8I9AKgw.js} +62 -43
- package/dist/evaluate-B8I9AKgw.js.map +1 -0
- package/dist/{evaluate-DzHq4EsU.d.ts → evaluate-B9_nukrc.d.ts} +2 -3
- package/dist/events-D97ZzAeq.js +475 -0
- package/dist/events-D97ZzAeq.js.map +1 -0
- package/dist/{fake-bootstrap-VpisF1WE.js → fake-bootstrap-4DFtzib0.js} +2 -2
- package/dist/{fake-bootstrap-VpisF1WE.js.map → fake-bootstrap-4DFtzib0.js.map} +1 -1
- package/dist/files-5HsFIpxw.js +1 -0
- package/dist/{files-g1watgRC.js → files-B0DbptiO.js} +25 -16
- package/dist/files-B0DbptiO.js.map +1 -0
- package/dist/{files-Cv856jLN.js → files-B4K1k__s.js} +5 -5
- package/dist/{files-Cv856jLN.js.map → files-B4K1k__s.js.map} +1 -1
- package/dist/files-BNg3wgw_.js +1 -0
- package/dist/files-BesexM88.js +1477 -0
- package/dist/files-BesexM88.js.map +1 -0
- package/dist/{files-BrGVs4gY.js → files-DE13BqBC.js} +2 -2
- package/dist/{files-BrGVs4gY.js.map → files-DE13BqBC.js.map} +1 -1
- package/dist/files-DNgQwgA0.js +1 -0
- package/dist/files-DvDUSrWL.js +1 -0
- package/dist/{files-BCraBodb.js → files-GBTUBAek.js} +3 -3
- package/dist/{files-BCraBodb.js.map → files-GBTUBAek.js.map} +1 -1
- package/dist/{files-BuKWZCzY.js → files-TwSVeWwM.js} +6 -6
- package/dist/{files-BuKWZCzY.js.map → files-TwSVeWwM.js.map} +1 -1
- package/dist/gateway.d.ts +2 -3
- package/dist/{git-DOrOtAiD.js → git-DatgUcnf.js} +3 -3
- package/dist/{git-DOrOtAiD.js.map → git-DatgUcnf.js.map} +1 -1
- package/dist/{harness-nwnyghJZ.js → harness-EZNoeUBf.js} +2 -2
- package/dist/{harness-nwnyghJZ.js.map → harness-EZNoeUBf.js.map} +1 -1
- package/dist/{harness-install-Dxho1yaU.js → harness-install-HgR73tpF.js} +4 -3
- package/dist/harness-install-HgR73tpF.js.map +1 -0
- package/dist/harness.d.ts +2 -3
- package/dist/harness.js +1 -1
- package/dist/{ids-B-JKTCP8.js → ids-DqEvrBFZ.js} +18 -13
- package/dist/ids-DqEvrBFZ.js.map +1 -0
- package/dist/{images-Ch1y1t6_.js → images-SRE4f3SM.js} +13 -12
- package/dist/images-SRE4f3SM.js.map +1 -0
- package/dist/index.d.ts +4 -5
- package/dist/index.js +5 -5
- package/dist/init-CS5kEaVg.js +1 -0
- package/dist/{init-C2HqCwnt.js → init-D5F9MYPC.js} +6 -6
- package/dist/{init-C2HqCwnt.js.map → init-D5F9MYPC.js.map} +1 -1
- package/dist/{ink-list-BbKXElcQ.js → ink-list-CLq6YVB8.js} +3 -3
- package/dist/{ink-list-BbKXElcQ.js.map → ink-list-CLq6YVB8.js.map} +1 -1
- package/dist/{inputs-5UIDpjz-.js → inputs-B_FsOD2N.js} +6 -6
- package/dist/{inputs-5UIDpjz-.js.map → inputs-B_FsOD2N.js.map} +1 -1
- package/dist/{inputs-load-CGPyigMC.js → inputs-load-B4MFkp0Q.js} +3 -3
- package/dist/{inputs-load-CGPyigMC.js.map → inputs-load-B4MFkp0Q.js.map} +1 -1
- package/dist/inputs-load-D4IsEjq3.js +1 -0
- package/dist/internal/vm.d.ts +15 -0
- package/dist/internal/vm.js +22 -0
- package/dist/internal/vm.js.map +1 -0
- package/dist/{invocations-BrZAMuTb.js → invocations-BxQqe5GU.js} +5 -5
- package/dist/{invocations-BrZAMuTb.js.map → invocations-BxQqe5GU.js.map} +1 -1
- package/dist/issue-DmSorsTF.js +1 -0
- package/dist/issue-iErT9KkK.js +120 -0
- package/dist/issue-iErT9KkK.js.map +1 -0
- package/dist/{jiti-radm1Soi.js → jiti-CtahaHaY.js} +4 -2
- package/dist/{jiti-radm1Soi.js.map → jiti-CtahaHaY.js.map} +1 -1
- package/dist/{judge-DwzqucLS.js → judge-MOKPsr6R.js} +7 -4
- package/dist/judge-MOKPsr6R.js.map +1 -0
- package/dist/judge.d.ts +5 -6
- package/dist/judge.js +1 -1
- package/dist/{judgments-Cj8bFaDG.js → judgments-Dur4D2pj.js} +2 -2
- package/dist/{judgments-Cj8bFaDG.js.map → judgments-Dur4D2pj.js.map} +1 -1
- package/dist/kinds-Dohijzi-.js +593 -0
- package/dist/kinds-Dohijzi-.js.map +1 -0
- package/dist/{layout-Czh5wOpz.js → layout-BhhJAEgf.js} +3 -3
- package/dist/{layout-Czh5wOpz.js.map → layout-BhhJAEgf.js.map} +1 -1
- package/dist/{list-B_C0k5ex.js → list-ClDb8qiX.js} +9 -7
- package/dist/list-ClDb8qiX.js.map +1 -0
- package/dist/{live-DgFm0H90.js → live-C7iGaDCA.js} +9 -9
- package/dist/{live-DgFm0H90.js.map → live-C7iGaDCA.js.map} +1 -1
- package/dist/live-C7kN5v2P.js +1 -0
- package/dist/{live-DGgIrVw0.js → live-QFILMmql.js} +2 -2
- package/dist/{live-DGgIrVw0.js.map → live-QFILMmql.js.map} +1 -1
- package/dist/{machine-service-2lIv5UWF.js → machine-service-DpJScNtA.js} +1 -1
- package/dist/{machine-service-Ct_1XMMi.js → machine-service-xFhakTs5.js} +287 -98
- package/dist/machine-service-xFhakTs5.js.map +1 -0
- package/dist/machines-Cm-rU7jp.js +279 -0
- package/dist/machines-Cm-rU7jp.js.map +1 -0
- package/dist/{model-DRa7yv6K.js → model-CcvSrrq9.js} +5 -5
- package/dist/{model-DRa7yv6K.js.map → model-CcvSrrq9.js.map} +1 -1
- package/dist/model-Colu5mEp.js +1 -0
- package/dist/{model-E5X8YBJM.js → model-D9WMMEWD.js} +4 -4
- package/dist/{model-E5X8YBJM.js.map → model-D9WMMEWD.js.map} +1 -1
- package/dist/{model-B1tdv9-d.js → model-Rmv-L9Jb.js} +1 -1
- package/dist/{model-DF77SgZv.js → model-mTaaEkeQ.js} +6 -6
- package/dist/{model-DF77SgZv.js.map → model-mTaaEkeQ.js.map} +1 -1
- package/dist/{node-BjuhqQwa.js → node-Bl2CtSjB.js} +8 -8
- package/dist/{node-BjuhqQwa.js.map → node-Bl2CtSjB.js.map} +1 -1
- package/dist/options-CmRy82gl.js +1 -0
- package/dist/{patch-BR8rdl7r.js → patch-DhJDHRFs.js} +2 -2
- package/dist/{patch-BR8rdl7r.js.map → patch-DhJDHRFs.js.map} +1 -1
- package/dist/{plan-BcT4G5jj.js → plan-CC0bKbm9.js} +11 -11
- package/dist/{plan-BcT4G5jj.js.map → plan-CC0bKbm9.js.map} +1 -1
- package/dist/{plugins-cC0sqoDA.js → plugins-PwEtW8GH.js} +8 -597
- package/dist/plugins-PwEtW8GH.js.map +1 -0
- package/dist/{preflight-C9OtTb7k.js → preflight-BHUEfA4m.js} +9 -4
- package/dist/preflight-BHUEfA4m.js.map +1 -0
- package/dist/{preflight-DySHXeFJ.js → preflight-BzvLYQ70.js} +8 -7
- package/dist/preflight-BzvLYQ70.js.map +1 -0
- package/dist/preflight-DEV_vrdB.js +1 -0
- package/dist/preflight-xa8_eGOW.js +1 -0
- package/dist/{prepare-nbX1CXXg.js → prepare-D7hPrh7Q.js} +19 -39
- package/dist/prepare-D7hPrh7Q.js.map +1 -0
- package/dist/prepare-DS42k409.js +2 -0
- package/dist/prices-C_mbZa5a.js +1 -0
- package/dist/{prices-BrY_ihLs.js → prices-DXJsP2Ha.js} +4 -4
- package/dist/{prices-BrY_ihLs.js.map → prices-DXJsP2Ha.js.map} +1 -1
- package/dist/process-RPlEhpHz.js +118 -0
- package/dist/process-RPlEhpHz.js.map +1 -0
- package/dist/{provenance-CkykifD9.js → provenance-DgQJ-dq7.js} +5 -5
- package/dist/{provenance-CkykifD9.js.map → provenance-DgQJ-dq7.js.map} +1 -1
- package/dist/{providers-bNgfKa6m.js → providers-B5Vr0hKH.js} +173 -31
- package/dist/providers-B5Vr0hKH.js.map +1 -0
- package/dist/providers-N4HDMeeo.js +1 -0
- package/dist/query-BXV6pRyI.js +1 -0
- package/dist/{query-DhV3a8lM.js → query-CmTjYbqh.js} +2 -2
- package/dist/{query-DhV3a8lM.js.map → query-CmTjYbqh.js.map} +1 -1
- package/dist/{questions-Csv64WCb.js → questions-DnqkJga0.js} +7 -7
- package/dist/{questions-Csv64WCb.js.map → questions-DnqkJga0.js.map} +1 -1
- package/dist/recipe-B0NeT_Sn.js +128 -0
- package/dist/recipe-B0NeT_Sn.js.map +1 -0
- package/dist/{record--vHreTLk.js → record-2liAelrB.js} +13 -5
- package/dist/record-2liAelrB.js.map +1 -0
- package/dist/{redact-t-L3VGy8.js → redact-DMueYS-v.js} +28 -6
- package/dist/redact-DMueYS-v.js.map +1 -0
- package/dist/{remarks-CYFOsnz5.js → remarks-D-9f1y1B.js} +10 -10
- package/dist/{remarks-CYFOsnz5.js.map → remarks-D-9f1y1B.js.map} +1 -1
- package/dist/{remarks-DqriPKxm.js → remarks-D5qOZzcX.js} +2 -2
- package/dist/{remarks-DqriPKxm.js.map → remarks-D5qOZzcX.js.map} +1 -1
- package/dist/{remote-0CHog7Oq.js → remote-B7BIRUTK.js} +6 -6
- package/dist/{remote-0CHog7Oq.js.map → remote-B7BIRUTK.js.map} +1 -1
- package/dist/{resolve-Bul8lHaa.js → resolve-B60w6DcB.js} +20 -5
- package/dist/resolve-B60w6DcB.js.map +1 -0
- package/dist/resolve-CCLiJX4i.js +1 -0
- package/dist/{resolve-DorSHDBs.js → resolve-t9sOkGGS.js} +51 -18
- package/dist/resolve-t9sOkGGS.js.map +1 -0
- package/dist/{results-DhMgRkR0.js → results-Df910ONm.js} +6 -6
- package/dist/{results-DhMgRkR0.js.map → results-Df910ONm.js.map} +1 -1
- package/dist/{resume-C8Ihfy-C.js → resume-4Q9q8AcE.js} +6 -6
- package/dist/{resume-C8Ihfy-C.js.map → resume-4Q9q8AcE.js.map} +1 -1
- package/dist/{retry-Bfk7pDti.js → retry-C15f5yyy.js} +4 -4
- package/dist/{retry-Bfk7pDti.js.map → retry-C15f5yyy.js.map} +1 -1
- package/dist/{root-BzeoyfGd.js → root-Cm93-6ix.js} +3 -3
- package/dist/{root-BzeoyfGd.js.map → root-Cm93-6ix.js.map} +1 -1
- package/dist/{runtime-CPUH0Vk5.js → runtime-CIsljVBy.js} +5 -5
- package/dist/{runtime-CPUH0Vk5.js.map → runtime-CIsljVBy.js.map} +1 -1
- package/dist/sandbox/boat.d.ts +14 -7
- package/dist/sandbox/boat.js +18 -4
- package/dist/sandbox/boat.js.map +1 -1
- package/dist/sandbox/daytona.d.ts +29 -0
- package/dist/sandbox/daytona.js +49 -0
- package/dist/sandbox/daytona.js.map +1 -0
- package/dist/{sandbox-z8q_4Ywn.js → sandbox-BffNervX.js} +3 -3
- package/dist/{sandbox-z8q_4Ywn.js.map → sandbox-BffNervX.js.map} +1 -1
- package/dist/sandbox.d.ts +4 -5
- package/dist/sandbox.js +1 -1
- package/dist/secrets-file-Dtd3h3kY.js +100 -0
- package/dist/secrets-file-Dtd3h3kY.js.map +1 -0
- package/dist/secrets-file-take-BXfYMTM-.js +33 -0
- package/dist/secrets-file-take-BXfYMTM-.js.map +1 -0
- package/dist/server-CeYUmuuu.js +1 -0
- package/dist/{server-BsQZtuF9.js → server-fSNuT3Z4.js} +13 -13
- package/dist/{server-BsQZtuF9.js.map → server-fSNuT3Z4.js.map} +1 -1
- package/dist/shared-B3iLKAiu.d.ts +1 -0
- package/dist/source-n7nUVm9p.js +1 -0
- package/dist/{source-9HWaTEgV.js → source-zoRWRMql.js} +2 -2
- package/dist/{source-9HWaTEgV.js.map → source-zoRWRMql.js.map} +1 -1
- package/dist/{src-D-PwBaBB.js → src-9V3C6A7C.js} +1 -1
- package/dist/{src-boB6D-5T.js → src-BQWAxhKD.js} +4 -4
- package/dist/{src-boB6D-5T.js.map → src-BQWAxhKD.js.map} +1 -1
- package/dist/{src-BfOlH_Bu.js → src-Bj3WJs3t.js} +2 -2
- package/dist/{src-CotUxxQV.js → src-CB5cZhaN.js} +1 -1
- package/dist/{src-C-ChdnG6.js → src-CDoAEO4u.js} +2 -2
- package/dist/{src-C-ChdnG6.js.map → src-CDoAEO4u.js.map} +1 -1
- package/dist/{src-C2K5_afU.js → src-CFBg2ecq.js} +1 -1
- package/dist/{src-DNWiU__5.js → src-CGBwMZgM.js} +2 -2
- package/dist/{src-DNWiU__5.js.map → src-CGBwMZgM.js.map} +1 -1
- package/dist/{src-BuGc40IF.js → src-CUrcaZ91.js} +1 -1
- package/dist/{src-CSVJjghq.js → src-CcbV6VpV.js} +2 -2
- package/dist/src-DB0vml0O.js +1 -0
- package/dist/{src-B2eHTCnp.js → src-DiS13D_q.js} +2 -2
- package/dist/{src-CWfy8ct8.js → src-OC89dAjO.js} +1127 -466
- package/dist/src-OC89dAjO.js.map +1 -0
- package/dist/{src-CcrQQB0_.js → src-TMKittwH.js} +1 -1
- package/dist/ssh-pool-ChpT-fDU.js +1 -0
- package/dist/ssh-pool-DwboLN9O.js +175 -0
- package/dist/ssh-pool-DwboLN9O.js.map +1 -0
- package/dist/{start-Db5VRcRZ.js → start-BwMyDneA.js} +148 -70
- package/dist/start-BwMyDneA.js.map +1 -0
- package/dist/{state-DUYdzNA7.js → state-CXTaT0t8.js} +10 -10
- package/dist/{state-DUYdzNA7.js.map → state-CXTaT0t8.js.map} +1 -1
- package/dist/state-CltRWlCu.js +1 -0
- package/dist/store/local.d.ts +2 -3
- package/dist/store/s3.d.ts +2 -3
- package/dist/{suite-DjGxmDSY.js → suite-C4XSg6Ls.js} +6 -6
- package/dist/{suite-DjGxmDSY.js.map → suite-C4XSg6Ls.js.map} +1 -1
- package/dist/suite-CIsyPqPA.js +2 -0
- package/dist/{summary-BK5Sa_N0.js → summary-DeeQJAR5.js} +8 -8
- package/dist/{summary-BK5Sa_N0.js.map → summary-DeeQJAR5.js.map} +1 -1
- package/dist/{sync-DUi_P2UJ.js → sync-bnI6WWaL.js} +6 -6
- package/dist/{sync-DUi_P2UJ.js.map → sync-bnI6WWaL.js.map} +1 -1
- package/dist/{tart-BQ_Ap0l4.js → tart-CSP5Q0qV.js} +10 -8
- package/dist/tart-CSP5Q0qV.js.map +1 -0
- package/dist/{tart-bake-D1RttYfM.js → tart-bake-BCKRfyKm.js} +9 -8
- package/dist/tart-bake-BCKRfyKm.js.map +1 -0
- package/dist/{tart-bake-DjFcsG3N.js → tart-bake-d9UvIfe3.js} +1 -1
- package/dist/{tart-cli-BOcluha1.js → tart-cli-C4d5FXG1.js} +1 -1
- package/dist/{tart-cli-gA9xEaQL.js → tart-cli-CqSpUYGV.js} +3 -2
- package/dist/tart-cli-CqSpUYGV.js.map +1 -0
- package/dist/{tart-hosts-CWse-ASo.js → tart-hosts-Du7SZM4w.js} +1 -1
- package/dist/{tart-hosts-CHNrfV6u.js → tart-hosts-G0EUDt07.js} +5 -4
- package/dist/tart-hosts-G0EUDt07.js.map +1 -0
- package/dist/{tart-images-CLBjfF9u.js → tart-images-De0-ib7R.js} +4 -4
- package/dist/{tart-images-CLBjfF9u.js.map → tart-images-De0-ib7R.js.map} +1 -1
- package/dist/testing.d.ts +4 -5
- package/dist/testing.js +4 -4
- package/dist/{tool-class-krsmEo44.js → tool-class-B3ZFTSOw.js} +2 -2
- package/dist/{tool-class-krsmEo44.js.map → tool-class-B3ZFTSOw.js.map} +1 -1
- package/dist/{trace-BpXByD7W.js → trace-CfppUzD9.js} +2 -2
- package/dist/{trace-BpXByD7W.js.map → trace-CfppUzD9.js.map} +1 -1
- package/dist/{traits-CCD8XsmI.js → traits-Bj1PM5F7.js} +2 -2
- package/dist/{traits-CCD8XsmI.js.map → traits-Bj1PM5F7.js.map} +1 -1
- package/dist/{transcript-BXWZiMuC.js → transcript-CW02A4s9.js} +3 -3
- package/dist/{transcript-BXWZiMuC.js.map → transcript-CW02A4s9.js.map} +1 -1
- package/dist/types-CbcnJxCy.js.map +1 -1
- package/dist/{types-DKK8jj--.d.ts → types-D4WEnzhY.d.ts} +192 -17
- package/dist/{ui-DKYjTVpn.js → ui-DfvPNmPP.js} +54 -485
- package/dist/ui-DfvPNmPP.js.map +1 -0
- package/dist/{vertex-BEWxHoxH.js → vertex-BLxYasfw.js} +2 -2
- package/dist/{vertex-BEWxHoxH.js.map → vertex-BLxYasfw.js.map} +1 -1
- package/dist/vertex-D4H9bKHD.d.ts +2 -0
- package/dist/vertex-DZDUpp0W.js +1 -0
- package/dist/view/index.d.ts +2 -3
- package/dist/view/index.js +10 -10
- package/dist/{views-B1zVLJsF.js → views-ChoSQxfF.js} +6 -6
- package/dist/{views-B1zVLJsF.js.map → views-ChoSQxfF.js.map} +1 -1
- package/dist/views-DU0PM0UW.js +2 -0
- package/dist/vm-container-DOtIi_rd.js +149 -0
- package/dist/vm-container-DOtIi_rd.js.map +1 -0
- package/dist/vm-images-CHutQVml.js +375 -0
- package/dist/vm-images-CHutQVml.js.map +1 -0
- package/dist/{worker-entry-DrAYYt0M.js → worker-entry-CKBfEt0h.js} +7 -7
- package/dist/{worker-entry-DrAYYt0M.js.map → worker-entry-CKBfEt0h.js.map} +1 -1
- package/dist/workspace-BKcNJAPb.js +1 -0
- package/dist/{workspace-DwTe1zo6.js → workspace-Cip2dVwU.js} +9 -8
- package/dist/workspace-Cip2dVwU.js.map +1 -0
- package/package.json +22 -10
- package/skills/reeval/SKILL.md +2 -2
- package/skills/reeval/references/environments.md +4 -3
- package/skills/setup/SKILL.md +1 -1
- package/dist/agents-KBTYhSSh.js.map +0 -1
- package/dist/app-files-Cmh9FGr5.js +0 -10
- package/dist/app-files-Cmh9FGr5.js.map +0 -1
- package/dist/attach-EbDGKGTO.js.map +0 -1
- package/dist/boat-Bzz8L-KQ.js +0 -701
- package/dist/boat-Bzz8L-KQ.js.map +0 -1
- package/dist/boat-Dek8ftIt.js +0 -120
- package/dist/boat-Dek8ftIt.js.map +0 -1
- package/dist/bundle-DZstHDeW.js.map +0 -1
- package/dist/capture-BkbPsfej.js.map +0 -1
- package/dist/capture-CUAvk9KM.js +0 -1
- package/dist/cases-FvhbM8M5.js +0 -1
- package/dist/cli-BgBBuxxJ.js.map +0 -1
- package/dist/cli-spec-B5L9n-DV.js.map +0 -1
- package/dist/command-loXH2jHr.js.map +0 -1
- package/dist/config-C0RKt00M.js.map +0 -1
- package/dist/cost-IM80LyGD.js +0 -1
- package/dist/db-3o8s2EyD.js +0 -2
- package/dist/docker-DrMnpL84.js +0 -1
- package/dist/doctor-B7utCSdh.js.map +0 -1
- package/dist/environment-C0Gg8kyN.js.map +0 -1
- package/dist/evaluate-BHQyAszQ.js.map +0 -1
- package/dist/files-BjOJw4sn.js +0 -1
- package/dist/files-CAzVG3Rr.js +0 -1
- package/dist/files-D-Lir4aE.js +0 -1
- package/dist/files-DRlJ0Xr2.js +0 -1
- package/dist/files-g1watgRC.js.map +0 -1
- package/dist/files-qjeqXnfE.js +0 -775
- package/dist/files-qjeqXnfE.js.map +0 -1
- package/dist/harness-install-Dxho1yaU.js.map +0 -1
- package/dist/ids-B-JKTCP8.js.map +0 -1
- package/dist/images-Ch1y1t6_.js.map +0 -1
- package/dist/init-CM9xwyre.js +0 -1
- package/dist/inputs-load-C82HOKnb.js +0 -1
- package/dist/judge-DwzqucLS.js.map +0 -1
- package/dist/list-B_C0k5ex.js.map +0 -1
- package/dist/live-C9Et_BVT.js +0 -1
- package/dist/machine-service-Ct_1XMMi.js.map +0 -1
- package/dist/machines-BnquHcBZ.js +0 -120
- package/dist/machines-BnquHcBZ.js.map +0 -1
- package/dist/model-Bcy4Qjmm.js +0 -1
- package/dist/options-C989kuVE.js +0 -1
- package/dist/plugins-cC0sqoDA.js.map +0 -1
- package/dist/preflight-BMVDBcux.js +0 -1
- package/dist/preflight-C9OtTb7k.js.map +0 -1
- package/dist/preflight-DySHXeFJ.js.map +0 -1
- package/dist/preflight-zsAn3heN.js +0 -1
- package/dist/prepare-MaRWRhNT.js +0 -2
- package/dist/prepare-nbX1CXXg.js.map +0 -1
- package/dist/prices-B1vm_lPk.js +0 -1
- package/dist/providers-BkLGzaSY.js +0 -1
- package/dist/providers-bNgfKa6m.js.map +0 -1
- package/dist/query-B2SQddoV.js +0 -1
- package/dist/record--vHreTLk.js.map +0 -1
- package/dist/redact-t-L3VGy8.js.map +0 -1
- package/dist/resolve-Bm9ZyFR-.js +0 -1
- package/dist/resolve-Bul8lHaa.js.map +0 -1
- package/dist/resolve-DorSHDBs.js.map +0 -1
- package/dist/server-ZaMzUNmV.js +0 -1
- package/dist/shared-CHvO7eLi.d.ts +0 -1
- package/dist/source-BcBDj-R0.js +0 -1
- package/dist/src-CWfy8ct8.js.map +0 -1
- package/dist/src-jYqNkT-F.js +0 -1
- package/dist/start-Db5VRcRZ.js.map +0 -1
- package/dist/state-CKIjZZRK.js +0 -1
- package/dist/suite-CH1aaAbs.js +0 -2
- package/dist/tarball-C8BSTAMk.js +0 -257
- package/dist/tarball-C8BSTAMk.js.map +0 -1
- package/dist/tart-BQ_Ap0l4.js.map +0 -1
- package/dist/tart-bake-D1RttYfM.js.map +0 -1
- package/dist/tart-cli-gA9xEaQL.js.map +0 -1
- package/dist/tart-hosts-CHNrfV6u.js.map +0 -1
- package/dist/ui-DKYjTVpn.js.map +0 -1
- package/dist/vertex-C7PI-WPc.d.ts +0 -3
- package/dist/vertex-DXfcXYKn.js +0 -1
- package/dist/views-DCjtw1jF.js +0 -2
- package/dist/workspace-CnRbV8cM.js +0 -1
- package/dist/workspace-DwTe1zo6.js.map +0 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { u as ownFileURL } from "./root-
|
|
2
|
-
import {
|
|
3
|
-
import { basename, dirname, join, posix, relative, win32 } from "node:path";
|
|
1
|
+
import { u as ownFileURL } from "./root-Cm93-6ix.js";
|
|
2
|
+
import { n as shellQuote, t as run } from "./process-RPlEhpHz.js";
|
|
4
3
|
import { execFileSync, spawn } from "node:child_process";
|
|
5
4
|
import { createHash, generateKeyPairSync, randomBytes, randomInt, sign } from "node:crypto";
|
|
5
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
7
|
+
import { basename, dirname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
7
8
|
import { fileURLToPath } from "node:url";
|
|
8
9
|
import { createHarnessSandboxTemplate } from "@ai-sdk/harness/agent";
|
|
9
|
-
import { isUtf8 } from "node:buffer";
|
|
10
10
|
import dockerignore from "@balena/dockerignore";
|
|
11
|
+
import { lstat, mkdir, readFile, readdir, readlink, symlink, utimes, writeFile } from "node:fs/promises";
|
|
12
|
+
import { isUtf8 } from "node:buffer";
|
|
11
13
|
import { Duplex, Readable, Transform } from "node:stream";
|
|
12
14
|
import net, { BlockList, isIP } from "node:net";
|
|
13
15
|
import http from "node:http";
|
|
@@ -17,6 +19,7 @@ import tls from "node:tls";
|
|
|
17
19
|
import zlib from "node:zlib";
|
|
18
20
|
import { lookup } from "node:dns/promises";
|
|
19
21
|
// ../sandbox-docker/src/engine.ts
|
|
22
|
+
const isRemoteEngine = (engine) => typeof engine === "object";
|
|
20
23
|
/**
|
|
21
24
|
* Docker's default seccomp profile, copied unmodified from moby/profiles (Apache-2.0),
|
|
22
25
|
* seccomp/default.json at 6fe7deb1b9fb7c0397a4593480d7d22b9ee8caef. Podman gets it on every
|
|
@@ -75,7 +78,8 @@ const ENGINES = {
|
|
|
75
78
|
createsWorkdir: false
|
|
76
79
|
}
|
|
77
80
|
};
|
|
78
|
-
|
|
81
|
+
/** A remote engine is Docker's CLI, as on this machine. */
|
|
82
|
+
const engineSpec = (engine = "docker") => ENGINES[isRemoteEngine(engine) ? "docker" : engine];
|
|
79
83
|
/**
|
|
80
84
|
* The `CONTAINER_HOST` that reaches a `podman machine` straight through its API socket (macOS) or
|
|
81
85
|
* named pipe (Windows), from `podman machine inspect`'s JSON.
|
|
@@ -252,117 +256,637 @@ function failureMessage(parts) {
|
|
|
252
256
|
function outputTail(text, max = 8) {
|
|
253
257
|
return stripAnsi(text).split(/\r?\n/).map((l) => l.trimEnd()).filter((l) => l.trim()).slice(-max);
|
|
254
258
|
}
|
|
255
|
-
// ../sandbox-docker/src/
|
|
256
|
-
const
|
|
257
|
-
const cmdEscape = (arg, twice) => {
|
|
258
|
-
const quoted = `"${arg.replace(/(\\*)"/g, "$1$1\\\"").replace(/(\\*)$/, "$1$1")}"`.replace(CMD_META, "^$1");
|
|
259
|
-
return twice ? quoted.replace(CMD_META, "^$1") : quoted;
|
|
260
|
-
};
|
|
259
|
+
// ../sandbox-docker/src/dockerignore.ts
|
|
260
|
+
const ignore = dockerignore.default;
|
|
261
261
|
/**
|
|
262
|
-
*
|
|
263
|
-
*
|
|
262
|
+
* A pattern `@balena/dockerignore` may match differently from BuildKit: escapes, character
|
|
263
|
+
* classes and the regexp characters it doesn't escape, a `**` joined to other characters, and the
|
|
264
|
+
* whitespace Go and JavaScript trim differently. One over 1024 characters is risky too, since
|
|
265
|
+
* JavaScript refuses a regexp that long that Go accepts, and so is one with more than four `*`
|
|
266
|
+
* runs, whose JavaScript regexp can backtrack for minutes where Go's runs in linear time.
|
|
264
267
|
*/
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
268
|
+
const RISKY = /[\\[\]^+(){}|\u0085\uFEFF]|[^/]\*\*|\*\*[^/]/;
|
|
269
|
+
const MAX_STARS = 4;
|
|
270
|
+
/**
|
|
271
|
+
* Names `@balena/dockerignore` may match differently: `?` matches one UTF-16 unit there and one
|
|
272
|
+
* code point in BuildKit, and `.` doesn't match a line terminator there but does in Go.
|
|
273
|
+
*/
|
|
274
|
+
const ODD_NAME = /[\n\r\u2028\u2029\u{10000}-\u{10FFFF}]/u;
|
|
275
|
+
const clean = (pattern) => posix.normalize(pattern).replace(/^\/+/, "").replace(/\/+$/, "");
|
|
276
|
+
/**
|
|
277
|
+
* `.dockerignore` lines as Docker reads them: a BOM is dropped, a line starting `#` is a comment,
|
|
278
|
+
* and `!` re-includes. A path is left out when a rule excludes it and no `!` rule matches it or a
|
|
279
|
+
* directory it's in: BuildKit then excludes it whatever order the rules are in, so this never
|
|
280
|
+
* leaves out a file `docker build` sends, though it keeps some it doesn't. A risky exclusion is
|
|
281
|
+
* dropped, and a risky `!` rule keeps everything, as does one `@balena/dockerignore` would read
|
|
282
|
+
* as a comment or a pattern that cleans to a leading `!` (`!!a`, `/ !a`), which the two read
|
|
283
|
+
* differently.
|
|
284
|
+
*/
|
|
285
|
+
function parseRules(text) {
|
|
286
|
+
const excludes = [];
|
|
287
|
+
const reincludes = [];
|
|
288
|
+
for (const line of text.replace(/^\uFEFF/, "").split(/\r?\n/)) {
|
|
289
|
+
if (line.startsWith("#")) continue;
|
|
290
|
+
let pattern = line.trim();
|
|
291
|
+
const negate = pattern.startsWith("!");
|
|
292
|
+
if (negate) pattern = pattern.slice(1).trim();
|
|
293
|
+
if (!pattern) continue;
|
|
294
|
+
const cleaned = clean(pattern);
|
|
295
|
+
const risky = RISKY.test(pattern) || pattern.length > 1024 || (pattern.match(/\*+/g)?.length ?? 0) > MAX_STARS || [".", ""].includes(cleaned);
|
|
296
|
+
if (cleaned.trim().startsWith("!") || negate && pattern.startsWith("#") || negate && risky) return {
|
|
297
|
+
left: () => false,
|
|
298
|
+
literal: null
|
|
299
|
+
};
|
|
300
|
+
if (!negate) {
|
|
301
|
+
if (!risky) excludes.push(line);
|
|
302
|
+
} else reincludes.push(pattern);
|
|
303
|
+
}
|
|
304
|
+
const exclude = ignore({ ignorecase: false }).add(excludes);
|
|
305
|
+
const reinclude = ignore({ ignorecase: false }).add(reincludes);
|
|
278
306
|
return {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
307
|
+
left: (path) => !ODD_NAME.test(path) && exclude.ignores(path) && !reinclude.ignores(path),
|
|
308
|
+
literal: reincludes.some((p) => /[*?]/.test(p)) ? null : reincludes.map(clean)
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
/** Whether reeval leaves `path` out of a hash under these `.dockerignore` rules. */
|
|
312
|
+
function dockerignoreMatcher(text) {
|
|
313
|
+
return parseRules(text).left;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Files in the build context that reeval hashes, sorted, relative to `context`: every file
|
|
317
|
+
* `docker build` sends (and some it doesn't), plus the Dockerfile and `.dockerignore`. A
|
|
318
|
+
* Dockerfile read from stdin (`dockerfile` null) has no `<Dockerfile>.dockerignore` of its own.
|
|
319
|
+
* A left-out directory is skipped only when every `!` rule is a literal path outside it. Docker
|
|
320
|
+
* doesn't apply an ignore file that's a symlink or not a file, so then every file is hashed; nor
|
|
321
|
+
* can it send what's in a directory it can't read.
|
|
322
|
+
*/
|
|
323
|
+
function contextFiles(context, dockerfile) {
|
|
324
|
+
const own = [...dockerfile ? [`${dockerfile}.dockerignore`] : [], join(context, ".dockerignore")].map((path) => ({
|
|
325
|
+
path,
|
|
326
|
+
stat: lstatSync(path, { throwIfNoEntry: false })
|
|
327
|
+
})).find(({ stat }) => stat);
|
|
328
|
+
const { left, literal } = parseRules(own?.stat?.isFile() ? readFileSync(own.path, "utf8") : "");
|
|
329
|
+
const always = [...dockerfile ? [relative(context, dockerfile)] : [], ".dockerignore"].map((path) => path.split("\\").join("/"));
|
|
330
|
+
const reach = [...always, ...literal ?? []];
|
|
331
|
+
const files = [];
|
|
332
|
+
const walk = (rel) => {
|
|
333
|
+
let entries;
|
|
334
|
+
try {
|
|
335
|
+
entries = readdirSync(join(context, rel), { withFileTypes: true });
|
|
336
|
+
} catch (error) {
|
|
337
|
+
if (rel && ["EACCES", "EPERM"].includes(error.code ?? "")) return;
|
|
338
|
+
throw error;
|
|
339
|
+
}
|
|
340
|
+
for (const entry of entries) {
|
|
341
|
+
const path = rel ? `${rel}/${entry.name}` : entry.name;
|
|
342
|
+
if (entry.isDirectory()) {
|
|
343
|
+
if (!(left(path) && literal && !reach.some((p) => p.startsWith(`${path}/`)))) walk(path);
|
|
344
|
+
} else if (!left(path) || always.includes(path)) files.push(path);
|
|
345
|
+
}
|
|
287
346
|
};
|
|
347
|
+
walk("");
|
|
348
|
+
return files.sort();
|
|
349
|
+
}
|
|
350
|
+
// ../sandbox-docker/src/tarball.ts
|
|
351
|
+
const BLOCK = 512;
|
|
352
|
+
const text$1 = (b, at, len) => {
|
|
353
|
+
const field = b.subarray(at, at + len);
|
|
354
|
+
const end = field.indexOf(0);
|
|
355
|
+
return (end < 0 ? field : field.subarray(0, end)).toString("utf8");
|
|
356
|
+
};
|
|
357
|
+
function octal(b, at, len) {
|
|
358
|
+
if ((b[at] ?? 0) & 128) {
|
|
359
|
+
let n = (b[at] ?? 0) & 127;
|
|
360
|
+
for (let i = 1; i < len; i++) n = n * 256 + (b[at + i] ?? 0);
|
|
361
|
+
return n;
|
|
362
|
+
}
|
|
363
|
+
const digits = text$1(b, at, len).trim();
|
|
364
|
+
return digits ? Number.parseInt(digits, 8) : 0;
|
|
365
|
+
}
|
|
366
|
+
/** `a/./b/` as `a/b`; null for a path that's absolute, empty or climbs out with `..`. */
|
|
367
|
+
function safeTarPath(path) {
|
|
368
|
+
if (path.startsWith("/") || /^[A-Za-z]:/.test(path) || path.includes("\\")) return null;
|
|
369
|
+
const parts = path.split("/").filter((p) => p !== "" && p !== ".");
|
|
370
|
+
if (!parts.length || parts.includes("..")) return null;
|
|
371
|
+
return parts.join("/");
|
|
372
|
+
}
|
|
373
|
+
function paxRecords(data) {
|
|
374
|
+
const out = {};
|
|
375
|
+
let at = 0;
|
|
376
|
+
while (at < data.length) {
|
|
377
|
+
const space = data.indexOf(32, at);
|
|
378
|
+
if (space < 0) break;
|
|
379
|
+
const len = Number(data.subarray(at, space).toString());
|
|
380
|
+
if (!(len > 0)) break;
|
|
381
|
+
const record = data.subarray(space + 1, at + len - 1).toString("utf8");
|
|
382
|
+
const eq = record.indexOf("=");
|
|
383
|
+
if (eq > 0) out[record.slice(0, eq)] = record.slice(eq + 1);
|
|
384
|
+
at += len;
|
|
385
|
+
}
|
|
386
|
+
return out;
|
|
288
387
|
}
|
|
289
388
|
/**
|
|
290
|
-
*
|
|
291
|
-
*
|
|
389
|
+
* The entries of an uncompressed tar, hard links resolved to copies of what they link to. Each
|
|
390
|
+
* path it leaves out for being absolute or climbing out (not the archive's own `./`) goes in
|
|
391
|
+
* `unsafe`, as the tar names it.
|
|
292
392
|
*/
|
|
293
|
-
function
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
393
|
+
function readTar(tar, unsafe) {
|
|
394
|
+
const out = [];
|
|
395
|
+
const files = /* @__PURE__ */ new Map();
|
|
396
|
+
let longName;
|
|
397
|
+
let longLink;
|
|
398
|
+
let pax = {};
|
|
399
|
+
let at = 0;
|
|
400
|
+
while (at + BLOCK <= tar.length) {
|
|
401
|
+
const h = tar.subarray(at, at + BLOCK);
|
|
402
|
+
if (h.every((byte) => byte === 0)) break;
|
|
403
|
+
const type = String.fromCharCode(h[156] ?? 0);
|
|
404
|
+
const size = pax.size !== void 0 ? Number(pax.size) : octal(h, 124, 12);
|
|
405
|
+
if (!Number.isSafeInteger(size) || size < 0) break;
|
|
406
|
+
const data = tar.subarray(at + BLOCK, at + BLOCK + size);
|
|
407
|
+
at += BLOCK + Math.ceil(size / BLOCK) * BLOCK;
|
|
408
|
+
if (type === "L") {
|
|
409
|
+
longName = text$1(data, 0, data.length);
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
if (type === "K") {
|
|
413
|
+
longLink = text$1(data, 0, data.length);
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
if (type === "x") {
|
|
417
|
+
pax = {
|
|
418
|
+
...pax,
|
|
419
|
+
...paxRecords(data)
|
|
420
|
+
};
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
if (type === "g") continue;
|
|
424
|
+
const prefix = text$1(h, 257, 6).startsWith("ustar") ? text$1(h, 345, 155) : "";
|
|
425
|
+
const name = text$1(h, 0, 100);
|
|
426
|
+
const raw = pax.path ?? longName ?? (prefix ? `${prefix}/${name}` : name);
|
|
427
|
+
const link = pax.linkpath ?? longLink ?? text$1(h, 157, 100);
|
|
428
|
+
const mtime = pax.mtime !== void 0 ? Math.floor(Number(pax.mtime)) : octal(h, 136, 12);
|
|
429
|
+
longName = longLink = void 0;
|
|
430
|
+
pax = {};
|
|
431
|
+
const path = safeTarPath(raw);
|
|
432
|
+
if (!path) {
|
|
433
|
+
if (raw.split("/").some((p) => p !== "" && p !== ".")) unsafe?.push(raw);
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
const mode = octal(h, 100, 8) & 4095;
|
|
437
|
+
if (type === "0" || type === "\0" || type === "7") {
|
|
438
|
+
const copy = Buffer.from(data);
|
|
439
|
+
files.set(path, copy);
|
|
440
|
+
out.push({
|
|
441
|
+
type: "file",
|
|
442
|
+
path,
|
|
443
|
+
mode,
|
|
444
|
+
mtime,
|
|
445
|
+
data: copy
|
|
446
|
+
});
|
|
447
|
+
} else if (type === "1") {
|
|
448
|
+
const target = safeTarPath(link);
|
|
449
|
+
const linked = target ? files.get(target) : void 0;
|
|
450
|
+
if (linked) out.push({
|
|
451
|
+
type: "file",
|
|
452
|
+
path,
|
|
453
|
+
mode,
|
|
454
|
+
mtime,
|
|
455
|
+
data: linked
|
|
456
|
+
});
|
|
457
|
+
} else if (type === "2") out.push({
|
|
458
|
+
type: "symlink",
|
|
459
|
+
path,
|
|
460
|
+
mode,
|
|
461
|
+
mtime,
|
|
462
|
+
target: link
|
|
463
|
+
});
|
|
464
|
+
else if (type === "5") out.push({
|
|
465
|
+
type: "dir",
|
|
466
|
+
path,
|
|
467
|
+
mode,
|
|
468
|
+
mtime
|
|
469
|
+
});
|
|
305
470
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
471
|
+
return out;
|
|
472
|
+
}
|
|
473
|
+
function paxEntry(fields) {
|
|
474
|
+
const body = Object.entries(fields).map(([k, v]) => {
|
|
475
|
+
const rest = ` ${k}=${v}\n`;
|
|
476
|
+
const restBytes = Buffer.byteLength(rest);
|
|
477
|
+
let len = restBytes + String(restBytes).length;
|
|
478
|
+
if (String(len).length > String(restBytes).length) len = restBytes + String(len).length;
|
|
479
|
+
return `${len}${rest}`;
|
|
480
|
+
}).join("");
|
|
481
|
+
const data = Buffer.from(body);
|
|
482
|
+
return Buffer.concat([header("PaxHeader", 420, data.length, 0, "x", ""), pad(data)]);
|
|
483
|
+
}
|
|
484
|
+
const pad = (data) => Buffer.concat([data, Buffer.alloc((BLOCK - data.length % BLOCK) % BLOCK)]);
|
|
485
|
+
function header(name, mode, size, mtime, type, link) {
|
|
486
|
+
const h = Buffer.alloc(BLOCK);
|
|
487
|
+
const put = (value, at, len) => {
|
|
488
|
+
Buffer.from(value).copy(h, at, 0, Math.min(len, Buffer.byteLength(value)));
|
|
489
|
+
};
|
|
490
|
+
const num = (value, at, len) => put(`${value.toString(8).padStart(len - 1, "0")}\0`, at, len);
|
|
491
|
+
put(name, 0, 100);
|
|
492
|
+
num(mode, 100, 8);
|
|
493
|
+
num(0, 108, 8);
|
|
494
|
+
num(0, 116, 8);
|
|
495
|
+
num(size, 124, 12);
|
|
496
|
+
num(Math.max(0, mtime), 136, 12);
|
|
497
|
+
h.fill(32, 148, 156);
|
|
498
|
+
put(type, 156, 1);
|
|
499
|
+
put(link, 157, 100);
|
|
500
|
+
put("ustar\0", 257, 6);
|
|
501
|
+
put("00", 263, 2);
|
|
502
|
+
let sum = 0;
|
|
503
|
+
for (const byte of h) sum += byte;
|
|
504
|
+
put(`${sum.toString(8).padStart(6, "0")}\0 `, 148, 8);
|
|
505
|
+
return h;
|
|
506
|
+
}
|
|
507
|
+
const fits = (s) => Buffer.byteLength(s) <= 100 && /^[\x20-\x7e]*$/.test(s);
|
|
508
|
+
/** An uncompressed tar of `entries`, with a pax header for a path or link target ustar can't hold. */
|
|
509
|
+
function writeTar(entries) {
|
|
510
|
+
const parts = [];
|
|
511
|
+
for (const e of entries) {
|
|
512
|
+
const name = e.type === "dir" ? `${e.path}/` : e.path;
|
|
513
|
+
const link = e.type === "symlink" ? e.target : "";
|
|
514
|
+
const long = {};
|
|
515
|
+
if (!fits(name)) long.path = name;
|
|
516
|
+
if (!fits(link)) long.linkpath = link;
|
|
517
|
+
if (Object.keys(long).length) parts.push(paxEntry(long));
|
|
518
|
+
const shortName = fits(name) ? name : "long-name";
|
|
519
|
+
const shortLink = fits(link) ? link : "long-link";
|
|
520
|
+
if (e.type === "file") parts.push(header(shortName, e.mode, e.data.length, e.mtime, "0", ""), pad(e.data));
|
|
521
|
+
else parts.push(header(shortName, e.mode, 0, e.mtime, e.type === "dir" ? "5" : "2", shortLink));
|
|
522
|
+
}
|
|
523
|
+
parts.push(Buffer.alloc(BLOCK * 2));
|
|
524
|
+
return Buffer.concat(parts);
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Writes `entries` under `dir`, never through a symbolic link: an entry whose parent on disk is a
|
|
528
|
+
* link or a file is skipped, as is one whose path exists already, so nothing lands outside `dir`
|
|
529
|
+
* even where the filesystem folds case. An entry the platform refuses (a name Windows can't hold,
|
|
530
|
+
* a link without the right to make one) is skipped too. Returns the paths it skipped.
|
|
531
|
+
*/
|
|
532
|
+
async function extractTar(entries, dir) {
|
|
533
|
+
const root = resolve(dir);
|
|
534
|
+
const skipped = [];
|
|
535
|
+
await mkdir(root, { recursive: true });
|
|
536
|
+
const times = [];
|
|
537
|
+
const parentsAreDirs = async (parts) => {
|
|
538
|
+
let at = root;
|
|
539
|
+
for (const part of parts.slice(0, -1)) {
|
|
540
|
+
at = join(at, part);
|
|
541
|
+
const info = await lstat(at).catch(() => null);
|
|
542
|
+
if (!info) await mkdir(at);
|
|
543
|
+
else if (!info.isDirectory()) return false;
|
|
544
|
+
}
|
|
545
|
+
return true;
|
|
546
|
+
};
|
|
547
|
+
for (const e of entries) {
|
|
548
|
+
const parts = e.path.split("/");
|
|
549
|
+
const target = join(root, ...parts);
|
|
309
550
|
try {
|
|
310
|
-
|
|
311
|
-
|
|
551
|
+
if (!target.startsWith(root + sep) || !await parentsAreDirs(parts)) {
|
|
552
|
+
skipped.push(e.path);
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
const existing = await lstat(target).catch(() => null);
|
|
556
|
+
if (e.type === "dir") {
|
|
557
|
+
if (!existing) await mkdir(target);
|
|
558
|
+
else if (!existing.isDirectory()) skipped.push(e.path);
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
if (existing) {
|
|
562
|
+
skipped.push(e.path);
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
if (e.type === "symlink") await symlink(e.target, target);
|
|
566
|
+
else {
|
|
567
|
+
await writeFile(target, e.data, {
|
|
568
|
+
mode: e.mode & 511 || 420,
|
|
569
|
+
flag: "wx"
|
|
570
|
+
});
|
|
571
|
+
times.push([target, e.mtime]);
|
|
572
|
+
}
|
|
573
|
+
} catch {
|
|
574
|
+
skipped.push(e.path);
|
|
575
|
+
}
|
|
312
576
|
}
|
|
577
|
+
for (const [path, mtime] of times) await utimes(path, mtime, mtime).catch(() => {});
|
|
578
|
+
return skipped;
|
|
313
579
|
}
|
|
314
|
-
/** `
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
file: cmd,
|
|
326
|
-
args,
|
|
327
|
-
verbatim: false
|
|
580
|
+
/** The tree under `dir` as entries, in a stable order; a symbolic link is kept as one, never followed. */
|
|
581
|
+
async function readTree(dir, prefix = "") {
|
|
582
|
+
const entries = [];
|
|
583
|
+
for (const name of (await readdir(dir)).sort()) {
|
|
584
|
+
const full = join(dir, name);
|
|
585
|
+
const path = prefix ? `${prefix}/${name}` : name;
|
|
586
|
+
const info = await lstat(full);
|
|
587
|
+
const meta = {
|
|
588
|
+
path,
|
|
589
|
+
mode: info.mode & 4095,
|
|
590
|
+
mtime: Math.floor(info.mtimeMs / 1e3)
|
|
328
591
|
};
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
windowsHide: true,
|
|
334
|
-
windowsVerbatimArguments: target.verbatim,
|
|
335
|
-
env: options.env ? {
|
|
336
|
-
...process.env,
|
|
337
|
-
...options.env
|
|
338
|
-
} : process.env
|
|
592
|
+
if (info.isSymbolicLink()) entries.push({
|
|
593
|
+
type: "symlink",
|
|
594
|
+
...meta,
|
|
595
|
+
target: await readlink(full)
|
|
339
596
|
});
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
597
|
+
else if (info.isDirectory()) entries.push({
|
|
598
|
+
type: "dir",
|
|
599
|
+
...meta
|
|
600
|
+
}, ...await readTree(full, path));
|
|
601
|
+
else if (info.isFile()) entries.push({
|
|
602
|
+
type: "file",
|
|
603
|
+
...meta,
|
|
604
|
+
data: await readFile(full)
|
|
345
605
|
});
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
606
|
+
}
|
|
607
|
+
return entries;
|
|
608
|
+
}
|
|
609
|
+
// ../sandbox-docker/src/remote-engine.ts
|
|
610
|
+
/**
|
|
611
|
+
* The remote side of a command with an environment: its first stdin line is the base64 of the
|
|
612
|
+
* `export`s, which `read` takes a byte at a time (stdin is a pipe), so the rest of stdin is the
|
|
613
|
+
* CLI's own.
|
|
614
|
+
*/
|
|
615
|
+
const WITH_ENV = "IFS= read -r reeval_env || exit 125; reeval_env=$(printf %s \"$reeval_env\" | base64 -d) || exit 125; eval \"$reeval_env\" || exit 125; unset reeval_env; exec \"$@\"";
|
|
616
|
+
/**
|
|
617
|
+
* How to run the engine's CLI with `args`: the CLI itself here, or ssh to it on a remote engine.
|
|
618
|
+
* `env` reaches the CLI's environment, never argv: on a remote engine it's the {@link
|
|
619
|
+
* EngineCommand.preamble}.
|
|
620
|
+
*/
|
|
621
|
+
function hostCommand(engine, args, env = {}) {
|
|
622
|
+
if (!isRemoteEngine(engine)) return {
|
|
623
|
+
bin: engineSpec(engine).bin,
|
|
624
|
+
args: [...args],
|
|
625
|
+
env: {
|
|
626
|
+
...engineEnv(engine),
|
|
627
|
+
...env
|
|
628
|
+
},
|
|
629
|
+
preamble: null
|
|
630
|
+
};
|
|
631
|
+
const docker = ["docker", ...args].map(shellQuote).join(" ");
|
|
632
|
+
const names = Object.keys(env);
|
|
633
|
+
for (const name of names) if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) throw new Error(`${name} isn't a variable name`);
|
|
634
|
+
const remote = names.length ? `sh -c ${shellQuote(WITH_ENV)} sh ${docker}` : `exec ${docker}`;
|
|
635
|
+
const [bin = "ssh", ...rest] = sshArgv(engine.target, remote);
|
|
636
|
+
const exports = names.map((name) => `export ${name}=${shellQuote(env[name] ?? "")}`).join("\n");
|
|
637
|
+
return {
|
|
638
|
+
bin,
|
|
639
|
+
args: rest,
|
|
640
|
+
env: {},
|
|
641
|
+
preamble: names.length ? Buffer.from(`${Buffer.from(exports).toString("base64")}\n`) : null
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Spawns the engine's CLI with `args` in its own process group, its output piped and no stdin of
|
|
646
|
+
* its own; on a remote engine stdin carries only the environment.
|
|
647
|
+
*/
|
|
648
|
+
function spawnEngine(engine, args, env = {}) {
|
|
649
|
+
const command = hostCommand(engine, args, env);
|
|
650
|
+
const child = spawn(command.bin, command.args, {
|
|
651
|
+
stdio: [
|
|
652
|
+
command.preamble ? "pipe" : "ignore",
|
|
653
|
+
"pipe",
|
|
654
|
+
"pipe"
|
|
655
|
+
],
|
|
656
|
+
detached: true,
|
|
657
|
+
env: {
|
|
658
|
+
...process.env,
|
|
659
|
+
...command.env
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
if (command.preamble && child.stdin) {
|
|
663
|
+
child.stdin.on("error", () => {});
|
|
664
|
+
child.stdin.end(command.preamble);
|
|
665
|
+
}
|
|
666
|
+
return child;
|
|
667
|
+
}
|
|
668
|
+
const literal = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
669
|
+
/**
|
|
670
|
+
* ssh failing to connect to `target`, so the remote CLI never ran and running it again is safe:
|
|
671
|
+
* the whole of stderr is ssh's own message naming the machine. A connection that drops later
|
|
672
|
+
* isn't one, since the command may have run, and nor is a remote command that printed the same.
|
|
673
|
+
*/
|
|
674
|
+
const isSshFailure = (r, target) => {
|
|
675
|
+
if (r.exitCode !== 255) return false;
|
|
676
|
+
const at = `${literal(target.host)} port ${target.port}`;
|
|
677
|
+
return new RegExp(`^(?:ssh: connect to host ${at}: [^\\n]+|kex_exchange_identification: [^\\n]+\\n(?:Connection (?:closed|reset) by \\S+ port ${target.port}|banner exchange: Connection to \\S+ port ${target.port}: [^\\n]+)|Connection timed out during banner exchange\\nConnection to \\S+ port ${target.port} timed out)$`).test(r.stderr.trim());
|
|
678
|
+
};
|
|
679
|
+
/** Commands that run a container's process, whose output and exit code are that process's. */
|
|
680
|
+
const RUNS_A_PROCESS = /* @__PURE__ */ new Set([
|
|
681
|
+
"exec",
|
|
682
|
+
"run",
|
|
683
|
+
"start",
|
|
684
|
+
"attach"
|
|
685
|
+
]);
|
|
686
|
+
/** Whether `args` is safe to run again after ssh failed to connect. */
|
|
687
|
+
const retriesSafely = (args) => !RUNS_A_PROCESS.has(args[0] ?? "");
|
|
688
|
+
/** How traces and messages name the engine's CLI. */
|
|
689
|
+
const engineLabel = (engine) => isRemoteEngine(engine) ? `docker on ${engine.description}` : engineSpec(engine).bin;
|
|
690
|
+
/** Option flags of `docker build` that take a value as the next argument. */
|
|
691
|
+
const BUILD_VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
692
|
+
"--add-host",
|
|
693
|
+
"--allow",
|
|
694
|
+
"--annotation",
|
|
695
|
+
"--attest",
|
|
696
|
+
"--build-arg",
|
|
697
|
+
"--build-context",
|
|
698
|
+
"--builder",
|
|
699
|
+
"--cache-from",
|
|
700
|
+
"--cache-to",
|
|
701
|
+
"--call",
|
|
702
|
+
"--cgroup-parent",
|
|
703
|
+
"--cpu-period",
|
|
704
|
+
"--cpu-quota",
|
|
705
|
+
"--cpu-shares",
|
|
706
|
+
"-c",
|
|
707
|
+
"--cpuset-cpus",
|
|
708
|
+
"--cpuset-mems",
|
|
709
|
+
"--file",
|
|
710
|
+
"-f",
|
|
711
|
+
"--iidfile",
|
|
712
|
+
"--isolation",
|
|
713
|
+
"--label",
|
|
714
|
+
"--memory",
|
|
715
|
+
"-m",
|
|
716
|
+
"--memory-swap",
|
|
717
|
+
"--metadata-file",
|
|
718
|
+
"--network",
|
|
719
|
+
"--no-cache-filter",
|
|
720
|
+
"--output",
|
|
721
|
+
"-o",
|
|
722
|
+
"--platform",
|
|
723
|
+
"--progress",
|
|
724
|
+
"--provenance",
|
|
725
|
+
"--sbom",
|
|
726
|
+
"--secret",
|
|
727
|
+
"--security-opt",
|
|
728
|
+
"--shm-size",
|
|
729
|
+
"--ssh",
|
|
730
|
+
"--tag",
|
|
731
|
+
"-t",
|
|
732
|
+
"--target",
|
|
733
|
+
"--ulimit"
|
|
734
|
+
]);
|
|
735
|
+
/** Whether a `docker build` flag's value names a file, directory or socket on this machine. */
|
|
736
|
+
function namesLocalPath(flag, value) {
|
|
737
|
+
switch (flag) {
|
|
738
|
+
case "--iidfile":
|
|
739
|
+
case "--metadata-file":
|
|
740
|
+
case "--ssh": return true;
|
|
741
|
+
case "--secret": return !/(?:^|,)env=/.test(value);
|
|
742
|
+
case "--build-context": {
|
|
743
|
+
const source = value.slice(value.indexOf("=") + 1);
|
|
744
|
+
return source.startsWith("oci-layout://") || !/^[a-z][a-z0-9+.-]*:\/\//.test(source);
|
|
745
|
+
}
|
|
746
|
+
case "--output":
|
|
747
|
+
case "-o": return !/(?:^|,)type=/.test(value) || /(?:^|,)(?:type=(?:local|tar)|dest=)/.test(value);
|
|
748
|
+
case "--cache-to":
|
|
749
|
+
case "--cache-from": return /(?:^|,)type=local/.test(value);
|
|
750
|
+
default: return false;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
const STDIN_DOCKERFILE = ".reeval-stdin.Dockerfile";
|
|
754
|
+
function contextEntries(context, files) {
|
|
755
|
+
const entries = [];
|
|
756
|
+
const dirs = /* @__PURE__ */ new Set();
|
|
757
|
+
for (const path of files) for (let at = path.indexOf("/"); at !== -1; at = path.indexOf("/", at + 1)) dirs.add(path.slice(0, at));
|
|
758
|
+
for (const path of [...dirs].sort()) {
|
|
759
|
+
const stat = lstatSync(join(context, path));
|
|
760
|
+
const mtime = Math.floor(stat.mtimeMs / 1e3);
|
|
761
|
+
entries.push({
|
|
762
|
+
type: "dir",
|
|
763
|
+
path,
|
|
764
|
+
mode: stat.mode & 4095,
|
|
765
|
+
mtime
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
for (const path of files) {
|
|
769
|
+
const full = join(context, path);
|
|
770
|
+
const stat = lstatSync(full, { throwIfNoEntry: false });
|
|
771
|
+
if (!stat) continue;
|
|
772
|
+
const mtime = Math.floor(stat.mtimeMs / 1e3);
|
|
773
|
+
const mode = stat.mode & 4095;
|
|
774
|
+
if (stat.isSymbolicLink()) entries.push({
|
|
775
|
+
type: "symlink",
|
|
776
|
+
path,
|
|
777
|
+
mode,
|
|
778
|
+
mtime,
|
|
779
|
+
target: readlinkSync(full)
|
|
780
|
+
});
|
|
781
|
+
else if (stat.isFile()) entries.push({
|
|
782
|
+
type: "file",
|
|
783
|
+
path,
|
|
784
|
+
mode,
|
|
785
|
+
mtime,
|
|
786
|
+
data: readFileSync(full)
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
return entries;
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* `docker build` arguments and input for a remote engine: a build context on this machine goes as
|
|
793
|
+
* a tar on stdin (`-`), with its `.dockerignore` rules applied by the builder as they would be
|
|
794
|
+
* here. The Dockerfile keeps its path in the context; one outside it, or one read from stdin,
|
|
795
|
+
* goes in the tar under a name of its own. Directories go as the files' parents, with their modes,
|
|
796
|
+
* so an empty one isn't sent. The context is read into memory whole. A flag that names a path on
|
|
797
|
+
* this machine (`--iidfile`, `--secret`, a local `--output`, …) is refused: the CLI would read or
|
|
798
|
+
* write it on the other one. Any other command, and a build whose context is stdin, a URL or a
|
|
799
|
+
* git repository, is as is.
|
|
800
|
+
*/
|
|
801
|
+
function remoteBuild(args, input) {
|
|
802
|
+
if (args[0] !== "build") return {
|
|
803
|
+
args: [...args],
|
|
804
|
+
input
|
|
805
|
+
};
|
|
806
|
+
let file = null;
|
|
807
|
+
let contextAt = -1;
|
|
808
|
+
for (let i = 1; i < args.length; i++) {
|
|
809
|
+
const arg = args[i];
|
|
810
|
+
const [flag = arg, joined] = arg.startsWith("--") ? arg.split(/=(.*)/s) : /^-(?:f|o)./.test(arg) ? [arg.slice(0, 2), arg.slice(2).replace(/^=/, "")] : [arg];
|
|
811
|
+
if (namesLocalPath(flag, joined ?? args[i + 1] ?? "")) throw new Error(`docker build ${flag} names a path on this machine, which a remote engine can't reach`);
|
|
812
|
+
if (BUILD_VALUE_FLAGS.has(arg)) {
|
|
813
|
+
if (arg === "--file" || arg === "-f") file = {
|
|
814
|
+
at: i + 1,
|
|
815
|
+
value: args[i + 1] ?? ""
|
|
816
|
+
};
|
|
817
|
+
i++;
|
|
818
|
+
} else if (flag === "-f" && joined !== void 0) file = {
|
|
819
|
+
at: i,
|
|
820
|
+
value: joined
|
|
349
821
|
};
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
822
|
+
else if (arg.startsWith("--file=")) file = {
|
|
823
|
+
at: i,
|
|
824
|
+
value: arg.slice(7)
|
|
825
|
+
};
|
|
826
|
+
else if (!arg.startsWith("-") || arg === "-") contextAt = i;
|
|
827
|
+
}
|
|
828
|
+
const context = contextAt === -1 ? null : args[contextAt];
|
|
829
|
+
if (context === null || context === "-") return {
|
|
830
|
+
args: [...args],
|
|
831
|
+
input
|
|
832
|
+
};
|
|
833
|
+
if (!statSync(context, { throwIfNoEntry: false })?.isDirectory()) return {
|
|
834
|
+
args: [...args],
|
|
835
|
+
input
|
|
836
|
+
};
|
|
837
|
+
const root = resolve(context);
|
|
838
|
+
const out = [...args];
|
|
839
|
+
out[contextAt] = "-";
|
|
840
|
+
const setFile = (value) => {
|
|
841
|
+
if (!file) out.splice(contextAt, 0, "--file", value);
|
|
842
|
+
else if (out[file.at]?.startsWith("--file=")) out[file.at] = `--file=${value}`;
|
|
843
|
+
else if (/^-f[^-]/.test(out[file.at] ?? "") && file.at !== contextAt) out[file.at] = `-f${value}`;
|
|
844
|
+
else out[file.at] = value;
|
|
845
|
+
};
|
|
846
|
+
const extra = [];
|
|
847
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
848
|
+
let dockerfile = null;
|
|
849
|
+
if (file?.value === "-") {
|
|
850
|
+
const data = Buffer.from(input ?? "");
|
|
851
|
+
extra.push({
|
|
852
|
+
type: "file",
|
|
853
|
+
path: STDIN_DOCKERFILE,
|
|
854
|
+
mode: 420,
|
|
855
|
+
mtime: now,
|
|
856
|
+
data
|
|
361
857
|
});
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
858
|
+
setFile(STDIN_DOCKERFILE);
|
|
859
|
+
} else {
|
|
860
|
+
dockerfile = file ? resolve(file.value) : join(root, "Dockerfile");
|
|
861
|
+
const inside = relative(root, dockerfile);
|
|
862
|
+
if (inside && !inside.startsWith("..") && !isAbsolute(inside)) {
|
|
863
|
+
if (file) setFile(inside.split(sep).join("/"));
|
|
864
|
+
} else {
|
|
865
|
+
const name = `.reeval-${createHash("sha256").update(dockerfile).digest("hex").slice(0, 12)}.Dockerfile`;
|
|
866
|
+
extra.push({
|
|
867
|
+
type: "file",
|
|
868
|
+
path: name,
|
|
869
|
+
mode: 420,
|
|
870
|
+
mtime: now,
|
|
871
|
+
data: readFileSync(dockerfile)
|
|
872
|
+
});
|
|
873
|
+
if (lstatSync(`${dockerfile}.dockerignore`, { throwIfNoEntry: false })?.isFile()) {
|
|
874
|
+
const data = readFileSync(`${dockerfile}.dockerignore`);
|
|
875
|
+
extra.push({
|
|
876
|
+
type: "file",
|
|
877
|
+
path: `${name}.dockerignore`,
|
|
878
|
+
mode: 420,
|
|
879
|
+
mtime: now,
|
|
880
|
+
data
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
setFile(name);
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
return {
|
|
887
|
+
args: out,
|
|
888
|
+
input: writeTar([...contextEntries(root, contextFiles(root, dockerfile).filter((path) => !/^\.\.(?:[\\/]|$)/.test(path) && !extra.some((e) => e.path === path))), ...extra])
|
|
889
|
+
};
|
|
366
890
|
}
|
|
367
891
|
// ../sandbox-docker/src/trace.ts
|
|
368
892
|
/** Most of each stream a trace keeps; the rest is counted. */
|
|
@@ -433,6 +957,174 @@ function traceDocker(args, startedAt, result, bin = "docker") {
|
|
|
433
957
|
});
|
|
434
958
|
} catch {}
|
|
435
959
|
}
|
|
960
|
+
// ../sandbox-docker/src/egress/transport.ts
|
|
961
|
+
/** Runs `command` in the sandbox to its end. */
|
|
962
|
+
async function execRun(transport, command, options) {
|
|
963
|
+
if (transport.run) return transport.run(command, options);
|
|
964
|
+
const [bin = "", ...args] = transport.argv(command);
|
|
965
|
+
const startedAt = Date.now();
|
|
966
|
+
try {
|
|
967
|
+
const r = await run(bin, args, {
|
|
968
|
+
...options,
|
|
969
|
+
env: transport.env,
|
|
970
|
+
binary: true
|
|
971
|
+
});
|
|
972
|
+
transport.trace?.([bin, ...args], startedAt, {
|
|
973
|
+
...r,
|
|
974
|
+
stdin: options.input.length
|
|
975
|
+
});
|
|
976
|
+
return r;
|
|
977
|
+
} catch (error) {
|
|
978
|
+
transport.trace?.([bin, ...args], startedAt, { error });
|
|
979
|
+
throw error;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
/** Starts `command` in the sandbox and leaves it running, its stdio piped. */
|
|
983
|
+
function execSpawn(transport, command) {
|
|
984
|
+
const argv = transport.argv(command);
|
|
985
|
+
const [bin = "", ...args] = argv;
|
|
986
|
+
const startedAt = Date.now();
|
|
987
|
+
const child = spawn(bin, args, {
|
|
988
|
+
stdio: "pipe",
|
|
989
|
+
detached: true,
|
|
990
|
+
env: {
|
|
991
|
+
...process.env,
|
|
992
|
+
...transport.env
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
let stderr = "";
|
|
996
|
+
child.stderr.on("data", (d) => {
|
|
997
|
+
stderr += d;
|
|
998
|
+
});
|
|
999
|
+
child.once("close", (code) => transport.trace?.(argv, startedAt, {
|
|
1000
|
+
exitCode: code,
|
|
1001
|
+
stderr
|
|
1002
|
+
}));
|
|
1003
|
+
return child;
|
|
1004
|
+
}
|
|
1005
|
+
/** What every `ssh` reeval runs passes: no prompt, a dropped connection noticed within a minute. */
|
|
1006
|
+
const SSH_OPTIONS = [
|
|
1007
|
+
"-o",
|
|
1008
|
+
"BatchMode=yes",
|
|
1009
|
+
"-o",
|
|
1010
|
+
"ServerAliveInterval=15",
|
|
1011
|
+
"-o",
|
|
1012
|
+
"ServerAliveCountMax=4",
|
|
1013
|
+
"-o",
|
|
1014
|
+
"LogLevel=ERROR"
|
|
1015
|
+
];
|
|
1016
|
+
/**
|
|
1017
|
+
* Whether `dir` is a directory only this user can enter, made (0700) first with `make`. An ssh
|
|
1018
|
+
* client trusts whatever listens at its ControlPath, so a socket in a directory another user can
|
|
1019
|
+
* write lets them stand in for the host.
|
|
1020
|
+
*/
|
|
1021
|
+
function privateDir(dir, o = {}) {
|
|
1022
|
+
try {
|
|
1023
|
+
if (o.make) mkdirSync(dir, {
|
|
1024
|
+
recursive: true,
|
|
1025
|
+
mode: 448
|
|
1026
|
+
});
|
|
1027
|
+
const st = lstatSync(dir);
|
|
1028
|
+
return st.isDirectory() && st.uid === process.getuid?.() && (st.mode & 63) === 0;
|
|
1029
|
+
} catch {
|
|
1030
|
+
return false;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* Whether ssh can listen on a control socket at `path` on `platform`. A socket's path has
|
|
1035
|
+
* `sizeof(sun_path)` bytes with its NUL (104 on macOS and the BSDs, 108 on Linux), and the master
|
|
1036
|
+
* first listens on `path` plus a 17-byte random suffix. `%C` expands to a 40-character hash.
|
|
1037
|
+
*/
|
|
1038
|
+
function controlPathFits(path, platform = process.platform) {
|
|
1039
|
+
const room = platform === "linux" ? 108 : 104;
|
|
1040
|
+
return Buffer.byteLength(path.replaceAll("%C", "C".repeat(40))) + 17 < room;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* The options that share one connection through a control socket at `path`, kept open `persistS`
|
|
1044
|
+
* seconds after the last command; none on Windows, whose OpenSSH has no ControlMaster, when the
|
|
1045
|
+
* path is too long for a socket ({@link controlPathFits}), or when the socket's directory isn't
|
|
1046
|
+
* {@link privateDir}. `path` may end in an ssh token such as `%C`.
|
|
1047
|
+
*/
|
|
1048
|
+
function controlOptions(path, persistS) {
|
|
1049
|
+
if (!path || process.platform === "win32" || !controlPathFits(path)) return [];
|
|
1050
|
+
if (!privateDir(dirname(path))) return [];
|
|
1051
|
+
return [
|
|
1052
|
+
"-o",
|
|
1053
|
+
"ControlMaster=auto",
|
|
1054
|
+
"-o",
|
|
1055
|
+
`ControlPath=${path}`,
|
|
1056
|
+
"-o",
|
|
1057
|
+
`ControlPersist=${persistS}`
|
|
1058
|
+
];
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* The host argv that runs `remote`, one shell command line, on `target`. ssh joins its remote
|
|
1062
|
+
* arguments into one line for the login shell, so the caller quotes it. No user config applies.
|
|
1063
|
+
*/
|
|
1064
|
+
function sshArgv(target, remote) {
|
|
1065
|
+
return [
|
|
1066
|
+
"ssh",
|
|
1067
|
+
"-T",
|
|
1068
|
+
"-F",
|
|
1069
|
+
"none",
|
|
1070
|
+
"-i",
|
|
1071
|
+
target.identityFile,
|
|
1072
|
+
"-p",
|
|
1073
|
+
String(target.port),
|
|
1074
|
+
...SSH_OPTIONS,
|
|
1075
|
+
"-o",
|
|
1076
|
+
"IdentitiesOnly=yes",
|
|
1077
|
+
"-o",
|
|
1078
|
+
"StrictHostKeyChecking=yes",
|
|
1079
|
+
"-o",
|
|
1080
|
+
`UserKnownHostsFile=${target.knownHostsFile}`,
|
|
1081
|
+
"-o",
|
|
1082
|
+
"GlobalKnownHostsFile=none",
|
|
1083
|
+
"-o",
|
|
1084
|
+
`HostKeyAlias=${target.hostKeyAlias}`,
|
|
1085
|
+
"-o",
|
|
1086
|
+
"ConnectTimeout=20",
|
|
1087
|
+
...controlOptions(target.controlPath, 300),
|
|
1088
|
+
`${target.user}@${target.host}`,
|
|
1089
|
+
remote
|
|
1090
|
+
];
|
|
1091
|
+
}
|
|
1092
|
+
/** How a command line on `target` runs as root: through `sudo -n`, unless it logs in as root. */
|
|
1093
|
+
const asRootPrefix = (target) => target.loginRoot ? "" : "sudo -n -- ";
|
|
1094
|
+
/** `ssh -T` into a VM, as root through `sudo -n` (with sudo's own `secure_path`) or as its login. */
|
|
1095
|
+
function sshTransport(target) {
|
|
1096
|
+
return {
|
|
1097
|
+
argv: (command) => sshArgv(target, `${asRootPrefix(target)}${command.map(shellQuote).join(" ")}`),
|
|
1098
|
+
trace: (argv, startedAt, end) => traceDocker(argv.slice(1), startedAt, end, "ssh")
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
/** `docker exec` (or `podman exec`) into a running container, as root. */
|
|
1102
|
+
function containerTransport(containerId, engine) {
|
|
1103
|
+
const sent = /* @__PURE__ */ new WeakMap();
|
|
1104
|
+
const exec = (command) => [
|
|
1105
|
+
"exec",
|
|
1106
|
+
"--interactive",
|
|
1107
|
+
"--user",
|
|
1108
|
+
"0:0",
|
|
1109
|
+
containerId,
|
|
1110
|
+
...command
|
|
1111
|
+
];
|
|
1112
|
+
return {
|
|
1113
|
+
argv: (command) => {
|
|
1114
|
+
const host = hostCommand(engine, exec(command));
|
|
1115
|
+
const argv = [host.bin, ...host.args];
|
|
1116
|
+
sent.set(argv, exec(command));
|
|
1117
|
+
return argv;
|
|
1118
|
+
},
|
|
1119
|
+
env: hostCommand(engine, []).env,
|
|
1120
|
+
run: (command, { input, signal }) => docker(exec(command), {
|
|
1121
|
+
input,
|
|
1122
|
+
signal,
|
|
1123
|
+
engine
|
|
1124
|
+
}),
|
|
1125
|
+
trace: (argv, startedAt, end) => traceDocker(sent.get(argv) ?? argv.slice(1), startedAt, end, engineLabel(engine))
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
436
1128
|
// ../sandbox-docker/src/docker-cli.ts
|
|
437
1129
|
/** How long to wait before each retry of a command that never reached Podman. */
|
|
438
1130
|
const CONNECTION_RETRY_MS = [
|
|
@@ -461,43 +1153,58 @@ const sleep = (ms, signal) => new Promise((resolve) => {
|
|
|
461
1153
|
* {@link isConnectionFailure}), and returns the last result.
|
|
462
1154
|
*/
|
|
463
1155
|
async function retryConnection(attempt, options = {}) {
|
|
464
|
-
const { delays = CONNECTION_RETRY_MS, signal, wait = sleep } = options;
|
|
1156
|
+
const { delays = CONNECTION_RETRY_MS, signal, wait = sleep, failed = isConnectionFailure } = options;
|
|
465
1157
|
let r = await attempt();
|
|
466
1158
|
for (const ms of delays) {
|
|
467
|
-
if (!
|
|
1159
|
+
if (!failed(r) || signal?.aborted) break;
|
|
468
1160
|
await wait(ms, signal);
|
|
469
1161
|
r = await attempt();
|
|
470
1162
|
}
|
|
471
1163
|
return r;
|
|
472
1164
|
}
|
|
473
|
-
/**
|
|
1165
|
+
/**
|
|
1166
|
+
* Runs the docker (or podman) CLI, here or on a remote engine's machine. `env` values are passed
|
|
1167
|
+
* via the CLI's environment, never argv.
|
|
1168
|
+
*/
|
|
474
1169
|
async function docker(args, options = {}) {
|
|
475
|
-
const { engine,
|
|
476
|
-
const
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
...rest.env
|
|
1170
|
+
const { engine, signal } = options;
|
|
1171
|
+
const remote = isRemoteEngine(engine);
|
|
1172
|
+
const call = remote ? remoteBuild(args, options.input) : {
|
|
1173
|
+
args,
|
|
1174
|
+
input: options.input
|
|
481
1175
|
};
|
|
1176
|
+
const command = hostCommand(engine, call.args, options.env);
|
|
1177
|
+
const input = command.preamble ? Buffer.concat([command.preamble, Buffer.from(call.input ?? "")]) : call.input;
|
|
1178
|
+
const bin = engineLabel(engine);
|
|
1179
|
+
const stdin = call.input?.length ?? 0;
|
|
482
1180
|
const once = async () => {
|
|
483
1181
|
const startedAt = Date.now();
|
|
484
1182
|
try {
|
|
485
|
-
const r = await run(bin, args, {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
1183
|
+
const r = await run(command.bin, command.args, {
|
|
1184
|
+
env: command.env,
|
|
1185
|
+
binary: true,
|
|
1186
|
+
...input !== void 0 ? { input } : {},
|
|
1187
|
+
...signal ? { signal } : {}
|
|
489
1188
|
});
|
|
490
|
-
traceDocker(args, startedAt, {
|
|
1189
|
+
traceDocker(call.args, startedAt, {
|
|
491
1190
|
...r,
|
|
492
1191
|
stdin
|
|
493
1192
|
}, bin);
|
|
494
1193
|
return r;
|
|
495
1194
|
} catch (error) {
|
|
496
|
-
traceDocker(args, startedAt, { error }, bin);
|
|
1195
|
+
traceDocker(call.args, startedAt, { error }, bin);
|
|
497
1196
|
throw error;
|
|
498
1197
|
}
|
|
499
1198
|
};
|
|
500
|
-
|
|
1199
|
+
if (remote) {
|
|
1200
|
+
if (!retriesSafely(call.args)) return once();
|
|
1201
|
+
const { target } = engine;
|
|
1202
|
+
return retryConnection(once, {
|
|
1203
|
+
signal,
|
|
1204
|
+
failed: (r) => isSshFailure(r, target)
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
return engine === "podman" ? retryConnection(once, { signal }) : once();
|
|
501
1208
|
}
|
|
502
1209
|
async function dockerOk(args, opts) {
|
|
503
1210
|
const r = await docker(args, opts);
|
|
@@ -519,12 +1226,14 @@ const REMOVAL_RETRY_MS = [
|
|
|
519
1226
|
* and tries again while it fails. Resolves either way.
|
|
520
1227
|
*/
|
|
521
1228
|
async function removeContainerDetached(id, engine, options = {}) {
|
|
522
|
-
const {
|
|
1229
|
+
const { rmForce } = engineSpec(engine);
|
|
523
1230
|
const { delays = REMOVAL_RETRY_MS, wait = sleep } = options;
|
|
524
1231
|
const args = [...rmForce, id];
|
|
1232
|
+
const command = hostCommand(engine, args);
|
|
1233
|
+
const bin = command.bin;
|
|
525
1234
|
const env = {
|
|
526
1235
|
...process.env,
|
|
527
|
-
...
|
|
1236
|
+
...command.env
|
|
528
1237
|
};
|
|
529
1238
|
const once = () => new Promise((resolve) => {
|
|
530
1239
|
const keepAlive = setInterval(() => {}, 1e3);
|
|
@@ -538,13 +1247,13 @@ async function removeContainerDetached(id, engine, options = {}) {
|
|
|
538
1247
|
traceDocker(args, startedAt, {
|
|
539
1248
|
exitCode,
|
|
540
1249
|
stderr
|
|
541
|
-
},
|
|
1250
|
+
}, engineLabel(engine));
|
|
542
1251
|
resolve({
|
|
543
1252
|
exitCode,
|
|
544
1253
|
stderr
|
|
545
1254
|
});
|
|
546
1255
|
};
|
|
547
|
-
const child = spawn(bin, args, {
|
|
1256
|
+
const child = spawn(bin, command.args, {
|
|
548
1257
|
detached: true,
|
|
549
1258
|
stdio: [
|
|
550
1259
|
"ignore",
|
|
@@ -577,6 +1286,19 @@ async function removeContainerDetached(id, engine, options = {}) {
|
|
|
577
1286
|
*/
|
|
578
1287
|
function sweepLabelDetached(label, seconds = 15, engine) {
|
|
579
1288
|
const { bin, rmForce } = engineSpec(engine);
|
|
1289
|
+
if (isRemoteEngine(engine)) {
|
|
1290
|
+
const filter = shellQuote(`label=${label}`);
|
|
1291
|
+
const loop = `for i in $(seq ${Math.max(1, Math.floor(seconds))}); do ids=$(docker ps -aq --filter ${filter}); [ -z "$ids" ] || docker ${rmForce.join(" ")} $ids >/dev/null 2>&1; sleep 1; done`;
|
|
1292
|
+
const [ssh = "ssh", ...rest] = sshArgv(engine.target, `sh -c ${shellQuote(loop)}`);
|
|
1293
|
+
const child = spawn(ssh, rest, {
|
|
1294
|
+
detached: true,
|
|
1295
|
+
stdio: "ignore",
|
|
1296
|
+
windowsHide: true
|
|
1297
|
+
});
|
|
1298
|
+
child.on("error", () => {});
|
|
1299
|
+
child.unref();
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
580
1302
|
const child = spawn(process.execPath, [
|
|
581
1303
|
"-e",
|
|
582
1304
|
`const { execFileSync } = require('node:child_process')
|
|
@@ -685,111 +1407,20 @@ async function imageInfo(image, engine) {
|
|
|
685
1407
|
], { engine }).catch((error) => {
|
|
686
1408
|
throw new Error(`${bin} image inspect ${image} couldn't run: ${error.message}`);
|
|
687
1409
|
});
|
|
688
|
-
if (r.exitCode !== 0) {
|
|
689
|
-
const stderr = r.stderr.trim();
|
|
690
|
-
if (isNoSuchImage(stderr)) return null;
|
|
691
|
-
throw new Error(`${bin} image inspect ${image} failed: ${stderr || `exit ${r.exitCode}`}`);
|
|
692
|
-
}
|
|
693
|
-
const info = JSON.parse(r.stdout.toString("utf8"));
|
|
694
|
-
const repoDigests = (info.repoDigests ?? []).filter(isRegistryDigest);
|
|
695
|
-
const platform = info.os && info.arch ? `${info.os}/${info.arch}` : null;
|
|
696
|
-
return {
|
|
697
|
-
labels: info.config?.Labels ?? {},
|
|
698
|
-
id: normalizeImageId(info.id),
|
|
699
|
-
repoDigests,
|
|
700
|
-
platform
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
// ../sandbox-docker/src/dockerignore.ts
|
|
704
|
-
const ignore = dockerignore.default;
|
|
705
|
-
/**
|
|
706
|
-
* A pattern `@balena/dockerignore` may match differently from BuildKit: escapes, character
|
|
707
|
-
* classes and the regexp characters it doesn't escape, a `**` joined to other characters, and the
|
|
708
|
-
* whitespace Go and JavaScript trim differently. One over 1024 characters is risky too, since
|
|
709
|
-
* JavaScript refuses a regexp that long that Go accepts, and so is one with more than four `*`
|
|
710
|
-
* runs, whose JavaScript regexp can backtrack for minutes where Go's runs in linear time.
|
|
711
|
-
*/
|
|
712
|
-
const RISKY = /[\\[\]^+(){}|\u0085\uFEFF]|[^/]\*\*|\*\*[^/]/;
|
|
713
|
-
const MAX_STARS = 4;
|
|
714
|
-
/**
|
|
715
|
-
* Names `@balena/dockerignore` may match differently: `?` matches one UTF-16 unit there and one
|
|
716
|
-
* code point in BuildKit, and `.` doesn't match a line terminator there but does in Go.
|
|
717
|
-
*/
|
|
718
|
-
const ODD_NAME = /[\n\r\u2028\u2029\u{10000}-\u{10FFFF}]/u;
|
|
719
|
-
const clean = (pattern) => posix.normalize(pattern).replace(/^\/+/, "").replace(/\/+$/, "");
|
|
720
|
-
/**
|
|
721
|
-
* `.dockerignore` lines as Docker reads them: a BOM is dropped, a line starting `#` is a comment,
|
|
722
|
-
* and `!` re-includes. A path is left out when a rule excludes it and no `!` rule matches it or a
|
|
723
|
-
* directory it's in: BuildKit then excludes it whatever order the rules are in, so this never
|
|
724
|
-
* leaves out a file `docker build` sends, though it keeps some it doesn't. A risky exclusion is
|
|
725
|
-
* dropped, and a risky `!` rule keeps everything, as does one `@balena/dockerignore` would read
|
|
726
|
-
* as a comment or a pattern that cleans to a leading `!` (`!!a`, `/ !a`), which the two read
|
|
727
|
-
* differently.
|
|
728
|
-
*/
|
|
729
|
-
function parseRules(text) {
|
|
730
|
-
const excludes = [];
|
|
731
|
-
const reincludes = [];
|
|
732
|
-
for (const line of text.replace(/^\uFEFF/, "").split(/\r?\n/)) {
|
|
733
|
-
if (line.startsWith("#")) continue;
|
|
734
|
-
let pattern = line.trim();
|
|
735
|
-
const negate = pattern.startsWith("!");
|
|
736
|
-
if (negate) pattern = pattern.slice(1).trim();
|
|
737
|
-
if (!pattern) continue;
|
|
738
|
-
const cleaned = clean(pattern);
|
|
739
|
-
const risky = RISKY.test(pattern) || pattern.length > 1024 || (pattern.match(/\*+/g)?.length ?? 0) > MAX_STARS || [".", ""].includes(cleaned);
|
|
740
|
-
if (cleaned.trim().startsWith("!") || negate && pattern.startsWith("#") || negate && risky) return {
|
|
741
|
-
left: () => false,
|
|
742
|
-
literal: null
|
|
743
|
-
};
|
|
744
|
-
if (!negate) {
|
|
745
|
-
if (!risky) excludes.push(line);
|
|
746
|
-
} else reincludes.push(pattern);
|
|
747
|
-
}
|
|
748
|
-
const exclude = ignore({ ignorecase: false }).add(excludes);
|
|
749
|
-
const reinclude = ignore({ ignorecase: false }).add(reincludes);
|
|
750
|
-
return {
|
|
751
|
-
left: (path) => !ODD_NAME.test(path) && exclude.ignores(path) && !reinclude.ignores(path),
|
|
752
|
-
literal: reincludes.some((p) => /[*?]/.test(p)) ? null : reincludes.map(clean)
|
|
753
|
-
};
|
|
754
|
-
}
|
|
755
|
-
/** Whether reeval leaves `path` out of a hash under these `.dockerignore` rules. */
|
|
756
|
-
function dockerignoreMatcher(text) {
|
|
757
|
-
return parseRules(text).left;
|
|
758
|
-
}
|
|
759
|
-
/**
|
|
760
|
-
* Files in the build context that reeval hashes, sorted, relative to `context`: every file
|
|
761
|
-
* `docker build` sends (and some it doesn't), plus the Dockerfile and `.dockerignore`. A
|
|
762
|
-
* Dockerfile read from stdin (`dockerfile` null) has no `<Dockerfile>.dockerignore` of its own.
|
|
763
|
-
* A left-out directory is skipped only when every `!` rule is a literal path outside it. Docker
|
|
764
|
-
* doesn't apply an ignore file that's a symlink or not a file, so then every file is hashed; nor
|
|
765
|
-
* can it send what's in a directory it can't read.
|
|
766
|
-
*/
|
|
767
|
-
function contextFiles(context, dockerfile) {
|
|
768
|
-
const own = [...dockerfile ? [`${dockerfile}.dockerignore`] : [], join(context, ".dockerignore")].map((path) => ({
|
|
769
|
-
path,
|
|
770
|
-
stat: lstatSync(path, { throwIfNoEntry: false })
|
|
771
|
-
})).find(({ stat }) => stat);
|
|
772
|
-
const { left, literal } = parseRules(own?.stat?.isFile() ? readFileSync(own.path, "utf8") : "");
|
|
773
|
-
const always = [...dockerfile ? [relative(context, dockerfile)] : [], ".dockerignore"].map((path) => path.split("\\").join("/"));
|
|
774
|
-
const reach = [...always, ...literal ?? []];
|
|
775
|
-
const files = [];
|
|
776
|
-
const walk = (rel) => {
|
|
777
|
-
let entries;
|
|
778
|
-
try {
|
|
779
|
-
entries = readdirSync(join(context, rel), { withFileTypes: true });
|
|
780
|
-
} catch (error) {
|
|
781
|
-
if (rel && ["EACCES", "EPERM"].includes(error.code ?? "")) return;
|
|
782
|
-
throw error;
|
|
783
|
-
}
|
|
784
|
-
for (const entry of entries) {
|
|
785
|
-
const path = rel ? `${rel}/${entry.name}` : entry.name;
|
|
786
|
-
if (entry.isDirectory()) {
|
|
787
|
-
if (!(left(path) && literal && !reach.some((p) => p.startsWith(`${path}/`)))) walk(path);
|
|
788
|
-
} else if (!left(path) || always.includes(path)) files.push(path);
|
|
789
|
-
}
|
|
1410
|
+
if (r.exitCode !== 0) {
|
|
1411
|
+
const stderr = r.stderr.trim();
|
|
1412
|
+
if (isNoSuchImage(stderr)) return null;
|
|
1413
|
+
throw new Error(`${bin} image inspect ${image} failed: ${stderr || `exit ${r.exitCode}`}`);
|
|
1414
|
+
}
|
|
1415
|
+
const info = JSON.parse(r.stdout.toString("utf8"));
|
|
1416
|
+
const repoDigests = (info.repoDigests ?? []).filter(isRegistryDigest);
|
|
1417
|
+
const platform = info.os && info.arch ? `${info.os}/${info.arch}` : null;
|
|
1418
|
+
return {
|
|
1419
|
+
labels: info.config?.Labels ?? {},
|
|
1420
|
+
id: normalizeImageId(info.id),
|
|
1421
|
+
repoDigests,
|
|
1422
|
+
platform
|
|
790
1423
|
};
|
|
791
|
-
walk("");
|
|
792
|
-
return files.sort();
|
|
793
1424
|
}
|
|
794
1425
|
// ../sandbox-docker/src/image.ts
|
|
795
1426
|
/**
|
|
@@ -806,7 +1437,7 @@ const HARNESS_PACKAGES = {
|
|
|
806
1437
|
name: "Cursor",
|
|
807
1438
|
cli: "@cursor/sdk",
|
|
808
1439
|
probe: `node -p "'@cursor/sdk ' + require(process.env.HOME + '/.ai-sdk-harness/.harness-bootstrap/cursor-sdk/node_modules/@cursor/sdk/package.json').version"`,
|
|
809
|
-
adapter: async () => (await import("./src-
|
|
1440
|
+
adapter: async () => (await import("./src-CUrcaZ91.js")).createCursorSdk()
|
|
810
1441
|
}
|
|
811
1442
|
},
|
|
812
1443
|
"claude-code": {
|
|
@@ -816,7 +1447,7 @@ const HARNESS_PACKAGES = {
|
|
|
816
1447
|
bootstrap: {
|
|
817
1448
|
name: "Claude Code",
|
|
818
1449
|
cli: "claude",
|
|
819
|
-
adapter: async () => (await import("./dist-
|
|
1450
|
+
adapter: async () => (await import("./dist-CZtW7eI5.js")).createClaudeCode()
|
|
820
1451
|
}
|
|
821
1452
|
},
|
|
822
1453
|
antigravity: {
|
|
@@ -825,7 +1456,7 @@ const HARNESS_PACKAGES = {
|
|
|
825
1456
|
bootstrap: {
|
|
826
1457
|
name: "Antigravity",
|
|
827
1458
|
cli: "agy",
|
|
828
|
-
adapter: async () => (await import("./src-
|
|
1459
|
+
adapter: async () => (await import("./src-CB5cZhaN.js")).createAntigravity()
|
|
829
1460
|
}
|
|
830
1461
|
},
|
|
831
1462
|
opencode: {
|
|
@@ -834,7 +1465,7 @@ const HARNESS_PACKAGES = {
|
|
|
834
1465
|
bootstrap: {
|
|
835
1466
|
name: "OpenCode",
|
|
836
1467
|
cli: "opencode",
|
|
837
|
-
adapter: async () => (await import("./src-
|
|
1468
|
+
adapter: async () => (await import("./src-DiS13D_q.js")).createOpenCode({
|
|
838
1469
|
auth: { GOOGLE_GENERATIVE_AI_API_KEY: "unused" },
|
|
839
1470
|
model: "google/unused"
|
|
840
1471
|
})
|
|
@@ -847,7 +1478,7 @@ const HARNESS_PACKAGES = {
|
|
|
847
1478
|
name: "Goose",
|
|
848
1479
|
cli: "goose",
|
|
849
1480
|
adapter: async () => {
|
|
850
|
-
const goose = await import("./src-
|
|
1481
|
+
const goose = await import("./src-Bj3WJs3t.js");
|
|
851
1482
|
return goose.createGoose({
|
|
852
1483
|
auth: { GOOGLE_API_KEY: "unused" },
|
|
853
1484
|
provider: goose.GEMINI_PROVIDER,
|
|
@@ -863,7 +1494,7 @@ const HARNESS_PACKAGES = {
|
|
|
863
1494
|
name: "pi",
|
|
864
1495
|
cli: "pi",
|
|
865
1496
|
adapter: async () => {
|
|
866
|
-
const pi = await import("./src-
|
|
1497
|
+
const pi = await import("./src-CcbV6VpV.js");
|
|
867
1498
|
const provider = pi.piProvider("google");
|
|
868
1499
|
if ("refused" in provider) throw new Error(provider.refused);
|
|
869
1500
|
return pi.createPi({
|
|
@@ -879,7 +1510,7 @@ const HARNESS_PACKAGES = {
|
|
|
879
1510
|
bootstrap: {
|
|
880
1511
|
name: "Codex",
|
|
881
1512
|
cli: "codex",
|
|
882
|
-
adapter: async () => (await import("./src-
|
|
1513
|
+
adapter: async () => (await import("./src-TMKittwH.js")).createCodex({ auth: { OPENAI_API_KEY: "unused" } })
|
|
883
1514
|
}
|
|
884
1515
|
},
|
|
885
1516
|
fx: {
|
|
@@ -888,7 +1519,7 @@ const HARNESS_PACKAGES = {
|
|
|
888
1519
|
bootstrap: {
|
|
889
1520
|
name: "fx",
|
|
890
1521
|
cli: "fx",
|
|
891
|
-
adapter: async () => (await import("./src-
|
|
1522
|
+
adapter: async () => (await import("./src-9V3C6A7C.js")).createFx({
|
|
892
1523
|
auth: { AI_GATEWAY_API_KEY: "unused" },
|
|
893
1524
|
model: "unused/unused"
|
|
894
1525
|
})
|
|
@@ -900,7 +1531,7 @@ const HARNESS_PACKAGES = {
|
|
|
900
1531
|
bootstrap: {
|
|
901
1532
|
name: "Grok Build",
|
|
902
1533
|
cli: "grok",
|
|
903
|
-
adapter: async () => (await import("./src-
|
|
1534
|
+
adapter: async () => (await import("./src-CFBg2ecq.js")).createGrokBuild({
|
|
904
1535
|
auth: { XAI_API_KEY: "unused" },
|
|
905
1536
|
model: "unused"
|
|
906
1537
|
})
|
|
@@ -922,7 +1553,7 @@ const imageFor = (harness) => `reeval-sandbox:${harness}-${adapterVersion(harnes
|
|
|
922
1553
|
const DEFAULT_IMAGE = imageFor("cursor");
|
|
923
1554
|
/** The `ai.reeval.harness` label value an image baked for `harness` carries. */
|
|
924
1555
|
const harnessLabel = (harness) => `${HARNESS_PACKAGES[harness].name}@${adapterVersion(harness)}`;
|
|
925
|
-
const LABEL = {
|
|
1556
|
+
const LABEL$1 = {
|
|
926
1557
|
managed: "ai.reeval.managed",
|
|
927
1558
|
run: "ai.reeval.run",
|
|
928
1559
|
/** Unique per session, so a create cut short can find what it made. */
|
|
@@ -1297,7 +1928,7 @@ function createMux(options) {
|
|
|
1297
1928
|
* Pipes two duplexes into each other. An error, or one side closing before its end, tears both
|
|
1298
1929
|
* down; a clean end half-closes the other side through `pipe`.
|
|
1299
1930
|
*/
|
|
1300
|
-
function link(a, b) {
|
|
1931
|
+
function link$1(a, b) {
|
|
1301
1932
|
a.pipe(b);
|
|
1302
1933
|
b.pipe(a);
|
|
1303
1934
|
const kill = () => {
|
|
@@ -1356,7 +1987,7 @@ function forwarderMain(io, makeMux, linkStreams, proxyPort) {
|
|
|
1356
1987
|
server.listen(proxyPort, "127.0.0.1", () => mux.ready());
|
|
1357
1988
|
}
|
|
1358
1989
|
/** The `node -e` script that runs {@link forwarderMain} in the container. */
|
|
1359
|
-
const forwarderScript = (proxyPort) => `(${forwarderMain.toString()})({ net: require('node:net'), Duplex: require('node:stream').Duplex, input: process.stdin, output: process.stdout, error: (m) => process.stderr.write(m + '\\n'), exit: (c) => process.exit(c) }, ${createMux.toString()}, ${link.toString()}, ${proxyPort})`;
|
|
1990
|
+
const forwarderScript = (proxyPort) => `(${forwarderMain.toString()})({ net: require('node:net'), Duplex: require('node:stream').Duplex, input: process.stdin, output: process.stdout, error: (m) => process.stderr.write(m + '\\n'), exit: (c) => process.exit(c) }, ${createMux.toString()}, ${link$1.toString()}, ${proxyPort})`;
|
|
1360
1991
|
// ../sandbox-docker/src/egress/effort.ts
|
|
1361
1992
|
/** The paths read, in order; `*` is any key of an object (a gateway's provider name). */
|
|
1362
1993
|
const PATHS = [
|
|
@@ -1795,6 +2426,24 @@ function unsubstituted(subs, request) {
|
|
|
1795
2426
|
}
|
|
1796
2427
|
return out;
|
|
1797
2428
|
}
|
|
2429
|
+
/**
|
|
2430
|
+
* The secrets whose placeholder a request carries, in its headers, path or query, where the
|
|
2431
|
+
* gateway won't swap their value in: to a host they aren't brokered to, or to one of their hosts
|
|
2432
|
+
* over plain HTTP (`secure` false). The gateway reads no body for this.
|
|
2433
|
+
*/
|
|
2434
|
+
function strayPlaceholders(subs, request, secure) {
|
|
2435
|
+
const text = [request.path, ...Object.values(request.headers).flat()].filter(Boolean).join("\n");
|
|
2436
|
+
const out = /* @__PURE__ */ new Map();
|
|
2437
|
+
for (const s of subs) {
|
|
2438
|
+
if (out.has(s.name) || !text.includes(s.placeholder)) continue;
|
|
2439
|
+
if (!hostAllowed(s.hosts, request.host)) out.set(s.name, "host_not_allowed");
|
|
2440
|
+
else if (!secure) out.set(s.name, "plain_http");
|
|
2441
|
+
}
|
|
2442
|
+
return [...out].map(([name, reason]) => ({
|
|
2443
|
+
name,
|
|
2444
|
+
reason
|
|
2445
|
+
}));
|
|
2446
|
+
}
|
|
1798
2447
|
/** A response header value with every real value on the host put back as its placeholder. */
|
|
1799
2448
|
const scrubValue = (subs, value) => subs.reduce((out, s) => replaceIn(out, s.value, s.placeholder), value);
|
|
1800
2449
|
/** Response headers with every real value on the host put back as its placeholder. */
|
|
@@ -2252,6 +2901,17 @@ function createEgressProxy(options) {
|
|
|
2252
2901
|
/** Substitutions for derived tokens, added as their exchanges answer; kept by setSubstitutions. */
|
|
2253
2902
|
let tokens = [];
|
|
2254
2903
|
const allSubs = () => tokens.length ? [...subs, ...tokens] : subs;
|
|
2904
|
+
const stray = (request, secure, method, url) => {
|
|
2905
|
+
if (!options.onStrayPlaceholder) return;
|
|
2906
|
+
for (const s of strayPlaceholders(subs, request, secure)) try {
|
|
2907
|
+
options.onStrayPlaceholder({
|
|
2908
|
+
...s,
|
|
2909
|
+
host: request.host,
|
|
2910
|
+
method,
|
|
2911
|
+
url
|
|
2912
|
+
});
|
|
2913
|
+
} catch {}
|
|
2914
|
+
};
|
|
2255
2915
|
const derived = options.derivedTokens ?? [];
|
|
2256
2916
|
const tokenHosts = derived.flatMap((d) => [d.endpoint.host, ...d.hosts]);
|
|
2257
2917
|
const locals = options.localResponses ?? [];
|
|
@@ -2543,7 +3203,7 @@ function createEgressProxy(options) {
|
|
|
2543
3203
|
upstream.once("connect", () => {
|
|
2544
3204
|
socket.write("HTTP/1.1 200 Connection Established\r\n\r\n");
|
|
2545
3205
|
if (head.length) upstream.write(head);
|
|
2546
|
-
link(socket, upstream);
|
|
3206
|
+
link$1(socket, upstream);
|
|
2547
3207
|
});
|
|
2548
3208
|
upstream.once("error", (error) => {
|
|
2549
3209
|
log(`reeval:egress CONNECT ${host}:${port} failed (${failure(error)})`);
|
|
@@ -2656,6 +3316,11 @@ function createEgressProxy(options) {
|
|
|
2656
3316
|
function onPlain(target, req, res, path, host, done) {
|
|
2657
3317
|
const url = `http://${target.host}:${target.port}${pathOnly(path)}`;
|
|
2658
3318
|
log(`reeval:egress ${req.method} ${url}`);
|
|
3319
|
+
stray({
|
|
3320
|
+
host: target.host,
|
|
3321
|
+
path,
|
|
3322
|
+
headers: req.headers
|
|
3323
|
+
}, false, req.method ?? "GET", url);
|
|
2659
3324
|
const upstream = http.request({
|
|
2660
3325
|
...reachAt(target),
|
|
2661
3326
|
port: target.port,
|
|
@@ -2812,6 +3477,11 @@ function createEgressProxy(options) {
|
|
|
2812
3477
|
return reply(socket, 421, refused);
|
|
2813
3478
|
}
|
|
2814
3479
|
log(`reeval:egress ${method} http://${authority}${pathOnly(path)} (upgrade)`);
|
|
3480
|
+
stray({
|
|
3481
|
+
host: target.host,
|
|
3482
|
+
path,
|
|
3483
|
+
headers: req.headers
|
|
3484
|
+
}, false, method, `http://${authority}${pathOnly(path)}`);
|
|
2815
3485
|
const upstream = http.request({
|
|
2816
3486
|
...reachAt(target),
|
|
2817
3487
|
port: target.port,
|
|
@@ -2833,7 +3503,7 @@ function createEgressProxy(options) {
|
|
|
2833
3503
|
socket.write(`${lines.join("\r\n")}\r\n\r\n`);
|
|
2834
3504
|
if (head.length) upSocket.write(head);
|
|
2835
3505
|
if (upHead.length) socket.write(upHead);
|
|
2836
|
-
link(socket, track(upSocket));
|
|
3506
|
+
link$1(socket, track(upSocket));
|
|
2837
3507
|
});
|
|
2838
3508
|
upstream.once("response", (up) => {
|
|
2839
3509
|
upgraded({ status: up.statusCode });
|
|
@@ -2940,6 +3610,7 @@ function createEgressProxy(options) {
|
|
|
2940
3610
|
method,
|
|
2941
3611
|
url
|
|
2942
3612
|
});
|
|
3613
|
+
stray(request, true, method, url);
|
|
2943
3614
|
const exchange = derived.find((d) => onEndpoint([d.endpoint], {
|
|
2944
3615
|
host: target.host,
|
|
2945
3616
|
method,
|
|
@@ -3387,13 +4058,13 @@ function createEgressProxy(options) {
|
|
|
3387
4058
|
track(upSocket);
|
|
3388
4059
|
if (!all.length) {
|
|
3389
4060
|
if (upHead.length) socket.write(upHead);
|
|
3390
|
-
return link(socket, upSocket);
|
|
4061
|
+
return link$1(socket, upSocket);
|
|
3391
4062
|
}
|
|
3392
4063
|
const frames = webSocketScrubber(all);
|
|
3393
4064
|
if (upHead.length) frames.write(upHead);
|
|
3394
4065
|
upSocket.pipe(frames);
|
|
3395
4066
|
upSocket.once("error", (error) => frames.destroy(error));
|
|
3396
|
-
link(socket, Duplex.from({
|
|
4067
|
+
link$1(socket, Duplex.from({
|
|
3397
4068
|
readable: frames,
|
|
3398
4069
|
writable: upSocket
|
|
3399
4070
|
}));
|
|
@@ -3491,167 +4162,6 @@ function createEgressProxy(options) {
|
|
|
3491
4162
|
}
|
|
3492
4163
|
};
|
|
3493
4164
|
}
|
|
3494
|
-
// ../sandbox-docker/src/egress/transport.ts
|
|
3495
|
-
/** Runs `command` in the sandbox to its end. */
|
|
3496
|
-
async function execRun(transport, command, options) {
|
|
3497
|
-
if (transport.run) return transport.run(command, options);
|
|
3498
|
-
const [bin = "", ...args] = transport.argv(command);
|
|
3499
|
-
const startedAt = Date.now();
|
|
3500
|
-
try {
|
|
3501
|
-
const r = await run(bin, args, {
|
|
3502
|
-
...options,
|
|
3503
|
-
env: transport.env,
|
|
3504
|
-
binary: true
|
|
3505
|
-
});
|
|
3506
|
-
transport.trace?.([bin, ...args], startedAt, {
|
|
3507
|
-
...r,
|
|
3508
|
-
stdin: options.input.length
|
|
3509
|
-
});
|
|
3510
|
-
return r;
|
|
3511
|
-
} catch (error) {
|
|
3512
|
-
transport.trace?.([bin, ...args], startedAt, { error });
|
|
3513
|
-
throw error;
|
|
3514
|
-
}
|
|
3515
|
-
}
|
|
3516
|
-
/** Starts `command` in the sandbox and leaves it running, its stdio piped. */
|
|
3517
|
-
function execSpawn(transport, command) {
|
|
3518
|
-
const argv = transport.argv(command);
|
|
3519
|
-
const [bin = "", ...args] = argv;
|
|
3520
|
-
const startedAt = Date.now();
|
|
3521
|
-
const child = spawn(bin, args, {
|
|
3522
|
-
stdio: "pipe",
|
|
3523
|
-
detached: true,
|
|
3524
|
-
env: {
|
|
3525
|
-
...process.env,
|
|
3526
|
-
...transport.env
|
|
3527
|
-
}
|
|
3528
|
-
});
|
|
3529
|
-
let stderr = "";
|
|
3530
|
-
child.stderr.on("data", (d) => {
|
|
3531
|
-
stderr += d;
|
|
3532
|
-
});
|
|
3533
|
-
child.once("close", (code) => transport.trace?.(argv, startedAt, {
|
|
3534
|
-
exitCode: code,
|
|
3535
|
-
stderr
|
|
3536
|
-
}));
|
|
3537
|
-
return child;
|
|
3538
|
-
}
|
|
3539
|
-
/** What every `ssh` reeval runs passes: no prompt, a dropped connection noticed within a minute. */
|
|
3540
|
-
const SSH_OPTIONS = [
|
|
3541
|
-
"-o",
|
|
3542
|
-
"BatchMode=yes",
|
|
3543
|
-
"-o",
|
|
3544
|
-
"ServerAliveInterval=15",
|
|
3545
|
-
"-o",
|
|
3546
|
-
"ServerAliveCountMax=4",
|
|
3547
|
-
"-o",
|
|
3548
|
-
"LogLevel=ERROR"
|
|
3549
|
-
];
|
|
3550
|
-
/**
|
|
3551
|
-
* Whether `dir` is a directory only this user can enter, made (0700) first with `make`. An ssh
|
|
3552
|
-
* client trusts whatever listens at its ControlPath, so a socket in a directory another user can
|
|
3553
|
-
* write lets them stand in for the host.
|
|
3554
|
-
*/
|
|
3555
|
-
function privateDir(dir, o = {}) {
|
|
3556
|
-
try {
|
|
3557
|
-
if (o.make) mkdirSync(dir, {
|
|
3558
|
-
recursive: true,
|
|
3559
|
-
mode: 448
|
|
3560
|
-
});
|
|
3561
|
-
const st = lstatSync(dir);
|
|
3562
|
-
return st.isDirectory() && st.uid === process.getuid?.() && (st.mode & 63) === 0;
|
|
3563
|
-
} catch {
|
|
3564
|
-
return false;
|
|
3565
|
-
}
|
|
3566
|
-
}
|
|
3567
|
-
/**
|
|
3568
|
-
* Whether ssh can listen on a control socket at `path` on `platform`. A socket's path has
|
|
3569
|
-
* `sizeof(sun_path)` bytes with its NUL (104 on macOS and the BSDs, 108 on Linux), and the master
|
|
3570
|
-
* first listens on `path` plus a 17-byte random suffix. `%C` expands to a 40-character hash.
|
|
3571
|
-
*/
|
|
3572
|
-
function controlPathFits(path, platform = process.platform) {
|
|
3573
|
-
const room = platform === "linux" ? 108 : 104;
|
|
3574
|
-
return Buffer.byteLength(path.replaceAll("%C", "C".repeat(40))) + 17 < room;
|
|
3575
|
-
}
|
|
3576
|
-
/**
|
|
3577
|
-
* The options that share one connection through a control socket at `path`, kept open `persistS`
|
|
3578
|
-
* seconds after the last command; none on Windows, whose OpenSSH has no ControlMaster, when the
|
|
3579
|
-
* path is too long for a socket ({@link controlPathFits}), or when the socket's directory isn't
|
|
3580
|
-
* {@link privateDir}. `path` may end in an ssh token such as `%C`.
|
|
3581
|
-
*/
|
|
3582
|
-
function controlOptions(path, persistS) {
|
|
3583
|
-
if (!path || process.platform === "win32" || !controlPathFits(path)) return [];
|
|
3584
|
-
if (!privateDir(dirname(path))) return [];
|
|
3585
|
-
return [
|
|
3586
|
-
"-o",
|
|
3587
|
-
"ControlMaster=auto",
|
|
3588
|
-
"-o",
|
|
3589
|
-
`ControlPath=${path}`,
|
|
3590
|
-
"-o",
|
|
3591
|
-
`ControlPersist=${persistS}`
|
|
3592
|
-
];
|
|
3593
|
-
}
|
|
3594
|
-
/**
|
|
3595
|
-
* The host argv that runs `remote`, one shell command line, on `target`. ssh joins its remote
|
|
3596
|
-
* arguments into one line for the login shell, so the caller quotes it. No user config applies.
|
|
3597
|
-
*/
|
|
3598
|
-
function sshArgv(target, remote) {
|
|
3599
|
-
return [
|
|
3600
|
-
"ssh",
|
|
3601
|
-
"-T",
|
|
3602
|
-
"-F",
|
|
3603
|
-
"none",
|
|
3604
|
-
"-i",
|
|
3605
|
-
target.identityFile,
|
|
3606
|
-
"-p",
|
|
3607
|
-
String(target.port),
|
|
3608
|
-
...SSH_OPTIONS,
|
|
3609
|
-
"-o",
|
|
3610
|
-
"IdentitiesOnly=yes",
|
|
3611
|
-
"-o",
|
|
3612
|
-
"StrictHostKeyChecking=yes",
|
|
3613
|
-
"-o",
|
|
3614
|
-
`UserKnownHostsFile=${target.knownHostsFile}`,
|
|
3615
|
-
"-o",
|
|
3616
|
-
"GlobalKnownHostsFile=none",
|
|
3617
|
-
"-o",
|
|
3618
|
-
`HostKeyAlias=${target.hostKeyAlias}`,
|
|
3619
|
-
"-o",
|
|
3620
|
-
"ConnectTimeout=20",
|
|
3621
|
-
...controlOptions(target.controlPath, 300),
|
|
3622
|
-
`${target.user}@${target.host}`,
|
|
3623
|
-
remote
|
|
3624
|
-
];
|
|
3625
|
-
}
|
|
3626
|
-
/** `ssh -T` into a VM, as root through `sudo -n`, with sudo's own `secure_path`. */
|
|
3627
|
-
function sshTransport(target) {
|
|
3628
|
-
return {
|
|
3629
|
-
argv: (command) => sshArgv(target, `sudo -n -- ${command.map(shellQuote).join(" ")}`),
|
|
3630
|
-
trace: (argv, startedAt, end) => traceDocker(argv.slice(1), startedAt, end, "ssh")
|
|
3631
|
-
};
|
|
3632
|
-
}
|
|
3633
|
-
/** `docker exec` (or `podman exec`) into a running container, as root. */
|
|
3634
|
-
function containerTransport(containerId, engine) {
|
|
3635
|
-
const { bin } = engineSpec(engine);
|
|
3636
|
-
const exec = (command) => [
|
|
3637
|
-
"exec",
|
|
3638
|
-
"--interactive",
|
|
3639
|
-
"--user",
|
|
3640
|
-
"0:0",
|
|
3641
|
-
containerId,
|
|
3642
|
-
...command
|
|
3643
|
-
];
|
|
3644
|
-
return {
|
|
3645
|
-
argv: (command) => [bin, ...exec(command)],
|
|
3646
|
-
env: engineEnv(engine),
|
|
3647
|
-
run: (command, { input, signal }) => docker(exec(command), {
|
|
3648
|
-
input,
|
|
3649
|
-
signal,
|
|
3650
|
-
engine
|
|
3651
|
-
}),
|
|
3652
|
-
trace: (argv, startedAt, end) => traceDocker(argv.slice(1), startedAt, end, bin)
|
|
3653
|
-
};
|
|
3654
|
-
}
|
|
3655
4165
|
// ../sandbox-docker/src/egress/gateway.ts
|
|
3656
4166
|
/** Where the forwarder listens inside the sandbox; every exec gets it as its HTTP(S) proxy. */
|
|
3657
4167
|
const PROXY_PORT = BASE_PROXY_PORT;
|
|
@@ -3867,7 +4377,7 @@ async function startGateway(transport, options, signal) {
|
|
|
3867
4377
|
if (stopped) return socket.destroy();
|
|
3868
4378
|
tunnels.add(socket);
|
|
3869
4379
|
socket.once("close", () => tunnels.delete(socket));
|
|
3870
|
-
link(socket, mux.open(port));
|
|
4380
|
+
link$1(socket, mux.open(port));
|
|
3871
4381
|
});
|
|
3872
4382
|
server.once("error", reject);
|
|
3873
4383
|
server.listen(0, "127.0.0.1", () => resolve(server));
|
|
@@ -4138,8 +4648,8 @@ async function networkMode(id, engine) {
|
|
|
4138
4648
|
async function createDockerSession(options) {
|
|
4139
4649
|
const nonce = randomBytes(8).toString("hex");
|
|
4140
4650
|
const labels = {
|
|
4141
|
-
[LABEL.managed]: "true",
|
|
4142
|
-
[LABEL.session]: nonce,
|
|
4651
|
+
[LABEL$1.managed]: "true",
|
|
4652
|
+
[LABEL$1.session]: nonce,
|
|
4143
4653
|
...options.labels
|
|
4144
4654
|
};
|
|
4145
4655
|
const lifetime = Math.ceil((options.lifetimeMs ?? 864e5) / 1e3);
|
|
@@ -4170,15 +4680,16 @@ async function createDockerSession(options) {
|
|
|
4170
4680
|
env,
|
|
4171
4681
|
engine
|
|
4172
4682
|
}).catch((error) => {
|
|
4173
|
-
if (signal?.aborted) sweepLabelDetached(`${LABEL.session}=${nonce}`, void 0, engine);
|
|
4683
|
+
if (signal?.aborted) sweepLabelDetached(`${LABEL$1.session}=${nonce}`, void 0, engine);
|
|
4174
4684
|
throw error;
|
|
4175
4685
|
});
|
|
4176
4686
|
let gateway;
|
|
4177
4687
|
let removed;
|
|
4178
4688
|
const observers = [];
|
|
4689
|
+
const creating = /* @__PURE__ */ new Set();
|
|
4179
4690
|
const remove = () => {
|
|
4180
4691
|
gateway?.close();
|
|
4181
|
-
removed ??= Promise.all([id, ...observers].map((c) => removeContainerDetached(c, engine))).then(() => {});
|
|
4692
|
+
removed ??= Promise.allSettled(creating).then(() => Promise.all([id, ...observers].map((c) => removeContainerDetached(c, engine)))).then(() => {});
|
|
4182
4693
|
return removed;
|
|
4183
4694
|
};
|
|
4184
4695
|
if (signal?.aborted) {
|
|
@@ -4363,18 +4874,7 @@ async function createDockerSession(options) {
|
|
|
4363
4874
|
/** Runs the engine's CLI with its output streamed; `stop` ends what it started. */
|
|
4364
4875
|
const streamed = (args, stop) => {
|
|
4365
4876
|
const startedAt = Date.now();
|
|
4366
|
-
const child =
|
|
4367
|
-
stdio: [
|
|
4368
|
-
"ignore",
|
|
4369
|
-
"pipe",
|
|
4370
|
-
"pipe"
|
|
4371
|
-
],
|
|
4372
|
-
detached: true,
|
|
4373
|
-
env: {
|
|
4374
|
-
...process.env,
|
|
4375
|
-
...engineEnv(engine)
|
|
4376
|
-
}
|
|
4377
|
-
});
|
|
4877
|
+
const child = spawnEngine(engine, args);
|
|
4378
4878
|
child.stderr.resume();
|
|
4379
4879
|
const exited = new Promise((resolve) => {
|
|
4380
4880
|
child.once("error", () => resolve({ exitCode: 127 }));
|
|
@@ -4382,7 +4882,7 @@ async function createDockerSession(options) {
|
|
|
4382
4882
|
traceDocker(args, startedAt, {
|
|
4383
4883
|
exitCode: code,
|
|
4384
4884
|
stdout: "<streamed>"
|
|
4385
|
-
},
|
|
4885
|
+
}, engineLabel(engine));
|
|
4386
4886
|
resolve({ exitCode: code ?? 1 });
|
|
4387
4887
|
});
|
|
4388
4888
|
});
|
|
@@ -4417,11 +4917,12 @@ async function createDockerSession(options) {
|
|
|
4417
4917
|
const observer = {
|
|
4418
4918
|
target: id,
|
|
4419
4919
|
async spawn(o) {
|
|
4420
|
-
|
|
4920
|
+
const gone = () => /* @__PURE__ */ new Error(`${spec.name} container ${id.slice(0, 12)} is gone`);
|
|
4921
|
+
if (removed) throw gone();
|
|
4421
4922
|
const name = `reeval-observer-${nonce}-${observers.length + 1}`;
|
|
4422
4923
|
observers.push(name);
|
|
4423
|
-
const
|
|
4424
|
-
"
|
|
4924
|
+
const created = docker([
|
|
4925
|
+
"create",
|
|
4425
4926
|
"--rm",
|
|
4426
4927
|
"--name",
|
|
4427
4928
|
name,
|
|
@@ -4446,8 +4947,16 @@ async function createDockerSession(options) {
|
|
|
4446
4947
|
options.image,
|
|
4447
4948
|
"-c",
|
|
4448
4949
|
o.command
|
|
4449
|
-
];
|
|
4450
|
-
|
|
4950
|
+
], { engine });
|
|
4951
|
+
creating.add(created);
|
|
4952
|
+
const r = await created.finally(() => creating.delete(created));
|
|
4953
|
+
if (r.exitCode !== 0) throw new Error(`${spec.bin} create failed: ${r.stderr.trim()}`);
|
|
4954
|
+
if (removed) throw gone();
|
|
4955
|
+
return streamed([
|
|
4956
|
+
"start",
|
|
4957
|
+
"--attach",
|
|
4958
|
+
name
|
|
4959
|
+
], () => removeContainerDetached(name, engine));
|
|
4451
4960
|
},
|
|
4452
4961
|
async run(o) {
|
|
4453
4962
|
const name = observers.at(-1);
|
|
@@ -4587,24 +5096,12 @@ async function createDockerSession(options) {
|
|
|
4587
5096
|
const marker = nextMarker();
|
|
4588
5097
|
const args = execArgs(o.command, marker, o.workingDirectory, env);
|
|
4589
5098
|
const startedAt = Date.now();
|
|
4590
|
-
const child =
|
|
4591
|
-
stdio: [
|
|
4592
|
-
"ignore",
|
|
4593
|
-
"pipe",
|
|
4594
|
-
"pipe"
|
|
4595
|
-
],
|
|
4596
|
-
detached: true,
|
|
4597
|
-
env: {
|
|
4598
|
-
...process.env,
|
|
4599
|
-
...engineEnv(engine),
|
|
4600
|
-
...env
|
|
4601
|
-
}
|
|
4602
|
-
});
|
|
5099
|
+
const child = spawnEngine(engine, args, env);
|
|
4603
5100
|
const exited = new Promise((resolve) => child.on("close", (code) => {
|
|
4604
5101
|
traceDocker(args, startedAt, {
|
|
4605
5102
|
exitCode: code,
|
|
4606
5103
|
stdout: "<streamed>"
|
|
4607
|
-
},
|
|
5104
|
+
}, engineLabel(engine));
|
|
4608
5105
|
resolve({ exitCode: code ?? 1 });
|
|
4609
5106
|
}));
|
|
4610
5107
|
const kill = async () => {
|
|
@@ -4823,8 +5320,8 @@ function buildError(output, what, reason, keep = () => true) {
|
|
|
4823
5320
|
});
|
|
4824
5321
|
}
|
|
4825
5322
|
/** Every image reeval builds carries this label, so `reeval clean --images` can find what it left. */
|
|
4826
|
-
const BUILT_BY = ["--label", `${LABEL.managed}=image`];
|
|
4827
|
-
const keyLabel = (key) => ["--label", `${LABEL.key}=${key}`];
|
|
5323
|
+
const BUILT_BY = ["--label", `${LABEL$1.managed}=image`];
|
|
5324
|
+
const keyLabel = (key) => ["--label", `${LABEL$1.key}=${key}`];
|
|
4828
5325
|
/** Removes the image `tag` pointed at before a rebuild, once the tag points elsewhere. */
|
|
4829
5326
|
async function replaced(tag, previous, engine) {
|
|
4830
5327
|
if (!previous) return;
|
|
@@ -4845,13 +5342,13 @@ async function pruneImages(engine) {
|
|
|
4845
5342
|
"--filter",
|
|
4846
5343
|
"dangling=true",
|
|
4847
5344
|
"--filter",
|
|
4848
|
-
`label=${LABEL.managed}=image`
|
|
5345
|
+
`label=${LABEL$1.managed}=image`
|
|
4849
5346
|
]), ...await list([
|
|
4850
5347
|
"-q",
|
|
4851
5348
|
"--filter",
|
|
4852
5349
|
"dangling=true",
|
|
4853
5350
|
"--filter",
|
|
4854
|
-
`label=${LABEL.harness}`
|
|
5351
|
+
`label=${LABEL$1.harness}`
|
|
4855
5352
|
])];
|
|
4856
5353
|
const bases = (await list([
|
|
4857
5354
|
"--format",
|
|
@@ -5051,7 +5548,7 @@ async function buildImage(log, options) {
|
|
|
5051
5548
|
await dockerOk([
|
|
5052
5549
|
"commit",
|
|
5053
5550
|
"--change",
|
|
5054
|
-
`LABEL ${LABEL.agentVersion}="${agentVersion}" ${LABEL.harness}="${harnessLabel(harness)}"${from ? digest ? ` ${LABEL.fromDigest}="${digest}"` : "" : ` ${LABEL.context}="${contextHash()}"`} ${LABEL.key}="${key}"`,
|
|
5551
|
+
`LABEL ${LABEL$1.agentVersion}="${agentVersion}" ${LABEL$1.harness}="${harnessLabel(harness)}"${from ? digest ? ` ${LABEL$1.fromDigest}="${digest}"` : "" : ` ${LABEL$1.context}="${contextHash()}"`} ${LABEL$1.key}="${key}"`,
|
|
5055
5552
|
"--change",
|
|
5056
5553
|
`WORKDIR ${SANDBOX_ROOT}`,
|
|
5057
5554
|
"--change",
|
|
@@ -5150,26 +5647,33 @@ function installScript(steps) {
|
|
|
5150
5647
|
return `${lines.join("\n")}\n`;
|
|
5151
5648
|
}
|
|
5152
5649
|
/**
|
|
5153
|
-
*
|
|
5154
|
-
*
|
|
5650
|
+
* The Dockerfile lines after `FROM` that run an install `script`: as root, but with the sandbox
|
|
5651
|
+
* user's home as HOME, so what an installer puts in `~` (uv, bun, rustup…) is where the agent
|
|
5652
|
+
* runs, and is then handed to that user.
|
|
5155
5653
|
*/
|
|
5156
|
-
|
|
5157
|
-
const { signal, engine } = options;
|
|
5158
|
-
const tag = installLayerTag(parent, steps);
|
|
5159
|
-
const previous = (await imageInfo(tag, engine))?.id;
|
|
5160
|
-
if (previous && !options.force) return tag;
|
|
5161
|
-
const script = installScript(steps);
|
|
5654
|
+
function installLayerLines(script) {
|
|
5162
5655
|
const encoded = Buffer.from(script).toString("base64");
|
|
5163
5656
|
const home = `$(getent passwd ${SANDBOX_USER} | cut -d: -f6)`;
|
|
5164
|
-
|
|
5165
|
-
`FROM ${parent.ref}`,
|
|
5657
|
+
return [
|
|
5166
5658
|
"USER root",
|
|
5167
5659
|
`RUN echo ${encoded} | base64 -d > /tmp/reeval-install.sh \\`,
|
|
5168
5660
|
` && if id -u ${SANDBOX_USER} >/dev/null 2>&1; then export HOME="${home}"; fi \\`,
|
|
5169
5661
|
" && bash /tmp/reeval-install.sh && rm /tmp/reeval-install.sh \\",
|
|
5170
5662
|
` && { ! id -u ${SANDBOX_USER} >/dev/null 2>&1 || find "$HOME" -xdev ! -user ${SANDBOX_USER} -exec chown -h ${SANDBOX_USER}: {} +; }`,
|
|
5171
5663
|
`WORKDIR ${SANDBOX_ROOT}`
|
|
5172
|
-
]
|
|
5664
|
+
];
|
|
5665
|
+
}
|
|
5666
|
+
/**
|
|
5667
|
+
* Builds the install layer if it's missing, or again with `force` (`reeval image build --force`,
|
|
5668
|
+
* whose rebuilt parent keeps its key). `output` gets the build's output, for a log file.
|
|
5669
|
+
*/
|
|
5670
|
+
async function buildInstallLayer(parent, steps, options = {}) {
|
|
5671
|
+
const { signal, engine } = options;
|
|
5672
|
+
const tag = installLayerTag(parent, steps);
|
|
5673
|
+
const previous = (await imageInfo(tag, engine))?.id;
|
|
5674
|
+
if (previous && !options.force) return tag;
|
|
5675
|
+
const script = installScript(steps);
|
|
5676
|
+
const dockerfile = [`FROM ${parent.ref}`, ...installLayerLines(script)].join("\n");
|
|
5173
5677
|
const build = await docker([
|
|
5174
5678
|
"build",
|
|
5175
5679
|
"--progress",
|
|
@@ -5361,6 +5865,24 @@ function dockerfileBases(dockerfile) {
|
|
|
5361
5865
|
};
|
|
5362
5866
|
}
|
|
5363
5867
|
/**
|
|
5868
|
+
* The image a Dockerfile's last stage starts from, through the stages it names, as its `FROM`
|
|
5869
|
+
* writes it: `${REEVAL_BASE}` for one built on the harness's image. The built image inherits its
|
|
5870
|
+
* labels, so this says whether it already has a harness's CLI. Null with no `FROM`.
|
|
5871
|
+
*/
|
|
5872
|
+
function dockerfileFinalBase(dockerfile) {
|
|
5873
|
+
const stages = /* @__PURE__ */ new Map();
|
|
5874
|
+
let last = null;
|
|
5875
|
+
const text = readFileSync(dockerfile, "utf8").replace(/\\[ \t]*\r?\n/g, " ");
|
|
5876
|
+
for (const line of text.split("\n")) {
|
|
5877
|
+
if (/^\s*#/.test(line)) continue;
|
|
5878
|
+
const from = /^\s*FROM\s+(?:--platform=\S+\s+)?(\S+)(?:\s+AS\s+(\S+))?/i.exec(line);
|
|
5879
|
+
if (!from?.[1]) continue;
|
|
5880
|
+
last = stages.get(from[1].toLowerCase()) ?? from[1];
|
|
5881
|
+
if (from[2]) stages.set(from[2].toLowerCase(), last);
|
|
5882
|
+
}
|
|
5883
|
+
return last;
|
|
5884
|
+
}
|
|
5885
|
+
/**
|
|
5364
5886
|
* A Dockerfile image's content key: its tag, plus the digest each of its {@link dockerfileBases}
|
|
5365
5887
|
* named when it was built, so a base that moved upstream is another image. One whose bases can't all
|
|
5366
5888
|
* be named this way is keyed on its local image id instead ({@link localKey}).
|
|
@@ -5483,11 +6005,11 @@ async function pullLayer(registry, layer, options = {}) {
|
|
|
5483
6005
|
};
|
|
5484
6006
|
try {
|
|
5485
6007
|
const info = await imageInfo(remote, engine).catch(() => null);
|
|
5486
|
-
const key = info?.labels[LABEL.key];
|
|
6008
|
+
const key = info?.labels[LABEL$1.key];
|
|
5487
6009
|
if (key !== layer.key) return {
|
|
5488
6010
|
pulled: false,
|
|
5489
6011
|
remote,
|
|
5490
|
-
reason: key ? `its ${LABEL.key} label is ${key}, not ${layer.key}` : `it has no ${LABEL.key} label`
|
|
6012
|
+
reason: key ? `its ${LABEL$1.key} label is ${key}, not ${layer.key}` : `it has no ${LABEL$1.key} label`
|
|
5491
6013
|
};
|
|
5492
6014
|
if (info?.platform !== platform) return {
|
|
5493
6015
|
pulled: false,
|
|
@@ -5552,6 +6074,136 @@ async function pushLayer(registry, layer, options = {}) {
|
|
|
5552
6074
|
}
|
|
5553
6075
|
return remote;
|
|
5554
6076
|
}
|
|
6077
|
+
// ../sandbox-docker/src/registry-api.ts
|
|
6078
|
+
const DIGEST = /^sha256:[0-9a-f]{64}$/;
|
|
6079
|
+
const LABEL = "[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?";
|
|
6080
|
+
const HOST = new RegExp(`^(?:${LABEL}(?:\\.${LABEL})*|\\[[0-9a-fA-F:]+\\])(?::\\d+)?$`);
|
|
6081
|
+
/**
|
|
6082
|
+
* The manifest types asked for, an index first: the digest is then the top-level manifest's, as
|
|
6083
|
+
* `docker buildx imagetools inspect` reports it and as `fromImageKey` keys a `from` image.
|
|
6084
|
+
*/
|
|
6085
|
+
const ACCEPT = [
|
|
6086
|
+
"application/vnd.oci.image.index.v1+json",
|
|
6087
|
+
"application/vnd.docker.distribution.manifest.list.v2+json",
|
|
6088
|
+
"application/vnd.oci.image.manifest.v1+json",
|
|
6089
|
+
"application/vnd.docker.distribution.manifest.v2+json"
|
|
6090
|
+
].join(", ");
|
|
6091
|
+
/**
|
|
6092
|
+
* `ref` as the registry API addresses it, normalized as Docker does: no registry is Docker Hub, a
|
|
6093
|
+
* one-part Docker Hub name is under `library/`, and no tag is `latest`. Null when it isn't a
|
|
6094
|
+
* reference.
|
|
6095
|
+
*/
|
|
6096
|
+
function parseImageRef(ref) {
|
|
6097
|
+
const at = ref.indexOf("@");
|
|
6098
|
+
const digest = at === -1 ? null : ref.slice(at + 1);
|
|
6099
|
+
if (digest !== null && !DIGEST.test(digest)) return null;
|
|
6100
|
+
let name = at === -1 ? ref : ref.slice(0, at);
|
|
6101
|
+
const slash = name.indexOf("/");
|
|
6102
|
+
const first = slash === -1 ? "" : name.slice(0, slash);
|
|
6103
|
+
let host = "docker.io";
|
|
6104
|
+
if (first && (first.includes(".") || first.includes(":") || first === "localhost")) {
|
|
6105
|
+
if (!HOST.test(first)) return null;
|
|
6106
|
+
host = first;
|
|
6107
|
+
name = name.slice(slash + 1);
|
|
6108
|
+
}
|
|
6109
|
+
const colon = name.lastIndexOf(":");
|
|
6110
|
+
const tag = colon === -1 ? null : name.slice(colon + 1);
|
|
6111
|
+
if (colon !== -1) name = name.slice(0, colon);
|
|
6112
|
+
if (tag !== null && !/^[\w][\w.-]{0,127}$/.test(tag)) return null;
|
|
6113
|
+
if (!/^[a-z0-9]+(?:(?:[._]|__|-+)[a-z0-9]+)*(?:\/[a-z0-9]+(?:(?:[._]|__|-+)[a-z0-9]+)*)*$/.test(name)) return null;
|
|
6114
|
+
if (host === "docker.io" || host === "index.docker.io") {
|
|
6115
|
+
host = "registry-1.docker.io";
|
|
6116
|
+
if (!name.includes("/")) name = `library/${name}`;
|
|
6117
|
+
}
|
|
6118
|
+
return {
|
|
6119
|
+
host,
|
|
6120
|
+
repository: name,
|
|
6121
|
+
reference: digest ?? tag ?? "latest"
|
|
6122
|
+
};
|
|
6123
|
+
}
|
|
6124
|
+
const loopback = (host) => /^(localhost|127\.\d+\.\d+\.\d+|\[::1\])(:\d+)?$/.test(host);
|
|
6125
|
+
/** A loopback registry speaks plain HTTP, as Docker allows without an insecure-registries entry. */
|
|
6126
|
+
const scheme = (host) => loopback(host) ? "http" : "https";
|
|
6127
|
+
/** The parameters of a `WWW-Authenticate` challenge: its scheme, lowercase, and its fields. */
|
|
6128
|
+
function challenge(header) {
|
|
6129
|
+
const match = /^\s*(\w+)\s*(.*)$/s.exec(header ?? "");
|
|
6130
|
+
const params = {};
|
|
6131
|
+
for (const [, key, quoted, bare] of (match?.[2] ?? "").matchAll(/(\w+)=(?:"((?:[^"\\]|\\.)*)"|([^\s,]*))/g)) if (key) params[key.toLowerCase()] = quoted?.replace(/\\(.)/g, "$1") ?? bare ?? "";
|
|
6132
|
+
return {
|
|
6133
|
+
scheme: match?.[1]?.toLowerCase() ?? "",
|
|
6134
|
+
params
|
|
6135
|
+
};
|
|
6136
|
+
}
|
|
6137
|
+
const basic = (c) => `Basic ${Buffer.from(`${c.username}:${c.password}`).toString("base64")}`;
|
|
6138
|
+
/**
|
|
6139
|
+
* What `ref` names in its registry now, without Docker: the digest of its top-level manifest (an
|
|
6140
|
+
* index for a multi-platform image), through the registry HTTP API. It follows the registry's
|
|
6141
|
+
* token challenge, anonymously or with `credential`'s login. A reference pinned by digest is that
|
|
6142
|
+
* digest. `error` when it doesn't resolve: no such image, access refused or no network.
|
|
6143
|
+
*/
|
|
6144
|
+
async function registryDigest(ref, options = {}) {
|
|
6145
|
+
const parsed = parseImageRef(ref);
|
|
6146
|
+
if (!parsed) return { error: `${ref} isn't an image reference` };
|
|
6147
|
+
if (DIGEST.test(parsed.reference)) return { digest: parsed.reference };
|
|
6148
|
+
const { host, repository, reference } = parsed;
|
|
6149
|
+
const fetchFn = options.fetch ?? fetch;
|
|
6150
|
+
const signal = AbortSignal.any([AbortSignal.timeout(options.timeoutMs ?? 15e3), ...options.signal ? [options.signal] : []]);
|
|
6151
|
+
const login = options.credential?.(host);
|
|
6152
|
+
const url = `${scheme(host)}://${host}/v2/${repository}/manifests/${encodeURIComponent(reference)}`;
|
|
6153
|
+
const ask = (method, authorization) => fetchFn(url, {
|
|
6154
|
+
method,
|
|
6155
|
+
headers: {
|
|
6156
|
+
accept: ACCEPT,
|
|
6157
|
+
...authorization ? { authorization } : {}
|
|
6158
|
+
},
|
|
6159
|
+
signal
|
|
6160
|
+
});
|
|
6161
|
+
try {
|
|
6162
|
+
let authorization = login && "token" in login ? `Bearer ${login.token}` : null;
|
|
6163
|
+
let response = await ask("HEAD", authorization);
|
|
6164
|
+
if (response.status === 401 && !(login && "token" in login)) {
|
|
6165
|
+
const asked = challenge(response.headers.get("www-authenticate"));
|
|
6166
|
+
if (asked.scheme === "bearer" && asked.params.realm) {
|
|
6167
|
+
const token = await bearerToken(asked.params, repository, login, fetchFn, signal);
|
|
6168
|
+
if ("error" in token) return { error: `${host} refused a token for ${repository}: ${token.error}` };
|
|
6169
|
+
authorization = `Bearer ${token.token}`;
|
|
6170
|
+
} else if (asked.scheme === "basic" && login) authorization = basic(login);
|
|
6171
|
+
if (authorization) response = await ask("HEAD", authorization);
|
|
6172
|
+
}
|
|
6173
|
+
if (response.ok) {
|
|
6174
|
+
const said = response.headers.get("docker-content-digest");
|
|
6175
|
+
if (said && DIGEST.test(said)) return { digest: said };
|
|
6176
|
+
const body = await ask("GET", authorization);
|
|
6177
|
+
if (body.ok) {
|
|
6178
|
+
const header = body.headers.get("docker-content-digest");
|
|
6179
|
+
if (header && DIGEST.test(header)) return { digest: header };
|
|
6180
|
+
const bytes = Buffer.from(await body.arrayBuffer());
|
|
6181
|
+
return { digest: `sha256:${createHash("sha256").update(bytes).digest("hex")}` };
|
|
6182
|
+
}
|
|
6183
|
+
response = body;
|
|
6184
|
+
}
|
|
6185
|
+
if (response.status === 401 || response.status === 403) return { error: `${host} refused ${repository} (${response.status}): it doesn't exist, or it's private and needs a registry login` };
|
|
6186
|
+
if (response.status === 404) return { error: `${ref} isn't in ${host}` };
|
|
6187
|
+
return { error: `${host} answered ${response.status} for ${ref}` };
|
|
6188
|
+
} catch (cause) {
|
|
6189
|
+
if (options.signal?.aborted) throw cause;
|
|
6190
|
+
return { error: `couldn't reach ${host}: ${cause instanceof Error ? cause.cause instanceof Error ? cause.cause.message : cause.message : String(cause)}` };
|
|
6191
|
+
}
|
|
6192
|
+
}
|
|
6193
|
+
async function bearerToken(params, repository, login, fetchFn, signal) {
|
|
6194
|
+
const url = new URL(params.realm);
|
|
6195
|
+
const protectedRealm = url.protocol === "https:" || loopback(url.host);
|
|
6196
|
+
if (params.service) url.searchParams.set("service", params.service);
|
|
6197
|
+
url.searchParams.set("scope", params.scope ?? `repository:${repository}:pull`);
|
|
6198
|
+
const response = await fetchFn(url, {
|
|
6199
|
+
headers: login && "username" in login && protectedRealm ? { authorization: basic(login) } : {},
|
|
6200
|
+
signal
|
|
6201
|
+
});
|
|
6202
|
+
if (!response.ok) return { error: `${response.status}` };
|
|
6203
|
+
const body = await response.json().catch(() => null);
|
|
6204
|
+
const token = body?.token ?? body?.access_token;
|
|
6205
|
+
return typeof token === "string" && token ? { token } : { error: "no token in the answer" };
|
|
6206
|
+
}
|
|
5555
6207
|
// ../sandbox-docker/src/shells.ts
|
|
5556
6208
|
const SYSTEM_PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
|
|
5557
6209
|
const EXEC_UMASK = "umask 022";
|
|
@@ -5565,7 +6217,7 @@ const envStream = (env) => Object.entries(env).map(([k, v]) => `${k}=${v}\0`).jo
|
|
|
5565
6217
|
*/
|
|
5566
6218
|
const READER = `${EXEC_UMASK}; while IFS= read -r -d "" kv; do export "$kv"; done; cd -- "$1" || exit 1; exec /usr/bin/perl -e 'setpgrp(0, 0); exec @ARGV' bash -c "$2" </dev/null`;
|
|
5567
6219
|
/**
|
|
5568
|
-
* The Linux profile: the login user has passwordless `sudo
|
|
6220
|
+
* The Linux profile: the login user has passwordless `sudo` or is root, the agent's commands run as
|
|
5569
6221
|
* {@link SANDBOX_USER} with only `user`'s variables, and reeval's own run as root in
|
|
5570
6222
|
* {@link SANDBOX_STATE}. Each command carries a marker in its environment, which `kill` finds in
|
|
5571
6223
|
* `/proc`. `remote` is the host argv that runs one command line as the login user (`ssh`).
|
|
@@ -5576,9 +6228,11 @@ function linuxShell(o) {
|
|
|
5576
6228
|
const seenHome = o.user.HOME;
|
|
5577
6229
|
const bind = o.layout && seenHome && o.layout.home !== seenHome ? o.layout.home : void 0;
|
|
5578
6230
|
const marker = (exec) => `${o.id}-${exec}`;
|
|
5579
|
-
const
|
|
6231
|
+
const sudo = o.loginRoot ? "" : "sudo -n -- ";
|
|
6232
|
+
const setpriv = `setpriv --reuid=${sandboxUser} --regid=${sandboxUser} --init-groups --`;
|
|
6233
|
+
const asSandboxUser = (command) => bind ? `${sudo}unshare --mount --propagation private /bin/sh -c ${shellQuote(`mount --bind ${shellQuote(bind)} ${shellQuote(seenHome ?? "")} && exec ${setpriv} ${command}`)}` : o.loginRoot ? `${setpriv} env -i HOME=${shellQuote(seenHome ?? "/")} PATH=${SYSTEM_PATH} ${command}` : `sudo -n -H -u ${sandboxUser} -- ${command}`;
|
|
5580
6234
|
const asUser = (cwd, command) => asSandboxUser(`env -i ${Object.entries(o.user).map(([k, v]) => shellQuote(`${k}=${v}`)).join(" ")} bash -c ${shellQuote(READER)} bash ${shellQuote(cwd)} ${shellQuote(command)}`);
|
|
5581
|
-
const asRoot = (command, mark) =>
|
|
6235
|
+
const asRoot = (command, mark) => `${sudo}env -i PATH=${SYSTEM_PATH} HOME=/root${mark ? ` ${EXEC_MARKER}=${mark}` : ""} /bin/sh -c ${shellQuote(`cd ${stateDir} || exit 1; ${EXEC_UMASK}; ${command}`)}`;
|
|
5582
6236
|
/**
|
|
5583
6237
|
* Killing the host's program leaves the command running on the machine, so kill what has its
|
|
5584
6238
|
* marker, and the process group of each: a process that cleared its environment (`env -i`)
|
|
@@ -5926,6 +6580,11 @@ const homeFiles = (label) => {
|
|
|
5926
6580
|
};
|
|
5927
6581
|
};
|
|
5928
6582
|
/**
|
|
6583
|
+
* Root commands that keep the sandbox user's home as the machine's copy for `label`, which a slot
|
|
6584
|
+
* unpacks into its own home rather than installing: what an image with the install baked in runs.
|
|
6585
|
+
*/
|
|
6586
|
+
const keepHomeCopy = (label) => `mkdir -p ${shellQuote(HOMES)} && chmod 700 ${shellQuote(HOMES)} && tar -C ${shellQuote(posix.dirname(SANDBOX_HOME))} -cf ${shellQuote(homeFiles(label).tar)} ${shellQuote(posix.basename(SANDBOX_HOME))}`;
|
|
6587
|
+
/**
|
|
5929
6588
|
* Root commands that empty a slot's home back to the skeleton. The directory itself stays: on a
|
|
5930
6589
|
* shared machine, slot 0's is where the other slots' commands see their own homes.
|
|
5931
6590
|
*/
|
|
@@ -5980,7 +6639,7 @@ function slotHome(layout, label) {
|
|
|
5980
6639
|
}
|
|
5981
6640
|
/**
|
|
5982
6641
|
* Sets up a Linux VM reached over SSH for a harness session: the login user has passwordless
|
|
5983
|
-
* `sudo
|
|
6642
|
+
* `sudo` or is root ({@link SshTarget.loginRoot}), and the agent, setup steps and checks run as {@link SANDBOX_USER}, a user made here with
|
|
5984
6643
|
* no `sudo` and none of the login user's groups or variables. Ports are reached through the
|
|
5985
6644
|
* egress gateway's tunnel. When setting up fails, the connection is closed.
|
|
5986
6645
|
*/
|
|
@@ -6057,7 +6716,8 @@ async function connectSsh(options) {
|
|
|
6057
6716
|
`mkdir -p ${layout.state} && chown 0:0 ${layout.state} && chmod 700 ${layout.state}`,
|
|
6058
6717
|
...options.prepare ? [options.prepare] : []
|
|
6059
6718
|
].join(" && ");
|
|
6060
|
-
const
|
|
6719
|
+
const sudo = asRootPrefix(target);
|
|
6720
|
+
const asRoot = options.layout ? `${sudo}flock ${SETUP_LOCK} /bin/sh -c ${shellQuote(setup)} sh "$PATH"` : `${sudo}/bin/sh -c ${shellQuote(setup)} sh "$PATH"`;
|
|
6061
6721
|
const deadline = Date.now() + (options.connectTimeoutMs ?? 6e4);
|
|
6062
6722
|
for (let wait = 500;; wait = Math.min(wait * 2, 5e3)) {
|
|
6063
6723
|
const made = await ssh(asRoot).catch(fail);
|
|
@@ -6087,7 +6747,8 @@ async function connectSsh(options) {
|
|
|
6087
6747
|
id: `${target.hostKeyAlias}-${layout.user}`,
|
|
6088
6748
|
user: baseEnv,
|
|
6089
6749
|
signal,
|
|
6090
|
-
layout
|
|
6750
|
+
layout,
|
|
6751
|
+
...target.loginRoot && { loginRoot: true }
|
|
6091
6752
|
});
|
|
6092
6753
|
return {
|
|
6093
6754
|
root: sshTransport(target),
|
|
@@ -6096,7 +6757,7 @@ async function connectSsh(options) {
|
|
|
6096
6757
|
restored: false,
|
|
6097
6758
|
waitedMs: 0
|
|
6098
6759
|
};
|
|
6099
|
-
const [bin = "ssh", ...args] = sshArgv(target,
|
|
6760
|
+
const [bin = "ssh", ...args] = sshArgv(target, `${sudo}/bin/sh -c ${shellQuote(`${EXEC_UMASK}\n${slotHome(layout, options.home)}`)}`);
|
|
6100
6761
|
const startedAt = Date.now();
|
|
6101
6762
|
const child = spawn(bin, args, { stdio: [
|
|
6102
6763
|
"pipe",
|
|
@@ -6152,7 +6813,7 @@ async function connectSsh(options) {
|
|
|
6152
6813
|
`mv ${shellQuote(f.tar)}.$$ ${shellQuote(f.tar)}`
|
|
6153
6814
|
].join(" && ");
|
|
6154
6815
|
try {
|
|
6155
|
-
const r = await ssh(
|
|
6816
|
+
const r = await ssh(`${sudo}/bin/sh -c ${shellQuote(command)}`);
|
|
6156
6817
|
if (r.exitCode !== 0) throw new Error(`Couldn't keep ${layout.user}'s home in ${options.description}: ${r.stderr.trim().slice(-500)}`);
|
|
6157
6818
|
} finally {
|
|
6158
6819
|
await release();
|
|
@@ -6184,6 +6845,6 @@ async function connectSsh(options) {
|
|
|
6184
6845
|
})
|
|
6185
6846
|
};
|
|
6186
6847
|
}
|
|
6187
|
-
export {
|
|
6848
|
+
export { PRIVILEGED_CAPABILITIES as $, hostCommand as $t, dockerfileBases as A, adapterVersion as At, isLocalKey as B, imageInfo as Bt, bakedHarnessName as C, HARNESS_PACKAGES as Ct, buildInstallLayer as D, SANDBOX_STATE as Dt, buildImage as E, SANDBOX_ROOT as Et, harnessImageFor as F, docker as Ft, pruneImages as G, controlOptions as Gt, pluginBuildDir as H, isRegistryDigest as Ht, imageKey as I, dockerAvailable as It, sourceTreeHash as J, sshArgv as Jt, reevalImageKey as K, controlPathFits as Kt, installLayerLines as L, dockerCapacity as Lt, dockerfileKey as M, imageFor as Mt, dockerfileTag as N, isBakedHarness as Nt, buildPluginLayer as O, SANDBOX_USER as Ot, fromImageKey as P, slotLayout as Pt, EgressUnavailableError as Q, traceDocker as Qt, installLayerTag as R, dockerOk as Rt, bakedAdapter as S, DEFAULT_IMAGE as St, buildDockerfile as T, SANDBOX_HOME as Tt, pluginBuildKey as U, removeContainerDetached as Ut, localKey as V, imageTags as Vt, pluginLayerTag as W, SSH_OPTIONS as Wt, usesReevalBase as X, OPAQUE_OUTPUT as Xt, toolchainDockerfile as Y, sshTransport as Yt, DEFAULT_LIMITS as Z, onDockerCommand as Zt, PLUGIN_BUILDS_DIR as _, ENGINES as _n, hostAllowed as _t, darwinShell as a, readTree as an, PROXY_PORT as at, bakeHarness as b, isRemoteEngine as bn, BASE_IMAGE as bt, enginePlatform as c, contextFiles as cn, usageReader as ct, registryProblem as d, RETRY_DELAYS as dn, matches as dt, isSshFailure as en, ROOT_CAPABILITIES as et, registryRef as f, causeLine as fn, onEndpoint as ft, PLATFORM as g, retryTransient as gn, defaultAllowedHosts as gt, NODE_IMAGE as h, parseBuildOutput as hn, PACKAGE_HOSTS as ht, transportSession as i, readTar as in, CA_PATH as it, dockerfileFinalBase as j, harnessLabel as jt, contextHash as k, WORKSPACE_DIR as kt, pullLayer as l, dockerignoreMatcher as ln, placeholder as lt, DOCKER_CONTEXT as m, isTransient as mn, HARNESS_HOSTS as mt, keepHomeCopy as n, spawnEngine as nn, dockerSandboxProvider as nt, parseImageRef as o, safeTarPath as on, startGateway as ot, MCP_TIMER as p, failureCause as pn, DOCKER_EGRESS as pt, resolveFrom as q, privateDir as qt, resetSlot as r, extractTar as rn, pathOperations as rt, registryDigest as s, writeTar as sn, MODEL_FIELD as st, connectSsh as t, remoteBuild as tn, createDockerSession as tt, pushLayer as u, ImageBuildError as un, applyTransformations as ut, PNPM_VERSION as v, dockerSeccompFile as vn, requestFacts as vt, bakedRecipe as w, LABEL$1 as wt, bakeKey as x, normalizeImageId as xn, BRIDGE_PORT as xt, REEVAL_BASE_ARG as y, engineSpec as yn, BAKED_HARNESSES as yt, installScript as z, dockerState as zt };
|
|
6188
6849
|
|
|
6189
|
-
//# sourceMappingURL=src-
|
|
6850
|
+
//# sourceMappingURL=src-OC89dAjO.js.map
|