@claude-flow/cli 3.32.26 → 3.32.30

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 (403) hide show
  1. package/.claude/helpers/.helpers-version +1 -1
  2. package/.claude/helpers/helpers.manifest.json +2 -2
  3. package/catalog-manifest.json +4 -4
  4. package/dist/src/commands/index.d.ts +1 -0
  5. package/dist/src/commands/index.js +5 -3
  6. package/dist/src/commands/memory.js +49 -5
  7. package/dist/src/commands/metaharness.js +25 -5
  8. package/dist/src/commands/policy.d.ts +4 -0
  9. package/dist/src/commands/policy.js +107 -0
  10. package/dist/src/index.js +18 -0
  11. package/dist/src/init/claudemd-generator.js +53 -2
  12. package/dist/src/mcp-client.js +25 -1
  13. package/dist/src/mcp-tools/capability-brain.d.ts +134 -0
  14. package/dist/src/mcp-tools/capability-brain.js +697 -0
  15. package/dist/src/mcp-tools/guidance-tools.d.ts +2 -0
  16. package/dist/src/mcp-tools/guidance-tools.js +369 -37
  17. package/dist/src/mcp-tools/index.d.ts +4 -1
  18. package/dist/src/mcp-tools/index.js +3 -1
  19. package/dist/src/mcp-tools/memory-tools.js +26 -0
  20. package/dist/src/mcp-tools/metaharness-tools.js +27 -1
  21. package/dist/src/mcp-tools/policy-tools.d.ts +3 -0
  22. package/dist/src/mcp-tools/policy-tools.js +121 -0
  23. package/dist/src/memory/memory-bridge.d.ts +11 -0
  24. package/dist/src/memory/memory-bridge.js +100 -21
  25. package/dist/src/memory/memory-initializer.d.ts +22 -1
  26. package/dist/src/memory/memory-initializer.js +184 -39
  27. package/dist/src/services/bounded-worker-pool.d.ts +28 -0
  28. package/dist/src/services/bounded-worker-pool.js +90 -0
  29. package/dist/src/services/harness-flywheel-runtime.d.ts +2 -0
  30. package/dist/src/services/harness-flywheel-runtime.js +18 -0
  31. package/dist/src/services/harness-flywheel.d.ts +4 -1
  32. package/dist/src/services/harness-flywheel.js +27 -6
  33. package/dist/src/services/policy-runtime.d.ts +38 -0
  34. package/dist/src/services/policy-runtime.js +340 -0
  35. package/node_modules/@claude-flow/codex/.agents/skills/memory-management/SKILL.md +45 -0
  36. package/node_modules/@claude-flow/codex/.agents/skills/security-audit/SKILL.md +46 -0
  37. package/node_modules/@claude-flow/codex/.agents/skills/sparc-methodology/SKILL.md +46 -0
  38. package/node_modules/@claude-flow/codex/.agents/skills/swarm-orchestration/SKILL.md +53 -0
  39. package/node_modules/@claude-flow/codex/README.md +1044 -0
  40. package/node_modules/@claude-flow/codex/dist/cli.d.ts +9 -0
  41. package/node_modules/@claude-flow/codex/dist/cli.d.ts.map +1 -0
  42. package/node_modules/@claude-flow/codex/dist/cli.js +686 -0
  43. package/node_modules/@claude-flow/codex/dist/cli.js.map +1 -0
  44. package/node_modules/@claude-flow/codex/dist/dual-mode/cli.d.ts +17 -0
  45. package/node_modules/@claude-flow/codex/dist/dual-mode/cli.d.ts.map +1 -0
  46. package/node_modules/@claude-flow/codex/dist/dual-mode/cli.js +278 -0
  47. package/node_modules/@claude-flow/codex/dist/dual-mode/cli.js.map +1 -0
  48. package/node_modules/@claude-flow/codex/dist/dual-mode/index.d.ts +8 -0
  49. package/node_modules/@claude-flow/codex/dist/dual-mode/index.d.ts.map +1 -0
  50. package/node_modules/@claude-flow/codex/dist/dual-mode/index.js +7 -0
  51. package/node_modules/@claude-flow/codex/dist/dual-mode/index.js.map +1 -0
  52. package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.d.ts +143 -0
  53. package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.d.ts.map +1 -0
  54. package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.js +621 -0
  55. package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.js.map +1 -0
  56. package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts +12 -0
  57. package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts.map +1 -0
  58. package/node_modules/@claude-flow/codex/dist/generators/agents-md.js +730 -0
  59. package/node_modules/@claude-flow/codex/dist/generators/agents-md.js.map +1 -0
  60. package/node_modules/@claude-flow/codex/dist/generators/config-toml.d.ts +74 -0
  61. package/node_modules/@claude-flow/codex/dist/generators/config-toml.d.ts.map +1 -0
  62. package/node_modules/@claude-flow/codex/dist/generators/config-toml.js +922 -0
  63. package/node_modules/@claude-flow/codex/dist/generators/config-toml.js.map +1 -0
  64. package/node_modules/@claude-flow/codex/dist/generators/index.d.ts +9 -0
  65. package/node_modules/@claude-flow/codex/dist/generators/index.d.ts.map +1 -0
  66. package/node_modules/@claude-flow/codex/dist/generators/index.js +9 -0
  67. package/node_modules/@claude-flow/codex/dist/generators/index.js.map +1 -0
  68. package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts +20 -0
  69. package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts.map +1 -0
  70. package/node_modules/@claude-flow/codex/dist/generators/skill-md.js +951 -0
  71. package/node_modules/@claude-flow/codex/dist/generators/skill-md.js.map +1 -0
  72. package/node_modules/@claude-flow/codex/dist/harness/build-evidence.d.ts +46 -0
  73. package/node_modules/@claude-flow/codex/dist/harness/build-evidence.d.ts.map +1 -0
  74. package/node_modules/@claude-flow/codex/dist/harness/build-evidence.js +126 -0
  75. package/node_modules/@claude-flow/codex/dist/harness/build-evidence.js.map +1 -0
  76. package/node_modules/@claude-flow/codex/dist/harness/contract.d.ts +153 -0
  77. package/node_modules/@claude-flow/codex/dist/harness/contract.d.ts.map +1 -0
  78. package/node_modules/@claude-flow/codex/dist/harness/contract.js +44 -0
  79. package/node_modules/@claude-flow/codex/dist/harness/contract.js.map +1 -0
  80. package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.d.ts +33 -0
  81. package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.d.ts.map +1 -0
  82. package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.js +175 -0
  83. package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.js.map +1 -0
  84. package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.d.ts +42 -0
  85. package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.d.ts.map +1 -0
  86. package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.js +140 -0
  87. package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.js.map +1 -0
  88. package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.d.ts +19 -0
  89. package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.d.ts.map +1 -0
  90. package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.js +79 -0
  91. package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.js.map +1 -0
  92. package/node_modules/@claude-flow/codex/dist/harness/index.d.ts +9 -0
  93. package/node_modules/@claude-flow/codex/dist/harness/index.d.ts.map +1 -0
  94. package/node_modules/@claude-flow/codex/dist/harness/index.js +9 -0
  95. package/node_modules/@claude-flow/codex/dist/harness/index.js.map +1 -0
  96. package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.d.ts +8 -0
  97. package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.d.ts.map +1 -0
  98. package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.js +10 -0
  99. package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.js.map +1 -0
  100. package/node_modules/@claude-flow/codex/dist/harness/repository-state.d.ts +68 -0
  101. package/node_modules/@claude-flow/codex/dist/harness/repository-state.d.ts.map +1 -0
  102. package/node_modules/@claude-flow/codex/dist/harness/repository-state.js +403 -0
  103. package/node_modules/@claude-flow/codex/dist/harness/repository-state.js.map +1 -0
  104. package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.d.ts +3 -0
  105. package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.d.ts.map +1 -0
  106. package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.js +14 -0
  107. package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.js.map +1 -0
  108. package/node_modules/@claude-flow/codex/dist/index.d.ts +53 -0
  109. package/node_modules/@claude-flow/codex/dist/index.d.ts.map +1 -0
  110. package/node_modules/@claude-flow/codex/dist/index.js +54 -0
  111. package/node_modules/@claude-flow/codex/dist/index.js.map +1 -0
  112. package/node_modules/@claude-flow/codex/dist/initializer.d.ts +98 -0
  113. package/node_modules/@claude-flow/codex/dist/initializer.d.ts.map +1 -0
  114. package/node_modules/@claude-flow/codex/dist/initializer.js +795 -0
  115. package/node_modules/@claude-flow/codex/dist/initializer.js.map +1 -0
  116. package/node_modules/@claude-flow/codex/dist/loop/cli.d.ts +3 -0
  117. package/node_modules/@claude-flow/codex/dist/loop/cli.d.ts.map +1 -0
  118. package/node_modules/@claude-flow/codex/dist/loop/cli.js +123 -0
  119. package/node_modules/@claude-flow/codex/dist/loop/cli.js.map +1 -0
  120. package/node_modules/@claude-flow/codex/dist/loop/index.d.ts +58 -0
  121. package/node_modules/@claude-flow/codex/dist/loop/index.d.ts.map +1 -0
  122. package/node_modules/@claude-flow/codex/dist/loop/index.js +230 -0
  123. package/node_modules/@claude-flow/codex/dist/loop/index.js.map +1 -0
  124. package/node_modules/@claude-flow/codex/dist/mcp-config.d.ts +28 -0
  125. package/node_modules/@claude-flow/codex/dist/mcp-config.d.ts.map +1 -0
  126. package/node_modules/@claude-flow/codex/dist/mcp-config.js +121 -0
  127. package/node_modules/@claude-flow/codex/dist/mcp-config.js.map +1 -0
  128. package/node_modules/@claude-flow/codex/dist/migrations/index.d.ts +114 -0
  129. package/node_modules/@claude-flow/codex/dist/migrations/index.d.ts.map +1 -0
  130. package/node_modules/@claude-flow/codex/dist/migrations/index.js +880 -0
  131. package/node_modules/@claude-flow/codex/dist/migrations/index.js.map +1 -0
  132. package/node_modules/@claude-flow/codex/dist/templates/index.d.ts +92 -0
  133. package/node_modules/@claude-flow/codex/dist/templates/index.d.ts.map +1 -0
  134. package/node_modules/@claude-flow/codex/dist/templates/index.js +284 -0
  135. package/node_modules/@claude-flow/codex/dist/templates/index.js.map +1 -0
  136. package/node_modules/@claude-flow/codex/dist/types.d.ts +240 -0
  137. package/node_modules/@claude-flow/codex/dist/types.d.ts.map +1 -0
  138. package/node_modules/@claude-flow/codex/dist/types.js +8 -0
  139. package/node_modules/@claude-flow/codex/dist/types.js.map +1 -0
  140. package/node_modules/@claude-flow/codex/dist/validators/index.d.ts +42 -0
  141. package/node_modules/@claude-flow/codex/dist/validators/index.d.ts.map +1 -0
  142. package/node_modules/@claude-flow/codex/dist/validators/index.js +929 -0
  143. package/node_modules/@claude-flow/codex/dist/validators/index.js.map +1 -0
  144. package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.d.ts +37 -0
  145. package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.d.ts.map +1 -0
  146. package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.js +137 -0
  147. package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.js.map +1 -0
  148. package/node_modules/@claude-flow/codex/dist/worktrees/index.d.ts +2 -0
  149. package/node_modules/@claude-flow/codex/dist/worktrees/index.d.ts.map +1 -0
  150. package/node_modules/@claude-flow/codex/dist/worktrees/index.js +2 -0
  151. package/node_modules/@claude-flow/codex/dist/worktrees/index.js.map +1 -0
  152. package/node_modules/@claude-flow/codex/package.json +122 -0
  153. package/node_modules/@claude-flow/plugin-agent-federation/README.md +49 -0
  154. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.d.ts +130 -0
  155. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.d.ts.map +1 -0
  156. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.js +239 -0
  157. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.js.map +1 -0
  158. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.d.ts +34 -0
  159. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.d.ts.map +1 -0
  160. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.js +69 -0
  161. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.js.map +1 -0
  162. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.d.ts +46 -0
  163. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.d.ts.map +1 -0
  164. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.js +84 -0
  165. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.js.map +1 -0
  166. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.d.ts +27 -0
  167. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.d.ts.map +1 -0
  168. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.js +46 -0
  169. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.js.map +1 -0
  170. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.d.ts +192 -0
  171. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.d.ts.map +1 -0
  172. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.js +253 -0
  173. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.js.map +1 -0
  174. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.d.ts +211 -0
  175. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.d.ts.map +1 -0
  176. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js +501 -0
  177. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js.map +1 -0
  178. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts +114 -0
  179. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts.map +1 -0
  180. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js +356 -0
  181. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js.map +1 -0
  182. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.d.ts +41 -0
  183. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.d.ts.map +1 -0
  184. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js +184 -0
  185. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js.map +1 -0
  186. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.d.ts +150 -0
  187. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.d.ts.map +1 -0
  188. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.js +128 -0
  189. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.js.map +1 -0
  190. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.d.ts +74 -0
  191. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.d.ts.map +1 -0
  192. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.js +179 -0
  193. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.js.map +1 -0
  194. package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.d.ts +13 -0
  195. package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.d.ts.map +1 -0
  196. package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js +189 -0
  197. package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js.map +1 -0
  198. package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.d.ts +7 -0
  199. package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.d.ts.map +1 -0
  200. package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.js +317 -0
  201. package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.js.map +1 -0
  202. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.d.ts +45 -0
  203. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.d.ts.map +1 -0
  204. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.js +71 -0
  205. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.js.map +1 -0
  206. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.d.ts +104 -0
  207. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.d.ts.map +1 -0
  208. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.js +152 -0
  209. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.js.map +1 -0
  210. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.d.ts +55 -0
  211. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.d.ts.map +1 -0
  212. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.js +105 -0
  213. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.js.map +1 -0
  214. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.d.ts +17 -0
  215. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.d.ts.map +1 -0
  216. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.js +35 -0
  217. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.js.map +1 -0
  218. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.d.ts +69 -0
  219. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.d.ts.map +1 -0
  220. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.js +149 -0
  221. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.js.map +1 -0
  222. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts +68 -0
  223. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts.map +1 -0
  224. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js +161 -0
  225. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js.map +1 -0
  226. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts +58 -0
  227. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts.map +1 -0
  228. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js +122 -0
  229. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js.map +1 -0
  230. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.d.ts +65 -0
  231. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.d.ts.map +1 -0
  232. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.js +208 -0
  233. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.js.map +1 -0
  234. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.d.ts +51 -0
  235. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.d.ts.map +1 -0
  236. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.js +147 -0
  237. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.js.map +1 -0
  238. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.d.ts +71 -0
  239. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.d.ts.map +1 -0
  240. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.js +194 -0
  241. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.js.map +1 -0
  242. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.d.ts +156 -0
  243. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.d.ts.map +1 -0
  244. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.js +292 -0
  245. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.js.map +1 -0
  246. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.d.ts +98 -0
  247. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.d.ts.map +1 -0
  248. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.js +122 -0
  249. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.js.map +1 -0
  250. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.d.ts +89 -0
  251. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.d.ts.map +1 -0
  252. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.js +165 -0
  253. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.js.map +1 -0
  254. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.d.ts +92 -0
  255. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.d.ts.map +1 -0
  256. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.js +100 -0
  257. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.js.map +1 -0
  258. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.d.ts +70 -0
  259. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.d.ts.map +1 -0
  260. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.js +104 -0
  261. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.js.map +1 -0
  262. package/node_modules/@claude-flow/plugin-agent-federation/dist/index.d.ts +23 -0
  263. package/node_modules/@claude-flow/plugin-agent-federation/dist/index.d.ts.map +1 -0
  264. package/node_modules/@claude-flow/plugin-agent-federation/dist/index.js +24 -0
  265. package/node_modules/@claude-flow/plugin-agent-federation/dist/index.js.map +1 -0
  266. package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.d.ts +10 -0
  267. package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.d.ts.map +1 -0
  268. package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.js +439 -0
  269. package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.js.map +1 -0
  270. package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts +19 -0
  271. package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts.map +1 -0
  272. package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js +515 -0
  273. package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js.map +1 -0
  274. package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.d.ts +72 -0
  275. package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.d.ts.map +1 -0
  276. package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js +269 -0
  277. package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js.map +1 -0
  278. package/node_modules/@claude-flow/plugin-agent-federation/dist/version.d.ts +3 -0
  279. package/node_modules/@claude-flow/plugin-agent-federation/dist/version.d.ts.map +1 -0
  280. package/node_modules/@claude-flow/plugin-agent-federation/dist/version.js +3 -0
  281. package/node_modules/@claude-flow/plugin-agent-federation/dist/version.js.map +1 -0
  282. package/node_modules/@claude-flow/plugin-agent-federation/package.json +64 -0
  283. package/node_modules/@claude-flow/security/README.md +292 -0
  284. package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.d.ts +97 -0
  285. package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.d.ts.map +1 -0
  286. package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.js +537 -0
  287. package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.js.map +1 -0
  288. package/node_modules/@claude-flow/security/dist/application/index.d.ts +7 -0
  289. package/node_modules/@claude-flow/security/dist/application/index.d.ts.map +1 -0
  290. package/node_modules/@claude-flow/security/dist/application/index.js +7 -0
  291. package/node_modules/@claude-flow/security/dist/application/index.js.map +1 -0
  292. package/node_modules/@claude-flow/security/dist/application/services/security-application-service.d.ts +71 -0
  293. package/node_modules/@claude-flow/security/dist/application/services/security-application-service.d.ts.map +1 -0
  294. package/node_modules/@claude-flow/security/dist/application/services/security-application-service.js +153 -0
  295. package/node_modules/@claude-flow/security/dist/application/services/security-application-service.js.map +1 -0
  296. package/node_modules/@claude-flow/security/dist/authorization/propagator.d.ts +148 -0
  297. package/node_modules/@claude-flow/security/dist/authorization/propagator.d.ts.map +1 -0
  298. package/node_modules/@claude-flow/security/dist/authorization/propagator.js +182 -0
  299. package/node_modules/@claude-flow/security/dist/authorization/propagator.js.map +1 -0
  300. package/node_modules/@claude-flow/security/dist/credential-generator.d.ts +176 -0
  301. package/node_modules/@claude-flow/security/dist/credential-generator.d.ts.map +1 -0
  302. package/node_modules/@claude-flow/security/dist/credential-generator.js +272 -0
  303. package/node_modules/@claude-flow/security/dist/credential-generator.js.map +1 -0
  304. package/node_modules/@claude-flow/security/dist/domain/entities/security-context.d.ts +68 -0
  305. package/node_modules/@claude-flow/security/dist/domain/entities/security-context.d.ts.map +1 -0
  306. package/node_modules/@claude-flow/security/dist/domain/entities/security-context.js +132 -0
  307. package/node_modules/@claude-flow/security/dist/domain/entities/security-context.js.map +1 -0
  308. package/node_modules/@claude-flow/security/dist/domain/index.d.ts +8 -0
  309. package/node_modules/@claude-flow/security/dist/domain/index.d.ts.map +1 -0
  310. package/node_modules/@claude-flow/security/dist/domain/index.js +8 -0
  311. package/node_modules/@claude-flow/security/dist/domain/index.js.map +1 -0
  312. package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.d.ts +71 -0
  313. package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.d.ts.map +1 -0
  314. package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.js +237 -0
  315. package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.js.map +1 -0
  316. package/node_modules/@claude-flow/security/dist/index.d.ts +129 -0
  317. package/node_modules/@claude-flow/security/dist/index.d.ts.map +1 -0
  318. package/node_modules/@claude-flow/security/dist/index.js +176 -0
  319. package/node_modules/@claude-flow/security/dist/index.js.map +1 -0
  320. package/node_modules/@claude-flow/security/dist/input-validator.d.ts +306 -0
  321. package/node_modules/@claude-flow/security/dist/input-validator.d.ts.map +1 -0
  322. package/node_modules/@claude-flow/security/dist/input-validator.js +393 -0
  323. package/node_modules/@claude-flow/security/dist/input-validator.js.map +1 -0
  324. package/node_modules/@claude-flow/security/dist/keychain-adapter.d.ts +48 -0
  325. package/node_modules/@claude-flow/security/dist/keychain-adapter.d.ts.map +1 -0
  326. package/node_modules/@claude-flow/security/dist/keychain-adapter.js +0 -0
  327. package/node_modules/@claude-flow/security/dist/keychain-adapter.js.map +1 -0
  328. package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.d.ts +133 -0
  329. package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.d.ts.map +1 -0
  330. package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.js +254 -0
  331. package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.js.map +1 -0
  332. package/node_modules/@claude-flow/security/dist/oauth/browser.d.ts +31 -0
  333. package/node_modules/@claude-flow/security/dist/oauth/browser.d.ts.map +1 -0
  334. package/node_modules/@claude-flow/security/dist/oauth/browser.js +55 -0
  335. package/node_modules/@claude-flow/security/dist/oauth/browser.js.map +1 -0
  336. package/node_modules/@claude-flow/security/dist/oauth/callback-server.d.ts +37 -0
  337. package/node_modules/@claude-flow/security/dist/oauth/callback-server.d.ts.map +1 -0
  338. package/node_modules/@claude-flow/security/dist/oauth/callback-server.js +86 -0
  339. package/node_modules/@claude-flow/security/dist/oauth/callback-server.js.map +1 -0
  340. package/node_modules/@claude-flow/security/dist/oauth/client.d.ts +57 -0
  341. package/node_modules/@claude-flow/security/dist/oauth/client.d.ts.map +1 -0
  342. package/node_modules/@claude-flow/security/dist/oauth/client.js +120 -0
  343. package/node_modules/@claude-flow/security/dist/oauth/client.js.map +1 -0
  344. package/node_modules/@claude-flow/security/dist/oauth/pkce.d.ts +25 -0
  345. package/node_modules/@claude-flow/security/dist/oauth/pkce.d.ts.map +1 -0
  346. package/node_modules/@claude-flow/security/dist/oauth/pkce.js +36 -0
  347. package/node_modules/@claude-flow/security/dist/oauth/pkce.js.map +1 -0
  348. package/node_modules/@claude-flow/security/dist/password-hasher.d.ts +128 -0
  349. package/node_modules/@claude-flow/security/dist/password-hasher.d.ts.map +1 -0
  350. package/node_modules/@claude-flow/security/dist/password-hasher.js +190 -0
  351. package/node_modules/@claude-flow/security/dist/password-hasher.js.map +1 -0
  352. package/node_modules/@claude-flow/security/dist/path-validator.d.ts +148 -0
  353. package/node_modules/@claude-flow/security/dist/path-validator.d.ts.map +1 -0
  354. package/node_modules/@claude-flow/security/dist/path-validator.js +421 -0
  355. package/node_modules/@claude-flow/security/dist/path-validator.js.map +1 -0
  356. package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.d.ts +125 -0
  357. package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.d.ts.map +1 -0
  358. package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.js +186 -0
  359. package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.js.map +1 -0
  360. package/node_modules/@claude-flow/security/dist/policy/canonical.d.ts +5 -0
  361. package/node_modules/@claude-flow/security/dist/policy/canonical.d.ts.map +1 -0
  362. package/node_modules/@claude-flow/security/dist/policy/canonical.js +30 -0
  363. package/node_modules/@claude-flow/security/dist/policy/canonical.js.map +1 -0
  364. package/node_modules/@claude-flow/security/dist/policy/engine.d.ts +34 -0
  365. package/node_modules/@claude-flow/security/dist/policy/engine.d.ts.map +1 -0
  366. package/node_modules/@claude-flow/security/dist/policy/engine.js +285 -0
  367. package/node_modules/@claude-flow/security/dist/policy/engine.js.map +1 -0
  368. package/node_modules/@claude-flow/security/dist/policy/envelope.d.ts +9 -0
  369. package/node_modules/@claude-flow/security/dist/policy/envelope.d.ts.map +1 -0
  370. package/node_modules/@claude-flow/security/dist/policy/envelope.js +90 -0
  371. package/node_modules/@claude-flow/security/dist/policy/envelope.js.map +1 -0
  372. package/node_modules/@claude-flow/security/dist/policy/evaluator.d.ts +4 -0
  373. package/node_modules/@claude-flow/security/dist/policy/evaluator.d.ts.map +1 -0
  374. package/node_modules/@claude-flow/security/dist/policy/evaluator.js +119 -0
  375. package/node_modules/@claude-flow/security/dist/policy/evaluator.js.map +1 -0
  376. package/node_modules/@claude-flow/security/dist/policy/index.d.ts +7 -0
  377. package/node_modules/@claude-flow/security/dist/policy/index.d.ts.map +1 -0
  378. package/node_modules/@claude-flow/security/dist/policy/index.js +7 -0
  379. package/node_modules/@claude-flow/security/dist/policy/index.js.map +1 -0
  380. package/node_modules/@claude-flow/security/dist/policy/product-plane.d.ts +238 -0
  381. package/node_modules/@claude-flow/security/dist/policy/product-plane.d.ts.map +1 -0
  382. package/node_modules/@claude-flow/security/dist/policy/product-plane.js +1022 -0
  383. package/node_modules/@claude-flow/security/dist/policy/product-plane.js.map +1 -0
  384. package/node_modules/@claude-flow/security/dist/policy/types.d.ts +169 -0
  385. package/node_modules/@claude-flow/security/dist/policy/types.d.ts.map +1 -0
  386. package/node_modules/@claude-flow/security/dist/policy/types.js +2 -0
  387. package/node_modules/@claude-flow/security/dist/policy/types.js.map +1 -0
  388. package/node_modules/@claude-flow/security/dist/safe-executor.d.ts +180 -0
  389. package/node_modules/@claude-flow/security/dist/safe-executor.d.ts.map +1 -0
  390. package/node_modules/@claude-flow/security/dist/safe-executor.js +390 -0
  391. package/node_modules/@claude-flow/security/dist/safe-executor.js.map +1 -0
  392. package/node_modules/@claude-flow/security/dist/token-generator.d.ts +224 -0
  393. package/node_modules/@claude-flow/security/dist/token-generator.d.ts.map +1 -0
  394. package/node_modules/@claude-flow/security/dist/token-generator.js +351 -0
  395. package/node_modules/@claude-flow/security/dist/token-generator.js.map +1 -0
  396. package/node_modules/@claude-flow/security/dist/tool-output-guardrail.d.ts +126 -0
  397. package/node_modules/@claude-flow/security/dist/tool-output-guardrail.d.ts.map +1 -0
  398. package/node_modules/@claude-flow/security/dist/tool-output-guardrail.js +257 -0
  399. package/node_modules/@claude-flow/security/dist/tool-output-guardrail.js.map +1 -0
  400. package/node_modules/@claude-flow/security/package.json +44 -0
  401. package/package.json +44 -12
  402. package/plugins/ruflo-metaharness/scripts/smoke.sh +22 -14
  403. package/plugins/ruflo-metaharness/scripts/test-mcp-tools.mjs +3 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-service.d.ts","sourceRoot":"","sources":["../../../src/domain/services/audit-service.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAChC,iBAAiB,GAAG,yBAAyB,GAC7C,qBAAqB,GAAG,qBAAqB,GAC7C,kBAAkB,GAAG,oBAAoB,GACzC,iBAAiB,GAAG,iBAAiB,GACrC,iBAAiB,GAAG,oBAAoB,GACxC,cAAc,GAAG,kBAAkB,GACnC,kBAAkB,GAAG,iBAAiB,GACtC,cAAc,GAAG,cAAc,GAAG,aAAa,GAC/C,iBAAiB,GAAG,gBAAgB,GAAG,gBAAgB,GACvD,eAAe,GAAG,cAAc,GAAG,qBAAqB,GACxD,oBAAoB,GAAG,iBAAiB,GACxC,mBAAmB,GAAG,kBAAkB,CAAC;AAE7C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;AAEnE,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,WAAW,GAAG,SAAS,GAAG,KAAK,GAAG,UAAU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QAAQ,CAAC,IAAI,CAAmB;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;gBAEpC,IAAI,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC;IAMlE,GAAG,CACP,SAAS,EAAE,wBAAwB,EACnC,OAAO,GAAE,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,gBAAgB,CAAC,CAAM,GAC/I,OAAO,CAAC,oBAAoB,CAAC;IAa1B,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAKzD,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAarE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAO5B,aAAa,IAAI,MAAM;IAIvB,OAAO,CAAC,UAAU;IAuBlB,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,KAAK;CAmBd"}
