@agent-watch-ai/edge 0.2.5 → 0.3.1

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 (346) hide show
  1. package/CHANGELOG.md +512 -0
  2. package/README.md +217 -96
  3. package/SECURITY.md +69 -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 +50 -4
  9. package/dist/cli/constants/cli.constants.js +54 -5
  10. package/dist/cli/context.d.ts +33 -2
  11. package/dist/cli/context.js +84 -14
  12. package/dist/cli/doctor.js +309 -32
  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 +439 -98
  26. package/dist/cli/status.js +82 -13
  27. package/dist/cli/toggle.d.ts +9 -0
  28. package/dist/cli/toggle.js +113 -0
  29. package/dist/cli/types/cli.types.d.ts +37 -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 +100 -13
  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 +113 -6
  41. package/dist/config/constants/config.constants.js +126 -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 +721 -84
  51. package/dist/config/schemas/config.schema.js +388 -15
  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 +111 -0
  71. package/dist/credentials/constants/credentials.constants.js +112 -0
  72. package/dist/credentials/credential-status.d.ts +14 -0
  73. package/dist/credentials/credential-status.js +34 -0
  74. package/dist/credentials/credentials.d.ts +72 -0
  75. package/dist/credentials/credentials.js +253 -0
  76. package/dist/credentials/device-api.d.ts +64 -0
  77. package/dist/credentials/device-api.js +150 -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 +62 -0
  81. package/dist/credentials/identity.js +90 -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 +18 -0
  93. package/dist/credentials/sign-in.js +86 -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 +195 -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 +62 -16
  104. package/dist/enforcement/enforcement.d.ts +23 -2
  105. package/dist/enforcement/enforcement.js +103 -15
  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 +64 -0
  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 +7 -0
  160. package/dist/pipeline/constants/pipeline.constants.js +7 -0
  161. package/dist/pipeline/hook-pipeline.js +360 -32
  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 +73 -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 +24 -2
  197. package/dist/providers/codex/codex.otel.js +147 -30
  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 +5 -0
  202. package/dist/providers/codex/constants/codex.otel.constants.js +5 -0
  203. package/dist/providers/constants/provider.constants.d.ts +0 -3
  204. package/dist/providers/constants/provider.constants.js +0 -3
  205. package/dist/providers/cursor/constants/cursor.constants.d.ts +7 -0
  206. package/dist/providers/cursor/constants/cursor.constants.js +7 -0
  207. package/dist/providers/cursor/cursor.adapter.d.ts +33 -1
  208. package/dist/providers/cursor/cursor.adapter.js +52 -3
  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 +3 -1
  215. package/dist/providers/gemini/constants/gemini.otel.constants.js +3 -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 +19 -20
  221. package/dist/providers/gemini/gemini.otel.js +121 -17
  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/constants/hook-refusal.constants.d.ts +7 -0
  232. package/dist/providers/shared/constants/hook-refusal.constants.js +7 -0
  233. package/dist/providers/shared/constants/shell-directories.constants.d.ts +30 -0
  234. package/dist/providers/shared/constants/shell-directories.constants.js +39 -0
  235. package/dist/providers/shared/constants/tooling.constants.d.ts +18 -2
  236. package/dist/providers/shared/constants/tooling.constants.js +19 -3
  237. package/dist/providers/shared/event-builder.d.ts +12 -14
  238. package/dist/providers/shared/event-builder.js +20 -14
  239. package/dist/providers/shared/exporter-allowlist.d.ts +20 -0
  240. package/dist/providers/shared/exporter-allowlist.js +49 -0
  241. package/dist/providers/shared/hook-config.d.ts +2 -21
  242. package/dist/providers/shared/hook-config.js +5 -4
  243. package/dist/providers/shared/hook-refusal.d.ts +12 -0
  244. package/dist/providers/shared/hook-refusal.js +17 -1
  245. package/dist/providers/shared/install-record.d.ts +12 -2
  246. package/dist/providers/shared/install-record.js +5 -2
  247. package/dist/providers/shared/shell-directories.d.ts +24 -0
  248. package/dist/providers/shared/shell-directories.js +90 -0
  249. package/dist/providers/shared/tooling.d.ts +12 -1
  250. package/dist/providers/shared/tooling.js +18 -0
  251. package/dist/providers/shared/types/adapter.types.d.ts +1 -2
  252. package/dist/providers/types/provider.types.d.ts +57 -1
  253. package/dist/snapshot/constants/snapshot.constants.d.ts +32 -0
  254. package/dist/snapshot/constants/snapshot.constants.js +33 -0
  255. package/dist/snapshot/snapshot-event.js +52 -11
  256. package/dist/snapshot/snapshot-pipeline.js +1 -1
  257. package/dist/snapshot/types/snapshot.types.d.ts +2 -0
  258. package/dist/storage/atomic-file.d.ts +7 -0
  259. package/dist/storage/atomic-file.js +1 -1
  260. package/dist/storage/constants/storage.constants.d.ts +17 -0
  261. package/dist/storage/constants/storage.constants.js +17 -0
  262. package/dist/storage/disabled.d.ts +13 -0
  263. package/dist/storage/disabled.js +24 -0
  264. package/dist/storage/index.d.ts +2 -0
  265. package/dist/storage/index.js +2 -0
  266. package/dist/storage/paths.js +3 -2
  267. package/dist/storage/schemas/storage.schema.d.ts +72 -0
  268. package/dist/storage/schemas/storage.schema.js +6 -0
  269. package/dist/storage/sweep-marker.d.ts +19 -0
  270. package/dist/storage/sweep-marker.js +55 -0
  271. package/dist/storage/types/storage.types.d.ts +2 -0
  272. package/dist/storage/uninstalled.d.ts +58 -0
  273. package/dist/storage/uninstalled.js +107 -0
  274. package/dist/transport/auth-block.d.ts +66 -0
  275. package/dist/transport/auth-block.js +129 -0
  276. package/dist/transport/constants/transport.constants.d.ts +82 -3
  277. package/dist/transport/constants/transport.constants.js +83 -4
  278. package/dist/transport/cooldown.js +8 -1
  279. package/dist/transport/delivery.d.ts +14 -6
  280. package/dist/transport/delivery.js +80 -55
  281. package/dist/transport/http-transport.d.ts +1 -0
  282. package/dist/transport/http-transport.js +52 -10
  283. package/dist/transport/index.d.ts +6 -3
  284. package/dist/transport/index.js +3 -0
  285. package/dist/transport/queue-partition.d.ts +91 -0
  286. package/dist/transport/queue-partition.js +143 -0
  287. package/dist/transport/queue.d.ts +99 -20
  288. package/dist/transport/queue.js +210 -69
  289. package/dist/transport/response-body.d.ts +25 -0
  290. package/dist/transport/response-body.js +64 -0
  291. package/dist/transport/send.d.ts +11 -0
  292. package/dist/transport/send.js +17 -0
  293. package/dist/transport/types/delivery-flow.types.d.ts +19 -0
  294. package/dist/transport/types/delivery-flow.types.js +1 -0
  295. package/dist/transport/types/transport.types.d.ts +45 -0
  296. package/dist/turns/claude-transcript.d.ts +19 -1
  297. package/dist/turns/claude-transcript.js +46 -1
  298. package/dist/turns/codex-originator.d.ts +11 -0
  299. package/dist/turns/codex-originator.js +31 -0
  300. package/dist/turns/codex-transcript.d.ts +30 -0
  301. package/dist/turns/codex-transcript.js +88 -0
  302. package/dist/turns/constants/turns.constants.d.ts +141 -5
  303. package/dist/turns/constants/turns.constants.js +155 -5
  304. package/dist/turns/file-identity.d.ts +27 -0
  305. package/dist/turns/file-identity.js +48 -0
  306. package/dist/turns/gemini-transcript.d.ts +30 -0
  307. package/dist/turns/gemini-transcript.js +96 -0
  308. package/dist/turns/index.d.ts +3 -3
  309. package/dist/turns/index.js +1 -1
  310. package/dist/turns/inherited-checkout.d.ts +54 -0
  311. package/dist/turns/inherited-checkout.js +155 -0
  312. package/dist/turns/native-session-titles.d.ts +26 -0
  313. package/dist/turns/native-session-titles.js +102 -0
  314. package/dist/turns/transcript.d.ts +3 -2
  315. package/dist/turns/transcript.js +5 -1
  316. package/dist/turns/turn-state.d.ts +224 -3
  317. package/dist/turns/turn-state.js +456 -21
  318. package/dist/turns/turn-summary.d.ts +1 -14
  319. package/dist/turns/turn-summary.js +87 -51
  320. package/dist/turns/turn-tracker.d.ts +21 -2
  321. package/dist/turns/turn-tracker.js +379 -56
  322. package/dist/turns/types/transcript.types.d.ts +5 -0
  323. package/dist/turns/types/turn-state.types.d.ts +116 -5
  324. package/dist/turns/types/turn-summary.types.d.ts +64 -14
  325. package/dist/turns/types/turn-tracker.types.d.ts +27 -1
  326. package/dist/turns/work-checkout.d.ts +65 -0
  327. package/dist/turns/work-checkout.js +666 -0
  328. package/dist/untraced/constants/untraced.constants.d.ts +31 -0
  329. package/dist/untraced/constants/untraced.constants.js +63 -0
  330. package/dist/untraced/untraced.d.ts +35 -0
  331. package/dist/untraced/untraced.js +105 -0
  332. package/dist/update/constants/update.constants.d.ts +18 -0
  333. package/dist/update/constants/update.constants.js +20 -0
  334. package/dist/update/update-check.d.ts +52 -0
  335. package/dist/update/update-check.js +113 -0
  336. package/docs/AUDIT_PROMPT.md +129 -0
  337. package/docs/DATA_HANDLING.md +648 -0
  338. package/docs/ENTERPRISE_DEPLOYMENT.md +179 -0
  339. package/docs/PERFORMANCE.md +81 -0
  340. package/package.json +14 -4
  341. package/dist/enrollment/enrollment-provider.d.ts +0 -5
  342. package/dist/enrollment/manual-enrollment.d.ts +0 -32
  343. package/dist/enrollment/manual-enrollment.js +0 -72
  344. package/example/README.md +0 -43
  345. package/example/server.mjs +0 -240
  346. /package/dist/{enrollment/enrollment-provider.js → config/types/destination.types.js} +0 -0
