@claude-flow/cli 3.32.29 → 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 (372) hide show
  1. package/.claude/helpers/helpers.manifest.json +2 -2
  2. package/catalog-manifest.json +2 -2
  3. package/dist/src/init/claudemd-generator.js +53 -2
  4. package/dist/src/mcp-tools/capability-brain.js +22 -22
  5. package/dist/src/mcp-tools/guidance-tools.js +1 -1
  6. package/node_modules/@claude-flow/codex/.agents/skills/memory-management/SKILL.md +45 -0
  7. package/node_modules/@claude-flow/codex/.agents/skills/security-audit/SKILL.md +46 -0
  8. package/node_modules/@claude-flow/codex/.agents/skills/sparc-methodology/SKILL.md +46 -0
  9. package/node_modules/@claude-flow/codex/.agents/skills/swarm-orchestration/SKILL.md +53 -0
  10. package/node_modules/@claude-flow/codex/README.md +1044 -0
  11. package/node_modules/@claude-flow/codex/dist/cli.d.ts +9 -0
  12. package/node_modules/@claude-flow/codex/dist/cli.d.ts.map +1 -0
  13. package/node_modules/@claude-flow/codex/dist/cli.js +686 -0
  14. package/node_modules/@claude-flow/codex/dist/cli.js.map +1 -0
  15. package/node_modules/@claude-flow/codex/dist/dual-mode/cli.d.ts +17 -0
  16. package/node_modules/@claude-flow/codex/dist/dual-mode/cli.d.ts.map +1 -0
  17. package/node_modules/@claude-flow/codex/dist/dual-mode/cli.js +278 -0
  18. package/node_modules/@claude-flow/codex/dist/dual-mode/cli.js.map +1 -0
  19. package/node_modules/@claude-flow/codex/dist/dual-mode/index.d.ts +8 -0
  20. package/node_modules/@claude-flow/codex/dist/dual-mode/index.d.ts.map +1 -0
  21. package/node_modules/@claude-flow/codex/dist/dual-mode/index.js +7 -0
  22. package/node_modules/@claude-flow/codex/dist/dual-mode/index.js.map +1 -0
  23. package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.d.ts +143 -0
  24. package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.d.ts.map +1 -0
  25. package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.js +621 -0
  26. package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.js.map +1 -0
  27. package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts +12 -0
  28. package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts.map +1 -0
  29. package/node_modules/@claude-flow/codex/dist/generators/agents-md.js +730 -0
  30. package/node_modules/@claude-flow/codex/dist/generators/agents-md.js.map +1 -0
  31. package/node_modules/@claude-flow/codex/dist/generators/config-toml.d.ts +74 -0
  32. package/node_modules/@claude-flow/codex/dist/generators/config-toml.d.ts.map +1 -0
  33. package/node_modules/@claude-flow/codex/dist/generators/config-toml.js +922 -0
  34. package/node_modules/@claude-flow/codex/dist/generators/config-toml.js.map +1 -0
  35. package/node_modules/@claude-flow/codex/dist/generators/index.d.ts +9 -0
  36. package/node_modules/@claude-flow/codex/dist/generators/index.d.ts.map +1 -0
  37. package/node_modules/@claude-flow/codex/dist/generators/index.js +9 -0
  38. package/node_modules/@claude-flow/codex/dist/generators/index.js.map +1 -0
  39. package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts +20 -0
  40. package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts.map +1 -0
  41. package/node_modules/@claude-flow/codex/dist/generators/skill-md.js +951 -0
  42. package/node_modules/@claude-flow/codex/dist/generators/skill-md.js.map +1 -0
  43. package/node_modules/@claude-flow/codex/dist/harness/build-evidence.d.ts +46 -0
  44. package/node_modules/@claude-flow/codex/dist/harness/build-evidence.d.ts.map +1 -0
  45. package/node_modules/@claude-flow/codex/dist/harness/build-evidence.js +126 -0
  46. package/node_modules/@claude-flow/codex/dist/harness/build-evidence.js.map +1 -0
  47. package/node_modules/@claude-flow/codex/dist/harness/contract.d.ts +153 -0
  48. package/node_modules/@claude-flow/codex/dist/harness/contract.d.ts.map +1 -0
  49. package/node_modules/@claude-flow/codex/dist/harness/contract.js +44 -0
  50. package/node_modules/@claude-flow/codex/dist/harness/contract.js.map +1 -0
  51. package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.d.ts +33 -0
  52. package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.d.ts.map +1 -0
  53. package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.js +175 -0
  54. package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.js.map +1 -0
  55. package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.d.ts +42 -0
  56. package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.d.ts.map +1 -0
  57. package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.js +140 -0
  58. package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.js.map +1 -0
  59. package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.d.ts +19 -0
  60. package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.d.ts.map +1 -0
  61. package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.js +79 -0
  62. package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.js.map +1 -0
  63. package/node_modules/@claude-flow/codex/dist/harness/index.d.ts +9 -0
  64. package/node_modules/@claude-flow/codex/dist/harness/index.d.ts.map +1 -0
  65. package/node_modules/@claude-flow/codex/dist/harness/index.js +9 -0
  66. package/node_modules/@claude-flow/codex/dist/harness/index.js.map +1 -0
  67. package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.d.ts +8 -0
  68. package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.d.ts.map +1 -0
  69. package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.js +10 -0
  70. package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.js.map +1 -0
  71. package/node_modules/@claude-flow/codex/dist/harness/repository-state.d.ts +68 -0
  72. package/node_modules/@claude-flow/codex/dist/harness/repository-state.d.ts.map +1 -0
  73. package/node_modules/@claude-flow/codex/dist/harness/repository-state.js +403 -0
  74. package/node_modules/@claude-flow/codex/dist/harness/repository-state.js.map +1 -0
  75. package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.d.ts +3 -0
  76. package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.d.ts.map +1 -0
  77. package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.js +14 -0
  78. package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.js.map +1 -0
  79. package/node_modules/@claude-flow/codex/dist/index.d.ts +53 -0
  80. package/node_modules/@claude-flow/codex/dist/index.d.ts.map +1 -0
  81. package/node_modules/@claude-flow/codex/dist/index.js +54 -0
  82. package/node_modules/@claude-flow/codex/dist/index.js.map +1 -0
  83. package/node_modules/@claude-flow/codex/dist/initializer.d.ts +98 -0
  84. package/node_modules/@claude-flow/codex/dist/initializer.d.ts.map +1 -0
  85. package/node_modules/@claude-flow/codex/dist/initializer.js +795 -0
  86. package/node_modules/@claude-flow/codex/dist/initializer.js.map +1 -0
  87. package/node_modules/@claude-flow/codex/dist/loop/cli.d.ts +3 -0
  88. package/node_modules/@claude-flow/codex/dist/loop/cli.d.ts.map +1 -0
  89. package/node_modules/@claude-flow/codex/dist/loop/cli.js +123 -0
  90. package/node_modules/@claude-flow/codex/dist/loop/cli.js.map +1 -0
  91. package/node_modules/@claude-flow/codex/dist/loop/index.d.ts +58 -0
  92. package/node_modules/@claude-flow/codex/dist/loop/index.d.ts.map +1 -0
  93. package/node_modules/@claude-flow/codex/dist/loop/index.js +230 -0
  94. package/node_modules/@claude-flow/codex/dist/loop/index.js.map +1 -0
  95. package/node_modules/@claude-flow/codex/dist/mcp-config.d.ts +28 -0
  96. package/node_modules/@claude-flow/codex/dist/mcp-config.d.ts.map +1 -0
  97. package/node_modules/@claude-flow/codex/dist/mcp-config.js +121 -0
  98. package/node_modules/@claude-flow/codex/dist/mcp-config.js.map +1 -0
  99. package/node_modules/@claude-flow/codex/dist/migrations/index.d.ts +114 -0
  100. package/node_modules/@claude-flow/codex/dist/migrations/index.d.ts.map +1 -0
  101. package/node_modules/@claude-flow/codex/dist/migrations/index.js +880 -0
  102. package/node_modules/@claude-flow/codex/dist/migrations/index.js.map +1 -0
  103. package/node_modules/@claude-flow/codex/dist/templates/index.d.ts +92 -0
  104. package/node_modules/@claude-flow/codex/dist/templates/index.d.ts.map +1 -0
  105. package/node_modules/@claude-flow/codex/dist/templates/index.js +284 -0
  106. package/node_modules/@claude-flow/codex/dist/templates/index.js.map +1 -0
  107. package/node_modules/@claude-flow/codex/dist/types.d.ts +240 -0
  108. package/node_modules/@claude-flow/codex/dist/types.d.ts.map +1 -0
  109. package/node_modules/@claude-flow/codex/dist/types.js +8 -0
  110. package/node_modules/@claude-flow/codex/dist/types.js.map +1 -0
  111. package/node_modules/@claude-flow/codex/dist/validators/index.d.ts +42 -0
  112. package/node_modules/@claude-flow/codex/dist/validators/index.d.ts.map +1 -0
  113. package/node_modules/@claude-flow/codex/dist/validators/index.js +929 -0
  114. package/node_modules/@claude-flow/codex/dist/validators/index.js.map +1 -0
  115. package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.d.ts +37 -0
  116. package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.d.ts.map +1 -0
  117. package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.js +137 -0
  118. package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.js.map +1 -0
  119. package/node_modules/@claude-flow/codex/dist/worktrees/index.d.ts +2 -0
  120. package/node_modules/@claude-flow/codex/dist/worktrees/index.d.ts.map +1 -0
  121. package/node_modules/@claude-flow/codex/dist/worktrees/index.js +2 -0
  122. package/node_modules/@claude-flow/codex/dist/worktrees/index.js.map +1 -0
  123. package/node_modules/@claude-flow/codex/package.json +122 -0
  124. package/node_modules/@claude-flow/plugin-agent-federation/README.md +49 -0
  125. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.d.ts +130 -0
  126. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.d.ts.map +1 -0
  127. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.js +239 -0
  128. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.js.map +1 -0
  129. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.d.ts +34 -0
  130. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.d.ts.map +1 -0
  131. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.js +69 -0
  132. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.js.map +1 -0
  133. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.d.ts +46 -0
  134. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.d.ts.map +1 -0
  135. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.js +84 -0
  136. package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.js.map +1 -0
  137. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.d.ts +27 -0
  138. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.d.ts.map +1 -0
  139. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.js +46 -0
  140. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.js.map +1 -0
  141. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.d.ts +192 -0
  142. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.d.ts.map +1 -0
  143. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.js +253 -0
  144. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.js.map +1 -0
  145. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.d.ts +211 -0
  146. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.d.ts.map +1 -0
  147. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js +501 -0
  148. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js.map +1 -0
  149. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts +114 -0
  150. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts.map +1 -0
  151. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js +356 -0
  152. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js.map +1 -0
  153. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.d.ts +41 -0
  154. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.d.ts.map +1 -0
  155. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js +184 -0
  156. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js.map +1 -0
  157. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.d.ts +150 -0
  158. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.d.ts.map +1 -0
  159. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.js +128 -0
  160. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.js.map +1 -0
  161. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.d.ts +74 -0
  162. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.d.ts.map +1 -0
  163. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.js +179 -0
  164. package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.js.map +1 -0
  165. package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.d.ts +13 -0
  166. package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.d.ts.map +1 -0
  167. package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js +189 -0
  168. package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js.map +1 -0
  169. package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.d.ts +7 -0
  170. package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.d.ts.map +1 -0
  171. package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.js +317 -0
  172. package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.js.map +1 -0
  173. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.d.ts +45 -0
  174. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.d.ts.map +1 -0
  175. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.js +71 -0
  176. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.js.map +1 -0
  177. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.d.ts +104 -0
  178. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.d.ts.map +1 -0
  179. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.js +152 -0
  180. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.js.map +1 -0
  181. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.d.ts +55 -0
  182. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.d.ts.map +1 -0
  183. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.js +105 -0
  184. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.js.map +1 -0
  185. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.d.ts +17 -0
  186. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.d.ts.map +1 -0
  187. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.js +35 -0
  188. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.js.map +1 -0
  189. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.d.ts +69 -0
  190. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.d.ts.map +1 -0
  191. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.js +149 -0
  192. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.js.map +1 -0
  193. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts +68 -0
  194. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts.map +1 -0
  195. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js +161 -0
  196. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js.map +1 -0
  197. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts +58 -0
  198. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts.map +1 -0
  199. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js +122 -0
  200. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js.map +1 -0
  201. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.d.ts +65 -0
  202. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.d.ts.map +1 -0
  203. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.js +208 -0
  204. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.js.map +1 -0
  205. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.d.ts +51 -0
  206. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.d.ts.map +1 -0
  207. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.js +147 -0
  208. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.js.map +1 -0
  209. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.d.ts +71 -0
  210. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.d.ts.map +1 -0
  211. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.js +194 -0
  212. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.js.map +1 -0
  213. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.d.ts +156 -0
  214. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.d.ts.map +1 -0
  215. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.js +292 -0
  216. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.js.map +1 -0
  217. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.d.ts +98 -0
  218. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.d.ts.map +1 -0
  219. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.js +122 -0
  220. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.js.map +1 -0
  221. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.d.ts +89 -0
  222. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.d.ts.map +1 -0
  223. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.js +165 -0
  224. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.js.map +1 -0
  225. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.d.ts +92 -0
  226. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.d.ts.map +1 -0
  227. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.js +100 -0
  228. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.js.map +1 -0
  229. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.d.ts +70 -0
  230. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.d.ts.map +1 -0
  231. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.js +104 -0
  232. package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.js.map +1 -0
  233. package/node_modules/@claude-flow/plugin-agent-federation/dist/index.d.ts +23 -0
  234. package/node_modules/@claude-flow/plugin-agent-federation/dist/index.d.ts.map +1 -0
  235. package/node_modules/@claude-flow/plugin-agent-federation/dist/index.js +24 -0
  236. package/node_modules/@claude-flow/plugin-agent-federation/dist/index.js.map +1 -0
  237. package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.d.ts +10 -0
  238. package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.d.ts.map +1 -0
  239. package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.js +439 -0
  240. package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.js.map +1 -0
  241. package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts +19 -0
  242. package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts.map +1 -0
  243. package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js +515 -0
  244. package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js.map +1 -0
  245. package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.d.ts +72 -0
  246. package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.d.ts.map +1 -0
  247. package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js +269 -0
  248. package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js.map +1 -0
  249. package/node_modules/@claude-flow/plugin-agent-federation/dist/version.d.ts +3 -0
  250. package/node_modules/@claude-flow/plugin-agent-federation/dist/version.d.ts.map +1 -0
  251. package/node_modules/@claude-flow/plugin-agent-federation/dist/version.js +3 -0
  252. package/node_modules/@claude-flow/plugin-agent-federation/dist/version.js.map +1 -0
  253. package/node_modules/@claude-flow/plugin-agent-federation/package.json +64 -0
  254. package/node_modules/@claude-flow/security/README.md +292 -0
  255. package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.d.ts +97 -0
  256. package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.d.ts.map +1 -0
  257. package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.js +537 -0
  258. package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.js.map +1 -0
  259. package/node_modules/@claude-flow/security/dist/application/index.d.ts +7 -0
  260. package/node_modules/@claude-flow/security/dist/application/index.d.ts.map +1 -0
  261. package/node_modules/@claude-flow/security/dist/application/index.js +7 -0
  262. package/node_modules/@claude-flow/security/dist/application/index.js.map +1 -0
  263. package/node_modules/@claude-flow/security/dist/application/services/security-application-service.d.ts +71 -0
  264. package/node_modules/@claude-flow/security/dist/application/services/security-application-service.d.ts.map +1 -0
  265. package/node_modules/@claude-flow/security/dist/application/services/security-application-service.js +153 -0
  266. package/node_modules/@claude-flow/security/dist/application/services/security-application-service.js.map +1 -0
  267. package/node_modules/@claude-flow/security/dist/authorization/propagator.d.ts +148 -0
  268. package/node_modules/@claude-flow/security/dist/authorization/propagator.d.ts.map +1 -0
  269. package/node_modules/@claude-flow/security/dist/authorization/propagator.js +182 -0
  270. package/node_modules/@claude-flow/security/dist/authorization/propagator.js.map +1 -0
  271. package/node_modules/@claude-flow/security/dist/credential-generator.d.ts +176 -0
  272. package/node_modules/@claude-flow/security/dist/credential-generator.d.ts.map +1 -0
  273. package/node_modules/@claude-flow/security/dist/credential-generator.js +272 -0
  274. package/node_modules/@claude-flow/security/dist/credential-generator.js.map +1 -0
  275. package/node_modules/@claude-flow/security/dist/domain/entities/security-context.d.ts +68 -0
  276. package/node_modules/@claude-flow/security/dist/domain/entities/security-context.d.ts.map +1 -0
  277. package/node_modules/@claude-flow/security/dist/domain/entities/security-context.js +132 -0
  278. package/node_modules/@claude-flow/security/dist/domain/entities/security-context.js.map +1 -0
  279. package/node_modules/@claude-flow/security/dist/domain/index.d.ts +8 -0
  280. package/node_modules/@claude-flow/security/dist/domain/index.d.ts.map +1 -0
  281. package/node_modules/@claude-flow/security/dist/domain/index.js +8 -0
  282. package/node_modules/@claude-flow/security/dist/domain/index.js.map +1 -0
  283. package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.d.ts +71 -0
  284. package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.d.ts.map +1 -0
  285. package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.js +237 -0
  286. package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.js.map +1 -0
  287. package/node_modules/@claude-flow/security/dist/index.d.ts +129 -0
  288. package/node_modules/@claude-flow/security/dist/index.d.ts.map +1 -0
  289. package/node_modules/@claude-flow/security/dist/index.js +176 -0
  290. package/node_modules/@claude-flow/security/dist/index.js.map +1 -0
  291. package/node_modules/@claude-flow/security/dist/input-validator.d.ts +306 -0
  292. package/node_modules/@claude-flow/security/dist/input-validator.d.ts.map +1 -0
  293. package/node_modules/@claude-flow/security/dist/input-validator.js +393 -0
  294. package/node_modules/@claude-flow/security/dist/input-validator.js.map +1 -0
  295. package/node_modules/@claude-flow/security/dist/keychain-adapter.d.ts +48 -0
  296. package/node_modules/@claude-flow/security/dist/keychain-adapter.d.ts.map +1 -0
  297. package/node_modules/@claude-flow/security/dist/keychain-adapter.js +0 -0
  298. package/node_modules/@claude-flow/security/dist/keychain-adapter.js.map +1 -0
  299. package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.d.ts +133 -0
  300. package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.d.ts.map +1 -0
  301. package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.js +254 -0
  302. package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.js.map +1 -0
  303. package/node_modules/@claude-flow/security/dist/oauth/browser.d.ts +31 -0
  304. package/node_modules/@claude-flow/security/dist/oauth/browser.d.ts.map +1 -0
  305. package/node_modules/@claude-flow/security/dist/oauth/browser.js +55 -0
  306. package/node_modules/@claude-flow/security/dist/oauth/browser.js.map +1 -0
  307. package/node_modules/@claude-flow/security/dist/oauth/callback-server.d.ts +37 -0
  308. package/node_modules/@claude-flow/security/dist/oauth/callback-server.d.ts.map +1 -0
  309. package/node_modules/@claude-flow/security/dist/oauth/callback-server.js +86 -0
  310. package/node_modules/@claude-flow/security/dist/oauth/callback-server.js.map +1 -0
  311. package/node_modules/@claude-flow/security/dist/oauth/client.d.ts +57 -0
  312. package/node_modules/@claude-flow/security/dist/oauth/client.d.ts.map +1 -0
  313. package/node_modules/@claude-flow/security/dist/oauth/client.js +120 -0
  314. package/node_modules/@claude-flow/security/dist/oauth/client.js.map +1 -0
  315. package/node_modules/@claude-flow/security/dist/oauth/pkce.d.ts +25 -0
  316. package/node_modules/@claude-flow/security/dist/oauth/pkce.d.ts.map +1 -0
  317. package/node_modules/@claude-flow/security/dist/oauth/pkce.js +36 -0
  318. package/node_modules/@claude-flow/security/dist/oauth/pkce.js.map +1 -0
  319. package/node_modules/@claude-flow/security/dist/password-hasher.d.ts +128 -0
  320. package/node_modules/@claude-flow/security/dist/password-hasher.d.ts.map +1 -0
  321. package/node_modules/@claude-flow/security/dist/password-hasher.js +190 -0
  322. package/node_modules/@claude-flow/security/dist/password-hasher.js.map +1 -0
  323. package/node_modules/@claude-flow/security/dist/path-validator.d.ts +148 -0
  324. package/node_modules/@claude-flow/security/dist/path-validator.d.ts.map +1 -0
  325. package/node_modules/@claude-flow/security/dist/path-validator.js +421 -0
  326. package/node_modules/@claude-flow/security/dist/path-validator.js.map +1 -0
  327. package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.d.ts +125 -0
  328. package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.d.ts.map +1 -0
  329. package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.js +186 -0
  330. package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.js.map +1 -0
  331. package/node_modules/@claude-flow/security/dist/policy/canonical.d.ts +5 -0
  332. package/node_modules/@claude-flow/security/dist/policy/canonical.d.ts.map +1 -0
  333. package/node_modules/@claude-flow/security/dist/policy/canonical.js +30 -0
  334. package/node_modules/@claude-flow/security/dist/policy/canonical.js.map +1 -0
  335. package/node_modules/@claude-flow/security/dist/policy/engine.d.ts +34 -0
  336. package/node_modules/@claude-flow/security/dist/policy/engine.d.ts.map +1 -0
  337. package/node_modules/@claude-flow/security/dist/policy/engine.js +285 -0
  338. package/node_modules/@claude-flow/security/dist/policy/engine.js.map +1 -0
  339. package/node_modules/@claude-flow/security/dist/policy/envelope.d.ts +9 -0
  340. package/node_modules/@claude-flow/security/dist/policy/envelope.d.ts.map +1 -0
  341. package/node_modules/@claude-flow/security/dist/policy/envelope.js +90 -0
  342. package/node_modules/@claude-flow/security/dist/policy/envelope.js.map +1 -0
  343. package/node_modules/@claude-flow/security/dist/policy/evaluator.d.ts +4 -0
  344. package/node_modules/@claude-flow/security/dist/policy/evaluator.d.ts.map +1 -0
  345. package/node_modules/@claude-flow/security/dist/policy/evaluator.js +119 -0
  346. package/node_modules/@claude-flow/security/dist/policy/evaluator.js.map +1 -0
  347. package/node_modules/@claude-flow/security/dist/policy/index.d.ts +7 -0
  348. package/node_modules/@claude-flow/security/dist/policy/index.d.ts.map +1 -0
  349. package/node_modules/@claude-flow/security/dist/policy/index.js +7 -0
  350. package/node_modules/@claude-flow/security/dist/policy/index.js.map +1 -0
  351. package/node_modules/@claude-flow/security/dist/policy/product-plane.d.ts +238 -0
  352. package/node_modules/@claude-flow/security/dist/policy/product-plane.d.ts.map +1 -0
  353. package/node_modules/@claude-flow/security/dist/policy/product-plane.js +1022 -0
  354. package/node_modules/@claude-flow/security/dist/policy/product-plane.js.map +1 -0
  355. package/node_modules/@claude-flow/security/dist/policy/types.d.ts +169 -0
  356. package/node_modules/@claude-flow/security/dist/policy/types.d.ts.map +1 -0
  357. package/node_modules/@claude-flow/security/dist/policy/types.js +2 -0
  358. package/node_modules/@claude-flow/security/dist/policy/types.js.map +1 -0
  359. package/node_modules/@claude-flow/security/dist/safe-executor.d.ts +180 -0
  360. package/node_modules/@claude-flow/security/dist/safe-executor.d.ts.map +1 -0
  361. package/node_modules/@claude-flow/security/dist/safe-executor.js +390 -0
  362. package/node_modules/@claude-flow/security/dist/safe-executor.js.map +1 -0
  363. package/node_modules/@claude-flow/security/dist/token-generator.d.ts +224 -0
  364. package/node_modules/@claude-flow/security/dist/token-generator.d.ts.map +1 -0
  365. package/node_modules/@claude-flow/security/dist/token-generator.js +351 -0
  366. package/node_modules/@claude-flow/security/dist/token-generator.js.map +1 -0
  367. package/node_modules/@claude-flow/security/dist/tool-output-guardrail.d.ts +126 -0
  368. package/node_modules/@claude-flow/security/dist/tool-output-guardrail.d.ts.map +1 -0
  369. package/node_modules/@claude-flow/security/dist/tool-output-guardrail.js +257 -0
  370. package/node_modules/@claude-flow/security/dist/tool-output-guardrail.js.map +1 -0
  371. package/node_modules/@claude-flow/security/package.json +44 -0
  372. package/package.json +24 -8
