@outerlayer/cli 0.27.1 → 0.28.2

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 (129) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +6 -0
  3. package/dist/{agent-setup-UW36TAQM.js → agent-setup-YVR5RO56.js} +17 -14
  4. package/dist/{bridge-B5VJVECY.js → bridge-WW2V7DTB.js} +3 -2
  5. package/dist/build-5FRC3RKM.js +13 -0
  6. package/dist/build-info.json +1 -1
  7. package/dist/{builder-6Y6ZWGNH.js → builder-4F2XNSFC.js} +7 -6
  8. package/dist/{check-YTXFVWK7.js → check-YEI6TCUH.js} +70 -61
  9. package/dist/{chunk-LPFOWUHG.js → chunk-25X2PJDI.js} +20 -13
  10. package/dist/{chunk-BPKO76QR.js → chunk-4XN5FRRJ.js} +4 -4
  11. package/dist/{chunk-EPPIISRD.js → chunk-55XLX5PA.js} +1 -1
  12. package/dist/{chunk-LOKSLO25.js → chunk-5B7BEQPR.js} +1 -1
  13. package/dist/chunk-5BHIBJDA.js +93 -0
  14. package/dist/{chunk-RHAGBUL5.js → chunk-5K3KB4YR.js} +1 -1
  15. package/dist/{chunk-ABXQBEYK.js → chunk-66T6XJAB.js} +1 -1
  16. package/dist/{chunk-ZFBJUOYT.js → chunk-6S4V4UIC.js} +10 -10
  17. package/dist/{chunk-BWH36FOC.js → chunk-7CK2TJFB.js} +20 -4
  18. package/dist/{chunk-QKIQ2R7F.js → chunk-ATJOFXTE.js} +3 -3
  19. package/dist/chunk-CDDED64E.js +13 -0
  20. package/dist/{chunk-QHH4OSD4.js → chunk-CTYSTE5C.js} +1 -1
  21. package/dist/{chunk-DJHNEGNM.js → chunk-DKWQMPSL.js} +18 -2
  22. package/dist/{chunk-IMOB4IOI.js → chunk-DQYMQ47E.js} +3 -2
  23. package/dist/{chunk-YETTWTAY.js → chunk-E7R2GIAW.js} +4 -4
  24. package/dist/{chunk-GFUE5TKO.js → chunk-F4FA3ZUT.js} +24 -14
  25. package/dist/{chunk-6TRNCUM4.js → chunk-FGF52V4V.js} +1 -1
  26. package/dist/{chunk-R7SGBXUD.js → chunk-GLL4TN2M.js} +226 -72
  27. package/dist/{chunk-MATUHHN4.js → chunk-GUXWQIEY.js} +1 -1
  28. package/dist/{chunk-B7DJVG25.js → chunk-HOB7Z4JQ.js} +3 -3
  29. package/dist/{chunk-2I3LIRZP.js → chunk-HXAEQPZR.js} +101 -10
  30. package/dist/{chunk-P33PZIWS.js → chunk-ITAIEJ2T.js} +7 -142
  31. package/dist/{chunk-RHGF73IU.js → chunk-IVX3U7KV.js} +1 -1
  32. package/dist/{chunk-7OUOLGUV.js → chunk-JGML2VUN.js} +3 -7
  33. package/dist/{chunk-6VFH52MP.js → chunk-KU7QL4XW.js} +24 -22
  34. package/dist/{chunk-2F762IXY.js → chunk-LNIFYSNK.js} +3 -3
  35. package/dist/{chunk-XBPUTQ7E.js → chunk-MHAR6S7B.js} +1 -1
  36. package/dist/{chunk-VS27BP3E.js → chunk-MKIC65SD.js} +52 -9
  37. package/dist/{chunk-64GMBWAK.js → chunk-MNHMUZGC.js} +6 -6
  38. package/dist/{chunk-7AQ5AM7U.js → chunk-MQHTM4YJ.js} +177 -21
  39. package/dist/{chunk-6KKM7VGZ.js → chunk-N7WAEEIU.js} +3 -3
  40. package/dist/{chunk-D7ECMB7B.js → chunk-NUHZV3A4.js} +1 -1
  41. package/dist/{chunk-5VMDGJGH.js → chunk-O65LES4V.js} +39 -25
  42. package/dist/{chunk-MHX7YX7Y.js → chunk-P2RWZCV7.js} +1 -1
  43. package/dist/chunk-QBQHQEUG.js +300 -0
  44. package/dist/{chunk-FP23SVDD.js → chunk-QJFDAKRF.js} +5 -5
  45. package/dist/{chunk-WUL2OP5A.js → chunk-QKXF7CLR.js} +3 -3
  46. package/dist/{chunk-XZ6Q6ZNR.js → chunk-SATUCMAJ.js} +3 -2
  47. package/dist/{chunk-Y7ZCHBYB.js → chunk-SFJXGISY.js} +3 -3
  48. package/dist/{chunk-2BTFKNTR.js → chunk-SJZL5F3F.js} +2 -2
  49. package/dist/{chunk-HWDYLXHH.js → chunk-T2QSWFSU.js} +4 -4
  50. package/dist/{chunk-E5IJ5533.js → chunk-TF7G2PR6.js} +3 -3
  51. package/dist/{chunk-O2IJTY7L.js → chunk-TVZAC2NP.js} +3 -3
  52. package/dist/{chunk-QE3UQAHK.js → chunk-UHU7H57K.js} +26 -7
  53. package/dist/{chunk-WSYXLLA5.js → chunk-USJZ2LDK.js} +6 -6
  54. package/dist/{chunk-EX5MQYEF.js → chunk-VC5J7QPV.js} +5 -5
  55. package/dist/{chunk-N4D5TMVU.js → chunk-VU7ZJPIR.js} +5 -5
  56. package/dist/{chunk-GLUKDQS4.js → chunk-WWQVKFN6.js} +1 -1
  57. package/dist/{chunk-55GNQPO6.js → chunk-X52PMPOM.js} +7 -7
  58. package/dist/{chunk-YB3CSYXX.js → chunk-XD4ZCMA4.js} +81 -2
  59. package/dist/{chunk-Y4OKEFAX.js → chunk-YL2VDSNF.js} +1 -1
  60. package/dist/{chunk-M3MHHIUW.js → chunk-Z3ASAXVU.js} +1 -1
  61. package/dist/{chunk-XS3FDWSZ.js → chunk-ZTY7HHYB.js} +1 -1
  62. package/dist/{claude-launcher-NQSZBTQ5.js → claude-launcher-7RGVOYCD.js} +6 -5
  63. package/dist/{cli-GHEOBXC7.js → cli-SCTKM2Y5.js} +151 -130
  64. package/dist/cli-update-notice-4DLZ3655.js +9 -0
  65. package/dist/{command-V7B7GTPZ.js → command-PY3C2E4B.js} +53 -37
  66. package/dist/{config-TWS5VZEN.js → config-5QYIKYUP.js} +3 -2
  67. package/dist/{connect-cmd-HGS7YPA2.js → connect-cmd-5TYAOK5M.js} +14 -11
  68. package/dist/{container-start-FHB2VDC4.js → container-start-7WLZMPEI.js} +37 -36
  69. package/dist/{control-plane-launch-DBQA3KLJ.js → control-plane-launch-FZMD4MXX.js} +13 -10
  70. package/dist/{dist-QPHZE47F.js → dist-JFVKLUHL.js} +1 -1
  71. package/dist/{docker-YT6Z3LXI.js → docker-ZTC4EIU4.js} +7 -6
  72. package/dist/{doctor-Y4NCNSJM.js → doctor-DQWRUAEB.js} +159 -41
  73. package/dist/{emit-artifact-cmd-ALDK55Y2.js → emit-artifact-cmd-SOXLBPQB.js} +19 -16
  74. package/dist/{emit-cmd-VAQHRWJR.js → emit-cmd-QUABLVO6.js} +6 -5
  75. package/dist/{emit-criteria-cmd-Q7SM6VP2.js → emit-criteria-cmd-JDO2VUG5.js} +15 -12
  76. package/dist/{emit-finding-cmd-2NBAPDSV.js → emit-finding-cmd-VCQPCLI2.js} +16 -13
  77. package/dist/{emit-result-cmd-KUSL56RI.js → emit-result-cmd-TKA3GAN7.js} +19 -16
  78. package/dist/{emit-step-cmd-KD4AKEAT.js → emit-step-cmd-XN44BXYU.js} +16 -13
  79. package/dist/{exec-client-6WVS7DRZ.js → exec-client-VKT2XNB3.js} +4 -3
  80. package/dist/fleet-readiness-G5X3MKP2.js +29 -0
  81. package/dist/{governing-source-VVUA5TKB.js → governing-source-B3M2U4BC.js} +21 -18
  82. package/dist/{guest-init-H5K2RW3P.js → guest-init-QW2DPX7H.js} +5 -4
  83. package/dist/{hook-fast-3SUJM765.js → hook-fast-EFC44SXV.js} +4 -1
  84. package/dist/{host-key-XNKZCWTS.js → host-key-AC6LTZDS.js} +4 -3
  85. package/dist/{image-tag-R34J4O3F.js → image-tag-SS7YKJHN.js} +4 -3
  86. package/dist/index.js +4 -4
  87. package/dist/init-5LHTF72R.js +56 -0
  88. package/dist/{init-3DAGX7UY.js → init-BTH5YPBC.js} +38 -37
  89. package/dist/{init-cmd-RIDBVSE4.js → init-cmd-L4VW3ZCT.js} +25 -21
  90. package/dist/{init-update-ECWNG47R.js → init-update-RWTQSTPE.js} +51 -35
  91. package/dist/{inspect-IPFA7AAT.js → inspect-L7JIBK3Y.js} +1 -1
  92. package/dist/{install-6OIY3KHZ.js → install-35SAMY75.js} +5 -5
  93. package/dist/{install-cmd-JMT67P35.js → install-cmd-GFY4QF72.js} +6 -5
  94. package/dist/{layout-XNFDTOET.js → layout-BBTQPS6V.js} +4 -3
  95. package/dist/{login-browser-EWXSGHM7.js → login-browser-WSOSQH2T.js} +2 -2
  96. package/dist/{logs-XHAS6LMZ.js → logs-X2IRDP5T.js} +3 -2
  97. package/dist/loop-QDV7T65M.js +80 -0
  98. package/dist/{machine-OOQ2NXC3.js → machine-PLNSGKNF.js} +32 -30
  99. package/dist/{machine-skills-FLIRJYP7.js → machine-skills-O7W6NMWB.js} +4 -3
  100. package/dist/{mcp-serve-cmd-LY5A3CE7.js → mcp-serve-cmd-IITCPAAR.js} +9 -6
  101. package/dist/{paths-LHSPNORF.js → paths-32DWGK35.js} +3 -2
  102. package/dist/pending-CSIY4Y2I.js +10 -0
  103. package/dist/{pidfile-DKMYYXLH.js → pidfile-CYCTH6NQ.js} +4 -3
  104. package/dist/{real-deps-KNNBQC75.js → real-deps-QX5YH7FG.js} +1 -1
  105. package/dist/{record-3LPTY3G5.js → record-N4WPZCGK.js} +4 -3
  106. package/dist/{relay-GFPPD6GF.js → relay-FJ5K37Z5.js} +8 -4
  107. package/dist/{runner-env-YRRNRKF4.js → runner-env-EIB6WFPG.js} +6 -7
  108. package/dist/{runner-identity-YS2BZXZV.js → runner-identity-S3V6I4I3.js} +7 -6
  109. package/dist/{runner-key-EFNTZWNX.js → runner-key-M4N2BY5A.js} +36 -35
  110. package/dist/{session-sender-SC5PSU2G.js → session-sender-UQ3VF732.js} +20 -17
  111. package/dist/{spec-cmd-JGYHHJ4P.js → spec-cmd-Z6MGATWC.js} +16 -13
  112. package/dist/{starter-pack-GPU4X6B7.js → starter-pack-5SOT5V4I.js} +4 -3
  113. package/dist/{status-7WM7S7JX.js → status-PWMPP4ES.js} +39 -37
  114. package/dist/{sync-cmd-ATXJVS7S.js → sync-cmd-N4R7ST6X.js} +19 -16
  115. package/dist/{watch-M7NR3DOW.js → watch-L5MSAWEO.js} +19 -16
  116. package/dist/{work-claim-cmd-DNUDZKJA.js → work-claim-cmd-CXALMILD.js} +21 -18
  117. package/dist/{work-cmd-VECTYST6.js → work-cmd-COESFSHE.js} +16 -13
  118. package/dist/{work-comment-cmd-F3NRWKPZ.js → work-comment-cmd-A4ZUVCSA.js} +16 -13
  119. package/dist/{work-logs-cmd-QF6P32FE.js → work-logs-cmd-CTF43MBE.js} +16 -13
  120. package/dist/{work-open-pr-cmd-XE23JA3R.js → work-open-pr-cmd-EMGYJXVD.js} +17 -14
  121. package/dist/{work-pr-cmd-BH56GUKN.js → work-pr-cmd-FEXMS6RH.js} +16 -13
  122. package/dist/{work-stop-cmd-C3F5HNUO.js → work-stop-cmd-NIHAN45R.js} +16 -13
  123. package/package.json +1 -1
  124. package/dist/build-HRLACBOZ.js +0 -12
  125. package/dist/chunk-STSLH5EJ.js +0 -71
  126. package/dist/init-SWKYV6CL.js +0 -55
  127. package/dist/loop-AIJZVUNA.js +0 -79
  128. package/dist/pending-3YZCSKON.js +0 -9
  129. package/dist/{chunk-6BLXUD56.js → chunk-HOU33DW5.js} +1 -1
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { readRepoConnection, findGitDirs } from './chunk-BJ3KTMDH.js';
4
3
  import { readCloudConfigStrict, readCloudConfig, cloudConfigPath } from './chunk-PJDQPF5N.js';
