@claude-flow/cli 3.32.3 → 3.32.4
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/helpers/helpers.manifest.json +2 -2
- package/catalog-manifest.json +2 -2
- package/dist/src/agenticow/speculative-exploration.d.ts +148 -0
- package/dist/src/agenticow/speculative-exploration.js +218 -0
- package/dist/src/appliance/gguf-engine.d.ts +91 -0
- package/dist/src/appliance/gguf-engine.js +425 -0
- package/dist/src/appliance/ruvllm-bridge.d.ts +102 -0
- package/dist/src/appliance/ruvllm-bridge.js +292 -0
- package/dist/src/appliance/rvfa-builder.d.ts +44 -0
- package/dist/src/appliance/rvfa-builder.js +329 -0
- package/dist/src/appliance/rvfa-distribution.d.ts +97 -0
- package/dist/src/appliance/rvfa-distribution.js +370 -0
- package/dist/src/appliance/rvfa-format.d.ts +111 -0
- package/dist/src/appliance/rvfa-format.js +393 -0
- package/dist/src/appliance/rvfa-runner.d.ts +69 -0
- package/dist/src/appliance/rvfa-runner.js +237 -0
- package/dist/src/appliance/rvfa-signing.d.ts +123 -0
- package/dist/src/appliance/rvfa-signing.js +347 -0
- package/dist/src/auth/client.d.ts +89 -0
- package/dist/src/auth/client.js +242 -0
- package/dist/src/auth/constants.d.ts +7 -0
- package/dist/src/auth/constants.js +7 -0
- package/dist/src/auth/scopes.d.ts +14 -0
- package/dist/src/auth/scopes.js +21 -0
- package/dist/src/auth/security-bridge.d.ts +36 -0
- package/dist/src/auth/security-bridge.js +42 -0
- package/dist/src/auth/session.d.ts +20 -0
- package/dist/src/auth/session.js +32 -0
- package/dist/src/auth/state.d.ts +19 -0
- package/dist/src/auth/state.js +53 -0
- package/dist/src/auth/types.d.ts +27 -0
- package/dist/src/auth/types.js +11 -0
- package/dist/src/autopilot-state.d.ts +77 -0
- package/dist/src/autopilot-state.js +271 -0
- package/dist/src/benchmarks/gaia-agent-planning.smoke.d.ts +18 -0
- package/dist/src/benchmarks/gaia-agent-planning.smoke.js +253 -0
- package/dist/src/benchmarks/gaia-agent.d.ts +198 -0
- package/dist/src/benchmarks/gaia-agent.js +651 -0
- package/dist/src/benchmarks/gaia-causal-memory.d.ts +133 -0
- package/dist/src/benchmarks/gaia-causal-memory.js +281 -0
- package/dist/src/benchmarks/gaia-causal-memory.smoke.d.ts +22 -0
- package/dist/src/benchmarks/gaia-causal-memory.smoke.js +300 -0
- package/dist/src/benchmarks/gaia-convergence.d.ts +138 -0
- package/dist/src/benchmarks/gaia-convergence.js +260 -0
- package/dist/src/benchmarks/gaia-convergence.smoke.d.ts +19 -0
- package/dist/src/benchmarks/gaia-convergence.smoke.js +246 -0
- package/dist/src/benchmarks/gaia-critic.d.ts +123 -0
- package/dist/src/benchmarks/gaia-critic.js +312 -0
- package/dist/src/benchmarks/gaia-critic.smoke.d.ts +21 -0
- package/dist/src/benchmarks/gaia-critic.smoke.js +327 -0
- package/dist/src/benchmarks/gaia-decomposer.d.ts +125 -0
- package/dist/src/benchmarks/gaia-decomposer.js +350 -0
- package/dist/src/benchmarks/gaia-decomposer.smoke.d.ts +21 -0
- package/dist/src/benchmarks/gaia-decomposer.smoke.js +228 -0
- package/dist/src/benchmarks/gaia-e2e-smoke.d.ts +27 -0
- package/dist/src/benchmarks/gaia-e2e-smoke.js +136 -0
- package/dist/src/benchmarks/gaia-extract.smoke.d.ts +45 -0
- package/dist/src/benchmarks/gaia-extract.smoke.js +242 -0
- package/dist/src/benchmarks/gaia-hardness/features.d.ts +46 -0
- package/dist/src/benchmarks/gaia-hardness/features.js +170 -0
- package/dist/src/benchmarks/gaia-hardness/predictor.d.ts +105 -0
- package/dist/src/benchmarks/gaia-hardness/predictor.js +260 -0
- package/dist/src/benchmarks/gaia-hardness/predictor.smoke.d.ts +20 -0
- package/dist/src/benchmarks/gaia-hardness/predictor.smoke.js +235 -0
- package/dist/src/benchmarks/gaia-hardness/train-data-loader.d.ts +51 -0
- package/dist/src/benchmarks/gaia-hardness/train-data-loader.js +179 -0
- package/dist/src/benchmarks/gaia-judge.d.ts +88 -0
- package/dist/src/benchmarks/gaia-judge.js +437 -0
- package/dist/src/benchmarks/gaia-loader.d.ts +87 -0
- package/dist/src/benchmarks/gaia-loader.js +326 -0
- package/dist/src/benchmarks/gaia-tools/file_read.d.ts +35 -0
- package/dist/src/benchmarks/gaia-tools/file_read.js +403 -0
- package/dist/src/benchmarks/gaia-tools/grounded_query.d.ts +126 -0
- package/dist/src/benchmarks/gaia-tools/grounded_query.js +225 -0
- package/dist/src/benchmarks/gaia-tools/index.d.ts +32 -0
- package/dist/src/benchmarks/gaia-tools/index.js +36 -0
- package/dist/src/benchmarks/gaia-tools/types.d.ts +62 -0
- package/dist/src/benchmarks/gaia-tools/types.js +12 -0
- package/dist/src/benchmarks/gaia-tools/web_search.d.ts +30 -0
- package/dist/src/benchmarks/gaia-tools/web_search.js +210 -0
- package/dist/src/benchmarks/gaia-voting.d.ts +88 -0
- package/dist/src/benchmarks/gaia-voting.js +297 -0
- package/dist/src/benchmarks/gaia-voting.smoke.d.ts +20 -0
- package/dist/src/benchmarks/gaia-voting.smoke.js +332 -0
- package/dist/src/benchmarks/pretrain/index.d.ts +58 -0
- package/dist/src/benchmarks/pretrain/index.js +404 -0
- package/dist/src/business-pods/bbs-budget-tracker.d.ts +139 -0
- package/dist/src/business-pods/bbs-budget-tracker.js +358 -0
- package/dist/src/business-pods/domain-affinity-policy.d.ts +47 -0
- package/dist/src/business-pods/domain-affinity-policy.js +65 -0
- package/dist/src/business-pods/pod-schema.d.ts +96 -0
- package/dist/src/business-pods/pod-schema.js +225 -0
- package/dist/src/commands/advisor.d.ts +15 -0
- package/dist/src/commands/advisor.js +94 -0
- package/dist/src/commands/agent-wasm.d.ts +14 -0
- package/dist/src/commands/agent-wasm.js +333 -0
- package/dist/src/commands/agent.d.ts +8 -0
- package/dist/src/commands/agent.js +927 -0
- package/dist/src/commands/analyze.d.ts +19 -0
- package/dist/src/commands/analyze.js +2047 -0
- package/dist/src/commands/announcements.d.ts +17 -0
- package/dist/src/commands/announcements.js +0 -0
- package/dist/src/commands/appliance-advanced.d.ts +9 -0
- package/dist/src/commands/appliance-advanced.js +215 -0
- package/dist/src/commands/appliance.d.ts +8 -0
- package/dist/src/commands/appliance.js +404 -0
- package/dist/src/commands/auth.d.ts +15 -0
- package/dist/src/commands/auth.js +244 -0
- package/dist/src/commands/autopilot.d.ts +15 -0
- package/dist/src/commands/autopilot.js +407 -0
- package/dist/src/commands/benchmark.d.ts +10 -0
- package/dist/src/commands/benchmark.js +460 -0
- package/dist/src/commands/claims.d.ts +10 -0
- package/dist/src/commands/claims.js +620 -0
- package/dist/src/commands/cleanup.d.ts +13 -0
- package/dist/src/commands/cleanup.js +250 -0
- package/dist/src/commands/completions.d.ts +10 -0
- package/dist/src/commands/completions.js +539 -0
- package/dist/src/commands/config.d.ts +8 -0
- package/dist/src/commands/config.js +428 -0
- package/dist/src/commands/daemon.d.ts +59 -0
- package/dist/src/commands/daemon.js +1733 -0
- package/dist/src/commands/deployment.d.ts +10 -0
- package/dist/src/commands/deployment.js +672 -0
- package/dist/src/commands/doctor.d.ts +10 -0
- package/dist/src/commands/doctor.js +1902 -0
- package/dist/src/commands/eject.d.ts +33 -0
- package/dist/src/commands/eject.js +195 -0
- package/dist/src/commands/embeddings.d.ts +18 -0
- package/dist/src/commands/embeddings.js +1623 -0
- package/dist/src/commands/funnel.d.ts +18 -0
- package/dist/src/commands/funnel.js +302 -0
- package/dist/src/commands/gaia-bench.d.ts +40 -0
- package/dist/src/commands/gaia-bench.js +597 -0
- package/dist/src/commands/guidance.d.ts +8 -0
- package/dist/src/commands/guidance.js +556 -0
- package/dist/src/commands/hive-mind.d.ts +11 -0
- package/dist/src/commands/hive-mind.js +1319 -0
- package/dist/src/commands/hooks.d.ts +8 -0
- package/dist/src/commands/hooks.js +4606 -0
- package/dist/src/commands/index.d.ts +118 -0
- package/dist/src/commands/index.js +366 -0
- package/dist/src/commands/init.d.ts +13 -0
- package/dist/src/commands/init.js +1297 -0
- package/dist/src/commands/issues.d.ts +21 -0
- package/dist/src/commands/issues.js +567 -0
- package/dist/src/commands/mcp.d.ts +11 -0
- package/dist/src/commands/mcp.js +732 -0
- package/dist/src/commands/memory-backup.d.ts +11 -0
- package/dist/src/commands/memory-backup.js +46 -0
- package/dist/src/commands/memory-distill.d.ts +27 -0
- package/dist/src/commands/memory-distill.js +374 -0
- package/dist/src/commands/memory.d.ts +8 -0
- package/dist/src/commands/memory.js +1596 -0
- package/dist/src/commands/metaharness.d.ts +39 -0
- package/dist/src/commands/metaharness.js +215 -0
- package/dist/src/commands/migrate.d.ts +8 -0
- package/dist/src/commands/migrate.js +742 -0
- package/dist/src/commands/neural.d.ts +10 -0
- package/dist/src/commands/neural.js +4331 -0
- package/dist/src/commands/performance.d.ts +10 -0
- package/dist/src/commands/performance.js +583 -0
- package/dist/src/commands/plugins.d.ts +11 -0
- package/dist/src/commands/plugins.js +826 -0
- package/dist/src/commands/process.d.ts +10 -0
- package/dist/src/commands/process.js +694 -0
- package/dist/src/commands/progress.d.ts +11 -0
- package/dist/src/commands/progress.js +259 -0
- package/dist/src/commands/providers.d.ts +10 -0
- package/dist/src/commands/providers.js +502 -0
- package/dist/src/commands/proxy-lifecycle.d.ts +12 -0
- package/dist/src/commands/proxy-lifecycle.js +232 -0
- package/dist/src/commands/proxy.d.ts +21 -0
- package/dist/src/commands/proxy.js +398 -0
- package/dist/src/commands/route.d.ts +16 -0
- package/dist/src/commands/route.js +822 -0
- package/dist/src/commands/ruvector/backup.d.ts +11 -0
- package/dist/src/commands/ruvector/backup.js +747 -0
- package/dist/src/commands/ruvector/benchmark.d.ts +11 -0
- package/dist/src/commands/ruvector/benchmark.js +490 -0
- package/dist/src/commands/ruvector/import.d.ts +18 -0
- package/dist/src/commands/ruvector/import.js +373 -0
- package/dist/src/commands/ruvector/index.d.ts +29 -0
- package/dist/src/commands/ruvector/index.js +129 -0
- package/dist/src/commands/ruvector/init.d.ts +11 -0
- package/dist/src/commands/ruvector/init.js +467 -0
- package/dist/src/commands/ruvector/migrate.d.ts +11 -0
- package/dist/src/commands/ruvector/migrate.js +498 -0
- package/dist/src/commands/ruvector/optimize.d.ts +11 -0
- package/dist/src/commands/ruvector/optimize.js +505 -0
- package/dist/src/commands/ruvector/pg-utils.d.ts +14 -0
- package/dist/src/commands/ruvector/pg-utils.js +41 -0
- package/dist/src/commands/ruvector/setup.d.ts +18 -0
- package/dist/src/commands/ruvector/setup.js +765 -0
- package/dist/src/commands/ruvector/status.d.ts +11 -0
- package/dist/src/commands/ruvector/status.js +479 -0
- package/dist/src/commands/security.d.ts +10 -0
- package/dist/src/commands/security.js +1012 -0
- package/dist/src/commands/session.d.ts +8 -0
- package/dist/src/commands/session.js +757 -0
- package/dist/src/commands/settings.d.ts +19 -0
- package/dist/src/commands/settings.js +180 -0
- package/dist/src/commands/spinner.d.ts +16 -0
- package/dist/src/commands/spinner.js +329 -0
- package/dist/src/commands/start.d.ts +8 -0
- package/dist/src/commands/start.js +418 -0
- package/dist/src/commands/status.d.ts +8 -0
- package/dist/src/commands/status.js +608 -0
- package/dist/src/commands/swarm.d.ts +8 -0
- package/dist/src/commands/swarm.js +891 -0
- package/dist/src/commands/task.d.ts +8 -0
- package/dist/src/commands/task.js +675 -0
- package/dist/src/commands/transfer-store.d.ts +13 -0
- package/dist/src/commands/transfer-store.js +428 -0
- package/dist/src/commands/update.d.ts +8 -0
- package/dist/src/commands/update.js +276 -0
- package/dist/src/commands/verify.d.ts +19 -0
- package/dist/src/commands/verify.js +261 -0
- package/dist/src/commands/version.d.ts +42 -0
- package/dist/src/commands/version.js +106 -0
- package/dist/src/commands/workflow.d.ts +8 -0
- package/dist/src/commands/workflow.js +617 -0
- package/dist/src/config/harness-feedback-applier.d.ts +50 -0
- package/dist/src/config/harness-feedback-applier.js +122 -0
- package/dist/src/config/proven-config-refresh.d.ts +39 -0
- package/dist/src/config/proven-config-refresh.js +154 -0
- package/dist/src/config/proven-config-rvfa.d.ts +23 -0
- package/dist/src/config/proven-config-rvfa.js +73 -0
- package/dist/src/config/proven-config.d.ts +86 -0
- package/dist/src/config/proven-config.js +176 -0
- package/dist/src/config-adapter.d.ts +15 -0
- package/dist/src/config-adapter.js +186 -0
- package/dist/src/encryption/vault.d.ts +94 -0
- package/dist/src/encryption/vault.js +172 -0
- package/dist/src/fs-secure.d.ts +86 -0
- package/dist/src/fs-secure.js +133 -0
- package/dist/src/funnel/advisor-tip.d.ts +58 -0
- package/dist/src/funnel/advisor-tip.js +92 -0
- package/dist/src/funnel/attribution.d.ts +37 -0
- package/dist/src/funnel/attribution.js +101 -0
- package/dist/src/funnel/consent.d.ts +22 -0
- package/dist/src/funnel/consent.js +58 -0
- package/dist/src/funnel/credit-errors.d.ts +31 -0
- package/dist/src/funnel/credit-errors.js +88 -0
- package/dist/src/funnel/credit-notifier.d.ts +44 -0
- package/dist/src/funnel/credit-notifier.js +74 -0
- package/dist/src/funnel/disclosure.d.ts +47 -0
- package/dist/src/funnel/disclosure.js +109 -0
- package/dist/src/funnel/enrollment.d.ts +36 -0
- package/dist/src/funnel/enrollment.js +64 -0
- package/dist/src/funnel/environment.d.ts +17 -0
- package/dist/src/funnel/environment.js +39 -0
- package/dist/src/funnel/event-transport.d.ts +51 -0
- package/dist/src/funnel/event-transport.js +199 -0
- package/dist/src/funnel/events.d.ts +42 -0
- package/dist/src/funnel/events.js +150 -0
- package/dist/src/funnel/index.d.ts +21 -0
- package/dist/src/funnel/index.js +21 -0
- package/dist/src/funnel/insights.d.ts +50 -0
- package/dist/src/funnel/insights.js +120 -0
- package/dist/src/funnel/local-signals.d.ts +20 -0
- package/dist/src/funnel/local-signals.js +77 -0
- package/dist/src/funnel/message-transport.d.ts +51 -0
- package/dist/src/funnel/message-transport.js +149 -0
- package/dist/src/funnel/messages.d.ts +55 -0
- package/dist/src/funnel/messages.js +160 -0
- package/dist/src/funnel/payout.d.ts +40 -0
- package/dist/src/funnel/payout.js +60 -0
- package/dist/src/funnel/power-saver-notifier.d.ts +44 -0
- package/dist/src/funnel/power-saver-notifier.js +92 -0
- package/dist/src/funnel/precedence.d.ts +16 -0
- package/dist/src/funnel/precedence.js +85 -0
- package/dist/src/funnel/promo.d.ts +41 -0
- package/dist/src/funnel/promo.js +144 -0
- package/dist/src/funnel/rate-limit-notifier.d.ts +55 -0
- package/dist/src/funnel/rate-limit-notifier.js +102 -0
- package/dist/src/funnel/rotation.d.ts +19 -0
- package/dist/src/funnel/rotation.js +70 -0
- package/dist/src/funnel/state.d.ts +13 -0
- package/dist/src/funnel/state.js +52 -0
- package/dist/src/funnel/toggle-cooldown.d.ts +17 -0
- package/dist/src/funnel/toggle-cooldown.js +32 -0
- package/dist/src/funnel/types.d.ts +98 -0
- package/dist/src/funnel/types.js +26 -0
- package/dist/src/index.d.ts +81 -0
- package/dist/src/index.js +609 -0
- package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
- package/dist/src/infrastructure/in-memory-repositories.js +264 -0
- package/dist/src/init/claudemd-generator.d.ts +16 -0
- package/dist/src/init/claudemd-generator.js +368 -0
- package/dist/src/init/executor.d.ts +41 -0
- package/dist/src/init/executor.js +2142 -0
- package/dist/src/init/helper-refresh.d.ts +79 -0
- package/dist/src/init/helper-refresh.js +347 -0
- package/dist/src/init/helper-signing.d.ts +37 -0
- package/dist/src/init/helper-signing.js +67 -0
- package/dist/src/init/helpers-generator.d.ts +87 -0
- package/dist/src/init/helpers-generator.js +1456 -0
- package/dist/src/init/index.d.ts +13 -0
- package/dist/src/init/index.js +15 -0
- package/dist/src/init/mcp-generator.d.ts +26 -0
- package/dist/src/init/mcp-generator.js +126 -0
- package/dist/src/init/memory-package-resolver.d.ts +53 -0
- package/dist/src/init/memory-package-resolver.js +118 -0
- package/dist/src/init/settings-generator.d.ts +14 -0
- package/dist/src/init/settings-generator.js +462 -0
- package/dist/src/init/statusline-generator.d.ts +28 -0
- package/dist/src/init/statusline-generator.js +177 -0
- package/dist/src/init/types.d.ts +331 -0
- package/dist/src/init/types.js +276 -0
- package/dist/src/log-filters.d.ts +46 -0
- package/dist/src/log-filters.js +107 -0
- package/dist/src/mcp-client.d.ts +92 -0
- package/dist/src/mcp-client.js +397 -0
- package/dist/src/mcp-server.d.ts +163 -0
- package/dist/src/mcp-server.js +751 -0
- package/dist/src/mcp-tools/agent-execute-core.d.ts +115 -0
- package/dist/src/mcp-tools/agent-execute-core.js +587 -0
- package/dist/src/mcp-tools/agent-tools.d.ts +9 -0
- package/dist/src/mcp-tools/agent-tools.js +837 -0
- package/dist/src/mcp-tools/agentbbs-tools.d.ts +28 -0
- package/dist/src/mcp-tools/agentbbs-tools.js +394 -0
- package/dist/src/mcp-tools/agentdb-tools.d.ts +35 -0
- package/dist/src/mcp-tools/agentdb-tools.js +1473 -0
- package/dist/src/mcp-tools/agenticow-loader.d.ts +59 -0
- package/dist/src/mcp-tools/agenticow-loader.js +105 -0
- package/dist/src/mcp-tools/agenticow-speculate-tools.d.ts +24 -0
- package/dist/src/mcp-tools/agenticow-speculate-tools.js +209 -0
- package/dist/src/mcp-tools/agenticow-tools.d.ts +36 -0
- package/dist/src/mcp-tools/agenticow-tools.js +360 -0
- package/dist/src/mcp-tools/analyze-tools.d.ts +38 -0
- package/dist/src/mcp-tools/analyze-tools.js +346 -0
- package/dist/src/mcp-tools/auto-install.d.ts +83 -0
- package/dist/src/mcp-tools/auto-install.js +131 -0
- package/dist/src/mcp-tools/autopilot-tools.d.ts +12 -0
- package/dist/src/mcp-tools/autopilot-tools.js +231 -0
- package/dist/src/mcp-tools/browser-intent-tools.d.ts +162 -0
- package/dist/src/mcp-tools/browser-intent-tools.js +548 -0
- package/dist/src/mcp-tools/browser-session-tools.d.ts +27 -0
- package/dist/src/mcp-tools/browser-session-tools.js +398 -0
- package/dist/src/mcp-tools/browser-tools.d.ts +21 -0
- package/dist/src/mcp-tools/browser-tools.js +760 -0
- package/dist/src/mcp-tools/business-pod-tools.d.ts +20 -0
- package/dist/src/mcp-tools/business-pod-tools.js +169 -0
- package/dist/src/mcp-tools/claims-tools.d.ts +12 -0
- package/dist/src/mcp-tools/claims-tools.js +863 -0
- package/dist/src/mcp-tools/config-tools.d.ts +8 -0
- package/dist/src/mcp-tools/config-tools.js +411 -0
- package/dist/src/mcp-tools/coordination-tools.d.ts +13 -0
- package/dist/src/mcp-tools/coordination-tools.js +729 -0
- package/dist/src/mcp-tools/daa-tools.d.ts +13 -0
- package/dist/src/mcp-tools/daa-tools.js +534 -0
- package/dist/src/mcp-tools/embeddings-tools.d.ts +9 -0
- package/dist/src/mcp-tools/embeddings-tools.js +904 -0
- package/dist/src/mcp-tools/github-tools.d.ts +9 -0
- package/dist/src/mcp-tools/github-tools.js +659 -0
- package/dist/src/mcp-tools/guidance-tools.d.ts +15 -0
- package/dist/src/mcp-tools/guidance-tools.js +639 -0
- package/dist/src/mcp-tools/hive-mind-tools.d.ts +8 -0
- package/dist/src/mcp-tools/hive-mind-tools.js +953 -0
- package/dist/src/mcp-tools/hooks-tools.d.ts +65 -0
- package/dist/src/mcp-tools/hooks-tools.js +4836 -0
- package/dist/src/mcp-tools/http-fetch-tools.d.ts +55 -0
- package/dist/src/mcp-tools/http-fetch-tools.js +329 -0
- package/dist/src/mcp-tools/index.d.ts +34 -0
- package/dist/src/mcp-tools/index.js +40 -0
- package/dist/src/mcp-tools/managed-agent-tools.d.ts +22 -0
- package/dist/src/mcp-tools/managed-agent-tools.js +357 -0
- package/dist/src/mcp-tools/memory-tools.d.ts +14 -0
- package/dist/src/mcp-tools/memory-tools.js +1330 -0
- package/dist/src/mcp-tools/metaharness-tools.d.ts +51 -0
- package/dist/src/mcp-tools/metaharness-tools.js +684 -0
- package/dist/src/mcp-tools/neural-tools.d.ts +54 -0
- package/dist/src/mcp-tools/neural-tools.js +1168 -0
- package/dist/src/mcp-tools/performance-tools.d.ts +16 -0
- package/dist/src/mcp-tools/performance-tools.js +675 -0
- package/dist/src/mcp-tools/progress-tools.d.ts +14 -0
- package/dist/src/mcp-tools/progress-tools.js +348 -0
- package/dist/src/mcp-tools/request-tracker.d.ts +17 -0
- package/dist/src/mcp-tools/request-tracker.js +27 -0
- package/dist/src/mcp-tools/ruvllm-tools.d.ts +9 -0
- package/dist/src/mcp-tools/ruvllm-tools.js +355 -0
- package/dist/src/mcp-tools/security-tools.d.ts +18 -0
- package/dist/src/mcp-tools/security-tools.js +556 -0
- package/dist/src/mcp-tools/session-tools.d.ts +8 -0
- package/dist/src/mcp-tools/session-tools.js +517 -0
- package/dist/src/mcp-tools/swarm-tools.d.ts +37 -0
- package/dist/src/mcp-tools/swarm-tools.js +390 -0
- package/dist/src/mcp-tools/system-tools.d.ts +13 -0
- package/dist/src/mcp-tools/system-tools.js +688 -0
- package/dist/src/mcp-tools/task-tools.d.ts +8 -0
- package/dist/src/mcp-tools/task-tools.js +487 -0
- package/dist/src/mcp-tools/terminal-tools.d.ts +8 -0
- package/dist/src/mcp-tools/terminal-tools.js +306 -0
- package/dist/src/mcp-tools/testgen-tools.d.ts +26 -0
- package/dist/src/mcp-tools/testgen-tools.js +168 -0
- package/dist/src/mcp-tools/tool-loop-guardrail.d.ts +31 -0
- package/dist/src/mcp-tools/tool-loop-guardrail.js +71 -0
- package/dist/src/mcp-tools/transfer-tools.d.ts +14 -0
- package/dist/src/mcp-tools/transfer-tools.js +447 -0
- package/dist/src/mcp-tools/types.d.ts +8 -0
- package/dist/src/mcp-tools/types.js +8 -0
- package/dist/src/mcp-tools/validate-input.d.ts +9 -0
- package/dist/src/mcp-tools/validate-input.js +9 -0
- package/dist/src/mcp-tools/wasm-agent-tools.d.ts +13 -0
- package/dist/src/mcp-tools/wasm-agent-tools.js +840 -0
- package/dist/src/mcp-tools/workflow-tools.d.ts +8 -0
- package/dist/src/mcp-tools/workflow-tools.js +884 -0
- package/dist/src/memory/bge-embedder.d.ts +25 -0
- package/dist/src/memory/bge-embedder.js +121 -0
- package/dist/src/memory/cross-encoder-rerank.d.ts +33 -0
- package/dist/src/memory/cross-encoder-rerank.js +123 -0
- package/dist/src/memory/embedding-policy.d.ts +21 -0
- package/dist/src/memory/embedding-policy.js +30 -0
- package/dist/src/memory/embedding-quantization.d.ts +62 -0
- package/dist/src/memory/embedding-quantization.js +156 -0
- package/dist/src/memory/ewc-consolidation.d.ts +305 -0
- package/dist/src/memory/ewc-consolidation.js +611 -0
- package/dist/src/memory/graph-edge-writer.d.ts +95 -0
- package/dist/src/memory/graph-edge-writer.js +217 -0
- package/dist/src/memory/hybrid-retrieval.d.ts +77 -0
- package/dist/src/memory/hybrid-retrieval.js +192 -0
- package/dist/src/memory/intelligence.d.ts +405 -0
- package/dist/src/memory/intelligence.js +1316 -0
- package/dist/src/memory/lucene-bm25.d.ts +19 -0
- package/dist/src/memory/lucene-bm25.js +308 -0
- package/dist/src/memory/memory-bridge.d.ts +537 -0
- package/dist/src/memory/memory-bridge.js +2460 -0
- package/dist/src/memory/memory-initializer.d.ts +556 -0
- package/dist/src/memory/memory-initializer.js +3021 -0
- package/dist/src/memory/neural-package-bridge.d.ts +48 -0
- package/dist/src/memory/neural-package-bridge.js +87 -0
- package/dist/src/memory/rabitq-index.d.ts +60 -0
- package/dist/src/memory/rabitq-index.js +242 -0
- package/dist/src/memory/sona-optimizer.d.ts +267 -0
- package/dist/src/memory/sona-optimizer.js +779 -0
- package/dist/src/memory/structured-distill.d.ts +48 -0
- package/dist/src/memory/structured-distill.js +125 -0
- package/dist/src/output.d.ts +9 -0
- package/dist/src/output.js +9 -0
- package/dist/src/parser.d.ts +89 -0
- package/dist/src/parser.js +516 -0
- package/dist/src/plugins/manager.d.ts +133 -0
- package/dist/src/plugins/manager.js +415 -0
- package/dist/src/plugins/store/discovery.d.ts +99 -0
- package/dist/src/plugins/store/discovery.js +1224 -0
- package/dist/src/plugins/store/index.d.ts +76 -0
- package/dist/src/plugins/store/index.js +141 -0
- package/dist/src/plugins/store/search.d.ts +46 -0
- package/dist/src/plugins/store/search.js +230 -0
- package/dist/src/plugins/store/types.d.ts +279 -0
- package/dist/src/plugins/store/types.js +7 -0
- package/dist/src/plugins/tests/demo-plugin-store.d.ts +7 -0
- package/dist/src/plugins/tests/demo-plugin-store.js +126 -0
- package/dist/src/plugins/tests/standalone-test.d.ts +12 -0
- package/dist/src/plugins/tests/standalone-test.js +188 -0
- package/dist/src/plugins/tests/test-plugin-store.d.ts +7 -0
- package/dist/src/plugins/tests/test-plugin-store.js +206 -0
- package/dist/src/production/circuit-breaker.d.ts +101 -0
- package/dist/src/production/circuit-breaker.js +241 -0
- package/dist/src/production/error-handler.d.ts +92 -0
- package/dist/src/production/error-handler.js +299 -0
- package/dist/src/production/index.d.ts +23 -0
- package/dist/src/production/index.js +18 -0
- package/dist/src/production/monitoring.d.ts +161 -0
- package/dist/src/production/monitoring.js +356 -0
- package/dist/src/production/rate-limiter.d.ts +80 -0
- package/dist/src/production/rate-limiter.js +201 -0
- package/dist/src/production/retry.d.ts +48 -0
- package/dist/src/production/retry.js +179 -0
- package/dist/src/prompt.d.ts +44 -0
- package/dist/src/prompt.js +501 -0
- package/dist/src/proxy/install.d.ts +29 -0
- package/dist/src/proxy/install.js +135 -0
- package/dist/src/proxy/lifecycle.d.ts +61 -0
- package/dist/src/proxy/lifecycle.js +249 -0
- package/dist/src/proxy/paths.d.ts +34 -0
- package/dist/src/proxy/paths.js +70 -0
- package/dist/src/proxy/release.d.ts +47 -0
- package/dist/src/proxy/release.js +138 -0
- package/dist/src/proxy/token-bridge.d.ts +5 -0
- package/dist/src/proxy/token-bridge.js +61 -0
- package/dist/src/proxy/verify.d.ts +44 -0
- package/dist/src/proxy/verify.js +68 -0
- package/dist/src/runtime/headless.d.ts +60 -0
- package/dist/src/runtime/headless.js +284 -0
- package/dist/src/runtime/parent-death-watchdog.d.ts +42 -0
- package/dist/src/runtime/parent-death-watchdog.js +70 -0
- package/dist/src/ruvector/agent-wasm.d.ts +228 -0
- package/dist/src/ruvector/agent-wasm.js +463 -0
- package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
- package/dist/src/ruvector/ast-analyzer.js +277 -0
- package/dist/src/ruvector/codemods/engine.d.ts +45 -0
- package/dist/src/ruvector/codemods/engine.js +291 -0
- package/dist/src/ruvector/codemods/scope-analysis.d.ts +29 -0
- package/dist/src/ruvector/codemods/scope-analysis.js +162 -0
- package/dist/src/ruvector/coverage-router.d.ts +160 -0
- package/dist/src/ruvector/coverage-router.js +531 -0
- package/dist/src/ruvector/coverage-tools.d.ts +33 -0
- package/dist/src/ruvector/coverage-tools.js +157 -0
- package/dist/src/ruvector/diff-classifier.d.ts +175 -0
- package/dist/src/ruvector/diff-classifier.js +699 -0
- package/dist/src/ruvector/diskann-backend.d.ts +78 -0
- package/dist/src/ruvector/diskann-backend.js +310 -0
- package/dist/src/ruvector/enhanced-model-router.d.ts +172 -0
- package/dist/src/ruvector/enhanced-model-router.js +577 -0
- package/dist/src/ruvector/graph-analyzer.d.ts +187 -0
- package/dist/src/ruvector/graph-analyzer.js +929 -0
- package/dist/src/ruvector/graph-backend.d.ts +79 -0
- package/dist/src/ruvector/graph-backend.js +220 -0
- package/dist/src/ruvector/index.d.ts +38 -0
- package/dist/src/ruvector/index.js +86 -0
- package/dist/src/ruvector/lora-adapter.d.ts +292 -0
- package/dist/src/ruvector/lora-adapter.js +710 -0
- package/dist/src/ruvector/model-prices.d.ts +50 -0
- package/dist/src/ruvector/model-prices.js +72 -0
- package/dist/src/ruvector/model-router.d.ts +408 -0
- package/dist/src/ruvector/model-router.js +1162 -0
- package/dist/src/ruvector/neural-router.d.ts +182 -0
- package/dist/src/ruvector/neural-router.js +825 -0
- package/dist/src/ruvector/output-verifier.d.ts +83 -0
- package/dist/src/ruvector/output-verifier.js +277 -0
- package/dist/src/ruvector/q-learning-router.d.ts +227 -0
- package/dist/src/ruvector/q-learning-router.js +721 -0
- package/dist/src/ruvector/router-calibrator.d.ts +65 -0
- package/dist/src/ruvector/router-calibrator.js +120 -0
- package/dist/src/ruvector/router-parallel-recorder.d.ts +127 -0
- package/dist/src/ruvector/router-parallel-recorder.js +183 -0
- package/dist/src/ruvector/router-trajectory.d.ts +194 -0
- package/dist/src/ruvector/router-trajectory.js +281 -0
- package/dist/src/ruvector/run-transcript-recorder.d.ts +154 -0
- package/dist/src/ruvector/run-transcript-recorder.js +209 -0
- package/dist/src/ruvector/ruvllm-wasm.d.ts +179 -0
- package/dist/src/ruvector/ruvllm-wasm.js +379 -0
- package/dist/src/ruvector/semantic-router.d.ts +77 -0
- package/dist/src/ruvector/semantic-router.js +178 -0
- package/dist/src/ruvector/task-embedder.d.ts +56 -0
- package/dist/src/ruvector/task-embedder.js +237 -0
- package/dist/src/ruvector/trajectory-tree.d.ts +113 -0
- package/dist/src/ruvector/trajectory-tree.js +237 -0
- package/dist/src/ruvector/vector-db.d.ts +73 -0
- package/dist/src/ruvector/vector-db.js +301 -0
- package/dist/src/ruvector/wasm-embedder.d.ts +13 -0
- package/dist/src/ruvector/wasm-embedder.js +143 -0
- package/dist/src/security/builtin-aidefence.d.ts +34 -0
- package/dist/src/security/builtin-aidefence.js +86 -0
- package/dist/src/services/agentic-flow-bridge.d.ts +50 -0
- package/dist/src/services/agentic-flow-bridge.js +95 -0
- package/dist/src/services/ai-job-dedup.d.ts +61 -0
- package/dist/src/services/ai-job-dedup.js +136 -0
- package/dist/src/services/checkpoint-gate.d.ts +140 -0
- package/dist/src/services/checkpoint-gate.js +223 -0
- package/dist/src/services/claim-service.d.ts +204 -0
- package/dist/src/services/claim-service.js +818 -0
- package/dist/src/services/config-file-manager.d.ts +37 -0
- package/dist/src/services/config-file-manager.js +224 -0
- package/dist/src/services/container-worker-pool.d.ts +204 -0
- package/dist/src/services/container-worker-pool.js +589 -0
- package/dist/src/services/daemon-autostart.d.ts +17 -0
- package/dist/src/services/daemon-autostart.js +102 -0
- package/dist/src/services/distill-oracle.d.ts +190 -0
- package/dist/src/services/distill-oracle.js +349 -0
- package/dist/src/services/distill-tuning.d.ts +111 -0
- package/dist/src/services/distill-tuning.js +510 -0
- package/dist/src/services/evolve-proof.d.ts +253 -0
- package/dist/src/services/evolve-proof.js +343 -0
- package/dist/src/services/fable-harness.d.ts +208 -0
- package/dist/src/services/fable-harness.js +388 -0
- package/dist/src/services/git-workspace-identity.d.ts +42 -0
- package/dist/src/services/git-workspace-identity.js +99 -0
- package/dist/src/services/global-ai-budget.d.ts +135 -0
- package/dist/src/services/global-ai-budget.js +415 -0
- package/dist/src/services/harness-benchmark.d.ts +68 -0
- package/dist/src/services/harness-benchmark.js +94 -0
- package/dist/src/services/harness-canary.d.ts +60 -0
- package/dist/src/services/harness-canary.js +69 -0
- package/dist/src/services/harness-corpus-harvester.d.ts +51 -0
- package/dist/src/services/harness-corpus-harvester.js +74 -0
- package/dist/src/services/harness-flywheel-generations.d.ts +115 -0
- package/dist/src/services/harness-flywheel-generations.js +360 -0
- package/dist/src/services/harness-flywheel-runtime.d.ts +25 -0
- package/dist/src/services/harness-flywheel-runtime.js +92 -0
- package/dist/src/services/harness-flywheel.d.ts +48 -0
- package/dist/src/services/harness-flywheel.js +207 -0
- package/dist/src/services/harness-frozen-eval.d.ts +22 -0
- package/dist/src/services/harness-frozen-eval.js +66 -0
- package/dist/src/services/harness-hosts.d.ts +40 -0
- package/dist/src/services/harness-hosts.js +88 -0
- package/dist/src/services/harness-improvement-ledger.d.ts +63 -0
- package/dist/src/services/harness-improvement-ledger.js +101 -0
- package/dist/src/services/harness-loop.d.ts +53 -0
- package/dist/src/services/harness-loop.js +85 -0
- package/dist/src/services/harness-qualification.d.ts +66 -0
- package/dist/src/services/harness-qualification.js +143 -0
- package/dist/src/services/harness-replay.d.ts +37 -0
- package/dist/src/services/harness-replay.js +92 -0
- package/dist/src/services/harness-verify.d.ts +33 -0
- package/dist/src/services/harness-verify.js +26 -0
- package/dist/src/services/harness-worker.d.ts +23 -0
- package/dist/src/services/harness-worker.js +66 -0
- package/dist/src/services/headless-worker-executor.d.ts +358 -0
- package/dist/src/services/headless-worker-executor.js +1269 -0
- package/dist/src/services/index.d.ts +13 -0
- package/dist/src/services/index.js +11 -0
- package/dist/src/services/memory-backup.d.ts +53 -0
- package/dist/src/services/memory-backup.js +198 -0
- package/dist/src/services/memory-distillation.d.ts +41 -0
- package/dist/src/services/memory-distillation.js +277 -0
- package/dist/src/services/native-training.d.ts +68 -0
- package/dist/src/services/native-training.js +141 -0
- package/dist/src/services/registry-api.d.ts +58 -0
- package/dist/src/services/registry-api.js +146 -0
- package/dist/src/services/repo-supervisor.d.ts +70 -0
- package/dist/src/services/repo-supervisor.js +228 -0
- package/dist/src/services/ruvector-training.d.ts +222 -0
- package/dist/src/services/ruvector-training.js +693 -0
- package/dist/src/services/swarm-memory-branches.d.ts +135 -0
- package/dist/src/services/swarm-memory-branches.js +213 -0
- package/dist/src/services/weight-eft.d.ts +305 -0
- package/dist/src/services/weight-eft.js +296 -0
- package/dist/src/services/worker-daemon.d.ts +439 -0
- package/dist/src/services/worker-daemon.js +1865 -0
- package/dist/src/services/worker-queue.d.ts +194 -0
- package/dist/src/services/worker-queue.js +513 -0
- package/dist/src/services/workspace-lease.d.ts +55 -0
- package/dist/src/services/workspace-lease.js +191 -0
- package/dist/src/suggest.d.ts +53 -0
- package/dist/src/suggest.js +200 -0
- package/dist/src/transfer/anonymization/index.d.ts +25 -0
- package/dist/src/transfer/anonymization/index.js +175 -0
- package/dist/src/transfer/deploy-seraphine.d.ts +13 -0
- package/dist/src/transfer/deploy-seraphine.js +205 -0
- package/dist/src/transfer/export.d.ts +25 -0
- package/dist/src/transfer/export.js +113 -0
- package/dist/src/transfer/index.d.ts +12 -0
- package/dist/src/transfer/index.js +31 -0
- package/dist/src/transfer/ipfs/client.d.ts +109 -0
- package/dist/src/transfer/ipfs/client.js +307 -0
- package/dist/src/transfer/ipfs/upload.d.ts +95 -0
- package/dist/src/transfer/ipfs/upload.js +413 -0
- package/dist/src/transfer/models/seraphine.d.ts +72 -0
- package/dist/src/transfer/models/seraphine.js +373 -0
- package/dist/src/transfer/serialization/cfp.d.ts +49 -0
- package/dist/src/transfer/serialization/cfp.js +183 -0
- package/dist/src/transfer/storage/gcs.d.ts +82 -0
- package/dist/src/transfer/storage/gcs.js +272 -0
- package/dist/src/transfer/storage/index.d.ts +6 -0
- package/dist/src/transfer/storage/index.js +6 -0
- package/dist/src/transfer/store/discovery.d.ts +84 -0
- package/dist/src/transfer/store/discovery.js +382 -0
- package/dist/src/transfer/store/download.d.ts +70 -0
- package/dist/src/transfer/store/download.js +334 -0
- package/dist/src/transfer/store/index.d.ts +84 -0
- package/dist/src/transfer/store/index.js +153 -0
- package/dist/src/transfer/store/publish.d.ts +76 -0
- package/dist/src/transfer/store/publish.js +294 -0
- package/dist/src/transfer/store/registry.d.ts +58 -0
- package/dist/src/transfer/store/registry.js +285 -0
- package/dist/src/transfer/store/search.d.ts +54 -0
- package/dist/src/transfer/store/search.js +232 -0
- package/dist/src/transfer/store/tests/standalone-test.d.ts +12 -0
- package/dist/src/transfer/store/tests/standalone-test.js +190 -0
- package/dist/src/transfer/store/types.d.ts +193 -0
- package/dist/src/transfer/store/types.js +6 -0
- package/dist/src/transfer/test-seraphine.d.ts +6 -0
- package/dist/src/transfer/test-seraphine.js +105 -0
- package/dist/src/transfer/tests/test-store.d.ts +7 -0
- package/dist/src/transfer/tests/test-store.js +214 -0
- package/dist/src/transfer/types.d.ts +245 -0
- package/dist/src/transfer/types.js +6 -0
- package/dist/src/types.d.ts +13 -0
- package/dist/src/types.js +13 -0
- package/dist/src/update/checker.d.ts +34 -0
- package/dist/src/update/checker.js +191 -0
- package/dist/src/update/executor.d.ts +33 -0
- package/dist/src/update/executor.js +217 -0
- package/dist/src/update/index.d.ts +33 -0
- package/dist/src/update/index.js +64 -0
- package/dist/src/update/rate-limiter.d.ts +20 -0
- package/dist/src/update/rate-limiter.js +96 -0
- package/dist/src/update/validator.d.ts +17 -0
- package/dist/src/update/validator.js +123 -0
- package/package.json +1 -1
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* router-trajectory.ts — Opt-in DRACO-shaped trajectory recorder for the
|
|
3
|
+
* cost-optimal model router (ADR-148, phase 5).
|
|
4
|
+
*
|
|
5
|
+
* Writes one JSON-line per routing decision and one per outcome to a
|
|
6
|
+
* shared `.swarm/model-router-trajectories.jsonl`. Outcome rows are
|
|
7
|
+
* matched to their decision via `task_hash` (FNV-1a-32 of the task text).
|
|
8
|
+
*
|
|
9
|
+
* Gated behind `CLAUDE_FLOW_ROUTER_TRAJECTORY=1`. Default: **off** — rows
|
|
10
|
+
* carry full task text + raw embeddings, which is a PII/retention surface
|
|
11
|
+
* we do not enable without explicit consent.
|
|
12
|
+
*
|
|
13
|
+
* Schema is versioned (`"v": 1`). New required fields bump the version;
|
|
14
|
+
* additive optional fields do not.
|
|
15
|
+
*
|
|
16
|
+
* COMPANION: run-transcript-recorder.ts (weight-eft capture path)
|
|
17
|
+
* --------------------------------------------------------------
|
|
18
|
+
* This recorder captures the routing DECISION only (task, embedding, scalar
|
|
19
|
+
* quality, tokens, cost) — enough to retrain the router. It deliberately does
|
|
20
|
+
* NOT carry the full message transcript, the produced patch, or a resolved
|
|
21
|
+
* boolean. `@metaharness/weight-eft` needs those to build SFT/DPO training
|
|
22
|
+
* rows, so a SEPARATE opt-in recorder — `run-transcript-recorder.ts` — captures
|
|
23
|
+
* the full run transcript to `.swarm/run-transcripts.jsonl`. Both share the
|
|
24
|
+
* `taskHash()` below as their join key, and both are off-by-default for the
|
|
25
|
+
* same PII/retention reason. Use `unifiedRecorderStatus()` (bottom of this
|
|
26
|
+
* file) to inspect both at once. Keeping them as two files keeps the routing
|
|
27
|
+
* hot path free of the heavier transcript payload.
|
|
28
|
+
*
|
|
29
|
+
* @module router-trajectory
|
|
30
|
+
*/
|
|
31
|
+
import { appendFileSync, mkdirSync, existsSync, statSync, renameSync, unlinkSync } from 'node:fs';
|
|
32
|
+
import { dirname, join, resolve as resolvePath } from 'node:path';
|
|
33
|
+
import { costUsd } from './model-prices.js';
|
|
34
|
+
// ============================================================================
|
|
35
|
+
// FNV-1a-32 (matches scripts/gen-seed-corpus.mjs)
|
|
36
|
+
// ============================================================================
|
|
37
|
+
export function taskHash(task) {
|
|
38
|
+
let h = 0x811c9dc5 >>> 0;
|
|
39
|
+
for (let i = 0; i < task.length; i++) {
|
|
40
|
+
h ^= task.charCodeAt(i);
|
|
41
|
+
h = (h + ((h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24))) >>> 0;
|
|
42
|
+
}
|
|
43
|
+
return h.toString(16).padStart(8, '0');
|
|
44
|
+
}
|
|
45
|
+
let _cfg = null;
|
|
46
|
+
/** Cached size of the current file; updated incrementally on each append to
|
|
47
|
+
* avoid a `statSync` per write. -1 means "unknown, probe on next append". */
|
|
48
|
+
let _cachedSize = -1;
|
|
49
|
+
function getConfig() {
|
|
50
|
+
if (_cfg !== null)
|
|
51
|
+
return _cfg;
|
|
52
|
+
const enabled = process.env.CLAUDE_FLOW_ROUTER_TRAJECTORY === '1';
|
|
53
|
+
const swarmDir = process.env.CLAUDE_FLOW_SWARM_DIR
|
|
54
|
+
?? resolvePath(process.cwd(), '.swarm');
|
|
55
|
+
_cfg = {
|
|
56
|
+
enabled,
|
|
57
|
+
path: process.env.CLAUDE_FLOW_ROUTER_TRAJECTORY_PATH
|
|
58
|
+
?? join(swarmDir, 'model-router-trajectories.jsonl'),
|
|
59
|
+
taskCharLimit: parseInt(process.env.CLAUDE_FLOW_ROUTER_TRAJECTORY_TASKLEN ?? '500', 10) || 500,
|
|
60
|
+
maxSizeBytes: parseInt(process.env.CLAUDE_FLOW_ROUTER_TRAJECTORY_MAXSIZE ?? `${10 * 1024 * 1024}`, 10) | 0,
|
|
61
|
+
maxRotations: Math.max(0, parseInt(process.env.CLAUDE_FLOW_ROUTER_TRAJECTORY_MAXROTATIONS ?? '3', 10) || 3),
|
|
62
|
+
};
|
|
63
|
+
return _cfg;
|
|
64
|
+
}
|
|
65
|
+
/** Rotate `path` → `path.1`, `path.1` → `path.2`, ..., dropping the oldest. */
|
|
66
|
+
function rotate(cfg) {
|
|
67
|
+
if (!existsSync(cfg.path))
|
|
68
|
+
return;
|
|
69
|
+
try {
|
|
70
|
+
// Walk from oldest to newest so each rename has a free target.
|
|
71
|
+
if (cfg.maxRotations === 0) {
|
|
72
|
+
// No history kept — just truncate by deleting.
|
|
73
|
+
unlinkSync(cfg.path);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const oldest = `${cfg.path}.${cfg.maxRotations}`;
|
|
77
|
+
if (existsSync(oldest))
|
|
78
|
+
unlinkSync(oldest);
|
|
79
|
+
for (let i = cfg.maxRotations - 1; i >= 1; i--) {
|
|
80
|
+
const src = `${cfg.path}.${i}`;
|
|
81
|
+
if (existsSync(src))
|
|
82
|
+
renameSync(src, `${cfg.path}.${i + 1}`);
|
|
83
|
+
}
|
|
84
|
+
renameSync(cfg.path, `${cfg.path}.1`);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
// If rotation fails (permissions, race), drop back to overwriting the
|
|
88
|
+
// active file by truncating its handle. Worst case we lose history.
|
|
89
|
+
try {
|
|
90
|
+
unlinkSync(cfg.path);
|
|
91
|
+
}
|
|
92
|
+
catch { /* */ }
|
|
93
|
+
}
|
|
94
|
+
_cachedSize = 0;
|
|
95
|
+
}
|
|
96
|
+
function appendRow(row) {
|
|
97
|
+
const cfg = getConfig();
|
|
98
|
+
if (!cfg.enabled)
|
|
99
|
+
return;
|
|
100
|
+
try {
|
|
101
|
+
const dir = dirname(cfg.path);
|
|
102
|
+
if (!existsSync(dir))
|
|
103
|
+
mkdirSync(dir, { recursive: true });
|
|
104
|
+
// Probe size lazily on first call this process, then track incrementally.
|
|
105
|
+
if (_cachedSize < 0) {
|
|
106
|
+
_cachedSize = existsSync(cfg.path) ? statSync(cfg.path).size : 0;
|
|
107
|
+
}
|
|
108
|
+
// One JSON object per line, newline-terminated. No leading whitespace —
|
|
109
|
+
// we want the file to be `jq -c`-friendly.
|
|
110
|
+
const line = JSON.stringify(row) + '\n';
|
|
111
|
+
const bytes = Buffer.byteLength(line, 'utf8');
|
|
112
|
+
// Rotate BEFORE writing if this row would push us past the cap.
|
|
113
|
+
if (cfg.maxSizeBytes > 0 && _cachedSize + bytes > cfg.maxSizeBytes) {
|
|
114
|
+
rotate(cfg);
|
|
115
|
+
}
|
|
116
|
+
appendFileSync(cfg.path, line);
|
|
117
|
+
_cachedSize += bytes;
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// Silent: trajectory collection must never break routing.
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// ============================================================================
|
|
124
|
+
// Public API
|
|
125
|
+
// ============================================================================
|
|
126
|
+
/** Record one decision. Cheap — a single appendFileSync of a JSONL row. */
|
|
127
|
+
export function recordDecision(args) {
|
|
128
|
+
const cfg = getConfig();
|
|
129
|
+
if (!cfg.enabled)
|
|
130
|
+
return;
|
|
131
|
+
const row = {
|
|
132
|
+
v: 1, type: 'decision',
|
|
133
|
+
ts: new Date().toISOString(),
|
|
134
|
+
task_hash: taskHash(args.task),
|
|
135
|
+
task: args.task.length > cfg.taskCharLimit ? args.task.slice(0, cfg.taskCharLimit) : args.task,
|
|
136
|
+
embedding: args.embedding,
|
|
137
|
+
complexity: args.complexity,
|
|
138
|
+
model: args.model,
|
|
139
|
+
confidence: args.confidence,
|
|
140
|
+
uncertainty: args.uncertainty,
|
|
141
|
+
routed_by: args.routedBy,
|
|
142
|
+
...(args.neuralBackend ? { neural_backend: args.neuralBackend } : {}),
|
|
143
|
+
...(args.abPair ? { ab_pair: args.abPair } : {}),
|
|
144
|
+
...(args.provider ? { provider: args.provider } : {}),
|
|
145
|
+
...(args.openrouterModel ? { openrouter_model: args.openrouterModel } : {}),
|
|
146
|
+
...(args.ensembleDisagreement !== undefined ? { ensemble_disagreement: args.ensembleDisagreement } : {}),
|
|
147
|
+
};
|
|
148
|
+
appendRow(row);
|
|
149
|
+
}
|
|
150
|
+
/** Record one outcome. Join to a decision by `task_hash`. */
|
|
151
|
+
export function recordTrajectoryOutcome(args) {
|
|
152
|
+
const cfg = getConfig();
|
|
153
|
+
if (!cfg.enabled)
|
|
154
|
+
return;
|
|
155
|
+
// iter 31 — compute USD spend at write time using the canonical price
|
|
156
|
+
// table. Cost is a first-class field so consumers don't need to JOIN
|
|
157
|
+
// against the decision row (which may live in a rotated file).
|
|
158
|
+
const cost_usd = args.tokens && (args.tokens.input > 0 || args.tokens.output > 0)
|
|
159
|
+
? costUsd(args.modelId, args.tokens.input, args.tokens.output)
|
|
160
|
+
: undefined;
|
|
161
|
+
const row = {
|
|
162
|
+
v: 1, type: 'outcome',
|
|
163
|
+
ts: new Date().toISOString(),
|
|
164
|
+
task_hash: taskHash(args.task),
|
|
165
|
+
quality: args.quality,
|
|
166
|
+
scores: args.scores,
|
|
167
|
+
source: args.source,
|
|
168
|
+
...(args.tokens ? { tokens: args.tokens } : {}),
|
|
169
|
+
...(cost_usd != null ? { cost_usd } : {}),
|
|
170
|
+
...(args.modelId ? { model_id: args.modelId } : {}),
|
|
171
|
+
};
|
|
172
|
+
appendRow(row);
|
|
173
|
+
}
|
|
174
|
+
/** Diagnostic for status/CLI. */
|
|
175
|
+
export function trajectoryRecorderStatus() {
|
|
176
|
+
return { ...getConfig() };
|
|
177
|
+
}
|
|
178
|
+
/** Map decision-side complexity ∈ [0,1] back to the corpus tier label. The
|
|
179
|
+
* buckets are deliberately the same boundaries the bandit uses so a pair
|
|
180
|
+
* drawn from production lands in the same KRR specialist that served it. */
|
|
181
|
+
export function tierFromComplexity(complexity) {
|
|
182
|
+
if (complexity < 0.34)
|
|
183
|
+
return 'cheap';
|
|
184
|
+
if (complexity < 0.67)
|
|
185
|
+
return 'mid';
|
|
186
|
+
return 'strong';
|
|
187
|
+
}
|
|
188
|
+
/** Pair decision+outcome rows by task_hash. Returns the rebuilt training rows
|
|
189
|
+
* + diagnostics so the caller (script or test) can report what was dropped
|
|
190
|
+
* and why. */
|
|
191
|
+
export function pairTrajectoryRows(rows) {
|
|
192
|
+
const decisions = new Map();
|
|
193
|
+
const outcomes = new Map();
|
|
194
|
+
// Latest-wins per hash. Production may re-run the same task — using the most
|
|
195
|
+
// recent outcome avoids polluting the corpus with stale judgments.
|
|
196
|
+
let dCount = 0, oCount = 0;
|
|
197
|
+
for (const row of rows) {
|
|
198
|
+
if (row.type === 'decision') {
|
|
199
|
+
dCount++;
|
|
200
|
+
const prev = decisions.get(row.task_hash);
|
|
201
|
+
if (!prev || row.ts > prev.ts)
|
|
202
|
+
decisions.set(row.task_hash, row);
|
|
203
|
+
}
|
|
204
|
+
else if (row.type === 'outcome') {
|
|
205
|
+
oCount++;
|
|
206
|
+
const prev = outcomes.get(row.task_hash);
|
|
207
|
+
if (!prev || row.ts > prev.ts)
|
|
208
|
+
outcomes.set(row.task_hash, row);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const pairs = [];
|
|
212
|
+
const bySource = {};
|
|
213
|
+
const byTier = {};
|
|
214
|
+
let droppedNoEmbedding = 0;
|
|
215
|
+
let droppedNoMatch = 0;
|
|
216
|
+
for (const [hash, dec] of decisions) {
|
|
217
|
+
const out = outcomes.get(hash);
|
|
218
|
+
if (!out) {
|
|
219
|
+
droppedNoMatch++;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (!dec.embedding || dec.embedding.length === 0) {
|
|
223
|
+
droppedNoEmbedding++;
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
// scores map: prefer the outcome's full per-model map (set by callers who
|
|
227
|
+
// ran multi-model comparisons); fall back to a single-model entry derived
|
|
228
|
+
// from the model the decision actually dispatched.
|
|
229
|
+
const scores = out.scores
|
|
230
|
+
?? { [dec.openrouter_model ?? dec.model]: out.quality };
|
|
231
|
+
const tier = tierFromComplexity(dec.complexity);
|
|
232
|
+
const source = out.source ?? 'unknown';
|
|
233
|
+
pairs.push({
|
|
234
|
+
task: dec.task,
|
|
235
|
+
embedding: dec.embedding,
|
|
236
|
+
scores,
|
|
237
|
+
tier,
|
|
238
|
+
source,
|
|
239
|
+
ts: out.ts,
|
|
240
|
+
});
|
|
241
|
+
bySource[source] = (bySource[source] ?? 0) + 1;
|
|
242
|
+
byTier[tier] = (byTier[tier] ?? 0) + 1;
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
pairs,
|
|
246
|
+
stats: {
|
|
247
|
+
totalRows: rows.length,
|
|
248
|
+
decisions: dCount,
|
|
249
|
+
outcomes: oCount,
|
|
250
|
+
paired: pairs.length,
|
|
251
|
+
droppedNoEmbedding,
|
|
252
|
+
droppedNoMatch,
|
|
253
|
+
bySource,
|
|
254
|
+
byTier,
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/** Test seam — reset cached config so unit tests can change env vars between cases. */
|
|
259
|
+
export function __resetTrajectoryRecorderForTests() {
|
|
260
|
+
_cfg = null;
|
|
261
|
+
_cachedSize = -1;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Unified status for BOTH the routing-decision recorder (this module) and the
|
|
265
|
+
* companion run-transcript recorder (the weight-eft capture path). The
|
|
266
|
+
* run-transcript recorder is loaded dynamically so this module has no static
|
|
267
|
+
* dependency on it (the reverse edge — run-transcript-recorder → taskHash —
|
|
268
|
+
* is the only static link, keeping the import acyclic).
|
|
269
|
+
*/
|
|
270
|
+
export async function unifiedRecorderStatus() {
|
|
271
|
+
const routerTrajectory = trajectoryRecorderStatus();
|
|
272
|
+
try {
|
|
273
|
+
const mod = await import('./run-transcript-recorder.js');
|
|
274
|
+
const s = mod.runTranscriptRecorderStatus();
|
|
275
|
+
return { routerTrajectory, runTranscripts: { enabled: s.enabled, path: s.path } };
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
return { routerTrajectory, runTranscripts: { unavailable: true } };
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
//# sourceMappingURL=router-trajectory.js.map
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* run-transcript-recorder.ts — Opt-in FULL run-transcript recorder for the
|
|
3
|
+
* weight-eft training-data export path (agenticow / ADR-150 weight-eft slice).
|
|
4
|
+
*
|
|
5
|
+
* WHY THIS EXISTS
|
|
6
|
+
* ---------------
|
|
7
|
+
* The existing `router-trajectory.ts` recorder captures only the ROUTING
|
|
8
|
+
* DECISION for a task: task text, embedding, scalar quality, tokens, cost.
|
|
9
|
+
* `@metaharness/weight-eft` needs something the routing recorder never had —
|
|
10
|
+
* the full ReAct message TRANSCRIPT, the produced patch, and a resolved
|
|
11
|
+
* boolean — to build SFT/DPO training rows. This module is that missing
|
|
12
|
+
* capture surface. It writes one JSON-line per completed run to
|
|
13
|
+
* `.swarm/run-transcripts.jsonl`, in a shape the archive-builder in
|
|
14
|
+
* `services/weight-eft.ts` maps directly to `DarwinTrajectory[]`.
|
|
15
|
+
*
|
|
16
|
+
* OFF BY DEFAULT (PII / RETENTION SURFACE)
|
|
17
|
+
* ----------------------------------------
|
|
18
|
+
* Rows carry the FULL prompt + assistant transcript + patch — a much larger
|
|
19
|
+
* PII/retention surface than the routing recorder. Mirroring why
|
|
20
|
+
* router-trajectory.ts is off-by-default, every write goes through the
|
|
21
|
+
* `CLAUDE_FLOW_RUN_TRANSCRIPTS=1` env gate. When unset (the default),
|
|
22
|
+
* `recordRunTranscript()` is a no-op. There is no way to enable it implicitly.
|
|
23
|
+
*
|
|
24
|
+
* HONESTY: `resolved` IS A PROXY
|
|
25
|
+
* ------------------------------
|
|
26
|
+
* `DarwinTrajectory.resolved` is meant to be GOLD-resolved status from the
|
|
27
|
+
* official SWE-bench harness. Ruflo has NO SWE-bench oracle. Every record
|
|
28
|
+
* therefore stamps `resolved_source` describing where the boolean actually
|
|
29
|
+
* came from, so no downstream consumer can mistake a proxy for gold:
|
|
30
|
+
* - 'gold-oracle' — a real conformant gold eval supplied it (never
|
|
31
|
+
* ruflo today; reserved for an external caller)
|
|
32
|
+
* - 'output-verifier' — ruflo's structural output-verifier confidence,
|
|
33
|
+
* thresholded — an EXPLICIT proxy
|
|
34
|
+
* - 'api-success' — the model returned without an API error — the
|
|
35
|
+
* weakest proxy (says nothing about correctness)
|
|
36
|
+
* - 'external' — supplied verbatim by the caller, provenance unknown
|
|
37
|
+
*
|
|
38
|
+
* ARCHITECTURAL CONSTRAINTS (mirror router-trajectory.ts / ADR-150)
|
|
39
|
+
* -----------------------------------------------------------------
|
|
40
|
+
* 1. OPT-IN — gated behind CLAUDE_FLOW_RUN_TRANSCRIPTS=1; default off.
|
|
41
|
+
* 2. NEVER THROWS — every fs op is try/caught at the append boundary; a
|
|
42
|
+
* failed write is silent (DEBUG-logged) and never breaks the run.
|
|
43
|
+
* 3. NO metaharness COUPLING — this module imports nothing from
|
|
44
|
+
* `@metaharness/*`; it only defines a portable record shape. The
|
|
45
|
+
* services/weight-eft.ts archive-builder does the (optional) mapping.
|
|
46
|
+
*
|
|
47
|
+
* SCHEMA (versioned, additive) — one JSONL row per completed run:
|
|
48
|
+
* { v, ts, instance_id, task_hash, model, tier, resolved, resolved_source,
|
|
49
|
+
* messages[], model_patch, sample?, source?, tokens?, cost_usd? }
|
|
50
|
+
*
|
|
51
|
+
* @module run-transcript-recorder
|
|
52
|
+
*/
|
|
53
|
+
/** An OpenAI-style tool call (the ReAct action). Mirrors weight-eft's ToolCall. */
|
|
54
|
+
export interface ToolCallLite {
|
|
55
|
+
id: string;
|
|
56
|
+
type: 'function';
|
|
57
|
+
function: {
|
|
58
|
+
name: string;
|
|
59
|
+
arguments: string;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** A chat message in an OpenAI-compatible transcript. Mirrors weight-eft's ChatMessage. */
|
|
63
|
+
export interface ChatMessageLite {
|
|
64
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
65
|
+
content: string | null;
|
|
66
|
+
tool_calls?: ToolCallLite[];
|
|
67
|
+
tool_call_id?: string;
|
|
68
|
+
name?: string;
|
|
69
|
+
}
|
|
70
|
+
/** Where a `resolved` boolean actually came from (never silently "gold"). */
|
|
71
|
+
export type ResolvedSource = 'gold-oracle' | 'output-verifier' | 'api-success' | 'external';
|
|
72
|
+
/** Ruflo's cascade tier. haiku → 'cheap' (first tier), sonnet/opus → 'frontier'. */
|
|
73
|
+
export type RunTier = 'cheap' | 'frontier';
|
|
74
|
+
/** One persisted run transcript. Maps 1:1 to a DarwinTrajectory (+ provenance). */
|
|
75
|
+
export interface RunTranscriptRecord {
|
|
76
|
+
v: 1;
|
|
77
|
+
ts: string;
|
|
78
|
+
instance_id: string;
|
|
79
|
+
task_hash: string;
|
|
80
|
+
model: string;
|
|
81
|
+
tier: RunTier;
|
|
82
|
+
resolved: boolean;
|
|
83
|
+
resolved_source: ResolvedSource;
|
|
84
|
+
messages: ChatMessageLite[];
|
|
85
|
+
model_patch: string;
|
|
86
|
+
sample?: number;
|
|
87
|
+
source?: string;
|
|
88
|
+
tokens?: {
|
|
89
|
+
input: number;
|
|
90
|
+
output: number;
|
|
91
|
+
};
|
|
92
|
+
cost_usd?: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Record one completed run transcript. Cheap — a single appendFileSync of a
|
|
96
|
+
* JSONL row. No-op when CLAUDE_FLOW_RUN_TRANSCRIPTS is unset (the default).
|
|
97
|
+
* Never throws.
|
|
98
|
+
*
|
|
99
|
+
* `resolvedSource` is REQUIRED so a proxy can never masquerade as gold. If you
|
|
100
|
+
* only have "the API returned", pass 'api-success' — the honest weakest label.
|
|
101
|
+
*/
|
|
102
|
+
export declare function recordRunTranscript(args: {
|
|
103
|
+
/** Task/issue text — used for the FNV hash + default instance id. */
|
|
104
|
+
task: string;
|
|
105
|
+
/** Concrete model id that produced the run (e.g. "claude-haiku-4"). */
|
|
106
|
+
model: string;
|
|
107
|
+
/** Ruflo cascade tier of `model`. */
|
|
108
|
+
tier: RunTier;
|
|
109
|
+
/** The resolved boolean (see resolvedSource for what it actually means). */
|
|
110
|
+
resolved: boolean;
|
|
111
|
+
/** Provenance of `resolved`. Never omit — honesty is the point. */
|
|
112
|
+
resolvedSource: ResolvedSource;
|
|
113
|
+
/** OpenAI-shaped message transcript (system/user/assistant/tool). */
|
|
114
|
+
messages: ChatMessageLite[];
|
|
115
|
+
/** Unified diff the run produced. '' when the path produces no patch. */
|
|
116
|
+
modelPatch?: string;
|
|
117
|
+
/** Override the default "run-<hash>" instance id (contamination key). */
|
|
118
|
+
instanceId?: string;
|
|
119
|
+
/** Best-of-N sample index on the same instance (default 0). */
|
|
120
|
+
sample?: number;
|
|
121
|
+
/** Provenance tag, e.g. "agent-execute", "autopilot". */
|
|
122
|
+
source?: string;
|
|
123
|
+
tokens?: {
|
|
124
|
+
input: number;
|
|
125
|
+
output: number;
|
|
126
|
+
};
|
|
127
|
+
costUsd?: number;
|
|
128
|
+
}): {
|
|
129
|
+
recorded: boolean;
|
|
130
|
+
instanceId: string;
|
|
131
|
+
taskHash: string;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Read + parse the run-transcript JSONL back into records. Used by the
|
|
135
|
+
* archive-builder (`services/weight-eft.ts`). Malformed lines are skipped and
|
|
136
|
+
* counted, never thrown. Returns `[]` if the file is absent.
|
|
137
|
+
*/
|
|
138
|
+
export declare function readRunTranscripts(path?: string): {
|
|
139
|
+
records: RunTranscriptRecord[];
|
|
140
|
+
malformed: number;
|
|
141
|
+
path: string;
|
|
142
|
+
};
|
|
143
|
+
/** Map a ruflo model tier label to the weight-eft policy tier. */
|
|
144
|
+
export declare function tierForModel(model: string | undefined): RunTier;
|
|
145
|
+
/** Diagnostic for status/CLI. */
|
|
146
|
+
export declare function runTranscriptRecorderStatus(): {
|
|
147
|
+
enabled: boolean;
|
|
148
|
+
path: string;
|
|
149
|
+
maxSizeBytes: number;
|
|
150
|
+
maxRotations: number;
|
|
151
|
+
};
|
|
152
|
+
/** @internal — test seam: reset cached config so tests can flip env vars. */
|
|
153
|
+
export declare function __resetRunTranscriptRecorderForTests(): void;
|
|
154
|
+
//# sourceMappingURL=run-transcript-recorder.d.ts.map
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* run-transcript-recorder.ts — Opt-in FULL run-transcript recorder for the
|
|
3
|
+
* weight-eft training-data export path (agenticow / ADR-150 weight-eft slice).
|
|
4
|
+
*
|
|
5
|
+
* WHY THIS EXISTS
|
|
6
|
+
* ---------------
|
|
7
|
+
* The existing `router-trajectory.ts` recorder captures only the ROUTING
|
|
8
|
+
* DECISION for a task: task text, embedding, scalar quality, tokens, cost.
|
|
9
|
+
* `@metaharness/weight-eft` needs something the routing recorder never had —
|
|
10
|
+
* the full ReAct message TRANSCRIPT, the produced patch, and a resolved
|
|
11
|
+
* boolean — to build SFT/DPO training rows. This module is that missing
|
|
12
|
+
* capture surface. It writes one JSON-line per completed run to
|
|
13
|
+
* `.swarm/run-transcripts.jsonl`, in a shape the archive-builder in
|
|
14
|
+
* `services/weight-eft.ts` maps directly to `DarwinTrajectory[]`.
|
|
15
|
+
*
|
|
16
|
+
* OFF BY DEFAULT (PII / RETENTION SURFACE)
|
|
17
|
+
* ----------------------------------------
|
|
18
|
+
* Rows carry the FULL prompt + assistant transcript + patch — a much larger
|
|
19
|
+
* PII/retention surface than the routing recorder. Mirroring why
|
|
20
|
+
* router-trajectory.ts is off-by-default, every write goes through the
|
|
21
|
+
* `CLAUDE_FLOW_RUN_TRANSCRIPTS=1` env gate. When unset (the default),
|
|
22
|
+
* `recordRunTranscript()` is a no-op. There is no way to enable it implicitly.
|
|
23
|
+
*
|
|
24
|
+
* HONESTY: `resolved` IS A PROXY
|
|
25
|
+
* ------------------------------
|
|
26
|
+
* `DarwinTrajectory.resolved` is meant to be GOLD-resolved status from the
|
|
27
|
+
* official SWE-bench harness. Ruflo has NO SWE-bench oracle. Every record
|
|
28
|
+
* therefore stamps `resolved_source` describing where the boolean actually
|
|
29
|
+
* came from, so no downstream consumer can mistake a proxy for gold:
|
|
30
|
+
* - 'gold-oracle' — a real conformant gold eval supplied it (never
|
|
31
|
+
* ruflo today; reserved for an external caller)
|
|
32
|
+
* - 'output-verifier' — ruflo's structural output-verifier confidence,
|
|
33
|
+
* thresholded — an EXPLICIT proxy
|
|
34
|
+
* - 'api-success' — the model returned without an API error — the
|
|
35
|
+
* weakest proxy (says nothing about correctness)
|
|
36
|
+
* - 'external' — supplied verbatim by the caller, provenance unknown
|
|
37
|
+
*
|
|
38
|
+
* ARCHITECTURAL CONSTRAINTS (mirror router-trajectory.ts / ADR-150)
|
|
39
|
+
* -----------------------------------------------------------------
|
|
40
|
+
* 1. OPT-IN — gated behind CLAUDE_FLOW_RUN_TRANSCRIPTS=1; default off.
|
|
41
|
+
* 2. NEVER THROWS — every fs op is try/caught at the append boundary; a
|
|
42
|
+
* failed write is silent (DEBUG-logged) and never breaks the run.
|
|
43
|
+
* 3. NO metaharness COUPLING — this module imports nothing from
|
|
44
|
+
* `@metaharness/*`; it only defines a portable record shape. The
|
|
45
|
+
* services/weight-eft.ts archive-builder does the (optional) mapping.
|
|
46
|
+
*
|
|
47
|
+
* SCHEMA (versioned, additive) — one JSONL row per completed run:
|
|
48
|
+
* { v, ts, instance_id, task_hash, model, tier, resolved, resolved_source,
|
|
49
|
+
* messages[], model_patch, sample?, source?, tokens?, cost_usd? }
|
|
50
|
+
*
|
|
51
|
+
* @module run-transcript-recorder
|
|
52
|
+
*/
|
|
53
|
+
import { appendFileSync, mkdirSync, existsSync, statSync, renameSync, unlinkSync, readFileSync } from 'node:fs';
|
|
54
|
+
import { dirname, join, resolve as resolvePath } from 'node:path';
|
|
55
|
+
import { taskHash } from './router-trajectory.js';
|
|
56
|
+
let _cfg = null;
|
|
57
|
+
let _cachedSize = -1;
|
|
58
|
+
function getConfig() {
|
|
59
|
+
if (_cfg !== null)
|
|
60
|
+
return _cfg;
|
|
61
|
+
const swarmDir = process.env.CLAUDE_FLOW_SWARM_DIR ?? resolvePath(process.cwd(), '.swarm');
|
|
62
|
+
_cfg = {
|
|
63
|
+
enabled: process.env.CLAUDE_FLOW_RUN_TRANSCRIPTS === '1',
|
|
64
|
+
path: process.env.CLAUDE_FLOW_RUN_TRANSCRIPTS_PATH ?? join(swarmDir, 'run-transcripts.jsonl'),
|
|
65
|
+
maxSizeBytes: parseInt(process.env.CLAUDE_FLOW_RUN_TRANSCRIPTS_MAXSIZE ?? `${25 * 1024 * 1024}`, 10) | 0,
|
|
66
|
+
maxRotations: Math.max(0, parseInt(process.env.CLAUDE_FLOW_RUN_TRANSCRIPTS_MAXROTATIONS ?? '3', 10) || 3),
|
|
67
|
+
};
|
|
68
|
+
return _cfg;
|
|
69
|
+
}
|
|
70
|
+
function rotate(cfg) {
|
|
71
|
+
if (!existsSync(cfg.path))
|
|
72
|
+
return;
|
|
73
|
+
try {
|
|
74
|
+
if (cfg.maxRotations === 0) {
|
|
75
|
+
unlinkSync(cfg.path);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const oldest = `${cfg.path}.${cfg.maxRotations}`;
|
|
79
|
+
if (existsSync(oldest))
|
|
80
|
+
unlinkSync(oldest);
|
|
81
|
+
for (let i = cfg.maxRotations - 1; i >= 1; i--) {
|
|
82
|
+
const src = `${cfg.path}.${i}`;
|
|
83
|
+
if (existsSync(src))
|
|
84
|
+
renameSync(src, `${cfg.path}.${i + 1}`);
|
|
85
|
+
}
|
|
86
|
+
renameSync(cfg.path, `${cfg.path}.1`);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
try {
|
|
90
|
+
unlinkSync(cfg.path);
|
|
91
|
+
}
|
|
92
|
+
catch { /* */ }
|
|
93
|
+
}
|
|
94
|
+
_cachedSize = 0;
|
|
95
|
+
}
|
|
96
|
+
function appendRow(row) {
|
|
97
|
+
const cfg = getConfig();
|
|
98
|
+
if (!cfg.enabled)
|
|
99
|
+
return;
|
|
100
|
+
try {
|
|
101
|
+
const dir = dirname(cfg.path);
|
|
102
|
+
if (!existsSync(dir))
|
|
103
|
+
mkdirSync(dir, { recursive: true });
|
|
104
|
+
if (_cachedSize < 0) {
|
|
105
|
+
_cachedSize = existsSync(cfg.path) ? statSync(cfg.path).size : 0;
|
|
106
|
+
}
|
|
107
|
+
const line = JSON.stringify(row) + '\n';
|
|
108
|
+
const bytes = Buffer.byteLength(line, 'utf8');
|
|
109
|
+
if (cfg.maxSizeBytes > 0 && _cachedSize + bytes > cfg.maxSizeBytes)
|
|
110
|
+
rotate(cfg);
|
|
111
|
+
appendFileSync(cfg.path, line);
|
|
112
|
+
_cachedSize += bytes;
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
if (process.env.DEBUG) {
|
|
116
|
+
// eslint-disable-next-line no-console
|
|
117
|
+
console.error('run-transcript: appendRow failed:', e.message);
|
|
118
|
+
}
|
|
119
|
+
// Never throw — transcript collection must never break a run.
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// ============================================================================
|
|
123
|
+
// Public API
|
|
124
|
+
// ============================================================================
|
|
125
|
+
/**
|
|
126
|
+
* Record one completed run transcript. Cheap — a single appendFileSync of a
|
|
127
|
+
* JSONL row. No-op when CLAUDE_FLOW_RUN_TRANSCRIPTS is unset (the default).
|
|
128
|
+
* Never throws.
|
|
129
|
+
*
|
|
130
|
+
* `resolvedSource` is REQUIRED so a proxy can never masquerade as gold. If you
|
|
131
|
+
* only have "the API returned", pass 'api-success' — the honest weakest label.
|
|
132
|
+
*/
|
|
133
|
+
export function recordRunTranscript(args) {
|
|
134
|
+
const cfg = getConfig();
|
|
135
|
+
const hash = taskHash(args.task);
|
|
136
|
+
const instanceId = args.instanceId ?? `run-${hash}`;
|
|
137
|
+
if (!cfg.enabled)
|
|
138
|
+
return { recorded: false, instanceId, taskHash: hash };
|
|
139
|
+
const row = {
|
|
140
|
+
v: 1,
|
|
141
|
+
ts: new Date().toISOString(),
|
|
142
|
+
instance_id: instanceId,
|
|
143
|
+
task_hash: hash,
|
|
144
|
+
model: args.model,
|
|
145
|
+
tier: args.tier,
|
|
146
|
+
resolved: args.resolved,
|
|
147
|
+
resolved_source: args.resolvedSource,
|
|
148
|
+
messages: args.messages,
|
|
149
|
+
model_patch: args.modelPatch ?? '',
|
|
150
|
+
...(args.sample !== undefined ? { sample: args.sample } : {}),
|
|
151
|
+
...(args.source ? { source: args.source } : {}),
|
|
152
|
+
...(args.tokens ? { tokens: args.tokens } : {}),
|
|
153
|
+
...(args.costUsd != null ? { cost_usd: args.costUsd } : {}),
|
|
154
|
+
};
|
|
155
|
+
appendRow(row);
|
|
156
|
+
return { recorded: true, instanceId, taskHash: hash };
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Read + parse the run-transcript JSONL back into records. Used by the
|
|
160
|
+
* archive-builder (`services/weight-eft.ts`). Malformed lines are skipped and
|
|
161
|
+
* counted, never thrown. Returns `[]` if the file is absent.
|
|
162
|
+
*/
|
|
163
|
+
export function readRunTranscripts(path) {
|
|
164
|
+
const p = path ?? getConfig().path;
|
|
165
|
+
if (!existsSync(p))
|
|
166
|
+
return { records: [], malformed: 0, path: p };
|
|
167
|
+
const records = [];
|
|
168
|
+
let malformed = 0;
|
|
169
|
+
try {
|
|
170
|
+
for (const line of readFileSync(p, 'utf8').split('\n')) {
|
|
171
|
+
if (!line.trim())
|
|
172
|
+
continue;
|
|
173
|
+
try {
|
|
174
|
+
const r = JSON.parse(line);
|
|
175
|
+
if (r && typeof r === 'object' && r.v === 1 && r.instance_id && Array.isArray(r.messages)) {
|
|
176
|
+
records.push(r);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
malformed++;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
malformed++;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
// unreadable file — treat as empty, never throw
|
|
189
|
+
}
|
|
190
|
+
return { records, malformed, path: p };
|
|
191
|
+
}
|
|
192
|
+
/** Map a ruflo model tier label to the weight-eft policy tier. */
|
|
193
|
+
export function tierForModel(model) {
|
|
194
|
+
// haiku (and any explicitly-cheap label) → 'cheap' (cascade first tier).
|
|
195
|
+
// sonnet / opus / everything else → 'frontier' (the escalation tier).
|
|
196
|
+
if (!model)
|
|
197
|
+
return 'frontier';
|
|
198
|
+
return /haiku/i.test(model) ? 'cheap' : 'frontier';
|
|
199
|
+
}
|
|
200
|
+
/** Diagnostic for status/CLI. */
|
|
201
|
+
export function runTranscriptRecorderStatus() {
|
|
202
|
+
return { ...getConfig() };
|
|
203
|
+
}
|
|
204
|
+
/** @internal — test seam: reset cached config so tests can flip env vars. */
|
|
205
|
+
export function __resetRunTranscriptRecorderForTests() {
|
|
206
|
+
_cfg = null;
|
|
207
|
+
_cachedSize = -1;
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=run-transcript-recorder.js.map
|