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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cli/agent-spawner.ts"],"sourcesContent":["/**\r\n * Agent Spawner Module\r\n *\r\n * High-level API for spawning agents with full type safety,\r\n * environment variable handling, provider configuration parsing,\r\n * and Redis coordination integration.\r\n *\r\n * Usage:\r\n * const spawner = new AgentSpawner();\r\n * const result = await spawner.spawnAgent({\r\n * agentType: 'backend-developer',\r\n * taskId: 'task-123',\r\n * iteration: 1,\r\n * mode: 'standard'\r\n * });\r\n */\r\n\r\nimport { existsSync, readFileSync } from 'fs';\r\nimport { resolve, join } from 'path';\r\nimport { execFileSync, spawn as childSpawn } from 'child_process';\r\nimport { v4 as uuidv4 } from 'uuid';\r\nimport { generateTaskId } from './spawn-agent-cli';\r\nimport { getEnvValue, getNetworkName } from '../lib/environment-contract';\r\n\r\n/**\r\n * Configuration for spawning an agent\r\n */\r\ninterface SpawnAgentConfig {\r\n agentType: string;\r\n taskId: string;\r\n iteration: number;\r\n mode: 'mvp' | 'standard' | 'enterprise';\r\n provider?: string;\r\n model?: string;\r\n prompt?: string;\r\n env?: Record<string, string>;\r\n background?: boolean;\r\n timeout?: number;\r\n}\r\n\r\n/**\r\n * Result of agent spawning operation\r\n */\r\ninterface SpawnResult {\r\n agentId: string;\r\n pid: number;\r\n status: 'spawned' | 'running' | 'failed';\r\n timestamp: string;\r\n error?: string;\r\n metadata?: Record<string, unknown>;\r\n}\r\n\r\n/**\r\n * Provider configuration parsed from agent profile\r\n */\r\ninterface ProviderConfig {\r\n provider: string;\r\n model: string;\r\n baseUrl?: string;\r\n}\r\n\r\n/**\r\n * Worker spawning configuration\r\n */\r\ninterface SpawnWorkerConfig {\r\n team: string;\r\n complexity: 'simple' | 'complex';\r\n providerMode: 'auto' | 'zai' | 'anthropic';\r\n agentType?: string;\r\n taskContext?: string;\r\n}\r\n\r\n/**\r\n * Validation result with optional error message\r\n */\r\ninterface ValidationResult {\r\n valid: boolean;\r\n error?: string;\r\n}\r\n\r\n/**\r\n * AgentSpawner class - Type-safe agent spawning with validation\r\n */\r\nexport class AgentSpawner {\r\n private projectRoot: string;\r\n private agentProfilesDir: string;\r\n private agentConfigFile: string;\r\n\r\n constructor(projectRoot?: string) {\r\n this.projectRoot = projectRoot || process.cwd();\r\n this.agentProfilesDir = resolve(this.projectRoot, '.claude/agents/cfn-dev-team');\r\n this.agentConfigFile = resolve(this.projectRoot, '.claude/cfn-config/team-providers.json');\r\n }\r\n\r\n /**\r\n * Spawn an agent with the given configuration\r\n */\r\n async spawnAgent(config: SpawnAgentConfig): Promise<SpawnResult> {\r\n const timestamp = new Date().toISOString();\r\n const agentId = this.generateAgentId(config.agentType);\r\n\r\n try {\r\n // Validate configuration\r\n this.validateSpawnConfig(config);\r\n\r\n // Check agent exists\r\n const agentExists = await this.validateAgentExists(config.agentType);\r\n if (!agentExists) {\r\n return {\r\n agentId,\r\n pid: -1,\r\n status: 'failed',\r\n timestamp,\r\n error: `Agent type not found: ${config.agentType}`\r\n };\r\n }\r\n\r\n // Parse provider configuration if not explicitly provided\r\n let provider = config.provider;\r\n let model = config.model;\r\n\r\n if (!provider || !model) {\r\n const providerConfig = await this.parseAgentProvider(config.agentType);\r\n provider = provider || providerConfig.provider;\r\n model = model || providerConfig.model;\r\n }\r\n\r\n // Build environment variables\r\n const env = this.buildEnvironment(config, agentId, provider, model);\r\n\r\n // Spawn the process\r\n const pid = await this.spawnProcess(config.agentType, env, config.background);\r\n\r\n return {\r\n agentId,\r\n pid,\r\n status: 'spawned',\r\n timestamp,\r\n metadata: {\r\n agentType: config.agentType,\r\n taskId: config.taskId,\r\n iteration: config.iteration,\r\n mode: config.mode,\r\n provider,\r\n model\r\n }\r\n };\r\n } catch (error) {\r\n return {\r\n agentId,\r\n pid: -1,\r\n status: 'failed',\r\n timestamp,\r\n error: error instanceof Error ? error.message : String(error)\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Spawn a worker with team configuration\r\n */\r\n async spawnWorker(config: SpawnWorkerConfig): Promise<SpawnResult> {\r\n const timestamp = new Date().toISOString();\r\n const workerId = this.generateWorkerId(config.team);\r\n\r\n try {\r\n // Validate worker configuration\r\n this.validateWorkerConfig(config);\r\n\r\n // Load team provider configuration\r\n const teamConfig = this.loadTeamConfig(config.team);\r\n\r\n // Select model based on complexity\r\n const model = this.selectModel(config.team, config.complexity);\r\n\r\n // Get API key from environment\r\n const apiKey = this.getApiKey(config.team, 'workers');\r\n\r\n // Build environment for worker\r\n const env = this.buildWorkerEnvironment(config, workerId, model, apiKey);\r\n\r\n // Provider routing\r\n this.routeWorkerProvider(config.providerMode, config.team, model, apiKey);\r\n\r\n return {\r\n agentId: workerId,\r\n pid: 0,\r\n status: 'spawned',\r\n timestamp,\r\n metadata: {\r\n team: config.team,\r\n complexity: config.complexity,\r\n model,\r\n provider: config.providerMode\r\n }\r\n };\r\n } catch (error) {\r\n return {\r\n agentId: workerId,\r\n pid: -1,\r\n status: 'failed',\r\n timestamp,\r\n error: error instanceof Error ? error.message : String(error)\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Validate that an agent type exists in the profiles directory\r\n */\r\n async validateAgentExists(agentType: string): Promise<boolean> {\r\n // Normalize agent type (handle both underscore and hyphen variations)\r\n const normalized = agentType.replace(/_/g, '-').toLowerCase();\r\n\r\n // Check for agent profile in subdirectories\r\n const possiblePaths = [\r\n resolve(this.agentProfilesDir, `${normalized}.md`),\r\n // Check in subdirectories\r\n ...this.findAgentInSubdirs(normalized)\r\n ];\r\n\r\n return possiblePaths.some(path => existsSync(path));\r\n }\r\n\r\n /**\r\n * Parse provider configuration from agent profile frontmatter\r\n */\r\n async parseAgentProvider(agentType: string): Promise<ProviderConfig> {\r\n const agentPath = this.findAgentProfile(agentType);\r\n\r\n if (!agentPath) {\r\n return {\r\n provider: 'zai',\r\n model: 'glm-4.6'\r\n };\r\n }\r\n\r\n try {\r\n const content = readFileSync(agentPath, 'utf-8');\r\n const providerMatch = content.match(/<!-- PROVIDER_PARAMETERS\\s*([\\s\\S]*?)\\s*-->/);\r\n\r\n if (providerMatch) {\r\n const params = providerMatch[1];\r\n const providerMatch_ = params.match(/provider:\\s*(\\w+)/);\r\n const modelMatch = params.match(/model:\\s*([^\\n]+)/);\r\n\r\n return {\r\n provider: providerMatch_?.[1] || 'zai',\r\n model: modelMatch?.[1]?.trim() || 'glm-4.6'\r\n };\r\n }\r\n } catch (error) {\r\n // Silent fallback\r\n }\r\n\r\n return {\r\n provider: 'zai',\r\n model: 'glm-4.6'\r\n };\r\n }\r\n\r\n /**\r\n * Generate a unique agent ID\r\n */\r\n private generateAgentId(agentType: string): string {\r\n const timestamp = Date.now();\r\n const random = Math.random().toString(36).substring(2, 9);\r\n return `agent-${agentType}-${timestamp}-${random}`;\r\n }\r\n\r\n /**\r\n * Generate a unique worker ID\r\n */\r\n private generateWorkerId(team: string): string {\r\n const uuid = uuidv4().substring(0, 8);\r\n return `worker-${team}-${uuid}`;\r\n }\r\n\r\n /**\r\n * Validate spawn configuration\r\n */\r\n private validateSpawnConfig(config: SpawnAgentConfig): void {\r\n const errors: string[] = [];\r\n\r\n if (!config.agentType || typeof config.agentType !== 'string') {\r\n errors.push('agentType must be a non-empty string');\r\n }\r\n\r\n if (!config.taskId || typeof config.taskId !== 'string') {\r\n errors.push('taskId must be a non-empty string');\r\n } else {\r\n const taskIdValidation = this.validateTaskId(config.taskId);\r\n if (!taskIdValidation.valid) {\r\n errors.push(taskIdValidation.error || 'Invalid taskId format');\r\n }\r\n }\r\n\r\n if (config.iteration === undefined || typeof config.iteration !== 'number') {\r\n errors.push('iteration must be a number');\r\n }\r\n\r\n if (!['mvp', 'standard', 'enterprise'].includes(config.mode)) {\r\n errors.push('mode must be mvp, standard, or enterprise');\r\n }\r\n\r\n if (errors.length > 0) {\r\n throw new Error(`Configuration validation failed:\\n${errors.join('\\n')}`);\r\n }\r\n }\r\n\r\n /**\r\n * Validate worker configuration\r\n */\r\n private validateWorkerConfig(config: SpawnWorkerConfig): void {\r\n const errors: string[] = [];\r\n\r\n if (!config.team || typeof config.team !== 'string') {\r\n errors.push('team must be a non-empty string');\r\n }\r\n\r\n if (!['simple', 'complex'].includes(config.complexity)) {\r\n errors.push('complexity must be simple or complex');\r\n }\r\n\r\n if (!['auto', 'zai', 'anthropic'].includes(config.providerMode)) {\r\n errors.push('providerMode must be auto, zai, or anthropic');\r\n }\r\n\r\n if (errors.length > 0) {\r\n throw new Error(`Worker configuration validation failed:\\n${errors.join('\\n')}`);\r\n }\r\n }\r\n\r\n /**\r\n * Validate task ID format (CVSS 8.9 - command injection prevention)\r\n * Supports both raw IDs and Phase 1 prefixed IDs (cli:*, trigger:*)\r\n * Pattern: alphanumeric, underscore, hyphen, dot, and colon (for mode prefix) only, max 128 chars\r\n *\r\n * Accepted formats:\r\n * - Raw: task-123 (16 chars)\r\n * - Prefixed: cli:task-123 (20 chars)\r\n * - Prefixed: trigger:task-123 (24 chars)\r\n */\r\n private validateTaskId(taskId: string): ValidationResult {\r\n if (typeof taskId !== 'string' || taskId.length === 0) {\r\n return { valid: false, error: 'Task ID must be a non-empty string' };\r\n }\r\n\r\n // Updated pattern to support namespace prefixes (e.g., cli:, trigger:, task:, orchestrator:)\r\n const taskIdPattern = /^([a-z]+:)?[a-zA-Z0-9_.-]{1,64}$/;\r\n if (!taskIdPattern.test(taskId)) {\r\n return {\r\n valid: false,\r\n error: 'Invalid task ID format - must contain optional namespace prefix (e.g., \"cli:\") and alphanumeric characters, dot, underscore, hyphens (max 64 chars)'\r\n };\r\n }\r\n\r\n return { valid: true };\r\n }\r\n\r\n /**\r\n * Build environment variables for agent execution\r\n *\r\n * Provider routing: Sets both PROVIDER and CLAUDE_API_PROVIDER for compatibility.\r\n * - PROVIDER: New convention used by agent-spawner\r\n * - CLAUDE_API_PROVIDER: Legacy convention used by anthropic-client.ts getAPIConfig()\r\n *\r\n * BUG FIX: Previously only set PROVIDER, but anthropic-client.ts checked CLAUDE_API_PROVIDER\r\n */\r\n private buildEnvironment(\r\n config: SpawnAgentConfig,\r\n agentId: string,\r\n provider: string,\r\n model: string\r\n ): Record<string, string> {\r\n const env: Record<string, string> = {\r\n ...process.env as Record<string, string>,\r\n AGENT_ID: agentId,\r\n AGENT_TYPE: config.agentType,\r\n TASK_ID: config.taskId,\r\n ITERATION: String(config.iteration),\r\n MODE: config.mode,\r\n // Provider routing - set both for compatibility\r\n PROVIDER: provider,\r\n CLAUDE_API_PROVIDER: provider, // BUG FIX: anthropic-client.ts reads this\r\n MODEL: model,\r\n SPAWNED_AT: new Date().toISOString(),\r\n PROJECT_ROOT: this.projectRoot,\r\n // Redis coordination for CLI mode agents (resolved via environment contract)\r\n CFN_REDIS_HOST: getEnvValue('redis_host', 'cli'),\r\n CFN_REDIS_PORT: getEnvValue('redis_port', 'cli'),\r\n // FIX: Don't use REDIS_PASSWORD from parent env - only explicit CFN_REDIS_PASSWORD\r\n // This prevents CLI agents from inheriting the wrong password from shell environment\r\n CFN_REDIS_PASSWORD: process.env.CFN_REDIS_PASSWORD || '',\r\n CFN_NETWORK_NAME: getNetworkName('cli')\r\n };\r\n\r\n // Add provider-specific API keys if available\r\n // This ensures spawned agents have access to the correct API key for their provider\r\n if (provider === 'zai' && process.env.ZAI_API_KEY) {\r\n env.ZAI_API_KEY = process.env.ZAI_API_KEY;\r\n }\r\n if (provider === 'kimi' && process.env.KIMI_API_KEY) {\r\n env.KIMI_API_KEY = process.env.KIMI_API_KEY;\r\n }\r\n if (provider === 'openrouter' && process.env.OPENROUTER_API_KEY) {\r\n env.OPENROUTER_API_KEY = process.env.OPENROUTER_API_KEY;\r\n }\r\n if (provider === 'anthropic' && process.env.ANTHROPIC_API_KEY) {\r\n env.ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY;\r\n }\r\n\r\n // Add optional prompt parameter if provided\r\n if (config.prompt) {\r\n env.PROMPT = config.prompt;\r\n }\r\n\r\n // Merge user-provided environment variables\r\n if (config.env) {\r\n Object.assign(env, config.env);\r\n }\r\n\r\n // Debug logging for provider routing\r\n console.error(`[agent-spawner] Building env for agent ${agentId}:`);\r\n console.error(`[agent-spawner] PROVIDER=${provider}, CLAUDE_API_PROVIDER=${provider}`);\r\n console.error(`[agent-spawner] Has ZAI_API_KEY: ${!!env.ZAI_API_KEY}`);\r\n console.error(`[agent-spawner] Has KIMI_API_KEY: ${!!env.KIMI_API_KEY}`);\r\n console.error(`[agent-spawner] Has ANTHROPIC_API_KEY: ${!!env.ANTHROPIC_API_KEY}`);\r\n\r\n return env;\r\n }\r\n\r\n /**\r\n * Build environment for worker process\r\n */\r\n private buildWorkerEnvironment(\r\n config: SpawnWorkerConfig,\r\n workerId: string,\r\n model: string,\r\n apiKey: string\r\n ): Record<string, string> {\r\n const env: Record<string, string> = {\r\n ...process.env as Record<string, string>,\r\n WORKER_ID: workerId,\r\n TEAM: config.team,\r\n COMPLEXITY: config.complexity,\r\n MODEL: model,\r\n API_KEY: apiKey,\r\n PROJECT_ROOT: this.projectRoot\r\n };\r\n\r\n if (config.agentType) {\r\n env.AGENT_TYPE = config.agentType;\r\n }\r\n\r\n if (config.taskContext) {\r\n env.TASK_CONTEXT = config.taskContext;\r\n }\r\n\r\n return env;\r\n }\r\n\r\n /**\r\n * Spawn the actual process\r\n */\r\n private async spawnProcess(\r\n agentType: string,\r\n env: Record<string, string>,\r\n background: boolean = true\r\n ): Promise<number> {\r\n const args = [\r\n 'src/cli/agent-executor.ts',\r\n '--agent-type', agentType\r\n ];\r\n\r\n const child = childSpawn('tsx', args, {\r\n env,\r\n stdio: background ? 'ignore' : 'inherit',\r\n detached: background\r\n });\r\n\r\n const pid = child.pid || 0;\r\n\r\n if (background) {\r\n child.unref();\r\n } else {\r\n await new Promise((resolve, reject) => {\r\n child.on('exit', (code) => {\r\n if (code !== 0) {\r\n reject(new Error(`Process exited with code ${code}`));\r\n } else {\r\n resolve(undefined);\r\n }\r\n });\r\n });\r\n }\r\n\r\n return pid;\r\n }\r\n\r\n /**\r\n * Find agent profile in directory structure\r\n */\r\n private findAgentProfile(agentType: string): string | null {\r\n const normalized = agentType.replace(/_/g, '-').toLowerCase();\r\n\r\n // Direct path\r\n const directPath = resolve(this.agentProfilesDir, `${normalized}.md`);\r\n if (existsSync(directPath)) {\r\n return directPath;\r\n }\r\n\r\n // Search in subdirectories\r\n const subdirs = [\r\n 'developers', 'testers', 'reviewers', 'architecture',\r\n 'dev-ops', 'product-owners', 'coordinators', 'analysts', 'utility'\r\n ];\r\n\r\n for (const subdir of subdirs) {\r\n const path = resolve(this.agentProfilesDir, subdir, `${normalized}.md`);\r\n if (existsSync(path)) {\r\n return path;\r\n }\r\n\r\n // Check nested subdirectories\r\n const nestedDirs = ['frontend', 'backend', 'database', 'quality', 'e2e', 'unit', 'validation', 'data'];\r\n for (const nested of nestedDirs) {\r\n const nestedPath = resolve(this.agentProfilesDir, subdir, nested, `${normalized}.md`);\r\n if (existsSync(nestedPath)) {\r\n return nestedPath;\r\n }\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Find agent in subdirectories\r\n */\r\n private findAgentInSubdirs(normalized: string): string[] {\r\n const paths: string[] = [];\r\n const subdirs = [\r\n 'developers', 'testers', 'reviewers', 'architecture',\r\n 'dev-ops', 'product-owners', 'coordinators', 'analysts', 'utility'\r\n ];\r\n\r\n for (const subdir of subdirs) {\r\n const path = resolve(this.agentProfilesDir, subdir, `${normalized}.md`);\r\n paths.push(path);\r\n\r\n // Check nested directories\r\n const nestedDirs = ['frontend', 'backend', 'database', 'quality', 'e2e', 'unit', 'validation', 'data'];\r\n for (const nested of nestedDirs) {\r\n paths.push(resolve(this.agentProfilesDir, subdir, nested, `${normalized}.md`));\r\n }\r\n }\r\n\r\n return paths;\r\n }\r\n\r\n /**\r\n * Load team configuration from config file\r\n */\r\n private loadTeamConfig(team: string): Record<string, unknown> {\r\n if (!existsSync(this.agentConfigFile)) {\r\n throw new Error(`Team configuration not found at ${this.agentConfigFile}`);\r\n }\r\n\r\n const content = readFileSync(this.agentConfigFile, 'utf-8');\r\n const config = JSON.parse(content);\r\n\r\n if (!config.teams || !config.teams[team]) {\r\n throw new Error(`Invalid or missing provider configuration for team: ${team}`);\r\n }\r\n\r\n return config.teams[team] as Record<string, unknown>;\r\n }\r\n\r\n /**\r\n * Select model based on complexity\r\n */\r\n private selectModel(team: string, complexity: 'simple' | 'complex'): string {\r\n const config = this.loadTeamConfig(team);\r\n const workers = config.workers as Record<string, unknown>;\r\n const models = workers?.models as Record<string, unknown>;\r\n\r\n if (models && models[complexity]) {\r\n return models[complexity] as string;\r\n }\r\n\r\n // Fallback to default complexity\r\n const defaultComplexity = 'simple';\r\n if (models && models[defaultComplexity]) {\r\n return models[defaultComplexity] as string;\r\n }\r\n\r\n return 'gpt-4';\r\n }\r\n\r\n /**\r\n * Get API key from environment\r\n */\r\n private getApiKey(team: string, role: 'coordinator' | 'workers'): string {\r\n const config = this.loadTeamConfig(team);\r\n const roleConfig = config[role] as Record<string, unknown>;\r\n\r\n if (!roleConfig) {\r\n throw new Error(`No configuration found for team=${team}, role=${role}`);\r\n }\r\n\r\n const apiKeyEnvVar = roleConfig.apiKeyEnvVar as string;\r\n\r\n if (!apiKeyEnvVar) {\r\n throw new Error(`apiKeyEnvVar not configured for team=${team}, role=${role}`);\r\n }\r\n\r\n const apiKey = process.env[apiKeyEnvVar];\r\n\r\n if (!apiKey) {\r\n throw new Error(`API key not found in environment variable: ${apiKeyEnvVar}`);\r\n }\r\n\r\n return apiKey;\r\n }\r\n\r\n /**\r\n * Route worker to appropriate provider\r\n */\r\n private routeWorkerProvider(\r\n providerMode: string,\r\n team: string,\r\n model: string,\r\n apiKey: string\r\n ): void {\r\n const config = this.loadTeamConfig(team);\r\n const workers = config.workers as Record<string, unknown>;\r\n const provider = workers?.provider as string;\r\n const baseUrl = workers?.baseUrl as string;\r\n\r\n switch (providerMode) {\r\n case 'auto':\r\n this.routeAutoProvider(provider, baseUrl, model, apiKey);\r\n break;\r\n case 'zai':\r\n process.env.ZAI_API_KEY = apiKey;\r\n process.env.ZAI_BASE_URL = baseUrl;\r\n process.env.ZAI_MODEL = model;\r\n break;\r\n case 'anthropic':\r\n process.env.ANTHROPIC_API_KEY = apiKey;\r\n process.env.ANTHROPIC_BASE_URL = baseUrl;\r\n process.env.ANTHROPIC_MODEL = model;\r\n break;\r\n default:\r\n throw new Error(`Invalid provider mode: ${providerMode}`);\r\n }\r\n }\r\n\r\n /**\r\n * Route to appropriate provider based on configuration\r\n */\r\n private routeAutoProvider(provider: string, baseUrl: string, model: string, apiKey: string): void {\r\n switch (provider) {\r\n case 'zai':\r\n process.env.ZAI_API_KEY = apiKey;\r\n process.env.ZAI_BASE_URL = baseUrl;\r\n process.env.ZAI_MODEL = model;\r\n break;\r\n case 'anthropic':\r\n process.env.ANTHROPIC_API_KEY = apiKey;\r\n process.env.ANTHROPIC_BASE_URL = baseUrl;\r\n process.env.ANTHROPIC_MODEL = model;\r\n break;\r\n default:\r\n throw new Error(`Unsupported provider: ${provider}`);\r\n }\r\n }\r\n}\r\n\r\nexport type { SpawnAgentConfig, SpawnResult, ProviderConfig, SpawnWorkerConfig };\r\n"],"names":["existsSync","readFileSync","resolve","spawn","childSpawn","v4","uuidv4","getEnvValue","getNetworkName","AgentSpawner","projectRoot","agentProfilesDir","agentConfigFile","process","cwd","spawnAgent","config","timestamp","Date","toISOString","agentId","generateAgentId","agentType","validateSpawnConfig","agentExists","validateAgentExists","pid","status","error","provider","model","providerConfig","parseAgentProvider","env","buildEnvironment","spawnProcess","background","metadata","taskId","iteration","mode","Error","message","String","spawnWorker","workerId","generateWorkerId","team","validateWorkerConfig","teamConfig","loadTeamConfig","selectModel","complexity","apiKey","getApiKey","buildWorkerEnvironment","routeWorkerProvider","providerMode","normalized","replace","toLowerCase","possiblePaths","findAgentInSubdirs","some","path","agentPath","findAgentProfile","content","providerMatch","match","params","providerMatch_","modelMatch","trim","now","random","Math","toString","substring","uuid","errors","push","taskIdValidation","validateTaskId","valid","undefined","includes","length","join","taskIdPattern","test","AGENT_ID","AGENT_TYPE","TASK_ID","ITERATION","MODE","PROVIDER","CLAUDE_API_PROVIDER","MODEL","SPAWNED_AT","PROJECT_ROOT","CFN_REDIS_HOST","CFN_REDIS_PORT","CFN_REDIS_PASSWORD","CFN_NETWORK_NAME","ZAI_API_KEY","KIMI_API_KEY","OPENROUTER_API_KEY","ANTHROPIC_API_KEY","prompt","PROMPT","Object","assign","console","WORKER_ID","TEAM","COMPLEXITY","API_KEY","taskContext","TASK_CONTEXT","args","child","stdio","detached","unref","Promise","reject","on","code","directPath","subdirs","subdir","nestedDirs","nested","nestedPath","paths","JSON","parse","teams","workers","models","defaultComplexity","role","roleConfig","apiKeyEnvVar","baseUrl","routeAutoProvider","ZAI_BASE_URL","ZAI_MODEL","ANTHROPIC_BASE_URL","ANTHROPIC_MODEL"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,UAAU,EAAEC,YAAY,QAAQ,KAAK;AAC9C,SAASC,OAAO,QAAc,OAAO;AACrC,SAAuBC,SAASC,UAAU,QAAQ,gBAAgB;AAClE,SAASC,MAAMC,MAAM,QAAQ,OAAO;AAEpC,SAASC,WAAW,EAAEC,cAAc,QAAQ,8BA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G,CAACmH,SAAS,GAAGtH;gBACxB;YACF,KAAK;gBACHjB,QAAQoB,GAAG,CAAC2E,iBAAiB,GAAGvD;gBAChCxC,QAAQoB,GAAG,CAACoH,kBAAkB,GAAGJ;gBACjCpI,QAAQoB,GAAG,CAACqH,eAAe,GAAGxH;gBAC9B;YACF;gBACE,MAAM,IAAIW,MAAM,CAAC,sBAAsB,EAAEZ,UAAU;QACvD;IACF;AACF"}
|
|
@@ -9,7 +9,8 @@ const path = require('path');
|
|
|
9
9
|
let AgentTokenManager = class AgentTokenManager {
|
|
10
10
|
constructor(options = {}){
|
|
11
11
|
// Support CFN standard variables with fallback to legacy MCP_REDIS_URL
|
|
12
|
-
|
|
12
|
+
// FIX: Default to 'localhost' for CLI mode (host execution), not 'cfn-redis' (Docker)
|
|
13
|
+
const redisHost = process.env.CFN_REDIS_HOST || 'localhost';
|
|
13
14
|
const redisPort = process.env.CFN_REDIS_PORT || '6379';
|
|
14
15
|
const defaultUrl = `redis://${redisHost}:${redisPort}`;
|
|
15
16
|
this.redisUrl = options.redisUrl || process.env.CFN_REDIS_URL || process.env.MCP_REDIS_URL || defaultUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/agent-token-manager.js"],"sourcesContent":["#!/usr/bin/env node\r\n\r\n/**\r\n * Agent Token Management CLI\r\n * Generate, register, and manage agent tokens for MCP authentication\r\n */\r\n\r\nconst crypto = require('crypto');\r\nconst Redis = require('redis');\r\nconst fs = require('fs').promises;\r\nconst path = require('path');\r\n\r\nclass AgentTokenManager {\r\n constructor(options = {}) {\r\n // Support CFN standard variables with fallback to legacy MCP_REDIS_URL\r\n const redisHost = process.env.CFN_REDIS_HOST || 'cfn-redis';\r\n const redisPort = process.env.CFN_REDIS_PORT || '6379';\r\n const defaultUrl = `redis://${redisHost}:${redisPort}`;\r\n this.redisUrl = options.redisUrl || process.env.CFN_REDIS_URL || process.env.MCP_REDIS_URL || defaultUrl;\r\n this.redis = null;\r\n this.agentConfigPath = options.agentConfigPath || './config/agent-whitelist.json';\r\n this.defaultExpiry = options.defaultExpiry || '24h';\r\n }\r\n\r\n async initialize() {\r\n try {\r\n this.redis = Redis.createClient({ url: this.redisUrl });\r\n await this.redis.connect();\r\n console.log('Connected to Redis for token management');\r\n } catch (error) {\r\n console.error('Failed to connect to Redis:', error);\r\n throw error;\r\n }\r\n }\r\n\r\n async loadAgentConfig() {\r\n try {\r\n const configPath = path.resolve(this.agentConfigPath);\r\n const config = await fs.readFile(configPath, 'utf8');\r\n return JSON.parse(config);\r\n } catch (error) {\r\n console.error('Failed to load agent config:', error);\r\n throw error;\r\n }\r\n }\r\n\r\n generateToken() {\r\n return crypto.randomBytes(32).toString('hex');\r\n }\r\n\r\n parseExpiry(expiry) {\r\n if (typeof expiry === 'number') {\r\n return expiry;\r\n }\r\n\r\n const match = expiry.match(/^(\\d+)([smhd])$/);\r\n if (!match) {\r\n return 86400; // Default to 24 hours\r\n }\r\n\r\n const value = parseInt(match[1]);\r\n const unit = match[2];\r\n const multipliers = { s: 1, m: 60, h: 3600, d: 86400 };\r\n\r\n return value * (multipliers[unit] || 86400);\r\n }\r\n\r\n async registerAgentToken(agentType, options = {}) {\r\n try {\r\n const config = await this.loadAgentConfig();\r\n const agentConfig = config.agents.find(a => a.type === agentType);\r\n\r\n if (!agentConfig) {\r\n throw new Error(`Unknown agent type: ${agentType}. Available types: ${config.agents.map(a => a.type).join(', ')}`);\r\n }\r\n\r\n const token = this.generateToken();\r\n const expiresIn = options.expiresIn || this.defaultExpiry;\r\n const expiresAt = Date.now() + (this.parseExpiry(expiresIn) * 1000);\r\n\r\n const tokenData = {\r\n token,\r\n agentType,\r\n displayName: agentConfig.displayName,\r\n skills: agentConfig.skills,\r\n allowedMcpServers: agentConfig.allowedMcpServers,\r\n resourceLimits: agentConfig.resourceLimits,\r\n expiresAt,\r\n createdAt: Date.now(),\r\n createdBy: options.createdBy || 'cli',\r\n description: options.description || `Token for ${agentConfig.displayName}`\r\n };\r\n\r\n // Store in Redis\r\n const key = `mcp:agent:${agentType}:${token}`;\r\n const value = JSON.stringify(tokenData);\r\n const ttlSeconds = this.parseExpiry(expiresIn);\r\n\r\n await this.redis.setEx(key, ttlSeconds, value);\r\n\r\n console.log(`✅ Token registered successfully!`);\r\n console.log(` Agent Type: ${agentConfig.displayName} (${agentType})`);\r\n console.log(` Token: ${token}`);\r\n console.log(` Skills: ${agentConfig.skills.join(', ')}`);\r\n console.log(` Allowed MCP Servers: ${agentConfig.allowedMcpServers.join(', ')}`);\r\n console.log(` Expires: ${new Date(expiresAt).toISOString()}`);\r\n console.log(` Memory Limit: ${agentConfig.resourceLimits.maxMemoryMB}MB`);\r\n console.log(` Rate Limit: ${agentConfig.resourceLimits.maxRequestsPerMinute}/min`);\r\n\r\n return tokenData;\r\n\r\n } catch (error) {\r\n console.error('❌ Failed to register token:', error.message);\r\n throw error;\r\n }\r\n }\r\n\r\n async listActiveTokens(agentType = null) {\r\n try {\r\n const pattern = agentType ? `mcp:agent:${agentType}:*` : 'mcp:agent:*';\r\n const keys = await this.redis.keys(pattern);\r\n const tokens = [];\r\n\r\n for (const key of keys) {\r\n const value = await this.redis.get(key);\r\n if (value) {\r\n const tokenData = JSON.parse(value);\r\n tokens.push({\r\n ...tokenData,\r\n key,\r\n status: tokenData.expiresAt > Date.now() ? 'active' : 'expired'\r\n });\r\n }\r\n }\r\n\r\n if (tokens.length === 0) {\r\n console.log('No active tokens found');\r\n return [];\r\n }\r\n\r\n console.log(`\\nActive Tokens (${tokens.length}):\\n`);\r\n console.log('Agent Type | Token | Expires At | Status');\r\n console.log('-------------------|------------------------------------|------------------------------|--------');\r\n\r\n for (const token of tokens) {\r\n const expiresAt = new Date(token.expiresAt).toISOString();\r\n const tokenShort = token.token.substring(0, 32);\r\n console.log(`${token.agentType.padEnd(17)} | ${tokenShort} | ${expiresAt} | ${token.status}`);\r\n }\r\n\r\n return tokens;\r\n\r\n } catch (error) {\r\n console.error('❌ Failed to list tokens:', error.message);\r\n throw error;\r\n }\r\n }\r\n\r\n async revokeToken(agentType, token) {\r\n try {\r\n const key = `mcp:agent:${agentType}:${token}`;\r\n const exists = await this.redis.exists(key);\r\n\r\n if (!exists) {\r\n throw new Error(`Token not found for agent ${agentType}`);\r\n }\r\n\r\n await this.redis.del(key);\r\n console.log(`✅ Token revoked successfully for agent ${agentType}`);\r\n console.log(` Token: ${token}`);\r\n\r\n } catch (error) {\r\n console.error('❌ Failed to revoke token:', error.message);\r\n throw error;\r\n }\r\n }\r\n\r\n async revokeAllTokens(agentType = null) {\r\n try {\r\n const pattern = agentType ? `mcp:agent:${agentType}:*` : 'mcp:agent:*';\r\n const keys = await this.redis.keys(pattern);\r\n\r\n if (keys.length === 0) {\r\n console.log('No tokens found to revoke');\r\n return 0;\r\n }\r\n\r\n await this.redis.del(keys);\r\n console.log(`✅ Revoked ${keys.length} tokens${agentType ? ` for agent ${agentType}` : ''}`);\r\n return keys.length;\r\n\r\n } catch (error) {\r\n console.error('❌ Failed to revoke tokens:', error.message);\r\n throw error;\r\n }\r\n }\r\n\r\n async validateToken(agentType, token) {\r\n try {\r\n const key = `mcp:agent:${agentType}:${token}`;\r\n const value = await this.redis.get(key);\r\n\r\n if (!value) {\r\n return { valid: false, reason: 'Token not found' };\r\n }\r\n\r\n const tokenData = JSON.parse(value);\r\n\r\n if (Date.now() > tokenData.expiresAt) {\r\n await this.redis.del(key);\r\n return { valid: false, reason: 'Token expired' };\r\n }\r\n\r\n return {\r\n valid: true,\r\n tokenData\r\n };\r\n\r\n } catch (error) {\r\n return { valid: false, reason: error.message };\r\n }\r\n }\r\n\r\n async getAgentInfo(agentType) {\r\n try {\r\n const config = await this.loadAgentConfig();\r\n const agentConfig = config.agents.find(a => a.type === agentType);\r\n\r\n if (!agentConfig) {\r\n throw new Error(`Unknown agent type: ${agentType}`);\r\n }\r\n\r\n console.log(`\\nAgent Information: ${agentConfig.displayName}`);\r\n console.log('='.repeat(50));\r\n console.log(`Type: ${agentConfig.type}`);\r\n console.log(`Skills: ${agentConfig.skills.join(', ')}`);\r\n console.log(`Allowed MCP Servers: ${agentConfig.allowedMcpServers.join(', ')}`);\r\n console.log(`Memory Limit: ${agentConfig.resourceLimits.maxMemoryMB}MB`);\r\n console.log(`Rate Limit: ${agentConfig.resourceLimits.maxRequestsPerMinute}/min`);\r\n console.log(`Max Concurrent: ${agentConfig.resourceLimits.maxConcurrentRequests}`);\r\n console.log(`Description: ${agentConfig.description}`);\r\n\r\n return agentConfig;\r\n\r\n } catch (error) {\r\n console.error('❌ Failed to get agent info:', error.message);\r\n throw error;\r\n }\r\n }\r\n\r\n async listAgentTypes() {\r\n try {\r\n const config = await this.loadAgentConfig();\r\n\r\n console.log(`\\nAvailable Agent Types (${config.agents.length}):\\n`);\r\n console.log('Agent Type | Display Name | Skills Count');\r\n console.log('------------------------|--------------------------------|-------------');\r\n\r\n for (const agent of config.agents) {\r\n const type = agent.type.padEnd(22);\r\n const name = agent.displayName.padEnd(32);\r\n const skills = agent.skills.length;\r\n console.log(`${type} | ${name} | ${skills}`);\r\n }\r\n\r\n return config.agents.map(a => a.type);\r\n\r\n } catch (error) {\r\n console.error('❌ Failed to list agent types:', error.message);\r\n throw error;\r\n }\r\n }\r\n\r\n async shutdown() {\r\n if (this.redis) {\r\n await this.redis.quit();\r\n }\r\n }\r\n}\r\n\r\n// CLI interface\r\nasync function main() {\r\n const args = process.argv.slice(2);\r\n const command = args[0];\r\n\r\n if (!command) {\r\n console.log(`\r\nAgent Token Management CLI\r\n\r\nUsage: node agent-token-manager.js <command> [options]\r\n\r\nCommands:\r\n register <agent-type> [options] Register a new token for an agent\r\n list [agent-type] List active tokens\r\n revoke <agent-type> <token> Revoke a specific token\r\n revoke-all [agent-type] Revoke all tokens (optionally for specific agent)\r\n validate <agent-type> <token> Validate a token\r\n info <agent-type> Show agent information\r\n types List available agent types\r\n\r\nOptions for 'register' command:\r\n --expires-in <duration> Token expiry (e.g., 1h, 30m, 7d) [default: 24h]\r\n --description <text> Token description\r\n --created-by <identifier> Creator identifier\r\n\r\nExamples:\r\n # Register token for frontend engineer\r\n node agent-token-manager.js register react-frontend-engineer\r\n\r\n # Register token with custom expiry\r\n node agent-token-manager.js register backend-developer --expires-in 2h\r\n\r\n # List all active tokens\r\n node agent-token-manager.js list\r\n\r\n # List tokens for specific agent\r\n node agent-token-manager.js list react-frontend-engineer\r\n\r\n # Revoke a specific token\r\n node agent-token-manager.js revoke react-frontend-engineer abc123...\r\n\r\n # Get agent information\r\n node agent-token-manager.js info security-specialist\r\n`);\r\n process.exit(0);\r\n }\r\n\r\n const tokenManager = new AgentTokenManager();\r\n\r\n try {\r\n await tokenManager.initialize();\r\n\r\n switch (command) {\r\n case 'register': {\r\n const agentType = args[1];\r\n if (!agentType) {\r\n throw new Error('Agent type is required for register command');\r\n }\r\n\r\n const options = {};\r\n for (let i = 2; i < args.length; i++) {\r\n if (args[i] === '--expires-in') {\r\n options.expiresIn = args[++i];\r\n } else if (args[i] === '--description') {\r\n options.description = args[++i];\r\n } else if (args[i] === '--created-by') {\r\n options.createdBy = args[++i];\r\n }\r\n }\r\n\r\n await tokenManager.registerAgentToken(agentType, options);\r\n break;\r\n }\r\n\r\n case 'list': {\r\n const agentType = args[1];\r\n await tokenManager.listActiveTokens(agentType);\r\n break;\r\n }\r\n\r\n case 'revoke': {\r\n const agentType = args[1];\r\n const token = args[2];\r\n if (!agentType || !token) {\r\n throw new Error('Agent type and token are required for revoke command');\r\n }\r\n await tokenManager.revokeToken(agentType, token);\r\n break;\r\n }\r\n\r\n case 'revoke-all': {\r\n const agentType = args[1];\r\n const count = await tokenManager.revokeAllTokens(agentType);\r\n console.log(`Revoked ${count} tokens`);\r\n break;\r\n }\r\n\r\n case 'validate': {\r\n const agentType = args[1];\r\n const token = args[2];\r\n if (!agentType || !token) {\r\n throw new Error('Agent type and token are required for validate command');\r\n }\r\n\r\n const result = await tokenManager.validateToken(agentType, token);\r\n if (result.valid) {\r\n console.log('✅ Token is valid');\r\n console.log(` Agent Type: ${result.tokenData.agentType}`);\r\n console.log(` Skills: ${result.tokenData.skills.join(', ')}`);\r\n console.log(` Expires: ${new Date(result.tokenData.expiresAt).toISOString()}`);\r\n } else {\r\n console.log('❌ Token is invalid');\r\n console.log(` Reason: ${result.reason}`);\r\n }\r\n break;\r\n }\r\n\r\n case 'info': {\r\n const agentType = args[1];\r\n if (!agentType) {\r\n throw new Error('Agent type is required for info command');\r\n }\r\n await tokenManager.getAgentInfo(agentType);\r\n break;\r\n }\r\n\r\n case 'types': {\r\n await tokenManager.listAgentTypes();\r\n break;\r\n }\r\n\r\n default:\r\n throw new Error(`Unknown command: ${command}`);\r\n }\r\n\r\n } catch (error) {\r\n console.error('❌ Error:', error.message);\r\n process.exit(1);\r\n } finally {\r\n await tokenManager.shutdown();\r\n }\r\n}\r\n\r\nif (require.main === module) {\r\n main().catch(error => {\r\n console.error('Fatal error:', error);\r\n process.exit(1);\r\n });\r\n}\r\n\r\nmodule.exports = AgentTokenManager;"],"names":["crypto","require","Redis","fs","promises","path","AgentTokenManager","options","redisHost","process","env","CFN_REDIS_HOST","redisPort","CFN_REDIS_PORT","defaultUrl","redisUrl","CFN_REDIS_URL","MCP_REDIS_URL","redis","agentConfigPath","defaultExpiry","initialize","createClient","url","connect","console","log","error","loadAgentConfig","configPath","resolve","config","readFile","JSON","parse","generateToken","randomBytes","toString","parseExpiry","expiry","match","value","parseInt","unit","multipliers","s","m","h","d","registerAgentToken","agentType","agentConfig","agents","find","a","type","Error","map","join","token","expiresIn","expiresAt","Date","now","tokenData","displayName","skills","allowedMcpServers","resourceLimits","createdAt","createdBy","description","key","stringify","ttlSeconds","setEx","toISOString","maxMemoryMB","maxRequestsPerMinute","message","listActiveTokens","pattern","keys","tokens","get","push","status","length","tokenShort","substring","padEnd","revokeToken","exists","del","revokeAllTokens","validateToken","valid","reason","getAgentInfo","repeat","maxConcurrentRequests","listAgentTypes","agent","name","shutdown","quit","main","args","argv","slice","command","exit","tokenManager","i","count","result","module","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;AAEA,IAAIvG,QAAQyG,IAAI,KAAKU,QAAQ;IAC3BV,OAAOW,KAAK,CAAC1F,CAAAA;QACXF,QAAQE,KAAK,CAAC,gBAAgBA;QAC9BlB,QAAQsG,IAAI,CAAC;IACf;AACF;AAEAK,OAAOE,OAAO,GAAGhH"}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/agent-token-manager.js"],"sourcesContent":["#!/usr/bin/env node\r\n\r\n/**\r\n * Agent Token Management CLI\r\n * Generate, register, and manage agent tokens for MCP authentication\r\n */\r\n\r\nconst crypto = require('crypto');\r\nconst Redis = require('redis');\r\nconst fs = require('fs').promises;\r\nconst path = require('path');\r\n\r\nclass AgentTokenManager {\r\n constructor(options = {}) {\r\n // Support CFN standard variables with fallback to legacy MCP_REDIS_URL\r\n // FIX: Default to 'localhost' for CLI mode (host execution), not 'cfn-redis' (Docker)\r\n const redisHost = process.env.CFN_REDIS_HOST || 'localhost';\r\n const redisPort = process.env.CFN_REDIS_PORT || '6379';\r\n const defaultUrl = `redis://${redisHost}:${redisPort}`;\r\n this.redisUrl = options.redisUrl || process.env.CFN_REDIS_URL || process.env.MCP_REDIS_URL || defaultUrl;\r\n this.redis = null;\r\n this.agentConfigPath = options.agentConfigPath || './config/agent-whitelist.json';\r\n this.defaultExpiry = options.defaultExpiry || '24h';\r\n }\r\n\r\n async initialize() {\r\n try {\r\n this.redis = Redis.createClient({ url: this.redisUrl });\r\n await this.redis.connect();\r\n console.log('Connected to Redis for token management');\r\n } catch (error) {\r\n console.error('Failed to connect to Redis:', error);\r\n throw error;\r\n }\r\n }\r\n\r\n async loadAgentConfig() {\r\n try {\r\n const configPath = path.resolve(this.agentConfigPath);\r\n const config = await fs.readFile(configPath, 'utf8');\r\n return JSON.parse(config);\r\n } catch (error) {\r\n console.error('Failed to load agent config:', error);\r\n throw error;\r\n }\r\n }\r\n\r\n generateToken() {\r\n return crypto.randomBytes(32).toString('hex');\r\n }\r\n\r\n parseExpiry(expiry) {\r\n if (typeof expiry === 'number') {\r\n return expiry;\r\n }\r\n\r\n const match = expiry.match(/^(\\d+)([smhd])$/);\r\n if (!match) {\r\n return 86400; // Default to 24 hours\r\n }\r\n\r\n const value = parseInt(match[1]);\r\n const unit = match[2];\r\n const multipliers = { s: 1, m: 60, h: 3600, d: 86400 };\r\n\r\n return value * (multipliers[unit] || 86400);\r\n }\r\n\r\n async registerAgentToken(agentType, options = {}) {\r\n try {\r\n const config = await this.loadAgentConfig();\r\n const agentConfig = config.agents.find(a => a.type === agentType);\r\n\r\n if (!agentConfig) {\r\n throw new Error(`Unknown agent type: ${agentType}. Available types: ${config.agents.map(a => a.type).join(', ')}`);\r\n }\r\n\r\n const token = this.generateToken();\r\n const expiresIn = options.expiresIn || this.defaultExpiry;\r\n const expiresAt = Date.now() + (this.parseExpiry(expiresIn) * 1000);\r\n\r\n const tokenData = {\r\n token,\r\n agentType,\r\n displayName: agentConfig.displayName,\r\n skills: agentConfig.skills,\r\n allowedMcpServers: agentConfig.allowedMcpServers,\r\n resourceLimits: agentConfig.resourceLimits,\r\n expiresAt,\r\n createdAt: Date.now(),\r\n createdBy: options.createdBy || 'cli',\r\n description: options.description || `Token for ${agentConfig.displayName}`\r\n };\r\n\r\n // Store in Redis\r\n const key = `mcp:agent:${agentType}:${token}`;\r\n const value = JSON.stringify(tokenData);\r\n const ttlSeconds = this.parseExpiry(expiresIn);\r\n\r\n await this.redis.setEx(key, ttlSeconds, value);\r\n\r\n console.log(`✅ Token registered successfully!`);\r\n console.log(` Agent Type: ${agentConfig.displayName} (${agentType})`);\r\n console.log(` Token: ${token}`);\r\n console.log(` Skills: ${agentConfig.skills.join(', ')}`);\r\n console.log(` Allowed MCP Servers: ${agentConfig.allowedMcpServers.join(', ')}`);\r\n console.log(` Expires: ${new Date(expiresAt).toISOString()}`);\r\n console.log(` Memory Limit: ${agentConfig.resourceLimits.maxMemoryMB}MB`);\r\n console.log(` Rate Limit: ${agentConfig.resourceLimits.maxRequestsPerMinute}/min`);\r\n\r\n return tokenData;\r\n\r\n } catch (error) {\r\n console.error('❌ Failed to register token:', error.message);\r\n throw error;\r\n }\r\n }\r\n\r\n async listActiveTokens(agentType = null) {\r\n try {\r\n const pattern = agentType ? `mcp:agent:${agentType}:*` : 'mcp:agent:*';\r\n const keys = await this.redis.keys(pattern);\r\n const tokens = [];\r\n\r\n for (const key of keys) {\r\n const value = await this.redis.get(key);\r\n if (value) {\r\n const tokenData = JSON.parse(value);\r\n tokens.push({\r\n ...tokenData,\r\n key,\r\n status: tokenData.expiresAt > Date.now() ? 'active' : 'expired'\r\n });\r\n }\r\n }\r\n\r\n if (tokens.length === 0) {\r\n console.log('No active tokens found');\r\n return [];\r\n }\r\n\r\n console.log(`\\nActive Tokens (${tokens.length}):\\n`);\r\n console.log('Agent Type | Token | Expires At | Status');\r\n console.log('-------------------|------------------------------------|------------------------------|--------');\r\n\r\n for (const token of tokens) {\r\n const expiresAt = new Date(token.expiresAt).toISOString();\r\n const tokenShort = token.token.substring(0, 32);\r\n console.log(`${token.agentType.padEnd(17)} | ${tokenShort} | ${expiresAt} | ${token.status}`);\r\n }\r\n\r\n return tokens;\r\n\r\n } catch (error) {\r\n console.error('❌ Failed to list tokens:', error.message);\r\n throw error;\r\n }\r\n }\r\n\r\n async revokeToken(agentType, token) {\r\n try {\r\n const key = `mcp:agent:${agentType}:${token}`;\r\n const exists = await this.redis.exists(key);\r\n\r\n if (!exists) {\r\n throw new Error(`Token not found for agent ${agentType}`);\r\n }\r\n\r\n await this.redis.del(key);\r\n console.log(`✅ Token revoked successfully for agent ${agentType}`);\r\n console.log(` Token: ${token}`);\r\n\r\n } catch (error) {\r\n console.error('❌ Failed to revoke token:', error.message);\r\n throw error;\r\n }\r\n }\r\n\r\n async revokeAllTokens(agentType = null) {\r\n try {\r\n const pattern = agentType ? `mcp:agent:${agentType}:*` : 'mcp:agent:*';\r\n const keys = await this.redis.keys(pattern);\r\n\r\n if (keys.length === 0) {\r\n console.log('No tokens found to revoke');\r\n return 0;\r\n }\r\n\r\n await this.redis.del(keys);\r\n console.log(`✅ Revoked ${keys.length} tokens${agentType ? ` for agent ${agentType}` : ''}`);\r\n return keys.length;\r\n\r\n } catch (error) {\r\n console.error('❌ Failed to revoke tokens:', error.message);\r\n throw error;\r\n }\r\n }\r\n\r\n async validateToken(agentType, token) {\r\n try {\r\n const key = `mcp:agent:${agentType}:${token}`;\r\n const value = await this.redis.get(key);\r\n\r\n if (!value) {\r\n return { valid: false, reason: 'Token not found' };\r\n }\r\n\r\n const tokenData = JSON.parse(value);\r\n\r\n if (Date.now() > tokenData.expiresAt) {\r\n await this.redis.del(key);\r\n return { valid: false, reason: 'Token expired' };\r\n }\r\n\r\n return {\r\n valid: true,\r\n tokenData\r\n };\r\n\r\n } catch (error) {\r\n return { valid: false, reason: error.message };\r\n }\r\n }\r\n\r\n async getAgentInfo(agentType) {\r\n try {\r\n const config = await this.loadAgentConfig();\r\n const agentConfig = config.agents.find(a => a.type === agentType);\r\n\r\n if (!agentConfig) {\r\n throw new Error(`Unknown agent type: ${agentType}`);\r\n }\r\n\r\n console.log(`\\nAgent Information: ${agentConfig.displayName}`);\r\n console.log('='.repeat(50));\r\n console.log(`Type: ${agentConfig.type}`);\r\n console.log(`Skills: ${agentConfig.skills.join(', ')}`);\r\n console.log(`Allowed MCP Servers: ${agentConfig.allowedMcpServers.join(', ')}`);\r\n console.log(`Memory Limit: ${agentConfig.resourceLimits.maxMemoryMB}MB`);\r\n console.log(`Rate Limit: ${agentConfig.resourceLimits.maxRequestsPerMinute}/min`);\r\n console.log(`Max Concurrent: ${agentConfig.resourceLimits.maxConcurrentRequests}`);\r\n console.log(`Description: ${agentConfig.description}`);\r\n\r\n return agentConfig;\r\n\r\n } catch (error) {\r\n console.error('❌ Failed to get agent info:', error.message);\r\n throw error;\r\n }\r\n }\r\n\r\n async listAgentTypes() {\r\n try {\r\n const config = await this.loadAgentConfig();\r\n\r\n console.log(`\\nAvailable Agent Types (${config.agents.length}):\\n`);\r\n console.log('Agent Type | Display Name | Skills Count');\r\n console.log('------------------------|--------------------------------|-------------');\r\n\r\n for (const agent of config.agents) {\r\n const type = agent.type.padEnd(22);\r\n const name = agent.displayName.padEnd(32);\r\n const skills = agent.skills.length;\r\n console.log(`${type} | ${name} | ${skills}`);\r\n }\r\n\r\n return config.agents.map(a => a.type);\r\n\r\n } catch (error) {\r\n console.error('❌ Failed to list agent types:', error.message);\r\n throw error;\r\n }\r\n }\r\n\r\n async shutdown() {\r\n if (this.redis) {\r\n await this.redis.quit();\r\n }\r\n }\r\n}\r\n\r\n// CLI interface\r\nasync function main() {\r\n const args = process.argv.slice(2);\r\n const command = args[0];\r\n\r\n if (!command) {\r\n console.log(`\r\nAgent Token Management CLI\r\n\r\nUsage: node agent-token-manager.js <command> [options]\r\n\r\nCommands:\r\n register <agent-type> [options] Register a new token for an agent\r\n list [agent-type] List active tokens\r\n revoke <agent-type> <token> Revoke a specific token\r\n revoke-all [agent-type] Revoke all tokens (optionally for specific agent)\r\n validate <agent-type> <token> Validate a token\r\n info <agent-type> Show agent information\r\n types List available agent types\r\n\r\nOptions for 'register' command:\r\n --expires-in <duration> Token expiry (e.g., 1h, 30m, 7d) [default: 24h]\r\n --description <text> Token description\r\n --created-by <identifier> Creator identifier\r\n\r\nExamples:\r\n # Register token for frontend engineer\r\n node agent-token-manager.js register react-frontend-engineer\r\n\r\n # Register token with custom expiry\r\n node agent-token-manager.js register backend-developer --expires-in 2h\r\n\r\n # List all active tokens\r\n node agent-token-manager.js list\r\n\r\n # List tokens for specific agent\r\n node agent-token-manager.js list react-frontend-engineer\r\n\r\n # Revoke a specific token\r\n node agent-token-manager.js revoke react-frontend-engineer abc123...\r\n\r\n # Get agent information\r\n node agent-token-manager.js info security-specialist\r\n`);\r\n process.exit(0);\r\n }\r\n\r\n const tokenManager = new AgentTokenManager();\r\n\r\n try {\r\n await tokenManager.initialize();\r\n\r\n switch (command) {\r\n case 'register': {\r\n const agentType = args[1];\r\n if (!agentType) {\r\n throw new Error('Agent type is required for register command');\r\n }\r\n\r\n const options = {};\r\n for (let i = 2; i < args.length; i++) {\r\n if (args[i] === '--expires-in') {\r\n options.expiresIn = args[++i];\r\n } else if (args[i] === '--description') {\r\n options.description = args[++i];\r\n } else if (args[i] === '--created-by') {\r\n options.createdBy = args[++i];\r\n }\r\n }\r\n\r\n await tokenManager.registerAgentToken(agentType, options);\r\n break;\r\n }\r\n\r\n case 'list': {\r\n const agentType = args[1];\r\n await tokenManager.listActiveTokens(agentType);\r\n break;\r\n }\r\n\r\n case 'revoke': {\r\n const agentType = args[1];\r\n const token = args[2];\r\n if (!agentType || !token) {\r\n throw new Error('Agent type and token are required for revoke command');\r\n }\r\n await tokenManager.revokeToken(agentType, token);\r\n break;\r\n }\r\n\r\n case 'revoke-all': {\r\n const agentType = args[1];\r\n const count = await tokenManager.revokeAllTokens(agentType);\r\n console.log(`Revoked ${count} tokens`);\r\n break;\r\n }\r\n\r\n case 'validate': {\r\n const agentType = args[1];\r\n const token = args[2];\r\n if (!agentType || !token) {\r\n throw new Error('Agent type and token are required for validate command');\r\n }\r\n\r\n const result = await tokenManager.validateToken(agentType, token);\r\n if (result.valid) {\r\n console.log('✅ Token is valid');\r\n console.log(` Agent Type: ${result.tokenData.agentType}`);\r\n console.log(` Skills: ${result.tokenData.skills.join(', ')}`);\r\n console.log(` Expires: ${new Date(result.tokenData.expiresAt).toISOString()}`);\r\n } else {\r\n console.log('❌ Token is invalid');\r\n console.log(` Reason: ${result.reason}`);\r\n }\r\n break;\r\n }\r\n\r\n case 'info': {\r\n const agentType = args[1];\r\n if (!agentType) {\r\n throw new Error('Agent type is required for info command');\r\n }\r\n await tokenManager.getAgentInfo(agentType);\r\n break;\r\n }\r\n\r\n case 'types': {\r\n await tokenManager.listAgentTypes();\r\n break;\r\n }\r\n\r\n default:\r\n throw new Error(`Unknown command: ${command}`);\r\n }\r\n\r\n } catch (error) {\r\n console.error('❌ Error:', error.message);\r\n process.exit(1);\r\n } finally {\r\n await tokenManager.shutdown();\r\n }\r\n}\r\n\r\nif (require.main === module) {\r\n main().catch(error => {\r\n console.error('Fatal error:', error);\r\n process.exit(1);\r\n });\r\n}\r\n\r\nmodule.exports = AgentTokenManager;"],"names":["crypto","require","Redis","fs","promises","path","AgentTokenManager","options","redisHost","process","env","CFN_REDIS_HOST","redisPort","CFN_REDIS_PORT","defaultUrl","redisUrl","CFN_REDIS_URL","MCP_REDIS_URL","redis","agentConfigPath","defaultExpiry","initialize","createClient","url","connect","console","log","error","loadAgentConfig","configPath","resolve","config","readFile","JSON","parse","generateToken","randomBytes","toString","parseExpiry","expiry","match","value","parseInt","unit","multipliers","s","m","h","d","registerAgentToken","agentType","agentConfig","agents","find","a","type","Error","map","join","token","expiresIn","expiresAt","Date","now","tokenData","displayName","skills","allowedMcpServers","resourceLimits","createdAt","createdBy","description","key","stringify","ttlSeconds","setEx","toISOString","maxMemoryMB","maxRequestsPerMinute","message","listActiveTokens","pattern","keys","tokens","get","push","status","length","tokenShort","substring","padEnd","revokeToken","exists","del","revokeAllTokens","validateToken","valid","reason","getAgentInfo","repeat","maxConcurrentRequests","listAgentTypes","agent","name","shutdown","quit","main","args","argv","slice","command","exit","tokenManager","i","count","result","module","catch","exports"],"mappings":";AAEA;;;CAGC,GAED,MAAMA,SAASC,QAAQ;AACvB,MAAMC,QAAQD,QAAQ;AACtB,MAAME,KAAKF,QAAQ,MAAMG,QAAQ;AACjC,MAAMC,OAAOJ,QAAQ;AAErB,IAAA,AAAMK,oBAAN,MAAMA;IACJ,YAAYC,UAAU,CAAC,CAAC,CAAE;QACxB,uEAAuE;QACvE,sFAAsF;QACtF,MAAMC,YAAYC,QAAQC,GAAG,CAACC,cAAc,IAAI;QAChD,MAAMC,YAAYH,QAAQC,GAAG,CAACG,cAAc,IAAI;QAChD,MAAMC,aAAa,CAAC,QAAQ,EAAEN,UAAU,CAAC,EAAEI,WAAW;QACtD,IAAI,CAACG,QAAQ,GAAGR,QAAQQ,QAAQ,IAAIN,QAAQC,GAAG,CA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AC,WAAW,EAAEyF,OAAOnD,SAAS,CAACE,MAAM,CAACR,IAAI,CAAC,OAAO;wBAC9DjC,QAAQC,GAAG,CAAC,CAAC,YAAY,EAAE,IAAIoC,KAAKqD,OAAOnD,SAAS,CAACH,SAAS,EAAEe,WAAW,IAAI;oBACjF,OAAO;wBACLnD,QAAQC,GAAG,CAAC;wBACZD,QAAQC,GAAG,CAAC,CAAC,WAAW,EAAEyF,OAAOlB,MAAM,EAAE;oBAC3C;oBACA;gBACF;YAEA,KAAK;gBAAQ;oBACX,MAAM/C,YAAYyD,IAAI,CAAC,EAAE;oBACzB,IAAI,CAACzD,WAAW;wBACd,MAAM,IAAIM,MAAM;oBAClB;oBACA,MAAMwD,aAAad,YAAY,CAAChD;oBAChC;gBACF;YAEA,KAAK;gBAAS;oBACZ,MAAM8D,aAAaX,cAAc;oBACjC;gBACF;YAEA;gBACE,MAAM,IAAI7C,MAAM,CAAC,iBAAiB,EAAEsD,SAAS;QACjD;IAEF,EAAE,OAAOnF,OAAO;QACdF,QAAQE,KAAK,CAAC,YAAYA,MAAMoD,OAAO;QACvCtE,QAAQsG,IAAI,CAAC;IACf,SAAU;QACR,MAAMC,aAAaR,QAAQ;IAC7B;AACF;AAEA,IAAIvG,QAAQyG,IAAI,KAAKU,QAAQ;IAC3BV,OAAOW,KAAK,CAAC1F,CAAAA;QACXF,QAAQE,KAAK,CAAC,gBAAgBA;QAC9BlB,QAAQsG,IAAI,CAAC;IACf;AACF;AAEAK,OAAOE,OAAO,GAAGhH"}
|
|
@@ -5,17 +5,47 @@
|
|
|
5
5
|
* Supports streaming responses and tool execution.
|
|
6
6
|
*/ import Anthropic from '@anthropic-ai/sdk';
|
|
7
7
|
import fs from 'fs/promises';
|
|
8
|
+
import fsSync from 'fs';
|
|
8
9
|
import path from 'path';
|
|
9
10
|
import { exec } from 'child_process';
|
|
10
11
|
import { promisify } from 'util';
|
|
11
12
|
import { executeTool } from './tool-executor.js';
|
|
12
13
|
const execAsync = promisify(exec);
|
|
14
|
+
// File-based debug logging (for background agents)
|
|
15
|
+
const AGENT_ID = process.env.AGENT_ID || 'unknown';
|
|
16
|
+
const API_LOG_FILE = `/tmp/cfn-api-${AGENT_ID}.log`;
|
|
17
|
+
function apiDebugLog(message, data) {
|
|
18
|
+
const timestamp = new Date().toISOString();
|
|
19
|
+
const logEntry = data ? `${timestamp} [${AGENT_ID}] ${message} ${JSON.stringify(data)}\n` : `${timestamp} [${AGENT_ID}] ${message}\n`;
|
|
20
|
+
try {
|
|
21
|
+
fsSync.appendFileSync(API_LOG_FILE, logEntry);
|
|
22
|
+
} catch (err) {
|
|
23
|
+
// Ignore logging errors
|
|
24
|
+
}
|
|
25
|
+
}
|
|
13
26
|
/**
|
|
14
27
|
* Get API configuration from environment and config files
|
|
28
|
+
*
|
|
29
|
+
* Provider resolution order:
|
|
30
|
+
* 1. CLAUDE_API_PROVIDER env var (legacy)
|
|
31
|
+
* 2. PROVIDER env var (set by agent-spawner from --provider flag)
|
|
32
|
+
* 3. Config file (.claude/config/api-provider.json)
|
|
33
|
+
* 4. Default to Z.ai (cost-effective fallback per project requirements)
|
|
34
|
+
*
|
|
35
|
+
* BUG FIX: Previously only checked CLAUDE_API_PROVIDER, ignoring --provider flag
|
|
36
|
+
* which sets PROVIDER env var via agent-spawner.ts
|
|
15
37
|
*/ export async function getAPIConfig() {
|
|
16
|
-
// Check environment
|
|
17
|
-
const envProvider = process.env.CLAUDE_API_PROVIDER;
|
|
18
|
-
|
|
38
|
+
// Check environment variables - support both CLAUDE_API_PROVIDER (legacy) and PROVIDER (from CLI --provider flag)
|
|
39
|
+
const envProvider = process.env.CLAUDE_API_PROVIDER || process.env.PROVIDER;
|
|
40
|
+
// Debug logging for provider routing (helps diagnose auth errors)
|
|
41
|
+
apiDebugLog('getAPIConfig: Provider detection', {
|
|
42
|
+
CLAUDE_API_PROVIDER: process.env.CLAUDE_API_PROVIDER,
|
|
43
|
+
PROVIDER: process.env.PROVIDER,
|
|
44
|
+
resolved: envProvider
|
|
45
|
+
});
|
|
46
|
+
console.error(`[provider-routing] CLAUDE_API_PROVIDER=${process.env.CLAUDE_API_PROVIDER || 'unset'}, PROVIDER=${process.env.PROVIDER || 'unset'}, resolved=${envProvider || 'none'}`);
|
|
47
|
+
if (envProvider === 'zai' || envProvider === 'z.ai') {
|
|
48
|
+
console.error('[provider-routing] Using Z.ai provider');
|
|
19
49
|
return {
|
|
20
50
|
provider: 'zai',
|
|
21
51
|
apiKey: process.env.ZAI_API_KEY || process.env.ANTHROPIC_API_KEY,
|
|
@@ -23,6 +53,7 @@ const execAsync = promisify(exec);
|
|
|
23
53
|
};
|
|
24
54
|
}
|
|
25
55
|
if (envProvider === 'kimi') {
|
|
56
|
+
console.error('[provider-routing] Using Kimi provider');
|
|
26
57
|
return {
|
|
27
58
|
provider: 'kimi',
|
|
28
59
|
apiKey: process.env.KIMI_API_KEY,
|
|
@@ -30,17 +61,26 @@ const execAsync = promisify(exec);
|
|
|
30
61
|
};
|
|
31
62
|
}
|
|
32
63
|
if (envProvider === 'openrouter') {
|
|
64
|
+
console.error('[provider-routing] Using OpenRouter provider');
|
|
33
65
|
return {
|
|
34
66
|
provider: 'openrouter',
|
|
35
67
|
apiKey: process.env.OPENROUTER_API_KEY,
|
|
36
68
|
baseURL: process.env.OPENROUTER_BASE_URL || 'https://openrouter.ai/api/v1'
|
|
37
69
|
};
|
|
38
70
|
}
|
|
71
|
+
if (envProvider === 'anthropic') {
|
|
72
|
+
console.error('[provider-routing] Using Anthropic provider (explicit)');
|
|
73
|
+
return {
|
|
74
|
+
provider: 'anthropic',
|
|
75
|
+
apiKey: process.env.ANTHROPIC_API_KEY
|
|
76
|
+
};
|
|
77
|
+
}
|
|
39
78
|
// Check config file
|
|
40
79
|
try {
|
|
41
80
|
const configPath = path.join('.claude', 'config', 'api-provider.json');
|
|
42
81
|
const config = JSON.parse(await fs.readFile(configPath, 'utf-8'));
|
|
43
82
|
if (config.provider === 'zai' || config.provider === 'z.ai') {
|
|
83
|
+
console.error('[provider-routing] Using Z.ai provider (from config file)');
|
|
44
84
|
return {
|
|
45
85
|
provider: 'zai',
|
|
46
86
|
apiKey: config.apiKey || process.env.ZAI_API_KEY || process.env.ANTHROPIC_API_KEY,
|
|
@@ -48,6 +88,7 @@ const execAsync = promisify(exec);
|
|
|
48
88
|
};
|
|
49
89
|
}
|
|
50
90
|
if (config.provider === 'kimi') {
|
|
91
|
+
console.error('[provider-routing] Using Kimi provider (from config file)');
|
|
51
92
|
return {
|
|
52
93
|
provider: 'kimi',
|
|
53
94
|
apiKey: config.apiKey || process.env.KIMI_API_KEY,
|
|
@@ -55,36 +96,76 @@ const execAsync = promisify(exec);
|
|
|
55
96
|
};
|
|
56
97
|
}
|
|
57
98
|
if (config.provider === 'openrouter') {
|
|
99
|
+
console.error('[provider-routing] Using OpenRouter provider (from config file)');
|
|
58
100
|
return {
|
|
59
101
|
provider: 'openrouter',
|
|
60
102
|
apiKey: config.apiKey || process.env.OPENROUTER_API_KEY,
|
|
61
103
|
baseURL: config.baseURL || process.env.OPENROUTER_BASE_URL || 'https://openrouter.ai/api/v1'
|
|
62
104
|
};
|
|
63
105
|
}
|
|
106
|
+
if (config.provider === 'anthropic') {
|
|
107
|
+
console.error('[provider-routing] Using Anthropic provider (from config file)');
|
|
108
|
+
return {
|
|
109
|
+
provider: 'anthropic',
|
|
110
|
+
apiKey: config.apiKey || process.env.ANTHROPIC_API_KEY
|
|
111
|
+
};
|
|
112
|
+
}
|
|
64
113
|
} catch {
|
|
65
114
|
// Config file doesn't exist, use defaults
|
|
66
115
|
}
|
|
67
|
-
// Default to
|
|
116
|
+
// Default to Z.ai (cost-effective fallback per project requirements)
|
|
117
|
+
// BUG FIX: Previously defaulted to Anthropic which caused auth errors when no provider specified
|
|
118
|
+
console.error('[provider-routing] Using Z.ai provider (default fallback)');
|
|
68
119
|
return {
|
|
69
|
-
provider: '
|
|
70
|
-
apiKey: process.env.ANTHROPIC_API_KEY
|
|
120
|
+
provider: 'zai',
|
|
121
|
+
apiKey: process.env.ZAI_API_KEY || process.env.ANTHROPIC_API_KEY,
|
|
122
|
+
baseURL: process.env.ZAI_BASE_URL || 'https://api.z.ai/api/anthropic'
|
|
71
123
|
};
|
|
72
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Validate provider configuration before creating client
|
|
127
|
+
* Provides clear error messages for missing credentials
|
|
128
|
+
*/ export function validateProviderConfig(config) {
|
|
129
|
+
if (!config.apiKey) {
|
|
130
|
+
const envVarMap = {
|
|
131
|
+
'zai': 'ZAI_API_KEY (or ANTHROPIC_API_KEY)',
|
|
132
|
+
'anthropic': 'ANTHROPIC_API_KEY',
|
|
133
|
+
'kimi': 'KIMI_API_KEY',
|
|
134
|
+
'openrouter': 'OPENROUTER_API_KEY'
|
|
135
|
+
};
|
|
136
|
+
const requiredVar = envVarMap[config.provider] || `${config.provider.toUpperCase()}_API_KEY`;
|
|
137
|
+
throw new Error(`[provider-validation] API key not found for provider '${config.provider}'. ` + `Set the ${requiredVar} environment variable.\n` + `Tip: If using --provider flag, ensure the corresponding API key is exported.`);
|
|
138
|
+
}
|
|
139
|
+
// Provider-specific validation
|
|
140
|
+
if (config.provider === 'kimi' || config.provider === 'openrouter') {
|
|
141
|
+
console.error(`[provider-validation] WARNING: Provider '${config.provider}' uses OpenAI-compatible API format.`);
|
|
142
|
+
console.error(`[provider-validation] The current implementation uses Anthropic SDK which may not be compatible.`);
|
|
143
|
+
console.error(`[provider-validation] Consider using provider 'zai' or 'anthropic' for now.`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
73
146
|
/**
|
|
74
147
|
* Create Anthropic client with appropriate configuration
|
|
148
|
+
*
|
|
149
|
+
* Supports providers that use Anthropic-compatible API format:
|
|
150
|
+
* - anthropic: Direct Anthropic API
|
|
151
|
+
* - zai: Z.ai proxy (Anthropic-compatible)
|
|
152
|
+
*
|
|
153
|
+
* For OpenAI-compatible providers (kimi, openrouter), this client
|
|
154
|
+
* may not work correctly. Future enhancement: add OpenAI client support.
|
|
75
155
|
*/ export async function createClient() {
|
|
76
156
|
const config = await getAPIConfig();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
157
|
+
// Validate configuration before attempting API call
|
|
158
|
+
validateProviderConfig(config);
|
|
80
159
|
const clientOptions = {
|
|
81
160
|
apiKey: config.apiKey,
|
|
82
161
|
timeout: 120000,
|
|
83
162
|
maxRetries: 2
|
|
84
163
|
};
|
|
85
|
-
|
|
164
|
+
// Z.ai uses Anthropic-compatible API format with custom base URL
|
|
165
|
+
if ((config.provider === 'zai' || config.provider === 'anthropic') && config.baseURL) {
|
|
86
166
|
clientOptions.baseURL = config.baseURL;
|
|
87
167
|
}
|
|
168
|
+
console.error(`[anthropic-client] Creating client for provider: ${config.provider}`);
|
|
88
169
|
return new Anthropic(clientOptions);
|
|
89
170
|
}
|
|
90
171
|
/**
|
|
@@ -124,8 +205,8 @@ const execAsync = promisify(exec);
|
|
|
124
205
|
let model = mapModelName(options.model, config.provider);
|
|
125
206
|
const maxTokens = options.maxTokens || 16000; // Sprint 6: 16K hard limit for GLM-4.6 (agents target 10K for buffer)
|
|
126
207
|
const temperature = options.temperature ?? 1.0;
|
|
127
|
-
//
|
|
128
|
-
|
|
208
|
+
// Streaming supported for both providers; retry without streaming if a provider rejects it
|
|
209
|
+
let enableStreaming = !!options.stream;
|
|
129
210
|
console.log(`[anthropic-client] Provider: ${config.provider}`);
|
|
130
211
|
console.log(`[anthropic-client] Model: ${model}`);
|
|
131
212
|
console.log(`[anthropic-client] Max tokens: ${maxTokens}`);
|
|
@@ -168,7 +249,7 @@ const execAsync = promisify(exec);
|
|
|
168
249
|
requestParams.tools = options.tools;
|
|
169
250
|
}
|
|
170
251
|
try {
|
|
171
|
-
// Streaming response
|
|
252
|
+
// Streaming response (preferred)
|
|
172
253
|
if (enableStreaming) {
|
|
173
254
|
let fullContent = '';
|
|
174
255
|
let inputTokens = 0;
|
|
@@ -220,6 +301,13 @@ const execAsync = promisify(exec);
|
|
|
220
301
|
stopReason: response.stop_reason || 'end_turn'
|
|
221
302
|
};
|
|
222
303
|
} catch (error) {
|
|
304
|
+
// If streaming fails on Z.ai, retry once without streaming before falling back to model fallback logic
|
|
305
|
+
if (enableStreaming && config.provider === 'zai') {
|
|
306
|
+
console.warn('[anthropic-client] Streaming failed on z.ai, retrying without streaming:', error);
|
|
307
|
+
enableStreaming = false;
|
|
308
|
+
attempts--; // do not consume a model attempt
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
223
311
|
lastError = error instanceof Error ? error : new Error(String(error));
|
|
224
312
|
console.error(`[anthropic-client] Error with model ${currentModel}:`, lastError.message);
|
|
225
313
|
// If this was the last attempt, throw the error
|
|
@@ -279,11 +367,22 @@ const execAsync = promisify(exec);
|
|
|
279
367
|
}
|
|
280
368
|
// Make API request (non-streaming for now to handle tool_use)
|
|
281
369
|
const response = await client.messages.create(requestParams);
|
|
370
|
+
apiDebugLog('executeWithTools: API response received', {
|
|
371
|
+
iteration,
|
|
372
|
+
contentBlockCount: response.content.length,
|
|
373
|
+
blockTypes: response.content.map((b)=>b.type),
|
|
374
|
+
stopReason: response.stop_reason
|
|
375
|
+
});
|
|
282
376
|
totalInputTokens += response.usage.input_tokens;
|
|
283
377
|
totalOutputTokens += response.usage.output_tokens;
|
|
284
378
|
// Extract content blocks
|
|
285
379
|
const textBlocks = response.content.filter((block)=>block.type === 'text');
|
|
286
380
|
const toolUseBlocks = response.content.filter((block)=>block.type === 'tool_use');
|
|
381
|
+
apiDebugLog('executeWithTools: Blocks extracted', {
|
|
382
|
+
textBlockCount: textBlocks.length,
|
|
383
|
+
toolUseBlockCount: toolUseBlocks.length,
|
|
384
|
+
toolNames: toolUseBlocks.map((b)=>b.name)
|
|
385
|
+
});
|
|
287
386
|
// Stream text output
|
|
288
387
|
for (const block of textBlocks){
|
|
289
388
|
if (block.type === 'text') {
|
|
@@ -356,11 +455,21 @@ const execAsync = promisify(exec);
|
|
|
356
455
|
let heartbeatInterval = null;
|
|
357
456
|
const taskId = process.env.TASK_ID;
|
|
358
457
|
// Bug #6 Fix: Read Redis connection parameters from process.env and interpolate in TypeScript
|
|
359
|
-
|
|
458
|
+
// FIX: Default to 'localhost' for CLI mode (host execution), not 'cfn-redis' (Docker)
|
|
459
|
+
const redisHost = process.env.CFN_REDIS_HOST || 'localhost';
|
|
360
460
|
const redisPort = process.env.CFN_REDIS_PORT || '6379';
|
|
361
461
|
try {
|
|
462
|
+
apiDebugLog('executeAgentAPI: ENTRY', {
|
|
463
|
+
agentType,
|
|
464
|
+
agentId,
|
|
465
|
+
hasTools: !!tools,
|
|
466
|
+
toolsLength: tools?.length || 0,
|
|
467
|
+
toolNames: tools?.map((t)=>t.name) || []
|
|
468
|
+
});
|
|
362
469
|
console.log(`[anthropic-client] Executing agent: ${agentType}`);
|
|
363
470
|
console.log(`[anthropic-client] Agent ID: ${agentId}`);
|
|
471
|
+
console.error(`[TOOL DEBUG executeAgentAPI] tools parameter: ${tools ? `Array[${tools.length}]` : 'undefined'}`);
|
|
472
|
+
console.error(`[TOOL DEBUG executeAgentAPI] tools names: ${tools?.map((t)=>t.name).join(', ') || 'NONE'}`);
|
|
364
473
|
if (messages && messages.length > 1) {
|
|
365
474
|
console.log(`[anthropic-client] Continuing conversation (${messages.length} messages)`);
|
|
366
475
|
}
|
|
@@ -380,6 +489,10 @@ const execAsync = promisify(exec);
|
|
|
380
489
|
// Otherwise use simple streaming
|
|
381
490
|
let response;
|
|
382
491
|
if (tools && tools.length > 0) {
|
|
492
|
+
apiDebugLog('executeAgentAPI: Using tool execution path', {
|
|
493
|
+
toolCount: tools.length,
|
|
494
|
+
toolNames: tools.map((t)=>t.name)
|
|
495
|
+
});
|
|
383
496
|
console.log(`[anthropic-client] Tools enabled: ${tools.map((t)=>t.name).join(', ')}`);
|
|
384
497
|
response = await executeWithTools({
|
|
385
498
|
model,
|