@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,297 @@
1
+ import path from 'node:path';
2
+ import { asRecord } from '../core/object.js';
3
+ import { debugLog } from '../core/logger.js';
4
+ import { next, runFlow, step, stop } from '../core/pipe.js';
5
+ import { loadEffectiveConfig } from '../config/repo-config.js';
6
+ import { DECISION_BLOCK } from '../enforcement/constants/enforcement.constants.js';
7
+ import { resolveEnforcement } from '../enforcement/enforcement.js';
8
+ import { enrichEvents } from '../events/enrich.js';
9
+ import { developerIdentity, runGit } from '../git/git-context.js';
10
+ import { runSnapshotPipeline } from '../snapshot/snapshot-pipeline.js';
11
+ import { SnapshotStateStore } from '../snapshot/snapshot-state.js';
12
+ import { SNAPSHOT_BUDGET_MS } from '../snapshot/constants/snapshot.constants.js';
13
+ import { BackendCooldown } from '../transport/cooldown.js';
14
+ import { DeliveryStats } from '../transport/delivery-stats.js';
15
+ import { deliverEvents } from '../transport/delivery.js';
16
+ import { HttpTransport } from '../transport/http-transport.js';
17
+ import { EventQueue } from '../transport/queue.js';
18
+ import { COOLDOWN_FILE_NAME, DELIVERY_STATS_FILE_NAME } from '../transport/constants/transport.constants.js';
19
+ import { eventsUrl } from '../config/config.js';
20
+ import { trackTurn } from '../turns/turn-tracker.js';
21
+ import { PAYLOAD_CWD_KEY, PROMPT_SUBMITTED_TYPE, STAGE_DELIVER, STAGE_ENFORCE, STAGE_ENRICH, STAGE_PARSE_EVENTS, STAGE_RESOLVE_CONTEXT, STAGE_SNAPSHOT, STAGE_TRACK_TURN, STOP_DRY_RUN, STOP_NO_EVENTS, STOP_NO_SNAPSHOT } from './constants/pipeline.constants.js';
22
+ /**
23
+ * The hook flow, as the list of stages it is.
24
+ *
25
+ * Read top to bottom, this is the whole contract of the hook path: work out
26
+ * where we are and what the effective config says, turn the payload into
27
+ * canonical events, ask whether this turn may start at all, attach development
28
+ * context, assemble the turn, deliver, and — when a turn has just closed — tell
29
+ * the platform what this repository's recent branches look like.
30
+ * Every stage takes the whole state and returns the next one, so adding or
31
+ * reordering a step is a change to this array rather than to a call graph.
32
+ */
33
+ const HOOK_STAGES = [
34
+ step(STAGE_RESOLVE_CONTEXT, resolveContext),
35
+ step(STAGE_PARSE_EVENTS, parseEvents),
36
+ step(STAGE_ENFORCE, enforce),
37
+ step(STAGE_ENRICH, enrich),
38
+ step(STAGE_TRACK_TURN, trackTurnStage),
39
+ step(STAGE_DELIVER, deliver),
40
+ step(STAGE_SNAPSHOT, snapshot)
41
+ ];
42
+ /**
43
+ * Run one hook payload through the flow.
44
+ *
45
+ * Never throws: a stage that fails ends the flow with whatever the last
46
+ * successful stage produced, because the caller is a hook that must answer the
47
+ * coding agent either way.
48
+ *
49
+ * @param input - Provider, environment, payload and dry-run flag.
50
+ * @returns The final state and where the flow stopped.
51
+ */
52
+ export function runHookPipeline(input) {
53
+ const initial = {
54
+ ...input,
55
+ cwd: resolvePayloadCwd(input),
56
+ config: input.globalConfig,
57
+ events: [],
58
+ outbound: []
59
+ };
60
+ return runFlow(HOOK_STAGES, initial, (trace) => {
61
+ if (trace.outcome === 'next')
62
+ return;
63
+ debugLog(`hook flow ${trace.outcome} at ${trace.step}${trace.reason ? `: ${trace.reason}` : ''}`);
64
+ });
65
+ }
66
+ /**
67
+ * Apply the repository's `.agentwatch.json` on top of the global config.
68
+ *
69
+ * Repository overrides govern content capture derived from *this* payload;
70
+ * identity, endpoints, emission toggles and delivery tuning stay global-only.
71
+ *
72
+ * @param state - Current flow state.
73
+ * @returns The state with its effective config resolved.
74
+ */
75
+ async function resolveContext(state) {
76
+ const effective = await loadEffectiveConfig(state.paths, state.cwd);
77
+ return next({ ...state, config: effective.config });
78
+ }
79
+ /**
80
+ * Turn the payload into canonical events.
81
+ *
82
+ * @param state - Current flow state.
83
+ * @returns The state with its events, or a stop when the payload carried none.
84
+ */
85
+ async function parseEvents(state) {
86
+ const events = await state.provider.parseHookEvent(state.payload, { env: state.env, config: state.config });
87
+ if (events.length === 0)
88
+ return stop(state, STOP_NO_EVENTS);
89
+ return next({ ...state, events });
90
+ }
91
+ /**
92
+ * Ask the platform whether this turn may start.
93
+ *
94
+ * Only the prompt hook is a gate, and only a provider that knows how to refuse
95
+ * one is asked about: everything else skips the check entirely, so no tool hook
96
+ * pays for it. A refusal lands in the state as a sentence to show; every failure
97
+ * of the check leaves the state untouched, which is what makes an unreachable
98
+ * platform a no-op rather than an outage.
99
+ *
100
+ * A dry run never asks. It previews what would be sent, and rehearsing a refusal
101
+ * would block a developer for a command that promised to change nothing.
102
+ *
103
+ * @param state - Current flow state.
104
+ * @returns The state, carrying the refusal when there is one.
105
+ */
106
+ async function enforce(state) {
107
+ if (state.dryRun || !state.provider.getBlockResponse || !isTurnGate(state))
108
+ return next(state);
109
+ const decision = await resolveEnforcement({
110
+ config: state.config,
111
+ paths: state.paths,
112
+ developerId: await developerIdentity(state.config.developerEmail, state.cwd, { home: state.env.home }),
113
+ now: state.env.now
114
+ });
115
+ if (decision.decision !== DECISION_BLOCK)
116
+ return next(state);
117
+ return next({ ...state, blockMessage: decision.message });
118
+ }
119
+ /**
120
+ * Whether this payload is the moment before the turn's first LLM call.
121
+ *
122
+ * @param state - Current flow state.
123
+ * @returns True when the provider reported a submitted prompt.
124
+ */
125
+ function isTurnGate(state) {
126
+ for (const event of state.events) {
127
+ if (event.event.type === PROMPT_SUBMITTED_TYPE)
128
+ return true;
129
+ }
130
+ return false;
131
+ }
132
+ /**
133
+ * Attach development context and scrub the events.
134
+ *
135
+ * @param state - Current flow state.
136
+ * @returns The state with enriched events.
137
+ */
138
+ async function enrich(state) {
139
+ const events = await enrichEvents(state.events, { config: state.config, cwd: state.cwd, home: state.env.home });
140
+ return next({ ...state, events });
141
+ }
142
+ /**
143
+ * Assemble the turn and decide what leaves this machine.
144
+ *
145
+ * Turn tracking always runs, even when summaries are not emitted: besides
146
+ * producing the summary it resolves token usage for the turn. Only
147
+ * `turn.summary` leaves the hook path — lifecycle events are internal assembly
148
+ * state, and `llm.call` records arrive through the native OTLP path.
149
+ *
150
+ * @param state - Current flow state.
151
+ * @returns The state with its summary and outbound records.
152
+ */
153
+ async function trackTurnStage(state) {
154
+ // A refused prompt never reached a model. Recording it would leave a prompt
155
+ // with no turn behind it, to be folded into whichever turn came next and
156
+ // inflate its prompt; the flow continues so the offline queue still drains.
157
+ if (state.blockMessage)
158
+ return next(state);
159
+ // Assembly failing must not cost the *queue* its drain: a hook that produced
160
+ // no summary still has a backlog to move, so this stage degrades to "no
161
+ // summary" instead of ending the flow.
162
+ const summary = await trackTurnSafely(state);
163
+ const outbound = summary && state.config.emit.turnSummaries ? [summary] : [];
164
+ return next({ ...state, summary, outbound });
165
+ }
166
+ /**
167
+ * Assemble the turn, degrading to no summary on any failure.
168
+ *
169
+ * @param state - Current flow state.
170
+ * @returns The summary, or undefined.
171
+ */
172
+ async function trackTurnSafely(state) {
173
+ try {
174
+ return await trackTurn({
175
+ agentId: state.provider.id,
176
+ rawPayload: state.payload,
177
+ events: state.events,
178
+ config: state.config,
179
+ turnsDir: state.paths.turnsDir,
180
+ locksDir: state.paths.locksDir,
181
+ env: state.env,
182
+ cwd: state.cwd,
183
+ readOnly: state.dryRun
184
+ });
185
+ }
186
+ catch (error) {
187
+ debugLog('turn summary failed:', error);
188
+ return undefined;
189
+ }
190
+ }
191
+ /**
192
+ * Send what this run produced, or queue it.
193
+ *
194
+ * @param state - Current flow state.
195
+ * @returns The state with the delivery outcome, or a stop on a dry run.
196
+ */
197
+ async function deliver(state) {
198
+ if (state.dryRun)
199
+ return stop(state, STOP_DRY_RUN);
200
+ const queue = buildQueue(state);
201
+ const delivery = await deliverEvents(state.outbound, buildTransport(state), queue, state.config.delivery.drainBatchSize, new BackendCooldown(path.join(state.paths.dataDir, COOLDOWN_FILE_NAME), state.env.now), new DeliveryStats(path.join(state.paths.dataDir, DELIVERY_STATS_FILE_NAME), state.env.now, state.paths.locksDir));
202
+ debugLog(`delivery: sent=${delivery.delivered} queued=${delivery.queued} drained=${delivery.drained} rejected=${delivery.rejected}`);
203
+ return next({ ...state, delivery });
204
+ }
205
+ /**
206
+ * Describe the repository's recent branches, after the turn has been delivered.
207
+ *
208
+ * Last, and awaited. Last because it must never delay the spend records, which
209
+ * are the reason the hook exists; awaited because the process exits the moment
210
+ * this returns, and a dangling promise would be killed somewhere between
211
+ * building the event and writing it to the queue.
212
+ *
213
+ * It runs only on a closed turn — the one hook per turn that already pays for
214
+ * full git context — and only when git capture is on: branch names and commit
215
+ * subjects are git metadata, and a developer who turned that off has said no to
216
+ * exactly this.
217
+ *
218
+ * @param state - Current flow state.
219
+ * @returns The state, unchanged. A snapshot never affects the hook's answer.
220
+ */
221
+ async function snapshot(state) {
222
+ const repository = state.summary?.repository;
223
+ if (!repository || !state.config.capture.git)
224
+ return stop(state, STOP_NO_SNAPSHOT);
225
+ await runSnapshotPipeline({
226
+ input: {
227
+ cwd: state.cwd,
228
+ repository,
229
+ provider: state.summary?.provider ?? state.provider.id,
230
+ surface: state.summary?.surface ?? state.provider.id,
231
+ agentName: state.summary?.agent.name ?? state.provider.id,
232
+ developerId: state.summary?.developer_id,
233
+ installationId: state.config.installationId,
234
+ sessionId: state.summary?.session_id,
235
+ capturedAt: state.env.now().toISOString(),
236
+ // Real time, deliberately, where the line above uses the injected clock:
237
+ // this bounds subprocess timeouts, which are measured against the wall.
238
+ deadline: Date.now() + SNAPSHOT_BUDGET_MS,
239
+ run: runGit
240
+ },
241
+ store: new SnapshotStateStore(state.paths.snapshotsDir),
242
+ queue: buildQueue(state)
243
+ });
244
+ return next(state);
245
+ }
246
+ /**
247
+ * The offline queue for this run.
248
+ *
249
+ * @param state - Current flow state.
250
+ * @returns A queue bound to this run's paths and delivery limits.
251
+ */
252
+ function buildQueue(state) {
253
+ return new EventQueue({
254
+ queueDir: state.paths.queueDir,
255
+ locksDir: state.paths.locksDir,
256
+ maxEvents: state.config.delivery.maxQueueEvents,
257
+ maxAttempts: state.config.delivery.maxAttempts,
258
+ maxEventAgeDays: state.config.delivery.maxEventAgeDays,
259
+ now: state.env.now
260
+ });
261
+ }
262
+ /**
263
+ * The transport for this run, when a backend is configured.
264
+ *
265
+ * @param state - Current flow state.
266
+ * @returns The transport, or undefined before setup has run.
267
+ */
268
+ function buildTransport(state) {
269
+ const url = eventsUrl(state.config);
270
+ if (!url)
271
+ return undefined;
272
+ return new HttpTransport({
273
+ eventsUrl: url,
274
+ token: state.config.token,
275
+ installationId: state.config.installationId,
276
+ timeoutMs: state.config.delivery.timeoutMs
277
+ });
278
+ }
279
+ /**
280
+ * Where this payload happened.
281
+ *
282
+ * Most agents report a top-level `cwd`; a provider that nests it (Antigravity
283
+ * carries `common.workspacePaths`) supplies `resolveCwd`. Without this the git
284
+ * context, the repository `.agentwatch.json` and every branch-derived ticket key
285
+ * would be resolved against whatever directory the hook process happened to
286
+ * start in.
287
+ *
288
+ * @param input - The flow's input.
289
+ * @returns The working directory to use.
290
+ */
291
+ function resolvePayloadCwd(input) {
292
+ const reported = asRecord(input.payload)?.[PAYLOAD_CWD_KEY];
293
+ if (typeof reported === 'string' && reported !== '')
294
+ return reported;
295
+ const resolved = input.provider.resolveCwd?.(input.payload);
296
+ return typeof resolved === 'string' && resolved !== '' ? resolved : input.env.cwd;
297
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The package's flows, expressed as ordered lists of named stages rather than
3
+ * as call graphs. The hook path is the one that runs inside the coding agent.
4
+ */
5
+ export type { HookPipelineInput, HookPipelineState } from './types/pipeline.types.js';
6
+ export { runHookPipeline } from './hook-pipeline.js';
@@ -0,0 +1 @@
1
+ export { runHookPipeline } from './hook-pipeline.js';
@@ -0,0 +1,48 @@
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 { AgentProvider } from '../../providers/types/provider.types.js';
5
+ import type { AgentWatchPaths } from '../../storage/types/storage.types.js';
6
+ import type { TurnSummaryEvent } from '../../turns/types/turn-summary.types.js';
7
+ import type { DeliveryOutcome } from '../../transport/types/transport.types.js';
8
+ /** Everything the hook flow needs to start. */
9
+ export interface HookPipelineInput {
10
+ readonly provider: AgentProvider;
11
+ readonly env: Env;
12
+ readonly paths: AgentWatchPaths;
13
+ /** The machine-global configuration, before the repository overlay. */
14
+ readonly globalConfig: AgentWatchConfig;
15
+ /** Decoded hook payload. */
16
+ readonly payload: unknown;
17
+ /** Preview only: append nothing, consume nothing, send nothing. */
18
+ readonly dryRun: boolean;
19
+ }
20
+ /**
21
+ * The state every stage of the hook flow reads and extends.
22
+ *
23
+ * One immutable value threaded through the stages, so each stage is a pure
24
+ * function of what came before it and the flow reads top to bottom.
25
+ */
26
+ export interface HookPipelineState extends HookPipelineInput {
27
+ /** Where the payload happened; resolved in the first stage. */
28
+ readonly cwd: string;
29
+ /** Global config with the repository overlay applied. */
30
+ readonly config: AgentWatchConfig;
31
+ /** Canonical events the provider adapter produced. */
32
+ readonly events: readonly AgentWatchEvent[];
33
+ /**
34
+ * The sentence the platform refused this turn with, when it refused it.
35
+ *
36
+ * Set only by the `enforce` stage and only for an explicit `block`; every
37
+ * failure of that check leaves it absent, which is what makes the turn
38
+ * proceed. Always non-empty when present — the decision schema will not parse
39
+ * a refusal without a message — so its presence *is* the refusal.
40
+ */
41
+ readonly blockMessage?: string;
42
+ /** The turn summary, when this payload closed a turn. */
43
+ readonly summary?: TurnSummaryEvent;
44
+ /** Records this run intends to send; empty on a dry run. */
45
+ readonly outbound: readonly TurnSummaryEvent[];
46
+ /** What delivery did, when it ran. */
47
+ readonly delivery?: DeliveryOutcome;
48
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { SecretPattern } from '../types/privacy.types.js';
2
+ /** Text substituted for anything recognized as a credential. */
3
+ export declare const REDACTED = "[REDACTED]";
4
+ /** Marker for a value nested deeper than the sanitizer will walk. */
5
+ export declare const TRUNCATED = "[TRUNCATED]";
6
+ /**
7
+ * Nesting depth the sanitizer walks before giving up. Untrusted payloads can
8
+ * be arbitrarily deep (or cyclic through structured clones), and the walk runs
9
+ * on the agent's critical path.
10
+ */
11
+ export declare const MAX_DEPTH = 12;
12
+ /** Longest string transmitted; the tail of anything longer is dropped. */
13
+ export declare const MAX_STRING_LENGTH = 8192;
14
+ /** Key names whose values are always redacted regardless of content. */
15
+ export declare const SENSITIVE_KEY_PATTERN: RegExp;
16
+ /**
17
+ * Content patterns for common credentials, applied to every outgoing string.
18
+ *
19
+ * Pre-compiled once at module load: the sanitizer runs over every captured
20
+ * prompt, response and tool payload, so building these inside the function
21
+ * would recompile the whole set per string (STYLEGUIDE 3.1).
22
+ */
23
+ export declare const SECRET_PATTERNS: readonly SecretPattern[];
@@ -0,0 +1,38 @@
1
+ /** Text substituted for anything recognized as a credential. */
2
+ export const REDACTED = '[REDACTED]';
3
+ /** Marker for a value nested deeper than the sanitizer will walk. */
4
+ export const TRUNCATED = '[TRUNCATED]';
5
+ /**
6
+ * Nesting depth the sanitizer walks before giving up. Untrusted payloads can
7
+ * be arbitrarily deep (or cyclic through structured clones), and the walk runs
8
+ * on the agent's critical path.
9
+ */
10
+ export const MAX_DEPTH = 12;
11
+ /** Longest string transmitted; the tail of anything longer is dropped. */
12
+ export const MAX_STRING_LENGTH = 8192;
13
+ /** Key names whose values are always redacted regardless of content. */
14
+ export const SENSITIVE_KEY_PATTERN = /(^|[_.-])(authorization|auth|token|secret|password|passwd|pwd|credential|credentials|api[_-]?key|apikey|access[_-]?key|private[_-]?key|session[_-]?key|cookie|bearer)([_.-]|$)/i;
15
+ /**
16
+ * Content patterns for common credentials, applied to every outgoing string.
17
+ *
18
+ * Pre-compiled once at module load: the sanitizer runs over every captured
19
+ * prompt, response and tool payload, so building these inside the function
20
+ * would recompile the whole set per string (STYLEGUIDE 3.1).
21
+ */
22
+ export const SECRET_PATTERNS = [
23
+ { name: 'private-key-block', pattern: /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g },
24
+ { name: 'url-credentials', pattern: /(\w+:\/\/)([^/\s:@]+)(?::([^/\s@]+))?@/g, replacement: `$1${REDACTED}@` },
25
+ { name: 'aws-access-key', pattern: /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g },
26
+ { name: 'github-token', pattern: /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}\b/g },
27
+ { name: 'github-fine-grained', pattern: /\bgithub_pat_[A-Za-z0-9_]{20,}\b/g },
28
+ { name: 'slack-token', pattern: /\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g },
29
+ { name: 'openai-anthropic-key', pattern: /\bsk-[A-Za-z0-9_-]{16,}\b/g },
30
+ { name: 'google-api-key', pattern: /\bAIza[0-9A-Za-z_-]{30,}\b/g },
31
+ { name: 'jwt', pattern: /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{4,}\b/g },
32
+ { name: 'auth-scheme', pattern: /\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]{8,}/gi, replacement: `$1 ${REDACTED}` },
33
+ {
34
+ name: 'assignment',
35
+ pattern: /\b(password|passwd|pwd|secret|token|api[_-]?key|apikey|access[_-]?key|client[_-]?secret)(\s*[=:]\s*)(["']?)[^\s"'&;]{6,}\3/gi,
36
+ replacement: `$1$2$3${REDACTED}$3`
37
+ }
38
+ ];
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The last gate before anything leaves the machine: known credential shapes
3
+ * are removed from every outgoing value, whatever the capture settings.
4
+ */
5
+ export type { SecretPattern } from './types/privacy.types.js';
6
+ export { REDACTED, SECRET_PATTERNS, SENSITIVE_KEY_PATTERN } from './constants/privacy.constants.js';
7
+ export { sanitizeText, sanitizeValue } from './sanitizer.js';
@@ -0,0 +1,2 @@
1
+ export { REDACTED, SECRET_PATTERNS, SENSITIVE_KEY_PATTERN } from './constants/privacy.constants.js';
2
+ export { sanitizeText, sanitizeValue } from './sanitizer.js';
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Redact known credential shapes inside a string, and cap its length.
3
+ *
4
+ * @param text - Text about to leave the machine.
5
+ * @returns The scrubbed text.
6
+ */
7
+ export declare function sanitizeText(text: string): string;
8
+ /**
9
+ * Recursively sanitize any value before it leaves the machine.
10
+ *
11
+ * Two independent defences, because either alone leaks: a value under a
12
+ * sensitive *key* is dropped whole whatever it looks like, and every string is
13
+ * pattern-scrubbed whatever key it sits under. Both run regardless of the
14
+ * user's capture settings — those decide what we collect, not whether secrets
15
+ * are removed from it.
16
+ *
17
+ * @param value - Value to sanitize; left untouched.
18
+ * @returns A sanitized copy of the same shape.
19
+ */
20
+ export declare function sanitizeValue<T>(value: T): T;
@@ -0,0 +1,52 @@
1
+ import { isRecord } from '../core/object.js';
2
+ import { MAX_DEPTH, MAX_STRING_LENGTH, REDACTED, SECRET_PATTERNS, SENSITIVE_KEY_PATTERN, TRUNCATED } from './constants/privacy.constants.js';
3
+ /**
4
+ * Redact known credential shapes inside a string, and cap its length.
5
+ *
6
+ * @param text - Text about to leave the machine.
7
+ * @returns The scrubbed text.
8
+ */
9
+ export function sanitizeText(text) {
10
+ let out = text.length > MAX_STRING_LENGTH ? text.slice(0, MAX_STRING_LENGTH) : text;
11
+ for (const { pattern, replacement } of SECRET_PATTERNS) {
12
+ out = out.replace(pattern, replacement ?? REDACTED);
13
+ }
14
+ return out;
15
+ }
16
+ /**
17
+ * Recursively sanitize any value before it leaves the machine.
18
+ *
19
+ * Two independent defences, because either alone leaks: a value under a
20
+ * sensitive *key* is dropped whole whatever it looks like, and every string is
21
+ * pattern-scrubbed whatever key it sits under. Both run regardless of the
22
+ * user's capture settings — those decide what we collect, not whether secrets
23
+ * are removed from it.
24
+ *
25
+ * @param value - Value to sanitize; left untouched.
26
+ * @returns A sanitized copy of the same shape.
27
+ */
28
+ export function sanitizeValue(value) {
29
+ return walk(value, 0);
30
+ }
31
+ /**
32
+ * Depth-bounded copy with redaction applied at every level.
33
+ *
34
+ * @param value - Current node.
35
+ * @param depth - Depth of this node.
36
+ * @returns The sanitized node.
37
+ */
38
+ function walk(value, depth) {
39
+ if (depth > MAX_DEPTH)
40
+ return TRUNCATED;
41
+ if (typeof value === 'string')
42
+ return sanitizeText(value);
43
+ if (Array.isArray(value))
44
+ return value.map((item) => walk(item, depth + 1));
45
+ if (!isRecord(value))
46
+ return value;
47
+ const out = {};
48
+ for (const [key, entry] of Object.entries(value)) {
49
+ out[key] = SENSITIVE_KEY_PATTERN.test(key) ? REDACTED : walk(entry, depth + 1);
50
+ }
51
+ return out;
52
+ }
@@ -0,0 +1,13 @@
1
+ /** One credential shape recognized in outgoing text. */
2
+ export interface SecretPattern {
3
+ /** Diagnostic name; never emitted. */
4
+ readonly name: string;
5
+ /** Global pattern, applied with String.prototype.replace. */
6
+ readonly pattern: RegExp;
7
+ /**
8
+ * Replacement template. Omit to blank the whole match; supply one to keep
9
+ * the harmless part (the scheme, the key name) so the redaction stays
10
+ * readable to whoever is debugging.
11
+ */
12
+ readonly replacement?: string;
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,54 @@
1
+ import type { AgentWatchEvent } from '../../events/types/events.types.js';
2
+ import type { HookContext } from '../types/provider.types.js';
3
+ import type { AntigravityHookEvent } from './types/antigravity.types.js';
4
+ export type { AntigravityHookEvent, AntigravityPayload } from './types/antigravity.types.js';
5
+ /**
6
+ * Which hook this payload is.
7
+ *
8
+ * `HookArgs` carries no event-name field: the event is whichever member of its
9
+ * oneof is set. Anything that is not a recognizable `HookArgs` returns
10
+ * undefined, so a schema change shows up as no telemetry rather than as
11
+ * mis-attributed telemetry.
12
+ *
13
+ * @param rawPayload - Raw JSON from the hook's stdin.
14
+ * @returns The hook name, or undefined.
15
+ */
16
+ export declare function antigravityHookEvent(rawPayload: unknown): AntigravityHookEvent | undefined;
17
+ /**
18
+ * Working directory for git and repo-config lookups.
19
+ *
20
+ * Antigravity reports a workspace list rather than a single `cwd`; the first
21
+ * entry is the primary workspace root.
22
+ *
23
+ * @param rawPayload - Raw JSON from the hook's stdin.
24
+ * @returns The primary workspace path, or undefined.
25
+ */
26
+ export declare function antigravityCwd(rawPayload: unknown): string | undefined;
27
+ /**
28
+ * Translate one Antigravity hook payload into canonical events.
29
+ *
30
+ * The two-level execution model matters for attribution: an *execution* is one
31
+ * agent run — the turn — and PreInvocation/PostInvocation bracket the individual
32
+ * model calls inside it. Treating an invocation as a turn boundary would emit
33
+ * one turn summary per model call and inflate every per-turn aggregate, so only
34
+ * `Stop` closes a turn here.
35
+ *
36
+ * @param rawPayload - Raw JSON from the hook's stdin.
37
+ * @param context - Environment and effective config.
38
+ * @returns The canonical events, or an empty list for an unusable payload.
39
+ */
40
+ export declare function parseAntigravityHookEvent(rawPayload: unknown, context: HookContext): AgentWatchEvent[];
41
+ /**
42
+ * The model id behind Antigravity's display name.
43
+ *
44
+ * Exported for the same reason it exists: `Claude Opus 4.6 (Thinking)` is not a
45
+ * model any price list, any other provider's records, or any group-by-model
46
+ * report can match, and the turn it describes is the only place the name
47
+ * appears. This translates the picker's label into the id every other agent
48
+ * reports — and leaves an id that already looks like one untouched, so it is
49
+ * safe to apply to whatever the payload happens to carry.
50
+ *
51
+ * @param displayName - `common.modelName`, as Antigravity wrote it.
52
+ * @returns The canonical id, or undefined when no model was named.
53
+ */
54
+ export declare function canonicalModelName(displayName: string | undefined): string | undefined;