@outerlayer/cli 0.34.0-next.20261025133402 → 0.34.0-next.20261025210240

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/{agent-setup-UXUWLV7O.js → agent-setup-FNDKCPUP.js} +8 -9
  2. package/dist/{bridge-OWCSVCXL.js → bridge-YJBB4YA3.js} +2 -3
  3. package/dist/build-B4OKU4MV.js +16 -0
  4. package/dist/{build-disk-5ZQHYBO3.js → build-disk-ZL46AEN3.js} +6 -8
  5. package/dist/build-info.json +1 -1
  6. package/dist/{builder-54GLXGFV.js → builder-XFPWE74N.js} +5 -7
  7. package/dist/{check-4TQZZOIQ.js → check-QULEN437.js} +43 -43
  8. package/dist/{chunk-CXQCBAKO.js → chunk-25GRRBTH.js} +1 -1
  9. package/dist/{chunk-4XYC2663.js → chunk-2D6CKNR7.js} +8 -4
  10. package/dist/{chunk-IHY457PB.js → chunk-2ILU7UAU.js} +1 -1
  11. package/dist/{chunk-JEOPIRUR.js → chunk-3EJBI5JW.js} +3 -3
  12. package/dist/{chunk-TVGLNHEB.js → chunk-3N77LUQI.js} +1 -1
  13. package/dist/{chunk-ES4ULBAL.js → chunk-4UPET3R7.js} +7 -3
  14. package/dist/{chunk-MPDLZCXM.js → chunk-5AFPP3GZ.js} +238 -14
  15. package/dist/{chunk-HAEDLXHA.js → chunk-63IVRRIO.js} +3 -3
  16. package/dist/{chunk-BTG5NZHN.js → chunk-6OLVVAOK.js} +4 -4
  17. package/dist/{chunk-3M6UYJSR.js → chunk-AVPLEFQR.js} +3 -3
  18. package/dist/{chunk-TVOZOOIW.js → chunk-BHSSGVOY.js} +3 -3
  19. package/dist/{chunk-QOUR4CQ7.js → chunk-CAQCDYKF.js} +2 -2
  20. package/dist/{chunk-SMMNU65K.js → chunk-DNZYXEMY.js} +13 -12
  21. package/dist/{chunk-LMICI7AY.js → chunk-EGVHFHY4.js} +3 -3
  22. package/dist/{chunk-RNVBSRZZ.js → chunk-FD5ASWTG.js} +18 -19
  23. package/dist/{chunk-NW5PDZYA.js → chunk-FDJPDZSR.js} +1 -1
  24. package/dist/{chunk-XA6PGME5.js → chunk-FVCHHSHB.js} +3 -3
  25. package/dist/{chunk-YOBQIXX6.js → chunk-G4W4B33M.js} +182 -3
  26. package/dist/{chunk-T7N3BAOO.js → chunk-GC5PVMIJ.js} +85 -17
  27. package/dist/{chunk-CCISO7EQ.js → chunk-HHFZXOBC.js} +12 -14
  28. package/dist/{chunk-AABYHGVO.js → chunk-INOUUSYI.js} +29 -9
  29. package/dist/{chunk-KDLQGTN6.js → chunk-JBCOUY4M.js} +2 -2
  30. package/dist/{chunk-POGPX7LI.js → chunk-JQSZTQSK.js} +24 -30
  31. package/dist/{chunk-JZD2NTRH.js → chunk-K2UAQWYO.js} +3 -3
  32. package/dist/{chunk-UC2DKBMS.js → chunk-KM2HLQE3.js} +2 -2
  33. package/dist/{chunk-XLJLR7EK.js → chunk-MOI2KDLH.js} +1 -1
  34. package/dist/{chunk-BUF6DSSM.js → chunk-NW26E4YU.js} +3 -3
  35. package/dist/{chunk-ZV2JJPDS.js → chunk-O4Z2MNNL.js} +6 -6
  36. package/dist/{chunk-2RBIW2PD.js → chunk-OGPEHSNW.js} +1 -1
  37. package/dist/{chunk-EZ7L5IZU.js → chunk-OQLF3MQQ.js} +3 -4
  38. package/dist/{chunk-J246WRLZ.js → chunk-OS7DJOQJ.js} +1 -1
  39. package/dist/{chunk-O5G6VQGZ.js → chunk-PFHTT4PP.js} +5 -5
  40. package/dist/{chunk-N7LAEN3T.js → chunk-PXGU3GKY.js} +1 -1
  41. package/dist/{chunk-WIK5KUGK.js → chunk-QANM5COC.js} +6 -6
  42. package/dist/{chunk-PSXVAOEB.js → chunk-QQP3S5FU.js} +3 -3
  43. package/dist/{chunk-AVLLJW5D.js → chunk-RFVIQLNB.js} +5 -5
  44. package/dist/{chunk-Z76GVJGQ.js → chunk-RHV5SRI2.js} +3 -3
  45. package/dist/{chunk-75KZUBHD.js → chunk-SI6WDF3U.js} +1 -1
  46. package/dist/chunk-SUOZYOWO.js +51 -0
  47. package/dist/{chunk-36T6W5RA.js → chunk-SYVRBBLW.js} +1 -1
  48. package/dist/{chunk-E34FRRSW.js → chunk-TBKV4L2W.js} +4 -4
  49. package/dist/{chunk-56ZHWIR2.js → chunk-TFPNPS4Q.js} +1 -1
  50. package/dist/{chunk-DUPM5LVJ.js → chunk-UMYYYF7B.js} +1 -1
  51. package/dist/{chunk-IW6Z337K.js → chunk-UN3SQTVL.js} +7 -7
  52. package/dist/{chunk-3NFZN7H6.js → chunk-UO4FQAOX.js} +16 -12
  53. package/dist/{chunk-ZWLEUSJW.js → chunk-VJ34F55N.js} +55 -39
  54. package/dist/{chunk-3RAAYBSG.js → chunk-YHKU2NOZ.js} +1 -1
  55. package/dist/{chunk-ENFBYN4A.js → chunk-YNMVVQOQ.js} +1 -1
  56. package/dist/{claude-launcher-JEB5BN7Q.js → claude-launcher-OQZNW7XJ.js} +1 -1
  57. package/dist/{cli-DY3EGPUB.js → cli-VHQPX2B7.js} +123 -117
  58. package/dist/{command-ZAXYAZCI.js → command-KFYK3WEF.js} +196 -60
  59. package/dist/{config-UN3X6AP2.js → config-QASNKYM6.js} +7 -9
  60. package/dist/{connect-cmd-TWM4FEKD.js → connect-cmd-MEDWMW3L.js} +8 -9
  61. package/dist/{container-start-JUNBJ7MU.js → container-start-2DHCWV73.js} +34 -36
  62. package/dist/{context-show-cmd-K5LRMDEO.js → context-show-cmd-VSFCG663.js} +9 -10
  63. package/dist/{control-plane-launch-LHOV2FPA.js → control-plane-launch-XBGHM7DB.js} +5 -6
  64. package/dist/{docker-YZKRM7IP.js → docker-TAC6G4VU.js} +5 -7
  65. package/dist/{doctor-YOAF7QPL.js → doctor-LK6E3XOW.js} +66 -41
  66. package/dist/{emit-artifact-cmd-SCF2FKKS.js → emit-artifact-cmd-L4REOPWX.js} +13 -14
  67. package/dist/{emit-cmd-7NMNKDK7.js → emit-cmd-7TU3JBJ2.js} +2 -2
  68. package/dist/{emit-criteria-cmd-B6CKUWTW.js → emit-criteria-cmd-QVFOQARC.js} +10 -11
  69. package/dist/{emit-demo-cmd-BNWRETMJ.js → emit-demo-cmd-L4B6OOTV.js} +15 -16
  70. package/dist/{emit-finding-cmd-TPSHNZNE.js → emit-finding-cmd-YXFCIWMU.js} +10 -11
  71. package/dist/{emit-result-cmd-J5DXIC2Q.js → emit-result-cmd-NI4LCTUM.js} +12 -13
  72. package/dist/{emit-step-cmd-NPH46KAO.js → emit-step-cmd-HWAUCZZB.js} +10 -11
  73. package/dist/{exec-client-ANW4KGMN.js → exec-client-QB4OZRGM.js} +3 -4
  74. package/dist/find-unit-4UR647S4.js +18 -0
  75. package/dist/{findings-cmd-4FJDCFL3.js → findings-cmd-O2IBO25E.js} +10 -11
  76. package/dist/{fleet-readiness-OK6534T6.js → fleet-readiness-NJYTQYTA.js} +5 -6
  77. package/dist/{governing-source-GNKTNM32.js → governing-source-JCI7VDQ6.js} +12 -13
  78. package/dist/{guest-init-C6M7YT3U.js → guest-init-IF5LXGUL.js} +4 -5
  79. package/dist/{hook-fast-LVTJWAG3.js → hook-fast-GPUL7T77.js} +1 -1
  80. package/dist/host-key-5RU322O3.js +9 -0
  81. package/dist/{image-tag-53DJPMSZ.js → image-tag-SEMBVB5D.js} +3 -4
  82. package/dist/index.js +4 -4
  83. package/dist/{init-RAJKTSPJ.js → init-2CEULE3F.js} +25 -27
  84. package/dist/{init-JGYMAOD5.js → init-FAIF7KOK.js} +25 -27
  85. package/dist/{init-cmd-IB3KTYCV.js → init-cmd-HZUUMO45.js} +13 -14
  86. package/dist/{init-update-VPWSWDY7.js → init-update-TTMFFNMB.js} +12 -13
  87. package/dist/{install-cmd-NP7GULCD.js → install-cmd-5H6M2KJ7.js} +5 -6
  88. package/dist/{logs-V6AES5FE.js → logs-6CMB3DO6.js} +2 -3
  89. package/dist/{loop-ZGDZMVFN.js → loop-7U7MVICV.js} +40 -42
  90. package/dist/{machine-LJ3VMGS3.js → machine-S3JHOX4V.js} +25 -27
  91. package/dist/{mcp-serve-cmd-DHGCAMJS.js → mcp-serve-cmd-MWGIN6YL.js} +4 -5
  92. package/dist/{paths-DMKAJVA5.js → paths-T2DEBI62.js} +2 -3
  93. package/dist/pending-ERXWVLLG.js +9 -0
  94. package/dist/{pidfile-XCTXBGA3.js → pidfile-EAD2OEM7.js} +3 -4
  95. package/dist/{record-RQLGRYWG.js → record-IMXQNHPB.js} +3 -4
  96. package/dist/{runner-env-AUG2OIP4.js → runner-env-BJPUHAKZ.js} +9 -11
  97. package/dist/{runner-identity-BQA4SBU6.js → runner-identity-ZCPPC2BJ.js} +5 -7
  98. package/dist/{runner-key-ZIF7M7YN.js → runner-key-CYSUYKSX.js} +25 -27
  99. package/dist/{session-sender-VQ4LHJ5K.js → session-sender-5T7BXPKC.js} +13 -14
  100. package/dist/{spec-cmd-PXM4FJ2O.js → spec-cmd-4ABYAFNZ.js} +11 -12
  101. package/dist/{status-27EFD2WE.js → status-2AP7J2L7.js} +32 -34
  102. package/dist/{sync-cmd-VAV7TR2A.js → sync-cmd-34CGNA6T.js} +12 -13
  103. package/dist/{update-steps-7YLAFW3E.js → update-steps-JQOCCDWO.js} +33 -35
  104. package/dist/{watch-42XJSTTB.js → watch-6HU7LCUY.js} +12 -13
  105. package/dist/{work-claim-cmd-HSG4OHFI.js → work-claim-cmd-5QKLHSCR.js} +16 -18
  106. package/dist/{work-cmd-KCBU3RSD.js → work-cmd-3MKUIE2C.js} +10 -11
  107. package/dist/{work-comment-cmd-QIP2OUJC.js → work-comment-cmd-ESC3DSHI.js} +11 -12
  108. package/dist/{work-demo-cmd-6IKAG6ES.js → work-demo-cmd-7S23DGYO.js} +10 -11
  109. package/dist/{work-logs-cmd-RMKJA4AI.js → work-logs-cmd-46UPNN7Q.js} +10 -11
  110. package/dist/{work-open-pr-cmd-IAVLUUWW.js → work-open-pr-cmd-JNGTGLIP.js} +11 -12
  111. package/dist/{work-pr-cmd-3U7SVQII.js → work-pr-cmd-2J2LKETD.js} +10 -11
  112. package/dist/{work-proofs-cmd-6ZY6ZNNE.js → work-proofs-cmd-HRWTHYSS.js} +11 -12
  113. package/dist/{work-proofs-record-54GBEUJP.js → work-proofs-record-6OKAT3IC.js} +18 -19
  114. package/dist/{work-stop-cmd-LH5XY4YL.js → work-stop-cmd-Y22XIVQ6.js} +10 -11
  115. package/package.json +1 -1
  116. package/dist/build-4HFDZTUX.js +0 -14
  117. package/dist/chunk-3Z3MPR55.js +0 -226
  118. package/dist/chunk-HACGUL52.js +0 -183
  119. package/dist/host-key-DUGGHAGR.js +0 -10
  120. package/dist/inspect-DNLXTXLA.js +0 -6
  121. package/dist/install-QJWJFIWB.js +0 -19
  122. package/dist/pending-B55JZFOV.js +0 -10
  123. package/dist/{chunk-2AIOOU3A.js → chunk-KPHRRCUY.js} +1 -1
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { TUNNEL_PORT, BRIDGE_ADDRESS, BRIDGE_CIDR } from './chunk-75KZUBHD.js';
3
+ import { TUNNEL_PORT, BRIDGE_ADDRESS, BRIDGE_CIDR } from './chunk-SI6WDF3U.js';
4
+ import { EXEC_PORT } from './chunk-OGPEHSNW.js';
4
5
  import { startTimeOf } from './chunk-JBJTC3UU.js';