@@ -1,11 +1,23 @@
1
+ import type { FailOpenReason } from '../../enforcement/types/enforcement.types.js';
1
2
  import type { ContentEvidence } from '../../events/types/events.types.js';
2
- /** A prompt the developer submitted. */
3
+ import type { Fingerprint } from '../../git/types/git.types.js';
4
+ /** A prompt the developer submitted: when, its length and SHA-256, and its text when `promptText` is on. */
3
5
  export interface PromptRecord {
4
6
  readonly kind: 'prompt';
5
7
  readonly at: string;
6
8
  readonly turnId?: string;
7
- readonly text?: string;
8
9
  readonly evidence?: ContentEvidence;
10
+ /** Scrubbed and bounded; present only when `capture.promptText` was on at the prompt hook. */
11
+ readonly text?: string;
12
+ /**
13
+ * Why this prompt ran without an enforcement decision, when it did.
14
+ *
15
+ * On the prompt record because the check and the summary happen in different
16
+ * hook processes, and this record is the file the prompt hook writes anyway —
17
+ * so reporting a fail-open costs no write of its own, and it belongs to exactly
18
+ * the turn it happened on.
19
+ */
20
+ readonly failOpenReason?: FailOpenReason;
9
21
  }
10
22
  /** One tool call the agent completed. */
