@claude-flow/cli 3.10.36 → 3.10.37
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/analysis/analyze-code-quality.md +178 -178
- package/.claude/agents/analysis/code-analyzer.md +209 -209
- package/.claude/agents/analysis/code-review/analyze-code-quality.md +178 -178
- package/.claude/agents/architecture/arch-system-design.md +156 -156
- package/.claude/agents/architecture/system-design/arch-system-design.md +154 -154
- package/.claude/agents/browser/browser-agent.yaml +182 -182
- package/.claude/agents/consensus/byzantine-coordinator.md +62 -62
- package/.claude/agents/consensus/crdt-synchronizer.md +996 -996
- package/.claude/agents/consensus/gossip-coordinator.md +62 -62
- package/.claude/agents/consensus/performance-benchmarker.md +850 -850
- package/.claude/agents/consensus/quorum-manager.md +822 -822
- package/.claude/agents/consensus/raft-manager.md +62 -62
- package/.claude/agents/consensus/security-manager.md +621 -621
- package/.claude/agents/core/planner.md +374 -374
- package/.claude/agents/custom/test-long-runner.md +44 -44
- package/.claude/agents/data/data-ml-model.md +444 -444
- package/.claude/agents/data/ml/data-ml-model.md +192 -192
- package/.claude/agents/development/backend/dev-backend-api.md +141 -141
- package/.claude/agents/development/dev-backend-api.md +344 -344
- package/.claude/agents/devops/ci-cd/ops-cicd-github.md +163 -163
- package/.claude/agents/devops/ops-cicd-github.md +164 -164
- package/.claude/agents/documentation/api-docs/docs-api-openapi.md +173 -173
- package/.claude/agents/documentation/docs-api-openapi.md +354 -354
- package/.claude/agents/flow-nexus/app-store.md +87 -87
- package/.claude/agents/flow-nexus/authentication.md +68 -68
- package/.claude/agents/flow-nexus/challenges.md +80 -80
- package/.claude/agents/flow-nexus/neural-network.md +87 -87
- package/.claude/agents/flow-nexus/payments.md +82 -82
- package/.claude/agents/flow-nexus/sandbox.md +75 -75
- package/.claude/agents/flow-nexus/swarm.md +75 -75
- package/.claude/agents/flow-nexus/user-tools.md +95 -95
- package/.claude/agents/flow-nexus/workflow.md +83 -83
- package/.claude/agents/github/code-review-swarm.md +377 -377
- package/.claude/agents/github/github-modes.md +172 -172
- package/.claude/agents/github/issue-tracker.md +575 -575
- package/.claude/agents/github/multi-repo-swarm.md +552 -552
- package/.claude/agents/github/pr-manager.md +437 -437
- package/.claude/agents/github/project-board-sync.md +508 -508
- package/.claude/agents/github/release-manager.md +604 -604
- package/.claude/agents/github/release-swarm.md +582 -582
- package/.claude/agents/github/repo-architect.md +397 -397
- package/.claude/agents/github/swarm-issue.md +572 -572
- package/.claude/agents/github/swarm-pr.md +427 -427
- package/.claude/agents/github/sync-coordinator.md +451 -451
- package/.claude/agents/github/workflow-automation.md +902 -902
- package/.claude/agents/goal/agent.md +815 -815
- package/.claude/agents/optimization/benchmark-suite.md +664 -664
- package/.claude/agents/optimization/load-balancer.md +430 -430
- package/.claude/agents/optimization/performance-monitor.md +671 -671
- package/.claude/agents/optimization/resource-allocator.md +673 -673
- package/.claude/agents/optimization/topology-optimizer.md +807 -807
- package/.claude/agents/payments/agentic-payments.md +126 -126
- package/.claude/agents/sona/sona-learning-optimizer.md +74 -74
- package/.claude/agents/sparc/architecture.md +698 -698
- package/.claude/agents/sparc/pseudocode.md +519 -519
- package/.claude/agents/sparc/refinement.md +801 -801
- package/.claude/agents/sparc/specification.md +477 -477
- package/.claude/agents/specialized/mobile/spec-mobile-react-native.md +224 -224
- package/.claude/agents/specialized/spec-mobile-react-native.md +226 -226
- package/.claude/agents/sublinear/consensus-coordinator.md +337 -337
- package/.claude/agents/sublinear/matrix-optimizer.md +184 -184
- package/.claude/agents/sublinear/pagerank-analyzer.md +298 -298
- package/.claude/agents/sublinear/performance-optimizer.md +367 -367
- package/.claude/agents/sublinear/trading-predictor.md +245 -245
- package/.claude/agents/swarm/adaptive-coordinator.md +1126 -1126
- package/.claude/agents/swarm/hierarchical-coordinator.md +709 -709
- package/.claude/agents/swarm/mesh-coordinator.md +962 -962
- package/.claude/agents/templates/automation-smart-agent.md +204 -204
- package/.claude/agents/templates/base-template-generator.md +289 -289
- package/.claude/agents/templates/coordinator-swarm-init.md +89 -89
- package/.claude/agents/templates/github-pr-manager.md +176 -176
- package/.claude/agents/templates/implementer-sparc-coder.md +258 -258
- package/.claude/agents/templates/memory-coordinator.md +186 -186
- package/.claude/agents/templates/orchestrator-task.md +138 -138
- package/.claude/agents/templates/performance-analyzer.md +198 -198
- package/.claude/agents/templates/sparc-coordinator.md +513 -513
- package/.claude/agents/testing/production-validator.md +394 -394
- package/.claude/agents/testing/tdd-london-swarm.md +243 -243
- package/.claude/agents/v3/aidefence-guardian.md +282 -282
- package/.claude/agents/v3/claims-authorizer.md +208 -208
- package/.claude/agents/v3/collective-intelligence-coordinator.md +993 -993
- package/.claude/agents/v3/ddd-domain-expert.md +220 -220
- package/.claude/agents/v3/injection-analyst.md +236 -236
- package/.claude/agents/v3/performance-engineer.md +1233 -1233
- package/.claude/agents/v3/pii-detector.md +151 -151
- package/.claude/agents/v3/reasoningbank-learner.md +213 -213
- package/.claude/agents/v3/security-architect-aidefence.md +410 -410
- package/.claude/agents/v3/security-architect.md +867 -867
- package/.claude/agents/v3/swarm-memory-manager.md +157 -157
- package/.claude/agents/v3/v3-integration-architect.md +205 -205
- package/.claude/commands/agents/README.md +50 -50
- package/.claude/commands/agents/agent-capabilities.md +140 -140
- package/.claude/commands/agents/agent-coordination.md +28 -28
- package/.claude/commands/agents/agent-spawning.md +28 -28
- package/.claude/commands/agents/agent-types.md +216 -216
- package/.claude/commands/agents/health.md +139 -139
- package/.claude/commands/agents/list.md +100 -100
- package/.claude/commands/agents/logs.md +130 -130
- package/.claude/commands/agents/metrics.md +122 -122
- package/.claude/commands/agents/pool.md +127 -127
- package/.claude/commands/agents/spawn.md +140 -140
- package/.claude/commands/agents/status.md +115 -115
- package/.claude/commands/agents/stop.md +102 -102
- package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +53 -53
- package/.claude/commands/analysis/README.md +9 -9
- package/.claude/commands/analysis/bottleneck-detect.md +162 -162
- package/.claude/commands/analysis/performance-bottlenecks.md +58 -58
- package/.claude/commands/analysis/performance-report.md +25 -25
- package/.claude/commands/analysis/token-efficiency.md +44 -44
- package/.claude/commands/analysis/token-usage.md +25 -25
- package/.claude/commands/automation/README.md +9 -9
- package/.claude/commands/automation/auto-agent.md +122 -122
- package/.claude/commands/automation/self-healing.md +105 -105
- package/.claude/commands/automation/session-memory.md +89 -89
- package/.claude/commands/automation/smart-agents.md +72 -72
- package/.claude/commands/automation/smart-spawn.md +25 -25
- package/.claude/commands/automation/workflow-select.md +25 -25
- package/.claude/commands/claude-flow-help.md +103 -103
- package/.claude/commands/claude-flow-memory.md +107 -107
- package/.claude/commands/claude-flow-swarm.md +205 -205
- package/.claude/commands/coordination/README.md +9 -9
- package/.claude/commands/coordination/agent-spawn.md +25 -25
- package/.claude/commands/coordination/init.md +44 -44
- package/.claude/commands/coordination/orchestrate.md +43 -43
- package/.claude/commands/coordination/spawn.md +45 -45
- package/.claude/commands/coordination/swarm-init.md +85 -85
- package/.claude/commands/coordination/task-orchestrate.md +25 -25
- package/.claude/commands/github/README.md +11 -11
- package/.claude/commands/github/code-review-swarm.md +513 -513
- package/.claude/commands/github/code-review.md +25 -25
- package/.claude/commands/github/github-modes.md +146 -146
- package/.claude/commands/github/github-swarm.md +121 -121
- package/.claude/commands/github/issue-tracker.md +291 -291
- package/.claude/commands/github/issue-triage.md +25 -25
- package/.claude/commands/github/multi-repo-swarm.md +518 -518
- package/.claude/commands/github/pr-enhance.md +26 -26
- package/.claude/commands/github/pr-manager.md +169 -169
- package/.claude/commands/github/project-board-sync.md +470 -470
- package/.claude/commands/github/release-manager.md +339 -339
- package/.claude/commands/github/release-swarm.md +543 -543
- package/.claude/commands/github/repo-analyze.md +25 -25
- package/.claude/commands/github/repo-architect.md +366 -366
- package/.claude/commands/github/swarm-issue.md +484 -484
- package/.claude/commands/github/swarm-pr.md +287 -287
- package/.claude/commands/github/sync-coordinator.md +302 -302
- package/.claude/commands/github/workflow-automation.md +441 -441
- package/.claude/commands/hive-mind/README.md +17 -17
- package/.claude/commands/hive-mind/hive-mind-consensus.md +8 -8
- package/.claude/commands/hive-mind/hive-mind-init.md +18 -18
- package/.claude/commands/hive-mind/hive-mind-memory.md +8 -8
- package/.claude/commands/hive-mind/hive-mind-metrics.md +8 -8
- package/.claude/commands/hive-mind/hive-mind-resume.md +8 -8
- package/.claude/commands/hive-mind/hive-mind-sessions.md +8 -8
- package/.claude/commands/hive-mind/hive-mind-spawn.md +21 -21
- package/.claude/commands/hive-mind/hive-mind-status.md +8 -8
- package/.claude/commands/hive-mind/hive-mind-stop.md +8 -8
- package/.claude/commands/hive-mind/hive-mind-wizard.md +8 -8
- package/.claude/commands/hive-mind/hive-mind.md +27 -27
- package/.claude/commands/hooks/README.md +11 -11
- package/.claude/commands/hooks/overview.md +57 -57
- package/.claude/commands/hooks/post-edit.md +117 -117
- package/.claude/commands/hooks/post-task.md +112 -112
- package/.claude/commands/hooks/pre-edit.md +113 -113
- package/.claude/commands/hooks/pre-task.md +111 -111
- package/.claude/commands/hooks/session-end.md +118 -118
- package/.claude/commands/hooks/setup.md +102 -102
- package/.claude/commands/memory/README.md +9 -9
- package/.claude/commands/memory/memory-persist.md +25 -25
- package/.claude/commands/memory/memory-search.md +25 -25
- package/.claude/commands/memory/memory-usage.md +25 -25
- package/.claude/commands/memory/neural.md +47 -47
- package/.claude/commands/monitoring/README.md +9 -9
- package/.claude/commands/monitoring/agent-metrics.md +25 -25
- package/.claude/commands/monitoring/agents.md +44 -44
- package/.claude/commands/monitoring/real-time-view.md +25 -25
- package/.claude/commands/monitoring/status.md +46 -46
- package/.claude/commands/monitoring/swarm-monitor.md +25 -25
- package/.claude/commands/optimization/README.md +9 -9
- package/.claude/commands/optimization/auto-topology.md +61 -61
- package/.claude/commands/optimization/cache-manage.md +25 -25
- package/.claude/commands/optimization/parallel-execute.md +25 -25
- package/.claude/commands/optimization/parallel-execution.md +49 -49
- package/.claude/commands/optimization/topology-optimize.md +25 -25
- package/.claude/commands/pair/README.md +260 -260
- package/.claude/commands/pair/commands.md +545 -545
- package/.claude/commands/pair/config.md +509 -509
- package/.claude/commands/pair/examples.md +511 -511
- package/.claude/commands/pair/modes.md +347 -347
- package/.claude/commands/pair/session.md +406 -406
- package/.claude/commands/pair/start.md +208 -208
- package/.claude/commands/sparc/analyzer.md +51 -51
- package/.claude/commands/sparc/architect.md +53 -53
- package/.claude/commands/sparc/ask.md +97 -97
- package/.claude/commands/sparc/batch-executor.md +54 -54
- package/.claude/commands/sparc/code.md +89 -89
- package/.claude/commands/sparc/coder.md +54 -54
- package/.claude/commands/sparc/debug.md +83 -83
- package/.claude/commands/sparc/debugger.md +54 -54
- package/.claude/commands/sparc/designer.md +53 -53
- package/.claude/commands/sparc/devops.md +109 -109
- package/.claude/commands/sparc/docs-writer.md +80 -80
- package/.claude/commands/sparc/documenter.md +54 -54
- package/.claude/commands/sparc/innovator.md +54 -54
- package/.claude/commands/sparc/integration.md +83 -83
- package/.claude/commands/sparc/mcp.md +117 -117
- package/.claude/commands/sparc/memory-manager.md +54 -54
- package/.claude/commands/sparc/optimizer.md +54 -54
- package/.claude/commands/sparc/orchestrator.md +131 -131
- package/.claude/commands/sparc/post-deployment-monitoring-mode.md +83 -83
- package/.claude/commands/sparc/refinement-optimization-mode.md +83 -83
- package/.claude/commands/sparc/researcher.md +54 -54
- package/.claude/commands/sparc/reviewer.md +54 -54
- package/.claude/commands/sparc/security-review.md +80 -80
- package/.claude/commands/sparc/sparc-modes.md +174 -174
- package/.claude/commands/sparc/sparc.md +111 -111
- package/.claude/commands/sparc/spec-pseudocode.md +80 -80
- package/.claude/commands/sparc/supabase-admin.md +348 -348
- package/.claude/commands/sparc/swarm-coordinator.md +54 -54
- package/.claude/commands/sparc/tdd.md +54 -54
- package/.claude/commands/sparc/tester.md +54 -54
- package/.claude/commands/sparc/tutorial.md +79 -79
- package/.claude/commands/sparc/workflow-manager.md +54 -54
- package/.claude/commands/sparc.md +166 -166
- package/.claude/commands/stream-chain/pipeline.md +120 -120
- package/.claude/commands/stream-chain/run.md +69 -69
- package/.claude/commands/swarm/README.md +15 -15
- package/.claude/commands/swarm/analysis.md +95 -95
- package/.claude/commands/swarm/development.md +96 -96
- package/.claude/commands/swarm/examples.md +168 -168
- package/.claude/commands/swarm/maintenance.md +102 -102
- package/.claude/commands/swarm/optimization.md +117 -117
- package/.claude/commands/swarm/research.md +136 -136
- package/.claude/commands/swarm/swarm-analysis.md +8 -8
- package/.claude/commands/swarm/swarm-background.md +8 -8
- package/.claude/commands/swarm/swarm-init.md +19 -19
- package/.claude/commands/swarm/swarm-modes.md +8 -8
- package/.claude/commands/swarm/swarm-monitor.md +8 -8
- package/.claude/commands/swarm/swarm-spawn.md +19 -19
- package/.claude/commands/swarm/swarm-status.md +8 -8
- package/.claude/commands/swarm/swarm-strategies.md +8 -8
- package/.claude/commands/swarm/swarm.md +87 -87
- package/.claude/commands/swarm/testing.md +131 -131
- package/.claude/commands/training/README.md +9 -9
- package/.claude/commands/training/model-update.md +25 -25
- package/.claude/commands/training/neural-patterns.md +107 -107
- package/.claude/commands/training/neural-train.md +75 -75
- package/.claude/commands/training/pattern-learn.md +25 -25
- package/.claude/commands/training/specialization.md +62 -62
- package/.claude/commands/truth/start.md +142 -142
- package/.claude/commands/verify/check.md +49 -49
- package/.claude/commands/verify/start.md +127 -127
- package/.claude/commands/workflows/README.md +9 -9
- package/.claude/commands/workflows/development.md +77 -77
- package/.claude/commands/workflows/research.md +62 -62
- package/.claude/commands/workflows/workflow-create.md +25 -25
- package/.claude/commands/workflows/workflow-execute.md +25 -25
- package/.claude/commands/workflows/workflow-export.md +25 -25
- package/.claude/helpers/README.md +96 -96
- package/.claude/helpers/adr-compliance.sh +186 -186
- package/.claude/helpers/auto-commit.sh +178 -178
- package/.claude/helpers/auto-memory-hook.mjs +368 -368
- package/.claude/helpers/checkpoint-manager.sh +251 -251
- package/.claude/helpers/daemon-manager.sh +252 -252
- package/.claude/helpers/ddd-tracker.sh +144 -144
- package/.claude/helpers/github-safe.js +156 -156
- package/.claude/helpers/github-setup.sh +45 -45
- package/.claude/helpers/guidance-hook.sh +13 -13
- package/.claude/helpers/guidance-hooks.sh +102 -102
- package/.claude/helpers/health-monitor.sh +108 -108
- package/.claude/helpers/hook-handler.cjs +286 -286
- package/.claude/helpers/intelligence.cjs +1031 -1031
- package/.claude/helpers/learning-hooks.sh +329 -329
- package/.claude/helpers/learning-optimizer.sh +127 -127
- package/.claude/helpers/learning-service.mjs +1144 -1144
- package/.claude/helpers/memory.js +83 -83
- package/.claude/helpers/metrics-db.mjs +488 -488
- package/.claude/helpers/pattern-consolidator.sh +86 -86
- package/.claude/helpers/perf-worker.sh +160 -160
- package/.claude/helpers/post-commit +16 -16
- package/.claude/helpers/pre-commit +26 -26
- package/.claude/helpers/quick-start.sh +19 -19
- package/.claude/helpers/router.js +105 -105
- package/.claude/helpers/security-scanner.sh +127 -127
- package/.claude/helpers/session.js +135 -135
- package/.claude/helpers/setup-mcp.sh +18 -18
- package/.claude/helpers/standard-checkpoint-hooks.sh +189 -189
- package/.claude/helpers/statusline-hook.sh +21 -21
- package/.claude/helpers/statusline.cjs +604 -604
- package/.claude/helpers/statusline.js +352 -352
- package/.claude/helpers/swarm-comms.sh +353 -353
- package/.claude/helpers/swarm-hooks.sh +761 -761
- package/.claude/helpers/swarm-monitor.sh +210 -210
- package/.claude/helpers/sync-v3-metrics.sh +245 -245
- package/.claude/helpers/update-v3-progress.sh +165 -165
- package/.claude/helpers/v3-quick-status.sh +57 -57
- package/.claude/helpers/v3.sh +110 -110
- package/.claude/helpers/validate-v3-config.sh +215 -215
- package/.claude/helpers/worker-manager.sh +170 -170
- package/.claude/settings.json +182 -182
- package/.claude/skills/agentdb-advanced/SKILL.md +550 -550
- package/.claude/skills/agentdb-learning/SKILL.md +545 -545
- package/.claude/skills/agentdb-memory-patterns/SKILL.md +339 -339
- package/.claude/skills/agentdb-optimization/SKILL.md +509 -509
- package/.claude/skills/agentdb-vector-search/SKILL.md +339 -339
- package/.claude/skills/browser/SKILL.md +204 -204
- package/.claude/skills/dual-mode/README.md +71 -71
- package/.claude/skills/dual-mode/dual-collect.md +103 -103
- package/.claude/skills/dual-mode/dual-coordinate.md +85 -85
- package/.claude/skills/dual-mode/dual-spawn.md +81 -81
- package/.claude/skills/flow-nexus-neural/SKILL.md +727 -727
- package/.claude/skills/flow-nexus-platform/SKILL.md +1154 -1154
- package/.claude/skills/flow-nexus-swarm/SKILL.md +604 -604
- package/.claude/skills/github-code-review/SKILL.md +1125 -1125
- package/.claude/skills/github-multi-repo/SKILL.md +862 -862
- package/.claude/skills/github-project-management/SKILL.md +1262 -1262
- package/.claude/skills/github-release-management/SKILL.md +1064 -1064
- package/.claude/skills/github-workflow-automation/SKILL.md +1047 -1047
- package/.claude/skills/hooks-automation/SKILL.md +1201 -1201
- package/.claude/skills/pair-programming/SKILL.md +1202 -1202
- package/.claude/skills/reasoningbank-agentdb/SKILL.md +446 -446
- package/.claude/skills/reasoningbank-intelligence/SKILL.md +201 -201
- package/.claude/skills/skill-builder/SKILL.md +910 -910
- package/.claude/skills/sparc-methodology/SKILL.md +1106 -1106
- package/.claude/skills/stream-chain/SKILL.md +560 -560
- package/.claude/skills/swarm-advanced/SKILL.md +970 -970
- package/.claude/skills/swarm-orchestration/SKILL.md +179 -179
- package/.claude/skills/v3-cli-modernization/SKILL.md +871 -871
- package/.claude/skills/v3-core-implementation/SKILL.md +796 -796
- package/.claude/skills/v3-ddd-architecture/SKILL.md +441 -441
- package/.claude/skills/v3-integration-deep/SKILL.md +240 -240
- package/.claude/skills/v3-mcp-optimization/SKILL.md +776 -776
- package/.claude/skills/v3-memory-unification/SKILL.md +173 -173
- package/.claude/skills/v3-performance-optimization/SKILL.md +389 -389
- package/.claude/skills/v3-security-overhaul/SKILL.md +81 -81
- package/.claude/skills/v3-swarm-coordination/SKILL.md +339 -339
- package/.claude/skills/verification-quality/SKILL.md +691 -691
- package/README.md +416 -416
- package/bin/cli.js +314 -314
- package/bin/mcp-server.js +224 -224
- package/bin/preinstall.cjs +2 -2
- package/dist/src/benchmarks/gaia-critic.js +24 -24
- package/dist/src/commands/completions.js +409 -409
- package/dist/src/commands/daemon.js +44 -44
- package/dist/src/commands/embeddings.js +29 -29
- package/dist/src/commands/embeddings.js.map +1 -1
- package/dist/src/commands/hive-mind.js +97 -97
- package/dist/src/commands/hooks.js +9 -9
- package/dist/src/commands/ruvector/backup.js +23 -23
- package/dist/src/commands/ruvector/benchmark.js +31 -31
- package/dist/src/commands/ruvector/import.js +14 -14
- package/dist/src/commands/ruvector/init.js +115 -115
- package/dist/src/commands/ruvector/migrate.js +99 -99
- package/dist/src/commands/ruvector/optimize.js +51 -51
- package/dist/src/commands/ruvector/setup.js +624 -624
- package/dist/src/commands/ruvector/status.js +38 -38
- package/dist/src/init/claudemd-generator.js +227 -227
- package/dist/src/init/executor.js +453 -453
- package/dist/src/init/helpers-generator.js +727 -727
- package/dist/src/init/statusline-generator.js +570 -570
- package/dist/src/mcp-tools/agentdb-tools.js +15 -15
- package/dist/src/memory/graph-edge-writer.js +18 -18
- package/dist/src/memory/memory-bridge.js +84 -84
- package/dist/src/memory/memory-initializer.js +393 -393
- package/dist/src/memory/rabitq-index.js +5 -5
- package/dist/src/runtime/headless.js +28 -28
- package/dist/src/ruvector/flash-attention.d.ts +195 -0
- package/dist/src/ruvector/flash-attention.d.ts.map +1 -0
- package/dist/src/ruvector/flash-attention.js +643 -0
- package/dist/src/ruvector/flash-attention.js.map +1 -0
- package/dist/src/ruvector/moe-router.d.ts +206 -0
- package/dist/src/ruvector/moe-router.d.ts.map +1 -0
- package/dist/src/ruvector/moe-router.js +626 -0
- package/dist/src/ruvector/moe-router.js.map +1 -0
- package/dist/src/services/event-stream.d.ts +25 -0
- package/dist/src/services/event-stream.js +27 -0
- package/dist/src/services/headless-worker-executor.js +84 -84
- package/dist/src/services/loop-worker-runner.d.ts +16 -0
- package/dist/src/services/loop-worker-runner.js +34 -0
- package/dist/src/services/runtime-capabilities.d.ts +22 -0
- package/dist/src/services/runtime-capabilities.js +45 -0
- package/dist/src/transfer/deploy-seraphine.js +23 -23
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +134 -134
- package/scripts/beir-bootstrap-significance.mjs +162 -162
- package/scripts/bench-rvagent.mjs +312 -312
- package/scripts/benchmark-codemods.mjs +127 -127
- package/scripts/benchmark-cross-repo.mjs +206 -206
- package/scripts/benchmark-pretrained-retrieval.mjs +305 -305
- package/scripts/benchmark-self-learning.mjs +241 -241
- package/scripts/benchmark-trajectory-mrr.mjs +191 -191
- package/scripts/deploy-ipfs-node.sh +153 -153
- package/scripts/grid-search-retrieval.mjs +216 -216
- package/scripts/postinstall.cjs +153 -153
- package/scripts/pretrain-from-github.mjs +358 -358
- package/scripts/publish-registry.ts +345 -345
- package/scripts/publish.sh +57 -57
- package/scripts/run-beir-bge.mjs +324 -336
- package/scripts/run-beir-hybrid.mjs +261 -263
- package/scripts/run-beir-lucene-bm25.mjs +154 -154
- package/scripts/run-beir-nfcorpus.mjs +231 -231
- package/scripts/run-beir-rrf-ablation.mjs +221 -221
- package/scripts/setup-ipfs-registry.md +366 -366
- package/dist/src/benchmarks/capability-tasks.d.ts +0 -126
- package/dist/src/benchmarks/capability-tasks.d.ts.map +0 -1
- package/dist/src/benchmarks/capability-tasks.js +0 -147
- package/dist/src/benchmarks/capability-tasks.js.map +0 -1
- package/dist/src/benchmarks/gaia-agent-contrastive.d.ts +0 -53
- package/dist/src/benchmarks/gaia-agent-contrastive.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-agent-contrastive.js +0 -177
- package/dist/src/benchmarks/gaia-agent-contrastive.js.map +0 -1
- package/dist/src/benchmarks/gaia-agent-gemini.d.ts +0 -51
- package/dist/src/benchmarks/gaia-agent-gemini.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-agent-gemini.js +0 -352
- package/dist/src/benchmarks/gaia-agent-gemini.js.map +0 -1
- package/dist/src/benchmarks/gaia-claude-p.d.ts +0 -105
- package/dist/src/benchmarks/gaia-claude-p.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-claude-p.js +0 -269
- package/dist/src/benchmarks/gaia-claude-p.js.map +0 -1
- package/dist/src/benchmarks/gaia-claude-p.smoke.d.ts +0 -20
- package/dist/src/benchmarks/gaia-claude-p.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-claude-p.smoke.js +0 -168
- package/dist/src/benchmarks/gaia-claude-p.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-codeagent-runner.py +0 -556
- package/dist/src/benchmarks/gaia-codeagent.d.ts +0 -129
- package/dist/src/benchmarks/gaia-codeagent.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-codeagent.js +0 -590
- package/dist/src/benchmarks/gaia-codeagent.js.map +0 -1
- package/dist/src/benchmarks/gaia-codeagent.smoke.d.ts +0 -33
- package/dist/src/benchmarks/gaia-codeagent.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-codeagent.smoke.js +0 -241
- package/dist/src/benchmarks/gaia-codeagent.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-dag-pilot.d.ts +0 -22
- package/dist/src/benchmarks/gaia-dag-pilot.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-dag-pilot.js +0 -158
- package/dist/src/benchmarks/gaia-dag-pilot.js.map +0 -1
- package/dist/src/benchmarks/gaia-dag.d.ts +0 -110
- package/dist/src/benchmarks/gaia-dag.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-dag.js +0 -658
- package/dist/src/benchmarks/gaia-dag.js.map +0 -1
- package/dist/src/benchmarks/gaia-dag.smoke.d.ts +0 -21
- package/dist/src/benchmarks/gaia-dag.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-dag.smoke.js +0 -290
- package/dist/src/benchmarks/gaia-dag.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-ensemble-pilot.d.ts +0 -17
- package/dist/src/benchmarks/gaia-ensemble-pilot.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-ensemble-pilot.js +0 -106
- package/dist/src/benchmarks/gaia-ensemble-pilot.js.map +0 -1
- package/dist/src/benchmarks/gaia-ensemble.d.ts +0 -103
- package/dist/src/benchmarks/gaia-ensemble.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-ensemble.js +0 -462
- package/dist/src/benchmarks/gaia-ensemble.js.map +0 -1
- package/dist/src/benchmarks/gaia-gemini-pilot.d.ts +0 -17
- package/dist/src/benchmarks/gaia-gemini-pilot.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-gemini-pilot.js +0 -168
- package/dist/src/benchmarks/gaia-gemini-pilot.js.map +0 -1
- package/dist/src/benchmarks/gaia-mode-router.d.ts +0 -67
- package/dist/src/benchmarks/gaia-mode-router.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-mode-router.js +0 -126
- package/dist/src/benchmarks/gaia-mode-router.js.map +0 -1
- package/dist/src/benchmarks/gaia-mode-router.smoke.d.ts +0 -15
- package/dist/src/benchmarks/gaia-mode-router.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-mode-router.smoke.js +0 -131
- package/dist/src/benchmarks/gaia-mode-router.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/grounded_query.smoke.d.ts +0 -24
- package/dist/src/benchmarks/gaia-tools/grounded_query.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/grounded_query.smoke.js +0 -276
- package/dist/src/benchmarks/gaia-tools/grounded_query.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/image_describe.d.ts +0 -45
- package/dist/src/benchmarks/gaia-tools/image_describe.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/image_describe.js +0 -222
- package/dist/src/benchmarks/gaia-tools/image_describe.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/image_describe.smoke.d.ts +0 -24
- package/dist/src/benchmarks/gaia-tools/image_describe.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/image_describe.smoke.js +0 -169
- package/dist/src/benchmarks/gaia-tools/image_describe.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/pdf_read.d.ts +0 -27
- package/dist/src/benchmarks/gaia-tools/pdf_read.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/pdf_read.js +0 -226
- package/dist/src/benchmarks/gaia-tools/pdf_read.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/python_exec.d.ts +0 -31
- package/dist/src/benchmarks/gaia-tools/python_exec.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/python_exec.js +0 -94
- package/dist/src/benchmarks/gaia-tools/python_exec.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/python_exec.smoke.d.ts +0 -13
- package/dist/src/benchmarks/gaia-tools/python_exec.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/python_exec.smoke.js +0 -98
- package/dist/src/benchmarks/gaia-tools/python_exec.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/visit_webpage.d.ts +0 -52
- package/dist/src/benchmarks/gaia-tools/visit_webpage.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/visit_webpage.js +0 -304
- package/dist/src/benchmarks/gaia-tools/visit_webpage.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/web_browse.d.ts +0 -61
- package/dist/src/benchmarks/gaia-tools/web_browse.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/web_browse.js +0 -217
- package/dist/src/benchmarks/gaia-tools/web_browse.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/web_browse.smoke.d.ts +0 -26
- package/dist/src/benchmarks/gaia-tools/web_browse.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/web_browse.smoke.js +0 -152
- package/dist/src/benchmarks/gaia-tools/web_browse.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-tools/web_search.smoke.d.ts +0 -24
- package/dist/src/benchmarks/gaia-tools/web_search.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-tools/web_search.smoke.js +0 -311
- package/dist/src/benchmarks/gaia-tools/web_search.smoke.js.map +0 -1
- package/dist/src/benchmarks/gaia-visit-webpage.smoke.d.ts +0 -25
- package/dist/src/benchmarks/gaia-visit-webpage.smoke.d.ts.map +0 -1
- package/dist/src/benchmarks/gaia-visit-webpage.smoke.js +0 -304
- package/dist/src/benchmarks/gaia-visit-webpage.smoke.js.map +0 -1
- package/dist/src/commands/performance-capability.d.ts +0 -30
- package/dist/src/commands/performance-capability.d.ts.map +0 -1
- package/dist/src/commands/performance-capability.js +0 -349
- package/dist/src/commands/performance-capability.js.map +0 -1
|
@@ -1,658 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GAIA DAG Harness — Co-Sight Architecture Port (ADR-139 Addendum)
|
|
3
|
-
*
|
|
4
|
-
* Ports the ZTE-AICloud/Co-Sight DAG orchestration pattern (Apache 2.0,
|
|
5
|
-
* arXiv 2510.21557) into the ruflo GAIA harness.
|
|
6
|
-
*
|
|
7
|
-
* Architecture:
|
|
8
|
-
* 1. PLAN — Claude Sonnet 4.6 reads the question and emits a DAG of 3-7
|
|
9
|
-
* steps: {id, description, depends_on: [], suggested_tool}.
|
|
10
|
-
* Claude-aware prompt: "3-5 steps max, direct answer when clear."
|
|
11
|
-
* 2. EXECUTE — Loop while ready steps exist (deps satisfied).
|
|
12
|
-
* Run all ready steps in PARALLEL (Promise.all, cap ≤5).
|
|
13
|
-
* Each step = a Gemini 2.5 Pro actor with the full tool suite.
|
|
14
|
-
* Actor marks step completed/blocked + writes step_notes.
|
|
15
|
-
* Blocked steps trigger planner re_plan before next cycle.
|
|
16
|
-
* 3. FINALIZE — Planner reads all step_notes → produces final answer
|
|
17
|
-
* using T2 extraction cascade from gaia-agent.ts.
|
|
18
|
-
* 4. CAMV — Async credibility labeling per step (stubbed, iter 65).
|
|
19
|
-
*
|
|
20
|
-
* Role assignment (env-configurable):
|
|
21
|
-
* PLAN_MODEL = claude-sonnet-4-6 (default)
|
|
22
|
-
* ACT_MODEL = gemini-2.5-pro (default)
|
|
23
|
-
* VISION_MODEL = gemini-2.5-pro (default, same as act)
|
|
24
|
-
*
|
|
25
|
-
* CLI:
|
|
26
|
-
* gaia-bench run --mode=dag --model claude-sonnet-4-6
|
|
27
|
-
*
|
|
28
|
-
* Cost: planner ~$0.02/Q + actors ~$0.03/Q = ~$0.05/Q (vs single-Sonnet ~$0.075)
|
|
29
|
-
*
|
|
30
|
-
* Refs: ADR-139, github.com/ZTE-AICloud/Co-Sight, arXiv 2510.21557, #2156
|
|
31
|
-
*/
|
|
32
|
-
import { execSync } from 'node:child_process';
|
|
33
|
-
import { createDefaultToolCatalogue, } from './gaia-tools/index.js';
|
|
34
|
-
import { normaliseAnswer } from './gaia-judge.js';
|
|
35
|
-
import { resolveAnthropicApiKey } from './gaia-agent.js';
|
|
36
|
-
// ---------------------------------------------------------------------------
|
|
37
|
-
// Constants
|
|
38
|
-
// ---------------------------------------------------------------------------
|
|
39
|
-
const ANTHROPIC_API_URL = 'https://api.anthropic.com/v1/messages';
|
|
40
|
-
const ANTHROPIC_API_VERSION = '2023-06-01';
|
|
41
|
-
const GEMINI_API_BASE = 'https://generativelanguage.googleapis.com/v1beta/models';
|
|
42
|
-
const DEFAULT_PLAN_MODEL = process.env['PLAN_MODEL'] ?? 'claude-sonnet-4-6';
|
|
43
|
-
const DEFAULT_ACT_MODEL = process.env['ACT_MODEL'] ?? 'gemini-2.5-pro';
|
|
44
|
-
const MAX_PLAN_STEPS = 7;
|
|
45
|
-
const MIN_PLAN_STEPS = 1;
|
|
46
|
-
const MAX_CONCURRENT_ACTORS = 5;
|
|
47
|
-
const MAX_ACTOR_TURNS = 8;
|
|
48
|
-
const MAX_REPLAN_CYCLES = 3;
|
|
49
|
-
const ACTOR_TIMEOUT_MS = 90_000;
|
|
50
|
-
const PLANNER_TIMEOUT_MS = 60_000;
|
|
51
|
-
const FINAL_ANSWER_RE = /FINAL_ANSWER:\s*(.+)/i;
|
|
52
|
-
// ---------------------------------------------------------------------------
|
|
53
|
-
// API key resolution
|
|
54
|
-
// ---------------------------------------------------------------------------
|
|
55
|
-
function resolveGeminiApiKey(supplied) {
|
|
56
|
-
if (supplied?.trim())
|
|
57
|
-
return supplied.trim();
|
|
58
|
-
const env = process.env['GOOGLE_AI_API_KEY'] ?? process.env['GEMINI_API_KEY'];
|
|
59
|
-
if (env?.trim())
|
|
60
|
-
return env.trim();
|
|
61
|
-
for (const secret of ['GOOGLE_AI_API_KEY', 'GEMINI_API_KEY']) {
|
|
62
|
-
try {
|
|
63
|
-
const out = execSync(`gcloud secrets versions access latest --secret=${secret} 2>/dev/null`, { encoding: 'utf-8', timeout: 10_000 }).trim();
|
|
64
|
-
if (out)
|
|
65
|
-
return out;
|
|
66
|
-
}
|
|
67
|
-
catch { /* fall through */ }
|
|
68
|
-
}
|
|
69
|
-
throw new Error('GOOGLE_AI_API_KEY / GEMINI_API_KEY not found in env or GCP Secret Manager.');
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Get all steps whose dependencies are fully satisfied (completed).
|
|
73
|
-
* Mirrors Co-Sight's Plan.get_ready_steps().
|
|
74
|
-
*/
|
|
75
|
-
export function getReadySteps(plan) {
|
|
76
|
-
return plan.steps.filter((step) => {
|
|
77
|
-
if (step.status !== 'not_started')
|
|
78
|
-
return false;
|
|
79
|
-
return step.depends_on.every((depId) => {
|
|
80
|
-
const dep = plan.steps.find((s) => s.id === depId);
|
|
81
|
-
return dep?.status === 'completed';
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
// ---------------------------------------------------------------------------
|
|
86
|
-
// Planner system prompt (Claude-aware, ported from planner_prompt.py)
|
|
87
|
-
// ---------------------------------------------------------------------------
|
|
88
|
-
function buildPlannerSystemPrompt() {
|
|
89
|
-
return [
|
|
90
|
-
'# Role and Objective',
|
|
91
|
-
'You are a planning assistant for a question-answering system. Your task is to create',
|
|
92
|
-
'a small, focused plan as a Directed Acyclic Graph (DAG) to answer the given question.',
|
|
93
|
-
'',
|
|
94
|
-
'# Plan Creation Rules (Claude model — simplified)',
|
|
95
|
-
'1. When the answer is clear and direct, create a SINGLE step: just answer the question.',
|
|
96
|
-
'2. Otherwise, create 3-5 high-level steps (NEVER more than 7).',
|
|
97
|
-
'3. Each step must be a concrete, actionable description.',
|
|
98
|
-
'4. Specify dependencies ONLY when a step genuinely requires output from a prior step.',
|
|
99
|
-
'5. Steps without dependencies run in parallel — prefer parallelism.',
|
|
100
|
-
'',
|
|
101
|
-
'# Output Format (JSON ONLY, no markdown fences)',
|
|
102
|
-
'{',
|
|
103
|
-
' "title": "brief plan title",',
|
|
104
|
-
' "steps": [',
|
|
105
|
-
' { "id": 0, "description": "step description", "depends_on": [], "suggested_tool": "web_search" },',
|
|
106
|
-
' { "id": 1, "description": "step description", "depends_on": [0], "suggested_tool": "python_exec" }',
|
|
107
|
-
' ]',
|
|
108
|
-
'}',
|
|
109
|
-
'',
|
|
110
|
-
'# Suggested Tools: web_search, grounded_query, file_read, python_exec',
|
|
111
|
-
'# Rules:',
|
|
112
|
-
'- ids must be sequential integers starting from 0',
|
|
113
|
-
'- depends_on contains only valid step ids from the same plan',
|
|
114
|
-
'- NO markdown, NO explanation — output ONLY the JSON object',
|
|
115
|
-
].join('\n');
|
|
116
|
-
}
|
|
117
|
-
function buildReplannerSystemPrompt() {
|
|
118
|
-
return [
|
|
119
|
-
'# Role and Objective',
|
|
120
|
-
'You are a planning assistant. Some steps in the current plan are BLOCKED.',
|
|
121
|
-
'Your task is to update the plan to work around the blocked steps.',
|
|
122
|
-
'',
|
|
123
|
-
'# Replan Rules',
|
|
124
|
-
'1. Preserve ALL completed steps — do not modify them.',
|
|
125
|
-
'2. For blocked steps: either try an alternative approach or skip if non-critical.',
|
|
126
|
-
'3. If the plan has enough information to answer already, output FINAL_ANSWER: <answer>',
|
|
127
|
-
'4. Keep the total step count ≤ 7.',
|
|
128
|
-
'',
|
|
129
|
-
'# Output',
|
|
130
|
-
'Either:',
|
|
131
|
-
' FINAL_ANSWER: <the answer>',
|
|
132
|
-
'Or updated JSON plan (same format as plan creation, include all steps with their current status):',
|
|
133
|
-
'{',
|
|
134
|
-
' "title": "...",',
|
|
135
|
-
' "steps": [...]',
|
|
136
|
-
'}',
|
|
137
|
-
].join('\n');
|
|
138
|
-
}
|
|
139
|
-
function buildFinalizerSystemPrompt() {
|
|
140
|
-
return [
|
|
141
|
-
'You are a precise question-answering agent finalizing a multi-step research task.',
|
|
142
|
-
'You have all the gathered evidence in step notes. Produce the final answer.',
|
|
143
|
-
'',
|
|
144
|
-
'RULES:',
|
|
145
|
-
'1. Synthesize ONLY from the provided step notes — do not invent facts.',
|
|
146
|
-
'2. Keep answers concise: just the value, name, or number unless context demands more.',
|
|
147
|
-
'3. Do NOT include units unless the question asks for them.',
|
|
148
|
-
'4. You MUST end with: FINAL_ANSWER: <your answer>',
|
|
149
|
-
'5. NEVER end without a FINAL_ANSWER line.',
|
|
150
|
-
].join('\n');
|
|
151
|
-
}
|
|
152
|
-
async function callAnthropic(apiKey, model, systemPrompt, messages, maxTokens, timeoutMs) {
|
|
153
|
-
const controller = new AbortController();
|
|
154
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
155
|
-
let res;
|
|
156
|
-
try {
|
|
157
|
-
res = await fetch(ANTHROPIC_API_URL, {
|
|
158
|
-
method: 'POST',
|
|
159
|
-
headers: {
|
|
160
|
-
'x-api-key': apiKey,
|
|
161
|
-
'anthropic-version': ANTHROPIC_API_VERSION,
|
|
162
|
-
'content-type': 'application/json',
|
|
163
|
-
},
|
|
164
|
-
body: JSON.stringify({ model, max_tokens: maxTokens, system: systemPrompt, messages }),
|
|
165
|
-
signal: controller.signal,
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
finally {
|
|
169
|
-
clearTimeout(timer);
|
|
170
|
-
}
|
|
171
|
-
if (!res.ok) {
|
|
172
|
-
const errText = await res.text().catch(() => '<unreadable>');
|
|
173
|
-
throw new Error(`Anthropic API error ${res.status}: ${errText.slice(0, 400)}`);
|
|
174
|
-
}
|
|
175
|
-
return (await res.json());
|
|
176
|
-
}
|
|
177
|
-
async function callGemini(apiKey, model, systemInstruction, contents, tools, maxTokens, timeoutMs) {
|
|
178
|
-
const url = `${GEMINI_API_BASE}/${model}:generateContent?key=${apiKey}`;
|
|
179
|
-
const controller = new AbortController();
|
|
180
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
181
|
-
let res;
|
|
182
|
-
try {
|
|
183
|
-
res = await fetch(url, {
|
|
184
|
-
method: 'POST',
|
|
185
|
-
headers: { 'content-type': 'application/json' },
|
|
186
|
-
body: JSON.stringify({
|
|
187
|
-
system_instruction: { parts: [{ text: systemInstruction }] },
|
|
188
|
-
contents,
|
|
189
|
-
tools: tools.length > 0 ? [{ function_declarations: tools }] : undefined,
|
|
190
|
-
generationConfig: { maxOutputTokens: maxTokens, temperature: 0 },
|
|
191
|
-
}),
|
|
192
|
-
signal: controller.signal,
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
finally {
|
|
196
|
-
clearTimeout(timer);
|
|
197
|
-
}
|
|
198
|
-
if (!res.ok) {
|
|
199
|
-
const errText = await res.text().catch(() => '<unreadable>');
|
|
200
|
-
throw new Error(`Gemini API error ${res.status}: ${errText.slice(0, 400)}`);
|
|
201
|
-
}
|
|
202
|
-
return (await res.json());
|
|
203
|
-
}
|
|
204
|
-
// ---------------------------------------------------------------------------
|
|
205
|
-
// Parse planner JSON output (robust)
|
|
206
|
-
// ---------------------------------------------------------------------------
|
|
207
|
-
function parsePlanJson(text) {
|
|
208
|
-
// Strip markdown fences if present
|
|
209
|
-
const cleaned = text.replace(/```(?:json)?\n?/g, '').replace(/```\n?/g, '').trim();
|
|
210
|
-
// Find the first '{' ... last '}'
|
|
211
|
-
const start = cleaned.indexOf('{');
|
|
212
|
-
const end = cleaned.lastIndexOf('}');
|
|
213
|
-
if (start === -1 || end === -1)
|
|
214
|
-
return null;
|
|
215
|
-
try {
|
|
216
|
-
const parsed = JSON.parse(cleaned.slice(start, end + 1));
|
|
217
|
-
if (!Array.isArray(parsed.steps) || parsed.steps.length === 0)
|
|
218
|
-
return null;
|
|
219
|
-
return {
|
|
220
|
-
steps: parsed.steps.map((s, i) => ({
|
|
221
|
-
id: typeof s.id === 'number' ? s.id : i,
|
|
222
|
-
description: String(s.description ?? `Step ${i}`),
|
|
223
|
-
depends_on: Array.isArray(s.depends_on) ? s.depends_on.map(Number) : [],
|
|
224
|
-
suggested_tool: s.suggested_tool,
|
|
225
|
-
})),
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
catch {
|
|
229
|
-
return null;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
// ---------------------------------------------------------------------------
|
|
233
|
-
// PLAN phase
|
|
234
|
-
// ---------------------------------------------------------------------------
|
|
235
|
-
async function createPlan(question, anthropicKey, planModel) {
|
|
236
|
-
const attachmentHint = question.file_path
|
|
237
|
-
? `\nThis question has an attached file at: ${question.file_path}`
|
|
238
|
-
: '';
|
|
239
|
-
const resp = await callAnthropic(anthropicKey, planModel, buildPlannerSystemPrompt(), [{ role: 'user', content: question.question + attachmentHint }], 1024, PLANNER_TIMEOUT_MS);
|
|
240
|
-
const text = resp.content
|
|
241
|
-
.filter((b) => b.type === 'text')
|
|
242
|
-
.map((b) => b.text)
|
|
243
|
-
.join('\n');
|
|
244
|
-
const parsed = parsePlanJson(text);
|
|
245
|
-
let steps;
|
|
246
|
-
if (parsed && parsed.steps.length >= MIN_PLAN_STEPS) {
|
|
247
|
-
// Cap steps
|
|
248
|
-
const rawSteps = parsed.steps.slice(0, MAX_PLAN_STEPS);
|
|
249
|
-
steps = rawSteps.map((s) => ({
|
|
250
|
-
id: s.id,
|
|
251
|
-
description: s.description,
|
|
252
|
-
depends_on: s.depends_on.filter((d) => d < rawSteps.length && d !== s.id),
|
|
253
|
-
suggested_tool: s.suggested_tool,
|
|
254
|
-
status: 'not_started',
|
|
255
|
-
step_notes: '',
|
|
256
|
-
}));
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
// Fallback: single-step plan (treat as direct answer task)
|
|
260
|
-
steps = [{
|
|
261
|
-
id: 0,
|
|
262
|
-
description: `Answer the question directly: ${question.question.slice(0, 100)}`,
|
|
263
|
-
depends_on: [],
|
|
264
|
-
status: 'not_started',
|
|
265
|
-
step_notes: '',
|
|
266
|
-
}];
|
|
267
|
-
}
|
|
268
|
-
return {
|
|
269
|
-
plan: { title: question.task_id, question: question.question, steps },
|
|
270
|
-
inputTokens: resp.usage.input_tokens,
|
|
271
|
-
outputTokens: resp.usage.output_tokens,
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
// ---------------------------------------------------------------------------
|
|
275
|
-
// ACTOR phase — Gemini 2.5 Pro executes a single step
|
|
276
|
-
// ---------------------------------------------------------------------------
|
|
277
|
-
function buildActorSystemPrompt(question, planSummary, stepDesc) {
|
|
278
|
-
return [
|
|
279
|
-
'You are a precise research agent executing one step of a multi-step plan.',
|
|
280
|
-
'',
|
|
281
|
-
`ORIGINAL QUESTION: ${question}`,
|
|
282
|
-
'',
|
|
283
|
-
`CURRENT PLAN STATE:\n${planSummary}`,
|
|
284
|
-
'',
|
|
285
|
-
`YOUR STEP: ${stepDesc}`,
|
|
286
|
-
'',
|
|
287
|
-
'RULES:',
|
|
288
|
-
'1. Use the available tools to gather information for your step.',
|
|
289
|
-
'2. When you have completed your step, output your findings as:',
|
|
290
|
-
' STEP_RESULT: <your findings and evidence>',
|
|
291
|
-
'3. If you cannot complete your step (blocked), output:',
|
|
292
|
-
' STEP_BLOCKED: <reason why blocked>',
|
|
293
|
-
'4. Keep responses focused on completing this specific step.',
|
|
294
|
-
'5. MANDATORY: Always end with either STEP_RESULT or STEP_BLOCKED.',
|
|
295
|
-
].join('\n');
|
|
296
|
-
}
|
|
297
|
-
function buildPlanSummary(plan) {
|
|
298
|
-
return plan.steps.map((s) => {
|
|
299
|
-
const statusIcon = { not_started: '[ ]', in_progress: '[→]', completed: '[✓]', blocked: '[!]' }[s.status];
|
|
300
|
-
const notes = s.step_notes ? ` → ${s.step_notes.slice(0, 200)}` : '';
|
|
301
|
-
return `${statusIcon} Step ${s.id}: ${s.description}${notes}`;
|
|
302
|
-
}).join('\n');
|
|
303
|
-
}
|
|
304
|
-
/** Convert ruflo tool catalogue to Gemini function declarations. */
|
|
305
|
-
function toGeminiFunctionDeclarations(catalogue) {
|
|
306
|
-
return catalogue.map((t) => ({
|
|
307
|
-
name: t.definition.name,
|
|
308
|
-
description: t.definition.description,
|
|
309
|
-
parameters: t.definition.input_schema,
|
|
310
|
-
}));
|
|
311
|
-
}
|
|
312
|
-
async function executeActorStep(question, step, plan, geminiKey, actModel, catalogue) {
|
|
313
|
-
const systemPrompt = buildActorSystemPrompt(question.question, buildPlanSummary(plan), step.description);
|
|
314
|
-
const tools = toGeminiFunctionDeclarations(catalogue);
|
|
315
|
-
let inputTokens = 0;
|
|
316
|
-
let outputTokens = 0;
|
|
317
|
-
const contents = [
|
|
318
|
-
{ role: 'user', parts: [{ text: `Execute your assigned step. Use tools as needed, then output STEP_RESULT or STEP_BLOCKED.` }] },
|
|
319
|
-
];
|
|
320
|
-
// Include attachment hint on first user message
|
|
321
|
-
if (question.file_path) {
|
|
322
|
-
contents[0].parts[0].text +=
|
|
323
|
-
`\nNote: There is an attached file at "${question.file_path}" — call file_read if needed.`;
|
|
324
|
-
}
|
|
325
|
-
const STEP_RESULT_RE = /STEP_RESULT:\s*([\s\S]+)/i;
|
|
326
|
-
const STEP_BLOCKED_RE = /STEP_BLOCKED:\s*(.+)/i;
|
|
327
|
-
for (let turn = 0; turn < MAX_ACTOR_TURNS; turn++) {
|
|
328
|
-
let resp;
|
|
329
|
-
try {
|
|
330
|
-
resp = await callGemini(geminiKey, actModel, systemPrompt, contents, tools, 2048, ACTOR_TIMEOUT_MS);
|
|
331
|
-
}
|
|
332
|
-
catch (err) {
|
|
333
|
-
return {
|
|
334
|
-
notes: `Actor error: ${err instanceof Error ? err.message : String(err)}`,
|
|
335
|
-
status: 'blocked',
|
|
336
|
-
inputTokens,
|
|
337
|
-
outputTokens,
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
inputTokens += resp.usageMetadata?.promptTokenCount ?? 0;
|
|
341
|
-
outputTokens += resp.usageMetadata?.candidatesTokenCount ?? 0;
|
|
342
|
-
const candidate = resp.candidates[0];
|
|
343
|
-
if (!candidate)
|
|
344
|
-
break;
|
|
345
|
-
const parts = candidate.content?.parts ?? [];
|
|
346
|
-
const textParts = parts.filter((p) => p.text).map((p) => p.text);
|
|
347
|
-
const funcCalls = parts.filter((p) => p.functionCall);
|
|
348
|
-
// Check for terminal signals in text
|
|
349
|
-
const fullText = textParts.join('\n');
|
|
350
|
-
const resultMatch = STEP_RESULT_RE.exec(fullText);
|
|
351
|
-
if (resultMatch) {
|
|
352
|
-
return { notes: resultMatch[1].trim().slice(0, 2000), status: 'completed', inputTokens, outputTokens };
|
|
353
|
-
}
|
|
354
|
-
const blockedMatch = STEP_BLOCKED_RE.exec(fullText);
|
|
355
|
-
if (blockedMatch) {
|
|
356
|
-
return { notes: blockedMatch[1].trim(), status: 'blocked', inputTokens, outputTokens };
|
|
357
|
-
}
|
|
358
|
-
// No function calls and finish — treat text as the result
|
|
359
|
-
if (funcCalls.length === 0) {
|
|
360
|
-
const answerText = fullText.trim();
|
|
361
|
-
if (answerText) {
|
|
362
|
-
return { notes: answerText.slice(0, 2000), status: 'completed', inputTokens, outputTokens };
|
|
363
|
-
}
|
|
364
|
-
break;
|
|
365
|
-
}
|
|
366
|
-
// Execute tool calls
|
|
367
|
-
const toolResultParts = [];
|
|
368
|
-
// Append model turn
|
|
369
|
-
contents.push({ role: 'model', parts: parts });
|
|
370
|
-
await Promise.all(funcCalls.map(async (part) => {
|
|
371
|
-
const fc = part.functionCall;
|
|
372
|
-
const tool = catalogue.find((t) => t.name === fc.name);
|
|
373
|
-
let result;
|
|
374
|
-
if (!tool) {
|
|
375
|
-
result = `Unknown tool: "${fc.name}"`;
|
|
376
|
-
}
|
|
377
|
-
else {
|
|
378
|
-
try {
|
|
379
|
-
result = await tool.execute(fc.args);
|
|
380
|
-
}
|
|
381
|
-
catch (err) {
|
|
382
|
-
result = `Tool error: ${err instanceof Error ? err.message : String(err)}`;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
// Truncate large outputs (mirrors Co-Sight MAX_TOOL_CONTENT_LENGTH)
|
|
386
|
-
toolResultParts.push({
|
|
387
|
-
functionResponse: { name: fc.name, response: { content: result.slice(0, 10_000) } },
|
|
388
|
-
});
|
|
389
|
-
}));
|
|
390
|
-
contents.push({ role: 'user', parts: toolResultParts });
|
|
391
|
-
}
|
|
392
|
-
return { notes: 'No result after max turns', status: 'blocked', inputTokens, outputTokens };
|
|
393
|
-
}
|
|
394
|
-
// ---------------------------------------------------------------------------
|
|
395
|
-
// REPLAN phase
|
|
396
|
-
// ---------------------------------------------------------------------------
|
|
397
|
-
async function replan(question, plan, anthropicKey, planModel) {
|
|
398
|
-
const planSummary = buildPlanSummary(plan);
|
|
399
|
-
const prompt = [
|
|
400
|
-
`QUESTION: ${question.question}`,
|
|
401
|
-
'',
|
|
402
|
-
`CURRENT PLAN:\n${planSummary}`,
|
|
403
|
-
'',
|
|
404
|
-
'Some steps are BLOCKED. Update the plan or provide the final answer if enough info is gathered.',
|
|
405
|
-
].join('\n');
|
|
406
|
-
const resp = await callAnthropic(anthropicKey, planModel, buildReplannerSystemPrompt(), [{ role: 'user', content: prompt }], 1024, PLANNER_TIMEOUT_MS);
|
|
407
|
-
const text = resp.content
|
|
408
|
-
.filter((b) => b.type === 'text')
|
|
409
|
-
.map((b) => b.text)
|
|
410
|
-
.join('\n');
|
|
411
|
-
// Check for early final answer
|
|
412
|
-
const faMatch = FINAL_ANSWER_RE.exec(text);
|
|
413
|
-
if (faMatch) {
|
|
414
|
-
return { earlyAnswer: faMatch[1].trim(), updatedSteps: null, inputTokens: resp.usage.input_tokens, outputTokens: resp.usage.output_tokens };
|
|
415
|
-
}
|
|
416
|
-
// Try to parse updated plan
|
|
417
|
-
const parsed = parsePlanJson(text);
|
|
418
|
-
if (parsed) {
|
|
419
|
-
const updatedSteps = parsed.steps.slice(0, MAX_PLAN_STEPS).map((s) => {
|
|
420
|
-
// Preserve completed/blocked status for existing steps
|
|
421
|
-
const existing = plan.steps.find((es) => es.id === s.id);
|
|
422
|
-
if (existing && existing.status !== 'not_started') {
|
|
423
|
-
return existing;
|
|
424
|
-
}
|
|
425
|
-
return {
|
|
426
|
-
id: s.id,
|
|
427
|
-
description: s.description,
|
|
428
|
-
depends_on: s.depends_on.filter((d) => d < parsed.steps.length && d !== s.id),
|
|
429
|
-
suggested_tool: s.suggested_tool,
|
|
430
|
-
status: 'not_started',
|
|
431
|
-
step_notes: '',
|
|
432
|
-
};
|
|
433
|
-
});
|
|
434
|
-
return { earlyAnswer: null, updatedSteps, inputTokens: resp.usage.input_tokens, outputTokens: resp.usage.output_tokens };
|
|
435
|
-
}
|
|
436
|
-
return { earlyAnswer: null, updatedSteps: null, inputTokens: resp.usage.input_tokens, outputTokens: resp.usage.output_tokens };
|
|
437
|
-
}
|
|
438
|
-
// ---------------------------------------------------------------------------
|
|
439
|
-
// FINALIZE phase
|
|
440
|
-
// ---------------------------------------------------------------------------
|
|
441
|
-
async function finalizePlan(question, plan, anthropicKey, planModel) {
|
|
442
|
-
const stepNotes = plan.steps
|
|
443
|
-
.filter((s) => s.step_notes)
|
|
444
|
-
.map((s) => `Step ${s.id} (${s.status}): ${s.description}\nFindings: ${s.step_notes}`)
|
|
445
|
-
.join('\n\n');
|
|
446
|
-
const prompt = [
|
|
447
|
-
`QUESTION: ${question.question}`,
|
|
448
|
-
'',
|
|
449
|
-
stepNotes ? `GATHERED EVIDENCE:\n${stepNotes}` : '(No step findings were gathered.)',
|
|
450
|
-
'',
|
|
451
|
-
'Based on the evidence above, provide the final answer.',
|
|
452
|
-
'End with: FINAL_ANSWER: <your answer>',
|
|
453
|
-
].join('\n');
|
|
454
|
-
const resp = await callAnthropic(anthropicKey, planModel, buildFinalizerSystemPrompt(), [{ role: 'user', content: prompt }], 1024, PLANNER_TIMEOUT_MS);
|
|
455
|
-
const text = resp.content
|
|
456
|
-
.filter((b) => b.type === 'text')
|
|
457
|
-
.map((b) => b.text)
|
|
458
|
-
.join('\n');
|
|
459
|
-
const match = FINAL_ANSWER_RE.exec(text);
|
|
460
|
-
return {
|
|
461
|
-
finalAnswer: match ? match[1].trim() : null,
|
|
462
|
-
inputTokens: resp.usage.input_tokens,
|
|
463
|
-
outputTokens: resp.usage.output_tokens,
|
|
464
|
-
};
|
|
465
|
-
}
|
|
466
|
-
// ---------------------------------------------------------------------------
|
|
467
|
-
// Pricing
|
|
468
|
-
// ---------------------------------------------------------------------------
|
|
469
|
-
function estimateCostUsd(planModel, actModel, planIn, planOut, actIn, actOut) {
|
|
470
|
-
const planPrice = planModel.startsWith('claude-sonnet')
|
|
471
|
-
? { inputPerM: 3.0, outputPerM: 15.0 }
|
|
472
|
-
: { inputPerM: 3.0, outputPerM: 15.0 };
|
|
473
|
-
const actPrice = actModel.startsWith('gemini-2.5-pro')
|
|
474
|
-
? { inputPerM: 1.25, outputPerM: 10.0 }
|
|
475
|
-
: { inputPerM: 1.25, outputPerM: 10.0 };
|
|
476
|
-
return (planIn / 1_000_000) * planPrice.inputPerM +
|
|
477
|
-
(planOut / 1_000_000) * planPrice.outputPerM +
|
|
478
|
-
(actIn / 1_000_000) * actPrice.inputPerM +
|
|
479
|
-
(actOut / 1_000_000) * actPrice.outputPerM;
|
|
480
|
-
}
|
|
481
|
-
// ---------------------------------------------------------------------------
|
|
482
|
-
// Main entry point: runGaiaDAG
|
|
483
|
-
// ---------------------------------------------------------------------------
|
|
484
|
-
/**
|
|
485
|
-
* Run a GAIA question through the Co-Sight DAG harness.
|
|
486
|
-
*
|
|
487
|
-
* Steps:
|
|
488
|
-
* 1. Planner (Claude Sonnet) creates a DAG plan.
|
|
489
|
-
* 2. Execute loop: parallel actors (Gemini 2.5 Pro) run ready steps.
|
|
490
|
-
* 3. Blocked steps trigger replan (up to MAX_REPLAN_CYCLES).
|
|
491
|
-
* 4. Finalizer (Claude Sonnet) reads all step notes → final answer.
|
|
492
|
-
*/
|
|
493
|
-
export async function runGaiaDAG(question, options = {}) {
|
|
494
|
-
const wallStart = Date.now();
|
|
495
|
-
const planModel = options.planModel ?? DEFAULT_PLAN_MODEL;
|
|
496
|
-
const actModel = options.actModel ?? DEFAULT_ACT_MODEL;
|
|
497
|
-
const anthropicKey = resolveAnthropicApiKey(options.anthropicApiKey);
|
|
498
|
-
const geminiKey = resolveGeminiApiKey(options.geminiApiKey);
|
|
499
|
-
const catalogue = options.catalogue ?? createDefaultToolCatalogue();
|
|
500
|
-
let plannerInputTokens = 0;
|
|
501
|
-
let plannerOutputTokens = 0;
|
|
502
|
-
let actorInputTokens = 0;
|
|
503
|
-
let actorOutputTokens = 0;
|
|
504
|
-
// PHASE 1: PLAN
|
|
505
|
-
process.stderr.write(`[dag] ${question.task_id} — planning with ${planModel}\n`);
|
|
506
|
-
let planResult;
|
|
507
|
-
try {
|
|
508
|
-
planResult = await createPlan(question, anthropicKey, planModel);
|
|
509
|
-
}
|
|
510
|
-
catch (err) {
|
|
511
|
-
return {
|
|
512
|
-
questionId: question.task_id,
|
|
513
|
-
finalAnswer: null,
|
|
514
|
-
normalisedAnswer: '',
|
|
515
|
-
plan: { title: question.task_id, question: question.question, steps: [] },
|
|
516
|
-
totalSteps: 0,
|
|
517
|
-
completedSteps: 0,
|
|
518
|
-
blockedSteps: 0,
|
|
519
|
-
plannerCycles: 0,
|
|
520
|
-
totalInputTokens: 0,
|
|
521
|
-
totalOutputTokens: 0,
|
|
522
|
-
estimatedCostUsd: 0,
|
|
523
|
-
wallMs: Date.now() - wallStart,
|
|
524
|
-
error: `Plan creation failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
const plan = planResult.plan;
|
|
528
|
-
plannerInputTokens += planResult.inputTokens;
|
|
529
|
-
plannerOutputTokens += planResult.outputTokens;
|
|
530
|
-
process.stderr.write(`[dag] ${question.task_id} — plan: ${plan.steps.length} steps\n` +
|
|
531
|
-
plan.steps.map((s) => ` [${s.id}] ${s.description} (deps: [${s.depends_on.join(',')}])`).join('\n') + '\n');
|
|
532
|
-
// PHASE 2: EXECUTE + REPLAN loop
|
|
533
|
-
let plannerCycles = 1; // count initial plan creation
|
|
534
|
-
let earlyAnswer = null;
|
|
535
|
-
for (let cycle = 0; cycle < MAX_REPLAN_CYCLES + 1; cycle++) {
|
|
536
|
-
const readySteps = getReadySteps(plan);
|
|
537
|
-
if (readySteps.length === 0)
|
|
538
|
-
break;
|
|
539
|
-
process.stderr.write(`[dag] ${question.task_id} — cycle ${cycle}: ${readySteps.length} ready steps\n`);
|
|
540
|
-
// Mark ready steps as in_progress
|
|
541
|
-
for (const step of readySteps)
|
|
542
|
-
step.status = 'in_progress';
|
|
543
|
-
// Run all ready steps in parallel (cap at MAX_CONCURRENT_ACTORS)
|
|
544
|
-
const batches = [];
|
|
545
|
-
for (let i = 0; i < readySteps.length; i += MAX_CONCURRENT_ACTORS) {
|
|
546
|
-
batches.push(readySteps.slice(i, i + MAX_CONCURRENT_ACTORS));
|
|
547
|
-
}
|
|
548
|
-
for (const batch of batches) {
|
|
549
|
-
const results = await Promise.all(batch.map((step) => executeActorStep(question, step, plan, geminiKey, actModel, catalogue)));
|
|
550
|
-
for (let i = 0; i < batch.length; i++) {
|
|
551
|
-
const step = batch[i];
|
|
552
|
-
const res = results[i];
|
|
553
|
-
step.step_notes = res.notes;
|
|
554
|
-
step.status = res.status;
|
|
555
|
-
actorInputTokens += res.inputTokens;
|
|
556
|
-
actorOutputTokens += res.outputTokens;
|
|
557
|
-
process.stderr.write(`[dag] ${question.task_id} — step ${step.id} → ${step.status}\n`);
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
// Check for blocked steps
|
|
561
|
-
const blockedSteps = plan.steps.filter((s) => s.status === 'blocked');
|
|
562
|
-
if (blockedSteps.length === 0)
|
|
563
|
-
continue;
|
|
564
|
-
// If any steps remain not_started or there are more cycles, try replan
|
|
565
|
-
const remainingSteps = plan.steps.filter((s) => s.status === 'not_started');
|
|
566
|
-
if (remainingSteps.length === 0 || cycle >= MAX_REPLAN_CYCLES)
|
|
567
|
-
break;
|
|
568
|
-
process.stderr.write(`[dag] ${question.task_id} — ${blockedSteps.length} blocked, replanning\n`);
|
|
569
|
-
plannerCycles++;
|
|
570
|
-
try {
|
|
571
|
-
const replanResult = await replan(question, plan, anthropicKey, planModel);
|
|
572
|
-
plannerInputTokens += replanResult.inputTokens;
|
|
573
|
-
plannerOutputTokens += replanResult.outputTokens;
|
|
574
|
-
if (replanResult.earlyAnswer) {
|
|
575
|
-
earlyAnswer = replanResult.earlyAnswer;
|
|
576
|
-
break;
|
|
577
|
-
}
|
|
578
|
-
if (replanResult.updatedSteps) {
|
|
579
|
-
plan.steps = replanResult.updatedSteps;
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
catch (err) {
|
|
583
|
-
process.stderr.write(`[dag] replan error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
584
|
-
break;
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
// PHASE 3: FINALIZE
|
|
588
|
-
let finalAnswer = earlyAnswer;
|
|
589
|
-
if (!finalAnswer) {
|
|
590
|
-
process.stderr.write(`[dag] ${question.task_id} — finalizing\n`);
|
|
591
|
-
try {
|
|
592
|
-
const fin = await finalizePlan(question, plan, anthropicKey, planModel);
|
|
593
|
-
plannerInputTokens += fin.inputTokens;
|
|
594
|
-
plannerOutputTokens += fin.outputTokens;
|
|
595
|
-
finalAnswer = fin.finalAnswer;
|
|
596
|
-
}
|
|
597
|
-
catch (err) {
|
|
598
|
-
process.stderr.write(`[dag] finalize error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
const completedSteps = plan.steps.filter((s) => s.status === 'completed').length;
|
|
602
|
-
const blockedSteps = plan.steps.filter((s) => s.status === 'blocked').length;
|
|
603
|
-
return {
|
|
604
|
-
questionId: question.task_id,
|
|
605
|
-
finalAnswer,
|
|
606
|
-
normalisedAnswer: normaliseAnswer(finalAnswer),
|
|
607
|
-
plan,
|
|
608
|
-
totalSteps: plan.steps.length,
|
|
609
|
-
completedSteps,
|
|
610
|
-
blockedSteps,
|
|
611
|
-
plannerCycles,
|
|
612
|
-
totalInputTokens: plannerInputTokens + actorInputTokens,
|
|
613
|
-
totalOutputTokens: plannerOutputTokens + actorOutputTokens,
|
|
614
|
-
estimatedCostUsd: estimateCostUsd(planModel, actModel, plannerInputTokens, plannerOutputTokens, actorInputTokens, actorOutputTokens),
|
|
615
|
-
wallMs: Date.now() - wallStart,
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
|
-
export async function runDagPilot(questions, options = {}) {
|
|
619
|
-
const perQuestion = [];
|
|
620
|
-
let correct = 0;
|
|
621
|
-
for (const q of questions) {
|
|
622
|
-
const result = await runGaiaDAG(q, options);
|
|
623
|
-
const isCorrect = result.normalisedAnswer !== '' && result.normalisedAnswer === normaliseAnswer(q.final_answer);
|
|
624
|
-
if (isCorrect)
|
|
625
|
-
correct++;
|
|
626
|
-
perQuestion.push({
|
|
627
|
-
taskId: q.task_id,
|
|
628
|
-
question: q.question.slice(0, 80),
|
|
629
|
-
expected: q.final_answer ?? '',
|
|
630
|
-
got: result.finalAnswer,
|
|
631
|
-
correct: isCorrect,
|
|
632
|
-
steps: result.totalSteps,
|
|
633
|
-
completedSteps: result.completedSteps,
|
|
634
|
-
blockedSteps: result.blockedSteps,
|
|
635
|
-
plannerCycles: result.plannerCycles,
|
|
636
|
-
costUsd: result.estimatedCostUsd,
|
|
637
|
-
wallMs: result.wallMs,
|
|
638
|
-
});
|
|
639
|
-
process.stderr.write(`[dag-pilot] ${q.task_id} → ${result.finalAnswer ?? 'null'} ` +
|
|
640
|
-
`(${isCorrect ? 'CORRECT' : 'WRONG'}, steps=${result.totalSteps}, ` +
|
|
641
|
-
`completed=${result.completedSteps}, $${result.estimatedCostUsd.toFixed(4)})\n`);
|
|
642
|
-
}
|
|
643
|
-
const totalCostUsd = perQuestion.reduce((s, r) => s + r.costUsd, 0);
|
|
644
|
-
const avgCostPerQ = totalCostUsd / Math.max(perQuestion.length, 1);
|
|
645
|
-
const meanWallMs = perQuestion.reduce((s, r) => s + r.wallMs, 0) / Math.max(perQuestion.length, 1);
|
|
646
|
-
const avgSteps = perQuestion.reduce((s, r) => s + r.steps, 0) / Math.max(perQuestion.length, 1);
|
|
647
|
-
return {
|
|
648
|
-
correct,
|
|
649
|
-
total: perQuestion.length,
|
|
650
|
-
accuracy: correct / Math.max(perQuestion.length, 1),
|
|
651
|
-
avgStepsPerQuestion: avgSteps,
|
|
652
|
-
perQuestion,
|
|
653
|
-
totalCostUsd,
|
|
654
|
-
projectedCost53Q: avgCostPerQ * 53,
|
|
655
|
-
meanWallMs,
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
//# sourceMappingURL=gaia-dag.js.map
|