5
- import { EXEC_PORT } from './chunk-2RBIW2PD.js';
6
- import { RELAY_PORT } from './chunk-YOBQIXX6.js';
6
+ import { RELAY_PORT } from './chunk-G4W4B33M.js';
7
7
  import { spawn, spawnSync } from 'child_process';
8
8
  import { symlinkSync, lstatSync, writeFileSync, chmodSync, mkdirSync, existsSync } from 'fs';
9
9
 
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { WorkCommandError, resolveCredentials, getJson } from './chunk-IW6Z337K.js';
3
+ import { WorkCommandError, resolveCredentials, getJson } from './chunk-UN3SQTVL.js';
4
+ import { C } from './chunk-ANPNT6PM.js';
4
5
  import { sanitizeTerminal } from './chunk-MECW77XP.js';
6
+ import { defaultFetch } from './chunk-3N77LUQI.js';
5
7
  import { resolveRepoIdentity } from './chunk-AJYZNISW.js';
6
- import { C } from './chunk-ANPNT6PM.js';
7
- import { defaultFetch } from './chunk-TVGLNHEB.js';
8
8
  import { parseWorkItemEnv } from './chunk-T2Q7ISPE.js';
9
9
  import { parseTrackerNumber, trackerNumberError } from './chunk-WZBHBH3J.js';