4
+ import { signRunnerRequest, signerFor } from './chunk-YL2VDSNF.js';
5
+ import { readRepoConnection, findGitDirs } from './chunk-BJ3KTMDH.js';
6
+ import { PLAIN_VERSION, recordCliVersion, removeRecordedVersion } from './chunk-5BHIBJDA.js';
7
+ import { resolvePackageVersion } from './chunk-RA3O54FC.js';
5
8
  import { cliInvocation } from './chunk-CRB3POP4.js';
6
9
  import { homeFromEnv } from './chunk-VNVZDWO3.js';
7
- import { resolvePackageVersion } from './chunk-RA3O54FC.js';
8
- import { signRunnerRequest, signerFor } from './chunk-Y4OKEFAX.js';
9
10
 
10
11
  createRequire(import.meta.url);
11
12
 
@@ -122,10 +123,25 @@ function withCliUserAgent(base, userAgent = () => cliUserAgent()) {
122
123
  return base(input, { ...init, headers: withHeader(init?.headers, "user-agent", userAgent()) });
123
124
  });
124
125
  }
126
+ function recordingCliVersion(base) {
127
+ return (async (input, init) => {
128
+ const response = await base(input, init);
129
+ try {
130
+ const header = response.headers.get("outerlayer-cli-version");
131
+ if (header !== null) {
132
+ if (PLAIN_VERSION.test(header)) recordCliVersion(homeFromEnv(), header);
133
+ } else if (response.ok && new Headers(input instanceof Request ? input.headers : init?.headers).get("authorization")?.startsWith("Bearer ")) {
134
+ removeRecordedVersion(homeFromEnv());
135
+ }
136
+ } catch {
137
+ }
138
+ return response;
139
+ });
140
+ }
125
141
  function globalFetch(input, init) {
126
142
  return globalThis.fetch(input, init);
127
143
  }
