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
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-Learning Pre-Training Benchmark Suite
|
|
3
|
+
* Comprehensive benchmarks for SONA, EWC++, MoE, pattern learning
|
|
4
|
+
*
|
|
5
|
+
* Metrics measured:
|
|
6
|
+
* - SONA adaptation latency (<0.05ms target)
|
|
7
|
+
* - Pattern learning throughput
|
|
8
|
+
* - EWC++ consolidation effectiveness
|
|
9
|
+
* - Memory retrieval accuracy
|
|
10
|
+
* - Pre-training convergence speed
|
|
11
|
+
*
|
|
12
|
+
* @module v1/cli/benchmarks/pretrain
|
|
13
|
+
*/
|
|
14
|
+
import { performance } from 'node:perf_hooks';
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Utility Functions
|
|
17
|
+
// ============================================================================
|
|
18
|
+
function percentile(sorted, p) {
|
|
19
|
+
const idx = Math.ceil((p / 100) * sorted.length) - 1;
|
|
20
|
+
return sorted[Math.max(0, idx)];
|
|
21
|
+
}
|
|
22
|
+
function mean(arr) {
|
|
23
|
+
return arr.reduce((a, b) => a + b, 0) / arr.length;
|
|
24
|
+
}
|
|
25
|
+
function stdDev(arr, avg) {
|
|
26
|
+
const squaredDiffs = arr.map(x => Math.pow(x - avg, 2));
|
|
27
|
+
return Math.sqrt(mean(squaredDiffs));
|
|
28
|
+
}
|
|
29
|
+
export function formatBenchmarkResult(result) {
|
|
30
|
+
const status = result.targetMet ? '\x1b[32m✓\x1b[0m' : '\x1b[31m✗\x1b[0m';
|
|
31
|
+
const target = result.targetMs ? ` (target: ${result.targetMs}ms)` : '';
|
|
32
|
+
return [
|
|
33
|
+
`${status} ${result.name}${target}`,
|
|
34
|
+
` Mean: ${result.meanMs.toFixed(4)}ms | Median: ${result.medianMs.toFixed(4)}ms`,
|
|
35
|
+
` p95: ${result.p95Ms.toFixed(4)}ms | p99: ${result.p99Ms.toFixed(4)}ms`,
|
|
36
|
+
` Min: ${result.minMs.toFixed(4)}ms | Max: ${result.maxMs.toFixed(4)}ms`,
|
|
37
|
+
` StdDev: ${result.stdDev.toFixed(4)}ms | Ops/s: ${result.opsPerSecond.toFixed(0)}`,
|
|
38
|
+
].join('\n');
|
|
39
|
+
}
|
|
40
|
+
// ============================================================================
|
|
41
|
+
// Core Benchmark Runner
|
|
42
|
+
// ============================================================================
|
|
43
|
+
export async function runBenchmark(name, fn, config) {
|
|
44
|
+
const { iterations, warmupIterations, targetMs, verbose } = config;
|
|
45
|
+
const times = [];
|
|
46
|
+
// Warmup phase
|
|
47
|
+
if (verbose)
|
|
48
|
+
console.log(` Warming up ${name} (${warmupIterations} iterations)...`);
|
|
49
|
+
for (let i = 0; i < warmupIterations; i++) {
|
|
50
|
+
await fn();
|
|
51
|
+
}
|
|
52
|
+
// Measurement phase
|
|
53
|
+
if (verbose)
|
|
54
|
+
console.log(` Running ${name} (${iterations} iterations)...`);
|
|
55
|
+
for (let i = 0; i < iterations; i++) {
|
|
56
|
+
const start = performance.now();
|
|
57
|
+
await fn();
|
|
58
|
+
times.push(performance.now() - start);
|
|
59
|
+
}
|
|
60
|
+
// Calculate statistics
|
|
61
|
+
const sorted = [...times].sort((a, b) => a - b);
|
|
62
|
+
const avg = mean(times);
|
|
63
|
+
const std = stdDev(times, avg);
|
|
64
|
+
return {
|
|
65
|
+
name,
|
|
66
|
+
iterations,
|
|
67
|
+
meanMs: avg,
|
|
68
|
+
medianMs: percentile(sorted, 50),
|
|
69
|
+
p95Ms: percentile(sorted, 95),
|
|
70
|
+
p99Ms: percentile(sorted, 99),
|
|
71
|
+
minMs: sorted[0],
|
|
72
|
+
maxMs: sorted[sorted.length - 1],
|
|
73
|
+
stdDev: std,
|
|
74
|
+
opsPerSecond: 1000 / avg,
|
|
75
|
+
targetMet: targetMs ? avg <= targetMs : true,
|
|
76
|
+
targetMs,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// ============================================================================
|
|
80
|
+
// SONA Adaptation Benchmarks
|
|
81
|
+
// ============================================================================
|
|
82
|
+
export async function benchmarkSONAAdaptation(config) {
|
|
83
|
+
// Fallback implementation for SONA adaptation
|
|
84
|
+
const sonaAdapt = async (_signal) => {
|
|
85
|
+
// Simulate SONA adaptation with minimal computation
|
|
86
|
+
const start = performance.now();
|
|
87
|
+
// Simple computation to simulate adaptation
|
|
88
|
+
let sum = 0;
|
|
89
|
+
for (let i = 0; i < 100; i++) {
|
|
90
|
+
sum += Math.sin(i) * Math.cos(i);
|
|
91
|
+
}
|
|
92
|
+
const latency = performance.now() - start;
|
|
93
|
+
return { adapted: sum > -1000, latencyMs: latency };
|
|
94
|
+
};
|
|
95
|
+
const testSignals = [
|
|
96
|
+
{ type: 'observation', content: 'User requested feature implementation' },
|
|
97
|
+
{ type: 'action', content: 'Created new component file' },
|
|
98
|
+
{ type: 'result', content: 'Component successfully rendered' },
|
|
99
|
+
{ type: 'thought', content: 'Should add error handling' },
|
|
100
|
+
];
|
|
101
|
+
let signalIdx = 0;
|
|
102
|
+
return runBenchmark('SONA Adaptation', async () => {
|
|
103
|
+
await sonaAdapt(testSignals[signalIdx % testSignals.length]);
|
|
104
|
+
signalIdx++;
|
|
105
|
+
}, { ...config, targetMs: config.targetMs || 0.05 });
|
|
106
|
+
}
|
|
107
|
+
// ============================================================================
|
|
108
|
+
// Pattern Learning Benchmarks
|
|
109
|
+
// ============================================================================
|
|
110
|
+
export async function benchmarkPatternLearning(config) {
|
|
111
|
+
// Simulate pattern learning step recording
|
|
112
|
+
const recordStep = async (_step) => {
|
|
113
|
+
// Simulate recording - just a hash computation
|
|
114
|
+
let hash = 0;
|
|
115
|
+
const str = _step.content;
|
|
116
|
+
for (let i = 0; i < str.length; i++) {
|
|
117
|
+
hash = ((hash << 5) - hash + str.charCodeAt(i)) | 0;
|
|
118
|
+
}
|
|
119
|
+
return hash;
|
|
120
|
+
};
|
|
121
|
+
const testSteps = [
|
|
122
|
+
{ type: 'observation', content: 'Analyzing codebase structure' },
|
|
123
|
+
{ type: 'thought', content: 'Identified potential optimization' },
|
|
124
|
+
{ type: 'action', content: 'Refactored module imports' },
|
|
125
|
+
{ type: 'result', content: 'Build time reduced by 15%' },
|
|
126
|
+
];
|
|
127
|
+
let stepIdx = 0;
|
|
128
|
+
return runBenchmark('Pattern Learning (Record Step)', async () => {
|
|
129
|
+
await recordStep(testSteps[stepIdx % testSteps.length]);
|
|
130
|
+
stepIdx++;
|
|
131
|
+
}, { ...config, targetMs: config.targetMs || 0.1 });
|
|
132
|
+
}
|
|
133
|
+
// ============================================================================
|
|
134
|
+
// EWC++ Consolidation Benchmarks
|
|
135
|
+
// ============================================================================
|
|
136
|
+
export async function benchmarkEWCConsolidation(config) {
|
|
137
|
+
// Simulate EWC++ consolidation
|
|
138
|
+
const consolidate = async () => {
|
|
139
|
+
// Simulate consolidation computation
|
|
140
|
+
const patterns = 100;
|
|
141
|
+
let consolidated = 0;
|
|
142
|
+
for (let i = 0; i < patterns; i++) {
|
|
143
|
+
// Simulate Fisher information computation
|
|
144
|
+
const importance = Math.random();
|
|
145
|
+
if (importance > 0.3) {
|
|
146
|
+
consolidated++;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return { consolidated, preserved: patterns - consolidated };
|
|
150
|
+
};
|
|
151
|
+
return runBenchmark('EWC++ Consolidation', async () => {
|
|
152
|
+
await consolidate();
|
|
153
|
+
}, { ...config, targetMs: config.targetMs || 5.0 });
|
|
154
|
+
}
|
|
155
|
+
// ============================================================================
|
|
156
|
+
// Memory Retrieval Benchmarks
|
|
157
|
+
// ============================================================================
|
|
158
|
+
export async function benchmarkMemoryRetrieval(config) {
|
|
159
|
+
// Simulate memory search
|
|
160
|
+
const searchEntries = async (_options) => {
|
|
161
|
+
// Simulate vector search with cosine similarity
|
|
162
|
+
const numVectors = 1000;
|
|
163
|
+
const dim = 384;
|
|
164
|
+
const queryVec = new Float32Array(dim).map(() => Math.random());
|
|
165
|
+
const results = [];
|
|
166
|
+
for (let i = 0; i < Math.min(numVectors, 100); i++) {
|
|
167
|
+
const vec = new Float32Array(dim).map(() => Math.random());
|
|
168
|
+
let dot = 0, normQ = 0, normV = 0;
|
|
169
|
+
for (let j = 0; j < dim; j++) {
|
|
170
|
+
dot += queryVec[j] * vec[j];
|
|
171
|
+
normQ += queryVec[j] * queryVec[j];
|
|
172
|
+
normV += vec[j] * vec[j];
|
|
173
|
+
}
|
|
174
|
+
results.push({ score: dot / (Math.sqrt(normQ) * Math.sqrt(normV)) });
|
|
175
|
+
}
|
|
176
|
+
return { results: results.slice(0, _options.limit || 10), searchTime: 1.0 };
|
|
177
|
+
};
|
|
178
|
+
const testQueries = [
|
|
179
|
+
'authentication patterns',
|
|
180
|
+
'error handling best practices',
|
|
181
|
+
'performance optimization techniques',
|
|
182
|
+
'testing strategies',
|
|
183
|
+
'security vulnerability fixes',
|
|
184
|
+
];
|
|
185
|
+
let queryIdx = 0;
|
|
186
|
+
return runBenchmark('Memory Retrieval (HNSW Search)', async () => {
|
|
187
|
+
await searchEntries({
|
|
188
|
+
query: testQueries[queryIdx % testQueries.length],
|
|
189
|
+
namespace: 'patterns',
|
|
190
|
+
limit: 10,
|
|
191
|
+
});
|
|
192
|
+
queryIdx++;
|
|
193
|
+
}, { ...config, targetMs: config.targetMs || 10.0 });
|
|
194
|
+
}
|
|
195
|
+
// ============================================================================
|
|
196
|
+
// Embedding Generation Benchmarks
|
|
197
|
+
// ============================================================================
|
|
198
|
+
export async function benchmarkEmbeddingGeneration(config) {
|
|
199
|
+
// Simulate embedding generation
|
|
200
|
+
const generateEmbedding = async (text) => {
|
|
201
|
+
const dim = 384;
|
|
202
|
+
const embedding = new Float32Array(dim);
|
|
203
|
+
for (let i = 0; i < dim; i++) {
|
|
204
|
+
let hash = 0;
|
|
205
|
+
for (let j = 0; j < text.length; j++) {
|
|
206
|
+
hash = ((hash << 5) - hash + text.charCodeAt(j) * (i + 1)) | 0;
|
|
207
|
+
}
|
|
208
|
+
embedding[i] = Math.sin(hash) * 0.5;
|
|
209
|
+
}
|
|
210
|
+
// Normalize
|
|
211
|
+
let norm = 0;
|
|
212
|
+
for (let i = 0; i < dim; i++) {
|
|
213
|
+
norm += embedding[i] * embedding[i];
|
|
214
|
+
}
|
|
215
|
+
norm = Math.sqrt(norm);
|
|
216
|
+
for (let i = 0; i < dim; i++) {
|
|
217
|
+
embedding[i] /= norm;
|
|
218
|
+
}
|
|
219
|
+
return embedding;
|
|
220
|
+
};
|
|
221
|
+
const testTexts = [
|
|
222
|
+
'Implement user authentication with JWT tokens',
|
|
223
|
+
'Fix memory leak in event handler cleanup',
|
|
224
|
+
'Add unit tests for payment processing module',
|
|
225
|
+
'Refactor database connection pooling',
|
|
226
|
+
'Optimize React component rendering performance',
|
|
227
|
+
];
|
|
228
|
+
let textIdx = 0;
|
|
229
|
+
return runBenchmark('Embedding Generation', async () => {
|
|
230
|
+
await generateEmbedding(testTexts[textIdx % testTexts.length]);
|
|
231
|
+
textIdx++;
|
|
232
|
+
}, { ...config, targetMs: config.targetMs || 5.0 });
|
|
233
|
+
}
|
|
234
|
+
// ============================================================================
|
|
235
|
+
// MoE Routing Benchmarks
|
|
236
|
+
// ============================================================================
|
|
237
|
+
export async function benchmarkMoERouting(config) {
|
|
238
|
+
// Simulate MoE routing
|
|
239
|
+
const experts = ['coder', 'tester', 'reviewer', 'architect', 'security'];
|
|
240
|
+
const route = async (task) => {
|
|
241
|
+
// Simple keyword-based routing simulation
|
|
242
|
+
const keywords = {
|
|
243
|
+
coder: ['implement', 'fix', 'code', 'function'],
|
|
244
|
+
tester: ['test', 'spec', 'coverage', 'unit'],
|
|
245
|
+
reviewer: ['review', 'quality', 'check'],
|
|
246
|
+
architect: ['design', 'architecture', 'pattern'],
|
|
247
|
+
security: ['security', 'auth', 'vulnerability'],
|
|
248
|
+
};
|
|
249
|
+
let bestExpert = 'coder';
|
|
250
|
+
let bestScore = 0;
|
|
251
|
+
for (const [expert, words] of Object.entries(keywords)) {
|
|
252
|
+
let score = 0;
|
|
253
|
+
for (const word of words) {
|
|
254
|
+
if (task.toLowerCase().includes(word)) {
|
|
255
|
+
score++;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (score > bestScore) {
|
|
259
|
+
bestScore = score;
|
|
260
|
+
bestExpert = expert;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return { expert: bestExpert, confidence: 0.7 + Math.random() * 0.25 };
|
|
264
|
+
};
|
|
265
|
+
const testTasks = [
|
|
266
|
+
'Fix authentication bug in login flow',
|
|
267
|
+
'Add new REST API endpoint for users',
|
|
268
|
+
'Write integration tests for checkout',
|
|
269
|
+
'Optimize database query performance',
|
|
270
|
+
'Review security of payment processing',
|
|
271
|
+
];
|
|
272
|
+
let taskIdx = 0;
|
|
273
|
+
return runBenchmark('MoE Expert Routing', async () => {
|
|
274
|
+
await route(testTasks[taskIdx % testTasks.length]);
|
|
275
|
+
taskIdx++;
|
|
276
|
+
}, { ...config, targetMs: config.targetMs || 1.0 });
|
|
277
|
+
}
|
|
278
|
+
// ============================================================================
|
|
279
|
+
// Batch Operations Benchmarks
|
|
280
|
+
// ============================================================================
|
|
281
|
+
export async function benchmarkBatchCosine(config) {
|
|
282
|
+
// Batch cosine similarity
|
|
283
|
+
const batchCosineSim = (query, vectors) => {
|
|
284
|
+
const results = new Float32Array(vectors.length);
|
|
285
|
+
for (let i = 0; i < vectors.length; i++) {
|
|
286
|
+
let dot = 0, normQ = 0, normV = 0;
|
|
287
|
+
for (let j = 0; j < query.length; j++) {
|
|
288
|
+
dot += query[j] * vectors[i][j];
|
|
289
|
+
normQ += query[j] * query[j];
|
|
290
|
+
normV += vectors[i][j] * vectors[i][j];
|
|
291
|
+
}
|
|
292
|
+
results[i] = dot / (Math.sqrt(normQ) * Math.sqrt(normV));
|
|
293
|
+
}
|
|
294
|
+
return results;
|
|
295
|
+
};
|
|
296
|
+
// Generate test vectors
|
|
297
|
+
const dim = 384;
|
|
298
|
+
const numVectors = 1000;
|
|
299
|
+
const query = new Float32Array(dim).map(() => Math.random());
|
|
300
|
+
const vectors = Array.from({ length: numVectors }, () => new Float32Array(dim).map(() => Math.random()));
|
|
301
|
+
return runBenchmark(`Batch Cosine Similarity (${numVectors} vectors)`, async () => {
|
|
302
|
+
batchCosineSim(query, vectors);
|
|
303
|
+
}, { ...config, targetMs: config.targetMs || 2.0 });
|
|
304
|
+
}
|
|
305
|
+
// ============================================================================
|
|
306
|
+
// Full Pre-Training Pipeline Benchmark
|
|
307
|
+
// ============================================================================
|
|
308
|
+
export async function benchmarkPretrainPipeline(config) {
|
|
309
|
+
// Simulate full pre-training pipeline
|
|
310
|
+
const pipeline = async () => {
|
|
311
|
+
// Step 1: Analyze repository structure (simulated)
|
|
312
|
+
const files = Array.from({ length: 50 }, (_, i) => ({
|
|
313
|
+
path: `src/module${i}/index.ts`,
|
|
314
|
+
content: `export function fn${i}() { return ${i}; }`,
|
|
315
|
+
}));
|
|
316
|
+
// Step 2: Generate embeddings for each file
|
|
317
|
+
const embeddings = [];
|
|
318
|
+
for (const file of files) {
|
|
319
|
+
const embedding = new Float32Array(384);
|
|
320
|
+
for (let i = 0; i < 384; i++) {
|
|
321
|
+
embedding[i] = Math.sin(file.path.charCodeAt(i % file.path.length) * (i + 1));
|
|
322
|
+
}
|
|
323
|
+
embeddings.push(embedding);
|
|
324
|
+
}
|
|
325
|
+
// Step 3: Build pattern index (simulated HNSW construction)
|
|
326
|
+
const index = new Map();
|
|
327
|
+
embeddings.forEach((emb, i) => index.set(i, emb));
|
|
328
|
+
// Step 4: Extract patterns
|
|
329
|
+
const patterns = files.slice(0, 10).map((f, i) => ({
|
|
330
|
+
id: `pattern-${i}`,
|
|
331
|
+
type: 'code-structure',
|
|
332
|
+
embedding: embeddings[i],
|
|
333
|
+
confidence: embeddings[i] ? 1.0 : 0, // real: has embedding = confident
|
|
334
|
+
}));
|
|
335
|
+
return { files: files.length, patterns: patterns.length };
|
|
336
|
+
};
|
|
337
|
+
return runBenchmark('Pre-Training Pipeline (50 files)', async () => {
|
|
338
|
+
await pipeline();
|
|
339
|
+
}, { ...config, targetMs: config.targetMs || 100.0 });
|
|
340
|
+
}
|
|
341
|
+
// ============================================================================
|
|
342
|
+
// Full Benchmark Suite
|
|
343
|
+
// ============================================================================
|
|
344
|
+
export async function runPretrainBenchmarkSuite(config = {}) {
|
|
345
|
+
const fullConfig = {
|
|
346
|
+
iterations: config.iterations || 100,
|
|
347
|
+
warmupIterations: config.warmupIterations || 10,
|
|
348
|
+
verbose: config.verbose ?? false,
|
|
349
|
+
};
|
|
350
|
+
console.log('\n\x1b[1m\x1b[36m═══════════════════════════════════════════════════════════════\x1b[0m');
|
|
351
|
+
console.log('\x1b[1m\x1b[36m Self-Learning Pre-Training Benchmark Suite\x1b[0m');
|
|
352
|
+
console.log('\x1b[1m\x1b[36m═══════════════════════════════════════════════════════════════\x1b[0m\n');
|
|
353
|
+
const startTime = performance.now();
|
|
354
|
+
const results = [];
|
|
355
|
+
// Run all benchmarks
|
|
356
|
+
const benchmarks = [
|
|
357
|
+
{ name: 'SONA', fn: () => benchmarkSONAAdaptation(fullConfig) },
|
|
358
|
+
{ name: 'Pattern Learning', fn: () => benchmarkPatternLearning(fullConfig) },
|
|
359
|
+
{ name: 'EWC++', fn: () => benchmarkEWCConsolidation({ ...fullConfig, iterations: 20 }) },
|
|
360
|
+
{ name: 'Memory Retrieval', fn: () => benchmarkMemoryRetrieval(fullConfig) },
|
|
361
|
+
{ name: 'Embedding Gen', fn: () => benchmarkEmbeddingGeneration(fullConfig) },
|
|
362
|
+
{ name: 'MoE Routing', fn: () => benchmarkMoERouting(fullConfig) },
|
|
363
|
+
{ name: 'Batch Cosine', fn: () => benchmarkBatchCosine(fullConfig) },
|
|
364
|
+
{ name: 'Pretrain Pipeline', fn: () => benchmarkPretrainPipeline({ ...fullConfig, iterations: 10 }) },
|
|
365
|
+
];
|
|
366
|
+
for (const benchmark of benchmarks) {
|
|
367
|
+
console.log(`\x1b[33m► Running ${benchmark.name} benchmark...\x1b[0m`);
|
|
368
|
+
try {
|
|
369
|
+
const result = await benchmark.fn();
|
|
370
|
+
results.push(result);
|
|
371
|
+
console.log(formatBenchmarkResult(result));
|
|
372
|
+
console.log();
|
|
373
|
+
}
|
|
374
|
+
catch (error) {
|
|
375
|
+
console.error(`\x1b[31m✗ ${benchmark.name} failed: ${error}\x1b[0m\n`);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
const totalDuration = performance.now() - startTime;
|
|
379
|
+
// Summary
|
|
380
|
+
console.log('\x1b[1m\x1b[36m═══════════════════════════════════════════════════════════════\x1b[0m');
|
|
381
|
+
console.log('\x1b[1m Summary\x1b[0m');
|
|
382
|
+
console.log('\x1b[36m───────────────────────────────────────────────────────────────\x1b[0m');
|
|
383
|
+
const passed = results.filter(r => r.targetMet).length;
|
|
384
|
+
const total = results.length;
|
|
385
|
+
console.log(` Total benchmarks: ${total}`);
|
|
386
|
+
console.log(` Targets met: \x1b[${passed === total ? '32' : '33'}m${passed}/${total}\x1b[0m`);
|
|
387
|
+
console.log(` Total duration: ${(totalDuration / 1000).toFixed(2)}s`);
|
|
388
|
+
console.log('\x1b[1m\x1b[36m═══════════════════════════════════════════════════════════════\x1b[0m\n');
|
|
389
|
+
return {
|
|
390
|
+
name: 'pretrain-benchmark-suite',
|
|
391
|
+
results,
|
|
392
|
+
totalDurationMs: totalDuration,
|
|
393
|
+
timestamp: new Date().toISOString(),
|
|
394
|
+
environment: {
|
|
395
|
+
nodeVersion: process.version,
|
|
396
|
+
platform: process.platform,
|
|
397
|
+
arch: process.arch,
|
|
398
|
+
cpuCount: (await import('node:os')).cpus().length,
|
|
399
|
+
},
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
// Export for CLI usage
|
|
403
|
+
export default runPretrainBenchmarkSuite;
|
|
404
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -20,7 +20,8 @@ export async function clickElement(client, sessionId, ref, options = {}) {
|
|
|
20
20
|
}
|
|
21
21
|
export async function clickPoint(client, sessionId, x, y, options = {}) {
|
|
22
22
|
const button = options.button ?? 'left';
|
|
23
|
-
|
|
23
|
+
// Cap clickCount to prevent unbounded loop DoS
|
|
24
|
+
const clickCount = Math.min(Math.max(1, Math.floor(options.clickCount ?? 1)), 100);
|
|
24
25
|
const modifiers = options.modifiers ?? 0;
|
|
25
26
|
const shared = { x, y, button, modifiers };
|
|
26
27
|
const buttonsMask = button === 'right' ? 2 : button === 'middle' ? 4 : 1;
|
|
@@ -69,7 +70,9 @@ export async function fillElement(client, sessionId, ref, value) {
|
|
|
69
70
|
await typeText(client, sessionId, value);
|
|
70
71
|
}
|
|
71
72
|
export async function typeText(client, sessionId, text) {
|
|
72
|
-
|
|
73
|
+
// Cap to 100 KB to prevent OOM in CDP message serializer
|
|
74
|
+
const safeText = text.length > 102_400 ? text.slice(0, 102_400) : text;
|
|
75
|
+
await client.send('Input.insertText', { text: safeText }, sessionId);
|
|
73
76
|
}
|
|
74
77
|
export async function pressKeyCombo(client, sessionId, key, modifiers) {
|
|
75
78
|
const { text: _text, ...keyInfo } = resolveKey(key);
|
|
@@ -184,6 +187,8 @@ function resolveKey(key) {
|
|
|
184
187
|
return { key, code: key };
|
|
185
188
|
}
|
|
186
189
|
export async function scrollElement(client, sessionId, direction, amount = 300, ref) {
|
|
190
|
+
// Cap scroll amount to prevent extreme delta values
|
|
191
|
+
amount = Math.min(Math.max(1, Math.floor(amount)), 100_000);
|
|
187
192
|
let x = 0;
|
|
188
193
|
let y = 0;
|
|
189
194
|
let deltaX = 0;
|
|
@@ -351,7 +356,9 @@ export async function readClipboard(client, sessionId) {
|
|
|
351
356
|
return result;
|
|
352
357
|
}
|
|
353
358
|
export async function writeClipboard(client, sessionId, text) {
|
|
354
|
-
|
|
359
|
+
// Cap to 100 KB to prevent OOM when serializing the CDP expression
|
|
360
|
+
const safeText = text.length > 102_400 ? text.slice(0, 102_400) : text;
|
|
361
|
+
await evaluateJs(client, sessionId, `navigator.clipboard.writeText(${JSON.stringify(safeText)})`);
|
|
355
362
|
}
|
|
356
363
|
export async function pushState(client, sessionId, url) {
|
|
357
364
|
// Try Next.js router first, then fallback to history.pushState
|
|
@@ -41,7 +41,12 @@ export async function isPortOpen(port) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
export async function launchBrowser(config = {}) {
|
|
44
|
-
const
|
|
44
|
+
const rawPort = config.port ?? DEFAULT_PORT;
|
|
45
|
+
// Validate port is in a safe range for localhost CDP debugging
|
|
46
|
+
if (!Number.isInteger(rawPort) || rawPort < 1024 || rawPort > 65535) {
|
|
47
|
+
throw new Error(`Invalid port: ${rawPort}. Must be an integer between 1024 and 65535.`);
|
|
48
|
+
}
|
|
49
|
+
const port = rawPort;
|
|
45
50
|
if (await isPortOpen(port)) {
|
|
46
51
|
return port;
|
|
47
52
|
}
|
|
@@ -69,7 +74,9 @@ export async function launchBrowser(config = {}) {
|
|
|
69
74
|
if (config.headless !== false) {
|
|
70
75
|
defaultArgs.push('--headless=new');
|
|
71
76
|
}
|
|
72
|
-
|
|
77
|
+
// Cap caller-supplied args to prevent memory exhaustion via huge argument arrays
|
|
78
|
+
const callerArgs = (config.args ?? []).slice(0, 50);
|
|
79
|
+
const args = [...defaultArgs, ...callerArgs];
|
|
73
80
|
const child = spawn(chromePath, args, {
|
|
74
81
|
detached: true,
|
|
75
82
|
stdio: 'ignore',
|
|
@@ -122,6 +129,9 @@ export async function connectToTarget(port, targetId) {
|
|
|
122
129
|
return { client, target, sessionId };
|
|
123
130
|
}
|
|
124
131
|
export async function openUrl(client, sessionId, url) {
|
|
132
|
+
// Cap to 2 MB to prevent OOM in CDP message serializer (e.g. data: URI attacks)
|
|
133
|
+
if (url.length > 2_097_152)
|
|
134
|
+
throw new Error('URL exceeds 2 MB limit');
|
|
125
135
|
await client.send('Page.navigate', { url }, sessionId);
|
|
126
136
|
await waitForNetworkIdle(client, sessionId, 500, 30_000);
|
|
127
137
|
}
|
|
@@ -68,6 +68,11 @@ export class CdpClient {
|
|
|
68
68
|
reject(new Error('CDP not connected'));
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
+
// Cap in-flight commands to prevent unbounded Map growth
|
|
72
|
+
if (this.pendingCommands.size >= 1000) {
|
|
73
|
+
reject(new Error('CDP command queue full (>1000 in-flight commands)'));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
71
76
|
const id = this.nextId++;
|
|
72
77
|
const cmd = { id, method, params };
|
|
73
78
|
if (sessionId)
|
|
@@ -88,7 +93,12 @@ export class CdpClient {
|
|
|
88
93
|
if (!this.eventListeners.has(event)) {
|
|
89
94
|
this.eventListeners.set(event, new Set());
|
|
90
95
|
}
|
|
91
|
-
this.eventListeners.get(event)
|
|
96
|
+
const listeners = this.eventListeners.get(event);
|
|
97
|
+
// Cap listeners per event to prevent unbounded Set growth
|
|
98
|
+
if (listeners.size >= 100) {
|
|
99
|
+
throw new Error(`CDP event listener limit reached for event: ${event}`);
|
|
100
|
+
}
|
|
101
|
+
listeners.add(fn);
|
|
92
102
|
return () => this.eventListeners.get(event)?.delete(fn);
|
|
93
103
|
}
|
|
94
104
|
once(event, sessionId) {
|
|
@@ -120,16 +130,24 @@ export class CdpClient {
|
|
|
120
130
|
return this.connected;
|
|
121
131
|
}
|
|
122
132
|
}
|
|
133
|
+
const CDP_RESPONSE_SIZE_LIMIT = 10 * 1024 * 1024; // 10 MB
|
|
134
|
+
async function readCdpJson(res) {
|
|
135
|
+
const text = await res.text();
|
|
136
|
+
if (text.length > CDP_RESPONSE_SIZE_LIMIT) {
|
|
137
|
+
throw new Error(`CDP response too large: ${text.length} bytes`);
|
|
138
|
+
}
|
|
139
|
+
return JSON.parse(text);
|
|
140
|
+
}
|
|
123
141
|
export async function fetchTargets(port) {
|
|
124
142
|
const res = await fetch(`http://127.0.0.1:${port}/json/list`);
|
|
125
143
|
if (!res.ok)
|
|
126
144
|
throw new Error(`Failed to fetch targets: ${res.statusText}`);
|
|
127
|
-
return res
|
|
145
|
+
return readCdpJson(res);
|
|
128
146
|
}
|
|
129
147
|
export async function fetchNewTarget(port, url) {
|
|
130
148
|
const res = await fetch(`http://127.0.0.1:${port}/json/new?${url}`);
|
|
131
149
|
if (!res.ok)
|
|
132
150
|
throw new Error(`Failed to create target: ${res.statusText}`);
|
|
133
|
-
return res
|
|
151
|
+
return readCdpJson(res);
|
|
134
152
|
}
|
|
135
153
|
//# sourceMappingURL=cdp.js.map
|
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
import { writeFile } from 'fs/promises';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import { tmpdir } from 'os';
|
|
2
|
+
import { join, resolve, relative, isAbsolute } from 'path';
|
|
3
|
+
import { tmpdir, homedir } from 'os';
|
|
4
|
+
const MAX_CONCURRENT_SESSIONS = 100;
|
|
5
|
+
const MAX_REQUESTS_PER_SESSION = 5_000;
|
|
4
6
|
const _sessions = new Map();
|
|
7
|
+
/** Validate output path is within cwd or home dir to prevent path traversal. */
|
|
8
|
+
function safeOutputPath(p) {
|
|
9
|
+
const resolved = resolve(p);
|
|
10
|
+
const cwd = process.cwd();
|
|
11
|
+
const home = homedir();
|
|
12
|
+
const relCwd = relative(cwd, resolved);
|
|
13
|
+
const relHome = relative(home, resolved);
|
|
14
|
+
if ((!relCwd.startsWith('..') && !isAbsolute(relCwd)) ||
|
|
15
|
+
(!relHome.startsWith('..') && !isAbsolute(relHome))) {
|
|
16
|
+
return resolved;
|
|
17
|
+
}
|
|
18
|
+
// Reject out-of-scope paths — fall back to tmpdir
|
|
19
|
+
return join(tmpdir(), `monomind-har-${Date.now()}.har`);
|
|
20
|
+
}
|
|
5
21
|
export async function startHarRecording(client, sessionId) {
|
|
6
22
|
if (_sessions.has(sessionId))
|
|
7
23
|
throw new Error('HAR recording already in progress');
|
|
24
|
+
if (_sessions.size >= MAX_CONCURRENT_SESSIONS) {
|
|
25
|
+
throw new Error(`HAR recording limit reached (max ${MAX_CONCURRENT_SESSIONS} concurrent sessions)`);
|
|
26
|
+
}
|
|
8
27
|
const requests = new Map();
|
|
9
28
|
const startTime = Date.now();
|
|
10
29
|
const startWallMs = startTime;
|
|
@@ -17,6 +36,9 @@ export async function startHarRecording(client, sessionId) {
|
|
|
17
36
|
const offReq = client.on('Network.requestWillBeSent', (params, sid) => {
|
|
18
37
|
if (sid !== sessionId)
|
|
19
38
|
return;
|
|
39
|
+
// Cap to prevent unbounded memory growth on high-traffic pages
|
|
40
|
+
if (requests.size >= MAX_REQUESTS_PER_SESSION)
|
|
41
|
+
return;
|
|
20
42
|
const p = params;
|
|
21
43
|
requests.set(p.requestId, {
|
|
22
44
|
id: p.requestId,
|
|
@@ -78,9 +100,9 @@ export async function stopHarRecording(client, sessionId, outputPath, captureRes
|
|
|
78
100
|
}
|
|
79
101
|
}
|
|
80
102
|
const har = buildHar(Array.from(state.requests.values()), state.startTime);
|
|
81
|
-
const
|
|
82
|
-
await writeFile(
|
|
83
|
-
return
|
|
103
|
+
const safePath = outputPath ? safeOutputPath(outputPath) : join(tmpdir(), `monomind-har-${Date.now()}.har`);
|
|
104
|
+
await writeFile(safePath, JSON.stringify(har, null, 2));
|
|
105
|
+
return safePath;
|
|
84
106
|
}
|
|
85
107
|
export function getHarStatus(sessionId) {
|
|
86
108
|
const state = _sessions.get(sessionId);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WASM Agent CLI Subcommands
|
|
3
|
+
*
|
|
4
|
+
* Exposes @monoes/rvagent-wasm operations via the `agent` CLI command.
|
|
5
|
+
* Wraps functions from monovector/agent-wasm.ts for CLI usage.
|
|
6
|
+
*/
|
|
7
|
+
import type { Command } from '../types.js';
|
|
8
|
+
export declare const wasmStatusCommand: Command;
|
|
9
|
+
export declare const wasmCreateCommand: Command;
|
|
10
|
+
export declare const wasmPromptCommand: Command;
|
|
11
|
+
export declare const wasmGalleryCommand: Command;
|
|
12
|
+
/** All WASM subcommands for the agent command */
|
|
13
|
+
export declare const wasmSubcommands: Command[];
|
|
14
|
+
//# sourceMappingURL=agent-wasm.d.ts.map
|