@agent-watch-ai/edge 0.2.5

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 (364) hide show
  1. package/CHANGELOG.md +251 -0
  2. package/LICENSE +21 -0
  3. package/README.md +168 -0
  4. package/dist/billing/billing-mode.d.ts +16 -0
  5. package/dist/billing/billing-mode.js +139 -0
  6. package/dist/billing/constants/billing.constants.d.ts +37 -0
  7. package/dist/billing/constants/billing.constants.js +38 -0
  8. package/dist/billing/index.d.ts +6 -0
  9. package/dist/billing/index.js +6 -0
  10. package/dist/cli/args.d.ts +29 -0
  11. package/dist/cli/args.js +61 -0
  12. package/dist/cli/constants/cli.constants.d.ts +60 -0
  13. package/dist/cli/constants/cli.constants.js +60 -0
  14. package/dist/cli/context.d.ts +51 -0
  15. package/dist/cli/context.js +108 -0
  16. package/dist/cli/doctor.d.ts +15 -0
  17. package/dist/cli/doctor.js +416 -0
  18. package/dist/cli/hook.d.ts +20 -0
  19. package/dist/cli/hook.js +166 -0
  20. package/dist/cli/index.d.ts +13 -0
  21. package/dist/cli/index.js +8 -0
  22. package/dist/cli/misc.d.ts +31 -0
  23. package/dist/cli/misc.js +63 -0
  24. package/dist/cli/setup.d.ts +32 -0
  25. package/dist/cli/setup.js +298 -0
  26. package/dist/cli/status.d.ts +11 -0
  27. package/dist/cli/status.js +174 -0
  28. package/dist/cli/types/cli.types.d.ts +69 -0
  29. package/dist/cli/types/cli.types.js +1 -0
  30. package/dist/cli/ui.d.ts +41 -0
  31. package/dist/cli/ui.js +78 -0
  32. package/dist/cli/uninstall.d.ts +13 -0
  33. package/dist/cli/uninstall.js +83 -0
  34. package/dist/cli.d.ts +2 -0
  35. package/dist/cli.js +124 -0
  36. package/dist/config/config-store.d.ts +29 -0
  37. package/dist/config/config-store.js +75 -0
  38. package/dist/config/config.d.ts +73 -0
  39. package/dist/config/config.js +115 -0
  40. package/dist/config/constants/config.constants.d.ts +62 -0
  41. package/dist/config/constants/config.constants.js +70 -0
  42. package/dist/config/index.d.ts +10 -0
  43. package/dist/config/index.js +5 -0
  44. package/dist/config/repo-config.d.ts +37 -0
  45. package/dist/config/repo-config.js +178 -0
  46. package/dist/config/schemas/config.schema.d.ts +409 -0
  47. package/dist/config/schemas/config.schema.js +97 -0
  48. package/dist/config/types/config.types.d.ts +33 -0
  49. package/dist/config/types/config.types.js +1 -0
  50. package/dist/core/async.d.ts +20 -0
  51. package/dist/core/async.js +32 -0
  52. package/dist/core/constants/core.constants.d.ts +18 -0
  53. package/dist/core/constants/core.constants.js +18 -0
  54. package/dist/core/env.d.ts +12 -0
  55. package/dist/core/env.js +20 -0
  56. package/dist/core/index.d.ts +13 -0
  57. package/dist/core/index.js +8 -0
  58. package/dist/core/logger.d.ts +27 -0
  59. package/dist/core/logger.js +82 -0
  60. package/dist/core/number.d.ts +33 -0
  61. package/dist/core/number.js +47 -0
  62. package/dist/core/object.d.ts +78 -0
  63. package/dist/core/object.js +127 -0
  64. package/dist/core/pipe.d.ts +55 -0
  65. package/dist/core/pipe.js +81 -0
  66. package/dist/core/types/core.types.d.ts +54 -0
  67. package/dist/core/types/core.types.js +4 -0
  68. package/dist/core/version.d.ts +19 -0
  69. package/dist/core/version.js +35 -0
  70. package/dist/core/which.d.ts +13 -0
  71. package/dist/core/which.js +57 -0
  72. package/dist/enforcement/constants/enforcement.constants.d.ts +23 -0
  73. package/dist/enforcement/constants/enforcement.constants.js +22 -0
  74. package/dist/enforcement/decision-cache.d.ts +57 -0
  75. package/dist/enforcement/decision-cache.js +138 -0
  76. package/dist/enforcement/decision-client.d.ts +14 -0
  77. package/dist/enforcement/decision-client.js +84 -0
  78. package/dist/enforcement/enforcement.d.ts +17 -0
  79. package/dist/enforcement/enforcement.js +90 -0
  80. package/dist/enforcement/index.d.ts +11 -0
  81. package/dist/enforcement/index.js +10 -0
  82. package/dist/enforcement/schemas/enforcement.schema.d.ts +30 -0
  83. package/dist/enforcement/schemas/enforcement.schema.js +36 -0
  84. package/dist/enforcement/types/enforcement.types.d.ts +59 -0
  85. package/dist/enforcement/types/enforcement.types.js +1 -0
  86. package/dist/enrollment/constants/enrollment.constants.d.ts +6 -0
  87. package/dist/enrollment/constants/enrollment.constants.js +6 -0
  88. package/dist/enrollment/enrollment-provider.d.ts +5 -0
  89. package/dist/enrollment/enrollment-provider.js +1 -0
  90. package/dist/enrollment/index.d.ts +7 -0
  91. package/dist/enrollment/index.js +1 -0
  92. package/dist/enrollment/manual-enrollment.d.ts +32 -0
  93. package/dist/enrollment/manual-enrollment.js +72 -0
  94. package/dist/enrollment/types/enrollment.types.d.ts +25 -0
  95. package/dist/enrollment/types/enrollment.types.js +1 -0
  96. package/dist/events/canonical-event.d.ts +10 -0
  97. package/dist/events/canonical-event.js +9 -0
  98. package/dist/events/constants/enrich.constants.d.ts +14 -0
  99. package/dist/events/constants/enrich.constants.js +15 -0
  100. package/dist/events/constants/events.constants.d.ts +35 -0
  101. package/dist/events/constants/events.constants.js +57 -0
  102. package/dist/events/enrich.d.ts +16 -0
  103. package/dist/events/enrich.js +226 -0
  104. package/dist/events/event-id.d.ts +32 -0
  105. package/dist/events/event-id.js +49 -0
  106. package/dist/events/index.d.ts +14 -0
  107. package/dist/events/index.js +5 -0
  108. package/dist/events/llm-call.d.ts +14 -0
  109. package/dist/events/llm-call.js +84 -0
  110. package/dist/events/product-event.d.ts +39 -0
  111. package/dist/events/product-event.js +19 -0
  112. package/dist/events/types/enrich.types.d.ts +25 -0
  113. package/dist/events/types/enrich.types.js +1 -0
  114. package/dist/events/types/events.types.d.ts +112 -0
  115. package/dist/events/types/events.types.js +1 -0
  116. package/dist/events/types/llm-call.types.d.ts +79 -0
  117. package/dist/events/types/llm-call.types.js +1 -0
  118. package/dist/events/types/repo-snapshot.types.d.ts +32 -0
  119. package/dist/events/types/repo-snapshot.types.js +1 -0
  120. package/dist/feature/constants/feature.constants.d.ts +10 -0
  121. package/dist/feature/constants/feature.constants.js +10 -0
  122. package/dist/feature/index.d.ts +6 -0
  123. package/dist/feature/index.js +6 -0
  124. package/dist/feature/ticket-candidates.d.ts +13 -0
  125. package/dist/feature/ticket-candidates.js +26 -0
  126. package/dist/git/constants/git.constants.d.ts +84 -0
  127. package/dist/git/constants/git.constants.js +113 -0
  128. package/dist/git/git-context.d.ts +52 -0
  129. package/dist/git/git-context.js +226 -0
  130. package/dist/git/index.d.ts +9 -0
  131. package/dist/git/index.js +3 -0
  132. package/dist/git/remote-sanitize.d.ts +26 -0
  133. package/dist/git/remote-sanitize.js +92 -0
  134. package/dist/git/repo-snapshot.d.ts +40 -0
  135. package/dist/git/repo-snapshot.js +95 -0
  136. package/dist/git/types/git.types.d.ts +36 -0
  137. package/dist/git/types/git.types.js +1 -0
  138. package/dist/git/types/snapshot.types.d.ts +25 -0
  139. package/dist/git/types/snapshot.types.js +1 -0
  140. package/dist/otlp/constants/otlp.constants.d.ts +84 -0
  141. package/dist/otlp/constants/otlp.constants.js +99 -0
  142. package/dist/otlp/http.d.ts +24 -0
  143. package/dist/otlp/http.js +37 -0
  144. package/dist/otlp/index.d.ts +9 -0
  145. package/dist/otlp/index.js +3 -0
  146. package/dist/otlp/normalize.d.ts +14 -0
  147. package/dist/otlp/normalize.js +404 -0
  148. package/dist/otlp/types/otlp.types.d.ts +69 -0
  149. package/dist/otlp/types/otlp.types.js +1 -0
  150. package/dist/pipeline/constants/pipeline.constants.d.ts +23 -0
  151. package/dist/pipeline/constants/pipeline.constants.js +22 -0
  152. package/dist/pipeline/hook-pipeline.d.ts +14 -0
  153. package/dist/pipeline/hook-pipeline.js +297 -0
  154. package/dist/pipeline/index.d.ts +6 -0
  155. package/dist/pipeline/index.js +1 -0
  156. package/dist/pipeline/types/pipeline.types.d.ts +48 -0
  157. package/dist/pipeline/types/pipeline.types.js +1 -0
  158. package/dist/privacy/constants/privacy.constants.d.ts +23 -0
  159. package/dist/privacy/constants/privacy.constants.js +38 -0
  160. package/dist/privacy/index.d.ts +7 -0
  161. package/dist/privacy/index.js +2 -0
  162. package/dist/privacy/sanitizer.d.ts +20 -0
  163. package/dist/privacy/sanitizer.js +52 -0
  164. package/dist/privacy/types/privacy.types.d.ts +13 -0
  165. package/dist/privacy/types/privacy.types.js +1 -0
  166. package/dist/providers/antigravity/antigravity.adapter.d.ts +54 -0
  167. package/dist/providers/antigravity/antigravity.adapter.js +311 -0
  168. package/dist/providers/antigravity/antigravity.detect.d.ts +25 -0
  169. package/dist/providers/antigravity/antigravity.detect.js +64 -0
  170. package/dist/providers/antigravity/antigravity.hooks.d.ts +24 -0
  171. package/dist/providers/antigravity/antigravity.hooks.js +126 -0
  172. package/dist/providers/antigravity/antigravity.provider.d.ts +2 -0
  173. package/dist/providers/antigravity/antigravity.provider.js +22 -0
  174. package/dist/providers/antigravity/constants/antigravity.constants.d.ts +72 -0
  175. package/dist/providers/antigravity/constants/antigravity.constants.js +75 -0
  176. package/dist/providers/antigravity/schemas/antigravity.schema.d.ts +521 -0
  177. package/dist/providers/antigravity/schemas/antigravity.schema.js +64 -0
  178. package/dist/providers/antigravity/types/antigravity.types.d.ts +13 -0
  179. package/dist/providers/antigravity/types/antigravity.types.js +1 -0
  180. package/dist/providers/claude/claude.adapter.d.ts +15 -0
  181. package/dist/providers/claude/claude.adapter.js +141 -0
  182. package/dist/providers/claude/claude.detect.d.ts +20 -0
  183. package/dist/providers/claude/claude.detect.js +57 -0
  184. package/dist/providers/claude/claude.hooks.d.ts +23 -0
  185. package/dist/providers/claude/claude.hooks.js +94 -0
  186. package/dist/providers/claude/claude.otel.d.ts +95 -0
  187. package/dist/providers/claude/claude.otel.js +331 -0
  188. package/dist/providers/claude/claude.provider.d.ts +2 -0
  189. package/dist/providers/claude/claude.provider.js +26 -0
  190. package/dist/providers/claude/constants/claude.constants.d.ts +34 -0
  191. package/dist/providers/claude/constants/claude.constants.js +54 -0
  192. package/dist/providers/claude/constants/claude.otel.constants.d.ts +17 -0
  193. package/dist/providers/claude/constants/claude.otel.constants.js +17 -0
  194. package/dist/providers/claude/schemas/claude.schema.d.ts +72 -0
  195. package/dist/providers/claude/schemas/claude.schema.js +32 -0
  196. package/dist/providers/claude/types/claude.types.d.ts +3 -0
  197. package/dist/providers/claude/types/claude.types.js +1 -0
  198. package/dist/providers/codex/codex.adapter.d.ts +11 -0
  199. package/dist/providers/codex/codex.adapter.js +106 -0
  200. package/dist/providers/codex/codex.detect.d.ts +30 -0
  201. package/dist/providers/codex/codex.detect.js +58 -0
  202. package/dist/providers/codex/codex.hooks.d.ts +27 -0
  203. package/dist/providers/codex/codex.hooks.js +129 -0
  204. package/dist/providers/codex/codex.otel.d.ts +51 -0
  205. package/dist/providers/codex/codex.otel.js +325 -0
  206. package/dist/providers/codex/codex.provider.d.ts +2 -0
  207. package/dist/providers/codex/codex.provider.js +25 -0
  208. package/dist/providers/codex/constants/codex.constants.d.ts +41 -0
  209. package/dist/providers/codex/constants/codex.constants.js +62 -0
  210. package/dist/providers/codex/constants/codex.otel.constants.d.ts +22 -0
  211. package/dist/providers/codex/constants/codex.otel.constants.js +22 -0
  212. package/dist/providers/codex/schemas/codex.schema.d.ts +70 -0
  213. package/dist/providers/codex/schemas/codex.schema.js +32 -0
  214. package/dist/providers/codex/types/codex.types.d.ts +3 -0
  215. package/dist/providers/codex/types/codex.types.js +1 -0
  216. package/dist/providers/constants/provider.constants.d.ts +33 -0
  217. package/dist/providers/constants/provider.constants.js +33 -0
  218. package/dist/providers/cursor/constants/cursor.constants.d.ts +58 -0
  219. package/dist/providers/cursor/constants/cursor.constants.js +95 -0
  220. package/dist/providers/cursor/cursor.adapter.d.ts +11 -0
  221. package/dist/providers/cursor/cursor.adapter.js +331 -0
  222. package/dist/providers/cursor/cursor.detect.d.ts +23 -0
  223. package/dist/providers/cursor/cursor.detect.js +66 -0
  224. package/dist/providers/cursor/cursor.hooks.d.ts +25 -0
  225. package/dist/providers/cursor/cursor.hooks.js +95 -0
  226. package/dist/providers/cursor/cursor.provider.d.ts +2 -0
  227. package/dist/providers/cursor/cursor.provider.js +27 -0
  228. package/dist/providers/cursor/schemas/cursor.schema.d.ts +130 -0
  229. package/dist/providers/cursor/schemas/cursor.schema.js +62 -0
  230. package/dist/providers/cursor/types/cursor.types.d.ts +3 -0
  231. package/dist/providers/cursor/types/cursor.types.js +1 -0
  232. package/dist/providers/gemini/constants/gemini.constants.d.ts +36 -0
  233. package/dist/providers/gemini/constants/gemini.constants.js +58 -0
  234. package/dist/providers/gemini/constants/gemini.otel.constants.d.ts +34 -0
  235. package/dist/providers/gemini/constants/gemini.otel.constants.js +48 -0
  236. package/dist/providers/gemini/gemini.adapter.d.ts +15 -0
  237. package/dist/providers/gemini/gemini.adapter.js +146 -0
  238. package/dist/providers/gemini/gemini.detect.d.ts +23 -0
  239. package/dist/providers/gemini/gemini.detect.js +78 -0
  240. package/dist/providers/gemini/gemini.hooks.d.ts +22 -0
  241. package/dist/providers/gemini/gemini.hooks.js +93 -0
  242. package/dist/providers/gemini/gemini.otel.d.ts +62 -0
  243. package/dist/providers/gemini/gemini.otel.js +274 -0
  244. package/dist/providers/gemini/gemini.provider.d.ts +2 -0
  245. package/dist/providers/gemini/gemini.provider.js +22 -0
  246. package/dist/providers/gemini/schemas/gemini.schema.d.ts +81 -0
  247. package/dist/providers/gemini/schemas/gemini.schema.js +35 -0
  248. package/dist/providers/gemini/types/gemini.types.d.ts +3 -0
  249. package/dist/providers/gemini/types/gemini.types.js +1 -0
  250. package/dist/providers/index.d.ts +14 -0
  251. package/dist/providers/index.js +8 -0
  252. package/dist/providers/provider.d.ts +16 -0
  253. package/dist/providers/provider.js +149 -0
  254. package/dist/providers/registry.d.ts +12 -0
  255. package/dist/providers/registry.js +23 -0
  256. package/dist/providers/shared/constants/hook-refusal.constants.d.ts +6 -0
  257. package/dist/providers/shared/constants/hook-refusal.constants.js +6 -0
  258. package/dist/providers/shared/constants/tooling.constants.d.ts +25 -0
  259. package/dist/providers/shared/constants/tooling.constants.js +25 -0
  260. package/dist/providers/shared/event-builder.d.ts +85 -0
  261. package/dist/providers/shared/event-builder.js +166 -0
  262. package/dist/providers/shared/hook-config.d.ts +80 -0
  263. package/dist/providers/shared/hook-config.js +164 -0
  264. package/dist/providers/shared/hook-refusal.d.ts +16 -0
  265. package/dist/providers/shared/hook-refusal.js +33 -0
  266. package/dist/providers/shared/install-record.d.ts +75 -0
  267. package/dist/providers/shared/install-record.js +113 -0
  268. package/dist/providers/shared/tooling.d.ts +58 -0
  269. package/dist/providers/shared/tooling.js +103 -0
  270. package/dist/providers/shared/types/adapter.types.d.ts +54 -0
  271. package/dist/providers/shared/types/adapter.types.js +1 -0
  272. package/dist/providers/shared/types/hook-config.types.d.ts +32 -0
  273. package/dist/providers/shared/types/hook-config.types.js +1 -0
  274. package/dist/providers/types/provider.types.d.ts +98 -0
  275. package/dist/providers/types/provider.types.js +1 -0
  276. package/dist/snapshot/branch-selection.d.ts +37 -0
  277. package/dist/snapshot/branch-selection.js +69 -0
  278. package/dist/snapshot/budget.d.ts +41 -0
  279. package/dist/snapshot/budget.js +67 -0
  280. package/dist/snapshot/constants/snapshot-stages.constants.d.ts +11 -0
  281. package/dist/snapshot/constants/snapshot-stages.constants.js +11 -0
  282. package/dist/snapshot/constants/snapshot.constants.d.ts +56 -0
  283. package/dist/snapshot/constants/snapshot.constants.js +56 -0
  284. package/dist/snapshot/index.d.ts +16 -0
  285. package/dist/snapshot/index.js +6 -0
  286. package/dist/snapshot/snapshot-event.d.ts +17 -0
  287. package/dist/snapshot/snapshot-event.js +66 -0
  288. package/dist/snapshot/snapshot-pipeline.d.ts +14 -0
  289. package/dist/snapshot/snapshot-pipeline.js +163 -0
  290. package/dist/snapshot/snapshot-state.d.ts +55 -0
  291. package/dist/snapshot/snapshot-state.js +100 -0
  292. package/dist/snapshot/types/snapshot.types.d.ts +86 -0
  293. package/dist/snapshot/types/snapshot.types.js +1 -0
  294. package/dist/storage/atomic-file.d.ts +25 -0
  295. package/dist/storage/atomic-file.js +76 -0
  296. package/dist/storage/constants/storage.constants.d.ts +34 -0
  297. package/dist/storage/constants/storage.constants.js +35 -0
  298. package/dist/storage/index.d.ts +10 -0
  299. package/dist/storage/index.js +5 -0
  300. package/dist/storage/install-state.d.ts +20 -0
  301. package/dist/storage/install-state.js +40 -0
  302. package/dist/storage/json-file.d.ts +13 -0
  303. package/dist/storage/json-file.js +31 -0
  304. package/dist/storage/lock.d.ts +15 -0
  305. package/dist/storage/lock.js +70 -0
  306. package/dist/storage/paths.d.ts +14 -0
  307. package/dist/storage/paths.js +42 -0
  308. package/dist/storage/schemas/storage.schema.d.ts +128 -0
  309. package/dist/storage/schemas/storage.schema.js +27 -0
  310. package/dist/storage/types/storage.types.d.ts +36 -0
  311. package/dist/storage/types/storage.types.js +1 -0
  312. package/dist/transport/constants/transport.constants.d.ts +47 -0
  313. package/dist/transport/constants/transport.constants.js +47 -0
  314. package/dist/transport/cooldown.d.ts +35 -0
  315. package/dist/transport/cooldown.js +62 -0
  316. package/dist/transport/delivery-stats.d.ts +65 -0
  317. package/dist/transport/delivery-stats.js +186 -0
  318. package/dist/transport/delivery.d.ts +26 -0
  319. package/dist/transport/delivery.js +80 -0
  320. package/dist/transport/headers.d.ts +12 -0
  321. package/dist/transport/headers.js +19 -0
  322. package/dist/transport/http-transport.d.ts +39 -0
  323. package/dist/transport/http-transport.js +106 -0
  324. package/dist/transport/index.d.ts +13 -0
  325. package/dist/transport/index.js +7 -0
  326. package/dist/transport/queue.d.ts +177 -0
  327. package/dist/transport/queue.js +474 -0
  328. package/dist/transport/schemas/queue.schema.d.ts +30 -0
  329. package/dist/transport/schemas/queue.schema.js +18 -0
  330. package/dist/transport/transport.d.ts +6 -0
  331. package/dist/transport/transport.js +1 -0
  332. package/dist/transport/types/transport.types.d.ts +102 -0
  333. package/dist/transport/types/transport.types.js +1 -0
  334. package/dist/turns/aggregate-usage.d.ts +20 -0
  335. package/dist/turns/aggregate-usage.js +269 -0
  336. package/dist/turns/claude-transcript.d.ts +18 -0
  337. package/dist/turns/claude-transcript.js +80 -0
  338. package/dist/turns/constants/turns.constants.d.ts +69 -0
  339. package/dist/turns/constants/turns.constants.js +86 -0
  340. package/dist/turns/cursor-transcript.d.ts +21 -0
  341. package/dist/turns/cursor-transcript.js +66 -0
  342. package/dist/turns/index.d.ts +17 -0
  343. package/dist/turns/index.js +7 -0
  344. package/dist/turns/transcript.d.ts +74 -0
  345. package/dist/turns/transcript.js +188 -0
  346. package/dist/turns/turn-state.d.ts +94 -0
  347. package/dist/turns/turn-state.js +234 -0
  348. package/dist/turns/turn-summary.d.ts +27 -0
  349. package/dist/turns/turn-summary.js +164 -0
  350. package/dist/turns/turn-tracker.d.ts +14 -0
  351. package/dist/turns/turn-tracker.js +521 -0
  352. package/dist/turns/types/aggregate-usage.types.d.ts +26 -0
  353. package/dist/turns/types/aggregate-usage.types.js +1 -0
  354. package/dist/turns/types/transcript.types.d.ts +41 -0
  355. package/dist/turns/types/transcript.types.js +1 -0
  356. package/dist/turns/types/turn-state.types.d.ts +37 -0
  357. package/dist/turns/types/turn-state.types.js +1 -0
  358. package/dist/turns/types/turn-summary.types.d.ts +106 -0
  359. package/dist/turns/types/turn-summary.types.js +1 -0
  360. package/dist/turns/types/turn-tracker.types.d.ts +27 -0
  361. package/dist/turns/types/turn-tracker.types.js +1 -0
  362. package/example/README.md +43 -0
  363. package/example/server.mjs +240 -0
  364. package/package.json +89 -0