10
10
  import { inferArtifactKind, mediaTypeForArtifactPath, WORK_ITEM_COMMENT_MAX_BODY_LENGTH } from './chunk-EOTMDIYC.js';
@@ -130,7 +130,7 @@ async function runWorkProofs(opts) {
130
130
  async function runWorkProofsCommand(opts) {
131
131
  try {
132
132
  if (opts.record) {
133
- const { runWorkProofsRecord } = await import('./work-proofs-record-54GBEUJP.js');
133
+ const { runWorkProofsRecord } = await import('./work-proofs-record-6OKAT3IC.js');
134
134
  const result2 = await runWorkProofsRecord(opts);
135
135
  process.exitCode = result2.exitCode;
136
136
  return;
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { fetchFactories, selectFactory, saveFactoryConnection, autoConnectedLine } from './chunk-XA6PGME5.js';
4
- import { resolveRepoIdentity } from './chunk-AJYZNISW.js';
5
- import { resolveGatewayCredentials } from './chunk-TVGLNHEB.js';
3
+ import { fetchFactories, selectFactory, saveFactoryConnection, autoConnectedLine } from './chunk-FVCHHSHB.js';
4
+ import { resolveGatewayCredentials } from './chunk-3N77LUQI.js';
6
5
  import { readCloudConfig } from './chunk-PJDQPF5N.js';
7
6
  import { findGitDirs, readRepoConnection } from './chunk-BJ3KTMDH.js';
7
+ import { resolveRepoIdentity } from './chunk-AJYZNISW.js';
8
8
  import { cliInvocation } from './chunk-CRB3POP4.js';
9
9
  import { homeFromEnv } from './chunk-VNVZDWO3.js';
10
10
 
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { resolveCredentials, postJson, getJson } from './chunk-IW6Z337K.js';
3
+ import { resolveCredentials, postJson, getJson } from './chunk-UN3SQTVL.js';
4
4
  import { detectActiveSession } from './chunk-IP7BIBXJ.js';
5
+ import { C } from './chunk-ANPNT6PM.js';
5
6
  import { sanitizeTerminal } from './chunk-MECW77XP.js';
7
+ import { defaultFetch } from './chunk-3N77LUQI.js';
6
8
  import { resolveRepoIdentity } from './chunk-AJYZNISW.js';
7
- import { C } from './chunk-ANPNT6PM.js';
8
- import { defaultFetch } from './chunk-TVGLNHEB.js';
9
9
  import { parseTrackerNumber, trackerNumberError } from './chunk-WZBHBH3J.js';
10
10
  import { homeFromEnv } from './chunk-VNVZDWO3.js';
11
11
  import { randomUUID } from 'crypto';
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
3
  import { removeRetiredSkills } from './chunk-JWNH4ZTF.js';
4
- import { defaultFetch, resolveGatewayCredentials } from './chunk-TVGLNHEB.js';
5
- import { withTokenHeader } from './chunk-YOBQIXX6.js';
4
+ import { defaultFetch, resolveGatewayCredentials } from './chunk-3N77LUQI.js';
6
5
  import { appendContextProvenance } from './chunk-ZJSNLVCE.js';
7
6
  import { loadMaintainedFiles, writeMaintainedFiles } from './chunk-ZQSANKS4.js';
8
7
  import { cliInvocation } from './chunk-CRB3POP4.js';
9
8
  import { writeDegraded, writeSourceCache, SOURCE_CACHE_TTL_RETRY_MS, writeContextManifest, SOURCE_CACHE_TTL_SUCCESS_MS, readSourceCache, isSourceCacheFresh, clearDegraded } from './chunk-YQR6E6OV.js';
10
9
  import { normalizeRepoName, parseOuterlayerConfig, classifyTree, emitTree } from './chunk-FGXT5OXS.js';
11
10
  import { homeFromEnv } from './chunk-VNVZDWO3.js';
11
+ import { withTokenHeader } from './chunk-G4W4B33M.js';
12
12
  import { execFileSync } from 'child_process';
13
13
  import { existsSync, mkdirSync, writeFileSync, chmodSync, lstatSync, readFileSync, copyFileSync } from 'fs';
14
14
  import { isAbsolute, join, dirname } from 'path';
@@ -1,12 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { placeholderQueues, placeholderProblem } from './chunk-POGPX7LI.js';
4
- import { checkFit } from './chunk-AABYHGVO.js';
5
- import { builtinKind, imageBuildOf } from './chunk-4XYC2663.js';
6
- import { realBuildDiskProbe, checkDiskFit, DEFAULT_CACHE_DISK, DEFAULT_BUILD_DISK } from './chunk-UC2DKBMS.js';
7
- import { builderDiskPinned } from './chunk-ES4ULBAL.js';
8
- import { FORWARDED_CLAUDE_CREDENTIAL_VARIABLES, claudeCredentialVariablesSet, claudeCredential, claudeEnvPath } from './chunk-YOBQIXX6.js';
9
- import { parseRunnerEnv } from './chunk-HACGUL52.js';
3
+ import { placeholderQueues, placeholderProblem } from './chunk-JQSZTQSK.js';
4
+ import { checkFit } from './chunk-INOUUSYI.js';
5
+ import { builtinKind, imageBuildOf, keepsHostBuilder } from './chunk-2D6CKNR7.js';
6
+ import { realBuildDiskProbe, checkDiskFit, DEFAULT_CACHE_DISK, DEFAULT_BUILD_DISK } from './chunk-KM2HLQE3.js';
7
+ import { builderDiskPinned } from './chunk-4UPET3R7.js';
8
+ import { FORWARDED_CLAUDE_CREDENTIAL_VARIABLES, claudeCredentialVariablesSet, claudeCredential, claudeEnvPath, parseRunnerEnv, BUILD_SLICE_MEMORY_ENV } from './chunk-G4W4B33M.js';
10
9
  import { closeSync, openSync, constants, readFileSync } from 'fs';
11
10
  import { join, dirname } from 'path';
12
11
  import { totalmem } from 'os';
@@ -26,6 +25,10 @@ function realBlockedProbes() {
26
25
  return { env: process.env, kvm: openKvm, totalMemoryBytes: totalmem, imageBuilder: "unknown", buildDisk: sharedBuildDisk };
27
26
  }
28
27
  var DEFAULT_BUILD_MEMORY = "8g";
28
+ function sliceMemoryOf(env) {
29
+ const bytes = Number(env[BUILD_SLICE_MEMORY_ENV]);
30
+ return Number.isSafeInteger(bytes) && bytes > 0 ? bytes : void 0;
31
+ }
29
32
  function managedProblems(facts) {
30
33
  const problems = [];
31
34
  if (builtinKind(facts.provision) !== "vm") {
@@ -93,9 +96,6 @@ function managedFactsOf(config, probes) {
93
96
  builderDiskPinned: probes.builderDiskPinned ?? builderDiskPinned()
94
97
  };
95
98
  }
96
- function keepsHostBuilder(config, builderDiskIsPinned) {
97
- return !(builtinKind(config.hooks.provision) === "vm" && imageBuildOf(config) === "vm" && (builderDiskIsPinned ?? builderDiskPinned()));
98
- }
99
99
  function checkBlockedWithSlots(config, probes) {
100
100
  const blocked = (reason) => ({ blocked: { reason } });
101
101
  let slots;
@@ -110,7 +110,8 @@ function checkBlockedWithSlots(config, probes) {
110
110
  const fit = checkFit({
111
111
  concurrency: config.concurrency,
112
112
  buildMemory: config.build?.memory ?? DEFAULT_BUILD_MEMORY,
113
- usableBytes: probes.totalMemoryBytes()
113
+ usableBytes: probes.totalMemoryBytes(),
114
+ sliceBytes: sliceMemoryOf(probes.env)
114
115
  });
115
116
  if (!fit.fits) {
116
117
  const advice = probes.inImage === true ? "Set OUTERLAYER_BUILD_MEMORY or OUTERLAYER_CONCURRENCY in the env file and recreate the container, or give the machine more memory" : `Lower runner.concurrency or runner.build.memory in ${config.configPath}`;
@@ -156,4 +157,4 @@ function checkBlockedWithSlots(config, probes) {
156
157
  return { slots };
157
158
  }
158
159
 
159
- export { checkBlockedWithSlots, keepsHostBuilder, managedFactsOf, managedProblems, realBlockedProbes };
160
+ export { checkBlockedWithSlots, managedFactsOf, managedProblems, realBlockedProbes };
@@ -2,11 +2,11 @@
2
2
  import { createRequire } from 'node:module';
3
3
  import { launchRefusalForSession } from './chunk-ESVW4MJY.js';
4
4
  import { detectActiveSession } from './chunk-IP7BIBXJ.js';
5
- import { autoConnect } from './chunk-3M6UYJSR.js';
5
+ import { autoConnect } from './chunk-AVPLEFQR.js';
6
+ import { C } from './chunk-ANPNT6PM.js';
6
7
  import { acquireSpoolLockAt } from './chunk-MECW77XP.js';
8
+ import { resolveGatewayCredentials, defaultFetch, unauthorizedMessage } from './chunk-3N77LUQI.js';
7
9
  import { resolveRepoIdentity } from './chunk-AJYZNISW.js';
8
- import { C } from './chunk-ANPNT6PM.js';
9
- import { resolveGatewayCredentials, defaultFetch, unauthorizedMessage } from './chunk-TVGLNHEB.js';
10
10
  import { launchedItemForSession } from './chunk-T2Q7ISPE.js';
11
11
  import { parseTrackerNumber, trackerNumberError } from './chunk-WZBHBH3J.js';
12
12
  import { StepNameSchema, StepBodySchema } from './chunk-EOTMDIYC.js';
@@ -1,35 +1,34 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
3
  import { readsJobState, READ_JOB_STATE_FORMATS, jobStateFormatOf } from './chunk-ZVB57WI6.js';
4
- import { DOCKERD_LOG, HELPER_PATH, HELPER_RECORD } from './chunk-HAEDLXHA.js';
5
- import { writeDockerClientConfig } from './chunk-75KZUBHD.js';
4
+ import { DOCKERD_LOG, HELPER_PATH, HELPER_RECORD } from './chunk-63IVRRIO.js';
6
5
  import { zodProblem } from './chunk-I3LTIAOR.js';
7
- import { senderPidfile } from './chunk-KDLQGTN6.js';
8
- import { installScrubContext } from './chunk-WIK5KUGK.js';
9
- import { ADDED_USER, shellQuote, GH_CONFIG_YML, ghHostsYml, hasClaudeCredential, AssetError, obtainImage, ensureRootfs, makeBuildsDirPrivate, gitRemoteFor, startServicesFor, createLeaseChannel, createBuildDisk, machineConfig, startJailedInto, resolveAgentUser, AgentUserError, runBuildSteps, startHostServices, LEASE_SECONDS, createContainerRuntime, stopContainer, cleanupContainer, outOfMemoryReason, closeHostBuild, dropManagedClaudeKey, containerSenderCommand, hostCommandEnvironment, execArgv, signalInContainer, syncInContainer, copyTranscriptsFromContainer, MANAGED_UNJAILED_REASON, senderAliveScript, helperFirecrackerNote, managedClaudeKeyValues, stopJailed, deleteBuildDisk, managedClaudeKeyFor, startCheckContainer, lifecycleSteps, lifecycleFailureReason, writeEvalInput, DeliveryFailure, EVAL_INPUT_NAME, copyTranscripts, senderSignalScript, containerJudgeEnvironment, ROOT_DISK_ID_PREFIX, copyJudgeTree } from './chunk-POGPX7LI.js';
10
- import { readBranchHead, fetchCommit, diffBetween } from './chunk-3NFZN7H6.js';
6
+ import { senderPidfile } from './chunk-JBCOUY4M.js';
7
+ import { installScrubContext } from './chunk-QANM5COC.js';
8
+ import { writeDockerClientConfig } from './chunk-SI6WDF3U.js';
9
+ import { ADDED_USER, shellQuote, GH_CONFIG_YML, ghHostsYml, hasClaudeCredential, AssetError, obtainImage, ensureRootfs, makeBuildsDirPrivate, gitRemoteFor, startServicesFor, createLeaseChannel, createBuildDisk, machineConfig, startJailedInto, resolveAgentUser, AgentUserError, runBuildSteps, startHostServices, LEASE_SECONDS, createContainerRuntime, stopContainer, cleanupContainer, outOfMemoryReason, closeHostBuild, dropManagedClaudeKey, containerSenderCommand, hostCommandEnvironment, execArgv, signalInContainer, syncInContainer, copyTranscriptsFromContainer, MANAGED_UNJAILED_REASON, senderAliveScript, helperFirecrackerNote, managedClaudeKeyValues, stopJailed, deleteBuildDisk, managedClaudeKeyFor, startCheckContainer, lifecycleSteps, lifecycleFailureReason, writeEvalInput, DeliveryFailure, EVAL_INPUT_NAME, copyTranscripts, senderSignalScript, containerJudgeEnvironment, ROOT_DISK_ID_PREFIX, copyJudgeTree } from './chunk-JQSZTQSK.js';
10
+ import { readBranchHead, fetchCommit, diffBetween } from './chunk-UO4FQAOX.js';
11
+ import { waitForAgent, vmExecArgs } from './chunk-2ILU7UAU.js';
12
+ import { socketPathProblem, vsockLinks, LEASE_LINK, linkVsockSockets } from './chunk-OGPEHSNW.js';
13
+ import { describeCallFailure, resolveGoverningSource, prefetchGovernedContext, refusalCode, removeStagedContext, stageGovernedContext, pinnedSourceOf, commandWithShim, logStamp, createRunnerLog, removeKeptContext, formatDuration, retrySend, formatClock, WORKFLOW_PERMISSION_REASON, keptContextTree } from './chunk-RFVIQLNB.js';
14
+ import { imageBuildOf, isBuiltinContainer, isBuiltinProcess, isBuiltinVm, DEFAULT_CHECK_TIME_LIMIT_MINUTES } from './chunk-2D6CKNR7.js';
15
+ import { DEFAULT_CACHE_DISK, formatBytes, allocatedBytes } from './chunk-KM2HLQE3.js';
16
+ import { parseSize, HASH_ARGV, parseProgramHash, JUDGE_PROGRAM, writeJobFile, readJobFile, childEnvironment, withAnswerProtocol, judgeCommand, MAX_REPORT_BYTES, JUDGE_MAX_TURNS, JUDGE_DIR, COMMAND_DIR, MAX_ITEMS_BYTES } from './chunk-5AFPP3GZ.js';
17
+ import { CLAUDE_CODE_VERSION, FIRECRACKER_VERSION } from './chunk-4UPET3R7.js';
11
18
  import { isSameProcess, startTimeOf } from './chunk-JBJTC3UU.js';
12
- import { waitForAgent, vmExecArgs } from './chunk-IHY457PB.js';
13
- import { socketPathProblem, vsockLinks, LEASE_LINK, linkVsockSockets } from './chunk-2RBIW2PD.js';
14
- import { describeCallFailure, resolveGoverningSource, prefetchGovernedContext, refusalCode, removeStagedContext, stageGovernedContext, pinnedSourceOf, commandWithShim, logStamp, createRunnerLog, removeKeptContext, formatDuration, retrySend, formatClock, WORKFLOW_PERMISSION_REASON, keptContextTree } from './chunk-AVLLJW5D.js';
15
- import { imageBuildOf, isBuiltinContainer, isBuiltinProcess, isBuiltinVm, DEFAULT_CHECK_TIME_LIMIT_MINUTES } from './chunk-4XYC2663.js';
16
- import { DEFAULT_CACHE_DISK, formatBytes, allocatedBytes } from './chunk-UC2DKBMS.js';
17
- import { parseSize, HASH_ARGV, parseProgramHash, JUDGE_PROGRAM, writeJobFile, readJobFile, childEnvironment, withAnswerProtocol, judgeCommand, MAX_REPORT_BYTES, JUDGE_MAX_TURNS, JUDGE_DIR, COMMAND_DIR, MAX_ITEMS_BYTES } from './chunk-MPDLZCXM.js';
18
- import { CLAUDE_CODE_VERSION, FIRECRACKER_VERSION } from './chunk-ES4ULBAL.js';
19
- import { WorkCommandError, postJson, isSignatureRefusal, getJson } from './chunk-IW6Z337K.js';
19
+ import { WorkCommandError, postJson, isSignatureRefusal, getJson } from './chunk-UN3SQTVL.js';
20
20
  import { planArtifactUpload } from './chunk-MECW77XP.js';
21
- import { scrubText } from './chunk-AJYZNISW.js';
22
21
  import { readCloudConfig } from './chunk-PJDQPF5N.js';
23
- import { signerFor } from './chunk-XLJLR7EK.js';
24
- import { RUNNER_FILE_MODE, runnerDir, buildDir, vsockPath, jobConsolePath } from './chunk-N7LAEN3T.js';
25
- import { JOB_MOUNT, repositoriesOf, primaryOf, buildEnvironment, CHECKOUT_DIR, claudeCredential, AGENT_CREDENTIAL_MISSING, sharedUserEnvironment, headerVariables, authorEnvironment, withTunnelRecord, commitIdentityRecord, buildMavenSettingsXml, CLAUDE_CREDENTIAL_VARIABLES, currentClaudeCredential, removedClaudeCredentialValues, managedClaudeCredential, RELAY_PORT, repositoryPath, lifecycleWorkdir, CHECK_ITEMS_FILE, MAVEN_SETTINGS_FILE, checkEnvironment, EVAL_INPUT_DIR } from './chunk-YOBQIXX6.js';
22
+ import { signerFor } from './chunk-MOI2KDLH.js';
26
23
  import { resolvePackRoot } from './chunk-ZQSANKS4.js';
24
+ import { scrubText } from './chunk-AJYZNISW.js';
27
25
  import { MAINTAINED_SKILLS } from './chunk-CDDED64E.js';
28
26
  import { resolveVersion } from './chunk-RA3O54FC.js';
29
27
  import { parsePolicy } from './chunk-FGXT5OXS.js';
30
28
  import { CheckItemsSchema, CHECK_ITEM_REASON_MAX_LENGTH } from './chunk-EOTMDIYC.js';
31
29
  import { homeFromEnv } from './chunk-VNVZDWO3.js';
32
- import { fdName } from './chunk-HACGUL52.js';
30
+ import { RUNNER_FILE_MODE, runnerDir, buildDir, vsockPath, jobConsolePath } from './chunk-PXGU3GKY.js';
31
+ import { JOB_MOUNT, repositoriesOf, primaryOf, buildEnvironment, CHECKOUT_DIR, claudeCredential, AGENT_CREDENTIAL_MISSING, sharedUserEnvironment, headerVariables, authorEnvironment, withTunnelRecord, commitIdentityRecord, fdName, buildMavenSettingsXml, CLAUDE_CREDENTIAL_VARIABLES, currentClaudeCredential, removedClaudeCredentialValues, managedClaudeCredential, RELAY_PORT, repositoryPath, lifecycleWorkdir, CHECK_ITEMS_FILE, MAVEN_SETTINGS_FILE, checkEnvironment, EVAL_INPUT_DIR } from './chunk-G4W4B33M.js';
33
32
  import { RUNNER_WORDED_REASONS, UNKNOWN_TRACKING_REASON } from './chunk-MESOOLF4.js';
34
33
  import { existsSync, statSync, appendFileSync, rmSync, mkdirSync, chmodSync, writeFileSync, openSync, readFileSync, closeSync, readdirSync, lstatSync, fstatSync, readSync, realpathSync } from 'fs';
35
34
  import { join, dirname, delimiter, sep } from 'path';
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { RUNNER_DIR_MODE, RUNNER_FILE_MODE } from './chunk-N7LAEN3T.js';
3
+ import { RUNNER_DIR_MODE, RUNNER_FILE_MODE } from './chunk-PXGU3GKY.js';
4
4
  import { readFileSync, mkdirSync, writeFileSync, renameSync } from 'fs';
5
5
  import { join } from 'path';
6
6
 
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
+ import { DEFAULT_DASHBOARD } from './chunk-Y5YCX6AL.js';
3
4
  import { sanitizeTerminal } from './chunk-MECW77XP.js';
4
- import { remoteLookupFailed } from './chunk-AJYZNISW.js';
5
5
  import { isAgentsMdLayout } from './chunk-NKOM4JKY.js';
6
- import { DEFAULT_DASHBOARD } from './chunk-Y5YCX6AL.js';
7
- import { cliFetch, resolveGatewayCredentials } from './chunk-TVGLNHEB.js';
6
+ import { cliFetch, resolveGatewayCredentials } from './chunk-3N77LUQI.js';
8
7
  import { readCloudConfig } from './chunk-PJDQPF5N.js';
9
8
  import { findGitDirs, writeRepoConnection, readRepoConnection } from './chunk-BJ3KTMDH.js';
9
+ import { remoteLookupFailed } from './chunk-AJYZNISW.js';
10
10
  import { cliInvocation } from './chunk-CRB3POP4.js';
11
11
  import { execFileSync } from 'child_process';
12
12
  import { lstatSync } from 'fs';
@@ -1,14 +1,193 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { parseRunnerEnv } from './chunk-HACGUL52.js';
4
3
  import { TARGET_TUNNEL, TARGET_LEASE, destinationTarget } from './chunk-MESOOLF4.js';
5
- import { readFileSync, mkdirSync, writeFileSync, existsSync, unlinkSync, chmodSync } from 'fs';
4
+ import { spawn, spawnSync } from 'child_process';
5
+ import { statSync, readFileSync, mkdirSync, writeFileSync, existsSync, unlinkSync, chmodSync } from 'fs';
6
6
  import { join, dirname } from 'path';
7
7
  import { request as request$1, createServer } from 'http';
8
8
  import { request } from 'https';
9
9
  import { createServer as createServer$1 } from 'net';
10
10
 
11
11
  createRequire(import.meta.url);
12
+ var FD_STORE_ENV = "OUTERLAYER_FD_STORE";
13
+ var MIN_SYSTEMD = 254;
14
+ var LISTEN_FDS_START = 3;
15
+ var FD_SLOTS_PER_BUILD = 64;
16
+ function fdName(buildId, socket) {
17
+ return `ol-${buildId}-${socket}`;
18
+ }
19
+ function listenFdOf(server) {
20
+ const handle = server._handle;
21
+ return typeof handle?.fd === "number" && handle.fd >= 0 ? handle.fd : void 0;
22
+ }
23
+ function parseListenFds(env, pid) {
24
+ const found = /* @__PURE__ */ new Map();
25
+ if (env.LISTEN_PID !== String(pid)) return found;
26
+ const count = Number(env.LISTEN_FDS);
27
+ if (!Number.isInteger(count) || count <= 0) return found;
28
+ const names = (env.LISTEN_FDNAMES ?? "").split(":");
29
+ for (let index = 0; index < count; index++) {
30
+ const name = names[index];
31
+ if (name !== void 0 && name !== "" && name !== "stored") found.set(name, LISTEN_FDS_START + index);
32
+ }
33
+ return found;
34
+ }
35
+ function listenOnFd(server, fd) {
36
+ return new Promise((resolve, reject) => {
37
+ server.once("error", reject);
38
+ server.listen({ fd }, () => {
39
+ server.off("error", reject);
40
+ resolve();
41
+ });
42
+ });
43
+ }
44
+ function run(spawnFn, command, args, fd) {
45
+ return new Promise((resolve) => {
46
+ let stdout = "";
47
+ let stderr = "";
48
+ let child;
49
+ try {
50
+ child = spawnFn(command, args, { stdio: ["ignore", "pipe", "pipe", ...fd === void 0 ? [] : [fd]] });
51
+ } catch (err) {
52
+ resolve({ status: null, stdout, stderr: err instanceof Error ? err.message : String(err) });
53
+ return;
54
+ }
55
+ child.stdout?.on("data", (chunk) => stdout += chunk.toString("utf8"));
56
+ child.stderr?.on("data", (chunk) => stderr += chunk.toString("utf8"));
57
+ child.on("error", (err) => resolve({ status: null, stdout, stderr: err.message }));
58
+ child.on("close", (status) => resolve({ status, stdout, stderr }));
59
+ });
60
+ }
61
+ function systemdVersion(ran) {
62
+ const match = /^systemd (\d+)/.exec(ran.stdout);
63
+ return ran.status === 0 && match !== null ? Number(match[1]) : void 0;
64
+ }
65
+ function realFdStorePort(options = {}) {
66
+ const env = options.env ?? process.env;
67
+ const pid = options.pid ?? process.pid;
68
+ const command = options.command ?? "systemd-notify";
69
+ const spawnFn = options.spawn ?? spawn;
70
+ let inherited;
71
+ let held2;
72
+ let version;
73
+ const inheritedNames = () => inherited ??= parseListenFds(env, pid);
74
+ const heldNames = () => held2 ??= new Set(inheritedNames().keys());
75
+ return {
76
+ async status() {
77
+ if (env.NOTIFY_SOCKET === void 0 || env.NOTIFY_SOCKET === "") return { ok: false, reason: "NOTIFY_SOCKET is not set, so this runner was not started by a service that accepts descriptors" };
78
+ const size = Number(env[FD_STORE_ENV]);
79
+ if (!Number.isInteger(size) || size <= 0) return { ok: false, reason: `${FD_STORE_ENV} is not set, so the service's unit keeps no descriptor store` };
80
+ version ??= run(spawnFn, command, ["--version"]).then(systemdVersion);
81
+ const found = await version;
82
+ if (found === void 0) return { ok: false, reason: `${command} could not be run, so no descriptor can be stored` };
83
+ if (found < MIN_SYSTEMD) return { ok: false, reason: `systemd ${found} cannot store a descriptor sent from a child process: it needs systemd ${MIN_SYSTEMD} or later` };
84
+ return { ok: true };
85
+ },
86
+ async push(name, server) {
87
+ const fd = listenFdOf(server);
88
+ if (fd === void 0) throw new Error(`${name} has no descriptor to store`);
89
+ const size = Number(env[FD_STORE_ENV]);
90
+ const names = heldNames();
91
+ if (Number.isInteger(size) && names.size >= size) {
92
+ throw new Error(`the descriptor store is full: it holds ${names.size} descriptors, the size the service's unit sets (FileDescriptorStoreMax=${size})`);
93
+ }
94
+ const ran = await run(spawnFn, command, [`--fd=${LISTEN_FDS_START}`, `--fdname=${name}`, "FDSTORE=1"], fd);
95
+ if (ran.status !== 0) throw new Error(`storing ${name} failed${ran.status === null ? "" : ` (exit ${ran.status})`}: ${ran.stderr.trim().split("\n")[0] ?? ""}`);
96
+ names.add(name);
97
+ },
98
+ async remove(name) {
99
+ const ran = await run(spawnFn, command, ["FDSTOREREMOVE=1", `FDNAME=${name}`]);
100
+ if (ran.status !== 0) throw new Error(`removing ${name} from the store failed${ran.status === null ? "" : ` (exit ${ran.status})`}: ${ran.stderr.trim().split("\n")[0] ?? ""}`);
101
+ heldNames().delete(name);
102
+ },
103
+ inherited() {
104
+ return inheritedNames();
105
+ },
106
+ listenOn: listenOnFd
107
+ };
108
+ }
109
+
110
+ // src/runner/service/slice.ts
111
+ var BUILD_SLICE_MEMORY_ENV = "OUTERLAYER_BUILD_SLICE_MEMORY";
112
+
113
+ // src/runner/service/inspect.ts
114
+ var CREDENTIAL_VARIABLES = ["CLAUDE_CODE_OAUTH_TOKEN", "ANTHROPIC_API_KEY"];
115
+ function property(shown, name) {
116
+ return new RegExp(`^${name}=(.*)$`, "m").exec(shown)?.[1]?.trim();
117
+ }
118
+ function holdsGroup(status, gid) {
119
+ const primary = /^Gid:\s+(\d+)/m.exec(status)?.[1];
120
+ const supplementary = /^Groups:[ \t]*(.*)$/m.exec(status)?.[1]?.trim().split(/\s+/).filter((g) => g !== "") ?? [];
121
+ return [primary, ...supplementary].some((g) => g !== void 0 && Number(g) === gid);
122
+ }
123
+ function parseRunnerEnv(text) {
124
+ const env = {};
125
+ for (const line of text.split("\n")) {
126
+ const match = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/.exec(line);
127
+ if (match === null) continue;
128
+ env[match[1]] = match[2].trim().replace(/^(["'])(.*)\1$/, "$2");
129
+ }
130
+ return env;
131
+ }
132
+ function credentialNames(env) {
133
+ const set = parseRunnerEnv(env ?? "");
134
+ return CREDENTIAL_VARIABLES.filter((name) => (set[name] ?? "").trim() !== "");
135
+ }
136
+ function startedWithStore(environ) {
137
+ const vars = new Map(environ.split("\0").map((entry) => [entry.slice(0, entry.indexOf("=")), entry.slice(entry.indexOf("=") + 1)]));
138
+ return (vars.get("NOTIFY_SOCKET") ?? "") !== "" && Number(vars.get(FD_STORE_ENV)) > 0;
139
+ }
140
+ function inspectService(unit, configDir, probes) {
141
+ const shown = probes.show(unit);
142
+ if (shown === void 0 || property(shown, "LoadState") !== "loaded") return void 0;
143
+ const pid = Number(property(shown, "MainPID") ?? "0");
144
+ const mainPid = Number.isInteger(pid) && pid > 0 ? pid : void 0;
145
+ const delegate = property(shown, "Delegate");
146
+ const storeMax = Number(property(shown, "FileDescriptorStoreMax"));
147
+ const status = mainPid === void 0 ? void 0 : probes.readFile(`/proc/${mainPid}/status`);
148
+ const environ = mainPid === void 0 ? void 0 : probes.readFile(`/proc/${mainPid}/environ`);
149
+ const systemd = Number(/^systemd (\d+)/.exec(probes.systemctlVersion?.() ?? "")?.[1]);
150
+ const kvm = probes.kvmGid();
151
+ const sliceMemory = Number(new RegExp(`(?:^|\\s)${BUILD_SLICE_MEMORY_ENV}=(\\d+)(?:\\s|$)`).exec(property(shown, "Environment") ?? "")?.[1]);
152
+ return {
153
+ unit,
154
+ ...Number.isSafeInteger(sliceMemory) && sliceMemory > 0 ? { buildSliceMemory: sliceMemory } : {},
155
+ mainPid,
156
+ delegate: delegate === void 0 ? void 0 : delegate !== "no",
157
+ ...Number.isInteger(storeMax) && property(shown, "FileDescriptorStoreMax") !== void 0 ? { fdStoreMax: storeMax } : {},
158
+ hasKvmGroup: status === void 0 || kvm === void 0 ? void 0 : holdsGroup(status, kvm),
159
+ ...environ === void 0 ? {} : { startedWithStore: startedWithStore(environ) },
160
+ ...systemd > 0 ? { systemdVersion: systemd } : {},
161
+ // `claude.env` first, where the service loads the credential from; `runner.env` holds one that was never moved.
162
+ credentialVariables: [.../* @__PURE__ */ new Set([...credentialNames(probes.readFile(join(configDir, "claude.env"))), ...credentialNames(probes.readFile(join(configDir, "runner.env")))])]
163
+ };
164
+ }
165
+ function realInspectProbes() {
166
+ return {
167
+ show: (unit) => {
168
+ const result = spawnSync("systemctl", ["show", "--property=LoadState,MainPID,Delegate,FileDescriptorStoreMax,Environment", unit], { encoding: "utf8", timeout: 1e4 });
169
+ return result.status === 0 ? result.stdout : void 0;
170
+ },
171
+ readFile: (path) => {
172
+ try {
173
+ return readFileSync(path, "utf8");
174
+ } catch {
175
+ return void 0;
176
+ }
177
+ },
178
+ systemctlVersion: () => {
179
+ const result = spawnSync("systemctl", ["--version"], { encoding: "utf8", timeout: 1e4 });
180
+ return result.status === 0 ? result.stdout : void 0;
181
+ },
182
+ kvmGid: () => {
183
+ try {
184
+ return statSync("/dev/kvm").gid;
185
+ } catch {
186
+ return void 0;
187
+ }
188
+ }
189
+ };
190
+ }
12
191
  var CLAUDE_CREDENTIAL_ID = "claude";
13
192
  var CLAUDE_ENV_FILE = "claude.env";
14
193
  function claudeEnvPath(configPath) {
@@ -871,4 +1050,4 @@ function routesOf(counts) {
871
1050
  return routes.length === 0 ? {} : { routes };
872
1051
  }
873
1052
 
874
- export { AGENT_CREDENTIAL_MISSING, BUILD_HOME, BUILT_IN_NAMES, CHECKOUT_DIR, CHECK_ITEMS_FILE, CLAUDE_CREDENTIAL_ID, CLAUDE_CREDENTIAL_VARIABLES, CLAUDE_ENV_FILE, CLAUDE_PORT, CLAUDE_SOCKET, DESTINATION_BASE_PORT, EVAL_INPUT_DIR, FORWARDED_CLAUDE_CREDENTIAL_VARIABLES, GATEWAY_PORT, GATEWAY_SOCKET, JOB_MOUNT, MAVEN_NO_PROXY_NOTE, MAVEN_SETTINGS_FILE, MAVEN_SPACE_NOTE, PROXY_WARNING_FLAG, RELAY_PORT, authorEnvironment, buildEnvironment, buildMavenSettingsXml, builtInEnvironment, checkEnvironment, checkoutPath, claudeCredential, claudeCredentialVariablesSet, claudeEnvPath, commitIdentityRecord, containerLocalAddress, credentialLineIn, currentClaudeCredential, destinationEnvironment, headerVariables, heldClaudeCredential, isRefusedInConfig, isReservedVariable, lifecycleWorkdir, managedClaudeCredential, mavenArgs, mavenSettingsXml, namesGlobalSettings, parseClaimIdentity, parseClaimedRepositories, parseIsolation, parseUnreachable, primaryOf, proxyEnvironment, readClaudeCredential, removedClaudeCredentialValues, repositoriesOf, repositoryPath, resolveDestinations, sharedUserEnvironment, startBuildServices, takeClaudeCredential, tokenHeader, withGitConfig, withHooksPath, withProxyWarningHidden, withTokenHeader, withTunnelRecord, withoutCredentialLines, writeBuildMavenSettings, writeMavenSettings };
1053
+ export { AGENT_CREDENTIAL_MISSING, BUILD_HOME, BUILD_SLICE_MEMORY_ENV, BUILT_IN_NAMES, CHECKOUT_DIR, CHECK_ITEMS_FILE, CLAUDE_CREDENTIAL_ID, CLAUDE_CREDENTIAL_VARIABLES, CLAUDE_ENV_FILE, CLAUDE_PORT, CLAUDE_SOCKET, DESTINATION_BASE_PORT, EVAL_INPUT_DIR, FD_SLOTS_PER_BUILD, FD_STORE_ENV, FORWARDED_CLAUDE_CREDENTIAL_VARIABLES, GATEWAY_PORT, GATEWAY_SOCKET, JOB_MOUNT, MAVEN_NO_PROXY_NOTE, MAVEN_SETTINGS_FILE, MAVEN_SPACE_NOTE, MIN_SYSTEMD, PROXY_WARNING_FLAG, RELAY_PORT, authorEnvironment, buildEnvironment, buildMavenSettingsXml, builtInEnvironment, checkEnvironment, checkoutPath, claudeCredential, claudeCredentialVariablesSet, claudeEnvPath, commitIdentityRecord, containerLocalAddress, credentialLineIn, currentClaudeCredential, destinationEnvironment, fdName, headerVariables, heldClaudeCredential, inspectService, isRefusedInConfig, isReservedVariable, lifecycleWorkdir, managedClaudeCredential, mavenArgs, mavenSettingsXml, namesGlobalSettings, parseClaimIdentity, parseClaimedRepositories, parseIsolation, parseRunnerEnv, parseUnreachable, primaryOf, proxyEnvironment, readClaudeCredential, realFdStorePort, realInspectProbes, removedClaudeCredentialValues, repositoriesOf, repositoryPath, resolveDestinations, sharedUserEnvironment, startBuildServices, takeClaudeCredential, tokenHeader, withGitConfig, withHooksPath, withProxyWarningHidden, withTokenHeader, withTunnelRecord, withoutCredentialLines, writeBuildMavenSettings, writeMavenSettings };
@@ -1,13 +1,67 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { launcherPath, writeLauncher, LauncherWriteError, pathNotes } from './chunk-J246WRLZ.js';
4
- import { currentVersion, currentLink, isInLayout, packageRootIn, versionDir, switchCurrent, execStartLine } from './chunk-DUPM5LVJ.js';
3
+ import { launcherPath, pathNotes, writeLauncher, LauncherWriteError } from './chunk-OS7DJOQJ.js';
4
+ import { currentVersion, currentLink, versionDir, execStartLine, isInLayout, packageRootIn, switchCurrent } from './chunk-UMYYYF7B.js';
5
5
  import { compareVersions } from './chunk-TQMI335S.js';
6
- import { RUNNER_DIR_MODE } from './chunk-N7LAEN3T.js';
7
- import { realpathSync, readFileSync, mkdirSync, rmSync, cpSync, existsSync } from 'fs';
6
+ import { runnerDir, RUNNER_DIR_MODE } from './chunk-PXGU3GKY.js';
7
+ import { lchownSync, lstatSync, realpathSync, readFileSync, mkdirSync, rmSync, cpSync, existsSync, readdirSync } from 'fs';
8
8
  import { dirname, sep, join } from 'path';
9
+ import { spawnSync } from 'child_process';
10
+ import { userInfo } from 'os';
9
11
 
10
12
  createRequire(import.meta.url);
13
+ function idOf(flag, account) {
14
+ const result = spawnSync("id", [flag, account], { encoding: "utf8" });
15
+ const id = Number(result.stdout);
16
+ return result.status === 0 && result.stdout.trim() !== "" && Number.isInteger(id) ? id : void 0;
17
+ }
18
+ function accountIdentity(account) {
19
+ const self = userInfo();
20
+ const uid = account === self.username ? self.uid : idOf("-u", account);
21
+ const gid = account === self.username ? self.gid : idOf("-g", account);
22
+ return uid === void 0 || gid === void 0 || uid < 0 || gid < 0 ? void 0 : { uid, gid };
23
+ }
24
+ function realOwnership() {
25
+ return {
26
+ uid: () => process.getuid?.(),
27
+ ownerOf: (path) => {
28
+ const info = lstatSync(path, { throwIfNoEntry: false });
29
+ return info === void 0 ? void 0 : { uid: info.uid, gid: info.gid };
30
+ },
31
+ identity: accountIdentity,
32
+ lchown: (path, owner) => lchownSync(path, owner.uid, owner.gid)
33
+ };
34
+ }
35
+ function forAnother(find, deps) {
36
+ if (deps.uid() !== 0) return void 0;
37
+ const owner = find();
38
+ return owner !== void 0 && owner.uid !== 0 ? owner : void 0;
39
+ }
40
+ function accountNamed(account, deps) {
41
+ return forAnother(() => deps.identity(account), deps);
42
+ }
43
+ function accountOwning(dir, deps) {
44
+ return forAnother(() => deps.ownerOf(dir), deps);
45
+ }
46
+ function handOver(owner, paths, deps) {
47
+ if (owner === void 0) return void 0;
48
+ const give = (path, tree) => {
49
+ const info = lstatSync(path, { throwIfNoEntry: false });
50
+ if (info === void 0) return;
51
+ deps.lchown(path, owner);
52
+ if (tree && info.isDirectory()) for (const name of readdirSync(path)) give(join(path, name), true);
53
+ };
54
+ for (const entry of paths) {
55
+ try {
56
+ give(entry.path, entry.tree === true);
57
+ } catch (err) {
58
+ return `${entry.path} could not be given to user id ${owner.uid}, the account the runner runs as (${err instanceof Error ? err.message : String(err)}): run \`chown -hR ${owner.uid}:${owner.gid} ${entry.path}\` as root`;
59
+ }
60
+ }
61
+ return void 0;
62
+ }
63
+
64
+ // src/runner/update/install-cmd.ts
11
65
  var RunnerInstallError = class extends Error {
12
66
  };
13
67
  var RunnerDowngradeError = class extends RunnerInstallError {
@@ -42,20 +96,17 @@ function runRunnerInstall(args) {
42
96
  `this CLI is ${version}, older than ${installed}, the version the runner runs from ${currentLink(configPath)}. Installing it would move the runner back to ${version}. Run \`${launcherPath(args.home)} ${command}\` instead, which runs ${installed}. To install ${version} anyway, run \`outerlayer ${command} --allow-downgrade\``
43
97
  );
44
98
  }
45
- if (!isInLayout(configPath, entry) && !sameBuildInstalled(packageRoot, packageRootIn(versionDir(configPath, version)))) {
46
- const target = packageRootIn(versionDir(configPath, version));
47
- mkdirSync(dirname(target), { recursive: true, mode: RUNNER_DIR_MODE });
48
- rmSync(target, { recursive: true, force: true });
49
- cpSync(packageRoot, target, { recursive: true });
50
- carryHoistedDevcontainerCli(packageRoot, target);
51
- }
52
- switchCurrent(configPath, version);
99
+ const ownership = args.ownership ?? realOwnership();
100
+ const account = args.account === void 0 ? accountOwning(dirname(configPath), ownership) : accountNamed(args.account, ownership);
101
+ const homeAccount = accountOwning(args.home, ownership);
53
102
  let written;
54
103
  try {
55
- written = writeLauncher({ home: args.home, configPath, nodePath, replace: args.replace });
56
- } catch (error) {
57
- if (error instanceof LauncherWriteError) throw new RunnerInstallError(error.message);
58
- throw error;
104
+ written = placeInLayout({ configPath, nodePath, home: args.home, replace: args.replace, entry, packageRoot, version });
105
+ } finally {
106
+ const launcher = launcherPath(args.home);
107
+ const problem = handOver(account, [{ path: runnerDir(configPath) }, { path: dirname(versionDir(configPath, version)) }, { path: versionDir(configPath, version), tree: true }, { path: currentLink(configPath) }], ownership) ?? // A launcher file the runner did not write stays with its owner.
108
+ handOver(homeAccount, [{ path: join(args.home, ".local") }, { path: dirname(launcher) }, ...written === void 0 || written.state === "foreign" ? [] : [{ path: launcher }]], ownership);
109
+ if (problem !== void 0 && written !== void 0) throw new RunnerInstallError(problem);
59
110
  }
60
111
  return {
61
112
  version,
@@ -69,6 +120,23 @@ function runRunnerInstall(args) {
69
120
  }
70
121
  };
71
122
  }
123
+ function placeInLayout(input) {
124
+ const { configPath, packageRoot, version } = input;
125
+ if (!isInLayout(configPath, input.entry) && !sameBuildInstalled(packageRoot, packageRootIn(versionDir(configPath, version)))) {
126
+ const target = packageRootIn(versionDir(configPath, version));
127
+ mkdirSync(dirname(target), { recursive: true, mode: RUNNER_DIR_MODE });
128
+ rmSync(target, { recursive: true, force: true });
129
+ cpSync(packageRoot, target, { recursive: true });
130
+ carryHoistedDevcontainerCli(packageRoot, target);
131
+ }
132
+ switchCurrent(configPath, version);
133
+ try {
134
+ return writeLauncher({ home: input.home, configPath, nodePath: input.nodePath, replace: input.replace });
135
+ } catch (error) {
136
+ if (error instanceof LauncherWriteError) throw new RunnerInstallError(error.message);
137
+ throw error;
138
+ }
139
+ }
72
140
  function sameBuildInstalled(source, target) {
73
141
  try {
74
142
  const wanted = readFileSync(join(source, "dist", "build-info.json"), "utf8");
@@ -95,4 +163,4 @@ function restartNote(result) {
95
163
  return `current moved from ${result.previous} to ${result.version}: a runner its service started restarts on ${result.version} at once when its running builds are container builds that carry on through the restart. Otherwise it takes no new work and waits for them to finish. A runner started by hand keeps running until you restart it`;
96
164
  }
97
165
 
98
- export { RunnerDowngradeError, RunnerInstallError, launcherSummary, restartNote, runRunnerInstall };
166
+ export { RunnerDowngradeError, RunnerInstallError, accountIdentity, accountNamed, handOver, launcherSummary, realOwnership, restartNote, runRunnerInstall };