@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,311 @@
1
+ import { sha256Hex } from '../../events/event-id.js';
2
+ import { baseEvent, promptPatch, responsePatch, toolPatch, withPatch } from '../shared/event-builder.js';
3
+ import { classifyTool, parseMcpToolName, toolCompleteType, toolStartType } from '../shared/tooling.js';
4
+ import { ANTIGRAVITY_DISPLAY_NAME, ANTIGRAVITY_HOOK_EVENT_BY_ARGS, ANTIGRAVITY_PROVIDER_ID, DOTLESS_MODEL_FAMILY, RE_MODEL_QUALIFIER, RE_MODEL_VERSION_DOT, RE_MODEL_WHITESPACE } from './constants/antigravity.constants.js';
5
+ import { antigravityPayloadSchema } from './schemas/antigravity.schema.js';
6
+ const ARGS_KEYS = Object.keys(ANTIGRAVITY_HOOK_EVENT_BY_ARGS);
7
+ /**
8
+ * Which hook this payload is.
9
+ *
10
+ * `HookArgs` carries no event-name field: the event is whichever member of its
11
+ * oneof is set. Anything that is not a recognizable `HookArgs` returns
12
+ * undefined, so a schema change shows up as no telemetry rather than as
13
+ * mis-attributed telemetry.
14
+ *
15
+ * @param rawPayload - Raw JSON from the hook's stdin.
16
+ * @returns The hook name, or undefined.
17
+ */
18
+ export function antigravityHookEvent(rawPayload) {
19
+ const parsed = antigravityPayloadSchema.safeParse(rawPayload);
20
+ if (!parsed.success)
21
+ return undefined;
22
+ const key = ARGS_KEYS.find((candidate) => parsed.data[candidate] !== undefined);
23
+ return key ? ANTIGRAVITY_HOOK_EVENT_BY_ARGS[key] : undefined;
24
+ }
25
+ /**
26
+ * Working directory for git and repo-config lookups.
27
+ *
28
+ * Antigravity reports a workspace list rather than a single `cwd`; the first
29
+ * entry is the primary workspace root.
30
+ *
31
+ * @param rawPayload - Raw JSON from the hook's stdin.
32
+ * @returns The primary workspace path, or undefined.
33
+ */
34
+ export function antigravityCwd(rawPayload) {
35
+ const parsed = antigravityPayloadSchema.safeParse(rawPayload);
36
+ if (!parsed.success)
37
+ return undefined;
38
+ return parsed.data.common?.workspacePaths?.[0];
39
+ }
40
+ /**
41
+ * Translate one Antigravity hook payload into canonical events.
42
+ *
43
+ * The two-level execution model matters for attribution: an *execution* is one
44
+ * agent run — the turn — and PreInvocation/PostInvocation bracket the individual
45
+ * model calls inside it. Treating an invocation as a turn boundary would emit
46
+ * one turn summary per model call and inflate every per-turn aggregate, so only
47
+ * `Stop` closes a turn here.
48
+ *
49
+ * @param rawPayload - Raw JSON from the hook's stdin.
50
+ * @param context - Environment and effective config.
51
+ * @returns The canonical events, or an empty list for an unusable payload.
52
+ */
53
+ export function parseAntigravityHookEvent(rawPayload, context) {
54
+ const parsed = antigravityPayloadSchema.safeParse(rawPayload);
55
+ if (!parsed.success)
56
+ return [];
57
+ const payload = parsed.data;
58
+ const hook = antigravityHookEvent(rawPayload);
59
+ if (!hook)
60
+ return [];
61
+ return [withPatch(antigravityBaseEvent(payload, hook), hookPatch(payload, hook, context))];
62
+ }
63
+ /**
64
+ * The model id behind Antigravity's display name.
65
+ *
66
+ * Exported for the same reason it exists: `Claude Opus 4.6 (Thinking)` is not a
67
+ * model any price list, any other provider's records, or any group-by-model
68
+ * report can match, and the turn it describes is the only place the name
69
+ * appears. This translates the picker's label into the id every other agent
70
+ * reports — and leaves an id that already looks like one untouched, so it is
71
+ * safe to apply to whatever the payload happens to carry.
72
+ *
73
+ * @param displayName - `common.modelName`, as Antigravity wrote it.
74
+ * @returns The canonical id, or undefined when no model was named.
75
+ */
76
+ export function canonicalModelName(displayName) {
77
+ if (!displayName)
78
+ return undefined;
79
+ const hyphenated = displayName
80
+ .toLowerCase()
81
+ .replace(RE_MODEL_QUALIFIER, '')
82
+ .trim()
83
+ .replace(RE_MODEL_WHITESPACE, '-');
84
+ if (!hyphenated)
85
+ return undefined;
86
+ if (!hyphenated.startsWith(DOTLESS_MODEL_FAMILY))
87
+ return hyphenated;
88
+ return hyphenated.replace(RE_MODEL_VERSION_DOT, '-');
89
+ }
90
+ /**
91
+ * The provider-independent part of the event.
92
+ *
93
+ * @param payload - Parsed hook payload.
94
+ * @param hook - Which hook fired.
95
+ * @returns The base event.
96
+ */
97
+ function antigravityBaseEvent(payload, hook) {
98
+ const common = payload.common;
99
+ const stepIdx = stepIdxOf(payload, hook);
100
+ const model = canonicalModelName(common?.modelName);
101
+ return baseEvent({
102
+ provider: ANTIGRAVITY_PROVIDER_ID,
103
+ displayName: ANTIGRAVITY_DISPLAY_NAME,
104
+ providerEventType: hook,
105
+ eventType: canonicalType(payload, hook),
106
+ sessionId: common?.conversationId,
107
+ // An execution is the turn: `StopHookArgs.executionNum` numbers executions
108
+ // within a conversation, and Stop fires once per execution.
109
+ turnId: common?.executionId,
110
+ toolUseId: stepIdx,
111
+ payloadFingerprint: sha256Hex(JSON.stringify(fingerprintParts(payload, hook))),
112
+ ai: model ? { model, billingMode: 'unknown' } : undefined,
113
+ providerMetadata: {
114
+ // The picker's own wording, kept beside the id it was translated into: it
115
+ // carries the thinking/effort selection, which the id does not.
116
+ modelDisplayName: common?.modelName,
117
+ transcriptPath: common?.transcriptPath,
118
+ artifactDirectoryPath: common?.artifactDirectoryPath,
119
+ stepIdx,
120
+ isBattleMode: common?.isBattleMode,
121
+ terminationReason: payload.stopHookArgs?.terminationReason,
122
+ fullyIdle: payload.stopHookArgs?.fullyIdle
123
+ },
124
+ timestamp: new Date().toISOString()
125
+ });
126
+ }
127
+ /**
128
+ * What this particular hook contributes on top of the base event.
129
+ *
130
+ * @param payload - Parsed hook payload.
131
+ * @param hook - Which hook fired.
132
+ * @param context - Environment and effective config.
133
+ * @returns The patch; empty for a hook we model but read nothing from.
134
+ */
135
+ function hookPatch(payload, hook, context) {
136
+ if (hook === 'PreInvocation') {
137
+ // Antigravity has no "user prompt submitted" hook: the prompt is carried on
138
+ // `common.lastUserInput` by every hook of the execution. The first
139
+ // invocation is therefore where the turn's prompt is recorded; later
140
+ // invocations are model calls inside the same turn.
141
+ if (!isFirstInvocation(payload.preInvocationHookArgs?.invocationNum))
142
+ return {};
143
+ return promptPatch(payload.common?.lastUserInput ?? '', context.config.capture);
144
+ }
145
+ if (hook === 'PostInvocation') {
146
+ return { metadata: { invocationNum: numeric(payload.postInvocationHookArgs?.invocationNum) } };
147
+ }
148
+ if (hook === 'PreToolUse' || hook === 'PostToolUse')
149
+ return antigravityToolPatch(payload, hook, context);
150
+ if (hook === 'Stop')
151
+ return responsePatch(payload.stopHookArgs?.finalModelOutput ?? '', context.config.capture);
152
+ return {};
153
+ }
154
+ /**
155
+ * Tool fields for one of Antigravity's two tool hooks.
156
+ *
157
+ * @param payload - Parsed hook payload.
158
+ * @param hook - Which of the two fired.
159
+ * @param context - Environment and effective config.
160
+ * @returns The patch.
161
+ */
162
+ function antigravityToolPatch(payload, hook, context) {
163
+ const toolCall = toolCallOf(payload, hook);
164
+ const kind = classifyTool(toolCall?.name);
165
+ const failed = hook === 'PostToolUse' && payload.postToolHookArgs?.error !== undefined;
166
+ const mcp = kind === 'mcp' && toolCall?.name ? parseMcpToolName(toolCall.name) : undefined;
167
+ return toolPatch({
168
+ name: toolCall?.name,
169
+ status: toolStatus(hook, failed),
170
+ kind,
171
+ input: toolCall?.args,
172
+ output: hook === 'PostToolUse' ? payload.postToolHookArgs?.result : undefined,
173
+ error: failed ? payload.postToolHookArgs?.error : undefined,
174
+ providerFields: mcp ? { mcpServer: mcp.server, mcpTool: mcp.tool } : undefined
175
+ }, context.config.capture);
176
+ }
177
+ /**
178
+ * Whether a tool hook reports a start, a failure, or a completion.
179
+ *
180
+ * @param hook - Which of the two tool hooks fired.
181
+ * @param failed - Whether the post-tool payload carried an error.
182
+ * @returns The tool status.
183
+ */
184
+ function toolStatus(hook, failed) {
185
+ if (hook === 'PreToolUse')
186
+ return 'started';
187
+ return failed ? 'failed' : 'completed';
188
+ }
189
+ /**
190
+ * Canonical type for a hook.
191
+ *
192
+ * @param payload - Parsed hook payload.
193
+ * @param hook - Which hook fired.
194
+ * @returns The canonical event type.
195
+ */
196
+ function canonicalType(payload, hook) {
197
+ if (hook === 'SessionStart')
198
+ return 'session.started';
199
+ if (hook === 'Stop')
200
+ return 'generation.completed';
201
+ if (hook === 'PreInvocation') {
202
+ return isFirstInvocation(payload.preInvocationHookArgs?.invocationNum) ? 'prompt.submitted' : 'agent.other';
203
+ }
204
+ if (hook === 'PostInvocation')
205
+ return 'agent.other';
206
+ if (hook === 'PreToolUse')
207
+ return toolStartType(classifyTool(payload.preToolHookArgs?.toolCall?.name));
208
+ if (payload.postToolHookArgs?.error !== undefined)
209
+ return 'tool.failed';
210
+ return toolCompleteType(classifyTool(payload.postToolHookArgs?.toolCall?.name));
211
+ }
212
+ /**
213
+ * Whether an invocation counter names the execution's first model call.
214
+ *
215
+ * The counter's base is not documented, so both 0 and 1 are treated as first. A
216
+ * repeat is harmless: the prompt record is keyed by the event id, which is
217
+ * stable for one execution and one prompt.
218
+ *
219
+ * @param invocationNum - The reported counter, in either proto3 JSON encoding.
220
+ * @returns True when this is the first invocation.
221
+ */
222
+ function isFirstInvocation(invocationNum) {
223
+ const value = numeric(invocationNum);
224
+ return value === undefined || value <= 1;
225
+ }
226
+ /**
227
+ * The tool call one of the tool hooks carries.
228
+ *
229
+ * @param payload - Parsed hook payload.
230
+ * @param hook - Which hook fired.
231
+ * @returns The call, or undefined for a non-tool hook.
232
+ */
233
+ function toolCallOf(payload, hook) {
234
+ if (hook === 'PreToolUse')
235
+ return payload.preToolHookArgs?.toolCall;
236
+ if (hook === 'PostToolUse')
237
+ return payload.postToolHookArgs?.toolCall;
238
+ return undefined;
239
+ }
240
+ /**
241
+ * The step index of a tool hook, as a string id.
242
+ *
243
+ * @param payload - Parsed hook payload.
244
+ * @param hook - Which hook fired.
245
+ * @returns The index, or undefined for a non-tool hook.
246
+ */
247
+ function stepIdxOf(payload, hook) {
248
+ const value = numeric(rawStepIdx(payload, hook));
249
+ return value === undefined ? undefined : String(value);
250
+ }
251
+ /**
252
+ * The step index as the payload encodes it.
253
+ *
254
+ * @param payload - Parsed hook payload.
255
+ * @param hook - Which hook fired.
256
+ * @returns The raw value, or undefined for a non-tool hook.
257
+ */
258
+ function rawStepIdx(payload, hook) {
259
+ if (hook === 'PreToolUse')
260
+ return payload.preToolHookArgs?.stepIdx;
261
+ if (hook === 'PostToolUse')
262
+ return payload.postToolHookArgs?.stepIdx;
263
+ return undefined;
264
+ }
265
+ /**
266
+ * What makes this event distinct from its siblings in the same turn.
267
+ *
268
+ * A prompt is identified by its text and nothing else: the invocation counter's
269
+ * base is undocumented, so the first-invocation test admits both 0 and 1, and
270
+ * including the counter here would give the same prompt two ids and append it to
271
+ * the turn twice. Every other event stays keyed by its own counter, which is
272
+ * what keeps successive invocations and tool calls apart.
273
+ *
274
+ * @param payload - Parsed hook payload.
275
+ * @param hook - Which hook fired.
276
+ * @returns The parts to hash.
277
+ */
278
+ function fingerprintParts(payload, hook) {
279
+ if (hook === 'PreInvocation' && isFirstInvocation(payload.preInvocationHookArgs?.invocationNum)) {
280
+ return ['prompt', payload.common?.lastUserInput ?? ''];
281
+ }
282
+ return [payload.common?.modelName, toolCallOf(payload, hook)?.name, invocationOf(payload, hook)];
283
+ }
284
+ /**
285
+ * The invocation counter of an invocation hook.
286
+ *
287
+ * @param payload - Parsed hook payload.
288
+ * @param hook - Which hook fired.
289
+ * @returns The counter, or undefined for other hooks.
290
+ */
291
+ function invocationOf(payload, hook) {
292
+ if (hook === 'PreInvocation')
293
+ return numeric(payload.preInvocationHookArgs?.invocationNum);
294
+ if (hook === 'PostInvocation')
295
+ return numeric(payload.postInvocationHookArgs?.invocationNum);
296
+ return undefined;
297
+ }
298
+ /**
299
+ * A proto3 JSON integer as a number, whichever encoding it arrived in.
300
+ *
301
+ * @param value - A number or its string form.
302
+ * @returns The finite number, or undefined.
303
+ */
304
+ function numeric(value) {
305
+ if (typeof value === 'number')
306
+ return Number.isFinite(value) ? value : undefined;
307
+ if (typeof value !== 'string' || value.trim() === '')
308
+ return undefined;
309
+ const parsed = Number(value);
310
+ return Number.isFinite(parsed) ? parsed : undefined;
311
+ }
@@ -0,0 +1,25 @@
1
+ import type { Env } from '../../core/types/core.types.js';
2
+ import type { DetectionResult } from '../types/provider.types.js';
3
+ /**
4
+ * Antigravity's configuration root.
5
+ *
6
+ * It shares Gemini's home directory: `~/.gemini/config`.
7
+ *
8
+ * @param env - Environment supplying HOME.
9
+ * @returns Absolute path of the config root.
10
+ */
11
+ export declare function antigravityRoot(env: Env): string;
12
+ /**
13
+ * Where Antigravity reads named hook groups from.
14
+ *
15
+ * @param env - Environment supplying HOME.
16
+ * @returns Absolute path of `hooks.json`.
17
+ */
18
+ export declare function antigravityHooksPath(env: Env): string;
19
+ /**
20
+ * Whether Antigravity is installed here, and whether our hooks are registered.
21
+ *
22
+ * @param env - Environment supplying HOME and PATH.
23
+ * @returns What was found.
24
+ */
25
+ export declare function detectAntigravity(env: Env): Promise<DetectionResult>;
@@ -0,0 +1,64 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { findExecutable } from '../../core/which.js';
4
+ import { readJsonFile } from '../../storage/json-file.js';
5
+ import { HOOK_COMMAND_MARKER } from '../constants/provider.constants.js';
6
+ import { ANTIGRAVITY_CLI_DIR_SEGMENTS, ANTIGRAVITY_EXECUTABLES, ANTIGRAVITY_HOOKS_FILE, ANTIGRAVITY_ROOT_SEGMENTS } from './constants/antigravity.constants.js';
7
+ /**
8
+ * Antigravity's configuration root.
9
+ *
10
+ * It shares Gemini's home directory: `~/.gemini/config`.
11
+ *
12
+ * @param env - Environment supplying HOME.
13
+ * @returns Absolute path of the config root.
14
+ */
15
+ export function antigravityRoot(env) {
16
+ return path.join(env.home, ...ANTIGRAVITY_ROOT_SEGMENTS);
17
+ }
18
+ /**
19
+ * Where Antigravity reads named hook groups from.
20
+ *
21
+ * @param env - Environment supplying HOME.
22
+ * @returns Absolute path of `hooks.json`.
23
+ */
24
+ export function antigravityHooksPath(env) {
25
+ return path.join(antigravityRoot(env), ANTIGRAVITY_HOOKS_FILE);
26
+ }
27
+ /**
28
+ * Whether Antigravity is installed here, and whether our hooks are registered.
29
+ *
30
+ * @param env - Environment supplying HOME and PATH.
31
+ * @returns What was found.
32
+ */
33
+ export async function detectAntigravity(env) {
34
+ const evidence = [];
35
+ if (fs.existsSync(path.join(env.home, ...ANTIGRAVITY_CLI_DIR_SEGMENTS))) {
36
+ evidence.push('~/.gemini/antigravity-cli directory exists');
37
+ }
38
+ const executablePath = findFirstExecutable(env);
39
+ if (executablePath)
40
+ evidence.push(`agy executable on PATH (${executablePath})`);
41
+ const hookConfigPath = antigravityHooksPath(env);
42
+ const read = await readJsonFile(hookConfigPath);
43
+ return {
44
+ detected: evidence.length > 0,
45
+ evidence,
46
+ executablePath,
47
+ hookConfigPath,
48
+ hooksInstalled: read.state === 'ok' && JSON.stringify(read.value).includes(HOOK_COMMAND_MARKER)
49
+ };
50
+ }
51
+ /**
52
+ * The first of Antigravity's executable names found on PATH.
53
+ *
54
+ * @param env - Environment supplying PATH.
55
+ * @returns The path, or undefined when neither is installed.
56
+ */
57
+ function findFirstExecutable(env) {
58
+ for (const name of ANTIGRAVITY_EXECUTABLES) {
59
+ const found = findExecutable(env, name);
60
+ if (found)
61
+ return found;
62
+ }
63
+ return undefined;
64
+ }
@@ -0,0 +1,24 @@
1
+ import type { SetupContext, SetupOutcome } from '../types/provider.types.js';
2
+ export { ANTIGRAVITY_HOOK_EVENTS } from './constants/antigravity.constants.js';
3
+ /**
4
+ * Register AgentWatch's hooks in `~/.gemini/config/hooks.json`.
5
+ *
6
+ * The file is a map of *named* groups, so AgentWatch owns exactly one top-level
7
+ * key and never touches another tool's group.
8
+ *
9
+ * @param context - Environment, paths, config and the hook command to write.
10
+ * @returns Whether the file changed, what to tell the user, and the next
11
+ * install state.
12
+ */
13
+ export declare function installAntigravityHooks(context: SetupContext): Promise<SetupOutcome>;
14
+ /**
15
+ * Remove AgentWatch's hooks from `~/.gemini/config/hooks.json`.
16
+ *
17
+ * Our own group goes wholesale; a group somebody else owns is only filtered, in
18
+ * case an AgentWatch command was hand-added to it.
19
+ *
20
+ * @param context - Environment, paths and current install state.
21
+ * @returns Whether the file changed, what to tell the user, and the next
22
+ * install state.
23
+ */
24
+ export declare function uninstallAntigravityHooks(context: SetupContext): Promise<SetupOutcome>;
@@ -0,0 +1,126 @@
1
+ import { asRecord, omitKeys } from '../../core/object.js';
2
+ import { backupFile } from '../../storage/atomic-file.js';
3
+ import { readJsonFile } from '../../storage/json-file.js';
4
+ import { registerOurHandlers, stripOurHandlers, sweepUnregisteredEvents, writeJsonValidated } from '../shared/hook-config.js';
5
+ import { withHookInstall, withoutAgent } from '../shared/install-record.js';
6
+ import { antigravityHooksPath } from './antigravity.detect.js';
7
+ import { ANTIGRAVITY_GROUP_NAME, ANTIGRAVITY_HOOK_EVENTS, ANTIGRAVITY_HOOK_TIMEOUT_MILLISECONDS, ANTIGRAVITY_MATCHED_EVENTS, ANTIGRAVITY_PROVIDER_ID } from './constants/antigravity.constants.js';
8
+ export { ANTIGRAVITY_HOOK_EVENTS } from './constants/antigravity.constants.js';
9
+ /** Antigravity accepts a bare handler as well as a matcher group. */
10
+ const STRIP_OPTIONS = { allowBareHandlers: true };
11
+ /**
12
+ * Register AgentWatch's hooks in `~/.gemini/config/hooks.json`.
13
+ *
14
+ * The file is a map of *named* groups, so AgentWatch owns exactly one top-level
15
+ * key and never touches another tool's group.
16
+ *
17
+ * @param context - Environment, paths, config and the hook command to write.
18
+ * @returns Whether the file changed, what to tell the user, and the next
19
+ * install state.
20
+ */
21
+ export async function installAntigravityHooks(context) {
22
+ const target = antigravityHooksPath(context.env);
23
+ const read = await readJsonFile(target);
24
+ if (read.state === 'invalid') {
25
+ return { ok: false, changed: false, messages: [`refusing to modify unparseable ${target} (${read.error})`] };
26
+ }
27
+ if (read.state === 'ok' && !asRecord(read.value)) {
28
+ return { ok: false, changed: false, messages: [`refusing to modify ${target}: top level is not an object`] };
29
+ }
30
+ const file = (read.state === 'ok' ? asRecord(read.value) : undefined) ?? {};
31
+ const group = asRecord(file[ANTIGRAVITY_GROUP_NAME]) ?? {};
32
+ const registered = registerOurHandlers(group, ANTIGRAVITY_HOOK_EVENTS, hookEntryFor(context.hookCommand), STRIP_OPTIONS);
33
+ const nextFile = {
34
+ ...file,
35
+ [ANTIGRAVITY_GROUP_NAME]: sweepUnregisteredEvents(registered, ANTIGRAVITY_HOOK_EVENTS, STRIP_OPTIONS)
36
+ };
37
+ const changed = JSON.stringify(nextFile) !== JSON.stringify(file);
38
+ if (changed) {
39
+ await backupFile(target, context.paths.backupsDir, context.env.now());
40
+ await writeJsonValidated(target, nextFile);
41
+ }
42
+ return {
43
+ ok: true,
44
+ changed,
45
+ messages: [
46
+ changed ? `hooks registered in ${target}` : 'hooks already registered',
47
+ ...(changed ? ['restart running Antigravity sessions to pick them up'] : [])
48
+ ],
49
+ installState: withHookInstall(context.installState, ANTIGRAVITY_PROVIDER_ID, {
50
+ hookConfigPath: target,
51
+ hookEvents: ANTIGRAVITY_HOOK_EVENTS,
52
+ hookCommand: context.hookCommand,
53
+ installedAt: context.env.now()
54
+ })
55
+ };
56
+ }
57
+ /**
58
+ * Remove AgentWatch's hooks from `~/.gemini/config/hooks.json`.
59
+ *
60
+ * Our own group goes wholesale; a group somebody else owns is only filtered, in
61
+ * case an AgentWatch command was hand-added to it.
62
+ *
63
+ * @param context - Environment, paths and current install state.
64
+ * @returns Whether the file changed, what to tell the user, and the next
65
+ * install state.
66
+ */
67
+ export async function uninstallAntigravityHooks(context) {
68
+ const target = antigravityHooksPath(context.env);
69
+ const read = await readJsonFile(target);
70
+ const forgotten = withoutAgent(context.installState, ANTIGRAVITY_PROVIDER_ID);
71
+ if (read.state === 'missing') {
72
+ return { ok: true, changed: false, messages: ['no Antigravity hooks file'], installState: forgotten };
73
+ }
74
+ if (read.state === 'invalid') {
75
+ return { ok: false, changed: false, messages: [`refusing to modify unparseable ${target} (${read.error})`] };
76
+ }
77
+ const file = asRecord(read.value);
78
+ if (!file) {
79
+ return { ok: false, changed: false, messages: [`refusing to modify ${target}: top level is not an object`] };
80
+ }
81
+ const nextFile = strippedGroups(file);
82
+ const changed = JSON.stringify(nextFile) !== JSON.stringify(file);
83
+ if (changed) {
84
+ await backupFile(target, context.paths.backupsDir, context.env.now());
85
+ await writeJsonValidated(target, nextFile);
86
+ }
87
+ return {
88
+ ok: true,
89
+ changed,
90
+ messages: [changed ? 'AgentWatch hooks removed' : 'no AgentWatch hooks found'],
91
+ installState: forgotten
92
+ };
93
+ }
94
+ /**
95
+ * Every group with our handlers removed, and emptied groups dropped.
96
+ *
97
+ * @param file - The whole hooks file.
98
+ * @returns The next file contents.
99
+ */
100
+ function strippedGroups(file) {
101
+ const emptied = new Set();
102
+ const next = { ...file };
103
+ for (const [name, value] of Object.entries(file)) {
104
+ const group = asRecord(value);
105
+ if (!group)
106
+ continue;
107
+ const stripped = stripOurHandlers(group, STRIP_OPTIONS).hooks;
108
+ if (Object.keys(stripped).length === 0) {
109
+ emptied.add(name);
110
+ continue;
111
+ }
112
+ next[name] = stripped;
113
+ }
114
+ return omitKeys(next, emptied);
115
+ }
116
+ /**
117
+ * Our entry for one event: a matcher group for tool events, a bare handler
118
+ * otherwise — both shapes Antigravity accepts.
119
+ *
120
+ * @param hookCommand - Command line agents will invoke.
121
+ * @returns A factory producing the entry for a given event name.
122
+ */
123
+ function hookEntryFor(hookCommand) {
124
+ const handler = { type: 'command', command: hookCommand, timeout: ANTIGRAVITY_HOOK_TIMEOUT_MILLISECONDS };
125
+ return (eventName) => (ANTIGRAVITY_MATCHED_EVENTS.has(eventName) ? { matcher: '*', hooks: [handler] } : handler);
126
+ }
@@ -0,0 +1,2 @@
1
+ import type { AgentProvider } from '../types/provider.types.js';
2
+ export declare const antigravityProvider: AgentProvider;
@@ -0,0 +1,22 @@
1
+ import { antigravityCwd, antigravityHookEvent, parseAntigravityHookEvent } from './antigravity.adapter.js';
2
+ import { detectAntigravity } from './antigravity.detect.js';
3
+ import { installAntigravityHooks, uninstallAntigravityHooks } from './antigravity.hooks.js';
4
+ import { ANTIGRAVITY_DISPLAY_NAME, ANTIGRAVITY_FALLBACK_DECISION, ANTIGRAVITY_HOOK_DECISIONS, ANTIGRAVITY_PROVIDER_ID } from './constants/antigravity.constants.js';
5
+ export const antigravityProvider = {
6
+ id: ANTIGRAVITY_PROVIDER_ID,
7
+ displayName: ANTIGRAVITY_DISPLAY_NAME,
8
+ detect: detectAntigravity,
9
+ installHooks: installAntigravityHooks,
10
+ uninstallHooks: uninstallAntigravityHooks,
11
+ parseHookEvent: async (payload, context) => parseAntigravityHookEvent(payload, context),
12
+ getHookResponse: (payload) => {
13
+ const hook = antigravityHookEvent(payload);
14
+ const decision = hook === undefined ? ANTIGRAVITY_FALLBACK_DECISION : ANTIGRAVITY_HOOK_DECISIONS[hook];
15
+ return { stdout: JSON.stringify(decision ?? {}), exitCode: 0 };
16
+ },
17
+ resolveCwd: antigravityCwd
18
+ // No nativeTelemetry: Antigravity exposes no OTLP exporter configuration, so
19
+ // there is no llm.call ledger source and turn summaries stay
20
+ // usage_status=pending. Adding a configurator would claim a capability the
21
+ // agent does not have.
22
+ };
@@ -0,0 +1,72 @@
1
+ export declare const ANTIGRAVITY_PROVIDER_ID = "antigravity";
2
+ export declare const ANTIGRAVITY_DISPLAY_NAME = "Google Antigravity";
3
+ /** Antigravity shares Gemini's home; its own config lives one level down. */
4
+ export declare const ANTIGRAVITY_ROOT_SEGMENTS: readonly [".gemini", "config"];
5
+ export declare const ANTIGRAVITY_CLI_DIR_SEGMENTS: readonly [".gemini", "antigravity-cli"];
6
+ export declare const ANTIGRAVITY_HOOKS_FILE = "hooks.json";
7
+ export declare const ANTIGRAVITY_EXECUTABLES: readonly ["agy", "antigravity"];
8
+ /**
9
+ * Antigravity reads `~/.gemini/config/hooks.json` as a map of *named* hook
10
+ * groups — its log line is "loaded N named hooks from N hooks.json file(s)" — so
11
+ * AgentWatch owns exactly one top-level key and never touches another tool's
12
+ * group.
13
+ */
14
+ export declare const ANTIGRAVITY_GROUP_NAME = "agentwatch";
15
+ export declare const ANTIGRAVITY_HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PreInvocation", "PostInvocation", "Stop"];
16
+ /** Tool-scoped events take a matcher; the rest are plain handler lists. */
17
+ export declare const ANTIGRAVITY_MATCHED_EVENTS: ReadonlySet<string>;
18
+ /**
19
+ * `HookHandlerConfig.timeout` carries no unit suffix, and Gemini CLI — the same
20
+ * Google hook runner — reads the field as milliseconds with a 60,000 default. A
21
+ * bare `30` there timed every AgentWatch hook out before node could start; see
22
+ * the identical constant in gemini.constants.ts. Milliseconds is also the safe
23
+ * reading of the two: an over-large upper bound costs nothing, because the hook
24
+ * exits in well under a second either way.
25
+ */
26
+ export declare const ANTIGRAVITY_HOOK_TIMEOUT_MILLISECONDS = 30000;
27
+ /**
28
+ * The decision each hook result must carry.
29
+ *
30
+ * `decision` is a required field of both `PreToolHookResult` and
31
+ * `StopHookResult`, and Antigravity has a dedicated `PreToolHookDeniedError`
32
+ * for a pre-tool hook that does not answer. A single `{}` for every hook — the
33
+ * previous behavior — therefore did not merely fail to observe: it blocked every
34
+ * tool call the agent tried to make. The remaining result messages
35
+ * (`PostToolHookResult`, the invocation hooks, `SessionStartHookResult`) carry
36
+ * no decision, so silence is correct for those.
37
+ */
38
+ export declare const ANTIGRAVITY_HOOK_DECISIONS: Readonly<Record<string, Readonly<Record<string, string>>>>;
39
+ /**
40
+ * Answer used for a payload we cannot classify at all.
41
+ *
42
+ * A pre-tool allow: the one payload shape we cannot read is also the one where
43
+ * staying silent would stall the agent, and telemetry must never do that.
44
+ */
45
+ export declare const ANTIGRAVITY_FALLBACK_DECISION: Readonly<Record<string, string>>;
46
+ /**
47
+ * Antigravity names its model the way its picker shows it — `Claude Opus 4.6
48
+ * (Thinking)`, `Gemini 3 Pro (High)` — not the way an API does. Every other
49
+ * agent reports a model *id*, so a display name reaches the backend as a model
50
+ * nobody has a price for and as a second name for a model the ledger already
51
+ * knows under its id. The patterns below turn one into the other.
52
+ */
53
+ /** Trailing selector the picker appends: `(Thinking)`, `(High)`, `(Fast)`. */
54
+ export declare const RE_MODEL_QUALIFIER: RegExp;
55
+ /** Any run of whitespace, which in an id is a single hyphen. */
56
+ export declare const RE_MODEL_WHITESPACE: RegExp;
57
+ /**
58
+ * Anthropic writes a version as `claude-opus-4-6`; Google and OpenAI keep the
59
+ * dot (`gemini-3.1-pro`, `gpt-5.2`). Converting dots for everyone would invent
60
+ * `gemini-3-1-pro`, which matches no price and no other row in the ledger.
61
+ */
62
+ export declare const RE_MODEL_VERSION_DOT: RegExp;
63
+ export declare const DOTLESS_MODEL_FAMILY = "claude";
64
+ /** oneof member of `HookArgs` -> the hook Antigravity fired, in hooks.json naming. */
65
+ export declare const ANTIGRAVITY_HOOK_EVENT_BY_ARGS: {
66
+ readonly preToolHookArgs: "PreToolUse";
67
+ readonly postToolHookArgs: "PostToolUse";
68
+ readonly preInvocationHookArgs: "PreInvocation";
69
+ readonly postInvocationHookArgs: "PostInvocation";
70
+ readonly stopHookArgs: "Stop";
71
+ readonly sessionStartHookArgs: "SessionStart";
72
+ };