@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,113 @@
1
+ import { omitKeys } from '../../core/object.js';
2
+ /**
3
+ * Install state with one agent's hook registration recorded.
4
+ *
5
+ * Returns a new state rather than editing the one it was given: setup runs
6
+ * several operations per agent and persists once at the end, and an operation
7
+ * that edited shared state would make the order of those calls part of the
8
+ * result.
9
+ *
10
+ * @param state - Current install state.
11
+ * @param agentId - Agent that was just installed.
12
+ * @param record - What was written, and where.
13
+ * @returns The next install state.
14
+ */
15
+ export function withHookInstall(state, agentId, record) {
16
+ const previous = state.agents[agentId];
17
+ return {
18
+ ...state,
19
+ agents: {
20
+ ...state.agents,
21
+ [agentId]: {
22
+ ...previous,
23
+ hooksInstalledAt: record.installedAt.toISOString(),
24
+ hookConfigPath: record.hookConfigPath,
25
+ hookEvents: [...record.hookEvents],
26
+ hookCommand: record.hookCommand,
27
+ otelOwnedKeys: previous?.otelOwnedKeys ?? [],
28
+ notes: record.notes ? [...record.notes] : (previous?.notes ?? [])
29
+ }
30
+ }
31
+ };
32
+ }
33
+ /**
34
+ * Install state with one agent's hook registration forgotten.
35
+ *
36
+ * The agent's entry survives so any native-telemetry record on it stays
37
+ * intact; only the hook fields are cleared.
38
+ *
39
+ * @param state - Current install state.
40
+ * @param agentId - Agent whose hooks were removed.
41
+ * @returns The next install state.
42
+ */
43
+ export function withoutHookInstall(state, agentId) {
44
+ const previous = state.agents[agentId];
45
+ if (!previous)
46
+ return state;
47
+ const cleared = { ...omitKeys(previous, new Set(['hooksInstalledAt'])), hookEvents: [] };
48
+ return { ...state, agents: { ...state.agents, [agentId]: cleared } };
49
+ }
50
+ /**
51
+ * Install state with one agent dropped entirely.
52
+ *
53
+ * For an agent whose config file is gone: there is nothing left to describe,
54
+ * and a stale entry would make `status` claim an installation that no longer
55
+ * exists.
56
+ *
57
+ * @param state - Current install state.
58
+ * @param agentId - Agent to forget.
59
+ * @returns The next install state.
60
+ */
61
+ export function withoutAgent(state, agentId) {
62
+ if (!(agentId in state.agents))
63
+ return state;
64
+ return { ...state, agents: omitKeys(state.agents, new Set([agentId])) };
65
+ }
66
+ /**
67
+ * Install state with one agent's native-telemetry configuration recorded.
68
+ *
69
+ * The owned-key list is the whole point of persisting this: without it,
70
+ * uninstall cannot tell the variables we wrote from the ones the developer set
71
+ * for their own collector.
72
+ *
73
+ * @param state - Current install state.
74
+ * @param agentId - Agent that was just configured.
75
+ * @param record - What was written, and where.
76
+ * @returns The next install state.
77
+ */
78
+ export function withOtelInstall(state, agentId, record) {
79
+ const previous = state.agents[agentId];
80
+ return {
81
+ ...state,
82
+ agents: {
83
+ ...state.agents,
84
+ [agentId]: {
85
+ ...previous,
86
+ hookEvents: previous?.hookEvents ?? [],
87
+ notes: previous?.notes ?? [],
88
+ otelConfiguredAt: record.configuredAt.toISOString(),
89
+ otelConfigPath: record.configPath,
90
+ otelOwnedKeys: [...new Set(record.ownedKeys)]
91
+ }
92
+ }
93
+ };
94
+ }
95
+ /**
96
+ * Install state with one agent's native-telemetry record cleared.
97
+ *
98
+ * @param state - Current install state.
99
+ * @param agentId - Agent whose configuration was removed.
100
+ * @returns The next install state.
101
+ */
102
+ export function withoutOtelInstall(state, agentId) {
103
+ const previous = state.agents[agentId];
104
+ if (!previous)
105
+ return state;
106
+ return {
107
+ ...state,
108
+ agents: {
109
+ ...state.agents,
110
+ [agentId]: { ...omitKeys(previous, new Set(['otelConfiguredAt'])), otelOwnedKeys: [] }
111
+ }
112
+ };
113
+ }
@@ -0,0 +1,58 @@
1
+ import type { CanonicalEventType, ContentEvidence } from '../../events/types/events.types.js';
2
+ import type { McpToolName, ToolKind } from '../types/provider.types.js';
3
+ export type { McpToolName, ToolKind } from '../types/provider.types.js';
4
+ /**
5
+ * What kind of thing a tool call is, whatever the agent calls it.
6
+ *
7
+ * The classification is what decides which canonical event type the call maps
8
+ * to, so "reading a file" is one product signal across every provider.
9
+ *
10
+ * @param toolName - Provider-reported tool name.
11
+ * @returns The kind, defaulting to 'other' for anything unrecognized.
12
+ */
13
+ export declare function classifyTool(toolName: string | undefined): ToolKind;
14
+ /**
15
+ * Canonical event type for a tool call starting.
16
+ *
17
+ * @param kind - Tool classification.
18
+ * @returns The event type.
19
+ */
20
+ export declare function toolStartType(kind: ToolKind): CanonicalEventType;
21
+ /**
22
+ * Canonical event type for a tool call finishing successfully.
23
+ *
24
+ * @param kind - Tool classification.
25
+ * @returns The event type.
26
+ */
27
+ export declare function toolCompleteType(kind: ToolKind): CanonicalEventType;
28
+ /**
29
+ * Split "mcp__server__tool" into its parts.
30
+ *
31
+ * @param toolName - Provider-reported tool name.
32
+ * @returns The server and tool, or an empty object for a non-MCP name.
33
+ */
34
+ export declare function parseMcpToolName(toolName: string): McpToolName;
35
+ /**
36
+ * Length and hash of text, as evidence for content we may not transmit.
37
+ *
38
+ * Lets the backend verify that a record describes the content the developer
39
+ * actually saw, without the content having to leave the machine.
40
+ *
41
+ * @param text - The content.
42
+ * @returns Its evidence.
43
+ */
44
+ export declare function contentEvidence(text: string): ContentEvidence;
45
+ /**
46
+ * Best-effort file path out of a heterogeneous tool input.
47
+ *
48
+ * @param toolInput - Whatever the provider passed as the call's arguments.
49
+ * @returns The path, or undefined when the input names none.
50
+ */
51
+ export declare function extractFilePath(toolInput: unknown): string | undefined;
52
+ /**
53
+ * Best-effort shell command out of a heterogeneous tool input.
54
+ *
55
+ * @param toolInput - Whatever the provider passed as the call's arguments.
56
+ * @returns The command, or undefined when the input names none.
57
+ */
58
+ export declare function extractCommand(toolInput: unknown): string | undefined;
@@ -0,0 +1,103 @@
1
+ import { asRecord, firstString } from '../../core/object.js';
2
+ import { sha256Hex } from '../../events/event-id.js';
3
+ import { COMMAND_KEYS, FILE_EDIT_TOOLS, FILE_PATH_KEYS, FILE_READ_TOOLS, MCP_TOOL_PREFIX, MCP_TOOL_SEPARATOR, SHELL_TOOLS } from './constants/tooling.constants.js';
4
+ /**
5
+ * What kind of thing a tool call is, whatever the agent calls it.
6
+ *
7
+ * The classification is what decides which canonical event type the call maps
8
+ * to, so "reading a file" is one product signal across every provider.
9
+ *
10
+ * @param toolName - Provider-reported tool name.
11
+ * @returns The kind, defaulting to 'other' for anything unrecognized.
12
+ */
13
+ export function classifyTool(toolName) {
14
+ if (!toolName)
15
+ return 'other';
16
+ if (toolName.startsWith(MCP_TOOL_PREFIX))
17
+ return 'mcp';
18
+ if (SHELL_TOOLS.has(toolName))
19
+ return 'shell';
20
+ if (FILE_READ_TOOLS.has(toolName))
21
+ return 'file-read';
22
+ if (FILE_EDIT_TOOLS.has(toolName))
23
+ return 'file-edit';
24
+ return 'other';
25
+ }
26
+ /**
27
+ * Canonical event type for a tool call starting.
28
+ *
29
+ * @param kind - Tool classification.
30
+ * @returns The event type.
31
+ */
32
+ export function toolStartType(kind) {
33
+ if (kind === 'shell')
34
+ return 'shell.started';
35
+ if (kind === 'mcp')
36
+ return 'mcp.started';
37
+ return 'tool.started';
38
+ }
39
+ /**
40
+ * Canonical event type for a tool call finishing successfully.
41
+ *
42
+ * @param kind - Tool classification.
43
+ * @returns The event type.
44
+ */
45
+ export function toolCompleteType(kind) {
46
+ if (kind === 'shell')
47
+ return 'shell.completed';
48
+ if (kind === 'mcp')
49
+ return 'mcp.completed';
50
+ if (kind === 'file-read')
51
+ return 'file.read';
52
+ if (kind === 'file-edit')
53
+ return 'file.edited';
54
+ return 'tool.completed';
55
+ }
56
+ /**
57
+ * Split "mcp__server__tool" into its parts.
58
+ *
59
+ * @param toolName - Provider-reported tool name.
60
+ * @returns The server and tool, or an empty object for a non-MCP name.
61
+ */
62
+ export function parseMcpToolName(toolName) {
63
+ if (!toolName.startsWith(MCP_TOOL_PREFIX))
64
+ return {};
65
+ const parts = toolName.split(MCP_TOOL_SEPARATOR);
66
+ return { server: parts[1], tool: parts.slice(2).join(MCP_TOOL_SEPARATOR) || undefined };
67
+ }
68
+ /**
69
+ * Length and hash of text, as evidence for content we may not transmit.
70
+ *
71
+ * Lets the backend verify that a record describes the content the developer
72
+ * actually saw, without the content having to leave the machine.
73
+ *
74
+ * @param text - The content.
75
+ * @returns Its evidence.
76
+ */
77
+ export function contentEvidence(text) {
78
+ return { length: text.length, sha256: sha256Hex(text) };
79
+ }
80
+ /**
81
+ * Best-effort file path out of a heterogeneous tool input.
82
+ *
83
+ * @param toolInput - Whatever the provider passed as the call's arguments.
84
+ * @returns The path, or undefined when the input names none.
85
+ */
86
+ export function extractFilePath(toolInput) {
87
+ const record = asRecord(toolInput);
88
+ if (!record)
89
+ return undefined;
90
+ return firstString(record, FILE_PATH_KEYS);
91
+ }
92
+ /**
93
+ * Best-effort shell command out of a heterogeneous tool input.
94
+ *
95
+ * @param toolInput - Whatever the provider passed as the call's arguments.
96
+ * @returns The command, or undefined when the input names none.
97
+ */
98
+ export function extractCommand(toolInput) {
99
+ const record = asRecord(toolInput);
100
+ if (!record)
101
+ return undefined;
102
+ return firstString(record, COMMAND_KEYS);
103
+ }
@@ -0,0 +1,54 @@
1
+ import type { CanonicalEventType, EventAi, EventPatch, EventTool } from '../../../events/types/events.types.js';
2
+ import type { UnknownRecord } from '../../../core/types/core.types.js';
3
+ import type { ToolKind, ToolStatus } from '../../types/provider.types.js';
4
+ /** Everything the base of a canonical event is derived from. */
5
+ export interface BaseEventInput {
6
+ /** Internal provider id, e.g. 'claude'. */
7
+ readonly provider: string;
8
+ /** Human-facing agent name, e.g. 'Claude Code'. */
9
+ readonly displayName: string;
10
+ /** The provider's own name for this hook. */
11
+ readonly providerEventType: string;
12
+ readonly eventType: CanonicalEventType;
13
+ readonly sessionId?: string;
14
+ readonly turnId?: string;
15
+ readonly agentId?: string;
16
+ readonly toolUseId?: string;
17
+ readonly promptId?: string;
18
+ /**
19
+ * Hash of the variable part of the payload, so two otherwise-identical
20
+ * events of one turn get distinct ids. Never raw content.
21
+ */
22
+ readonly payloadFingerprint: string;
23
+ readonly ai?: EventAi;
24
+ /** Provider-specific fields, kept under `metadata.provider`. */
25
+ readonly providerMetadata?: UnknownRecord;
26
+ /** ISO timestamp; injectable so a build is reproducible in tests. */
27
+ readonly timestamp: string;
28
+ }
29
+ /** A tool call as the shared builder understands it. */
30
+ export interface ToolCallInput {
31
+ readonly name?: string;
32
+ readonly status: ToolStatus;
33
+ readonly kind: ToolKind;
34
+ readonly durationMs?: number;
35
+ readonly toolUseId?: string;
36
+ /** Raw arguments, whatever shape the provider used. */
37
+ readonly input?: unknown;
38
+ /** Raw result, whatever shape the provider used. */
39
+ readonly output?: unknown;
40
+ /** Error detail, when the call failed. */
41
+ readonly error?: unknown;
42
+ /** Extra provider-specific fields for `metadata.provider`, e.g. MCP routing. */
43
+ readonly providerFields?: UnknownRecord;
44
+ }
45
+ /** What the effective config allows to be captured. */
46
+ export interface CapturePolicy {
47
+ readonly prompts: boolean;
48
+ readonly responses: boolean;
49
+ readonly toolInput: boolean;
50
+ readonly toolOutput: boolean;
51
+ readonly files: boolean;
52
+ }
53
+ /** The pieces of an event a per-hook mapping contributes. */
54
+ export type { EventPatch, EventTool };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import type { UnknownRecord } from '../../../core/types/core.types.js';
2
+ /**
3
+ * A matcher group as Claude, Codex, Gemini and Antigravity write it: an
4
+ * optional tool-name matcher plus a list of command handlers.
5
+ */
6
+ export interface HookMatcherGroup {
7
+ readonly matcher?: string;
8
+ readonly hooks: readonly UnknownRecord[];
9
+ readonly [key: string]: unknown;
10
+ }
11
+ /** One command handler inside a group (or, for Cursor, on its own). */
12
+ export interface HookHandler {
13
+ readonly type?: string;
14
+ readonly command?: string;
15
+ readonly timeout?: number;
16
+ readonly [key: string]: unknown;
17
+ }
18
+ export interface StripOptions {
19
+ /**
20
+ * Also treat a bare handler as strippable.
21
+ *
22
+ * Antigravity accepts both a matcher group and a bare handler in the same
23
+ * list, so both shapes have to be recognized or an uninstall would leave one
24
+ * behind.
25
+ */
26
+ readonly allowBareHandlers?: boolean;
27
+ }
28
+ /** An event map with AgentWatch's entries removed, and whether that changed it. */
29
+ export interface StripResult {
30
+ readonly hooks: UnknownRecord;
31
+ readonly changed: boolean;
32
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,98 @@
1
+ import type { AgentWatchConfig } from '../../config/types/config.types.js';
2
+ import type { Env } from '../../core/types/core.types.js';
3
+ import type { AgentWatchEvent } from '../../events/types/events.types.js';
4
+ import type { AgentWatchPaths, InstallState } from '../../storage/types/storage.types.js';
5
+ /** What detection found out about one agent on this machine. */
6
+ export interface DetectionResult {
7
+ readonly detected: boolean;
8
+ /** Human-readable reasons, e.g. "~/.claude exists", "claude on PATH". */
9
+ readonly evidence: readonly string[];
10
+ readonly executablePath?: string;
11
+ /** File AgentWatch hooks are (or would be) registered in. */
12
+ readonly hookConfigPath: string;
13
+ readonly hooksInstalled: boolean;
14
+ }
15
+ export interface SetupContext {
16
+ readonly env: Env;
17
+ readonly paths: AgentWatchPaths;
18
+ readonly config: AgentWatchConfig;
19
+ /** Command line agents will invoke, e.g. "/usr/local/bin/agentwatch hook --agent claude". */
20
+ readonly hookCommand: string;
21
+ /** What setup has recorded so far; an operation returns the next version. */
22
+ readonly installState: InstallState;
23
+ }
24
+ export interface SetupOutcome {
25
+ readonly ok: boolean;
26
+ readonly changed: boolean;
27
+ /** User-facing notes: required manual steps, skip reasons, errors. */
28
+ readonly messages: readonly string[];
29
+ /**
30
+ * Install state after this operation, when it recorded anything.
31
+ *
32
+ * Returned rather than mutated in place: setup runs several operations per
33
+ * agent and persists once at the end, and an operation that edited a shared
34
+ * object would make the order of those calls part of the result.
35
+ */
36
+ readonly installState?: InstallState;
37
+ }
38
+ export interface HookContext {
39
+ readonly env: Env;
40
+ readonly config: AgentWatchConfig;
41
+ }
42
+ export interface ProviderHookResponse {
43
+ /** Written verbatim to stdout; omit for protocol-safe silence. */
44
+ readonly stdout?: string;
45
+ readonly exitCode: number;
46
+ }
47
+ export interface NativeTelemetryStatus {
48
+ readonly supported: boolean;
49
+ /** Configured by AgentWatch. */
50
+ readonly configured: boolean;
51
+ /** Foreign telemetry configuration we refuse to overwrite. */
52
+ readonly conflict?: string;
53
+ readonly detail?: string;
54
+ }
55
+ export interface NativeTelemetryConfigurator {
56
+ supported(env: Env): Promise<boolean>;
57
+ inspect(context: SetupContext): Promise<NativeTelemetryStatus>;
58
+ configure(context: SetupContext): Promise<SetupOutcome>;
59
+ uninstall(context: SetupContext): Promise<SetupOutcome>;
60
+ }
61
+ export interface AgentProvider {
62
+ readonly id: string;
63
+ readonly displayName: string;
64
+ detect(env: Env): Promise<DetectionResult>;
65
+ installHooks(context: SetupContext): Promise<SetupOutcome>;
66
+ uninstallHooks(context: SetupContext): Promise<SetupOutcome>;
67
+ parseHookEvent(payload: unknown, context: HookContext): Promise<AgentWatchEvent[]>;
68
+ getHookResponse(payload: unknown): ProviderHookResponse;
69
+ /**
70
+ * The agent's own way of refusing the turn this payload belongs to, when this
71
+ * hook is one it can refuse.
72
+ *
73
+ * Only the prompt-submit hook of each agent is a gate: it is the last moment
74
+ * before the turn's first LLM call, so a refusal there costs nothing that has
75
+ * already been paid for. Every other payload — and every provider whose
76
+ * refusal contract is not verified — returns undefined, which means the turn
77
+ * proceeds. Blocking is a decision the platform makes; a provider only knows
78
+ * how to say it.
79
+ */
80
+ getBlockResponse?(payload: unknown, message: string): ProviderHookResponse | undefined;
81
+ /**
82
+ * Working directory this payload was produced in, when the provider does not
83
+ * report it as a top-level `cwd`. Git context, repository config and ticket
84
+ * candidates all hang off this path, so a provider that nests it (Antigravity
85
+ * reports `common.workspacePaths`) has to say where it is.
86
+ */
87
+ resolveCwd?(payload: unknown): string | undefined;
88
+ readonly nativeTelemetry?: NativeTelemetryConfigurator;
89
+ }
90
+ /** How a tool call is classified for canonical event mapping. */
91
+ export type ToolKind = 'shell' | 'mcp' | 'file-read' | 'file-edit' | 'other';
92
+ /** Lifecycle position of a tool event. */
93
+ export type ToolStatus = 'started' | 'completed' | 'failed';
94
+ /** "mcp__server__tool" split into its parts. */
95
+ export interface McpToolName {
96
+ readonly server?: string;
97
+ readonly tool?: string;
98
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ import type { BranchRef } from '../git/types/snapshot.types.js';
2
+ import type { SelectionInput, SnapshotState } from './types/snapshot.types.js';
3
+ /**
4
+ * Which branches are worth describing again.
5
+ *
6
+ * Four reasons, and each one is a bug if it is missing:
7
+ *
8
+ * - the branch is new — nothing has ever been reported about it;
9
+ * - its head moved — the obvious one;
10
+ * - the default branch changed since the last send, because every delta was
11
+ * computed against the wrong base and no head has to move for that to be
12
+ * true;
13
+ * - the entry is older than the heartbeat, which is the only thing that ever
14
+ * re-offers a finished branch to a tracker connected after the fact.
15
+ *
16
+ * @param input - The refs git reported and what was last sent.
17
+ * @returns The branches to describe. Empty means send nothing at all.
18
+ */
19
+ export declare function selectChangedBranches(input: SelectionInput): readonly BranchRef[];
20
+ /**
21
+ * The state to store once a snapshot has been queued.
22
+ *
23
+ * A branch is recorded as reported only if it was actually described. The
24
+ * cache is a record of what the platform has been told, not of what git said:
25
+ * a branch whose head moved and which then fell outside the budget must keep
26
+ * its *old* head here, or the next turn compares the new head against the new
27
+ * head, finds them equal, and the work disappears until the heartbeat six hours
28
+ * later.
29
+ *
30
+ * A branch that was listed but never sent is therefore left exactly as it was —
31
+ * and one that has never been sent at all is left out, so it stays new.
32
+ *
33
+ * @param input - Refs, previous state and the send's own clock.
34
+ * @param sent - The branches this snapshot actually described.
35
+ * @returns The state to write.
36
+ */
37
+ export declare function nextSnapshotState(input: SelectionInput, sent: readonly BranchRef[]): SnapshotState;
@@ -0,0 +1,69 @@
1
+ import { SNAPSHOT_REFRESH_MS } from './constants/snapshot.constants.js';
2
+ /**
3
+ * Which branches are worth describing again.
4
+ *
5
+ * Four reasons, and each one is a bug if it is missing:
6
+ *
7
+ * - the branch is new — nothing has ever been reported about it;
8
+ * - its head moved — the obvious one;
9
+ * - the default branch changed since the last send, because every delta was
10
+ * computed against the wrong base and no head has to move for that to be
11
+ * true;
12
+ * - the entry is older than the heartbeat, which is the only thing that ever
13
+ * re-offers a finished branch to a tracker connected after the fact.
14
+ *
15
+ * @param input - The refs git reported and what was last sent.
16
+ * @returns The branches to describe. Empty means send nothing at all.
17
+ */
18
+ export function selectChangedBranches(input) {
19
+ const rebased = input.stored.defaultBranch !== input.defaultBranch;
20
+ return input.refs.filter((ref) => {
21
+ if (rebased)
22
+ return true;
23
+ const entry = input.stored.branches[ref.name];
24
+ if (!entry)
25
+ return true;
26
+ if (entry.headSha !== ref.headSha)
27
+ return true;
28
+ return input.now - entry.lastSentAt >= SNAPSHOT_REFRESH_MS;
29
+ });
30
+ }
31
+ /**
32
+ * The state to store once a snapshot has been queued.
33
+ *
34
+ * A branch is recorded as reported only if it was actually described. The
35
+ * cache is a record of what the platform has been told, not of what git said:
36
+ * a branch whose head moved and which then fell outside the budget must keep
37
+ * its *old* head here, or the next turn compares the new head against the new
38
+ * head, finds them equal, and the work disappears until the heartbeat six hours
39
+ * later.
40
+ *
41
+ * A branch that was listed but never sent is therefore left exactly as it was —
42
+ * and one that has never been sent at all is left out, so it stays new.
43
+ *
44
+ * @param input - Refs, previous state and the send's own clock.
45
+ * @param sent - The branches this snapshot actually described.
46
+ * @returns The state to write.
47
+ */
48
+ export function nextSnapshotState(input, sent) {
49
+ const sentNames = new Set(sent.map((ref) => ref.name));
50
+ const branches = {};
51
+ for (const ref of input.refs) {
52
+ if (sentNames.has(ref.name)) {
53
+ branches[ref.name] = { headSha: ref.headSha, lastSentAt: input.now };
54
+ continue;
55
+ }
56
+ const previous = input.stored.branches[ref.name];
57
+ if (previous)
58
+ branches[ref.name] = previous;
59
+ }
60
+ // The recorded base only moves once every branch has been described against
61
+ // it. Recording it early would end the `rebased` selection for branches whose
62
+ // deltas were never recomputed, and they would sit on the wrong base until
63
+ // their heads happened to move.
64
+ const described = input.refs.every((ref) => sentNames.has(ref.name));
65
+ return {
66
+ defaultBranch: described ? input.defaultBranch : input.stored.defaultBranch,
67
+ branches
68
+ };
69
+ }
@@ -0,0 +1,41 @@
1
+ import type { GitRunner } from '../git/types/git.types.js';
2
+ /**
3
+ * How long a deadline still allows, never below zero.
4
+ *
5
+ * @param deadline - Epoch milliseconds the flow must be finished by.
6
+ * @param now - Current time, injectable for tests.
7
+ * @returns Milliseconds left.
8
+ */
9
+ export declare function remainingMs(deadline: number, now?: () => number): number;
10
+ /**
11
+ * A git runner that cannot outlive the flow's budget.
12
+ *
13
+ * Without this the budget bounds nothing that matters: the listing may wait a
14
+ * second, resolving the default branch may wait three more across its
15
+ * fallbacks, and a `git log` that started inside the budget runs to its own
16
+ * timeout regardless. Four sequential seconds is not "at most one", and this
17
+ * runs on the hook's answer path.
18
+ *
19
+ * A call with no time left is not made at all — its caller reads the absent
20
+ * output the same way it reads a repository that could not be listed.
21
+ *
22
+ * @param run - The real runner.
23
+ * @param deadline - Epoch milliseconds the flow must be finished by.
24
+ * @param now - Current time, injectable for tests.
25
+ * @returns A runner whose timeout is whatever is left, capped at the git default.
26
+ */
27
+ export declare function budgetedRunner(run: GitRunner, deadline: number, now?: () => number): GitRunner;
28
+ /**
29
+ * Give up on work that outlives the budget.
30
+ *
31
+ * Used for the two local writes at the end of the flow. Abandoning either is
32
+ * safe by construction: an enqueue that did not finish means nothing was
33
+ * recorded as sent, and a cache write that did not finish means the branches
34
+ * are simply offered again next turn.
35
+ *
36
+ * @param work - The promise to bound.
37
+ * @param deadline - Epoch milliseconds the flow must be finished by.
38
+ * @param now - Current time, injectable for tests.
39
+ * @returns True when the work finished inside the budget.
40
+ */
41
+ export declare function withinBudget(work: Promise<unknown>, deadline: number, now?: () => number): Promise<boolean>;