128
- var cliFetch = withCliUserAgent(globalFetch);
144
+ var cliFetch = recordingCliVersion(withCliUserAgent(globalFetch));
129
145
  var defaultFetch = signingFetch(cliFetch);
130
146
 
131
147
  export { cliFetch, defaultFetch, resolveGatewayCredentials, signingFetchFor, unauthorizedMessage };
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { launcherPath, writeLauncher, LauncherWriteError, pathNotes } from './chunk-QHH4OSD4.js';
4
- import { currentVersion, currentLink, isInLayout, packageRootIn, versionDir, switchCurrent, execStartLine } from './chunk-MATUHHN4.js';
3
+ import { launcherPath, writeLauncher, LauncherWriteError, pathNotes } from './chunk-CTYSTE5C.js';
4
+ import { currentVersion, currentLink, isInLayout, packageRootIn, versionDir, switchCurrent, execStartLine } from './chunk-GUXWQIEY.js';
5
5
  import { compareVersions } from './chunk-TQMI335S.js';
6
- import { RUNNER_DIR_MODE } from './chunk-RHAGBUL5.js';
6
+ import { RUNNER_DIR_MODE } from './chunk-5K3KB4YR.js';
7
7
  import { realpathSync, readFileSync, mkdirSync, rmSync, cpSync, existsSync } from 'fs';
