@outerlayer/cli 0.36.0-next.20261102124202 → 0.36.0-next.20261102195652

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 (180) hide show
  1. package/dist/agent-setup-5UWZZMZM.js +39 -0
  2. package/dist/agent-subcommand-4TEUJJNL.js +25 -0
  3. package/dist/{bridge-DFG2GTXQ.js → bridge-4KPODDN7.js} +6 -4
  4. package/dist/{build-THAD3B4Q.js → build-3CEFKWGY.js} +13 -11
  5. package/dist/{build-disk-HO2VPIBJ.js → build-disk-DLW3WKC5.js} +11 -9
  6. package/dist/build-info.json +1 -1
  7. package/dist/{builder-AXJNIF4S.js → builder-ALMQ5AWP.js} +10 -8
  8. package/dist/caller-XNBGW4SP.js +22 -0
  9. package/dist/{check-SF2OVZXB.js → check-AEDFTYH6.js} +61 -59
  10. package/dist/{chunk-772ILTCK.js → chunk-2XN34EKQ.js} +3 -3
  11. package/dist/{chunk-KN4VIK53.js → chunk-2YC3TXWX.js} +1 -1
  12. package/dist/{chunk-6JJITHBI.js → chunk-42DBDDHP.js} +1 -1
  13. package/dist/chunk-4DLJ343I.js +38 -0
  14. package/dist/{chunk-5WYT3PPE.js → chunk-4OD45RBP.js} +4 -1
  15. package/dist/{chunk-PTPF36Q7.js → chunk-4UUKUOS7.js} +3 -3
  16. package/dist/{chunk-RK4JQRVT.js → chunk-5XX75FJ6.js} +9 -9
  17. package/dist/{chunk-TWYHSMHM.js → chunk-6JLYU322.js} +3 -2
  18. package/dist/{chunk-5GHJFETA.js → chunk-6KH3NMIT.js} +3010 -1196
  19. package/dist/{chunk-GSXGA6KF.js → chunk-6QSIK5VA.js} +1 -1
  20. package/dist/{chunk-5FIOUQGC.js → chunk-6Z7R24XA.js} +8 -8
  21. package/dist/{chunk-LVXR37OG.js → chunk-73E33ZA2.js} +9 -8
  22. package/dist/{chunk-4TNUQLXH.js → chunk-7UGMB5VS.js} +12 -11
  23. package/dist/{chunk-J7TCTARR.js → chunk-7XTLS5PG.js} +5 -5
  24. package/dist/{chunk-K3X3L5YW.js → chunk-A24PDRNU.js} +6 -6
  25. package/dist/{chunk-GDZTL6BI.js → chunk-A2U7T4ZH.js} +123 -277
  26. package/dist/{chunk-GZ75FRLB.js → chunk-B36NSEUM.js} +1 -1
  27. package/dist/{chunk-XHFSBSIA.js → chunk-B5SWBFVE.js} +3 -2
  28. package/dist/{chunk-NTMRMBLM.js → chunk-BACWWK3E.js} +22 -7
  29. package/dist/{chunk-RSRZDF3K.js → chunk-BN5U4RJU.js} +11 -9
  30. package/dist/{chunk-NC3QAHOS.js → chunk-BSPJI5T7.js} +4 -2
  31. package/dist/{chunk-A5Y2HBVU.js → chunk-BZSJ77MO.js} +1 -1
  32. package/dist/{chunk-L3JXQDVH.js → chunk-CA4OE2QT.js} +4 -4
  33. package/dist/{chunk-ESSJPSJ2.js → chunk-CI5LFLKH.js} +2 -2
  34. package/dist/{chunk-M2NIHHQI.js → chunk-CXJC3JLN.js} +3 -2
  35. package/dist/{chunk-WDQPBAFV.js → chunk-D6EXW4EB.js} +2 -1
  36. package/dist/{chunk-PQDFW422.js → chunk-D74RGORK.js} +1 -1
  37. package/dist/{chunk-NWBB2SQ4.js → chunk-DL2RYNXQ.js} +66 -25
  38. package/dist/{chunk-J7Y3PCO2.js → chunk-DTQPDMHG.js} +2 -1
  39. package/dist/{chunk-6LO62EQ5.js → chunk-F36EKGMP.js} +712 -249
  40. package/dist/{chunk-HIN4BMRW.js → chunk-FIUUESD4.js} +5 -5
  41. package/dist/{chunk-XLOM2BNL.js → chunk-FOSYM7TQ.js} +1 -1
  42. package/dist/{chunk-LCOQN6NR.js → chunk-FWKQHKCR.js} +4 -4
  43. package/dist/{chunk-IP7BIBXJ.js → chunk-FWSVWPMS.js} +16 -7
  44. package/dist/{chunk-GD6KIHOS.js → chunk-G35Y4LN5.js} +5 -2
  45. package/dist/{chunk-LSXHTBAM.js → chunk-GBGJGYEE.js} +7 -7
  46. package/dist/{chunk-Q42K6XZ6.js → chunk-H23JP73I.js} +1 -1
  47. package/dist/{chunk-WLMAGMTU.js → chunk-H2NJG3TE.js} +4 -3
  48. package/dist/{chunk-4CTVN3C5.js → chunk-HRBSEXYC.js} +5 -5
  49. package/dist/{chunk-T5Z22NA6.js → chunk-HRHWA6TZ.js} +1 -1
  50. package/dist/chunk-HTRDL42C.js +45 -0
  51. package/dist/{chunk-WNYH42PF.js → chunk-HZVS4MGL.js} +7 -7
  52. package/dist/{chunk-YBAVN6WS.js → chunk-I4DM7SNX.js} +7 -7
  53. package/dist/{chunk-CKPQOQFC.js → chunk-I6U6QPN6.js} +769 -101
  54. package/dist/{chunk-QJDX6VJS.js → chunk-IX6CFXSW.js} +10 -9
  55. package/dist/{chunk-FIO6PIZ6.js → chunk-J2OMKFYB.js} +3 -3
  56. package/dist/{chunk-C3JWWPLC.js → chunk-J6HWRVN2.js} +10 -8
  57. package/dist/{chunk-PT34C6SU.js → chunk-J6VC3JCG.js} +1 -1
  58. package/dist/{chunk-I6FRCBMU.js → chunk-JBPVEXHQ.js} +8 -8
  59. package/dist/{chunk-EBIYRRJW.js → chunk-JVHWWJ2J.js} +80 -94
  60. package/dist/{chunk-LYFLUNWK.js → chunk-KN3TDNF7.js} +7 -7
  61. package/dist/{chunk-RPZIHELI.js → chunk-LHHDX7FB.js} +5 -5
  62. package/dist/{chunk-FUJUFLDC.js → chunk-LO4CK734.js} +8 -14
  63. package/dist/chunk-LSLK4RS4.js +82 -0
  64. package/dist/{chunk-I626B72C.js → chunk-LSZUTI6O.js} +1 -1
  65. package/dist/{chunk-JVCQZDQ6.js → chunk-LZS5EYZ6.js} +1 -1
  66. package/dist/{chunk-OYKAOHX5.js → chunk-M4HH2F64.js} +6 -6
  67. package/dist/{chunk-CVGQ3BNF.js → chunk-ML5YKV3B.js} +1 -1
  68. package/dist/{chunk-H2FFONRY.js → chunk-MVPOYQQY.js} +1 -1
  69. package/dist/{chunk-JXXHLQQR.js → chunk-NMBXA3AT.js} +3 -3
  70. package/dist/{chunk-VRQM4A64.js → chunk-PBGNX3PS.js} +1 -1
  71. package/dist/{chunk-CJJDJ7AT.js → chunk-PIZA7OG2.js} +5 -3
  72. package/dist/{chunk-L2BA2HXM.js → chunk-PN4LWT5F.js} +1 -1
  73. package/dist/{chunk-TYCZVJTB.js → chunk-PSQEGJPN.js} +5 -5
  74. package/dist/{chunk-EUDG754F.js → chunk-SBZ545DH.js} +2 -2
  75. package/dist/{chunk-5FND4PIU.js → chunk-T2KBHW6P.js} +3 -3
  76. package/dist/chunk-T5QBWM6M.js +113 -0
  77. package/dist/{chunk-XABJMU5A.js → chunk-UCMIS74X.js} +2 -2
  78. package/dist/{chunk-564Q2STF.js → chunk-VKKKVYA4.js} +1 -1
  79. package/dist/{chunk-AAGU5FJF.js → chunk-WGC7UFRM.js} +1 -1
  80. package/dist/{chunk-XAOIHYPS.js → chunk-WVAXJOWG.js} +5 -4
  81. package/dist/{chunk-AYLYAOHH.js → chunk-XIDDJSQU.js} +3 -2
  82. package/dist/{chunk-OZOATEK3.js → chunk-Y2P3HWUG.js} +6 -6
  83. package/dist/{chunk-PKO5IDW4.js → chunk-Y5S2G2EZ.js} +7 -7
  84. package/dist/{chunk-WQB3XOEP.js → chunk-Z3MB7SV7.js} +6 -6
  85. package/dist/{chunk-XE3DIJJT.js → chunk-Z66CKWOM.js} +1 -1
  86. package/dist/chunk-ZHQC43NH.js +130 -0
  87. package/dist/{chunk-3FSKTGM6.js → chunk-ZSRMJOAK.js} +3 -3
  88. package/dist/{claude-launcher-LXZPTDNC.js → claude-launcher-NJGZUB3P.js} +82 -108
  89. package/dist/{cli-QFUT3UQS.js → cli-POIDBCZA.js} +323 -293
  90. package/dist/{command-45RZT4CK.js → command-ZLBFX553.js} +55 -53
  91. package/dist/config-GKSSGMXD.js +21 -0
  92. package/dist/{connect-cmd-LUCQ7FSV.js → connect-cmd-6YKNFJJR.js} +12 -10
  93. package/dist/{container-start-T776VI3M.js → container-start-55QELXPJ.js} +53 -51
  94. package/dist/{context-cleanup-QE2MIO2Q.js → context-cleanup-3K2AOECJ.js} +4 -2
  95. package/dist/{context-show-cmd-7QEHUOEL.js → context-show-cmd-FGMRJ7IG.js} +13 -11
  96. package/dist/{control-plane-launch-THUH6YU5.js → control-plane-launch-DGPA3ONU.js} +25 -21
  97. package/dist/{demo-record-cmd-SBERRQNW.js → demo-record-cmd-2OKCGST7.js} +7 -5
  98. package/dist/{demo-voice-cmd-VM3FITZU.js → demo-voice-cmd-BPTSL7JA.js} +24 -22
  99. package/dist/{dist-6KGTCWKR.js → dist-VVZIGSAF.js} +1 -1
  100. package/dist/{docker-MQNLK4OO.js → docker-GFEEV42Z.js} +10 -8
  101. package/dist/{doctor-NQOSPJGS.js → doctor-ZOQSI3HL.js} +55 -53
  102. package/dist/emit-artifact-cmd-3LDJ4VRW.js +43 -0
  103. package/dist/{emit-cmd-ZPFCPVSR.js → emit-cmd-RO4L4PFZ.js} +7 -5
  104. package/dist/emit-criteria-cmd-V3ERJXHB.js +34 -0
  105. package/dist/{emit-demo-cmd-PMQGNNVX.js → emit-demo-cmd-5KL64L74.js} +24 -22
  106. package/dist/{emit-finding-cmd-MYWQN5WW.js → emit-finding-cmd-R4OEWQQR.js} +17 -15
  107. package/dist/{emit-result-cmd-GXK3KMAP.js → emit-result-cmd-5YNQDTYG.js} +22 -20
  108. package/dist/{emit-step-cmd-ZV2XTUVT.js → emit-step-cmd-Z5WC7UEQ.js} +17 -15
  109. package/dist/{exec-client-P7RFRUCK.js → exec-client-54XKNPTI.js} +7 -5
  110. package/dist/find-unit-OI56YEX5.js +23 -0
  111. package/dist/{findings-cmd-OGMBVVSM.js → findings-cmd-J5ZCY2AT.js} +17 -15
  112. package/dist/{fleet-readiness-4RBKLXBQ.js → fleet-readiness-DKCFOUYP.js} +13 -11
  113. package/dist/{governing-source-XJMXFSAR.js → governing-source-7PD4ISRN.js} +21 -19
  114. package/dist/{guest-init-XZHRPIMG.js → guest-init-5QZRGP62.js} +8 -6
  115. package/dist/{hook-fast-ZOWGWCPO.js → hook-fast-ICT2PRQX.js} +4 -2
  116. package/dist/{pending-YU2GE2UV.js → hook-install-GDNRMML4.js} +5 -5
  117. package/dist/{hook-wrap-fast-545QJSBJ.js → hook-wrap-fast-LWWKKPGK.js} +4 -2
  118. package/dist/host-checks-GADKYJFN.js +78 -0
  119. package/dist/host-key-FI6KWMJC.js +16 -0
  120. package/dist/{image-tag-E4JK2APF.js → image-tag-RX4WTHJH.js} +7 -5
  121. package/dist/index.js +8 -9
  122. package/dist/{init-LO6U7YTW.js → init-BZXVQO22.js} +51 -49
  123. package/dist/init-EKF4ILHF.js +78 -0
  124. package/dist/{init-cmd-2JANO5EN.js → init-cmd-3LWFEKHD.js} +35 -29
  125. package/dist/{init-update-D6PRTGNE.js → init-update-THEHC25C.js} +24 -22
  126. package/dist/{install-cmd-SJMBNQEH.js → install-cmd-WBVTTE5Z.js} +9 -7
  127. package/dist/{layout-AQHIMJMO.js → layout-7XMC7S6K.js} +4 -2
  128. package/dist/{logs-NE55HOET.js → logs-7YIXBO2K.js} +6 -4
  129. package/dist/loop-RUQQ4L5A.js +89 -0
  130. package/dist/machine-IGHZW3IO.js +78 -0
  131. package/dist/{machine-skills-KK2HXYMR.js → machine-skills-HR4RNRNR.js} +4 -2
  132. package/dist/{mcp-install-cmd-2QAS3AQZ.js → mcp-install-cmd-SMPLT43Q.js} +4 -2
  133. package/dist/{mcp-serve-cmd-U6USKHYR.js → mcp-serve-cmd-HLS24XCG.js} +8 -6
  134. package/dist/{paths-O7LCWY33.js → paths-2YTU4QIO.js} +6 -4
  135. package/dist/pending-S2SKIBCB.js +16 -0
  136. package/dist/{pidfile-5GDCQ5HA.js → pidfile-SPBTMTCJ.js} +7 -5
  137. package/dist/{record-NETSDAO6.js → record-3KXRFK5C.js} +7 -5
  138. package/dist/{relay-VZ733BVJ.js → relay-I2T43PPB.js} +4 -2
  139. package/dist/{relay-protocol-24GEUGCO.js → relay-protocol-GI2GC2AM.js} +4 -2
  140. package/dist/runner-env-HOWRS6I6.js +23 -0
  141. package/dist/{runner-identity-PSCZBILD.js → runner-identity-32MTGA2F.js} +10 -8
  142. package/dist/{runner-key-VM2LYVRK.js → runner-key-FXYWHMMO.js} +51 -49
  143. package/dist/{session-sender-P2RHDM6U.js → session-sender-B6INUY7G.js} +23 -21
  144. package/dist/{shell-function-NRD4KVUK.js → shell-function-GYD2ZQQG.js} +2 -1
  145. package/dist/{spec-cmd-LGKP6MT7.js → spec-cmd-ZEZFMC4A.js} +18 -16
  146. package/dist/{starter-pack-SMK6UPRL.js → starter-pack-IMKIUA56.js} +5 -3
  147. package/dist/state-DVKFUWB3.js +16 -0
  148. package/dist/{status-HEHCNIDS.js → status-VPFIIHOZ.js} +51 -49
  149. package/dist/{statusline-fast-E7RWVREA.js → statusline-fast-NUVHCNRX.js} +4 -2
  150. package/dist/{sync-cmd-HKN45HXL.js → sync-cmd-W756BQWX.js} +22 -20
  151. package/dist/update-steps-D6L6AG6E.js +79 -0
  152. package/dist/{watch-RGZCUCR3.js → watch-6EDRJZMG.js} +22 -20
  153. package/dist/{work-claim-cmd-6DSPGCZE.js → work-claim-cmd-7HR4AVCT.js} +22 -20
  154. package/dist/{work-cmd-GPLYLWY7.js → work-cmd-ZP4UIHBT.js} +15 -13
  155. package/dist/{work-comment-cmd-V5WM7LAW.js → work-comment-cmd-CYDOEMW3.js} +18 -16
  156. package/dist/{work-demo-cmd-SWWI6AGD.js → work-demo-cmd-3A7Z3VVS.js} +15 -13
  157. package/dist/{work-launch-TTGSHLY4.js → work-launch-LWDQXLGI.js} +1 -1
  158. package/dist/{work-logs-cmd-CTFBOPCI.js → work-logs-cmd-NDPSRSCM.js} +15 -13
  159. package/dist/{work-open-pr-cmd-HX2U3YBR.js → work-open-pr-cmd-Z5B3ERAU.js} +17 -15
  160. package/dist/{work-pr-cmd-EI2R4FQG.js → work-pr-cmd-ZVPGCDWD.js} +16 -14
  161. package/dist/{work-proofs-cmd-QXNPHLYC.js → work-proofs-cmd-VAXJ5UBF.js} +18 -16
  162. package/dist/{work-proofs-record-72OKWEES.js → work-proofs-record-K467JH24.js} +28 -26
  163. package/dist/{work-stop-cmd-7M7ZYUN2.js → work-stop-cmd-J45Q2QT7.js} +15 -13
  164. package/package.json +3 -3
  165. package/dist/agent-setup-AOB76EDJ.js +0 -37
  166. package/dist/caller-GOY2X6QT.js +0 -20
  167. package/dist/chunk-KYDEBGJG.js +0 -402
  168. package/dist/config-WYQPXLOP.js +0 -19
  169. package/dist/emit-artifact-cmd-6E365VBQ.js +0 -41
  170. package/dist/emit-criteria-cmd-HWQOYZZ4.js +0 -32
  171. package/dist/find-unit-63SXQ7IM.js +0 -21
  172. package/dist/host-checks-WHW24PJR.js +0 -76
  173. package/dist/host-key-MWLXB5U5.js +0 -14
  174. package/dist/init-EZIAHBMH.js +0 -76
  175. package/dist/loop-2E34CGCX.js +0 -87
  176. package/dist/machine-6ALGG4IO.js +0 -76
  177. package/dist/runner-env-KHCONH2R.js +0 -21
  178. package/dist/settings-XB2HYBKO.js +0 -7
  179. package/dist/state-RJR4PMMX.js +0 -14
  180. package/dist/update-steps-7E4RD47J.js +0 -77
