@cluesmith/codev 2.0.0-rc.9 → 2.0.1

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 (537) hide show
  1. package/bin/af.js +2 -2
  2. package/bin/consult.js +1 -1
  3. package/dashboard/dist/assets/index-4n9zpWLY.css +32 -0
  4. package/dashboard/dist/assets/index-b38SaXk5.js +136 -0
  5. package/dashboard/dist/assets/index-b38SaXk5.js.map +1 -0
  6. package/dashboard/dist/index.html +14 -0
  7. package/dist/agent-farm/cli.d.ts.map +1 -1
  8. package/dist/agent-farm/cli.js +179 -104
  9. package/dist/agent-farm/cli.js.map +1 -1
  10. package/dist/agent-farm/commands/architect.d.ts +3 -3
  11. package/dist/agent-farm/commands/architect.d.ts.map +1 -1
  12. package/dist/agent-farm/commands/architect.js +20 -147
  13. package/dist/agent-farm/commands/architect.js.map +1 -1
  14. package/dist/agent-farm/commands/attach.d.ts +13 -0
  15. package/dist/agent-farm/commands/attach.d.ts.map +1 -0
  16. package/dist/agent-farm/commands/attach.js +144 -0
  17. package/dist/agent-farm/commands/attach.js.map +1 -0
  18. package/dist/agent-farm/commands/cleanup.d.ts.map +1 -1
  19. package/dist/agent-farm/commands/cleanup.js +35 -19
  20. package/dist/agent-farm/commands/cleanup.js.map +1 -1
  21. package/dist/agent-farm/commands/consult.d.ts +3 -4
  22. package/dist/agent-farm/commands/consult.d.ts.map +1 -1
  23. package/dist/agent-farm/commands/consult.js +27 -37
  24. package/dist/agent-farm/commands/consult.js.map +1 -1
  25. package/dist/agent-farm/commands/index.d.ts +2 -2
  26. package/dist/agent-farm/commands/index.d.ts.map +1 -1
  27. package/dist/agent-farm/commands/index.js +2 -2
  28. package/dist/agent-farm/commands/index.js.map +1 -1
  29. package/dist/agent-farm/commands/open.d.ts +4 -2
  30. package/dist/agent-farm/commands/open.d.ts.map +1 -1
  31. package/dist/agent-farm/commands/open.js +33 -83
  32. package/dist/agent-farm/commands/open.js.map +1 -1
  33. package/dist/agent-farm/commands/send.d.ts +1 -1
  34. package/dist/agent-farm/commands/send.d.ts.map +1 -1
  35. package/dist/agent-farm/commands/send.js +70 -79
  36. package/dist/agent-farm/commands/send.js.map +1 -1
  37. package/dist/agent-farm/commands/shell.d.ts +15 -0
  38. package/dist/agent-farm/commands/shell.d.ts.map +1 -0
  39. package/dist/agent-farm/commands/shell.js +50 -0
  40. package/dist/agent-farm/commands/shell.js.map +1 -0
  41. package/dist/agent-farm/commands/spawn-roles.d.ts +80 -0
  42. package/dist/agent-farm/commands/spawn-roles.d.ts.map +1 -0
  43. package/dist/agent-farm/commands/spawn-roles.js +278 -0
  44. package/dist/agent-farm/commands/spawn-roles.js.map +1 -0
  45. package/dist/agent-farm/commands/spawn-worktree.d.ts +96 -0
  46. package/dist/agent-farm/commands/spawn-worktree.d.ts.map +1 -0
  47. package/dist/agent-farm/commands/spawn-worktree.js +305 -0
  48. package/dist/agent-farm/commands/spawn-worktree.js.map +1 -0
  49. package/dist/agent-farm/commands/spawn.d.ts +5 -1
  50. package/dist/agent-farm/commands/spawn.d.ts.map +1 -1
  51. package/dist/agent-farm/commands/spawn.js +241 -561
  52. package/dist/agent-farm/commands/spawn.js.map +1 -1
  53. package/dist/agent-farm/commands/start.d.ts +10 -20
  54. package/dist/agent-farm/commands/start.d.ts.map +1 -1
  55. package/dist/agent-farm/commands/start.js +45 -449
  56. package/dist/agent-farm/commands/start.js.map +1 -1
  57. package/dist/agent-farm/commands/status.d.ts +2 -0
  58. package/dist/agent-farm/commands/status.d.ts.map +1 -1
  59. package/dist/agent-farm/commands/status.js +75 -24
  60. package/dist/agent-farm/commands/status.js.map +1 -1
  61. package/dist/agent-farm/commands/stop.d.ts +6 -0
  62. package/dist/agent-farm/commands/stop.d.ts.map +1 -1
  63. package/dist/agent-farm/commands/stop.js +49 -109
  64. package/dist/agent-farm/commands/stop.js.map +1 -1
  65. package/dist/agent-farm/commands/tower-cloud.d.ts +48 -0
  66. package/dist/agent-farm/commands/tower-cloud.d.ts.map +1 -0
  67. package/dist/agent-farm/commands/tower-cloud.js +293 -0
  68. package/dist/agent-farm/commands/tower-cloud.js.map +1 -0
  69. package/dist/agent-farm/commands/tower.d.ts +9 -0
  70. package/dist/agent-farm/commands/tower.d.ts.map +1 -1
  71. package/dist/agent-farm/commands/tower.js +59 -19
  72. package/dist/agent-farm/commands/tower.js.map +1 -1
  73. package/dist/agent-farm/db/index.d.ts +6 -2
  74. package/dist/agent-farm/db/index.d.ts.map +1 -1
  75. package/dist/agent-farm/db/index.js +301 -19
  76. package/dist/agent-farm/db/index.js.map +1 -1
  77. package/dist/agent-farm/db/migrate.d.ts +0 -4
  78. package/dist/agent-farm/db/migrate.d.ts.map +1 -1
  79. package/dist/agent-farm/db/migrate.js +6 -55
  80. package/dist/agent-farm/db/migrate.js.map +1 -1
  81. package/dist/agent-farm/db/schema.d.ts +3 -3
  82. package/dist/agent-farm/db/schema.d.ts.map +1 -1
  83. package/dist/agent-farm/db/schema.js +25 -19
  84. package/dist/agent-farm/db/schema.js.map +1 -1
  85. package/dist/agent-farm/db/types.d.ts +3 -13
  86. package/dist/agent-farm/db/types.d.ts.map +1 -1
  87. package/dist/agent-farm/db/types.js +3 -11
  88. package/dist/agent-farm/db/types.js.map +1 -1
  89. package/dist/agent-farm/hq-connector.d.ts +2 -6
  90. package/dist/agent-farm/hq-connector.d.ts.map +1 -1
  91. package/dist/agent-farm/hq-connector.js +2 -17
  92. package/dist/agent-farm/hq-connector.js.map +1 -1
  93. package/dist/agent-farm/lib/cloud-config.d.ts +59 -0
  94. package/dist/agent-farm/lib/cloud-config.d.ts.map +1 -0
  95. package/dist/agent-farm/lib/cloud-config.js +143 -0
  96. package/dist/agent-farm/lib/cloud-config.js.map +1 -0
  97. package/dist/agent-farm/lib/device-name.d.ts +25 -0
  98. package/dist/agent-farm/lib/device-name.d.ts.map +1 -0
  99. package/dist/agent-farm/lib/device-name.js +46 -0
  100. package/dist/agent-farm/lib/device-name.js.map +1 -0
  101. package/dist/agent-farm/lib/nonce-store.d.ts +28 -0
  102. package/dist/agent-farm/lib/nonce-store.d.ts.map +1 -0
  103. package/dist/agent-farm/lib/nonce-store.js +60 -0
  104. package/dist/agent-farm/lib/nonce-store.js.map +1 -0
  105. package/dist/agent-farm/lib/token-exchange.d.ts +18 -0
  106. package/dist/agent-farm/lib/token-exchange.d.ts.map +1 -0
  107. package/dist/agent-farm/lib/token-exchange.js +48 -0
  108. package/dist/agent-farm/lib/token-exchange.js.map +1 -0
  109. package/dist/agent-farm/lib/tower-client.d.ts +163 -0
  110. package/dist/agent-farm/lib/tower-client.d.ts.map +1 -0
  111. package/dist/agent-farm/lib/tower-client.js +233 -0
  112. package/dist/agent-farm/lib/tower-client.js.map +1 -0
  113. package/dist/agent-farm/lib/tunnel-client.d.ts +117 -0
  114. package/dist/agent-farm/lib/tunnel-client.d.ts.map +1 -0
  115. package/dist/agent-farm/lib/tunnel-client.js +504 -0
  116. package/dist/agent-farm/lib/tunnel-client.js.map +1 -0
  117. package/dist/agent-farm/servers/tower-instances.d.ts +82 -0
  118. package/dist/agent-farm/servers/tower-instances.d.ts.map +1 -0
  119. package/dist/agent-farm/servers/tower-instances.js +454 -0
  120. package/dist/agent-farm/servers/tower-instances.js.map +1 -0
  121. package/dist/agent-farm/servers/tower-routes.d.ts +34 -0
  122. package/dist/agent-farm/servers/tower-routes.d.ts.map +1 -0
  123. package/dist/agent-farm/servers/tower-routes.js +1445 -0
  124. package/dist/agent-farm/servers/tower-routes.js.map +1 -0
  125. package/dist/agent-farm/servers/tower-server.d.ts +5 -2
  126. package/dist/agent-farm/servers/tower-server.d.ts.map +1 -1
  127. package/dist/agent-farm/servers/tower-server.js +157 -475
  128. package/dist/agent-farm/servers/tower-server.js.map +1 -1
  129. package/dist/agent-farm/servers/tower-terminals.d.ts +119 -0
  130. package/dist/agent-farm/servers/tower-terminals.d.ts.map +1 -0
  131. package/dist/agent-farm/servers/tower-terminals.js +629 -0
  132. package/dist/agent-farm/servers/tower-terminals.js.map +1 -0
  133. package/dist/agent-farm/servers/tower-tunnel.d.ts +34 -0
  134. package/dist/agent-farm/servers/tower-tunnel.d.ts.map +1 -0
  135. package/dist/agent-farm/servers/tower-tunnel.js +480 -0
  136. package/dist/agent-farm/servers/tower-tunnel.js.map +1 -0
  137. package/dist/agent-farm/servers/tower-types.d.ts +86 -0
  138. package/dist/agent-farm/servers/tower-types.d.ts.map +1 -0
  139. package/dist/agent-farm/servers/tower-types.js +6 -0
  140. package/dist/agent-farm/servers/tower-types.js.map +1 -0
  141. package/dist/agent-farm/servers/tower-utils.d.ts +58 -0
  142. package/dist/agent-farm/servers/tower-utils.d.ts.map +1 -0
  143. package/dist/agent-farm/servers/tower-utils.js +182 -0
  144. package/dist/agent-farm/servers/tower-utils.js.map +1 -0
  145. package/dist/agent-farm/servers/tower-websocket.d.ts +25 -0
  146. package/dist/agent-farm/servers/tower-websocket.d.ts.map +1 -0
  147. package/dist/agent-farm/servers/tower-websocket.js +171 -0
  148. package/dist/agent-farm/servers/tower-websocket.js.map +1 -0
  149. package/dist/agent-farm/state.d.ts +6 -2
  150. package/dist/agent-farm/state.d.ts.map +1 -1
  151. package/dist/agent-farm/state.js +34 -25
  152. package/dist/agent-farm/state.js.map +1 -1
  153. package/dist/agent-farm/types.d.ts +49 -26
  154. package/dist/agent-farm/types.d.ts.map +1 -1
  155. package/dist/agent-farm/utils/config.d.ts +0 -5
  156. package/dist/agent-farm/utils/config.d.ts.map +1 -1
  157. package/dist/agent-farm/utils/config.js +12 -44
  158. package/dist/agent-farm/utils/config.js.map +1 -1
  159. package/dist/agent-farm/utils/deps.d.ts.map +1 -1
  160. package/dist/agent-farm/utils/deps.js +0 -32
  161. package/dist/agent-farm/utils/deps.js.map +1 -1
  162. package/dist/agent-farm/utils/file-tabs.d.ts +27 -0
  163. package/dist/agent-farm/utils/file-tabs.d.ts.map +1 -0
  164. package/dist/agent-farm/utils/file-tabs.js +46 -0
  165. package/dist/agent-farm/utils/file-tabs.js.map +1 -0
  166. package/dist/agent-farm/utils/gate-status.d.ts +16 -0
  167. package/dist/agent-farm/utils/gate-status.d.ts.map +1 -0
  168. package/dist/agent-farm/utils/gate-status.js +79 -0
  169. package/dist/agent-farm/utils/gate-status.js.map +1 -0
  170. package/dist/agent-farm/utils/gate-watcher.d.ts +38 -0
  171. package/dist/agent-farm/utils/gate-watcher.d.ts.map +1 -0
  172. package/dist/agent-farm/utils/gate-watcher.js +122 -0
  173. package/dist/agent-farm/utils/gate-watcher.js.map +1 -0
  174. package/dist/agent-farm/utils/index.d.ts +0 -1
  175. package/dist/agent-farm/utils/index.d.ts.map +1 -1
  176. package/dist/agent-farm/utils/index.js +0 -1
  177. package/dist/agent-farm/utils/index.js.map +1 -1
  178. package/dist/agent-farm/utils/notifications.d.ts +30 -0
  179. package/dist/agent-farm/utils/notifications.d.ts.map +1 -0
  180. package/dist/agent-farm/utils/notifications.js +121 -0
  181. package/dist/agent-farm/utils/notifications.js.map +1 -0
  182. package/dist/agent-farm/utils/server-utils.d.ts +5 -5
  183. package/dist/agent-farm/utils/server-utils.d.ts.map +1 -1
  184. package/dist/agent-farm/utils/server-utils.js +5 -16
  185. package/dist/agent-farm/utils/server-utils.js.map +1 -1
  186. package/dist/agent-farm/utils/session.d.ts +32 -0
  187. package/dist/agent-farm/utils/session.d.ts.map +1 -0
  188. package/dist/agent-farm/utils/session.js +57 -0
  189. package/dist/agent-farm/utils/session.js.map +1 -0
  190. package/dist/agent-farm/utils/shell.d.ts +9 -22
  191. package/dist/agent-farm/utils/shell.d.ts.map +1 -1
  192. package/dist/agent-farm/utils/shell.js +34 -34
  193. package/dist/agent-farm/utils/shell.js.map +1 -1
  194. package/dist/cli.d.ts.map +1 -1
  195. package/dist/cli.js +6 -37
  196. package/dist/cli.js.map +1 -1
  197. package/dist/commands/adopt.d.ts.map +1 -1
  198. package/dist/commands/adopt.js +33 -4
  199. package/dist/commands/adopt.js.map +1 -1
  200. package/dist/commands/consult/index.d.ts +13 -2
  201. package/dist/commands/consult/index.d.ts.map +1 -1
  202. package/dist/commands/consult/index.js +244 -29
  203. package/dist/commands/consult/index.js.map +1 -1
  204. package/dist/commands/doctor.d.ts.map +1 -1
  205. package/dist/commands/doctor.js +96 -79
  206. package/dist/commands/doctor.js.map +1 -1
  207. package/dist/commands/init.d.ts.map +1 -1
  208. package/dist/commands/init.js +36 -3
  209. package/dist/commands/init.js.map +1 -1
  210. package/dist/commands/porch/build-counter.d.ts +5 -0
  211. package/dist/commands/porch/build-counter.d.ts.map +1 -0
  212. package/dist/commands/porch/build-counter.js +5 -0
  213. package/dist/commands/porch/build-counter.js.map +1 -0
  214. package/dist/commands/porch/checks.d.ts +3 -2
  215. package/dist/commands/porch/checks.d.ts.map +1 -1
  216. package/dist/commands/porch/checks.js +8 -2
  217. package/dist/commands/porch/checks.js.map +1 -1
  218. package/dist/commands/porch/index.d.ts +4 -0
  219. package/dist/commands/porch/index.d.ts.map +1 -1
  220. package/dist/commands/porch/index.js +109 -70
  221. package/dist/commands/porch/index.js.map +1 -1
  222. package/dist/commands/porch/next.d.ts +22 -0
  223. package/dist/commands/porch/next.d.ts.map +1 -0
  224. package/dist/commands/porch/next.js +571 -0
  225. package/dist/commands/porch/next.js.map +1 -0
  226. package/dist/commands/porch/plan.d.ts +11 -1
  227. package/dist/commands/porch/plan.d.ts.map +1 -1
  228. package/dist/commands/porch/plan.js +33 -5
  229. package/dist/commands/porch/plan.js.map +1 -1
  230. package/dist/commands/porch/prompts.d.ts.map +1 -1
  231. package/dist/commands/porch/prompts.js +44 -26
  232. package/dist/commands/porch/prompts.js.map +1 -1
  233. package/dist/commands/porch/protocol.d.ts +6 -4
  234. package/dist/commands/porch/protocol.d.ts.map +1 -1
  235. package/dist/commands/porch/protocol.js +59 -15
  236. package/dist/commands/porch/protocol.js.map +1 -1
  237. package/dist/commands/porch/state.d.ts +29 -2
  238. package/dist/commands/porch/state.d.ts.map +1 -1
  239. package/dist/commands/porch/state.js +71 -3
  240. package/dist/commands/porch/state.js.map +1 -1
  241. package/dist/commands/porch/types.d.ts +45 -2
  242. package/dist/commands/porch/types.d.ts.map +1 -1
  243. package/dist/commands/porch/verdict.d.ts +31 -0
  244. package/dist/commands/porch/verdict.d.ts.map +1 -0
  245. package/dist/commands/porch/verdict.js +59 -0
  246. package/dist/commands/porch/verdict.js.map +1 -0
  247. package/dist/commands/update.d.ts.map +1 -1
  248. package/dist/commands/update.js +18 -6
  249. package/dist/commands/update.js.map +1 -1
  250. package/dist/lib/scaffold.d.ts +13 -0
  251. package/dist/lib/scaffold.d.ts.map +1 -1
  252. package/dist/lib/scaffold.js +36 -0
  253. package/dist/lib/scaffold.js.map +1 -1
  254. package/dist/terminal/index.d.ts +8 -0
  255. package/dist/terminal/index.d.ts.map +1 -0
  256. package/dist/terminal/index.js +5 -0
  257. package/dist/terminal/index.js.map +1 -0
  258. package/dist/terminal/pty-manager.d.ts +69 -0
  259. package/dist/terminal/pty-manager.d.ts.map +1 -0
  260. package/dist/terminal/pty-manager.js +377 -0
  261. package/dist/terminal/pty-manager.js.map +1 -0
  262. package/dist/terminal/pty-session.d.ts +104 -0
  263. package/dist/terminal/pty-session.d.ts.map +1 -0
  264. package/dist/terminal/pty-session.js +327 -0
  265. package/dist/terminal/pty-session.js.map +1 -0
  266. package/dist/terminal/ring-buffer.d.ts +34 -0
  267. package/dist/terminal/ring-buffer.d.ts.map +1 -0
  268. package/dist/terminal/ring-buffer.js +94 -0
  269. package/dist/terminal/ring-buffer.js.map +1 -0
  270. package/dist/terminal/session-manager.d.ts +115 -0
  271. package/dist/terminal/session-manager.d.ts.map +1 -0
  272. package/dist/terminal/session-manager.js +582 -0
  273. package/dist/terminal/session-manager.js.map +1 -0
  274. package/dist/terminal/shellper-client.d.ts +66 -0
  275. package/dist/terminal/shellper-client.d.ts.map +1 -0
  276. package/dist/terminal/shellper-client.js +234 -0
  277. package/dist/terminal/shellper-client.js.map +1 -0
  278. package/dist/terminal/shellper-main.d.ts +19 -0
  279. package/dist/terminal/shellper-main.d.ts.map +1 -0
  280. package/dist/terminal/shellper-main.js +153 -0
  281. package/dist/terminal/shellper-main.js.map +1 -0
  282. package/dist/terminal/shellper-process.d.ts +75 -0
  283. package/dist/terminal/shellper-process.d.ts.map +1 -0
  284. package/dist/terminal/shellper-process.js +279 -0
  285. package/dist/terminal/shellper-process.js.map +1 -0
  286. package/dist/terminal/shellper-protocol.d.ts +115 -0
  287. package/dist/terminal/shellper-protocol.d.ts.map +1 -0
  288. package/dist/terminal/shellper-protocol.js +214 -0
  289. package/dist/terminal/shellper-protocol.js.map +1 -0
  290. package/dist/terminal/shellper-replay-buffer.d.ts +38 -0
  291. package/dist/terminal/shellper-replay-buffer.d.ts.map +1 -0
  292. package/dist/terminal/shellper-replay-buffer.js +94 -0
  293. package/dist/terminal/shellper-replay-buffer.js.map +1 -0
  294. package/dist/terminal/ws-protocol.d.ts +27 -0
  295. package/dist/terminal/ws-protocol.d.ts.map +1 -0
  296. package/dist/terminal/ws-protocol.js +44 -0
  297. package/dist/terminal/ws-protocol.js.map +1 -0
  298. package/package.json +17 -5
  299. package/skeleton/.claude/skills/af/SKILL.md +89 -0
  300. package/skeleton/.claude/skills/codev/SKILL.md +41 -0
  301. package/skeleton/.claude/skills/consult/SKILL.md +81 -0
  302. package/skeleton/.claude/skills/generate-image/SKILL.md +56 -0
  303. package/skeleton/DEPENDENCIES.md +4 -62
  304. package/skeleton/builders.md +1 -1
  305. package/skeleton/consult-types/impl-review.md +18 -9
  306. package/skeleton/consult-types/integration-review.md +1 -1
  307. package/skeleton/consult-types/plan-review.md +1 -1
  308. package/skeleton/consult-types/pr-ready.md +1 -1
  309. package/skeleton/consult-types/spec-review.md +1 -1
  310. package/skeleton/porch/prompts/defend.md +1 -1
  311. package/skeleton/porch/prompts/evaluate.md +2 -2
  312. package/skeleton/porch/prompts/implement.md +1 -1
  313. package/skeleton/porch/prompts/plan.md +1 -1
  314. package/skeleton/porch/prompts/review.md +4 -4
  315. package/skeleton/porch/prompts/specify.md +1 -1
  316. package/skeleton/porch/prompts/understand.md +2 -2
  317. package/skeleton/protocol-schema.json +282 -0
  318. package/skeleton/protocols/bugfix/builder-prompt.md +60 -0
  319. package/skeleton/protocols/bugfix/prompts/fix.md +77 -0
  320. package/skeleton/protocols/bugfix/prompts/investigate.md +77 -0
  321. package/skeleton/protocols/bugfix/prompts/pr.md +84 -0
  322. package/skeleton/protocols/bugfix/protocol.json +20 -33
  323. package/skeleton/protocols/experiment/builder-prompt.md +52 -0
  324. package/skeleton/protocols/experiment/protocol.json +101 -0
  325. package/skeleton/protocols/experiment/protocol.md +3 -3
  326. package/skeleton/protocols/experiment/templates/notes.md +1 -1
  327. package/skeleton/protocols/maintain/builder-prompt.md +46 -0
  328. package/skeleton/protocols/maintain/prompts/audit.md +111 -0
  329. package/skeleton/protocols/maintain/prompts/clean.md +91 -0
  330. package/skeleton/protocols/maintain/prompts/sync.md +113 -0
  331. package/skeleton/protocols/maintain/prompts/verify.md +110 -0
  332. package/skeleton/protocols/maintain/protocol.json +141 -0
  333. package/skeleton/protocols/maintain/protocol.md +17 -11
  334. package/skeleton/protocols/protocol-schema.json +54 -1
  335. package/skeleton/protocols/spir/builder-prompt.md +66 -0
  336. package/skeleton/protocols/spir/prompts/implement.md +208 -0
  337. package/skeleton/protocols/{spider → spir}/prompts/plan.md +6 -70
  338. package/skeleton/protocols/{spider → spir}/prompts/review.md +20 -39
  339. package/skeleton/protocols/{spider → spir}/prompts/specify.md +24 -59
  340. package/skeleton/protocols/{spider → spir}/protocol.json +30 -10
  341. package/skeleton/protocols/{spider → spir}/protocol.md +35 -21
  342. package/skeleton/protocols/spir/templates/review.md +89 -0
  343. package/skeleton/protocols/tick/builder-prompt.md +56 -0
  344. package/skeleton/protocols/tick/protocol.json +7 -2
  345. package/skeleton/protocols/tick/protocol.md +18 -18
  346. package/skeleton/protocols/tick/templates/review.md +1 -1
  347. package/skeleton/resources/commands/agent-farm.md +63 -46
  348. package/skeleton/resources/commands/codev.md +0 -2
  349. package/skeleton/resources/commands/overview.md +7 -17
  350. package/skeleton/resources/workflow-reference.md +4 -4
  351. package/skeleton/roles/architect.md +151 -306
  352. package/skeleton/roles/builder.md +115 -332
  353. package/skeleton/roles/consultant.md +6 -6
  354. package/skeleton/templates/AGENTS.md +2 -2
  355. package/skeleton/templates/CLAUDE.md +2 -2
  356. package/skeleton/templates/cheatsheet.md +7 -5
  357. package/skeleton/templates/projectlist.md +1 -1
  358. package/templates/dashboard/index.html +17 -16
  359. package/templates/dashboard/js/dialogs.js +7 -7
  360. package/templates/dashboard/js/files.js +2 -2
  361. package/templates/dashboard/js/main.js +4 -4
  362. package/templates/dashboard/js/projects.js +3 -3
  363. package/templates/dashboard/js/tabs.js +1 -1
  364. package/templates/dashboard/js/utils.js +22 -1
  365. package/templates/open.html +26 -0
  366. package/templates/tower.html +731 -91
  367. package/dist/agent-farm/commands/kickoff.d.ts +0 -20
  368. package/dist/agent-farm/commands/kickoff.d.ts.map +0 -1
  369. package/dist/agent-farm/commands/kickoff.js +0 -273
  370. package/dist/agent-farm/commands/kickoff.js.map +0 -1
  371. package/dist/agent-farm/commands/rename.d.ts +0 -13
  372. package/dist/agent-farm/commands/rename.d.ts.map +0 -1
  373. package/dist/agent-farm/commands/rename.js +0 -33
  374. package/dist/agent-farm/commands/rename.js.map +0 -1
  375. package/dist/agent-farm/commands/tutorial.d.ts +0 -10
  376. package/dist/agent-farm/commands/tutorial.d.ts.map +0 -1
  377. package/dist/agent-farm/commands/tutorial.js +0 -49
  378. package/dist/agent-farm/commands/tutorial.js.map +0 -1
  379. package/dist/agent-farm/commands/util.d.ts +0 -15
  380. package/dist/agent-farm/commands/util.d.ts.map +0 -1
  381. package/dist/agent-farm/commands/util.js +0 -108
  382. package/dist/agent-farm/commands/util.js.map +0 -1
  383. package/dist/agent-farm/servers/dashboard-server.d.ts +0 -7
  384. package/dist/agent-farm/servers/dashboard-server.d.ts.map +0 -1
  385. package/dist/agent-farm/servers/dashboard-server.js +0 -1858
  386. package/dist/agent-farm/servers/dashboard-server.js.map +0 -1
  387. package/dist/agent-farm/servers/open-server.d.ts +0 -7
  388. package/dist/agent-farm/servers/open-server.d.ts.map +0 -1
  389. package/dist/agent-farm/servers/open-server.js +0 -315
  390. package/dist/agent-farm/servers/open-server.js.map +0 -1
  391. package/dist/agent-farm/tutorial/index.d.ts +0 -8
  392. package/dist/agent-farm/tutorial/index.d.ts.map +0 -1
  393. package/dist/agent-farm/tutorial/index.js +0 -8
  394. package/dist/agent-farm/tutorial/index.js.map +0 -1
  395. package/dist/agent-farm/tutorial/prompts.d.ts +0 -57
  396. package/dist/agent-farm/tutorial/prompts.d.ts.map +0 -1
  397. package/dist/agent-farm/tutorial/prompts.js +0 -147
  398. package/dist/agent-farm/tutorial/prompts.js.map +0 -1
  399. package/dist/agent-farm/tutorial/runner.d.ts +0 -52
  400. package/dist/agent-farm/tutorial/runner.d.ts.map +0 -1
  401. package/dist/agent-farm/tutorial/runner.js +0 -204
  402. package/dist/agent-farm/tutorial/runner.js.map +0 -1
  403. package/dist/agent-farm/tutorial/state.d.ts +0 -26
  404. package/dist/agent-farm/tutorial/state.d.ts.map +0 -1
  405. package/dist/agent-farm/tutorial/state.js +0 -89
  406. package/dist/agent-farm/tutorial/state.js.map +0 -1
  407. package/dist/agent-farm/tutorial/steps/first-spec.d.ts +0 -7
  408. package/dist/agent-farm/tutorial/steps/first-spec.d.ts.map +0 -1
  409. package/dist/agent-farm/tutorial/steps/first-spec.js +0 -136
  410. package/dist/agent-farm/tutorial/steps/first-spec.js.map +0 -1
  411. package/dist/agent-farm/tutorial/steps/implementation.d.ts +0 -7
  412. package/dist/agent-farm/tutorial/steps/implementation.d.ts.map +0 -1
  413. package/dist/agent-farm/tutorial/steps/implementation.js +0 -76
  414. package/dist/agent-farm/tutorial/steps/implementation.js.map +0 -1
  415. package/dist/agent-farm/tutorial/steps/index.d.ts +0 -10
  416. package/dist/agent-farm/tutorial/steps/index.d.ts.map +0 -1
  417. package/dist/agent-farm/tutorial/steps/index.js +0 -10
  418. package/dist/agent-farm/tutorial/steps/index.js.map +0 -1
  419. package/dist/agent-farm/tutorial/steps/planning.d.ts +0 -7
  420. package/dist/agent-farm/tutorial/steps/planning.d.ts.map +0 -1
  421. package/dist/agent-farm/tutorial/steps/planning.js +0 -143
  422. package/dist/agent-farm/tutorial/steps/planning.js.map +0 -1
  423. package/dist/agent-farm/tutorial/steps/review.d.ts +0 -7
  424. package/dist/agent-farm/tutorial/steps/review.d.ts.map +0 -1
  425. package/dist/agent-farm/tutorial/steps/review.js +0 -78
  426. package/dist/agent-farm/tutorial/steps/review.js.map +0 -1
  427. package/dist/agent-farm/tutorial/steps/setup.d.ts +0 -7
  428. package/dist/agent-farm/tutorial/steps/setup.d.ts.map +0 -1
  429. package/dist/agent-farm/tutorial/steps/setup.js +0 -126
  430. package/dist/agent-farm/tutorial/steps/setup.js.map +0 -1
  431. package/dist/agent-farm/tutorial/steps/welcome.d.ts +0 -7
  432. package/dist/agent-farm/tutorial/steps/welcome.d.ts.map +0 -1
  433. package/dist/agent-farm/tutorial/steps/welcome.js +0 -50
  434. package/dist/agent-farm/tutorial/steps/welcome.js.map +0 -1
  435. package/dist/agent-farm/utils/orphan-handler.d.ts +0 -27
  436. package/dist/agent-farm/utils/orphan-handler.d.ts.map +0 -1
  437. package/dist/agent-farm/utils/orphan-handler.js +0 -149
  438. package/dist/agent-farm/utils/orphan-handler.js.map +0 -1
  439. package/dist/agent-farm/utils/port-registry.d.ts +0 -58
  440. package/dist/agent-farm/utils/port-registry.d.ts.map +0 -1
  441. package/dist/agent-farm/utils/port-registry.js +0 -166
  442. package/dist/agent-farm/utils/port-registry.js.map +0 -1
  443. package/dist/agent-farm/utils/terminal-ports.d.ts +0 -18
  444. package/dist/agent-farm/utils/terminal-ports.d.ts.map +0 -1
  445. package/dist/agent-farm/utils/terminal-ports.js +0 -35
  446. package/dist/agent-farm/utils/terminal-ports.js.map +0 -1
  447. package/dist/commands/pcheck/cache.d.ts +0 -48
  448. package/dist/commands/pcheck/cache.d.ts.map +0 -1
  449. package/dist/commands/pcheck/cache.js +0 -170
  450. package/dist/commands/pcheck/cache.js.map +0 -1
  451. package/dist/commands/pcheck/evaluator.d.ts +0 -15
  452. package/dist/commands/pcheck/evaluator.d.ts.map +0 -1
  453. package/dist/commands/pcheck/evaluator.js +0 -246
  454. package/dist/commands/pcheck/evaluator.js.map +0 -1
  455. package/dist/commands/pcheck/index.d.ts +0 -12
  456. package/dist/commands/pcheck/index.d.ts.map +0 -1
  457. package/dist/commands/pcheck/index.js +0 -249
  458. package/dist/commands/pcheck/index.js.map +0 -1
  459. package/dist/commands/pcheck/parser.d.ts +0 -39
  460. package/dist/commands/pcheck/parser.d.ts.map +0 -1
  461. package/dist/commands/pcheck/parser.js +0 -155
  462. package/dist/commands/pcheck/parser.js.map +0 -1
  463. package/dist/commands/pcheck/types.d.ts +0 -82
  464. package/dist/commands/pcheck/types.d.ts.map +0 -1
  465. package/dist/commands/pcheck/types.js +0 -5
  466. package/dist/commands/pcheck/types.js.map +0 -1
  467. package/dist/commands/porch/claude.d.ts +0 -29
  468. package/dist/commands/porch/claude.d.ts.map +0 -1
  469. package/dist/commands/porch/claude.js +0 -79
  470. package/dist/commands/porch/claude.js.map +0 -1
  471. package/dist/commands/porch/consultation.d.ts +0 -56
  472. package/dist/commands/porch/consultation.d.ts.map +0 -1
  473. package/dist/commands/porch/consultation.js +0 -330
  474. package/dist/commands/porch/consultation.js.map +0 -1
  475. package/dist/commands/porch/notifications.d.ts +0 -99
  476. package/dist/commands/porch/notifications.d.ts.map +0 -1
  477. package/dist/commands/porch/notifications.js +0 -223
  478. package/dist/commands/porch/notifications.js.map +0 -1
  479. package/dist/commands/porch/plan-parser.d.ts +0 -38
  480. package/dist/commands/porch/plan-parser.d.ts.map +0 -1
  481. package/dist/commands/porch/plan-parser.js +0 -166
  482. package/dist/commands/porch/plan-parser.js.map +0 -1
  483. package/dist/commands/porch/protocol-loader.d.ts +0 -46
  484. package/dist/commands/porch/protocol-loader.d.ts.map +0 -1
  485. package/dist/commands/porch/protocol-loader.js +0 -262
  486. package/dist/commands/porch/protocol-loader.js.map +0 -1
  487. package/dist/commands/porch/repl.d.ts +0 -33
  488. package/dist/commands/porch/repl.d.ts.map +0 -1
  489. package/dist/commands/porch/repl.js +0 -206
  490. package/dist/commands/porch/repl.js.map +0 -1
  491. package/dist/commands/porch/run.d.ts +0 -15
  492. package/dist/commands/porch/run.d.ts.map +0 -1
  493. package/dist/commands/porch/run.js +0 -551
  494. package/dist/commands/porch/run.js.map +0 -1
  495. package/dist/commands/porch/signal-parser.d.ts +0 -102
  496. package/dist/commands/porch/signal-parser.d.ts.map +0 -1
  497. package/dist/commands/porch/signal-parser.js +0 -199
  498. package/dist/commands/porch/signal-parser.js.map +0 -1
  499. package/dist/commands/porch/signals.d.ts +0 -35
  500. package/dist/commands/porch/signals.d.ts.map +0 -1
  501. package/dist/commands/porch/signals.js +0 -76
  502. package/dist/commands/porch/signals.js.map +0 -1
  503. package/dist/commands/porch2/checks.d.ts +0 -29
  504. package/dist/commands/porch2/checks.d.ts.map +0 -1
  505. package/dist/commands/porch2/checks.js +0 -141
  506. package/dist/commands/porch2/checks.js.map +0 -1
  507. package/dist/commands/porch2/index.d.ts +0 -38
  508. package/dist/commands/porch2/index.d.ts.map +0 -1
  509. package/dist/commands/porch2/index.js +0 -483
  510. package/dist/commands/porch2/index.js.map +0 -1
  511. package/dist/commands/porch2/plan.d.ts +0 -70
  512. package/dist/commands/porch2/plan.d.ts.map +0 -1
  513. package/dist/commands/porch2/plan.js +0 -227
  514. package/dist/commands/porch2/plan.js.map +0 -1
  515. package/dist/commands/porch2/protocol.d.ts +0 -37
  516. package/dist/commands/porch2/protocol.d.ts.map +0 -1
  517. package/dist/commands/porch2/protocol.js +0 -183
  518. package/dist/commands/porch2/protocol.js.map +0 -1
  519. package/dist/commands/porch2/state.d.ts +0 -35
  520. package/dist/commands/porch2/state.d.ts.map +0 -1
  521. package/dist/commands/porch2/state.js +0 -124
  522. package/dist/commands/porch2/state.js.map +0 -1
  523. package/dist/commands/porch2/types.d.ts +0 -79
  524. package/dist/commands/porch2/types.d.ts.map +0 -1
  525. package/dist/commands/porch2/types.js +0 -8
  526. package/dist/commands/porch2/types.js.map +0 -1
  527. package/dist/commands/tower.d.ts +0 -16
  528. package/dist/commands/tower.d.ts.map +0 -1
  529. package/dist/commands/tower.js +0 -21
  530. package/dist/commands/tower.js.map +0 -1
  531. package/skeleton/config.json +0 -7
  532. package/skeleton/protocols/spider/prompts/defend.md +0 -215
  533. package/skeleton/protocols/spider/prompts/evaluate.md +0 -241
  534. package/skeleton/protocols/spider/prompts/implement.md +0 -149
  535. package/skeleton/protocols/spider/templates/review.md +0 -207
  536. /package/skeleton/protocols/{spider → spir}/templates/plan.md +0 -0
  537. /package/skeleton/protocols/{spider → spir}/templates/spec.md +0 -0
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Spec 0100: Gate watcher for detecting gate transitions and sending af send notifications.
3
+ *
4
+ * Tracks which gates have been notified (dedup) and sends `af send architect`
5
+ * messages when new gates appear. Uses a dual-map design:
6
+ * - notified: Map<key, timestamp> for dedup
7
+ * - projectKeys: Map<projectPath, Set<key>> for clearing on gate resolution
8
+ */
9
+ import { execFile } from 'node:child_process';
10
+ import { resolve, dirname } from 'node:path';
11
+ import { fileURLToPath } from 'node:url';
12
+ // Strip ANSI escape sequences
13
+ const ANSI_RE = /\x1B\[[0-9;]*[A-Za-z]/g;
14
+ // Reject control characters that could be injected
15
+ const CONTROL_CHAR_RE = /[;\n\r]/;
16
+ /**
17
+ * Sanitize a string for use in af send messages.
18
+ * Returns null if the value contains unsafe control characters.
19
+ */
20
+ function sanitize(value) {
21
+ const stripped = value.replace(ANSI_RE, '').trim();
22
+ if (!stripped || CONTROL_CHAR_RE.test(stripped))
23
+ return null;
24
+ return stripped;
25
+ }
26
+ /**
27
+ * Resolve the path to the `af` CLI binary.
28
+ * Works from both source (src/) and compiled (dist/) contexts.
29
+ */
30
+ function resolveAfBinary() {
31
+ // From dist/agent-farm/utils/gate-watcher.js → bin/af.js
32
+ // From src/agent-farm/utils/gate-watcher.ts → bin/af.js
33
+ const thisDir = typeof __dirname !== 'undefined'
34
+ ? __dirname
35
+ : dirname(fileURLToPath(import.meta.url));
36
+ // thisDir = .../packages/codev/dist/agent-farm/utils or .../src/agent-farm/utils
37
+ // Navigate up to packages/codev/bin/af.js
38
+ return resolve(thisDir, '../../../bin/af.js');
39
+ }
40
+ export class GateWatcher {
41
+ /** Dedup map: key -> ISO timestamp of first notification */
42
+ notified = new Map();
43
+ /** Index: projectPath -> set of keys in `notified` */
44
+ projectKeys = new Map();
45
+ /** Logger function */
46
+ log;
47
+ /** Path to af binary */
48
+ afBinary;
49
+ constructor(log, afBinary) {
50
+ this.log = log;
51
+ this.afBinary = afBinary ?? resolveAfBinary();
52
+ }
53
+ /**
54
+ * Check gate status for a project and send notification if it's a new gate.
55
+ */
56
+ async checkAndNotify(gateStatus, projectPath) {
57
+ if (!gateStatus.hasGate) {
58
+ // Gate resolved — clear all entries for this project
59
+ this.clearProject(projectPath);
60
+ return;
61
+ }
62
+ const { builderId, gateName } = gateStatus;
63
+ if (!builderId || !gateName)
64
+ return;
65
+ const key = `${projectPath}:${builderId}:${gateName}`;
66
+ // Already notified for this exact gate
67
+ if (this.notified.has(key))
68
+ return;
69
+ // Gate changed for this project — clear old entries, add new one
70
+ this.clearProject(projectPath);
71
+ this.notified.set(key, new Date().toISOString());
72
+ const keys = new Set();
73
+ keys.add(key);
74
+ this.projectKeys.set(projectPath, keys);
75
+ // Sanitize before sending
76
+ const safeBuilderId = sanitize(builderId);
77
+ const safeGateName = sanitize(gateName);
78
+ if (!safeBuilderId || !safeGateName) {
79
+ this.log('WARN', `Gate watcher: skipping af send — unsafe gateName or builderId for project ${projectPath}`);
80
+ return;
81
+ }
82
+ const message = [
83
+ `GATE: ${safeGateName} (Builder ${safeBuilderId})`,
84
+ `Builder ${safeBuilderId} is waiting for approval.`,
85
+ `Run: porch approve ${safeBuilderId} ${safeGateName}`,
86
+ ].join('\n');
87
+ await this.sendToArchitect(message, projectPath);
88
+ }
89
+ /**
90
+ * Clear all tracked keys for a project.
91
+ */
92
+ clearProject(projectPath) {
93
+ const keys = this.projectKeys.get(projectPath);
94
+ if (keys) {
95
+ for (const k of keys) {
96
+ this.notified.delete(k);
97
+ }
98
+ this.projectKeys.delete(projectPath);
99
+ }
100
+ }
101
+ /**
102
+ * Send a message to the architect via af send.
103
+ */
104
+ sendToArchitect(message, projectPath) {
105
+ return new Promise((resolve) => {
106
+ execFile(process.execPath, [this.afBinary, 'send', 'architect', message, '--raw', '--no-enter'], { cwd: projectPath, timeout: 10_000 }, (error) => {
107
+ if (error) {
108
+ this.log('WARN', `Gate watcher: af send failed for ${projectPath}: ${error.message}`);
109
+ }
110
+ resolve();
111
+ });
112
+ });
113
+ }
114
+ /**
115
+ * Reset all state (useful for testing).
116
+ */
117
+ reset() {
118
+ this.notified.clear();
119
+ this.projectKeys.clear();
120
+ }
121
+ }
122
+ //# sourceMappingURL=gate-watcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gate-watcher.js","sourceRoot":"","sources":["../../../src/agent-farm/utils/gate-watcher.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,8BAA8B;AAC9B,MAAM,OAAO,GAAG,wBAAwB,CAAC;AAEzC,mDAAmD;AACnD,MAAM,eAAe,GAAG,SAAS,CAAC;AAElC;;;GAGG;AACH,SAAS,QAAQ,CAAC,KAAa;IAC7B,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACnD,IAAI,CAAC,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AAC;IACH,CAAC;IAED;;OAEG;IACK,eAAe,CAAC,OAAe,EAAE,WAAmB;QAC1D,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACnC,QAAQ,CACN,OAAO,CAAC,QAAQ,EAChB,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,EACpE,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,EACrC,CAAC,KAAK,EAAE,EAAE;gBACR,IAAI,KAAK,EAAE,CAAC;oBACV,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,oCAAoC,WAAW,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;gBACxF,CAAC;gBACD,OAAO,EAAE,CAAC;YACZ,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACF"}
@@ -2,5 +2,4 @@ export * from './config.js';
2
2
  export * from './deps.js';
3
3
  export * from './logger.js';
4
4
  export * from './shell.js';
5
- export * from './port-registry.js';
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent-farm/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent-farm/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
@@ -2,5 +2,4 @@ export * from './config.js';
2
2
  export * from './deps.js';
3
3
  export * from './logger.js';
4
4
  export * from './shell.js';
5
- export * from './port-registry.js';
6
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agent-farm/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agent-farm/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Push notification utilities for porch events.
3
+ * Sends notifications to the tower dashboard for real-time updates.
4
+ */
5
+ export type NotificationType = 'gate' | 'blocked' | 'error' | 'info';
6
+ interface NotificationPayload {
7
+ type: NotificationType;
8
+ projectPath: string;
9
+ projectId: string;
10
+ details: string;
11
+ }
12
+ /**
13
+ * Send a push notification to the tower dashboard.
14
+ * Notifications are delivered via SSE to connected browsers.
15
+ */
16
+ export declare function sendPushNotification(payload: NotificationPayload): Promise<void>;
17
+ /**
18
+ * Send notification when a gate is hit.
19
+ */
20
+ export declare function notifyGateHit(projectRoot: string, projectId: string, gateName: string): Promise<void>;
21
+ /**
22
+ * Send notification when builder is blocked.
23
+ */
24
+ export declare function notifyBlocked(projectRoot: string, projectId: string, reason: string): Promise<void>;
25
+ /**
26
+ * Send notification when build fails.
27
+ */
28
+ export declare function notifyError(projectRoot: string, projectId: string, error: string): Promise<void>;
29
+ export {};
30
+ //# sourceMappingURL=notifications.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../../src/agent-farm/utils/notifications.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAErE,UAAU,mBAAmB;IAC3B,IAAI,EAAE,gBAAgB,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AA+BD;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoDtF;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAOf;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAOf;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAYf"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Push notification utilities for porch events.
3
+ * Sends notifications to the tower dashboard for real-time updates.
4
+ */
5
+ import path from 'node:path';
6
+ // Default tower port
7
+ const TOWER_PORT = process.env.CODEV_TOWER_PORT || '4100';
8
+ // Track sent notifications to avoid duplicates within short window
9
+ const recentNotifications = new Map();
10
+ const DEDUPE_WINDOW_MS = 60000; // 1 minute
11
+ function isDuplicate(key) {
12
+ const lastSent = recentNotifications.get(key);
13
+ if (lastSent && Date.now() - lastSent < DEDUPE_WINDOW_MS) {
14
+ return true;
15
+ }
16
+ recentNotifications.set(key, Date.now());
17
+ return false;
18
+ }
19
+ /**
20
+ * Get canonical project path from worktree path.
21
+ * Builder worktrees are at: <project>/.builders/<id>/<branch>
22
+ * Porch runs in these worktrees but notifications need the canonical path.
23
+ */
24
+ function getCanonicalProjectPath(cwd) {
25
+ const builderMatch = cwd.match(/^(.+)\/.builders\/[^/]+$/);
26
+ if (builderMatch) {
27
+ return builderMatch[1]; // Return canonical project root
28
+ }
29
+ return cwd;
30
+ }
31
+ /**
32
+ * Send a push notification to the tower dashboard.
33
+ * Notifications are delivered via SSE to connected browsers.
34
+ */
35
+ export async function sendPushNotification(payload) {
36
+ // Dedupe by project + type + details
37
+ const dedupeKey = `${payload.projectPath}:${payload.type}:${payload.details}`;
38
+ if (isDuplicate(dedupeKey)) {
39
+ return;
40
+ }
41
+ const projectName = path.basename(payload.projectPath);
42
+ let title;
43
+ let body;
44
+ switch (payload.type) {
45
+ case 'gate':
46
+ title = `${projectName}: Gate ${payload.details}`;
47
+ body = `Project ${payload.projectId} needs approval`;
48
+ break;
49
+ case 'blocked':
50
+ title = `${projectName}: Builder Blocked`;
51
+ body = `${payload.projectId}: ${payload.details}`;
52
+ break;
53
+ case 'error':
54
+ title = `${projectName}: Build Failed`;
55
+ body = `${payload.projectId}: ${payload.details}`;
56
+ break;
57
+ case 'info':
58
+ default:
59
+ title = `${projectName}`;
60
+ body = payload.details;
61
+ break;
62
+ }
63
+ try {
64
+ const response = await fetch(`http://localhost:${TOWER_PORT}/api/notify`, {
65
+ method: 'POST',
66
+ headers: {
67
+ 'Content-Type': 'application/json',
68
+ },
69
+ body: JSON.stringify({
70
+ type: payload.type,
71
+ title,
72
+ body,
73
+ project: payload.projectPath,
74
+ }),
75
+ });
76
+ if (!response.ok) {
77
+ console.warn(`[notifications] Tower responded ${response.status} for ${payload.type} notification (project ${payload.projectId})`);
78
+ }
79
+ }
80
+ catch {
81
+ // Tower may not be running - silently ignore
82
+ }
83
+ }
84
+ /**
85
+ * Send notification when a gate is hit.
86
+ */
87
+ export async function notifyGateHit(projectRoot, projectId, gateName) {
88
+ await sendPushNotification({
89
+ type: 'gate',
90
+ projectPath: getCanonicalProjectPath(projectRoot),
91
+ projectId,
92
+ details: gateName,
93
+ });
94
+ }
95
+ /**
96
+ * Send notification when builder is blocked.
97
+ */
98
+ export async function notifyBlocked(projectRoot, projectId, reason) {
99
+ await sendPushNotification({
100
+ type: 'blocked',
101
+ projectPath: getCanonicalProjectPath(projectRoot),
102
+ projectId,
103
+ details: reason,
104
+ });
105
+ }
106
+ /**
107
+ * Send notification when build fails.
108
+ */
109
+ export async function notifyError(projectRoot, projectId, error) {
110
+ // Only send if CODEV_PUSH_ERRORS is enabled
111
+ if (process.env.CODEV_PUSH_ERRORS !== 'true') {
112
+ return;
113
+ }
114
+ await sendPushNotification({
115
+ type: 'error',
116
+ projectPath: getCanonicalProjectPath(projectRoot),
117
+ projectId,
118
+ details: error,
119
+ });
120
+ }
121
+ //# sourceMappingURL=notifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notifications.js","sourceRoot":"","sources":["../../../src/agent-farm/utils/notifications.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAW7B,qBAAqB;AACrB,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,MAAM,CAAC;AAE1D,mEAAmE;AACnE,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAkB,CAAC;AACtD,MAAM,gBAAgB,GAAG,KAAK,CAAC,CAAC,WAAW;AAE3C,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,QAAQ,GAAG,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9C,IAAI,QAAQ,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,GAAG,gBAAgB,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACzC,OAAO,KAAK,CAAC;AACf,CA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,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,MAAM,EAAE,CAAC;QAC7C,OAAO;IACT,CAAC;IAED,MAAM,oBAAoB,CAAC;QACzB,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,uBAAuB,CAAC,WAAW,CAAC;QACjD,SAAS;QACT,OAAO,EAAE,KAAK;KACf,CAAC,CAAC;AACL,CAAC"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Shared server utilities
3
- * Extracted from dashboard-server.ts, tower-server.ts, open-server.ts
3
+ * Extracted from tower-server.ts and open-server.ts
4
4
  * to eliminate code duplication (Maintenance Run 0004)
5
5
  */
6
6
  import type * as http from 'node:http';
@@ -15,10 +15,10 @@ export declare function escapeHtml(str: string): string;
15
15
  */
16
16
  export declare function parseJsonBody(req: http.IncomingMessage, maxSize?: number): Promise<Record<string, unknown>>;
17
17
  /**
18
- * Security: Validate request origin to prevent CSRF and DNS rebinding attacks
19
- * Allows only localhost and 127.0.0.1 hosts/origins
18
+ * Security: Validate request origin
19
+ * Currently allows all requests - security is handled by the server binding to localhost only.
20
20
  * @param req - HTTP incoming message
21
- * @returns true if request should be allowed
21
+ * @returns true (always allowed)
22
22
  */
23
- export declare function isRequestAllowed(req: http.IncomingMessage): boolean;
23
+ export declare function isRequestAllowed(_req: http.IncomingMessage): boolean;
24
24
  //# sourceMappingURL=server-utils.d.ts.map
@@ -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;AAEvC;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO9C;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;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,GAAG,OAAO,CAgBnE"}
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;AAEvC;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO9C;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;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,eAAe,GAAG,OAAO,CAEpE"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Shared server utilities
3
- * Extracted from dashboard-server.ts, tower-server.ts, open-server.ts
3
+ * Extracted from tower-server.ts and open-server.ts
4
4
  * to eliminate code duplication (Maintenance Run 0004)
5
5
  */
6
6
  /**
@@ -44,23 +44,12 @@ export function parseJsonBody(req, maxSize = 1024 * 1024) {
44
44
  });
45
45
  }
46
46
  /**
47
- * Security: Validate request origin to prevent CSRF and DNS rebinding attacks
48
- * Allows only localhost and 127.0.0.1 hosts/origins
47
+ * Security: Validate request origin
48
+ * Currently allows all requests - security is handled by the server binding to localhost only.
49
49
  * @param req - HTTP incoming message
50
- * @returns true if request should be allowed
50
+ * @returns true (always allowed)
51
51
  */
52
- export function isRequestAllowed(req) {
53
- const host = req.headers.host;
54
- const origin = req.headers.origin;
55
- // Host check (prevent DNS rebinding attacks)
56
- if (host && !host.startsWith('localhost') && !host.startsWith('127.0.0.1')) {
57
- return false;
58
- }
59
- // Origin check (prevent CSRF from external sites)
60
- // Note: CLI tools/curl might not send Origin, so we only block if Origin is present and invalid
61
- if (origin && !origin.startsWith('http://localhost') && !origin.startsWith('http://127.0.0.1')) {
62
- return false;
63
- }
52
+ export function isRequestAllowed(_req) {
64
53
  return true;
65
54
  }
66
55
  //# sourceMappingURL=server-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server-utils.js","sourceRoot":"","sources":["../../../src/agent-farm/utils/server-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG;SACP,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,GAAyB,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI;IAC5E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,IAAI,IAAI,GAAG,CAAC,CAAC;QAEb,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;YAC/B,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC;YACrB,IAAI,IAAI,GAAG,OAAO,EAAE,CAAC;gBACnB,MAAM,CAAC,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC;gBAC5C,GAAG,CAAC,OAAO,EAAE,CAAC;gBACd,OAAO;YACT,CAAC;YACD,IAAI,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC3B,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YACjB,IAAI,CAAC;gBACH,OAAO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Q,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,GAAyB,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI;IAC5E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,IAAI,IAAI,GAAG,CAAC,CAAC;QAEb,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;YAC/B,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC;YACrB,IAAI,IAAI,GAAG,OAAO,EAAE,CAAC;gBACnB,MAAM,CAAC,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC;gBAC5C,GAAG,CAAC,OAAO,EAAE,CAAC;gBACd,OAAO;YACT,CAAC;YACD,IAAI,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC3B,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YACjB,IAAI,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACxC,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;YACpC,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAA0B;IACzD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Shared session-naming utilities for Agent Farm.
3
+ * Centralizes session name generation to prevent drift between commands.
4
+ */
5
+ import type { Config } from '../types.js';
6
+ /**
7
+ * Get a namespaced session name for a builder: builder-{project}-{id}
8
+ */
9
+ export declare function getBuilderSessionName(config: Config, builderId: string): string;
10
+ /**
11
+ * Parsed metadata from a session name.
12
+ * Our naming convention: architect-{basename}, builder-{basename}-{specId}, shell-{basename}-{shellId}
13
+ */
14
+ export interface ParsedSession {
15
+ type: 'architect' | 'builder' | 'shell';
16
+ projectBasename: string;
17
+ roleId: string | null;
18
+ }
19
+ /**
20
+ * Parse a codev session name to extract type, project, and role.
21
+ * Returns null if the name doesn't match any known codev pattern.
22
+ *
23
+ * Examples:
24
+ * "architect-codev-public" → { type: 'architect', projectBasename: 'codev-public', roleId: null }
25
+ * "builder-codevos_ai-0001" → { type: 'builder', projectBasename: 'codevos_ai', roleId: '0001' }
26
+ * "builder-codev-public-bugfix-242" → { type: 'builder', projectBasename: 'codev-public', roleId: 'bugfix-242' }
27
+ * "builder-codev-public-task-AbCd" → { type: 'builder', projectBasename: 'codev-public', roleId: 'task-AbCd' }
28
+ * "builder-codev-public-worktree-QwEr" → { type: 'builder', projectBasename: 'codev-public', roleId: 'worktree-QwEr' }
29
+ * "shell-codev-public-shell-1" → { type: 'shell', projectBasename: 'codev-public', roleId: 'shell-1' }
30
+ */
31
+ export declare function parseSessionName(name: string): ParsedSession | null;
32
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/agent-farm/utils/session.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE/E;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;IACxC,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAsCnE"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Shared session-naming utilities for Agent Farm.
3
+ * Centralizes session name generation to prevent drift between commands.
4
+ */
5
+ import { basename } from 'node:path';
6
+ /**
7
+ * Get a namespaced session name for a builder: builder-{project}-{id}
8
+ */
9
+ export function getBuilderSessionName(config, builderId) {
10
+ return `builder-${basename(config.projectRoot)}-${builderId}`;
11
+ }
12
+ /**
13
+ * Parse a codev session name to extract type, project, and role.
14
+ * Returns null if the name doesn't match any known codev pattern.
15
+ *
16
+ * Examples:
17
+ * "architect-codev-public" → { type: 'architect', projectBasename: 'codev-public', roleId: null }
18
+ * "builder-codevos_ai-0001" → { type: 'builder', projectBasename: 'codevos_ai', roleId: '0001' }
19
+ * "builder-codev-public-bugfix-242" → { type: 'builder', projectBasename: 'codev-public', roleId: 'bugfix-242' }
20
+ * "builder-codev-public-task-AbCd" → { type: 'builder', projectBasename: 'codev-public', roleId: 'task-AbCd' }
21
+ * "builder-codev-public-worktree-QwEr" → { type: 'builder', projectBasename: 'codev-public', roleId: 'worktree-QwEr' }
22
+ * "shell-codev-public-shell-1" → { type: 'shell', projectBasename: 'codev-public', roleId: 'shell-1' }
23
+ */
24
+ export function parseSessionName(name) {
25
+ // architect-{basename}
26
+ const architectMatch = name.match(/^architect-(.+)$/);
27
+ if (architectMatch) {
28
+ return { type: 'architect', projectBasename: architectMatch[1], roleId: null };
29
+ }
30
+ // builder-{basename}-bugfix-{N} — bugfix builder (issue number)
31
+ const bugfixMatch = name.match(/^builder-(.+)-(bugfix-\d+)$/);
32
+ if (bugfixMatch) {
33
+ return { type: 'builder', projectBasename: bugfixMatch[1], roleId: bugfixMatch[2] };
34
+ }
35
+ // builder-{basename}-task-{shortId} — ad-hoc task builder (shortId is URL-safe base64: a-zA-Z0-9_-)
36
+ const taskMatch = name.match(/^builder-(.+)-(task-[a-zA-Z0-9_-]+)$/);
37
+ if (taskMatch) {
38
+ return { type: 'builder', projectBasename: taskMatch[1], roleId: taskMatch[2] };
39
+ }
40
+ // builder-{basename}-worktree-{shortId} — generic worktree builder (shortId is URL-safe base64)
41
+ const worktreeMatch = name.match(/^builder-(.+)-(worktree-[a-zA-Z0-9_-]+)$/);
42
+ if (worktreeMatch) {
43
+ return { type: 'builder', projectBasename: worktreeMatch[1], roleId: worktreeMatch[2] };
44
+ }
45
+ // builder-{basename}-{specId} — SPIR builder (spec ID is digits, any length)
46
+ const builderMatch = name.match(/^builder-(.+)-(\d+)$/);
47
+ if (builderMatch) {
48
+ return { type: 'builder', projectBasename: builderMatch[1], roleId: builderMatch[2] };
49
+ }
50
+ // shell-{basename}-{shellId} — shellId is "shell-N" (last two segments)
51
+ const shellMatch = name.match(/^shell-(.+)-(shell-\d+)$/);
52
+ if (shellMatch) {
53
+ return { type: 'shell', projectBasename: shellMatch[1], roleId: shellMatch[2] };
54
+ }
55
+ return null;
56
+ }
57
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/agent-farm/utils/session.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGrC;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAc,EAAE,SAAiB;IACrE,OAAO,WAAW,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,SAAS,EAAE,CAAC;AAChE,CAAC;AAYD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,uBAAuB;IACvB,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACtD,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,EAAE,IAAI,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EAAE,CAAC;QACf,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;IAClF,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -20,6 +20,7 @@ export declare function run(command: string, options?: {
20
20
  export declare function spawnDetached(command: string, args: string[], options?: {
21
21
  cwd?: string;
22
22
  logFile?: string;
23
+ env?: NodeJS.ProcessEnv;
23
24
  }): ChildProcess;
24
25
  /**
25
26
  * Check if a command exists
@@ -36,32 +37,18 @@ export declare function findAvailablePort(startPort: number): Promise<number>;
36
37
  */
37
38
  export declare function isProcessRunning(pid: number): Promise<boolean>;
38
39
  /**
39
- * Kill a process tree
40
+ * Kill a single process with SIGTERM → wait → SIGKILL escalation.
41
+ * Does NOT walk the process tree — safe for shellper/session processes
42
+ * where tree-kill could kill siblings across projects.
40
43
  */
41
44
  export declare function killProcess(pid: number): Promise<void>;
42
45
  /**
43
- * Open a URL in the default browser
46
+ * Kill a process tree (all children). Use for annotation servers and
47
+ * dashboard servers where children must also die.
44
48
  */
45
- export declare function openBrowser(url: string): Promise<void>;
46
- export interface TtydOptions {
47
- /** Port to run ttyd on */
48
- port: number;
49
- /** tmux session name to attach to (REQUIRED - prevents attaching to wrong session) */
50
- sessionName: string;
51
- /** Working directory */
52
- cwd?: string;
53
- /** Custom index.html path for ttyd */
54
- customIndexPath?: string;
55
- /** Bind host (default: localhost, use 0.0.0.0 for remote access) */
56
- bindHost?: string;
57
- }
49
+ export declare function killProcessTree(pid: number): Promise<void>;
58
50
  /**
59
- * Spawn ttyd attached to a specific tmux session.
60
- *
61
- * IMPORTANT: Always specify sessionName to prevent ttyd from attaching
62
- * to the wrong tmux session. This has caused cross-project issues.
63
- *
64
- * @returns The spawned child process, or null if spawn failed
51
+ * Open a URL in the default browser
65
52
  */
66
- export declare function spawnTtyd(options: TtydOptions): ChildProcess | null;
53
+ export declare function openBrowser(url: string): Promise<void>;
67
54
  //# sourceMappingURL=shell.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/agent-farm/utils/shell.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKpE,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAsB,GAAG,CACvB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC/C,OAAO,CAAC,UAAU,CAAC,CAgBrB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/C,YAAY,CA6Cd;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAYrE;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAuB1E;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOpE;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB5D;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG5D;AAED,MAAM,WAAW,WAAW;IAC1B,0BAA0B;IAC1B,IAAI,E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EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOpE;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB5D;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAehE;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG5D"}
@@ -29,10 +29,12 @@ export async function run(command, options = {}) {
29
29
  */
30
30
  export function spawnDetached(command, args, options = {}) {
31
31
  // Always capture stderr for error reporting, even when not logging
32
+ // Explicitly pass environment to ensure CODEV_WEB_KEY etc. are inherited
32
33
  const child = spawn(command, args, {
33
34
  cwd: options.cwd,
34
35
  detached: true,
35
36
  stdio: ['ignore', 'pipe', 'pipe'], // Always capture stdout/stderr
37
+ env: options.env || process.env,
36
38
  });
37
39
  // Buffer stderr for error reporting (keeps last 4KB)
38
40
  let stderrBuffer = '';
@@ -122,14 +124,44 @@ export async function isProcessRunning(pid) {
122
124
  }
123
125
  }
124
126
  /**
125
- * Kill a process tree
127
+ * Kill a single process with SIGTERM → wait → SIGKILL escalation.
128
+ * Does NOT walk the process tree — safe for shellper/session processes
129
+ * where tree-kill could kill siblings across projects.
126
130
  */
127
131
  export async function killProcess(pid) {
132
+ // Send SIGTERM
133
+ try {
134
+ process.kill(pid, 'SIGTERM');
135
+ }
136
+ catch (err) {
137
+ if (err.code === 'ESRCH')
138
+ return; // already gone
139
+ throw err;
140
+ }
141
+ // Wait up to 3s for process to exit, then escalate to SIGKILL
142
+ for (let i = 0; i < 6; i++) {
143
+ await new Promise((r) => setTimeout(r, 500));
144
+ if (!(await isProcessRunning(pid)))
145
+ return;
146
+ }
147
+ try {
148
+ process.kill(pid, 'SIGKILL');
149
+ }
150
+ catch (err) {
151
+ if (err.code === 'ESRCH')
152
+ return;
153
+ throw err;
154
+ }
155
+ }
156
+ /**
157
+ * Kill a process tree (all children). Use for annotation servers and
158
+ * dashboard servers where children must also die.
159
+ */
160
+ export async function killProcessTree(pid) {
128
161
  const treeKill = (await import('tree-kill')).default;
129
162
  return new Promise((resolve, reject) => {
130
163
  treeKill(pid, 'SIGTERM', (err) => {
131
164
  if (err) {
132
- // Try SIGKILL if SIGTERM fails
133
165
  treeKill(pid, 'SIGKILL', (err2) => {
134
166
  if (err2)
135
167
  reject(err2);
@@ -150,36 +182,4 @@ export async function openBrowser(url) {
150
182
  const open = (await import('open')).default;
151
183
  await open(url);
152
184
  }
153
- /**
154
- * Spawn ttyd attached to a specific tmux session.
155
- *
156
- * IMPORTANT: Always specify sessionName to prevent ttyd from attaching
157
- * to the wrong tmux session. This has caused cross-project issues.
158
- *
159
- * @returns The spawned child process, or null if spawn failed
160
- */
161
- export function spawnTtyd(options) {
162
- const { port, sessionName, cwd, customIndexPath, bindHost } = options;
163
- const ttydArgs = [
164
- '-W',
165
- '-p', String(port),
166
- '-t', 'theme={"background":"#000000"}',
167
- '-t', 'rightClickSelectsWord=true',
168
- ];
169
- // Add bind interface if specified (default is localhost)
170
- if (bindHost) {
171
- ttydArgs.push('-i', bindHost);
172
- }
173
- // Add custom index if provided and exists
174
- if (customIndexPath) {
175
- ttydArgs.push('-I', customIndexPath);
176
- }
177
- // CRITICAL: Always specify the session name to prevent attaching to wrong session
178
- ttydArgs.push('tmux', 'attach-session', '-t', sessionName);
179
- const child = spawnDetached('ttyd', ttydArgs, { cwd });
180
- if (!child.pid) {
181
- return null;
182
- }
183
- return child;
184
- }
185
185
  //# sourceMappingURL=shell.js.map