8
8
  import { dirname, sep, join } from 'path';
9
9
 
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from 'node:module';
3
+
4
+ createRequire(import.meta.url);
5
+
6
+ // src/maintained-line.ts
7
+ var MAINTAINED_SKILLS = ["outerlayer-evidence", "outerlayer-amend", "outerlayer-findings", "outerlayer-cli", "outerlayer-build"];
8
+ var MAINTAINED_LINE_VERSION = /^<!-- maintained by OuterLayer (\S+?)\. /m;
9
+ function maintainedLineVersion(text) {
10
+ return MAINTAINED_LINE_VERSION.exec(text)?.[1];
11
+ }
12
+
13
+ export { MAINTAINED_SKILLS, maintainedLineVersion };
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { currentLink } from './chunk-MATUHHN4.js';
3
+ import { currentLink } from './chunk-GUXWQIEY.js';
4
4
  import { readFileSync, statSync, chmodSync, mkdirSync, writeFileSync, renameSync, rmSync, existsSync, lstatSync, accessSync, constants, realpathSync } from 'fs';
5
5
  import { randomBytes } from 'crypto';
6
6
  import { join, dirname, delimiter, resolve } from 'path';
@@ -3,6 +3,8 @@ import { createRequire } from 'node:module';
3
3
  import { appendContextProvenance } from './chunk-ZJSNLVCE.js';