@@ -1,13 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module';
3
3
  import { RESERVED_EMIT_NAMES, ARTIFACT_KINDS, ArtifactCriterionIdSchema } from './chunk-WUKLQWGY.js';
4
+ import { CLAUDE_CODE_HOOKS } from './chunk-T5QBWM6M.js';
5
+ import { CLAUDE_CODE, NATIVE_AGENTS, LEGACY_AGENT } from './chunk-LSLK4RS4.js';
4
6
  import { MAINTAINED_SKILLS } from './chunk-CDDED64E.js';
5
7
  import { resolvePackageVersion } from './chunk-RA3O54FC.js';
6
8
  import { homeFromEnv } from './chunk-352DHUTP.js';
7
9
  import { __commonJS, __require, __toESM } from './chunk-Z5GEFMRW.js';
8
- import { existsSync, readFileSync, mkdirSync, writeFileSync, readdirSync, rmSync, renameSync, realpathSync, readlinkSync, symlinkSync, copyFileSync, lstatSync } from 'fs';
10
+ import { existsSync, readFileSync, mkdirSync, writeFileSync, readdirSync, rmSync, renameSync, realpathSync, readlinkSync, symlinkSync, copyFileSync, statSync, accessSync, constants, lstatSync } from 'fs';
9
11
  import { join as join$1, dirname } from 'path';