11
23
  export interface ToolRecord {
@@ -14,22 +26,121 @@ export interface ToolRecord {
14
26
  readonly turnId?: string;
15
27
  readonly tool?: string;
16
28
  readonly filePath?: string;
29
+ /**
30
+ * The absolute root of the checkout `filePath` is relative to, wherever it
31
+ * lies; absent for a file in no checkout, whose path is a bare basename.
32
+ *
33
+ * Local turn state only, never on the wire: it exists so the closing turn can
34
+ * decide which checkout the turn worked in. Absolute because the cwd each
35
+ * hook reports moves with a lasting `cd`, so a path relative to the tool
36
+ * hook's cwd means nothing to the Stop hook's.
37
+ */
38
+ readonly repositoryRoot?: string;
17
39
  /**
18
40
  * Reads and edits are different product signals: a file the agent merely
19
41
  * read must not appear in the summary's files_touched (modified) list.
20
42
  */
21
43
  readonly access?: 'read' | 'edit';
44
+ /** A file outside every checkout, home-relative; under `capture.files`. */
45
+ readonly externalPath?: string;
46
+ /** The shell command or connector call, bounded; under `capture.toolInput`. */
47
+ readonly input?: ToolInputSummary;
48
+ }
49
+ /** What went into one shell or connector (MCP) call, as the turn summary sends it. */
50
+ export interface ToolInputSummary {
51
+ readonly tool: string;
52
+ /** Shell command text. */
53
+ readonly command?: string;
54
+ /** Connector server: its name, or for Cursor its url or launch command. */
55
+ readonly server?: string;
56
+ /** Connector tool name. */
57
+ readonly name?: string;
58
+ /** Connector arguments as JSON text, cut at the bound. */
59
+ readonly arguments?: string;
22
60
  }
23
- /** Response text delivered outside the Stop event (Cursor's afterAgentResponse). */
61
+ /** How a turn came to name a checkout. */
62
+ export type CheckoutVia = 'cwd' | 'file' | 'shell';
63
+ /**
64
+ * A checkout a turn named, from one tool hook. Local turn state only, never sent.
65
+ *
66
+ * The first record of a root in a turn carries its `seq` (order of first
67
+ * sight) and its `baseline`; later ones are votes. A root's record from a shell
68
+ * call is a vote for it; the call's own cwd votes only when the call named no
69
+ * checkout (`named: false`), because where an agent sits is weaker evidence
70
+ * than where it says it is looking.
71
+ */
72
+ export interface CheckoutRecord {
73
+ readonly kind: 'checkout';
74
+ readonly at: string;
75
+ readonly turnId?: string;
76
+ /** Canonical absolute root. */
77
+ readonly root: string;
78
+ readonly via: CheckoutVia;
79
+ /** The call named a checkout in its shell command. */
80
+ readonly named: boolean;
81
+ /** Order of first sight in the turn; only on a root's first record. */
82
+ readonly seq?: number;
83
+ /** The checkout when the turn first named it; absent when git could not say. */
84
+ readonly baseline?: Fingerprint;
85
+ }
86
+ /** A response delivered outside the Stop event (Cursor's afterAgentResponse); evidence only. */
24
87
  export interface ResponseRecord {
25
88
  readonly kind: 'response';
26
89
  readonly at: string;
27
90
  readonly turnId?: string;
28
- readonly text?: string;
29
91
  readonly evidence?: ContentEvidence;
30
92
  }
93
+ /**
94
+ * What model a session is on, as the agent named it.
95
+ *
96
+ * Not a `TurnRecord`: it belongs to the session rather than to a turn, is never
97
+ * collected into a summary, and outlives every record until the session ends.
98
+ */
99
+ export interface SessionModelRecord {
100
+ readonly model: string;
101
+ }
31
102
  /** Anything the accumulator persists between hook invocations. */
32
- export type TurnRecord = PromptRecord | ToolRecord | ResponseRecord;
103
+ export type TurnRecord = PromptRecord | ToolRecord | ResponseRecord | CheckoutRecord;
104
+ /** The session's last changed checkout, as `work-checkout.json` holds it. Local only. */
105
+ export interface WorkCheckoutMemo {
106
+ readonly root: string;
107
+ readonly repository: string;
108
+ readonly at: string;
109
+ /** The branch the session changed there; another session sharing the checkout reads it (SPEC §3a). */
110
+ readonly branch?: string;
111
+ /** The files the session's changing turns reported there on that branch, capped. */
112
+ readonly files?: readonly string[];
113
+ }
114
+ /** What another active session on the machine has changed, for a turn sharing its checkout. Local only. */
115
+ export interface SessionActivity {
116
+ readonly memo?: WorkCheckoutMemo;
117
+ /** Its open turns' edit-tool files: repository-relative, with the absolute root they are relative to; `current` when of its newest turn. */
118
+ readonly edits: readonly {
119
+ readonly root: string;
120
+ readonly filePath: string;
121
+ readonly current: boolean;
122
+ }[];
123
+ /** The branch each checkout its newest open turn named was on when that turn first named it. */
124
+ readonly baselines: readonly {
125
+ readonly root: string;
126
+ readonly branch: string;
127
+ }[];
128
+ }
129
+ /** The agent process a session runs in, as `agent-process.json` holds it. Local only. */
130
+ export interface AgentProcessRecord {
131
+ readonly pid: number;
132
+ /** `ps` start time, so a reused pid is not mistaken for the session's agent. */
133
+ readonly started?: string;
134
+ }
135
+ /** What a session inherited from the process that started it, as `inherited-checkout.json` holds it. Local only. */
136
+ export interface InheritedCheckoutMemo {
137
+ /** The live parent agent session found among the ancestors. */
138
+ readonly parent?: string;
139
+ /** The nearest ancestor's checkout, for when the parent has none (yet). */
140
+ readonly root?: string;
141
+ /** How many walks the deadline cut or that failed, set only while the session may walk again. */
142
+ readonly cuts?: number;
143
+ }
33
144
  /** A record together with the file it was read from, so it can be consumed. */
34
145
  export interface TurnStateEntry {
35
146
  readonly file: string;
@@ -1,6 +1,8 @@
1
+ import type { FailOpenReason } from '../../enforcement/types/enforcement.types.js';
1
2
  import type { AgentWatchEvent, ContentEvidence, EventGit, FeatureCandidate, UsageBillingMode } from '../../events/types/events.types.js';
2
- import type { PromptRecord, ToolRecord } from './turn-state.types.js';
3
- import type { TurnUsage } from './transcript.types.js';
3
+ import type { ContentHash } from '../../git/types/git.types.js';
4
+ import type { PromptRecord, ToolInputSummary, ToolRecord } from './turn-state.types.js';
5
+ import type { SessionTitles, TurnUsage } from './transcript.types.js';
4
6
  /**
5
7
  * Usage attributed to one agent inside a turn — the main agent, or one of the
6
8
  * child agents it spawned — derived from the same call ledger as the totals.
@@ -26,10 +28,21 @@ export interface AgentUsageSummary {
26
28
  * batches may still arrive. `complete` — the backend has decided none can.
27
29
  */
28
30
  export type TurnUsageStatus = 'pending' | 'provisional' | 'complete' | 'partial';
31
+ /**
32
+ * How a turn's checkout was chosen: it `changed` there; it changed nothing and
33
+ * `carried` the session's last changed checkout; it only `referenced` one; or it
34
+ * reports the folder it ended in (`cwd`), as before this existed. A session
35
+ * started outside any checkout reports the one of the process that started it
36
+ * (`inherited`).
37
+ */
38
+ export type WorkEvidence = 'changed' | 'carried' | 'referenced' | 'cwd' | 'inherited';
29
39
  /**
30
40
  * One prompt→response turn, flattened for direct backend consumption: who
31
- * (developer), where (repo/branch/commit/ticket), what (prompt, response,
32
- * tools, files) and how much it cost.
41
+ * (developer), where (repo/branch/commit/ticket), what (prompt and response
42
+ * evidence, tools, files) and how much it cost.
43
+ *
44
+ * Prompt text and tool inputs ride along only under their opt-in content flags;
45
+ * there is no response text field: the agent's replies are never collected.
33
46
  *
34
47
  * The only product record the hook path emits; the backend finalizes its usage
35
48
  * from the atomic llm.call rows.
@@ -40,19 +53,41 @@ export interface TurnSummaryEvent extends AgentWatchEvent<'turn.summary'> {
40
53
  readonly session_id?: string;
41
54
  readonly turn_id?: string;
42
55
  readonly developer_id?: string;
56
+ /** What to call this developer; the platform keeps its own if this is absent. */
57
+ readonly developer_name?: string;
43
58
  readonly repository?: string;
44
59
  readonly branch?: string;
45
60
  readonly commit?: string;
46
61
  readonly jira_ids?: readonly string[];
47
- /** Working-tree changes reported by git at the end of the turn. */
62
+ /** Ticket keys the session's opening prompt named, in order; the same on every turn of the session. Under `capture.git`. */
63
+ readonly prompt_jira_ids?: readonly string[];
64
+ /** The files this turn changed in its checkout: its edits, its commits' files, its new dirt. */
48
65
  readonly files_changed?: readonly string[];
66
+ /** How the repository and branch above were chosen; absent when the turn names none. */
67
+ readonly work_evidence?: WorkEvidence;
68
+ /** The session id of the agent that started this one: declared by its launcher, or the live parent an `inherited` checkout came from. */
69
+ readonly parent_session_id?: string;
70
+ /** One-way content ids of files the turn's tools named, in a folder with no git; under `capture.files`. */
71
+ readonly content_hashes?: readonly ContentHash[];
72
+ /** The repository address the nearest project manifest names, cleaned like a git remote; under `capture.files`. */
73
+ readonly manifest_repository?: string;
49
74
  /** Files edited by the agent's tools during this turn (repo-relative). */
50
75
  readonly files_touched?: readonly string[];
51
76
  /** Files the agent's tools only read during this turn (repo-relative). */
52
77
  readonly files_read?: readonly string[];
53
- readonly prompt?: string;
78
+ /** Files outside every checkout the turn's tools edited, home-relative (`~/Documents/a.xlsx`). */
79
+ readonly external_files_touched?: readonly string[];
80
+ /** Files outside every checkout the turn's tools only read, home-relative. */
81
+ readonly external_files_read?: readonly string[];
54
82
  readonly prompt_evidence?: ContentEvidence;
55
- readonly response?: string;
83
+ /** The turn's first prompt, harness blocks removed, scrubbed, bounded; under `capture.promptText`. */
84
+ readonly prompt_text?: string;
85
+ /** The session's latest name, scrubbed then cut to 200; under `capture.sessionTitle`; when the provider exposes one. */
86
+ readonly session_name?: string;
87
+ /** The session's latest generated/display title, scrubbed then cut to 200; under `capture.sessionTitle`; when exposed. Can paraphrase the first prompt. */
88
+ readonly session_title?: string;
89
+ /** The turn's shell commands and connector calls, bounded; under `capture.toolInput`. */
90
+ readonly tool_inputs?: readonly ToolInputSummary[];
56
91
  readonly response_evidence?: ContentEvidence;
57
92
  readonly tool_calls: number;
58
93
  readonly tools_used: Readonly<Record<string, number>>;
@@ -72,14 +107,16 @@ export interface TurnSummaryEvent extends AgentWatchEvent<'turn.summary'> {
72
107
  readonly agent_usage?: readonly AgentUsageSummary[];
73
108
  /** Hook summaries start pending/provisional; only backend aggregation is complete. */
74
109
  readonly usage_status: TurnUsageStatus;
110
+ /**
111
+ * Present only when the turn ran because no enforcement decision arrived, and
112
+ * then only as a category. Absent — never null — when the turn had a decision
113
+ * or nothing was asked. Top-level, beside `usage_status`: the platform reads it
114
+ * nowhere else.
115
+ */
116
+ readonly enforcement_fail_open_reason?: FailOpenReason;
75
117
  readonly started_at?: string;
76
118
  readonly ended_at: string;
77
119
  }
78
- /** The response the user actually saw, however the provider delivered it. */
79
- export interface TurnResponse {
80
- readonly text?: string;
81
- readonly evidence?: ContentEvidence;
82
- }
83
120
  export interface BuildTurnSummaryInput {
84
121
  /** Internal provider id ('claude' | 'codex' | ...); mapped to the public label. */
85
122
  readonly provider: string;
@@ -87,20 +124,33 @@ export interface BuildTurnSummaryInput {
87
124
  readonly sessionId?: string;
88
125
  readonly turnId?: string;
89
126
  readonly developerId?: string;
127
+ readonly developerName?: string;
90
128
  readonly installationId?: string;
91
129
  readonly git?: EventGit;
92
130
  readonly featureCandidates?: readonly FeatureCandidate[];
131
+ /** The session's opening prompt keys, as the tracker remembered them. */
132
+ readonly promptJiraIds?: readonly string[];
133
+ readonly workEvidence?: WorkEvidence;
134
+ readonly parentSessionId?: string;
135
+ readonly contentHashes?: readonly ContentHash[];
136
+ readonly manifestRepository?: string;
93
137
  readonly prompts: readonly PromptRecord[];
138
+ /** The session's latest native name and generated/display title as the agent holds them, unscrubbed. */
139
+ readonly sessionTitles?: SessionTitles;
94
140
  readonly tools: readonly ToolRecord[];
95
- readonly response?: TurnResponse;
141
+ /** Evidence of the response the user actually saw, however the provider delivered it. */
142
+ readonly response?: ContentEvidence;
96
143
  readonly usage?: TurnUsage;
97
144
  readonly model?: string;
98
145
  readonly billingMode?: UsageBillingMode;
99
146
  readonly endedAt: string;
100
147
  }
101
- /** Files the turn's tools read versus modified. */
148
+ /** Files the turn's tools read versus modified, inside and outside a checkout. */
102
149
  export interface TouchedFiles {
103
150
  readonly toolsUsed: Readonly<Record<string, number>>;
104
151
  readonly filesTouched: readonly string[];
105
152
  readonly filesRead: readonly string[];
153
+ readonly externalTouched: readonly string[];
154
+ readonly externalRead: readonly string[];
155
+ readonly toolInputs: readonly ToolInputSummary[];
106
156
  }
@@ -1,6 +1,9 @@
1
- import type { AgentWatchConfig } from '../../config/types/config.types.js';
1
+ import type { AgentWatchConfig, CaptureConfig, ConfigLoadResult } from '../../config/types/config.types.js';
2
+ import type { FailOpenReason } from '../../enforcement/types/enforcement.types.js';
2
3
  import type { Env } from '../../core/types/core.types.js';
3
4
  import type { AgentWatchEvent } from '../../events/types/events.types.js';
5
+ import type { AgentWatchPaths } from '../../storage/types/storage.types.js';
6
+ import type { TurnSummaryEvent } from './turn-summary.types.js';
4
7
  export interface TrackTurnOptions {
5
8
  readonly agentId: string;
6
9
  /** Raw provider payload; source of the transcript path. */
@@ -8,12 +11,35 @@ export interface TrackTurnOptions {
8
11
  /** Enriched + sanitized canonical events produced from this payload. */
9
12
  readonly events: readonly AgentWatchEvent[];
10
13
  readonly config: AgentWatchConfig;
14
+ /**
15
+ * The machine-global config as loaded, roots intact. `config` is the start
16
+ * folder's effective config with its roots stripped, and a session started
17
+ * above its repositories needs both: which tenant each repository beneath the
18
+ * start folder belongs to, and that repository's own `.agentwatch.json`.
19
+ */
20
+ readonly globalConfig: ConfigLoadResult;
21
+ readonly paths: AgentWatchPaths;
11
22
  readonly turnsDir: string;
12
23
  readonly locksDir: string;
13
24
  readonly env: Env;
14
25
  readonly cwd: string;
15
26
  /** Preview a Stop without appending, consuming, claiming, or sweeping state. */
16
27
  readonly readOnly?: boolean;
28
+ /** Why this payload's prompt was allowed without a decision, when it was. */
29
+ readonly failOpenReason?: FailOpenReason;
30
+ /** Real roots of the checkouts this payload's shell command named; roots only. */
31
+ readonly nominations?: readonly string[];
32
+ /** Real roots of the folders the agent has open (Cursor's workspace roots); weak candidates, like the cwd. */
33
+ readonly workspaceRoots?: readonly string[];
34
+ }
35
+ /** What one hook payload did to its turn. */
36
+ export interface TurnOutcome {
37
+ /** The summary, when this payload closed a turn. */
38
+ readonly summary?: TurnSummaryEvent;
39
+ /** Local root of the checkout that summary reported. Never sent. */
40
+ readonly workRoot?: string;
41
+ /** That checkout's own capture policy, when it is not the hook folder's. */
42
+ readonly capture?: CaptureConfig;
17
43
  }
18
44
  /** The window a closing turn may claim transcript usage from. */
19
45
  export interface TurnWindow {
@@ -0,0 +1,65 @@
1
+ import type { CaptureConfig } from '../config/types/config.types.js';
2
+ import type { AgentWatchEvent, EventGit, FeatureCandidate } from '../events/types/events.types.js';
3
+ import type { TurnStateStore } from './turn-state.js';
4
+ import type { ToolRecord, TurnRecord } from './types/turn-state.types.js';
5
+ import type { WorkEvidence } from './types/turn-summary.types.js';
6
+ import type { TrackTurnOptions } from './types/turn-tracker.types.js';
7
+ /** What a closing turn reports about where it worked. */
8
+ export interface WorkCheckout {
9
+ /** The checkout's git fields as the summary sends them; absent when it names none. */
10
+ readonly git?: EventGit;
11
+ readonly featureCandidates?: readonly FeatureCandidate[];
12
+ /**
13
+ * The turn's tools with every repo-relative path dropped that lies outside the
14
+ * reported checkout. A file in no checkout keeps its home-relative `externalPath`.
15
+ */
16
+ readonly tools: readonly ToolRecord[];
17
+ readonly evidence?: WorkEvidence;
18
+ /** The live parent agent session an `inherited` checkout came from. */
19
+ readonly parentSessionId?: string;
20
+ /** Local root of the reported checkout. Never sent. */
21
+ readonly root?: string;
22
+ /** The reported checkout's own capture policy, which delivery re-applies. */
23
+ readonly capture?: CaptureConfig;
24
+ /** Every file the turn changed there, uncapped, for the session's memo. Never sent. */
25
+ readonly changed?: readonly string[];
26
+ }
27
+ /**
28
+ * Write down the checkouts this tool hook names, for its turn's close.
29
+ *
30
+ * On a tool-start hook: the checkout of the hook's cwd, of a file tool's path,
31
+ * and of every directory the shell command named (`options.nominations`, roots
32
+ * only). On a completion hook: the file's checkout and the shell command's
33
+ * checkouts, when the turn has not named them yet — a command can create the
34
+ * worktree it then works in. The first time a turn names a checkout, its baseline fingerprint is
35
+ * taken — the one git process a tool hook may add — and later sightings are
36
+ * votes, one small file each.
37
+ *
38
+ * Only checkouts this session may report are written: the same admission the
39
+ * close applies, asked early so no git process runs in another tenant's
40
+ * checkout.
41
+ *
42
+ * @param store - Per-session state store.
43
+ * @param sessionId - Provider session id.
44
+ * @param event - The tool event, already enriched.
45
+ * @param options - Tracking options.
46
+ */
47
+ export declare function recordCheckouts(store: TurnStateStore, sessionId: string, event: AgentWatchEvent, options: TrackTurnOptions): Promise<void>;
48
+ /**
49
+ * Which checkout a closing turn worked in, and what it changed there.
50
+ *
51
+ * Every admitted checkout the turn named is fingerprinted again, all at once,
52
+ * and compared with its baseline. The turn reports, in this order: the one it
53
+ * changed most (`changed`); else the session's last changed checkout
54
+ * (`carried`); else the one it named most (`referenced`); else the Stop folder's
55
+ * own repository, as before this existed (`cwd`). Ties go to the checkout named
56
+ * first. Every failure makes a candidate lose, never the summary.
57
+ *
58
+ * @param store - Per-session state store.
59
+ * @param sessionId - Provider session id.
60
+ * @param records - This turn's records.
61
+ * @param stopEvent - The closing event, enriched for the Stop folder.
62
+ * @param options - Tracking options.
63
+ * @returns The checkout to report and the tools with its paths only.
64
+ */
65
+ export declare function resolveWorkCheckout(store: TurnStateStore, sessionId: string, records: readonly TurnRecord[], stopEvent: AgentWatchEvent, options: TrackTurnOptions): Promise<WorkCheckout>;