4
4
  import { CONTROL_PLANE_DIR_VARIABLE } from './chunk-HCVLP7XA.js';
5
5
  import { readRepoConnection, findGitDirs } from './chunk-BJ3KTMDH.js';
6
+ import { updateNoticeContext, staleMachineCopiesContext } from './chunk-5BHIBJDA.js';
7
+ import { resolvePackageVersion } from './chunk-RA3O54FC.js';
6
8
  import { cliInvocation } from './chunk-CRB3POP4.js';
7
9
  import { deadHooksState, huskyPrepareScript, preparePackageManagerCommand } from './chunk-TUSYOL2O.js';
8
10
  import { homeFromEnv } from './chunk-VNVZDWO3.js';
@@ -682,7 +684,7 @@ async function missingControlPlane(cwd, sessionId, home, env) {
682
684
  cleanupEarlierCopies(dirs);
683
685
  }
684
686
  if (!contextPossiblyGoverned(cwd, home)) return void 0;
685
- const { governanceOf } = await import('./control-plane-launch-DBQA3KLJ.js');
687
+ const { governanceOf } = await import('./control-plane-launch-FZMD4MXX.js');
686
688
  if (await governanceOf({ cwd, env, home }) !== "governed") return void 0;
687
689
  recordMissingContext(dirs, sessionId, home);
688
690
  const launcher = `${cliInvocation()} claude`;