10
12
  import { fileURLToPath } from 'url';
13
+ import { spawnSync } from 'child_process';
11
14
  import { homedir } from 'os';
12
15
 
13
16
  createRequire(import.meta.url);
@@ -7270,6 +7273,21 @@ var require_dist = __commonJS({
7270
7273
  }
7271
7274
  });
7272
7275
 
7276
+ // ../agents/src/adapter.ts
7277
+ var McpFileError = class extends Error {
7278
+ constructor(problem) {
7279
+ super(`the MCP file ${problem}`);
7280
+ this.problem = problem;
7281
+ }
7282
+ };
7283
+ var HookTextError = class extends Error {
7284
+ constructor(cause) {
7285
+ super(`the hook settings are not valid: ${cause instanceof Error ? cause.message : String(cause)}`);
7286
+ this.cause = cause;
7287
+ this.name = "HookTextError";
7288
+ }
7289
+ };
7290
+
7273
7291
  // ../context-format/dist/index.js
7274
7292
  var import_yaml = __toESM(require_dist(), 1);
7275
7293
  function normalizePath(path) {
@@ -8506,90 +8524,6 @@ function parseProofsConfig(text) {
8506
8524
  return problems.length > 0 ? { ok: false, problems } : { ok: true, value: { setup, teardown, runners } };
8507
8525
  }
8508
8526
 
8509
- // ../agents/src/claude-code/descriptor.ts
8510
- var CLAUDE_CODE = {
8511
- id: "claude-code",
8512
- label: "Claude Code",
8513
- color: "#D97757",
8514
- program: "claude",
8515
- legacy: {
8516
- subcommand: "claude",
8517
- runnerName: "claude",
8518
- usageEventValue: "claude_code",
8519
- envFile: "claude.env",
8520
- credentialId: "claude",
8521
- imagePaths: ["/opt/outerlayer/claude", "/usr/local/bin/claude", "/etc/claude-code"],
8522
- toolsVersionKey: "claudeCodeVersion",
8523
- handOffKey: "claudeCredential"
8524
- },
8525
- versions: { minimum: "2.1.284", tested: { from: "2.1.0", to: "2.1.255" } },
8526
- providers: ["anthropic"],
8527
- credentials: {
8528
- label: "Claude",
8529
- setupCommand: "claude setup-token",
8530
- forwarded: ["CLAUDE_CODE_OAUTH_TOKEN", "ANTHROPIC_API_KEY"],
8531
- stripped: ["CLAUDE_CODE_OAUTH_TOKEN", "ANTHROPIC_API_KEY", "ANTHROPIC_AUTH_TOKEN"],
8532
- placeholders: {
8533
- CLAUDE_CODE_OAUTH_TOKEN: "sk-ant-oat01-placeholder-not-a-real-token",
8534
- ANTHROPIC_API_KEY: "sk-ant-api03-placeholder-not-a-real-key"
8535
- },
8536
- kinds: {
8537
- CLAUDE_CODE_OAUTH_TOKEN: { pattern: "^sk-ant-oat[0-9]*-[A-Za-z0-9_-]+$", provider: "anthropic", providerKind: "oauth-token", starts: "sk-ant-oat" },
8538
- ANTHROPIC_API_KEY: { pattern: "^sk-ant-api[0-9]*-[A-Za-z0-9_-]+$", provider: "anthropic", providerKind: "api-key", starts: "sk-ant-api" },
8539
- ANTHROPIC_AUTH_TOKEN: { pattern: ".+", provider: "anthropic", providerKind: "oauth-token", starts: "" }
8540
- }
8541
- },
8542
- context: {
8543
- instructionFiles: ["CLAUDE.md"],
8544
- repoSkillFolders: [".claude/skills"],
8545
- userSkillFolder: "~/.claude/skills",
8546
- attach: "additive",
8547
- native: ["agents-md", "skills", "settings-hooks", "subagents", "commands", "mcp"]
8548
- },
8549
- capabilities: {
8550
- sessionId: "assignable",
8551
- resume: true,
8552
- fork: true,
8553
- subagents: { spawnTools: ["Agent", "Task"], transcript: "separate-file" },
8554
- cost: "status-line",
8555
- longCommands: "blocking",
8556
- permission: { unattended: "bypassPermissions", "accept-edits": "acceptEdits", plan: "plan", default: "default" },
8557
- structuredOutput: true,
8558
- mcp: true,
8559
- judge: true
8560
- },
8561
- hooks: { contextCap: 1e4, timeoutCeilingMs: 6e5 }
8562
- };
8563
-
8564
- // ../agents/src/native/agents.ts
8565
- var NATIVE_AGENTS = {
8566
- "claude-code": CLAUDE_CODE
8567
- };
8568
- var LEGACY_AGENT = "claude-code";
8569
-
8570
- // ../agents/src/providers/index.ts
8571
- var PROVIDERS = {
8572
- anthropic: {
8573
- id: "anthropic",
8574
- label: "Anthropic",
8575
- upstream: "https://api.anthropic.com/",
8576
- credentialKinds: [
8577
- { id: "api-key", label: "API key", header: "x-api-key", prefix: "" },
8578
- { id: "oauth-token", label: "OAuth token", header: "Authorization", prefix: "Bearer " }
8579
- ],
8580
- droppedHeaders: ["x-api-key", "authorization"],
8581
- destination: { name: "claude", port: 3127, socket: "claude.sock" }
8582
- }
8583
- };
8584
-
8585
- // ../agents/src/adapter.ts
8586
- var McpFileError = class extends Error {
8587
- constructor(problem) {
8588
- super(`the MCP file ${problem}`);
8589
- this.problem = problem;
8590
- }
8591
- };
8592
-
8593
8527
  // ../agents/src/claude-code/credentials.ts
8594
8528
  var { forwarded, kinds, placeholders } = CLAUDE_CODE.credentials;
8595
8529
  var FORWARDED = forwarded;
@@ -8662,7 +8596,7 @@ function parentOf(path) {
8662
8596
  return cut <= 0 ? path.slice(0, cut + 1) : path.slice(0, cut);
8663
8597
  }
8664
8598
  function filesOf(fs) {
8665
- const exists = (path) => {
8599
+ const exists2 = (path) => {
8666
8600
  const kind = fs.kind(path);
8667
8601
  if (kind !== "link") return kind !== "missing";
8668
8602
  try {
@@ -8684,7 +8618,7 @@ function filesOf(fs) {
8684
8618
  };
8685
8619
  const readText = (path) => fs.kind(path) === "file" ? fs.readText(path) : void 0;
8686
8620
  const isFile = (path) => fs.kind(path) === "file";
8687
- return { exists, filesUnder: filesUnder2, readText, isFile };
8621
+ return { exists: exists2, filesUnder: filesUnder2, readText, isFile };
8688
8622
  }
8689
8623
  function deliveredSettings(raw, dir) {
8690
8624
  if (raw === void 0) return "{}\n";
@@ -8703,7 +8637,7 @@ function deliveredSettings(raw, dir) {
8703
8637
  }
8704
8638
  function createDelivery(io) {
8705
8639
  const { fs } = io;
8706
- const { exists, filesUnder: filesUnder2, readText, isFile } = filesOf(fs);
8640
+ const { exists: exists2, filesUnder: filesUnder2, readText, isFile } = filesOf(fs);
8707
8641
  return {
8708
8642
  compose({ tree, dir, maintainedSkills }) {
8709
8643
  const added = [];
@@ -8715,16 +8649,16 @@ function createDelivery(io) {
8715
8649
  for (const skill of maintainedSkills) {
8716
8650
  for (const rel of filesUnder2(join(tree, ".outerlayer/skills", skill))) {
8717
8651
  const target = `.claude/skills/${skill}/${rel}`;
8718
- if (exists(join(tree, target))) continue;
8652
+ if (exists2(join(tree, target))) continue;
8719
8653
  fs.makeDir(parentOf(join(tree, target)));
8720
8654
  fs.copy(join(tree, ".outerlayer/skills", skill, rel), join(tree, target));
8721
8655
  added.push(target);
8722
8656
  }
8723
8657
  }
8724
8658
  const agentSkills = join(tree, ".agents/skills");
8725
- if (exists(agentSkills) && fs.kind(agentSkills) === "directory") {
8659
+ if (exists2(agentSkills) && fs.kind(agentSkills) === "directory") {
8726
8660
  for (const name of fs.list(agentSkills)) {
8727
- if (fs.kind(join(agentSkills, name)) !== "directory" || exists(join(tree, ".claude/skills", name))) continue;
8661
+ if (fs.kind(join(agentSkills, name)) !== "directory" || exists2(join(tree, ".claude/skills", name))) continue;
8728
8662
  for (const rel of filesUnder2(join(agentSkills, name))) {
8729
8663
  const target = `.claude/skills/${name}/${rel}`;
8730
8664
  fs.makeDir(parentOf(join(tree, target)));
@@ -8750,13 +8684,608 @@ ${instructions}`);
8750
8684
  },
8751
8685
  deliveredSkills(tree) {
8752
8686
  const dir = join(tree, ".claude/skills");
8753
- if (!exists(dir)) return [];
8687
+ if (!exists2(dir)) return [];
8754
8688
  return fs.list(dir).filter((name) => fs.kind(join(dir, name)) === "directory").sort();
8755
8689
  },
8756
8690
  escapesDelivery: hookCommandEscapesControlPlane
8757
8691
  };
8758
8692
  }
8759
8693
 
8694
+ // ../agents/src/claude-code/settings.ts
8695
+ var REGISTERED_EVENTS = CLAUDE_CODE_HOOKS.events;
8696
+ var MARKER = "_outerlayer";
8697
+ var WRAP_MARKER = "_outerlayerWrapped";
8698
+ function ourCommandBins(settings, cli) {
8699
+ return unique(ourCommandLaunches(settings, cli).map((launch) => launch.bin));
8700
+ }
8701
+ function ourDirectScriptBins(settings, cli) {
8702
+ return unique(ourCommandLaunches(settings, cli).filter((launch) => !launch.viaNode && launch.script).map((launch) => launch.bin));
8703
+ }
8704
+ function ourCommandLaunches(settings, cli) {
8705
+ const launches = [];
8706
+ const add = (command) => {
8707
+ const parsed = cli.split(command);
8708
+ if (!parsed || parsed.viaNpx) return;
8709
+ if (!["hook", "hook-wrap", "statusline"].includes(parsed.args[0] ?? "")) return;
8710
+ if (parsed.bin.includes("$") || !isAbsolutePath(parsed.bin)) return;
8711
+ launches.push(parsed);
8712
+ };
8713
+ for (const matchers of Object.values(settings?.hooks ?? {})) {
8714
+ for (const matcher of matchers ?? []) for (const h of matcher.hooks ?? []) add(h.command);
8715
+ }
8716
+ add(settings?.statusLine?.command);
8717
+ return launches;
8718
+ }
8719
+ function isAbsolutePath(path) {
8720
+ return path.startsWith("/") || /^[A-Za-z]:[\\/]/.test(path) || path.startsWith("\\\\");
8721
+ }
8722
+ function unique(values) {
8723
+ return [...new Set(values)];
8724
+ }
8725
+ function parseLifecycleHookCommand(command, cli) {
8726
+ const args = cli.parse(command);
8727
+ if (!args || args.length !== 2 || args[0] !== "hook") return null;
8728
+ return REGISTERED_EVENTS.includes(args[1]) ? args[1] : null;
8729
+ }
8730
+ function parseWrappedHookCommand(command, cli) {
8731
+ const args = cli.parse(command);
8732
+ if (!args || args[0] !== "hook-wrap" || args[1] !== "--id") return null;
8733
+ if (args.length === 4 ? args[3] !== "--capture-output" : args.length !== 3) return null;
8734
+ return cli.decode(args[2]);
8735
+ }
8736
+ function isOurHookCommand(h, cli) {
8737
+ return h[MARKER] === true || parseLifecycleHookCommand(h.command, cli) !== null;
8738
+ }
8739
+ function wrappedOriginalCommand(h, cli) {
8740
+ if (typeof h[WRAP_MARKER] === "string") return h[WRAP_MARKER];
8741
+ return parseWrappedHookCommand(h.command, cli);
8742
+ }
8743
+ function isWrapped(h, cli) {
8744
+ return wrappedOriginalCommand(h, cli) !== null;
8745
+ }
8746
+ function ourEntry(cli, event) {
8747
+ return {
8748
+ hooks: [{ type: "command", command: cli.command(`hook ${event}`), [MARKER]: true }]
8749
+ };
8750
+ }
8751
+ function pruneOurHooks(blocks, cli) {
8752
+ let removedAny = false;
8753
+ const kept = blocks.filter((block) => {
8754
+ const original = block.hooks ?? [];
8755
+ const remaining = original.filter((h) => !isOurHookCommand(h, cli));
8756
+ if (remaining.length !== original.length) {
8757
+ removedAny = true;
8758
+ block.hooks = remaining;
8759
+ }
8760
+ return remaining.length > 0 || original.length === 0;
8761
+ });
8762
+ return { kept, removedAny };
8763
+ }
8764
+ function mergeHooks(settings, cli) {
8765
+ const next = settings ? structuredClone(settings) : {};
8766
+ next.hooks = next.hooks ? { ...next.hooks } : {};
8767
+ let changed = false;
8768
+ for (const event of REGISTERED_EVENTS) {
8769
+ const existing = next.hooks[event] ?? [];
8770
+ const before = JSON.stringify(existing);
8771
+ const foreign = pruneOurHooks(existing, cli).kept;
8772
+ const desired = [...foreign, ourEntry(cli, event)];
8773
+ if (before !== JSON.stringify(desired)) changed = true;
8774
+ next.hooks[event] = desired;
8775
+ }
8776
+ return { next, changed };
8777
+ }
8778
+ function removeHooks(settings, cli) {
8779
+ const next = settings ? structuredClone(settings) : {};
8780
+ if (!next.hooks) return { next, changed: false };
8781
+ let changed = false;
8782
+ for (const event of Object.keys(next.hooks)) {
8783
+ const { kept, removedAny } = pruneOurHooks(next.hooks[event] ?? [], cli);
8784
+ if (removedAny) changed = true;
8785
+ if (kept.length === 0) delete next.hooks[event];
8786
+ else next.hooks[event] = kept;
8787
+ }
8788
+ if (next.hooks && Object.keys(next.hooks).length === 0) delete next.hooks;
8789
+ return { next, changed };
8790
+ }
8791
+ function runsCommand(h) {
8792
+ return typeof h.command === "string";
8793
+ }
8794
+ function listHookCandidates(settings, cli) {
8795
+ const out = [];
8796
+ const hooks = settings?.hooks ?? {};
8797
+ for (const event of Object.keys(hooks)) {
8798
+ (hooks[event] ?? []).forEach((matcher, matcherIndex) => {
8799
+ matcher.hooks.forEach((h, hookIndex) => {
8800
+ if (!runsCommand(h) || isOurHookCommand(h, cli)) return;
8801
+ const original = wrappedOriginalCommand(h, cli);
8802
+ out.push({
8803
+ event,
8804
+ matcherIndex,
8805
+ hookIndex,
8806
+ matcher: matcher.matcher,
8807
+ command: original ?? h.command,
8808
+ wrapped: original !== null
8809
+ });
8810
+ });
8811
+ });
8812
+ }
8813
+ return out;
8814
+ }
8815
+ function wrapHookCommand(cli, h, opts = {}) {
8816
+ if (isWrapped(h, cli)) return h;
8817
+ const flag = opts.captureOutput ? " --capture-output" : "";
8818
+ return { ...h, command: cli.command(`hook-wrap --id ${cli.encode(h.command)}${flag}`), [WRAP_MARKER]: h.command };
8819
+ }
8820
+ function unwrapHookCommand(h, cli) {
8821
+ const original = wrappedOriginalCommand(h, cli);
8822
+ if (original === null) return h;
8823
+ const restored = { ...h, command: original };
8824
+ delete restored[WRAP_MARKER];
8825
+ return restored;
8826
+ }
8827
+ var AUTO_WRAP_EVENTS = ["PreToolUse", "PostToolUse"];
8828
+ function wrapHooks(settings, cli, opts = {}) {
8829
+ const next = settings ? structuredClone(settings) : {};
8830
+ const wrapped = [];
8831
+ if (!cli.resolvable()) {
8832
+ return { next, changed: false, wrapped, skippedUnresolvedBin: true };
8833
+ }
8834
+ let changed = false;
8835
+ if (!next.hooks) return { next, changed, wrapped };
8836
+ for (const event of Object.keys(next.hooks)) {
8837
+ if (opts.events && !opts.events.includes(event)) continue;
8838
+ const matchers = next.hooks[event] ?? [];
8839
+ for (let mi = 0; mi < matchers.length; mi++) {
8840
+ const matcher = matchers[mi];
8841
+ for (let hi = 0; hi < matcher.hooks.length; hi++) {
8842
+ const h = matcher.hooks[hi];
8843
+ if (!runsCommand(h) || isOurHookCommand(h, cli) || isWrapped(h, cli)) continue;
8844
+ const candidate = {
8845
+ event,
8846
+ matcherIndex: mi,
8847
+ hookIndex: hi,
8848
+ matcher: matcher.matcher,
8849
+ command: h.command,
8850
+ wrapped: false
8851
+ };
8852
+ if (opts.select && !opts.select(candidate)) continue;
8853
+ matcher.hooks[hi] = wrapHookCommand(cli, h, { captureOutput: opts.captureOutput });
8854
+ wrapped.push(candidate);
8855
+ changed = true;
8856
+ }
8857
+ }
8858
+ }
8859
+ return { next, changed, wrapped };
8860
+ }
8861
+ function repointWrappedHooks(settings, cli) {
8862
+ const next = settings ? structuredClone(settings) : {};
8863
+ let changed = false;
8864
+ if (!next.hooks || !cli.resolvable()) return { next, changed };
8865
+ for (const matchers of Object.values(next.hooks)) {
8866
+ for (const matcher of matchers ?? []) {
8867
+ for (let hi = 0; hi < matcher.hooks.length; hi++) {
8868
+ const h = matcher.hooks[hi];
8869
+ const parsed = cli.split(h.command);
8870
+ if (!parsed || parsed.args[0] !== "hook-wrap") continue;
8871
+ if (cli.startsLikeCommand(parsed)) continue;
8872
+ const original = wrappedOriginalCommand(h, cli);
8873
+ if (original === null) continue;
8874
+ const flag = parsed.args.includes("--capture-output") ? " --capture-output" : "";
8875
+ const desired = cli.command(`hook-wrap --id ${cli.encode(original)}${flag}`);
8876
+ matcher.hooks[hi] = { ...h, command: desired, [WRAP_MARKER]: original };
8877
+ changed = true;
8878
+ }
8879
+ }
8880
+ }
8881
+ return { next, changed };
8882
+ }
8883
+ function statuslineCommand(cli) {
8884
+ return cli.command("statusline");
8885
+ }
8886
+ function statuslineWrapCommand(cli, original) {
8887
+ return cli.command(`statusline --wrap-id ${cli.encode(original)}`);
8888
+ }
8889
+ function isOurStatuslineSlot(slot, cli) {
8890
+ if (slot[MARKER] === true) return true;
8891
+ const args = cli.parse(slot.command);
8892
+ if (!args || args[0] !== "statusline") return false;
8893
+ return args.length === 1 || statuslineWrappedOriginal(slot, cli) !== null;
8894
+ }
8895
+ function statuslineWrappedOriginal(slot, cli) {
8896
+ if (typeof slot[WRAP_MARKER] === "string") return slot[WRAP_MARKER];
8897
+ const args = cli.parse(slot.command);
8898
+ if (!args || args.length !== 3 || args[0] !== "statusline" || args[1] !== "--wrap-id") return null;
8899
+ return cli.decode(args[2]);
8900
+ }
8901
+ function mergeStatusline(settings, cli) {
8902
+ const next = settings ? structuredClone(settings) : {};
8903
+ const slot = next.statusLine;
8904
+ if (slot === void 0 || slot === null) {
8905
+ next.statusLine = { type: "command", command: statuslineCommand(cli), [MARKER]: true };
8906
+ return { next, changed: true, outcome: "installed" };
8907
+ }
8908
+ if (typeof slot !== "object") {
8909
+ return { next, changed: false, outcome: "skipped" };
8910
+ }
8911
+ if (isOurStatuslineSlot(slot, cli)) {
8912
+ const original2 = statuslineWrappedOriginal(slot, cli);
8913
+ const desired = original2 !== null ? statuslineWrapCommand(cli, original2) : statuslineCommand(cli);
8914
+ const stripped = slot[MARKER] !== true || original2 !== null && typeof slot[WRAP_MARKER] !== "string";
8915
+ if (slot.command === desired && !stripped) {
8916
+ return { next, changed: false, outcome: "unchanged", ...original2 !== null ? { wrappedCommand: original2 } : {} };
8917
+ }
8918
+ slot.command = desired;
8919
+ slot[MARKER] = true;
8920
+ if (original2 !== null) slot[WRAP_MARKER] = original2;
8921
+ return { next, changed: true, outcome: "repaired", ...original2 !== null ? { wrappedCommand: original2 } : {} };
8922
+ }
8923
+ if (slot.type !== "command" || typeof slot.command !== "string") {
8924
+ return { next, changed: false, outcome: "skipped" };
8925
+ }
8926
+ const original = slot.command;
8927
+ slot.command = statuslineWrapCommand(cli, original);
8928
+ slot[MARKER] = true;
8929
+ slot[WRAP_MARKER] = original;
8930
+ return { next, changed: true, outcome: "wrapped", wrappedCommand: original };
8931
+ }
8932
+ function removeStatusline(settings, cli) {
8933
+ const next = settings ? structuredClone(settings) : {};
8934
+ const slot = next.statusLine;
8935
+ if (!slot || typeof slot !== "object" || !isOurStatuslineSlot(slot, cli)) {
8936
+ return { next, changed: false };
8937
+ }
8938
+ const original = statuslineWrappedOriginal(slot, cli);
8939
+ if (original !== null) {
8940
+ delete slot[MARKER];
8941
+ delete slot[WRAP_MARKER];
8942
+ slot.command = original;
8943
+ return { next, changed: true, restoredCommand: original };
8944
+ }
8945
+ delete next.statusLine;
8946
+ return { next, changed: true };
8947
+ }
8948
+ function unwrapHooks(settings, cli) {
8949
+ const next = settings ? structuredClone(settings) : {};
8950
+ let changed = false;
8951
+ let unwrapped = 0;
8952
+ if (!next.hooks) return { next, changed, unwrapped };
8953
+ for (const event of Object.keys(next.hooks)) {
8954
+ const matchers = next.hooks[event] ?? [];
8955
+ for (const matcher of matchers) {
8956
+ for (let hi = 0; hi < matcher.hooks.length; hi++) {
8957
+ const h = matcher.hooks[hi];
8958
+ if (!isWrapped(h, cli)) continue;
8959
+ matcher.hooks[hi] = unwrapHookCommand(h, cli);
8960
+ unwrapped++;
8961
+ changed = true;
8962
+ }
8963
+ }
8964
+ }
8965
+ return { next, changed, unwrapped };
8966
+ }
8967
+ function parseSettings(text) {
8968
+ if (text === void 0) return null;
8969
+ if (text.trim() === "") return {};
8970
+ try {
8971
+ return JSON.parse(text);
8972
+ } catch (err) {
8973
+ throw new HookTextError(err);
8974
+ }
8975
+ }
8976
+ function render(settings) {
8977
+ return `${JSON.stringify(settings, null, 2)}
8978
+ `;
8979
+ }
8980
+ function install(text, cli, options) {
8981
+ const current = parseSettings(text);
8982
+ const merged = mergeHooks(current, cli);
8983
+ const repointed = repointWrappedHooks(merged.next, cli);
8984
+ let next = repointed.next;
8985
+ let changed = merged.changed || repointed.changed;
8986
+ let wrapped = [];
8987
+ if (options.wrap) {
8988
+ const wrapResult = wrapHooks(next, cli, { events: [...AUTO_WRAP_EVENTS] });
8989
+ if (wrapResult.changed) {
8990
+ next = wrapResult.next;
8991
+ changed = true;
8992
+ wrapped = wrapResult.wrapped;
8993
+ }
8994
+ }
8995
+ let statusline;
8996
+ let statuslineWrappedCommand;
8997
+ if (options.statusline) {
8998
+ const slotResult = mergeStatusline(next, cli);
8999
+ statusline = slotResult.outcome;
9000
+ statuslineWrappedCommand = slotResult.wrappedCommand;
9001
+ if (slotResult.changed) {
9002
+ next = slotResult.next;
9003
+ changed = true;
9004
+ }
9005
+ }
9006
+ return {
9007
+ text: render(next),
9008
+ changed,
9009
+ events: REGISTERED_EVENTS,
9010
+ wrapped,
9011
+ ...statusline ? { statusline } : {},
9012
+ ...statuslineWrappedCommand ? { statuslineWrappedCommand } : {}
9013
+ };
9014
+ }
9015
+ function remove(text, cli) {
9016
+ const hooksRemoved = removeHooks(parseSettings(text), cli);
9017
+ const hooksUnwrapped = unwrapHooks(hooksRemoved.next, cli);
9018
+ const statuslineRemoved = removeStatusline(hooksUnwrapped.next, cli);
9019
+ return {
9020
+ text: render(statuslineRemoved.next),
9021
+ changed: hooksRemoved.changed || hooksUnwrapped.changed || statuslineRemoved.changed,
9022
+ unwrapped: hooksUnwrapped.unwrapped,
9023
+ ...statuslineRemoved.restoredCommand ? { restoredStatusline: statuslineRemoved.restoredCommand } : {}
9024
+ };
9025
+ }
9026
+ function installed(text, cli) {
9027
+ const settings = parseSettings(text);
9028
+ const hooks = settings?.hooks;
9029
+ const wrapped = [];
9030
+ for (const event of Object.keys(hooks ?? {})) {
9031
+ for (const block of hooks?.[event] ?? []) {
9032
+ for (const h of block.hooks ?? []) {
9033
+ const original = wrappedOriginalCommand(h, cli);
9034
+ if (original !== null) wrapped.push({ event, original });
9035
+ }
9036
+ }
9037
+ }
9038
+ const slot = settings?.statusLine;
9039
+ let statusline = { slot: "empty" };
9040
+ if (slot && typeof slot === "object") {
9041
+ if (isOurStatuslineSlot(slot, cli)) {
9042
+ const wrapping = statuslineWrappedOriginal(slot, cli);
9043
+ statusline = { slot: "ours", ...wrapping === null ? {} : { wrapping } };
9044
+ } else if (typeof slot.command === "string") {
9045
+ statusline = { slot: "foreign", command: slot.command };
9046
+ }
9047
+ }
9048
+ return {
9049
+ hasHooks: Boolean(hooks),
9050
+ events: hooks ? REGISTERED_EVENTS.filter((event) => (hooks[event] ?? []).some((block) => (block.hooks ?? []).some((h) => isOurHookCommand(h, cli)))) : [],
9051
+ bins: ourCommandBins(settings, cli),
9052
+ directScriptBins: ourDirectScriptBins(settings, cli),
9053
+ wrapped,
9054
+ statusline
9055
+ };
9056
+ }
9057
+ var CLAUDE_CODE_HOOK_INSTALL = {
9058
+ settingsFile(scope, where) {
9059
+ const base = scope === "user" ? where.home : where.cwd;
9060
+ const separator = base.includes("\\") && !base.includes("/") ? "\\" : "/";
9061
+ return [base.replace(/[\\/]+$/, ""), ".claude", "settings.json"].join(separator);
9062
+ },
9063
+ install,
9064
+ remove,
9065
+ installed,
9066
+ candidates: (text, cli) => listHookCandidates(parseSettings(text), cli),
9067
+ wrap(text, cli, options) {
9068
+ const result = wrapHooks(parseSettings(text), cli, options);
9069
+ return { text: render(result.next), changed: result.changed, wrapped: result.wrapped, ...result.skippedUnresolvedBin ? { skippedUnresolvedBin: true } : {} };
9070
+ },
9071
+ unwrap(text, cli) {
9072
+ const result = unwrapHooks(parseSettings(text), cli);
9073
+ return { text: render(result.next), changed: result.changed, unwrapped: result.unwrapped };
9074
+ },
9075
+ managedSettings: {
9076
+ locations: [
9077
+ " macOS (MDM): /Library/Application Support/ClaudeCode/managed-settings.json",
9078
+ " (domain com.anthropic.claudecode)",
9079
+ " Linux: /etc/claude-code/managed-settings.json",
9080
+ " Windows (GPO): HKLM\\SOFTWARE\\Policies\\ClaudeCode, as a REG_SZ value named Settings"
9081
+ ],
9082
+ document(command) {
9083
+ const hooks = {};
9084
+ for (const event of REGISTERED_EVENTS) hooks[event] = [{ hooks: [{ type: "command", command: command(event) }] }];
9085
+ return { hooks };
9086
+ }
9087
+ }
9088
+ };
9089
+
9090
+ // ../agents/src/claude-code/diagnostics.ts
9091
+ var NAME = CLAUDE_CODE.label;
9092
+ var PROGRAM = CLAUDE_CODE.program;
9093
+ function compareVersions(a, b) {
9094
+ const parse2 = (version) => version.split(".").map((part) => Number.isFinite(Number.parseInt(part, 10)) ? Number.parseInt(part, 10) : 0);
9095
+ const left = parse2(a);
9096
+ const right = parse2(b);
9097
+ for (let i = 0; i < 3; i++) {
9098
+ if ((left[i] ?? 0) !== (right[i] ?? 0)) return (left[i] ?? 0) - (right[i] ?? 0);
9099
+ }
9100
+ return 0;
9101
+ }
9102
+ var joinPath2 = (...parts) => joinWith("/", parts);
9103
+ function joinWith(separator, parts) {
9104
+ const doubled = new RegExp(`${separator.replace(/[\\/]/g, "\\$&")}{2,}`, "g");
9105
+ const joined = parts.join(separator);
9106
+ const lead = separator === "\\" && joined.startsWith("\\\\") ? "\\\\" : "";
9107
+ return lead + joined.slice(lead.length).replace(doubled, separator);
9108
+ }
9109
+ var joinerOf = (input) => (...parts) => joinWith(input.separator ?? "/", parts);
9110
+ function exists(io, path) {
9111
+ return io.fs.stat(path).kind !== "missing";
9112
+ }
9113
+ function homeCheck(io, input) {
9114
+ const dir = joinerOf(input)(input.home, ".claude");
9115
+ return [
9116
+ exists(io, dir) ? { name: `${NAME} home`, status: "pass", detail: dir } : { name: `${NAME} home`, status: "fail", detail: `${dir} not found`, fix: `Install ${NAME}, then run a session so transcripts exist.` }
9117
+ ];
9118
+ }
9119
+ function retentionCheck(io, input) {
9120
+ const name = "Retention (cleanupPeriodDays)";
9121
+ let settings;
9122
+ try {
9123
+ const text = io.fs.readText(joinerOf(input)(input.home, ".claude", "settings.json"));
9124
+ settings = text === void 0 ? null : text.trim() === "" ? {} : JSON.parse(text);
9125
+ } catch {
9126
+ return [{ name, status: "warn", detail: "settings unreadable" }];
9127
+ }
9128
+ const raw = settings?.cleanupPeriodDays;
9129
+ const days = typeof raw === "number" ? raw : 30;
9130
+ if (days === 0) {
9131
+ return [
9132
+ {
9133
+ name,
9134
+ status: "fail",
9135
+ detail: "set to 0 \u2014 this DISABLES transcript persistence (upstream anthropics/claude-code#23710 and #59248)",
9136
+ fix: `Remove cleanupPeriodDays or set it \u226514; run \`${input.cli} daemon\` to mirror before deletion.`
9137
+ }
9138
+ ];
9139
+ }
9140
+ if (days < 14) {
9141
+ return [{ name, status: "warn", detail: `${days}d \u2014 transcripts deleted quickly`, fix: `Run \`${input.cli} daemon\` so raws are mirrored before cleanup.` }];
9142
+ }
9143
+ return [{ name, status: "pass", detail: `${days}d` }];
9144
+ }
9145
+ function versionCheck(io, input) {
9146
+ const name = `${NAME} version`;
9147
+ const ran = io.runSync(PROGRAM, ["--version"], { timeoutMs: 5e3 });
9148
+ if (ran.code !== 0) return [{ name, status: "warn", detail: `could not run \`${PROGRAM} --version\``, fix: `Ensure \`${PROGRAM}\` is on PATH.` }];
9149
+ const version = ran.stdout.trim();
9150
+ const parsed = version.match(/\d+\.\d+\.\d+/)?.[0];
9151
+ if (!parsed) return [{ name, status: "warn", detail: `unrecognized: ${version}` }];
9152
+ const tested = input.tested ?? CLAUDE_CODE.versions.tested;
9153
+ if (compareVersions(parsed, tested.to) > 0) {
9154
+ return [{ name, status: "pass", detail: `${parsed} (newer than ${tested.to}, the latest version this release was tested with)` }];
9155
+ }
9156
+ if (compareVersions(parsed, tested.from) < 0) {
9157
+ return [{ name, status: "warn", detail: `${parsed} is older than validated (${tested.from})` }];
9158
+ }
9159
+ return [{ name, status: "pass", detail: parsed }];
9160
+ }
9161
+ function settingsCheck(io, input) {
9162
+ for (const scope of ["user", "project"]) {
9163
+ const path = CLAUDE_CODE_HOOK_INSTALL.settingsFile(scope, { home: input.home, cwd: input.cwd ?? "." });
9164
+ if (!exists(io, path)) continue;
9165
+ let text;
9166
+ try {
9167
+ text = io.fs.readText(path);
9168
+ } catch (err) {
9169
+ return [{ name: "Settings JSON valid", status: "fail", detail: `${path} is unreadable`, fix: `refusing to modify ${path}: it cannot be read (${err instanceof Error ? err.message : String(err)})` }];
9170
+ }
9171
+ try {
9172
+ if (text === void 0) throw new Error("the file is not text");
9173
+ if (text.trim() !== "") JSON.parse(text);
9174
+ } catch (err) {
9175
+ const cause = err instanceof Error ? err.message : String(err);
9176
+ return [{ name: "Settings JSON valid", status: "fail", detail: `${path} is corrupt`, fix: `refusing to modify ${path}: it is not valid JSON (${cause})` }];
9177
+ }
9178
+ }
9179
+ return [{ name: "Settings JSON valid", status: "pass", detail: "all settings files parse" }];
9180
+ }
9181
+ function distinctInstalls(io, paths) {
9182
+ const seen = /* @__PURE__ */ new Set();
9183
+ const out = [];
9184
+ for (const path of paths) {
9185
+ let real = path;
9186
+ try {
9187
+ real = io.fs.realPath(path);
9188
+ } catch {
9189
+ }
9190
+ if (seen.has(real)) continue;
9191
+ seen.add(real);
9192
+ out.push(path);
9193
+ }
9194
+ return out;
9195
+ }
9196
+ function installsCheck(io) {
9197
+ let found = io.runSync("which", ["-a", PROGRAM], { timeoutMs: 5e3 });
9198
+ if (found.code === null) found = io.runSync("where", [PROGRAM], { timeoutMs: 5e3 });
9199
+ const listed = found.code === 0 ? found.stdout.split(/\r?\n/).filter((line) => line.trim().length > 0) : [];
9200
+ const installs = distinctInstalls(io, listed);
9201
+ if (installs.length > 1) {
9202
+ return [{ name: `${NAME} installs`, status: "warn", detail: `multiple found: ${installs.join(", ")}`, fix: "Multiple installs can diverge in version; keep one." }];
9203
+ }
9204
+ return [];
9205
+ }
9206
+ function hookCommandsOf(settings) {
9207
+ const hooks = settings?.hooks;
9208
+ if (typeof hooks !== "object" || hooks === null) return [];
9209
+ const commands = [];
9210
+ for (const groups of Object.values(hooks)) {
9211
+ if (!Array.isArray(groups)) continue;
9212
+ for (const group of groups) {
9213
+ const entries = group?.hooks;
9214
+ if (!Array.isArray(entries)) continue;
9215
+ for (const entry of entries) {
9216
+ const command = entry?.command;
9217
+ if (typeof command === "string") commands.push(command);
9218
+ }
9219
+ }
9220
+ }
9221
+ return commands;
9222
+ }
9223
+ function controlPlaneHooksCheck(io, input, context) {
9224
+ const top = io.runSync("git", ["-C", input.cwd ?? ".", "rev-parse", "--show-toplevel"], { timeoutMs: 2e3 });
9225
+ if (top.code !== 0) return [];
9226
+ const repoRoot = top.stdout.trim();
9227
+ if (!exists(io, joinerOf(input)(repoRoot, ".outerlayer"))) return [];
9228
+ let settings;
9229
+ try {
9230
+ settings = JSON.parse(io.fs.readText(joinerOf(input)(repoRoot, ".claude", "settings.json")) ?? "");
9231
+ } catch {
9232
+ return [];
9233
+ }
9234
+ const escaping = hookCommandsOf(settings).filter((command) => context.escapesDelivery(command, input.controlPlaneVariable));
9235
+ if (escaping.length === 0) return [];
9236
+ return [
9237
+ {
9238
+ name: "Control plane hook paths",
9239
+ status: "warn",
9240
+ detail: `${escaping.length === 1 ? "this hook command reaches" : "these hook commands reach"} a .claude directory by a path a governed build does not provide, so ${escaping.length === 1 ? "it fails" : "they fail"} there without a message: ${escaping.map((command) => `\`${command}\``).join(", ")}`,
9241
+ fix: `Name the script as \`\${${input.controlPlaneVariable}:-$CLAUDE_PROJECT_DIR}/.claude/\u2026\`. A governed build sets ${input.controlPlaneVariable} to where it reads the control plane; a checkout that holds its own copy falls back to the project directory.`
9242
+ }
9243
+ ];
9244
+ }
9245
+ function scanTranscripts(io, root) {
9246
+ let count = 0;
9247
+ let newest = 0;
9248
+ const walk = (dir) => {
9249
+ let names;
9250
+ try {
9251
+ names = io.fs.list(dir);
9252
+ } catch {
9253
+ return;
9254
+ }
9255
+ for (const name of names) {
9256
+ const path = joinPath2(dir, name);
9257
+ const stat = io.fs.stat(path);
9258
+ if (stat.kind === "directory") walk(path);
9259
+ else if (stat.kind === "file" && name.endsWith(".jsonl") && stat.size > 0) {
9260
+ count += 1;
9261
+ if (stat.mtimeMs > newest) newest = stat.mtimeMs;
9262
+ }
9263
+ }
9264
+ };
9265
+ walk(root);
9266
+ return { count, newest };
9267
+ }
9268
+ function createDiagnostics(io, context) {
9269
+ const sections = {
9270
+ home: (input) => homeCheck(io, input),
9271
+ retention: (input) => retentionCheck(io, input),
9272
+ version: (input) => versionCheck(io, input),
9273
+ settings: (input) => settingsCheck(io, input),
9274
+ installs: () => installsCheck(io),
9275
+ "control-plane-hooks": (input) => controlPlaneHooksCheck(io, input, context)
9276
+ };
9277
+ return {
9278
+ checks(input) {
9279
+ const wanted = input.sections ?? Object.keys(sections);
9280
+ return Object.fromEntries(wanted.map((section) => [section, sections[section](input)]));
9281
+ },
9282
+ sessions(home) {
9283
+ const root = joinPath2(home, ".claude", "projects");
9284
+ return exists(io, root) ? scanTranscripts(io, root) : void 0;
9285
+ }
9286
+ };
9287
+ }
9288
+
8760
9289
  // ../agents/src/claude-code/emit.ts
8761
9290
  function buildClaudeCode(input) {
8762
9291
  const files = [];
@@ -8840,6 +9369,98 @@ function createClaudeCodeImage() {
8840
9369
  };
8841
9370
  }
8842
9371
 
9372
+ // ../agents/src/claude-code/launch.ts
9373
+ var SESSION_ID_VARIABLE = "OUTERLAYER_SESSION_ID";
9374
+ var RESUME_SESSION_VARIABLE = "OUTERLAYER_RESUME_SESSION";
9375
+ var OWN_SESSION_FLAGS = /* @__PURE__ */ new Set(["--resume", "-r", "--continue", "-c", "--session-id", "--fork-session"]);
9376
+ var SHIM_SCRIPT = `#!/bin/sh
9377
+ exec outerlayer ${CLAUDE_CODE.legacy.subcommand} "$@"
9378
+ `;
9379
+ var joinPath3 = (...parts) => parts.join("/").replace(/\/{2,}/g, "/");
9380
+ function sessionArgs(env, callerArgs = []) {
9381
+ const { [SESSION_ID_VARIABLE]: sessionId, [RESUME_SESSION_VARIABLE]: resume, ...rest } = env;
9382
+ const named = sessionId !== void 0 && sessionId !== "";
9383
+ const resumes = resume !== void 0 && resume !== "";
9384
+ if (callerArgs.some((arg) => OWN_SESSION_FLAGS.has(arg)) || !named && !resumes) return { args: [], env: rest };
9385
+ return { args: [...resumes ? ["--resume", resume, "--fork-session"] : [], ...named ? ["--session-id", sessionId] : []], env: rest };
9386
+ }
9387
+ function configDir(io, env) {
9388
+ return env.CLAUDE_CONFIG_DIR ?? joinPath3(env.HOME || io.home(), ".claude");
9389
+ }
9390
+ function findTranscript(io, dir, id) {
9391
+ const root = joinPath3(dir, "projects");
9392
+ let projects;
9393
+ try {
9394
+ projects = io.fs.list(root);
9395
+ } catch {
9396
+ return void 0;
9397
+ }
9398
+ for (const project of projects) {
9399
+ const candidate = joinPath3(root, project, `${id}.jsonl`);
9400
+ if (io.fs.stat(candidate).kind !== "missing") return candidate;
9401
+ }
9402
+ return void 0;
9403
+ }
9404
+ function hasReplySince(io, path, sinceMs) {
9405
+ if (path === void 0) return false;
9406
+ try {
9407
+ for (const line of (io.fs.readText(path) ?? "").split("\n")) {
9408
+ if (!line.includes('"assistant"')) continue;
9409
+ const entry = JSON.parse(line);
9410
+ if (entry.type === "assistant" && typeof entry.timestamp === "string" && Date.parse(entry.timestamp) >= sinceMs) return true;
9411
+ }
9412
+ } catch {
9413
+ }
9414
+ return false;
9415
+ }
9416
+ function isSkipped(io, candidate) {
9417
+ try {
9418
+ return io.fs.stat(candidate).size === new TextEncoder().encode(SHIM_SCRIPT).length && io.fs.readText(candidate) === SHIM_SCRIPT;
9419
+ } catch {
9420
+ return true;
9421
+ }
9422
+ }
9423
+ function findProgram(io, path, delimiter) {
9424
+ const list = path ?? "";
9425
+ for (const entry of list.split(delimiter)) {
9426
+ if (entry === "") continue;
9427
+ const candidate = joinPath3(entry, CLAUDE_CODE.program);
9428
+ if (!io.fs.executable(candidate)) continue;
9429
+ if (isSkipped(io, candidate)) continue;
9430
+ return candidate;
9431
+ }
9432
+ return void 0;
9433
+ }
9434
+ function interactive(input) {
9435
+ const plane = input.controlPlane;
9436
+ const own = input.ownSkills === void 0 ? [] : ["--add-dir", input.ownSkills];
9437
+ const front = plane === void 0 ? own : ["--add-dir", plane, ...own, "--settings", joinPath3(plane, "settings.json")];
9438
+ const env = plane === void 0 ? input.env : { ...input.env, CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD: "1" };
9439
+ return {
9440
+ program: input.program,
9441
+ args: [...front, ...input.callerArgs],
9442
+ env: Object.fromEntries(Object.entries(env).filter((entry) => entry[1] !== void 0)),
9443
+ driver: "exec",
9444
+ exitFrom: "code"
9445
+ };
9446
+ }
9447
+ function createLaunch(io) {
9448
+ return {
9449
+ findProgram: (path, delimiter = ":") => findProgram(io, path, delimiter),
9450
+ version: (program, env) => io.runSync(program, ["--version"], { env, timeoutMs: 15e3 }).stdout,
9451
+ interactive,
9452
+ session: {
9453
+ args: sessionArgs,
9454
+ exists: (id, env) => findTranscript(io, configDir(io, env), id) !== void 0,
9455
+ hasReplySince: (id, env, sinceMs) => hasReplySince(io, findTranscript(io, configDir(io, env), id), sinceMs),
9456
+ discard(id, env) {
9457
+ const path = findTranscript(io, configDir(io, env), id);
9458
+ if (path !== void 0) io.fs.remove(path);
9459
+ }
9460
+ }
9461
+ };
9462
+ }
9463
+
8843
9464
  // ../agents/src/claude-code/mcp.ts
8844
9465
  function documentOf(text) {
8845
9466
  if (text === void 0) return {};
@@ -8884,14 +9505,23 @@ var CLAUDE_CODE_MCP = {
8884
9505
 
8885
9506
  // ../agents/src/claude-code/adapter.ts
8886
9507
  function createClaudeCodeAdapter(io) {
9508
+ const context = {
9509
+ emit: buildClaudeCode,
9510
+ ...createDelivery(io),
9511
+ mcp: CLAUDE_CODE_MCP
9512
+ };
8887
9513
  return {
8888
- context: {
8889
- emit: buildClaudeCode,
8890
- ...createDelivery(io),
8891
- mcp: CLAUDE_CODE_MCP
9514
+ context,
9515
+ launch: createLaunch(io),
9516
+ lifecycle: {
9517
+ source: { kind: "hook-process", codec: CLAUDE_CODE_HOOKS },
9518
+ detectInSession: (env) => Boolean(env.CLAUDECODE),
9519
+ install: CLAUDE_CODE_HOOK_INSTALL
8892
9520
  },
9521
+ deliver: { kind: "hook-reply", cap: CLAUDE_CODE.hooks.contextCap, format: CLAUDE_CODE_HOOKS.reply },
8893
9522
  credentials: createClaudeCodeCredentials(),
8894
- image: createClaudeCodeImage()
9523
+ image: createClaudeCodeImage(),
9524
+ diagnostics: createDiagnostics(io, context)
8895
9525
  };
8896
9526
  }
8897
9527
 
@@ -8904,6 +9534,14 @@ var ADAPTER_FACTORIES = {
8904
9534
  var TREE_ROOT = "/work/control-plane";
8905
9535
  var PATHS = [".outerlayer/AGENTS.md", ".outerlayer/skills/build/SKILL.md", ".outerlayer/commands/ship.md", ".outerlayer/mcp.json"];
8906
9536
  ({
9537
+ hooks: {
9538
+ payloads: Object.fromEntries(
9539
+ ["SessionStart", "SessionEnd", "Stop", "PostToolUse"].map((name) => [
9540
+ name,
9541
+ JSON.stringify({ session_id: "session-1", transcript_path: "/sessions/session-1.jsonl", cwd: "/work", hook_event_name: name, tool_name: "Bash", tool_use_id: "tool-1" })
9542
+ ])
9543
+ )
9544
+ },
8907
9545
  context: {
8908
9546
  emitInput: { entries: classifyTree(PATHS).entries},
8909
9547
  tree: {
@@ -8991,11 +9629,11 @@ function writeMaintainedFiles(repoRoot, files) {
8991
9629
  const rewritten = [];
8992
9630
  for (const file of files) {
8993
9631
  const abs = join$1(repoRoot, file.path);
8994
- const exists = existsSync(abs);
8995
- if (exists && readFileSync(abs, "utf8") === file.content) continue;
9632
+ const exists2 = existsSync(abs);
9633
+ if (exists2 && readFileSync(abs, "utf8") === file.content) continue;
8996
9634
  mkdirSync(dirname(abs), { recursive: true });
8997
9635
  writeFileSync(abs, file.content);
8998
- (exists ? rewritten : created).push(file.path);
9636
+ (exists2 ? rewritten : created).push(file.path);
8999
9637
  }
9000
9638
  return { created, rewritten };
9001
9639
  }
@@ -9054,6 +9692,23 @@ function createNodeAgentFs() {
9054
9692
  return "missing";
9055
9693
  }
9056
9694
  },
9695
+ stat(path) {
9696
+ try {
9697
+ const stat = statSync(path);
9698
+ return { kind: stat.isDirectory() ? "directory" : stat.isFile() ? "file" : "missing", size: stat.size, mtimeMs: stat.mtimeMs };
9699
+ } catch {
9700
+ return { kind: "missing", size: 0, mtimeMs: 0 };
9701
+ }
9702
+ },
9703
+ executable(path) {
9704
+ if (process.platform === "win32") return statSync(path, { throwIfNoEntry: false }) !== void 0;
9705
+ try {
9706
+ accessSync(path, constants.X_OK);
9707
+ return true;
9708
+ } catch {
9709
+ return false;
9710
+ }
9711
+ },
9057
9712
  readText(path) {
9058
9713
  let content;
9059
9714
  try {
@@ -9089,6 +9744,19 @@ function createNodeAgentIO() {
9089
9744
  if (options?.stdin !== void 0) child.stdin?.end(options.stdin);
9090
9745
  });
9091
9746
  },
9747
+ runSync(program, args, options) {
9748
+ try {
9749
+ const result = spawnSync(program, [...args], {
9750
+ env: options?.env ?? process.env,
9751
+ encoding: "utf8",
9752
+ ...options?.timeoutMs === void 0 ? {} : { timeout: options.timeoutMs },
9753
+ stdio: ["ignore", "pipe", "pipe"]
9754
+ });
9755
+ return { code: result.status, stdout: result.stdout ?? "", stderr: result.stderr ?? "" };
9756
+ } catch {
9757
+ return { code: null, stdout: "", stderr: "" };
9758
+ }
9759
+ },
9092
9760
  home: () => homeFromEnv() || homedir(),
9093
9761
  env: () => ({ ...process.env }),
9094
9762
  now: () => /* @__PURE__ */ new Date()
@@ -9131,4 +9799,4 @@ function skillBases(agents = defaultAgents()) {
9131
9799
  return [AGENTS_SKILLS_BASE, ...contextAgents(agents).flatMap((agent) => agent.descriptor.context.repoSkillFolders)];
9132
9800
  }
9133
9801
 
9134
- export { AGENTS_SKILLS_BASE, CONTEXT_PIN_FILENAME, FORMER_MAINTAINED_NAMES, LEGACY_AGENT, MACHINE_SKILL_PATH, McpFileError, OUTERLAYER_SKILLS_BASE, PROVIDERS, TEMPLATE_SKILLS, agentById, agentRootFolders, classifyTree, contextAgents, defaultAgents, emitBuilders, emitTree, extractFacts, generatedHeaderSource, isMaintainedCopy, legacyAgent, legacySubcommand, loadMachineSkillFiles, loadMaintainedFiles, loadTemplateFiles, maintainedFilesForExistingSkills, namesCore, normalizePath, normalizeRepoName, orderSessions, parseOuterlayerConfig, parsePolicy, parseProofsConfig, resolvePackRoot, restoreSkillPaths, rewriteSkillPaths, sessionsToTimeline, skillBases, skillDir, splitRawFile, targetIds, userSkillFolderIn, writeMaintainedFiles };
9802
+ export { ADAPTER_FACTORIES, AGENTS_SKILLS_BASE, CONTEXT_PIN_FILENAME, FORMER_MAINTAINED_NAMES, HookTextError, MACHINE_SKILL_PATH, McpFileError, OUTERLAYER_SKILLS_BASE, TEMPLATE_SKILLS, agentById, agentRootFolders, classifyTree, contextAgents, createNodeAgentIO, defaultAgents, emitBuilders, emitTree, extractFacts, generatedHeaderSource, isMaintainedCopy, legacyAgent, legacySubcommand, loadMachineSkillFiles, loadMaintainedFiles, loadTemplateFiles, maintainedFilesForExistingSkills, namesCore, normalizePath, normalizeRepoName, orderSessions, parseOuterlayerConfig, parsePolicy, parseProofsConfig, resolvePackRoot, restoreSkillPaths, rewriteSkillPaths, sessionsToTimeline, skillBases, skillDir, splitRawFile, targetIds, userSkillFolderIn, writeMaintainedFiles };