monomind 1.11.13 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/generated/channel-intelligence-director.md +87 -0
- package/.claude/agents/generated/chief-growth-officer.md +88 -0
- package/.claude/agents/generated/content-seo-strategist.md +90 -0
- package/.claude/agents/generated/developer-community-strategist.md +91 -0
- package/.claude/agents/generated/outreach-partnership-strategist.md +90 -0
- package/.claude/agents/generated/social-media-strategist.md +91 -0
- package/.claude/agents/generated/video-visual-strategist.md +90 -0
- package/.claude/commands/mastermind/idea.md +1 -1
- package/.claude/helpers/auto-memory-hook.mjs +13 -4
- package/.claude/helpers/control-start.cjs +5 -0
- package/.claude/helpers/event-logger.cjs +114 -0
- package/.claude/helpers/handlers/adr-draft-handler.cjs +19 -5
- package/.claude/helpers/handlers/agent-start-handler.cjs +13 -4
- package/.claude/helpers/handlers/compact-handler.cjs +2 -0
- package/.claude/helpers/handlers/edit-handler.cjs +1 -1
- package/.claude/helpers/handlers/gates-handler.cjs +3 -0
- package/.claude/helpers/handlers/graph-status-handler.cjs +14 -8
- package/.claude/helpers/handlers/loops-status-handler.cjs +5 -2
- package/.claude/helpers/handlers/route-handler.cjs +13 -6
- package/.claude/helpers/handlers/session-handler.cjs +11 -4
- package/.claude/helpers/handlers/session-restore-handler.cjs +21 -11
- package/.claude/helpers/handlers/task-handler.cjs +13 -5
- package/.claude/helpers/intelligence.cjs +7 -2
- package/.claude/helpers/loop-tracker.cjs +15 -3
- package/.claude/helpers/memory.cjs +6 -1
- package/.claude/helpers/router.cjs +5 -2
- package/.claude/helpers/session.cjs +2 -0
- package/.claude/helpers/statusline.cjs +10 -2
- package/.claude/helpers/utils/micro-agents.cjs +20 -4
- package/.claude/scheduled_tasks.lock +1 -1
- package/.claude/settings.json +92 -1
- package/.claude/skills/mastermind/_protocol.md +23 -13
- package/.claude/skills/mastermind/architect.md +6 -9
- package/.claude/skills/mastermind/build.md +3 -3
- package/.claude/skills/mastermind/content.md +3 -3
- package/.claude/skills/mastermind/createorg.md +2 -2
- package/.claude/skills/mastermind/finance.md +3 -3
- package/.claude/skills/mastermind/idea.md +5 -3
- package/.claude/skills/mastermind/marketing.md +3 -3
- package/.claude/skills/mastermind/monitor.md +2 -2
- package/.claude/skills/mastermind/release.md +3 -3
- package/.claude/skills/mastermind/research.md +3 -3
- package/.claude/skills/mastermind/review.md +3 -3
- package/.claude/skills/mastermind/runorg.md +153 -86
- package/.claude/skills/mastermind/sales.md +3 -3
- package/README.md +286 -129
- package/package.json +19 -2
- package/packages/@monomind/cli/README.md +286 -129
- package/packages/@monomind/cli/bundled-graph/dist/src/build.js +73 -0
- package/packages/@monomind/cli/bundled-graph/dist/src/cluster.js +120 -0
- package/packages/@monomind/cli/bundled-graph/package.json +57 -0
- package/packages/@monomind/cli/dist/src/agents/halt-signal.d.ts +25 -0
- package/packages/@monomind/cli/dist/src/agents/halt-signal.js +76 -0
- package/packages/@monomind/cli/dist/src/agents/index.d.ts +18 -0
- package/packages/@monomind/cli/dist/src/agents/index.js +13 -0
- package/packages/@monomind/cli/dist/src/agents/managed-agent.d.ts +41 -0
- package/packages/@monomind/cli/dist/src/agents/managed-agent.js +69 -0
- package/packages/@monomind/cli/dist/src/agents/prompt-experiment.d.ts +23 -0
- package/packages/@monomind/cli/dist/src/agents/prompt-experiment.js +49 -0
- package/packages/@monomind/cli/dist/src/agents/prompt-version-manager.d.ts +22 -0
- package/packages/@monomind/cli/dist/src/agents/prompt-version-manager.js +80 -0
- package/packages/@monomind/cli/dist/src/agents/registry-builder.js +2 -0
- package/packages/@monomind/cli/dist/src/agents/registry-query.d.ts +71 -0
- package/packages/@monomind/cli/dist/src/agents/registry-query.js +125 -0
- package/packages/@monomind/cli/dist/src/agents/score-decay.d.ts +19 -0
- package/packages/@monomind/cli/dist/src/agents/score-decay.js +22 -0
- package/packages/@monomind/cli/dist/src/agents/shared-instructions-loader.d.ts +13 -0
- package/packages/@monomind/cli/dist/src/agents/shared-instructions-loader.js +40 -0
- package/packages/@monomind/cli/dist/src/agents/specialization-scorer.d.ts +54 -0
- package/packages/@monomind/cli/dist/src/agents/specialization-scorer.js +212 -0
- package/packages/@monomind/cli/dist/src/agents/termination-watcher.d.ts +30 -0
- package/packages/@monomind/cli/dist/src/agents/termination-watcher.js +84 -0
- package/packages/@monomind/cli/dist/src/agents/trigger-index.d.ts +20 -0
- package/packages/@monomind/cli/dist/src/agents/trigger-index.js +38 -0
- package/packages/@monomind/cli/dist/src/agents/trigger-scanner.d.ts +64 -0
- package/packages/@monomind/cli/dist/src/agents/trigger-scanner.js +308 -0
- package/packages/@monomind/cli/dist/src/agents/version-diff.d.ts +18 -0
- package/packages/@monomind/cli/dist/src/agents/version-diff.js +64 -0
- package/packages/@monomind/cli/dist/src/agents/version-store.d.ts +60 -0
- package/packages/@monomind/cli/dist/src/agents/version-store.js +235 -0
- package/packages/@monomind/cli/dist/src/autopilot-state.js +10 -5
- package/packages/@monomind/cli/dist/src/benchmarks/benchmark-runner.js +13 -0
- package/packages/@monomind/cli/dist/src/benchmarks/metric-evaluators.js +20 -9
- package/packages/@monomind/cli/dist/src/benchmarks/pretrain/index.d.ts +45 -0
- package/packages/@monomind/cli/dist/src/benchmarks/pretrain/index.js +404 -0
- package/packages/@monomind/cli/dist/src/browser/actions.js +10 -3
- package/packages/@monomind/cli/dist/src/browser/browser.js +12 -2
- package/packages/@monomind/cli/dist/src/browser/cdp.js +21 -3
- package/packages/@monomind/cli/dist/src/browser/har.js +27 -5
- package/packages/@monomind/cli/dist/src/commands/agent-wasm.d.ts +14 -0
- package/packages/@monomind/cli/dist/src/commands/agent-wasm.js +333 -0
- package/packages/@monomind/cli/dist/src/commands/agent.js +11 -8
- package/packages/@monomind/cli/dist/src/commands/analyze.js +36 -21
- package/packages/@monomind/cli/dist/src/commands/autopilot.js +12 -4
- package/packages/@monomind/cli/dist/src/commands/benchmark.js +51 -8
- package/packages/@monomind/cli/dist/src/commands/browse.js +5 -2
- package/packages/@monomind/cli/dist/src/commands/claims.js +29 -11
- package/packages/@monomind/cli/dist/src/commands/cleanup.js +25 -5
- package/packages/@monomind/cli/dist/src/commands/config.js +15 -7
- package/packages/@monomind/cli/dist/src/commands/daemon.js +6 -0
- package/packages/@monomind/cli/dist/src/commands/deployment.js +34 -19
- package/packages/@monomind/cli/dist/src/commands/doctor.js +151 -20
- package/packages/@monomind/cli/dist/src/commands/guidance.js +15 -2
- package/packages/@monomind/cli/dist/src/commands/hive-mind.js +37 -14
- package/packages/@monomind/cli/dist/src/commands/hooks.js +42 -25
- package/packages/@monomind/cli/dist/src/commands/init.js +9 -4
- package/packages/@monomind/cli/dist/src/commands/issues.js +29 -26
- package/packages/@monomind/cli/dist/src/commands/mcp.js +11 -5
- package/packages/@monomind/cli/dist/src/commands/memory.js +10 -0
- package/packages/@monomind/cli/dist/src/commands/migrate.js +5 -5
- package/packages/@monomind/cli/dist/src/commands/monograph.js +18 -5
- package/packages/@monomind/cli/dist/src/commands/monovector/backup.js +8 -2
- package/packages/@monomind/cli/dist/src/commands/monovector/benchmark.js +20 -7
- package/packages/@monomind/cli/dist/src/commands/monovector/import.js +15 -0
- package/packages/@monomind/cli/dist/src/commands/monovector/migrate.js +4 -1
- package/packages/@monomind/cli/dist/src/commands/monovector/optimize.js +11 -0
- package/packages/@monomind/cli/dist/src/commands/monovector/setup.js +11 -1
- package/packages/@monomind/cli/dist/src/commands/neural.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/performance.js +20 -7
- package/packages/@monomind/cli/dist/src/commands/platforms.js +90 -8
- package/packages/@monomind/cli/dist/src/commands/plugins.js +12 -5
- package/packages/@monomind/cli/dist/src/commands/process.js +33 -10
- package/packages/@monomind/cli/dist/src/commands/progress.js +5 -3
- package/packages/@monomind/cli/dist/src/commands/providers.js +5 -5
- package/packages/@monomind/cli/dist/src/commands/replay.js +8 -2
- package/packages/@monomind/cli/dist/src/commands/route.js +27 -7
- package/packages/@monomind/cli/dist/src/commands/security.js +4 -0
- package/packages/@monomind/cli/dist/src/commands/session.js +12 -1
- package/packages/@monomind/cli/dist/src/commands/start.js +11 -4
- package/packages/@monomind/cli/dist/src/commands/status.js +7 -4
- package/packages/@monomind/cli/dist/src/commands/swarm.js +27 -13
- package/packages/@monomind/cli/dist/src/commands/task.js +26 -11
- package/packages/@monomind/cli/dist/src/commands/tokens.js +7 -2
- package/packages/@monomind/cli/dist/src/commands/transfer-store.js +36 -22
- package/packages/@monomind/cli/dist/src/commands/ui.js +68 -0
- package/packages/@monomind/cli/dist/src/commands/update.js +15 -3
- package/packages/@monomind/cli/dist/src/commands/workflow.js +39 -6
- package/packages/@monomind/cli/dist/src/consensus/audit-writer.js +18 -7
- package/packages/@monomind/cli/dist/src/consensus/index.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/consensus/index.js +6 -0
- package/packages/@monomind/cli/dist/src/consensus/vote-signer.js +25 -8
- package/packages/@monomind/cli/dist/src/context/context-provider.d.ts +44 -0
- package/packages/@monomind/cli/dist/src/context/context-provider.js +25 -0
- package/packages/@monomind/cli/dist/src/context/git-state-provider.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/context/git-state-provider.js +34 -0
- package/packages/@monomind/cli/dist/src/context/index.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/context/index.js +12 -0
- package/packages/@monomind/cli/dist/src/context/project-conventions-provider.d.ts +15 -0
- package/packages/@monomind/cli/dist/src/context/project-conventions-provider.js +19 -0
- package/packages/@monomind/cli/dist/src/context/prompt-assembler.d.ts +26 -0
- package/packages/@monomind/cli/dist/src/context/prompt-assembler.js +93 -0
- package/packages/@monomind/cli/dist/src/context/task-history-provider.d.ts +24 -0
- package/packages/@monomind/cli/dist/src/context/task-history-provider.js +32 -0
- package/packages/@monomind/cli/dist/src/context/user-preferences-provider.d.ts +14 -0
- package/packages/@monomind/cli/dist/src/context/user-preferences-provider.js +27 -0
- package/packages/@monomind/cli/dist/src/dlq/dlq-reader.d.ts +31 -0
- package/packages/@monomind/cli/dist/src/dlq/dlq-reader.js +81 -0
- package/packages/@monomind/cli/dist/src/dlq/dlq-writer.d.ts +24 -0
- package/packages/@monomind/cli/dist/src/dlq/dlq-writer.js +65 -0
- package/packages/@monomind/cli/dist/src/dlq/index.d.ts +10 -0
- package/packages/@monomind/cli/dist/src/dlq/index.js +7 -0
- package/packages/@monomind/cli/dist/src/eval/dataset-manager.d.ts +33 -0
- package/packages/@monomind/cli/dist/src/eval/dataset-manager.js +107 -0
- package/packages/@monomind/cli/dist/src/eval/dataset-runner.d.ts +23 -0
- package/packages/@monomind/cli/dist/src/eval/dataset-runner.js +59 -0
- package/packages/@monomind/cli/dist/src/eval/index.d.ts +10 -0
- package/packages/@monomind/cli/dist/src/eval/index.js +7 -0
- package/packages/@monomind/cli/dist/src/eval/trace-collector.d.ts +40 -0
- package/packages/@monomind/cli/dist/src/eval/trace-collector.js +102 -0
- package/packages/@monomind/cli/dist/src/index.js +7 -3
- package/packages/@monomind/cli/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
- package/packages/@monomind/cli/dist/src/infrastructure/in-memory-repositories.js +264 -0
- package/packages/@monomind/cli/dist/src/init/executor.js +14 -11
- package/packages/@monomind/cli/dist/src/init/shared-instructions-generator.js +20 -4
- package/packages/@monomind/cli/dist/src/init/statusline-generator.js +33 -12
- package/packages/@monomind/cli/dist/src/interactive/interrupt.d.ts +22 -0
- package/packages/@monomind/cli/dist/src/interactive/interrupt.js +71 -0
- package/packages/@monomind/cli/dist/src/mcp/deprecation-injector.d.ts +25 -0
- package/packages/@monomind/cli/dist/src/mcp/deprecation-injector.js +48 -0
- package/packages/@monomind/cli/dist/src/mcp/tool-registry.d.ts +61 -0
- package/packages/@monomind/cli/dist/src/mcp/tool-registry.js +246 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/a2a-tools.js +98 -13
- package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.js +16 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/analyze-tools.js +80 -17
- package/packages/@monomind/cli/dist/src/mcp-tools/browser-tools.js +84 -22
- package/packages/@monomind/cli/dist/src/mcp-tools/claims-tools.js +35 -7
- package/packages/@monomind/cli/dist/src/mcp-tools/config-tools.js +82 -17
- package/packages/@monomind/cli/dist/src/mcp-tools/coordination-tools.js +37 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/daa-tools.js +49 -7
- package/packages/@monomind/cli/dist/src/mcp-tools/embeddings-tools.js +45 -18
- package/packages/@monomind/cli/dist/src/mcp-tools/github-tools.js +75 -25
- package/packages/@monomind/cli/dist/src/mcp-tools/guidance-tools.js +32 -10
- package/packages/@monomind/cli/dist/src/mcp-tools/hive-mind-tools.js +91 -20
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-tools.js +188 -29
- package/packages/@monomind/cli/dist/src/mcp-tools/memory-tools.js +25 -7
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-compat.js +11 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +148 -26
- package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.js +44 -9
- package/packages/@monomind/cli/dist/src/mcp-tools/performance-tools.js +45 -10
- package/packages/@monomind/cli/dist/src/mcp-tools/progress-tools.js +7 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/request-tracker.js +15 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/security-tools.js +61 -9
- package/packages/@monomind/cli/dist/src/mcp-tools/session-tools.js +45 -14
- package/packages/@monomind/cli/dist/src/mcp-tools/swarm-tools.js +15 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/system-tools.js +14 -7
- package/packages/@monomind/cli/dist/src/mcp-tools/task-tools.js +52 -10
- package/packages/@monomind/cli/dist/src/mcp-tools/terminal-tools.js +40 -6
- package/packages/@monomind/cli/dist/src/mcp-tools/transfer-tools.js +37 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/wasm-agent-tools.d.ts +9 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/wasm-agent-tools.js +230 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/workflow-tools.js +29 -6
- package/packages/@monomind/cli/dist/src/memory/ewc-consolidation.js +26 -10
- package/packages/@monomind/cli/dist/src/memory/intelligence.js +80 -19
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +21 -2
- package/packages/@monomind/cli/dist/src/memory/memory-initializer.js +67 -3
- package/packages/@monomind/cli/dist/src/memory/sona-optimizer.js +14 -4
- package/packages/@monomind/cli/dist/src/model/complexity-scorer.d.ts +21 -0
- package/packages/@monomind/cli/dist/src/model/complexity-scorer.js +106 -0
- package/packages/@monomind/cli/dist/src/model/index.d.ts +4 -0
- package/packages/@monomind/cli/dist/src/model/index.js +4 -0
- package/packages/@monomind/cli/dist/src/model/model-settings.d.ts +22 -0
- package/packages/@monomind/cli/dist/src/model/model-settings.js +33 -0
- package/packages/@monomind/cli/dist/src/model/model-tier-resolver.d.ts +24 -0
- package/packages/@monomind/cli/dist/src/model/model-tier-resolver.js +65 -0
- package/packages/@monomind/cli/dist/src/monovector/capabilities.d.ts +34 -0
- package/packages/@monomind/cli/dist/src/monovector/capabilities.js +37 -0
- package/packages/@monomind/cli/dist/src/monovector/command-outcomes.js +43 -7
- package/packages/@monomind/cli/dist/src/monovector/coverage-router.js +8 -4
- package/packages/@monomind/cli/dist/src/monovector/coverage-tools.js +6 -3
- package/packages/@monomind/cli/dist/src/monovector/diff-classifier.js +13 -0
- package/packages/@monomind/cli/dist/src/monovector/route-outcomes.d.ts +2 -1
- package/packages/@monomind/cli/dist/src/monovector/route-outcomes.js +46 -4
- package/packages/@monomind/cli/dist/src/observability/replay-reader.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/orchestration/index.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/orchestration/index.js +6 -0
- package/packages/@monomind/cli/dist/src/orchestration/mode-dispatcher.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/orchestration/mode-dispatcher.js +31 -0
- package/packages/@monomind/cli/dist/src/orchestration/routing-modes.d.ts +68 -0
- package/packages/@monomind/cli/dist/src/orchestration/routing-modes.js +180 -0
- package/packages/@monomind/cli/dist/src/plugins/manager.js +8 -3
- package/packages/@monomind/cli/dist/src/plugins/store/discovery.js +46 -2
- package/packages/@monomind/cli/dist/src/plugins/store/search.js +5 -4
- package/packages/@monomind/cli/dist/src/plugins/tests/demo-plugin-store.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/plugins/tests/demo-plugin-store.js +126 -0
- package/packages/@monomind/cli/dist/src/plugins/tests/standalone-test.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/plugins/tests/standalone-test.js +188 -0
- package/packages/@monomind/cli/dist/src/plugins/tests/test-plugin-store.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/plugins/tests/test-plugin-store.js +206 -0
- package/packages/@monomind/cli/dist/src/production/circuit-breaker.js +17 -3
- package/packages/@monomind/cli/dist/src/production/error-handler.js +3 -0
- package/packages/@monomind/cli/dist/src/production/monitoring.js +20 -3
- package/packages/@monomind/cli/dist/src/production/rate-limiter.js +13 -4
- package/packages/@monomind/cli/dist/src/production/retry.js +17 -9
- package/packages/@monomind/cli/dist/src/routing/embed-worker.js +6 -2
- package/packages/@monomind/cli/dist/src/routing/embedder.js +0 -0
- package/packages/@monomind/cli/dist/src/routing/llm-caller.js +13 -2
- package/packages/@monomind/cli/dist/src/routing/route-layer-factory.js +18 -3
- package/packages/@monomind/cli/dist/src/runtime/headless.d.ts +60 -0
- package/packages/@monomind/cli/dist/src/runtime/headless.js +284 -0
- package/packages/@monomind/cli/dist/src/services/agentic-flow-bridge.d.ts +50 -0
- package/packages/@monomind/cli/dist/src/services/agentic-flow-bridge.js +95 -0
- package/packages/@monomind/cli/dist/src/services/claim-service.d.ts +1 -0
- package/packages/@monomind/cli/dist/src/services/claim-service.js +8 -0
- package/packages/@monomind/cli/dist/src/services/config-file-manager.js +14 -2
- package/packages/@monomind/cli/dist/src/services/container-worker-pool.d.ts +197 -0
- package/packages/@monomind/cli/dist/src/services/container-worker-pool.js +623 -0
- package/packages/@monomind/cli/dist/src/services/headless-worker-executor.js +18 -2
- package/packages/@monomind/cli/dist/src/services/index.d.ts +13 -0
- package/packages/@monomind/cli/dist/src/services/index.js +11 -0
- package/packages/@monomind/cli/dist/src/services/worker-daemon.js +53 -12
- package/packages/@monomind/cli/dist/src/services/worker-queue.d.ts +201 -0
- package/packages/@monomind/cli/dist/src/services/worker-queue.js +594 -0
- package/packages/@monomind/cli/dist/src/swarm/communication-graph.d.ts +25 -0
- package/packages/@monomind/cli/dist/src/swarm/communication-graph.js +77 -0
- package/packages/@monomind/cli/dist/src/swarm/flow-enforcer.d.ts +31 -0
- package/packages/@monomind/cli/dist/src/swarm/flow-enforcer.js +61 -0
- package/packages/@monomind/cli/dist/src/swarm/flow-visualizer.d.ts +19 -0
- package/packages/@monomind/cli/dist/src/swarm/flow-visualizer.js +68 -0
- package/packages/@monomind/cli/dist/src/transfer/anonymization/index.d.ts +0 -3
- package/packages/@monomind/cli/dist/src/transfer/anonymization/index.js +16 -1
- package/packages/@monomind/cli/dist/src/transfer/deploy-seraphine.d.ts +13 -0
- package/packages/@monomind/cli/dist/src/transfer/deploy-seraphine.js +205 -0
- package/packages/@monomind/cli/dist/src/transfer/export.js +8 -0
- package/packages/@monomind/cli/dist/src/transfer/ipfs/upload.js +33 -3
- package/packages/@monomind/cli/dist/src/transfer/serialization/cfp.js +9 -3
- package/packages/@monomind/cli/dist/src/transfer/storage/gcs.js +37 -3
- package/packages/@monomind/cli/dist/src/transfer/store/discovery.js +45 -3
- package/packages/@monomind/cli/dist/src/transfer/store/download.js +5 -0
- package/packages/@monomind/cli/dist/src/transfer/store/publish.js +13 -1
- package/packages/@monomind/cli/dist/src/transfer/store/registry.d.ts +8 -0
- package/packages/@monomind/cli/dist/src/transfer/store/registry.js +30 -5
- package/packages/@monomind/cli/dist/src/transfer/store/search.js +20 -5
- package/packages/@monomind/cli/dist/src/transfer/store/tests/standalone-test.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/transfer/store/tests/standalone-test.js +190 -0
- package/packages/@monomind/cli/dist/src/transfer/test-seraphine.d.ts +6 -0
- package/packages/@monomind/cli/dist/src/transfer/test-seraphine.js +105 -0
- package/packages/@monomind/cli/dist/src/transfer/tests/test-store.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/transfer/tests/test-store.js +214 -0
- package/packages/@monomind/cli/dist/src/update/checker.js +59 -7
- package/packages/@monomind/cli/dist/src/update/executor.js +50 -3
- package/packages/@monomind/cli/dist/src/update/index.js +18 -1
- package/packages/@monomind/cli/dist/src/update/rate-limiter.d.ts +6 -0
- package/packages/@monomind/cli/dist/src/update/rate-limiter.js +79 -7
- package/packages/@monomind/cli/dist/src/update/validator.js +52 -1
- package/packages/@monomind/cli/dist/src/workflow/condition-evaluator.d.ts +10 -0
- package/packages/@monomind/cli/dist/src/workflow/condition-evaluator.js +82 -0
- package/packages/@monomind/cli/dist/src/workflow/context-resolver.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/workflow/context-resolver.js +23 -0
- package/packages/@monomind/cli/dist/src/workflow/dag-builder.d.ts +17 -0
- package/packages/@monomind/cli/dist/src/workflow/dag-builder.js +129 -0
- package/packages/@monomind/cli/dist/src/workflow/dag-executor.d.ts +9 -0
- package/packages/@monomind/cli/dist/src/workflow/dag-executor.js +116 -0
- package/packages/@monomind/cli/dist/src/workflow/dag-types.d.ts +41 -0
- package/packages/@monomind/cli/dist/src/workflow/dag-types.js +8 -0
- package/packages/@monomind/cli/dist/src/workflow/dsl-parser.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/workflow/dsl-parser.js +20 -0
- package/packages/@monomind/cli/dist/src/workflow/dsl-schema.d.ts +165 -0
- package/packages/@monomind/cli/dist/src/workflow/dsl-schema.js +82 -0
- package/packages/@monomind/cli/dist/src/workflow/index.d.ts +13 -0
- package/packages/@monomind/cli/dist/src/workflow/index.js +11 -0
- package/packages/@monomind/cli/dist/src/workflow/template-engine.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/workflow/template-engine.js +40 -0
- package/packages/@monomind/cli/dist/src/workflow/workflow-executor.d.ts +29 -0
- package/packages/@monomind/cli/dist/src/workflow/workflow-executor.js +227 -0
- package/packages/@monomind/cli/package.json +9 -10
- package/packages/@monomind/guidance/dist/adversarial.d.ts +284 -0
- package/packages/@monomind/guidance/dist/adversarial.js +572 -0
- package/packages/@monomind/guidance/dist/analyzer.d.ts +530 -0
- package/packages/@monomind/guidance/dist/analyzer.js +2518 -0
- package/packages/@monomind/guidance/dist/artifacts.d.ts +283 -0
- package/packages/@monomind/guidance/dist/artifacts.js +356 -0
- package/packages/@monomind/guidance/dist/authority.d.ts +290 -0
- package/packages/@monomind/guidance/dist/authority.js +558 -0
- package/packages/@monomind/guidance/dist/capabilities.d.ts +209 -0
- package/packages/@monomind/guidance/dist/capabilities.js +485 -0
- package/packages/@monomind/guidance/dist/coherence.d.ts +233 -0
- package/packages/@monomind/guidance/dist/coherence.js +372 -0
- package/packages/@monomind/guidance/dist/compiler.d.ts +87 -0
- package/packages/@monomind/guidance/dist/compiler.js +419 -0
- package/packages/@monomind/guidance/dist/conformance-kit.d.ts +225 -0
- package/packages/@monomind/guidance/dist/conformance-kit.js +629 -0
- package/packages/@monomind/guidance/dist/continue-gate.d.ts +214 -0
- package/packages/@monomind/guidance/dist/continue-gate.js +353 -0
- package/packages/@monomind/guidance/dist/crypto-utils.d.ts +17 -0
- package/packages/@monomind/guidance/dist/crypto-utils.js +24 -0
- package/packages/@monomind/guidance/dist/evolution.d.ts +282 -0
- package/packages/@monomind/guidance/dist/evolution.js +500 -0
- package/packages/@monomind/guidance/dist/gates.d.ts +79 -0
- package/packages/@monomind/guidance/dist/gates.js +302 -0
- package/packages/@monomind/guidance/dist/gateway.d.ts +206 -0
- package/packages/@monomind/guidance/dist/gateway.js +452 -0
- package/packages/@monomind/guidance/dist/generators.d.ts +153 -0
- package/packages/@monomind/guidance/dist/generators.js +682 -0
- package/packages/@monomind/guidance/dist/headless.d.ts +177 -0
- package/packages/@monomind/guidance/dist/headless.js +342 -0
- package/packages/@monomind/guidance/dist/hooks.d.ts +109 -0
- package/packages/@monomind/guidance/dist/hooks.js +347 -0
- package/packages/@monomind/guidance/dist/index.d.ts +205 -0
- package/packages/@monomind/guidance/dist/index.js +321 -0
- package/packages/@monomind/guidance/dist/ledger.d.ts +162 -0
- package/packages/@monomind/guidance/dist/ledger.js +375 -0
- package/packages/@monomind/guidance/dist/manifest-validator.d.ts +289 -0
- package/packages/@monomind/guidance/dist/manifest-validator.js +838 -0
- package/packages/@monomind/guidance/dist/memory-gate.d.ts +222 -0
- package/packages/@monomind/guidance/dist/memory-gate.js +382 -0
- package/packages/@monomind/guidance/dist/meta-governance.d.ts +265 -0
- package/packages/@monomind/guidance/dist/meta-governance.js +348 -0
- package/packages/@monomind/guidance/dist/optimizer.d.ts +104 -0
- package/packages/@monomind/guidance/dist/optimizer.js +329 -0
- package/packages/@monomind/guidance/dist/persistence.d.ts +189 -0
- package/packages/@monomind/guidance/dist/persistence.js +464 -0
- package/packages/@monomind/guidance/dist/proof.d.ts +185 -0
- package/packages/@monomind/guidance/dist/proof.js +238 -0
- package/packages/@monomind/guidance/dist/retriever.d.ts +116 -0
- package/packages/@monomind/guidance/dist/retriever.js +394 -0
- package/packages/@monomind/guidance/dist/ruvbot-integration.d.ts +370 -0
- package/packages/@monomind/guidance/dist/ruvbot-integration.js +738 -0
- package/packages/@monomind/guidance/dist/temporal.d.ts +426 -0
- package/packages/@monomind/guidance/dist/temporal.js +658 -0
- package/packages/@monomind/guidance/dist/trust.d.ts +283 -0
- package/packages/@monomind/guidance/dist/trust.js +473 -0
- package/packages/@monomind/guidance/dist/truth-anchors.d.ts +276 -0
- package/packages/@monomind/guidance/dist/truth-anchors.js +488 -0
- package/packages/@monomind/guidance/dist/types.d.ts +378 -0
- package/packages/@monomind/guidance/dist/types.js +10 -0
- package/packages/@monomind/guidance/dist/uncertainty.d.ts +372 -0
- package/packages/@monomind/guidance/dist/uncertainty.js +619 -0
- package/packages/@monomind/guidance/dist/wasm-kernel.d.ts +48 -0
- package/packages/@monomind/guidance/dist/wasm-kernel.js +158 -0
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
import * as fs from 'fs';
|
|
12
12
|
import * as path from 'path';
|
|
13
13
|
import { safeParseEmbedding } from './memory-bridge.js';
|
|
14
|
+
/** Maximum SQLite database file size accepted before read (256 MB). */
|
|
15
|
+
const MAX_DB_FILE_BYTES = 256 * 1024 * 1024;
|
|
14
16
|
// ADR-053: Lazy import of AgentDB v1 bridge
|
|
15
17
|
let _bridge;
|
|
16
18
|
async function getBridge() {
|
|
@@ -733,6 +735,11 @@ export async function ensureSchemaColumns(dbPath) {
|
|
|
733
735
|
}
|
|
734
736
|
const initSqlJs = (await import('sql.js')).default;
|
|
735
737
|
const SQL = await initSqlJs();
|
|
738
|
+
// Guard against excessively large DB files to prevent OOM.
|
|
739
|
+
const ensureStat = fs.statSync(dbPath);
|
|
740
|
+
if (ensureStat.size > MAX_DB_FILE_BYTES) {
|
|
741
|
+
return { success: false, columnsAdded, error: `Database file too large: ${ensureStat.size} bytes` };
|
|
742
|
+
}
|
|
736
743
|
const fileBuffer = fs.readFileSync(dbPath);
|
|
737
744
|
const db = new SQL.Database(fileBuffer);
|
|
738
745
|
// Get current columns in memory_entries
|
|
@@ -802,6 +809,14 @@ export async function checkAndMigrateLegacy(options) {
|
|
|
802
809
|
try {
|
|
803
810
|
const initSqlJs = (await import('sql.js')).default;
|
|
804
811
|
const SQL = await initSqlJs();
|
|
812
|
+
// Guard against excessively large legacy DB files to prevent OOM.
|
|
813
|
+
const legacyStat = fs.statSync(legacyPath);
|
|
814
|
+
if (legacyStat.size > MAX_DB_FILE_BYTES) {
|
|
815
|
+
if (verbose) {
|
|
816
|
+
console.warn(`[memory] Skipping legacy DB at ${legacyPath}: file too large (${legacyStat.size} bytes)`);
|
|
817
|
+
}
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
805
820
|
const legacyBuffer = fs.readFileSync(legacyPath);
|
|
806
821
|
const legacyDb = new SQL.Database(legacyBuffer);
|
|
807
822
|
// Check if it has data
|
|
@@ -1080,6 +1095,11 @@ export async function checkMemoryInitialization(dbPath) {
|
|
|
1080
1095
|
// Try to load with sql.js
|
|
1081
1096
|
const initSqlJs = (await import('sql.js')).default;
|
|
1082
1097
|
const SQL = await initSqlJs();
|
|
1098
|
+
// Guard against excessively large DB files to prevent OOM.
|
|
1099
|
+
const checkStat = fs.statSync(path_);
|
|
1100
|
+
if (checkStat.size > MAX_DB_FILE_BYTES) {
|
|
1101
|
+
return { initialized: false };
|
|
1102
|
+
}
|
|
1083
1103
|
const fileBuffer = fs.readFileSync(path_);
|
|
1084
1104
|
const db = new SQL.Database(fileBuffer);
|
|
1085
1105
|
// Check for metadata table
|
|
@@ -1125,6 +1145,11 @@ export async function applyTemporalDecay(dbPath) {
|
|
|
1125
1145
|
try {
|
|
1126
1146
|
const initSqlJs = (await import('sql.js')).default;
|
|
1127
1147
|
const SQL = await initSqlJs();
|
|
1148
|
+
// Guard against excessively large DB files to prevent OOM.
|
|
1149
|
+
const decayStat = fs.statSync(path_);
|
|
1150
|
+
if (decayStat.size > MAX_DB_FILE_BYTES) {
|
|
1151
|
+
return { success: false, patternsDecayed: 0, error: `Database file too large: ${decayStat.size} bytes` };
|
|
1152
|
+
}
|
|
1128
1153
|
const fileBuffer = fs.readFileSync(path_);
|
|
1129
1154
|
const db = new SQL.Database(fileBuffer);
|
|
1130
1155
|
// Apply decay: confidence *= exp(-decay_rate * days_since_last_use)
|
|
@@ -1445,6 +1470,11 @@ export async function verifyMemoryInit(dbPath, options) {
|
|
|
1445
1470
|
const initSqlJs = (await import('sql.js')).default;
|
|
1446
1471
|
const SQL = await initSqlJs();
|
|
1447
1472
|
const fs = await import('fs');
|
|
1473
|
+
// Guard against excessively large DB files to prevent OOM.
|
|
1474
|
+
const verifyStat = fs.statSync(dbPath);
|
|
1475
|
+
if (verifyStat.size > MAX_DB_FILE_BYTES) {
|
|
1476
|
+
return { success: false, tests: [{ name: 'Database access', passed: false, details: `File too large: ${verifyStat.size} bytes` }], summary: { passed: 0, failed: 1, total: 1 } };
|
|
1477
|
+
}
|
|
1448
1478
|
// Load database
|
|
1449
1479
|
const fileBuffer = fs.readFileSync(dbPath);
|
|
1450
1480
|
const db = new SQL.Database(fileBuffer);
|
|
@@ -1631,6 +1661,11 @@ export async function storeEntry(options) {
|
|
|
1631
1661
|
await ensureSchemaColumns(dbPath);
|
|
1632
1662
|
const initSqlJs = (await import('sql.js')).default;
|
|
1633
1663
|
const SQL = await initSqlJs();
|
|
1664
|
+
// Guard against excessively large DB files to prevent OOM.
|
|
1665
|
+
const storeStat = fs.statSync(dbPath);
|
|
1666
|
+
if (storeStat.size > MAX_DB_FILE_BYTES) {
|
|
1667
|
+
return { success: false, id: '', error: `Database file too large: ${storeStat.size} bytes` };
|
|
1668
|
+
}
|
|
1634
1669
|
const fileBuffer = fs.readFileSync(dbPath);
|
|
1635
1670
|
const db = new SQL.Database(fileBuffer);
|
|
1636
1671
|
const id = `entry_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
@@ -1727,6 +1762,11 @@ export async function searchEntries(options) {
|
|
|
1727
1762
|
}
|
|
1728
1763
|
// Ensure schema has all required columns (migration for older DBs)
|
|
1729
1764
|
await ensureSchemaColumns(dbPath);
|
|
1765
|
+
// Guard against excessively large DB files to prevent OOM.
|
|
1766
|
+
const searchStat = fs.statSync(dbPath);
|
|
1767
|
+
if (searchStat.size > MAX_DB_FILE_BYTES) {
|
|
1768
|
+
return { success: false, results: [], searchTime: 0, error: `Database file too large: ${searchStat.size} bytes` };
|
|
1769
|
+
}
|
|
1730
1770
|
// Generate query embedding
|
|
1731
1771
|
const queryEmb = await generateEmbedding(query);
|
|
1732
1772
|
const queryEmbedding = queryEmb.embedding;
|
|
@@ -1744,6 +1784,11 @@ export async function searchEntries(options) {
|
|
|
1744
1784
|
// Fall back to brute-force SQLite search
|
|
1745
1785
|
const initSqlJs = (await import('sql.js')).default;
|
|
1746
1786
|
const SQL = await initSqlJs();
|
|
1787
|
+
// Guard against excessively large DB files to prevent OOM.
|
|
1788
|
+
const searchFbStat = fs.statSync(dbPath);
|
|
1789
|
+
if (searchFbStat.size > MAX_DB_FILE_BYTES) {
|
|
1790
|
+
return { success: false, results: [], searchTime: Date.now() - startTime, error: `Database file too large: ${searchFbStat.size} bytes` };
|
|
1791
|
+
}
|
|
1747
1792
|
const fileBuffer = fs.readFileSync(dbPath);
|
|
1748
1793
|
const db = new SQL.Database(fileBuffer);
|
|
1749
1794
|
// Get entries with embeddings
|
|
@@ -1854,6 +1899,11 @@ export async function listEntries(options) {
|
|
|
1854
1899
|
await ensureSchemaColumns(dbPath);
|
|
1855
1900
|
const initSqlJs = (await import('sql.js')).default;
|
|
1856
1901
|
const SQL = await initSqlJs();
|
|
1902
|
+
// Guard against excessively large DB files to prevent OOM.
|
|
1903
|
+
const listStat = fs.statSync(dbPath);
|
|
1904
|
+
if (listStat.size > MAX_DB_FILE_BYTES) {
|
|
1905
|
+
return { success: false, entries: [], total: 0, error: `Database file too large: ${listStat.size} bytes` };
|
|
1906
|
+
}
|
|
1857
1907
|
const fileBuffer = fs.readFileSync(dbPath);
|
|
1858
1908
|
const db = new SQL.Database(fileBuffer);
|
|
1859
1909
|
// Get total count
|
|
@@ -1870,9 +1920,13 @@ export async function listEntries(options) {
|
|
|
1870
1920
|
countStmt.free();
|
|
1871
1921
|
const countResult = countRows.length > 0 ? [{ values: countRows }] : [];
|
|
1872
1922
|
const total = countResult[0]?.values?.[0]?.[0] || 0;
|
|
1873
|
-
// Get entries
|
|
1874
|
-
|
|
1875
|
-
const
|
|
1923
|
+
// Get entries — cap limit to 10 000 to prevent full-table loads that OOM
|
|
1924
|
+
// the sql.js in-memory database on large datasets.
|
|
1925
|
+
const MAX_LIST_LIMIT = 10_000;
|
|
1926
|
+
const rawLimit = parseInt(String(limit), 10);
|
|
1927
|
+
const safeLimit = Number.isFinite(rawLimit) && rawLimit > 0 ? Math.min(rawLimit, MAX_LIST_LIMIT) : 100;
|
|
1928
|
+
const rawOffset = parseInt(String(offset), 10);
|
|
1929
|
+
const safeOffset = Number.isFinite(rawOffset) && rawOffset >= 0 ? rawOffset : 0;
|
|
1876
1930
|
const listStmt = namespace
|
|
1877
1931
|
? db.prepare(`SELECT id, key, namespace, content, embedding, access_count, created_at, updated_at FROM memory_entries WHERE status = 'active' AND namespace = ? ORDER BY updated_at DESC LIMIT ? OFFSET ?`)
|
|
1878
1932
|
: db.prepare(`SELECT id, key, namespace, content, embedding, access_count, created_at, updated_at FROM memory_entries WHERE status = 'active' ORDER BY updated_at DESC LIMIT ? OFFSET ?`);
|
|
@@ -1939,6 +1993,11 @@ export async function getEntry(options) {
|
|
|
1939
1993
|
await ensureSchemaColumns(dbPath);
|
|
1940
1994
|
const initSqlJs = (await import('sql.js')).default;
|
|
1941
1995
|
const SQL = await initSqlJs();
|
|
1996
|
+
// Guard against excessively large DB files to prevent OOM.
|
|
1997
|
+
const getStat = fs.statSync(dbPath);
|
|
1998
|
+
if (getStat.size > MAX_DB_FILE_BYTES) {
|
|
1999
|
+
return { success: false, found: false, error: `Database file too large: ${getStat.size} bytes` };
|
|
2000
|
+
}
|
|
1942
2001
|
const fileBuffer = fs.readFileSync(dbPath);
|
|
1943
2002
|
const db = new SQL.Database(fileBuffer);
|
|
1944
2003
|
// Find entry by key
|
|
@@ -2041,6 +2100,11 @@ export async function deleteEntry(options) {
|
|
|
2041
2100
|
await ensureSchemaColumns(dbPath);
|
|
2042
2101
|
const initSqlJs = (await import('sql.js')).default;
|
|
2043
2102
|
const SQL = await initSqlJs();
|
|
2103
|
+
// Guard against excessively large DB files to prevent OOM.
|
|
2104
|
+
const deleteStat = fs.statSync(dbPath);
|
|
2105
|
+
if (deleteStat.size > MAX_DB_FILE_BYTES) {
|
|
2106
|
+
return { success: false, deleted: false, key, namespace, remainingEntries: 0, error: `Database file too large: ${deleteStat.size} bytes` };
|
|
2107
|
+
}
|
|
2044
2108
|
const fileBuffer = fs.readFileSync(dbPath);
|
|
2045
2109
|
const db = new SQL.Database(fileBuffer);
|
|
2046
2110
|
// Check if entry exists first
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* - Persists patterns to .swarm/sona-patterns.json
|
|
12
12
|
* @module v1/cli/memory/sona-optimizer
|
|
13
13
|
*/
|
|
14
|
-
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'fs';
|
|
14
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'fs';
|
|
15
15
|
import { dirname, join } from 'path';
|
|
16
16
|
// ============================================================================
|
|
17
17
|
// Constants
|
|
@@ -473,6 +473,8 @@ export class SONAOptimizer {
|
|
|
473
473
|
if (!existsSync(fullPath)) {
|
|
474
474
|
return false;
|
|
475
475
|
}
|
|
476
|
+
if (statSync(fullPath).size > 50 * 1024 * 1024)
|
|
477
|
+
return false;
|
|
476
478
|
const data = readFileSync(fullPath, 'utf-8');
|
|
477
479
|
const state = JSON.parse(data);
|
|
478
480
|
// Validate version
|
|
@@ -480,9 +482,13 @@ export class SONAOptimizer {
|
|
|
480
482
|
console.error('[SONA] Incompatible state version, starting fresh');
|
|
481
483
|
return false;
|
|
482
484
|
}
|
|
483
|
-
// Load patterns
|
|
485
|
+
// Load patterns — also cap key length so a crafted state file cannot
|
|
486
|
+
// store arbitrarily long keys that bloat the in-memory Map. The key is
|
|
487
|
+
// an agent:keyword string; 512 chars is ample for any real value.
|
|
484
488
|
this.patterns.clear();
|
|
485
489
|
for (const [key, pattern] of Object.entries(state.patterns)) {
|
|
490
|
+
if (typeof key !== 'string' || key.length > 512)
|
|
491
|
+
continue;
|
|
486
492
|
if (this.validatePattern(pattern)) {
|
|
487
493
|
this.patterns.set(key, pattern);
|
|
488
494
|
}
|
|
@@ -497,7 +503,9 @@ export class SONAOptimizer {
|
|
|
497
503
|
return true;
|
|
498
504
|
}
|
|
499
505
|
catch (err) {
|
|
500
|
-
|
|
506
|
+
// Strip filesystem paths from error before logging to prevent path disclosure
|
|
507
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
508
|
+
console.error(`[SONA] Failed to load state: ${msg.replace(/\/[^\s:]+(\/|(?=\s|:|$))/g, '<path>/').slice(0, 200)}`);
|
|
501
509
|
return false;
|
|
502
510
|
}
|
|
503
511
|
}
|
|
@@ -532,7 +540,9 @@ export class SONAOptimizer {
|
|
|
532
540
|
return true;
|
|
533
541
|
}
|
|
534
542
|
catch (err) {
|
|
535
|
-
|
|
543
|
+
// Strip filesystem paths from error before logging to prevent path disclosure
|
|
544
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
545
|
+
console.error(`[SONA] Failed to save state: ${msg.replace(/\/[^\s:]+(\/|(?=\s|:|$))/g, '<path>/').slice(0, 200)}`);
|
|
536
546
|
return false;
|
|
537
547
|
}
|
|
538
548
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heuristic complexity scorer for task descriptions.
|
|
3
|
+
*
|
|
4
|
+
* Returns a score in [0, 100] that drives automatic model-tier selection.
|
|
5
|
+
* Higher scores indicate tasks that benefit from more capable (and costly)
|
|
6
|
+
* models.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Agent slugs that inherently deal with high-complexity work.
|
|
10
|
+
* When one of these agents is involved the score gets a +20 bonus.
|
|
11
|
+
*/
|
|
12
|
+
export declare const HIGH_COMPLEXITY_AGENTS: ReadonlySet<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Score the complexity of a task description.
|
|
15
|
+
*
|
|
16
|
+
* @param taskDescription - Free-text description of the task.
|
|
17
|
+
* @param agentSlug - Optional agent identifier; certain agents boost the score.
|
|
18
|
+
* @returns A number in [0, 100].
|
|
19
|
+
*/
|
|
20
|
+
export declare function scoreComplexity(taskDescription: string, agentSlug?: string): number;
|
|
21
|
+
//# sourceMappingURL=complexity-scorer.d.ts.map
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heuristic complexity scorer for task descriptions.
|
|
3
|
+
*
|
|
4
|
+
* Returns a score in [0, 100] that drives automatic model-tier selection.
|
|
5
|
+
* Higher scores indicate tasks that benefit from more capable (and costly)
|
|
6
|
+
* models.
|
|
7
|
+
*/
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Keyword sets
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
const HIGH_COMPLEXITY_KEYWORDS = [
|
|
12
|
+
'architecture',
|
|
13
|
+
'distributed',
|
|
14
|
+
'security audit',
|
|
15
|
+
'cve',
|
|
16
|
+
'consensus',
|
|
17
|
+
'fault-tolerant',
|
|
18
|
+
'migrate',
|
|
19
|
+
'refactor across',
|
|
20
|
+
'orchestrat',
|
|
21
|
+
'design system',
|
|
22
|
+
'database schema',
|
|
23
|
+
'performance optim',
|
|
24
|
+
'threat model',
|
|
25
|
+
'encryption',
|
|
26
|
+
'zero-knowledge',
|
|
27
|
+
];
|
|
28
|
+
const LOW_COMPLEXITY_KEYWORDS = [
|
|
29
|
+
'format',
|
|
30
|
+
'list',
|
|
31
|
+
'rename',
|
|
32
|
+
'sort',
|
|
33
|
+
'typo',
|
|
34
|
+
'lint',
|
|
35
|
+
'log',
|
|
36
|
+
'comment',
|
|
37
|
+
'print',
|
|
38
|
+
'echo',
|
|
39
|
+
'delete unused',
|
|
40
|
+
'remove import',
|
|
41
|
+
];
|
|
42
|
+
/**
|
|
43
|
+
* Agent slugs that inherently deal with high-complexity work.
|
|
44
|
+
* When one of these agents is involved the score gets a +20 bonus.
|
|
45
|
+
*/
|
|
46
|
+
export const HIGH_COMPLEXITY_AGENTS = new Set([
|
|
47
|
+
'engineering-software-architect',
|
|
48
|
+
'security-architect',
|
|
49
|
+
'security-auditor',
|
|
50
|
+
'system-architect',
|
|
51
|
+
'performance-engineer',
|
|
52
|
+
'byzantine-coordinator',
|
|
53
|
+
'collective-intelligence-coordinator',
|
|
54
|
+
]);
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
// Patterns
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
const STEP_INDICATOR_RE = /(?:step\s*\d|first[\s,].*then[\s,]|phase\s*\d)/i;
|
|
59
|
+
const CODE_BLOCK_RE = /```[\s\S]*?```/;
|
|
60
|
+
const FILE_REF_RE = /\b[\w./-]+\.\w{1,5}\b/;
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
// Scorer
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
/**
|
|
65
|
+
* Score the complexity of a task description.
|
|
66
|
+
*
|
|
67
|
+
* @param taskDescription - Free-text description of the task.
|
|
68
|
+
* @param agentSlug - Optional agent identifier; certain agents boost the score.
|
|
69
|
+
* @returns A number in [0, 100].
|
|
70
|
+
*/
|
|
71
|
+
export function scoreComplexity(taskDescription, agentSlug) {
|
|
72
|
+
let score = 50;
|
|
73
|
+
const lower = taskDescription.toLowerCase();
|
|
74
|
+
const wordCount = taskDescription.trim().split(/\s+/).length;
|
|
75
|
+
// -- Word-count adjustments ------------------------------------------------
|
|
76
|
+
if (wordCount < 20) {
|
|
77
|
+
score -= 20;
|
|
78
|
+
}
|
|
79
|
+
if (wordCount > 100) {
|
|
80
|
+
score += 20;
|
|
81
|
+
}
|
|
82
|
+
if (wordCount > 200) {
|
|
83
|
+
score += 10;
|
|
84
|
+
}
|
|
85
|
+
// -- Keyword adjustments (first match only) --------------------------------
|
|
86
|
+
if (HIGH_COMPLEXITY_KEYWORDS.some((kw) => lower.includes(kw))) {
|
|
87
|
+
score += 10;
|
|
88
|
+
}
|
|
89
|
+
if (LOW_COMPLEXITY_KEYWORDS.some((kw) => lower.includes(kw))) {
|
|
90
|
+
score -= 10;
|
|
91
|
+
}
|
|
92
|
+
// -- Structural indicators -------------------------------------------------
|
|
93
|
+
if (STEP_INDICATOR_RE.test(taskDescription)) {
|
|
94
|
+
score += 10;
|
|
95
|
+
}
|
|
96
|
+
if (CODE_BLOCK_RE.test(taskDescription) || FILE_REF_RE.test(taskDescription)) {
|
|
97
|
+
score += 5;
|
|
98
|
+
}
|
|
99
|
+
// -- Agent bonus -----------------------------------------------------------
|
|
100
|
+
if (agentSlug && HIGH_COMPLEXITY_AGENTS.has(agentSlug)) {
|
|
101
|
+
score += 20;
|
|
102
|
+
}
|
|
103
|
+
// -- Clamp -----------------------------------------------------------------
|
|
104
|
+
return Math.max(0, Math.min(100, score));
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=complexity-scorer.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { type ModelTier, type ModelSettings, type ModelPreference, TIER_DEFAULTS, MODEL_IDS, } from './model-settings.js';
|
|
2
|
+
export { scoreComplexity, HIGH_COMPLEXITY_AGENTS, } from './complexity-scorer.js';
|
|
3
|
+
export { type ResolvedModelSettings, resolveModelTier, } from './model-tier-resolver.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-run model tier selection — types and constants.
|
|
3
|
+
*
|
|
4
|
+
* Each tier maps to a concrete Claude model ID and carries sensible defaults
|
|
5
|
+
* for token budget, temperature, and extended-thinking.
|
|
6
|
+
*/
|
|
7
|
+
export type ModelTier = 'haiku' | 'sonnet' | 'opus';
|
|
8
|
+
export interface ModelSettings {
|
|
9
|
+
model: ModelTier;
|
|
10
|
+
maxTokens?: number;
|
|
11
|
+
maxCostUsd?: number;
|
|
12
|
+
extendedThinking?: boolean;
|
|
13
|
+
temperature?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface ModelPreference {
|
|
16
|
+
default: ModelTier;
|
|
17
|
+
maxCostUsd?: number;
|
|
18
|
+
extendedThinking?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare const TIER_DEFAULTS: Record<ModelTier, ModelSettings>;
|
|
21
|
+
export declare const MODEL_IDS: Record<ModelTier, string>;
|
|
22
|
+
//# sourceMappingURL=model-settings.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-run model tier selection — types and constants.
|
|
3
|
+
*
|
|
4
|
+
* Each tier maps to a concrete Claude model ID and carries sensible defaults
|
|
5
|
+
* for token budget, temperature, and extended-thinking.
|
|
6
|
+
*/
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// Constants
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
export const TIER_DEFAULTS = {
|
|
11
|
+
haiku: {
|
|
12
|
+
model: 'haiku',
|
|
13
|
+
maxTokens: 2048,
|
|
14
|
+
temperature: 0.3,
|
|
15
|
+
},
|
|
16
|
+
sonnet: {
|
|
17
|
+
model: 'sonnet',
|
|
18
|
+
maxTokens: 8192,
|
|
19
|
+
temperature: 0.5,
|
|
20
|
+
},
|
|
21
|
+
opus: {
|
|
22
|
+
model: 'opus',
|
|
23
|
+
maxTokens: 16384,
|
|
24
|
+
temperature: 0.7,
|
|
25
|
+
extendedThinking: true,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export const MODEL_IDS = {
|
|
29
|
+
haiku: 'claude-haiku-4-5',
|
|
30
|
+
sonnet: 'claude-sonnet-4-5',
|
|
31
|
+
opus: 'claude-opus-4-5',
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=model-settings.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves the concrete model tier for a given agent + task combination.
|
|
3
|
+
*
|
|
4
|
+
* Resolution order:
|
|
5
|
+
* 1. Orchestrator override (explicit)
|
|
6
|
+
* 2. Complexity-based automatic selection
|
|
7
|
+
* 3. Agent preference default
|
|
8
|
+
* 4. Fallback to sonnet
|
|
9
|
+
*/
|
|
10
|
+
import type { ModelSettings, ModelPreference } from './model-settings.js';
|
|
11
|
+
export interface ResolvedModelSettings extends ModelSettings {
|
|
12
|
+
complexityScore: number;
|
|
13
|
+
resolutionReason: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Determine the best model tier for a task.
|
|
17
|
+
*
|
|
18
|
+
* @param agentSlug - The agent that will execute the task.
|
|
19
|
+
* @param taskDescription - Free-text task description.
|
|
20
|
+
* @param agentPreference - Optional per-agent preference.
|
|
21
|
+
* @param orchestratorOverride - Optional hard override from the orchestrator.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveModelTier(agentSlug: string, taskDescription: string, agentPreference?: ModelPreference, orchestratorOverride?: Partial<ModelSettings>): ResolvedModelSettings;
|
|
24
|
+
//# sourceMappingURL=model-tier-resolver.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves the concrete model tier for a given agent + task combination.
|
|
3
|
+
*
|
|
4
|
+
* Resolution order:
|
|
5
|
+
* 1. Orchestrator override (explicit)
|
|
6
|
+
* 2. Complexity-based automatic selection
|
|
7
|
+
* 3. Agent preference default
|
|
8
|
+
* 4. Fallback to sonnet
|
|
9
|
+
*/
|
|
10
|
+
import { TIER_DEFAULTS } from './model-settings.js';
|
|
11
|
+
import { scoreComplexity, HIGH_COMPLEXITY_AGENTS } from './complexity-scorer.js';
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Resolver
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
/**
|
|
16
|
+
* Determine the best model tier for a task.
|
|
17
|
+
*
|
|
18
|
+
* @param agentSlug - The agent that will execute the task.
|
|
19
|
+
* @param taskDescription - Free-text task description.
|
|
20
|
+
* @param agentPreference - Optional per-agent preference.
|
|
21
|
+
* @param orchestratorOverride - Optional hard override from the orchestrator.
|
|
22
|
+
*/
|
|
23
|
+
export function resolveModelTier(agentSlug, taskDescription, agentPreference, orchestratorOverride) {
|
|
24
|
+
const complexity = scoreComplexity(taskDescription, agentSlug);
|
|
25
|
+
// ----- 1. Orchestrator override ------------------------------------------
|
|
26
|
+
if (orchestratorOverride?.model) {
|
|
27
|
+
return buildResult(orchestratorOverride.model, complexity, 'orchestrator_override', agentPreference);
|
|
28
|
+
}
|
|
29
|
+
// ----- 2. Complexity-based selection -------------------------------------
|
|
30
|
+
const preferredDefault = agentPreference?.default ?? 'sonnet';
|
|
31
|
+
let tier;
|
|
32
|
+
let reason;
|
|
33
|
+
if (complexity < 30 && preferredDefault !== 'opus') {
|
|
34
|
+
tier = 'haiku';
|
|
35
|
+
reason = 'low_complexity';
|
|
36
|
+
}
|
|
37
|
+
else if (complexity >= 70 || HIGH_COMPLEXITY_AGENTS.has(agentSlug)) {
|
|
38
|
+
tier = 'opus';
|
|
39
|
+
reason = complexity >= 70 ? 'high_complexity' : 'high_complexity_agent';
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
tier = preferredDefault;
|
|
43
|
+
reason = 'default_preference';
|
|
44
|
+
}
|
|
45
|
+
return buildResult(tier, complexity, reason, agentPreference);
|
|
46
|
+
}
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
// Helpers
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
function buildResult(tier, complexityScore, resolutionReason, preference) {
|
|
51
|
+
const base = { ...TIER_DEFAULTS[tier] };
|
|
52
|
+
// Propagate preference overrides
|
|
53
|
+
if (preference?.maxCostUsd !== undefined) {
|
|
54
|
+
base.maxCostUsd = preference.maxCostUsd;
|
|
55
|
+
}
|
|
56
|
+
if (preference?.extendedThinking !== undefined) {
|
|
57
|
+
base.extendedThinking = preference.extendedThinking;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
...base,
|
|
61
|
+
complexityScore,
|
|
62
|
+
resolutionReason,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=model-tier-resolver.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability surface for the (removed) @monoes/* native learning packages.
|
|
3
|
+
*
|
|
4
|
+
* Lean teardown: the SONA / native / WASM learning layer (@monoes/sona, router,
|
|
5
|
+
* attention, learning-wasm, core, and @monomind/monovector-upstream) has been
|
|
6
|
+
* removed. This module is now a stub that always reports "nothing native is
|
|
7
|
+
* available", so every caller takes the pure-JS / keyword-routing path. The
|
|
8
|
+
* function and type surface is preserved so importers (index.ts, hooks-tools.ts,
|
|
9
|
+
* doctor.ts, neural.ts) keep compiling without change.
|
|
10
|
+
*/
|
|
11
|
+
export interface MonoesCapabilities {
|
|
12
|
+
/** @monoes/sona SonaEngine available — always false after teardown */
|
|
13
|
+
sona: boolean;
|
|
14
|
+
/** @monoes/router backend — always 'none' after teardown */
|
|
15
|
+
router: 'native' | 'js' | 'none';
|
|
16
|
+
/** @monoes/attention FlashAttention available — always false after teardown */
|
|
17
|
+
attention: boolean;
|
|
18
|
+
/** @monoes/learning-wasm WasmMicroLoRA available — always false after teardown */
|
|
19
|
+
learningWasm: boolean;
|
|
20
|
+
/** @monomind/monovector-upstream plugin loaded — always false after teardown */
|
|
21
|
+
upstreamPlugin: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns the stubbed capability surface — all native backends report absent.
|
|
25
|
+
* Async to preserve the original signature; callers `await` this everywhere.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getCapabilities(): Promise<MonoesCapabilities>;
|
|
28
|
+
/** Synchronous read of the (constant) capability surface. */
|
|
29
|
+
export declare function getCachedCapabilities(): MonoesCapabilities | null;
|
|
30
|
+
/** No-op after teardown — there is nothing to re-probe. */
|
|
31
|
+
export declare function resetCapabilitiesCache(): void;
|
|
32
|
+
/** Returns the stubbed capability surface — kept for API compatibility. */
|
|
33
|
+
export declare function refreshCapabilities(): Promise<MonoesCapabilities>;
|
|
34
|
+
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability surface for the (removed) @monoes/* native learning packages.
|
|
3
|
+
*
|
|
4
|
+
* Lean teardown: the SONA / native / WASM learning layer (@monoes/sona, router,
|
|
5
|
+
* attention, learning-wasm, core, and @monomind/monovector-upstream) has been
|
|
6
|
+
* removed. This module is now a stub that always reports "nothing native is
|
|
7
|
+
* available", so every caller takes the pure-JS / keyword-routing path. The
|
|
8
|
+
* function and type surface is preserved so importers (index.ts, hooks-tools.ts,
|
|
9
|
+
* doctor.ts, neural.ts) keep compiling without change.
|
|
10
|
+
*/
|
|
11
|
+
const STUB_CAPABILITIES = {
|
|
12
|
+
sona: false,
|
|
13
|
+
router: 'none',
|
|
14
|
+
attention: false,
|
|
15
|
+
learningWasm: false,
|
|
16
|
+
upstreamPlugin: false,
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Returns the stubbed capability surface — all native backends report absent.
|
|
20
|
+
* Async to preserve the original signature; callers `await` this everywhere.
|
|
21
|
+
*/
|
|
22
|
+
export async function getCapabilities() {
|
|
23
|
+
return STUB_CAPABILITIES;
|
|
24
|
+
}
|
|
25
|
+
/** Synchronous read of the (constant) capability surface. */
|
|
26
|
+
export function getCachedCapabilities() {
|
|
27
|
+
return STUB_CAPABILITIES;
|
|
28
|
+
}
|
|
29
|
+
/** No-op after teardown — there is nothing to re-probe. */
|
|
30
|
+
export function resetCapabilitiesCache() {
|
|
31
|
+
/* no-op */
|
|
32
|
+
}
|
|
33
|
+
/** Returns the stubbed capability surface — kept for API compatibility. */
|
|
34
|
+
export async function refreshCapabilities() {
|
|
35
|
+
return STUB_CAPABILITIES;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=capabilities.js.map
|
|
@@ -3,19 +3,43 @@
|
|
|
3
3
|
* success signal from real command exit codes, instead of trusting a
|
|
4
4
|
* caller-supplied --success flag.
|
|
5
5
|
*/
|
|
6
|
-
import { promises as fs } from 'node:fs';
|
|
6
|
+
import { promises as fs, statSync } from 'node:fs';
|
|
7
7
|
import { join } from 'node:path';
|
|
8
|
+
/** Refuse to read files larger than this to prevent OOM. */
|
|
9
|
+
const MAX_FILE_BYTES = 50 * 1024 * 1024; // 50 MB
|
|
10
|
+
/** Cap command string length to prevent file bloat. */
|
|
11
|
+
const MAX_COMMAND_LEN = 500;
|
|
8
12
|
function storePath(baseDir) {
|
|
9
13
|
return join(baseDir, 'command-outcomes.jsonl');
|
|
10
14
|
}
|
|
15
|
+
/** Maximum number of command-outcome records to keep.
|
|
16
|
+
* deriveRecentSuccess only uses records within a 5-minute window (typically < 50), so
|
|
17
|
+
* anything older is dead weight. 500 gives a comfortable buffer. */
|
|
18
|
+
const MAX_COMMAND_RECORDS = 500;
|
|
11
19
|
/** Append a command outcome. Non-fatal on error. */
|
|
12
20
|
export async function recordCommand(baseDir, cmd) {
|
|
13
21
|
try {
|
|
14
22
|
await fs.mkdir(baseDir, { recursive: true });
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
const path = storePath(baseDir);
|
|
24
|
+
// Cap command length to prevent individual records from bloating the file.
|
|
25
|
+
const safeCommand = cmd.command.length > MAX_COMMAND_LEN ? cmd.command.slice(0, MAX_COMMAND_LEN) : cmd.command;
|
|
26
|
+
const rec = { ts: cmd.ts, command: safeCommand, exitCode: cmd.exitCode, success: cmd.exitCode === 0 };
|
|
27
|
+
await fs.appendFile(path, JSON.stringify(rec) + '\n', 'utf8');
|
|
28
|
+
// Opportunistic trim: rewrite only when the file exceeds the cap.
|
|
29
|
+
// Avoids an extra stat() on every call by catching the overcount lazily.
|
|
30
|
+
// Guard with size check first to prevent OOM on unexpectedly large files.
|
|
31
|
+
try {
|
|
32
|
+
if (statSync(path).size > MAX_FILE_BYTES)
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const content = await fs.readFile(path, 'utf8').catch(() => '');
|
|
39
|
+
const lines = content.trim().split('\n').filter(Boolean);
|
|
40
|
+
if (lines.length > MAX_COMMAND_RECORDS) {
|
|
41
|
+
await fs.writeFile(path, lines.slice(-MAX_COMMAND_RECORDS).join('\n') + '\n', 'utf8');
|
|
42
|
+
}
|
|
19
43
|
}
|
|
20
44
|
catch { /* non-fatal */ }
|
|
21
45
|
}
|
|
@@ -42,7 +66,13 @@ export async function recordCommand(baseDir, cmd) {
|
|
|
42
66
|
*/
|
|
43
67
|
export async function deriveRecentSuccess(baseDir, windowMs = 300_000) {
|
|
44
68
|
try {
|
|
45
|
-
const
|
|
69
|
+
const p = storePath(baseDir);
|
|
70
|
+
try {
|
|
71
|
+
if (statSync(p).size > MAX_FILE_BYTES)
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
catch { /* file absent */ }
|
|
75
|
+
const content = await fs.readFile(p, 'utf8').catch(() => '');
|
|
46
76
|
if (!content)
|
|
47
77
|
return null;
|
|
48
78
|
const now = Date.now();
|
|
@@ -67,7 +97,13 @@ export async function deriveRecentSuccess(baseDir, windowMs = 300_000) {
|
|
|
67
97
|
/** Read recent command outcomes (for diagnostics). */
|
|
68
98
|
export async function readCommandOutcomes(baseDir, windowMs = 300_000) {
|
|
69
99
|
try {
|
|
70
|
-
const
|
|
100
|
+
const p = storePath(baseDir);
|
|
101
|
+
try {
|
|
102
|
+
if (statSync(p).size > MAX_FILE_BYTES)
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
catch { /* file absent */ }
|
|
106
|
+
const content = await fs.readFile(p, 'utf8').catch(() => '');
|
|
71
107
|
if (!content)
|
|
72
108
|
return [];
|
|
73
109
|
const now = Date.now();
|