@agent-watch-ai/edge 0.2.5 → 0.4.0

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 (348) hide show
  1. package/CHANGELOG.md +558 -0
  2. package/README.md +222 -97
  3. package/SECURITY.md +72 -0
  4. package/dist/billing/session-billing.d.ts +19 -0
  5. package/dist/billing/session-billing.js +52 -0
  6. package/dist/cli/args.d.ts +10 -0
  7. package/dist/cli/args.js +20 -0
  8. package/dist/cli/constants/cli.constants.d.ts +52 -4
  9. package/dist/cli/constants/cli.constants.js +56 -5
  10. package/dist/cli/context.d.ts +33 -2
  11. package/dist/cli/context.js +84 -14
  12. package/dist/cli/doctor.js +321 -33
  13. package/dist/cli/hook-check.d.ts +23 -0
  14. package/dist/cli/hook-check.js +114 -0
  15. package/dist/cli/hook.js +118 -7
  16. package/dist/cli/index.d.ts +3 -1
  17. package/dist/cli/index.js +3 -1
  18. package/dist/cli/misc.d.ts +11 -0
  19. package/dist/cli/misc.js +80 -4
  20. package/dist/cli/npx-install.d.ts +37 -0
  21. package/dist/cli/npx-install.js +79 -0
  22. package/dist/cli/open-browser.d.ts +39 -0
  23. package/dist/cli/open-browser.js +62 -0
  24. package/dist/cli/setup.d.ts +17 -8
  25. package/dist/cli/setup.js +553 -103
  26. package/dist/cli/status.js +82 -13
  27. package/dist/cli/toggle.d.ts +9 -0
  28. package/dist/cli/toggle.js +117 -0
  29. package/dist/cli/types/cli.types.d.ts +43 -3
  30. package/dist/cli/ui.d.ts +7 -0
  31. package/dist/cli/ui.js +10 -1
  32. package/dist/cli/uninstall.js +39 -2
  33. package/dist/cli/update.d.ts +17 -0
  34. package/dist/cli/update.js +76 -0
  35. package/dist/cli.js +110 -12
  36. package/dist/config/config-store.d.ts +57 -0
  37. package/dist/config/config-store.js +250 -12
  38. package/dist/config/config.d.ts +53 -6
  39. package/dist/config/config.js +66 -6
  40. package/dist/config/constants/config.constants.d.ts +116 -6
  41. package/dist/config/constants/config.constants.js +131 -8
  42. package/dist/config/destination.d.ts +24 -0
  43. package/dist/config/destination.js +33 -0
  44. package/dist/config/index.d.ts +7 -4
  45. package/dist/config/index.js +5 -3
  46. package/dist/config/repo-config.d.ts +11 -7
  47. package/dist/config/repo-config.js +64 -15
  48. package/dist/config/root-config.d.ts +72 -0
  49. package/dist/config/root-config.js +170 -0
  50. package/dist/config/schemas/config.schema.d.ts +831 -84
  51. package/dist/config/schemas/config.schema.js +398 -16
  52. package/dist/config/types/config.types.d.ts +15 -1
  53. package/dist/config/types/destination.types.d.ts +8 -0
  54. package/dist/core/async.d.ts +36 -0
  55. package/dist/core/async.js +68 -0
  56. package/dist/core/index.d.ts +1 -1
  57. package/dist/core/index.js +1 -1
  58. package/dist/core/object.d.ts +5 -0
  59. package/dist/core/object.js +9 -4
  60. package/dist/core/pipe.d.ts +0 -13
  61. package/dist/core/pipe.js +1 -9
  62. package/dist/core/types/core.types.d.ts +9 -0
  63. package/dist/core/types/core.types.js +0 -3
  64. package/dist/core/which.d.ts +14 -0
  65. package/dist/core/which.js +43 -3
  66. package/dist/credentials/budget.d.ts +9 -0
  67. package/dist/credentials/budget.js +16 -0
  68. package/dist/credentials/command-runner.d.ts +16 -0
  69. package/dist/credentials/command-runner.js +37 -0
  70. package/dist/credentials/constants/credentials.constants.d.ts +119 -0
  71. package/dist/credentials/constants/credentials.constants.js +120 -0
  72. package/dist/credentials/credential-status.d.ts +14 -0
  73. package/dist/credentials/credential-status.js +38 -0
  74. package/dist/credentials/credentials.d.ts +86 -0
  75. package/dist/credentials/credentials.js +278 -0
  76. package/dist/credentials/device-api.d.ts +73 -0
  77. package/dist/credentials/device-api.js +161 -0
  78. package/dist/credentials/device-state.d.ts +31 -0
  79. package/dist/credentials/device-state.js +51 -0
  80. package/dist/credentials/identity.d.ts +73 -0
  81. package/dist/credentials/identity.js +101 -0
  82. package/dist/credentials/index.d.ts +7 -0
  83. package/dist/credentials/index.js +5 -0
  84. package/dist/credentials/migration.d.ts +46 -0
  85. package/dist/credentials/migration.js +164 -0
  86. package/dist/credentials/schemas/device-api.schema.d.ts +77 -0
  87. package/dist/credentials/schemas/device-api.schema.js +33 -0
  88. package/dist/credentials/schemas/device-state.schema.d.ts +51 -0
  89. package/dist/credentials/schemas/device-state.schema.js +20 -0
  90. package/dist/credentials/secret-store.d.ts +54 -0
  91. package/dist/credentials/secret-store.js +217 -0
  92. package/dist/credentials/sign-in.d.ts +31 -0
  93. package/dist/credentials/sign-in.js +105 -0
  94. package/dist/credentials/token-refresher.d.ts +39 -0
  95. package/dist/credentials/token-refresher.js +185 -0
  96. package/dist/credentials/types/credentials.types.d.ts +206 -0
  97. package/dist/credentials/types/credentials.types.js +1 -0
  98. package/dist/enforcement/constants/enforcement.constants.d.ts +47 -1
  99. package/dist/enforcement/constants/enforcement.constants.js +56 -0
  100. package/dist/enforcement/decision-cache.d.ts +20 -1
  101. package/dist/enforcement/decision-cache.js +65 -2
  102. package/dist/enforcement/decision-client.d.ts +9 -8
  103. package/dist/enforcement/decision-client.js +64 -17
  104. package/dist/enforcement/enforcement.d.ts +23 -2
  105. package/dist/enforcement/enforcement.js +107 -17
  106. package/dist/enforcement/index.d.ts +4 -3
  107. package/dist/enforcement/index.js +3 -2
  108. package/dist/enforcement/types/enforcement.types.d.ts +66 -2
  109. package/dist/enrollment/constants/enrollment.constants.d.ts +2 -6
  110. package/dist/enrollment/constants/enrollment.constants.js +2 -6
  111. package/dist/enrollment/enrollment.d.ts +16 -0
  112. package/dist/enrollment/enrollment.js +54 -0
  113. package/dist/enrollment/index.d.ts +3 -7
  114. package/dist/enrollment/index.js +1 -1
  115. package/dist/enrollment/types/enrollment.types.d.ts +9 -13
  116. package/dist/events/constants/enrich.constants.d.ts +15 -0
  117. package/dist/events/constants/enrich.constants.js +15 -0
  118. package/dist/events/constants/events.constants.d.ts +6 -2
  119. package/dist/events/constants/events.constants.js +5 -1
  120. package/dist/events/enrich.js +92 -10
  121. package/dist/events/event-id.d.ts +0 -8
  122. package/dist/events/event-id.js +0 -10
  123. package/dist/events/index.d.ts +2 -2
  124. package/dist/events/index.js +1 -1
  125. package/dist/events/product-event.d.ts +9 -6
  126. package/dist/events/types/repo-snapshot.types.d.ts +7 -0
  127. package/dist/events/types/session-billing.types.d.ts +16 -0
  128. package/dist/events/types/session-billing.types.js +1 -0
  129. package/dist/feature/constants/feature.constants.d.ts +7 -0
  130. package/dist/feature/constants/feature.constants.js +7 -0
  131. package/dist/feature/index.d.ts +1 -1
  132. package/dist/feature/index.js +1 -1
  133. package/dist/feature/ticket-candidates.d.ts +14 -0
  134. package/dist/feature/ticket-candidates.js +26 -8
  135. package/dist/git/blob-hash.d.ts +21 -0
  136. package/dist/git/blob-hash.js +69 -0
  137. package/dist/git/checkout-root.d.ts +27 -0
  138. package/dist/git/checkout-root.js +75 -0
  139. package/dist/git/constants/git.constants.d.ts +160 -0
  140. package/dist/git/constants/git.constants.js +181 -0
  141. package/dist/git/fingerprint.d.ts +74 -0
  142. package/dist/git/fingerprint.js +219 -0
  143. package/dist/git/gate-checkout.d.ts +44 -0
  144. package/dist/git/gate-checkout.js +201 -0
  145. package/dist/git/git-context.d.ts +45 -0
  146. package/dist/git/git-context.js +61 -3
  147. package/dist/git/index.d.ts +4 -2
  148. package/dist/git/index.js +2 -1
  149. package/dist/git/manifest-repository.d.ts +13 -0
  150. package/dist/git/manifest-repository.js +92 -0
  151. package/dist/git/repo-snapshot.d.ts +29 -3
  152. package/dist/git/repo-snapshot.js +110 -7
  153. package/dist/git/repository-root.d.ts +39 -0
  154. package/dist/git/repository-root.js +131 -0
  155. package/dist/git/types/git.types.d.ts +55 -0
  156. package/dist/git/types/repository-root.types.d.ts +11 -0
  157. package/dist/git/types/repository-root.types.js +1 -0
  158. package/dist/git/types/snapshot.types.d.ts +9 -0
  159. package/dist/pipeline/constants/pipeline.constants.d.ts +10 -0
  160. package/dist/pipeline/constants/pipeline.constants.js +10 -0
  161. package/dist/pipeline/hook-pipeline.js +410 -33
  162. package/dist/pipeline/types/pipeline.types.d.ts +39 -4
  163. package/dist/privacy/constants/privacy.constants.js +15 -1
  164. package/dist/privacy/index.d.ts +1 -0
  165. package/dist/privacy/index.js +1 -0
  166. package/dist/privacy/product-capture.d.ts +12 -0
  167. package/dist/privacy/product-capture.js +75 -0
  168. package/dist/privacy/sanitizer.d.ts +21 -3
  169. package/dist/privacy/sanitizer.js +52 -8
  170. package/dist/process/ancestors.d.ts +39 -0
  171. package/dist/process/ancestors.js +121 -0
  172. package/dist/process/constants/process.constants.d.ts +34 -0
  173. package/dist/process/constants/process.constants.js +34 -0
  174. package/dist/process/index.d.ts +7 -0
  175. package/dist/process/index.js +2 -0
  176. package/dist/process/types/process.types.d.ts +23 -0
  177. package/dist/process/types/process.types.js +1 -0
  178. package/dist/providers/antigravity/antigravity.adapter.d.ts +12 -1
  179. package/dist/providers/antigravity/antigravity.adapter.js +21 -3
  180. package/dist/providers/antigravity/antigravity.detect.d.ts +0 -9
  181. package/dist/providers/antigravity/antigravity.detect.js +1 -1
  182. package/dist/providers/antigravity/antigravity.provider.js +3 -2
  183. package/dist/providers/antigravity/constants/antigravity.constants.d.ts +2 -0
  184. package/dist/providers/antigravity/constants/antigravity.constants.js +2 -0
  185. package/dist/providers/claude/claude.adapter.d.ts +11 -1
  186. package/dist/providers/claude/claude.adapter.js +26 -5
  187. package/dist/providers/claude/claude.otel.d.ts +32 -18
  188. package/dist/providers/claude/claude.otel.js +81 -6
  189. package/dist/providers/claude/claude.provider.js +5 -2
  190. package/dist/providers/claude/constants/claude.constants.d.ts +2 -0
  191. package/dist/providers/claude/constants/claude.constants.js +2 -0
  192. package/dist/providers/claude/constants/claude.otel.constants.d.ts +4 -0
  193. package/dist/providers/claude/constants/claude.otel.constants.js +8 -0
  194. package/dist/providers/codex/codex.adapter.d.ts +15 -1
  195. package/dist/providers/codex/codex.adapter.js +29 -5
  196. package/dist/providers/codex/codex.otel.d.ts +36 -3
  197. package/dist/providers/codex/codex.otel.js +199 -32
  198. package/dist/providers/codex/codex.provider.js +5 -2
  199. package/dist/providers/codex/constants/codex.constants.d.ts +2 -0
  200. package/dist/providers/codex/constants/codex.constants.js +16 -0
  201. package/dist/providers/codex/constants/codex.otel.constants.d.ts +10 -0
  202. package/dist/providers/codex/constants/codex.otel.constants.js +10 -0
  203. package/dist/providers/constants/provider.constants.d.ts +8 -3
  204. package/dist/providers/constants/provider.constants.js +8 -3
  205. package/dist/providers/cursor/constants/cursor.constants.d.ts +9 -0
  206. package/dist/providers/cursor/constants/cursor.constants.js +9 -0
  207. package/dist/providers/cursor/cursor.adapter.d.ts +33 -1
  208. package/dist/providers/cursor/cursor.adapter.js +129 -4
  209. package/dist/providers/cursor/cursor.detect.d.ts +0 -7
  210. package/dist/providers/cursor/cursor.detect.js +1 -1
  211. package/dist/providers/cursor/cursor.provider.js +5 -2
  212. package/dist/providers/gemini/constants/gemini.constants.d.ts +9 -0
  213. package/dist/providers/gemini/constants/gemini.constants.js +9 -0
  214. package/dist/providers/gemini/constants/gemini.otel.constants.d.ts +9 -1
  215. package/dist/providers/gemini/constants/gemini.otel.constants.js +9 -0
  216. package/dist/providers/gemini/gemini.adapter.d.ts +14 -1
  217. package/dist/providers/gemini/gemini.adapter.js +25 -5
  218. package/dist/providers/gemini/gemini.detect.d.ts +0 -7
  219. package/dist/providers/gemini/gemini.detect.js +1 -1
  220. package/dist/providers/gemini/gemini.otel.d.ts +30 -21
  221. package/dist/providers/gemini/gemini.otel.js +166 -22
  222. package/dist/providers/gemini/gemini.provider.js +2 -1
  223. package/dist/providers/index.d.ts +1 -1
  224. package/dist/providers/index.js +1 -1
  225. package/dist/providers/loaders.d.ts +10 -0
  226. package/dist/providers/loaders.js +40 -0
  227. package/dist/providers/provider.d.ts +11 -0
  228. package/dist/providers/provider.js +1 -1
  229. package/dist/providers/registry.d.ts +11 -8
  230. package/dist/providers/registry.js +11 -15
  231. package/dist/providers/shared/bearer-rewrite.d.ts +19 -0
  232. package/dist/providers/shared/bearer-rewrite.js +46 -0
  233. package/dist/providers/shared/constants/hook-refusal.constants.d.ts +7 -0
  234. package/dist/providers/shared/constants/hook-refusal.constants.js +7 -0
  235. package/dist/providers/shared/constants/shell-directories.constants.d.ts +30 -0
  236. package/dist/providers/shared/constants/shell-directories.constants.js +39 -0
  237. package/dist/providers/shared/constants/tooling.constants.d.ts +24 -2
  238. package/dist/providers/shared/constants/tooling.constants.js +25 -3
  239. package/dist/providers/shared/event-builder.d.ts +12 -14
  240. package/dist/providers/shared/event-builder.js +20 -14
  241. package/dist/providers/shared/exporter-allowlist.d.ts +20 -0
  242. package/dist/providers/shared/exporter-allowlist.js +49 -0
  243. package/dist/providers/shared/hook-config.d.ts +2 -21
  244. package/dist/providers/shared/hook-config.js +5 -4
  245. package/dist/providers/shared/hook-refusal.d.ts +12 -0
  246. package/dist/providers/shared/hook-refusal.js +17 -1
  247. package/dist/providers/shared/install-record.d.ts +12 -2
  248. package/dist/providers/shared/install-record.js +5 -2
  249. package/dist/providers/shared/shell-directories.d.ts +24 -0
  250. package/dist/providers/shared/shell-directories.js +90 -0
  251. package/dist/providers/shared/tooling.d.ts +40 -1
  252. package/dist/providers/shared/tooling.js +70 -1
  253. package/dist/providers/shared/types/adapter.types.d.ts +1 -2
  254. package/dist/providers/types/provider.types.d.ts +81 -1
  255. package/dist/snapshot/constants/snapshot.constants.d.ts +32 -0
  256. package/dist/snapshot/constants/snapshot.constants.js +33 -0
  257. package/dist/snapshot/snapshot-event.js +52 -11
  258. package/dist/snapshot/snapshot-pipeline.js +1 -1
  259. package/dist/snapshot/types/snapshot.types.d.ts +2 -0
  260. package/dist/storage/atomic-file.d.ts +21 -0
  261. package/dist/storage/atomic-file.js +20 -1
  262. package/dist/storage/constants/storage.constants.d.ts +19 -0
  263. package/dist/storage/constants/storage.constants.js +19 -0
  264. package/dist/storage/disabled.d.ts +13 -0
  265. package/dist/storage/disabled.js +24 -0
  266. package/dist/storage/index.d.ts +2 -0
  267. package/dist/storage/index.js +2 -0
  268. package/dist/storage/paths.js +3 -2
  269. package/dist/storage/schemas/storage.schema.d.ts +72 -0
  270. package/dist/storage/schemas/storage.schema.js +6 -0
  271. package/dist/storage/sweep-marker.d.ts +19 -0
  272. package/dist/storage/sweep-marker.js +55 -0
  273. package/dist/storage/types/storage.types.d.ts +2 -0
  274. package/dist/storage/uninstalled.d.ts +58 -0
  275. package/dist/storage/uninstalled.js +107 -0
  276. package/dist/transport/auth-block.d.ts +66 -0
  277. package/dist/transport/auth-block.js +129 -0
  278. package/dist/transport/constants/transport.constants.d.ts +82 -3
  279. package/dist/transport/constants/transport.constants.js +83 -4
  280. package/dist/transport/cooldown.js +8 -1
  281. package/dist/transport/delivery.d.ts +14 -6
  282. package/dist/transport/delivery.js +80 -55
  283. package/dist/transport/http-transport.d.ts +1 -0
  284. package/dist/transport/http-transport.js +52 -10
  285. package/dist/transport/index.d.ts +6 -3
  286. package/dist/transport/index.js +3 -0
  287. package/dist/transport/queue-partition.d.ts +91 -0
  288. package/dist/transport/queue-partition.js +143 -0
  289. package/dist/transport/queue.d.ts +99 -20
  290. package/dist/transport/queue.js +210 -69
  291. package/dist/transport/response-body.d.ts +25 -0
  292. package/dist/transport/response-body.js +64 -0
  293. package/dist/transport/send.d.ts +11 -0
  294. package/dist/transport/send.js +17 -0
  295. package/dist/transport/types/delivery-flow.types.d.ts +19 -0
  296. package/dist/transport/types/delivery-flow.types.js +1 -0
  297. package/dist/transport/types/transport.types.d.ts +45 -0
  298. package/dist/turns/claude-transcript.d.ts +19 -1
  299. package/dist/turns/claude-transcript.js +46 -1
  300. package/dist/turns/codex-originator.d.ts +11 -0
  301. package/dist/turns/codex-originator.js +31 -0
  302. package/dist/turns/codex-transcript.d.ts +30 -0
  303. package/dist/turns/codex-transcript.js +88 -0
  304. package/dist/turns/constants/turns.constants.d.ts +141 -5
  305. package/dist/turns/constants/turns.constants.js +155 -5
  306. package/dist/turns/file-identity.d.ts +27 -0
  307. package/dist/turns/file-identity.js +48 -0
  308. package/dist/turns/gemini-transcript.d.ts +30 -0
  309. package/dist/turns/gemini-transcript.js +96 -0
  310. package/dist/turns/index.d.ts +3 -3
  311. package/dist/turns/index.js +1 -1
  312. package/dist/turns/inherited-checkout.d.ts +54 -0
  313. package/dist/turns/inherited-checkout.js +155 -0
  314. package/dist/turns/native-session-titles.d.ts +26 -0
  315. package/dist/turns/native-session-titles.js +102 -0
  316. package/dist/turns/transcript.d.ts +3 -2
  317. package/dist/turns/transcript.js +5 -1
  318. package/dist/turns/turn-state.d.ts +224 -3
  319. package/dist/turns/turn-state.js +456 -21
  320. package/dist/turns/turn-summary.d.ts +1 -14
  321. package/dist/turns/turn-summary.js +87 -51
  322. package/dist/turns/turn-tracker.d.ts +21 -2
  323. package/dist/turns/turn-tracker.js +379 -56
  324. package/dist/turns/types/transcript.types.d.ts +5 -0
  325. package/dist/turns/types/turn-state.types.d.ts +116 -5
  326. package/dist/turns/types/turn-summary.types.d.ts +64 -14
  327. package/dist/turns/types/turn-tracker.types.d.ts +27 -1
  328. package/dist/turns/work-checkout.d.ts +67 -0
  329. package/dist/turns/work-checkout.js +700 -0
  330. package/dist/untraced/constants/untraced.constants.d.ts +31 -0
  331. package/dist/untraced/constants/untraced.constants.js +63 -0
  332. package/dist/untraced/untraced.d.ts +35 -0
  333. package/dist/untraced/untraced.js +105 -0
  334. package/dist/update/constants/update.constants.d.ts +18 -0
  335. package/dist/update/constants/update.constants.js +20 -0
  336. package/dist/update/update-check.d.ts +52 -0
  337. package/dist/update/update-check.js +113 -0
  338. package/docs/AUDIT_PROMPT.md +129 -0
  339. package/docs/DATA_HANDLING.md +655 -0
  340. package/docs/ENTERPRISE_DEPLOYMENT.md +194 -0
  341. package/docs/PERFORMANCE.md +81 -0
  342. package/package.json +14 -4
  343. package/dist/enrollment/enrollment-provider.d.ts +0 -5
  344. package/dist/enrollment/manual-enrollment.d.ts +0 -32
  345. package/dist/enrollment/manual-enrollment.js +0 -72
  346. package/example/README.md +0 -43
  347. package/example/server.mjs +0 -240
  348. /package/dist/{enrollment/enrollment-provider.js → config/types/destination.types.js} +0 -0
