claude-flow-novice 2.15.11 → 2.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (741) hide show
  1. package/.claude/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
  2. package/.claude/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +1 -1
  3. package/.claude/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +1 -1
  4. package/.claude/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +1 -1
  5. package/.claude/cfn-extras/skills/google-sheets-progress/SKILL.md +1 -1
  6. package/.claude/commands/CFN_LOOP_FRONTEND.md +1 -1
  7. package/.claude/commands/cfn-loop-cli.md +214 -442
  8. package/.claude/commands/cfn-loop-frontend.md +1 -1
  9. package/.claude/commands/cfn-loop-task.md +2 -2
  10. package/.claude/commands/cfn-loop-trigger.md +114 -0
  11. package/.claude/commands/deprecated/cfn-loop.md +2 -2
  12. package/.claude/hooks/cfn-invoke-post-edit-ts.sh +100 -0
  13. package/.claude/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
  14. package/.claude/hooks/cfn-invoke-post-edit.sh +53 -5
  15. package/.claude/hooks/cfn-invoke-post-edit.sh.backup +87 -0
  16. package/.claude/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
  17. package/.claude/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
  18. package/.claude/hooks/cfn-invoke-pre-edit.sh +22 -0
  19. package/.claude/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
  20. package/.claude/hooks/cfn-post-edit.config.json +9 -2
  21. package/.claude/root-claude-distribute/CFN-CLAUDE.md +1 -1
  22. package/.claude/skills/cfn-agent-spawning/SKILL.md +48 -1
  23. package/.claude/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
  24. package/.claude/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
  25. package/.claude/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
  26. package/.claude/skills/{cfn-redis-coordination/check-dependencies.sh → cfn-agent-spawning/check-dependencies.sh.backup} +3 -5
  27. package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
  28. package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
  29. package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
  30. package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
  31. package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
  32. package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
  33. package/.claude/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
  34. package/.claude/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
  35. package/.claude/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
  36. package/.claude/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
  37. package/.claude/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
  38. package/.claude/skills/cfn-backlog-management/SKILL.md +1 -1
  39. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
  40. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
  41. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
  42. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
  43. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
  44. package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
  45. package/.claude/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
  46. package/.claude/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
  47. package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
  48. package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
  49. package/.claude/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
  50. package/.claude/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
  51. package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
  52. package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
  53. package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
  54. package/.claude/skills/cfn-loop-orchestration/SKILL.md +159 -48
  55. package/.claude/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
  56. package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
  57. package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
  58. package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
  59. package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
  60. package/.claude/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
  61. package/.claude/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
  62. package/.claude/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
  63. package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
  64. package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
  65. package/.claude/skills/cfn-loop-orchestration/{orchestrate-wrapper.sh → archive/legacy-bash/orchestrate-wrapper.sh} +11 -1
  66. package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
  67. package/.claude/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
  68. package/.claude/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
  69. package/.claude/skills/cfn-loop-orchestration/package-lock.json +3 -0
  70. package/.claude/skills/cfn-loop-orchestration/package.json +4 -0
  71. package/.claude/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
  72. package/.claude/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
  73. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
  74. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
  75. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
  76. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
  77. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
  78. package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
  79. package/.claude/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
  80. package/.claude/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
  81. package/.claude/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
  82. package/.claude/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
  83. package/.claude/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
  84. package/.claude/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
  85. package/.claude/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
  86. package/.claude/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
  87. package/.claude/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
  88. package/.claude/skills/cfn-loop-orchestration/src/index.ts +2 -0
  89. package/.claude/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
  90. package/.claude/skills/cfn-loop-orchestration/src/types.ts +56 -0
  91. package/.claude/skills/cfn-loop-orchestration/test-cli.sh +92 -0
  92. package/.claude/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
  93. package/.claude/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
  94. package/.claude/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
  95. package/.claude/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
  96. package/.claude/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
  97. package/.claude/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
  98. package/.claude/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
  99. package/.claude/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
  100. package/.claude/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
  101. package/.claude/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
  102. package/.claude/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
  103. package/.claude/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
  104. package/.claude/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
  105. package/.claude/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
  106. package/.claude/skills/cfn-loop-validation/INDEX.md +531 -0
  107. package/.claude/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
  108. package/.claude/skills/cfn-loop-validation/SKILL.md +48 -1
  109. package/.claude/skills/cfn-loop-validation/SKILL.md.backup +353 -0
  110. package/.claude/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
  111. package/.claude/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
  112. package/.claude/skills/cfn-loop-validation/check-dependencies.sh +22 -0
  113. package/{claude-assets/skills/cfn-redis-coordination/check-dependencies.sh → .claude/skills/cfn-loop-validation/check-dependencies.sh.backup} +4 -5
  114. package/.claude/skills/cfn-loop-validation/detect-vapor.sh +59 -0
  115. package/.claude/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
  116. package/.claude/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
  117. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
  118. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
  119. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
  120. package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
  121. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
  122. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
  123. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
  124. package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
  125. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
  126. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
  127. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
  128. package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
  129. package/.claude/skills/cfn-loop-validation/dist/types.d.ts +156 -0
  130. package/.claude/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
  131. package/.claude/skills/cfn-loop-validation/dist/types.js +66 -0
  132. package/.claude/skills/cfn-loop-validation/dist/types.js.map +1 -0
  133. package/.claude/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
  134. package/.claude/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
  135. package/.claude/skills/cfn-loop-validation/dist/validator.js +411 -0
  136. package/.claude/skills/cfn-loop-validation/dist/validator.js.map +1 -0
  137. package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
  138. package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
  139. package/.claude/skills/cfn-loop-validation/package.json +93 -0
  140. package/.claude/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
  141. package/.claude/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
  142. package/.claude/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
  143. package/.claude/skills/cfn-loop-validation/src/types.ts +215 -0
  144. package/.claude/skills/cfn-loop-validation/src/validator.ts +503 -0
  145. package/.claude/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
  146. package/.claude/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
  147. package/.claude/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
  148. package/.claude/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
  149. package/.claude/skills/cfn-loop-validation/validate-gate.sh +63 -0
  150. package/.claude/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
  151. package/.claude/skills/cfn-loop-validation/validate-iteration.sh +22 -0
  152. package/.claude/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
  153. package/.claude/skills/cfn-product-owner-decision/SKILL.md +479 -147
  154. package/.claude/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
  155. package/.claude/skills/cfn-product-owner-decision/{execute-decision.sh → archive/legacy-bash/execute-decision.sh} +24 -2
  156. package/.claude/skills/pre-edit-backup/SKILL.md +324 -0
  157. package/.claude/skills/pre-edit-backup/SKILL.md.backup +277 -0
  158. package/.claude/skills/pre-edit-backup/backup.sh +22 -0
  159. package/.claude/skills/pre-edit-backup/backup.sh.backup +107 -0
  160. package/claude-assets/agents/cfn-dev-team/analysts/root-cause-analyst.md +2 -2
  161. package/claude-assets/agents/cfn-dev-team/architecture/base-template-generator.md +1 -1
  162. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +3 -2
  163. package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +1 -0
  164. package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +2 -1
  165. package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +1 -0
  166. package/claude-assets/agents/cfn-dev-team/dev-ops/devops-engineer.md +11 -1
  167. package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +58 -35
  168. package/claude-assets/agents/cfn-dev-team/dev-ops/github-commit-agent.md +2 -2
  169. package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +47 -37
  170. package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +18 -18
  171. package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +40 -58
  172. package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +19 -21
  173. package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +20 -29
  174. package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +15 -19
  175. package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +15 -10
  176. package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +16 -11
  177. package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +16 -26
  178. package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +18 -22
  179. package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +17 -21
  180. package/claude-assets/agents/cfn-dev-team/documentation/pseudocode.md +1 -1
  181. package/claude-assets/agents/cfn-dev-team/product-owners/accessibility-advocate-persona.md +1 -1
  182. package/claude-assets/agents/cfn-dev-team/product-owners/cto-agent.md +1 -1
  183. package/claude-assets/agents/cfn-dev-team/product-owners/power-user-persona.md +1 -1
  184. package/claude-assets/agents/cfn-dev-team/product-owners/product-owner.md +1 -5
  185. package/claude-assets/agents/cfn-dev-team/reviewers/code-reviewer.md +20 -51
  186. package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +22 -71
  187. package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +21 -64
  188. package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +22 -67
  189. package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +24 -68
  190. package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +8 -36
  191. package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +9 -38
  192. package/claude-assets/agents/cfn-dev-team/testers/contract-tester.md +17 -55
  193. package/claude-assets/agents/cfn-dev-team/testers/e2e/playwright-tester.md +1 -1
  194. package/claude-assets/agents/cfn-dev-team/testers/integration-tester.md +18 -56
  195. package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +9 -37
  196. package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +18 -56
  197. package/claude-assets/agents/cfn-dev-team/testers/mutation-testing-specialist.md +18 -49
  198. package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +8 -37
  199. package/claude-assets/agents/cfn-dev-team/testers/tester.md +7 -27
  200. package/claude-assets/agents/cfn-dev-team/testers/unit/tdd-london-unit-swarm.md +1 -1
  201. package/claude-assets/agents/cfn-dev-team/utility/agent-builder.md +11 -0
  202. package/claude-assets/agents/cfn-dev-team/utility/analyst.md +13 -29
  203. package/claude-assets/agents/cfn-dev-team/utility/claude-code-expert.md +1 -1
  204. package/claude-assets/agents/cfn-dev-team/utility/code-booster.md +13 -13
  205. package/claude-assets/agents/cfn-dev-team/utility/context-curator.md +7 -2
  206. package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +6 -11
  207. package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +121 -715
  208. package/claude-assets/agents/cfn-dev-team/utility/researcher.md +13 -22
  209. package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +147 -573
  210. package/claude-assets/agents/custom/cfn-docker-expert.md +103 -0
  211. package/claude-assets/agents/custom/cfn-loops-cli-expert.md +438 -0
  212. package/claude-assets/agents/custom/cfn-redis-operations.md +529 -529
  213. package/claude-assets/agents/custom/cfn-system-expert.md +1 -1
  214. package/claude-assets/agents/custom/trigger-dev-expert.md +369 -0
  215. package/claude-assets/agents/docker-team/micro-sprint-planner.md +747 -747
  216. package/claude-assets/agents/project-only-agents/npm-package-specialist.md +1 -1
  217. package/claude-assets/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
  218. package/claude-assets/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +1 -1
  219. package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +1 -1
  220. package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +1 -1
  221. package/claude-assets/cfn-extras/skills/google-sheets-progress/SKILL.md +1 -1
  222. package/claude-assets/commands/CFN_LOOP_FRONTEND.md +1 -1
  223. package/claude-assets/commands/cfn-loop-cli.md +214 -442
  224. package/claude-assets/commands/cfn-loop-frontend.md +1 -1
  225. package/claude-assets/commands/cfn-loop-task.md +2 -2
  226. package/claude-assets/commands/cfn-loop-trigger.md +114 -0
  227. package/claude-assets/commands/deprecated/cfn-loop.md +2 -2
  228. package/claude-assets/hooks/GIT-HOOKS-USAGE-EXAMPLES.md +116 -0
  229. package/claude-assets/hooks/README-GIT-HOOKS.md +443 -0
  230. package/claude-assets/hooks/SKILL.md +518 -0
  231. package/claude-assets/hooks/SKILL.md.backup +471 -0
  232. package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh +100 -0
  233. package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
  234. package/claude-assets/hooks/cfn-invoke-post-edit.sh +53 -5
  235. package/claude-assets/hooks/cfn-invoke-post-edit.sh.backup +87 -0
  236. package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
  237. package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
  238. package/claude-assets/hooks/cfn-invoke-pre-edit.sh +22 -0
  239. package/claude-assets/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
  240. package/claude-assets/hooks/cfn-post-edit.config.json +9 -2
  241. package/claude-assets/hooks/install-git-hooks.sh +243 -0
  242. package/claude-assets/hooks/subagent-start.sh +98 -0
  243. package/claude-assets/hooks/subagent-stop.sh +93 -0
  244. package/claude-assets/hooks/validators/credential-scanner.sh +172 -0
  245. package/claude-assets/root-claude-distribute/CFN-CLAUDE.md +1 -1
  246. package/claude-assets/skills/cfn-agent-selection-with-fallback/DELIVERABLES.md +409 -0
  247. package/claude-assets/skills/cfn-agent-selection-with-fallback/IMPLEMENTATION_SUMMARY.md +396 -0
  248. package/claude-assets/skills/cfn-agent-selection-with-fallback/INTEGRATION_GUIDE.md +308 -0
  249. package/claude-assets/skills/cfn-agent-selection-with-fallback/QUICK_REFERENCE.md +239 -0
  250. package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md +107 -1
  251. package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md.backup +302 -0
  252. package/claude-assets/skills/cfn-agent-selection-with-fallback/TYPESCRIPT_MIGRATION.md +295 -0
  253. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.cjs +297 -0
  254. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.js +297 -0
  255. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.cjs +96 -0
  256. package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.js +96 -0
  257. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh +45 -0
  258. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh.backup +23 -0
  259. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh +22 -0
  260. package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh.backup +173 -0
  261. package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.test.ts +357 -0
  262. package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.ts +350 -0
  263. package/claude-assets/skills/cfn-agent-selection-with-fallback/src/cli.ts +74 -0
  264. package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh +22 -0
  265. package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh.backup +71 -0
  266. package/claude-assets/skills/cfn-agent-selection-with-fallback/tsconfig.json +18 -0
  267. package/claude-assets/skills/cfn-agent-spawning/SKILL.md +48 -1
  268. package/claude-assets/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
  269. package/claude-assets/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
  270. package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
  271. package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh.backup +30 -0
  272. package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
  273. package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
  274. package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
  275. package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
  276. package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
  277. package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
  278. package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
  279. package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
  280. package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
  281. package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
  282. package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
  283. package/claude-assets/skills/cfn-backlog-management/SKILL.md +1 -1
  284. package/claude-assets/skills/cfn-coordination/agent-completion.sh.backup +36 -0
  285. package/claude-assets/skills/cfn-coordination/coordination-signal.sh.backup +36 -0
  286. package/claude-assets/skills/cfn-coordination/coordination-wait.sh.backup +36 -0
  287. package/claude-assets/skills/cfn-dependency-ingestion/README.md +101 -0
  288. package/claude-assets/skills/cfn-dependency-ingestion/SKILL.md +397 -0
  289. package/claude-assets/skills/cfn-dependency-ingestion/build.sh +23 -0
  290. package/claude-assets/skills/cfn-dependency-ingestion/dist/ingest-dependencies.js +478 -0
  291. package/claude-assets/skills/cfn-dependency-ingestion/ingest-dependencies.sh +295 -0
  292. package/claude-assets/skills/cfn-dependency-ingestion/ingest.sh +237 -0
  293. package/claude-assets/skills/cfn-dependency-ingestion/manifests/cli-mode-dependencies.txt +73 -0
  294. package/claude-assets/skills/cfn-dependency-ingestion/manifests/shared-dependencies.txt +57 -0
  295. package/claude-assets/skills/cfn-dependency-ingestion/manifests/trigger-dev-dependencies.txt +82 -0
  296. package/claude-assets/skills/cfn-dependency-ingestion/manifests/trigger-mode-dependencies.txt +80 -0
  297. package/claude-assets/skills/cfn-dependency-ingestion/src/ingest-dependencies.ts +563 -0
  298. package/claude-assets/skills/cfn-environment-sanitization/sanitize-environment.sh +14 -4
  299. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
  300. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
  301. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
  302. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
  303. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
  304. package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
  305. package/claude-assets/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
  306. package/claude-assets/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
  307. package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
  308. package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
  309. package/claude-assets/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
  310. package/claude-assets/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
  311. package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
  312. package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
  313. package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
  314. package/claude-assets/skills/cfn-loop-orchestration/SKILL.md +159 -48
  315. package/claude-assets/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
  316. package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
  317. package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
  318. package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
  319. package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
  320. package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
  321. package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
  322. package/claude-assets/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
  323. package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
  324. package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
  325. package/claude-assets/skills/cfn-loop-orchestration/{orchestrate-wrapper.sh → archive/legacy-bash/orchestrate-wrapper.sh} +11 -1
  326. package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
  327. package/claude-assets/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
  328. package/claude-assets/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
  329. package/claude-assets/skills/cfn-loop-orchestration/package-lock.json +3 -0
  330. package/claude-assets/skills/cfn-loop-orchestration/package.json +4 -0
  331. package/claude-assets/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
  332. package/claude-assets/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
  333. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
  334. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
  335. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
  336. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
  337. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
  338. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
  339. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
  340. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
  341. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
  342. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
  343. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
  344. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
  345. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
  346. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
  347. package/claude-assets/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
  348. package/claude-assets/skills/cfn-loop-orchestration/src/index.ts +2 -0
  349. package/claude-assets/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
  350. package/claude-assets/skills/cfn-loop-orchestration/src/types.ts +56 -0
  351. package/claude-assets/skills/cfn-loop-orchestration/test-cli.sh +92 -0
  352. package/claude-assets/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
  353. package/claude-assets/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
  354. package/claude-assets/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
  355. package/claude-assets/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
  356. package/claude-assets/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
  357. package/claude-assets/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
  358. package/claude-assets/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
  359. package/claude-assets/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
  360. package/claude-assets/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
  361. package/claude-assets/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
  362. package/claude-assets/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
  363. package/claude-assets/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
  364. package/claude-assets/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
  365. package/claude-assets/skills/cfn-loop-output-processing/.eslintrc.json +33 -0
  366. package/claude-assets/skills/cfn-loop-output-processing/DELIVERY_SUMMARY.txt +462 -0
  367. package/claude-assets/skills/cfn-loop-output-processing/DEPRECATION_NOTICE.md +183 -0
  368. package/claude-assets/skills/cfn-loop-output-processing/EXAMPLES.md +609 -0
  369. package/claude-assets/skills/cfn-loop-output-processing/IMPLEMENTATION_SUMMARY.md +418 -0
  370. package/claude-assets/skills/cfn-loop-output-processing/INDEX.md +531 -0
  371. package/claude-assets/skills/cfn-loop-output-processing/MIGRATION.md +362 -0
  372. package/claude-assets/skills/cfn-loop-output-processing/README.md +114 -0
  373. package/claude-assets/skills/cfn-loop-output-processing/SKILL.md +633 -0
  374. package/{.claude/skills/cfn-docker-redis-coordination → claude-assets/skills/cfn-loop-output-processing}/jest.config.js +7 -15
  375. package/claude-assets/skills/cfn-loop-output-processing/package.json +50 -0
  376. package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop2.ts +195 -0
  377. package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop3.ts +157 -0
  378. package/claude-assets/skills/cfn-loop-output-processing/src/output-processor.ts +632 -0
  379. package/claude-assets/skills/cfn-loop-output-processing/tests/output-processor.test.ts +617 -0
  380. package/claude-assets/skills/{cfn-docker-redis-coordination → cfn-loop-output-processing}/tsconfig.json +16 -7
  381. package/claude-assets/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
  382. package/claude-assets/skills/cfn-loop-validation/INDEX.md +531 -0
  383. package/claude-assets/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
  384. package/claude-assets/skills/cfn-loop-validation/SKILL.md +48 -1
  385. package/claude-assets/skills/cfn-loop-validation/SKILL.md.backup +353 -0
  386. package/claude-assets/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
  387. package/claude-assets/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
  388. package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh +22 -0
  389. package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh.backup +31 -0
  390. package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh +59 -0
  391. package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
  392. package/claude-assets/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
  393. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
  394. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
  395. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
  396. package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
  397. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
  398. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
  399. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
  400. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
  401. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
  402. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
  403. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
  404. package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
  405. package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts +156 -0
  406. package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
  407. package/claude-assets/skills/cfn-loop-validation/dist/types.js +66 -0
  408. package/claude-assets/skills/cfn-loop-validation/dist/types.js.map +1 -0
  409. package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
  410. package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
  411. package/claude-assets/skills/cfn-loop-validation/dist/validator.js +411 -0
  412. package/claude-assets/skills/cfn-loop-validation/dist/validator.js.map +1 -0
  413. package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
  414. package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
  415. package/claude-assets/skills/cfn-loop-validation/package.json +93 -0
  416. package/claude-assets/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
  417. package/claude-assets/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
  418. package/claude-assets/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
  419. package/claude-assets/skills/cfn-loop-validation/src/types.ts +215 -0
  420. package/claude-assets/skills/cfn-loop-validation/src/validator.ts +503 -0
  421. package/claude-assets/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
  422. package/claude-assets/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
  423. package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
  424. package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
  425. package/claude-assets/skills/cfn-loop-validation/validate-gate.sh +63 -0
  426. package/claude-assets/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
  427. package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh +22 -0
  428. package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
  429. package/claude-assets/skills/cfn-product-owner-decision/SKILL.md +479 -147
  430. package/claude-assets/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
  431. package/claude-assets/skills/cfn-product-owner-decision/{execute-decision.sh → archive/legacy-bash/execute-decision.sh} +24 -2
  432. package/claude-assets/skills/cfn-provider-routing/README.md +129 -0
  433. package/claude-assets/skills/cfn-provider-routing/SKILL.md +215 -0
  434. package/claude-assets/skills/cfn-provider-routing/resolve-provider-model.ts +223 -0
  435. package/claude-assets/skills/docker-build/build.sh +1 -1
  436. package/claude-assets/skills/pre-edit-backup/SKILL.md +324 -0
  437. package/claude-assets/skills/pre-edit-backup/SKILL.md.backup +277 -0
  438. package/claude-assets/skills/pre-edit-backup/backup.sh +22 -0
  439. package/claude-assets/skills/pre-edit-backup/backup.sh.backup +107 -0
  440. package/dist/agent/skill-mcp-selector.js +2 -1
  441. package/dist/agent/skill-mcp-selector.js.map +1 -1
  442. package/dist/api/auth-endpoints.js +415 -0
  443. package/dist/api/auth-endpoints.js.map +1 -0
  444. package/dist/api/task-endpoints.js +562 -0
  445. package/dist/api/task-endpoints.js.map +1 -0
  446. package/dist/backend/server.js +418 -0
  447. package/dist/backend/server.js.map +1 -0
  448. package/dist/cfn-loop/product-owner/decision-parser.js +356 -0
  449. package/dist/cfn-loop/product-owner/decision-parser.js.map +1 -0
  450. package/dist/cfn-loop/product-owner/index.js +1 -0
  451. package/dist/cfn-loop/product-owner/index.js.map +1 -1
  452. package/dist/cli/agent-command.js +1 -1
  453. package/dist/cli/agent-command.js.map +1 -1
  454. package/dist/cli/agent-completion.js +273 -0
  455. package/dist/cli/agent-completion.js.map +1 -0
  456. package/dist/cli/agent-executor.js +470 -26
  457. package/dist/cli/agent-executor.js.map +1 -1
  458. package/dist/cli/agent-prompt-builder.js +83 -48
  459. package/dist/cli/agent-prompt-builder.js.map +1 -1
  460. package/dist/cli/agent-spawn.js +7 -4
  461. package/dist/cli/agent-spawn.js.map +1 -1
  462. package/dist/cli/agent-spawner.js +546 -0
  463. package/dist/cli/agent-spawner.js.map +1 -0
  464. package/dist/cli/agent-token-manager.js +2 -1
  465. package/dist/cli/agent-token-manager.js.map +1 -1
  466. package/dist/cli/anthropic-client.js +127 -14
  467. package/dist/cli/anthropic-client.js.map +1 -1
  468. package/dist/cli/cfn-context.js +2 -1
  469. package/dist/cli/cfn-context.js.map +1 -1
  470. package/dist/cli/cfn-metrics.js +2 -1
  471. package/dist/cli/cfn-metrics.js.map +1 -1
  472. package/dist/cli/cfn-redis.js +2 -1
  473. package/dist/cli/cfn-redis.js.map +1 -1
  474. package/dist/cli/cli-agent-context.js +2 -0
  475. package/dist/cli/cli-agent-context.js.map +1 -1
  476. package/dist/cli/config-manager.js +90 -356
  477. package/dist/cli/config-manager.js.map +1 -1
  478. package/dist/cli/conversation-fork-cleanup.js +2 -1
  479. package/dist/cli/conversation-fork-cleanup.js.map +1 -1
  480. package/dist/cli/conversation-fork.js +2 -1
  481. package/dist/cli/conversation-fork.js.map +1 -1
  482. package/dist/cli/coordination/agent-messaging.js +415 -0
  483. package/dist/cli/coordination/agent-messaging.js.map +1 -0
  484. package/dist/cli/coordination/wait-for-threshold.js +232 -0
  485. package/dist/cli/coordination/wait-for-threshold.js.map +1 -0
  486. package/dist/cli/index.js +11 -0
  487. package/dist/cli/index.js.map +1 -1
  488. package/dist/cli/iteration-history.js +2 -1
  489. package/dist/cli/iteration-history.js.map +1 -1
  490. package/dist/cli/parse-decision-cli.js +268 -0
  491. package/dist/cli/parse-decision-cli.js.map +1 -0
  492. package/dist/cli/post-edit-hook.js +83 -0
  493. package/dist/cli/post-edit-hook.js.map +1 -0
  494. package/dist/cli/pre-edit-hook.js +77 -0
  495. package/dist/cli/pre-edit-hook.js.map +1 -0
  496. package/dist/cli/process-lifecycle.js +5 -1
  497. package/dist/cli/process-lifecycle.js.map +1 -1
  498. package/dist/cli/spawn-agent-cli.js +244 -0
  499. package/dist/cli/spawn-agent-cli.js.map +1 -0
  500. package/dist/coordination/coordination-wrapper.js +383 -0
  501. package/dist/coordination/coordination-wrapper.js.map +1 -0
  502. package/dist/coordination/redis-waiting-mode.js +4 -0
  503. package/dist/coordination/redis-waiting-mode.js.map +1 -1
  504. package/dist/coordination/store-success-criteria.js +68 -0
  505. package/dist/coordination/store-success-criteria.js.map +1 -0
  506. package/dist/coordination/store-task-context.js +65 -0
  507. package/dist/coordination/store-task-context.js.map +1 -0
  508. package/dist/hooks/backup-manager.js +273 -0
  509. package/dist/hooks/backup-manager.js.map +1 -0
  510. package/dist/hooks/post-edit-validator.js +388 -0
  511. package/dist/hooks/post-edit-validator.js.map +1 -0
  512. package/dist/integration/index.js +19 -0
  513. package/dist/integration/index.js.map +1 -0
  514. package/dist/integration/task-mode-adapter.js +297 -0
  515. package/dist/integration/task-mode-adapter.js.map +1 -0
  516. package/dist/integration/trigger-dev-client.js +253 -0
  517. package/dist/integration/trigger-dev-client.js.map +1 -0
  518. package/dist/integration/trigger-dev-webhooks.js +362 -0
  519. package/dist/integration/trigger-dev-webhooks.js.map +1 -0
  520. package/dist/lib/artifact-registry.js +4 -0
  521. package/dist/lib/artifact-registry.js.map +1 -1
  522. package/dist/lib/connection-pool.js +390 -0
  523. package/dist/lib/connection-pool.js.map +1 -0
  524. package/dist/lib/environment-contract.js +258 -0
  525. package/dist/lib/environment-contract.js.map +1 -0
  526. package/dist/lib/path-validator.js +14 -5
  527. package/dist/lib/path-validator.js.map +1 -1
  528. package/dist/lib/query-optimizer.js +388 -0
  529. package/dist/lib/query-optimizer.js.map +1 -0
  530. package/dist/lib/redis-queue-manager.js +5 -1
  531. package/dist/lib/redis-queue-manager.js.map +1 -1
  532. package/dist/lib/result-cache.js +285 -0
  533. package/dist/lib/result-cache.js.map +1 -0
  534. package/dist/mcp/auth-middleware.js +2 -1
  535. package/dist/mcp/auth-middleware.js.map +1 -1
  536. package/dist/mcp/playwright-mcp-server-auth.js +2 -1
  537. package/dist/mcp/playwright-mcp-server-auth.js.map +1 -1
  538. package/dist/middleware/authentication.js +317 -0
  539. package/dist/middleware/authentication.js.map +1 -0
  540. package/dist/services/authentication.js +669 -0
  541. package/dist/services/authentication.js.map +1 -0
  542. package/dist/services/session-management.js +436 -0
  543. package/dist/services/session-management.js.map +1 -0
  544. package/dist/services/skill-deployment.js +8 -6
  545. package/dist/services/skill-deployment.js.map +1 -1
  546. package/dist/services/user-service.js +710 -0
  547. package/dist/services/user-service.js.map +1 -0
  548. package/dist/types/trigger-dev-events.d.js +10 -0
  549. package/dist/types/trigger-dev-events.d.js.map +1 -0
  550. package/docs/README.md +240 -0
  551. package/package.json +15 -4
  552. package/scripts/build-agent-image.sh +1 -1
  553. package/scripts/compare-workflow-performance.sh +556 -0
  554. package/scripts/cost-allocation-tracker.sh +632 -0
  555. package/scripts/docker-rebuild-all-agents.sh +2 -2
  556. package/scripts/migrate-to-optimized-workflows.sh +438 -0
  557. package/scripts/organize-docs.sh +338 -0
  558. package/scripts/reorganize-tests.sh +280 -0
  559. package/scripts/trigger-dev-setup.sh +279 -0
  560. package/tests/README.md +45 -0
  561. package/.claude/commands/cost-savings-status.md +0 -34
  562. package/.claude/commands/metrics-summary.md +0 -58
  563. package/.claude/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
  564. package/.claude/skills/cfn-docker-redis-coordination/README.md +0 -294
  565. package/.claude/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
  566. package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
  567. package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
  568. package/.claude/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
  569. package/.claude/skills/cfn-docker-redis-coordination/package.json +0 -40
  570. package/.claude/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
  571. package/.claude/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
  572. package/.claude/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
  573. package/.claude/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
  574. package/.claude/skills/cfn-docker-redis-coordination/tsconfig.json +0 -30
  575. package/.claude/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
  576. package/.claude/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
  577. package/.claude/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
  578. package/.claude/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
  579. package/.claude/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
  580. package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
  581. package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
  582. package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
  583. package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
  584. package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
  585. package/.claude/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
  586. package/.claude/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
  587. package/.claude/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
  588. package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
  589. package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
  590. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
  591. package/.claude/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
  592. package/.claude/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
  593. package/.claude/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
  594. package/.claude/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
  595. package/.claude/skills/cfn-redis-coordination/config.json +0 -61
  596. package/.claude/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
  597. package/.claude/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
  598. package/.claude/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
  599. package/.claude/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
  600. package/.claude/skills/cfn-redis-coordination/jest.config.js +0 -23
  601. package/.claude/skills/cfn-redis-coordination/package-lock.json +0 -5272
  602. package/.claude/skills/cfn-redis-coordination/package.json +0 -45
  603. package/.claude/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
  604. package/.claude/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
  605. package/.claude/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
  606. package/.claude/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
  607. package/.claude/skills/cfn-redis-coordination/src/index.ts +0 -82
  608. package/.claude/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
  609. package/.claude/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
  610. package/.claude/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
  611. package/.claude/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
  612. package/.claude/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
  613. package/.claude/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
  614. package/.claude/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
  615. package/.claude/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
  616. package/.claude/skills/cfn-redis-coordination/src/types.ts +0 -235
  617. package/.claude/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
  618. package/.claude/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
  619. package/.claude/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
  620. package/.claude/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
  621. package/.claude/skills/cfn-redis-coordination/test-redis-check.js +0 -84
  622. package/.claude/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
  623. package/.claude/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
  624. package/.claude/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
  625. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +0 -980
  626. package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +0 -759
  627. package/claude-assets/agents/custom/test-mcp-access.md +0 -24
  628. package/claude-assets/agents/typescript-specialist.md +0 -280
  629. package/claude-assets/commands/cost-savings-status.md +0 -34
  630. package/claude-assets/commands/metrics-summary.md +0 -58
  631. package/claude-assets/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
  632. package/claude-assets/skills/cfn-docker-redis-coordination/README.md +0 -294
  633. package/claude-assets/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
  634. package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
  635. package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
  636. package/claude-assets/skills/cfn-docker-redis-coordination/jest.config.js +0 -37
  637. package/claude-assets/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
  638. package/claude-assets/skills/cfn-docker-redis-coordination/package.json +0 -40
  639. package/claude-assets/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
  640. package/claude-assets/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
  641. package/claude-assets/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
  642. package/claude-assets/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
  643. package/claude-assets/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
  644. package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
  645. package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
  646. package/claude-assets/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
  647. package/claude-assets/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
  648. package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
  649. package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
  650. package/claude-assets/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
  651. package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
  652. package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
  653. package/claude-assets/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
  654. package/claude-assets/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
  655. package/claude-assets/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
  656. package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
  657. package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
  658. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
  659. package/claude-assets/skills/cfn-redis-cleanup/cleanup-redis.sh +0 -130
  660. package/claude-assets/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
  661. package/claude-assets/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
  662. package/claude-assets/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
  663. package/claude-assets/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
  664. package/claude-assets/skills/cfn-redis-coordination/config.json +0 -61
  665. package/claude-assets/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
  666. package/claude-assets/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
  667. package/claude-assets/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
  668. package/claude-assets/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
  669. package/claude-assets/skills/cfn-redis-coordination/jest.config.js +0 -23
  670. package/claude-assets/skills/cfn-redis-coordination/package-lock.json +0 -5272
  671. package/claude-assets/skills/cfn-redis-coordination/package.json +0 -45
  672. package/claude-assets/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
  673. package/claude-assets/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
  674. package/claude-assets/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
  675. package/claude-assets/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
  676. package/claude-assets/skills/cfn-redis-coordination/src/index.ts +0 -82
  677. package/claude-assets/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
  678. package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
  679. package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
  680. package/claude-assets/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
  681. package/claude-assets/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
  682. package/claude-assets/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
  683. package/claude-assets/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
  684. package/claude-assets/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
  685. package/claude-assets/skills/cfn-redis-coordination/src/types.ts +0 -235
  686. package/claude-assets/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
  687. package/claude-assets/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
  688. package/claude-assets/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
  689. package/claude-assets/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
  690. package/claude-assets/skills/cfn-redis-coordination/test-redis-check.js +0 -84
  691. package/claude-assets/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
  692. package/claude-assets/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
  693. package/claude-assets/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
  694. package/claude-assets/skills/cfn-redis-data-extraction/SKILL.md +0 -442
  695. package/claude-assets/skills/cfn-redis-data-extraction/extract.sh +0 -306
  696. package/dist/coordination/index.js +0 -25
  697. package/dist/coordination/index.js.map +0 -1
  698. package/docs/BUG_19_MEMORY_LEAK_TASK_MODE.md +0 -405
  699. package/docs/MEMORY_CLEANUP_GUIDE.md +0 -358
  700. package/docs/MEMORY_LEAK_FIX_SUMMARY.md +0 -322
  701. package/docs/REDIS_CLEANUP_EXECUTIVE_SUMMARY.md +0 -319
  702. package/docs/REDIS_CLEANUP_VERIFICATION_REPORT.md +0 -574
  703. package/tests/test-memory-leak-task-mode.sh +0 -435
  704. /package/.claude/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
  705. /package/.claude/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
  706. /package/.claude/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
  707. /package/.claude/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
  708. /package/.claude/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
  709. /package/.claude/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
  710. /package/.claude/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
  711. /package/.claude/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
  712. /package/.claude/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
  713. /package/.claude/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
  714. /package/.claude/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
  715. /package/.claude/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
  716. /package/.claude/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
  717. /package/.claude/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
  718. /package/.claude/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
  719. /package/.claude/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
  720. /package/.claude/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
  721. /package/.claude/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
  722. /package/.claude/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
  723. /package/claude-assets/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
  724. /package/claude-assets/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
  725. /package/claude-assets/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
  726. /package/claude-assets/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
  727. /package/claude-assets/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
  728. /package/claude-assets/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
  729. /package/claude-assets/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
  730. /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
  731. /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
  732. /package/claude-assets/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
  733. /package/claude-assets/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
  734. /package/claude-assets/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
  735. /package/claude-assets/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
  736. /package/claude-assets/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
  737. /package/claude-assets/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
  738. /package/claude-assets/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
  739. /package/claude-assets/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
  740. /package/claude-assets/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
  741. /package/claude-assets/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