@@ -754,6 +756,8 @@ async function runHookFast(event, home = homeFromEnv(), read = readStdin, env =
754
756
  let hookErrorsMessage;
755
757
  let renewalHookMessage;
756
758
  let machineSkillsMessage;
759
+ let updateNoticeMessage;
760
+ let staleCopiesMessage;
757
761
  if (resolvedEvent === "SessionStart") {
758
762
  const hookErrorsBytes = fileSizeBytes(join(dir, "hook-errors.log"));
759
763
  const hookErrorsSeen = hookErrorsSeenBytes(home);
@@ -776,6 +780,18 @@ async function runHookFast(event, home = homeFromEnv(), read = readStdin, env =
776
780
  } catch (err) {
777
781
  logHookError(home, err);
778
782
  }
783
+ try {
784
+ updateNoticeMessage = updateNoticeContext(home, resolvePackageVersion(), env) ?? void 0;
785
+ } catch (err) {
786
+ logHookError(home, err);
787
+ }
788
+ if (machineSkillsMessage === void 0) {
789
+ try {
790
+ staleCopiesMessage = staleMachineCopiesContext(home, resolvePackageVersion()) ?? void 0;
791
+ } catch (err) {
792
+ logHookError(home, err);
793
+ }
794
+ }
779
795
  try {
780
796
  deadHooksMessage = deadHooksAutoHealContext(sessionCwd, home) ?? void 0;
781
797
  } catch (err) {
@@ -800,7 +816,7 @@ async function runHookFast(event, home = homeFromEnv(), read = readStdin, env =
800
816
  sessionCwd,
801
817
  (out) => process.stdout.write(out),
802
818
  missingPlane?.person,
803
- [missingPlane?.agent, machineSkillsMessage, deadHooksMessage, workLaunchMessage, hookErrorsMessage, renewalHookMessage].filter(
819
+ [missingPlane?.agent, machineSkillsMessage, staleCopiesMessage, updateNoticeMessage, deadHooksMessage, workLaunchMessage, hookErrorsMessage, renewalHookMessage].filter(
804
820
  (s) => s !== void 0
805
821
  )
806
822
  );
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { MAINTAINED_SKILLS, loadMachineSkillFiles, resolvePackRoot, maintainedLineVersion } from './chunk-7OUOLGUV.js';
4
- import { homeFromEnv } from './chunk-VNVZDWO3.js';
3
+ import { loadMachineSkillFiles, resolvePackRoot } from './chunk-JGML2VUN.js';
4
+ import { MAINTAINED_SKILLS, maintainedLineVersion } from './chunk-CDDED64E.js';
5
5
  import { resolvePackageVersion } from './chunk-RA3O54FC.js';
6
+ import { homeFromEnv } from './chunk-VNVZDWO3.js';
6
7
  import { randomBytes } from 'crypto';
7
8
  import { existsSync, symlinkSync, realpathSync, lstatSync, readFileSync, mkdirSync, rmSync, renameSync, writeFileSync, cpSync } from 'fs';
8
9
  import { join, resolve, dirname, relative } from 'path';
@@ -48,10 +48,10 @@ async function fetchProvenance(version, fetchImpl) {
48
48
  }
49
49
 
50
50
  // src/runner/update/npm.ts
51
- function run(file, args, cwd) {
51
+ function run(file, args, cwd, env) {
52
52
  const COMMAND_TIMEOUT_MS = 10 * 6e4;
53
53
  return new Promise((resolve) => {
54
- const child = spawn(file, args, { cwd, stdio: ["ignore", "pipe", "pipe"], timeout: COMMAND_TIMEOUT_MS });
54
+ const child = spawn(file, args, { cwd, ...env === void 0 ? {} : { env }, stdio: ["ignore", "pipe", "pipe"], timeout: COMMAND_TIMEOUT_MS });
55
55
  let stdout = "";
56
56
  let stderr = "";
57
57
  child.stdout.on("data", (chunk) => stdout += chunk.toString());
@@ -66,10 +66,10 @@ function npmExecutable(nodePath) {
66
66
  }
67
67
  function realRunNpm(nodePath) {
68
68
  const npm = npmExecutable(nodePath);
69
- return (args, cwd) => run(npm, args, cwd);
69
+ return (args, cwd, env) => run(npm, args, cwd, env);
70
70
  }
71
71
  function realRunNode(nodePath) {
72
- return (args, cwd) => run(nodePath, args, cwd);
72
+ return (args, cwd, env) => run(nodePath, args, cwd, env);
73
73
  }
74
74
  function npmSupportsProvenance(version) {
75
75
  const match = /^(\d+)\.(\d+)/.exec(version.trim());
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
- import { DEFAULT_UNIT_NAME } from './chunk-7AQ5AM7U.js';
4
- import { parseRunnerEnv } from './chunk-STSLH5EJ.js';
5
- import { RUNNER_FILE_MODE } from './chunk-RHAGBUL5.js';
3
+ import { DEFAULT_UNIT_NAME } from './chunk-MQHTM4YJ.js';
4
+ import { RUNNER_FILE_MODE } from './chunk-5K3KB4YR.js';
5
+ import { claudeEnvPath, withoutCredentialLines } from './chunk-HXAEQPZR.js';
6
+ import { parseRunnerEnv } from './chunk-XD4ZCMA4.js';
6
7
  import { existsSync, readFileSync, writeFileSync, renameSync, rmSync } from 'fs';
7
8
  import { join, dirname } from 'path';
8
9
 
@@ -20,7 +21,6 @@ var CLAUDE_CREDENTIAL_NAMES = ["CLAUDE_CODE_OAUTH_TOKEN", "ANTHROPIC_API_KEY"];
20
21
  var RunnerEnvError = class extends Error {
21
22
  };
22
23
  var CREDENTIAL_SHAPE = /^sk-ant-(oat|api)[0-9]*-[A-Za-z0-9_-]+$/;
23
- var SETS = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)=/;
24
24
  function runnerEnvPath(configPath) {
25
25
  return join(dirname(configPath), "runner.env");
26
26
  }
@@ -35,18 +35,15 @@ function credentialFromStdin(text) {
35
35
  }
36
36
  return { variable: kind === "oat" ? "CLAUDE_CODE_OAUTH_TOKEN" : "ANTHROPIC_API_KEY", value };
37
37
  }
38
- function hasStoredCredential(configPath) {
39
- const path = runnerEnvPath(configPath);
38
+ function setsCredential(path) {
40
39
  if (!existsSync(path)) return false;
41
40
  const env = parseRunnerEnv(readFileSync(path, "utf8"));
42
41
  return CLAUDE_CREDENTIAL_NAMES.some((name) => env[name]);
43
42
  }
44
- function storeClaudeCredential(configPath, credential) {
45
- const path = runnerEnvPath(configPath);
46
- const kept = existsSync(path) ? readFileSync(path, "utf8").split("\n").filter((line) => !CLAUDE_CREDENTIAL_NAMES.includes(SETS.exec(line)?.[1] ?? "")) : [];
47
- while (kept[kept.length - 1] === "") kept.pop();
48
- const text = `${[...kept, `${credential.variable}=${credential.value}`].join("\n")}
49
- `;
43
+ function hasStoredCredential(configPath) {
44
+ return setsCredential(claudeEnvPath(configPath)) || setsCredential(runnerEnvPath(configPath));
45
+ }
46
+ function replaceFile(path, text) {
50
47
  const temporary = `${path}.${process.pid}.tmp`;
51
48
  try {
52
49
  writeFileSync(temporary, text, { mode: RUNNER_FILE_MODE, flag: "wx" });
@@ -55,11 +52,24 @@ function storeClaudeCredential(configPath, credential) {
55
52
  rmSync(temporary, { force: true });
56
53
  throw err;
57
54
  }
55
+ }
56
+ function storeClaudeCredential(configPath, credential) {
57
+ const path = claudeEnvPath(configPath);
58
+ replaceFile(path, `${credential.variable}=${credential.value}
59
+ `);
60
+ const runnerPath = runnerEnvPath(configPath);
61
+ if (existsSync(runnerPath)) {
62
+ const dropped = withoutCredentialLines(readFileSync(runnerPath, "utf8"));
63
+ if (dropped !== void 0) replaceFile(runnerPath, dropped);
64
+ }
58
65
  return path;
59
66
  }
60
67
  function restartForCredential(state, unitName = DEFAULT_UNIT_NAME) {
61
- if (state !== "pending-restart" && state !== "differs") return void 0;
62
- return `The service ${unitName} reads runner.env only when it starts. Restart it so it uses the stored credential: sudo systemctl restart ${unitName}`;
68
+ if (state === "differs") {
69
+ return `The service ${unitName} was not written by runner init, so it may not load claude.env, the one file that now holds the credential. Add EnvironmentFile=-<config directory>/claude.env to it, or run runner install --service --replace. Then restart it: sudo systemctl restart ${unitName}`;
70
+ }
71
+ if (state !== "pending-restart") return void 0;
72
+ return `The service ${unitName} loads claude.env only when it starts. Restart it so it uses the stored credential: sudo systemctl restart ${unitName}`;
63
73
  }
64
74
 
65
75
  export { AGENT_COMMANDS, RunnerEnvError, credentialFromStdin, hasStoredCredential, isAgentName, restartForCredential, storeClaudeCredential };
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
3
  import { rewriteControlPlanePaths, rewriteAgentsFilePaths, SUPPORTED_CONTROL_PLANE_LAYOUT, rewriteHookCommand } from './chunk-HCVLP7XA.js';
4
- import { MAINTAINED_SKILLS } from './chunk-7OUOLGUV.js';
4
+ import { MAINTAINED_SKILLS } from './chunk-CDDED64E.js';
5
5
  import { existsSync, mkdirSync, copyFileSync, lstatSync, readdirSync, writeFileSync, readFileSync } from 'fs';
6
6
  import { join, dirname } from 'path';
7
7