@@ -0,0 +1,149 @@
1
+ const DEFAULT_AUDIT_CONFIG = {
2
+ complianceMode: 'none',
3
+ retentionDays: 90,
4
+ batchSize: 100,
5
+ };
6
+ const SEVERITY_BY_EVENT_TYPE = {
7
+ peer_discovered: 'info',
8
+ peer_manifest_published: 'info',
9
+ handshake_initiated: 'info',
10
+ handshake_completed: 'info',
11
+ handshake_failed: 'warn',
12
+ handshake_rejected: 'warn',
13
+ session_created: 'info',
14
+ session_renewed: 'info',
15
+ session_expired: 'info',
16
+ session_terminated: 'info',
17
+ message_sent: 'info',
18
+ message_received: 'info',
19
+ message_rejected: 'warn',
20
+ message_timeout: 'warn',
21
+ pii_detected: 'warn',
22
+ pii_stripped: 'info',
23
+ pii_blocked: 'warn',
24
+ threat_detected: 'error',
25
+ threat_blocked: 'critical',
26
+ threat_learned: 'info',
27
+ claim_checked: 'info',
28
+ claim_denied: 'warn',
29
+ trust_level_changed: 'warn',
30
+ consensus_proposed: 'info',
31
+ consensus_voted: 'info',
32
+ consensus_reached: 'info',
33
+ consensus_failed: 'warn',
34
+ };
35
+ const CATEGORY_BY_EVENT_TYPE = {
36
+ peer_discovered: 'discovery',
37
+ peer_manifest_published: 'discovery',
38
+ handshake_initiated: 'handshake',
39
+ handshake_completed: 'handshake',
40
+ handshake_failed: 'handshake',
41
+ handshake_rejected: 'handshake',
42
+ session_created: 'handshake',
43
+ session_renewed: 'handshake',
44
+ session_expired: 'handshake',
45
+ session_terminated: 'handshake',
46
+ message_sent: 'message',
47
+ message_received: 'message',
48
+ message_rejected: 'message',
49
+ message_timeout: 'message',
50
+ pii_detected: 'pii',
51
+ pii_stripped: 'pii',
52
+ pii_blocked: 'pii',
53
+ threat_detected: 'security',
54
+ threat_blocked: 'security',
55
+ threat_learned: 'security',
56
+ claim_checked: 'security',
57
+ claim_denied: 'security',
58
+ trust_level_changed: 'security',
59
+ consensus_proposed: 'consensus',
60
+ consensus_voted: 'consensus',
61
+ consensus_reached: 'consensus',
62
+ consensus_failed: 'consensus',
63
+ };
64
+ export class AuditService {
65
+ deps;
66
+ config;
67
+ buffer;
68
+ constructor(deps, config) {
69
+ this.deps = deps;
70
+ this.config = { ...DEFAULT_AUDIT_CONFIG, ...config };
71
+ this.buffer = [];
72
+ }
73
+ async log(eventType, details = {}) {
74
+ const event = this.buildEvent(eventType, details);
75
+ this.buffer.push(event);
76
+ this.deps.onAuditEvent?.(event);
77
+ if (this.buffer.length >= this.config.batchSize || event.severity === 'critical') {
78
+ await this.flush();
79
+ }
80
+ return event;
81
+ }
82
+ async query(query) {
83
+ await this.flush();
84
+ return this.deps.queryEvents(query);
85
+ }
86
+ async export(query, format) {
87
+ const events = await this.query(query);
88
+ switch (format) {
89
+ case 'json':
90
+ return JSON.stringify(events, null, 2);
91
+ case 'ndjson':
92
+ return events.map(e => JSON.stringify(e)).join('\n');
93
+ case 'csv':
94
+ return this.toCsv(events);
95
+ }
96
+ }
97
+ async flush() {
98
+ const eventsToFlush = this.buffer.splice(0, this.buffer.length);
99
+ for (const event of eventsToFlush) {
100
+ await this.deps.persistEvent(event);
101
+ }
102
+ }
103
+ getBufferSize() {
104
+ return this.buffer.length;
105
+ }
106
+ buildEvent(eventType, details) {
107
+ const event = {
108
+ eventId: this.deps.generateEventId(),
109
+ timestamp: new Date().toISOString(),
110
+ nodeId: this.deps.getLocalNodeId(),
111
+ eventType,
112
+ severity: SEVERITY_BY_EVENT_TYPE[eventType],
113
+ category: CATEGORY_BY_EVENT_TYPE[eventType],
114
+ complianceMode: this.config.complianceMode,
115
+ dataResidency: this.config.dataResidency,
116
+ ...details,
117
+ };
118
+ if (this.config.complianceMode === 'hipaa') {
119
+ return this.applyHipaaCompliance(event);
120
+ }
121
+ return event;
122
+ }
123
+ applyHipaaCompliance(event) {
124
+ if (event.piiDetected && event.metadata) {
125
+ const sanitizedMetadata = { ...event.metadata };
126
+ delete sanitizedMetadata['rawContent'];
127
+ delete sanitizedMetadata['originalValue'];
128
+ return { ...event, metadata: sanitizedMetadata };
129
+ }
130
+ return event;
131
+ }
132
+ toCsv(events) {
133
+ if (events.length === 0)
134
+ return '';
135
+ const headers = [
136
+ 'eventId', 'timestamp', 'nodeId', 'eventType', 'severity',
137
+ 'category', 'sourceNodeId', 'targetNodeId', 'sessionId',
138
+ 'trustLevel', 'piiDetected', 'threatDetected', 'latencyMs',
139
+ ];
140
+ const rows = events.map(e => headers.map(h => {
141
+ const val = e[h];
142
+ if (val === undefined || val === null)
143
+ return '';
144
+ return String(val);
145
+ }).join(','));
146
+ return [headers.join(','), ...rows].join('\n');
147
+ }
148
+ }
149
+ //# sourceMappingURL=audit-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-service.js","sourceRoot":"","sources":["../../../src/domain/services/audit-service.ts"],"names":[],"mappings":"AAiFA,MAAM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QACrB,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CACb,CAAC;QAEF,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CACF"}
@@ -0,0 +1,68 @@
1
+ import { FederationNode } from '../entities/federation-node.js';
2
+ import type { WgManifestSection } from '../value-objects/wg-config.js';
3
+ export type DiscoveryMechanism = 'static' | 'dns-sd' | 'ipfs-registry' | 'a2a-card';
4
+ export interface FederationManifest {
5
+ readonly nodeId: string;
6
+ readonly publicKey: string;
7
+ readonly endpoint: string;
8
+ readonly capabilities: {
9
+ readonly agentTypes: readonly string[];
10
+ readonly maxConcurrentSessions: number;
11
+ readonly supportedProtocols: readonly string[];
12
+ readonly complianceModes: readonly string[];
13
+ };
14
+ readonly version: string;
15
+ readonly signature: string;
16
+ readonly timestamp: string;
17
+ /**
18
+ * ADR-111 — optional WG mesh identity. Present only when the publishing
19
+ * node has opted into the in-tree WG layer (`config.wgMesh: true`).
20
+ * The Ed25519 manifest signature covers this block too — peers verifying
21
+ * the manifest also verify the WG-key binding.
22
+ */
23
+ readonly wg?: WgManifestSection;
24
+ }
25
+ export interface DiscoveryServiceDeps {
26
+ signManifest: (manifest: Omit<FederationManifest, 'signature'>) => Promise<string>;
27
+ verifyManifest: (manifest: FederationManifest) => Promise<boolean>;
28
+ onPeerDiscovered?: (node: FederationNode) => void;
29
+ }
30
+ export interface DiscoveryConfig {
31
+ readonly staticPeers: readonly string[];
32
+ readonly enableDnsSd: boolean;
33
+ readonly enableIpfsRegistry: boolean;
34
+ readonly ipfsRegistryCid?: string;
35
+ readonly discoveryIntervalMs: number;
36
+ readonly staleThresholdMs: number;
37
+ }
38
+ export declare class DiscoveryService {
39
+ private readonly deps;
40
+ private readonly config;
41
+ private readonly knownPeers;
42
+ private localManifest;
43
+ private discoveryTimer;
44
+ constructor(deps: DiscoveryServiceDeps, config?: Partial<DiscoveryConfig>);
45
+ publishManifest(manifest: Omit<FederationManifest, 'signature'>): Promise<FederationManifest>;
46
+ getLocalManifest(): FederationManifest | null;
47
+ discoverPeers(): Promise<FederationNode[]>;
48
+ addStaticPeer(endpoint: string, manifest?: FederationManifest): Promise<FederationNode>;
49
+ /**
50
+ * Register an externally-discovered peer (e.g. mapped from an A2A Agent
51
+ * Card via `fromAgentCard`). Unlike `addStaticPeer` this takes a fully
52
+ * constructed node — the caller owns validation of the external format —
53
+ * and the node keeps whatever trust level it was constructed with
54
+ * (A2A-card peers arrive UNTRUSTED). Existing peers are refreshed, not
55
+ * replaced, so accumulated trust state survives re-discovery.
56
+ */
57
+ registerExternalPeer(node: FederationNode): FederationNode;
58
+ removePeer(nodeId: string): boolean;
59
+ getPeer(nodeId: string): FederationNode | undefined;
60
+ listPeers(): FederationNode[];
61
+ listActivePeers(): FederationNode[];
62
+ pruneStale(): string[];
63
+ startPeriodicDiscovery(): void;
64
+ stopPeriodicDiscovery(): void;
65
+ private findByEndpoint;
66
+ private hashEndpoint;
67
+ }
68
+ //# sourceMappingURL=discovery-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery-service.d.ts","sourceRoot":"","sources":["../../../src/domain/services/discovery-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA4B,MAAM,gCAAgC,CAAC;AAE1F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,QAAQ,GAAG,eAAe,GAAG,UAAU,CAAC;AAEpF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE;QACrB,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,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,EAAE,oBAAoB,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC;IAQnE,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAMnG,gBAAgB,IAAI,kBAAkB,GAAG,IAAI;IAIvC,aAAa,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IA2B1C,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IAwC7F;;;;;;;OAOG;IACH,oBAAoB,CAAC,IAAI,EAAE,cAAc,GAAG,cAAc;IAW1D,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAInC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAInD,SAAS,IAAI,cAAc,EAAE;IAI7B,eAAe,IAAI,cAAc,EAAE;IAInC,UAAU,IAAI,MAAM,EAAE;IAWtB,sBAAsB,IAAI,IAAI;IAO9B,qBAAqB,IAAI,IAAI;IAO7B,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,YAAY;CASrB"}
@@ -0,0 +1,161 @@
1
+ import { FederationNode } from '../entities/federation-node.js';
2
+ import { TrustLevel } from '../entities/trust-level.js';
3
+ const DEFAULT_DISCOVERY_CONFIG = {
4
+ staticPeers: [],
5
+ enableDnsSd: false,
6
+ enableIpfsRegistry: false,
7
+ discoveryIntervalMs: 60_000,
8
+ staleThresholdMs: 300_000,
9
+ };
10
+ export class DiscoveryService {
11
+ deps;
12
+ config;
13
+ knownPeers;
14
+ localManifest;
15
+ discoveryTimer;
16
+ constructor(deps, config) {
17
+ this.deps = deps;
18
+ this.config = { ...DEFAULT_DISCOVERY_CONFIG, ...config };
19
+ this.knownPeers = new Map();
20
+ this.localManifest = null;
21
+ this.discoveryTimer = null;
22
+ }
23
+ async publishManifest(manifest) {
24
+ const signature = await this.deps.signManifest(manifest);
25
+ this.localManifest = { ...manifest, signature };
26
+ return this.localManifest;
27
+ }
28
+ getLocalManifest() {
29
+ return this.localManifest;
30
+ }
31
+ async discoverPeers() {
32
+ const discovered = [];
33
+ for (const endpoint of this.config.staticPeers) {
34
+ const existing = this.findByEndpoint(endpoint);
35
+ if (!existing) {
36
+ const node = FederationNode.create({
37
+ nodeId: `static-${this.hashEndpoint(endpoint)}`,
38
+ publicKey: '',
39
+ endpoint,
40
+ capabilities: {
41
+ agentTypes: [],
42
+ maxConcurrentSessions: 1,
43
+ supportedProtocols: ['websocket', 'http'],
44
+ complianceModes: [],
45
+ },
46
+ metadata: { discoveryMechanism: 'static' },
47
+ });
48
+ this.knownPeers.set(node.nodeId, node);
49
+ discovered.push(node);
50
+ this.deps.onPeerDiscovered?.(node);
51
+ }
52
+ }
53
+ return discovered;
54
+ }
55
+ async addStaticPeer(endpoint, manifest) {
56
+ if (manifest) {
57
+ if (manifest.endpoint !== endpoint) {
58
+ throw new Error(`Manifest endpoint mismatch: expected ${endpoint}`);
59
+ }
60
+ const valid = await this.deps.verifyManifest(manifest);
61
+ if (!valid) {
62
+ throw new Error(`Invalid manifest signature for endpoint: ${endpoint}`);
63
+ }
64
+ }
65
+ const nodeId = manifest?.nodeId ?? `static-${this.hashEndpoint(endpoint)}`;
66
+ const existing = this.knownPeers.get(nodeId);
67
+ if (existing) {
68
+ existing.markSeen();
69
+ return existing;
70
+ }
71
+ const node = FederationNode.create({
72
+ nodeId,
73
+ publicKey: manifest?.publicKey ?? '',
74
+ endpoint,
75
+ capabilities: manifest?.capabilities ?? {
76
+ agentTypes: [],
77
+ maxConcurrentSessions: 1,
78
+ supportedProtocols: ['websocket', 'http'],
79
+ complianceModes: [],
80
+ },
81
+ trustLevel: manifest ? TrustLevel.VERIFIED : TrustLevel.UNTRUSTED,
82
+ metadata: {
83
+ discoveryMechanism: 'static',
84
+ version: manifest?.version,
85
+ },
86
+ });
87
+ this.knownPeers.set(nodeId, node);
88
+ this.deps.onPeerDiscovered?.(node);
89
+ return node;
90
+ }
91
+ /**
92
+ * Register an externally-discovered peer (e.g. mapped from an A2A Agent
93
+ * Card via `fromAgentCard`). Unlike `addStaticPeer` this takes a fully
94
+ * constructed node — the caller owns validation of the external format —
95
+ * and the node keeps whatever trust level it was constructed with
96
+ * (A2A-card peers arrive UNTRUSTED). Existing peers are refreshed, not
97
+ * replaced, so accumulated trust state survives re-discovery.
98
+ */
99
+ registerExternalPeer(node) {
100
+ const existing = this.knownPeers.get(node.nodeId);
101
+ if (existing) {
102
+ existing.markSeen();
103
+ return existing;
104
+ }
105
+ this.knownPeers.set(node.nodeId, node);
106
+ this.deps.onPeerDiscovered?.(node);
107
+ return node;
108
+ }
109
+ removePeer(nodeId) {
110
+ return this.knownPeers.delete(nodeId);
111
+ }
112
+ getPeer(nodeId) {
113
+ return this.knownPeers.get(nodeId);
114
+ }
115
+ listPeers() {
116
+ return Array.from(this.knownPeers.values());
117
+ }
118
+ listActivePeers() {
119
+ return this.listPeers().filter(p => !p.isStale(this.config.staleThresholdMs));
120
+ }
121
+ pruneStale() {
122
+ const pruned = [];
123
+ for (const [nodeId, node] of this.knownPeers) {
124
+ if (node.isStale(this.config.staleThresholdMs)) {
125
+ this.knownPeers.delete(nodeId);
126
+ pruned.push(nodeId);
127
+ }
128
+ }
129
+ return pruned;
130
+ }
131
+ startPeriodicDiscovery() {
132
+ if (this.discoveryTimer)
133
+ return;
134
+ this.discoveryTimer = setInterval(() => {
135
+ this.discoverPeers().catch(() => { });
136
+ }, this.config.discoveryIntervalMs);
137
+ }
138
+ stopPeriodicDiscovery() {
139
+ if (this.discoveryTimer) {
140
+ clearInterval(this.discoveryTimer);
141
+ this.discoveryTimer = null;
142
+ }
143
+ }
144
+ findByEndpoint(endpoint) {
145
+ for (const node of this.knownPeers.values()) {
146
+ if (node.endpoint === endpoint)
147
+ return node;
148
+ }
149
+ return undefined;
150
+ }
151
+ hashEndpoint(endpoint) {
152
+ let hash = 0;
153
+ for (let i = 0; i < endpoint.length; i++) {
154
+ const char = endpoint.charCodeAt(i);
155
+ hash = ((hash << 5) - hash) + char;
156
+ hash |= 0;
157
+ }
158
+ return Math.abs(hash).toString(36);
159
+ }
160
+ }
161
+ //# sourceMappingURL=discovery-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery-service.js","sourceRoot":"","sources":["../../../src/domain/services/discovery-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA4B,MAAM,gCAAgC,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AA0CxD,MAAM,wBAAwB,GAAoB;IAChD,WAAW,EAAE,EAAE;IACf,WAAW,EAAE,KAAK;IAClB,kBAAkB,EAAE,KAAK;IACzB,mBAAmB,EAAE,MAAM;IAC3B,gBAAgB,EAAE,OAAO;CAC1B,CAAC;AAEF,MAAM,OAAO,gBAAgB;IACV,IAAI,CAAuB;IAC3B,MAAM,CAAkB;IACxB,UAAU,CAA8B;IACjD,aAAa,CAA4B;IACzC,cAAc,CAAwC;IAE9D,YAAY,IAA0B,EAAE,MAAiC;QACvE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,wBAAwB,EAAE,GAAG,MAAM,EAAE,CAAC;QACzD,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,QAA+C;QACnE,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACzD,IAAI,CAAC,aAAa,GAAG,EAAE,GAAG,QAAQ,EAAE,SAAS,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,gBAAgB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C,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,GAAG,EAAE;YACrC,IAAI,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACvC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IACtC,CAAC;IAED,qBAAqB;QACnB,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,aAAa,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YACnC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC7B,CAAC;IACH,CAAC;IAEO,cAAc,CAAC,QAAgB;QACrC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;YAC5C,IAAI,IAAI,CAAC,QAAQ,KAAK,QAAQ;gBAAE,OAAO,IAAI,CAAC;QAC9C,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,YAAY,CAAC,QAAgB;QACnC,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACzC,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACpC,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;YACnC,IAAI,IAAI,CAAC,CAAC;QACZ,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACrC,CAAC;CACF"}
@@ -0,0 +1,58 @@
1
+ import { FederationNode } from '../entities/federation-node.js';
2
+ import { FederationSession } from '../entities/federation-session.js';
3
+ export interface HandshakeChallenge {
4
+ readonly challengeId: string;
5
+ readonly nonce: string;
6
+ readonly timestamp: string;
7
+ readonly sourceNodeId: string;
8
+ readonly targetNodeId: string;
9
+ }
10
+ export interface HandshakeChallengeResponse {
11
+ readonly challengeId: string;
12
+ readonly signedNonce: string;
13
+ readonly publicKey: string;
14
+ readonly capabilities: readonly string[];
15
+ }
16
+ export interface HandshakeResult {
17
+ readonly success: boolean;
18
+ readonly session?: FederationSession;
19
+ readonly error?: string;
20
+ }
21
+ export interface HandshakeServiceDeps {
22
+ generateSessionId: () => string;
23
+ generateSessionToken: () => string;
24
+ generateNonce: () => string;
25
+ signChallenge: (nonce: string) => Promise<string>;
26
+ verifySignature: (nonce: string, signature: string, publicKey: string) => Promise<boolean>;
27
+ getLocalNodeId: () => string;
28
+ getLocalPublicKey: () => string;
29
+ getLocalCapabilities: () => readonly string[];
30
+ }
31
+ export interface HandshakeConfig {
32
+ readonly sessionTtlMs: number;
33
+ readonly maxSessionTtlMs: number;
34
+ readonly heartbeatIntervalMs: number;
35
+ readonly challengeTimeoutMs: number;
36
+ }
37
+ export declare class HandshakeService {
38
+ private readonly deps;
39
+ private readonly config;
40
+ private readonly pendingChallenges;
41
+ constructor(deps: HandshakeServiceDeps, config?: Partial<HandshakeConfig>);
42
+ initiateHandshake(remoteNode: FederationNode): Promise<HandshakeChallenge>;
43
+ respondToHandshake(challenge: HandshakeChallenge): Promise<HandshakeChallengeResponse>;
44
+ verifyChallenge(response: HandshakeChallengeResponse, remoteNode: FederationNode): Promise<HandshakeResult>;
45
+ /**
46
+ * Establish a capability-limited session from discovery evidence.
47
+ *
48
+ * A signed manifest proves that the advertised key bound the protocol list;
49
+ * it does not prove live challenge response, so this path never elevates
50
+ * beyond VERIFIED. Endpoint-only peers remain UNTRUSTED with no negotiated
51
+ * optional capabilities. A future wire handshake may elevate either session
52
+ * after authenticating a response received from the remote process.
53
+ */
54
+ establishDiscoverySession(remoteNode: FederationNode, verifiedManifest: boolean): FederationSession;
55
+ renewSession(session: FederationSession): FederationSession;
56
+ private cleanExpiredChallenges;
57
+ }
58
+ //# sourceMappingURL=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AE,MAAM,MAAM,CAAC;IAC7B,iBAAiB,EAAE,MAAM,MAAM,CAAC;IAChC,oBAAoB,EAAE,MAAM,SAAS,MAAM,EAAE,CAAC;CAC/C;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;CACrC;AASD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAuB;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAoE;gBAE1F,IAAI,EAAE,oBAAoB,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC;IAMnE,iBAAiB,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAmB1E,kBAAkB,CAAC,SAAS,EAAE,kBAAkB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAWtF,eAAe,CACnB,QAAQ,EAAE,0BAA0B,EACpC,UAAU,EAAE,cAAc,GACzB,OAAO,CAAC,eAAe,CAAC;IAiD3B;;;;;;;;OAQG;IACH,yBAAyB,CACvB,UAAU,EAAE,cAAc,EAC1B,gBAAgB,EAAE,OAAO,GACxB,iBAAiB;IAsBpB,YAAY,CAAC,OAAO,EAAE,iBAAiB,GAAG,iBAAiB;IAY3D,OAAO,CAAC,sBAAsB;CAQ/B"}
@@ -0,0 +1,122 @@
1
+ import { FederationSession } from '../entities/federation-session.js';
2
+ import { TrustLevel } from '../entities/trust-level.js';
3
+ const DEFAULT_HANDSHAKE_CONFIG = {
4
+ sessionTtlMs: 3_600_000,
5
+ maxSessionTtlMs: 86_400_000,
6
+ heartbeatIntervalMs: 30_000,
7
+ challengeTimeoutMs: 10_000,
8
+ };
9
+ export class HandshakeService {
10
+ deps;
11
+ config;
12
+ pendingChallenges;
13
+ constructor(deps, config) {
14
+ this.deps = deps;
15
+ this.config = { ...DEFAULT_HANDSHAKE_CONFIG, ...config };
16
+ this.pendingChallenges = new Map();
17
+ }
18
+ async initiateHandshake(remoteNode) {
19
+ const nonce = this.deps.generateNonce();
20
+ const challenge = {
21
+ challengeId: this.deps.generateSessionId(),
22
+ nonce,
23
+ timestamp: new Date().toISOString(),
24
+ sourceNodeId: this.deps.getLocalNodeId(),
25
+ targetNodeId: remoteNode.nodeId,
26
+ };
27
+ this.pendingChallenges.set(challenge.challengeId, {
28
+ challenge,
29
+ expiresAt: Date.now() + this.config.challengeTimeoutMs,
30
+ });
31
+ this.cleanExpiredChallenges();
32
+ return challenge;
33
+ }
34
+ async respondToHandshake(challenge) {
35
+ const signedNonce = await this.deps.signChallenge(challenge.nonce);
36
+ return {
37
+ challengeId: challenge.challengeId,
38
+ signedNonce,
39
+ publicKey: this.deps.getLocalPublicKey(),
40
+ capabilities: this.deps.getLocalCapabilities(),
41
+ };
42
+ }
43
+ async verifyChallenge(response, remoteNode) {
44
+ const pending = this.pendingChallenges.get(response.challengeId);
45
+ if (!pending) {
46
+ return { success: false, error: 'Unknown or expired challenge' };
47
+ }
48
+ if (Date.now() > pending.expiresAt) {
49
+ this.pendingChallenges.delete(response.challengeId);
50
+ return { success: false, error: 'Challenge expired' };
51
+ }
52
+ const isValid = await this.deps.verifySignature(pending.challenge.nonce, response.signedNonce, response.publicKey);
53
+ this.pendingChallenges.delete(response.challengeId);
54
+ if (!isValid) {
55
+ return { success: false, error: 'Invalid challenge signature' };
56
+ }
57
+ const localCapabilities = this.deps.getLocalCapabilities();
58
+ const negotiatedCapabilities = localCapabilities.filter(cap => response.capabilities.includes(cap));
59
+ const now = new Date();
60
+ const session = new FederationSession({
61
+ sessionId: this.deps.generateSessionId(),
62
+ localNodeId: this.deps.getLocalNodeId(),
63
+ remoteNodeId: remoteNode.nodeId,
64
+ trustLevel: TrustLevel.ATTESTED,
65
+ negotiatedCapabilities,
66
+ createdAt: now,
67
+ expiresAt: new Date(now.getTime() + this.config.sessionTtlMs),
68
+ heartbeatInterval: this.config.heartbeatIntervalMs,
69
+ sessionToken: this.deps.generateSessionToken(),
70
+ metrics: FederationSession.createMetrics(),
71
+ });
72
+ remoteNode.updateTrustLevel(TrustLevel.ATTESTED);
73
+ remoteNode.markSeen();
74
+ return { success: true, session };
75
+ }
76
+ /**
77
+ * Establish a capability-limited session from discovery evidence.
78
+ *
79
+ * A signed manifest proves that the advertised key bound the protocol list;
80
+ * it does not prove live challenge response, so this path never elevates
81
+ * beyond VERIFIED. Endpoint-only peers remain UNTRUSTED with no negotiated
82
+ * optional capabilities. A future wire handshake may elevate either session
83
+ * after authenticating a response received from the remote process.
84
+ */
85
+ establishDiscoverySession(remoteNode, verifiedManifest) {
86
+ const remoteCapabilities = verifiedManifest
87
+ ? remoteNode.capabilities.supportedProtocols
88
+ : [];
89
+ const negotiatedCapabilities = this.deps.getLocalCapabilities().filter((capability) => remoteCapabilities.includes(capability));
90
+ const now = new Date();
91
+ return new FederationSession({
92
+ sessionId: this.deps.generateSessionId(),
93
+ localNodeId: this.deps.getLocalNodeId(),
94
+ remoteNodeId: remoteNode.nodeId,
95
+ trustLevel: verifiedManifest ? TrustLevel.VERIFIED : TrustLevel.UNTRUSTED,
96
+ negotiatedCapabilities,
97
+ createdAt: now,
98
+ expiresAt: new Date(now.getTime() + this.config.sessionTtlMs),
99
+ heartbeatInterval: this.config.heartbeatIntervalMs,
100
+ sessionToken: this.deps.generateSessionToken(),
101
+ metrics: FederationSession.createMetrics(),
102
+ });
103
+ }
104
+ renewSession(session) {
105
+ const remainingTtl = this.config.maxSessionTtlMs - (Date.now() - session.createdAt.getTime());
106
+ const renewalTtl = Math.min(this.config.sessionTtlMs, remainingTtl);
107
+ if (renewalTtl <= 0) {
108
+ throw new Error('Session has exceeded maximum TTL and cannot be renewed');
109
+ }
110
+ session.renew(new Date(Date.now() + renewalTtl));
111
+ return session;
112
+ }
113
+ cleanExpiredChallenges() {
114
+ const now = Date.now();
115
+ for (const [id, pending] of this.pendingChallenges) {
116
+ if (now > pending.expiresAt) {
117
+ this.pendingChallenges.delete(id);
118
+ }
119
+ }
120
+ }
121
+ }
122
+ //# sourceMappingURL=handshake-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handshake-service.js","sourceRoot":"","sources":["../../../src/domain/services/handshake-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAuB,MAAM,mCAAmC,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAyCxD,MAAM,wBAAwB,GAAoB;IAChD,YAAY,EAAE,SAAS;IACvB,eAAe,EAAE,UAAU;IAC3B,mBAAmB,EAAE,MAAM;IAC3B,kBAAkB,EAAE,MAAM;CAC3B,CAAC;AAEF,MAAM,OAAO,gBAAgB;IACV,IAAI,CAAuB;IAC3B,MAAM,CAAkB;IACxB,iBAAiB,CAAoE;IAEtG,YAAY,IAA0B,EAAE,MAAiC;QACvE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,wBAAwB,EAAE,GAAG,MAAM,EAAE,CAAC;QACzD,IAAI,CAAC,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,UAA0B;QAChD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QACxC,MAAM,SAAS,GAAuB;YACpC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC1C,KAAK;YACL,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YACxC,YAAY,EAAE,UAAU,CAAC,MAAM;SAChC,CAAC;QAEF,IAA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