@agent-watch-ai/edge 0.6.0 → 0.7.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 (282) hide show
  1. package/CHANGELOG.md +219 -9
  2. package/README.md +303 -4
  3. package/dist/billing/billing-mode.d.ts +37 -5
  4. package/dist/billing/billing-mode.js +28 -19
  5. package/dist/billing/constants/billing.constants.d.ts +0 -2
  6. package/dist/billing/constants/billing.constants.js +0 -2
  7. package/dist/billing/index.d.ts +2 -1
  8. package/dist/billing/index.js +1 -1
  9. package/dist/billing/session-billing.d.ts +3 -2
  10. package/dist/billing/session-billing.js +8 -8
  11. package/dist/billing/types/billing.types.d.ts +7 -0
  12. package/dist/capture/capture-env.d.ts +147 -0
  13. package/dist/capture/capture-env.js +301 -0
  14. package/dist/capture/captured-step.d.ts +88 -0
  15. package/dist/capture/captured-step.js +479 -0
  16. package/dist/capture/constants/capture.constants.d.ts +70 -0
  17. package/dist/capture/constants/capture.constants.js +72 -0
  18. package/dist/capture/launched-runs.d.ts +16 -0
  19. package/dist/capture/launched-runs.js +151 -0
  20. package/dist/capture/node.cjs +697 -0
  21. package/dist/capture/node.d.cts +32 -0
  22. package/dist/capture/python/sitecustomize.py +823 -0
  23. package/dist/capture/schemas/capture.schema.d.ts +35 -0
  24. package/dist/capture/schemas/capture.schema.js +31 -0
  25. package/dist/capture/types/capture.types.d.ts +20 -0
  26. package/dist/cli/constants/cli.constants.d.ts +2 -6
  27. package/dist/cli/constants/cli.constants.js +3 -7
  28. package/dist/cli/context.d.ts +19 -22
  29. package/dist/cli/context.js +23 -54
  30. package/dist/cli/doctor-run-capture.d.ts +13 -0
  31. package/dist/cli/doctor-run-capture.js +19 -0
  32. package/dist/cli/doctor.js +16 -67
  33. package/dist/cli/hook.d.ts +14 -0
  34. package/dist/cli/hook.js +40 -0
  35. package/dist/cli/index.d.ts +1 -1
  36. package/dist/cli/index.js +1 -1
  37. package/dist/cli/misc.js +10 -2
  38. package/dist/cli/replay.d.ts +33 -0
  39. package/dist/cli/replay.js +193 -0
  40. package/dist/cli/setup.d.ts +10 -2
  41. package/dist/cli/setup.js +154 -26
  42. package/dist/cli/status.js +45 -5
  43. package/dist/cli/toggle.js +10 -0
  44. package/dist/cli/types/cli.types.d.ts +15 -1
  45. package/dist/cli/uninstall.js +8 -22
  46. package/dist/cli.js +104 -17
  47. package/dist/config/config.d.ts +0 -2
  48. package/dist/config/config.js +0 -1
  49. package/dist/config/constants/config.constants.js +2 -0
  50. package/dist/config/events-transport.d.ts +15 -0
  51. package/dist/config/events-transport.js +29 -0
  52. package/dist/config/index.d.ts +2 -1
  53. package/dist/config/index.js +1 -0
  54. package/dist/config/root-config.d.ts +12 -0
  55. package/dist/config/root-config.js +24 -0
  56. package/dist/config/schemas/config.schema.d.ts +13 -0
  57. package/dist/config/schemas/config.schema.js +42 -6
  58. package/dist/config/types/config.types.d.ts +7 -0
  59. package/dist/core/index.d.ts +1 -1
  60. package/dist/core/index.js +1 -1
  61. package/dist/core/version.d.ts +9 -0
  62. package/dist/core/version.js +14 -0
  63. package/dist/core/which.d.ts +11 -0
  64. package/dist/core/which.js +18 -0
  65. package/dist/credentials/cloud-claim.d.ts +32 -0
  66. package/dist/credentials/cloud-claim.js +42 -0
  67. package/dist/credentials/constants/credentials.constants.d.ts +8 -1
  68. package/dist/credentials/constants/credentials.constants.js +9 -2
  69. package/dist/credentials/device-api.d.ts +15 -1
  70. package/dist/credentials/device-api.js +12 -1
  71. package/dist/credentials/sign-in.d.ts +27 -0
  72. package/dist/credentials/sign-in.js +31 -1
  73. package/dist/credentials/token-refresher.d.ts +5 -1
  74. package/dist/credentials/token-refresher.js +10 -2
  75. package/dist/events/constants/events.constants.d.ts +5 -2
  76. package/dist/events/constants/events.constants.js +4 -1
  77. package/dist/events/index.d.ts +1 -0
  78. package/dist/events/product-event.d.ts +6 -3
  79. package/dist/events/types/events.types.d.ts +6 -0
  80. package/dist/events/types/replay-progress.types.d.ts +26 -0
  81. package/dist/events/types/replay-progress.types.js +1 -0
  82. package/dist/events/types/repo-tree.types.d.ts +2 -1
  83. package/dist/feature/ticket-candidates.d.ts +1 -1
  84. package/dist/git/checkout-root.d.ts +15 -0
  85. package/dist/git/checkout-root.js +18 -0
  86. package/dist/git/code-state.d.ts +2 -16
  87. package/dist/git/code-state.js +11 -12
  88. package/dist/git/constants/git.constants.d.ts +31 -11
  89. package/dist/git/constants/git.constants.js +36 -12
  90. package/dist/git/fingerprint.d.ts +3 -6
  91. package/dist/git/fingerprint.js +5 -8
  92. package/dist/git/git-context.js +5 -1
  93. package/dist/git/index.d.ts +1 -2
  94. package/dist/git/index.js +1 -1
  95. package/dist/git/repo-snapshot.d.ts +13 -4
  96. package/dist/git/repo-snapshot.js +47 -9
  97. package/dist/git/types/snapshot.types.d.ts +2 -0
  98. package/dist/pipeline/constants/pipeline.constants.d.ts +3 -0
  99. package/dist/pipeline/constants/pipeline.constants.js +3 -0
  100. package/dist/pipeline/hook-pipeline.js +81 -57
  101. package/dist/privacy/product-capture.js +2 -0
  102. package/dist/providers/antigravity/antigravity.capture.d.ts +2 -0
  103. package/dist/providers/antigravity/antigravity.capture.js +5 -0
  104. package/dist/providers/antigravity/antigravity.detect.js +8 -22
  105. package/dist/providers/antigravity/antigravity.provider.js +10 -3
  106. package/dist/providers/antigravity/constants/antigravity.constants.d.ts +1 -0
  107. package/dist/providers/antigravity/constants/antigravity.constants.js +1 -0
  108. package/dist/providers/claude/claude.adapter.js +9 -6
  109. package/dist/providers/claude/claude.detect.js +2 -17
  110. package/dist/providers/claude/claude.otel.d.ts +21 -3
  111. package/dist/providers/claude/claude.otel.js +216 -61
  112. package/dist/providers/claude/claude.provider.js +17 -1
  113. package/dist/providers/claude/claude.version.d.ts +9 -0
  114. package/dist/providers/claude/claude.version.js +28 -0
  115. package/dist/providers/claude/constants/claude.constants.d.ts +27 -0
  116. package/dist/providers/claude/constants/claude.constants.js +27 -0
  117. package/dist/providers/claude/constants/claude.otel.constants.d.ts +27 -0
  118. package/dist/providers/claude/constants/claude.otel.constants.js +45 -5
  119. package/dist/providers/claude/types/claude.types.d.ts +13 -0
  120. package/dist/providers/codex/codex.capture.d.ts +76 -0
  121. package/dist/providers/codex/codex.capture.js +454 -0
  122. package/dist/providers/codex/codex.detect.js +2 -4
  123. package/dist/providers/codex/codex.otel.d.ts +38 -2
  124. package/dist/providers/codex/codex.otel.js +50 -6
  125. package/dist/providers/codex/codex.provider.js +8 -0
  126. package/dist/providers/codex/codex.surface.d.ts +9 -0
  127. package/dist/{turns/codex-originator.js → providers/codex/codex.surface.js} +17 -3
  128. package/dist/providers/codex/codex.titles.d.ts +14 -0
  129. package/dist/providers/codex/codex.titles.js +35 -0
  130. package/dist/providers/codex/constants/codex.constants.d.ts +4 -0
  131. package/dist/providers/codex/constants/codex.constants.js +4 -0
  132. package/dist/providers/cursor/constants/cursor.constants.d.ts +17 -4
  133. package/dist/providers/cursor/constants/cursor.constants.js +25 -5
  134. package/dist/providers/cursor/cursor-mcp-memo.d.ts +34 -0
  135. package/dist/providers/cursor/cursor-mcp-memo.js +94 -0
  136. package/dist/providers/cursor/cursor.adapter.js +20 -82
  137. package/dist/providers/cursor/cursor.capture.d.ts +1 -0
  138. package/dist/providers/cursor/cursor.capture.js +4 -0
  139. package/dist/providers/cursor/cursor.detect.d.ts +5 -1
  140. package/dist/providers/cursor/cursor.detect.js +11 -26
  141. package/dist/providers/cursor/cursor.hooks.js +2 -2
  142. package/dist/providers/cursor/cursor.provider.js +16 -7
  143. package/dist/providers/cursor/cursor.titles.d.ts +14 -0
  144. package/dist/providers/cursor/cursor.titles.js +20 -0
  145. package/dist/providers/cursor/schemas/cursor.schema.d.ts +3 -3
  146. package/dist/providers/cursor/schemas/cursor.schema.js +5 -3
  147. package/dist/providers/gemini/constants/gemini.constants.d.ts +16 -0
  148. package/dist/providers/gemini/constants/gemini.constants.js +17 -0
  149. package/dist/providers/gemini/gemini.capture.d.ts +81 -0
  150. package/dist/providers/gemini/gemini.capture.js +210 -0
  151. package/dist/providers/gemini/gemini.detect.js +57 -24
  152. package/dist/providers/gemini/gemini.otel.d.ts +38 -2
  153. package/dist/providers/gemini/gemini.otel.js +56 -125
  154. package/dist/providers/gemini/gemini.provider.js +5 -0
  155. package/dist/providers/index.d.ts +1 -0
  156. package/dist/providers/index.js +1 -0
  157. package/dist/providers/provider.d.ts +8 -0
  158. package/dist/providers/provider.js +9 -0
  159. package/dist/providers/registry.d.ts +14 -0
  160. package/dist/providers/registry.js +14 -0
  161. package/dist/providers/shared/constants/hook-config.constants.d.ts +2 -0
  162. package/dist/providers/shared/constants/hook-config.constants.js +2 -0
  163. package/dist/providers/shared/constants/terminal-capture.constants.d.ts +6 -0
  164. package/dist/providers/shared/constants/terminal-capture.constants.js +6 -0
  165. package/dist/providers/shared/editor-paths.d.ts +8 -0
  166. package/dist/providers/shared/editor-paths.js +18 -0
  167. package/dist/providers/shared/hook-config.d.ts +5 -0
  168. package/dist/providers/shared/hook-config.js +39 -1
  169. package/dist/providers/shared/hooks-marker.d.ts +14 -0
  170. package/dist/providers/shared/hooks-marker.js +23 -0
  171. package/dist/providers/shared/install-record.d.ts +29 -0
  172. package/dist/providers/shared/install-record.js +52 -0
  173. package/dist/providers/shared/session-title-store.d.ts +23 -0
  174. package/dist/providers/shared/session-title-store.js +50 -0
  175. package/dist/providers/shared/terminal-capture.d.ts +41 -0
  176. package/dist/providers/shared/terminal-capture.js +109 -0
  177. package/dist/providers/shared/tooling.d.ts +21 -0
  178. package/dist/providers/shared/tooling.js +36 -1
  179. package/dist/providers/types/provider.types.d.ts +57 -4
  180. package/dist/replay/checkout-resolver.d.ts +29 -0
  181. package/dist/replay/checkout-resolver.js +69 -0
  182. package/dist/replay/codex-turns.d.ts +24 -0
  183. package/dist/replay/codex-turns.js +221 -0
  184. package/dist/replay/constants/replay.constants.d.ts +99 -0
  185. package/dist/replay/constants/replay.constants.js +102 -0
  186. package/dist/replay/describe.d.ts +10 -0
  187. package/dist/replay/describe.js +31 -0
  188. package/dist/replay/gemini-turns.d.ts +36 -0
  189. package/dist/replay/gemini-turns.js +192 -0
  190. package/dist/replay/machine.d.ts +34 -0
  191. package/dist/replay/machine.js +68 -0
  192. package/dist/replay/progress-event.d.ts +21 -0
  193. package/dist/replay/progress-event.js +45 -0
  194. package/dist/replay/replay-runner.d.ts +58 -0
  195. package/dist/replay/replay-runner.js +529 -0
  196. package/dist/replay/replay-scan.d.ts +83 -0
  197. package/dist/replay/replay-scan.js +170 -0
  198. package/dist/replay/replay-state.d.ts +108 -0
  199. package/dist/replay/replay-state.js +199 -0
  200. package/dist/replay/resume.d.ts +18 -0
  201. package/dist/replay/resume.js +34 -0
  202. package/dist/replay/start.d.ts +23 -0
  203. package/dist/replay/start.js +39 -0
  204. package/dist/replay/throttle.d.ts +35 -0
  205. package/dist/replay/throttle.js +41 -0
  206. package/dist/replay/transcript-turns.d.ts +35 -0
  207. package/dist/replay/transcript-turns.js +215 -0
  208. package/dist/replay/turn-event.d.ts +38 -0
  209. package/dist/replay/turn-event.js +116 -0
  210. package/dist/replay/types/replay.types.d.ts +162 -0
  211. package/dist/replay/types/replay.types.js +1 -0
  212. package/dist/replay/window.d.ts +28 -0
  213. package/dist/replay/window.js +41 -0
  214. package/dist/snapshot/branch-selection.d.ts +40 -23
  215. package/dist/snapshot/branch-selection.js +71 -41
  216. package/dist/snapshot/constants/snapshot-stages.constants.d.ts +3 -1
  217. package/dist/snapshot/constants/snapshot-stages.constants.js +3 -1
  218. package/dist/snapshot/constants/snapshot.constants.d.ts +34 -7
  219. package/dist/snapshot/constants/snapshot.constants.js +34 -7
  220. package/dist/snapshot/index.d.ts +2 -2
  221. package/dist/snapshot/index.js +1 -1
  222. package/dist/snapshot/snapshot-pipeline.js +89 -26
  223. package/dist/snapshot/snapshot-state.js +6 -2
  224. package/dist/snapshot/tree-pipeline.d.ts +1 -1
  225. package/dist/snapshot/tree-pipeline.js +34 -15
  226. package/dist/snapshot/types/snapshot.types.d.ts +20 -3
  227. package/dist/storage/schemas/storage.schema.d.ts +2 -0
  228. package/dist/storage/schemas/storage.schema.js +6 -0
  229. package/dist/transport/delivery-stats.d.ts +13 -1
  230. package/dist/transport/delivery-stats.js +18 -2
  231. package/dist/transport/delivery.d.ts +4 -3
  232. package/dist/transport/delivery.js +21 -7
  233. package/dist/transport/identity-delivery.d.ts +20 -0
  234. package/dist/transport/identity-delivery.js +41 -0
  235. package/dist/transport/index.d.ts +2 -0
  236. package/dist/transport/index.js +1 -0
  237. package/dist/transport/types/delivery-flow.types.d.ts +7 -0
  238. package/dist/turns/claude-transcript.js +4 -12
  239. package/dist/turns/codex-transcript.d.ts +9 -0
  240. package/dist/turns/codex-transcript.js +27 -19
  241. package/dist/turns/constants/turns.constants.d.ts +13 -12
  242. package/dist/turns/constants/turns.constants.js +15 -19
  243. package/dist/turns/gemini-transcript.d.ts +19 -1
  244. package/dist/turns/gemini-transcript.js +29 -18
  245. package/dist/turns/index.d.ts +3 -4
  246. package/dist/turns/index.js +2 -3
  247. package/dist/turns/run-state.d.ts +71 -0
  248. package/dist/turns/run-state.js +114 -0
  249. package/dist/turns/tool-events.d.ts +11 -1
  250. package/dist/turns/tool-events.js +32 -9
  251. package/dist/turns/transcript.d.ts +15 -14
  252. package/dist/turns/transcript.js +23 -4
  253. package/dist/turns/turn-state.d.ts +49 -7
  254. package/dist/turns/turn-state.js +78 -10
  255. package/dist/turns/turn-summary.js +7 -2
  256. package/dist/turns/turn-tracker.d.ts +9 -16
  257. package/dist/turns/turn-tracker.js +162 -86
  258. package/dist/turns/types/transcript.types.d.ts +11 -1
  259. package/dist/turns/types/turn-provider.types.d.ts +33 -0
  260. package/dist/turns/types/turn-provider.types.js +1 -0
  261. package/dist/turns/types/turn-state.types.d.ts +9 -0
  262. package/dist/turns/types/turn-summary.types.d.ts +17 -1
  263. package/dist/turns/types/turn-tracker.types.d.ts +3 -1
  264. package/dist/turns/work-checkout.js +1 -2
  265. package/docs/AUDIT_PROMPT.md +10 -0
  266. package/docs/DATA_HANDLING.md +193 -7
  267. package/docs/ENTERPRISE_DEPLOYMENT.md +1 -1
  268. package/docs/PERFORMANCE.md +10 -0
  269. package/package.json +3 -2
  270. package/dist/events/canonical-event.d.ts +0 -10
  271. package/dist/events/canonical-event.js +0 -9
  272. package/dist/git/repository-root.d.ts +0 -39
  273. package/dist/git/repository-root.js +0 -131
  274. package/dist/git/types/repository-root.types.d.ts +0 -11
  275. package/dist/transport/transport.d.ts +0 -6
  276. package/dist/turns/codex-originator.d.ts +0 -11
  277. package/dist/turns/cursor-transcript.d.ts +0 -21
  278. package/dist/turns/cursor-transcript.js +0 -66
  279. package/dist/turns/native-session-titles.d.ts +0 -26
  280. package/dist/turns/native-session-titles.js +0 -102
  281. /package/dist/{git/types/repository-root.types.js → billing/types/billing.types.js} +0 -0
  282. /package/dist/{transport/transport.js → capture/types/capture.types.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -2,10 +2,220 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.7.0
6
+
7
+ - `agentwatch setup --agent <id>` now installs hooks into that one agent only. Before, the
8
+ flag was ignored and setup wrote hooks and native telemetry into every detected
9
+ agent. The native exporter settings (signals, endpoint, identity) are machine-wide,
10
+ so setup still rewrites the exporter of every agent installed before, not only the
11
+ one named. An unknown id, or an agent that is not detected, is refused before anything
12
+ is written. Setup with `--agent` starts no background replay, since a replay reads
13
+ every agent's sessions; `agentwatch replay` still does that by hand.
14
+ `uninstall --agent <id> --purge` is refused instead of skipping the purge without a
15
+ word. `--agent` is taken by setup, uninstall and hook; `off`, `on`, `doctor` and
16
+ `replay` now refuse it and exit 1 instead of acting on every agent, and
17
+ `uninstall --agent` with no value is refused instead of removing every agent and
18
+ revoking the device. `status` names a flag it does not take and still exits 0. The
19
+ help lists all five ids: claude, codex, cursor, gemini, antigravity.
20
+ - Cursor: setup no longer hooks `afterTabFileEdit` (a hook process on every Tab
21
+ accept that no turn could use) and takes an older registration off; run
22
+ `agentwatch setup` again to remove it from an existing install. Background
23
+ agent turns report surface `cloud`. A project `.cursor` folder counts as Cursor
24
+ installed only when it holds `hooks.json`. MCP server memos idle for 7 days are
25
+ deleted, checked at most once a day. Run
26
+ capture reads the editor settings under `%APPDATA%` on Windows.
27
+ - `agentwatch status` now shows what an agent cannot report, as doctor already did
28
+ for Cursor, while its hooks are installed and Agent Watch is on: no token usage in
29
+ its hooks or transcripts, and only shell hooks from `cursor-agent`. Setup prints
30
+ both notes for Cursor now, not only the first. A Cursor Stop no longer reads the
31
+ transcript tail for usage it never holds.
32
+ - The end of a Claude Code turn no longer waits for Edge to send it. In a terminal
33
+ session the Stop and SubagentStop hooks hand their work to a background process and
34
+ return in about 0.1 s; before, the developer waited for the send, about 1 s typically
35
+ and up to 6 s. Headless runs (`claude -p`, the Agent SDK, the GitHub Action) still process their Stop
36
+ before returning, because the session ends right after it. Nothing changes in
37
+ `~/.claude/settings.json`, so there is no need to run `agentwatch setup` again.
38
+ - A folder in `ignoredRoots` now also stops Claude Code's own telemetry: `agentwatch
39
+ otel-headers` prints no credential there, so the LLM calls Claude Code exports
40
+ from that folder are refused and nothing from it is counted. Claude Code asks for
41
+ headers about every 29 minutes, so a call exported with a header it already held
42
+ can still arrive. Codex and Gemini CLI keep a fixed credential in their own config
43
+ file and still export from an ignored folder.
44
+ - Run capture now reaches Codex and Gemini CLI as well. Setup adds the capture copy
45
+ to `NODE_OPTIONS` and `PYTHONPATH` in `[shell_environment_policy.set]` of Codex's
46
+ `config.toml` and in `~/.gemini/.env`, keeping any value you have there, and
47
+ uninstall takes out only those parts. It does not depend on those agents' native
48
+ export: usage only, so a developer's own telemetry config or withheld content
49
+ consent does not stop it. `agentwatch status` and `agentwatch doctor` say per agent
50
+ when it is off and why, including a Codex include filter that strips the keys, and
51
+ a project `.env` or a shell value that hides Gemini's. Cursor and Antigravity report
52
+ "no environment route" and nothing is written for them until the route is verified
53
+ on the app. The capture copy stays until the last agent's hooks are gone.
54
+ Setup also adds `<data dir>/captured`, and only that folder, to
55
+ `[sandbox_workspace_write] writable_roots` in Codex's `config.toml`; your entries
56
+ stay, credentials and the rest of the data dir stay outside it, and uninstall takes
57
+ out only our entry. Under Codex's default workspace-write sandbox on macOS, a
58
+ script's call is captured only if the script can reach the network and the record
59
+ can be attributed. Today the sandbox denies `ps`, so such records are dropped; the
60
+ spool root is in place for when that is fixed. Status says so, and names what works
61
+ today: `sandbox_mode = "danger-full-access"` or an escalated command. It says off,
62
+ and to run `agentwatch setup`, when the entry is missing, and warns under
63
+ `sandbox_mode = "read-only"` or a `default_permissions` profile, which Edge does not
64
+ edit.
65
+ - Edge counts the LLM calls of code Claude Code runs. A script Claude Code starts
66
+ through its shell tool, in the foreground or the background, has each Anthropic,
67
+ OpenAI, Google (Gemini, Vertex AI) and Bedrock call recorded, through an SDK or
68
+ raw HTTP, and delivered as a call of the session and turn that ran it, labelled
69
+ with the entry file. Usage only: no prompt, response or key is read or kept. Setup
70
+ copies the capture shims to `<data dir>/capture/` and adds that copy to
71
+ `NODE_OPTIONS` (`--require`) and `PYTHONPATH` in Claude Code's settings, keeping
72
+ the value you have. Uninstall takes out the copy and only those parts; restart
73
+ running Claude Code sessions after it, because Node refuses to start when a
74
+ `--require` target is missing. After updating Edge, run `agentwatch setup` to
75
+ refresh the copy; `agentwatch status` warns when it is out of date, and shows run
76
+ capture per agent and why when it is off. The untraced-runs notice is no longer
77
+ shown for a run whose calls were captured. Run `agentwatch setup` again and restart
78
+ Claude Code to turn it on.
79
+ - Each Claude Code cloud session claims a device of its own.
80
+ `agentwatch setup --cloud` runs from the organization's managed SessionStart
81
+ hook. In a Claude Code cloud session with no credential, it signs a claim with
82
+ the organization's cloud session key from the managed settings
83
+ (`AGENTWATCH_CLOUD_ORGANIZATION`, `AGENTWATCH_CLOUD_KEY`), trades it for a
84
+ device for the developer's Claude account email, and installs as setup does.
85
+ Every cloud VM is its own device, so two sessions no longer share one
86
+ credential. It never uses the VM's git email, installs nothing when no account
87
+ email is found, returns at once on resume, does nothing outside a cloud
88
+ session, and always exits 0. The README's managed settings block changes to
89
+ the one Settings shows; the setup-script path with an install key is unchanged.
90
+ - Edge refreshes its device token once when the gateway answers a plain 401.
91
+ When a second holder of the same device credential refreshed it, the first
92
+ holder's access token was dropped, the gateway answered a bare 401, and Edge
93
+ stopped sending and queued until the cached token aged out. Edge now refreshes
94
+ once, resends the batch once, and only then stops sending. Answers that name a
95
+ reason (revoked, unknown, expired secret, installation mismatch) behave as
96
+ before.
97
+ - Edge resends the repository's file listing (`repo.tree`, used when there is
98
+ no GitHub App) when the default branch's tree changes. It was sent once and
99
+ never refreshed, so files added later stayed unknown and tool use on them
100
+ could not be attributed. Edge compares the tree with the one it sent at most
101
+ once an hour per repository (one git lookup) and resends on a difference.
102
+ - Cursor turn summaries carry the Cursor account email (`account_email`, from
103
+ the hook's `user_email`) beside `developer_id`, except on a machine that
104
+ serves two tenants, and the session's mode from its sessionStart
105
+ (`session_mode` from `composer_mode`, `is_cloud_agent` from
106
+ `is_background_agent`). Needs the core contract that declares these fields;
107
+ an older core drops them.
108
+ - `agentwatch on` no longer stays disabled when an agent has its own telemetry
109
+ config that AgentWatch refuses to overwrite (Claude Code OTLP keys or its own
110
+ `otelHeadersHelper`, a Codex `[otel]` section, Gemini telemetry keys). That agent is skipped, as setup
111
+ skips it, and the off switch is cleared; before, `on` and `setup` refused
112
+ until `disabled.json` was deleted by hand.
113
+ - `agentwatch off` and `uninstall` no longer remove Claude Code telemetry
114
+ settings the developer had before AgentWatch: setup records what each key
115
+ held before it was set and uninstall puts it back, value and type alike.
116
+ With no record, env keys are removed only while the base OTLP endpoint is an
117
+ Agent Watch one, a signal sent to the developer's own per-signal endpoint
118
+ keeps what it needs, and every key left in place is named. Setups recorded by
119
+ earlier versions have no prior values, so their keys are still only removed.
120
+ - Setup, `off`, `on` and uninstall keep a symlinked agent JSON config
121
+ (`~/.claude/settings.json`, `~/.gemini/settings.json`, the Codex, Cursor and
122
+ Antigravity `hooks.json`, for example linked into a dotfiles repository by
123
+ stow or chezmoi): it is written at the link's target instead of the link
124
+ being replaced by a regular file. Codex `config.toml` and Gemini `.env` still
125
+ replace a link, because they hold the bearer token and it must not land in a
126
+ dotfiles repository.
127
+ - `agentwatch replay` (and setup's background replay) now replays Codex and
128
+ Gemini CLI sessions too, from `~/.codex/sessions` and `~/.gemini/tmp`, under
129
+ the same rules as Claude Code: metadata only, the 30-day window clamped to
130
+ the open charge period, the same throttle, `ignoredRoots` and per-folder
131
+ `.agentwatch.json`, and `replay.progress` counting every agent together.
132
+ Codex turns carry the live hook's `turn_id`, the repository of their folder
133
+ and no branch. Gemini chat files do not record the live hook's id, so only
134
+ Gemini turns that began before AgentWatch first installed Gemini hooks on the
135
+ machine are replayed (install state now records `hooksFirstInstalledAt`); a
136
+ machine whose Gemini hooks predate this version replays none. Gemini sessions
137
+ written before gemini-cli 0.46 record no token counts and are skipped, not
138
+ sent as `pending` turns. Setup reports any existing replay state for the
139
+ current identity and writes one machine-wide attempt marker, so a later setup
140
+ never starts a second automatic replay even after the credential changes. An
141
+ explicit `agentwatch replay --machine` or `--root <path>` still starts fresh.
142
+ - Checks run by background subagents, and checks past the 200-call cap, are
143
+ now sent. A tool record that completes after its turn closed rides the next
144
+ Stop's `tool_events` instead of waiting for the 24 h sweep, and the cap keeps
145
+ checks ahead of other calls.
146
+ - Claude Code turns carry names only: `tool_events[].skill` for a Skill call and
147
+ the turn summary's `command` for the slash command a first prompt opens with.
148
+ Both are withheld when `capture.git` is off and are listed in
149
+ `docs/DATA_HANDLING.md`. Older platforms ignore them.
150
+ - `ignoredRoots` in the machine config (global only): a plain entry ignores that
151
+ directory, `<dir>/**` its subtree. A hook in an ignored directory parses,
152
+ enforces, sends and queues nothing, and replay skips it. A malformed list is
153
+ refused, not read as empty.
154
+ - `repo.snapshot` leaves out branches whose work is already on the default
155
+ branch: no commits of their own (fully merged, or never committed on), a
156
+ squash or rebase merge `git merge-tree` shows changes nothing (git >= 2.38),
157
+ or an upstream that is `[gone]` on first sight (a branch already recorded
158
+ always gets a real check, so commits after the merge are sent). The ten-branch
159
+ window fills from the next-newest live branches: up to 100 are listed and at
160
+ most 20 checked per snapshot, inside the one-second budget. Unknown stays
161
+ sent: no trunk, an old git, a timeout or a merge that conflicts keep the
162
+ branch. Merged verdicts are cached by head and base, so they are not checked
163
+ again and new commits send the branch again. Every edge git call now runs
164
+ with `GIT_NO_LAZY_FETCH=1`, so a partial clone never fetches inside a hook.
165
+ - Gemini CLI is no longer reported as detected on a machine that only has
166
+ Antigravity. Antigravity also lives in `~/.gemini`, so the directory alone no
167
+ longer counts, nor do the Google sign-in files the two share: detection needs
168
+ a file only Gemini CLI writes (`tmp/`, `installation_id`, or a
169
+ `settings.json` holding more than what AgentWatch setup wrote), and a
170
+ `.gemini` in the working tree counts only when it is not the Gemini home or
171
+ `~/.gemini`.
5
172
  - `@agent-watch-ai/otel` (npm) and `agent-watch-otel` (PyPI) are released
6
173
  together from one `otel-vX.Y.Z` tag by `otel-release.yml`, at one version and
7
174
  only when both suites pass. `python-release.yml` no longer publishes alone.
8
175
 
176
+ ### Setup replays the developer's earlier Claude Code sessions
177
+
178
+ `agentwatch setup` now starts, in the background, a replay of the Claude Code
179
+ sessions already on the machine (`~/.claude/projects`), so a newly installed
180
+ developer appears with recent history instead of after their next session. It
181
+ sends the same metadata the hooks send for a turn (never prompt text unless
182
+ prompt capture is already on, never a commit), only for the last 30 days
183
+ (`--replay-days N`) and never from before the open charge period, one turn id
184
+ per prompt so it can never double-count a live turn or a second replay.
185
+ `--no-replay` skips it; `agentwatch replay --stop`, `--resume` and `--dry-run`
186
+ control it; `agentwatch status` shows its progress. It runs at the lowest
187
+ priority, 20 turns every 5 seconds, and waits while the machine is busy, on
188
+ battery or an agent is working. New record `replay.progress` (counts and the
189
+ window only). Needs a platform that accepts `replay.progress` and a replayed
190
+ `pending` turn status.
191
+
192
+ ### `@agent-watch-ai/otel` and `agent-watch-otel` 0.2.1
193
+
194
+ - Fixed (Node): an application whose OpenTelemetry resource still had a promised
195
+ attribute, such as the `host.id` of NodeSDK's default host detector, logged
196
+ "Accessing resource attributes before async attributes settled" for each LLM
197
+ span. The processor now reads the attributes that are already known
198
+ (`service.name`, `service.version`) and leaves the pending ones out, without
199
+ waiting. No span or call is dropped. The Python package changes only its version.
200
+
201
+ ### `@agent-watch-ai/otel` and `agent-watch-otel` 0.2.0
202
+
203
+ - **Changed: which agent a call is charged to.** An LLM span's agent is now the
204
+ first of the span attributes `agent.name`, `gen_ai.agent.name` and `llm.task`
205
+ that is set and not blank, and the span name only when none is. Before, it
206
+ was always the span name. An application that declares an agent name now
207
+ reports that name, in the stored call and in the pre-call budget check alike,
208
+ where 0.1.0 reported the span name. It is the rule Agent Watch already uses
209
+ when it reads the same spans from Phoenix or Langfuse, so both now name one
210
+ agent with one cap. Such an application's agents appear under their new
211
+ names from the upgrade on; history recorded under the span name stays where
212
+ it is. `guard(agentName)` with an explicit name is unchanged.
213
+ - A model call that reached the provider and failed (a 5xx, or a timeout or
214
+ reset after the request was sent) is reported as `errored`, with its input
215
+ estimated from the request body's size when the provider gave no count. A
216
+ 4xx, 429 included, is reported errored with no estimate; a call that never
217
+ connected carries neither.
218
+
9
219
  ## 0.6.0
10
220
 
11
221
  ### New record: `repo.tree`
@@ -16,7 +226,7 @@ declaration and route names, read from git's object store: never file contents,
16
226
  never the working copy, no blob or tree ids. It is what a tenant with no GitHub
17
227
  App gets its feature catalog named from. Needs `capture.git` and
18
228
  `capture.files`; `docs/DATA_HANDLING.md` lists every field. Needs a platform
19
- that accepts `repo.tree` (AWT-680).
229
+ that accepts `repo.tree`.
20
230
 
21
231
  ### Fields nothing reads are no longer sent
22
232
 
@@ -25,7 +235,7 @@ response's length and SHA-256), sends at most one `prompt_jira_ids` key (the
25
235
  platform reads only the first), and sends `content_hashes` as blob ids without
26
236
  paths. `repo.snapshot` drops branch `last_commit_at`, commit `authored_at` and
27
237
  each file's `status` letter. Records queued by an older release lose the same
28
- fields at delivery. Needs a platform that accepts their absence (AWT-682).
238
+ fields at delivery. Needs a platform that accepts their absence.
29
239
 
30
240
  ## 0.5.0
31
241
 
@@ -37,7 +247,7 @@ Antigravity. Each record has the tool, call id, status, exit code, start and
37
247
  end times, and a fingerprint of the command or connector arguments, hashed in
38
248
  memory. An allowlisted check that ran also carries HEAD and a digest of the
39
249
  working tree. Nothing is sent with `capture.git` off. `docs/DATA_HANDLING.md`
40
- lists every field. Needs a platform that accepts `tool_events` (AWT-674).
250
+ lists every field. Needs a platform that accepts `tool_events`.
41
251
 
42
252
  ### Behaviour change: Gemini CLI telemetry moves to `~/.gemini/.env`
43
253
 
@@ -114,7 +324,7 @@ version left in `settings.json`. Re-run setup on machines with Gemini CLI.
114
324
  - After a browser sign-in, setup names the account that approved it as the
115
325
  developer (`developer: you@company.com (signed in)`) and stores that email,
116
326
  instead of this checkout's git email. A gateway that does not yet send the
117
- approver (before AWT-555) gets the email stored on this machine with a note that the
327
+ approver gets the email stored on this machine with a note that the
118
328
  platform credits the approver; an approver that is not a plain email is
119
329
  ignored. The approver also replaces an explicit `--developer-email` for that
120
330
  scope, and it is the email hooks send with each turn and match per-developer
@@ -144,7 +354,7 @@ On its first run that reaches the backend, the edge trades the install key in
144
354
  `~/.agentwatch/config.json` for a per-device credential (`POST /v1/devices/enroll`),
145
355
  keeps the device secret in the macOS Keychain, libsecret or Windows DPAPI, and
146
356
  records the device beside the key in the config (the key stays until Codex and
147
- Gemini move to short-lived tokens, AWT-357). Hooks, `status`, `doctor` and the Claude Code
357
+ Gemini move to short-lived tokens). Hooks, `status`, `doctor` and the Claude Code
148
358
  header helper send a one-hour access token, refreshed by one process per machine.
149
359
  Without a keychain the secret is a 0600 file and `status`/`doctor` say so. A
150
360
  revoked device queues events and is reported once. `uninstall` removes the secret.
@@ -163,7 +373,7 @@ repo `.agentwatch.json` cannot set `device`. See `SECURITY.md` and `docs/DATA_HA
163
373
  A turn in a checkout with no branch checked out (an automated reviewer's
164
374
  worktree, or `git checkout <sha>`) now reports, as its branch, the one
165
375
  remote-tracking branch whose tip is the checked-out commit, without its remote's
166
- prefix, and that branch's ticket keys (AWT-439). When no branch or several point
376
+ prefix, and that branch's ticket keys. When no branch or several point
167
377
  there, or one of them is the repository's default branch (`<remote>/HEAD` names
168
378
  it, else `main` or `master`), the turn reports no branch, as before. A branch another
169
379
  active session changed is still withheld.
@@ -175,7 +385,7 @@ is sent beyond the branch name a checked-out branch would have sent.
175
385
  ### Behaviour change: sessions sharing a checkout are judged by their own work
176
386
 
177
387
  When several agent sessions work in one checkout, a turn no longer takes another
178
- session's work as its own (AWT-438):
388
+ session's work as its own:
179
389
 
180
390
  - A branch switch, pull or reset with no commit of the turn's own is no change.
181
391
  Before, it counted as a lesser change. An empty commit of the turn's own still
@@ -219,7 +429,7 @@ The edge now extracts ticket keys (same syntax as branch keys) from a session's
219
429
  opening prompt, on the machine, and sends them as `prompt_jira_ids` on every turn
220
430
  summary, at every tier, with no consent step. Every candidate key is sent, with no
221
431
  prefix filter, and the platform keeps only keys it knows; the edge no longer
222
- calls `GET /v1/ticket-prefixes` (AWT-326). The prompt text still leaves
432
+ calls `GET /v1/ticket-prefixes`. The prompt text still leaves
223
433
  only with `capture.promptText`. The keys are kept in a local memo,
224
434
  `prompt-tickets.json`, whose 24-hour expiry counts from SessionEnd.
225
435
  `capture.git: false` withholds `prompt_jira_ids`. See `docs/DATA_HANDLING.md`.
@@ -308,7 +518,7 @@ latency without introducing competing timeout controls. CLI/status transports
308
518
  remain reusable with a fresh timeout per request (3 seconds in status), including
309
519
  bounded isolation probes. Local budget deferrals do not spend retry attempts.
310
520
 
311
- ### New: browser sign-in enrollment (AWT-538)
521
+ ### New: browser sign-in enrollment
312
522
 
313
523
  `agentwatch setup "https://<backend>?organization=<organization id>"` starts a
314
524
  device-code session, prints the verification link and code, and polls until the
package/README.md CHANGED
@@ -59,7 +59,302 @@ Per-agent notes:
59
59
  * **OpenAI Codex** — new hooks must be trusted once: launch `codex`, type `/hooks`, approve the AgentWatch entries.
60
60
  * **Gemini CLI** — telemetry is written to `~/.gemini/.env` (Gemini 0.63+ does not apply the `settings.json` `env` block): `GEMINI_TELEMETRY_ENABLED` with `GEMINI_TELEMETRY_TARGET=local`, and the access token in `OTEL_EXPORTER_OTLP_HEADERS`; Gemini has no `otelHeadersHelper`. Gemini loads that file only in a trusted folder, and a project `.env` or `.gemini/.env` found first replaces it. The switch, target and endpoint are also set in the `settings.json` `telemetry` block, and `agentwatch status` warns when a project `.env` hides the token.
61
61
  * **Google Antigravity** — a turn is one *execution*: `PreInvocation`/`PostInvocation` bracket the model calls inside it and only `Stop` closes it. The prompt comes from `common.lastUserInput`; there is no user-prompt hook.
62
- * **Cursor** — the CLI emits shell hooks only; the full lifecycle exists in IDE sessions. Cloud agents need a committed `.cursor/hooks.json` and the package installed in the cloud environment. Accepted tab edits (`afterTabFileEdit`) are monitored; high-frequency `beforeTabFileRead` is ignored.
62
+ * **Cursor** — the CLI emits shell hooks only; the full lifecycle exists in IDE sessions. Cloud agents need a committed `.cursor/hooks.json` and the package installed in the cloud environment. Tab completions (`afterTabFileEdit`, `beforeTabFileRead`) are not hooked: they fire on every accept and belong to no conversation. Background agent turns report surface `cloud`. Cursor cost comes from the Cursor Admin API connection in Integrations.
63
+
64
+ ---
65
+
66
+ ## Claude Code cloud sessions
67
+
68
+ Sessions at claude.ai/code (and `claude --cloud`) run in a fresh VM per session, and that VM never
69
+ reads `~/.claude/settings.json`. So the hooks `agentwatch setup` writes there do not run in the cloud. A
70
+ cloud session runs hooks from two places only: the repository's committed `.claude/settings.json`
71
+ (any plan), and the organization's server-managed settings (Team and Enterprise).
72
+
73
+ ### Any plan: setup script and committed hooks
74
+
75
+ Repository hooks run only in a session with **one** repository that is not a Project thread. Three
76
+ steps, all needed:
77
+
78
+ **1. Environment setup script** (in the environment dialog). It runs as root before the environment's
79
+ variables are set, so the install key has to be written into the script itself:
80
+
81
+ ```bash
82
+ npm install -g @agent-watch-ai/edge
83
+ mkdir -p ~/.claude
84
+ NODE_USE_ENV_PROXY=1 agentwatch setup --token YOUR_INSTALL_KEY \
85
+ --developer-email you@company.com --developer-name "Your Name" --no-replay || true
86
+ ```
87
+
88
+ * `mkdir -p ~/.claude`: without it, setup can find no Claude Code yet, exits 0 and writes nothing.
89
+ * `--developer-email` and `--developer-name`: the VM's git identity is `Claude <noreply@anthropic.com>`,
90
+ and without these flags every turn would be labelled with that name.
91
+ * `|| true`: a setup script that exits non-zero stops the session from starting. A failed setup
92
+ must not do that.
93
+ * Use a **personal** environment. Anyone who uses an environment can read its setup script, and
94
+ the snapshot bakes in one developer's email. In a shared organization environment, every
95
+ member's work would be reported as that one developer.
96
+
97
+ **2. Network access: Custom**, with `api.agent-watch.ai` on the allowed domains list and "Also
98
+ include default list of common package managers" checked (npm needs it). On the default Trusted
99
+ level the gateway is refused and every turn stays queued.
100
+
101
+ **3. Commit the hooks** as `.claude/settings.json` in the repository. Merge them with any hooks
102
+ already there:
103
+
104
+ ```json
105
+ {
106
+ "hooks": {
107
+ "SessionStart": [{ "hooks": [{ "type": "command", "timeout": 30, "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude" }] }],
108
+ "SessionEnd": [{ "hooks": [{ "type": "command", "timeout": 30, "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude" }] }],
109
+ "UserPromptSubmit": [{ "hooks": [{ "type": "command", "timeout": 30, "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude" }] }],
110
+ "PreToolUse": [{ "matcher": "*", "hooks": [{ "type": "command", "timeout": 30, "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude" }] }],
111
+ "PostToolUse": [{ "matcher": "*", "hooks": [{ "type": "command", "timeout": 30, "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude" }] }],
112
+ "PostToolUseFailure": [{ "matcher": "*", "hooks": [{ "type": "command", "timeout": 30, "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude" }] }],
113
+ "PermissionRequest": [{ "matcher": "*", "hooks": [{ "type": "command", "timeout": 30, "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude" }] }],
114
+ "Stop": [{ "hooks": [{ "type": "command", "timeout": 30, "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude" }] }],
115
+ "SubagentStart": [{ "hooks": [{ "type": "command", "timeout": 30, "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude" }] }],
116
+ "SubagentStop": [{ "hooks": [{ "type": "command", "timeout": 30, "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude" }] }]
117
+ }
118
+ }
119
+ ```
120
+
121
+ The guard makes the file a no-op everywhere except a cloud session (`CLAUDE_CODE_REMOTE=true`) that has
122
+ Edge installed. So a teammate's laptop, which reports through its own user-level hooks, is not
123
+ counted twice. `NODE_USE_ENV_PROXY=1` (Node 22.21+ or 24+) makes Node's `fetch` honour the
124
+ session's `HTTPS_PROXY`, which it otherwise ignores. Without it, records stay queued.
125
+
126
+ Known limits:
127
+
128
+ * **Not covered**: a session with several repositories reads only `enabledPlugins` and
129
+ `extraKnownMarketplaces` from each repository's settings, so no hooks run. A thread inside a
130
+ claude.ai Project reads no repository hooks or `env` at all.
131
+ * **Cost comes from the session transcript only** (`usage_status: provisional`). Telemetry export
132
+ variables never apply from a repository's `.claude/settings.json`, and the user settings file that
133
+ `setup` configures them in is not read. So there is no `llm.call` ledger for these turns.
134
+ * **A turn is sent when it ends.** If the gateway cannot be reached at that moment, the turn waits
135
+ in the queue on the VM's disk and goes with the next turn. When the session's VM is reclaimed,
136
+ whatever is still queued is lost.
137
+ * **The install key lives in the environment's setup script**, readable by anyone who can use that
138
+ environment. Rotating it means editing the script, which also rebuilds the environment's cache.
139
+
140
+ ### Team and Enterprise: server-managed settings and a cloud session key (experimental)
141
+
142
+ Not yet run in a real cloud session. Until it has been, use the any-plan path above as the
143
+ fallback.
144
+
145
+ Every cloud VM claims a device of its own, for the developer signed in to the session, with no
146
+ per-developer setup and no install key. Server-managed settings reach every cloud session,
147
+ multi-repository ones included, with no repository file.
148
+
149
+ **1. Generate the cloud session key.** An Agent Watch admin opens **Settings** and generates the
150
+ organization's cloud session key. Settings shows this block once, with your organization's id and
151
+ private key in place of the placeholders:
152
+
153
+ ```json
154
+ {
155
+ "env": {
156
+ "AGENTWATCH_CLOUD_ORGANIZATION": "YOUR_ORGANIZATION_ID",
157
+ "AGENTWATCH_CLOUD_KEY": "YOUR_CLOUD_SESSION_KEY",
158
+ "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
159
+ "OTEL_LOGS_EXPORTER": "otlp",
160
+ "OTEL_METRICS_EXPORTER": "none",
161
+ "OTEL_TRACES_EXPORTER": "none",
162
+ "OTEL_EXPORTER_OTLP_PROTOCOL": "http/json",
163
+ "OTEL_EXPORTER_OTLP_ENDPOINT": "https://api.agent-watch.ai/v1/otlp",
164
+ "OTEL_LOG_USER_PROMPTS": "0",
165
+ "OTEL_LOG_TOOL_DETAILS": "0",
166
+ "OTEL_LOG_TOOL_CONTENT": "0"
167
+ },
168
+ "otelHeadersHelper": "command -v agentwatch >/dev/null || { echo '{}'; exit 0; }; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch otel-headers",
169
+ "hooks": {
170
+ "SessionStart": [
171
+ {
172
+ "matcher": "startup|resume",
173
+ "hooks": [
174
+ {
175
+ "type": "command",
176
+ "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] || exit 0; NODE_USE_ENV_PROXY=1 npx -y @agent-watch-ai/edge setup --cloud --no-replay >>/tmp/agentwatch-bootstrap.log 2>&1 || true"
177
+ }
178
+ ]
179
+ },
180
+ {
181
+ "hooks": [
182
+ {
183
+ "type": "command",
184
+ "timeout": 30,
185
+ "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude"
186
+ }
187
+ ]
188
+ }
189
+ ],
190
+ "SessionEnd": [
191
+ {
192
+ "hooks": [
193
+ {
194
+ "type": "command",
195
+ "timeout": 30,
196
+ "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude"
197
+ }
198
+ ]
199
+ }
200
+ ],
201
+ "UserPromptSubmit": [
202
+ {
203
+ "hooks": [
204
+ {
205
+ "type": "command",
206
+ "timeout": 30,
207
+ "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude"
208
+ }
209
+ ]
210
+ }
211
+ ],
212
+ "PreToolUse": [
213
+ {
214
+ "matcher": "*",
215
+ "hooks": [
216
+ {
217
+ "type": "command",
218
+ "timeout": 30,
219
+ "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude"
220
+ }
221
+ ]
222
+ }
223
+ ],
224
+ "PostToolUse": [
225
+ {
226
+ "matcher": "*",
227
+ "hooks": [
228
+ {
229
+ "type": "command",
230
+ "timeout": 30,
231
+ "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude"
232
+ }
233
+ ]
234
+ }
235
+ ],
236
+ "PostToolUseFailure": [
237
+ {
238
+ "matcher": "*",
239
+ "hooks": [
240
+ {
241
+ "type": "command",
242
+ "timeout": 30,
243
+ "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude"
244
+ }
245
+ ]
246
+ }
247
+ ],
248
+ "PermissionRequest": [
249
+ {
250
+ "matcher": "*",
251
+ "hooks": [
252
+ {
253
+ "type": "command",
254
+ "timeout": 30,
255
+ "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude"
256
+ }
257
+ ]
258
+ }
259
+ ],
260
+ "Stop": [
261
+ {
262
+ "hooks": [
263
+ {
264
+ "type": "command",
265
+ "timeout": 30,
266
+ "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude"
267
+ }
268
+ ]
269
+ }
270
+ ],
271
+ "SubagentStart": [
272
+ {
273
+ "hooks": [
274
+ {
275
+ "type": "command",
276
+ "timeout": 30,
277
+ "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude"
278
+ }
279
+ ]
280
+ }
281
+ ],
282
+ "SubagentStop": [
283
+ {
284
+ "hooks": [
285
+ {
286
+ "type": "command",
287
+ "timeout": 30,
288
+ "command": "[ \"$CLAUDE_CODE_REMOTE\" = true ] && command -v agentwatch >/dev/null || exit 0; NODE_USE_ENV_PROXY=1 NODE_NO_WARNINGS=1 exec agentwatch hook --agent claude"
289
+ }
290
+ ]
291
+ }
292
+ ]
293
+ }
294
+ }
295
+ ```
296
+
297
+ The block holds everything: the claim, the hooks that send each turn, and Claude Code's usage
298
+ export. The hooks do nothing outside a cloud session. In one, `npx` installs Edge on the VM and runs
299
+ `agentwatch setup --cloud`, which claims the device. Its output goes to
300
+ `/tmp/agentwatch-bootstrap.log`, not into the session.
301
+
302
+ **2. Paste it into managed settings**, in **Organization settings > Claude Code > Managed settings**
303
+ on claude.ai. This needs the Team or Enterprise plan and the Owner or Primary Owner role in your
304
+ Claude organization. If the organization already has managed settings, the two have to be combined.
305
+
306
+ No setup script is needed. Do not run `agentwatch setup` in one: its filesystem is snapshotted and
307
+ reused by later sessions, and every VM would then share one device.
308
+
309
+ **What `agentwatch setup --cloud` does.** Only in a cloud session (`CLAUDE_CODE_REMOTE=true`) with
310
+ no Agent Watch credential yet:
311
+
312
+ * It reads the organization id and key from the managed `env` above, and the developer's email from
313
+ the session's Claude account (`oauthAccount.emailAddress` in `~/.claude.json`). Never git's
314
+ `noreply@anthropic.com`: without an account email it installs nothing and logs one line saying so.
315
+ * It signs a claim with the key (Node's built-in Ed25519), trades it for a device of this VM's own,
316
+ and stores it the way `setup` does. Every VM is its own device, and each refreshes on its own.
317
+ * On `resume`, or anywhere a credential is already present, it returns at once, before `npx`
318
+ installs anything.
319
+ * It always exits 0: a refused claim or an unreachable Agent Watch never stops the session, and
320
+ turns stay queued on the VM.
321
+
322
+ Every member of the organization can read the key: it is in the approval dialog and in the settings
323
+ cache on each member's machine. Generating a new key in Settings replaces it at once; devices
324
+ already claimed keep working until they expire or are revoked.
325
+
326
+ **Never copy `~/.agentwatch` between VMs.** A raw copy carries the first VM's `installationId` (and,
327
+ from an install-key setup, its `token`), so two VMs would fight over one device. Let each VM claim
328
+ its own.
329
+
330
+ **What this does on laptops.** Server-managed settings apply wherever someone signs in to the
331
+ organization, laptops included:
332
+
333
+ * **The hooks do nothing there.** Each one exits at once outside a cloud session, before `npx` or
334
+ `agentwatch` runs. A laptop with Edge keeps reporting through its own user-level hooks, once.
335
+ * **The telemetry `env` applies to every member.** Every member's Claude Code exports its usage
336
+ logs (token counts, model, cost; never prompt text or tool content) to `api.agent-watch.ai`:
337
+ * On a laptop with Edge, the export carries that machine's credential and lands in the
338
+ organization's Agent Watch account. Edge already sends it there.
339
+ * On a laptop without Edge, the export still leaves the machine and reaches Agent Watch. It
340
+ has no credential, so the gateway refuses it.
341
+ * Admins who do not want that should take `CLAUDE_CODE_ENABLE_TELEMETRY`, the `OTEL_*` values and
342
+ `otelHeadersHelper` out of the block, and keep the two `AGENTWATCH_CLOUD_*` values. The hooks
343
+ then report cloud turns with cost from the transcript only.
344
+ * **Each member approves once.** Hooks, `otelHeadersHelper` and `OTEL_EXPORTER_OTLP_ENDPOINT` need a
345
+ one-time security approval in an interactive session. Declining it exits Claude Code.
346
+ Non-interactive runs apply the settings for that run without asking. The docs do not say which
347
+ of the two a cloud session at claude.ai/code is, so that is not yet verified.
348
+
349
+ **The network step.** No managed setting can add a domain to a cloud environment's allowlist. Each
350
+ environment needs network access **Custom**, with `api.agent-watch.ai` and "Also include default
351
+ list of common package managers" (`npx` needs npm). An Owner can do it once for everyone:
352
+ create an organization-shared environment with those settings on the **Cloud environments** admin
353
+ page, and make it the organization's default environment. Otherwise each developer sets it on
354
+ their own environment.
355
+
356
+ The cloud documentation behind each of these points, and the container runs that tested them, are in
357
+ [docs/CLAUDE_CODE_CLOUD.md](https://github.com/agent-watch-ai/agent-watch-edge/blob/main/docs/CLAUDE_CODE_CLOUD.md).
63
358
 
64
359
  ---
65
360
 
@@ -87,9 +382,12 @@ agentwatch otel-headers # print OTel headers f
87
382
  | `--allow-custom-endpoint` | Trust the origin of this run's `--endpoint` when it is outside the Agent Watch hosts, such as a self-hosted backend. Only that origin is stored, in `customEndpoints`, and `status` and `doctor` show it. A re-run naming an origin already trusted needs no flag. Without it, setup refuses such a URL and writes nothing, and a config that names one sends nothing there: records stay queued and `doctor` names the fix. A config written before this release keeps its backends: they are added to `customEndpoints` once, on first load. A native exporter AgentWatch wrote into an agent's own config that points at a refused host is removed by `setup`, by `doctor`, and by the hooks at most once a day; `otel-headers` gives Claude Code's exporter the bearer only when it sends to the configured, allowed host. TLS is still checked against the system trust store, with no pinning | off |
88
383
  | `--token <token>` | Bearer token for the backend | — |
89
384
  | `--developer-email <email>` | Identity on turn summaries, and what per-developer budgets key on. Setup refuses to write a config when neither this flag nor git names a developer | `git config user.email` |
90
- | `--root <path>` | File a second identity under a project root, so one machine can report to two tenants (needs its own `--token`) | — |
385
+ | `--root <path>` | With setup or replay, use the identity under this project root; setup needs its own `--token` | — |
386
+ | `--machine` | With replay, use the machine identity regardless of the shell directory | shell directory |
91
387
  | `--otel <signals>` | Signals the agents export: `logs`, `traces`, `metrics`, `all`, `none` | `logs` |
92
- | `--agent <id>` | Limit the command to one agent (`claude`, `codex`, `cursor`, `gemini`, `antigravity`) | all detected |
388
+ | `--replay-days <n>` | How many days of earlier Claude Code, Codex and Gemini CLI sessions the machine's one automatic setup replay covers; later setup runs never repeat it automatically (see "What reaches the backend") | `30` |
389
+ | `--no-replay` | Do not replay earlier sessions | replays |
390
+ | `--agent <id>` | With `setup`, `uninstall` and `hook`: limit the command to one agent (`claude`, `codex`, `cursor`, `gemini`, `antigravity`). Setup still updates the exporter of every agent installed before, since signals and endpoint are machine-wide. `off`, `on`, `doctor` and `replay` refuse it; `status` ignores it | all detected |
93
391
  | `--dry-run` | With `hook`: print the events instead of sending them | `false` |
94
392
  | `--json` | With `doctor`: machine-readable output | `false` |
95
393
  | `--verbose` | Diagnostic logs on stderr | `false` |
@@ -267,10 +565,11 @@ To try it locally: `BLOCK=1 npm run example` refuses every check.
267
565
 
268
566
  | Record | How | Contents |
269
567
  |---|---|---|
270
- | `turn.summary` | Edge hooks → `POST <backend>/v1/events` | One completed turn: tool counts, file paths (repo-relative, and home-relative outside a checkout), Git branch, ticket keys from the branch name and the first from the opening prompt. With Git capture on, `tool_events`: per tool call its order, status, exit code, times, a sha256 fingerprint of the normalized command or connector arguments (never the text), and for a test/lint/build check over 60 s the commit and a working-tree digest. Prompt text and shell/connector inputs only when opted in. Never response text. |
568
+ | `turn.summary` | Edge hooks → `POST <backend>/v1/events` | One completed turn: tool counts, file paths (repo-relative, and home-relative outside a checkout), Git branch, ticket keys from the branch name and the first from the opening prompt. With Git capture on, `tool_events`: per tool call its order, status, exit code, times, a sha256 fingerprint of the normalized command or connector arguments (never the text), and for a test/lint/build check over 60 s the commit and a working-tree digest; from Claude Code, also the name of a skill a `Skill` call ran (`skill`) and of the slash command the turn opened with (`command`, `/ship-it now` sends `ship-it`), names only, never arguments. Prompt text and shell/connector inputs only when opted in. Never response text. |
271
569
  | `llm.call` | The agent's own OTLP → `POST <backend>/v1/otlp/v1/logs` | Token usage, cost and latency per model request. The edge does not proxy this. |
272
570
  | `repo.snapshot` | Edge hooks, after a closed turn | Changed branch/commit metadata, including commit subjects, when Git capture is on. |
273
571
  | `repo.tree` | Edge hooks, after the first closed turn in a repository, once per install identity | The default branch's source paths and top-level declaration and route names, when Git and file capture are on. Never file contents. |
572
+ | `turn.summary` (replay) | The first eligible `agentwatch setup` on a machine starts, in the background, a slow replay of the developer's earlier Claude Code, Codex and Gemini CLI sessions from `~/.claude/projects`, `~/.codex/sessions` and `~/.gemini/tmp`. A machine-wide marker prevents later setup runs—even after signing in again—from repeating it automatically (`--replay-days N`, default 30; `--no-replay` skips without claiming it; explicit `agentwatch replay` remains available). | The same metadata a live turn carries (tokens, times, repository, branch, ticket keys, touched file paths; Codex and Gemini turns carry no branch or paths), nothing from before the open charge period, no commit, no prompt text unless prompt capture is already on. Gemini turns only from before Gemini hooks were first installed. Plus `replay.progress`: counts only. |
274
573
 
275
574
  The backend joins `llm.call` to `turn.summary` on conversation and turn ids.
276
575