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.
- package/.claude/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
- package/.claude/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +1 -1
- package/.claude/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +1 -1
- package/.claude/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +1 -1
- package/.claude/cfn-extras/skills/google-sheets-progress/SKILL.md +1 -1
- package/.claude/commands/CFN_LOOP_FRONTEND.md +1 -1
- package/.claude/commands/cfn-loop-cli.md +214 -442
- package/.claude/commands/cfn-loop-frontend.md +1 -1
- package/.claude/commands/cfn-loop-task.md +2 -2
- package/.claude/commands/cfn-loop-trigger.md +114 -0
- package/.claude/commands/deprecated/cfn-loop.md +2 -2
- package/.claude/hooks/cfn-invoke-post-edit-ts.sh +100 -0
- package/.claude/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
- package/.claude/hooks/cfn-invoke-post-edit.sh +53 -5
- package/.claude/hooks/cfn-invoke-post-edit.sh.backup +87 -0
- package/.claude/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
- package/.claude/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
- package/.claude/hooks/cfn-invoke-pre-edit.sh +22 -0
- package/.claude/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
- package/.claude/hooks/cfn-post-edit.config.json +9 -2
- package/.claude/root-claude-distribute/CFN-CLAUDE.md +1 -1
- package/.claude/skills/cfn-agent-spawning/SKILL.md +48 -1
- package/.claude/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
- package/.claude/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
- package/.claude/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
- package/.claude/skills/{cfn-redis-coordination/check-dependencies.sh → cfn-agent-spawning/check-dependencies.sh.backup} +3 -5
- package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
- package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
- package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
- package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
- package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
- package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
- package/.claude/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
- package/.claude/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
- package/.claude/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
- package/.claude/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
- package/.claude/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
- package/.claude/skills/cfn-backlog-management/SKILL.md +1 -1
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
- package/.claude/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
- package/.claude/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
- package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
- package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
- package/.claude/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
- package/.claude/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
- package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
- package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
- package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
- package/.claude/skills/cfn-loop-orchestration/SKILL.md +159 -48
- package/.claude/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
- package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
- package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
- package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
- package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
- package/.claude/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
- package/.claude/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
- package/.claude/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
- package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
- package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
- package/.claude/skills/cfn-loop-orchestration/{orchestrate-wrapper.sh → archive/legacy-bash/orchestrate-wrapper.sh} +11 -1
- package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
- package/.claude/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
- package/.claude/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
- package/.claude/skills/cfn-loop-orchestration/package-lock.json +3 -0
- package/.claude/skills/cfn-loop-orchestration/package.json +4 -0
- package/.claude/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
- package/.claude/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
- package/.claude/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
- package/.claude/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
- package/.claude/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
- package/.claude/skills/cfn-loop-orchestration/src/index.ts +2 -0
- package/.claude/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
- package/.claude/skills/cfn-loop-orchestration/src/types.ts +56 -0
- package/.claude/skills/cfn-loop-orchestration/test-cli.sh +92 -0
- package/.claude/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
- package/.claude/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
- package/.claude/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
- package/.claude/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
- package/.claude/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
- package/.claude/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
- package/.claude/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
- package/.claude/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
- package/.claude/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
- package/.claude/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
- package/.claude/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
- package/.claude/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
- package/.claude/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
- package/.claude/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
- package/.claude/skills/cfn-loop-validation/INDEX.md +531 -0
- package/.claude/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
- package/.claude/skills/cfn-loop-validation/SKILL.md +48 -1
- package/.claude/skills/cfn-loop-validation/SKILL.md.backup +353 -0
- package/.claude/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
- package/.claude/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
- package/.claude/skills/cfn-loop-validation/check-dependencies.sh +22 -0
- package/{claude-assets/skills/cfn-redis-coordination/check-dependencies.sh → .claude/skills/cfn-loop-validation/check-dependencies.sh.backup} +4 -5
- package/.claude/skills/cfn-loop-validation/detect-vapor.sh +59 -0
- package/.claude/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
- package/.claude/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/types.d.ts +156 -0
- package/.claude/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/types.js +66 -0
- package/.claude/skills/cfn-loop-validation/dist/types.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
- package/.claude/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/validator.js +411 -0
- package/.claude/skills/cfn-loop-validation/dist/validator.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
- package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
- package/.claude/skills/cfn-loop-validation/package.json +93 -0
- package/.claude/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
- package/.claude/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
- package/.claude/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
- package/.claude/skills/cfn-loop-validation/src/types.ts +215 -0
- package/.claude/skills/cfn-loop-validation/src/validator.ts +503 -0
- package/.claude/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
- package/.claude/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
- package/.claude/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
- package/.claude/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
- package/.claude/skills/cfn-loop-validation/validate-gate.sh +63 -0
- package/.claude/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
- package/.claude/skills/cfn-loop-validation/validate-iteration.sh +22 -0
- package/.claude/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
- package/.claude/skills/cfn-product-owner-decision/SKILL.md +479 -147
- package/.claude/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
- package/.claude/skills/cfn-product-owner-decision/{execute-decision.sh → archive/legacy-bash/execute-decision.sh} +24 -2
- package/.claude/skills/pre-edit-backup/SKILL.md +324 -0
- package/.claude/skills/pre-edit-backup/SKILL.md.backup +277 -0
- package/.claude/skills/pre-edit-backup/backup.sh +22 -0
- package/.claude/skills/pre-edit-backup/backup.sh.backup +107 -0
- package/claude-assets/agents/cfn-dev-team/analysts/root-cause-analyst.md +2 -2
- package/claude-assets/agents/cfn-dev-team/architecture/base-template-generator.md +1 -1
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +3 -2
- package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +1 -0
- package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +2 -1
- package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +1 -0
- package/claude-assets/agents/cfn-dev-team/dev-ops/devops-engineer.md +11 -1
- package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +58 -35
- package/claude-assets/agents/cfn-dev-team/dev-ops/github-commit-agent.md +2 -2
- package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +47 -37
- package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +18 -18
- package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +40 -58
- package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +19 -21
- package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +20 -29
- package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +15 -19
- package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +15 -10
- package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +16 -11
- package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +16 -26
- package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +18 -22
- package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +17 -21
- package/claude-assets/agents/cfn-dev-team/documentation/pseudocode.md +1 -1
- package/claude-assets/agents/cfn-dev-team/product-owners/accessibility-advocate-persona.md +1 -1
- package/claude-assets/agents/cfn-dev-team/product-owners/cto-agent.md +1 -1
- package/claude-assets/agents/cfn-dev-team/product-owners/power-user-persona.md +1 -1
- package/claude-assets/agents/cfn-dev-team/product-owners/product-owner.md +1 -5
- package/claude-assets/agents/cfn-dev-team/reviewers/code-reviewer.md +20 -51
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +22 -71
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +21 -64
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +22 -67
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +24 -68
- package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +8 -36
- package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +9 -38
- package/claude-assets/agents/cfn-dev-team/testers/contract-tester.md +17 -55
- package/claude-assets/agents/cfn-dev-team/testers/e2e/playwright-tester.md +1 -1
- package/claude-assets/agents/cfn-dev-team/testers/integration-tester.md +18 -56
- package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +9 -37
- package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +18 -56
- package/claude-assets/agents/cfn-dev-team/testers/mutation-testing-specialist.md +18 -49
- package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +8 -37
- package/claude-assets/agents/cfn-dev-team/testers/tester.md +7 -27
- package/claude-assets/agents/cfn-dev-team/testers/unit/tdd-london-unit-swarm.md +1 -1
- package/claude-assets/agents/cfn-dev-team/utility/agent-builder.md +11 -0
- package/claude-assets/agents/cfn-dev-team/utility/analyst.md +13 -29
- package/claude-assets/agents/cfn-dev-team/utility/claude-code-expert.md +1 -1
- package/claude-assets/agents/cfn-dev-team/utility/code-booster.md +13 -13
- package/claude-assets/agents/cfn-dev-team/utility/context-curator.md +7 -2
- package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +6 -11
- package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +121 -715
- package/claude-assets/agents/cfn-dev-team/utility/researcher.md +13 -22
- package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +147 -573
- package/claude-assets/agents/custom/cfn-docker-expert.md +103 -0
- package/claude-assets/agents/custom/cfn-loops-cli-expert.md +438 -0
- package/claude-assets/agents/custom/cfn-redis-operations.md +529 -529
- package/claude-assets/agents/custom/cfn-system-expert.md +1 -1
- package/claude-assets/agents/custom/trigger-dev-expert.md +369 -0
- package/claude-assets/agents/docker-team/micro-sprint-planner.md +747 -747
- package/claude-assets/agents/project-only-agents/npm-package-specialist.md +1 -1
- package/claude-assets/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
- package/claude-assets/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +1 -1
- package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +1 -1
- package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +1 -1
- package/claude-assets/cfn-extras/skills/google-sheets-progress/SKILL.md +1 -1
- package/claude-assets/commands/CFN_LOOP_FRONTEND.md +1 -1
- package/claude-assets/commands/cfn-loop-cli.md +214 -442
- package/claude-assets/commands/cfn-loop-frontend.md +1 -1
- package/claude-assets/commands/cfn-loop-task.md +2 -2
- package/claude-assets/commands/cfn-loop-trigger.md +114 -0
- package/claude-assets/commands/deprecated/cfn-loop.md +2 -2
- package/claude-assets/hooks/GIT-HOOKS-USAGE-EXAMPLES.md +116 -0
- package/claude-assets/hooks/README-GIT-HOOKS.md +443 -0
- package/claude-assets/hooks/SKILL.md +518 -0
- package/claude-assets/hooks/SKILL.md.backup +471 -0
- package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh +100 -0
- package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
- package/claude-assets/hooks/cfn-invoke-post-edit.sh +53 -5
- package/claude-assets/hooks/cfn-invoke-post-edit.sh.backup +87 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit.sh +22 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
- package/claude-assets/hooks/cfn-post-edit.config.json +9 -2
- package/claude-assets/hooks/install-git-hooks.sh +243 -0
- package/claude-assets/hooks/subagent-start.sh +98 -0
- package/claude-assets/hooks/subagent-stop.sh +93 -0
- package/claude-assets/hooks/validators/credential-scanner.sh +172 -0
- package/claude-assets/root-claude-distribute/CFN-CLAUDE.md +1 -1
- package/claude-assets/skills/cfn-agent-selection-with-fallback/DELIVERABLES.md +409 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/IMPLEMENTATION_SUMMARY.md +396 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/INTEGRATION_GUIDE.md +308 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/QUICK_REFERENCE.md +239 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md +107 -1
- package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md.backup +302 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/TYPESCRIPT_MIGRATION.md +295 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.cjs +297 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.js +297 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.cjs +96 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.js +96 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh +45 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh.backup +23 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh +22 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh.backup +173 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.test.ts +357 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.ts +350 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/src/cli.ts +74 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh +22 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh.backup +71 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/tsconfig.json +18 -0
- package/claude-assets/skills/cfn-agent-spawning/SKILL.md +48 -1
- package/claude-assets/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
- package/claude-assets/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
- package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh.backup +30 -0
- package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
- package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
- package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
- package/claude-assets/skills/cfn-backlog-management/SKILL.md +1 -1
- package/claude-assets/skills/cfn-coordination/agent-completion.sh.backup +36 -0
- package/claude-assets/skills/cfn-coordination/coordination-signal.sh.backup +36 -0
- package/claude-assets/skills/cfn-coordination/coordination-wait.sh.backup +36 -0
- package/claude-assets/skills/cfn-dependency-ingestion/README.md +101 -0
- package/claude-assets/skills/cfn-dependency-ingestion/SKILL.md +397 -0
- package/claude-assets/skills/cfn-dependency-ingestion/build.sh +23 -0
- package/claude-assets/skills/cfn-dependency-ingestion/dist/ingest-dependencies.js +478 -0
- package/claude-assets/skills/cfn-dependency-ingestion/ingest-dependencies.sh +295 -0
- package/claude-assets/skills/cfn-dependency-ingestion/ingest.sh +237 -0
- package/claude-assets/skills/cfn-dependency-ingestion/manifests/cli-mode-dependencies.txt +73 -0
- package/claude-assets/skills/cfn-dependency-ingestion/manifests/shared-dependencies.txt +57 -0
- package/claude-assets/skills/cfn-dependency-ingestion/manifests/trigger-dev-dependencies.txt +82 -0
- package/claude-assets/skills/cfn-dependency-ingestion/manifests/trigger-mode-dependencies.txt +80 -0
- package/claude-assets/skills/cfn-dependency-ingestion/src/ingest-dependencies.ts +563 -0
- package/claude-assets/skills/cfn-environment-sanitization/sanitize-environment.sh +14 -4
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
- package/claude-assets/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
- package/claude-assets/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
- package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
- package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
- package/claude-assets/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
- package/claude-assets/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
- package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
- package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
- package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
- package/claude-assets/skills/cfn-loop-orchestration/SKILL.md +159 -48
- package/claude-assets/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
- package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
- package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
- package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
- package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
- package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
- package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
- package/claude-assets/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
- package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
- package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
- package/claude-assets/skills/cfn-loop-orchestration/{orchestrate-wrapper.sh → archive/legacy-bash/orchestrate-wrapper.sh} +11 -1
- package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
- package/claude-assets/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
- package/claude-assets/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
- package/claude-assets/skills/cfn-loop-orchestration/package-lock.json +3 -0
- package/claude-assets/skills/cfn-loop-orchestration/package.json +4 -0
- package/claude-assets/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/index.ts +2 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
- package/claude-assets/skills/cfn-loop-orchestration/src/types.ts +56 -0
- package/claude-assets/skills/cfn-loop-orchestration/test-cli.sh +92 -0
- package/claude-assets/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
- package/claude-assets/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
- package/claude-assets/skills/cfn-loop-output-processing/.eslintrc.json +33 -0
- package/claude-assets/skills/cfn-loop-output-processing/DELIVERY_SUMMARY.txt +462 -0
- package/claude-assets/skills/cfn-loop-output-processing/DEPRECATION_NOTICE.md +183 -0
- package/claude-assets/skills/cfn-loop-output-processing/EXAMPLES.md +609 -0
- package/claude-assets/skills/cfn-loop-output-processing/IMPLEMENTATION_SUMMARY.md +418 -0
- package/claude-assets/skills/cfn-loop-output-processing/INDEX.md +531 -0
- package/claude-assets/skills/cfn-loop-output-processing/MIGRATION.md +362 -0
- package/claude-assets/skills/cfn-loop-output-processing/README.md +114 -0
- package/claude-assets/skills/cfn-loop-output-processing/SKILL.md +633 -0
- package/{.claude/skills/cfn-docker-redis-coordination → claude-assets/skills/cfn-loop-output-processing}/jest.config.js +7 -15
- package/claude-assets/skills/cfn-loop-output-processing/package.json +50 -0
- package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop2.ts +195 -0
- package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop3.ts +157 -0
- package/claude-assets/skills/cfn-loop-output-processing/src/output-processor.ts +632 -0
- package/claude-assets/skills/cfn-loop-output-processing/tests/output-processor.test.ts +617 -0
- package/claude-assets/skills/{cfn-docker-redis-coordination → cfn-loop-output-processing}/tsconfig.json +16 -7
- package/claude-assets/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
- package/claude-assets/skills/cfn-loop-validation/INDEX.md +531 -0
- package/claude-assets/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
- package/claude-assets/skills/cfn-loop-validation/SKILL.md +48 -1
- package/claude-assets/skills/cfn-loop-validation/SKILL.md.backup +353 -0
- package/claude-assets/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
- package/claude-assets/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
- package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh +22 -0
- package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh.backup +31 -0
- package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh +59 -0
- package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
- package/claude-assets/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts +156 -0
- package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/types.js +66 -0
- package/claude-assets/skills/cfn-loop-validation/dist/types.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
- package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/validator.js +411 -0
- package/claude-assets/skills/cfn-loop-validation/dist/validator.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
- package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
- package/claude-assets/skills/cfn-loop-validation/package.json +93 -0
- package/claude-assets/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
- package/claude-assets/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
- package/claude-assets/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
- package/claude-assets/skills/cfn-loop-validation/src/types.ts +215 -0
- package/claude-assets/skills/cfn-loop-validation/src/validator.ts +503 -0
- package/claude-assets/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
- package/claude-assets/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
- package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
- package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
- package/claude-assets/skills/cfn-loop-validation/validate-gate.sh +63 -0
- package/claude-assets/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
- package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh +22 -0
- package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
- package/claude-assets/skills/cfn-product-owner-decision/SKILL.md +479 -147
- package/claude-assets/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
- package/claude-assets/skills/cfn-product-owner-decision/{execute-decision.sh → archive/legacy-bash/execute-decision.sh} +24 -2
- package/claude-assets/skills/cfn-provider-routing/README.md +129 -0
- package/claude-assets/skills/cfn-provider-routing/SKILL.md +215 -0
- package/claude-assets/skills/cfn-provider-routing/resolve-provider-model.ts +223 -0
- package/claude-assets/skills/docker-build/build.sh +1 -1
- package/claude-assets/skills/pre-edit-backup/SKILL.md +324 -0
- package/claude-assets/skills/pre-edit-backup/SKILL.md.backup +277 -0
- package/claude-assets/skills/pre-edit-backup/backup.sh +22 -0
- package/claude-assets/skills/pre-edit-backup/backup.sh.backup +107 -0
- package/dist/agent/skill-mcp-selector.js +2 -1
- package/dist/agent/skill-mcp-selector.js.map +1 -1
- package/dist/api/auth-endpoints.js +415 -0
- package/dist/api/auth-endpoints.js.map +1 -0
- package/dist/api/task-endpoints.js +562 -0
- package/dist/api/task-endpoints.js.map +1 -0
- package/dist/backend/server.js +418 -0
- package/dist/backend/server.js.map +1 -0
- package/dist/cfn-loop/product-owner/decision-parser.js +356 -0
- package/dist/cfn-loop/product-owner/decision-parser.js.map +1 -0
- package/dist/cfn-loop/product-owner/index.js +1 -0
- package/dist/cfn-loop/product-owner/index.js.map +1 -1
- package/dist/cli/agent-command.js +1 -1
- package/dist/cli/agent-command.js.map +1 -1
- package/dist/cli/agent-completion.js +273 -0
- package/dist/cli/agent-completion.js.map +1 -0
- package/dist/cli/agent-executor.js +470 -26
- package/dist/cli/agent-executor.js.map +1 -1
- package/dist/cli/agent-prompt-builder.js +83 -48
- package/dist/cli/agent-prompt-builder.js.map +1 -1
- package/dist/cli/agent-spawn.js +7 -4
- package/dist/cli/agent-spawn.js.map +1 -1
- package/dist/cli/agent-spawner.js +546 -0
- package/dist/cli/agent-spawner.js.map +1 -0
- package/dist/cli/agent-token-manager.js +2 -1
- package/dist/cli/agent-token-manager.js.map +1 -1
- package/dist/cli/anthropic-client.js +127 -14
- package/dist/cli/anthropic-client.js.map +1 -1
- package/dist/cli/cfn-context.js +2 -1
- package/dist/cli/cfn-context.js.map +1 -1
- package/dist/cli/cfn-metrics.js +2 -1
- package/dist/cli/cfn-metrics.js.map +1 -1
- package/dist/cli/cfn-redis.js +2 -1
- package/dist/cli/cfn-redis.js.map +1 -1
- package/dist/cli/cli-agent-context.js +2 -0
- package/dist/cli/cli-agent-context.js.map +1 -1
- package/dist/cli/config-manager.js +90 -356
- package/dist/cli/config-manager.js.map +1 -1
- package/dist/cli/conversation-fork-cleanup.js +2 -1
- package/dist/cli/conversation-fork-cleanup.js.map +1 -1
- package/dist/cli/conversation-fork.js +2 -1
- package/dist/cli/conversation-fork.js.map +1 -1
- package/dist/cli/coordination/agent-messaging.js +415 -0
- package/dist/cli/coordination/agent-messaging.js.map +1 -0
- package/dist/cli/coordination/wait-for-threshold.js +232 -0
- package/dist/cli/coordination/wait-for-threshold.js.map +1 -0
- package/dist/cli/index.js +11 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/iteration-history.js +2 -1
- package/dist/cli/iteration-history.js.map +1 -1
- package/dist/cli/parse-decision-cli.js +268 -0
- package/dist/cli/parse-decision-cli.js.map +1 -0
- package/dist/cli/post-edit-hook.js +83 -0
- package/dist/cli/post-edit-hook.js.map +1 -0
- package/dist/cli/pre-edit-hook.js +77 -0
- package/dist/cli/pre-edit-hook.js.map +1 -0
- package/dist/cli/process-lifecycle.js +5 -1
- package/dist/cli/process-lifecycle.js.map +1 -1
- package/dist/cli/spawn-agent-cli.js +244 -0
- package/dist/cli/spawn-agent-cli.js.map +1 -0
- package/dist/coordination/coordination-wrapper.js +383 -0
- package/dist/coordination/coordination-wrapper.js.map +1 -0
- package/dist/coordination/redis-waiting-mode.js +4 -0
- package/dist/coordination/redis-waiting-mode.js.map +1 -1
- package/dist/coordination/store-success-criteria.js +68 -0
- package/dist/coordination/store-success-criteria.js.map +1 -0
- package/dist/coordination/store-task-context.js +65 -0
- package/dist/coordination/store-task-context.js.map +1 -0
- package/dist/hooks/backup-manager.js +273 -0
- package/dist/hooks/backup-manager.js.map +1 -0
- package/dist/hooks/post-edit-validator.js +388 -0
- package/dist/hooks/post-edit-validator.js.map +1 -0
- package/dist/integration/index.js +19 -0
- package/dist/integration/index.js.map +1 -0
- package/dist/integration/task-mode-adapter.js +297 -0
- package/dist/integration/task-mode-adapter.js.map +1 -0
- package/dist/integration/trigger-dev-client.js +253 -0
- package/dist/integration/trigger-dev-client.js.map +1 -0
- package/dist/integration/trigger-dev-webhooks.js +362 -0
- package/dist/integration/trigger-dev-webhooks.js.map +1 -0
- package/dist/lib/artifact-registry.js +4 -0
- package/dist/lib/artifact-registry.js.map +1 -1
- package/dist/lib/connection-pool.js +390 -0
- package/dist/lib/connection-pool.js.map +1 -0
- package/dist/lib/environment-contract.js +258 -0
- package/dist/lib/environment-contract.js.map +1 -0
- package/dist/lib/path-validator.js +14 -5
- package/dist/lib/path-validator.js.map +1 -1
- package/dist/lib/query-optimizer.js +388 -0
- package/dist/lib/query-optimizer.js.map +1 -0
- package/dist/lib/redis-queue-manager.js +5 -1
- package/dist/lib/redis-queue-manager.js.map +1 -1
- package/dist/lib/result-cache.js +285 -0
- package/dist/lib/result-cache.js.map +1 -0
- package/dist/mcp/auth-middleware.js +2 -1
- package/dist/mcp/auth-middleware.js.map +1 -1
- package/dist/mcp/playwright-mcp-server-auth.js +2 -1
- package/dist/mcp/playwright-mcp-server-auth.js.map +1 -1
- package/dist/middleware/authentication.js +317 -0
- package/dist/middleware/authentication.js.map +1 -0
- package/dist/services/authentication.js +669 -0
- package/dist/services/authentication.js.map +1 -0
- package/dist/services/session-management.js +436 -0
- package/dist/services/session-management.js.map +1 -0
- package/dist/services/skill-deployment.js +8 -6
- package/dist/services/skill-deployment.js.map +1 -1
- package/dist/services/user-service.js +710 -0
- package/dist/services/user-service.js.map +1 -0
- package/dist/types/trigger-dev-events.d.js +10 -0
- package/dist/types/trigger-dev-events.d.js.map +1 -0
- package/docs/README.md +240 -0
- package/package.json +15 -4
- package/scripts/build-agent-image.sh +1 -1
- package/scripts/compare-workflow-performance.sh +556 -0
- package/scripts/cost-allocation-tracker.sh +632 -0
- package/scripts/docker-rebuild-all-agents.sh +2 -2
- package/scripts/migrate-to-optimized-workflows.sh +438 -0
- package/scripts/organize-docs.sh +338 -0
- package/scripts/reorganize-tests.sh +280 -0
- package/scripts/trigger-dev-setup.sh +279 -0
- package/tests/README.md +45 -0
- package/.claude/commands/cost-savings-status.md +0 -34
- package/.claude/commands/metrics-summary.md +0 -58
- package/.claude/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
- package/.claude/skills/cfn-docker-redis-coordination/README.md +0 -294
- package/.claude/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
- package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
- package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
- package/.claude/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
- package/.claude/skills/cfn-docker-redis-coordination/package.json +0 -40
- package/.claude/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
- package/.claude/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
- package/.claude/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
- package/.claude/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
- package/.claude/skills/cfn-docker-redis-coordination/tsconfig.json +0 -30
- package/.claude/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
- package/.claude/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
- package/.claude/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
- package/.claude/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
- package/.claude/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
- package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
- package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
- package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
- package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
- package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
- package/.claude/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
- package/.claude/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
- package/.claude/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
- package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
- package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
- package/.claude/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
- package/.claude/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
- package/.claude/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
- package/.claude/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
- package/.claude/skills/cfn-redis-coordination/config.json +0 -61
- package/.claude/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
- package/.claude/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
- package/.claude/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
- package/.claude/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
- package/.claude/skills/cfn-redis-coordination/jest.config.js +0 -23
- package/.claude/skills/cfn-redis-coordination/package-lock.json +0 -5272
- package/.claude/skills/cfn-redis-coordination/package.json +0 -45
- package/.claude/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
- package/.claude/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
- package/.claude/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
- package/.claude/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
- package/.claude/skills/cfn-redis-coordination/src/index.ts +0 -82
- package/.claude/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
- package/.claude/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
- package/.claude/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
- package/.claude/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
- package/.claude/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
- package/.claude/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
- package/.claude/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
- package/.claude/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
- package/.claude/skills/cfn-redis-coordination/src/types.ts +0 -235
- package/.claude/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
- package/.claude/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
- package/.claude/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
- package/.claude/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
- package/.claude/skills/cfn-redis-coordination/test-redis-check.js +0 -84
- package/.claude/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
- package/.claude/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
- package/.claude/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +0 -980
- package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +0 -759
- package/claude-assets/agents/custom/test-mcp-access.md +0 -24
- package/claude-assets/agents/typescript-specialist.md +0 -280
- package/claude-assets/commands/cost-savings-status.md +0 -34
- package/claude-assets/commands/metrics-summary.md +0 -58
- package/claude-assets/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
- package/claude-assets/skills/cfn-docker-redis-coordination/README.md +0 -294
- package/claude-assets/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
- package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
- package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
- package/claude-assets/skills/cfn-docker-redis-coordination/jest.config.js +0 -37
- package/claude-assets/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
- package/claude-assets/skills/cfn-docker-redis-coordination/package.json +0 -40
- package/claude-assets/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
- package/claude-assets/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
- package/claude-assets/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
- package/claude-assets/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
- package/claude-assets/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
- package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
- package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
- package/claude-assets/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
- package/claude-assets/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
- package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
- package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
- package/claude-assets/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
- package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
- package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
- package/claude-assets/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
- package/claude-assets/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
- package/claude-assets/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
- package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
- package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
- package/claude-assets/skills/cfn-redis-cleanup/cleanup-redis.sh +0 -130
- package/claude-assets/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
- package/claude-assets/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
- package/claude-assets/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
- package/claude-assets/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
- package/claude-assets/skills/cfn-redis-coordination/config.json +0 -61
- package/claude-assets/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
- package/claude-assets/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
- package/claude-assets/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
- package/claude-assets/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
- package/claude-assets/skills/cfn-redis-coordination/jest.config.js +0 -23
- package/claude-assets/skills/cfn-redis-coordination/package-lock.json +0 -5272
- package/claude-assets/skills/cfn-redis-coordination/package.json +0 -45
- package/claude-assets/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
- package/claude-assets/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
- package/claude-assets/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
- package/claude-assets/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
- package/claude-assets/skills/cfn-redis-coordination/src/index.ts +0 -82
- package/claude-assets/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
- package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
- package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
- package/claude-assets/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
- package/claude-assets/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
- package/claude-assets/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
- package/claude-assets/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
- package/claude-assets/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
- package/claude-assets/skills/cfn-redis-coordination/src/types.ts +0 -235
- package/claude-assets/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
- package/claude-assets/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
- package/claude-assets/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
- package/claude-assets/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
- package/claude-assets/skills/cfn-redis-coordination/test-redis-check.js +0 -84
- package/claude-assets/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
- package/claude-assets/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
- package/claude-assets/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
- package/claude-assets/skills/cfn-redis-data-extraction/SKILL.md +0 -442
- package/claude-assets/skills/cfn-redis-data-extraction/extract.sh +0 -306
- package/dist/coordination/index.js +0 -25
- package/dist/coordination/index.js.map +0 -1
- package/docs/BUG_19_MEMORY_LEAK_TASK_MODE.md +0 -405
- package/docs/MEMORY_CLEANUP_GUIDE.md +0 -358
- package/docs/MEMORY_LEAK_FIX_SUMMARY.md +0 -322
- package/docs/REDIS_CLEANUP_EXECUTIVE_SUMMARY.md +0 -319
- package/docs/REDIS_CLEANUP_VERIFICATION_REPORT.md +0 -574
- package/tests/test-memory-leak-task-mode.sh +0 -435
- /package/.claude/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
- /package/.claude/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
- /package/claude-assets/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mcp/playwright-mcp-server-auth.js"],"sourcesContent":["#!/usr/bin/env node\r\n\r\n/**\r\n * Enhanced Playwright MCP Server with Authentication\r\n * Includes token-based authentication and authorization\r\n */\r\n\r\nconst { chromium } = require('playwright');\r\nconst readline = require('readline');\r\nconst MCPAuthMiddleware = require('./auth-middleware.js');\r\n\r\nclass AuthenticatedPlaywrightMCPServer {\r\n constructor(options = {}) {\r\n this.browser = null;\r\n this.page = null;\r\n this.rl = readline.createInterface({\r\n input: process.stdin,\r\n output: process.stdout,\r\n terminal: false\r\n });\r\n\r\n // Initialize authentication middleware\r\n this.auth = new MCPAuthMiddleware({\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 authRequired: options.authRequired !== false && process.env.MCP_AUTH_REQUIRED !== 'false',\r\n agentConfigPath: options.agentConfigPath || process.env.MCP_AGENT_CONFIG || './config/agent-whitelist.json',\r\n skillConfigPath: options.skillConfigPath || process.env.MCP_SKILL_CONFIG || './config/skill-requirements.json',\r\n rateLimitMax: options.rateLimitMax || parseInt(process.env.MCP_RATE_LIMIT_MAX) || 60,\r\n rateLimitWindow: options.rateLimitWindow || parseInt(process.env.MCP_RATE_LIMIT_WINDOW) || 60\r\n });\r\n\r\n this.tools = {\r\n take_screenshot: {\r\n name: 'take_screenshot',\r\n description: 'Take a screenshot of a webpage (requires browser-automation, screenshot-capture skills)',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n url: { type: 'string', description: 'URL to capture' },\r\n filename: { type: 'string', description: 'Screenshot filename (optional)' },\r\n fullPage: { type: 'boolean', default: false, description: 'Capture full page' },\r\n waitTime: { type: 'number', default: 3000, description: 'Wait time before screenshot (ms)' }\r\n },\r\n required: ['url']\r\n },\r\n skillRequirements: ['browser-automation', 'screenshot-capture']\r\n },\r\n search_google: {\r\n name: 'search_google',\r\n description: 'Search Google and return results (requires browser-automation, web-search skills)',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n query: { type: 'string', description: 'Search query' },\r\n screenshot: { type: 'boolean', default: true, description: 'Take screenshot of results' },\r\n resultCount: { type: 'number', default: 5, description: 'Number of results to return' }\r\n },\r\n required: ['query']\r\n },\r\n skillRequirements: ['browser-automation', 'web-search']\r\n },\r\n navigate_and_interact: {\r\n name: 'navigate_and_interact',\r\n description: 'Navigate to a webpage and interact with elements (requires browser-automation, web-interaction skills)',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n url: { type: 'string', description: 'URL to navigate to' },\r\n actions: {\r\n type: 'array',\r\n description: 'Array of actions to perform',\r\n items: {\r\n type: 'object',\r\n properties: {\r\n type: { type: 'string', enum: ['click', 'fill', 'press', 'wait'] },\r\n selector: { type: 'string', description: 'CSS selector' },\r\n value: { type: 'string', description: 'Value for fill actions' },\r\n key: { type: 'string', description: 'Key for press actions' }\r\n }\r\n }\r\n },\r\n screenshot: { type: 'boolean', default: false }\r\n },\r\n required: ['url']\r\n },\r\n skillRequirements: ['browser-automation', 'web-interaction']\r\n }\r\n };\r\n\r\n this.stats = {\r\n totalRequests: 0,\r\n authorizedRequests: 0,\r\n rejectedRequests: 0,\r\n toolUsage: {},\r\n lastActivity: null\r\n };\r\n }\r\n\r\n async initialize() {\r\n try {\r\n // Initialize authentication\r\n await this.auth.initialize();\r\n console.error('[MCP-Server] Authentication middleware initialized');\r\n\r\n // Initialize Playwright browser\r\n await this.initBrowser();\r\n console.error('[MCP-Server] Playwright browser initialized');\r\n\r\n console.error('[MCP-Server] Authenticated Playwright MCP Server ready');\r\n } catch (error) {\r\n console.error('[MCP-Server] Failed to initialize:', error);\r\n process.exit(1);\r\n }\r\n }\r\n\r\n async initBrowser() {\r\n if (!this.browser) {\r\n this.browser = await chromium.launch({\r\n headless: true,\r\n args: [\r\n '--no-sandbox',\r\n '--disable-setuid-sandbox',\r\n '--disable-dev-shm-usage',\r\n '--disable-gpu'\r\n ]\r\n });\r\n this.page = await this.browser.newPage();\r\n }\r\n }\r\n\r\n async takeScreenshot(args, agentContext) {\r\n await this.initBrowser();\r\n\r\n console.error(`[MCP-Server] Taking screenshot for ${agentContext.agentType}`);\r\n\r\n await this.page.goto(args.url, {\r\n waitUntil: 'networkidle',\r\n timeout: 15000\r\n });\r\n\r\n if (args.waitTime > 0) {\r\n await this.page.waitForTimeout(args.waitTime);\r\n }\r\n\r\n const timestamp = new Date().toISOString().replace(/[:.]/g, '-');\r\n const filename = args.filename || `screenshot-${agentContext.agentType}-${timestamp}.png`;\r\n const filepath = `/app/screenshots/${filename}`;\r\n\r\n await this.page.screenshot({\r\n path: filepath,\r\n fullPage: args.fullPage || false\r\n });\r\n\r\n return {\r\n success: true,\r\n filename: filename,\r\n filepath: filepath,\r\n url: args.url,\r\n title: await this.page.title(),\r\n size: `${this.page.viewportSize()?.width || 1280}x${this.page.viewportSize()?.height || 720}`,\r\n capturedBy: agentContext.agentType,\r\n timestamp: new Date().toISOString()\r\n };\r\n }\r\n\r\n async searchGoogle(args, agentContext) {\r\n await this.initBrowser();\r\n\r\n console.error(`[MCP-Server] Google search for ${agentContext.agentType}: \"${args.query}\"`);\r\n\r\n await this.page.goto('https://www.google.com', {\r\n waitUntil: 'networkidle',\r\n timeout: 15000\r\n });\r\n\r\n // Handle cookies popup if present\r\n try {\r\n await this.page.waitForSelector('button[aria-label*=\"Accept\"], button[aria-label*=\"agree\"]', { timeout: 3000 });\r\n await this.page.click('button[aria-label*=\"Accept\"], button[aria-label*=\"agree\"]');\r\n await this.page.waitForTimeout(1000);\r\n } catch (e) {\r\n // No cookie popup, continue\r\n }\r\n\r\n // Perform search\r\n const searchBox = await this.page.waitForSelector('textarea[name=\"q\"], input[name=\"q\"]', { timeout: 10000 });\r\n await searchBox.fill(args.query);\r\n await searchBox.press('Enter');\r\n\r\n // Wait for results\r\n await this.page.waitForSelector('[role=\"main\"], #search', { timeout: 15000 });\r\n\r\n // Extract results\r\n const results = await this.page.$$eval('div[data-hveid] h3', elements =>\r\n elements.slice(0, args.resultCount || 5).map(el => el.textContent.trim())\r\n );\r\n\r\n let screenshotInfo = null;\r\n if (args.screenshot) {\r\n const timestamp = new Date().toISOString().replace(/[:.]/g, '-');\r\n const filename = `google-search-${args.query.toLowerCase().replace(/\\s+/g, '-')}-${timestamp}.png`;\r\n await this.page.screenshot({ path: `/app/screenshots/${filename}` });\r\n screenshotInfo = {\r\n filename,\r\n path: `/app/screenshots/${filename}`,\r\n url: this.page.url()\r\n };\r\n }\r\n\r\n return {\r\n success: true,\r\n query: args.query,\r\n results: results,\r\n resultCount: results.length,\r\n screenshot: screenshotInfo,\r\n url: this.page.url(),\r\n title: await this.page.title(),\r\n searchedBy: agentContext.agentType,\r\n timestamp: new Date().toISOString()\r\n };\r\n }\r\n\r\n async navigateAndInteract(args, agentContext) {\r\n await this.initBrowser();\r\n\r\n console.error(`[MCP-Server] Page interaction for ${agentContext.agentType}: ${args.url}`);\r\n\r\n await this.page.goto(args.url, {\r\n waitUntil: 'networkidle',\r\n timeout: 15000\r\n });\r\n\r\n const results = [];\r\n\r\n for (const action of args.actions || []) {\r\n try {\r\n switch (action.type) {\r\n case 'click':\r\n await this.page.waitForSelector(action.selector, { timeout: 5000 });\r\n await this.page.click(action.selector);\r\n results.push({ action: 'click', selector: action.selector, success: true });\r\n break;\r\n\r\n case 'fill':\r\n await this.page.waitForSelector(action.selector, { timeout: 5000 });\r\n await this.page.fill(action.selector, action.value);\r\n results.push({ action: 'fill', selector: action.selector, value: action.value, success: true });\r\n break;\r\n\r\n case 'press':\r\n await this.page.press(action.selector || 'body', action.key);\r\n results.push({ action: 'press', key: action.key, success: true });\r\n break;\r\n\r\n case 'wait':\r\n await this.page.waitForTimeout(parseInt(action.value) || 1000);\r\n results.push({ action: 'wait', duration: action.value, success: true });\r\n break;\r\n }\r\n } catch (error) {\r\n results.push({\r\n action: action.type,\r\n selector: action.selector,\r\n success: false,\r\n error: error.message\r\n });\r\n }\r\n }\r\n\r\n let screenshotInfo = null;\r\n if (args.screenshot) {\r\n const timestamp = new Date().toISOString().replace(/[:.]/g, '-');\r\n const filename = `interaction-${agentContext.agentType}-${timestamp}.png`;\r\n await this.page.screenshot({ path: `/app/screenshots/${filename}` });\r\n screenshotInfo = {\r\n filename,\r\n path: `/app/screenshots/${filename}`\r\n };\r\n }\r\n\r\n return {\r\n success: true,\r\n url: args.url,\r\n actions: results,\r\n screenshot: screenshotInfo,\r\n title: await this.page.title(),\r\n interactedBy: agentContext.agentType,\r\n timestamp: new Date().toISOString()\r\n };\r\n }\r\n\r\n async handleMessage(message) {\r\n try {\r\n this.stats.totalRequests++;\r\n this.stats.lastActivity = Date.now();\r\n\r\n // Initialize request context\r\n const request = {\r\n headers: {\r\n 'x-agent-token': message.params?.context?.agentToken,\r\n 'x-agent-type': message.params?.context?.agentType\r\n },\r\n body: message\r\n };\r\n\r\n const response = {\r\n writeHead: () => {},\r\n end: (data) => {\r\n // For JSON-RPC, we'll just return the data directly\r\n this.responseData = JSON.parse(data);\r\n }\r\n };\r\n\r\n // Authenticate request\r\n let authenticationPassed = false;\r\n await this.auth.authenticateRequest(request, response, () => {\r\n authenticationPassed = true;\r\n });\r\n\r\n if (!authenticationPassed) {\r\n this.stats.rejectedRequests++;\r\n return this.responseData || {\r\n jsonrpc: '2.0',\r\n id: message.id,\r\n error: {\r\n code: -32001,\r\n message: 'Authentication failed'\r\n }\r\n };\r\n }\r\n\r\n this.stats.authorizedRequests++;\r\n\r\n // Authentication passed, process request\r\n if (message.method === 'initialize') {\r\n return {\r\n jsonrpc: '2.0',\r\n id: message.id,\r\n result: {\r\n protocolVersion: '2024-11-05',\r\n capabilities: {\r\n tools: {}\r\n },\r\n serverInfo: {\r\n name: 'playwright-mcp-server-authenticated',\r\n version: '1.0.0',\r\n authentication: 'enabled'\r\n }\r\n }\r\n };\r\n } else if (message.method === 'tools/list') {\r\n return {\r\n jsonrpc: '2.0',\r\n id: message.id,\r\n result: { tools: Object.values(this.tools) }\r\n };\r\n } else if (message.method === 'tools/call') {\r\n const toolName = message.params.name;\r\n const args = message.params.arguments || {};\r\n const agentContext = request.agentContext || {\r\n agentType: 'unknown',\r\n authenticated: false\r\n };\r\n\r\n // Update tool usage stats\r\n this.stats.toolUsage[toolName] = (this.stats.toolUsage[toolName] || 0) + 1;\r\n\r\n let result;\r\n if (toolName === 'take_screenshot') {\r\n result = await this.takeScreenshot(args, agentContext);\r\n } else if (toolName === 'search_google') {\r\n result = await this.searchGoogle(args, agentContext);\r\n } else if (toolName === 'navigate_and_interact') {\r\n result = await this.navigateAndInteract(args, agentContext);\r\n } else {\r\n throw new Error(`Unknown tool: ${toolName}`);\r\n }\r\n\r\n console.error(`[MCP-Server] Tool ${toolName} executed by ${agentContext.agentType}`);\r\n\r\n return {\r\n jsonrpc: '2.0',\r\n id: message.id,\r\n result: {\r\n content: [{\r\n type: 'text',\r\n text: JSON.stringify(result, null, 2)\r\n }]\r\n }\r\n };\r\n }\r\n } catch (error) {\r\n console.error('[MCP-Server] Error handling message:', error);\r\n return {\r\n jsonrpc: '2.0',\r\n id: message.id || null,\r\n error: {\r\n code: -32000,\r\n message: error.message\r\n }\r\n };\r\n }\r\n }\r\n\r\n async start() {\r\n await this.initialize();\r\n\r\n this.rl.on('line', async (line) => {\r\n try {\r\n const message = JSON.parse(line);\r\n const response = await this.handleMessage(message);\r\n console.log(JSON.stringify(response));\r\n } catch (error) {\r\n console.log(JSON.stringify({\r\n jsonrpc: '2.0',\r\n id: null,\r\n error: {\r\n code: -32700,\r\n message: `Parse error: ${error.message}`\r\n }\r\n }));\r\n }\r\n });\r\n\r\n // Cleanup on exit\r\n process.on('SIGINT', async () => {\r\n console.error('[MCP-Server] Shutting down authenticated Playwright MCP Server...');\r\n await this.shutdown();\r\n process.exit(0);\r\n });\r\n\r\n // Log statistics periodically\r\n setInterval(() => {\r\n console.error(`[MCP-Server] Stats: ${this.stats.totalRequests} total, ${this.stats.authorizedRequests} authorized, ${this.stats.rejectedRequests} rejected`);\r\n console.error(`[MCP-Server] Tool usage:`, JSON.stringify(this.stats.toolUsage));\r\n }, 60000); // Every minute\r\n }\r\n\r\n async getStats() {\r\n const authStats = await this.auth.getStats();\r\n return {\r\n server: {\r\n name: 'playwright-mcp-server-authenticated',\r\n uptime: process.uptime(),\r\n ...this.stats\r\n },\r\n authentication: authStats\r\n };\r\n }\r\n\r\n async shutdown() {\r\n try {\r\n if (this.browser) await this.browser.close();\r\n if (this.rl) this.rl.close();\r\n if (this.auth) await this.auth.shutdown();\r\n console.error('[MCP-Server] Shutdown complete');\r\n } catch (error) {\r\n console.error('[MCP-Server] Error during shutdown:', error);\r\n }\r\n }\r\n}\r\n\r\n// Start the server\r\nconst server = new AuthenticatedPlaywrightMCPServer({\r\n redisUrl: process.env.MCP_REDIS_URL,\r\n authRequired: process.env.MCP_AUTH_REQUIRED !== 'false',\r\n rateLimitMax: parseInt(process.env.MCP_RATE_LIMIT_MAX) || 60\r\n});\r\n\r\nserver.start().catch(error => {\r\n console.error('[MCP-Server] Failed to start authenticated Playwright MCP Server:', error);\r\n process.exit(1);\r\n});"],"names":["chromium","require","readline","MCPAuthMiddleware","AuthenticatedPlaywrightMCPServer","options","browser","page","rl","createInterface","input","process","stdin","output","stdout","terminal","auth","redisUrl","env","CFN_REDIS_URL","MCP_REDIS_URL","CFN_REDIS_HOST","CFN_REDIS_PORT","authRequired","MCP_AUTH_REQUIRED","agentConfigPath","MCP_AGENT_CONFIG","skillConfigPath","MCP_SKILL_CONFIG","rateLimitMax","parseInt","MCP_RATE_LIMIT_MAX","rateLimitWindow","MCP_RATE_LIMIT_WINDOW","tools","take_screenshot","name","description","inputSchema","type","properties","url","filename","fullPage","default","waitTime","required","skillRequirements","search_google","query","screenshot","resultCount","navigate_and_interact","actions","items","enum","selector","value","key","stats","totalRequests","authorizedRequests","rejectedRequests","toolUsage","lastActivity","initialize","console","error","initBrowser","exit","launch","headless","args","newPage","takeScreenshot","agentContext","agentType","goto","waitUntil","timeout","waitForTimeout","timestamp","Date","toISOString","replace","filepath","path","success","title","size","viewportSize","width","height","capturedBy","searchGoogle","waitForSelector","click","e","searchBox","fill","press","results","$$eval","elements","slice","map","el","textContent","trim","screenshotInfo","toLowerCase","length","searchedBy","navigateAndInteract","action","push","duration","message","interactedBy","handleMessage","now","request","headers","params","context","agentToken","body","response","writeHead","end","data","responseData","JSON","parse","authenticationPassed","authenticateRequest","jsonrpc","id","code","method","result","protocolVersion","capabilities","serverInfo","version","authentication","Object","values","toolName","arguments","authenticated","Error","content","text","stringify","start","on","line","log","shutdown","setInterval","getStats","authStats","server","uptime","close","catch"],"mappings":";AAEA;;;CAGC,GAED,MAAM,EAAEA,QAAQ,EAAE,GAAGC,QAAQ;AAC7B,MAAMC,WAAWD,QAAQ;AACzB,MAAME,oBAAoBF,QAAQ;AAElC,IAAA,AAAMG,mCAAN,MAAMA;IACF,YAAYC,UAAU,CAAC,CAAC,CAAE;QACtB,IAAI,CAACC,OAAO,GAAG;QACf,IAAI,CAACC,IAAI,GAAG;QACZ,IAAI,CAACC,EAAE,GAA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AcC,SAASnB,QAAQO,GAAG,CAACa,kBAAkB,KAAK;AAC9D;AAEAoI,OAAOR,KAAK,GAAGW,KAAK,CAACnG,CAAAA;IACjBD,QAAQC,KAAK,CAAC,qEAAqEA;IACnFxD,QAAQ0D,IAAI,CAAC;AACjB"}
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/playwright-mcp-server-auth.js"],"sourcesContent":["#!/usr/bin/env node\r\n\r\n/**\r\n * Enhanced Playwright MCP Server with Authentication\r\n * Includes token-based authentication and authorization\r\n */\r\n\r\nconst { chromium } = require('playwright');\r\nconst readline = require('readline');\r\nconst MCPAuthMiddleware = require('./auth-middleware.js');\r\n\r\nclass AuthenticatedPlaywrightMCPServer {\r\n constructor(options = {}) {\r\n this.browser = null;\r\n this.page = null;\r\n this.rl = readline.createInterface({\r\n input: process.stdin,\r\n output: process.stdout,\r\n terminal: false\r\n });\r\n\r\n // Initialize authentication middleware\r\n this.auth = new MCPAuthMiddleware({\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 authRequired: options.authRequired !== false && process.env.MCP_AUTH_REQUIRED !== 'false',\r\n agentConfigPath: options.agentConfigPath || process.env.MCP_AGENT_CONFIG || './config/agent-whitelist.json',\r\n skillConfigPath: options.skillConfigPath || process.env.MCP_SKILL_CONFIG || './config/skill-requirements.json',\r\n rateLimitMax: options.rateLimitMax || parseInt(process.env.MCP_RATE_LIMIT_MAX) || 60,\r\n rateLimitWindow: options.rateLimitWindow || parseInt(process.env.MCP_RATE_LIMIT_WINDOW) || 60\r\n });\r\n\r\n this.tools = {\r\n take_screenshot: {\r\n name: 'take_screenshot',\r\n description: 'Take a screenshot of a webpage (requires browser-automation, screenshot-capture skills)',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n url: { type: 'string', description: 'URL to capture' },\r\n filename: { type: 'string', description: 'Screenshot filename (optional)' },\r\n fullPage: { type: 'boolean', default: false, description: 'Capture full page' },\r\n waitTime: { type: 'number', default: 3000, description: 'Wait time before screenshot (ms)' }\r\n },\r\n required: ['url']\r\n },\r\n skillRequirements: ['browser-automation', 'screenshot-capture']\r\n },\r\n search_google: {\r\n name: 'search_google',\r\n description: 'Search Google and return results (requires browser-automation, web-search skills)',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n query: { type: 'string', description: 'Search query' },\r\n screenshot: { type: 'boolean', default: true, description: 'Take screenshot of results' },\r\n resultCount: { type: 'number', default: 5, description: 'Number of results to return' }\r\n },\r\n required: ['query']\r\n },\r\n skillRequirements: ['browser-automation', 'web-search']\r\n },\r\n navigate_and_interact: {\r\n name: 'navigate_and_interact',\r\n description: 'Navigate to a webpage and interact with elements (requires browser-automation, web-interaction skills)',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n url: { type: 'string', description: 'URL to navigate to' },\r\n actions: {\r\n type: 'array',\r\n description: 'Array of actions to perform',\r\n items: {\r\n type: 'object',\r\n properties: {\r\n type: { type: 'string', enum: ['click', 'fill', 'press', 'wait'] },\r\n selector: { type: 'string', description: 'CSS selector' },\r\n value: { type: 'string', description: 'Value for fill actions' },\r\n key: { type: 'string', description: 'Key for press actions' }\r\n }\r\n }\r\n },\r\n screenshot: { type: 'boolean', default: false }\r\n },\r\n required: ['url']\r\n },\r\n skillRequirements: ['browser-automation', 'web-interaction']\r\n }\r\n };\r\n\r\n this.stats = {\r\n totalRequests: 0,\r\n authorizedRequests: 0,\r\n rejectedRequests: 0,\r\n toolUsage: {},\r\n lastActivity: null\r\n };\r\n }\r\n\r\n async initialize() {\r\n try {\r\n // Initialize authentication\r\n await this.auth.initialize();\r\n console.error('[MCP-Server] Authentication middleware initialized');\r\n\r\n // Initialize Playwright browser\r\n await this.initBrowser();\r\n console.error('[MCP-Server] Playwright browser initialized');\r\n\r\n console.error('[MCP-Server] Authenticated Playwright MCP Server ready');\r\n } catch (error) {\r\n console.error('[MCP-Server] Failed to initialize:', error);\r\n process.exit(1);\r\n }\r\n }\r\n\r\n async initBrowser() {\r\n if (!this.browser) {\r\n this.browser = await chromium.launch({\r\n headless: true,\r\n args: [\r\n '--no-sandbox',\r\n '--disable-setuid-sandbox',\r\n '--disable-dev-shm-usage',\r\n '--disable-gpu'\r\n ]\r\n });\r\n this.page = await this.browser.newPage();\r\n }\r\n }\r\n\r\n async takeScreenshot(args, agentContext) {\r\n await this.initBrowser();\r\n\r\n console.error(`[MCP-Server] Taking screenshot for ${agentContext.agentType}`);\r\n\r\n await this.page.goto(args.url, {\r\n waitUntil: 'networkidle',\r\n timeout: 15000\r\n });\r\n\r\n if (args.waitTime > 0) {\r\n await this.page.waitForTimeout(args.waitTime);\r\n }\r\n\r\n const timestamp = new Date().toISOString().replace(/[:.]/g, '-');\r\n const filename = args.filename || `screenshot-${agentContext.agentType}-${timestamp}.png`;\r\n const filepath = `/app/screenshots/${filename}`;\r\n\r\n await this.page.screenshot({\r\n path: filepath,\r\n fullPage: args.fullPage || false\r\n });\r\n\r\n return {\r\n success: true,\r\n filename: filename,\r\n filepath: filepath,\r\n url: args.url,\r\n title: await this.page.title(),\r\n size: `${this.page.viewportSize()?.width || 1280}x${this.page.viewportSize()?.height || 720}`,\r\n capturedBy: agentContext.agentType,\r\n timestamp: new Date().toISOString()\r\n };\r\n }\r\n\r\n async searchGoogle(args, agentContext) {\r\n await this.initBrowser();\r\n\r\n console.error(`[MCP-Server] Google search for ${agentContext.agentType}: \"${args.query}\"`);\r\n\r\n await this.page.goto('https://www.google.com', {\r\n waitUntil: 'networkidle',\r\n timeout: 15000\r\n });\r\n\r\n // Handle cookies popup if present\r\n try {\r\n await this.page.waitForSelector('button[aria-label*=\"Accept\"], button[aria-label*=\"agree\"]', { timeout: 3000 });\r\n await this.page.click('button[aria-label*=\"Accept\"], button[aria-label*=\"agree\"]');\r\n await this.page.waitForTimeout(1000);\r\n } catch (e) {\r\n // No cookie popup, continue\r\n }\r\n\r\n // Perform search\r\n const searchBox = await this.page.waitForSelector('textarea[name=\"q\"], input[name=\"q\"]', { timeout: 10000 });\r\n await searchBox.fill(args.query);\r\n await searchBox.press('Enter');\r\n\r\n // Wait for results\r\n await this.page.waitForSelector('[role=\"main\"], #search', { timeout: 15000 });\r\n\r\n // Extract results\r\n const results = await this.page.$$eval('div[data-hveid] h3', elements =>\r\n elements.slice(0, args.resultCount || 5).map(el => el.textContent.trim())\r\n );\r\n\r\n let screenshotInfo = null;\r\n if (args.screenshot) {\r\n const timestamp = new Date().toISOString().replace(/[:.]/g, '-');\r\n const filename = `google-search-${args.query.toLowerCase().replace(/\\s+/g, '-')}-${timestamp}.png`;\r\n await this.page.screenshot({ path: `/app/screenshots/${filename}` });\r\n screenshotInfo = {\r\n filename,\r\n path: `/app/screenshots/${filename}`,\r\n url: this.page.url()\r\n };\r\n }\r\n\r\n return {\r\n success: true,\r\n query: args.query,\r\n results: results,\r\n resultCount: results.length,\r\n screenshot: screenshotInfo,\r\n url: this.page.url(),\r\n title: await this.page.title(),\r\n searchedBy: agentContext.agentType,\r\n timestamp: new Date().toISOString()\r\n };\r\n }\r\n\r\n async navigateAndInteract(args, agentContext) {\r\n await this.initBrowser();\r\n\r\n console.error(`[MCP-Server] Page interaction for ${agentContext.agentType}: ${args.url}`);\r\n\r\n await this.page.goto(args.url, {\r\n waitUntil: 'networkidle',\r\n timeout: 15000\r\n });\r\n\r\n const results = [];\r\n\r\n for (const action of args.actions || []) {\r\n try {\r\n switch (action.type) {\r\n case 'click':\r\n await this.page.waitForSelector(action.selector, { timeout: 5000 });\r\n await this.page.click(action.selector);\r\n results.push({ action: 'click', selector: action.selector, success: true });\r\n break;\r\n\r\n case 'fill':\r\n await this.page.waitForSelector(action.selector, { timeout: 5000 });\r\n await this.page.fill(action.selector, action.value);\r\n results.push({ action: 'fill', selector: action.selector, value: action.value, success: true });\r\n break;\r\n\r\n case 'press':\r\n await this.page.press(action.selector || 'body', action.key);\r\n results.push({ action: 'press', key: action.key, success: true });\r\n break;\r\n\r\n case 'wait':\r\n await this.page.waitForTimeout(parseInt(action.value) || 1000);\r\n results.push({ action: 'wait', duration: action.value, success: true });\r\n break;\r\n }\r\n } catch (error) {\r\n results.push({\r\n action: action.type,\r\n selector: action.selector,\r\n success: false,\r\n error: error.message\r\n });\r\n }\r\n }\r\n\r\n let screenshotInfo = null;\r\n if (args.screenshot) {\r\n const timestamp = new Date().toISOString().replace(/[:.]/g, '-');\r\n const filename = `interaction-${agentContext.agentType}-${timestamp}.png`;\r\n await this.page.screenshot({ path: `/app/screenshots/${filename}` });\r\n screenshotInfo = {\r\n filename,\r\n path: `/app/screenshots/${filename}`\r\n };\r\n }\r\n\r\n return {\r\n success: true,\r\n url: args.url,\r\n actions: results,\r\n screenshot: screenshotInfo,\r\n title: await this.page.title(),\r\n interactedBy: agentContext.agentType,\r\n timestamp: new Date().toISOString()\r\n };\r\n }\r\n\r\n async handleMessage(message) {\r\n try {\r\n this.stats.totalRequests++;\r\n this.stats.lastActivity = Date.now();\r\n\r\n // Initialize request context\r\n const request = {\r\n headers: {\r\n 'x-agent-token': message.params?.context?.agentToken,\r\n 'x-agent-type': message.params?.context?.agentType\r\n },\r\n body: message\r\n };\r\n\r\n const response = {\r\n writeHead: () => {},\r\n end: (data) => {\r\n // For JSON-RPC, we'll just return the data directly\r\n this.responseData = JSON.parse(data);\r\n }\r\n };\r\n\r\n // Authenticate request\r\n let authenticationPassed = false;\r\n await this.auth.authenticateRequest(request, response, () => {\r\n authenticationPassed = true;\r\n });\r\n\r\n if (!authenticationPassed) {\r\n this.stats.rejectedRequests++;\r\n return this.responseData || {\r\n jsonrpc: '2.0',\r\n id: message.id,\r\n error: {\r\n code: -32001,\r\n message: 'Authentication failed'\r\n }\r\n };\r\n }\r\n\r\n this.stats.authorizedRequests++;\r\n\r\n // Authentication passed, process request\r\n if (message.method === 'initialize') {\r\n return {\r\n jsonrpc: '2.0',\r\n id: message.id,\r\n result: {\r\n protocolVersion: '2024-11-05',\r\n capabilities: {\r\n tools: {}\r\n },\r\n serverInfo: {\r\n name: 'playwright-mcp-server-authenticated',\r\n version: '1.0.0',\r\n authentication: 'enabled'\r\n }\r\n }\r\n };\r\n } else if (message.method === 'tools/list') {\r\n return {\r\n jsonrpc: '2.0',\r\n id: message.id,\r\n result: { tools: Object.values(this.tools) }\r\n };\r\n } else if (message.method === 'tools/call') {\r\n const toolName = message.params.name;\r\n const args = message.params.arguments || {};\r\n const agentContext = request.agentContext || {\r\n agentType: 'unknown',\r\n authenticated: false\r\n };\r\n\r\n // Update tool usage stats\r\n this.stats.toolUsage[toolName] = (this.stats.toolUsage[toolName] || 0) + 1;\r\n\r\n let result;\r\n if (toolName === 'take_screenshot') {\r\n result = await this.takeScreenshot(args, agentContext);\r\n } else if (toolName === 'search_google') {\r\n result = await this.searchGoogle(args, agentContext);\r\n } else if (toolName === 'navigate_and_interact') {\r\n result = await this.navigateAndInteract(args, agentContext);\r\n } else {\r\n throw new Error(`Unknown tool: ${toolName}`);\r\n }\r\n\r\n console.error(`[MCP-Server] Tool ${toolName} executed by ${agentContext.agentType}`);\r\n\r\n return {\r\n jsonrpc: '2.0',\r\n id: message.id,\r\n result: {\r\n content: [{\r\n type: 'text',\r\n text: JSON.stringify(result, null, 2)\r\n }]\r\n }\r\n };\r\n }\r\n } catch (error) {\r\n console.error('[MCP-Server] Error handling message:', error);\r\n return {\r\n jsonrpc: '2.0',\r\n id: message.id || null,\r\n error: {\r\n code: -32000,\r\n message: error.message\r\n }\r\n };\r\n }\r\n }\r\n\r\n async start() {\r\n await this.initialize();\r\n\r\n this.rl.on('line', async (line) => {\r\n try {\r\n const message = JSON.parse(line);\r\n const response = await this.handleMessage(message);\r\n console.log(JSON.stringify(response));\r\n } catch (error) {\r\n console.log(JSON.stringify({\r\n jsonrpc: '2.0',\r\n id: null,\r\n error: {\r\n code: -32700,\r\n message: `Parse error: ${error.message}`\r\n }\r\n }));\r\n }\r\n });\r\n\r\n // Cleanup on exit\r\n process.on('SIGINT', async () => {\r\n console.error('[MCP-Server] Shutting down authenticated Playwright MCP Server...');\r\n await this.shutdown();\r\n process.exit(0);\r\n });\r\n\r\n // Log statistics periodically\r\n setInterval(() => {\r\n console.error(`[MCP-Server] Stats: ${this.stats.totalRequests} total, ${this.stats.authorizedRequests} authorized, ${this.stats.rejectedRequests} rejected`);\r\n console.error(`[MCP-Server] Tool usage:`, JSON.stringify(this.stats.toolUsage));\r\n }, 60000); // Every minute\r\n }\r\n\r\n async getStats() {\r\n const authStats = await this.auth.getStats();\r\n return {\r\n server: {\r\n name: 'playwright-mcp-server-authenticated',\r\n uptime: process.uptime(),\r\n ...this.stats\r\n },\r\n authentication: authStats\r\n };\r\n }\r\n\r\n async shutdown() {\r\n try {\r\n if (this.browser) await this.browser.close();\r\n if (this.rl) this.rl.close();\r\n if (this.auth) await this.auth.shutdown();\r\n console.error('[MCP-Server] Shutdown complete');\r\n } catch (error) {\r\n console.error('[MCP-Server] Error during shutdown:', error);\r\n }\r\n }\r\n}\r\n\r\n// Start the server\r\nconst server = new AuthenticatedPlaywrightMCPServer({\r\n redisUrl: process.env.MCP_REDIS_URL,\r\n authRequired: process.env.MCP_AUTH_REQUIRED !== 'false',\r\n rateLimitMax: parseInt(process.env.MCP_RATE_LIMIT_MAX) || 60\r\n});\r\n\r\nserver.start().catch(error => {\r\n console.error('[MCP-Server] Failed to start authenticated Playwright MCP Server:', error);\r\n process.exit(1);\r\n});"],"names":["chromium","require","readline","MCPAuthMiddleware","AuthenticatedPlaywrightMCPServer","options","browser","page","rl","createInterface","input","process","stdin","output","stdout","terminal","auth","redisUrl","env","CFN_REDIS_URL","MCP_REDIS_URL","CFN_REDIS_HOST","CFN_REDIS_PORT","authRequired","MCP_AUTH_REQUIRED","agentConfigPath","MCP_AGENT_CONFIG","skillConfigPath","MCP_SKILL_CONFIG","rateLimitMax","parseInt","MCP_RATE_LIMIT_MAX","rateLimitWindow","MCP_RATE_LIMIT_WINDOW","tools","take_screenshot","name","description","inputSchema","type","properties","url","filename","fullPage","default","waitTime","required","skillRequirements","search_google","query","screenshot","resultCount","navigate_and_interact","actions","items","enum","selector","value","key","stats","totalRequests","authorizedRequests","rejectedRequests","toolUsage","lastActivity","initialize","console","error","initBrowser","exit","launch","headless","args","newPage","takeScreenshot","agentContext","agentType","goto","waitUntil","timeout","waitForTimeout","timestamp","Date","toISOString","replace","filepath","path","success","title","size","viewportSize","width","height","capturedBy","searchGoogle","waitForSelector","click","e","searchBox","fill","press","results","$$eval","elements","slice","map","el","textContent","trim","screenshotInfo","toLowerCase","length","searchedBy","navigateAndInteract","action","push","duration","message","interactedBy","handleMessage","now","request","headers","params","context","agentToken","body","response","writeHead","end","data","responseData","JSON","parse","authenticationPassed","authenticateRequest","jsonrpc","id","code","method","result","protocolVersion","capabilities","serverInfo","version","authentication","Object","values","toolName","arguments","authenticated","Error","content","text","stringify","start","on","line","log","shutdown","setInterval","getStats","authStats","server","uptime","close","catch"],"mappings":";AAEA;;;CAGC,GAED,MAAM,EAAEA,QAAQ,EAAE,GAAGC,QAAQ;AAC7B,MAAMC,WAAWD,QAAQ;AACzB,MAAME,oBAAoBF,QAAQ;AAElC,IAAA,AAAMG,mCAAN,MAAMA;IACF,YAAYC,UAAU,CAAC,CAAC,CAAE;QACtB,IAAI,CAACC,OAAO,GAAG;QACf,IAAI,CAACC,IAAI,GAAG;QACZ,IAAI,CAACC,EAAE,GAAGN,SAASO,eAAe,CAAC;YAC/BC,OAAOC,QAAQC,KAAK;YACpBC,QAAQF,QAAQG,MAAM;YACtBC,UAAU;QACd;QAEA,uCAAuC;QACvC,IAAI,CAACC,IAAI,GAAG,IAAIb,kBAAkB;YAC9B,0GAA0G;YAC1Gc,UAAUZ,QAAQY,QAAQ,IAAIN,QAAQO,GAAG,CAACC,aAAa,IAAIR,QAAQO,GAAG,CAACE,aAAa,IAAI,CAAC,QAAQ,EAAET,QAAQO,GAA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for Express.js
|
|
5
|
+
* with JWT token validation, role-based access control, and security features.
|
|
6
|
+
*/ import jwt from 'jsonwebtoken';
|
|
7
|
+
import bcrypt from 'bcrypt';
|
|
8
|
+
import { logger } from '../utils/logger.js';
|
|
9
|
+
import { StandardError, ErrorCode } from '../../lib/errors.js';
|
|
10
|
+
/**
|
|
11
|
+
* Authentication middleware that validates JWT tokens
|
|
12
|
+
*
|
|
13
|
+
* @param config Authentication configuration
|
|
14
|
+
* @returns Express middleware function
|
|
15
|
+
*/ export function authenticationMiddleware(config) {
|
|
16
|
+
return async (req, res, next)=>{
|
|
17
|
+
try {
|
|
18
|
+
// Check for authorization header
|
|
19
|
+
const authHeader = req.headers.authorization;
|
|
20
|
+
if (!authHeader) {
|
|
21
|
+
res.status(401).json({
|
|
22
|
+
error: 'Unauthorized',
|
|
23
|
+
message: 'No authorization header provided',
|
|
24
|
+
errorCode: 'AUTH_001'
|
|
25
|
+
});
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
// Validate authorization header format
|
|
29
|
+
if (!authHeader.startsWith('Bearer ')) {
|
|
30
|
+
res.status(401).json({
|
|
31
|
+
error: 'Unauthorized',
|
|
32
|
+
message: 'Invalid authorization header format',
|
|
33
|
+
errorCode: 'AUTH_003'
|
|
34
|
+
});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// Extract and sanitize token
|
|
38
|
+
const token = authHeader.slice(7).trim();
|
|
39
|
+
if (!token) {
|
|
40
|
+
res.status(401).json({
|
|
41
|
+
error: 'Unauthorized',
|
|
42
|
+
message: 'No token provided',
|
|
43
|
+
errorCode: 'AUTH_005'
|
|
44
|
+
});
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// Verify JWT token
|
|
48
|
+
let decoded;
|
|
49
|
+
try {
|
|
50
|
+
decoded = jwt.verify(token, config.jwtSecret);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
// Handle specific JWT errors
|
|
53
|
+
if (error instanceof jwt.TokenExpiredError) {
|
|
54
|
+
res.status(401).json({
|
|
55
|
+
error: 'Unauthorized',
|
|
56
|
+
message: 'Token has expired',
|
|
57
|
+
errorCode: 'AUTH_004'
|
|
58
|
+
});
|
|
59
|
+
return;
|
|
60
|
+
} else if (error instanceof jwt.JsonWebTokenError) {
|
|
61
|
+
res.status(401).json({
|
|
62
|
+
error: 'Unauthorized',
|
|
63
|
+
message: 'Invalid or expired token',
|
|
64
|
+
errorCode: 'AUTH_002'
|
|
65
|
+
});
|
|
66
|
+
return;
|
|
67
|
+
} else {
|
|
68
|
+
logger.error('Unexpected JWT verification error:', error);
|
|
69
|
+
res.status(401).json({
|
|
70
|
+
error: 'Unauthorized',
|
|
71
|
+
message: 'Token verification failed',
|
|
72
|
+
errorCode: 'AUTH_006'
|
|
73
|
+
});
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Attach user information to request
|
|
78
|
+
req.user = {
|
|
79
|
+
userId: decoded.userId,
|
|
80
|
+
email: decoded.email,
|
|
81
|
+
role: decoded.role,
|
|
82
|
+
iat: decoded.iat,
|
|
83
|
+
exp: decoded.exp
|
|
84
|
+
};
|
|
85
|
+
// Log successful authentication
|
|
86
|
+
logger.info(`User authenticated: ${decoded.userId} (${decoded.email})`, {
|
|
87
|
+
userId: decoded.userId,
|
|
88
|
+
role: decoded.role,
|
|
89
|
+
ip: req.ip,
|
|
90
|
+
userAgent: req.headers['user-agent']
|
|
91
|
+
});
|
|
92
|
+
next();
|
|
93
|
+
} catch (error) {
|
|
94
|
+
logger.error('Authentication middleware error:', error);
|
|
95
|
+
res.status(500).json({
|
|
96
|
+
error: 'Internal Server Error',
|
|
97
|
+
message: 'Authentication service unavailable',
|
|
98
|
+
errorCode: 'AUTH_500'
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Authorization middleware for role-based access control
|
|
105
|
+
*
|
|
106
|
+
* @param requiredRoles Array of roles that are allowed to access the resource
|
|
107
|
+
* @returns Express middleware function
|
|
108
|
+
*/ export function authorizationMiddleware(requiredRoles) {
|
|
109
|
+
return (req, res, next)=>{
|
|
110
|
+
try {
|
|
111
|
+
// Check if user is authenticated
|
|
112
|
+
if (!req.user) {
|
|
113
|
+
res.status(401).json({
|
|
114
|
+
error: 'Unauthorized',
|
|
115
|
+
message: 'User not authenticated'
|
|
116
|
+
});
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// Check if user has required role
|
|
120
|
+
if (!requiredRoles.includes(req.user.role)) {
|
|
121
|
+
res.status(403).json({
|
|
122
|
+
error: 'Forbidden',
|
|
123
|
+
message: 'Insufficient permissions',
|
|
124
|
+
requiredRoles,
|
|
125
|
+
userRole: req.user.role
|
|
126
|
+
});
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
// Log successful authorization
|
|
130
|
+
logger.info(`User authorized: ${req.user.userId} (${req.user.role})`, {
|
|
131
|
+
userId: req.user.userId,
|
|
132
|
+
role: req.user.role,
|
|
133
|
+
requiredRoles
|
|
134
|
+
});
|
|
135
|
+
next();
|
|
136
|
+
} catch (error) {
|
|
137
|
+
logger.error('Authorization middleware error:', error);
|
|
138
|
+
res.status(500).json({
|
|
139
|
+
error: 'Internal Server Error',
|
|
140
|
+
message: 'Authorization service unavailable'
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Password utilities for secure password handling
|
|
147
|
+
*/ export class PasswordUtils {
|
|
148
|
+
/**
|
|
149
|
+
* Hash a password using bcrypt
|
|
150
|
+
*
|
|
151
|
+
* @param password Plain text password
|
|
152
|
+
* @param rounds Number of bcrypt rounds (default 12)
|
|
153
|
+
* @returns Hashed password
|
|
154
|
+
*/ static async hashPassword(password, rounds = 12) {
|
|
155
|
+
try {
|
|
156
|
+
return await bcrypt.hash(password, rounds);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
logger.error('Password hashing error:', error);
|
|
159
|
+
throw new StandardError('Failed to hash password', ErrorCode.INTERNAL_ERROR);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Generate salt for password hashing
|
|
164
|
+
*
|
|
165
|
+
* @param rounds Number of bcrypt rounds (default 12)
|
|
166
|
+
* @returns Salt string
|
|
167
|
+
*/ static async generateSalt(rounds = 12) {
|
|
168
|
+
try {
|
|
169
|
+
return await bcrypt.genSalt(rounds);
|
|
170
|
+
} catch (error) {
|
|
171
|
+
logger.error('Salt generation error:', error);
|
|
172
|
+
throw new StandardError('Failed to generate salt', ErrorCode.INTERNAL_ERROR);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Compare a plain text password with a hash
|
|
177
|
+
*
|
|
178
|
+
* @param password Plain text password
|
|
179
|
+
* @param hash Hashed password
|
|
180
|
+
* @returns True if passwords match
|
|
181
|
+
*/ static async comparePassword(password, hash) {
|
|
182
|
+
try {
|
|
183
|
+
return await bcrypt.compare(password, hash);
|
|
184
|
+
} catch (error) {
|
|
185
|
+
logger.error('Password comparison error:', error);
|
|
186
|
+
throw new StandardError('Failed to compare passwords', ErrorCode.INTERNAL_ERROR);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Validate password strength
|
|
191
|
+
*
|
|
192
|
+
* @param password Password to validate
|
|
193
|
+
* @returns True if password meets strength requirements
|
|
194
|
+
*/ static validatePasswordStrength(password) {
|
|
195
|
+
// Minimum 8 characters, at least one uppercase, one lowercase, one number, and one special character
|
|
196
|
+
const minLength = 8;
|
|
197
|
+
const hasUpperCase = /[A-Z]/.test(password);
|
|
198
|
+
const hasLowerCase = /[a-z]/.test(password);
|
|
199
|
+
const hasNumbers = /\d/.test(password);
|
|
200
|
+
const hasSpecialChar = /[!@#$%^&*(),.?":{}|<>]/.test(password);
|
|
201
|
+
return password.length >= minLength && hasUpperCase && hasLowerCase && hasNumbers && hasSpecialChar;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* JWT utilities for token management
|
|
206
|
+
*/ export class JWTUtils {
|
|
207
|
+
/**
|
|
208
|
+
* Generate a JWT token
|
|
209
|
+
*
|
|
210
|
+
* @param payload Token payload
|
|
211
|
+
* @param secret JWT secret
|
|
212
|
+
* @param expiresIn Token expiration time
|
|
213
|
+
* @returns JWT token
|
|
214
|
+
*/ static generateToken(payload, secret, expiresIn = '24h') {
|
|
215
|
+
try {
|
|
216
|
+
return jwt.sign(payload, secret, {
|
|
217
|
+
expiresIn
|
|
218
|
+
});
|
|
219
|
+
} catch (error) {
|
|
220
|
+
logger.error('Token generation error:', error);
|
|
221
|
+
throw new StandardError('Failed to generate token', ErrorCode.INTERNAL_ERROR);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Verify a JWT token
|
|
226
|
+
*
|
|
227
|
+
* @param token JWT token
|
|
228
|
+
* @param secret JWT secret
|
|
229
|
+
* @returns Decoded payload
|
|
230
|
+
*/ static verifyToken(token, secret) {
|
|
231
|
+
try {
|
|
232
|
+
return jwt.verify(token, secret);
|
|
233
|
+
} catch (error) {
|
|
234
|
+
if (error instanceof jwt.TokenExpiredError) {
|
|
235
|
+
throw new StandardError('Token has expired', ErrorCode.TOKEN_EXPIRED);
|
|
236
|
+
} else if (error instanceof jwt.JsonWebTokenError) {
|
|
237
|
+
throw new StandardError('Invalid token', ErrorCode.INVALID_TOKEN);
|
|
238
|
+
} else {
|
|
239
|
+
throw new StandardError('Token verification failed', ErrorCode.INTERNAL_ERROR);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Decode a JWT token without verification (for debugging)
|
|
245
|
+
*
|
|
246
|
+
* @param token JWT token
|
|
247
|
+
* @returns Decoded payload
|
|
248
|
+
*/ static decodeToken(token) {
|
|
249
|
+
try {
|
|
250
|
+
return jwt.decode(token);
|
|
251
|
+
} catch (error) {
|
|
252
|
+
logger.error('Token decoding error:', error);
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Rate limiting utilities for authentication endpoints
|
|
259
|
+
*/ export class AuthRateLimit {
|
|
260
|
+
static attempts = new Map();
|
|
261
|
+
/**
|
|
262
|
+
* Check if user has exceeded login attempts
|
|
263
|
+
*
|
|
264
|
+
* @param identifier User identifier (email, IP, etc.)
|
|
265
|
+
* @param maxAttempts Maximum allowed attempts
|
|
266
|
+
* @param windowMs Time window in milliseconds
|
|
267
|
+
* @returns True if attempts exceeded
|
|
268
|
+
*/ static hasExceededAttempts(identifier, maxAttempts = 5, windowMs = 15 * 60 * 1000 // 15 minutes
|
|
269
|
+
) {
|
|
270
|
+
const now = Date.now();
|
|
271
|
+
const attempts = this.attempts.get(identifier);
|
|
272
|
+
if (!attempts) {
|
|
273
|
+
this.attempts.set(identifier, {
|
|
274
|
+
count: 1,
|
|
275
|
+
lastAttempt: now
|
|
276
|
+
});
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
// Reset if window has expired
|
|
280
|
+
if (now - attempts.lastAttempt > windowMs) {
|
|
281
|
+
this.attempts.set(identifier, {
|
|
282
|
+
count: 1,
|
|
283
|
+
lastAttempt: now
|
|
284
|
+
});
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
// Increment attempts
|
|
288
|
+
attempts.count++;
|
|
289
|
+
attempts.lastAttempt = now;
|
|
290
|
+
// Check if exceeded
|
|
291
|
+
if (attempts.count > maxAttempts) {
|
|
292
|
+
logger.warn(`Login attempts exceeded for ${identifier}`, {
|
|
293
|
+
identifier,
|
|
294
|
+
attempts: attempts.count,
|
|
295
|
+
windowMs
|
|
296
|
+
});
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Clear failed attempts for a user
|
|
303
|
+
*
|
|
304
|
+
* @param identifier User identifier
|
|
305
|
+
*/ static clearAttempts(identifier) {
|
|
306
|
+
this.attempts.delete(identifier);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
export default {
|
|
310
|
+
authenticationMiddleware,
|
|
311
|
+
authorizationMiddleware,
|
|
312
|
+
PasswordUtils,
|
|
313
|
+
JWTUtils,
|
|
314
|
+
AuthRateLimit
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
//# sourceMappingURL=authentication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/middleware/authentication.ts"],"sourcesContent":["/**\r\n * Authentication Middleware\r\n * \r\n * Comprehensive authentication and authorization middleware for Express.js\r\n * with JWT token validation, role-based access control, and security features.\r\n */\r\n\r\nimport { Request, Response, NextFunction } from 'express';\r\nimport jwt from 'jsonwebtoken';\r\nimport bcrypt from 'bcrypt';\r\nimport { logger } from '../utils/logger.js';\r\nimport { StandardError, ErrorCode } from '../../lib/errors.js';\r\n\r\n// Extend Express Request type to include user\r\ndeclare global {\r\n namespace Express {\r\n interface Request {\r\n user?: {\r\n userId: string;\r\n email: string;\r\n role: string;\r\n iat?: number;\r\n exp?: number;\r\n };\r\n }\r\n }\r\n}\r\n\r\nexport interface AuthConfig {\r\n jwtSecret: string;\r\n jwtExpiration: string;\r\n bcryptRounds: number;\r\n}\r\n\r\nexport interface JWTPayload {\r\n userId: string;\r\n email: string;\r\n role: string;\r\n iat?: number;\r\n exp?: number;\r\n}\r\n\r\n/**\r\n * Authentication middleware that validates JWT tokens\r\n * \r\n * @param config Authentication configuration\r\n * @returns Express middleware function\r\n */\r\nexport function authenticationMiddleware(config: AuthConfig) {\r\n return async (req: Request, res: Response, next: NextFunction): Promise<void> => {\r\n try {\r\n // Check for authorization header\r\n const authHeader = req.headers.authorization;\r\n if (!authHeader) {\r\n res.status(401).json({\r\n error: 'Unauthorized',\r\n message: 'No authorization header provided',\r\n errorCode: 'AUTH_001',\r\n });\r\n return;\r\n }\r\n\r\n // Validate authorization header format\r\n if (!authHeader.startsWith('Bearer ')) {\r\n res.status(401).json({\r\n error: 'Unauthorized',\r\n message: 'Invalid authorization header format',\r\n errorCode: 'AUTH_003',\r\n });\r\n return;\r\n }\r\n\r\n // Extract and sanitize token\r\n const token = authHeader.slice(7).trim();\r\n if (!token) {\r\n res.status(401).json({\r\n error: 'Unauthorized',\r\n message: 'No token provided',\r\n errorCode: 'AUTH_005',\r\n });\r\n return;\r\n }\r\n\r\n // Verify JWT token\r\n let decoded: JWTPayload;\r\n try {\r\n decoded = jwt.verify(token, config.jwtSecret) as JWTPayload;\r\n } catch (error) {\r\n // Handle specific JWT errors\r\n if (error instanceof jwt.TokenExpiredError) {\r\n res.status(401).json({\r\n error: 'Unauthorized',\r\n message: 'Token has expired',\r\n errorCode: 'AUTH_004',\r\n });\r\n return;\r\n } else if (error instanceof jwt.JsonWebTokenError) {\r\n res.status(401).json({\r\n error: 'Unauthorized',\r\n message: 'Invalid or expired token',\r\n errorCode: 'AUTH_002',\r\n });\r\n return;\r\n } else {\r\n logger.error('Unexpected JWT verification error:', error);\r\n res.status(401).json({\r\n error: 'Unauthorized',\r\n message: 'Token verification failed',\r\n errorCode: 'AUTH_006',\r\n });\r\n return;\r\n }\r\n }\r\n\r\n // Attach user information to request\r\n req.user = {\r\n userId: decoded.userId,\r\n email: decoded.email,\r\n role: decoded.role,\r\n iat: decoded.iat,\r\n exp: decoded.exp,\r\n };\r\n\r\n // Log successful authentication\r\n logger.info(`User authenticated: ${decoded.userId} (${decoded.email})`, {\r\n userId: decoded.userId,\r\n role: decoded.role,\r\n ip: req.ip,\r\n userAgent: req.headers['user-agent'],\r\n });\r\n\r\n next();\r\n } catch (error) {\r\n logger.error('Authentication middleware error:', error);\r\n res.status(500).json({\r\n error: 'Internal Server Error',\r\n message: 'Authentication service unavailable',\r\n errorCode: 'AUTH_500',\r\n });\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Authorization middleware for role-based access control\r\n * \r\n * @param requiredRoles Array of roles that are allowed to access the resource\r\n * @returns Express middleware function\r\n */\r\nexport function authorizationMiddleware(requiredRoles: string[]) {\r\n return (req: Request, res: Response, next: NextFunction): void => {\r\n try {\r\n // Check if user is authenticated\r\n if (!req.user) {\r\n res.status(401).json({\r\n error: 'Unauthorized',\r\n message: 'User not authenticated',\r\n });\r\n return;\r\n }\r\n\r\n // Check if user has required role\r\n if (!requiredRoles.includes(req.user.role)) {\r\n res.status(403).json({\r\n error: 'Forbidden',\r\n message: 'Insufficient permissions',\r\n requiredRoles,\r\n userRole: req.user.role,\r\n });\r\n return;\r\n }\r\n\r\n // Log successful authorization\r\n logger.info(`User authorized: ${req.user.userId} (${req.user.role})`, {\r\n userId: req.user.userId,\r\n role: req.user.role,\r\n requiredRoles,\r\n });\r\n\r\n next();\r\n } catch (error) {\r\n logger.error('Authorization middleware error:', error);\r\n res.status(500).json({\r\n error: 'Internal Server Error',\r\n message: 'Authorization service unavailable',\r\n });\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Password utilities for secure password handling\r\n */\r\nexport class PasswordUtils {\r\n /**\r\n * Hash a password using bcrypt\r\n * \r\n * @param password Plain text password\r\n * @param rounds Number of bcrypt rounds (default 12)\r\n * @returns Hashed password\r\n */\r\n static async hashPassword(password: string, rounds: number = 12): Promise<string> {\r\n try {\r\n return await bcrypt.hash(password, rounds);\r\n } catch (error) {\r\n logger.error('Password hashing error:', error);\r\n throw new StandardError('Failed to hash password', ErrorCode.INTERNAL_ERROR);\r\n }\r\n }\r\n\r\n /**\r\n * Generate salt for password hashing\r\n * \r\n * @param rounds Number of bcrypt rounds (default 12)\r\n * @returns Salt string\r\n */\r\n static async generateSalt(rounds: number = 12): Promise<string> {\r\n try {\r\n return await bcrypt.genSalt(rounds);\r\n } catch (error) {\r\n logger.error('Salt generation error:', error);\r\n throw new StandardError('Failed to generate salt', ErrorCode.INTERNAL_ERROR);\r\n }\r\n }\r\n\r\n /**\r\n * Compare a plain text password with a hash\r\n * \r\n * @param password Plain text password\r\n * @param hash Hashed password\r\n * @returns True if passwords match\r\n */\r\n static async comparePassword(password: string, hash: string): Promise<boolean> {\r\n try {\r\n return await bcrypt.compare(password, hash);\r\n } catch (error) {\r\n logger.error('Password comparison error:', error);\r\n throw new StandardError('Failed to compare passwords', ErrorCode.INTERNAL_ERROR);\r\n }\r\n }\r\n\r\n /**\r\n * Validate password strength\r\n * \r\n * @param password Password to validate\r\n * @returns True if password meets strength requirements\r\n */\r\n static validatePasswordStrength(password: string): boolean {\r\n // Minimum 8 characters, at least one uppercase, one lowercase, one number, and one special character\r\n const minLength = 8;\r\n const hasUpperCase = /[A-Z]/.test(password);\r\n const hasLowerCase = /[a-z]/.test(password);\r\n const hasNumbers = /\\d/.test(password);\r\n const hasSpecialChar = /[!@#$%^&*(),.?\":{}|<>]/.test(password);\r\n\r\n return (\r\n password.length >= minLength &&\r\n hasUpperCase &&\r\n hasLowerCase &&\r\n hasNumbers &&\r\n hasSpecialChar\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * JWT utilities for token management\r\n */\r\nexport class JWTUtils {\r\n /**\r\n * Generate a JWT token\r\n * \r\n * @param payload Token payload\r\n * @param secret JWT secret\r\n * @param expiresIn Token expiration time\r\n * @returns JWT token\r\n */\r\n static generateToken(\r\n payload: Omit<JWTPayload, 'iat' | 'exp'>,\r\n secret: string,\r\n expiresIn: string = '24h'\r\n ): string {\r\n try {\r\n return jwt.sign(payload, secret, { expiresIn });\r\n } catch (error) {\r\n logger.error('Token generation error:', error);\r\n throw new StandardError('Failed to generate token', ErrorCode.INTERNAL_ERROR);\r\n }\r\n }\r\n\r\n /**\r\n * Verify a JWT token\r\n * \r\n * @param token JWT token\r\n * @param secret JWT secret\r\n * @returns Decoded payload\r\n */\r\n static verifyToken(token: string, secret: string): JWTPayload {\r\n try {\r\n return jwt.verify(token, secret) as JWTPayload;\r\n } catch (error) {\r\n if (error instanceof jwt.TokenExpiredError) {\r\n throw new StandardError('Token has expired', ErrorCode.TOKEN_EXPIRED);\r\n } else if (error instanceof jwt.JsonWebTokenError) {\r\n throw new StandardError('Invalid token', ErrorCode.INVALID_TOKEN);\r\n } else {\r\n throw new StandardError('Token verification failed', ErrorCode.INTERNAL_ERROR);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Decode a JWT token without verification (for debugging)\r\n * \r\n * @param token JWT token\r\n * @returns Decoded payload\r\n */\r\n static decodeToken(token: string): JWTPayload | null {\r\n try {\r\n return jwt.decode(token) as JWTPayload;\r\n } catch (error) {\r\n logger.error('Token decoding error:', error);\r\n return null;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Rate limiting utilities for authentication endpoints\r\n */\r\nexport class AuthRateLimit {\r\n private static attempts = new Map<string, { count: number; lastAttempt: number }>();\r\n\r\n /**\r\n * Check if user has exceeded login attempts\r\n * \r\n * @param identifier User identifier (email, IP, etc.)\r\n * @param maxAttempts Maximum allowed attempts\r\n * @param windowMs Time window in milliseconds\r\n * @returns True if attempts exceeded\r\n */\r\n static hasExceededAttempts(\r\n identifier: string,\r\n maxAttempts: number = 5,\r\n windowMs: number = 15 * 60 * 1000 // 15 minutes\r\n ): boolean {\r\n const now = Date.now();\r\n const attempts = this.attempts.get(identifier);\r\n\r\n if (!attempts) {\r\n this.attempts.set(identifier, { count: 1, lastAttempt: now });\r\n return false;\r\n }\r\n\r\n // Reset if window has expired\r\n if (now - attempts.lastAttempt > windowMs) {\r\n this.attempts.set(identifier, { count: 1, lastAttempt: now });\r\n return false;\r\n }\r\n\r\n // Increment attempts\r\n attempts.count++;\r\n attempts.lastAttempt = now;\r\n\r\n // Check if exceeded\r\n if (attempts.count > maxAttempts) {\r\n logger.warn(`Login attempts exceeded for ${identifier}`, {\r\n identifier,\r\n attempts: attempts.count,\r\n windowMs,\r\n });\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Clear failed attempts for a user\r\n * \r\n * @param identifier User identifier\r\n */\r\n static clearAttempts(identifier: string): void {\r\n this.attempts.delete(identifier);\r\n }\r\n}\r\n\r\nexport default {\r\n authenticationMiddleware,\r\n authorizationMiddleware,\r\n PasswordUtils,\r\n JWTUtils,\r\n AuthRateLimit,\r\n};"],"names":["jwt","bcrypt","logger","StandardError","ErrorCode","authenticationMiddleware","config","req","res","next","authHeader","headers","authorization","status","json","error","message","errorCode","startsWith","token","slice","trim","decoded","verify","jwtSecret","TokenExpiredError","JsonWebTokenError","user","userId","email","role","iat","exp","info","ip","userAgent","authorizationMiddleware","requiredRoles","includes","userRole","PasswordUtils","hashPassword","password","rounds","hash","INTERNAL_ERROR","generateSalt","genSalt","comparePassword","compare","validatePasswordStrength","minLength","hasUpperCase","test","hasLowerCase","hasNumbers","hasSpecialChar","length","JWTUtils","generateToken","payload","secret","expiresIn","sign","verifyToken","TOKEN_EXPIRED","INVALID_TOKEN","decodeToken","decode","AuthRateLimit","attempts","Map","hasExceededAttempts","identifier","maxAttempts","windowMs","now","Date","get","set","count","lastAttempt","warn","clearAttempts","delete"],"mappings":"AAAA;;;;;CAKC,GAGD,OAAOA,SAAS,eAAe;AAC/B,OAAOC,YAAY,SAAS;AAC5B,SAASC,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,aAAa,EAAEC,SAAS,QAAQ,sBAAsB;AA+B/D;;;;;CAKC,GACD,OAAO,SAASC,yBAAyBC,MAAkB;IACzD,OAAO,OAAOC,KAAcC,KAAeC;QACzC,IAAI;YACF,iCAAiC;YACjC,MAAMC,aAAaH,IAAII,OAAO,CAACC,aAAa;YAC5C,IAAI,CAACF,YAAY;gBACfF,IAAIK,MAAM,CAAC,KAAKC,IAAI,CAAC;oBACnBC,OAAO;oBACPC,SAAS;oBACTC,WAAW;gBACb;gBACA;YACF;YAEA,uCAAuC;YACvC,IAAI,CAACP,WAAWQ,UAAU,CAAC,YAAY;gBACrCV,IAAIK,MAAM,CAAC,KAAKC,IAAI,CAAC;oBACnBC,OAAO;oBACPC,SAAS;oBACT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