agentic-flow 1.0.0
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/agents/MIGRATION_SUMMARY.md +222 -0
- package/.claude/agents/README.md +89 -0
- package/.claude/agents/analysis/code-analyzer.md +209 -0
- package/.claude/agents/analysis/code-review/analyze-code-quality.md +180 -0
- package/.claude/agents/architecture/system-design/arch-system-design.md +156 -0
- package/.claude/agents/base-template-generator.md +42 -0
- package/.claude/agents/consensus/README.md +253 -0
- package/.claude/agents/consensus/byzantine-coordinator.md +63 -0
- package/.claude/agents/consensus/crdt-synchronizer.md +997 -0
- package/.claude/agents/consensus/gossip-coordinator.md +63 -0
- package/.claude/agents/consensus/performance-benchmarker.md +851 -0
- package/.claude/agents/consensus/quorum-manager.md +823 -0
- package/.claude/agents/consensus/raft-manager.md +63 -0
- package/.claude/agents/consensus/security-manager.md +622 -0
- package/.claude/agents/core/coder.md +211 -0
- package/.claude/agents/core/planner.md +116 -0
- package/.claude/agents/core/researcher.md +136 -0
- package/.claude/agents/core/reviewer.md +272 -0
- package/.claude/agents/core/tester.md +266 -0
- package/.claude/agents/data/ml/data-ml-model.md +193 -0
- package/.claude/agents/development/backend/dev-backend-api.md +142 -0
- package/.claude/agents/devops/ci-cd/ops-cicd-github.md +164 -0
- package/.claude/agents/documentation/api-docs/docs-api-openapi.md +174 -0
- package/.claude/agents/flow-nexus/app-store.md +88 -0
- package/.claude/agents/flow-nexus/authentication.md +69 -0
- package/.claude/agents/flow-nexus/challenges.md +81 -0
- package/.claude/agents/flow-nexus/neural-network.md +88 -0
- package/.claude/agents/flow-nexus/payments.md +83 -0
- package/.claude/agents/flow-nexus/sandbox.md +76 -0
- package/.claude/agents/flow-nexus/swarm.md +76 -0
- package/.claude/agents/flow-nexus/user-tools.md +96 -0
- package/.claude/agents/flow-nexus/workflow.md +84 -0
- package/.claude/agents/github/code-review-swarm.md +538 -0
- package/.claude/agents/github/github-modes.md +173 -0
- package/.claude/agents/github/issue-tracker.md +319 -0
- package/.claude/agents/github/multi-repo-swarm.md +553 -0
- package/.claude/agents/github/pr-manager.md +191 -0
- package/.claude/agents/github/project-board-sync.md +509 -0
- package/.claude/agents/github/release-manager.md +367 -0
- package/.claude/agents/github/release-swarm.md +583 -0
- package/.claude/agents/github/repo-architect.md +398 -0
- package/.claude/agents/github/swarm-issue.md +573 -0
- package/.claude/agents/github/swarm-pr.md +428 -0
- package/.claude/agents/github/sync-coordinator.md +452 -0
- package/.claude/agents/github/workflow-automation.md +635 -0
- package/.claude/agents/goal/agent.md +816 -0
- package/.claude/agents/goal/goal-planner.md +73 -0
- package/.claude/agents/optimization/README.md +250 -0
- package/.claude/agents/optimization/benchmark-suite.md +665 -0
- package/.claude/agents/optimization/load-balancer.md +431 -0
- package/.claude/agents/optimization/performance-monitor.md +672 -0
- package/.claude/agents/optimization/resource-allocator.md +674 -0
- package/.claude/agents/optimization/topology-optimizer.md +808 -0
- package/.claude/agents/payments/agentic-payments.md +126 -0
- package/.claude/agents/sparc/architecture.md +472 -0
- package/.claude/agents/sparc/pseudocode.md +318 -0
- package/.claude/agents/sparc/refinement.md +525 -0
- package/.claude/agents/sparc/specification.md +276 -0
- package/.claude/agents/specialized/mobile/spec-mobile-react-native.md +226 -0
- package/.claude/agents/sublinear/consensus-coordinator.md +338 -0
- package/.claude/agents/sublinear/matrix-optimizer.md +185 -0
- package/.claude/agents/sublinear/pagerank-analyzer.md +299 -0
- package/.claude/agents/sublinear/performance-optimizer.md +368 -0
- package/.claude/agents/sublinear/trading-predictor.md +246 -0
- package/.claude/agents/swarm/README.md +190 -0
- package/.claude/agents/swarm/adaptive-coordinator.md +396 -0
- package/.claude/agents/swarm/hierarchical-coordinator.md +256 -0
- package/.claude/agents/swarm/mesh-coordinator.md +392 -0
- package/.claude/agents/templates/automation-smart-agent.md +205 -0
- package/.claude/agents/templates/coordinator-swarm-init.md +90 -0
- package/.claude/agents/templates/github-pr-manager.md +177 -0
- package/.claude/agents/templates/implementer-sparc-coder.md +259 -0
- package/.claude/agents/templates/memory-coordinator.md +187 -0
- package/.claude/agents/templates/migration-plan.md +746 -0
- package/.claude/agents/templates/orchestrator-task.md +139 -0
- package/.claude/agents/templates/performance-analyzer.md +199 -0
- package/.claude/agents/templates/sparc-coordinator.md +183 -0
- package/.claude/agents/test-neural.md +14 -0
- package/.claude/agents/testing/unit/tdd-london-swarm.md +244 -0
- package/.claude/agents/testing/validation/production-validator.md +395 -0
- package/.claude/commands/agents/README.md +10 -0
- package/.claude/commands/agents/agent-capabilities.md +21 -0
- package/.claude/commands/agents/agent-coordination.md +28 -0
- package/.claude/commands/agents/agent-spawning.md +28 -0
- package/.claude/commands/agents/agent-types.md +26 -0
- package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +54 -0
- package/.claude/commands/analysis/README.md +9 -0
- package/.claude/commands/analysis/bottleneck-detect.md +162 -0
- package/.claude/commands/analysis/performance-bottlenecks.md +59 -0
- package/.claude/commands/analysis/performance-report.md +25 -0
- package/.claude/commands/analysis/token-efficiency.md +45 -0
- package/.claude/commands/analysis/token-usage.md +25 -0
- package/.claude/commands/automation/README.md +9 -0
- package/.claude/commands/automation/auto-agent.md +122 -0
- package/.claude/commands/automation/self-healing.md +106 -0
- package/.claude/commands/automation/session-memory.md +90 -0
- package/.claude/commands/automation/smart-agents.md +73 -0
- package/.claude/commands/automation/smart-spawn.md +25 -0
- package/.claude/commands/automation/workflow-select.md +25 -0
- package/.claude/commands/claude-flow-help.md +103 -0
- package/.claude/commands/claude-flow-memory.md +107 -0
- package/.claude/commands/claude-flow-swarm.md +205 -0
- package/.claude/commands/coordination/README.md +9 -0
- package/.claude/commands/coordination/agent-spawn.md +25 -0
- package/.claude/commands/coordination/init.md +44 -0
- package/.claude/commands/coordination/orchestrate.md +43 -0
- package/.claude/commands/coordination/spawn.md +45 -0
- package/.claude/commands/coordination/swarm-init.md +85 -0
- package/.claude/commands/coordination/task-orchestrate.md +25 -0
- package/.claude/commands/flow-nexus/app-store.md +124 -0
- package/.claude/commands/flow-nexus/challenges.md +120 -0
- package/.claude/commands/flow-nexus/login-registration.md +65 -0
- package/.claude/commands/flow-nexus/neural-network.md +134 -0
- package/.claude/commands/flow-nexus/payments.md +116 -0
- package/.claude/commands/flow-nexus/sandbox.md +83 -0
- package/.claude/commands/flow-nexus/swarm.md +87 -0
- package/.claude/commands/flow-nexus/user-tools.md +152 -0
- package/.claude/commands/flow-nexus/workflow.md +115 -0
- package/.claude/commands/github/README.md +11 -0
- package/.claude/commands/github/code-review-swarm.md +514 -0
- package/.claude/commands/github/code-review.md +25 -0
- package/.claude/commands/github/github-modes.md +147 -0
- package/.claude/commands/github/github-swarm.md +121 -0
- package/.claude/commands/github/issue-tracker.md +292 -0
- package/.claude/commands/github/issue-triage.md +25 -0
- package/.claude/commands/github/multi-repo-swarm.md +519 -0
- package/.claude/commands/github/pr-enhance.md +26 -0
- package/.claude/commands/github/pr-manager.md +170 -0
- package/.claude/commands/github/project-board-sync.md +471 -0
- package/.claude/commands/github/release-manager.md +338 -0
- package/.claude/commands/github/release-swarm.md +544 -0
- package/.claude/commands/github/repo-analyze.md +25 -0
- package/.claude/commands/github/repo-architect.md +367 -0
- package/.claude/commands/github/swarm-issue.md +482 -0
- package/.claude/commands/github/swarm-pr.md +285 -0
- package/.claude/commands/github/sync-coordinator.md +301 -0
- package/.claude/commands/github/workflow-automation.md +442 -0
- package/.claude/commands/hive-mind/README.md +17 -0
- package/.claude/commands/hive-mind/hive-mind-consensus.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-init.md +18 -0
- package/.claude/commands/hive-mind/hive-mind-memory.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-metrics.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-resume.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-sessions.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-spawn.md +21 -0
- package/.claude/commands/hive-mind/hive-mind-status.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-stop.md +8 -0
- package/.claude/commands/hive-mind/hive-mind-wizard.md +8 -0
- package/.claude/commands/hive-mind/hive-mind.md +27 -0
- package/.claude/commands/hooks/README.md +11 -0
- package/.claude/commands/hooks/overview.md +58 -0
- package/.claude/commands/hooks/post-edit.md +117 -0
- package/.claude/commands/hooks/post-task.md +112 -0
- package/.claude/commands/hooks/pre-edit.md +113 -0
- package/.claude/commands/hooks/pre-task.md +111 -0
- package/.claude/commands/hooks/session-end.md +118 -0
- package/.claude/commands/hooks/setup.md +103 -0
- package/.claude/commands/memory/README.md +9 -0
- package/.claude/commands/memory/memory-persist.md +25 -0
- package/.claude/commands/memory/memory-search.md +25 -0
- package/.claude/commands/memory/memory-usage.md +25 -0
- package/.claude/commands/memory/neural.md +47 -0
- package/.claude/commands/memory/usage.md +46 -0
- package/.claude/commands/monitoring/README.md +9 -0
- package/.claude/commands/monitoring/agent-metrics.md +25 -0
- package/.claude/commands/monitoring/agents.md +44 -0
- package/.claude/commands/monitoring/real-time-view.md +25 -0
- package/.claude/commands/monitoring/status.md +46 -0
- package/.claude/commands/monitoring/swarm-monitor.md +25 -0
- package/.claude/commands/optimization/README.md +9 -0
- package/.claude/commands/optimization/auto-topology.md +62 -0
- package/.claude/commands/optimization/cache-manage.md +25 -0
- package/.claude/commands/optimization/parallel-execute.md +25 -0
- package/.claude/commands/optimization/parallel-execution.md +50 -0
- package/.claude/commands/optimization/topology-optimize.md +25 -0
- package/.claude/commands/pair/README.md +261 -0
- package/.claude/commands/pair/commands.md +546 -0
- package/.claude/commands/pair/config.md +510 -0
- package/.claude/commands/pair/examples.md +512 -0
- package/.claude/commands/pair/modes.md +348 -0
- package/.claude/commands/pair/session.md +407 -0
- package/.claude/commands/pair/start.md +209 -0
- package/.claude/commands/sparc/analyzer.md +52 -0
- package/.claude/commands/sparc/architect.md +53 -0
- package/.claude/commands/sparc/ask.md +97 -0
- package/.claude/commands/sparc/batch-executor.md +54 -0
- package/.claude/commands/sparc/code.md +89 -0
- package/.claude/commands/sparc/coder.md +54 -0
- package/.claude/commands/sparc/debug.md +83 -0
- package/.claude/commands/sparc/debugger.md +54 -0
- package/.claude/commands/sparc/designer.md +53 -0
- package/.claude/commands/sparc/devops.md +109 -0
- package/.claude/commands/sparc/docs-writer.md +80 -0
- package/.claude/commands/sparc/documenter.md +54 -0
- package/.claude/commands/sparc/innovator.md +54 -0
- package/.claude/commands/sparc/integration.md +83 -0
- package/.claude/commands/sparc/mcp.md +117 -0
- package/.claude/commands/sparc/memory-manager.md +54 -0
- package/.claude/commands/sparc/optimizer.md +54 -0
- package/.claude/commands/sparc/orchestrator.md +132 -0
- package/.claude/commands/sparc/post-deployment-monitoring-mode.md +83 -0
- package/.claude/commands/sparc/refinement-optimization-mode.md +83 -0
- package/.claude/commands/sparc/researcher.md +54 -0
- package/.claude/commands/sparc/reviewer.md +54 -0
- package/.claude/commands/sparc/security-review.md +80 -0
- package/.claude/commands/sparc/sparc-modes.md +174 -0
- package/.claude/commands/sparc/sparc.md +111 -0
- package/.claude/commands/sparc/spec-pseudocode.md +80 -0
- package/.claude/commands/sparc/supabase-admin.md +348 -0
- package/.claude/commands/sparc/swarm-coordinator.md +54 -0
- package/.claude/commands/sparc/tdd.md +54 -0
- package/.claude/commands/sparc/tester.md +54 -0
- package/.claude/commands/sparc/tutorial.md +79 -0
- package/.claude/commands/sparc/workflow-manager.md +54 -0
- package/.claude/commands/sparc.md +166 -0
- package/.claude/commands/stream-chain/pipeline.md +121 -0
- package/.claude/commands/stream-chain/run.md +70 -0
- package/.claude/commands/swarm/README.md +15 -0
- package/.claude/commands/swarm/analysis.md +95 -0
- package/.claude/commands/swarm/development.md +96 -0
- package/.claude/commands/swarm/examples.md +168 -0
- package/.claude/commands/swarm/maintenance.md +102 -0
- package/.claude/commands/swarm/optimization.md +117 -0
- package/.claude/commands/swarm/research.md +136 -0
- package/.claude/commands/swarm/swarm-analysis.md +8 -0
- package/.claude/commands/swarm/swarm-background.md +8 -0
- package/.claude/commands/swarm/swarm-init.md +19 -0
- package/.claude/commands/swarm/swarm-modes.md +8 -0
- package/.claude/commands/swarm/swarm-monitor.md +8 -0
- package/.claude/commands/swarm/swarm-spawn.md +19 -0
- package/.claude/commands/swarm/swarm-status.md +8 -0
- package/.claude/commands/swarm/swarm-strategies.md +8 -0
- package/.claude/commands/swarm/swarm.md +27 -0
- package/.claude/commands/swarm/testing.md +131 -0
- package/.claude/commands/training/README.md +9 -0
- package/.claude/commands/training/model-update.md +25 -0
- package/.claude/commands/training/neural-patterns.md +74 -0
- package/.claude/commands/training/neural-train.md +25 -0
- package/.claude/commands/training/pattern-learn.md +25 -0
- package/.claude/commands/training/specialization.md +63 -0
- package/.claude/commands/truth/start.md +143 -0
- package/.claude/commands/verify/check.md +50 -0
- package/.claude/commands/verify/start.md +128 -0
- package/.claude/commands/workflows/README.md +9 -0
- package/.claude/commands/workflows/development.md +78 -0
- package/.claude/commands/workflows/research.md +63 -0
- package/.claude/commands/workflows/workflow-create.md +25 -0
- package/.claude/commands/workflows/workflow-execute.md +25 -0
- package/.claude/commands/workflows/workflow-export.md +25 -0
- package/.claude/helpers/checkpoint-manager.sh +251 -0
- package/.claude/helpers/github-safe.js +106 -0
- package/.claude/helpers/github-setup.sh +28 -0
- package/.claude/helpers/quick-start.sh +19 -0
- package/.claude/helpers/setup-mcp.sh +18 -0
- package/.claude/helpers/standard-checkpoint-hooks.sh +179 -0
- package/.claude/mcp.json +13 -0
- package/.claude/settings-backup.json +130 -0
- package/.claude/settings-optimized.json +116 -0
- package/.claude/settings-simple.json +78 -0
- package/.claude/settings.json +114 -0
- package/.claude/settings.local.json +14 -0
- package/README.md +1280 -0
- package/dist/agents/claudeAgent.js +73 -0
- package/dist/agents/claudeFlowAgent.js +115 -0
- package/dist/agents/codeReviewAgent.js +34 -0
- package/dist/agents/dataAgent.js +34 -0
- package/dist/agents/directApiAgent.js +260 -0
- package/dist/agents/webResearchAgent.js +35 -0
- package/dist/cli/mcp.js +135 -0
- package/dist/cli-proxy.js +246 -0
- package/dist/cli.js +158 -0
- package/dist/config/claudeFlow.js +67 -0
- package/dist/config/tools.js +33 -0
- package/dist/coordination/parallelSwarm.js +226 -0
- package/dist/examples/multi-agent-orchestration.js +45 -0
- package/dist/examples/parallel-swarm-deployment.js +171 -0
- package/dist/examples/use-goal-planner.js +52 -0
- package/dist/health.js +46 -0
- package/dist/index-with-proxy.js +101 -0
- package/dist/index.js +167 -0
- package/dist/mcp/claudeFlowSdkServer.js +202 -0
- package/dist/mcp/fastmcp/servers/claude-flow-sdk.js +198 -0
- package/dist/mcp/fastmcp/servers/http-streaming-updated.js +421 -0
- package/dist/mcp/fastmcp/servers/poc-stdio.js +82 -0
- package/dist/mcp/fastmcp/servers/stdio-full.js +421 -0
- package/dist/mcp/fastmcp/tools/agent/add-agent.js +107 -0
- package/dist/mcp/fastmcp/tools/agent/add-command.js +117 -0
- package/dist/mcp/fastmcp/tools/agent/execute.js +56 -0
- package/dist/mcp/fastmcp/tools/agent/list.js +82 -0
- package/dist/mcp/fastmcp/tools/agent/parallel.js +63 -0
- package/dist/mcp/fastmcp/tools/memory/retrieve.js +38 -0
- package/dist/mcp/fastmcp/tools/memory/search.js +41 -0
- package/dist/mcp/fastmcp/tools/memory/store.js +56 -0
- package/dist/mcp/fastmcp/tools/swarm/init.js +41 -0
- package/dist/mcp/fastmcp/tools/swarm/orchestrate.js +47 -0
- package/dist/mcp/fastmcp/tools/swarm/spawn.js +40 -0
- package/dist/mcp/fastmcp/types/index.js +2 -0
- package/dist/proxy/anthropic-to-openrouter.js +246 -0
- package/dist/router/providers/anthropic.js +89 -0
- package/dist/router/providers/onnx-local-optimized.js +167 -0
- package/dist/router/providers/onnx-local.js +294 -0
- package/dist/router/providers/onnx-phi4.js +190 -0
- package/dist/router/providers/onnx.js +242 -0
- package/dist/router/providers/openrouter.js +242 -0
- package/dist/router/router.js +283 -0
- package/dist/router/test-integration.js +140 -0
- package/dist/router/test-onnx-benchmark.js +145 -0
- package/dist/router/test-onnx-integration.js +128 -0
- package/dist/router/test-onnx-local.js +37 -0
- package/dist/router/test-onnx.js +148 -0
- package/dist/router/test-openrouter.js +121 -0
- package/dist/router/test-phi4.js +137 -0
- package/dist/router/types.js +2 -0
- package/dist/utils/agentLoader.js +106 -0
- package/dist/utils/cli.js +128 -0
- package/dist/utils/logger.js +41 -0
- package/dist/utils/mcpCommands.js +214 -0
- package/dist/utils/model-downloader.js +182 -0
- package/dist/utils/retry.js +54 -0
- package/docs/.claude-flow/metrics/agent-metrics.json +1 -0
- package/docs/.claude-flow/metrics/performance.json +9 -0
- package/docs/.claude-flow/metrics/task-metrics.json +10 -0
- package/docs/CHANGELOG.md +155 -0
- package/docs/CLAUDE.md +352 -0
- package/docs/COMPLETE_VALIDATION_SUMMARY.md +405 -0
- package/docs/INDEX.md +183 -0
- package/docs/LICENSE +21 -0
- package/docs/ONNX_CLI_USAGE.md +344 -0
- package/docs/ONNX_ENV_VARS.md +564 -0
- package/docs/ONNX_INTEGRATION.md +422 -0
- package/docs/ONNX_OPTIMIZATION_GUIDE.md +665 -0
- package/docs/ONNX_OPTIMIZATION_SUMMARY.md +374 -0
- package/docs/ONNX_VS_CLAUDE_QUALITY.md +442 -0
- package/docs/OPENROUTER_DEPLOYMENT.md +495 -0
- package/docs/architecture/EXECUTIVE_SUMMARY.md +310 -0
- package/docs/architecture/IMPROVEMENT_PLAN.md +11 -0
- package/docs/architecture/INTEGRATION-STATUS.md +290 -0
- package/docs/architecture/MULTI_MODEL_ROUTER_PLAN.md +620 -0
- package/docs/architecture/QUICK_WINS.md +333 -0
- package/docs/architecture/README.md +15 -0
- package/docs/architecture/RESEARCH_SUMMARY.md +652 -0
- package/docs/archived/FASTMCP_COMPLETE.md +428 -0
- package/docs/archived/FASTMCP_INTEGRATION_STATUS.md +288 -0
- package/docs/archived/FLOW-NEXUS-COMPLETE.md +269 -0
- package/docs/archived/INTEGRATION_CONFIRMED.md +351 -0
- package/docs/archived/ONNX_FINAL_REPORT.md +312 -0
- package/docs/archived/ONNX_IMPLEMENTATION_COMPLETE.md +215 -0
- package/docs/archived/ONNX_IMPLEMENTATION_SUMMARY.md +197 -0
- package/docs/archived/ONNX_SUCCESS_REPORT.md +271 -0
- package/docs/archived/OPENROUTER_PROXY_COMPLETE.md +494 -0
- package/docs/archived/PACKAGE-COMPLETE.md +138 -0
- package/docs/archived/README.md +27 -0
- package/docs/archived/RESEARCH_COMPLETE.txt +335 -0
- package/docs/archived/SDK-SETUP-COMPLETE.md +252 -0
- package/docs/guides/ALTERNATIVE_LLM_MODELS.md +524 -0
- package/docs/guides/DOCKER_AGENT_USAGE.md +352 -0
- package/docs/guides/IMPLEMENTATION_EXAMPLES.md +960 -0
- package/docs/guides/NPM-PUBLISH.md +218 -0
- package/docs/guides/README.md +17 -0
- package/docs/guides/agent-sdk.md +234 -0
- package/docs/integrations/CLAUDE_AGENTS_INTEGRATION.md +356 -0
- package/docs/integrations/CLAUDE_FLOW_INTEGRATION.md +535 -0
- package/docs/integrations/FASTMCP_CLI_INTEGRATION.md +503 -0
- package/docs/integrations/FLOW-NEXUS-INTEGRATION.md +319 -0
- package/docs/integrations/README.md +18 -0
- package/docs/integrations/fastmcp-implementation-plan.md +2516 -0
- package/docs/integrations/fastmcp-poc-integration.md +198 -0
- package/docs/router/ONNX_PHI4_RESEARCH.md +220 -0
- package/docs/router/ONNX_RUNTIME_INTEGRATION_PLAN.md +866 -0
- package/docs/router/PHI4_HYPEROPTIMIZATION_PLAN.md +2488 -0
- package/docs/router/README.md +552 -0
- package/docs/router/ROUTER_CONFIG_REFERENCE.md +577 -0
- package/docs/router/ROUTER_USER_GUIDE.md +865 -0
- package/docs/validation/DOCKER_MCP_VALIDATION.md +358 -0
- package/docs/validation/DOCKER_OPENROUTER_VALIDATION.md +443 -0
- package/docs/validation/FINAL_SYSTEM_VALIDATION.md +458 -0
- package/docs/validation/FINAL_VALIDATION_SUMMARY.md +409 -0
- package/docs/validation/MCP_CLI_TOOLS_VALIDATION.md +266 -0
- package/docs/validation/MODEL_VALIDATION_REPORT.md +386 -0
- package/docs/validation/OPENROUTER_VALIDATION_COMPLETE.md +382 -0
- package/docs/validation/README.md +20 -0
- package/docs/validation/ROUTER_VALIDATION.md +311 -0
- package/package.json +140 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Generic agent that uses .claude/agents definitions
|
|
2
|
+
import { query } from "@anthropic-ai/claude-agent-sdk";
|
|
3
|
+
import { logger } from "../utils/logger.js";
|
|
4
|
+
import { withRetry } from "../utils/retry.js";
|
|
5
|
+
import { claudeFlowSdkServer } from "../mcp/claudeFlowSdkServer.js";
|
|
6
|
+
export async function claudeAgent(agent, input, onStream, modelOverride) {
|
|
7
|
+
const startTime = Date.now();
|
|
8
|
+
logger.info('Starting Claude agent', {
|
|
9
|
+
agent: agent.name,
|
|
10
|
+
input: input.substring(0, 100),
|
|
11
|
+
model: modelOverride || 'default'
|
|
12
|
+
});
|
|
13
|
+
return withRetry(async () => {
|
|
14
|
+
// Quad MCP server setup: in-SDK + claude-flow + flow-nexus + agentic-payments
|
|
15
|
+
const result = query({
|
|
16
|
+
prompt: input,
|
|
17
|
+
options: {
|
|
18
|
+
systemPrompt: agent.systemPrompt,
|
|
19
|
+
model: modelOverride, // Support custom models like OpenRouter
|
|
20
|
+
permissionMode: 'bypassPermissions', // Auto-approve all tool usage for Docker automation
|
|
21
|
+
mcpServers: {
|
|
22
|
+
// In-SDK server: 6 basic tools (memory + swarm)
|
|
23
|
+
'claude-flow-sdk': claudeFlowSdkServer,
|
|
24
|
+
// Full MCP server: 101 tools via subprocess (neural, analysis, workflow, github, daa, system)
|
|
25
|
+
'claude-flow': {
|
|
26
|
+
command: 'npx',
|
|
27
|
+
args: ['claude-flow@alpha', 'mcp', 'start'],
|
|
28
|
+
env: {
|
|
29
|
+
...process.env,
|
|
30
|
+
MCP_AUTO_START: 'true'
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
// Flow Nexus MCP server: 96 cloud tools (sandboxes, swarms, neural, workflows)
|
|
34
|
+
'flow-nexus': {
|
|
35
|
+
command: 'npx',
|
|
36
|
+
args: ['flow-nexus@latest', 'mcp', 'start'],
|
|
37
|
+
env: {
|
|
38
|
+
...process.env,
|
|
39
|
+
FLOW_NEXUS_AUTO_START: 'true'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
// Agentic Payments MCP server: Payment authorization and multi-agent consensus
|
|
43
|
+
'agentic-payments': {
|
|
44
|
+
command: 'npx',
|
|
45
|
+
args: ['-y', 'agentic-payments', 'mcp'],
|
|
46
|
+
env: {
|
|
47
|
+
...process.env,
|
|
48
|
+
AGENTIC_PAYMENTS_AUTO_START: 'true'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// allowedTools: removed to enable ALL tools from all servers
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
let output = '';
|
|
56
|
+
for await (const msg of result) {
|
|
57
|
+
if (msg.type === 'assistant') {
|
|
58
|
+
const chunk = msg.message.content?.map((c) => c.type === 'text' ? c.text : '').join('') || '';
|
|
59
|
+
output += chunk;
|
|
60
|
+
if (onStream && chunk) {
|
|
61
|
+
onStream(chunk);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const duration = Date.now() - startTime;
|
|
66
|
+
logger.info('Claude agent completed', {
|
|
67
|
+
agent: agent.name,
|
|
68
|
+
duration,
|
|
69
|
+
outputLength: output.length
|
|
70
|
+
});
|
|
71
|
+
return { output, agent: agent.name };
|
|
72
|
+
});
|
|
73
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Agent with Claude Flow memory and coordination capabilities
|
|
2
|
+
import { query } from '@anthropic-ai/claude-agent-sdk';
|
|
3
|
+
import { logger } from '../utils/logger.js';
|
|
4
|
+
import { withRetry } from '../utils/retry.js';
|
|
5
|
+
import { toolConfig } from '../config/tools.js';
|
|
6
|
+
import { getMemoryConfig, getSwarmConfig } from '../config/claudeFlow.js';
|
|
7
|
+
/**
|
|
8
|
+
* Execute agent with Claude Flow memory and coordination
|
|
9
|
+
*/
|
|
10
|
+
export async function claudeFlowAgent(agentName, systemPrompt, input, options = {}) {
|
|
11
|
+
const { enableMemory = true, enableCoordination = false, memoryNamespace, swarmTopology = 'mesh', onStream } = options;
|
|
12
|
+
const startTime = Date.now();
|
|
13
|
+
logger.info('Starting Claude Flow agent', {
|
|
14
|
+
agentName,
|
|
15
|
+
input: input.substring(0, 100),
|
|
16
|
+
enableMemory,
|
|
17
|
+
enableCoordination
|
|
18
|
+
});
|
|
19
|
+
// Prepare memory context if enabled
|
|
20
|
+
let memoryContext = '';
|
|
21
|
+
if (enableMemory) {
|
|
22
|
+
const memoryConfig = getMemoryConfig(memoryNamespace || agentName);
|
|
23
|
+
memoryContext = `
|
|
24
|
+
|
|
25
|
+
You have access to persistent memory via claude-flow tools:
|
|
26
|
+
- Store: mcp__claude-flow__memory_usage with action="store", namespace="${memoryConfig.namespace}"
|
|
27
|
+
- Retrieve: mcp__claude-flow__memory_usage with action="retrieve", namespace="${memoryConfig.namespace}"
|
|
28
|
+
- Search: mcp__claude-flow__memory_search with pattern="search query"
|
|
29
|
+
|
|
30
|
+
Use memory to persist important information across conversations.`;
|
|
31
|
+
}
|
|
32
|
+
// Prepare coordination context if enabled
|
|
33
|
+
let coordinationContext = '';
|
|
34
|
+
if (enableCoordination) {
|
|
35
|
+
const swarmConfig = getSwarmConfig(swarmTopology);
|
|
36
|
+
coordinationContext = `
|
|
37
|
+
|
|
38
|
+
You have access to swarm coordination via claude-flow tools:
|
|
39
|
+
- Init swarm: mcp__claude-flow__swarm_init with topology="${swarmConfig.topology}"
|
|
40
|
+
- Spawn agent: mcp__claude-flow__agent_spawn with type="researcher|coder|analyst"
|
|
41
|
+
- Orchestrate: mcp__claude-flow__task_orchestrate with task="description"
|
|
42
|
+
- Check status: mcp__claude-flow__swarm_status
|
|
43
|
+
|
|
44
|
+
Use coordination for complex multi-agent tasks.`;
|
|
45
|
+
}
|
|
46
|
+
const enhancedSystemPrompt = `${systemPrompt}${memoryContext}${coordinationContext}`;
|
|
47
|
+
return withRetry(async () => {
|
|
48
|
+
const result = query({
|
|
49
|
+
prompt: input,
|
|
50
|
+
options: {
|
|
51
|
+
systemPrompt: enhancedSystemPrompt,
|
|
52
|
+
...toolConfig
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
let output = '';
|
|
56
|
+
for await (const msg of result) {
|
|
57
|
+
if (msg.type === 'assistant') {
|
|
58
|
+
const chunk = msg.message.content
|
|
59
|
+
?.map((c) => (c.type === 'text' ? c.text : ''))
|
|
60
|
+
.join('') || '';
|
|
61
|
+
output += chunk;
|
|
62
|
+
if (onStream && chunk) {
|
|
63
|
+
onStream(chunk);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const duration = Date.now() - startTime;
|
|
68
|
+
logger.info('Claude Flow agent completed', {
|
|
69
|
+
agentName,
|
|
70
|
+
duration,
|
|
71
|
+
outputLength: output.length,
|
|
72
|
+
memoryUsed: enableMemory,
|
|
73
|
+
coordinationUsed: enableCoordination
|
|
74
|
+
});
|
|
75
|
+
return { output };
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Example: Memory-enabled research agent
|
|
80
|
+
*/
|
|
81
|
+
export async function memoryResearchAgent(topic, onStream) {
|
|
82
|
+
return claudeFlowAgent('memory-researcher', `You are a research agent with persistent memory.
|
|
83
|
+
|
|
84
|
+
Research the given topic thoroughly and store key findings in memory for future reference.
|
|
85
|
+
Use memory_usage tool to store important facts, insights, and references.`, `Research topic: ${topic}`, {
|
|
86
|
+
enableMemory: true,
|
|
87
|
+
enableCoordination: false,
|
|
88
|
+
onStream
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Example: Coordination-enabled orchestrator agent
|
|
93
|
+
*/
|
|
94
|
+
export async function orchestratorAgent(task, onStream) {
|
|
95
|
+
return claudeFlowAgent('orchestrator', `You are an orchestration agent that coordinates multiple specialized agents.
|
|
96
|
+
|
|
97
|
+
Break down complex tasks and delegate to specialized agents using swarm coordination.
|
|
98
|
+
Use swarm_init, agent_spawn, and task_orchestrate tools to manage the workflow.`, `Orchestrate task: ${task}`, {
|
|
99
|
+
enableMemory: true,
|
|
100
|
+
enableCoordination: true,
|
|
101
|
+
swarmTopology: 'hierarchical',
|
|
102
|
+
onStream
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Example: Full-featured agent with memory and coordination
|
|
107
|
+
*/
|
|
108
|
+
export async function hybridAgent(task, agentName = 'hybrid', systemPrompt = 'You are a versatile agent with memory and coordination capabilities.', onStream) {
|
|
109
|
+
return claudeFlowAgent(agentName, systemPrompt, task, {
|
|
110
|
+
enableMemory: true,
|
|
111
|
+
enableCoordination: true,
|
|
112
|
+
swarmTopology: 'mesh',
|
|
113
|
+
onStream
|
|
114
|
+
});
|
|
115
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/agents/codeReviewAgent.ts
|
|
2
|
+
import { query } from "@anthropic-ai/claude-agent-sdk";
|
|
3
|
+
import { logger } from "../utils/logger.js";
|
|
4
|
+
import { withRetry } from "../utils/retry.js";
|
|
5
|
+
import { toolConfig } from "../config/tools.js";
|
|
6
|
+
export async function codeReviewAgent(input, onStream) {
|
|
7
|
+
const startTime = Date.now();
|
|
8
|
+
logger.info('Starting code review agent', { input: input.substring(0, 100) });
|
|
9
|
+
return withRetry(async () => {
|
|
10
|
+
const result = query({
|
|
11
|
+
prompt: input,
|
|
12
|
+
options: {
|
|
13
|
+
systemPrompt: `You review diffs and point out risks, complexity, and tests to add.`,
|
|
14
|
+
...toolConfig
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
let output = '';
|
|
18
|
+
for await (const msg of result) {
|
|
19
|
+
if (msg.type === 'assistant') {
|
|
20
|
+
const chunk = msg.message.content?.map((c) => c.type === 'text' ? c.text : '').join('') || '';
|
|
21
|
+
output += chunk;
|
|
22
|
+
if (onStream && chunk) {
|
|
23
|
+
onStream(chunk);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const duration = Date.now() - startTime;
|
|
28
|
+
logger.info('Code review agent completed', {
|
|
29
|
+
duration,
|
|
30
|
+
outputLength: output.length
|
|
31
|
+
});
|
|
32
|
+
return { output };
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/agents/dataAgent.ts
|
|
2
|
+
import { query } from "@anthropic-ai/claude-agent-sdk";
|
|
3
|
+
import { logger } from "../utils/logger.js";
|
|
4
|
+
import { withRetry } from "../utils/retry.js";
|
|
5
|
+
import { toolConfig } from "../config/tools.js";
|
|
6
|
+
export async function dataAgent(input, onStream) {
|
|
7
|
+
const startTime = Date.now();
|
|
8
|
+
logger.info('Starting data agent', { input: input.substring(0, 100) });
|
|
9
|
+
return withRetry(async () => {
|
|
10
|
+
const result = query({
|
|
11
|
+
prompt: input,
|
|
12
|
+
options: {
|
|
13
|
+
systemPrompt: `You analyze tabular data and produce a short brief with 3 key stats and 1 risk.`,
|
|
14
|
+
...toolConfig
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
let output = '';
|
|
18
|
+
for await (const msg of result) {
|
|
19
|
+
if (msg.type === 'assistant') {
|
|
20
|
+
const chunk = msg.message.content?.map((c) => c.type === 'text' ? c.text : '').join('') || '';
|
|
21
|
+
output += chunk;
|
|
22
|
+
if (onStream && chunk) {
|
|
23
|
+
onStream(chunk);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const duration = Date.now() - startTime;
|
|
28
|
+
logger.info('Data agent completed', {
|
|
29
|
+
duration,
|
|
30
|
+
outputLength: output.length
|
|
31
|
+
});
|
|
32
|
+
return { output };
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// Direct Anthropic API agent with in-process tool execution (no subprocess)
|
|
2
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
3
|
+
import { logger } from '../utils/logger.js';
|
|
4
|
+
import { withRetry } from '../utils/retry.js';
|
|
5
|
+
import { execSync } from 'child_process';
|
|
6
|
+
const anthropic = new Anthropic({
|
|
7
|
+
apiKey: process.env.ANTHROPIC_API_KEY
|
|
8
|
+
});
|
|
9
|
+
// Define claude-flow tools as native Anthropic tool definitions
|
|
10
|
+
const claudeFlowTools = [
|
|
11
|
+
{
|
|
12
|
+
name: 'memory_store',
|
|
13
|
+
description: 'Store a value in persistent memory with optional namespace and TTL',
|
|
14
|
+
input_schema: {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
key: { type: 'string', description: 'Memory key' },
|
|
18
|
+
value: { type: 'string', description: 'Value to store' },
|
|
19
|
+
namespace: { type: 'string', description: 'Memory namespace', default: 'default' },
|
|
20
|
+
ttl: { type: 'number', description: 'Time-to-live in seconds' }
|
|
21
|
+
},
|
|
22
|
+
required: ['key', 'value']
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'memory_retrieve',
|
|
27
|
+
description: 'Retrieve a value from persistent memory',
|
|
28
|
+
input_schema: {
|
|
29
|
+
type: 'object',
|
|
30
|
+
properties: {
|
|
31
|
+
key: { type: 'string', description: 'Memory key' },
|
|
32
|
+
namespace: { type: 'string', description: 'Memory namespace', default: 'default' }
|
|
33
|
+
},
|
|
34
|
+
required: ['key']
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'memory_search',
|
|
39
|
+
description: 'Search for keys matching a pattern in memory',
|
|
40
|
+
input_schema: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties: {
|
|
43
|
+
pattern: { type: 'string', description: 'Search pattern (supports wildcards)' },
|
|
44
|
+
namespace: { type: 'string', description: 'Memory namespace to search in' },
|
|
45
|
+
limit: { type: 'number', description: 'Maximum results to return', default: 10 }
|
|
46
|
+
},
|
|
47
|
+
required: ['pattern']
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'swarm_init',
|
|
52
|
+
description: 'Initialize a multi-agent swarm with specified topology',
|
|
53
|
+
input_schema: {
|
|
54
|
+
type: 'object',
|
|
55
|
+
properties: {
|
|
56
|
+
topology: { type: 'string', enum: ['mesh', 'hierarchical', 'ring', 'star'], description: 'Swarm topology' },
|
|
57
|
+
maxAgents: { type: 'number', description: 'Maximum number of agents', default: 8 },
|
|
58
|
+
strategy: { type: 'string', enum: ['balanced', 'specialized', 'adaptive'], description: 'Agent distribution strategy', default: 'balanced' }
|
|
59
|
+
},
|
|
60
|
+
required: ['topology']
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'agent_spawn',
|
|
65
|
+
description: 'Spawn a new agent in the swarm',
|
|
66
|
+
input_schema: {
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties: {
|
|
69
|
+
type: { type: 'string', enum: ['researcher', 'coder', 'analyst', 'optimizer', 'coordinator'], description: 'Agent type' },
|
|
70
|
+
capabilities: { type: 'array', items: { type: 'string' }, description: 'Agent capabilities' },
|
|
71
|
+
name: { type: 'string', description: 'Custom agent name' }
|
|
72
|
+
},
|
|
73
|
+
required: ['type']
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'task_orchestrate',
|
|
78
|
+
description: 'Orchestrate a complex task across the swarm',
|
|
79
|
+
input_schema: {
|
|
80
|
+
type: 'object',
|
|
81
|
+
properties: {
|
|
82
|
+
task: { type: 'string', description: 'Task description or instructions' },
|
|
83
|
+
strategy: { type: 'string', enum: ['parallel', 'sequential', 'adaptive'], description: 'Execution strategy', default: 'adaptive' },
|
|
84
|
+
priority: { type: 'string', enum: ['low', 'medium', 'high', 'critical'], description: 'Task priority', default: 'medium' },
|
|
85
|
+
maxAgents: { type: 'number', description: 'Maximum agents to use for this task' }
|
|
86
|
+
},
|
|
87
|
+
required: ['task']
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'swarm_status',
|
|
92
|
+
description: 'Get current swarm status and metrics',
|
|
93
|
+
input_schema: {
|
|
94
|
+
type: 'object',
|
|
95
|
+
properties: {
|
|
96
|
+
verbose: { type: 'boolean', description: 'Include detailed metrics', default: false }
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
// Execute tool calls using claude-flow CLI
|
|
102
|
+
async function executeToolCall(toolName, toolInput) {
|
|
103
|
+
try {
|
|
104
|
+
logger.info('Executing tool', { toolName, input: toolInput });
|
|
105
|
+
switch (toolName) {
|
|
106
|
+
case 'memory_store': {
|
|
107
|
+
const { key, value, namespace = 'default', ttl } = toolInput;
|
|
108
|
+
const cmd = `npx claude-flow@alpha memory store "${key}" "${value}" --namespace "${namespace}"${ttl ? ` --ttl ${ttl}` : ''}`;
|
|
109
|
+
const result = execSync(cmd, { encoding: 'utf-8', maxBuffer: 10 * 1024 * 1024 });
|
|
110
|
+
logger.info('Memory stored', { key, namespace });
|
|
111
|
+
return `✅ Stored successfully\n📝 Key: ${key}\n📦 Namespace: ${namespace}\n💾 Size: ${value.length} bytes`;
|
|
112
|
+
}
|
|
113
|
+
case 'memory_retrieve': {
|
|
114
|
+
const { key, namespace = 'default' } = toolInput;
|
|
115
|
+
const cmd = `npx claude-flow@alpha memory retrieve "${key}" --namespace "${namespace}"`;
|
|
116
|
+
const result = execSync(cmd, { encoding: 'utf-8' });
|
|
117
|
+
logger.info('Memory retrieved', { key });
|
|
118
|
+
return `✅ Retrieved:\n${result}`;
|
|
119
|
+
}
|
|
120
|
+
case 'memory_search': {
|
|
121
|
+
const { pattern, namespace, limit = 10 } = toolInput;
|
|
122
|
+
const cmd = `npx claude-flow@alpha memory search "${pattern}"${namespace ? ` --namespace "${namespace}"` : ''} --limit ${limit}`;
|
|
123
|
+
const result = execSync(cmd, { encoding: 'utf-8' });
|
|
124
|
+
return `🔍 Search results:\n${result}`;
|
|
125
|
+
}
|
|
126
|
+
case 'swarm_init': {
|
|
127
|
+
const { topology, maxAgents = 8, strategy = 'balanced' } = toolInput;
|
|
128
|
+
const cmd = `npx claude-flow@alpha swarm init --topology ${topology} --max-agents ${maxAgents} --strategy ${strategy}`;
|
|
129
|
+
const result = execSync(cmd, { encoding: 'utf-8' });
|
|
130
|
+
return `🚀 Swarm initialized:\n${result}`;
|
|
131
|
+
}
|
|
132
|
+
case 'agent_spawn': {
|
|
133
|
+
const { type, capabilities, name } = toolInput;
|
|
134
|
+
const capStr = capabilities ? ` --capabilities "${capabilities.join(',')}"` : '';
|
|
135
|
+
const nameStr = name ? ` --name "${name}"` : '';
|
|
136
|
+
const cmd = `npx claude-flow@alpha agent spawn --type ${type}${capStr}${nameStr}`;
|
|
137
|
+
const result = execSync(cmd, { encoding: 'utf-8' });
|
|
138
|
+
return `🤖 Agent spawned:\n${result}`;
|
|
139
|
+
}
|
|
140
|
+
case 'task_orchestrate': {
|
|
141
|
+
const { task, strategy = 'adaptive', priority = 'medium', maxAgents } = toolInput;
|
|
142
|
+
const maxStr = maxAgents ? ` --max-agents ${maxAgents}` : '';
|
|
143
|
+
const cmd = `npx claude-flow@alpha task orchestrate "${task}" --strategy ${strategy} --priority ${priority}${maxStr}`;
|
|
144
|
+
const result = execSync(cmd, { encoding: 'utf-8' });
|
|
145
|
+
return `⚡ Task orchestrated:\n${result}`;
|
|
146
|
+
}
|
|
147
|
+
case 'swarm_status': {
|
|
148
|
+
const { verbose = false } = toolInput;
|
|
149
|
+
const cmd = `npx claude-flow@alpha swarm status${verbose ? ' --verbose' : ''}`;
|
|
150
|
+
const result = execSync(cmd, { encoding: 'utf-8' });
|
|
151
|
+
return `📊 Swarm status:\n${result}`;
|
|
152
|
+
}
|
|
153
|
+
default:
|
|
154
|
+
throw new Error(`Unknown tool: ${toolName}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
logger.error('Tool execution failed', { toolName, error: error.message });
|
|
159
|
+
return `❌ Tool execution failed: ${error.message}`;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Direct API agent using Anthropic SDK with native tool calling
|
|
164
|
+
* Bypasses Claude Agent SDK subprocess issues entirely
|
|
165
|
+
*/
|
|
166
|
+
export async function directApiAgent(agent, input, onStream) {
|
|
167
|
+
const startTime = Date.now();
|
|
168
|
+
logger.info('Starting direct API agent', {
|
|
169
|
+
agent: agent.name,
|
|
170
|
+
input: input.substring(0, 100)
|
|
171
|
+
});
|
|
172
|
+
return withRetry(async () => {
|
|
173
|
+
const messages = [
|
|
174
|
+
{ role: 'user', content: input }
|
|
175
|
+
];
|
|
176
|
+
let finalOutput = '';
|
|
177
|
+
let toolUseCount = 0;
|
|
178
|
+
const maxToolUses = 10; // Prevent infinite loops
|
|
179
|
+
// Agentic loop: keep calling API until no more tool uses
|
|
180
|
+
while (toolUseCount < maxToolUses) {
|
|
181
|
+
logger.debug('API call iteration', { toolUseCount, messagesLength: messages.length });
|
|
182
|
+
const response = await anthropic.messages.create({
|
|
183
|
+
model: 'claude-sonnet-4-5-20250929',
|
|
184
|
+
max_tokens: 8192,
|
|
185
|
+
system: agent.systemPrompt || 'You are a helpful AI assistant.',
|
|
186
|
+
messages,
|
|
187
|
+
tools: claudeFlowTools
|
|
188
|
+
});
|
|
189
|
+
logger.debug('API response', {
|
|
190
|
+
stopReason: response.stop_reason,
|
|
191
|
+
contentBlocks: response.content.length
|
|
192
|
+
});
|
|
193
|
+
// Process response content
|
|
194
|
+
const toolResults = [];
|
|
195
|
+
for (const block of response.content) {
|
|
196
|
+
if (block.type === 'text') {
|
|
197
|
+
finalOutput += block.text;
|
|
198
|
+
if (onStream) {
|
|
199
|
+
onStream(block.text);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else if (block.type === 'tool_use') {
|
|
203
|
+
toolUseCount++;
|
|
204
|
+
logger.info('Tool use requested', {
|
|
205
|
+
toolName: block.name,
|
|
206
|
+
toolUseId: block.id
|
|
207
|
+
});
|
|
208
|
+
// Execute the tool
|
|
209
|
+
const toolResult = await executeToolCall(block.name, block.input);
|
|
210
|
+
// Collect tool result
|
|
211
|
+
toolResults.push({
|
|
212
|
+
type: 'tool_result',
|
|
213
|
+
tool_use_id: block.id,
|
|
214
|
+
content: toolResult
|
|
215
|
+
});
|
|
216
|
+
logger.debug('Tool result collected', {
|
|
217
|
+
toolUseId: block.id,
|
|
218
|
+
resultLength: toolResult.length
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// If there were tool uses, add assistant message and all tool results
|
|
223
|
+
if (toolResults.length > 0) {
|
|
224
|
+
// Add assistant message with tool uses
|
|
225
|
+
messages.push({
|
|
226
|
+
role: 'assistant',
|
|
227
|
+
content: response.content
|
|
228
|
+
});
|
|
229
|
+
// Add all tool results in one user message
|
|
230
|
+
messages.push({
|
|
231
|
+
role: 'user',
|
|
232
|
+
content: toolResults
|
|
233
|
+
});
|
|
234
|
+
logger.debug('Tool results added to conversation', {
|
|
235
|
+
count: toolResults.length
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
// Stop if no tool use or end_turn
|
|
239
|
+
if (response.stop_reason === 'end_turn' || response.content.every(b => b.type === 'text')) {
|
|
240
|
+
// Add final assistant message if it has text
|
|
241
|
+
const textContent = response.content.filter(b => b.type === 'text');
|
|
242
|
+
if (textContent.length > 0 && messages[messages.length - 1].role !== 'assistant') {
|
|
243
|
+
messages.push({
|
|
244
|
+
role: 'assistant',
|
|
245
|
+
content: response.content
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const duration = Date.now() - startTime;
|
|
252
|
+
logger.info('Direct API agent completed', {
|
|
253
|
+
agent: agent.name,
|
|
254
|
+
duration,
|
|
255
|
+
toolUseCount,
|
|
256
|
+
outputLength: finalOutput.length
|
|
257
|
+
});
|
|
258
|
+
return { output: finalOutput, agent: agent.name };
|
|
259
|
+
});
|
|
260
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/agents/webResearchAgent.ts
|
|
2
|
+
import { query } from "@anthropic-ai/claude-agent-sdk";
|
|
3
|
+
import { logger } from "../utils/logger.js";
|
|
4
|
+
import { withRetry } from "../utils/retry.js";
|
|
5
|
+
import { toolConfig } from "../config/tools.js";
|
|
6
|
+
export async function webResearchAgent(input, onStream) {
|
|
7
|
+
const startTime = Date.now();
|
|
8
|
+
logger.info('Starting web research agent', { input: input.substring(0, 100) });
|
|
9
|
+
return withRetry(async () => {
|
|
10
|
+
const result = query({
|
|
11
|
+
prompt: input,
|
|
12
|
+
options: {
|
|
13
|
+
systemPrompt: `You perform fast web-style reconnaissance and return a concise bullet list of findings.`,
|
|
14
|
+
...toolConfig
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
let output = '';
|
|
18
|
+
for await (const msg of result) {
|
|
19
|
+
if (msg.type === 'assistant') {
|
|
20
|
+
const chunk = msg.message.content?.map((c) => c.type === 'text' ? c.text : '').join('') || '';
|
|
21
|
+
output += chunk;
|
|
22
|
+
// Stream chunks in real-time
|
|
23
|
+
if (onStream && chunk) {
|
|
24
|
+
onStream(chunk);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const duration = Date.now() - startTime;
|
|
29
|
+
logger.info('Web research agent completed', {
|
|
30
|
+
duration,
|
|
31
|
+
outputLength: output.length
|
|
32
|
+
});
|
|
33
|
+
return { output };
|
|
34
|
+
});
|
|
35
|
+
}
|