claude-flow-novice 2.15.11 → 2.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
- package/.claude/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +1 -1
- package/.claude/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +1 -1
- package/.claude/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +1 -1
- package/.claude/cfn-extras/skills/google-sheets-progress/SKILL.md +1 -1
- package/.claude/commands/CFN_LOOP_FRONTEND.md +1 -1
- package/.claude/commands/cfn-loop-cli.md +214 -442
- package/.claude/commands/cfn-loop-frontend.md +1 -1
- package/.claude/commands/cfn-loop-task.md +2 -2
- package/.claude/commands/cfn-loop-trigger.md +114 -0
- package/.claude/commands/deprecated/cfn-loop.md +2 -2
- package/.claude/hooks/cfn-invoke-post-edit-ts.sh +100 -0
- package/.claude/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
- package/.claude/hooks/cfn-invoke-post-edit.sh +53 -5
- package/.claude/hooks/cfn-invoke-post-edit.sh.backup +87 -0
- package/.claude/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
- package/.claude/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
- package/.claude/hooks/cfn-invoke-pre-edit.sh +22 -0
- package/.claude/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
- package/.claude/hooks/cfn-post-edit.config.json +9 -2
- package/.claude/root-claude-distribute/CFN-CLAUDE.md +1 -1
- package/.claude/skills/cfn-agent-spawning/SKILL.md +48 -1
- package/.claude/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
- package/.claude/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
- package/.claude/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
- package/.claude/skills/{cfn-redis-coordination/check-dependencies.sh → cfn-agent-spawning/check-dependencies.sh.backup} +3 -5
- package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
- package/.claude/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
- package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
- package/.claude/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
- package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
- package/.claude/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
- package/.claude/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
- package/.claude/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
- package/.claude/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
- package/.claude/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
- package/.claude/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
- package/.claude/skills/cfn-backlog-management/SKILL.md +1 -1
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
- package/.claude/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
- package/.claude/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
- package/.claude/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
- package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
- package/.claude/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
- package/.claude/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
- package/.claude/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
- package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
- package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
- package/.claude/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
- package/.claude/skills/cfn-loop-orchestration/SKILL.md +159 -48
- package/.claude/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
- package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
- package/.claude/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
- package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
- package/.claude/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
- package/.claude/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
- package/.claude/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
- package/.claude/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
- package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
- package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
- package/.claude/skills/cfn-loop-orchestration/{orchestrate-wrapper.sh → archive/legacy-bash/orchestrate-wrapper.sh} +11 -1
- package/.claude/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
- package/.claude/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
- package/.claude/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
- package/.claude/skills/cfn-loop-orchestration/package-lock.json +3 -0
- package/.claude/skills/cfn-loop-orchestration/package.json +4 -0
- package/.claude/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
- package/.claude/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
- package/.claude/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
- package/.claude/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
- package/.claude/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
- package/.claude/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
- package/.claude/skills/cfn-loop-orchestration/src/index.ts +2 -0
- package/.claude/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
- package/.claude/skills/cfn-loop-orchestration/src/types.ts +56 -0
- package/.claude/skills/cfn-loop-orchestration/test-cli.sh +92 -0
- package/.claude/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
- package/.claude/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
- package/.claude/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
- package/.claude/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
- package/.claude/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
- package/.claude/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
- package/.claude/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
- package/.claude/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
- package/.claude/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
- package/.claude/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
- package/.claude/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
- package/.claude/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
- package/.claude/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
- package/.claude/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
- package/.claude/skills/cfn-loop-validation/INDEX.md +531 -0
- package/.claude/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
- package/.claude/skills/cfn-loop-validation/SKILL.md +48 -1
- package/.claude/skills/cfn-loop-validation/SKILL.md.backup +353 -0
- package/.claude/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
- package/.claude/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
- package/.claude/skills/cfn-loop-validation/check-dependencies.sh +22 -0
- package/{claude-assets/skills/cfn-redis-coordination/check-dependencies.sh → .claude/skills/cfn-loop-validation/check-dependencies.sh.backup} +4 -5
- package/.claude/skills/cfn-loop-validation/detect-vapor.sh +59 -0
- package/.claude/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
- package/.claude/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
- package/.claude/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/types.d.ts +156 -0
- package/.claude/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/types.js +66 -0
- package/.claude/skills/cfn-loop-validation/dist/types.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
- package/.claude/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
- package/.claude/skills/cfn-loop-validation/dist/validator.js +411 -0
- package/.claude/skills/cfn-loop-validation/dist/validator.js.map +1 -0
- package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
- package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
- package/.claude/skills/cfn-loop-validation/package.json +93 -0
- package/.claude/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
- package/.claude/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
- package/.claude/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
- package/.claude/skills/cfn-loop-validation/src/types.ts +215 -0
- package/.claude/skills/cfn-loop-validation/src/validator.ts +503 -0
- package/.claude/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
- package/.claude/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
- package/.claude/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
- package/.claude/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
- package/.claude/skills/cfn-loop-validation/validate-gate.sh +63 -0
- package/.claude/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
- package/.claude/skills/cfn-loop-validation/validate-iteration.sh +22 -0
- package/.claude/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
- package/.claude/skills/cfn-product-owner-decision/SKILL.md +479 -147
- package/.claude/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
- package/.claude/skills/cfn-product-owner-decision/{execute-decision.sh → archive/legacy-bash/execute-decision.sh} +24 -2
- package/.claude/skills/pre-edit-backup/SKILL.md +324 -0
- package/.claude/skills/pre-edit-backup/SKILL.md.backup +277 -0
- package/.claude/skills/pre-edit-backup/backup.sh +22 -0
- package/.claude/skills/pre-edit-backup/backup.sh.backup +107 -0
- package/claude-assets/agents/cfn-dev-team/analysts/root-cause-analyst.md +2 -2
- package/claude-assets/agents/cfn-dev-team/architecture/base-template-generator.md +1 -1
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +3 -2
- package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +1 -0
- package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +2 -1
- package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +1 -0
- package/claude-assets/agents/cfn-dev-team/dev-ops/devops-engineer.md +11 -1
- package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +58 -35
- package/claude-assets/agents/cfn-dev-team/dev-ops/github-commit-agent.md +2 -2
- package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +47 -37
- package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +18 -18
- package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +40 -58
- package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +19 -21
- package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +20 -29
- package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +15 -19
- package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +15 -10
- package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +16 -11
- package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +16 -26
- package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +18 -22
- package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +17 -21
- package/claude-assets/agents/cfn-dev-team/documentation/pseudocode.md +1 -1
- package/claude-assets/agents/cfn-dev-team/product-owners/accessibility-advocate-persona.md +1 -1
- package/claude-assets/agents/cfn-dev-team/product-owners/cto-agent.md +1 -1
- package/claude-assets/agents/cfn-dev-team/product-owners/power-user-persona.md +1 -1
- package/claude-assets/agents/cfn-dev-team/product-owners/product-owner.md +1 -5
- package/claude-assets/agents/cfn-dev-team/reviewers/code-reviewer.md +20 -51
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +22 -71
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +21 -64
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +22 -67
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +24 -68
- package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +8 -36
- package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +9 -38
- package/claude-assets/agents/cfn-dev-team/testers/contract-tester.md +17 -55
- package/claude-assets/agents/cfn-dev-team/testers/e2e/playwright-tester.md +1 -1
- package/claude-assets/agents/cfn-dev-team/testers/integration-tester.md +18 -56
- package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +9 -37
- package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +18 -56
- package/claude-assets/agents/cfn-dev-team/testers/mutation-testing-specialist.md +18 -49
- package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +8 -37
- package/claude-assets/agents/cfn-dev-team/testers/tester.md +7 -27
- package/claude-assets/agents/cfn-dev-team/testers/unit/tdd-london-unit-swarm.md +1 -1
- package/claude-assets/agents/cfn-dev-team/utility/agent-builder.md +11 -0
- package/claude-assets/agents/cfn-dev-team/utility/analyst.md +13 -29
- package/claude-assets/agents/cfn-dev-team/utility/claude-code-expert.md +1 -1
- package/claude-assets/agents/cfn-dev-team/utility/code-booster.md +13 -13
- package/claude-assets/agents/cfn-dev-team/utility/context-curator.md +7 -2
- package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +6 -11
- package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +121 -715
- package/claude-assets/agents/cfn-dev-team/utility/researcher.md +13 -22
- package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +147 -573
- package/claude-assets/agents/custom/cfn-docker-expert.md +103 -0
- package/claude-assets/agents/custom/cfn-loops-cli-expert.md +438 -0
- package/claude-assets/agents/custom/cfn-redis-operations.md +529 -529
- package/claude-assets/agents/custom/cfn-system-expert.md +1 -1
- package/claude-assets/agents/custom/trigger-dev-expert.md +369 -0
- package/claude-assets/agents/docker-team/micro-sprint-planner.md +747 -747
- package/claude-assets/agents/project-only-agents/npm-package-specialist.md +1 -1
- package/claude-assets/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
- package/claude-assets/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +1 -1
- package/claude-assets/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +1 -1
- package/claude-assets/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +1 -1
- package/claude-assets/cfn-extras/skills/google-sheets-progress/SKILL.md +1 -1
- package/claude-assets/commands/CFN_LOOP_FRONTEND.md +1 -1
- package/claude-assets/commands/cfn-loop-cli.md +214 -442
- package/claude-assets/commands/cfn-loop-frontend.md +1 -1
- package/claude-assets/commands/cfn-loop-task.md +2 -2
- package/claude-assets/commands/cfn-loop-trigger.md +114 -0
- package/claude-assets/commands/deprecated/cfn-loop.md +2 -2
- package/claude-assets/hooks/GIT-HOOKS-USAGE-EXAMPLES.md +116 -0
- package/claude-assets/hooks/README-GIT-HOOKS.md +443 -0
- package/claude-assets/hooks/SKILL.md +518 -0
- package/claude-assets/hooks/SKILL.md.backup +471 -0
- package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh +100 -0
- package/claude-assets/hooks/cfn-invoke-post-edit-ts.sh.backup +78 -0
- package/claude-assets/hooks/cfn-invoke-post-edit.sh +53 -5
- package/claude-assets/hooks/cfn-invoke-post-edit.sh.backup +87 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit-ts.sh.backup +94 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit.sh +22 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit.sh.backup +88 -0
- package/claude-assets/hooks/cfn-post-edit.config.json +9 -2
- package/claude-assets/hooks/install-git-hooks.sh +243 -0
- package/claude-assets/hooks/subagent-start.sh +98 -0
- package/claude-assets/hooks/subagent-stop.sh +93 -0
- package/claude-assets/hooks/validators/credential-scanner.sh +172 -0
- package/claude-assets/root-claude-distribute/CFN-CLAUDE.md +1 -1
- package/claude-assets/skills/cfn-agent-selection-with-fallback/DELIVERABLES.md +409 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/IMPLEMENTATION_SUMMARY.md +396 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/INTEGRATION_GUIDE.md +308 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/QUICK_REFERENCE.md +239 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md +107 -1
- package/claude-assets/skills/cfn-agent-selection-with-fallback/SKILL.md.backup +302 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/TYPESCRIPT_MIGRATION.md +295 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.cjs +297 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/agent-selector.js +297 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.cjs +96 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/dist/cli.js +96 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh +45 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents-ts.sh.backup +23 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh +22 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/select-agents.sh.backup +173 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.test.ts +357 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/src/agent-selector.ts +350 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/src/cli.ts +74 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh +22 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/task-classifier.sh.backup +71 -0
- package/claude-assets/skills/cfn-agent-selection-with-fallback/tsconfig.json +18 -0
- package/claude-assets/skills/cfn-agent-spawning/SKILL.md +48 -1
- package/claude-assets/skills/cfn-agent-spawning/SKILL.md.backup +135 -0
- package/claude-assets/skills/cfn-agent-spawning/TYPESCRIPT_MIGRATION.md +567 -0
- package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/check-dependencies.sh.backup +30 -0
- package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/get-agent-provider-env.sh.backup +127 -0
- package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/parse-agent-provider.sh.backup +59 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh +63 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent-wrapper.sh.backup +41 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh +26 -1
- package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-templates.sh.backup +613 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh +22 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh.backup +176 -0
- package/claude-assets/skills/cfn-backlog-management/SKILL.md +1 -1
- package/claude-assets/skills/cfn-coordination/agent-completion.sh.backup +36 -0
- package/claude-assets/skills/cfn-coordination/coordination-signal.sh.backup +36 -0
- package/claude-assets/skills/cfn-coordination/coordination-wait.sh.backup +36 -0
- package/claude-assets/skills/cfn-dependency-ingestion/README.md +101 -0
- package/claude-assets/skills/cfn-dependency-ingestion/SKILL.md +397 -0
- package/claude-assets/skills/cfn-dependency-ingestion/build.sh +23 -0
- package/claude-assets/skills/cfn-dependency-ingestion/dist/ingest-dependencies.js +478 -0
- package/claude-assets/skills/cfn-dependency-ingestion/ingest-dependencies.sh +295 -0
- package/claude-assets/skills/cfn-dependency-ingestion/ingest.sh +237 -0
- package/claude-assets/skills/cfn-dependency-ingestion/manifests/cli-mode-dependencies.txt +73 -0
- package/claude-assets/skills/cfn-dependency-ingestion/manifests/shared-dependencies.txt +57 -0
- package/claude-assets/skills/cfn-dependency-ingestion/manifests/trigger-dev-dependencies.txt +82 -0
- package/claude-assets/skills/cfn-dependency-ingestion/manifests/trigger-mode-dependencies.txt +80 -0
- package/claude-assets/skills/cfn-dependency-ingestion/src/ingest-dependencies.ts +563 -0
- package/claude-assets/skills/cfn-environment-sanitization/sanitize-environment.sh +14 -4
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/metadata.json +8 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/original +271 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763619700_33aff4a69b99159e4e849107ebc4d09f/revert.sh +7 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/metadata.json +8 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/original +325 -0
- package/claude-assets/skills/cfn-loop-orchestration/.backups/unknown/1763671642_06496e8c399a79db08167cc00ed4b31e/revert.sh +7 -0
- package/claude-assets/skills/cfn-loop-orchestration/CLI_IMPLEMENTATION_SUMMARY.md +330 -0
- package/claude-assets/skills/cfn-loop-orchestration/CONFIGURATION_IMPROVEMENTS.md +318 -0
- package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_MIGRATION.md +308 -0
- package/claude-assets/skills/cfn-loop-orchestration/CONTEXT_LOOKUP_QUICK_START.md +378 -0
- package/claude-assets/skills/cfn-loop-orchestration/E2E_VALIDATION_REPORT.md +262 -0
- package/claude-assets/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +319 -519
- package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_E2E_REPORT.md +299 -0
- package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_EXECUTION_SUMMARY.md +403 -0
- package/claude-assets/skills/cfn-loop-orchestration/NORTH_STAR_INDEX.md +323 -0
- package/claude-assets/skills/cfn-loop-orchestration/SKILL.md +159 -48
- package/claude-assets/skills/cfn-loop-orchestration/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
- package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_REPORT.md +335 -0
- package/claude-assets/skills/cfn-loop-orchestration/TEST_COVERAGE_SUMMARY.md +456 -0
- package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_REPORT.md +709 -0
- package/claude-assets/skills/cfn-loop-orchestration/TYPESCRIPT_INTEGRATION_SUMMARY.md +257 -0
- package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_REPORT.md +572 -0
- package/claude-assets/skills/cfn-loop-orchestration/VALIDATION_SUMMARY.txt +196 -0
- package/claude-assets/skills/cfn-loop-orchestration/VALIDATOR_MODULE_GUIDE.md +526 -0
- package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/README.md +167 -0
- package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate-enhanced.sh +548 -0
- package/claude-assets/skills/cfn-loop-orchestration/{orchestrate-wrapper.sh → archive/legacy-bash/orchestrate-wrapper.sh} +11 -1
- package/claude-assets/skills/cfn-loop-orchestration/archive/legacy-bash/orchestrate.sh +182 -0
- package/claude-assets/skills/cfn-loop-orchestration/e2e-validation-fixed.js +240 -0
- package/claude-assets/skills/cfn-loop-orchestration/e2e-validation.js +213 -0
- package/claude-assets/skills/cfn-loop-orchestration/package-lock.json +3 -0
- package/claude-assets/skills/cfn-loop-orchestration/package.json +4 -0
- package/claude-assets/skills/cfn-loop-orchestration/run-north-star-e2e.ts +210 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/cli/orchestrator-cli.ts +396 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_IMPLEMENTATION.md +375 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/confidence-aggregator.ts +473 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/consensus.ts +1 -1
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-injector.ts +349 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/context-lookup.ts +486 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/deliverable-verifier.ts +6 -2
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/gate-check.ts +1 -1
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/product-owner-decision.ts +316 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/spawn-agents.ts +357 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/helpers/validator.ts +276 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/index.ts +2 -0
- package/claude-assets/skills/cfn-loop-orchestration/src/orchestrate.ts +743 -2
- package/claude-assets/skills/cfn-loop-orchestration/src/types.ts +56 -0
- package/claude-assets/skills/cfn-loop-orchestration/test-cli.sh +92 -0
- package/claude-assets/skills/cfn-loop-orchestration/test-typescript-integration.sh +442 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/agent-spawner.test.ts +124 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/confidence-aggregator.test.ts +604 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/context-injector.test.ts +561 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/context-lookup.test.ts +661 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/deliverable-verifier.test.ts +2 -2
- package/claude-assets/skills/cfn-loop-orchestration/tests/gate-check-edge-cases.test.ts +422 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/gate-checker.test.ts +276 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/logger.test.ts +291 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/north-star-e2e.test.ts +334 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/redis-coordinator.test.ts +321 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/spawn-agents.test.ts +284 -0
- package/claude-assets/skills/cfn-loop-orchestration/tests/validator.test.ts +643 -0
- package/claude-assets/skills/cfn-loop-output-processing/.eslintrc.json +33 -0
- package/claude-assets/skills/cfn-loop-output-processing/DELIVERY_SUMMARY.txt +462 -0
- package/claude-assets/skills/cfn-loop-output-processing/DEPRECATION_NOTICE.md +183 -0
- package/claude-assets/skills/cfn-loop-output-processing/EXAMPLES.md +609 -0
- package/claude-assets/skills/cfn-loop-output-processing/IMPLEMENTATION_SUMMARY.md +418 -0
- package/claude-assets/skills/cfn-loop-output-processing/INDEX.md +531 -0
- package/claude-assets/skills/cfn-loop-output-processing/MIGRATION.md +362 -0
- package/claude-assets/skills/cfn-loop-output-processing/README.md +114 -0
- package/claude-assets/skills/cfn-loop-output-processing/SKILL.md +633 -0
- package/{.claude/skills/cfn-docker-redis-coordination → claude-assets/skills/cfn-loop-output-processing}/jest.config.js +7 -15
- package/claude-assets/skills/cfn-loop-output-processing/package.json +50 -0
- package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop2.ts +195 -0
- package/claude-assets/skills/cfn-loop-output-processing/src/cli/process-loop3.ts +157 -0
- package/claude-assets/skills/cfn-loop-output-processing/src/output-processor.ts +632 -0
- package/claude-assets/skills/cfn-loop-output-processing/tests/output-processor.test.ts +617 -0
- package/claude-assets/skills/{cfn-docker-redis-coordination → cfn-loop-output-processing}/tsconfig.json +16 -7
- package/claude-assets/skills/cfn-loop-validation/IMPLEMENTATION_SUMMARY.md +672 -0
- package/claude-assets/skills/cfn-loop-validation/INDEX.md +531 -0
- package/claude-assets/skills/cfn-loop-validation/README_TYPESCRIPT.md +454 -0
- package/claude-assets/skills/cfn-loop-validation/SKILL.md +48 -1
- package/claude-assets/skills/cfn-loop-validation/SKILL.md.backup +353 -0
- package/claude-assets/skills/cfn-loop-validation/SKILL_TYPESCRIPT.md +782 -0
- package/claude-assets/skills/cfn-loop-validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
- package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh +22 -0
- package/claude-assets/skills/cfn-loop-validation/check-dependencies.sh.backup +31 -0
- package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh +59 -0
- package/claude-assets/skills/cfn-loop-validation/detect-vapor.sh.backup +37 -0
- package/claude-assets/skills/cfn-loop-validation/dist/.tsbuildinfo +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts +14 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js +185 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/detect-vapor.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts +14 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js +176 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-deliverables.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts +19 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js +123 -0
- package/claude-assets/skills/cfn-loop-validation/dist/cli/validate-gate.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts +156 -0
- package/claude-assets/skills/cfn-loop-validation/dist/types.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/types.js +66 -0
- package/claude-assets/skills/cfn-loop-validation/dist/types.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts +85 -0
- package/claude-assets/skills/cfn-loop-validation/dist/validator.d.ts.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/dist/validator.js +411 -0
- package/claude-assets/skills/cfn-loop-validation/dist/validator.js.map +1 -0
- package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +22 -0
- package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh.backup +252 -0
- package/claude-assets/skills/cfn-loop-validation/package.json +93 -0
- package/claude-assets/skills/cfn-loop-validation/src/cli/detect-vapor.ts +177 -0
- package/claude-assets/skills/cfn-loop-validation/src/cli/validate-deliverables.ts +161 -0
- package/claude-assets/skills/cfn-loop-validation/src/cli/validate-gate.ts +139 -0
- package/claude-assets/skills/cfn-loop-validation/src/types.ts +215 -0
- package/claude-assets/skills/cfn-loop-validation/src/validator.ts +503 -0
- package/claude-assets/skills/cfn-loop-validation/tests/validator.test.ts +537 -0
- package/claude-assets/skills/{cfn-redis-coordination → cfn-loop-validation}/tsconfig.json +34 -31
- package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh +59 -0
- package/claude-assets/skills/cfn-loop-validation/validate-deliverables.sh.backup +37 -0
- package/claude-assets/skills/cfn-loop-validation/validate-gate.sh +63 -0
- package/claude-assets/skills/cfn-loop-validation/validate-gate.sh.backup +41 -0
- package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh +22 -0
- package/claude-assets/skills/cfn-loop-validation/validate-iteration.sh.backup +134 -0
- package/claude-assets/skills/cfn-product-owner-decision/SKILL.md +479 -147
- package/claude-assets/skills/cfn-product-owner-decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
- package/claude-assets/skills/cfn-product-owner-decision/{execute-decision.sh → archive/legacy-bash/execute-decision.sh} +24 -2
- package/claude-assets/skills/cfn-provider-routing/README.md +129 -0
- package/claude-assets/skills/cfn-provider-routing/SKILL.md +215 -0
- package/claude-assets/skills/cfn-provider-routing/resolve-provider-model.ts +223 -0
- package/claude-assets/skills/docker-build/build.sh +1 -1
- package/claude-assets/skills/pre-edit-backup/SKILL.md +324 -0
- package/claude-assets/skills/pre-edit-backup/SKILL.md.backup +277 -0
- package/claude-assets/skills/pre-edit-backup/backup.sh +22 -0
- package/claude-assets/skills/pre-edit-backup/backup.sh.backup +107 -0
- package/dist/agent/skill-mcp-selector.js +2 -1
- package/dist/agent/skill-mcp-selector.js.map +1 -1
- package/dist/api/auth-endpoints.js +415 -0
- package/dist/api/auth-endpoints.js.map +1 -0
- package/dist/api/task-endpoints.js +562 -0
- package/dist/api/task-endpoints.js.map +1 -0
- package/dist/backend/server.js +418 -0
- package/dist/backend/server.js.map +1 -0
- package/dist/cfn-loop/product-owner/decision-parser.js +356 -0
- package/dist/cfn-loop/product-owner/decision-parser.js.map +1 -0
- package/dist/cfn-loop/product-owner/index.js +1 -0
- package/dist/cfn-loop/product-owner/index.js.map +1 -1
- package/dist/cli/agent-command.js +1 -1
- package/dist/cli/agent-command.js.map +1 -1
- package/dist/cli/agent-completion.js +273 -0
- package/dist/cli/agent-completion.js.map +1 -0
- package/dist/cli/agent-executor.js +470 -26
- package/dist/cli/agent-executor.js.map +1 -1
- package/dist/cli/agent-prompt-builder.js +83 -48
- package/dist/cli/agent-prompt-builder.js.map +1 -1
- package/dist/cli/agent-spawn.js +7 -4
- package/dist/cli/agent-spawn.js.map +1 -1
- package/dist/cli/agent-spawner.js +546 -0
- package/dist/cli/agent-spawner.js.map +1 -0
- package/dist/cli/agent-token-manager.js +2 -1
- package/dist/cli/agent-token-manager.js.map +1 -1
- package/dist/cli/anthropic-client.js +127 -14
- package/dist/cli/anthropic-client.js.map +1 -1
- package/dist/cli/cfn-context.js +2 -1
- package/dist/cli/cfn-context.js.map +1 -1
- package/dist/cli/cfn-metrics.js +2 -1
- package/dist/cli/cfn-metrics.js.map +1 -1
- package/dist/cli/cfn-redis.js +2 -1
- package/dist/cli/cfn-redis.js.map +1 -1
- package/dist/cli/cli-agent-context.js +2 -0
- package/dist/cli/cli-agent-context.js.map +1 -1
- package/dist/cli/config-manager.js +90 -356
- package/dist/cli/config-manager.js.map +1 -1
- package/dist/cli/conversation-fork-cleanup.js +2 -1
- package/dist/cli/conversation-fork-cleanup.js.map +1 -1
- package/dist/cli/conversation-fork.js +2 -1
- package/dist/cli/conversation-fork.js.map +1 -1
- package/dist/cli/coordination/agent-messaging.js +415 -0
- package/dist/cli/coordination/agent-messaging.js.map +1 -0
- package/dist/cli/coordination/wait-for-threshold.js +232 -0
- package/dist/cli/coordination/wait-for-threshold.js.map +1 -0
- package/dist/cli/index.js +11 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/iteration-history.js +2 -1
- package/dist/cli/iteration-history.js.map +1 -1
- package/dist/cli/parse-decision-cli.js +268 -0
- package/dist/cli/parse-decision-cli.js.map +1 -0
- package/dist/cli/post-edit-hook.js +83 -0
- package/dist/cli/post-edit-hook.js.map +1 -0
- package/dist/cli/pre-edit-hook.js +77 -0
- package/dist/cli/pre-edit-hook.js.map +1 -0
- package/dist/cli/process-lifecycle.js +5 -1
- package/dist/cli/process-lifecycle.js.map +1 -1
- package/dist/cli/spawn-agent-cli.js +244 -0
- package/dist/cli/spawn-agent-cli.js.map +1 -0
- package/dist/coordination/coordination-wrapper.js +383 -0
- package/dist/coordination/coordination-wrapper.js.map +1 -0
- package/dist/coordination/redis-waiting-mode.js +4 -0
- package/dist/coordination/redis-waiting-mode.js.map +1 -1
- package/dist/coordination/store-success-criteria.js +68 -0
- package/dist/coordination/store-success-criteria.js.map +1 -0
- package/dist/coordination/store-task-context.js +65 -0
- package/dist/coordination/store-task-context.js.map +1 -0
- package/dist/hooks/backup-manager.js +273 -0
- package/dist/hooks/backup-manager.js.map +1 -0
- package/dist/hooks/post-edit-validator.js +388 -0
- package/dist/hooks/post-edit-validator.js.map +1 -0
- package/dist/integration/index.js +19 -0
- package/dist/integration/index.js.map +1 -0
- package/dist/integration/task-mode-adapter.js +297 -0
- package/dist/integration/task-mode-adapter.js.map +1 -0
- package/dist/integration/trigger-dev-client.js +253 -0
- package/dist/integration/trigger-dev-client.js.map +1 -0
- package/dist/integration/trigger-dev-webhooks.js +362 -0
- package/dist/integration/trigger-dev-webhooks.js.map +1 -0
- package/dist/lib/artifact-registry.js +4 -0
- package/dist/lib/artifact-registry.js.map +1 -1
- package/dist/lib/connection-pool.js +390 -0
- package/dist/lib/connection-pool.js.map +1 -0
- package/dist/lib/environment-contract.js +258 -0
- package/dist/lib/environment-contract.js.map +1 -0
- package/dist/lib/path-validator.js +14 -5
- package/dist/lib/path-validator.js.map +1 -1
- package/dist/lib/query-optimizer.js +388 -0
- package/dist/lib/query-optimizer.js.map +1 -0
- package/dist/lib/redis-queue-manager.js +5 -1
- package/dist/lib/redis-queue-manager.js.map +1 -1
- package/dist/lib/result-cache.js +285 -0
- package/dist/lib/result-cache.js.map +1 -0
- package/dist/mcp/auth-middleware.js +2 -1
- package/dist/mcp/auth-middleware.js.map +1 -1
- package/dist/mcp/playwright-mcp-server-auth.js +2 -1
- package/dist/mcp/playwright-mcp-server-auth.js.map +1 -1
- package/dist/middleware/authentication.js +317 -0
- package/dist/middleware/authentication.js.map +1 -0
- package/dist/services/authentication.js +669 -0
- package/dist/services/authentication.js.map +1 -0
- package/dist/services/session-management.js +436 -0
- package/dist/services/session-management.js.map +1 -0
- package/dist/services/skill-deployment.js +8 -6
- package/dist/services/skill-deployment.js.map +1 -1
- package/dist/services/user-service.js +710 -0
- package/dist/services/user-service.js.map +1 -0
- package/dist/types/trigger-dev-events.d.js +10 -0
- package/dist/types/trigger-dev-events.d.js.map +1 -0
- package/docs/README.md +240 -0
- package/package.json +15 -4
- package/scripts/build-agent-image.sh +1 -1
- package/scripts/compare-workflow-performance.sh +556 -0
- package/scripts/cost-allocation-tracker.sh +632 -0
- package/scripts/docker-rebuild-all-agents.sh +2 -2
- package/scripts/migrate-to-optimized-workflows.sh +438 -0
- package/scripts/organize-docs.sh +338 -0
- package/scripts/reorganize-tests.sh +280 -0
- package/scripts/trigger-dev-setup.sh +279 -0
- package/tests/README.md +45 -0
- package/.claude/commands/cost-savings-status.md +0 -34
- package/.claude/commands/metrics-summary.md +0 -58
- package/.claude/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
- package/.claude/skills/cfn-docker-redis-coordination/README.md +0 -294
- package/.claude/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
- package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
- package/.claude/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
- package/.claude/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
- package/.claude/skills/cfn-docker-redis-coordination/package.json +0 -40
- package/.claude/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
- package/.claude/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
- package/.claude/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
- package/.claude/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
- package/.claude/skills/cfn-docker-redis-coordination/tsconfig.json +0 -30
- package/.claude/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
- package/.claude/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
- package/.claude/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
- package/.claude/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
- package/.claude/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
- package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
- package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
- package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
- package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
- package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
- package/.claude/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
- package/.claude/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
- package/.claude/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
- package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
- package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
- package/.claude/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
- package/.claude/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
- package/.claude/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
- package/.claude/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
- package/.claude/skills/cfn-redis-coordination/config.json +0 -61
- package/.claude/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
- package/.claude/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
- package/.claude/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
- package/.claude/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
- package/.claude/skills/cfn-redis-coordination/jest.config.js +0 -23
- package/.claude/skills/cfn-redis-coordination/package-lock.json +0 -5272
- package/.claude/skills/cfn-redis-coordination/package.json +0 -45
- package/.claude/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
- package/.claude/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
- package/.claude/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
- package/.claude/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
- package/.claude/skills/cfn-redis-coordination/src/index.ts +0 -82
- package/.claude/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
- package/.claude/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
- package/.claude/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
- package/.claude/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
- package/.claude/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
- package/.claude/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
- package/.claude/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
- package/.claude/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
- package/.claude/skills/cfn-redis-coordination/src/types.ts +0 -235
- package/.claude/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
- package/.claude/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
- package/.claude/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
- package/.claude/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
- package/.claude/skills/cfn-redis-coordination/test-redis-check.js +0 -84
- package/.claude/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
- package/.claude/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
- package/.claude/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +0 -980
- package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +0 -759
- package/claude-assets/agents/custom/test-mcp-access.md +0 -24
- package/claude-assets/agents/typescript-specialist.md +0 -280
- package/claude-assets/commands/cost-savings-status.md +0 -34
- package/claude-assets/commands/metrics-summary.md +0 -58
- package/claude-assets/skills/cfn-docker-redis-coordination/MIGRATION_SUMMARY.md +0 -348
- package/claude-assets/skills/cfn-docker-redis-coordination/README.md +0 -294
- package/claude-assets/skills/cfn-docker-redis-coordination/SKILL.md +0 -435
- package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh +0 -650
- package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh.backup-1763145142 +0 -641
- package/claude-assets/skills/cfn-docker-redis-coordination/jest.config.js +0 -37
- package/claude-assets/skills/cfn-docker-redis-coordination/package-lock.json +0 -5259
- package/claude-assets/skills/cfn-docker-redis-coordination/package.json +0 -40
- package/claude-assets/skills/cfn-docker-redis-coordination/src/coordinator.ts +0 -801
- package/claude-assets/skills/cfn-docker-redis-coordination/src/index.ts +0 -42
- package/claude-assets/skills/cfn-docker-redis-coordination/src/types.ts +0 -351
- package/claude-assets/skills/cfn-docker-redis-coordination/tests/coordinator.test.ts +0 -1464
- package/claude-assets/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +0 -228
- package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +0 -104
- package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus.sh +0 -94
- package/claude-assets/skills/cfn-loop-orchestration/helpers/context-injection.sh +0 -142
- package/claude-assets/skills/cfn-loop-orchestration/helpers/context-lookup.sh +0 -359
- package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +0 -123
- package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +0 -71
- package/claude-assets/skills/cfn-loop-orchestration/helpers/gate-check.sh +0 -56
- package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +0 -89
- package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +0 -87
- package/claude-assets/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +0 -104
- package/claude-assets/skills/cfn-loop-orchestration/helpers/parse-test-results.sh +0 -56
- package/claude-assets/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +0 -290
- package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +0 -47
- package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +0 -51
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +0 -1345
- package/claude-assets/skills/cfn-redis-cleanup/cleanup-redis.sh +0 -130
- package/claude-assets/skills/cfn-redis-coordination/AGENT_LOGGING.md +0 -280
- package/claude-assets/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +0 -209
- package/claude-assets/skills/cfn-redis-coordination/CENTRALIZED_REDIS_WRAPPER.md +0 -319
- package/claude-assets/skills/cfn-redis-coordination/agent-log.sh.bak +0 -124
- package/claude-assets/skills/cfn-redis-coordination/config.json +0 -61
- package/claude-assets/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +0 -82
- package/claude-assets/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +0 -274
- package/claude-assets/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -0
- package/claude-assets/skills/cfn-redis-coordination/docs/migration/PHASE_3_REDIS_COORDINATION_COMPLETION_REPORT.md +0 -553
- package/claude-assets/skills/cfn-redis-coordination/jest.config.js +0 -23
- package/claude-assets/skills/cfn-redis-coordination/package-lock.json +0 -5272
- package/claude-assets/skills/cfn-redis-coordination/package.json +0 -45
- package/claude-assets/skills/cfn-redis-coordination/src/agent-logger.ts +0 -446
- package/claude-assets/skills/cfn-redis-coordination/src/agent-recovery.ts +0 -454
- package/claude-assets/skills/cfn-redis-coordination/src/completion-reporter.ts +0 -396
- package/claude-assets/skills/cfn-redis-coordination/src/context-manager.ts +0 -327
- package/claude-assets/skills/cfn-redis-coordination/src/index.ts +0 -82
- package/claude-assets/skills/cfn-redis-coordination/src/mode-detector.ts +0 -155
- package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-client.ts +0 -305
- package/claude-assets/skills/cfn-redis-coordination/src/redis/redis-functions.ts +0 -283
- package/claude-assets/skills/cfn-redis-coordination/src/redis-client.ts +0 -654
- package/claude-assets/skills/cfn-redis-coordination/src/result-collector.ts +0 -437
- package/claude-assets/skills/cfn-redis-coordination/src/swarm-manager.ts +0 -494
- package/claude-assets/skills/cfn-redis-coordination/src/task-analyzer.ts +0 -404
- package/claude-assets/skills/cfn-redis-coordination/src/task-executor.ts +0 -423
- package/claude-assets/skills/cfn-redis-coordination/src/types.ts +0 -235
- package/claude-assets/skills/cfn-redis-coordination/src/waiting-coordinator.ts +0 -587
- package/claude-assets/skills/cfn-redis-coordination/store-success-criteria.sh +0 -85
- package/claude-assets/skills/cfn-redis-coordination/test-connection-attempts.js +0 -70
- package/claude-assets/skills/cfn-redis-coordination/test-mode-simple.js +0 -121
- package/claude-assets/skills/cfn-redis-coordination/test-redis-check.js +0 -84
- package/claude-assets/skills/cfn-redis-coordination/test-task-mode-redis.cjs +0 -391
- package/claude-assets/skills/cfn-redis-coordination/tests/coordination.test.ts +0 -788
- package/claude-assets/skills/cfn-redis-coordination/update-all-scripts.sh +0 -67
- package/claude-assets/skills/cfn-redis-data-extraction/SKILL.md +0 -442
- package/claude-assets/skills/cfn-redis-data-extraction/extract.sh +0 -306
- package/dist/coordination/index.js +0 -25
- package/dist/coordination/index.js.map +0 -1
- package/docs/BUG_19_MEMORY_LEAK_TASK_MODE.md +0 -405
- package/docs/MEMORY_CLEANUP_GUIDE.md +0 -358
- package/docs/MEMORY_LEAK_FIX_SUMMARY.md +0 -322
- package/docs/REDIS_CLEANUP_EXECUTIVE_SUMMARY.md +0 -319
- package/docs/REDIS_CLEANUP_VERIFICATION_REPORT.md +0 -574
- package/tests/test-memory-leak-task-mode.sh +0 -435
- /package/.claude/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
- /package/.claude/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
- /package/.claude/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-loop-orchestration/{inject-loop-context.sh → archive/legacy-bash/inject-loop-context.sh} +0 -0
- /package/claude-assets/skills/cfn-loop-orchestration/{monitor-execution.sh → archive/legacy-bash/monitor-execution.sh} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{agent-log.sh → agent-log.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{agent-recovery.sh → agent-recovery.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{analyze-task-complexity.sh → analyze-task-complexity.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/bash-wrappers/{store-context.sh → store-context.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{cancel-swarm.sh → cancel-swarm.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-exec.sh → cfn-loop-exec.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{cfn-loop-relaunch.sh → cfn-loop-relaunch.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{collect-confidence-scores.sh → collect-confidence-scores.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{collect-results.sh → collect-results.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{complete-swarm.sh → complete-swarm.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{get-context.sh → get-context.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{get-success-criteria.sh → get-success-criteria.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{invoke-waiting-mode.sh → invoke-waiting-mode.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{redis-cli-wrapper.sh → redis-cli-wrapper.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{redis-functions.sh → redis-functions.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{report-completion.sh → report-completion.sh.backup} +0 -0
- /package/claude-assets/skills/cfn-redis-coordination/{store-context.sh → store-context.sh.backup} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/conversation-fork.ts"],"sourcesContent":["/**\r\n * Conversation Fork Management\r\n *\r\n * Implements application-level conversation forking for CFN Loop iterations.\r\n * Stores conversation history in Redis and allows branching at specific points.\r\n *\r\n * Sprint 4: Conversation Forking (v2.7.0)\r\n */\r\n\r\nimport { execSync } from 'child_process';\r\nimport { randomBytes } from 'crypto';\r\n\r\n// Bug #6 Fix: Read Redis connection parameters from process.env\r\nconst redisHost = process.env.CFN_REDIS_HOST || 'cfn-redis';\r\nconst redisPort = process.env.CFN_REDIS_PORT || '6379';\r\n\r\nexport interface Message {\r\n role: 'user' | 'assistant';\r\n content: string;\r\n iteration: number;\r\n timestamp: string;\r\n}\r\n\r\nexport interface ForkMetadata {\r\n forkId: string;\r\n taskId: string;\r\n agentId: string;\r\n createdAt: string;\r\n parentIteration: number;\r\n messageCount: number;\r\n}\r\n\r\n/**\r\n * Store a message in conversation history\r\n * MEMORY LEAK FIX: Now sets TTL on message list to prevent indefinite accumulation\r\n */\r\nexport async function storeMessage(\r\n taskId: string,\r\n agentId: string,\r\n message: Message\r\n): Promise<void> {\r\n const key = `swarm:${taskId}:${agentId}:messages`;\r\n const messageJson = JSON.stringify(message);\r\n\r\n try {\r\n execSync(`redis-cli -h ${redisHost} -p ${redisPort} rpush \"${key}\" '${messageJson.replace(/'/g, \"'\\\\''\")}'`, {\r\n encoding: 'utf8'\r\n });\r\n\r\n // MEMORY LEAK FIX: Set TTL on message list (24h default)\r\n // This prevents messages from accumulating indefinitely across multiple tasks\r\n const messageTTL = parseInt(process.env.CFN_MESSAGE_TTL || '86400', 10); // 24 hours\r\n execSync(`redis-cli -h ${redisHost} -p ${redisPort} expire \"${key}\" ${messageTTL}`, {\r\n encoding: 'utf8'\r\n });\r\n } catch (error) {\r\n console.error(`[conversation-fork] Failed to store message:`, error);\r\n throw error;\r\n }\r\n}\r\n\r\n/**\r\n * Load all messages from conversation history\r\n */\r\nexport async function loadMessages(\r\n taskId: string,\r\n agentId: string,\r\n forkId?: string\r\n): Promise<Message[]> {\r\n const key = forkId\r\n ? `swarm:${taskId}:${agentId}:fork:${forkId}:messages`\r\n : `swarm:${taskId}:${agentId}:messages`;\r\n\r\n try {\r\n const output = execSync(`redis-cli -h ${redisHost} -p ${redisPort} lrange \"${key}\" 0 -1`, {\r\n encoding: 'utf8'\r\n }).trim();\r\n\r\n if (!output || output === '(empty array)') {\r\n return [];\r\n }\r\n\r\n // Redis returns each message on a new line\r\n const lines = output.split('\\n');\r\n return lines.map(line => JSON.parse(line));\r\n } catch (error) {\r\n console.error(`[conversation-fork] Failed to load messages:`, error);\r\n return [];\r\n }\r\n}\r\n\r\n/**\r\n * Create a fork from current conversation state\r\n * Copies all messages up to current iteration\r\n * MEMORY LEAK FIX: Now sets TTL on fork message list matching metadata TTL\r\n */\r\nexport async function createFork(\r\n taskId: string,\r\n agentId: string,\r\n currentIteration: number\r\n): Promise<string> {\r\n // Generate unique fork ID\r\n const forkId = `fork-${currentIteration}-${randomBytes(4).toString('hex')}`;\r\n\r\n // Load messages up to current iteration\r\n const messages = await loadMessages(taskId, agentId);\r\n const forkMessages = messages.filter(m => m.iteration <= currentIteration);\r\n\r\n if (forkMessages.length === 0) {\r\n throw new Error(`No messages found for iteration ${currentIteration}`);\r\n }\r\n\r\n // Store fork snapshot\r\n const forkKey = `swarm:${taskId}:${agentId}:fork:${forkId}:messages`;\r\n const forkTTL = parseInt(process.env.CFN_FORK_TTL || '86400', 10); // 24 hours\r\n\r\n for (const message of forkMessages) {\r\n const messageJson = JSON.stringify(message);\r\n execSync(`redis-cli -h ${redisHost} -p ${redisPort} rpush \"${forkKey}\" '${messageJson.replace(/'/g, \"'\\\\''\")}'`, {\r\n encoding: 'utf8'\r\n });\r\n }\r\n\r\n // MEMORY LEAK FIX: Set TTL on fork messages (was missing before)\r\n execSync(`redis-cli -h ${redisHost} -p ${redisPort} expire \"${forkKey}\" ${forkTTL}`, {\r\n encoding: 'utf8'\r\n });\r\n\r\n // Store fork metadata\r\n const metadata: ForkMetadata = {\r\n forkId,\r\n taskId,\r\n agentId,\r\n createdAt: new Date().toISOString(),\r\n parentIteration: currentIteration,\r\n messageCount: forkMessages.length\r\n };\r\n\r\n const metaKey = `swarm:${taskId}:${agentId}:fork:${forkId}:meta`;\r\n execSync(`redis-cli -h ${redisHost} -p ${redisPort} setex \"${metaKey}\" ${forkTTL} '${JSON.stringify(metadata)}'`, {\r\n encoding: 'utf8'\r\n });\r\n\r\n // Set as current fork\r\n const currentForkKey = `swarm:${taskId}:${agentId}:current-fork`;\r\n execSync(`redis-cli -h ${redisHost} -p ${redisPort} setex \"${currentForkKey}\" ${forkTTL} \"${forkId}\"`, {\r\n encoding: 'utf8'\r\n });\r\n\r\n console.log(`[conversation-fork] Created fork ${forkId} with ${forkMessages.length} messages (TTL: ${forkTTL}s)`);\r\n\r\n return forkId;\r\n}\r\n\r\n/**\r\n * Get current active fork ID\r\n */\r\nexport async function getCurrentFork(\r\n taskId: string,\r\n agentId: string\r\n): Promise<string | null> {\r\n const key = `swarm:${taskId}:${agentId}:current-fork`;\r\n\r\n try {\r\n const forkId = execSync(`redis-cli -h ${redisHost} -p ${redisPort} get \"${key}\"`, {\r\n encoding: 'utf8'\r\n }).trim();\r\n\r\n if (forkId === '(nil)' || !forkId) {\r\n return null;\r\n }\r\n\r\n return forkId;\r\n } catch (error) {\r\n return null;\r\n }\r\n}\r\n\r\n/**\r\n * Get fork metadata\r\n */\r\nexport async function getForkMetadata(\r\n taskId: string,\r\n agentId: string,\r\n forkId: string\r\n): Promise<ForkMetadata | null> {\r\n const key = `swarm:${taskId}:${agentId}:fork:${forkId}:meta`;\r\n\r\n try {\r\n const metaJson = execSync(`redis-cli -h ${redisHost} -p ${redisPort} get \"${key}\"`, {\r\n encoding: 'utf8'\r\n }).trim();\r\n\r\n if (metaJson === '(nil)' || !metaJson) {\r\n return null;\r\n }\r\n\r\n return JSON.parse(metaJson);\r\n } catch (error) {\r\n return null;\r\n }\r\n}\r\n\r\n/**\r\n * List all forks for an agent\r\n */\r\nexport async function listForks(\r\n taskId: string,\r\n agentId: string\r\n): Promise<ForkMetadata[]> {\r\n const pattern = `swarm:${taskId}:${agentId}:fork:*:meta`;\r\n\r\n try {\r\n const keys = execSync(`redis-cli -h ${redisHost} -p ${redisPort} keys \"${pattern}\"`, {\r\n encoding: 'utf8'\r\n }).trim().split('\\n').filter(k => k);\r\n\r\n const forks: ForkMetadata[] = [];\r\n\r\n for (const key of keys) {\r\n const metaJson = execSync(`redis-cli -h ${redisHost} -p ${redisPort} get \"${key}\"`, {\r\n encoding: 'utf8'\r\n }).trim();\r\n\r\n if (metaJson && metaJson !== '(nil)') {\r\n forks.push(JSON.parse(metaJson));\r\n }\r\n }\r\n\r\n return forks.sort((a, b) =>\r\n new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()\r\n );\r\n } catch (error) {\r\n console.error(`[conversation-fork] Failed to list forks:`, error);\r\n return [];\r\n }\r\n}\r\n\r\n/**\r\n * Delete a fork and its messages\r\n */\r\nexport async function deleteFork(\r\n taskId: string,\r\n agentId: string,\r\n forkId: string\r\n): Promise<void> {\r\n const messagesKey = `swarm:${taskId}:${agentId}:fork:${forkId}:messages`;\r\n const metaKey = `swarm:${taskId}:${agentId}:fork:${forkId}:meta`;\r\n\r\n try {\r\n execSync(`redis-cli -h ${redisHost} -p ${redisPort} del \"${messagesKey}\" \"${metaKey}\"`, {\r\n encoding: 'utf8'\r\n });\r\n\r\n console.log(`[conversation-fork] Deleted fork ${forkId}`);\r\n } catch (error) {\r\n console.error(`[conversation-fork] Failed to delete fork:`, error);\r\n throw error;\r\n }\r\n}\r\n\r\n/**\r\n * Clear current fork (start fresh conversation)\r\n */\r\nexport async function clearCurrentFork(\r\n taskId: string,\r\n agentId: string\r\n): Promise<void> {\r\n const key = `swarm:${taskId}:${agentId}:current-fork`;\r\n\r\n try {\r\n execSync(`redis-cli -h ${redisHost} -p ${redisPort} del \"${key}\"`, {\r\n encoding: 'utf8'\r\n });\r\n } catch (error) {\r\n console.error(`[conversation-fork] Failed to clear current fork:`, error);\r\n }\r\n}\r\n\r\n/**\r\n * Format messages for Anthropic API\r\n */\r\nexport function formatMessagesForAPI(messages: Message[]): Array<{role: string, content: string}> {\r\n return messages.map(m => ({\r\n role: m.role,\r\n content: m.content\r\n }));\r\n}\r\n\r\n/**\r\n * Get conversation statistics\r\n */\r\nexport async function getConversationStats(\r\n taskId: string,\r\n agentId: string,\r\n forkId?: string\r\n): Promise<{\r\n messageCount: number;\r\n userMessages: number;\r\n assistantMessages: number;\r\n iterations: number;\r\n firstMessage: string | null;\r\n lastMessage: string | null;\r\n}> {\r\n const messages = await loadMessages(taskId, agentId, forkId);\r\n\r\n if (messages.length === 0) {\r\n return {\r\n messageCount: 0,\r\n userMessages: 0,\r\n assistantMessages: 0,\r\n iterations: 0,\r\n firstMessage: null,\r\n lastMessage: null\r\n };\r\n }\r\n\r\n const userMessages = messages.filter(m => m.role === 'user').length;\r\n const assistantMessages = messages.filter(m => m.role === 'assistant').length;\r\n const iterations = Math.max(...messages.map(m => m.iteration));\r\n\r\n return {\r\n messageCount: messages.length,\r\n userMessages,\r\n assistantMessages,\r\n iterations,\r\n firstMessage: messages[0].timestamp,\r\n lastMessage: messages[messages.length - 1].timestamp\r\n };\r\n}\r\n"],"names":["execSync","randomBytes","redisHost","process","env","CFN_REDIS_HOST","redisPort","CFN_REDIS_PORT","storeMessage","taskId","agentId","message","key","messageJson","JSON","stringify","replace","encoding","messageTTL","parseInt","CFN_MESSAGE_TTL","error","console","loadMessages","forkId","output","trim","lines","split","map","line","parse","createFork","currentIteration","toString","messages","forkMessages","filter","m","iteration","length","Error","forkKey","forkTTL","CFN_FORK_TTL","metadata","createdAt","Date","toISOString","parentIteration","messageCount","metaKey","currentForkKey","log","getCurrentFork","getForkMetadata","metaJson","listForks","pattern","keys","k","forks","push","sort","a","b","getTime","deleteFork","messagesKey","clearCurrentFork","formatMessagesForAPI","role","content","getConversationStats","userMessages","assistantMessages","iterations","firstMessage","lastMessage","Math","max","timestamp"],"mappings":"AAAA;;;;;;;CAOC,GAED,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,WAAW,QAAQ,SAAS;AAErC,gEAAgE;AAChE,MAAMC,YAAYC,QAAQC,GAAG,CAACC,cAAc,IAAI;AAChD,MAAMC,YAAYH,QAAQC,GAAG,CAACG,cAAc,IAAI;AAkBhD;;;CAGC,GACD,OAAO,eAAeC,aACpBC,MAAc,EACdC,OAAe,EACfC,OAAgB;IAEhB,MAAMC,MAAM,CAAC,MAAM,EAAEH,OAAO,CAAC,EAAEC,QAAQ,SAAS,CAAC;IACjD,MAAMG,cAAcC,KAAKC,SAAS,CAACJ;IAEnC,IAAI;QACFX,SAAS,CAAC,aAAa,EAAEE,UAAU,IAAI,EAAEI,UAAU,QAAQ,EAAEM,IAAI,GAAG,EAAEC,YAAYG,OAAO,CAAC,MAAM,SAAS,CAAC,CAAC,EAAE;YAC3GC,UAAU;QACZ;QAEA,yDAAyD;QACzD,8EAA8E;QAC9E,MAAMC,aAAaC,SAAShB,QAAQC,GAAG,CAACgB,eA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OAAO;QACLW,cAAcf,SAASK,MAAM;QAC7BkC;QACAC;QACAC;QACAC,cAAc1C,QAAQ,CAAC,EAAE,CAAC8C,SAAS;QACnCH,aAAa3C,QAAQ,CAACA,SAASK,MAAM,GAAG,EAAE,CAACyC,SAAS;IACtD;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/cli/conversation-fork.ts"],"sourcesContent":["/**\r\n * Conversation Fork Management\r\n *\r\n * Implements application-level conversation forking for CFN Loop iterations.\r\n * Stores conversation history in Redis and allows branching at specific points.\r\n *\r\n * Sprint 4: Conversation Forking (v2.7.0)\r\n */\r\n\r\nimport { execSync } from 'child_process';\r\nimport { randomBytes } from 'crypto';\r\n\r\n// Bug #6 Fix: Read Redis connection parameters from process.env\r\n// FIX: Default to 'localhost' for CLI mode (host execution), not 'cfn-redis' (Docker)\r\nconst redisHost = process.env.CFN_REDIS_HOST || 'localhost';\r\nconst redisPort = process.env.CFN_REDIS_PORT || '6379';\r\n\r\nexport interface Message {\r\n role: 'user' | 'assistant';\r\n content: string;\r\n iteration: number;\r\n timestamp: string;\r\n}\r\n\r\nexport interface ForkMetadata {\r\n forkId: string;\r\n taskId: string;\r\n agentId: string;\r\n createdAt: string;\r\n parentIteration: number;\r\n messageCount: number;\r\n}\r\n\r\n/**\r\n * Store a message in conversation history\r\n * MEMORY LEAK FIX: Now sets TTL on message list to prevent indefinite accumulation\r\n */\r\nexport async function storeMessage(\r\n taskId: string,\r\n agentId: string,\r\n message: Message\r\n): Promise<void> {\r\n const key = `swarm:${taskId}:${agentId}:messages`;\r\n const messageJson = JSON.stringify(message);\r\n\r\n try {\r\n execSync(`redis-cli -h ${redisHost} -p ${redisPort} rpush \"${key}\" '${messageJson.replace(/'/g, \"'\\\\''\")}'`, {\r\n encoding: 'utf8'\r\n });\r\n\r\n // MEMORY LEAK FIX: Set TTL on message list (24h default)\r\n // This prevents messages from accumulating indefinitely across multiple tasks\r\n const messageTTL = parseInt(process.env.CFN_MESSAGE_TTL || '86400', 10); // 24 hours\r\n execSync(`redis-cli -h ${redisHost} -p ${redisPort} expire \"${key}\" ${messageTTL}`, {\r\n encoding: 'utf8'\r\n });\r\n } catch (error) {\r\n console.error(`[conversation-fork] Failed to store message:`, error);\r\n throw error;\r\n }\r\n}\r\n\r\n/**\r\n * Load all messages from conversation history\r\n */\r\nexport async function loadMessages(\r\n taskId: string,\r\n agentId: string,\r\n forkId?: string\r\n): Promise<Message[]> {\r\n const key = forkId\r\n ? `swarm:${taskId}:${agentId}:fork:${forkId}:messages`\r\n : `swarm:${taskId}:${agentId}:messages`;\r\n\r\n try {\r\n const output = execSync(`redis-cli -h ${redisHost} -p ${redisPort} lrange \"${key}\" 0 -1`, {\r\n encoding: 'utf8'\r\n }).trim();\r\n\r\n if (!output || output === '(empty array)') {\r\n return [];\r\n }\r\n\r\n // Redis returns each message on a new line\r\n const lines = output.split('\\n');\r\n return lines.map(line => JSON.parse(line));\r\n } catch (error) {\r\n console.error(`[conversation-fork] Failed to load messages:`, error);\r\n return [];\r\n }\r\n}\r\n\r\n/**\r\n * Create a fork from current conversation state\r\n * Copies all messages up to current iteration\r\n * MEMORY LEAK FIX: Now sets TTL on fork message list matching metadata TTL\r\n */\r\nexport async function createFork(\r\n taskId: string,\r\n agentId: string,\r\n currentIteration: number\r\n): Promise<string> {\r\n // Generate unique fork ID\r\n const forkId = `fork-${currentIteration}-${randomBytes(4).toString('hex')}`;\r\n\r\n // Load messages up to current iteration\r\n const messages = await loadMessages(taskId, agentId);\r\n const forkMessages = messages.filter(m => m.iteration <= currentIteration);\r\n\r\n if (forkMessages.length === 0) {\r\n throw new Error(`No messages found for iteration ${currentIteration}`);\r\n }\r\n\r\n // Store fork snapshot\r\n const forkKey = `swarm:${taskId}:${agentId}:fork:${forkId}:messages`;\r\n const forkTTL = parseInt(process.env.CFN_FORK_TTL || '86400', 10); // 24 hours\r\n\r\n for (const message of forkMessages) {\r\n const messageJson = JSON.stringify(message);\r\n execSync(`redis-cli -h ${redisHost} -p ${redisPort} rpush \"${forkKey}\" '${messageJson.replace(/'/g, \"'\\\\''\")}'`, {\r\n encoding: 'utf8'\r\n });\r\n }\r\n\r\n // MEMORY LEAK FIX: Set TTL on fork messages (was missing before)\r\n execSync(`redis-cli -h ${redisHost} -p ${redisPort} expire \"${forkKey}\" ${forkTTL}`, {\r\n encoding: 'utf8'\r\n });\r\n\r\n // Store fork metadata\r\n const metadata: ForkMetadata = {\r\n forkId,\r\n taskId,\r\n agentId,\r\n createdAt: new Date().toISOString(),\r\n parentIteration: currentIteration,\r\n messageCount: forkMessages.length\r\n };\r\n\r\n const metaKey = `swarm:${taskId}:${agentId}:fork:${forkId}:meta`;\r\n execSync(`redis-cli -h ${redisHost} -p ${redisPort} setex \"${metaKey}\" ${forkTTL} '${JSON.stringify(metadata)}'`, {\r\n encoding: 'utf8'\r\n });\r\n\r\n // Set as current fork\r\n const currentForkKey = `swarm:${taskId}:${agentId}:current-fork`;\r\n execSync(`redis-cli -h ${redisHost} -p ${redisPort} setex \"${currentForkKey}\" ${forkTTL} \"${forkId}\"`, {\r\n encoding: 'utf8'\r\n });\r\n\r\n console.log(`[conversation-fork] Created fork ${forkId} with ${forkMessages.length} messages (TTL: ${forkTTL}s)`);\r\n\r\n return forkId;\r\n}\r\n\r\n/**\r\n * Get current active fork ID\r\n */\r\nexport async function getCurrentFork(\r\n taskId: string,\r\n agentId: string\r\n): Promise<string | null> {\r\n const key = `swarm:${taskId}:${agentId}:current-fork`;\r\n\r\n try {\r\n const forkId = execSync(`redis-cli -h ${redisHost} -p ${redisPort} get \"${key}\"`, {\r\n encoding: 'utf8'\r\n }).trim();\r\n\r\n if (forkId === '(nil)' || !forkId) {\r\n return null;\r\n }\r\n\r\n return forkId;\r\n } catch (error) {\r\n return null;\r\n }\r\n}\r\n\r\n/**\r\n * Get fork metadata\r\n */\r\nexport async function getForkMetadata(\r\n taskId: string,\r\n agentId: string,\r\n forkId: string\r\n): Promise<ForkMetadata | null> {\r\n const key = `swarm:${taskId}:${agentId}:fork:${forkId}:meta`;\r\n\r\n try {\r\n const metaJson = execSync(`redis-cli -h ${redisHost} -p ${redisPort} get \"${key}\"`, {\r\n encoding: 'utf8'\r\n }).trim();\r\n\r\n if (metaJson === '(nil)' || !metaJson) {\r\n return null;\r\n }\r\n\r\n return JSON.parse(metaJson);\r\n } catch (error) {\r\n return null;\r\n }\r\n}\r\n\r\n/**\r\n * List all forks for an agent\r\n */\r\nexport async function listForks(\r\n taskId: string,\r\n agentId: string\r\n): Promise<ForkMetadata[]> {\r\n const pattern = `swarm:${taskId}:${agentId}:fork:*:meta`;\r\n\r\n try {\r\n const keys = execSync(`redis-cli -h ${redisHost} -p ${redisPort} keys \"${pattern}\"`, {\r\n encoding: 'utf8'\r\n }).trim().split('\\n').filter(k => k);\r\n\r\n const forks: ForkMetadata[] = [];\r\n\r\n for (const key of keys) {\r\n const metaJson = execSync(`redis-cli -h ${redisHost} -p ${redisPort} get \"${key}\"`, {\r\n encoding: 'utf8'\r\n }).trim();\r\n\r\n if (metaJson && metaJson !== '(nil)') {\r\n forks.push(JSON.parse(metaJson));\r\n }\r\n }\r\n\r\n return forks.sort((a, b) =>\r\n new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()\r\n );\r\n } catch (error) {\r\n console.error(`[conversation-fork] Failed to list forks:`, error);\r\n return [];\r\n }\r\n}\r\n\r\n/**\r\n * Delete a fork and its messages\r\n */\r\nexport async function deleteFork(\r\n taskId: string,\r\n agentId: string,\r\n forkId: string\r\n): Promise<void> {\r\n const messagesKey = `swarm:${taskId}:${agentId}:fork:${forkId}:messages`;\r\n const metaKey = `swarm:${taskId}:${agentId}:fork:${forkId}:meta`;\r\n\r\n try {\r\n execSync(`redis-cli -h ${redisHost} -p ${redisPort} del \"${messagesKey}\" \"${metaKey}\"`, {\r\n encoding: 'utf8'\r\n });\r\n\r\n console.log(`[conversation-fork] Deleted fork ${forkId}`);\r\n } catch (error) {\r\n console.error(`[conversation-fork] Failed to delete fork:`, error);\r\n throw error;\r\n }\r\n}\r\n\r\n/**\r\n * Clear current fork (start fresh conversation)\r\n */\r\nexport async function clearCurrentFork(\r\n taskId: string,\r\n agentId: string\r\n): Promise<void> {\r\n const key = `swarm:${taskId}:${agentId}:current-fork`;\r\n\r\n try {\r\n execSync(`redis-cli -h ${redisHost} -p ${redisPort} del \"${key}\"`, {\r\n encoding: 'utf8'\r\n });\r\n } catch (error) {\r\n console.error(`[conversation-fork] Failed to clear current fork:`, error);\r\n }\r\n}\r\n\r\n/**\r\n * Format messages for Anthropic API\r\n */\r\nexport function formatMessagesForAPI(messages: Message[]): Array<{role: string, content: string}> {\r\n return messages.map(m => ({\r\n role: m.role,\r\n content: m.content\r\n }));\r\n}\r\n\r\n/**\r\n * Get conversation statistics\r\n */\r\nexport async function getConversationStats(\r\n taskId: string,\r\n agentId: string,\r\n forkId?: string\r\n): Promise<{\r\n messageCount: number;\r\n userMessages: number;\r\n assistantMessages: number;\r\n iterations: number;\r\n firstMessage: string | null;\r\n lastMessage: string | null;\r\n}> {\r\n const messages = await loadMessages(taskId, agentId, forkId);\r\n\r\n if (messages.length === 0) {\r\n return {\r\n messageCount: 0,\r\n userMessages: 0,\r\n assistantMessages: 0,\r\n iterations: 0,\r\n firstMessage: null,\r\n lastMessage: null\r\n };\r\n }\r\n\r\n const userMessages = messages.filter(m => m.role === 'user').length;\r\n const assistantMessages = messages.filter(m => m.role === 'assistant').length;\r\n const iterations = Math.max(...messages.map(m => m.iteration));\r\n\r\n return {\r\n messageCount: messages.length,\r\n userMessages,\r\n assistantMessages,\r\n iterations,\r\n firstMessage: messages[0].timestamp,\r\n lastMessage: messages[messages.length - 1].timestamp\r\n };\r\n}\r\n"],"names":["execSync","randomBytes","redisHost","process","env","CFN_REDIS_HOST","redisPort","CFN_REDIS_PORT","storeMessage","taskId","agentId","message","key","messageJson","JSON","stringify","replace","encoding","messageTTL","parseInt","CFN_MESSAGE_TTL","error","console","loadMessages","forkId","output","trim","lines","split","map","line","parse","createFork","currentIteration","toString","messages","forkMessages","filter","m","iteration","length","Error","forkKey","forkTTL","CFN_FORK_TTL","metadata","createdAt","Date","toISOString","parentIteration","messageCount","metaKey","currentForkKey","log","getCurrentFork","getForkMetadata","metaJson","listForks","pattern","keys","k","forks","push","sort","a","b","getTime","deleteFork","messagesKey","clearCurrentFork","formatMessagesForAPI","role","content","getConversationStats","userMessages","assistantMessages","iterations","firstMessage","lastMessage","Math","max","timestamp"],"mappings":"AAAA;;;;;;;CAOC,GAED,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,WAAW,QAAQ,SAAS;AAErC,gEAAgE;AAChE,sFAAsF;AACtF,MAAMC,YAAYC,QAAQC,GAAG,CAACC,cAAc,IAAI;AAChD,MAAMC,YAAYH,QAAQC,GAAG,CAACG,cAAc,IAAI;AAkBhD;;;CAGC,GACD,OAAO,eAAeC,aACpBC,MAAc,EACdC,OAAe,EACfC,OAAgB;IAEhB,MAAMC,MAAM,CAAC,MAAM,EAAEH,OAAO,CAAC,EAAEC,QAAQ,SAAS,CAAC;IACjD,MAAMG,cAAcC,KAAKC,SAAS,CAACJ;IAEnC,IAAI;QACFX,SAAS,CAAC,aAAa,EAAEE,UAAU,IAAI,EAAEI,UAAU,QAAQ,EAAEM,IAAI,GAAG,EAAEC,YAAYG,OAAO,CAAC,MAAM,SAAS,CAAC,CAAC,EAAE;YAC3GC,UAAU;QACZ;QAEA,yDAAyD;QACzD,8EAA8E;QAC9E,MAAMC,aAAaC,SAAShB,QAAQC,GAAG,CAACgB,eAAe,IAAI,SAAS,KAAK,WAAW;QACpFpB,SAAS,CAAC,aAAa,EAAEE,UAAU,IAAI,EAAEI,UAAU,SAAS,EAAEM,IAAI,EAAE,EAAEM,YAAY,EAAE;YAClFD,UAAU;QACZ;IACF,EAAE,OAAOI,OAAO;QACdC,QAAQD,KAAK,CAAC,CAAC,4CAA4C,CAAC,EAAEA;QAC9D,MAAMA;IACR;AACF;AAEA;;CAEC,GACD,OAAO,eAAeE,aACpBd,M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
4
|
+
*
|
|
5
|
+
* Enables Main Chat to send commands to running CLI agents, and agents to process them.
|
|
6
|
+
*
|
|
7
|
+
* Main Chat → Agent: LPUSH cfn:agent:{taskId}:{agentId}:commands
|
|
8
|
+
* Agent → Main Chat: SET cfn:agent:{taskId}:{agentId}:status (response)
|
|
9
|
+
*
|
|
10
|
+
* Supported Commands:
|
|
11
|
+
* - status: Request agent status update
|
|
12
|
+
* - redirect: Redirect agent to new task/context
|
|
13
|
+
* - abort: Request clean agent abort
|
|
14
|
+
* - pause: Request agent pause for N seconds
|
|
15
|
+
*
|
|
16
|
+
* Usage (Main Chat - send command):
|
|
17
|
+
* npx tsx src/cli/coordination/agent-messaging.ts send \
|
|
18
|
+
* --task-id <id> --agent-id <aid> --command status
|
|
19
|
+
*
|
|
20
|
+
* Usage (Agent - process commands):
|
|
21
|
+
* npx tsx src/cli/coordination/agent-messaging.ts listen \
|
|
22
|
+
* --task-id <id> --agent-id <aid> --poll-interval 5
|
|
23
|
+
*/ import { createClient } from 'redis';
|
|
24
|
+
// ============================================================================
|
|
25
|
+
// Redis Key Helpers
|
|
26
|
+
// ============================================================================
|
|
27
|
+
function getCommandsKey(taskId, agentId) {
|
|
28
|
+
return `cfn:agent:${taskId}:${agentId}:commands`;
|
|
29
|
+
}
|
|
30
|
+
function getStatusKey(taskId, agentId) {
|
|
31
|
+
return `cfn:agent:${taskId}:${agentId}:status`;
|
|
32
|
+
}
|
|
33
|
+
function getResponseKey(taskId, agentId, commandId) {
|
|
34
|
+
return `cfn:agent:${taskId}:${agentId}:response:${commandId}`;
|
|
35
|
+
}
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Main Chat Side - Send Commands
|
|
38
|
+
// ============================================================================
|
|
39
|
+
/**
|
|
40
|
+
* Send a command to an agent via Redis
|
|
41
|
+
*/ export async function sendCommand(config, command) {
|
|
42
|
+
const { taskId, agentId, redisHost = process.env.CFN_REDIS_HOST || 'localhost', redisPort = parseInt(process.env.CFN_REDIS_PORT || '6379', 10), redisPassword = process.env.CFN_REDIS_PASSWORD || undefined } = config;
|
|
43
|
+
const client = createClient({
|
|
44
|
+
socket: {
|
|
45
|
+
host: redisHost,
|
|
46
|
+
port: redisPort
|
|
47
|
+
},
|
|
48
|
+
password: redisPassword || undefined
|
|
49
|
+
});
|
|
50
|
+
const commandId = `cmd-${Date.now()}-${Math.random().toString(36).substring(2, 8)}`;
|
|
51
|
+
const fullCommand = {
|
|
52
|
+
...command,
|
|
53
|
+
id: commandId,
|
|
54
|
+
timestamp: new Date().toISOString(),
|
|
55
|
+
replyTo: getResponseKey(taskId, agentId, commandId)
|
|
56
|
+
};
|
|
57
|
+
try {
|
|
58
|
+
await client.connect();
|
|
59
|
+
const commandsKey = getCommandsKey(taskId, agentId);
|
|
60
|
+
await client.lPush(commandsKey, JSON.stringify(fullCommand));
|
|
61
|
+
console.log(`[agent-msg] Sent command ${command.type} to ${agentId}`);
|
|
62
|
+
console.log(`[agent-msg] Commands key: ${commandsKey}`);
|
|
63
|
+
console.log(`[agent-msg] Command ID: ${commandId}`);
|
|
64
|
+
return {
|
|
65
|
+
sent: true,
|
|
66
|
+
commandId
|
|
67
|
+
};
|
|
68
|
+
} finally{
|
|
69
|
+
await client.disconnect();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Wait for agent response to a command
|
|
74
|
+
*/ export async function waitForResponse(config, commandId, timeoutSeconds = 30) {
|
|
75
|
+
const { taskId, agentId, redisHost = process.env.CFN_REDIS_HOST || 'localhost', redisPort = parseInt(process.env.CFN_REDIS_PORT || '6379', 10), redisPassword = process.env.CFN_REDIS_PASSWORD || undefined } = config;
|
|
76
|
+
const client = createClient({
|
|
77
|
+
socket: {
|
|
78
|
+
host: redisHost,
|
|
79
|
+
port: redisPort
|
|
80
|
+
},
|
|
81
|
+
password: redisPassword || undefined
|
|
82
|
+
});
|
|
83
|
+
try {
|
|
84
|
+
await client.connect();
|
|
85
|
+
const responseKey = getResponseKey(taskId, agentId, commandId);
|
|
86
|
+
const result = await client.blPop(responseKey, timeoutSeconds);
|
|
87
|
+
if (result) {
|
|
88
|
+
return JSON.parse(result.element);
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
} finally{
|
|
92
|
+
await client.disconnect();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get current agent status (non-blocking)
|
|
97
|
+
*/ export async function getAgentStatus(config) {
|
|
98
|
+
const { taskId, agentId, redisHost = process.env.CFN_REDIS_HOST || 'localhost', redisPort = parseInt(process.env.CFN_REDIS_PORT || '6379', 10), redisPassword = process.env.CFN_REDIS_PASSWORD || undefined } = config;
|
|
99
|
+
const client = createClient({
|
|
100
|
+
socket: {
|
|
101
|
+
host: redisHost,
|
|
102
|
+
port: redisPort
|
|
103
|
+
},
|
|
104
|
+
password: redisPassword || undefined
|
|
105
|
+
});
|
|
106
|
+
try {
|
|
107
|
+
await client.connect();
|
|
108
|
+
const statusKey = getStatusKey(taskId, agentId);
|
|
109
|
+
const status = await client.get(statusKey);
|
|
110
|
+
if (status) {
|
|
111
|
+
return JSON.parse(status);
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
} finally{
|
|
115
|
+
await client.disconnect();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Agent command processor - polls for and processes commands
|
|
120
|
+
*/ export class AgentCommandProcessor {
|
|
121
|
+
config;
|
|
122
|
+
client = null;
|
|
123
|
+
running = false;
|
|
124
|
+
handlers = new Map();
|
|
125
|
+
constructor(config){
|
|
126
|
+
this.config = config;
|
|
127
|
+
// Default handlers
|
|
128
|
+
this.handlers.set('status', this.handleStatus.bind(this));
|
|
129
|
+
this.handlers.set('abort', this.handleAbort.bind(this));
|
|
130
|
+
this.handlers.set('pause', this.handlePause.bind(this));
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Register a custom command handler
|
|
134
|
+
*/ onCommand(type, handler) {
|
|
135
|
+
this.handlers.set(type, handler);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Start processing commands (non-blocking poll loop)
|
|
139
|
+
*/ async start(pollIntervalSeconds = 5) {
|
|
140
|
+
const { taskId, agentId, redisHost = process.env.CFN_REDIS_HOST || 'localhost', redisPort = parseInt(process.env.CFN_REDIS_PORT || '6379', 10), redisPassword = process.env.CFN_REDIS_PASSWORD || undefined } = this.config;
|
|
141
|
+
this.client = createClient({
|
|
142
|
+
socket: {
|
|
143
|
+
host: redisHost,
|
|
144
|
+
port: redisPort
|
|
145
|
+
},
|
|
146
|
+
password: redisPassword || undefined
|
|
147
|
+
});
|
|
148
|
+
await this.client.connect();
|
|
149
|
+
this.running = true;
|
|
150
|
+
const commandsKey = getCommandsKey(taskId, agentId);
|
|
151
|
+
console.log(`[agent-processor] Started listening on ${commandsKey}`);
|
|
152
|
+
// Non-blocking poll loop
|
|
153
|
+
while(this.running){
|
|
154
|
+
try {
|
|
155
|
+
// Short BLPOP to check for commands without blocking too long
|
|
156
|
+
const result = await this.client.blPop(commandsKey, pollIntervalSeconds);
|
|
157
|
+
if (result) {
|
|
158
|
+
const command = JSON.parse(result.element);
|
|
159
|
+
console.log(`[agent-processor] Received command: ${command.type} (${command.id})`);
|
|
160
|
+
// Process command
|
|
161
|
+
const handler = this.handlers.get(command.type);
|
|
162
|
+
if (handler) {
|
|
163
|
+
const response = await handler(command);
|
|
164
|
+
// Send response if handler returned status
|
|
165
|
+
if (response && command.replyTo) {
|
|
166
|
+
await this.client.lPush(command.replyTo, JSON.stringify(response));
|
|
167
|
+
console.log(`[agent-processor] Sent response to ${command.replyTo}`);
|
|
168
|
+
}
|
|
169
|
+
} else {
|
|
170
|
+
console.warn(`[agent-processor] No handler for command type: ${command.type}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
} catch (err) {
|
|
174
|
+
if (this.running) {
|
|
175
|
+
console.error(`[agent-processor] Error processing command:`, err);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Stop processing commands
|
|
182
|
+
*/ async stop() {
|
|
183
|
+
this.running = false;
|
|
184
|
+
if (this.client) {
|
|
185
|
+
await this.client.disconnect();
|
|
186
|
+
this.client = null;
|
|
187
|
+
}
|
|
188
|
+
console.log(`[agent-processor] Stopped`);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Update agent status in Redis
|
|
192
|
+
*/ async updateStatus(status) {
|
|
193
|
+
if (!this.client) return;
|
|
194
|
+
const { taskId, agentId } = this.config;
|
|
195
|
+
const fullStatus = {
|
|
196
|
+
agentId,
|
|
197
|
+
taskId,
|
|
198
|
+
status: 'running',
|
|
199
|
+
timestamp: new Date().toISOString(),
|
|
200
|
+
...status
|
|
201
|
+
};
|
|
202
|
+
const statusKey = getStatusKey(taskId, agentId);
|
|
203
|
+
await this.client.set(statusKey, JSON.stringify(fullStatus));
|
|
204
|
+
// Expire after 1 hour
|
|
205
|
+
await this.client.expire(statusKey, 3600);
|
|
206
|
+
}
|
|
207
|
+
// Default handlers
|
|
208
|
+
async handleStatus(command) {
|
|
209
|
+
const { taskId, agentId } = this.config;
|
|
210
|
+
return {
|
|
211
|
+
agentId,
|
|
212
|
+
taskId,
|
|
213
|
+
status: 'running',
|
|
214
|
+
timestamp: new Date().toISOString(),
|
|
215
|
+
metadata: {
|
|
216
|
+
respondingTo: command.id
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
async handleAbort(_command) {
|
|
221
|
+
const { taskId, agentId } = this.config;
|
|
222
|
+
console.log(`[agent-processor] Abort requested, shutting down...`);
|
|
223
|
+
// Schedule stop after response
|
|
224
|
+
setTimeout(()=>this.stop(), 100);
|
|
225
|
+
return {
|
|
226
|
+
agentId,
|
|
227
|
+
taskId,
|
|
228
|
+
status: 'aborting',
|
|
229
|
+
timestamp: new Date().toISOString()
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
async handlePause(command) {
|
|
233
|
+
const { taskId, agentId } = this.config;
|
|
234
|
+
const pauseSeconds = command.payload?.seconds || 10;
|
|
235
|
+
console.log(`[agent-processor] Pausing for ${pauseSeconds}s...`);
|
|
236
|
+
await new Promise((resolve)=>setTimeout(resolve, pauseSeconds * 1000));
|
|
237
|
+
console.log(`[agent-processor] Resumed after pause`);
|
|
238
|
+
return {
|
|
239
|
+
agentId,
|
|
240
|
+
taskId,
|
|
241
|
+
status: 'running',
|
|
242
|
+
timestamp: new Date().toISOString(),
|
|
243
|
+
metadata: {
|
|
244
|
+
pausedFor: pauseSeconds
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// ============================================================================
|
|
250
|
+
// CLI Entry Point
|
|
251
|
+
// ============================================================================
|
|
252
|
+
function printHelp() {
|
|
253
|
+
console.log(`
|
|
254
|
+
Agent Messaging - Bidirectional Redis Communication
|
|
255
|
+
|
|
256
|
+
USAGE:
|
|
257
|
+
# Send command to agent (Main Chat side)
|
|
258
|
+
npx tsx src/cli/coordination/agent-messaging.ts send \\
|
|
259
|
+
--task-id <id> --agent-id <aid> --command <type> [--payload <json>]
|
|
260
|
+
|
|
261
|
+
# Listen for commands (Agent side)
|
|
262
|
+
npx tsx src/cli/coordination/agent-messaging.ts listen \\
|
|
263
|
+
--task-id <id> --agent-id <aid> [--poll-interval <seconds>]
|
|
264
|
+
|
|
265
|
+
# Get agent status (Main Chat side)
|
|
266
|
+
npx tsx src/cli/coordination/agent-messaging.ts status \\
|
|
267
|
+
--task-id <id> --agent-id <aid>
|
|
268
|
+
|
|
269
|
+
COMMANDS:
|
|
270
|
+
status Request agent status update
|
|
271
|
+
redirect Redirect agent to new task (include --payload)
|
|
272
|
+
abort Request clean agent abort
|
|
273
|
+
pause Pause agent (include --payload '{"seconds": 10}')
|
|
274
|
+
custom Custom command (include --payload)
|
|
275
|
+
|
|
276
|
+
EXAMPLES:
|
|
277
|
+
# Request status from agent
|
|
278
|
+
npx tsx src/cli/coordination/agent-messaging.ts send \\
|
|
279
|
+
--task-id cfn-cli-123 --agent-id backend-dev-456 --command status
|
|
280
|
+
|
|
281
|
+
# Abort agent
|
|
282
|
+
npx tsx src/cli/coordination/agent-messaging.ts send \\
|
|
283
|
+
--task-id cfn-cli-123 --agent-id backend-dev-456 --command abort
|
|
284
|
+
|
|
285
|
+
# Pause agent for 30 seconds
|
|
286
|
+
npx tsx src/cli/coordination/agent-messaging.ts send \\
|
|
287
|
+
--task-id cfn-cli-123 --agent-id backend-dev-456 \\
|
|
288
|
+
--command pause --payload '{"seconds": 30}'
|
|
289
|
+
|
|
290
|
+
# Redirect agent to new context
|
|
291
|
+
npx tsx src/cli/coordination/agent-messaging.ts send \\
|
|
292
|
+
--task-id cfn-cli-123 --agent-id backend-dev-456 \\
|
|
293
|
+
--command redirect --payload '{"newTask": "Focus on security tests"}'
|
|
294
|
+
|
|
295
|
+
# Start listening for commands (agent side)
|
|
296
|
+
npx tsx src/cli/coordination/agent-messaging.ts listen \\
|
|
297
|
+
--task-id cfn-cli-123 --agent-id backend-dev-456 --poll-interval 5
|
|
298
|
+
`);
|
|
299
|
+
}
|
|
300
|
+
async function main() {
|
|
301
|
+
const args = process.argv.slice(2);
|
|
302
|
+
const action = args[0];
|
|
303
|
+
if (!action || action === '--help' || action === '-h') {
|
|
304
|
+
printHelp();
|
|
305
|
+
process.exit(0);
|
|
306
|
+
}
|
|
307
|
+
// Parse common args
|
|
308
|
+
let taskId;
|
|
309
|
+
let agentId;
|
|
310
|
+
let command;
|
|
311
|
+
let payload;
|
|
312
|
+
let pollInterval = 5;
|
|
313
|
+
for(let i = 1; i < args.length; i++){
|
|
314
|
+
const arg = args[i];
|
|
315
|
+
const value = args[i + 1];
|
|
316
|
+
switch(arg){
|
|
317
|
+
case '--task-id':
|
|
318
|
+
case '-t':
|
|
319
|
+
taskId = value;
|
|
320
|
+
i++;
|
|
321
|
+
break;
|
|
322
|
+
case '--agent-id':
|
|
323
|
+
case '-a':
|
|
324
|
+
agentId = value;
|
|
325
|
+
i++;
|
|
326
|
+
break;
|
|
327
|
+
case '--command':
|
|
328
|
+
case '-c':
|
|
329
|
+
command = value;
|
|
330
|
+
i++;
|
|
331
|
+
break;
|
|
332
|
+
case '--payload':
|
|
333
|
+
case '-p':
|
|
334
|
+
try {
|
|
335
|
+
payload = JSON.parse(value);
|
|
336
|
+
} catch {
|
|
337
|
+
console.error('Invalid JSON payload');
|
|
338
|
+
process.exit(1);
|
|
339
|
+
}
|
|
340
|
+
i++;
|
|
341
|
+
break;
|
|
342
|
+
case '--poll-interval':
|
|
343
|
+
pollInterval = parseInt(value, 10);
|
|
344
|
+
i++;
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
if (!taskId || !agentId) {
|
|
349
|
+
console.error('Error: --task-id and --agent-id are required');
|
|
350
|
+
process.exit(1);
|
|
351
|
+
}
|
|
352
|
+
const config = {
|
|
353
|
+
taskId,
|
|
354
|
+
agentId
|
|
355
|
+
};
|
|
356
|
+
switch(action){
|
|
357
|
+
case 'send':
|
|
358
|
+
{
|
|
359
|
+
if (!command) {
|
|
360
|
+
console.error('Error: --command is required for send action');
|
|
361
|
+
process.exit(1);
|
|
362
|
+
}
|
|
363
|
+
const result = await sendCommand(config, {
|
|
364
|
+
type: command,
|
|
365
|
+
payload
|
|
366
|
+
});
|
|
367
|
+
console.log(JSON.stringify(result, null, 2));
|
|
368
|
+
// Wait for response
|
|
369
|
+
console.log('\n[agent-msg] Waiting for response (30s timeout)...');
|
|
370
|
+
const response = await waitForResponse(config, result.commandId, 30);
|
|
371
|
+
if (response) {
|
|
372
|
+
console.log('[agent-msg] Response received:');
|
|
373
|
+
console.log(JSON.stringify(response, null, 2));
|
|
374
|
+
} else {
|
|
375
|
+
console.log('[agent-msg] No response received (timeout)');
|
|
376
|
+
}
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
case 'listen':
|
|
380
|
+
{
|
|
381
|
+
const processor = new AgentCommandProcessor(config);
|
|
382
|
+
// Handle shutdown signals
|
|
383
|
+
process.on('SIGINT', async ()=>{
|
|
384
|
+
console.log('\n[agent-msg] Received SIGINT, stopping...');
|
|
385
|
+
await processor.stop();
|
|
386
|
+
process.exit(0);
|
|
387
|
+
});
|
|
388
|
+
await processor.start(pollInterval);
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
case 'status':
|
|
392
|
+
{
|
|
393
|
+
const status = await getAgentStatus(config);
|
|
394
|
+
if (status) {
|
|
395
|
+
console.log(JSON.stringify(status, null, 2));
|
|
396
|
+
} else {
|
|
397
|
+
console.log('No status available for agent');
|
|
398
|
+
}
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
default:
|
|
402
|
+
console.error(`Unknown action: ${action}`);
|
|
403
|
+
printHelp();
|
|
404
|
+
process.exit(1);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
// Run if called directly
|
|
408
|
+
if (import.meta.url.endsWith(process.argv[1]?.replace(/\\/g, '/') || '')) {
|
|
409
|
+
main().catch((err)=>{
|
|
410
|
+
console.error('[agent-msg] Fatal error:', err);
|
|
411
|
+
process.exit(2);
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
//# sourceMappingURL=agent-messaging.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/coordination/agent-messaging.ts"],"sourcesContent":["#!/usr/bin/env node\r\n/**\r\n * Agent Messaging - Bidirectional Redis Communication\r\n *\r\n * Enables Main Chat to send commands to running CLI agents, and agents to process them.\r\n *\r\n * Main Chat → Agent: LPUSH cfn:agent:{taskId}:{agentId}:commands\r\n * Agent → Main Chat: SET cfn:agent:{taskId}:{agentId}:status (response)\r\n *\r\n * Supported Commands:\r\n * - status: Request agent status update\r\n * - redirect: Redirect agent to new task/context\r\n * - abort: Request clean agent abort\r\n * - pause: Request agent pause for N seconds\r\n *\r\n * Usage (Main Chat - send command):\r\n * npx tsx src/cli/coordination/agent-messaging.ts send \\\r\n * --task-id <id> --agent-id <aid> --command status\r\n *\r\n * Usage (Agent - process commands):\r\n * npx tsx src/cli/coordination/agent-messaging.ts listen \\\r\n * --task-id <id> --agent-id <aid> --poll-interval 5\r\n */\r\n\r\nimport { createClient, RedisClientType } from 'redis';\r\n\r\n// ============================================================================\r\n// Types\r\n// ============================================================================\r\n\r\nexport type CommandType = 'status' | 'redirect' | 'abort' | 'pause' | 'custom';\r\n\r\nexport interface AgentCommand {\r\n id: string;\r\n type: CommandType;\r\n timestamp: string;\r\n payload?: Record<string, unknown>;\r\n replyTo?: string; // Optional key for response\r\n}\r\n\r\nexport interface AgentStatus {\r\n agentId: string;\r\n taskId: string;\r\n status: 'running' | 'paused' | 'aborting' | 'completed';\r\n timestamp: string;\r\n progress?: number;\r\n currentStep?: string;\r\n metadata?: Record<string, unknown>;\r\n}\r\n\r\nexport interface MessagingConfig {\r\n taskId: string;\r\n agentId: string;\r\n redisHost?: string;\r\n redisPort?: number;\r\n redisPassword?: string;\r\n}\r\n\r\n// ============================================================================\r\n// Redis Key Helpers\r\n// ============================================================================\r\n\r\nfunction getCommandsKey(taskId: string, agentId: string): string {\r\n return `cfn:agent:${taskId}:${agentId}:commands`;\r\n}\r\n\r\nfunction getStatusKey(taskId: string, agentId: string): string {\r\n return `cfn:agent:${taskId}:${agentId}:status`;\r\n}\r\n\r\nfunction getResponseKey(taskId: string, agentId: string, commandId: string): string {\r\n return `cfn:agent:${taskId}:${agentId}:response:${commandId}`;\r\n}\r\n\r\n// ============================================================================\r\n// Main Chat Side - Send Commands\r\n// ============================================================================\r\n\r\n/**\r\n * Send a command to an agent via Redis\r\n */\r\nexport async function sendCommand(\r\n config: MessagingConfig,\r\n command: Omit<AgentCommand, 'id' | 'timestamp'>\r\n): Promise<{ sent: boolean; commandId: string }> {\r\n const {\r\n taskId,\r\n agentId,\r\n redisHost = process.env.CFN_REDIS_HOST || 'localhost',\r\n redisPort = parseInt(process.env.CFN_REDIS_PORT || '6379', 10),\r\n redisPassword = process.env.CFN_REDIS_PASSWORD || undefined\r\n } = config;\r\n\r\n const client: RedisClientType = createClient({\r\n socket: { host: redisHost, port: redisPort },\r\n password: redisPassword || undefined\r\n });\r\n\r\n const commandId = `cmd-${Date.now()}-${Math.random().toString(36).substring(2, 8)}`;\r\n const fullCommand: AgentCommand = {\r\n ...command,\r\n id: commandId,\r\n timestamp: new Date().toISOString(),\r\n replyTo: getResponseKey(taskId, agentId, commandId)\r\n };\r\n\r\n try {\r\n await client.connect();\r\n\r\n const commandsKey = getCommandsKey(taskId, agentId);\r\n await client.lPush(commandsKey, JSON.stringify(fullCommand));\r\n\r\n console.log(`[agent-msg] Sent command ${command.type} to ${agentId}`);\r\n console.log(`[agent-msg] Commands key: ${commandsKey}`);\r\n console.log(`[agent-msg] Command ID: ${commandId}`);\r\n\r\n return { sent: true, commandId };\r\n } finally {\r\n await client.disconnect();\r\n }\r\n}\r\n\r\n/**\r\n * Wait for agent response to a command\r\n */\r\nexport async function waitForResponse(\r\n config: MessagingConfig,\r\n commandId: string,\r\n timeoutSeconds: number = 30\r\n): Promise<AgentStatus | null> {\r\n const {\r\n taskId,\r\n agentId,\r\n redisHost = process.env.CFN_REDIS_HOST || 'localhost',\r\n redisPort = parseInt(process.env.CFN_REDIS_PORT || '6379', 10),\r\n redisPassword = process.env.CFN_REDIS_PASSWORD || undefined\r\n } = config;\r\n\r\n const client: RedisClientType = createClient({\r\n socket: { host: redisHost, port: redisPort },\r\n password: redisPassword || undefined\r\n });\r\n\r\n try {\r\n await client.connect();\r\n\r\n const responseKey = getResponseKey(taskId, agentId, commandId);\r\n const result = await client.blPop(responseKey, timeoutSeconds);\r\n\r\n if (result) {\r\n return JSON.parse(result.element) as AgentStatus;\r\n }\r\n return null;\r\n } finally {\r\n await client.disconnect();\r\n }\r\n}\r\n\r\n/**\r\n * Get current agent status (non-blocking)\r\n */\r\nexport async function getAgentStatus(config: MessagingConfig): Promise<AgentStatus | null> {\r\n const {\r\n taskId,\r\n agentId,\r\n redisHost = process.env.CFN_REDIS_HOST || 'localhost',\r\n redisPort = parseInt(process.env.CFN_REDIS_PORT || '6379', 10),\r\n redisPassword = process.env.CFN_REDIS_PASSWORD || undefined\r\n } = config;\r\n\r\n const client: RedisClientType = createClient({\r\n socket: { host: redisHost, port: redisPort },\r\n password: redisPassword || undefined\r\n });\r\n\r\n try {\r\n await client.connect();\r\n\r\n const statusKey = getStatusKey(taskId, agentId);\r\n const status = await client.get(statusKey);\r\n\r\n if (status) {\r\n return JSON.parse(status) as AgentStatus;\r\n }\r\n return null;\r\n } finally {\r\n await client.disconnect();\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// Agent Side - Process Commands\r\n// ============================================================================\r\n\r\nexport type CommandHandler = (command: AgentCommand) => Promise<AgentStatus | void>;\r\n\r\n/**\r\n * Agent command processor - polls for and processes commands\r\n */\r\nexport class AgentCommandProcessor {\r\n private client: RedisClientType | null = null;\r\n private running = false;\r\n private handlers: Map<CommandType, CommandHandler> = new Map();\r\n\r\n constructor(private config: MessagingConfig) {\r\n // Default handlers\r\n this.handlers.set('status', this.handleStatus.bind(this));\r\n this.handlers.set('abort', this.handleAbort.bind(this));\r\n this.handlers.set('pause', this.handlePause.bind(this));\r\n }\r\n\r\n /**\r\n * Register a custom command handler\r\n */\r\n onCommand(type: CommandType, handler: CommandHandler): void {\r\n this.handlers.set(type, handler);\r\n }\r\n\r\n /**\r\n * Start processing commands (non-blocking poll loop)\r\n */\r\n async start(pollIntervalSeconds: number = 5): Promise<void> {\r\n const {\r\n taskId,\r\n agentId,\r\n redisHost = process.env.CFN_REDIS_HOST || 'localhost',\r\n redisPort = parseInt(process.env.CFN_REDIS_PORT || '6379', 10),\r\n redisPassword = process.env.CFN_REDIS_PASSWORD || undefined\r\n } = this.config;\r\n\r\n this.client = createClient({\r\n socket: { host: redisHost, port: redisPort },\r\n password: redisPassword || undefined\r\n });\r\n\r\n await this.client.connect();\r\n this.running = true;\r\n\r\n const commandsKey = getCommandsKey(taskId, agentId);\r\n console.log(`[agent-processor] Started listening on ${commandsKey}`);\r\n\r\n // Non-blocking poll loop\r\n while (this.running) {\r\n try {\r\n // Short BLPOP to check for commands without blocking too long\r\n const result = await this.client.blPop(commandsKey, pollIntervalSeconds);\r\n\r\n if (result) {\r\n const command: AgentCommand = JSON.parse(result.element);\r\n console.log(`[agent-processor] Received command: ${command.type} (${command.id})`);\r\n\r\n // Process command\r\n const handler = this.handlers.get(command.type);\r\n if (handler) {\r\n const response = await handler(command);\r\n\r\n // Send response if handler returned status\r\n if (response && command.replyTo) {\r\n await this.client.lPush(command.replyTo, JSON.stringify(response));\r\n console.log(`[agent-processor] Sent response to ${command.replyTo}`);\r\n }\r\n } else {\r\n console.warn(`[agent-processor] No handler for command type: ${command.type}`);\r\n }\r\n }\r\n } catch (err) {\r\n if (this.running) {\r\n console.error(`[agent-processor] Error processing command:`, err);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Stop processing commands\r\n */\r\n async stop(): Promise<void> {\r\n this.running = false;\r\n if (this.client) {\r\n await this.client.disconnect();\r\n this.client = null;\r\n }\r\n console.log(`[agent-processor] Stopped`);\r\n }\r\n\r\n /**\r\n * Update agent status in Redis\r\n */\r\n async updateStatus(status: Partial<AgentStatus>): Promise<void> {\r\n if (!this.client) return;\r\n\r\n const { taskId, agentId } = this.config;\r\n const fullStatus: AgentStatus = {\r\n agentId,\r\n taskId,\r\n status: 'running',\r\n timestamp: new Date().toISOString(),\r\n ...status\r\n };\r\n\r\n const statusKey = getStatusKey(taskId, agentId);\r\n await this.client.set(statusKey, JSON.stringify(fullStatus) as string);\r\n // Expire after 1 hour\r\n await this.client.expire(statusKey, 3600);\r\n }\r\n\r\n // Default handlers\r\n\r\n private async handleStatus(command: AgentCommand): Promise<AgentStatus> {\r\n const { taskId, agentId } = this.config;\r\n return {\r\n agentId,\r\n taskId,\r\n status: 'running',\r\n timestamp: new Date().toISOString(),\r\n metadata: { respondingTo: command.id }\r\n };\r\n }\r\n\r\n private async handleAbort(_command: AgentCommand): Promise<AgentStatus> {\r\n const { taskId, agentId } = this.config;\r\n console.log(`[agent-processor] Abort requested, shutting down...`);\r\n\r\n // Schedule stop after response\r\n setTimeout(() => this.stop(), 100);\r\n\r\n return {\r\n agentId,\r\n taskId,\r\n status: 'aborting',\r\n timestamp: new Date().toISOString()\r\n };\r\n }\r\n\r\n private async handlePause(command: AgentCommand): Promise<AgentStatus> {\r\n const { taskId, agentId } = this.config;\r\n const pauseSeconds = (command.payload?.seconds as number) || 10;\r\n\r\n console.log(`[agent-processor] Pausing for ${pauseSeconds}s...`);\r\n await new Promise(resolve => setTimeout(resolve, pauseSeconds * 1000));\r\n console.log(`[agent-processor] Resumed after pause`);\r\n\r\n return {\r\n agentId,\r\n taskId,\r\n status: 'running',\r\n timestamp: new Date().toISOString(),\r\n metadata: { pausedFor: pauseSeconds }\r\n };\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// CLI Entry Point\r\n// ============================================================================\r\n\r\nfunction printHelp(): void {\r\n console.log(`\r\nAgent Messaging - Bidirectional Redis Communication\r\n\r\nUSAGE:\r\n # Send command to agent (Main Chat side)\r\n npx tsx src/cli/coordination/agent-messaging.ts send \\\\\r\n --task-id <id> --agent-id <aid> --command <type> [--payload <json>]\r\n\r\n # Listen for commands (Agent side)\r\n npx tsx src/cli/coordination/agent-messaging.ts listen \\\\\r\n --task-id <id> --agent-id <aid> [--poll-interval <seconds>]\r\n\r\n # Get agent status (Main Chat side)\r\n npx tsx src/cli/coordination/agent-messaging.ts status \\\\\r\n --task-id <id> --agent-id <aid>\r\n\r\nCOMMANDS:\r\n status Request agent status update\r\n redirect Redirect agent to new task (include --payload)\r\n abort Request clean agent abort\r\n pause Pause agent (include --payload '{\"seconds\": 10}')\r\n custom Custom command (include --payload)\r\n\r\nEXAMPLES:\r\n # Request status from agent\r\n npx tsx src/cli/coordination/agent-messaging.ts send \\\\\r\n --task-id cfn-cli-123 --agent-id backend-dev-456 --command status\r\n\r\n # Abort agent\r\n npx tsx src/cli/coordination/agent-messaging.ts send \\\\\r\n --task-id cfn-cli-123 --agent-id backend-dev-456 --command abort\r\n\r\n # Pause agent for 30 seconds\r\n npx tsx src/cli/coordination/agent-messaging.ts send \\\\\r\n --task-id cfn-cli-123 --agent-id backend-dev-456 \\\\\r\n --command pause --payload '{\"seconds\": 30}'\r\n\r\n # Redirect agent to new context\r\n npx tsx src/cli/coordination/agent-messaging.ts send \\\\\r\n --task-id cfn-cli-123 --agent-id backend-dev-456 \\\\\r\n --command redirect --payload '{\"newTask\": \"Focus on security tests\"}'\r\n\r\n # Start listening for commands (agent side)\r\n npx tsx src/cli/coordination/agent-messaging.ts listen \\\\\r\n --task-id cfn-cli-123 --agent-id backend-dev-456 --poll-interval 5\r\n`);\r\n}\r\n\r\nasync function main(): Promise<void> {\r\n const args = process.argv.slice(2);\r\n const action = args[0];\r\n\r\n if (!action || action === '--help' || action === '-h') {\r\n printHelp();\r\n process.exit(0);\r\n }\r\n\r\n // Parse common args\r\n let taskId: string | undefined;\r\n let agentId: string | undefined;\r\n let command: CommandType | undefined;\r\n let payload: Record<string, unknown> | undefined;\r\n let pollInterval = 5;\r\n\r\n for (let i = 1; i < args.length; i++) {\r\n const arg = args[i];\r\n const value = args[i + 1];\r\n\r\n switch (arg) {\r\n case '--task-id':\r\n case '-t':\r\n taskId = value;\r\n i++;\r\n break;\r\n case '--agent-id':\r\n case '-a':\r\n agentId = value;\r\n i++;\r\n break;\r\n case '--command':\r\n case '-c':\r\n command = value as CommandType;\r\n i++;\r\n break;\r\n case '--payload':\r\n case '-p':\r\n try {\r\n payload = JSON.parse(value);\r\n } catch {\r\n console.error('Invalid JSON payload');\r\n process.exit(1);\r\n }\r\n i++;\r\n break;\r\n case '--poll-interval':\r\n pollInterval = parseInt(value, 10);\r\n i++;\r\n break;\r\n }\r\n }\r\n\r\n if (!taskId || !agentId) {\r\n console.error('Error: --task-id and --agent-id are required');\r\n process.exit(1);\r\n }\r\n\r\n const config: MessagingConfig = { taskId, agentId };\r\n\r\n switch (action) {\r\n case 'send': {\r\n if (!command) {\r\n console.error('Error: --command is required for send action');\r\n process.exit(1);\r\n }\r\n const result = await sendCommand(config, { type: command, payload });\r\n console.log(JSON.stringify(result, null, 2));\r\n\r\n // Wait for response\r\n console.log('\\n[agent-msg] Waiting for response (30s timeout)...');\r\n const response = await waitForResponse(config, result.commandId, 30);\r\n if (response) {\r\n console.log('[agent-msg] Response received:');\r\n console.log(JSON.stringify(response, null, 2));\r\n } else {\r\n console.log('[agent-msg] No response received (timeout)');\r\n }\r\n break;\r\n }\r\n\r\n case 'listen': {\r\n const processor = new AgentCommandProcessor(config);\r\n\r\n // Handle shutdown signals\r\n process.on('SIGINT', async () => {\r\n console.log('\\n[agent-msg] Received SIGINT, stopping...');\r\n await processor.stop();\r\n process.exit(0);\r\n });\r\n\r\n await processor.start(pollInterval);\r\n break;\r\n }\r\n\r\n case 'status': {\r\n const status = await getAgentStatus(config);\r\n if (status) {\r\n console.log(JSON.stringify(status, null, 2));\r\n } else {\r\n console.log('No status available for agent');\r\n }\r\n break;\r\n }\r\n\r\n default:\r\n console.error(`Unknown action: ${action}`);\r\n printHelp();\r\n process.exit(1);\r\n }\r\n}\r\n\r\n// Run if called directly\r\nif (import.meta.url.endsWith(process.argv[1]?.replace(/\\\\/g, '/') || '')) {\r\n main().catch(err => {\r\n console.error('[agent-msg] Fatal error:', err);\r\n process.exit(2);\r\n });\r\n}\r\n"],"names":["createClient","getCommandsKey","taskId","agentId","getStatusKey","getResponseKey","commandId","sendCommand","config","command","redisHost","process","env","CFN_REDIS_HOST","redisPort","parseInt","CFN_REDIS_PORT","redisPassword","CFN_REDIS_PASSWORD","undefined","client","socket","host","port","password","Date","now","Math","random","toString","substring","fullCommand","id","timestamp","toISOString","replyTo","connect","commandsKey","lPush","JSON","stringify","console","log","type","sent","disconnect","waitForResponse","timeoutSeconds","responseKey","result","blPop","parse","element","getAgentStatus","statusKey","status","get","AgentCommandProcessor","running","handlers","Map","set","handleStatus","bind","handleAbort","handlePause","onCommand","handler","start","pollIntervalSeconds","response","warn","err","error","stop","updateStatus","fullStatus","expire","metadata","respondingTo","_command","setTimeout","pauseSeconds","payload","seconds","Promise","resolve","pausedFor","printHelp","main","args","argv","slice","action","exit","pollInterval","i","length","arg","value","processor","on","url","endsWith","replace","catch"],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;CAqBC,GAED,SAASA,YAAY,QAAyB,QAAQ;AAkCtD,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E,SAASC,eAAeC,MAAc,EAAEC,OAAe;IACrD,OAAO,CAAC,UAAU,EAAED,OAAO,CAAC,EAAEC,QAAQ,SAAS,CAAC;AAClD;AAEA,SAASC,aAAaF,MAAc,EAAEC,OAAe;IACnD,OAAO,CAAC,UAAU,EAAED,OAAO,CAAC,EAAEC,QAAQ,OAAO,CAAC;AAChD;AAEA,SAASE,eAAeH,MAAc,EAAEC,OAAe,EAAEG,SAAiB;IACxE,OAAO,CAAC,UAAU,EAAEJ,OAAO,CAAC,EAAEC,QAAQ,UAAU,EAAEG,WAAW;AAC/D;AAEA,+EAA+E;AAC/E,iCAAiC;AACjC,+EAA+E;AAE/E;;CAEC,GACD,OAAO,eAAeC,YACpBC,MAAuB,EACvBC,OAA+C;IAE/C,MAAM,EACJP,MAAM,EACNC,OAAO,EACPO,YAAYC,QAAQC,GAAG,CAACC,cAAc,IAAI,WAAW,EACrDC,YAAYC,SAASJ,QAAQC,GAAG,CAACI,cAAc,IAAI,QAAQ,GAAG,EAC9DC,gBAAgBN,QAAQC,GAAG,CAACM,kBAAkB,IAAIC,SAAS,EAC5D,GAAGX;IAEJ,MAAMY,SAA0BpB,aAAa;QAC3CqB,QAAQ;YAAEC,MAAMZ;YAAWa,MAAMT;QAAU;QAC3CU,UAAUP,iBAAiBE;IAC7B;IAEA,MAAMb,YAAY,CAAC,I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