@@ -0,0 +1,416 @@
1
+ import { execFile } from 'node:child_process';
2
+ import fs from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import process from 'node:process';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { eventsUrl, otlpBaseUrl } from '../config/config.js';
7
+ import { loadEffectiveConfig } from '../config/repo-config.js';
8
+ import { CONTENT_CAPTURE_FLAGS } from '../config/constants/config.constants.js';
9
+ import { meetsMinVersion, parseVersion } from '../core/version.js';
10
+ import { findExecutable } from '../core/which.js';
11
+ import { developerIdentity } from '../git/git-context.js';
12
+ import { providers } from '../providers/registry.js';
13
+ import { buildCliContext, buildHookCommand, buildQueue } from './context.js';
14
+ import { BACKEND_PROBE_TIMEOUT_MS, CLAUDE_MIN_VERSION_FOR_PROMPT_ID, CLAUDE_VERSION_TIMEOUT_MS, DEVELOPER_IDENTITY_CHECK, DEVELOPER_IDENTITY_REMEDIES, GIT_VERSION_TIMEOUT_MS, MIN_NODE_MAJOR, NO_DEVELOPER_IDENTITY, STALE_QUEUE_AGE_MS } from './constants/cli.constants.js';
15
+ import { bold, dim, levelSymbol, println } from './ui.js';
16
+ /**
17
+ * `agentwatch doctor` — every reason telemetry might not be arriving, in one
18
+ * pass.
19
+ *
20
+ * Each check is independent and self-contained, which is what makes the output
21
+ * useful: a developer reads down the list and the first non-ok line is the thing
22
+ * to fix.
23
+ *
24
+ * @param env - Ambient environment.
25
+ * @param options - Output options and the git runner override.
26
+ * @returns 1 when any check failed, else 0.
27
+ */
28
+ export async function runDoctor(env, options = {}) {
29
+ const context = await buildCliContext(env);
30
+ const checks = [
31
+ nodeVersionCheck(),
32
+ configurationCheck(context),
33
+ ...endpointChecks(context),
34
+ await developerIdentityCheck(env, context, options),
35
+ ...(await connectivityChecks(context)),
36
+ await gitCheck(),
37
+ await buildFreshnessCheck(),
38
+ ...(await agentChecks(env, context)),
39
+ ...(await queueChecks(context)),
40
+ await writableCheck('data directory writable', context.paths.dataDir),
41
+ await writableCheck('config directory writable', context.paths.configDir),
42
+ ...(await repositoryChecks(env, context))
43
+ ];
44
+ if (options.json) {
45
+ println(JSON.stringify({ schemaVersion: 1, checks }, null, 2));
46
+ return exitCode(checks);
47
+ }
48
+ println(bold('AgentWatch Doctor'));
49
+ println();
50
+ for (const check of checks) {
51
+ println(`${levelSymbol(check.level)} ${check.name}${check.detail ? dim(` — ${check.detail}`) : ''}`);
52
+ }
53
+ println();
54
+ return exitCode(checks);
55
+ }
56
+ /**
57
+ * Whether the runtime is new enough.
58
+ *
59
+ * @returns The check.
60
+ */
61
+ function nodeVersionCheck() {
62
+ const major = Number(process.versions.node.split('.')[0]);
63
+ return {
64
+ name: 'Node.js version',
65
+ level: major >= MIN_NODE_MAJOR ? 'ok' : 'fail',
66
+ detail: `v${process.versions.node}${major >= MIN_NODE_MAJOR ? '' : ` (need >= ${MIN_NODE_MAJOR})`}`
67
+ };
68
+ }
69
+ /**
70
+ * Whether the configuration file is present and readable.
71
+ *
72
+ * @param context - Resolved CLI context.
73
+ * @returns The check.
74
+ */
75
+ function configurationCheck(context) {
76
+ if (context.configState === 'ok')
77
+ return { name: 'configuration', level: 'ok', detail: context.paths.configFile };
78
+ if (context.configState === 'missing')
79
+ return { name: 'configuration', level: 'warn', detail: 'not found — run `agentwatch setup`' };
80
+ return { name: 'configuration', level: 'fail', detail: context.configError };
81
+ }
82
+ /**
83
+ * Whether a backend and a token are configured. Never reveals the token.
84
+ *
85
+ * @param context - Resolved CLI context.
86
+ * @returns The checks.
87
+ */
88
+ function endpointChecks(context) {
89
+ return [
90
+ { name: 'backend endpoint', level: context.config.endpoint ? 'ok' : 'warn', detail: context.config.endpoint ?? 'not configured' },
91
+ { name: 'auth token', level: 'ok', detail: context.config.token ? 'present (hidden)' : 'none configured' }
92
+ ];
93
+ }
94
+ /**
95
+ * Whether anything on this machine can name the developer.
96
+ *
97
+ * `fail`, not `warn`: per-developer enforcement is keyed on this identity, and
98
+ * an unknown one is allowed silently — so a machine that cannot name its
99
+ * developer is a machine that reports healthy while enforcing nothing. A
100
+ * scripted rollout has to be able to fail it instead of shipping it.
101
+ *
102
+ * @param env - Ambient environment.
103
+ * @param context - Resolved CLI context.
104
+ * @param options - Carries the git runner override.
105
+ * @returns The check.
106
+ */
107
+ async function developerIdentityCheck(env, context, options) {
108
+ const identity = await developerIdentity(context.config.developerEmail, env.cwd, { home: env.home, run: options.gitRun });
109
+ if (!identity)
110
+ return { name: DEVELOPER_IDENTITY_CHECK, level: 'fail', detail: `${NO_DEVELOPER_IDENTITY}; ${DEVELOPER_IDENTITY_REMEDIES}` };
111
+ return { name: DEVELOPER_IDENTITY_CHECK, level: 'ok', detail: identity };
112
+ }
113
+ /**
114
+ * Whether the backend answers at all, and where OTLP would go.
115
+ *
116
+ * Any HTTP answer proves reachability: the check is about the network path, not
117
+ * about whether an empty batch is accepted.
118
+ *
119
+ * @param context - Resolved CLI context.
120
+ * @returns The checks.
121
+ */
122
+ async function connectivityChecks(context) {
123
+ const checks = [];
124
+ const url = eventsUrl(context.config);
125
+ if (url)
126
+ checks.push(await probeBackend(url));
127
+ const otlp = otlpBaseUrl(context.config);
128
+ if (otlp)
129
+ checks.push({ name: 'OTLP base URL', level: 'ok', detail: otlp });
130
+ return checks;
131
+ }
132
+ /**
133
+ * Post an empty batch and report what came back.
134
+ *
135
+ * @param url - The events URL.
136
+ * @returns The check.
137
+ */
138
+ async function probeBackend(url) {
139
+ try {
140
+ const response = await fetch(url, {
141
+ method: 'POST',
142
+ headers: { 'content-type': 'application/json' },
143
+ body: JSON.stringify({ events: [] }),
144
+ signal: AbortSignal.timeout(BACKEND_PROBE_TIMEOUT_MS)
145
+ });
146
+ return { name: 'backend connectivity', level: response.ok ? 'ok' : 'warn', detail: `${url} -> HTTP ${response.status}` };
147
+ }
148
+ catch (error) {
149
+ return { name: 'backend connectivity', level: 'fail', detail: `${url} unreachable (${error.name})` };
150
+ }
151
+ }
152
+ /**
153
+ * Whether git is available for enrichment.
154
+ *
155
+ * @returns The check.
156
+ */
157
+ async function gitCheck() {
158
+ const version = await execVersion('git', ['--version'], GIT_VERSION_TIMEOUT_MS);
159
+ return { name: 'git available', level: version ? 'ok' : 'warn', detail: version?.trim() ?? 'git not found on PATH' };
160
+ }
161
+ /**
162
+ * Per-agent checks: detected, hooked, and exporting telemetry.
163
+ *
164
+ * @param env - Ambient environment.
165
+ * @param context - Resolved CLI context.
166
+ * @returns The checks, in provider order.
167
+ */
168
+ async function agentChecks(env, context) {
169
+ const checks = [];
170
+ for (const provider of providers) {
171
+ const detection = await provider.detect(env);
172
+ if (!detection.detected) {
173
+ checks.push({ name: provider.displayName, level: 'warn', detail: 'not detected' });
174
+ continue;
175
+ }
176
+ checks.push({ name: `${provider.displayName} detected`, level: 'ok', detail: detection.evidence.join('; ') });
177
+ checks.push(...(await providerCaveats(provider, env)));
178
+ checks.push({
179
+ name: `${provider.displayName} hooks`,
180
+ level: detection.hooksInstalled ? 'ok' : 'warn',
181
+ detail: detection.hooksInstalled ? detection.hookConfigPath : 'not installed — run `agentwatch setup`'
182
+ });
183
+ if (provider.nativeTelemetry)
184
+ checks.push(await otelCheck(provider, env, context));
185
+ }
186
+ return checks;
187
+ }
188
+ /**
189
+ * Known limitations of one agent, reported as warnings.
190
+ *
191
+ * These are not misconfigurations the developer can fix; they exist so an
192
+ * absent number is explained rather than mistaken for a bug in the edge.
193
+ *
194
+ * @param provider - The agent's provider.
195
+ * @param env - Ambient environment.
196
+ * @returns The checks, empty for agents with no caveats.
197
+ */
198
+ async function providerCaveats(provider, env) {
199
+ if (provider.id === 'claude')
200
+ return [await claudeVersionCheck(env)];
201
+ if (provider.id !== 'cursor')
202
+ return [];
203
+ return [
204
+ {
205
+ name: 'Cursor token usage',
206
+ level: 'warn',
207
+ detail: 'Cursor transcripts carry no token usage yet — Cursor turn summaries stay usage_status=pending until Cursor enriches them'
208
+ },
209
+ {
210
+ name: 'Cursor CLI hooks',
211
+ level: 'warn',
212
+ detail: 'cursor-agent (CLI) currently emits only shell hook events (known Cursor issue); IDE sessions are fully covered'
213
+ }
214
+ ];
215
+ }
216
+ /**
217
+ * Whether Claude Code is new enough for prompt-id turn correlation.
218
+ *
219
+ * @param env - Ambient environment.
220
+ * @returns The check.
221
+ */
222
+ async function claudeVersionCheck(env) {
223
+ const name = 'Claude Code version';
224
+ const bin = findExecutable(env, 'claude');
225
+ if (!bin) {
226
+ return { name, level: 'warn', detail: `claude not on PATH; cannot verify >= ${CLAUDE_MIN_VERSION_FOR_PROMPT_ID} (needed for turn correlation)` };
227
+ }
228
+ const output = await execVersion(bin, ['--version'], CLAUDE_VERSION_TIMEOUT_MS);
229
+ const version = output ? parseVersion(output) : undefined;
230
+ if (!version) {
231
+ return { name, level: 'warn', detail: `could not determine version (need >= ${CLAUDE_MIN_VERSION_FOR_PROMPT_ID} for turn correlation)` };
232
+ }
233
+ if (meetsMinVersion(version, CLAUDE_MIN_VERSION_FOR_PROMPT_ID))
234
+ return { name, level: 'ok', detail: version };
235
+ return {
236
+ name,
237
+ level: 'warn',
238
+ detail: `${version} — prompt_id turn correlation needs >= ${CLAUDE_MIN_VERSION_FOR_PROMPT_ID}; turn_id will be empty`
239
+ };
240
+ }
241
+ /**
242
+ * Whether one agent's native telemetry is configured.
243
+ *
244
+ * This one is `fail` rather than `warn`: without it there is no llm.call ledger
245
+ * at all, so every turn's cost would be missing.
246
+ *
247
+ * @param provider - The agent's provider.
248
+ * @param env - Ambient environment.
249
+ * @param context - Resolved CLI context.
250
+ * @returns The check.
251
+ */
252
+ async function otelCheck(provider, env, context) {
253
+ const setupContext = {
254
+ env,
255
+ paths: context.paths,
256
+ config: context.config,
257
+ hookCommand: buildHookCommand(env, provider.id),
258
+ installState: context.installState
259
+ };
260
+ const status = await provider.nativeTelemetry.inspect(setupContext);
261
+ return {
262
+ name: `${provider.displayName} native OpenTelemetry`,
263
+ level: status.configured ? 'ok' : 'fail',
264
+ detail: status.configured
265
+ ? (status.detail ?? 'configured (llm.call ledger enabled)')
266
+ : (status.conflict ?? status.detail ?? 'not configured — llm.call records would be lost')
267
+ };
268
+ }
269
+ /**
270
+ * Whether the offline queue is healthy.
271
+ *
272
+ * @param context - Resolved CLI context.
273
+ * @returns The check.
274
+ */
275
+ async function queueChecks(context) {
276
+ const queue = buildQueue(context);
277
+ const pending = await queue.pendingCount();
278
+ const oldest = await queue.oldestPendingAgeMs();
279
+ const stale = pending > 0 && oldest !== undefined && oldest > STALE_QUEUE_AGE_MS;
280
+ return [
281
+ {
282
+ name: 'delivery queue',
283
+ level: stale ? 'warn' : 'ok',
284
+ detail: `${pending} pending${oldest !== undefined ? `, oldest ${Math.round(oldest / 60000)} min` : ''}`
285
+ }
286
+ ];
287
+ }
288
+ /**
289
+ * Repository overrides for this directory, and the resulting privacy posture.
290
+ *
291
+ * The posture is reported from the EFFECTIVE config so it matches what hooks
292
+ * actually do here, not what the global file says.
293
+ *
294
+ * @param env - Ambient environment.
295
+ * @param context - Resolved CLI context.
296
+ * @returns The checks.
297
+ */
298
+ async function repositoryChecks(env, context) {
299
+ const checks = [];
300
+ let capture = context.config.capture;
301
+ try {
302
+ const effective = await loadEffectiveConfig(context.paths, env.cwd);
303
+ capture = effective.config.capture;
304
+ if (effective.repoConfigFile) {
305
+ checks.push({
306
+ name: 'repo config',
307
+ level: effective.warnings.length > 0 ? 'warn' : 'ok',
308
+ detail: effective.warnings.length > 0 ? `${effective.repoConfigFile}: ${effective.warnings.join('; ')}` : effective.repoConfigFile
309
+ });
310
+ }
311
+ }
312
+ catch {
313
+ // Repo overrides are best-effort; their absence is not a finding.
314
+ }
315
+ const enabled = CONTENT_CAPTURE_FLAGS.filter((flag) => capture[flag]);
316
+ checks.push({
317
+ name: 'privacy',
318
+ level: 'ok',
319
+ detail: enabled.length === 0
320
+ ? 'content capture disabled (metadata only)'
321
+ : `content capture ENABLED for: ${enabled.join(', ')} (effective for this directory)`
322
+ });
323
+ return checks;
324
+ }
325
+ /**
326
+ * Whether a directory can actually be written to.
327
+ *
328
+ * @param name - Check name.
329
+ * @param dir - Directory to probe.
330
+ * @returns The check.
331
+ */
332
+ async function writableCheck(name, dir) {
333
+ try {
334
+ await fs.mkdir(dir, { recursive: true });
335
+ const probe = path.join(dir, `.probe-${process.pid}`);
336
+ await fs.writeFile(probe, 'ok');
337
+ await fs.rm(probe, { force: true });
338
+ return { name, level: 'ok', detail: dir };
339
+ }
340
+ catch (error) {
341
+ return { name, level: 'fail', detail: `${dir}: ${error.message}` };
342
+ }
343
+ }
344
+ /**
345
+ * Whether the running build matches the sources beside it.
346
+ *
347
+ * Only meaningful for a checkout linked with `npm link` or run from `dist`
348
+ * directly — a published install has no `src` and is skipped. It exists because
349
+ * a stale `dist` is invisible from the outside and looks exactly like a broken
350
+ * agent: a provider added to the registry but never rebuilt made every hook
351
+ * answer `unknown agent`, for days, while the agent dutifully called it on every
352
+ * tool use.
353
+ *
354
+ * @returns The check.
355
+ */
356
+ async function buildFreshnessCheck() {
357
+ const name = 'build up to date';
358
+ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
359
+ const [srcTime, distTime] = await Promise.all([newestMtime(path.join(root, 'src')), newestMtime(path.join(root, 'dist'))]);
360
+ if (srcTime === undefined || distTime === undefined) {
361
+ return { name, level: 'ok', detail: 'published install (no sources to compare)' };
362
+ }
363
+ if (srcTime <= distTime)
364
+ return { name, level: 'ok', detail: 'dist is newer than src' };
365
+ return { name, level: 'warn', detail: 'src is newer than dist — run `npm run build`; the installed CLI is running stale code' };
366
+ }
367
+ /**
368
+ * Newest mtime anywhere under a directory.
369
+ *
370
+ * @param dir - Directory to walk.
371
+ * @returns Epoch milliseconds, or undefined when the directory does not exist.
372
+ */
373
+ async function newestMtime(dir) {
374
+ let newest;
375
+ const walk = async (current) => {
376
+ for (const entry of await fs.readdir(current, { withFileTypes: true })) {
377
+ const full = path.join(current, entry.name);
378
+ if (entry.isDirectory()) {
379
+ await walk(full);
380
+ continue;
381
+ }
382
+ const stat = await fs.stat(full);
383
+ if (newest === undefined || stat.mtimeMs > newest)
384
+ newest = stat.mtimeMs;
385
+ }
386
+ };
387
+ try {
388
+ await walk(dir);
389
+ }
390
+ catch {
391
+ return undefined;
392
+ }
393
+ return newest;
394
+ }
395
+ /**
396
+ * Run a `--version`-style command, treating any failure as no answer.
397
+ *
398
+ * @param command - Executable.
399
+ * @param args - Its arguments.
400
+ * @param timeoutMs - Kill budget.
401
+ * @returns Its stdout, or undefined.
402
+ */
403
+ function execVersion(command, args, timeoutMs) {
404
+ return new Promise((resolve) => {
405
+ execFile(command, [...args], { timeout: timeoutMs }, (error, stdout) => resolve(error ? undefined : stdout));
406
+ });
407
+ }
408
+ /**
409
+ * The process exit code for a set of checks.
410
+ *
411
+ * @param checks - Everything that was checked.
412
+ * @returns 1 when anything failed, else 0.
413
+ */
414
+ function exitCode(checks) {
415
+ return checks.some((check) => check.level === 'fail') ? 1 : 0;
416
+ }
@@ -0,0 +1,20 @@
1
+ import type { HookRunOptions } from './types/cli.types.js';
2
+ export type { HookRunOptions } from './types/cli.types.js';
3
+ /**
4
+ * The `hook` command: read stdin, run the flow, answer the agent.
5
+ *
6
+ * This runs inside the coding agent's critical path, and it must NEVER fail the
7
+ * agent. Every failure — an unknown agent, an unreadable payload, a broken
8
+ * config, a stage that throws — degrades to the provider's safe response with
9
+ * exit code 0. Telemetry is worth strictly less than the developer's session.
10
+ *
11
+ * The one answer that is not passive comes from the flow: when the platform
12
+ * explicitly refused this developer's turn, the provider's own refusal is
13
+ * written instead of silence. It is still exit code 0 — a refusal the agent
14
+ * understands, not a hook that failed.
15
+ *
16
+ * @param agentId - Value of `--agent`.
17
+ * @param options - Environment, injected stdin, dry-run flag, stdout sink.
18
+ * @returns The process exit code; always one the agent tolerates.
19
+ */
20
+ export declare function runHook(agentId: string, options: HookRunOptions): Promise<number>;
@@ -0,0 +1,166 @@
1
+ import process from 'node:process';
2
+ import { loadConfig } from '../config/config-store.js';
3
+ import { debugLog, warnLog } from '../core/logger.js';
4
+ import { runHookPipeline } from '../pipeline/hook-pipeline.js';
5
+ import { getProvider } from '../providers/registry.js';
6
+ import { resolvePaths } from '../storage/paths.js';
7
+ import { MAX_STDIN_BYTES, STDIN_TIMEOUT_MS } from './constants/cli.constants.js';
8
+ /**
9
+ * The `hook` command: read stdin, run the flow, answer the agent.
10
+ *
11
+ * This runs inside the coding agent's critical path, and it must NEVER fail the
12
+ * agent. Every failure — an unknown agent, an unreadable payload, a broken
13
+ * config, a stage that throws — degrades to the provider's safe response with
14
+ * exit code 0. Telemetry is worth strictly less than the developer's session.
15
+ *
16
+ * The one answer that is not passive comes from the flow: when the platform
17
+ * explicitly refused this developer's turn, the provider's own refusal is
18
+ * written instead of silence. It is still exit code 0 — a refusal the agent
19
+ * understands, not a hook that failed.
20
+ *
21
+ * @param agentId - Value of `--agent`.
22
+ * @param options - Environment, injected stdin, dry-run flag, stdout sink.
23
+ * @returns The process exit code; always one the agent tolerates.
24
+ */
25
+ export async function runHook(agentId, options) {
26
+ const provider = getProvider(agentId);
27
+ if (!provider) {
28
+ warnLog(`unknown agent "${agentId}"; passing through`);
29
+ return 0;
30
+ }
31
+ const payload = await readPayload(options);
32
+ try {
33
+ const result = payload === undefined ? undefined : await processPayload(provider, payload, options);
34
+ const response = respondToDecision(provider, payload, result);
35
+ if (response.stdout)
36
+ writeStdout(options, response.stdout);
37
+ return response.exitCode;
38
+ }
39
+ catch (error) {
40
+ // Telemetry must never break the coding agent.
41
+ debugLog('hook processing failed:', error);
42
+ return 0;
43
+ }
44
+ }
45
+ /**
46
+ * What to answer the agent with.
47
+ *
48
+ * The provider's passive response unless the flow came back carrying a refusal
49
+ * *and* the provider knows how to express one for this hook. A provider that
50
+ * returns nothing is not overridden into silence-plus-block: no refusal is sent
51
+ * on a protocol whose contract for it is unverified.
52
+ *
53
+ * @param provider - The agent's provider.
54
+ * @param payload - Decoded hook payload.
55
+ * @param result - Final flow state, when the payload was processed.
56
+ * @returns The response to write.
57
+ */
58
+ function respondToDecision(provider, payload, result) {
59
+ const message = result?.blockMessage;
60
+ if (message === undefined)
61
+ return provider.getHookResponse(payload);
62
+ const refusal = provider.getBlockResponse?.(payload, message);
63
+ if (!refusal)
64
+ return provider.getHookResponse(payload);
65
+ // The agent shows `message` through its own protocol, but a prompt that
66
+ // vanishes with its explanation buried in a transcript view is a support
67
+ // ticket: say it on stderr too.
68
+ warnLog(message);
69
+ return refusal;
70
+ }
71
+ /**
72
+ * Run one payload through the hook flow and print a dry run's result.
73
+ *
74
+ * @param provider - The agent's provider.
75
+ * @param payload - Decoded hook payload.
76
+ * @param options - Environment, dry-run flag and stdout sink.
77
+ * @returns The flow's final state.
78
+ */
79
+ async function processPayload(provider, payload, options) {
80
+ const paths = resolvePaths(options.env);
81
+ const loaded = await loadConfig(paths);
82
+ const result = await runHookPipeline({
83
+ provider,
84
+ env: options.env,
85
+ paths,
86
+ globalConfig: loaded.config,
87
+ payload,
88
+ dryRun: options.dryRun === true
89
+ });
90
+ if (options.dryRun)
91
+ writeStdout(options, JSON.stringify({ events: result.state.outbound }, null, 2) + '\n');
92
+ return result.state;
93
+ }
94
+ /**
95
+ * Decode the hook payload.
96
+ *
97
+ * An empty payload is a valid `{}` — some hooks fire with no body — while an
98
+ * unreadable one becomes undefined, which tells the caller to answer the agent
99
+ * without processing anything.
100
+ *
101
+ * @param options - Environment and injected stdin.
102
+ * @returns The decoded payload, or undefined.
103
+ */
104
+ async function readPayload(options) {
105
+ try {
106
+ const input = options.input ?? (await readStdin());
107
+ return input.trim() === '' ? {} : JSON.parse(input);
108
+ }
109
+ catch (error) {
110
+ debugLog('failed to read/parse hook payload:', error);
111
+ return undefined;
112
+ }
113
+ }
114
+ /**
115
+ * Write to the hook's stdout.
116
+ *
117
+ * @param options - Carries the injectable sink.
118
+ * @param text - Exactly what the agent's protocol expects.
119
+ */
120
+ function writeStdout(options, text) {
121
+ const write = options.writeStdout ?? ((value) => process.stdout.write(value));
122
+ write(text);
123
+ }
124
+ /**
125
+ * Read stdin to the end, bounded by size and time.
126
+ *
127
+ * Both bounds exist because the writer is the agent, not us: a hook that waited
128
+ * forever, or buffered an unbounded payload, would take the agent's session
129
+ * down with it.
130
+ *
131
+ * @returns The payload text; whatever arrived, if the timeout fires first.
132
+ */
133
+ function readStdin() {
134
+ return new Promise((resolve, reject) => {
135
+ const chunks = [];
136
+ let size = 0;
137
+ const cleanup = () => {
138
+ clearTimeout(timer);
139
+ process.stdin.off('data', onData);
140
+ process.stdin.off('end', onEnd);
141
+ process.stdin.off('error', onError);
142
+ };
143
+ const finish = () => {
144
+ cleanup();
145
+ resolve(Buffer.concat(chunks).toString('utf8'));
146
+ };
147
+ const onData = (chunk) => {
148
+ size += chunk.length;
149
+ if (size > MAX_STDIN_BYTES) {
150
+ cleanup();
151
+ reject(new Error('hook payload exceeds size limit'));
152
+ return;
153
+ }
154
+ chunks.push(chunk);
155
+ };
156
+ const onEnd = () => finish();
157
+ const onError = (error) => {
158
+ cleanup();
159
+ reject(error);
160
+ };
161
+ const timer = setTimeout(finish, STDIN_TIMEOUT_MS);
162
+ process.stdin.on('data', onData);
163
+ process.stdin.on('end', onEnd);
164
+ process.stdin.on('error', onError);
165
+ });
166
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The command surface. Every command resolves its context once, then works from
3
+ * that value; nothing here reaches for ambient state on its own.
4
+ */
5
+ export type { Check, CheckLevel, CliContext, HookRunOptions, ParsedArgs, SetupOptions, UninstallOptions } from './types/cli.types.js';
6
+ export { boolFlag, parseArgs, stringFlag } from './args.js';
7
+ export { buildCliContext, buildDeliveryStats, buildHookCommand, buildQueue, buildTransport } from './context.js';
8
+ export { runHook } from './hook.js';
9
+ export { runSetup } from './setup.js';
10
+ export { runStatus } from './status.js';
11
+ export { runDoctor } from './doctor.js';
12
+ export { runUninstall } from './uninstall.js';
13
+ export { runAgents, runConfig, runOtelHeaders } from './misc.js';
@@ -0,0 +1,8 @@
1
+ export { boolFlag, parseArgs, stringFlag } from './args.js';
2
+ export { buildCliContext, buildDeliveryStats, buildHookCommand, buildQueue, buildTransport } from './context.js';
3
+ export { runHook } from './hook.js';
4
+ export { runSetup } from './setup.js';
5
+ export { runStatus } from './status.js';
6
+ export { runDoctor } from './doctor.js';
7
+ export { runUninstall } from './uninstall.js';
8
+ export { runAgents, runConfig, runOtelHeaders } from './misc.js';
@@ -0,0 +1,31 @@
1
+ import type { Env } from '../core/types/core.types.js';
2
+ /**
3
+ * `agentwatch agents` — detection details for debugging.
4
+ *
5
+ * @param env - Ambient environment.
6
+ * @returns Exit code 0; detection is informational.
7
+ */
8
+ export declare function runAgents(env: Env): Promise<number>;
9
+ /**
10
+ * `agentwatch config` — the effective configuration for this directory, with
11
+ * the token redacted.
12
+ *
13
+ * Effective, not global: what hooks actually do here is the global file plus the
14
+ * repository overlay, and showing only the former would answer the wrong
15
+ * question.
16
+ *
17
+ * @param env - Ambient environment.
18
+ * @returns 1 when the global config is invalid, else 0.
19
+ */
20
+ export declare function runConfig(env: Env): Promise<number>;
21
+ /**
22
+ * `agentwatch otel-headers` — Claude Code's otelHeadersHelper contract.
23
+ *
24
+ * Print a JSON object of OTLP headers on stdout and nothing else: this is how
25
+ * the bearer token reaches the exporter without ever being written into Claude's
26
+ * settings file.
27
+ *
28
+ * @param env - Ambient environment.
29
+ * @returns Exit code 0.
30
+ */
31
+ export declare function runOtelHeaders(env: Env): Promise<number>;