@cluesmith/codev 3.3.5 → 3.3.7

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 (247) hide show
  1. package/dashboard-dist/assets/{index-r3bZzLmX.css → index-BjcqV9Vv.css} +1 -1
  2. package/dashboard-dist/assets/{index-BuflRUi6.js → index-b7GnZV2i.js} +55 -55
  3. package/dashboard-dist/assets/index-b7GnZV2i.js.map +1 -0
  4. package/dashboard-dist/index.html +2 -2
  5. package/dist/agent-farm/cli.d.ts.map +1 -1
  6. package/dist/agent-farm/cli.js +50 -17
  7. package/dist/agent-farm/cli.js.map +1 -1
  8. package/dist/agent-farm/commands/architect.d.ts.map +1 -1
  9. package/dist/agent-farm/commands/architect.js +5 -1
  10. package/dist/agent-farm/commands/architect.js.map +1 -1
  11. package/dist/agent-farm/commands/attach.d.ts +1 -1
  12. package/dist/agent-farm/commands/attach.d.ts.map +1 -1
  13. package/dist/agent-farm/commands/cleanup.d.ts +1 -1
  14. package/dist/agent-farm/commands/cleanup.d.ts.map +1 -1
  15. package/dist/agent-farm/commands/cleanup.js +2 -1
  16. package/dist/agent-farm/commands/cleanup.js.map +1 -1
  17. package/dist/agent-farm/commands/decisions.d.ts +25 -0
  18. package/dist/agent-farm/commands/decisions.d.ts.map +1 -0
  19. package/dist/agent-farm/commands/decisions.js +54 -0
  20. package/dist/agent-farm/commands/decisions.js.map +1 -0
  21. package/dist/agent-farm/commands/ide.d.ts +32 -3
  22. package/dist/agent-farm/commands/ide.d.ts.map +1 -1
  23. package/dist/agent-farm/commands/ide.js +180 -19
  24. package/dist/agent-farm/commands/ide.js.map +1 -1
  25. package/dist/agent-farm/commands/reset/context.d.ts +4 -2
  26. package/dist/agent-farm/commands/reset/context.d.ts.map +1 -1
  27. package/dist/agent-farm/commands/reset/context.js +12 -4
  28. package/dist/agent-farm/commands/reset/context.js.map +1 -1
  29. package/dist/agent-farm/commands/send.d.ts.map +1 -1
  30. package/dist/agent-farm/commands/send.js +13 -18
  31. package/dist/agent-farm/commands/send.js.map +1 -1
  32. package/dist/agent-farm/commands/spawn-worktree.d.ts +7 -0
  33. package/dist/agent-farm/commands/spawn-worktree.d.ts.map +1 -1
  34. package/dist/agent-farm/commands/spawn-worktree.js +51 -18
  35. package/dist/agent-farm/commands/spawn-worktree.js.map +1 -1
  36. package/dist/agent-farm/commands/spawn.d.ts +17 -0
  37. package/dist/agent-farm/commands/spawn.d.ts.map +1 -1
  38. package/dist/agent-farm/commands/spawn.js +41 -19
  39. package/dist/agent-farm/commands/spawn.js.map +1 -1
  40. package/dist/agent-farm/lib/builder-lookup.d.ts +3 -2
  41. package/dist/agent-farm/lib/builder-lookup.d.ts.map +1 -1
  42. package/dist/agent-farm/lib/builder-lookup.js +24 -9
  43. package/dist/agent-farm/lib/builder-lookup.js.map +1 -1
  44. package/dist/agent-farm/lib/ide-extensions.d.ts +82 -0
  45. package/dist/agent-farm/lib/ide-extensions.d.ts.map +1 -0
  46. package/dist/agent-farm/lib/ide-extensions.js +179 -0
  47. package/dist/agent-farm/lib/ide-extensions.js.map +1 -0
  48. package/dist/agent-farm/lib/ide-prefix.d.ts +10 -0
  49. package/dist/agent-farm/lib/ide-prefix.d.ts.map +1 -0
  50. package/dist/agent-farm/lib/ide-prefix.js +13 -0
  51. package/dist/agent-farm/lib/ide-prefix.js.map +1 -0
  52. package/dist/agent-farm/lib/ide-record.d.ts +20 -3
  53. package/dist/agent-farm/lib/ide-record.d.ts.map +1 -1
  54. package/dist/agent-farm/lib/ide-record.js +34 -3
  55. package/dist/agent-farm/lib/ide-record.js.map +1 -1
  56. package/dist/agent-farm/lib/ide-version.d.ts +97 -0
  57. package/dist/agent-farm/lib/ide-version.d.ts.map +1 -0
  58. package/dist/agent-farm/lib/ide-version.js +224 -0
  59. package/dist/agent-farm/lib/ide-version.js.map +1 -0
  60. package/dist/agent-farm/lib/tunnel-client.d.ts.map +1 -1
  61. package/dist/agent-farm/lib/tunnel-client.js +7 -3
  62. package/dist/agent-farm/lib/tunnel-client.js.map +1 -1
  63. package/dist/agent-farm/servers/agent-state/broadcast.d.ts +19 -0
  64. package/dist/agent-farm/servers/agent-state/broadcast.d.ts.map +1 -0
  65. package/dist/agent-farm/servers/agent-state/broadcast.js +30 -0
  66. package/dist/agent-farm/servers/agent-state/broadcast.js.map +1 -0
  67. package/dist/agent-farm/servers/agent-state/identity.d.ts +50 -0
  68. package/dist/agent-farm/servers/agent-state/identity.d.ts.map +1 -0
  69. package/dist/agent-farm/servers/agent-state/identity.js +120 -0
  70. package/dist/agent-farm/servers/agent-state/identity.js.map +1 -0
  71. package/dist/agent-farm/servers/agent-state/liveness.d.ts +107 -0
  72. package/dist/agent-farm/servers/agent-state/liveness.d.ts.map +1 -0
  73. package/dist/agent-farm/servers/agent-state/liveness.js +224 -0
  74. package/dist/agent-farm/servers/agent-state/liveness.js.map +1 -0
  75. package/dist/agent-farm/servers/agent-state/route.d.ts +38 -0
  76. package/dist/agent-farm/servers/agent-state/route.d.ts.map +1 -0
  77. package/dist/agent-farm/servers/agent-state/route.js +170 -0
  78. package/dist/agent-farm/servers/agent-state/route.js.map +1 -0
  79. package/dist/agent-farm/servers/agent-state/serve.d.ts +31 -0
  80. package/dist/agent-farm/servers/agent-state/serve.d.ts.map +1 -0
  81. package/dist/agent-farm/servers/agent-state/serve.js +49 -0
  82. package/dist/agent-farm/servers/agent-state/serve.js.map +1 -0
  83. package/dist/agent-farm/servers/agent-state/store.d.ts +76 -0
  84. package/dist/agent-farm/servers/agent-state/store.d.ts.map +1 -0
  85. package/dist/agent-farm/servers/agent-state/store.js +157 -0
  86. package/dist/agent-farm/servers/agent-state/store.js.map +1 -0
  87. package/dist/agent-farm/servers/decisions/parse.d.ts.map +1 -1
  88. package/dist/agent-farm/servers/decisions/parse.js +45 -15
  89. package/dist/agent-farm/servers/decisions/parse.js.map +1 -1
  90. package/dist/agent-farm/servers/decisions/stamp.d.ts +6 -2
  91. package/dist/agent-farm/servers/decisions/stamp.d.ts.map +1 -1
  92. package/dist/agent-farm/servers/decisions/stamp.js +53 -29
  93. package/dist/agent-farm/servers/decisions/stamp.js.map +1 -1
  94. package/dist/agent-farm/servers/decisions/template.d.ts +2 -0
  95. package/dist/agent-farm/servers/decisions/template.d.ts.map +1 -0
  96. package/dist/agent-farm/servers/decisions/template.js +15 -0
  97. package/dist/agent-farm/servers/decisions/template.js.map +1 -0
  98. package/dist/agent-farm/servers/ide-forward.d.ts +57 -5
  99. package/dist/agent-farm/servers/ide-forward.d.ts.map +1 -1
  100. package/dist/agent-farm/servers/ide-forward.js +263 -31
  101. package/dist/agent-farm/servers/ide-forward.js.map +1 -1
  102. package/dist/agent-farm/servers/ide-server.d.ts +28 -8
  103. package/dist/agent-farm/servers/ide-server.d.ts.map +1 -1
  104. package/dist/agent-farm/servers/ide-server.js +151 -52
  105. package/dist/agent-farm/servers/ide-server.js.map +1 -1
  106. package/dist/agent-farm/servers/overview.d.ts +27 -1
  107. package/dist/agent-farm/servers/overview.d.ts.map +1 -1
  108. package/dist/agent-farm/servers/overview.js +184 -31
  109. package/dist/agent-farm/servers/overview.js.map +1 -1
  110. package/dist/agent-farm/servers/tower-instances.d.ts +14 -1
  111. package/dist/agent-farm/servers/tower-instances.d.ts.map +1 -1
  112. package/dist/agent-farm/servers/tower-instances.js +51 -9
  113. package/dist/agent-farm/servers/tower-instances.js.map +1 -1
  114. package/dist/agent-farm/servers/tower-routes.d.ts.map +1 -1
  115. package/dist/agent-farm/servers/tower-routes.js +149 -15
  116. package/dist/agent-farm/servers/tower-routes.js.map +1 -1
  117. package/dist/agent-farm/servers/tower-server.js +35 -1
  118. package/dist/agent-farm/servers/tower-server.js.map +1 -1
  119. package/dist/agent-farm/servers/tower-terminals.d.ts +25 -0
  120. package/dist/agent-farm/servers/tower-terminals.d.ts.map +1 -1
  121. package/dist/agent-farm/servers/tower-terminals.js +128 -4
  122. package/dist/agent-farm/servers/tower-terminals.js.map +1 -1
  123. package/dist/agent-farm/servers/tower-utils.d.ts.map +1 -1
  124. package/dist/agent-farm/servers/tower-utils.js +18 -5
  125. package/dist/agent-farm/servers/tower-utils.js.map +1 -1
  126. package/dist/agent-farm/servers/tower-websocket.d.ts.map +1 -1
  127. package/dist/agent-farm/servers/tower-websocket.js +11 -7
  128. package/dist/agent-farm/servers/tower-websocket.js.map +1 -1
  129. package/dist/agent-farm/utils/builder-worktree-identity.d.ts +39 -0
  130. package/dist/agent-farm/utils/builder-worktree-identity.d.ts.map +1 -0
  131. package/dist/agent-farm/utils/builder-worktree-identity.js +42 -0
  132. package/dist/agent-farm/utils/builder-worktree-identity.js.map +1 -0
  133. package/dist/agent-farm/utils/harness.d.ts +71 -0
  134. package/dist/agent-farm/utils/harness.d.ts.map +1 -1
  135. package/dist/agent-farm/utils/harness.js +153 -0
  136. package/dist/agent-farm/utils/harness.js.map +1 -1
  137. package/dist/agent-farm/utils/lifecycle-reporter.d.ts +79 -0
  138. package/dist/agent-farm/utils/lifecycle-reporter.d.ts.map +1 -0
  139. package/dist/agent-farm/utils/lifecycle-reporter.js +347 -0
  140. package/dist/agent-farm/utils/lifecycle-reporter.js.map +1 -0
  141. package/dist/agent-farm/utils/server-utils.d.ts +54 -19
  142. package/dist/agent-farm/utils/server-utils.d.ts.map +1 -1
  143. package/dist/agent-farm/utils/server-utils.js +144 -27
  144. package/dist/agent-farm/utils/server-utils.js.map +1 -1
  145. package/dist/cli.d.ts.map +1 -1
  146. package/dist/cli.js +17 -0
  147. package/dist/cli.js.map +1 -1
  148. package/dist/commands/adopt.d.ts +16 -2
  149. package/dist/commands/adopt.d.ts.map +1 -1
  150. package/dist/commands/adopt.js +67 -23
  151. package/dist/commands/adopt.js.map +1 -1
  152. package/dist/commands/bootstrap-docs.d.ts +132 -0
  153. package/dist/commands/bootstrap-docs.d.ts.map +1 -0
  154. package/dist/commands/bootstrap-docs.js +725 -0
  155. package/dist/commands/bootstrap-docs.js.map +1 -0
  156. package/dist/commands/consult/index.d.ts.map +1 -1
  157. package/dist/commands/consult/index.js +14 -1
  158. package/dist/commands/consult/index.js.map +1 -1
  159. package/dist/commands/consult/tree-tripwire.d.ts +2 -75
  160. package/dist/commands/consult/tree-tripwire.d.ts.map +1 -1
  161. package/dist/commands/consult/tree-tripwire.js +7 -184
  162. package/dist/commands/consult/tree-tripwire.js.map +1 -1
  163. package/dist/commands/doctor.d.ts.map +1 -1
  164. package/dist/commands/doctor.js +36 -4
  165. package/dist/commands/doctor.js.map +1 -1
  166. package/dist/commands/porch/state.d.ts +0 -4
  167. package/dist/commands/porch/state.d.ts.map +1 -1
  168. package/dist/commands/porch/state.js +23 -10
  169. package/dist/commands/porch/state.js.map +1 -1
  170. package/dist/commands/update.d.ts +5 -1
  171. package/dist/commands/update.d.ts.map +1 -1
  172. package/dist/commands/update.js +73 -18
  173. package/dist/commands/update.js.map +1 -1
  174. package/dist/lib/agent-env.d.ts +22 -1
  175. package/dist/lib/agent-env.d.ts.map +1 -1
  176. package/dist/lib/agent-env.js +27 -1
  177. package/dist/lib/agent-env.js.map +1 -1
  178. package/dist/lib/agent-process.d.ts +23 -0
  179. package/dist/lib/agent-process.d.ts.map +1 -0
  180. package/dist/lib/agent-process.js +24 -0
  181. package/dist/lib/agent-process.js.map +1 -0
  182. package/dist/lib/forge-contracts.d.ts +9 -3
  183. package/dist/lib/forge-contracts.d.ts.map +1 -1
  184. package/dist/lib/forge-contracts.js.map +1 -1
  185. package/dist/lib/forge.d.ts +8 -5
  186. package/dist/lib/forge.d.ts.map +1 -1
  187. package/dist/lib/forge.js +57 -1
  188. package/dist/lib/forge.js.map +1 -1
  189. package/dist/lib/github.d.ts.map +1 -1
  190. package/dist/lib/github.js +38 -0
  191. package/dist/lib/github.js.map +1 -1
  192. package/dist/lib/governance-bootstrap.d.ts +155 -0
  193. package/dist/lib/governance-bootstrap.d.ts.map +1 -0
  194. package/dist/lib/governance-bootstrap.js +469 -0
  195. package/dist/lib/governance-bootstrap.js.map +1 -0
  196. package/dist/lib/issue-id.d.ts +34 -0
  197. package/dist/lib/issue-id.d.ts.map +1 -0
  198. package/dist/lib/issue-id.js +61 -0
  199. package/dist/lib/issue-id.js.map +1 -0
  200. package/dist/lib/scaffold.d.ts +4 -0
  201. package/dist/lib/scaffold.d.ts.map +1 -1
  202. package/dist/lib/scaffold.js +29 -5
  203. package/dist/lib/scaffold.js.map +1 -1
  204. package/dist/lib/shipped-skill-hashes.d.ts +10 -0
  205. package/dist/lib/shipped-skill-hashes.d.ts.map +1 -0
  206. package/dist/lib/shipped-skill-hashes.js +197 -0
  207. package/dist/lib/shipped-skill-hashes.js.map +1 -0
  208. package/dist/lib/skill-refresh.d.ts +90 -0
  209. package/dist/lib/skill-refresh.d.ts.map +1 -0
  210. package/dist/lib/skill-refresh.js +267 -0
  211. package/dist/lib/skill-refresh.js.map +1 -0
  212. package/dist/lib/tree-snapshot.d.ts +172 -0
  213. package/dist/lib/tree-snapshot.d.ts.map +1 -0
  214. package/dist/lib/tree-snapshot.js +393 -0
  215. package/dist/lib/tree-snapshot.js.map +1 -0
  216. package/dist/terminal/pty-session.d.ts +5 -0
  217. package/dist/terminal/pty-session.d.ts.map +1 -1
  218. package/dist/terminal/pty-session.js +7 -0
  219. package/dist/terminal/pty-session.js.map +1 -1
  220. package/ide-extension/codev-vscode.vsix +0 -0
  221. package/ide-extension/manifest.json +7 -0
  222. package/package.json +8 -6
  223. package/scripts/forge/jira/_lib.sh +113 -0
  224. package/scripts/forge/jira/auth-status.sh +29 -0
  225. package/scripts/forge/jira/issue-comment.sh +23 -0
  226. package/scripts/forge/jira/issue-list.sh +32 -0
  227. package/scripts/forge/jira/issue-search.sh +40 -0
  228. package/scripts/forge/jira/issue-view.sh +41 -0
  229. package/scripts/forge/jira/recently-closed.sh +81 -0
  230. package/scripts/forge/jira/user-identity.sh +18 -0
  231. package/skeleton/.claude/skills/afx/SKILL.md +36 -0
  232. package/skeleton/.claude/skills/codev/SKILL.md +18 -2
  233. package/skeleton/.claude/skills/update-arch-docs/SKILL.md +28 -2
  234. package/skeleton/.codex/skills/afx/SKILL.md +36 -0
  235. package/skeleton/.codex/skills/codev/SKILL.md +18 -2
  236. package/skeleton/.codex/skills/update-arch-docs/SKILL.md +28 -2
  237. package/skeleton/resources/commands/agent-farm.md +139 -0
  238. package/skeleton/resources/commands/codev.md +47 -0
  239. package/skeleton/resources/commands/overview.md +1 -0
  240. package/skeleton/resources/decision-protocol.md +215 -0
  241. package/skeleton/resources/workflow-reference.md +12 -0
  242. package/skeleton/roles/architect.md +6 -0
  243. package/skeleton/templates/bootstrap-docs-prompt.md +16 -0
  244. package/skeleton/templates/bootstrap-docs-review-prompt.md +19 -0
  245. package/skeleton/templates/cheatsheet.md +1 -0
  246. package/templates/tower.html +78 -3
  247. package/dashboard-dist/assets/index-BuflRUi6.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"harness.js","sourceRoot":"","sources":["../../../src/agent-farm/utils/harness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AA6HpE,gFAAgF;AAChF,qBAAqB;AACrB,gFAAgF;AAEhF,MAAM,CAAC,MAAM,cAAc,GAAoB;IAC7C,+EAA+E;IAC/E,+EAA+E;IAC/E,4DAA4D;IAC5D,oBAAoB,EAAE,IAAI;IAC1B,kBAAkB,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;QAC3C,IAAI,EAAE,CAAC,wBAAwB,EAAE,OAAO,CAAC;QACzC,GAAG,EAAE,EAAE;KACR,CAAC;IACF,wBAAwB,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;QACjD,QAAQ,EAAE,kCAAkC,sBAAsB,CAAC,QAAQ,CAAC,KAAK;QACjF,GAAG,EAAE,EAAE;KACR,CAAC;IACF,WAAW,EAAE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,CAAC,0BAA0B,EAAE,CAAC;QACjF,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,MAAM,EAAE,QAAQ,IAAI,2EAA2E;SAChG,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,QAAQ,CAAC,wBAAwB,EAAE,CAAC,KAAK,CAAC,CAAC;IAC3D,IAAI,OAAO;QAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAE1D,MAAM,eAAe,GAAG,QAAQ,CAAC,0BAA0B,CAAC;IAC5D,OAAO;QACL,SAAS,EAAE,IAAI;QACf,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACxB,UAAU;YACV,IAAI,EAAE,CAAC,GAAG,KAAK,EAAE,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;SAClD,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Claude lifecycle reporter (Spec 1595).
3
+ *
4
+ * Every Claude agent Codev launches reports its lifecycle to Tower so the
5
+ * overview can serve working / needs-input / idle from the harness itself
6
+ * instead of inferring it from PTY silence. This module is the single source of
7
+ * truth for the Claude provider's reporter, in the shape of the write-guard
8
+ * (`worktree-write-guard.ts`): two generated files, installed into a
9
+ * codev-owned directory no agent session writes to:
10
+ * - `claude-lifecycle-reporter.cjs`: a dependency-free Node hook script
11
+ * - `claude-lifecycle-reporter-settings.json`: the hook set, handed to the harness
12
+ * with `--settings <path>` through `CLAUDE_HARNESS.buildLifecycleReporterInjection`
13
+ *
14
+ * The script translates Claude hook names to the harness-neutral
15
+ * `AgentLifecycleEvent` vocabulary, so no Claude hook name crosses the wire.
16
+ * Identity comes only from the launch environment (`CODEV_BUILDER_WORKTREE`, or
17
+ * `CODEV_ARCHITECT_WORKSPACE` with `CODEV_ARCHITECT_NAME`); with neither set it
18
+ * sends nothing.
19
+ *
20
+ * Fail-open by construction (SC15): every hook is `async`, the script makes one
21
+ * request with a sub-second deadline and no retry, writes nothing to stdout
22
+ * (so it can never make a permission decision), and always exits 0. The hook
23
+ * command is a shell wrapper that exits 0 silently even when the script is
24
+ * missing. Neither file embeds a secret: the local key is read at hook time.
25
+ *
26
+ * @see codev/specs/1595-agent-attention-states-working.md
27
+ */
28
+ import { type HarnessProvider } from './harness.js';
29
+ /**
30
+ * Basename of the installed reporter script. Both files read Claude's hook payloads and settings
31
+ * format, so their names carry the harness: another harness's reporter installs beside them under
32
+ * its own names, never over them.
33
+ */
34
+ export declare const LIFECYCLE_REPORTER_SCRIPT_NAME = "claude-lifecycle-reporter.cjs";
35
+ /** Basename of the installed settings file carrying the hook set. */
36
+ export declare const LIFECYCLE_REPORTER_SETTINGS_NAME = "claude-lifecycle-reporter-settings.json";
37
+ /** Seconds the harness allows each hook before abandoning it. The script itself finishes well inside it. */
38
+ export declare const LIFECYCLE_HOOK_TIMEOUT_SECONDS = 3;
39
+ /** Claude's question tool: the PreToolUse matcher and the script's question-kind test both read it. */
40
+ export declare const CLAUDE_QUESTION_TOOL = "AskUserQuestion";
41
+ /** The directory both files are installed into. */
42
+ export declare function lifecycleReporterDir(): string;
43
+ /**
44
+ * The self-contained Node reporter script, written verbatim to the hooks
45
+ * directory. A string constant so it ships with the compiled package; the unit
46
+ * test writes it to a temp file and runs it with fixture stdin, so the
47
+ * constant is the tested artifact.
48
+ */
49
+ export declare const LIFECYCLE_REPORTER_SCRIPT = "#!/usr/bin/env node\n// AUTO-GENERATED by @cluesmith/codev (Spec 1595). Do not edit;\n// edit packages/codev/src/agent-farm/utils/lifecycle-reporter.ts instead.\n'use strict';\n\nconst fs = require('node:fs');\nconst http = require('node:http');\nconst os = require('node:os');\nconst path = require('node:path');\n\nconst QUESTION_TOOL = 'AskUserQuestion';\nconst DEFAULT_TOWER_PORT = 4100;\nconst REQUEST_DEADLINE_MS = 800;\nconst OVERALL_DEADLINE_MS = 1500;\nconst MAX_BODY_BYTES = 8192;\nconst MAX_SESSION_ID_LENGTH = 128;\nconst MAX_TOOL_LENGTH = 64;\nconst MAX_SUMMARY_LENGTH = 200;\n\nfunction done() {\n process.exit(0);\n}\n\n// Single line, control characters removed, at most maxLength UTF-16 units\n// without splitting a surrogate pair. Empty means \"omit the field\".\nfunction plainText(value, maxLength) {\n if (typeof value !== 'string') return '';\n let text = value\n .replace(/\\s*[\\r\\n\\u2028\\u2029]+\\s*/g, ' ')\n .replace(/\\t/g, ' ')\n .replace(/[\\u0000-\\u001f\\u007f-\\u009f]/g, '')\n .trim();\n if (text.length > maxLength) {\n text = text.slice(0, maxLength);\n const last = text.charCodeAt(text.length - 1);\n if (last >= 0xd800 && last <= 0xdbff) text = text.slice(0, -1);\n }\n return text;\n}\n\n// The tool's primary argument: a command's text, a path, a pattern, a URL,\n// or the question being asked.\nfunction primaryArgument(toolName, toolInput) {\n if (!toolInput || typeof toolInput !== 'object') return '';\n if (toolName === QUESTION_TOOL) {\n const questions = toolInput.questions;\n if (Array.isArray(questions) && questions[0] && typeof questions[0].question === 'string') {\n return questions[0].question;\n }\n return '';\n }\n const keys = ['command', 'file_path', 'notebook_path', 'path', 'url', 'pattern', 'query', 'description', 'prompt'];\n for (const key of keys) {\n if (typeof toolInput[key] === 'string' && toolInput[key]) return toolInput[key];\n }\n return '';\n}\n\nfunction needsInputDetail(input) {\n const toolName = typeof input.tool_name === 'string' ? input.tool_name : '';\n const detail = { kind: toolName === QUESTION_TOOL ? 'question' : 'permission' };\n const tool = plainText(toolName, MAX_TOOL_LENGTH);\n if (tool) detail.tool = tool;\n const summary = plainText(primaryArgument(toolName, input.tool_input), MAX_SUMMARY_LENGTH);\n if (summary) detail.summary = summary;\n return detail;\n}\n\n// Claude hook payload -> neutral { event, needsInput?, backgroundWork? }, or null.\nfunction translate(input) {\n switch (input.hook_event_name) {\n case 'SessionStart':\n return { event: 'session-started' };\n case 'UserPromptSubmit':\n return { event: 'turn-started' };\n case 'PostToolUse':\n return { event: 'tool-activity' };\n case 'PreToolUse':\n if (input.tool_name !== QUESTION_TOOL) return null;\n return { event: 'needs-input', needsInput: needsInputDetail(input) };\n case 'PermissionRequest':\n return { event: 'needs-input', needsInput: needsInputDetail(input) };\n case 'Notification':\n if (input.notification_type === 'permission_prompt') return { event: 'needs-input' };\n if (input.notification_type === 'elicitation_dialog') return { event: 'needs-input', needsInput: { kind: 'question' } };\n if (input.notification_type === 'idle_prompt') return { event: 'turn-ended' };\n return null;\n case 'Stop': {\n const tasks = input.background_tasks;\n return { event: 'turn-ended', backgroundWork: Array.isArray(tasks) && tasks.length > 0 };\n }\n default:\n return null;\n }\n}\n\nfunction launchIdentity() {\n const env = process.env;\n if (env.CODEV_BUILDER_WORKTREE) {\n return { kind: 'builder', worktreePath: env.CODEV_BUILDER_WORKTREE };\n }\n if (env.CODEV_ARCHITECT_WORKSPACE && env.CODEV_ARCHITECT_NAME) {\n return { kind: 'architect', workspacePath: env.CODEV_ARCHITECT_WORKSPACE, name: env.CODEV_ARCHITECT_NAME };\n }\n return null;\n}\n\nfunction towerKey() {\n const override = (process.env.CODEV_TOWER_KEY || '').trim();\n if (override) return override;\n const dir = process.env.CODEV_AGENT_FARM_DIR\n ? path.resolve(process.env.CODEV_AGENT_FARM_DIR)\n : path.join(os.homedir(), '.agent-farm');\n try {\n return fs.readFileSync(path.join(dir, 'local-key'), 'utf8').trim();\n } catch (e) {\n return '';\n }\n}\n\nfunction towerPort() {\n const port = Number.parseInt(process.env.CODEV_TOWER_PORT || '', 10);\n if (Number.isInteger(port) && port > 0 && port < 65536) return port;\n return DEFAULT_TOWER_PORT;\n}\n\nfunction post(body, key) {\n const req = http.request({\n host: '127.0.0.1',\n port: towerPort(),\n path: '/api/agent-lifecycle',\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Content-Length': Buffer.byteLength(body),\n 'codev-tower-key': key,\n },\n }, (res) => {\n res.resume();\n res.on('end', done);\n res.on('error', done);\n });\n req.on('error', done);\n setTimeout(() => {\n req.destroy();\n done();\n }, REQUEST_DEADLINE_MS);\n req.end(body);\n}\n\nfunction main(raw) {\n const at = Date.now();\n let input;\n try {\n input = JSON.parse(raw);\n } catch (e) {\n return done();\n }\n if (!input || typeof input !== 'object') return done();\n\n const agent = launchIdentity();\n if (!agent) return done();\n\n const sessionId = input.session_id;\n if (typeof sessionId !== 'string' || !sessionId || sessionId.length > MAX_SESSION_ID_LENGTH) return done();\n\n const translated = translate(input);\n if (!translated) return done();\n\n const key = towerKey();\n if (!key) return done();\n\n const event = { agent: agent, sessionId: sessionId, event: translated.event, at: at };\n if (translated.needsInput) event.needsInput = translated.needsInput;\n if (translated.backgroundWork !== undefined) event.backgroundWork = translated.backgroundWork;\n\n const body = JSON.stringify(event);\n if (Buffer.byteLength(body) > MAX_BODY_BYTES) return done();\n post(body, key);\n}\n\n// A stdin that never closes must not keep the hook alive.\nsetTimeout(done, OVERALL_DEADLINE_MS).unref();\n\nlet buf = '';\nprocess.stdin.setEncoding('utf8');\nprocess.stdin.on('data', (d) => {\n buf += d;\n});\nprocess.stdin.on('error', done);\nprocess.stdin.on('end', () => {\n try {\n main(buf);\n } catch (e) {\n done();\n }\n});\n";
50
+ /**
51
+ * The hook command, identical for every agent. A shell wrapper rather than a
52
+ * bare `node <path>`, so a deleted script, a missing `node` or a crash
53
+ * produces no output and exit 0.
54
+ */
55
+ export declare function buildLifecycleHookCommand(scriptPath: string): string;
56
+ /** The settings document wiring the reporter onto every Claude hook it translates. */
57
+ export declare function buildLifecycleReporterSettings(scriptPath: string): string;
58
+ /**
59
+ * Install the reporter script and its settings file, and return the absolute
60
+ * settings path to hand to the harness. Directory mode 0700, files 0600,
61
+ * set explicitly rather than left to the umask. Throws on a filesystem error;
62
+ * callers use `resolveLifecycleReporterInjection`, which fails open.
63
+ */
64
+ export declare function ensureLifecycleReporterInstalled(dir?: string): string;
65
+ export type LifecycleReporterInjection = ReturnType<NonNullable<HarnessProvider['buildLifecycleReporterInjection']>>;
66
+ /**
67
+ * The reporter injection for a launch on `harness`, or null when the harness
68
+ * has no reporter or the files could not be installed. Installs (or refreshes)
69
+ * the files first: the harness refuses to start when its `--settings` file is
70
+ * missing, so the flag is only ever injected right after a successful install.
71
+ * A failure is logged and the agent launches without a reporter, which falls
72
+ * back to today's PTY-silence behavior.
73
+ *
74
+ * The installed files are Claude's (only `CLAUDE_HARNESS` carries the
75
+ * capability). A harness that gains a reporter (#1796) installs its own
76
+ * harness-named files rather than reusing these.
77
+ */
78
+ export declare function resolveLifecycleReporterInjection(harness: HarnessProvider, dir?: string): LifecycleReporterInjection | null;
79
+ //# sourceMappingURL=lifecycle-reporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle-reporter.d.ts","sourceRoot":"","sources":["../../../src/agent-farm/utils/lifecycle-reporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAQH,OAAO,EAAuC,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAEzF;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,kCAAkC,CAAC;AAE9E,qEAAqE;AACrE,eAAO,MAAM,gCAAgC,4CAA4C,CAAC;AAE1F,4GAA4G;AAC5G,eAAO,MAAM,8BAA8B,IAAI,CAAC;AAEhD,uGAAuG;AACvG,eAAO,MAAM,oBAAoB,oBAAoB,CAAC;AAEtD,mDAAmD;AACnD,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,uyMAqMrC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAGpE;AAED,sFAAsF;AACtF,wBAAgB,8BAA8B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAmBzE;AAwBD;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAAC,GAAG,GAAE,MAA+B,GAAG,MAAM,CAQ7F;AAED,MAAM,MAAM,0BAA0B,GAAG,UAAU,CAAC,WAAW,CAAC,eAAe,CAAC,iCAAiC,CAAC,CAAC,CAAC,CAAC;AAErH;;;;;;;;;;;GAWG;AACH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,eAAe,EACxB,GAAG,CAAC,EAAE,MAAM,GACX,0BAA0B,GAAG,IAAI,CAUnC"}
@@ -0,0 +1,347 @@
1
+ /**
2
+ * Claude lifecycle reporter (Spec 1595).
3
+ *
4
+ * Every Claude agent Codev launches reports its lifecycle to Tower so the
5
+ * overview can serve working / needs-input / idle from the harness itself
6
+ * instead of inferring it from PTY silence. This module is the single source of
7
+ * truth for the Claude provider's reporter, in the shape of the write-guard
8
+ * (`worktree-write-guard.ts`): two generated files, installed into a
9
+ * codev-owned directory no agent session writes to:
10
+ * - `claude-lifecycle-reporter.cjs`: a dependency-free Node hook script
11
+ * - `claude-lifecycle-reporter-settings.json`: the hook set, handed to the harness
12
+ * with `--settings <path>` through `CLAUDE_HARNESS.buildLifecycleReporterInjection`
13
+ *
14
+ * The script translates Claude hook names to the harness-neutral
15
+ * `AgentLifecycleEvent` vocabulary, so no Claude hook name crosses the wire.
16
+ * Identity comes only from the launch environment (`CODEV_BUILDER_WORKTREE`, or
17
+ * `CODEV_ARCHITECT_WORKSPACE` with `CODEV_ARCHITECT_NAME`); with neither set it
18
+ * sends nothing.
19
+ *
20
+ * Fail-open by construction (SC15): every hook is `async`, the script makes one
21
+ * request with a sub-second deadline and no retry, writes nothing to stdout
22
+ * (so it can never make a permission decision), and always exits 0. The hook
23
+ * command is a shell wrapper that exits 0 silently even when the script is
24
+ * missing. Neither file embeds a secret: the local key is read at hook time.
25
+ *
26
+ * @see codev/specs/1595-agent-attention-states-working.md
27
+ */
28
+ import { chmodSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
29
+ import { join } from 'node:path';
30
+ import { randomBytes } from 'node:crypto';
31
+ import { AGENT_FARM_DIR } from '@cluesmith/codev-core/constants';
32
+ import { DEFAULT_TOWER_PORT } from '@cluesmith/codev-sdk/constants';
33
+ import { logger } from './logger.js';
34
+ import { shellEscapeSingleQuote, toShellPath } from './harness.js';
35
+ /**
36
+ * Basename of the installed reporter script. Both files read Claude's hook payloads and settings
37
+ * format, so their names carry the harness: another harness's reporter installs beside them under
38
+ * its own names, never over them.
39
+ */
40
+ export const LIFECYCLE_REPORTER_SCRIPT_NAME = 'claude-lifecycle-reporter.cjs';
41
+ /** Basename of the installed settings file carrying the hook set. */
42
+ export const LIFECYCLE_REPORTER_SETTINGS_NAME = 'claude-lifecycle-reporter-settings.json';
43
+ /** Seconds the harness allows each hook before abandoning it. The script itself finishes well inside it. */
44
+ export const LIFECYCLE_HOOK_TIMEOUT_SECONDS = 3;
45
+ /** Claude's question tool: the PreToolUse matcher and the script's question-kind test both read it. */
46
+ export const CLAUDE_QUESTION_TOOL = 'AskUserQuestion';
47
+ /** The directory both files are installed into. */
48
+ export function lifecycleReporterDir() {
49
+ return join(AGENT_FARM_DIR, 'hooks');
50
+ }
51
+ /**
52
+ * The self-contained Node reporter script, written verbatim to the hooks
53
+ * directory. A string constant so it ships with the compiled package; the unit
54
+ * test writes it to a temp file and runs it with fixture stdin, so the
55
+ * constant is the tested artifact.
56
+ */
57
+ export const LIFECYCLE_REPORTER_SCRIPT = `#!/usr/bin/env node
58
+ // AUTO-GENERATED by @cluesmith/codev (Spec 1595). Do not edit;
59
+ // edit packages/codev/src/agent-farm/utils/lifecycle-reporter.ts instead.
60
+ 'use strict';
61
+
62
+ const fs = require('node:fs');
63
+ const http = require('node:http');
64
+ const os = require('node:os');
65
+ const path = require('node:path');
66
+
67
+ const QUESTION_TOOL = '${CLAUDE_QUESTION_TOOL}';
68
+ const DEFAULT_TOWER_PORT = ${DEFAULT_TOWER_PORT};
69
+ const REQUEST_DEADLINE_MS = 800;
70
+ const OVERALL_DEADLINE_MS = 1500;
71
+ const MAX_BODY_BYTES = 8192;
72
+ const MAX_SESSION_ID_LENGTH = 128;
73
+ const MAX_TOOL_LENGTH = 64;
74
+ const MAX_SUMMARY_LENGTH = 200;
75
+
76
+ function done() {
77
+ process.exit(0);
78
+ }
79
+
80
+ // Single line, control characters removed, at most maxLength UTF-16 units
81
+ // without splitting a surrogate pair. Empty means "omit the field".
82
+ function plainText(value, maxLength) {
83
+ if (typeof value !== 'string') return '';
84
+ let text = value
85
+ .replace(/\\s*[\\r\\n\\u2028\\u2029]+\\s*/g, ' ')
86
+ .replace(/\\t/g, ' ')
87
+ .replace(/[\\u0000-\\u001f\\u007f-\\u009f]/g, '')
88
+ .trim();
89
+ if (text.length > maxLength) {
90
+ text = text.slice(0, maxLength);
91
+ const last = text.charCodeAt(text.length - 1);
92
+ if (last >= 0xd800 && last <= 0xdbff) text = text.slice(0, -1);
93
+ }
94
+ return text;
95
+ }
96
+
97
+ // The tool's primary argument: a command's text, a path, a pattern, a URL,
98
+ // or the question being asked.
99
+ function primaryArgument(toolName, toolInput) {
100
+ if (!toolInput || typeof toolInput !== 'object') return '';
101
+ if (toolName === QUESTION_TOOL) {
102
+ const questions = toolInput.questions;
103
+ if (Array.isArray(questions) && questions[0] && typeof questions[0].question === 'string') {
104
+ return questions[0].question;
105
+ }
106
+ return '';
107
+ }
108
+ const keys = ['command', 'file_path', 'notebook_path', 'path', 'url', 'pattern', 'query', 'description', 'prompt'];
109
+ for (const key of keys) {
110
+ if (typeof toolInput[key] === 'string' && toolInput[key]) return toolInput[key];
111
+ }
112
+ return '';
113
+ }
114
+
115
+ function needsInputDetail(input) {
116
+ const toolName = typeof input.tool_name === 'string' ? input.tool_name : '';
117
+ const detail = { kind: toolName === QUESTION_TOOL ? 'question' : 'permission' };
118
+ const tool = plainText(toolName, MAX_TOOL_LENGTH);
119
+ if (tool) detail.tool = tool;
120
+ const summary = plainText(primaryArgument(toolName, input.tool_input), MAX_SUMMARY_LENGTH);
121
+ if (summary) detail.summary = summary;
122
+ return detail;
123
+ }
124
+
125
+ // Claude hook payload -> neutral { event, needsInput?, backgroundWork? }, or null.
126
+ function translate(input) {
127
+ switch (input.hook_event_name) {
128
+ case 'SessionStart':
129
+ return { event: 'session-started' };
130
+ case 'UserPromptSubmit':
131
+ return { event: 'turn-started' };
132
+ case 'PostToolUse':
133
+ return { event: 'tool-activity' };
134
+ case 'PreToolUse':
135
+ if (input.tool_name !== QUESTION_TOOL) return null;
136
+ return { event: 'needs-input', needsInput: needsInputDetail(input) };
137
+ case 'PermissionRequest':
138
+ return { event: 'needs-input', needsInput: needsInputDetail(input) };
139
+ case 'Notification':
140
+ if (input.notification_type === 'permission_prompt') return { event: 'needs-input' };
141
+ if (input.notification_type === 'elicitation_dialog') return { event: 'needs-input', needsInput: { kind: 'question' } };
142
+ if (input.notification_type === 'idle_prompt') return { event: 'turn-ended' };
143
+ return null;
144
+ case 'Stop': {
145
+ const tasks = input.background_tasks;
146
+ return { event: 'turn-ended', backgroundWork: Array.isArray(tasks) && tasks.length > 0 };
147
+ }
148
+ default:
149
+ return null;
150
+ }
151
+ }
152
+
153
+ function launchIdentity() {
154
+ const env = process.env;
155
+ if (env.CODEV_BUILDER_WORKTREE) {
156
+ return { kind: 'builder', worktreePath: env.CODEV_BUILDER_WORKTREE };
157
+ }
158
+ if (env.CODEV_ARCHITECT_WORKSPACE && env.CODEV_ARCHITECT_NAME) {
159
+ return { kind: 'architect', workspacePath: env.CODEV_ARCHITECT_WORKSPACE, name: env.CODEV_ARCHITECT_NAME };
160
+ }
161
+ return null;
162
+ }
163
+
164
+ function towerKey() {
165
+ const override = (process.env.CODEV_TOWER_KEY || '').trim();
166
+ if (override) return override;
167
+ const dir = process.env.CODEV_AGENT_FARM_DIR
168
+ ? path.resolve(process.env.CODEV_AGENT_FARM_DIR)
169
+ : path.join(os.homedir(), '.agent-farm');
170
+ try {
171
+ return fs.readFileSync(path.join(dir, 'local-key'), 'utf8').trim();
172
+ } catch (e) {
173
+ return '';
174
+ }
175
+ }
176
+
177
+ function towerPort() {
178
+ const port = Number.parseInt(process.env.CODEV_TOWER_PORT || '', 10);
179
+ if (Number.isInteger(port) && port > 0 && port < 65536) return port;
180
+ return DEFAULT_TOWER_PORT;
181
+ }
182
+
183
+ function post(body, key) {
184
+ const req = http.request({
185
+ host: '127.0.0.1',
186
+ port: towerPort(),
187
+ path: '/api/agent-lifecycle',
188
+ method: 'POST',
189
+ headers: {
190
+ 'Content-Type': 'application/json',
191
+ 'Content-Length': Buffer.byteLength(body),
192
+ 'codev-tower-key': key,
193
+ },
194
+ }, (res) => {
195
+ res.resume();
196
+ res.on('end', done);
197
+ res.on('error', done);
198
+ });
199
+ req.on('error', done);
200
+ setTimeout(() => {
201
+ req.destroy();
202
+ done();
203
+ }, REQUEST_DEADLINE_MS);
204
+ req.end(body);
205
+ }
206
+
207
+ function main(raw) {
208
+ const at = Date.now();
209
+ let input;
210
+ try {
211
+ input = JSON.parse(raw);
212
+ } catch (e) {
213
+ return done();
214
+ }
215
+ if (!input || typeof input !== 'object') return done();
216
+
217
+ const agent = launchIdentity();
218
+ if (!agent) return done();
219
+
220
+ const sessionId = input.session_id;
221
+ if (typeof sessionId !== 'string' || !sessionId || sessionId.length > MAX_SESSION_ID_LENGTH) return done();
222
+
223
+ const translated = translate(input);
224
+ if (!translated) return done();
225
+
226
+ const key = towerKey();
227
+ if (!key) return done();
228
+
229
+ const event = { agent: agent, sessionId: sessionId, event: translated.event, at: at };
230
+ if (translated.needsInput) event.needsInput = translated.needsInput;
231
+ if (translated.backgroundWork !== undefined) event.backgroundWork = translated.backgroundWork;
232
+
233
+ const body = JSON.stringify(event);
234
+ if (Buffer.byteLength(body) > MAX_BODY_BYTES) return done();
235
+ post(body, key);
236
+ }
237
+
238
+ // A stdin that never closes must not keep the hook alive.
239
+ setTimeout(done, OVERALL_DEADLINE_MS).unref();
240
+
241
+ let buf = '';
242
+ process.stdin.setEncoding('utf8');
243
+ process.stdin.on('data', (d) => {
244
+ buf += d;
245
+ });
246
+ process.stdin.on('error', done);
247
+ process.stdin.on('end', () => {
248
+ try {
249
+ main(buf);
250
+ } catch (e) {
251
+ done();
252
+ }
253
+ });
254
+ `;
255
+ /**
256
+ * The hook command, identical for every agent. A shell wrapper rather than a
257
+ * bare `node <path>`, so a deleted script, a missing `node` or a crash
258
+ * produces no output and exit 0.
259
+ */
260
+ export function buildLifecycleHookCommand(scriptPath) {
261
+ const script = `'${shellEscapeSingleQuote(toShellPath(scriptPath))}'`;
262
+ return `[ -f ${script} ] && node ${script} >/dev/null 2>&1; exit 0`;
263
+ }
264
+ /** The settings document wiring the reporter onto every Claude hook it translates. */
265
+ export function buildLifecycleReporterSettings(scriptPath) {
266
+ const hook = {
267
+ type: 'command',
268
+ command: buildLifecycleHookCommand(scriptPath),
269
+ async: true,
270
+ timeout: LIFECYCLE_HOOK_TIMEOUT_SECONDS,
271
+ };
272
+ const settings = {
273
+ hooks: {
274
+ SessionStart: [{ hooks: [hook] }],
275
+ UserPromptSubmit: [{ hooks: [hook] }],
276
+ PostToolUse: [{ matcher: '*', hooks: [hook] }],
277
+ PreToolUse: [{ matcher: CLAUDE_QUESTION_TOOL, hooks: [hook] }],
278
+ PermissionRequest: [{ matcher: '*', hooks: [hook] }],
279
+ Notification: [{ hooks: [hook] }],
280
+ Stop: [{ hooks: [hook] }],
281
+ },
282
+ };
283
+ return JSON.stringify(settings, null, 2) + '\n';
284
+ }
285
+ /**
286
+ * Write `content` to `path` with mode 0600 through a temp file and a rename,
287
+ * only when it differs from what is there. The mode is enforced either way, so
288
+ * a file left with a wider mode is tightened.
289
+ */
290
+ function writeFileIfChanged(path, content) {
291
+ let current = null;
292
+ try {
293
+ current = readFileSync(path, 'utf8');
294
+ }
295
+ catch {
296
+ current = null;
297
+ }
298
+ if (current === content) {
299
+ chmodSync(path, 0o600);
300
+ return;
301
+ }
302
+ const temp = `${path}.${process.pid}.${randomBytes(4).toString('hex')}.tmp`;
303
+ writeFileSync(temp, content, { mode: 0o600 });
304
+ chmodSync(temp, 0o600);
305
+ renameSync(temp, path);
306
+ }
307
+ /**
308
+ * Install the reporter script and its settings file, and return the absolute
309
+ * settings path to hand to the harness. Directory mode 0700, files 0600,
310
+ * set explicitly rather than left to the umask. Throws on a filesystem error;
311
+ * callers use `resolveLifecycleReporterInjection`, which fails open.
312
+ */
313
+ export function ensureLifecycleReporterInstalled(dir = lifecycleReporterDir()) {
314
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
315
+ chmodSync(dir, 0o700);
316
+ const scriptPath = join(dir, LIFECYCLE_REPORTER_SCRIPT_NAME);
317
+ const settingsPath = join(dir, LIFECYCLE_REPORTER_SETTINGS_NAME);
318
+ writeFileIfChanged(scriptPath, LIFECYCLE_REPORTER_SCRIPT);
319
+ writeFileIfChanged(settingsPath, buildLifecycleReporterSettings(scriptPath));
320
+ return settingsPath;
321
+ }
322
+ /**
323
+ * The reporter injection for a launch on `harness`, or null when the harness
324
+ * has no reporter or the files could not be installed. Installs (or refreshes)
325
+ * the files first: the harness refuses to start when its `--settings` file is
326
+ * missing, so the flag is only ever injected right after a successful install.
327
+ * A failure is logged and the agent launches without a reporter, which falls
328
+ * back to today's PTY-silence behavior.
329
+ *
330
+ * The installed files are Claude's (only `CLAUDE_HARNESS` carries the
331
+ * capability). A harness that gains a reporter (#1796) installs its own
332
+ * harness-named files rather than reusing these.
333
+ */
334
+ export function resolveLifecycleReporterInjection(harness, dir) {
335
+ if (!harness.buildLifecycleReporterInjection)
336
+ return null;
337
+ let settingsPath;
338
+ try {
339
+ settingsPath = ensureLifecycleReporterInstalled(dir);
340
+ }
341
+ catch (err) {
342
+ logger.warn(`Lifecycle reporter not installed; launching without it: ${err instanceof Error ? err.message : String(err)}`);
343
+ return null;
344
+ }
345
+ return harness.buildLifecycleReporterInjection(settingsPath);
346
+ }
347
+ //# sourceMappingURL=lifecycle-reporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle-reporter.js","sourceRoot":"","sources":["../../../src/agent-farm/utils/lifecycle-reporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,O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,CAAC;IACvD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,IAAI,CAAC,2DAA2D,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC3H,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,OAAO,CAAC,+BAA+B,CAAC,YAAY,CAAC,CAAC;AAC/D,CAAC"}
@@ -89,31 +89,66 @@ export declare function isAllowedHost(hostHeader: string | undefined): boolean;
89
89
  * @returns true if the request is authorized
90
90
  */
91
91
  export declare function isRequestAllowed(req: http.IncomingMessage): boolean;
92
+ /** Name of the forward cookie. Never forwarded to the IDE server. */
93
+ export declare const IDE_FORWARD_COOKIE = "codev-ide-session";
94
+ /**
95
+ * The forward cookie's expected value: `HMAC-SHA256(localKey, purpose)`, hex.
96
+ * Derived from `getExpectedKey()` on EVERY call (never cached at module load),
97
+ * so the `CODEV_TOWER_KEY` override and `resetExpectedKeyCache()` are honoured
98
+ * and rotating the local key revokes every cookie. That rotation is the only
99
+ * revocation. The value cannot be inverted to the key, so it never grants
100
+ * Tower's API routes. Returns null (fail closed) when the key is unavailable.
101
+ */
102
+ export declare function ideForwardCookieValue(): string | null;
103
+ /** The `Set-Cookie` value `POST /api/ide/session` returns, or null when the key is unavailable. */
104
+ export declare function ideForwardSetCookie(): string | null;
105
+ /**
106
+ * Read one cookie's value from a `Cookie` header (string or string[] shape), or
107
+ * null if absent. Exact-name match: `codev-ide-session2` is not `codev-ide-session`.
108
+ */
109
+ export declare function cookieValue(header: string | string[] | undefined, name: string): string | null;
110
+ /**
111
+ * Cross-port guard for the forward cookie (Issue #1869). A cookie-authorized
112
+ * request may proceed only when it is not initiated by another origin:
113
+ * - `Origin`, if present, must be this request's own origin
114
+ * (`http(s)://<Host>`) or an exact `CODEV_TOWER_ALLOWED_ORIGINS` entry;
115
+ * - `Sec-Fetch-Site`, if present, must be `same-origin` or `none`
116
+ * (`same-site` is exactly the other-localhost-port case and is refused).
117
+ * A request with neither header passes: top-level navigations and same-origin
118
+ * asset GETs may omit them, while browsers always send `Origin` on WebSocket
119
+ * upgrades and cross-origin fetches, which is the set this must refuse.
120
+ * Applied ONLY to the cookie branch; the key-header branch never calls it.
121
+ */
122
+ export declare function isSameOriginForwardRequest(req: http.IncomingMessage): boolean;
123
+ /** Outcome of the forward authorization decision, with a log-safe reason on refusal. */
124
+ export type ForwardAuthDecision = {
125
+ allowed: true;
126
+ via: 'header' | 'cookie';
127
+ } | {
128
+ allowed: false;
129
+ reason: string;
130
+ };
92
131
  /**
93
132
  * Security: decide whether a request may proceed to the IDE prefix forward
94
- * (Issue #1668). This is the ONE authorization seam for the forward — both the
95
- * HTTP path (which also passes the general `isRequestAllowed` choke point) and
96
- * the WebSocket upgrade call it.
133
+ * (Issue #1668). This is the ONE authorization seam for the forward: the HTTP
134
+ * path (`isRequestAllowed` delegates every `/ide*` path here) and the WebSocket
135
+ * upgrade both call it.
97
136
  *
98
- * It reuses the exact primitives the HTTP choke point uses: the Host guard plus
99
- * a constant-time match of the shared local key from the `codev-tower-key`
100
- * header. That header is what `TunnelClient.stampLocalHeaders` stamps on every
101
- * tunnel-borne request (HTTP and WS-CONNECT alike, #1588), so a browser
102
- * arriving via the cloud proxy authenticates here without offering the WS
103
- * subprotocol key that the dashboard's `isWebSocketAllowed` requires (the IDE
104
- * workbench's own WebSockets are vanilla `?reconnectionToken=` connections that
105
- * offer no subprotocol).
137
+ * Fixed order:
138
+ * 1. Host guard (DNS rebinding).
139
+ * 2. Key header (`codev-tower-key` / legacy `codev-web-key`), constant-time.
140
+ * This is what `TunnelClient.stampLocalHeaders` stamps on every tunnel-borne
141
+ * request (#1588), so the cloud path authorizes here, with no origin check
142
+ * (a cloud browser's `Origin` is the cloud host, never Tower's).
143
+ * 3. Forward cookie (Issue #1869), constant-time, AND the cross-port guard.
106
144
  *
107
145
  * There is deliberately NO per-folder logic: the IDE server offers no per-folder
108
- * isolation — any authenticated connection can open any path its OS user can
109
- * read (same trust as a terminal) — so authorization is a whole-boundary key +
110
- * Host decision and nothing finer (Issue #1668 §D2).
111
- *
112
- * This function is the swap point for #1589 (per-session remote credential): its
113
- * body can move from the local-key stamp to a per-session credential without
114
- * touching the proxying code, which calls it and only then strips/stamps headers.
115
- * Fails closed when the expected key is unavailable.
146
+ * isolation, so authorization is a whole-boundary decision (Issue #1668 §D2).
147
+ * This is the swap point for #1589 (per-session remote credential). Fails closed
148
+ * when the expected key is unavailable. Reasons never contain credential values.
116
149
  */
150
+ export declare function decideForwardAuthorization(req: http.IncomingMessage): ForwardAuthDecision;
151
+ /** Boolean form of `decideForwardAuthorization`. */
117
152
  export declare function isForwardAuthorized(req: http.IncomingMessage): boolean;
118
153
  /**
119
154
  * The subprotocol the server echoes back on a terminal WebSocket handshake:
@@ -1 +1 @@
1
- {"version":3,"file":"server-utils.d.ts","sourceRoot":"","sources":["../../../src/agent-farm/utils/server-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AAKvC;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO9C;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,SAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAgB1F;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,SAAc,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAyBhH;AAsBD;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAS9C;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,SAAS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