@@ -1,7 +1,8 @@
1
1
  import { sha256Hex } from '../../events/event-id.js';
2
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';
3
+ import { asRecord } from '../../core/object.js';
4
+ import { classifyTool, extractCommand, parseMcpToolName, shellCallOf, toolCompleteType, toolStartType } from '../shared/tooling.js';
5
+ import { ANTIGRAVITY_CWD_KEY, 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
6
  import { antigravityPayloadSchema } from './schemas/antigravity.schema.js';
6
7
  const ARGS_KEYS = Object.keys(ANTIGRAVITY_HOOK_EVENT_BY_ARGS);
7
8
  /**
@@ -37,6 +38,23 @@ export function antigravityCwd(rawPayload) {
37
38
  return undefined;
38
39
  return parsed.data.common?.workspacePaths?.[0];
39
40
  }
41
+ /**
42
+ * The command a `run_command` tool call runs, and its `Cwd`, before and after it
43
+ * ran (a command can create the worktree it works in).
44
+ *
45
+ * Arguments as the fixtures record them, read off the tool schema in the `agy`
46
+ * binary: `CommandLine` and `Cwd`, PascalCase.
47
+ *
48
+ * @param rawPayload - Raw JSON from the hook's stdin.
49
+ * @returns The call, or undefined for any other payload.
50
+ */
51
+ export function antigravityShellCall(rawPayload) {
52
+ const parsed = antigravityPayloadSchema.safeParse(rawPayload);
53
+ const toolCall = parsed.success ? (parsed.data.preToolHookArgs ?? parsed.data.postToolHookArgs)?.toolCall : undefined;
54
+ if (classifyTool(toolCall?.name) !== 'shell')
55
+ return undefined;
56
+ return shellCallOf(extractCommand(toolCall?.args), asRecord(toolCall?.args)?.[ANTIGRAVITY_CWD_KEY]);
57
+ }
40
58
  /**
41
59
  * Translate one Antigravity hook payload into canonical events.
42
60
  *
@@ -148,7 +166,7 @@ function hookPatch(payload, hook, context) {
148
166
  if (hook === 'PreToolUse' || hook === 'PostToolUse')
149
167
  return antigravityToolPatch(payload, hook, context);
150
168
  if (hook === 'Stop')
151
- return responsePatch(payload.stopHookArgs?.finalModelOutput ?? '', context.config.capture);
169
+ return responsePatch(payload.stopHookArgs?.finalModelOutput ?? '');
152
170
  return {};
153
171
  }
154
172
  /**
@@ -1,14 +1,5 @@
1
1
  import type { Env } from '../../core/types/core.types.js';
2
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
3
  /**
13
4
  * Where Antigravity reads named hook groups from.
14
5
  *
@@ -12,7 +12,7 @@ import { ANTIGRAVITY_CLI_DIR_SEGMENTS, ANTIGRAVITY_EXECUTABLES, ANTIGRAVITY_HOOK
12
12
  * @param env - Environment supplying HOME.
13
13
  * @returns Absolute path of the config root.
14
14
  */
15
- export function antigravityRoot(env) {
15
+ function antigravityRoot(env) {
16
16
  return path.join(env.home, ...ANTIGRAVITY_ROOT_SEGMENTS);
17
17
  }
18
18
  /**
@@ -1,4 +1,4 @@
1
- import { antigravityCwd, antigravityHookEvent, parseAntigravityHookEvent } from './antigravity.adapter.js';
1
+ import { antigravityCwd, antigravityHookEvent, antigravityShellCall, parseAntigravityHookEvent } from './antigravity.adapter.js';
2
2
  import { detectAntigravity } from './antigravity.detect.js';
3
3
  import { installAntigravityHooks, uninstallAntigravityHooks } from './antigravity.hooks.js';
4
4
  import { ANTIGRAVITY_DISPLAY_NAME, ANTIGRAVITY_FALLBACK_DECISION, ANTIGRAVITY_HOOK_DECISIONS, ANTIGRAVITY_PROVIDER_ID } from './constants/antigravity.constants.js';
@@ -14,7 +14,8 @@ export const antigravityProvider = {
14
14
  const decision = hook === undefined ? ANTIGRAVITY_FALLBACK_DECISION : ANTIGRAVITY_HOOK_DECISIONS[hook];
15
15
  return { stdout: JSON.stringify(decision ?? {}), exitCode: 0 };
16
16
  },
17
- resolveCwd: antigravityCwd
17
+ resolveCwd: antigravityCwd,
18
+ shellCall: antigravityShellCall
18
19
  // No nativeTelemetry: Antigravity exposes no OTLP exporter configuration, so
19
20
  // there is no llm.call ledger source and turn summaries stay
20
21
  // usage_status=pending. Adding a configurator would claim a capability the
@@ -1,5 +1,7 @@
1
1
  export declare const ANTIGRAVITY_PROVIDER_ID = "antigravity";
2
2
  export declare const ANTIGRAVITY_DISPLAY_NAME = "Google Antigravity";
3
+ /** `run_command`'s working-directory argument, PascalCase like all of its arguments. */
4
+ export declare const ANTIGRAVITY_CWD_KEY = "Cwd";
3
5
  /** Antigravity shares Gemini's home; its own config lives one level down. */
4
6
  export declare const ANTIGRAVITY_ROOT_SEGMENTS: readonly [".gemini", "config"];
5
7
  export declare const ANTIGRAVITY_CLI_DIR_SEGMENTS: readonly [".gemini", "antigravity-cli"];
@@ -1,5 +1,7 @@
1
1
  export const ANTIGRAVITY_PROVIDER_ID = 'antigravity';
2
2
  export const ANTIGRAVITY_DISPLAY_NAME = 'Google Antigravity';
3
+ /** `run_command`'s working-directory argument, PascalCase like all of its arguments. */
4
+ export const ANTIGRAVITY_CWD_KEY = 'Cwd';
3
5
  /** Antigravity shares Gemini's home; its own config lives one level down. */
4
6
  export const ANTIGRAVITY_ROOT_SEGMENTS = ['.gemini', 'config'];
5
7
  export const ANTIGRAVITY_CLI_DIR_SEGMENTS = ['.gemini', 'antigravity-cli'];
@@ -1,5 +1,5 @@
1
1
  import type { AgentWatchEvent } from '../../events/types/events.types.js';
2
- import type { HookContext } from '../types/provider.types.js';
2
+ import type { HookContext, ShellCall } from '../types/provider.types.js';
3
3
  export type { ClaudePayload } from './types/claude.types.js';
4
4
  /**
5
5
  * Translate one Claude Code hook payload into canonical events.
@@ -13,3 +13,13 @@ export type { ClaudePayload } from './types/claude.types.js';
13
13
  * @returns The canonical events, or an empty list.
14
14
  */
15
15
  export declare function parseClaudeHookEvent(rawPayload: unknown, context: HookContext): AgentWatchEvent[];
16
+ /**
17
+ * The command a Bash tool hook is about to run, or has just run.
18
+ *
19
+ * Claude reports no separate working directory for the call: it runs in the
20
+ * payload's `cwd`.
21
+ *
22
+ * @param rawPayload - Raw JSON from the hook's stdin.
23
+ * @returns The command, or undefined for any other payload.
24
+ */
25
+ export declare function claudeShellCall(rawPayload: unknown): ShellCall | undefined;
@@ -1,7 +1,7 @@
1
1
  import { sha256Hex } from '../../events/event-id.js';
2
2
  import { baseEvent, promptPatch, responsePatch, toolPatch, withPatch } from '../shared/event-builder.js';
3
- import { classifyTool, parseMcpToolName, toolCompleteType, toolStartType } from '../shared/tooling.js';
4
- import { CLAUDE_DISPLAY_NAME, CLAUDE_EVENT_TYPE_MAP, CLAUDE_PROVIDER_ID, CLAUDE_TOOL_EVENTS, CLAUDE_TOOL_START_EVENTS, CLAUDE_UNKNOWN_EVENT } from './constants/claude.constants.js';
3
+ import { classifyTool, extractCommand, parseMcpToolName, toolCompleteType, toolStartType } from '../shared/tooling.js';
4
+ import { CLAUDE_DISPLAY_NAME, CLAUDE_EVENT_TYPE_MAP, CLAUDE_PROVIDER_ID, CLAUDE_SHELL_REREAD_EVENTS, CLAUDE_TOOL_EVENTS, CLAUDE_TOOL_START_EVENTS, CLAUDE_UNKNOWN_EVENT } from './constants/claude.constants.js';
5
5
  import { claudePayloadSchema } from './schemas/claude.schema.js';
6
6
  /**
7
7
  * Translate one Claude Code hook payload into canonical events.
@@ -22,6 +22,28 @@ export function parseClaudeHookEvent(rawPayload, context) {
22
22
  const providerEventType = payload.hook_event_name ?? CLAUDE_UNKNOWN_EVENT;
23
23
  return [withPatch(claudeBaseEvent(payload, providerEventType), hookPatch(payload, providerEventType, context))];
24
24
  }
25
+ /**
26
+ * The command a Bash tool hook is about to run, or has just run.
27
+ *
28
+ * Claude reports no separate working directory for the call: it runs in the
29
+ * payload's `cwd`.
30
+ *
31
+ * @param rawPayload - Raw JSON from the hook's stdin.
32
+ * @returns The command, or undefined for any other payload.
33
+ */
34
+ export function claudeShellCall(rawPayload) {
35
+ const parsed = claudePayloadSchema.safeParse(rawPayload);
36
+ const hookName = parsed.success ? (parsed.data.hook_event_name ?? '') : '';
37
+ // The completion too, failed or not: a command can create the worktree it
38
+ // works in, which only exists to be found once the command has run — and a
39
+ // command that exits non-zero may have got that far.
40
+ if (!parsed.success || (!CLAUDE_TOOL_START_EVENTS.has(hookName) && !CLAUDE_SHELL_REREAD_EVENTS.has(hookName)))
41
+ return undefined;
42
+ if (classifyTool(parsed.data.tool_name) !== 'shell')
43
+ return undefined;
44
+ const command = extractCommand(parsed.data.tool_input);
45
+ return command ? { command } : undefined;
46
+ }
25
47
  /**
26
48
  * The provider-independent part of the event.
27
49
  *
@@ -62,7 +84,6 @@ function claudeBaseEvent(payload, providerEventType) {
62
84
  * @returns The patch; empty for a hook we model but read nothing from.
63
85
  */
64
86
  function hookPatch(payload, providerEventType, context) {
65
- const capture = context.config.capture;
66
87
  if (providerEventType === 'SessionStart') {
67
88
  return {
68
89
  metadata: { sessionSource: payload.source },
@@ -72,11 +93,11 @@ function hookPatch(payload, providerEventType, context) {
72
93
  if (providerEventType === 'SessionEnd')
73
94
  return { metadata: { sessionEndReason: payload.reason } };
74
95
  if (providerEventType === 'UserPromptSubmit')
75
- return promptPatch(payload.prompt ?? '', capture);
96
+ return promptPatch(payload.prompt ?? '', context.config.capture);
76
97
  if (CLAUDE_TOOL_EVENTS.has(providerEventType))
77
98
  return claudeToolPatch(payload, providerEventType, context);
78
99
  if (providerEventType === 'Stop') {
79
- const response = responsePatch(payload.last_assistant_message ?? '', capture);
100
+ const response = responsePatch(payload.last_assistant_message ?? '');
80
101
  return { ...response, metadata: { stopHookActive: payload.stop_hook_active, ...response.metadata } };
81
102
  }
82
103
  if (providerEventType === 'SubagentStart' || providerEventType === 'SubagentStop') {
@@ -1,31 +1,37 @@
1
1
  import type { Env } from '../../core/types/core.types.js';
2
2
  import type { NativeTelemetryConfigurator, NativeTelemetryStatus, SetupContext, SetupOutcome } from '../types/provider.types.js';
3
+ /** Where Claude Code's exporters send, as its settings file says. */
4
+ export interface ClaudeExporterTargets {
5
+ /** `OTEL_EXPORTER_OTLP_ENDPOINT`, when set. */
6
+ readonly base?: string;
7
+ /** Every per-signal endpoint that is set; each overrides the base for its signal. */
8
+ readonly signals: readonly string[];
9
+ }
3
10
  /**
4
- * The telemetry environment AgentWatch wants in Claude Code's settings.
11
+ * Where Claude Code's exporters actually send, read from the settings file
12
+ * setup writes them into.
5
13
  *
6
- * Claude Code's native OpenTelemetry (verified against
7
- * code.claude.com/docs/en/monitoring-usage, 2026-08) is configured through the
8
- * settings.json `env` block. Each `claude_code.api_request` log becomes one
9
- * llm.call; the enhanced-traces beta adds `claude_code.llm_request` spans
10
- * carrying query_source/agent_id, which is what keeps child-agent traffic from
11
- * being folded into the main agent.
14
+ * The bearer `otel-headers` hands out goes wherever these say, and anyone who
15
+ * can edit that file can change them, so the helper checks them rather than
16
+ * trusting that they still say what setup wrote.
12
17
  *
13
- * @param context - Environment, paths and effective config.
14
- * @returns The desired variables, or undefined when telemetry is off or no
15
- * backend is configured.
18
+ * @param env - Ambient environment, for the settings path.
19
+ * @returns The endpoints; empty when the file is missing or unreadable.
16
20
  */
17
- export declare function desiredClaudeOtelEnv(context: SetupContext): Record<string, string> | undefined;
21
+ export declare function claudeExporterTargets(env: Env): Promise<ClaudeExporterTargets>;
18
22
  /**
19
- * The `agentwatch otel-headers` command for this install.
23
+ * Exporter endpoints set anywhere but the user settings file: the environment
24
+ * the helper inherits from Claude Code, and the project and local settings of
25
+ * the working directory and each folder above it.
20
26
  *
21
- * Bearer auth goes through Claude's documented header-helper hook so the token
22
- * never lands in the settings file — which is world-readable, committed by some
23
- * users, and backed up by others.
27
+ * Claude Code merges those over the user file, so either can send the export,
28
+ * and with it the bearer, somewhere the user file does not say. A cloned repo is
29
+ * a likelier author of that than the developer's own home settings.
24
30
  *
25
- * @param hookCommand - The generated `<bin> hook --agent claude` command.
26
- * @returns The helper command reusing the same binary path.
31
+ * @param env - Ambient environment: its variables and working directory.
32
+ * @returns Every endpoint set, base and per signal alike.
27
33
  */
28
- export declare function headersHelperCommand(hookCommand: string): string;
34
+ export declare function claudeOverrideTargets(env: Env): Promise<readonly string[]>;
29
35
  /**
30
36
  * Configures Claude Code's own OTLP export, which is where the llm.call usage
31
37
  * ledger comes from.
@@ -70,6 +76,14 @@ export declare class ClaudeOtelConfigurator implements NativeTelemetryConfigurat
70
76
  * install state.
71
77
  */
72
78
  uninstall(context: SetupContext): Promise<SetupOutcome>;
79
+ /**
80
+ * Where the exporter setup recorded as AgentWatch's sends. Nothing without
81
+ * that record: the endpoint may then be the developer's own.
82
+ *
83
+ * @param context - Environment and install state.
84
+ * @returns The owned endpoint, or none.
85
+ */
86
+ exporterEndpoints(context: SetupContext): Promise<readonly string[]>;
73
87
  /**
74
88
  * Handle `configure` when telemetry is off or unconfigurable.
75
89
  *
@@ -1,13 +1,29 @@
1
+ import path from 'node:path';
1
2
  import { asRecord, omitKeys } from '../../core/object.js';
2
3
  import { enabledSignalNames, otelEnabled, otlpBaseUrl } from '../../config/config.js';
3
4
  import { backupFile } from '../../storage/atomic-file.js';
5
+ import { hasCredential } from '../../credentials/identity.js';
4
6
  import { readJsonFile } from '../../storage/json-file.js';
5
7
  import { writeJsonValidated } from '../shared/hook-config.js';
6
8
  import { withOtelInstall, withoutOtelInstall } from '../shared/install-record.js';
7
9
  import { HOOK_COMMAND_MARKER } from '../constants/provider.constants.js';
8
10
  import { claudeSettingsPath } from './claude.detect.js';
9
11
  import { CLAUDE_PROVIDER_ID } from './constants/claude.constants.js';
10
- import { ENV_BLOCK_KEY, HEADERS_HELPER_KEY, OTEL_EXPORTER_NONE, OTEL_EXPORTER_OTLP, OTLP_PROTOCOL, RE_HOOK_SUFFIX } from './constants/claude.otel.constants.js';
12
+ import { ENV_BLOCK_KEY, HEADERS_HELPER_KEY, OTEL_EXPORTER_NONE, OTEL_EXPORTER_OTLP, OTLP_ENDPOINT_KEY, OTLP_PROTOCOL, OTLP_SIGNAL_ENDPOINT_KEYS, RE_HOOK_SUFFIX } from './constants/claude.otel.constants.js';
13
+ /**
14
+ * Claude's own content-logging switches, forced off.
15
+ *
16
+ * Never treated as a foreign key: a user who set `OTEL_LOG_USER_PROMPTS=1`
17
+ * before installing is exactly the case this exists to override, and refusing
18
+ * to configure them would leave prompt logging on *and* drop the llm.call
19
+ * ledger. Overriding a switch that only ever reduces what leaves the machine
20
+ * is not the redirection the conflict check protects against.
21
+ */
22
+ const CONTENT_LOG_OFF = {
23
+ OTEL_LOG_USER_PROMPTS: '0',
24
+ OTEL_LOG_TOOL_DETAILS: '0',
25
+ OTEL_LOG_TOOL_CONTENT: '0'
26
+ };
11
27
  /**
12
28
  * The telemetry environment AgentWatch wants in Claude Code's settings.
13
29
  *
@@ -22,23 +38,69 @@ import { ENV_BLOCK_KEY, HEADERS_HELPER_KEY, OTEL_EXPORTER_NONE, OTEL_EXPORTER_OT
22
38
  * @returns The desired variables, or undefined when telemetry is off or no
23
39
  * backend is configured.
24
40
  */
25
- export function desiredClaudeOtelEnv(context) {
41
+ function desiredClaudeOtelEnv(context) {
26
42
  const otlpBase = otlpBaseUrl(context.config);
27
43
  if (!otlpBase || !otelEnabled(context.config))
28
44
  return undefined;
29
45
  const signals = context.config.otel;
30
46
  return {
31
47
  CLAUDE_CODE_ENABLE_TELEMETRY: '1',
48
+ ...CONTENT_LOG_OFF,
32
49
  OTEL_METRICS_EXPORTER: signals.metrics ? OTEL_EXPORTER_OTLP : OTEL_EXPORTER_NONE,
33
50
  OTEL_LOGS_EXPORTER: signals.logs ? OTEL_EXPORTER_OTLP : OTEL_EXPORTER_NONE,
34
51
  OTEL_TRACES_EXPORTER: signals.traces ? OTEL_EXPORTER_OTLP : OTEL_EXPORTER_NONE,
35
52
  // No default protocol exists; it has to be explicit.
36
53
  OTEL_EXPORTER_OTLP_PROTOCOL: OTLP_PROTOCOL,
37
- OTEL_EXPORTER_OTLP_ENDPOINT: otlpBase,
54
+ [OTLP_ENDPOINT_KEY]: otlpBase,
38
55
  // The beta flag only adds the llm_request spans; it stays tied to traces.
39
56
  ...(signals.traces ? { CLAUDE_CODE_ENHANCED_TELEMETRY_BETA: '1' } : {})
40
57
  };
41
58
  }
59
+ /**
60
+ * Where Claude Code's exporters actually send, read from the settings file
61
+ * setup writes them into.
62
+ *
63
+ * The bearer `otel-headers` hands out goes wherever these say, and anyone who
64
+ * can edit that file can change them, so the helper checks them rather than
65
+ * trusting that they still say what setup wrote.
66
+ *
67
+ * @param env - Ambient environment, for the settings path.
68
+ * @returns The endpoints; empty when the file is missing or unreadable.
69
+ */
70
+ export async function claudeExporterTargets(env) {
71
+ const read = await readJsonFile(claudeSettingsPath(env));
72
+ const envBlock = asRecord(read.state === 'ok' ? asRecord(read.value)?.[ENV_BLOCK_KEY] : undefined) ?? {};
73
+ const base = envBlock[OTLP_ENDPOINT_KEY];
74
+ const signals = OTLP_SIGNAL_ENDPOINT_KEYS.map((key) => envBlock[key]).filter((value) => value !== undefined).map(String);
75
+ return { ...(typeof base === 'string' ? { base } : {}), signals };
76
+ }
77
+ /** Project settings files Claude Code layers over the user file, in a `.claude` folder. */
78
+ const PROJECT_SETTINGS_FILES = ['settings.json', 'settings.local.json'];
79
+ /**
80
+ * Exporter endpoints set anywhere but the user settings file: the environment
81
+ * the helper inherits from Claude Code, and the project and local settings of
82
+ * the working directory and each folder above it.
83
+ *
84
+ * Claude Code merges those over the user file, so either can send the export,
85
+ * and with it the bearer, somewhere the user file does not say. A cloned repo is
86
+ * a likelier author of that than the developer's own home settings.
87
+ *
88
+ * @param env - Ambient environment: its variables and working directory.
89
+ * @returns Every endpoint set, base and per signal alike.
90
+ */
91
+ export async function claudeOverrideTargets(env) {
92
+ const keys = [OTLP_ENDPOINT_KEY, ...OTLP_SIGNAL_ENDPOINT_KEYS];
93
+ const targets = keys.map((key) => env.vars[key]).filter((value) => value !== undefined && value !== '');
94
+ for (let dir = path.resolve(env.cwd);; dir = path.dirname(dir)) {
95
+ for (const file of PROJECT_SETTINGS_FILES) {
96
+ const read = await readJsonFile(path.join(dir, '.claude', file));
97
+ const envBlock = asRecord(read.state === 'ok' ? asRecord(read.value)?.[ENV_BLOCK_KEY] : undefined) ?? {};
98
+ targets.push(...keys.map((key) => envBlock[key]).filter((value) => value !== undefined).map(String));
99
+ }
100
+ if (path.dirname(dir) === dir)
101
+ return targets;
102
+ }
103
+ }
42
104
  /**
43
105
  * The `agentwatch otel-headers` command for this install.
44
106
  *
@@ -49,7 +111,7 @@ export function desiredClaudeOtelEnv(context) {
49
111
  * @param hookCommand - The generated `<bin> hook --agent claude` command.
50
112
  * @returns The helper command reusing the same binary path.
51
113
  */
52
- export function headersHelperCommand(hookCommand) {
114
+ function headersHelperCommand(hookCommand) {
53
115
  return `${hookCommand.replace(RE_HOOK_SUFFIX, '')} otel-headers`;
54
116
  }
55
117
  /**
@@ -195,6 +257,19 @@ export class ClaudeOtelConfigurator {
195
257
  installState: withoutOtelInstall(context.installState, CLAUDE_PROVIDER_ID)
196
258
  };
197
259
  }
260
+ /**
261
+ * Where the exporter setup recorded as AgentWatch's sends. Nothing without
262
+ * that record: the endpoint may then be the developer's own.
263
+ *
264
+ * @param context - Environment and install state.
265
+ * @returns The owned endpoint, or none.
266
+ */
267
+ async exporterEndpoints(context) {
268
+ if (!this.ownedKeys(context).includes(OTLP_ENDPOINT_KEY))
269
+ return [];
270
+ const { base } = await claudeExporterTargets(context.env);
271
+ return base === undefined ? [] : [base];
272
+ }
198
273
  /**
199
274
  * Handle `configure` when telemetry is off or unconfigurable.
200
275
  *
@@ -228,7 +303,7 @@ export class ClaudeOtelConfigurator {
228
303
  * @returns The next settings and the extra owned key, or a conflict message.
229
304
  */
230
305
  applyHeadersHelper(settings, context) {
231
- if (!context.config.token)
306
+ if (!hasCredential(context.config))
232
307
  return { settings, ownedExtra: [] };
233
308
  const helperCommand = headersHelperCommand(context.hookCommand);
234
309
  const existing = settings[HEADERS_HELPER_KEY];
@@ -274,7 +349,7 @@ function inspectDisabled(settings, envBlock, ownedKeys) {
274
349
  * @returns The conflicting key names.
275
350
  */
276
351
  function foreignKeys(envBlock, desired, ownedKeys) {
277
- const owned = new Set(ownedKeys);
352
+ const owned = new Set([...ownedKeys, ...Object.keys(CONTENT_LOG_OFF)]);
278
353
  return Object.keys(desired).filter((key) => envBlock[key] !== undefined && envBlock[key] !== desired[key] && !owned.has(key));
279
354
  }
280
355
  /**
@@ -1,8 +1,8 @@
1
- import { hookRefusal } from '../shared/hook-refusal.js';
1
+ import { hookNotice, hookRefusal } from '../shared/hook-refusal.js';
2
2
  import { CLAUDE_PROMPT_SUBMIT_EVENTS } from './constants/claude.constants.js';
3
3
  import { detectClaude } from './claude.detect.js';
4
4
  import { installClaudeHooks, uninstallClaudeHooks } from './claude.hooks.js';
5
- import { parseClaudeHookEvent } from './claude.adapter.js';
5
+ import { claudeShellCall, parseClaudeHookEvent } from './claude.adapter.js';
6
6
  import { ClaudeOtelConfigurator } from './claude.otel.js';
7
7
  export const claudeProvider = {
8
8
  id: 'claude',
@@ -22,5 +22,8 @@ export const claudeProvider = {
22
22
  * event can be refused by this path.
23
23
  */
24
24
  getBlockResponse: (payload, message) => hookRefusal(payload, CLAUDE_PROMPT_SUBMIT_EVENTS, { decision: 'block', reason: message }),
25
+ /** A line for the developer after a shell run, as `systemMessage`; never plain stdout. */
26
+ getNoticeResponse: (payload, message) => hookNotice(payload, message),
27
+ shellCall: claudeShellCall,
25
28
  nativeTelemetry: new ClaudeOtelConfigurator()
26
29
  };
@@ -22,6 +22,8 @@ export declare const CLAUDE_EVENT_TYPE_MAP: Readonly<Record<string, CanonicalEve
22
22
  export declare const CLAUDE_TOOL_EVENTS: ReadonlySet<string>;
23
23
  /** Hooks that report a tool call as starting rather than finishing. */
24
24
  export declare const CLAUDE_TOOL_START_EVENTS: ReadonlySet<string>;
25
+ /** Completions whose shell command is read again for a checkout the command created. */
26
+ export declare const CLAUDE_SHELL_REREAD_EVENTS: ReadonlySet<string>;
25
27
  /**
26
28
  * The one hook a budget refusal may travel on.
27
29
  *
@@ -42,6 +42,8 @@ export const CLAUDE_EVENT_TYPE_MAP = {
42
42
  export const CLAUDE_TOOL_EVENTS = new Set(['PreToolUse', 'PostToolUse', 'PostToolUseFailure', 'PermissionRequest']);
43
43
  /** Hooks that report a tool call as starting rather than finishing. */
44
44
  export const CLAUDE_TOOL_START_EVENTS = new Set(['PreToolUse', 'PermissionRequest']);
45
+ /** Completions whose shell command is read again for a checkout the command created. */
46
+ export const CLAUDE_SHELL_REREAD_EVENTS = new Set(['PostToolUse', 'PostToolUseFailure']);
45
47
  /**
46
48
  * The one hook a budget refusal may travel on.
47
49
  *
@@ -15,3 +15,7 @@ export declare const OTEL_EXPORTER_OTLP = "otlp";
15
15
  export declare const OTLP_PROTOCOL = "http/json";
16
16
  /** Trailing `hook --agent <id>` of a hook command, stripped to reuse the binary. */
17
17
  export declare const RE_HOOK_SUFFIX: RegExp;
18
+ /** Where Claude Code's exporters send: the OTLP base every signal derives from. */
19
+ export declare const OTLP_ENDPOINT_KEY = "OTEL_EXPORTER_OTLP_ENDPOINT";
20
+ /** Per-signal endpoints, which override the base for that one signal. */
21
+ export declare const OTLP_SIGNAL_ENDPOINT_KEYS: readonly string[];
@@ -15,3 +15,11 @@ export const OTEL_EXPORTER_OTLP = 'otlp';
15
15
  export const OTLP_PROTOCOL = 'http/json';
16
16
  /** Trailing `hook --agent <id>` of a hook command, stripped to reuse the binary. */
17
17
  export const RE_HOOK_SUFFIX = /\s+hook\s+--agent\s+\S+\s*$/;
18
+ /** Where Claude Code's exporters send: the OTLP base every signal derives from. */
19
+ export const OTLP_ENDPOINT_KEY = 'OTEL_EXPORTER_OTLP_ENDPOINT';
20
+ /** Per-signal endpoints, which override the base for that one signal. */
21
+ export const OTLP_SIGNAL_ENDPOINT_KEYS = [
22
+ 'OTEL_EXPORTER_OTLP_LOGS_ENDPOINT',
23
+ 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT',
24
+ 'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT'
25
+ ];
@@ -1,5 +1,5 @@
1
1
  import type { AgentWatchEvent } from '../../events/types/events.types.js';
2
- import type { HookContext } from '../types/provider.types.js';
2
+ import type { HookContext, ShellCall } from '../types/provider.types.js';
3
3
  export type { CodexPayload } from './types/codex.types.js';
4
4
  /**
5
5
  * Translate one Codex hook payload into canonical events.
@@ -9,3 +9,17 @@ export type { CodexPayload } from './types/codex.types.js';
9
9
  * @returns The canonical events, or an empty list for an unusable payload.
10
10
  */
11
11
  export declare function parseCodexHookEvent(rawPayload: unknown, context: HookContext): AgentWatchEvent[];
12
+ /**
13
+ * The command a shell call runs, on its `PreToolUse` and its `PostToolUse` —
14
+ * the latter because a command can create the worktree it works in.
15
+ *
16
+ * Codex reports every shell call to hooks as `Bash` with `tool_input:
17
+ * {command}` (openai/codex `core/src/tools/hook_names.rs`,
18
+ * `handlers/unified_exec/exec_command.rs`, 2026-09). The model's own `workdir`
19
+ * argument is dropped before the hook, so there is no working directory to
20
+ * read: the call runs in the payload's `cwd` unless its command says otherwise.
21
+ *
22
+ * @param rawPayload - Raw JSON from the hook's stdin.
23
+ * @returns The command, or undefined for any other payload.
24
+ */
25
+ export declare function codexShellCall(rawPayload: unknown): ShellCall | undefined;
@@ -1,7 +1,9 @@
1
1
  import { sha256Hex } from '../../events/event-id.js';
2
2
  import { baseEvent, promptPatch, responsePatch, toolPatch, withPatch } from '../shared/event-builder.js';
3
- import { classifyTool, toolCompleteType, toolStartType } from '../shared/tooling.js';
4
- import { CODEX_DISPLAY_NAME, CODEX_EVENT_TYPE_MAP, CODEX_PROVIDER_ID, CODEX_TOOL_EVENTS, CODEX_UNKNOWN_EVENT } from './constants/codex.constants.js';
3
+ import { asRecord } from '../../core/object.js';
4
+ import { SHELL_COMMAND_KEY } from '../shared/constants/tooling.constants.js';
5
+ import { classifyTool, parseMcpToolName, shellCallOf, toolCompleteType, toolStartType } from '../shared/tooling.js';
6
+ import { CODEX_DISPLAY_NAME, CODEX_EVENT_TYPE_MAP, CODEX_PROVIDER_ID, CODEX_SHELL_CALL_EVENTS, CODEX_TOOL_EVENTS, CODEX_UNKNOWN_EVENT } from './constants/codex.constants.js';
5
7
  import { codexPayloadSchema } from './schemas/codex.schema.js';
6
8
  /**
7
9
  * Translate one Codex hook payload into canonical events.
@@ -18,6 +20,25 @@ export function parseCodexHookEvent(rawPayload, context) {
18
20
  const providerEventType = payload.hook_event_name ?? CODEX_UNKNOWN_EVENT;
19
21
  return [withPatch(codexBaseEvent(payload, providerEventType), hookPatch(payload, providerEventType, context))];
20
22
  }
23
+ /**
24
+ * The command a shell call runs, on its `PreToolUse` and its `PostToolUse` —
25
+ * the latter because a command can create the worktree it works in.
26
+ *
27
+ * Codex reports every shell call to hooks as `Bash` with `tool_input:
28
+ * {command}` (openai/codex `core/src/tools/hook_names.rs`,
29
+ * `handlers/unified_exec/exec_command.rs`, 2026-09). The model's own `workdir`
30
+ * argument is dropped before the hook, so there is no working directory to
31
+ * read: the call runs in the payload's `cwd` unless its command says otherwise.
32
+ *
33
+ * @param rawPayload - Raw JSON from the hook's stdin.
34
+ * @returns The command, or undefined for any other payload.
35
+ */
36
+ export function codexShellCall(rawPayload) {
37
+ const parsed = codexPayloadSchema.safeParse(rawPayload);
38
+ if (!parsed.success || !CODEX_SHELL_CALL_EVENTS.has(parsed.data.hook_event_name ?? '') || classifyTool(parsed.data.tool_name) !== 'shell')
39
+ return undefined;
40
+ return shellCallOf(asRecord(parsed.data.tool_input)?.[SHELL_COMMAND_KEY], undefined);
41
+ }
21
42
  /**
22
43
  * The provider-independent part of the event.
23
44
  *
@@ -65,17 +86,20 @@ function hookPatch(payload, providerEventType, context) {
65
86
  if (providerEventType === 'UserPromptSubmit')
66
87
  return promptPatch(payload.prompt ?? '', capture);
67
88
  if (CODEX_TOOL_EVENTS.has(providerEventType)) {
89
+ const kind = classifyTool(payload.tool_name);
90
+ const mcp = kind === 'mcp' && payload.tool_name ? parseMcpToolName(payload.tool_name) : undefined;
68
91
  return toolPatch({
69
92
  name: payload.tool_name,
70
93
  status: providerEventType === 'PostToolUse' ? 'completed' : 'started',
71
- kind: classifyTool(payload.tool_name),
94
+ kind,
72
95
  toolUseId: payload.tool_use_id,
73
96
  input: payload.tool_input,
74
- output: payload.tool_response
97
+ output: payload.tool_response,
98
+ providerFields: mcp ? { mcpServer: mcp.server, mcpTool: mcp.tool } : undefined
75
99
  }, capture);
76
100
  }
77
101
  if (providerEventType === 'Stop') {
78
- const response = responsePatch(payload.last_assistant_message ?? '', capture);
102
+ const response = responsePatch(payload.last_assistant_message ?? '');
79
103
  return { ...response, metadata: { stopHookActive: payload.stop_hook_active, ...response.metadata } };
80
104
  }
81
105
  if (providerEventType === 'SubagentStart' || providerEventType === 'SubagentStop') {
@@ -1,5 +1,6 @@
1
1
  import type { Env } from '../../core/types/core.types.js';
2
- import type { NativeTelemetryConfigurator, NativeTelemetryStatus, SetupContext, SetupOutcome } from '../types/provider.types.js';
2
+ import type { AgentWatchConfig, OtelSignalName } from '../../config/types/config.types.js';
3
+ import type { BearerRewriteContext, NativeTelemetryConfigurator, NativeTelemetryStatus, SetupContext, SetupOutcome } from '../types/provider.types.js';
3
4
  /**
4
5
  * Configures Codex's own OTLP export.
5
6
  *
@@ -33,14 +34,46 @@ export declare class CodexOtelConfigurator implements NativeTelemetryConfigurato
33
34
  /**
34
35
  * Remove the managed block from Codex's config.toml.
35
36
  *
36
- * Only the marker-delimited region goes; everything the developer wrote
37
- * around it — comments included — is preserved byte for byte.
37
+ * Only our own `[otel]` table goes. Everything the developer wrote around the
38
+ * markers — comments included — is preserved byte for byte, and so is
39
+ * anything the agent wrote *inside* them: Codex parks its `[hooks.state]`
40
+ * trust hashes there when it re-serializes the file.
38
41
  *
39
42
  * @param context - Environment, paths and install state.
40
43
  * @returns Whether the file changed, what to tell the user, and the next
41
44
  * install state.
42
45
  */
43
46
  uninstall(context: SetupContext): Promise<SetupOutcome>;
47
+ /**
48
+ * Swap the bearer in our exporters for the current one.
49
+ *
50
+ * Only the bearer in our own `[otel]` table changes: an MCP server's
51
+ * `Authorization` that Codex parked inside our markers is not ours. No
52
+ * backup: one per rotation would collect copies of every token.
53
+ *
54
+ * @param context - The recorded file, its contents as read and the current bearer.
55
+ * @returns True when the file was rewritten.
56
+ */
57
+ rewriteBearer(context: BearerRewriteContext): Promise<boolean>;
58
+ /**
59
+ * Where the managed block's exporters send. The block is AgentWatch's whole,
60
+ * so every endpoint in it is.
61
+ *
62
+ * @param context - Environment.
63
+ * @returns The endpoints; none when there is no block or it does not parse.
64
+ */
65
+ exporterEndpoints(context: SetupContext): Promise<readonly string[]>;
66
+ /**
67
+ * Signals Codex was asked for but will not be given under current consent.
68
+ *
69
+ * Codex's usage logs and traces both carry tool arguments and results with no
70
+ * per-field filter, so the two of them stand or fall together on
71
+ * `toolContentConsented`.
72
+ *
73
+ * @param config - Effective configuration.
74
+ * @returns The requested signals that are held back; empty when none are.
75
+ */
76
+ withheldSignals(config: AgentWatchConfig): readonly OtelSignalName[];
44
77
  /**
45
78
  * Handle `configure` when Codex telemetry is deliberately off.
46
79
  *