@@ -0,0 +1,254 @@
1
+ /**
2
+ * MCP Tool Composition Inspector — ADR-320 (this ADR; ruvnet/ruflo dream-cycle
3
+ * proposal, arXiv:2606.27027 "ShareLock").
4
+ *
5
+ * The attack: an adversary registers N seemingly-benign MCP tools whose
6
+ * individual descriptions look fine in isolation, but whose CONCATENATION
7
+ * (or pairwise overlap) forms an injection payload targeting a downstream
8
+ * agent — a Shamir-secret-sharing-style split across tool descriptions.
9
+ * Per-tool inspection misses this because each fragment sits under any
10
+ * single-tool detection threshold.
11
+ *
12
+ * Relationship to prior art in this repo
13
+ * ---------------------------------------
14
+ * A CLI-only v1 of this idea already shipped directly to `main`
15
+ * (dream-cycle #2783, commits 381b7ebcc/581cd2bf3) as
16
+ * `v3/@claude-flow/cli/src/security/mcp-composition-inspector.ts` — an
17
+ * on-demand `ruflo security composition-scan` command using exact
18
+ * common-substring matching plus an injection-phrase catalog and
19
+ * typosquat check. That module's own header explicitly scopes itself as
20
+ * "a bounded engineering fix rather than an ADR-scope subsystem" and lists
21
+ * "Future v2: SimHash + LSH for scale" as deliberately deferred. THIS
22
+ * module is that v2: a reusable `@claude-flow/security` library primitive
23
+ * (not a CLI-only tool) built around a real SimHash fingerprint, so it can
24
+ * be called from a pre-task/pre-tool-use hook before a multi-tool chain
25
+ * executes, per this ADR's implementation target. It does not replace or
26
+ * import the CLI v1 — the two are independent, complementary detectors
27
+ * (exact-substring vs. hashed-shingle-overlap) that a caller may run
28
+ * together.
29
+ *
30
+ * Detection method (deterministic, no LLM call)
31
+ * -----------------------------------------------
32
+ * 1. Each tool description is normalized and split into overlapping
33
+ * word-shingles (default: 5-word windows). Shingling — rather than
34
+ * whole-description comparison — is what lets us find a SMALL embedded
35
+ * fragment inside an otherwise unrelated, benign description.
36
+ * 2. Each tool gets a 64-bit SimHash fingerprint: every shingle is hashed
37
+ * (FNV-1a, 64-bit) and the fingerprint bits are set by majority vote
38
+ * across all of a tool's shingle hashes. Two tools whose descriptions
39
+ * share enough content have a SMALL Hamming distance between
40
+ * fingerprints — this is the O(1)-per-pair coarse filter that avoids an
41
+ * LLM call and stays cheap even at hundreds of registered tools (fast
42
+ * 64-bit XOR + popcount per pair).
43
+ * 3. An inverted shingle-hash index (hash -> set of tool indices) is built
44
+ * once, in O(total shingles). For each pair flagged by the SimHash
45
+ * filter (or found in the index) the SAME index is used to compute the
46
+ * actual overlapping shingle text — this is what makes the finding
47
+ * reportable (the SimHash score alone can't tell an operator *what*
48
+ * matched).
49
+ * 4. A fragment's "population" (how many distinct tools carry it) caps
50
+ * false positives: shared shingles that appear in more than
51
+ * `maxFragmentPopulation` (default 3) tools are template language
52
+ * (e.g. every ruflo `memory_*` tool's boilerplate), not an attack —
53
+ * Shamir-split attacks concentrate a fragment in a small conspiracy of
54
+ * 2-3 tools. Same population-cap idea as the CLI v1, reimplemented here
55
+ * against the hash index instead of raw substrings.
56
+ *
57
+ * This is a heuristic detector, not a security boundary: it reports
58
+ * SUSPECTS. Default action is warn + log; blocking is opt-in via
59
+ * `CLAUDE_FLOW_MCP_COMPOSITION_BLOCK=1` (see {@link evaluateToolComposition}).
60
+ *
61
+ * @module @claude-flow/security/mcp-composition-inspector
62
+ */
63
+ // ============================================================================
64
+ // SimHash primitives (plain TS, no dependency)
65
+ // ============================================================================
66
+ const FNV_OFFSET_BASIS_64 = 0xcbf29ce484222325n;
67
+ const FNV_PRIME_64 = 0x100000001b3n;
68
+ const MASK_64 = (1n << 64n) - 1n;
69
+ /** FNV-1a, 64-bit. Deterministic, dependency-free, good avalanche for short strings. */
70
+ export function fnv1a64(input) {
71
+ let hash = FNV_OFFSET_BASIS_64;
72
+ for (let i = 0; i < input.length; i++) {
73
+ hash ^= BigInt(input.charCodeAt(i));
74
+ hash = (hash * FNV_PRIME_64) & MASK_64;
75
+ }
76
+ return hash;
77
+ }
78
+ /**
79
+ * Classic SimHash: bit-vote a 64-bit fingerprint across a list of token
80
+ * hashes. Near-duplicate token sets (even with some fragments differing)
81
+ * produce fingerprints with a small Hamming distance.
82
+ */
83
+ export function simhash64(shingles) {
84
+ if (shingles.length === 0)
85
+ return 0n;
86
+ const bitVotes = new Array(64).fill(0);
87
+ for (const shingle of shingles) {
88
+ const h = fnv1a64(shingle);
89
+ for (let bit = 0; bit < 64; bit++) {
90
+ const set = (h >> BigInt(bit)) & 1n;
91
+ bitVotes[bit] += set === 1n ? 1 : -1;
92
+ }
93
+ }
94
+ let fingerprint = 0n;
95
+ for (let bit = 0; bit < 64; bit++) {
96
+ if (bitVotes[bit] > 0)
97
+ fingerprint |= 1n << BigInt(bit);
98
+ }
99
+ return fingerprint;
100
+ }
101
+ /** Hamming distance between two 64-bit fingerprints (0..64). */
102
+ export function hammingDistance64(a, b) {
103
+ let x = (a ^ b) & MASK_64;
104
+ let count = 0;
105
+ while (x > 0n) {
106
+ count += Number(x & 1n);
107
+ x >>= 1n;
108
+ }
109
+ return count;
110
+ }
111
+ // ============================================================================
112
+ // Shingling
113
+ // ============================================================================
114
+ function normalize(text) {
115
+ return text.toLowerCase().replace(/\s+/g, ' ').trim();
116
+ }
117
+ /** Overlapping word-shingles of `k` words each. Falls back to the whole (short) text as a single shingle. */
118
+ function wordShingles(text, k) {
119
+ const words = normalize(text).split(' ').filter(Boolean);
120
+ if (words.length === 0)
121
+ return [];
122
+ if (words.length < k)
123
+ return [words.join(' ')];
124
+ const shingles = [];
125
+ for (let i = 0; i + k <= words.length; i++) {
126
+ shingles.push(words.slice(i, i + k).join(' '));
127
+ }
128
+ return shingles;
129
+ }
130
+ export function inspectToolComposition(tools, options = {}) {
131
+ const shingleSize = options.shingleSize ?? 5;
132
+ const simhashThreshold = options.simhashThreshold ?? 0.6;
133
+ const fragmentOverlapThreshold = options.fragmentOverlapThreshold ?? 0.25;
134
+ const maxFragmentPopulation = options.maxFragmentPopulation ?? 3;
135
+ const minShingleChars = options.minShingleChars ?? 12;
136
+ const maxSampleFragments = options.maxSampleFragments ?? 5;
137
+ const indexed = tools.map((t, idx) => {
138
+ const shingles = wordShingles(t.description, shingleSize).filter((s) => s.length >= minShingleChars);
139
+ const hashKeys = new Set(shingles.map((s) => fnv1a64(s).toString(36)));
140
+ return {
141
+ idx,
142
+ name: t.name,
143
+ shingles,
144
+ hashKeys,
145
+ fingerprint: simhash64(shingles),
146
+ };
147
+ });
148
+ // Inverted index: shingle-hash -> {tools that carry it, sample text}.
149
+ const shingleToTools = new Map();
150
+ const shingleSampleText = new Map();
151
+ for (const t of indexed) {
152
+ for (const shingle of t.shingles) {
153
+ const key = fnv1a64(shingle).toString(36);
154
+ const set = shingleToTools.get(key) ?? new Set();
155
+ set.add(t.idx);
156
+ shingleToTools.set(key, set);
157
+ if (!shingleSampleText.has(key))
158
+ shingleSampleText.set(key, shingle);
159
+ }
160
+ }
161
+ const findings = [];
162
+ const stats = {
163
+ toolsScanned: tools.length,
164
+ pairsCompared: 0,
165
+ shinglesIndexed: shingleToTools.size,
166
+ candidatePairsFromSimhash: 0,
167
+ };
168
+ for (let i = 0; i < indexed.length; i++) {
169
+ for (let j = i + 1; j < indexed.length; j++) {
170
+ stats.pairsCompared++;
171
+ const a = indexed[i];
172
+ const b = indexed[j];
173
+ const hamming = hammingDistance64(a.fingerprint, b.fingerprint);
174
+ const simhashSimilarity = a.shingles.length > 0 && b.shingles.length > 0 ? 1 - hamming / 64 : 0;
175
+ if (simhashSimilarity >= simhashThreshold)
176
+ stats.candidatePairsFromSimhash++;
177
+ // Low-population shared shingles between this pair, via the inverted index.
178
+ let sharedCount = 0;
179
+ let maxPopulationSeen = 0;
180
+ const sample = [];
181
+ for (const key of a.hashKeys) {
182
+ if (!b.hashKeys.has(key))
183
+ continue;
184
+ const population = shingleToTools.get(key)?.size ?? 0;
185
+ if (population > maxFragmentPopulation)
186
+ continue; // template language, not an attack signature
187
+ sharedCount++;
188
+ maxPopulationSeen = Math.max(maxPopulationSeen, population);
189
+ if (sample.length < maxSampleFragments) {
190
+ const text = shingleSampleText.get(key);
191
+ if (text)
192
+ sample.push(text);
193
+ }
194
+ }
195
+ const minShingleCount = Math.max(1, Math.min(a.shingles.length, b.shingles.length));
196
+ const fragmentOverlapScore = sharedCount / minShingleCount;
197
+ const flagBySimhash = simhashSimilarity >= simhashThreshold && sharedCount > 0;
198
+ const flagByFragment = fragmentOverlapScore >= fragmentOverlapThreshold && sharedCount > 0;
199
+ if (!flagBySimhash && !flagByFragment)
200
+ continue;
201
+ findings.push({
202
+ toolA: a.name,
203
+ toolB: b.name,
204
+ simhashSimilarity: Number(simhashSimilarity.toFixed(3)),
205
+ fragmentOverlapScore: Number(fragmentOverlapScore.toFixed(3)),
206
+ sharedFragments: sample,
207
+ fragmentPopulation: maxPopulationSeen,
208
+ reason: flagBySimhash
209
+ ? `SimHash similarity ${simhashSimilarity.toFixed(2)} (Hamming distance ${hamming}/64) with ${sharedCount} low-population shared shingle(s) (population <= ${maxFragmentPopulation}) — possible cross-tool instruction fragment`
210
+ : `Fragment overlap ${fragmentOverlapScore.toFixed(2)} (${sharedCount}/${minShingleCount} shingles shared, population <= ${maxFragmentPopulation}) — possible Shamir-split instruction fragment`,
211
+ });
212
+ }
213
+ }
214
+ return { findings, stats };
215
+ }
216
+ // ============================================================================
217
+ // Guard: env-var-gated warn/block decision
218
+ // ============================================================================
219
+ const COMPOSITION_BLOCK_ENV = 'CLAUDE_FLOW_MCP_COMPOSITION_BLOCK';
220
+ /** Reads `CLAUDE_FLOW_MCP_COMPOSITION_BLOCK` fresh on every call. '1' or 'true' (case-insensitive) enables blocking; unset/anything else keeps the default warn+log posture. */
221
+ export function isCompositionBlockEnabled() {
222
+ const raw = process.env[COMPOSITION_BLOCK_ENV];
223
+ return raw === '1' || raw?.toLowerCase() === 'true';
224
+ }
225
+ /**
226
+ * Runs {@link inspectToolComposition} and applies the ADR-320 default
227
+ * posture: warn + log (via `console.warn`) unless
228
+ * `CLAUDE_FLOW_MCP_COMPOSITION_BLOCK=1`, in which case the chain is marked
229
+ * `blocked: true` — the caller (the pre-task hook / MCP dispatcher) decides
230
+ * what "blocked" means operationally; this function does not throw or abort
231
+ * anything itself.
232
+ */
233
+ export function evaluateToolComposition(tools, options = {}) {
234
+ const result = inspectToolComposition(tools, options);
235
+ if (result.findings.length === 0) {
236
+ return { result, action: 'none', blocked: false };
237
+ }
238
+ const summary = `MCP Composition Inspector: ${result.findings.length} suspicious cross-tool fragment(s) ` +
239
+ `across ${result.stats.toolsScanned} tools (${result.stats.pairsCompared} pairs compared)`;
240
+ if (isCompositionBlockEnabled()) {
241
+ const message = `${summary} — blocking chain (${COMPOSITION_BLOCK_ENV}=1)`;
242
+ console.warn(`[mcp-composition-inspector] ${message}`);
243
+ for (const f of result.findings) {
244
+ console.warn(` - ${f.toolA} <-> ${f.toolB}: ${f.reason}`);
245
+ }
246
+ return { result, action: 'block', blocked: true, message };
247
+ }
248
+ console.warn(`[mcp-composition-inspector] ${summary}`);
249
+ for (const f of result.findings) {
250
+ console.warn(` - ${f.toolA} <-> ${f.toolB}: ${f.reason}`);
251
+ }
252
+ return { result, action: 'warn', blocked: false, message: summary };
253
+ }
254
+ //# sourceMappingURL=mcp-composition-inspector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-composition-inspector.js","sourceRoot":"","sources":["../src/mcp-composition-inspector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AA4DH,+EAA+E;AAC/E,+CAA+C;AAC/C,+EAA+E;AAE/E,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAChD,MAAM,YAAY,GAAG,cAAc,CAAC;AACpC,MAAM,OAAO,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC;AAEjC,wFAAwF;AACxF,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,IAAI,IAAI,GAAG,mBAAmB,CAAC;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,GAAG,CAAC,IAAI,GAAG,YAAY,CAAC,GAAG,OAAO,CAAC;IACzC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,QAA2B;IACnD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAI,KAAK,CAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,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AAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAC7D,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC7D,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,+BAA+B,OAAO,EAAE,CAAC,CAAC;IACvD,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QAChC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACtE,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Opens the system default browser for the `ruflo auth login` flow. A
3
+ * TypeScript port of meta-proxy's `src/oauth/browser.rs`.
4
+ *
5
+ * Deliberately does NOT go through `SafeExecutor.execute()`: `SafeExecutor`'s
6
+ * blocked-argument patterns (`safe-executor.ts`'s `DEFAULT_BLOCKED_PATTERNS`)
7
+ * include a bare `&`, which is meant to catch shell-metacharacter injection in
8
+ * command-line-style arguments — but it also appears in every real OAuth
9
+ * authorize URL's query string (`?a=1&b=2&...`), so passing one through would
10
+ * false-positive-reject on every real invocation. That blocklist is the wrong
11
+ * tool for a URL argument: with `shell: false` (used here, same as
12
+ * `SafeExecutor`), a single argv element containing `&` is inert — there's no
13
+ * shell to interpret it. The actual safety property that matters is "the URL
14
+ * was constructed by us from validated components, never from raw external
15
+ * input" (this module's `authorizeUrl()` in `client.ts` is the only caller),
16
+ * which `assertSafeUrl` below checks directly instead.
17
+ *
18
+ * @module v3/security/oauth/browser
19
+ */
20
+ /**
21
+ * Attempts to open `url` in the system default browser. Resolves whether or
22
+ * not a browser window actually appeared — this cannot be confirmed in
23
+ * general, which is why the caller always also prints the URL as a fallback.
24
+ */
25
+ export declare function openBrowser(url: string): Promise<void>;
26
+ /** Pure command selection, exported for platform regression tests. */
27
+ export declare function browserCommand(url: string, platform?: NodeJS.Platform): {
28
+ cmd: string;
29
+ args: string[];
30
+ };
31
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/oauth/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAYH;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQtD;AAED,sEAAsE;AACtE,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAWzH"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Opens the system default browser for the `ruflo auth login` flow. A
3
+ * TypeScript port of meta-proxy's `src/oauth/browser.rs`.
4
+ *
5
+ * Deliberately does NOT go through `SafeExecutor.execute()`: `SafeExecutor`'s
6
+ * blocked-argument patterns (`safe-executor.ts`'s `DEFAULT_BLOCKED_PATTERNS`)
7
+ * include a bare `&`, which is meant to catch shell-metacharacter injection in
8
+ * command-line-style arguments — but it also appears in every real OAuth
9
+ * authorize URL's query string (`?a=1&b=2&...`), so passing one through would
10
+ * false-positive-reject on every real invocation. That blocklist is the wrong
11
+ * tool for a URL argument: with `shell: false` (used here, same as
12
+ * `SafeExecutor`), a single argv element containing `&` is inert — there's no
13
+ * shell to interpret it. The actual safety property that matters is "the URL
14
+ * was constructed by us from validated components, never from raw external
15
+ * input" (this module's `authorizeUrl()` in `client.ts` is the only caller),
16
+ * which `assertSafeUrl` below checks directly instead.
17
+ *
18
+ * @module v3/security/oauth/browser
19
+ */
20
+ import { execFile } from 'node:child_process';
21
+ /** Throws if `url` isn't a well-formed https/http URL — the one check that matters here. */
22
+ function assertSafeUrl(url) {
23
+ const parsed = new URL(url); // throws on malformed input
24
+ if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
25
+ throw new Error(`refusing to open non-http(s) URL scheme: ${parsed.protocol}`);
26
+ }
27
+ }
28
+ /**
29
+ * Attempts to open `url` in the system default browser. Resolves whether or
30
+ * not a browser window actually appeared — this cannot be confirmed in
31
+ * general, which is why the caller always also prints the URL as a fallback.
32
+ */
33
+ export function openBrowser(url) {
34
+ assertSafeUrl(url);
35
+ const { cmd, args } = browserCommand(url);
36
+ return new Promise((resolve) => {
37
+ execFile(cmd, args, { shell: false, windowsHide: true }, () => resolve());
38
+ });
39
+ }
40
+ /** Pure command selection, exported for platform regression tests. */
41
+ export function browserCommand(url, platform = process.platform) {
42
+ assertSafeUrl(url);
43
+ if (platform === 'darwin') {
44
+ return { cmd: 'open', args: [url] };
45
+ }
46
+ else if (platform === 'win32') {
47
+ // cmd.exe treats OAuth query-string `&` separators as command operators,
48
+ // truncating the URL before client_id. Use the URL handler without a shell.
49
+ return { cmd: 'rundll32.exe', args: ['url.dll,FileProtocolHandler', url] };
50
+ }
51
+ else {
52
+ return { cmd: 'xdg-open', args: [url] };
53
+ }
54
+ }
55
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/oauth/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,4FAA4F;AAC5F,SAAS,aAAa,CAAC,GAAW;IAChC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,4BAA4B;IACzD,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,4CAA4C,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IACjF,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,aAAa,CAAC,GAAG,CAAC,CAAC;IAEnB,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IAE1C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;AACL,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,WAA4B,OAAO,CAAC,QAAQ;IACtF,aAAa,CAAC,GAAG,CAAC,CAAC;IACnB,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IACtC,CAAC;SAAM,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QAChC,yEAAyE;QACzE,4EAA4E;QAC5E,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,6BAA6B,EAAE,GAAG,CAAC,EAAE,CAAC;IAC7E,CAAC;SAAM,CAAC;QACN,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1C,CAAC;AACH,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Ephemeral-port localhost callback server for the browser-based OAuth flow
3
+ * (ADR-306). A minimal single-request HTTP server — deliberately not a full
4
+ * framework for one GET route that lives for one request and then shuts
5
+ * down. A TypeScript port of meta-proxy's `src/oauth/callback_server.rs`.
6
+ *
7
+ * @module v3/security/oauth/callback-server
8
+ */
9
+ export interface CallbackResult {
10
+ code: string | null;
11
+ state: string | null;
12
+ error: string | null;
13
+ }
14
+ export declare class CallbackTimeoutError extends Error {
15
+ constructor();
16
+ }
17
+ export declare class CallbackServer {
18
+ private readonly server;
19
+ readonly redirectUri: string;
20
+ readonly port: number;
21
+ private constructor();
22
+ /**
23
+ * Binds `127.0.0.1:0` (OS-assigned ephemeral port) and returns the server
24
+ * plus the exact `redirect_uri` to send in the authorize request — must be
25
+ * the `http://127.0.0.1:<port>/oauth/callback` shape identity's
26
+ * `validate_redirect_uri` accepts.
27
+ */
28
+ static bind(): Promise<CallbackServer>;
29
+ /**
30
+ * Waits for exactly one `GET /oauth/callback?...` request, replies with the
31
+ * browser success page, closes the server, and returns the parsed query
32
+ * parameters. Times out after `waitForMs` so a login attempt the user
33
+ * abandons in the browser doesn't hang the CLI forever.
34
+ */
35
+ awaitCallback(waitForMs?: number): Promise<CallbackResult>;
36
+ }
37
+ //# sourceMappingURL=callback-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callback-server.d.ts","sourceRoot":"","sources":["../../src/oauth/callback-server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAeD,qBAAa,oBAAqB,SAAQ,KAAK;;CAK9C;AAED,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,MAAM;aACP,WAAW,EAAE,MAAM;aACnB,IAAI,EAAE,MAAM;IAH9B,OAAO;IAMP;;;;;OAKG;WACU,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC;IAa5C;;;;;OAKG;IACG,aAAa,CAAC,SAAS,SAAqB,GAAG,OAAO,CAAC,cAAc,CAAC;CA0B7E"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Ephemeral-port localhost callback server for the browser-based OAuth flow
3
+ * (ADR-306). A minimal single-request HTTP server — deliberately not a full
4
+ * framework for one GET route that lives for one request and then shuts
5
+ * down. A TypeScript port of meta-proxy's `src/oauth/callback_server.rs`.
6
+ *
7
+ * @module v3/security/oauth/callback-server
8
+ */
9
+ import { createServer } from 'node:http';
10
+ const SUCCESS_PAGE = `<html>
11
+ <body style="background:#0a0a0a; color:#f5f5f5; font-family:sans-serif;
12
+ display:flex; align-items:center; justify-content:center;
13
+ height:100vh; margin:0;">
14
+ <div style="text-align:center;">
15
+ <h1>&#10003; ruflo login successful</h1>
16
+ <p>You can close this tab and return to your terminal.</p>
17
+ </div>
18
+ </body>
19
+ </html>`;
20
+ const DEFAULT_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes, matches meta-proxy's CALLBACK_TIMEOUT
21
+ export class CallbackTimeoutError extends Error {
22
+ constructor() {
23
+ super('timed out waiting for OAuth callback');
24
+ this.name = 'CallbackTimeoutError';
25
+ }
26
+ }
27
+ export class CallbackServer {
28
+ server;
29
+ redirectUri;
30
+ port;
31
+ constructor(server, redirectUri, port) {
32
+ this.server = server;
33
+ this.redirectUri = redirectUri;
34
+ this.port = port;
35
+ }
36
+ /**
37
+ * Binds `127.0.0.1:0` (OS-assigned ephemeral port) and returns the server
38
+ * plus the exact `redirect_uri` to send in the authorize request — must be
39
+ * the `http://127.0.0.1:<port>/oauth/callback` shape identity's
40
+ * `validate_redirect_uri` accepts.
41
+ */
42
+ static async bind() {
43
+ return new Promise((resolve, reject) => {
44
+ const server = createServer();
45
+ server.once('error', reject);
46
+ server.listen(0, '127.0.0.1', () => {
47
+ server.removeListener('error', reject);
48
+ const addr = server.address();
49
+ const redirectUri = `http://127.0.0.1:${addr.port}/oauth/callback`;
50
+ resolve(new CallbackServer(server, redirectUri, addr.port));
51
+ });
52
+ });
53
+ }
54
+ /**
55
+ * Waits for exactly one `GET /oauth/callback?...` request, replies with the
56
+ * browser success page, closes the server, and returns the parsed query
57
+ * parameters. Times out after `waitForMs` so a login attempt the user
58
+ * abandons in the browser doesn't hang the CLI forever.
59
+ */
60
+ async awaitCallback(waitForMs = DEFAULT_TIMEOUT_MS) {
61
+ return new Promise((resolve, reject) => {
62
+ const timer = setTimeout(() => {
63
+ this.server.close();
64
+ reject(new CallbackTimeoutError());
65
+ }, waitForMs);
66
+ this.server.once('request', (req, res) => {
67
+ clearTimeout(timer);
68
+ const url = new URL(req.url ?? '/oauth/callback', 'http://127.0.0.1');
69
+ const result = {
70
+ code: url.searchParams.get('code'),
71
+ state: url.searchParams.get('state'),
72
+ error: url.searchParams.get('error'),
73
+ };
74
+ res.writeHead(200, {
75
+ 'content-type': 'text/html; charset=utf-8',
76
+ connection: 'close',
77
+ });
78
+ res.end(SUCCESS_PAGE, () => {
79
+ this.server.close();
80
+ resolve(result);
81
+ });
82
+ });
83
+ });
84
+ }
85
+ }
86
+ //# sourceMappingURL=callback-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callback-server.js","sourceRoot":"","sources":["../../src/oauth/callback-server.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAC;AAStD,MAAM,YAAY,GAAG;;;;;;;;;QASb,CAAC;AAET,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,mDAAmD;AAE7F,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C;QACE,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED,MAAM,OAAO,cAAc;IAEN;IACD;IACA;IAHlB,YACmB,MAAc,EACf,WAAmB,EACnB,IAAY;QAFX,WAAM,GAAN,MAAM,CAAQ;QACf,gBAAW,GAAX,WAAW,CAAQ;QACnB,SAAI,GAAJ,IAAI,CAAQ;IAC3B,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AAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC;oBAClC,KAAK,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC;oBACpC,KAAK,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC;iBACrC,CAAC;gBACF,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE;oBACjB,cAAc,EAAE,0BAA0B;oBAC1C,UAAU,EAAE,OAAO;iBACpB,CAAC,CAAC;gBACH,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,EAAE;oBACzB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;oBACpB,OAAO,CAAC,MAAM,CAAC,CAAC;gBAClB,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * HTTP client for `auth.cognitum.one`'s OAuth surface (ADR-306): authorize
3
+ * URL construction, `POST /oauth/token` (`authorization_code` and
4
+ * `refresh_token` grants), and `POST /v1/oauth/code-exchange` (OOB fallback).
5
+ *
6
+ * A TypeScript port of meta-proxy's `src/oauth/client.rs`
7
+ * (cognitum-one/meta-proxy) — same base URL, same endpoints, same
8
+ * form/query parameter names, confirmed live 2026-07-16 (a real
9
+ * `GET /oauth/authorize?...&client_id=meta-proxy&redirect_uri=<ruflo-controlled
10
+ * loopback>` returns a working consent page, not a redirect_uri-mismatch
11
+ * error — so this client reuses meta-proxy's registered `client_id` rather
12
+ * than requiring a new one).
13
+ *
14
+ * Deliberately NOT `api.cognitum.one/v1/auth/*` — that's what ruflo's own
15
+ * checked-in OpenAPI spec (v3/docs/api/cognitum-v1.openapi.yaml, ADR-308)
16
+ * describes, but it does not match what the real identity server serves.
17
+ * This client targets the proven, live surface instead.
18
+ *
19
+ * @module v3/security/oauth/client
20
+ */
21
+ export declare const CLIENT_ID = "meta-proxy";
22
+ export declare const SCOPE = "inference";
23
+ /** RFC 8252 out-of-band sentinel — the OOB/manual-paste flow's `redirect_uri`. */
24
+ export declare const OOB_REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob";
25
+ export interface TokenResponse {
26
+ access_token: string;
27
+ token_type: string;
28
+ account_email?: string;
29
+ refresh_token?: string;
30
+ expires_in?: number;
31
+ }
32
+ export declare class OAuthError extends Error {
33
+ readonly code: 'network' | 'protocol' | 'unexpected_shape';
34
+ readonly oauthError?: string | undefined;
35
+ readonly oauthDescription?: string | undefined;
36
+ constructor(message: string, code: 'network' | 'protocol' | 'unexpected_shape', oauthError?: string | undefined, oauthDescription?: string | undefined);
37
+ }
38
+ /** Builds the `/oauth/authorize` URL for the standard loopback-redirect flow. */
39
+ export declare function authorizeUrl(redirectUri: string, state: string, codeChallenge: string): string;
40
+ /** `POST /oauth/token` with `grant_type=authorization_code`. */
41
+ export declare function exchangeCode(code: string, codeVerifier: string, redirectUri: string, base?: string): Promise<TokenResponse>;
42
+ /**
43
+ * `POST /oauth/token` with `grant_type=refresh_token`. identity rotates
44
+ * refresh tokens with reuse detection: presenting a refresh token returns a
45
+ * NEW refresh token and revokes the old one, and re-presenting a spent one
46
+ * revokes the whole session family. Callers MUST persist the returned
47
+ * `refresh_token` atomically before using the new access token, and must
48
+ * never retry a failed refresh with the same token.
49
+ */
50
+ export declare function refreshToken(refreshTokenValue: string, base?: string): Promise<TokenResponse>;
51
+ /**
52
+ * `POST /v1/oauth/code-exchange` — the OOB manual-entry fallback for
53
+ * headless/SSH/container environments where no browser round-trip to
54
+ * `127.0.0.1` is reachable.
55
+ */
56
+ export declare function exchangeManualCode(code: string, codeVerifier: string, base?: string): Promise<TokenResponse>;
57
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/oauth/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,SAAS,eAAe,CAAC;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