@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
@@ -2,10 +2,7 @@ import { ENFORCEMENT_PATH, EVENTS_PATH, OTEL_ALL, OTEL_NONE, OTEL_SIGNAL_NAMES,
2
2
  import { configSchema } from './schemas/config.schema.js';
3
3
  export { captureSchema, configSchema, deliverySchema, emitSchema, enforcementSchema, otelSchema } from './schemas/config.schema.js';
4
4
  /**
5
- * The configuration a deliberate `agentwatch setup` writes: full capture.
6
- *
7
- * Distinct from the runtime fallback in config-store, which is what a
8
- * *missing* config degrades to.
5
+ * The configuration a deliberate `agentwatch setup` writes: metadata only.
9
6
  *
10
7
  * @returns A config with every default applied.
11
8
  */
@@ -60,10 +57,27 @@ export function parseOtelSignals(value) {
60
57
  /**
61
58
  * Where product events are POSTed.
62
59
  *
60
+ * `null` is checked before truthiness, and that is not a formality: `null` is
61
+ * how `deliverableUrl` records "a URL was written here and refused", and it
62
+ * means something a *missing* field does not. Read by truthiness the two are
63
+ * the same value, so a refused `roots[].eventsUrl` fell through to the
64
+ * machine-global `endpoint` — the root's own destination being unusable is
65
+ * exactly when it must not inherit the other tenant's. A consultant whose
66
+ * `roots["/work/clientA"]` points `eventsUrl` at an internal `http:` collector
67
+ * would have had every prompt, response and branch name under that directory
68
+ * POSTed to their corporate backend under clientA's bearer.
69
+ *
70
+ * So a refusal is sticky where an absence is derivable. `otlpBaseUrl` holds the
71
+ * same rule for the same reason; `enforcementUrl` deliberately does not, and
72
+ * says why.
73
+ *
63
74
  * @param config - Effective configuration.
64
- * @returns The events URL, or undefined when no backend is configured.
75
+ * @returns The events URL, or undefined when no backend is configured or the
76
+ * one configured here was refused.
65
77
  */
66
78
  export function eventsUrl(config) {
79
+ if (config.eventsUrl === null)
80
+ return undefined;
67
81
  if (config.eventsUrl)
68
82
  return config.eventsUrl;
69
83
  if (!config.endpoint)
@@ -77,15 +91,33 @@ export function eventsUrl(config) {
77
91
  * this base themselves, so it must stay a base and not a signal route.
78
92
  *
79
93
  * @param config - Effective configuration.
80
- * @returns The OTLP base URL, or undefined when no backend is configured.
94
+ * @returns The OTLP base URL, or undefined when no backend is configured or the
95
+ * one configured here was refused.
81
96
  */
82
97
  export function otlpBaseUrl(config) {
98
+ // Refused, not absent — see `eventsUrl`. Worse here than there: `otel-headers`
99
+ // hands the root's bearer to the agent's exporter only when the root's OTLP
100
+ // base equals the machine's, so a refused root URL that fell back to the
101
+ // machine's made those two equal and opened the guard.
102
+ if (config.otlpUrl === null)
103
+ return undefined;
83
104
  if (config.otlpUrl)
84
105
  return config.otlpUrl;
85
106
  if (!config.endpoint)
86
107
  return undefined;
87
108
  return joinUrl(config.endpoint, OTLP_BASE_PATH);
88
109
  }
110
+ /**
111
+ * Use the same collector check for exporter credentials and setup diagnostics.
112
+ * Missing collectors cannot establish permission to expose a root's bearer.
113
+ * @param machine - Configuration used by the machine-wide exporter.
114
+ * @param identity - Effective configuration for the selected directory.
115
+ * @returns Whether the exporter can use this identity's credential.
116
+ */
117
+ export function sharesOtlpCollector(machine, identity) {
118
+ const base = otlpBaseUrl(identity);
119
+ return base !== undefined && base === otlpBaseUrl(machine);
120
+ }
89
121
  /**
90
122
  * Where the pre-turn budget check asks its question.
91
123
  *
@@ -93,6 +125,21 @@ export function otlpBaseUrl(config) {
93
125
  * endpoint; the override exists for the same reason the other two do — a
94
126
  * deployment that does not put every route behind one host.
95
127
  *
128
+ * The one accessor that does *not* hold `eventsUrl`'s rule, and deliberately.
129
+ * There, refusing to derive is fail-safe: nothing leaves. Here it is fail-open
130
+ * — `resolveEnforcement` answers `ALLOW` when there is no URL to ask, and
131
+ * `enforcementWouldAsk` stops the caller even paying for the identity lookup —
132
+ * so one `http:` line in a field nobody uses would switch every `block` cap on
133
+ * the machine off silently. The security argument does not carry either: the
134
+ * derived URL is a path on an `endpoint` already validated as `https:`, so
135
+ * deriving sends the bearer nowhere it was not already going. `doctor` reports
136
+ * the refused field as `configuration: fail` regardless.
137
+ *
138
+ * Root resolution retains this route only for the shared backend. A root with
139
+ * a different base derives its decision route there; a route-only root still
140
+ * uses machine enforcement, so setting endpoint is required for a separate
141
+ * enforcement backend.
142
+ *
96
143
  * @param config - Effective configuration.
97
144
  * @returns The decision URL, or undefined when no backend is configured.
98
145
  */
@@ -113,3 +160,16 @@ export function enforcementUrl(config) {
113
160
  export function joinUrl(base, suffix) {
114
161
  return base.replace(RE_TRAILING_SLASHES, '') + suffix;
115
162
  }
163
+ /**
164
+ * Whether the machine has consented to tool arguments and results leaving it.
165
+ *
166
+ * Native provider logs carry both with no per-field filter, so this one answer
167
+ * decides whether a Codex or Gemini exporter may be configured at all — and
168
+ * `doctor` needs the same answer to explain why one was not.
169
+ *
170
+ * @param config - Effective configuration.
171
+ * @returns True when global consent and both tool flags are on.
172
+ */
173
+ export function toolContentConsented(config) {
174
+ return config.contentCaptureConsent && config.capture.toolInput && config.capture.toolOutput;
175
+ }
@@ -8,11 +8,21 @@ export declare const DEFAULT_MAX_EVENT_AGE_DAYS = 7;
8
8
  * Pre-turn budget check defaults.
9
9
  *
10
10
  * The timeout is a hard ceiling on a request that sits between the developer
11
- * pressing enter and their agent starting work, and the TTL mirrors the cache
12
- * the platform keeps for the same decision.
11
+ * pressing enter and their agent starting work.
12
+ *
13
+ * The TTL is both the fallback when the platform gives no usable
14
+ * `cache_ttl_ms` and the ceiling on any advice it does give, so it is the one
15
+ * number on the path no platform change can shorten.
13
16
  */
14
17
  export declare const DEFAULT_ENFORCEMENT_TIMEOUT_MS = 300;
15
- export declare const DEFAULT_ENFORCEMENT_CACHE_TTL_MS = 60000;
18
+ export declare const DEFAULT_ENFORCEMENT_CACHE_TTL_MS = 5000;
19
+ /**
20
+ * The window the product promises between a cap being crossed and the next
21
+ * turn being refused. A local answer held longer would break it on its own, so
22
+ * this caps the TTL whatever the config says — including the 60 s every earlier
23
+ * install wrote into its config file, because `saveConfig` persists defaults.
24
+ */
25
+ export declare const ENFORCEMENT_WINDOW_MS = 5000;
16
26
  /** Native OTLP signal names, in report order. */
17
27
  export declare const OTEL_SIGNAL_NAMES: readonly ["logs", "traces", "metrics"];
18
28
  /** O(1) validation of a `--otel` list entry. */
@@ -22,10 +32,75 @@ export declare const OTEL_ALL = "all";
22
32
  export declare const OTEL_NONE = "none";
23
33
  /** Backend routes derived from the configured base endpoint. */
24
34
  export declare const EVENTS_PATH = "/v1/events";
35
+ /**
36
+ * Hosts a plain-`http:` backend URL is allowed to name.
37
+ *
38
+ * A local collector and the test suite are the only legitimate `http:`
39
+ * destinations; anywhere else the bearer and the captured content would cross a
40
+ * network in cleartext.
41
+ */
42
+ export declare const LOOPBACK_HOSTS: ReadonlySet<string>;
43
+ /**
44
+ * The only non-loopback hosts the edge sends to without `--allow-custom-endpoint`.
45
+ *
46
+ * Exact names, lower-case, no trailing dot, matched whole: a suffix match would
47
+ * let `api.agent-watch.ai.evil.example` through. Compiled into the release
48
+ * rather than read from anywhere, so a forged setup line cannot widen it — that
49
+ * line is exactly the attack this list exists for (SPEC R9).
50
+ *
51
+ * `api` is the production gateway the onboarding spec confirms live; `ingest`
52
+ * is the name the platform's own install-instruction tests render. No staging
53
+ * gateway name exists anywhere yet. A human confirms this list before release
54
+ * (device-enrollment plan E11).
55
+ */
56
+ export declare const AGENT_WATCH_HOSTS: ReadonlySet<string>;
57
+ /** Where setup points the edge when neither `--endpoint` nor the config names a backend. */
58
+ export declare const DEFAULT_ENDPOINT = "https://api.agent-watch.ai";
59
+ /** Said to whoever wrote the URL, so the remedy is in the message. */
60
+ export declare const DELIVERABLE_URL_MESSAGE = "must be an https:// URL (http:// is allowed for localhost only)";
61
+ /**
62
+ * Said about a URL outside `AGENT_WATCH_HOSTS` and `customEndpoints`, after its
63
+ * origin. Says that nothing is lost; the remedy follows it.
64
+ */
65
+ export declare const CUSTOM_ENDPOINT_MESSAGE = "is not an Agent Watch host \u2014 ignored, records stay queued on this machine";
66
+ /** Config key: the origins this machine trusts outside `AGENT_WATCH_HOSTS`. */
67
+ export declare const CUSTOM_ENDPOINTS_KEY = "customEndpoints";
68
+ /**
69
+ * Config key recording that the file was written, or migrated, by an edge that
70
+ * enforces the allowlist. A file without it predates the allowlist, and its
71
+ * backends are grandfathered once (see `screenConfigUrls`).
72
+ */
73
+ export declare const ALLOWLIST_VERSION_KEY = "allowlistVersion";
74
+ export declare const ALLOWLIST_VERSION = 1;
75
+ /**
76
+ * Every field of the config file itself that holds a backend URL.
77
+ *
78
+ * One list, so a fifth URL field is reported by `screenConfigUrls` the
79
+ * moment the schema validates it.
80
+ */
81
+ export declare const URL_FIELDS: readonly string[];
82
+ /**
83
+ * The subset a `roots[]` entry may carry.
84
+ *
85
+ * Not the same set, and reporting them as if it were made `doctor` *fail* on a
86
+ * `roots[].enforcementUrl`: `rootOverrideSchema` strips it as an unknown key
87
+ * whatever its value, so it has never had any effect. A per-root enforcement URL
88
+ * would mean adding it there, not reporting it here.
89
+ */
90
+ export declare const ROOT_URL_FIELDS: readonly string[];
91
+ /** The URL field of a `device` block: where uninstall sends the device secret. */
92
+ export declare const DEVICE_URL_FIELDS: readonly string[];
25
93
  export declare const OTLP_BASE_PATH = "/v1/otlp";
26
94
  export declare const ENFORCEMENT_PATH = "/v1/enforcement/decision";
27
95
  /** Repository-level overrides file, found by walking up from the working directory. */
28
96
  export declare const REPO_CONFIG_NAME = ".agentwatch.json";
97
+ /**
98
+ * Per-project identity block in the global config: absolute project root ->
99
+ * the credentials and endpoints to use for work under it. This is how one
100
+ * machine reports to two tenants; the repo file still cannot set any of it,
101
+ * which is why the key is global-only like the fields it carries.
102
+ */
103
+ export declare const ROOTS_KEY = "roots";
29
104
  /**
30
105
  * Keys a repo file may not set: it is committed and shared, so secrets and
31
106
  * per-machine identity stay in the global ~/.agentwatch/config.json only.
@@ -49,14 +124,46 @@ export declare const GLOBAL_ONLY_BLOCKS: readonly ["delivery", "otel", "enforcem
49
124
  /**
50
125
  * Emission toggles a repo file may not narrow. `llm.call` is the mandatory
51
126
  * usage ledger and `turn.summary` is the only hook-path usage record: a repo
52
- * file may narrow *capture* (prompts, responses, files) but must never be able
127
+ * file may narrow *capture* (tool content, git, files) but must never be able
53
128
  * to silence usage telemetry for everyone who clones the repository.
54
129
  */
55
130
  export declare const GLOBAL_ONLY_EMIT_KEYS: ReadonlySet<string>;
131
+ /**
132
+ * The capture flags that carry raw content off the machine: the developer's
133
+ * prompt text, tool arguments and tool results, and the session's title. Response text is not here
134
+ * because nothing can send it.
135
+ *
136
+ * Named once because two rules key on exactly this set: the consent gate zeroes
137
+ * them on load, and `saveConfig` preserves the user's own values rather than the
138
+ * gated ones, so granting consent later restores a choice instead of finding it
139
+ * erased.
140
+ */
141
+ export declare const CONTENT_CAPTURE_KEYS: readonly ["promptText", "toolInput", "toolOutput", "sessionTitle"];
142
+ /**
143
+ * Capture flags earlier releases honoured and this one ignores. Prompt text is
144
+ * `promptText` now, a new name on purpose: a config that still says
145
+ * `prompts: true` from before AWT-281 must not start sending on upgrade. The
146
+ * agent's replies are not collected at all. Stripped on load; named so `setup`
147
+ * can remove them from the file once and `doctor` can say they remain.
148
+ */
149
+ export declare const RETIRED_CAPTURE_KEYS: readonly ["prompts", "responses"];
150
+ /** The capture block, which a repo file may narrow but never widen. */
151
+ export declare const CAPTURE_KEY = "capture";
56
152
  /** Nested blocks merged field-by-field instead of replaced wholesale. */
57
153
  export declare const MERGE_BLOCKS: readonly ["capture", "emit"];
58
154
  /** Ceiling on the upward walk looking for a repo config. */
59
155
  export declare const MAX_WALK_DEPTH = 32;
60
- /** Capture flags that mean raw content leaves the machine. */
61
- export declare const CONTENT_CAPTURE_FLAGS: readonly ["prompts", "responses", "toolInput", "toolOutput"];
62
156
  export declare const RE_TRAILING_SLASHES: RegExp;
157
+ /** Explicit routes belong to the backend selected at enrollment. */
158
+ export declare const ROUTE_FIELDS: readonly ["eventsUrl", "otlpUrl", "enforcementUrl"];
159
+ /** The fields that hold an identity's credential; a root naming one replaces both. */
160
+ export declare const CREDENTIAL_KEYS: ReadonlySet<string>;
161
+ /** The device credential reference alone, removed by uninstall. */
162
+ export declare const DEVICE_KEY: ReadonlySet<string>;
163
+ /** One writer of config.json at a time: setup, uninstall and a hook's exchange. */
164
+ export declare const CONFIG_LOCK = "config";
165
+ /** How long setup and uninstall wait for a hook holding the config lock; a hook holds it for one read and one write. */
166
+ export declare const CONFIG_LOCK_WAIT_MS = 2000;
167
+ /** How long a hook waits for it: part of its credential budget, never more. */
168
+ export declare const CONFIG_LOCK_HOOK_WAIT_MS = 200;
169
+ export declare const CONFIG_LOCK_POLL_MS = 20;
@@ -8,11 +8,21 @@ export const DEFAULT_MAX_EVENT_AGE_DAYS = 7;
8
8
  * Pre-turn budget check defaults.
9
9
  *
10
10
  * The timeout is a hard ceiling on a request that sits between the developer
11
- * pressing enter and their agent starting work, and the TTL mirrors the cache
12
- * the platform keeps for the same decision.
11
+ * pressing enter and their agent starting work.
12
+ *
13
+ * The TTL is both the fallback when the platform gives no usable
14
+ * `cache_ttl_ms` and the ceiling on any advice it does give, so it is the one
15
+ * number on the path no platform change can shorten.
13
16
  */
14
17
  export const DEFAULT_ENFORCEMENT_TIMEOUT_MS = 300;
15
- export const DEFAULT_ENFORCEMENT_CACHE_TTL_MS = 60_000;
18
+ export const DEFAULT_ENFORCEMENT_CACHE_TTL_MS = 5_000;
19
+ /**
20
+ * The window the product promises between a cap being crossed and the next
21
+ * turn being refused. A local answer held longer would break it on its own, so
22
+ * this caps the TTL whatever the config says — including the 60 s every earlier
23
+ * install wrote into its config file, because `saveConfig` persists defaults.
24
+ */
25
+ export const ENFORCEMENT_WINDOW_MS = 5_000;
16
26
  /** Native OTLP signal names, in report order. */
17
27
  export const OTEL_SIGNAL_NAMES = ['logs', 'traces', 'metrics'];
18
28
  /** O(1) validation of a `--otel` list entry. */
@@ -22,10 +32,75 @@ export const OTEL_ALL = 'all';
22
32
  export const OTEL_NONE = 'none';
23
33
  /** Backend routes derived from the configured base endpoint. */
24
34
  export const EVENTS_PATH = '/v1/events';
35
+ /**
36
+ * Hosts a plain-`http:` backend URL is allowed to name.
37
+ *
38
+ * A local collector and the test suite are the only legitimate `http:`
39
+ * destinations; anywhere else the bearer and the captured content would cross a
40
+ * network in cleartext.
41
+ */
42
+ export const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '::1', '[::1]']);
43
+ /**
44
+ * The only non-loopback hosts the edge sends to without `--allow-custom-endpoint`.
45
+ *
46
+ * Exact names, lower-case, no trailing dot, matched whole: a suffix match would
47
+ * let `api.agent-watch.ai.evil.example` through. Compiled into the release
48
+ * rather than read from anywhere, so a forged setup line cannot widen it — that
49
+ * line is exactly the attack this list exists for (SPEC R9).
50
+ *
51
+ * `api` is the production gateway the onboarding spec confirms live; `ingest`
52
+ * is the name the platform's own install-instruction tests render. No staging
53
+ * gateway name exists anywhere yet. A human confirms this list before release
54
+ * (device-enrollment plan E11).
55
+ */
56
+ export const AGENT_WATCH_HOSTS = new Set(['api.agent-watch.ai', 'ingest.agent-watch.ai']);
57
+ /** Where setup points the edge when neither `--endpoint` nor the config names a backend. */
58
+ export const DEFAULT_ENDPOINT = 'https://api.agent-watch.ai';
59
+ /** Said to whoever wrote the URL, so the remedy is in the message. */
60
+ export const DELIVERABLE_URL_MESSAGE = 'must be an https:// URL (http:// is allowed for localhost only)';
61
+ /**
62
+ * Said about a URL outside `AGENT_WATCH_HOSTS` and `customEndpoints`, after its
63
+ * origin. Says that nothing is lost; the remedy follows it.
64
+ */
65
+ export const CUSTOM_ENDPOINT_MESSAGE = 'is not an Agent Watch host — ignored, records stay queued on this machine';
66
+ /** Config key: the origins this machine trusts outside `AGENT_WATCH_HOSTS`. */
67
+ export const CUSTOM_ENDPOINTS_KEY = 'customEndpoints';
68
+ /**
69
+ * Config key recording that the file was written, or migrated, by an edge that
70
+ * enforces the allowlist. A file without it predates the allowlist, and its
71
+ * backends are grandfathered once (see `screenConfigUrls`).
72
+ */
73
+ export const ALLOWLIST_VERSION_KEY = 'allowlistVersion';
74
+ export const ALLOWLIST_VERSION = 1;
75
+ /**
76
+ * Every field of the config file itself that holds a backend URL.
77
+ *
78
+ * One list, so a fifth URL field is reported by `screenConfigUrls` the
79
+ * moment the schema validates it.
80
+ */
81
+ export const URL_FIELDS = ['endpoint', 'eventsUrl', 'otlpUrl', 'enforcementUrl'];
82
+ /**
83
+ * The subset a `roots[]` entry may carry.
84
+ *
85
+ * Not the same set, and reporting them as if it were made `doctor` *fail* on a
86
+ * `roots[].enforcementUrl`: `rootOverrideSchema` strips it as an unknown key
87
+ * whatever its value, so it has never had any effect. A per-root enforcement URL
88
+ * would mean adding it there, not reporting it here.
89
+ */
90
+ export const ROOT_URL_FIELDS = ['endpoint', 'eventsUrl', 'otlpUrl'];
91
+ /** The URL field of a `device` block: where uninstall sends the device secret. */
92
+ export const DEVICE_URL_FIELDS = ['endpoint'];
25
93
  export const OTLP_BASE_PATH = '/v1/otlp';
26
94
  export const ENFORCEMENT_PATH = '/v1/enforcement/decision';
27
95
  /** Repository-level overrides file, found by walking up from the working directory. */
28
96
  export const REPO_CONFIG_NAME = '.agentwatch.json';
97
+ /**
98
+ * Per-project identity block in the global config: absolute project root ->
99
+ * the credentials and endpoints to use for work under it. This is how one
100
+ * machine reports to two tenants; the repo file still cannot set any of it,
101
+ * which is why the key is global-only like the fields it carries.
102
+ */
103
+ export const ROOTS_KEY = 'roots';
29
104
  /**
30
105
  * Keys a repo file may not set: it is committed and shared, so secrets and
31
106
  * per-machine identity stay in the global ~/.agentwatch/config.json only.
@@ -33,13 +108,24 @@ export const REPO_CONFIG_NAME = '.agentwatch.json';
33
108
  * would exfiltrate the global bearer token along with the telemetry.
34
109
  */
35
110
  export const GLOBAL_ONLY_KEYS = new Set([
111
+ 'contentCaptureConsent',
112
+ CUSTOM_ENDPOINTS_KEY,
113
+ ALLOWLIST_VERSION_KEY,
36
114
  'token',
115
+ // Names where the device secret is kept: a repo file that pointed it at the
116
+ // wrong store would leave every hook there with no bearer and every prompt
117
+ // unchecked, a one-line budget-cap bypass.
118
+ 'device',
37
119
  'installationId',
38
120
  'developerEmail',
121
+ 'developerName',
122
+ 'untracedNotices',
123
+ 'updateNotices',
39
124
  'endpoint',
40
125
  'eventsUrl',
41
126
  'otlpUrl',
42
- 'enforcementUrl'
127
+ 'enforcementUrl',
128
+ ROOTS_KEY
43
129
  ]);
44
130
  /**
45
131
  * Whole blocks a repo file may not touch.
@@ -57,14 +143,46 @@ export const GLOBAL_ONLY_BLOCKS = ['delivery', 'otel', 'enforcement'];
57
143
  /**
58
144
  * Emission toggles a repo file may not narrow. `llm.call` is the mandatory
59
145
  * usage ledger and `turn.summary` is the only hook-path usage record: a repo
60
- * file may narrow *capture* (prompts, responses, files) but must never be able
146
+ * file may narrow *capture* (tool content, git, files) but must never be able
61
147
  * to silence usage telemetry for everyone who clones the repository.
62
148
  */
63
149
  export const GLOBAL_ONLY_EMIT_KEYS = new Set(['llmCalls', 'turnSummaries']);
150
+ /**
151
+ * The capture flags that carry raw content off the machine: the developer's
152
+ * prompt text, tool arguments and tool results, and the session's title. Response text is not here
153
+ * because nothing can send it.
154
+ *
155
+ * Named once because two rules key on exactly this set: the consent gate zeroes
156
+ * them on load, and `saveConfig` preserves the user's own values rather than the
157
+ * gated ones, so granting consent later restores a choice instead of finding it
158
+ * erased.
159
+ */
160
+ export const CONTENT_CAPTURE_KEYS = ['promptText', 'toolInput', 'toolOutput', 'sessionTitle'];
161
+ /**
162
+ * Capture flags earlier releases honoured and this one ignores. Prompt text is
163
+ * `promptText` now, a new name on purpose: a config that still says
164
+ * `prompts: true` from before AWT-281 must not start sending on upgrade. The
165
+ * agent's replies are not collected at all. Stripped on load; named so `setup`
166
+ * can remove them from the file once and `doctor` can say they remain.
167
+ */
168
+ export const RETIRED_CAPTURE_KEYS = ['prompts', 'responses'];
169
+ /** The capture block, which a repo file may narrow but never widen. */
170
+ export const CAPTURE_KEY = 'capture';
64
171
  /** Nested blocks merged field-by-field instead of replaced wholesale. */
65
- export const MERGE_BLOCKS = ['capture', 'emit'];
172
+ export const MERGE_BLOCKS = [CAPTURE_KEY, 'emit'];
66
173
  /** Ceiling on the upward walk looking for a repo config. */
67
174
  export const MAX_WALK_DEPTH = 32;
68
- /** Capture flags that mean raw content leaves the machine. */
69
- export const CONTENT_CAPTURE_FLAGS = ['prompts', 'responses', 'toolInput', 'toolOutput'];
70
175
  export const RE_TRAILING_SLASHES = /\/+$/;
176
+ /** Explicit routes belong to the backend selected at enrollment. */
177
+ export const ROUTE_FIELDS = ['eventsUrl', 'otlpUrl', 'enforcementUrl'];
178
+ /** The fields that hold an identity's credential; a root naming one replaces both. */
179
+ export const CREDENTIAL_KEYS = new Set(['token', 'device']);
180
+ /** The device credential reference alone, removed by uninstall. */
181
+ export const DEVICE_KEY = new Set(['device']);
182
+ /** One writer of config.json at a time: setup, uninstall and a hook's exchange. */
183
+ export const CONFIG_LOCK = 'config';
184
+ /** How long setup and uninstall wait for a hook holding the config lock; a hook holds it for one read and one write. */
185
+ export const CONFIG_LOCK_WAIT_MS = 2_000;
186
+ /** How long a hook waits for it: part of its credential budget, never more. */
187
+ export const CONFIG_LOCK_HOOK_WAIT_MS = 200;
188
+ export const CONFIG_LOCK_POLL_MS = 20;
@@ -0,0 +1,24 @@
1
+ import type { Destination, DestinationTransition } from './types/destination.types.js';
2
+ /**
3
+ * Keep enrollment and runtime comparisons on the same base-path convention.
4
+ * @param endpoint - A validated backend base URL.
5
+ * @returns The base used when deriving routes.
6
+ */
7
+ export declare function normalizeEndpoint(endpoint: string): string;
8
+ /**
9
+ * Missing or refused bases cannot establish that two destinations are safe to share.
10
+ * @param left - Previously configured base.
11
+ * @param right - Proposed base.
12
+ * @returns Whether both usable bases identify the same destination.
13
+ */
14
+ export declare function sameEndpoint(left: string | null | undefined, right: string | null | undefined): boolean;
15
+ /**
16
+ * Plan one enrollment transition for either a machine or a root. Live routes
17
+ * survive only a known unchanged base; refusals survive until explicitly repaired.
18
+ * Every cleared live route is returned for reporting before the write.
19
+ * @param stored - Explicit routes belonging to the identity being updated.
20
+ * @param previous - Its previous base, including any permitted inheritance.
21
+ * @param endpoint - The validated base selected by enrollment.
22
+ * @returns The route patch and the fields the operator must be told were cleared.
23
+ */
24
+ export declare function transitionDestination(stored: Destination, previous: Destination['endpoint'], endpoint: string): DestinationTransition;
@@ -0,0 +1,33 @@
1
+ import { RE_TRAILING_SLASHES, ROUTE_FIELDS } from './constants/config.constants.js';
2
+ /**
3
+ * Keep enrollment and runtime comparisons on the same base-path convention.
4
+ * @param endpoint - A validated backend base URL.
5
+ * @returns The base used when deriving routes.
6
+ */
7
+ export function normalizeEndpoint(endpoint) {
8
+ return endpoint.replace(RE_TRAILING_SLASHES, '');
9
+ }
10
+ /**
11
+ * Missing or refused bases cannot establish that two destinations are safe to share.
12
+ * @param left - Previously configured base.
13
+ * @param right - Proposed base.
14
+ * @returns Whether both usable bases identify the same destination.
15
+ */
16
+ export function sameEndpoint(left, right) {
17
+ return typeof left === 'string' && typeof right === 'string' && normalizeEndpoint(left) === normalizeEndpoint(right);
18
+ }
19
+ /**
20
+ * Plan one enrollment transition for either a machine or a root. Live routes
21
+ * survive only a known unchanged base; refusals survive until explicitly repaired.
22
+ * Every cleared live route is returned for reporting before the write.
23
+ * @param stored - Explicit routes belonging to the identity being updated.
24
+ * @param previous - Its previous base, including any permitted inheritance.
25
+ * @param endpoint - The validated base selected by enrollment.
26
+ * @returns The route patch and the fields the operator must be told were cleared.
27
+ */
28
+ export function transitionDestination(stored, previous, endpoint) {
29
+ const unchanged = sameEndpoint(previous, endpoint);
30
+ const routes = Object.fromEntries(ROUTE_FIELDS.map((field) => [field, stored[field] === null || unchanged ? stored[field] : undefined]));
31
+ const cleared = ROUTE_FIELDS.filter((field) => typeof stored[field] === 'string' && !unchanged);
32
+ return { routes, cleared };
33
+ }
@@ -2,9 +2,12 @@
2
2
  * What the edge is configured to do: the global file, the repository overlay
3
3
  * on top of it, and the routes derived from the endpoint.
4
4
  */
5
- export type { AgentWatchConfig, CaptureConfig, ConfigLoadResult, EffectiveConfig, MergedConfig, OtelConfig, OtelSignalName } from './types/config.types.js';
6
- export { CONTENT_CAPTURE_FLAGS, OTEL_SIGNAL_NAMES, REPO_CONFIG_NAME } from './constants/config.constants.js';
5
+ export type { AgentWatchConfig, CaptureConfig, ConfigLoadResult, EffectiveConfig, MergedConfig, OtelConfig, OtelSignalName, RootedConfig, RootOverride } from './types/config.types.js';
6
+ export { CONTENT_CAPTURE_KEYS, OTEL_SIGNAL_NAMES, REPO_CONFIG_NAME, ROOTS_KEY } from './constants/config.constants.js';
7
7
  export { captureSchema, configSchema, deliverySchema, emitSchema, otelSchema } from './schemas/config.schema.js';
8
- export { defaultConfig, enabledSignalNames, eventsUrl, joinUrl, otelEnabled, otlpBaseUrl, parseOtelSignals } from './config.js';
9
- export { ensureInstallationId, loadConfig, saveConfig } from './config-store.js';
8
+ export { defaultConfig, enabledSignalNames, eventsUrl, joinUrl, otelEnabled, otlpBaseUrl, parseOtelSignals, sharesOtlpCollector } from './config.js';
9
+ export { attachDevice, ensureInstallationId, loadConfig, saveConfig, updateConfig, withStoredDevices } from './config-store.js';
10
10
  export { findRepoConfigFile, loadEffectiveConfig, mergeRepoConfig } from './repo-config.js';
11
+ export { applyRootOverride, canonicalRoot, selectRoot, servesMultipleIdentities } from './root-config.js';
12
+ export { normalizeEndpoint, sameEndpoint, transitionDestination } from './destination.js';
13
+ export type { Destination, DestinationTransition } from './types/destination.types.js';
@@ -1,5 +1,7 @@
1
- export { CONTENT_CAPTURE_FLAGS, OTEL_SIGNAL_NAMES, REPO_CONFIG_NAME } from './constants/config.constants.js';
1
+ export { CONTENT_CAPTURE_KEYS, OTEL_SIGNAL_NAMES, REPO_CONFIG_NAME, ROOTS_KEY } from './constants/config.constants.js';
2
2
  export { captureSchema, configSchema, deliverySchema, emitSchema, otelSchema } from './schemas/config.schema.js';
3
- export { defaultConfig, enabledSignalNames, eventsUrl, joinUrl, otelEnabled, otlpBaseUrl, parseOtelSignals } from './config.js';
4
- export { ensureInstallationId, loadConfig, saveConfig } from './config-store.js';
3
+ export { defaultConfig, enabledSignalNames, eventsUrl, joinUrl, otelEnabled, otlpBaseUrl, parseOtelSignals, sharesOtlpCollector } from './config.js';
4
+ export { attachDevice, ensureInstallationId, loadConfig, saveConfig, updateConfig, withStoredDevices } from './config-store.js';
5
5
  export { findRepoConfigFile, loadEffectiveConfig, mergeRepoConfig } from './repo-config.js';
6
+ export { applyRootOverride, canonicalRoot, selectRoot, servesMultipleIdentities } from './root-config.js';
7
+ export { normalizeEndpoint, sameEndpoint, transitionDestination } from './destination.js';
@@ -1,5 +1,5 @@
1
1
  import type { AgentWatchPaths } from '../storage/types/storage.types.js';
2
- import type { AgentWatchConfig, EffectiveConfig, MergedConfig } from './types/config.types.js';
2
+ import type { AgentWatchConfig, ConfigLoadResult, EffectiveConfig, MergedConfig } from './types/config.types.js';
3
3
  export { REPO_CONFIG_NAME } from './constants/config.constants.js';
4
4
  export type { EffectiveConfig, MergedConfig } from './types/config.types.js';
5
5
  /**
@@ -13,11 +13,11 @@ export declare function findRepoConfigFile(startDir: string): Promise<string | u
13
13
  * Overlay repository overrides on the global config.
14
14
  *
15
15
  * A repo file is committed and shared, which is what every rule here follows
16
- * from: it may narrow what is captured, and it may not touch identity,
17
- * credentials, delivery destinations or the usage ledger. Anything refused is
18
- * reported rather than silently dropped, and an invalid *result* degrades to
19
- * the global config — a broken repo file must never disable telemetry or break
20
- * a hook.
16
+ * from: it may only ever narrow what is captured, and it may not touch
17
+ * identity, credentials, delivery destinations or the usage ledger. Anything
18
+ * refused is reported rather than silently dropped, and an invalid *result*
19
+ * degrades to the global config — a broken repo file must never disable
20
+ * telemetry or break a hook.
21
21
  *
22
22
  * @param global - The machine's global config.
23
23
  * @param repoValue - Raw decoded contents of the repo file.
@@ -32,6 +32,10 @@ export declare function mergeRepoConfig(global: AgentWatchConfig, repoValue: unk
32
32
  *
33
33
  * @param paths - Resolved AgentWatch paths.
34
34
  * @param cwd - Directory the payload came from.
35
+ * @param preloaded - The global config if the caller already read it. The hook
36
+ * path has it in hand before the first stage runs, and re-reading the file
37
+ * there was one more open, read and parse on every one of the ten-odd hooks a
38
+ * turn fires.
35
39
  * @returns The effective config, its warnings, and the file that produced it.
36
40
  */
37
- export declare function loadEffectiveConfig(paths: AgentWatchPaths, cwd: string): Promise<EffectiveConfig>;
41
+ export declare function loadEffectiveConfig(paths: AgentWatchPaths, cwd: string, preloaded?: ConfigLoadResult): Promise<EffectiveConfig>;