@@ -0,0 +1,285 @@
1
+ /**
2
+ * Agent Result Cache - Phase 6 Performance Optimization
3
+ *
4
+ * Implements Redis-based caching for agent results to reduce redundant work.
5
+ *
6
+ * Performance targets:
7
+ * - Cache hit rate: ~80% (with 1-hour TTL)
8
+ * - Cache operation latency: <10ms
9
+ * - 80% reduction in redundant agent execution
10
+ *
11
+ * Features:
12
+ * - SHA256-based task hashing for cache keys
13
+ * - Configurable TTL (default 1 hour)
14
+ * - Prometheus metrics (hits, misses, size)
15
+ * - Graceful degradation if Redis unavailable
16
+ * - TypeScript strict mode (no any types)
17
+ * - Cache invalidation API
18
+ */ import { createHash } from 'crypto';
19
+ import { getRedisPool } from './connection-pool.js';
20
+ /**
21
+ * Default cache configuration
22
+ */ const DEFAULT_CONFIG = {
23
+ ttlSeconds: parseInt(process.env.CFN_CACHE_TTL_SECONDS || '3600', 10),
24
+ maxEntries: parseInt(process.env.CFN_CACHE_MAX_ENTRIES || '10000', 10),
25
+ prefix: process.env.CFN_CACHE_PREFIX || 'cfn:cache:'
26
+ };
27
+ /**
28
+ * Metrics tracking
29
+ */ let cacheHits = 0;
30
+ let cacheMisses = 0;
31
+ let cacheSizeBytes = 0;
32
+ let cacheEntries = 0;
33
+ /**
34
+ * Cache availability flag
35
+ */ let cacheAvailable = true;
36
+ /**
37
+ * Generate SHA256 hash for task description
38
+ * Ensures consistent cache keys for identical tasks
39
+ */ export function generateTaskHash(taskDescription) {
40
+ return createHash('sha256').update(taskDescription.trim()).digest('hex');
41
+ }
42
+ /**
43
+ * Build cache key from agent type and task hash
44
+ */ function buildCacheKey(agentType, taskHash) {
45
+ return `${DEFAULT_CONFIG.prefix}${agentType}:${taskHash}`;
46
+ }
47
+ /**
48
+ * Get cached result for agent task
49
+ * Returns null if cache miss or error
50
+ *
51
+ * @param agentType - Type of agent (e.g., 'backend-developer')
52
+ * @param taskDescription - Task description to hash
53
+ * @returns Cached result or null
54
+ */ export async function getCachedResult(agentType, taskDescription) {
55
+ if (!cacheAvailable) {
56
+ cacheMisses++;
57
+ return null;
58
+ }
59
+ try {
60
+ const redis = getRedisPool();
61
+ const taskHash = generateTaskHash(taskDescription);
62
+ const cacheKey = buildCacheKey(agentType, taskHash);
63
+ const startTime = Date.now();
64
+ const cachedData = await redis.get(cacheKey);
65
+ const latency = Date.now() - startTime;
66
+ if (latency > 10) {
67
+ console.warn(`Cache GET latency ${latency}ms exceeds 10ms target`);
68
+ }
69
+ if (!cachedData) {
70
+ cacheMisses++;
71
+ return null;
72
+ }
73
+ const parsed = JSON.parse(cachedData);
74
+ // Validate expiration
75
+ const expiresAt = new Date(parsed.expiresAt);
76
+ if (expiresAt < new Date()) {
77
+ // Expired, delete and return null
78
+ await redis.del(cacheKey);
79
+ cacheMisses++;
80
+ return null;
81
+ }
82
+ cacheHits++;
83
+ return parsed;
84
+ } catch (error) {
85
+ const err = error;
86
+ console.error('Cache GET error:', err.message);
87
+ // Graceful degradation
88
+ cacheAvailable = false;
89
+ cacheMisses++;
90
+ return null;
91
+ }
92
+ }
93
+ /**
94
+ * Set cached result for agent task
95
+ * Implements TTL-based expiration and size limits
96
+ *
97
+ * @param agentType - Type of agent
98
+ * @param taskDescription - Task description to hash
99
+ * @param result - Agent result to cache
100
+ * @param confidence - Confidence score
101
+ */ export async function setCachedResult(agentType, taskDescription, result, confidence) {
102
+ if (!cacheAvailable) {
103
+ return;
104
+ }
105
+ try {
106
+ const redis = getRedisPool();
107
+ const taskHash = generateTaskHash(taskDescription);
108
+ const cacheKey = buildCacheKey(agentType, taskHash);
109
+ // Check max entries limit
110
+ const currentEntries = await redis.dbsize();
111
+ if (currentEntries >= DEFAULT_CONFIG.maxEntries) {
112
+ console.warn(`Cache at max capacity (${DEFAULT_CONFIG.maxEntries} entries), evicting oldest entries`);
113
+ // Redis with maxmemory-policy=allkeys-lru handles eviction automatically
114
+ }
115
+ const now = new Date();
116
+ const expiresAt = new Date(now.getTime() + DEFAULT_CONFIG.ttlSeconds * 1000);
117
+ const cachedResult = {
118
+ agentType,
119
+ taskHash,
120
+ result,
121
+ confidence,
122
+ cachedAt: now.toISOString(),
123
+ expiresAt: expiresAt.toISOString()
124
+ };
125
+ const serialized = JSON.stringify(cachedResult);
126
+ const sizeBytes = Buffer.byteLength(serialized, 'utf8');
127
+ const startTime = Date.now();
128
+ await redis.set(cacheKey, serialized, 'EX', DEFAULT_CONFIG.ttlSeconds);
129
+ const latency = Date.now() - startTime;
130
+ if (latency > 10) {
131
+ console.warn(`Cache SET latency ${latency}ms exceeds 10ms target`);
132
+ }
133
+ // Update metrics
134
+ cacheSizeBytes += sizeBytes;
135
+ cacheEntries++;
136
+ } catch (error) {
137
+ const err = error;
138
+ console.error('Cache SET error:', err.message);
139
+ // Graceful degradation
140
+ cacheAvailable = false;
141
+ }
142
+ }
143
+ /**
144
+ * Invalidate cache entries
145
+ * If agentType provided, only invalidates that agent's cache
146
+ * Otherwise, clears all cache entries
147
+ *
148
+ * @param agentType - Optional agent type to target
149
+ * @returns Number of entries deleted
150
+ */ export async function invalidateCache(agentType) {
151
+ if (!cacheAvailable) {
152
+ return 0;
153
+ }
154
+ try {
155
+ const redis = getRedisPool();
156
+ let deletedCount = 0;
157
+ if (agentType) {
158
+ // Delete specific agent type cache entries
159
+ const pattern = `${DEFAULT_CONFIG.prefix}${agentType}:*`;
160
+ const keys = await redis.keys(pattern);
161
+ if (keys.length > 0) {
162
+ deletedCount = await redis.del(...keys);
163
+ }
164
+ } else {
165
+ // Delete all cache entries
166
+ const pattern = `${DEFAULT_CONFIG.prefix}*`;
167
+ const keys = await redis.keys(pattern);
168
+ if (keys.length > 0) {
169
+ deletedCount = await redis.del(...keys);
170
+ }
171
+ }
172
+ // Reset metrics
173
+ if (!agentType) {
174
+ cacheHits = 0;
175
+ cacheMisses = 0;
176
+ cacheSizeBytes = 0;
177
+ cacheEntries = 0;
178
+ }
179
+ console.log(`Cache invalidated: ${deletedCount} entries deleted`);
180
+ return deletedCount;
181
+ } catch (error) {
182
+ const err = error;
183
+ console.error('Cache invalidation error:', err.message);
184
+ cacheAvailable = false;
185
+ return 0;
186
+ }
187
+ }
188
+ /**
189
+ * Get cache metrics for Prometheus monitoring
190
+ * Exposes hits, misses, hit rate, size, and entry count
191
+ */ export function getCacheMetrics() {
192
+ const totalRequests = cacheHits + cacheMisses;
193
+ const hitRate = totalRequests > 0 ? cacheHits / totalRequests : 0;
194
+ return {
195
+ hits: cacheHits,
196
+ misses: cacheMisses,
197
+ totalRequests,
198
+ hitRate: parseFloat(hitRate.toFixed(4)),
199
+ sizeBytes: cacheSizeBytes,
200
+ entries: cacheEntries,
201
+ lastUpdated: new Date().toISOString()
202
+ };
203
+ }
204
+ /**
205
+ * Reset cache metrics
206
+ * Used for testing and monitoring reset
207
+ */ export function resetCacheMetrics() {
208
+ cacheHits = 0;
209
+ cacheMisses = 0;
210
+ cacheSizeBytes = 0;
211
+ cacheEntries = 0;
212
+ console.log('Cache metrics reset');
213
+ }
214
+ /**
215
+ * Check if cache is available
216
+ * Used for graceful degradation checks
217
+ */ export function isCacheAvailable() {
218
+ return cacheAvailable;
219
+ }
220
+ /**
221
+ * Reset cache availability flag
222
+ * Used after Redis reconnection
223
+ */ export function resetCacheAvailability() {
224
+ cacheAvailable = true;
225
+ console.log('Cache availability reset');
226
+ }
227
+ /**
228
+ * Get cache configuration
229
+ * Returns current cache settings
230
+ */ export function getCacheConfig() {
231
+ return {
232
+ ...DEFAULT_CONFIG
233
+ };
234
+ }
235
+ /**
236
+ * Update cache TTL for future entries
237
+ * Does not affect existing cached entries
238
+ *
239
+ * @param ttlSeconds - New TTL in seconds
240
+ */ export function updateCacheTTL(ttlSeconds) {
241
+ if (ttlSeconds < 60 || ttlSeconds > 86400) {
242
+ throw new Error(`Invalid TTL: ${ttlSeconds}s. Must be between 60s (1 min) and 86400s (24 hours).`);
243
+ }
244
+ DEFAULT_CONFIG.ttlSeconds = ttlSeconds;
245
+ console.log(`Cache TTL updated to ${ttlSeconds} seconds`);
246
+ }
247
+ /**
248
+ * Get cache entry count from Redis
249
+ * More accurate than tracked metric (accounts for evictions)
250
+ */ export async function getCacheEntryCount() {
251
+ if (!cacheAvailable) {
252
+ return 0;
253
+ }
254
+ try {
255
+ const redis = getRedisPool();
256
+ const pattern = `${DEFAULT_CONFIG.prefix}*`;
257
+ const keys = await redis.keys(pattern);
258
+ return keys.length;
259
+ } catch (error) {
260
+ const err = error;
261
+ console.error('Failed to get cache entry count:', err.message);
262
+ return 0;
263
+ }
264
+ }
265
+ /**
266
+ * Prewarm cache with common agent tasks
267
+ * Used during system initialization
268
+ *
269
+ * @param entries - Array of [agentType, taskDescription, result, confidence] tuples
270
+ */ export async function prewarmCache(entries) {
271
+ let warmedCount = 0;
272
+ for (const [agentType, taskDescription, result, confidence] of entries){
273
+ try {
274
+ await setCachedResult(agentType, taskDescription, result, confidence);
275
+ warmedCount++;
276
+ } catch (error) {
277
+ const err = error;
278
+ console.error(`Failed to prewarm cache entry: ${err.message}`);
279
+ }
280
+ }
281
+ console.log(`Cache prewarmed with ${warmedCount} entries`);
282
+ return warmedCount;
283
+ }
284
+
285
+ //# sourceMappingURL=result-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/result-cache.ts"],"sourcesContent":["/**\r\n * Agent Result Cache - Phase 6 Performance Optimization\r\n *\r\n * Implements Redis-based caching for agent results to reduce redundant work.\r\n *\r\n * Performance targets:\r\n * - Cache hit rate: ~80% (with 1-hour TTL)\r\n * - Cache operation latency: <10ms\r\n * - 80% reduction in redundant agent execution\r\n *\r\n * Features:\r\n * - SHA256-based task hashing for cache keys\r\n * - Configurable TTL (default 1 hour)\r\n * - Prometheus metrics (hits, misses, size)\r\n * - Graceful degradation if Redis unavailable\r\n * - TypeScript strict mode (no any types)\r\n * - Cache invalidation API\r\n */\r\n\r\nimport { createHash } from 'crypto';\r\nimport { getRedisPool } from './connection-pool.js';\r\n\r\n/**\r\n * Cache configuration\r\n */\r\nexport interface CacheConfig {\r\n ttlSeconds: number; // Default 3600 (1 hour)\r\n maxEntries: number; // Default 10000\r\n prefix: string; // Default 'cfn:cache:'\r\n}\r\n\r\n/**\r\n * Cached result structure\r\n */\r\nexport interface CachedResult {\r\n agentType: string;\r\n taskHash: string;\r\n result: unknown;\r\n confidence: number;\r\n cachedAt: string;\r\n expiresAt: string;\r\n}\r\n\r\n/**\r\n * Cache metrics for Prometheus monitoring\r\n */\r\nexport interface CacheMetrics {\r\n hits: number;\r\n misses: number;\r\n totalRequests: number;\r\n hitRate: number;\r\n sizeBytes: number;\r\n entries: number;\r\n lastUpdated: string;\r\n}\r\n\r\n/**\r\n * Default cache configuration\r\n */\r\nconst DEFAULT_CONFIG: CacheConfig = {\r\n ttlSeconds: parseInt(process.env.CFN_CACHE_TTL_SECONDS || '3600', 10),\r\n maxEntries: parseInt(process.env.CFN_CACHE_MAX_ENTRIES || '10000', 10),\r\n prefix: process.env.CFN_CACHE_PREFIX || 'cfn:cache:',\r\n};\r\n\r\n/**\r\n * Metrics tracking\r\n */\r\nlet cacheHits = 0;\r\nlet cacheMisses = 0;\r\nlet cacheSizeBytes = 0;\r\nlet cacheEntries = 0;\r\n\r\n/**\r\n * Cache availability flag\r\n */\r\nlet cacheAvailable = true;\r\n\r\n/**\r\n * Generate SHA256 hash for task description\r\n * Ensures consistent cache keys for identical tasks\r\n */\r\nexport function generateTaskHash(taskDescription: string): string {\r\n return createHash('sha256').update(taskDescription.trim()).digest('hex');\r\n}\r\n\r\n/**\r\n * Build cache key from agent type and task hash\r\n */\r\nfunction buildCacheKey(agentType: string, taskHash: string): string {\r\n return `${DEFAULT_CONFIG.prefix}${agentType}:${taskHash}`;\r\n}\r\n\r\n/**\r\n * Get cached result for agent task\r\n * Returns null if cache miss or error\r\n *\r\n * @param agentType - Type of agent (e.g., 'backend-developer')\r\n * @param taskDescription - Task description to hash\r\n * @returns Cached result or null\r\n */\r\nexport async function getCachedResult(\r\n agentType: string,\r\n taskDescription: string\r\n): Promise<CachedResult | null> {\r\n if (!cacheAvailable) {\r\n cacheMisses++;\r\n return null;\r\n }\r\n\r\n try {\r\n const redis = getRedisPool();\r\n const taskHash = generateTaskHash(taskDescription);\r\n const cacheKey = buildCacheKey(agentType, taskHash);\r\n\r\n const startTime = Date.now();\r\n const cachedData = await redis.get(cacheKey);\r\n const latency = Date.now() - startTime;\r\n\r\n if (latency > 10) {\r\n console.warn(`Cache GET latency ${latency}ms exceeds 10ms target`);\r\n }\r\n\r\n if (!cachedData) {\r\n cacheMisses++;\r\n return null;\r\n }\r\n\r\n const parsed = JSON.parse(cachedData) as CachedResult;\r\n\r\n // Validate expiration\r\n const expiresAt = new Date(parsed.expiresAt);\r\n if (expiresAt < new Date()) {\r\n // Expired, delete and return null\r\n await redis.del(cacheKey);\r\n cacheMisses++;\r\n return null;\r\n }\r\n\r\n cacheHits++;\r\n return parsed;\r\n } catch (error) {\r\n const err = error as Error;\r\n console.error('Cache GET error:', err.message);\r\n // Graceful degradation\r\n cacheAvailable = false;\r\n cacheMisses++;\r\n return null;\r\n }\r\n}\r\n\r\n/**\r\n * Set cached result for agent task\r\n * Implements TTL-based expiration and size limits\r\n *\r\n * @param agentType - Type of agent\r\n * @param taskDescription - Task description to hash\r\n * @param result - Agent result to cache\r\n * @param confidence - Confidence score\r\n */\r\nexport async function setCachedResult(\r\n agentType: string,\r\n taskDescription: string,\r\n result: unknown,\r\n confidence: number\r\n): Promise<void> {\r\n if (!cacheAvailable) {\r\n return;\r\n }\r\n\r\n try {\r\n const redis = getRedisPool();\r\n const taskHash = generateTaskHash(taskDescription);\r\n const cacheKey = buildCacheKey(agentType, taskHash);\r\n\r\n // Check max entries limit\r\n const currentEntries = await redis.dbsize();\r\n if (currentEntries >= DEFAULT_CONFIG.maxEntries) {\r\n console.warn(\r\n `Cache at max capacity (${DEFAULT_CONFIG.maxEntries} entries), evicting oldest entries`\r\n );\r\n // Redis with maxmemory-policy=allkeys-lru handles eviction automatically\r\n }\r\n\r\n const now = new Date();\r\n const expiresAt = new Date(now.getTime() + DEFAULT_CONFIG.ttlSeconds * 1000);\r\n\r\n const cachedResult: CachedResult = {\r\n agentType,\r\n taskHash,\r\n result,\r\n confidence,\r\n cachedAt: now.toISOString(),\r\n expiresAt: expiresAt.toISOString(),\r\n };\r\n\r\n const serialized = JSON.stringify(cachedResult);\r\n const sizeBytes = Buffer.byteLength(serialized, 'utf8');\r\n\r\n const startTime = Date.now();\r\n await redis.set(cacheKey, serialized, 'EX', DEFAULT_CONFIG.ttlSeconds);\r\n const latency = Date.now() - startTime;\r\n\r\n if (latency > 10) {\r\n console.warn(`Cache SET latency ${latency}ms exceeds 10ms target`);\r\n }\r\n\r\n // Update metrics\r\n cacheSizeBytes += sizeBytes;\r\n cacheEntries++;\r\n } catch (error) {\r\n const err = error as Error;\r\n console.error('Cache SET error:', err.message);\r\n // Graceful degradation\r\n cacheAvailable = false;\r\n }\r\n}\r\n\r\n/**\r\n * Invalidate cache entries\r\n * If agentType provided, only invalidates that agent's cache\r\n * Otherwise, clears all cache entries\r\n *\r\n * @param agentType - Optional agent type to target\r\n * @returns Number of entries deleted\r\n */\r\nexport async function invalidateCache(agentType?: string): Promise<number> {\r\n if (!cacheAvailable) {\r\n return 0;\r\n }\r\n\r\n try {\r\n const redis = getRedisPool();\r\n let deletedCount = 0;\r\n\r\n if (agentType) {\r\n // Delete specific agent type cache entries\r\n const pattern = `${DEFAULT_CONFIG.prefix}${agentType}:*`;\r\n const keys = await redis.keys(pattern);\r\n\r\n if (keys.length > 0) {\r\n deletedCount = await redis.del(...keys);\r\n }\r\n } else {\r\n // Delete all cache entries\r\n const pattern = `${DEFAULT_CONFIG.prefix}*`;\r\n const keys = await redis.keys(pattern);\r\n\r\n if (keys.length > 0) {\r\n deletedCount = await redis.del(...keys);\r\n }\r\n }\r\n\r\n // Reset metrics\r\n if (!agentType) {\r\n cacheHits = 0;\r\n cacheMisses = 0;\r\n cacheSizeBytes = 0;\r\n cacheEntries = 0;\r\n }\r\n\r\n console.log(`Cache invalidated: ${deletedCount} entries deleted`);\r\n return deletedCount;\r\n } catch (error) {\r\n const err = error as Error;\r\n console.error('Cache invalidation error:', err.message);\r\n cacheAvailable = false;\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * Get cache metrics for Prometheus monitoring\r\n * Exposes hits, misses, hit rate, size, and entry count\r\n */\r\nexport function getCacheMetrics(): CacheMetrics {\r\n const totalRequests = cacheHits + cacheMisses;\r\n const hitRate = totalRequests > 0 ? cacheHits / totalRequests : 0;\r\n\r\n return {\r\n hits: cacheHits,\r\n misses: cacheMisses,\r\n totalRequests,\r\n hitRate: parseFloat(hitRate.toFixed(4)),\r\n sizeBytes: cacheSizeBytes,\r\n entries: cacheEntries,\r\n lastUpdated: new Date().toISOString(),\r\n };\r\n}\r\n\r\n/**\r\n * Reset cache metrics\r\n * Used for testing and monitoring reset\r\n */\r\nexport function resetCacheMetrics(): void {\r\n cacheHits = 0;\r\n cacheMisses = 0;\r\n cacheSizeBytes = 0;\r\n cacheEntries = 0;\r\n console.log('Cache metrics reset');\r\n}\r\n\r\n/**\r\n * Check if cache is available\r\n * Used for graceful degradation checks\r\n */\r\nexport function isCacheAvailable(): boolean {\r\n return cacheAvailable;\r\n}\r\n\r\n/**\r\n * Reset cache availability flag\r\n * Used after Redis reconnection\r\n */\r\nexport function resetCacheAvailability(): void {\r\n cacheAvailable = true;\r\n console.log('Cache availability reset');\r\n}\r\n\r\n/**\r\n * Get cache configuration\r\n * Returns current cache settings\r\n */\r\nexport function getCacheConfig(): CacheConfig {\r\n return { ...DEFAULT_CONFIG };\r\n}\r\n\r\n/**\r\n * Update cache TTL for future entries\r\n * Does not affect existing cached entries\r\n *\r\n * @param ttlSeconds - New TTL in seconds\r\n */\r\nexport function updateCacheTTL(ttlSeconds: number): void {\r\n if (ttlSeconds < 60 || ttlSeconds > 86400) {\r\n throw new Error(\r\n `Invalid TTL: ${ttlSeconds}s. Must be between 60s (1 min) and 86400s (24 hours).`\r\n );\r\n }\r\n DEFAULT_CONFIG.ttlSeconds = ttlSeconds;\r\n console.log(`Cache TTL updated to ${ttlSeconds} seconds`);\r\n}\r\n\r\n/**\r\n * Get cache entry count from Redis\r\n * More accurate than tracked metric (accounts for evictions)\r\n */\r\nexport async function getCacheEntryCount(): Promise<number> {\r\n if (!cacheAvailable) {\r\n return 0;\r\n }\r\n\r\n try {\r\n const redis = getRedisPool();\r\n const pattern = `${DEFAULT_CONFIG.prefix}*`;\r\n const keys = await redis.keys(pattern);\r\n return keys.length;\r\n } catch (error) {\r\n const err = error as Error;\r\n console.error('Failed to get cache entry count:', err.message);\r\n return 0;\r\n }\r\n}\r\n\r\n/**\r\n * Prewarm cache with common agent tasks\r\n * Used during system initialization\r\n *\r\n * @param entries - Array of [agentType, taskDescription, result, confidence] tuples\r\n */\r\nexport async function prewarmCache(\r\n entries: Array<[string, string, unknown, number]>\r\n): Promise<number> {\r\n let warmedCount = 0;\r\n\r\n for (const [agentType, taskDescription, result, confidence] of entries) {\r\n try {\r\n await setCachedResult(agentType, taskDescription, result, confidence);\r\n warmedCount++;\r\n } catch (error) {\r\n const err = error as Error;\r\n console.error(`Failed to prewarm cache entry: ${err.message}`);\r\n }\r\n }\r\n\r\n console.log(`Cache prewarmed with ${warmedCount} entries`);\r\n return warmedCount;\r\n}\r\n"],"names":["createHash","getRedisPool","DEFAULT_CONFIG","ttlSeconds","parseInt","process","env","CFN_CACHE_TTL_SECONDS","maxEntries","CFN_CACHE_MAX_ENTRIES","prefix","CFN_CACHE_PREFIX","cacheHits","cacheMisses","cacheSizeBytes","cacheEntries","cacheAvailable","generateTaskHash","taskDescription","update","trim","digest","buildCacheKey","agentType","taskHash","getCachedResult","redis","cacheKey","startTime","Date","now","cachedData","get","latency","console","warn","parsed","JSON","parse","expiresAt","del","error","err","message","setCachedResult","result","confidence","currentEntries","dbsize","getTime","cachedResult","cachedAt","toISOString","serialized","stringify","sizeBytes","Buffer","byteLength","set","invalidateCache","deletedCount","pattern","keys","length","log","getCacheMetrics","totalRequests","hitRate","hits","misses","parseFloat","toFixed","entries","lastUpdated","resetCacheMetrics","isCacheAvailable","resetCacheAvailability","getCacheConfig","updateCacheTTL","Error","getCacheEntryCount","prewarmCache","warmedCount"],"mappings":"AAAA;;;;;;;;;;;;;;;;;CAiBC,GAED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AAesC,aACpBT,OAAiD;IAEjD,IAAIU,cAAc;IAElB,KAAK,MAAM,CAAC3D,WAAWL,iBAAiB2B,QAAQC,WAAW,IAAI0B,QAAS;QACtE,IAAI;YACF,MAAM5B,gBAAgBrB,WAAWL,iBAAiB2B,QAAQC;YAC1DoC;QACF,EAAE,OAAOzC,OAAO;YACd,MAAMC,MAAMD;YACZP,QAAQO,KAAK,CAAC,CAAC,+BAA+B,EAAEC,IAAIC,OAAO,EAAE;QAC/D;IACF;IAEAT,QAAQ8B,GAAG,CAAC,CAAC,qBAAqB,EAAEkB,YAAY,QAAQ,CAAC;IACzD,OAAOA;AACT"}
@@ -9,7 +9,8 @@ let MCPAuthMiddleware = class MCPAuthMiddleware {
9
9
  constructor(options = {}){
10
10
  this.redis = null;
11
11
  this.options = {
12
- redisUrl: options.redisUrl || process.env.CFN_REDIS_URL || process.env.MCP_REDIS_URL || `redis://${process.env.CFN_REDIS_HOST || 'cfn-redis'}:${process.env.CFN_REDIS_PORT || 6379}`,
12
+ // FIX: Default to 'localhost' for host execution, Docker deployments should set CFN_REDIS_HOST explicitly
13
+ redisUrl: options.redisUrl || process.env.CFN_REDIS_URL || process.env.MCP_REDIS_URL || `redis://${process.env.CFN_REDIS_HOST || 'localhost'}:${process.env.CFN_REDIS_PORT || 6379}`,
13
14
  tokenExpiry: options.tokenExpiry || '24h',
14
15
  authRequired: options.authRequired !== false,
15
16
  rateLimitWindow: options.rateLimitWindow || 60,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/mcp/auth-middleware.js"],"sourcesContent":["/**\r\n * MCP Authentication Middleware\r\n * Token-based authentication and authorization for MCP containers\r\n */\r\n\r\nconst crypto = require('crypto');\r\nconst Redis = require('redis');\r\nconst fs = require('fs').promises;\r\nconst path = require('path');\r\n\r\nclass MCPAuthMiddleware {\r\n constructor(options = {}) {\r\n this.redis = null;\r\n this.options = {\r\n redisUrl: options.redisUrl || process.env.CFN_REDIS_URL || process.env.MCP_REDIS_URL || `redis://${process.env.CFN_REDIS_HOST || 'cfn-redis'}:${process.env.CFN_REDIS_PORT || 6379}`,\r\n tokenExpiry: options.tokenExpiry || '24h',\r\n authRequired: options.authRequired !== false,\r\n rateLimitWindow: options.rateLimitWindow || 60, // seconds\r\n rateLimitMax: options.rateLimitMax || 100,\r\n agentConfigPath: options.agentConfigPath || './config/agent-whitelist.json',\r\n skillConfigPath: options.skillConfigPath || './config/skill-requirements.json',\r\n ...options\r\n };\r\n\r\n this.agentWhitelist = new Map();\r\n this.skillRequirements = new Map();\r\n this.rateLimitCache = new Map();\r\n }\r\n\r\n /**\r\n * Initialize authentication middleware\r\n */\r\n async initialize() {\r\n try {\r\n // Connect to Redis\r\n this.redis = Redis.createClient({ url: this.options.redisUrl });\r\n await this.redis.connect();\r\n\r\n console.log('[MCPAuth] Connected to Redis for authentication');\r\n\r\n // Load configuration\r\n await this.loadAgentWhitelist();\r\n await this.loadSkillRequirements();\r\n\r\n // Start cleanup interval\r\n this.startCleanupInterval();\r\n\r\n console.log('[MCPAuth] Authentication middleware initialized successfully');\r\n } catch (error) {\r\n console.error('[MCPAuth] Failed to initialize:', error);\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Load agent whitelist from configuration\r\n */\r\n async loadAgentWhitelist() {\r\n try {\r\n const configPath = path.resolve(this.options.agentConfigPath);\r\n const config = await fs.readFile(configPath, 'utf8');\r\n const whitelist = JSON.parse(config);\r\n\r\n this.agentWhitelist.clear();\r\n for (const agent of whitelist.agents) {\r\n this.agentWhitelist.set(agent.type, agent);\r\n }\r\n\r\n console.log(`[MCPAuth] Loaded ${this.agentWhitelist.size} agent configurations`);\r\n } catch (error) {\r\n console.warn('[MCPAuth] Failed to load agent whitelist:', error.message);\r\n // Default to empty whitelist (deny all)\r\n this.agentWhitelist.clear();\r\n }\r\n }\r\n\r\n /**\r\n * Load skill requirements from configuration\r\n */\r\n async loadSkillRequirements() {\r\n try {\r\n const configPath = path.resolve(this.options.skillConfigPath);\r\n const config = await fs.readFile(configPath, 'utf8');\r\n const requirements = JSON.parse(config);\r\n\r\n this.skillRequirements.clear();\r\n for (const [tool, req] of Object.entries(requirements.tools)) {\r\n this.skillRequirements.set(tool, req);\r\n }\r\n\r\n console.log(`[MCPAuth] Loaded ${this.skillRequirements.size} tool skill requirements`);\r\n } catch (error) {\r\n console.warn('[MCPAuth] Failed to load skill requirements:', error.message);\r\n this.skillRequirements.clear();\r\n }\r\n }\r\n\r\n /**\r\n * Authenticate agent request\r\n */\r\n async authenticateRequest(request, response, next) {\r\n try {\r\n // Skip authentication if not required\r\n if (!this.options.authRequired) {\r\n return next();\r\n }\r\n\r\n // Extract authentication headers\r\n const agentToken = request.headers['x-agent-token'];\r\n const agentType = request.headers['x-agent-type'];\r\n const toolName = request.body?.name || request.params?.toolName;\r\n\r\n // Validate required headers\r\n if (!agentToken || !agentType) {\r\n return this.sendErrorResponse(response, 401, 'Missing authentication headers', {\r\n required: ['x-agent-token', 'x-agent-type']\r\n });\r\n }\r\n\r\n // Validate token in Redis\r\n const tokenData = await this.validateToken(agentToken, agentType);\r\n if (!tokenData) {\r\n return this.sendErrorResponse(response, 401, 'Invalid or expired token', {\r\n agentType,\r\n tokenValid: false\r\n });\r\n }\r\n\r\n // Validate agent type against whitelist\r\n if (!this.isAgentAuthorized(agentType)) {\r\n return this.sendErrorResponse(response, 403, 'Agent type not authorized', {\r\n agentType,\r\n allowedTypes: Array.from(this.agentWhitelist.keys())\r\n });\r\n }\r\n\r\n // Validate skill-based tool access\r\n if (toolName && !this.authorizeToolAccess(agentType, toolName)) {\r\n const toolRequirements = this.skillRequirements.get(toolName);\r\n return this.sendErrorResponse(response, 403, 'Insufficient skills for tool access', {\r\n agentType,\r\n toolName,\r\n requiredSkills: toolRequirements?.requiredSkills || [],\r\n agentSkills: tokenData.skills || []\r\n });\r\n }\r\n\r\n // Check rate limits\r\n if (!this.checkRateLimit(agentType, agentToken)) {\r\n return this.sendErrorResponse(response, 429, 'Rate limit exceeded', {\r\n agentType,\r\n window: this.options.rateLimitWindow,\r\n maxRequests: this.options.rateLimitMax\r\n });\r\n }\r\n\r\n // Add agent context to request\r\n request.agentContext = {\r\n agentType,\r\n agentToken,\r\n skills: tokenData.skills || [],\r\n authenticated: true,\r\n timestamp: Date.now()\r\n };\r\n\r\n // Update last activity\r\n await this.updateAgentActivity(agentToken, agentType);\r\n\r\n return next();\r\n\r\n } catch (error) {\r\n console.error('[MCPAuth] Authentication error:', error);\r\n return this.sendErrorResponse(response, 500, 'Authentication error', {\r\n error: error.message\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Validate token against Redis\r\n */\r\n async validateToken(token, agentType) {\r\n try {\r\n const key = `mcp:agent:${agentType}:${token}`;\r\n const tokenData = await this.redis.get(key);\r\n\r\n if (!tokenData) {\r\n return null;\r\n }\r\n\r\n const data = JSON.parse(tokenData);\r\n\r\n // Check expiration\r\n if (Date.now() > data.expiresAt) {\r\n await this.redis.del(key);\r\n return null;\r\n }\r\n\r\n return data;\r\n } catch (error) {\r\n console.error('[MCPAuth] Token validation error:', error);\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Check if agent type is authorized\r\n */\r\n isAgentAuthorized(agentType) {\r\n return this.agentWhitelist.has(agentType);\r\n }\r\n\r\n /**\r\n * Authorize tool access based on skills\r\n */\r\n authorizeToolAccess(agentType, toolName) {\r\n const toolRequirements = this.skillRequirements.get(toolName);\r\n if (!toolRequirements) {\r\n // No skill requirements defined - allow access\r\n return true;\r\n }\r\n\r\n const agentConfig = this.agentWhitelist.get(agentType);\r\n if (!agentConfig) {\r\n return false;\r\n }\r\n\r\n const requiredSkills = toolRequirements.requiredSkills || [];\r\n const agentSkills = agentConfig.skills || [];\r\n\r\n // Check if agent has all required skills\r\n return requiredSkills.every(skill => agentSkills.includes(skill));\r\n }\r\n\r\n /**\r\n * Check rate limits for agent\r\n */\r\n checkRateLimit(agentType, token) {\r\n const now = Date.now();\r\n const windowStart = now - (this.options.rateLimitWindow * 1000);\r\n const key = `${agentType}:${token}`;\r\n\r\n if (!this.rateLimitCache.has(key)) {\r\n this.rateLimitCache.set(key, []);\r\n }\r\n\r\n const requests = this.rateLimitCache.get(key);\r\n\r\n // Remove old requests outside window\r\n const validRequests = requests.filter(timestamp => timestamp > windowStart);\r\n this.rateLimitCache.set(key, validRequests);\r\n\r\n // Check if under limit\r\n if (validRequests.length >= this.options.rateLimitMax) {\r\n return false;\r\n }\r\n\r\n // Add current request\r\n validRequests.push(now);\r\n return true;\r\n }\r\n\r\n /**\r\n * Update agent activity in Redis\r\n */\r\n async updateAgentActivity(token, agentType) {\r\n try {\r\n const key = `mcp:agent:${agentType}:${token}`;\r\n const activity = {\r\n lastActivity: Date.now(),\r\n requestCount: 1\r\n };\r\n\r\n await this.redis.hIncrBy(key, 'requestCount', 1);\r\n await this.redis.hSet(key, 'lastActivity', Date.now().toString());\r\n await this.redis.expire(key, this.parseExpiry(this.options.tokenExpiry));\r\n } catch (error) {\r\n console.error('[MCPAuth] Failed to update activity:', error);\r\n }\r\n }\r\n\r\n /**\r\n * Generate agent token\r\n */\r\n generateAgentToken(agentType, skills = [], expiresIn = null) {\r\n const token = crypto.randomBytes(32).toString('hex');\r\n const expiresAt = Date.now() + (this.parseExpiry(expiresIn || this.options.tokenExpiry) * 1000);\r\n\r\n return {\r\n token,\r\n agentType,\r\n skills,\r\n expiresAt,\r\n createdAt: Date.now()\r\n };\r\n }\r\n\r\n /**\r\n * Register agent token in Redis\r\n */\r\n async registerAgentToken(tokenData) {\r\n try {\r\n const key = `mcp:agent:${tokenData.agentType}:${tokenData.token}`;\r\n const value = JSON.stringify(tokenData);\r\n\r\n await this.redis.setEx(key, this.parseExpiry(this.options.tokenExpiry), value);\r\n\r\n console.log(`[MCPAuth] Registered token for agent: ${tokenData.agentType}`);\r\n return tokenData;\r\n } catch (error) {\r\n console.error('[MCPAuth] Failed to register token:', error);\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Revoke agent token\r\n */\r\n async revokeAgentToken(agentType, token) {\r\n try {\r\n const key = `mcp:agent:${agentType}:${token}`;\r\n await this.redis.del(key);\r\n\r\n console.log(`[MCPAuth] Revoked token for agent: ${agentType}`);\r\n return true;\r\n } catch (error) {\r\n console.error('[MCPAuth] Failed to revoke token:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Send error response\r\n */\r\n sendErrorResponse(response, statusCode, message, details = null) {\r\n const errorResponse = {\r\n jsonrpc: '2.0',\r\n error: {\r\n code: statusCode === 401 ? -32001 : statusCode === 403 ? -32002 : -32003,\r\n message,\r\n ...(details && { details })\r\n },\r\n id: response.body?.id || null\r\n };\r\n\r\n response.writeHead(statusCode, { 'Content-Type': 'application/json' });\r\n response.end(JSON.stringify(errorResponse));\r\n }\r\n\r\n /**\r\n * Parse expiry string to seconds\r\n */\r\n parseExpiry(expiry) {\r\n if (typeof expiry === 'number') {\r\n return expiry;\r\n }\r\n\r\n const match = expiry.match(/^(\\d+)([smhd])$/);\r\n if (!match) {\r\n return 3600; // Default to 1 hour\r\n }\r\n\r\n const value = parseInt(match[1]);\r\n const unit = match[2];\r\n const multipliers = { s: 1, m: 60, h: 3600, d: 86400 };\r\n\r\n return value * (multipliers[unit] || 3600);\r\n }\r\n\r\n /**\r\n * Start cleanup interval for rate limit cache\r\n */\r\n startCleanupInterval() {\r\n setInterval(() => {\r\n const now = Date.now();\r\n const windowStart = now - (this.options.rateLimitWindow * 1000);\r\n\r\n for (const [key, requests] of this.rateLimitCache.entries()) {\r\n const validRequests = requests.filter(timestamp => timestamp > windowStart);\r\n if (validRequests.length === 0) {\r\n this.rateLimitCache.delete(key);\r\n } else {\r\n this.rateLimitCache.set(key, validRequests);\r\n }\r\n }\r\n }, 60000); // Clean up every minute\r\n }\r\n\r\n /**\r\n * Get authentication statistics\r\n */\r\n async getStats() {\r\n try {\r\n const stats = {\r\n registeredAgents: this.agentWhitelist.size,\r\n configuredTools: this.skillRequirements.size,\r\n rateLimitedClients: this.rateLimitCache.size,\r\n redisConnected: this.redis?.isOpen || false\r\n };\r\n\r\n // Get active tokens count\r\n if (this.redis?.isOpen) {\r\n const keys = await this.redis.keys('mcp:agent:*');\r\n stats.activeTokens = keys.length;\r\n }\r\n\r\n return stats;\r\n } catch (error) {\r\n console.error('[MCPAuth] Failed to get stats:', error);\r\n return { error: error.message };\r\n }\r\n }\r\n\r\n /**\r\n * Shutdown authentication middleware\r\n */\r\n async shutdown() {\r\n try {\r\n if (this.redis) {\r\n await this.redis.quit();\r\n this.redis = null;\r\n }\r\n console.log('[MCPAuth] Authentication middleware shutdown complete');\r\n } catch (error) {\r\n console.error('[MCPAuth] Shutdown error:', error);\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = MCPAuthMiddleware;"],"names":["crypto","require","Redis","fs","promises","path","MCPAuthMiddleware","options","redis","redisUrl","process","env","CFN_REDIS_URL","MCP_REDIS_URL","CFN_REDIS_HOST","CFN_REDIS_PORT","tokenExpiry","authRequired","rateLimitWindow","rateLimitMax","agentConfigPath","skillConfigPath","agentWhitelist","Map","skillRequirements","rateLimitCache","initialize","createClient","url","connect","console","log","loadAgentWhitelist","loadSkillRequirements","startCleanupInterval","error","configPath","resolve","config","readFile","whitelist","JSON","parse","clear","agent","agents","set","type","size","warn","message","requirements","tool","req","Object","entries","tools","authenticateRequest","request","response","next","agentToken","headers","agentType","toolName","body","name","params","sendErrorResponse","required","tokenData","validateToken","tokenValid","isAgentAuthorized","allowedTypes","Array","from","keys","authorizeToolAccess","toolRequirements","get","requiredSkills","agentSkills","skills","checkRateLimit","window","maxRequests","agentContext","authenticated","timestamp","Date","now","updateAgentActivity","token","key","data","expiresAt","del","has","agentConfig","every","skill","includes","windowStart","requests","validRequests","filter","length","push","activity","lastActivity","requestCount","hIncrBy","hSet","toString","expire","parseExpiry","generateAgentToken","expiresIn","randomBytes","createdAt","registerAgentToken","value","stringify","setEx","revokeAgentToken","statusCode","details","errorResponse","jsonrpc","code","id","writeHead","end","expiry","match","parseInt","unit","multipliers","s","m","h","d","setInterval","delete","getStats","stats","registeredAgents","configuredTools","rateLimitedClients","redisConnected","isOpen","activeTokens","shutdown","quit","module","exports"],"mappings":"AAAA;;;CAGC,GAED,MAAMA,SAASC,QAAQ;AACvB,MAAMC,QAAQD,QAAQ;AACtB,MAAME,KAAKF,QAAQ,MAAMG,QAAQ;AACjC,MAAMC,OAAOJ,QAAQ;AAErB,IAAA,AAAMK,oBAAN,MAAMA;IACJ,YAAYC,UAAU,CAAC,CAAC,CAAE;QACxB,IAAI,CAACC,KAAK,GAAG;QACb,IAAI,CAACD,OAAO,GAAG;YACbE,UAAUF,QAAQE,QAAQ,IAAIC,QAAQC,GAAG,CAACC,aAAa,IAAIF,QAAQC,GAAG,CAACE,aAAa,IAAI,CAAC,QAAQ,EAAEH,QAAQC,GAAG,CAACG,cAAc,IAAI,YAAY,CAAC,EAAEJ,QAAQC,GAAG,CAACI,cAAc,IAAI,MAAM;YACpLC,aAAaT,QAAQS,WAAW,IAAI;YACpCC,cAAcV,QAAQU,YAAY,KAAK;YACvCC,iBAAiBX,QAAQW,eAAe,IAAI;YAC5CC,cAAcZ,QAAQY,YAAY,IAAI;YACtCC,iBAAiBb,QAAQa,eAAe,IAAI;YAC5CC,iBAAiBd,QAAQc,eAAe,IAAI;YAC5C,GAAGd,OAAO;QACZ;QAEA,IAAI,CAACe,cAAc,GAAG,IAAIC;QAC1B,IAAI,CAACC,iBAAiB,GAAG,IAAID;QAC7B,IAAI,CAACE,cAAc,GAAG,IAAIF;IAC5B;IAEA;;GAEC,GACD,MAAMG,aAAa;QACjB,IAAI;YACF,mBAAmB;YACnB,IAAI,CAAClB,KAAK,GAAGN,MAAMyB,YAAY,CAAC;gBAAEC,KAAK,IAAI,CAACrB,OAAO,CAACE,QAAQ;YAAC;YAC7D,MAAM,IAAI,CAACD,KAAK,CAACqB,OAAO;YAExBC,QAAQC,GAAG,CAAC;YAEZ,qBAAqB;YACrB,MAAM,IAAI,CAACC,kBAAkB;YAC7B,MAAM,IAAI,CAACC,qBAA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M,YAAY,GAAG3E,KAAK8B,MAAM;YAClC;YAEA,OAAOuC;QACT,EAAE,OAAO/G,OAAO;YACdL,QAAQK,KAAK,CAAC,kCAAkCA;YAChD,OAAO;gBAAEA,OAAOA,MAAMe,OAAO;YAAC;QAChC;IACF;IAEA;;GAEC,GACD,MAAMuG,WAAW;QACf,IAAI;YACF,IAAI,IAAI,CAACjJ,KAAK,EAAE;gBACd,MAAM,IAAI,CAACA,KAAK,CAACkJ,IAAI;gBACrB,IAAI,CAAClJ,KAAK,GAAG;YACf;YACAsB,QAAQC,GAAG,CAAC;QACd,EAAE,OAAOI,OAAO;YACdL,QAAQK,KAAK,CAAC,6BAA6BA;QAC7C;IACF;AACF;AAEAwH,OAAOC,OAAO,GAAGtJ"}
1
+ {"version":3,"sources":["../../src/mcp/auth-middleware.js"],"sourcesContent":["/**\r\n * MCP Authentication Middleware\r\n * Token-based authentication and authorization for MCP containers\r\n */\r\n\r\nconst crypto = require('crypto');\r\nconst Redis = require('redis');\r\nconst fs = require('fs').promises;\r\nconst path = require('path');\r\n\r\nclass MCPAuthMiddleware {\r\n constructor(options = {}) {\r\n this.redis = null;\r\n this.options = {\r\n // FIX: Default to 'localhost' for host execution, Docker deployments should set CFN_REDIS_HOST explicitly\r\n redisUrl: options.redisUrl || process.env.CFN_REDIS_URL || process.env.MCP_REDIS_URL || `redis://${process.env.CFN_REDIS_HOST || 'localhost'}:${process.env.CFN_REDIS_PORT || 6379}`,\r\n tokenExpiry: options.tokenExpiry || '24h',\r\n authRequired: options.authRequired !== false,\r\n rateLimitWindow: options.rateLimitWindow || 60, // seconds\r\n rateLimitMax: options.rateLimitMax || 100,\r\n agentConfigPath: options.agentConfigPath || './config/agent-whitelist.json',\r\n skillConfigPath: options.skillConfigPath || './config/skill-requirements.json',\r\n ...options\r\n };\r\n\r\n this.agentWhitelist = new Map();\r\n this.skillRequirements = new Map();\r\n this.rateLimitCache = new Map();\r\n }\r\n\r\n /**\r\n * Initialize authentication middleware\r\n */\r\n async initialize() {\r\n try {\r\n // Connect to Redis\r\n this.redis = Redis.createClient({ url: this.options.redisUrl });\r\n await this.redis.connect();\r\n\r\n console.log('[MCPAuth] Connected to Redis for authentication');\r\n\r\n // Load configuration\r\n await this.loadAgentWhitelist();\r\n await this.loadSkillRequirements();\r\n\r\n // Start cleanup interval\r\n this.startCleanupInterval();\r\n\r\n console.log('[MCPAuth] Authentication middleware initialized successfully');\r\n } catch (error) {\r\n console.error('[MCPAuth] Failed to initialize:', error);\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Load agent whitelist from configuration\r\n */\r\n async loadAgentWhitelist() {\r\n try {\r\n const configPath = path.resolve(this.options.agentConfigPath);\r\n const config = await fs.readFile(configPath, 'utf8');\r\n const whitelist = JSON.parse(config);\r\n\r\n this.agentWhitelist.clear();\r\n for (const agent of whitelist.agents) {\r\n this.agentWhitelist.set(agent.type, agent);\r\n }\r\n\r\n console.log(`[MCPAuth] Loaded ${this.agentWhitelist.size} agent configurations`);\r\n } catch (error) {\r\n console.warn('[MCPAuth] Failed to load agent whitelist:', error.message);\r\n // Default to empty whitelist (deny all)\r\n this.agentWhitelist.clear();\r\n }\r\n }\r\n\r\n /**\r\n * Load skill requirements from configuration\r\n */\r\n async loadSkillRequirements() {\r\n try {\r\n const configPath = path.resolve(this.options.skillConfigPath);\r\n const config = await fs.readFile(configPath, 'utf8');\r\n const requirements = JSON.parse(config);\r\n\r\n this.skillRequirements.clear();\r\n for (const [tool, req] of Object.entries(requirements.tools)) {\r\n this.skillRequirements.set(tool, req);\r\n }\r\n\r\n console.log(`[MCPAuth] Loaded ${this.skillRequirements.size} tool skill requirements`);\r\n } catch (error) {\r\n console.warn('[MCPAuth] Failed to load skill requirements:', error.message);\r\n this.skillRequirements.clear();\r\n }\r\n }\r\n\r\n /**\r\n * Authenticate agent request\r\n */\r\n async authenticateRequest(request, response, next) {\r\n try {\r\n // Skip authentication if not required\r\n if (!this.options.authRequired) {\r\n return next();\r\n }\r\n\r\n // Extract authentication headers\r\n const agentToken = request.headers['x-agent-token'];\r\n const agentType = request.headers['x-agent-type'];\r\n const toolName = request.body?.name || request.params?.toolName;\r\n\r\n // Validate required headers\r\n if (!agentToken || !agentType) {\r\n return this.sendErrorResponse(response, 401, 'Missing authentication headers', {\r\n required: ['x-agent-token', 'x-agent-type']\r\n });\r\n }\r\n\r\n // Validate token in Redis\r\n const tokenData = await this.validateToken(agentToken, agentType);\r\n if (!tokenData) {\r\n return this.sendErrorResponse(response, 401, 'Invalid or expired token', {\r\n agentType,\r\n tokenValid: false\r\n });\r\n }\r\n\r\n // Validate agent type against whitelist\r\n if (!this.isAgentAuthorized(agentType)) {\r\n return this.sendErrorResponse(response, 403, 'Agent type not authorized', {\r\n agentType,\r\n allowedTypes: Array.from(this.agentWhitelist.keys())\r\n });\r\n }\r\n\r\n // Validate skill-based tool access\r\n if (toolName && !this.authorizeToolAccess(agentType, toolName)) {\r\n const toolRequirements = this.skillRequirements.get(toolName);\r\n return this.sendErrorResponse(response, 403, 'Insufficient skills for tool access', {\r\n agentType,\r\n toolName,\r\n requiredSkills: toolRequirements?.requiredSkills || [],\r\n agentSkills: tokenData.skills || []\r\n });\r\n }\r\n\r\n // Check rate limits\r\n if (!this.checkRateLimit(agentType, agentToken)) {\r\n return this.sendErrorResponse(response, 429, 'Rate limit exceeded', {\r\n agentType,\r\n window: this.options.rateLimitWindow,\r\n maxRequests: this.options.rateLimitMax\r\n });\r\n }\r\n\r\n // Add agent context to request\r\n request.agentContext = {\r\n agentType,\r\n agentToken,\r\n skills: tokenData.skills || [],\r\n authenticated: true,\r\n timestamp: Date.now()\r\n };\r\n\r\n // Update last activity\r\n await this.updateAgentActivity(agentToken, agentType);\r\n\r\n return next();\r\n\r\n } catch (error) {\r\n console.error('[MCPAuth] Authentication error:', error);\r\n return this.sendErrorResponse(response, 500, 'Authentication error', {\r\n error: error.message\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Validate token against Redis\r\n */\r\n async validateToken(token, agentType) {\r\n try {\r\n const key = `mcp:agent:${agentType}:${token}`;\r\n const tokenData = await this.redis.get(key);\r\n\r\n if (!tokenData) {\r\n return null;\r\n }\r\n\r\n const data = JSON.parse(tokenData);\r\n\r\n // Check expiration\r\n if (Date.now() > data.expiresAt) {\r\n await this.redis.del(key);\r\n return null;\r\n }\r\n\r\n return data;\r\n } catch (error) {\r\n console.error('[MCPAuth] Token validation error:', error);\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Check if agent type is authorized\r\n */\r\n isAgentAuthorized(agentType) {\r\n return this.agentWhitelist.has(agentType);\r\n }\r\n\r\n /**\r\n * Authorize tool access based on skills\r\n */\r\n authorizeToolAccess(agentType, toolName) {\r\n const toolRequirements = this.skillRequirements.get(toolName);\r\n if (!toolRequirements) {\r\n // No skill requirements defined - allow access\r\n return true;\r\n }\r\n\r\n const agentConfig = this.agentWhitelist.get(agentType);\r\n if (!agentConfig) {\r\n return false;\r\n }\r\n\r\n const requiredSkills = toolRequirements.requiredSkills || [];\r\n const agentSkills = agentConfig.skills || [];\r\n\r\n // Check if agent has all required skills\r\n return requiredSkills.every(skill => agentSkills.includes(skill));\r\n }\r\n\r\n /**\r\n * Check rate limits for agent\r\n */\r\n checkRateLimit(agentType, token) {\r\n const now = Date.now();\r\n const windowStart = now - (this.options.rateLimitWindow * 1000);\r\n const key = `${agentType}:${token}`;\r\n\r\n if (!this.rateLimitCache.has(key)) {\r\n this.rateLimitCache.set(key, []);\r\n }\r\n\r\n const requests = this.rateLimitCache.get(key);\r\n\r\n // Remove old requests outside window\r\n const validRequests = requests.filter(timestamp => timestamp > windowStart);\r\n this.rateLimitCache.set(key, validRequests);\r\n\r\n // Check if under limit\r\n if (validRequests.length >= this.options.rateLimitMax) {\r\n return false;\r\n }\r\n\r\n // Add current request\r\n validRequests.push(now);\r\n return true;\r\n }\r\n\r\n /**\r\n * Update agent activity in Redis\r\n */\r\n async updateAgentActivity(token, agentType) {\r\n try {\r\n const key = `mcp:agent:${agentType}:${token}`;\r\n const activity = {\r\n lastActivity: Date.now(),\r\n requestCount: 1\r\n };\r\n\r\n await this.redis.hIncrBy(key, 'requestCount', 1);\r\n await this.redis.hSet(key, 'lastActivity', Date.now().toString());\r\n await this.redis.expire(key, this.parseExpiry(this.options.tokenExpiry));\r\n } catch (error) {\r\n console.error('[MCPAuth] Failed to update activity:', error);\r\n }\r\n }\r\n\r\n /**\r\n * Generate agent token\r\n */\r\n generateAgentToken(agentType, skills = [], expiresIn = null) {\r\n const token = crypto.randomBytes(32).toString('hex');\r\n const expiresAt = Date.now() + (this.parseExpiry(expiresIn || this.options.tokenExpiry) * 1000);\r\n\r\n return {\r\n token,\r\n agentType,\r\n skills,\r\n expiresAt,\r\n createdAt: Date.now()\r\n };\r\n }\r\n\r\n /**\r\n * Register agent token in Redis\r\n */\r\n async registerAgentToken(tokenData) {\r\n try {\r\n const key = `mcp:agent:${tokenData.agentType}:${tokenData.token}`;\r\n const value = JSON.stringify(tokenData);\r\n\r\n await this.redis.setEx(key, this.parseExpiry(this.options.tokenExpiry), value);\r\n\r\n console.log(`[MCPAuth] Registered token for agent: ${tokenData.agentType}`);\r\n return tokenData;\r\n } catch (error) {\r\n console.error('[MCPAuth] Failed to register token:', error);\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * Revoke agent token\r\n */\r\n async revokeAgentToken(agentType, token) {\r\n try {\r\n const key = `mcp:agent:${agentType}:${token}`;\r\n await this.redis.del(key);\r\n\r\n console.log(`[MCPAuth] Revoked token for agent: ${agentType}`);\r\n return true;\r\n } catch (error) {\r\n console.error('[MCPAuth] Failed to revoke token:', error);\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * Send error response\r\n */\r\n sendErrorResponse(response, statusCode, message, details = null) {\r\n const errorResponse = {\r\n jsonrpc: '2.0',\r\n error: {\r\n code: statusCode === 401 ? -32001 : statusCode === 403 ? -32002 : -32003,\r\n message,\r\n ...(details && { details })\r\n },\r\n id: response.body?.id || null\r\n };\r\n\r\n response.writeHead(statusCode, { 'Content-Type': 'application/json' });\r\n response.end(JSON.stringify(errorResponse));\r\n }\r\n\r\n /**\r\n * Parse expiry string to seconds\r\n */\r\n parseExpiry(expiry) {\r\n if (typeof expiry === 'number') {\r\n return expiry;\r\n }\r\n\r\n const match = expiry.match(/^(\\d+)([smhd])$/);\r\n if (!match) {\r\n return 3600; // Default to 1 hour\r\n }\r\n\r\n const value = parseInt(match[1]);\r\n const unit = match[2];\r\n const multipliers = { s: 1, m: 60, h: 3600, d: 86400 };\r\n\r\n return value * (multipliers[unit] || 3600);\r\n }\r\n\r\n /**\r\n * Start cleanup interval for rate limit cache\r\n */\r\n startCleanupInterval() {\r\n setInterval(() => {\r\n const now = Date.now();\r\n const windowStart = now - (this.options.rateLimitWindow * 1000);\r\n\r\n for (const [key, requests] of this.rateLimitCache.entries()) {\r\n const validRequests = requests.filter(timestamp => timestamp > windowStart);\r\n if (validRequests.length === 0) {\r\n this.rateLimitCache.delete(key);\r\n } else {\r\n this.rateLimitCache.set(key, validRequests);\r\n }\r\n }\r\n }, 60000); // Clean up every minute\r\n }\r\n\r\n /**\r\n * Get authentication statistics\r\n */\r\n async getStats() {\r\n try {\r\n const stats = {\r\n registeredAgents: this.agentWhitelist.size,\r\n configuredTools: this.skillRequirements.size,\r\n rateLimitedClients: this.rateLimitCache.size,\r\n redisConnected: this.redis?.isOpen || false\r\n };\r\n\r\n // Get active tokens count\r\n if (this.redis?.isOpen) {\r\n const keys = await this.redis.keys('mcp:agent:*');\r\n stats.activeTokens = keys.length;\r\n }\r\n\r\n return stats;\r\n } catch (error) {\r\n console.error('[MCPAuth] Failed to get stats:', error);\r\n return { error: error.message };\r\n }\r\n }\r\n\r\n /**\r\n * Shutdown authentication middleware\r\n */\r\n async shutdown() {\r\n try {\r\n if (this.redis) {\r\n await this.redis.quit();\r\n this.redis = null;\r\n }\r\n console.log('[MCPAuth] Authentication middleware shutdown complete');\r\n } catch (error) {\r\n console.error('[MCPAuth] Shutdown error:', error);\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = MCPAuthMiddleware;"],"names":["crypto","require","Redis","fs","promises","path","MCPAuthMiddleware","options","redis","redisUrl","process","env","CFN_REDIS_URL","MCP_REDIS_URL","CFN_REDIS_HOST","CFN_REDIS_PORT","tokenExpiry","authRequired","rateLimitWindow","rateLimitMax","agentConfigPath","skillConfigPath","agentWhitelist","Map","skillRequirements","rateLimitCache","initialize","createClient","url","connect","console","log","loadAgentWhitelist","loadSkillRequirements","startCleanupInterval","error","configPath","resolve","config","readFile","whitelist","JSON","parse","clear","agent","agents","set","type","size","warn","message","requirements","tool","req","Object","entries","tools","authenticateRequest","request","response","next","agentToken","headers","agentType","toolName","body","name","params","sendErrorResponse","required","tokenData","validateToken","tokenValid","isAgentAuthorized","allowedTypes","Array","from","keys","authorizeToolAccess","toolRequirements","get","requiredSkills","agentSkills","skills","checkRateLimit","window","maxRequests","agentContext","authenticated","timestamp","Date","now","updateAgentActivity","token","key","data","expiresAt","del","has","agentConfig","every","skill","includes","windowStart","requests","validRequests","filter","length","push","activity","lastActivity","requestCount","hIncrBy","hSet","toString","expire","parseExpiry","generateAgentToken","expiresIn","randomBytes","createdAt","registerAgentToken","value","stringify","setEx","revokeAgentToken","statusCode","details","errorResponse","jsonrpc","code","id","writeHead","end","expiry","match","parseInt","unit","multipliers","s","m","h","d","setInterval","delete","getStats","stats","registeredAgents","configuredTools","rateLimitedClients","redisConnected","isOpen","activeTokens","shutdown","quit","module","exports"],"mappings":"AAAA;;;CAGC,GAED,MAAMA,SAASC,QAAQ;AACvB,MAAMC,QAAQD,QAAQ;AACtB,MAAME,KAAKF,QAAQ,MAAMG,QAAQ;AACjC,MAAMC,OAAOJ,QAAQ;AAErB,IAAA,AAAMK,oBAAN,MAAMA;IACJ,YAAYC,UAAU,CAAC,CAAC,CAAE;QACxB,IAAI,CAACC,KAAK,GAAG;QACb,IAAI,CAACD,OAAO,GAAG;YACb,0GAA0G;YAC1GE,UAAUF,QAAQE,QAAQ,I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AAO;YACdL,QAAQK,KAAK,CAAC,6BAA6BA;QAC7C;IACF;AACF;AAEAwH,OAAOC,OAAO,GAAGtJ"}
@@ -16,7 +16,8 @@ let AuthenticatedPlaywrightMCPServer = class AuthenticatedPlaywrightMCPServer {
16
16
  });
17
17
  // Initialize authentication middleware
18
18
  this.auth = new MCPAuthMiddleware({
19
- redisUrl: options.redisUrl || process.env.CFN_REDIS_URL || process.env.MCP_REDIS_URL || `redis://${process.env.CFN_REDIS_HOST || 'cfn-redis'}:${process.env.CFN_REDIS_PORT || 6379}`,
19
+ // FIX: Default to 'localhost' for host execution, Docker deployments should set CFN_REDIS_HOST explicitly
20
+ redisUrl: options.redisUrl || process.env.CFN_REDIS_URL || process.env.MCP_REDIS_URL || `redis://${process.env.CFN_REDIS_HOST || 'localhost'}:${process.env.CFN_REDIS_PORT || 6379}`,
20
21
  authRequired: options.authRequired !== false && process.env.MCP_AUTH_REQUIRED !== 'false',
21
22
  agentConfigPath: options.agentConfigPath || process.env.MCP_AGENT_CONFIG || './config/agent-whitelist.json',
22
23
  skillConfigPath: options.skillConfigPath || process.env.MCP_SKILL_CONFIG || './config/skill-requirements.json',