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
|
@@ -33,6 +33,11 @@ export class RateLimiter {
|
|
|
33
33
|
* Check if a request is allowed
|
|
34
34
|
*/
|
|
35
35
|
check(operation, userId) {
|
|
36
|
+
// Cap operation and userId lengths so bucket keys cannot inflate the Map
|
|
37
|
+
const safeOp = typeof operation === 'string' ? operation.slice(0, 256) : 'unknown';
|
|
38
|
+
const safeUserId = userId ? userId.slice(0, 256) : undefined;
|
|
39
|
+
operation = safeOp;
|
|
40
|
+
userId = safeUserId;
|
|
36
41
|
// Check whitelist
|
|
37
42
|
if (this.config.whitelist.includes(operation)) {
|
|
38
43
|
return { allowed: true, remaining: Infinity, resetAt: 0 };
|
|
@@ -157,10 +162,14 @@ export class RateLimiter {
|
|
|
157
162
|
// Private Methods
|
|
158
163
|
// ============================================================================
|
|
159
164
|
getLimits(operation) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
165
|
+
// Object.hasOwn guards against prototype-pollution: if someone passes
|
|
166
|
+
// '__proto__' as the operation name, falling through to the default is safe.
|
|
167
|
+
return (Object.hasOwn(this.config.operationLimits, operation)
|
|
168
|
+
? this.config.operationLimits[operation]
|
|
169
|
+
: {
|
|
170
|
+
maxRequests: this.config.maxRequests,
|
|
171
|
+
windowMs: this.config.windowMs,
|
|
172
|
+
});
|
|
164
173
|
}
|
|
165
174
|
createBucket() {
|
|
166
175
|
return {
|
|
@@ -59,13 +59,15 @@ function calculateDelay(attempt, config, strategy = 'exponential') {
|
|
|
59
59
|
return Math.round(Math.max(0, delay));
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
* Fibonacci helper for fibonacci backoff
|
|
62
|
+
* Fibonacci helper for fibonacci backoff — capped at n=40 to prevent
|
|
63
|
+
* excessively long loops when maxAttempts is set to a large value.
|
|
63
64
|
*/
|
|
64
65
|
function fibonacci(n) {
|
|
65
|
-
|
|
66
|
+
const capped = Math.min(n, 40);
|
|
67
|
+
if (capped <= 1)
|
|
66
68
|
return 1;
|
|
67
69
|
let a = 1, b = 1;
|
|
68
|
-
for (let i = 2; i <=
|
|
70
|
+
for (let i = 2; i <= capped; i++) {
|
|
69
71
|
[a, b] = [b, a + b];
|
|
70
72
|
}
|
|
71
73
|
return b;
|
|
@@ -99,8 +101,12 @@ function sleep(ms) {
|
|
|
99
101
|
*/
|
|
100
102
|
export async function withRetry(fn, config = {}, strategy = 'exponential') {
|
|
101
103
|
const finalConfig = { ...DEFAULT_CONFIG, ...config };
|
|
104
|
+
// Clamp maxAttempts and maxDelayMs to safe ranges to prevent runaway retry loops
|
|
105
|
+
finalConfig.maxAttempts = Math.min(Math.max(1, finalConfig.maxAttempts), 100);
|
|
106
|
+
finalConfig.maxDelayMs = Math.min(Math.max(0, finalConfig.maxDelayMs), 300_000); // 5 min ceiling
|
|
102
107
|
const startTime = Date.now();
|
|
103
108
|
const retryHistory = [];
|
|
109
|
+
const MAX_RETRY_HISTORY = 100;
|
|
104
110
|
let lastError;
|
|
105
111
|
let attempt = 0;
|
|
106
112
|
while (attempt < finalConfig.maxAttempts) {
|
|
@@ -129,12 +135,14 @@ export async function withRetry(fn, config = {}, strategy = 'exponential') {
|
|
|
129
135
|
}
|
|
130
136
|
// Calculate delay
|
|
131
137
|
const delay = calculateDelay(attempt, finalConfig, strategy);
|
|
132
|
-
// Record retry
|
|
133
|
-
retryHistory.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
// Record retry (cap history size and error message length to prevent OOM)
|
|
139
|
+
if (retryHistory.length < MAX_RETRY_HISTORY) {
|
|
140
|
+
retryHistory.push({
|
|
141
|
+
attempt,
|
|
142
|
+
error: lastError.message.slice(0, 512),
|
|
143
|
+
delayMs: delay,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
138
146
|
// Call retry callback
|
|
139
147
|
if (finalConfig.onRetry) {
|
|
140
148
|
finalConfig.onRetry(lastError, attempt, delay);
|
|
@@ -22,12 +22,16 @@ import { createSemanticRouting } from './embedder.js';
|
|
|
22
22
|
// don't land on stdout and corrupt the single JSON result line the parent
|
|
23
23
|
// parses. Must be set before the (lazy) transformers import in embedder.ts.
|
|
24
24
|
process.env.TRANSFORMERS_VERBOSITY ??= 'error';
|
|
25
|
+
/** Max task string length before it's silently truncated — prevents OOM in the embedding model. */
|
|
26
|
+
const MAX_TASK_LENGTH = 2_000;
|
|
25
27
|
async function main() {
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
28
|
+
const rawTask = process.argv[2];
|
|
29
|
+
if (!rawTask) {
|
|
28
30
|
process.stderr.write('embed-worker: missing task argument\n');
|
|
29
31
|
process.exit(2);
|
|
30
32
|
}
|
|
33
|
+
// Cap the task to prevent OOM when an oversized string is passed to the embedding model.
|
|
34
|
+
const task = rawTask.length > MAX_TASK_LENGTH ? rawTask.slice(0, MAX_TASK_LENGTH) : rawTask;
|
|
31
35
|
const { RouteLayer, ALL_ROUTES } = await import('@monomind/routing');
|
|
32
36
|
const semantic = await createSemanticRouting(ALL_ROUTES);
|
|
33
37
|
if (!semantic) {
|
|
Binary file
|
|
@@ -16,6 +16,8 @@ import { spawn, execSync } from 'child_process';
|
|
|
16
16
|
import { tmpdir } from 'os';
|
|
17
17
|
/** Default model for routing fallback — Haiku is fast and cheap for slug classification. */
|
|
18
18
|
const DEFAULT_ROUTING_MODEL = 'haiku';
|
|
19
|
+
/** Runtime-validated set of allowed model aliases. */
|
|
20
|
+
const ALLOWED_MODELS = new Set(['haiku', 'sonnet', 'opus']);
|
|
19
21
|
/**
|
|
20
22
|
* Max time to wait for a single classification before giving up.
|
|
21
23
|
* `claude --print` is a full headless session (cold start ~10s, can spike),
|
|
@@ -23,6 +25,8 @@ const DEFAULT_ROUTING_MODEL = 'haiku';
|
|
|
23
25
|
* on timeout rather than blocking the caller.
|
|
24
26
|
*/
|
|
25
27
|
const DEFAULT_TIMEOUT_MS = 45_000;
|
|
28
|
+
/** Hard upper cap on caller-supplied timeoutMs — prevents disabling the SIGTERM/SIGKILL guard. */
|
|
29
|
+
const MAX_TIMEOUT_MS = 120_000;
|
|
26
30
|
/** Cap captured output so a runaway child can't grow parent memory unbounded. */
|
|
27
31
|
const MAX_OUTPUT = 1024 * 1024; // 1 MB — a slug response is tiny
|
|
28
32
|
let claudeAvailable = null;
|
|
@@ -49,8 +53,15 @@ export function isClaudeCodeAvailable() {
|
|
|
49
53
|
export function createClaudeLLMCaller(options = {}) {
|
|
50
54
|
if (!isClaudeCodeAvailable())
|
|
51
55
|
return null;
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
// Runtime enum guard — TypeScript union is compile-time only; JS callers
|
|
57
|
+
// could otherwise inject an arbitrary string into the --model flag.
|
|
58
|
+
const rawModel = options.model ?? DEFAULT_ROUTING_MODEL;
|
|
59
|
+
const model = ALLOWED_MODELS.has(rawModel) ? rawModel : DEFAULT_ROUTING_MODEL;
|
|
60
|
+
// Cap caller-supplied timeout so a huge value can't disable the SIGTERM/SIGKILL guard.
|
|
61
|
+
const rawTimeout = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
62
|
+
const timeoutMs = Math.min(typeof rawTimeout === 'number' && Number.isFinite(rawTimeout) && rawTimeout > 0
|
|
63
|
+
? rawTimeout
|
|
64
|
+
: DEFAULT_TIMEOUT_MS, MAX_TIMEOUT_MS);
|
|
54
65
|
const cwd = options.cwd ?? tmpdir();
|
|
55
66
|
return (prompt) => new Promise((resolve, reject) => {
|
|
56
67
|
const env = { ...process.env };
|
|
@@ -25,12 +25,20 @@ const WORKER_PATH = join(dirname(fileURLToPath(import.meta.url)), 'embed-worker.
|
|
|
25
25
|
const WORKER_TIMEOUT_MS = 90_000;
|
|
26
26
|
/** Cap worker stdout so a runaway child can't grow parent memory unbounded. */
|
|
27
27
|
const MAX_WORKER_OUTPUT = 4 * 1024 * 1024; // 4 MB
|
|
28
|
+
/** Cap the task string length to prevent OOM/DoS via oversized argv. */
|
|
29
|
+
const MAX_TASK_LENGTH = 2_000;
|
|
30
|
+
/** Cap stderr reflected in error messages to prevent log-inflation attacks. */
|
|
31
|
+
const MAX_STDERR_IN_ERROR = 500;
|
|
32
|
+
/** Cap allScores array passed to the LLM fallback to prevent downstream OOM. */
|
|
33
|
+
const MAX_ALL_SCORES = 100;
|
|
28
34
|
/** Marker the worker prefixes its result line with (see embed-worker.ts). */
|
|
29
35
|
const RESULT_MARKER = '__ROUTE_RESULT__';
|
|
30
36
|
/** Run the embedding worker for one task. Resolves the RouteResult, or rejects. */
|
|
31
37
|
function runWorker(task) {
|
|
38
|
+
// Cap task length before passing as argv to prevent OOM/DoS via oversized args.
|
|
39
|
+
const safeTask = task.length > MAX_TASK_LENGTH ? task.slice(0, MAX_TASK_LENGTH) : task;
|
|
32
40
|
return new Promise((resolve, reject) => {
|
|
33
|
-
const child = spawn(process.execPath, [WORKER_PATH,
|
|
41
|
+
const child = spawn(process.execPath, [WORKER_PATH, safeTask], {
|
|
34
42
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
35
43
|
windowsHide: true,
|
|
36
44
|
});
|
|
@@ -75,7 +83,10 @@ function runWorker(task) {
|
|
|
75
83
|
settled = true;
|
|
76
84
|
clearTimeout(timer);
|
|
77
85
|
if (code !== 0) {
|
|
78
|
-
|
|
86
|
+
// Truncate stderr before embedding in Error to prevent log-inflation via
|
|
87
|
+
// a malicious or runaway child writing oversized diagnostic output.
|
|
88
|
+
const stderrSnippet = stderr.trim().slice(0, MAX_STDERR_IN_ERROR);
|
|
89
|
+
reject(new Error(stderrSnippet || `worker exited ${code}`));
|
|
79
90
|
return;
|
|
80
91
|
}
|
|
81
92
|
// Extract the marked result line — model-loader output may have written
|
|
@@ -130,8 +141,12 @@ export async function createConfiguredRouteLayer(opts = {}) {
|
|
|
130
141
|
}
|
|
131
142
|
// 3. Below threshold → Claude fallback in the parent, reusing scores.
|
|
132
143
|
if (llmCaller && Array.isArray(semantic.allScores) && semantic.allScores.length) {
|
|
144
|
+
// Cap allScores to prevent downstream OOM if the worker sends an oversized array.
|
|
145
|
+
const scores = semantic.allScores.length > MAX_ALL_SCORES
|
|
146
|
+
? semantic.allScores.slice(0, MAX_ALL_SCORES)
|
|
147
|
+
: semantic.allScores;
|
|
133
148
|
const fallback = new LLMFallbackRouter({ llmCaller, model: 'haiku' });
|
|
134
|
-
return fallback.classify(taskDescription, ALL_ROUTES,
|
|
149
|
+
return fallback.classify(taskDescription, ALL_ROUTES, scores);
|
|
135
150
|
}
|
|
136
151
|
if (!opts.debug)
|
|
137
152
|
delete semantic.allScores;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Headless Runtime for Background Workers
|
|
4
|
+
* Runs without TTY for daemon processes and scheduled tasks
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* npx @monomind/cli headless --worker <type>
|
|
8
|
+
* npx @monomind/cli headless --daemon
|
|
9
|
+
* npx @monomind/cli headless --benchmark
|
|
10
|
+
*
|
|
11
|
+
* Environment:
|
|
12
|
+
* MONOMIND_HEADLESS=true
|
|
13
|
+
* CLAUDE_CODE_HEADLESS=true
|
|
14
|
+
*
|
|
15
|
+
* @module v1/cli/runtime/headless
|
|
16
|
+
*/
|
|
17
|
+
import { type HeadlessWorkerType } from '../services/headless-worker-executor.js';
|
|
18
|
+
interface HeadlessConfig {
|
|
19
|
+
mode: 'worker' | 'daemon' | 'benchmark' | 'status';
|
|
20
|
+
workerType?: HeadlessWorkerType;
|
|
21
|
+
timeout?: number;
|
|
22
|
+
verbose?: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface BenchmarkResults {
|
|
25
|
+
sona: {
|
|
26
|
+
avgMs: number;
|
|
27
|
+
targetMet: boolean;
|
|
28
|
+
};
|
|
29
|
+
flashAttention: {
|
|
30
|
+
throughputPerMs: number;
|
|
31
|
+
speedup: number;
|
|
32
|
+
};
|
|
33
|
+
hnsw: {
|
|
34
|
+
entriesIndexed: number;
|
|
35
|
+
searchTime: number;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Run a specific worker
|
|
40
|
+
*/
|
|
41
|
+
declare function runWorker(workerType: HeadlessWorkerType, timeout: number): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Run daemon mode
|
|
44
|
+
*/
|
|
45
|
+
declare function runDaemon(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Run benchmarks
|
|
48
|
+
*/
|
|
49
|
+
declare function runBenchmarks(): Promise<BenchmarkResults>;
|
|
50
|
+
/**
|
|
51
|
+
* Show system status
|
|
52
|
+
*/
|
|
53
|
+
declare function showStatus(): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Main entry point
|
|
56
|
+
*/
|
|
57
|
+
declare function main(): Promise<void>;
|
|
58
|
+
export { main, runWorker, runDaemon, runBenchmarks, showStatus };
|
|
59
|
+
export type { HeadlessConfig, BenchmarkResults };
|
|
60
|
+
//# sourceMappingURL=headless.d.ts.map
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Headless Runtime for Background Workers
|
|
4
|
+
* Runs without TTY for daemon processes and scheduled tasks
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* npx @monomind/cli headless --worker <type>
|
|
8
|
+
* npx @monomind/cli headless --daemon
|
|
9
|
+
* npx @monomind/cli headless --benchmark
|
|
10
|
+
*
|
|
11
|
+
* Environment:
|
|
12
|
+
* MONOMIND_HEADLESS=true
|
|
13
|
+
* CLAUDE_CODE_HEADLESS=true
|
|
14
|
+
*
|
|
15
|
+
* @module v1/cli/runtime/headless
|
|
16
|
+
*/
|
|
17
|
+
import { HeadlessWorkerExecutor, HEADLESS_WORKER_TYPES } from '../services/headless-worker-executor.js';
|
|
18
|
+
import { getDaemon, startDaemon, stopDaemon } from '../services/worker-daemon.js';
|
|
19
|
+
import { initializeIntelligence, benchmarkAdaptation, getIntelligenceStats } from '../memory/intelligence.js';
|
|
20
|
+
import { getHNSWStatus, batchCosineSim, flashAttentionSearch } from '../memory/memory-initializer.js';
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// Main Runtime
|
|
23
|
+
// ============================================================================
|
|
24
|
+
/**
|
|
25
|
+
* Parse command line arguments
|
|
26
|
+
*/
|
|
27
|
+
function parseArgs() {
|
|
28
|
+
const args = process.argv.slice(2);
|
|
29
|
+
const config = {
|
|
30
|
+
mode: 'status',
|
|
31
|
+
verbose: false
|
|
32
|
+
};
|
|
33
|
+
for (let i = 0; i < args.length; i++) {
|
|
34
|
+
const arg = args[i];
|
|
35
|
+
if (arg === '--worker' || arg === '-w') {
|
|
36
|
+
config.mode = 'worker';
|
|
37
|
+
config.workerType = args[++i];
|
|
38
|
+
}
|
|
39
|
+
else if (arg === '--daemon' || arg === '-d') {
|
|
40
|
+
config.mode = 'daemon';
|
|
41
|
+
}
|
|
42
|
+
else if (arg === '--benchmark' || arg === '-b') {
|
|
43
|
+
config.mode = 'benchmark';
|
|
44
|
+
}
|
|
45
|
+
else if (arg === '--status' || arg === '-s') {
|
|
46
|
+
config.mode = 'status';
|
|
47
|
+
}
|
|
48
|
+
else if (arg === '--timeout' || arg === '-t') {
|
|
49
|
+
config.timeout = parseInt(args[++i], 10) || 60000;
|
|
50
|
+
}
|
|
51
|
+
else if (arg === '--verbose' || arg === '-v') {
|
|
52
|
+
config.verbose = true;
|
|
53
|
+
}
|
|
54
|
+
else if (arg === '--help' || arg === '-h') {
|
|
55
|
+
showHelp();
|
|
56
|
+
process.exit(0);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return config;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Show help message
|
|
63
|
+
*/
|
|
64
|
+
function showHelp() {
|
|
65
|
+
console.log(`
|
|
66
|
+
Headless Runtime for Monomind
|
|
67
|
+
|
|
68
|
+
Usage:
|
|
69
|
+
headless --worker <type> Run a specific worker
|
|
70
|
+
headless --daemon Start background daemon
|
|
71
|
+
headless --benchmark Run performance benchmarks
|
|
72
|
+
headless --status Show system status
|
|
73
|
+
|
|
74
|
+
Workers: ${HEADLESS_WORKER_TYPES.join(', ')}
|
|
75
|
+
|
|
76
|
+
Options:
|
|
77
|
+
-w, --worker <type> Worker type to run
|
|
78
|
+
-d, --daemon Run as daemon
|
|
79
|
+
-b, --benchmark Run benchmarks
|
|
80
|
+
-s, --status Show status
|
|
81
|
+
-t, --timeout <ms> Execution timeout (default: 60000)
|
|
82
|
+
-v, --verbose Verbose output
|
|
83
|
+
-h, --help Show help
|
|
84
|
+
|
|
85
|
+
Environment:
|
|
86
|
+
MONOMIND_HEADLESS=true Enable headless mode
|
|
87
|
+
CLAUDE_CODE_HEADLESS=true Enable Claude Code headless
|
|
88
|
+
|
|
89
|
+
Examples:
|
|
90
|
+
headless --worker audit --timeout 120000
|
|
91
|
+
headless --daemon
|
|
92
|
+
headless --benchmark
|
|
93
|
+
`);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Run a specific worker
|
|
97
|
+
*/
|
|
98
|
+
async function runWorker(workerType, timeout) {
|
|
99
|
+
console.log(`[Headless] Starting worker: ${workerType}`);
|
|
100
|
+
const executor = new HeadlessWorkerExecutor(process.cwd(), {
|
|
101
|
+
maxConcurrent: 1,
|
|
102
|
+
defaultTimeoutMs: timeout
|
|
103
|
+
});
|
|
104
|
+
try {
|
|
105
|
+
const result = await executor.execute(workerType, {
|
|
106
|
+
timeoutMs: timeout,
|
|
107
|
+
model: 'sonnet',
|
|
108
|
+
sandbox: 'permissive'
|
|
109
|
+
});
|
|
110
|
+
if (result.success) {
|
|
111
|
+
console.log(`[Headless] Worker ${workerType} completed successfully`);
|
|
112
|
+
console.log(`[Headless] Duration: ${result.durationMs}ms`);
|
|
113
|
+
if (result.output) {
|
|
114
|
+
console.log(`[Headless] Output: ${JSON.stringify(result.output).slice(0, 500)}...`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
console.error(`[Headless] Worker ${workerType} failed: ${result.error}`);
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
// executor doesn't have shutdown, just let it be garbage collected
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Run daemon mode
|
|
128
|
+
*/
|
|
129
|
+
async function runDaemon() {
|
|
130
|
+
console.log('[Headless] Starting daemon mode...');
|
|
131
|
+
// Start the daemon
|
|
132
|
+
const daemon = await startDaemon(process.cwd());
|
|
133
|
+
console.log('[Headless] Daemon started');
|
|
134
|
+
console.log('[Headless] Press Ctrl+C to stop');
|
|
135
|
+
// Handle shutdown
|
|
136
|
+
process.on('SIGINT', async () => {
|
|
137
|
+
console.log('\n[Headless] Shutting down daemon...');
|
|
138
|
+
await stopDaemon();
|
|
139
|
+
process.exit(0);
|
|
140
|
+
});
|
|
141
|
+
process.on('SIGTERM', async () => {
|
|
142
|
+
console.log('\n[Headless] Received SIGTERM, shutting down...');
|
|
143
|
+
await stopDaemon();
|
|
144
|
+
process.exit(0);
|
|
145
|
+
});
|
|
146
|
+
// Keep process running
|
|
147
|
+
await new Promise(() => { });
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Run benchmarks
|
|
151
|
+
*/
|
|
152
|
+
async function runBenchmarks() {
|
|
153
|
+
console.log('=== Monomind Performance Benchmarks ===\n');
|
|
154
|
+
// Initialize intelligence
|
|
155
|
+
await initializeIntelligence();
|
|
156
|
+
// SONA Benchmark
|
|
157
|
+
console.log('1. SONA Adaptation Benchmark (10,000 iterations)...');
|
|
158
|
+
const sonaResult = benchmarkAdaptation(10000);
|
|
159
|
+
console.log(` Average: ${sonaResult.avgMs.toFixed(4)}ms`);
|
|
160
|
+
console.log(` Target (<0.05ms): ${sonaResult.targetMet ? '✅ ACHIEVED' : '❌ NOT MET'}`);
|
|
161
|
+
// Flash Attention Benchmark
|
|
162
|
+
console.log('\n2. Flash Attention Search Benchmark...');
|
|
163
|
+
const dim = 384;
|
|
164
|
+
const count = 10000;
|
|
165
|
+
const query = new Float32Array(dim).map(() => Math.random() - 0.5);
|
|
166
|
+
const vectors = Array.from({ length: count }, () => new Float32Array(dim).map(() => Math.random() - 0.5));
|
|
167
|
+
// Warmup
|
|
168
|
+
flashAttentionSearch(query, vectors, { k: 10 });
|
|
169
|
+
const flashStart = performance.now();
|
|
170
|
+
for (let i = 0; i < 10; i++) {
|
|
171
|
+
flashAttentionSearch(query, vectors, { k: 10 });
|
|
172
|
+
}
|
|
173
|
+
const flashTime = (performance.now() - flashStart) / 10;
|
|
174
|
+
const throughput = count / flashTime;
|
|
175
|
+
// Brute force comparison
|
|
176
|
+
const bruteStart = performance.now();
|
|
177
|
+
for (let i = 0; i < 10; i++) {
|
|
178
|
+
const scores = batchCosineSim(query, vectors);
|
|
179
|
+
Array.from({ length: count }, (_, i) => i)
|
|
180
|
+
.sort((a, b) => scores[b] - scores[a])
|
|
181
|
+
.slice(0, 10);
|
|
182
|
+
}
|
|
183
|
+
const bruteTime = (performance.now() - bruteStart) / 10;
|
|
184
|
+
const speedup = bruteTime / flashTime;
|
|
185
|
+
console.log(` Throughput: ${throughput.toFixed(0)} vectors/ms`);
|
|
186
|
+
console.log(` Time for 10k vectors: ${flashTime.toFixed(2)}ms`);
|
|
187
|
+
console.log(` Speedup vs brute force: ${speedup.toFixed(2)}x`);
|
|
188
|
+
// HNSW Status
|
|
189
|
+
console.log('\n3. HNSW Index Status...');
|
|
190
|
+
const hnswStatus = getHNSWStatus();
|
|
191
|
+
console.log(` Entries indexed: ${hnswStatus.entryCount}`);
|
|
192
|
+
console.log(` Initialized: ${hnswStatus.initialized}`);
|
|
193
|
+
// Intelligence Stats
|
|
194
|
+
console.log('\n4. Intelligence System Stats...');
|
|
195
|
+
const stats = getIntelligenceStats();
|
|
196
|
+
console.log(` SONA enabled: ${stats.sonaEnabled}`);
|
|
197
|
+
console.log(` Patterns learned: ${stats.patternsLearned}`);
|
|
198
|
+
console.log(` Avg adaptation time: ${stats.avgAdaptationTime.toFixed(4)}ms`);
|
|
199
|
+
console.log('\n=== Benchmark Complete ===');
|
|
200
|
+
return {
|
|
201
|
+
sona: {
|
|
202
|
+
avgMs: sonaResult.avgMs,
|
|
203
|
+
targetMet: sonaResult.targetMet
|
|
204
|
+
},
|
|
205
|
+
flashAttention: {
|
|
206
|
+
throughputPerMs: throughput,
|
|
207
|
+
speedup
|
|
208
|
+
},
|
|
209
|
+
hnsw: {
|
|
210
|
+
entriesIndexed: hnswStatus.entryCount,
|
|
211
|
+
searchTime: flashTime
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Show system status
|
|
217
|
+
*/
|
|
218
|
+
async function showStatus() {
|
|
219
|
+
console.log('=== Monomind System Status ===\n');
|
|
220
|
+
// Check daemon
|
|
221
|
+
const daemon = getDaemon();
|
|
222
|
+
console.log('Daemon:');
|
|
223
|
+
if (daemon) {
|
|
224
|
+
const status = daemon.getStatus();
|
|
225
|
+
console.log(` Running: ${status.running}`);
|
|
226
|
+
console.log(` PID: ${status.pid}`);
|
|
227
|
+
console.log(` Workers: ${status.workers.size}`);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
console.log(' Not initialized');
|
|
231
|
+
}
|
|
232
|
+
// Intelligence
|
|
233
|
+
const stats = getIntelligenceStats();
|
|
234
|
+
console.log('\nIntelligence:');
|
|
235
|
+
console.log(` SONA enabled: ${stats.sonaEnabled}`);
|
|
236
|
+
console.log(` ReasoningBank size: ${stats.reasoningBankSize}`);
|
|
237
|
+
console.log(` Patterns learned: ${stats.patternsLearned}`);
|
|
238
|
+
// HNSW
|
|
239
|
+
const hnsw = getHNSWStatus();
|
|
240
|
+
console.log('\nHNSW Index:');
|
|
241
|
+
console.log(` Initialized: ${hnsw.initialized}`);
|
|
242
|
+
console.log(` Entries: ${hnsw.entryCount}`);
|
|
243
|
+
console.log('\nEnvironment:');
|
|
244
|
+
console.log(` MONOMIND_HEADLESS: ${process.env.MONOMIND_HEADLESS || 'not set'}`);
|
|
245
|
+
console.log(` CLAUDE_CODE_HEADLESS: ${process.env.CLAUDE_CODE_HEADLESS || 'not set'}`);
|
|
246
|
+
console.log(` NODE_ENV: ${process.env.NODE_ENV || 'development'}`);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Main entry point
|
|
250
|
+
*/
|
|
251
|
+
async function main() {
|
|
252
|
+
// Set headless environment
|
|
253
|
+
process.env.MONOMIND_HEADLESS = 'true';
|
|
254
|
+
const config = parseArgs();
|
|
255
|
+
try {
|
|
256
|
+
switch (config.mode) {
|
|
257
|
+
case 'worker':
|
|
258
|
+
if (!config.workerType || !HEADLESS_WORKER_TYPES.includes(config.workerType)) {
|
|
259
|
+
console.error(`Invalid worker type. Available: ${HEADLESS_WORKER_TYPES.join(', ')}`);
|
|
260
|
+
process.exit(1);
|
|
261
|
+
}
|
|
262
|
+
await runWorker(config.workerType, config.timeout || 60000);
|
|
263
|
+
break;
|
|
264
|
+
case 'daemon':
|
|
265
|
+
await runDaemon();
|
|
266
|
+
break;
|
|
267
|
+
case 'benchmark':
|
|
268
|
+
await runBenchmarks();
|
|
269
|
+
break;
|
|
270
|
+
case 'status':
|
|
271
|
+
default:
|
|
272
|
+
await showStatus();
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
console.error('[Headless] Error:', error instanceof Error ? error.message : String(error));
|
|
278
|
+
process.exit(1);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// Run if executed directly
|
|
282
|
+
main().catch(console.error);
|
|
283
|
+
export { main, runWorker, runDaemon, runBenchmarks, showStatus };
|
|
284
|
+
//# sourceMappingURL=headless.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentic-flow v1 integration bridge
|
|
3
|
+
*
|
|
4
|
+
* Provides a single lazy-loading entry point for all agentic-flow v1
|
|
5
|
+
* subpath exports. Every accessor returns `null` when agentic-flow is
|
|
6
|
+
* not installed — callers never throw on missing optional dependency.
|
|
7
|
+
*
|
|
8
|
+
* @module agentic-flow-bridge
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Load the ReasoningBank module (4-step learning pipeline).
|
|
12
|
+
* Returns null if agentic-flow is not installed.
|
|
13
|
+
* Race-safe: concurrent callers share the same import Promise.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getReasoningBank(): Promise<typeof import("agentic-flow/reasoningbank") | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Load the ModelRouter module (multi-provider LLM routing).
|
|
18
|
+
* Returns null if agentic-flow is not installed.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getRouter(): Promise<typeof import("agentic-flow/router") | null>;
|
|
21
|
+
/**
|
|
22
|
+
* Load the Orchestration module (workflow engine).
|
|
23
|
+
* Returns null if agentic-flow is not installed.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getOrchestration(): Promise<typeof import("agentic-flow/orchestration") | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Compute an embedding vector via ReasoningBank, falling back to null.
|
|
28
|
+
*/
|
|
29
|
+
export declare function computeEmbedding(text: string): Promise<number[] | null>;
|
|
30
|
+
/**
|
|
31
|
+
* Retrieve memories matching a query via ReasoningBank.
|
|
32
|
+
*/
|
|
33
|
+
export declare function retrieveMemories(query: string, opts?: {
|
|
34
|
+
k?: number;
|
|
35
|
+
}): Promise<any[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Check whether agentic-flow v1 is available at runtime.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isAvailable(): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* Return a summary of available agentic-flow v1 capabilities.
|
|
42
|
+
*/
|
|
43
|
+
export declare function capabilities(): Promise<{
|
|
44
|
+
available: boolean;
|
|
45
|
+
reasoningBank: boolean;
|
|
46
|
+
router: boolean;
|
|
47
|
+
orchestration: boolean;
|
|
48
|
+
version: string | null;
|
|
49
|
+
}>;
|
|
50
|
+
//# sourceMappingURL=agentic-flow-bridge.d.ts.map
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentic-flow v1 integration bridge
|
|
3
|
+
*
|
|
4
|
+
* Provides a single lazy-loading entry point for all agentic-flow v1
|
|
5
|
+
* subpath exports. Every accessor returns `null` when agentic-flow is
|
|
6
|
+
* not installed — callers never throw on missing optional dependency.
|
|
7
|
+
*
|
|
8
|
+
* @module agentic-flow-bridge
|
|
9
|
+
*/
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Cached module handles (Promise-based to prevent TOCTOU races)
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
let _reasoningBankP = null;
|
|
14
|
+
let _routerP = null;
|
|
15
|
+
let _orchestrationP = null;
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Public loaders
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
/**
|
|
20
|
+
* Load the ReasoningBank module (4-step learning pipeline).
|
|
21
|
+
* Returns null if agentic-flow is not installed.
|
|
22
|
+
* Race-safe: concurrent callers share the same import Promise.
|
|
23
|
+
*/
|
|
24
|
+
export function getReasoningBank() {
|
|
25
|
+
if (_reasoningBankP === null) {
|
|
26
|
+
_reasoningBankP = import('agentic-flow/reasoningbank').catch(() => null);
|
|
27
|
+
}
|
|
28
|
+
return _reasoningBankP;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Load the ModelRouter module (multi-provider LLM routing).
|
|
32
|
+
* Returns null if agentic-flow is not installed.
|
|
33
|
+
*/
|
|
34
|
+
export function getRouter() {
|
|
35
|
+
if (_routerP === null) {
|
|
36
|
+
_routerP = import('agentic-flow/router').catch(() => null);
|
|
37
|
+
}
|
|
38
|
+
return _routerP;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Load the Orchestration module (workflow engine).
|
|
42
|
+
* Returns null if agentic-flow is not installed.
|
|
43
|
+
*/
|
|
44
|
+
export function getOrchestration() {
|
|
45
|
+
if (_orchestrationP === null) {
|
|
46
|
+
_orchestrationP = import('agentic-flow/orchestration').catch(() => null);
|
|
47
|
+
}
|
|
48
|
+
return _orchestrationP;
|
|
49
|
+
}
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
// Convenience helpers
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
/**
|
|
54
|
+
* Compute an embedding vector via ReasoningBank, falling back to null.
|
|
55
|
+
*/
|
|
56
|
+
export async function computeEmbedding(text) {
|
|
57
|
+
const rb = await getReasoningBank();
|
|
58
|
+
if (!rb?.computeEmbedding)
|
|
59
|
+
return null;
|
|
60
|
+
return rb.computeEmbedding(text);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Retrieve memories matching a query via ReasoningBank.
|
|
64
|
+
*/
|
|
65
|
+
export async function retrieveMemories(query, opts) {
|
|
66
|
+
const rb = await getReasoningBank();
|
|
67
|
+
if (!rb?.retrieveMemories)
|
|
68
|
+
return [];
|
|
69
|
+
return rb.retrieveMemories(query, opts);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Check whether agentic-flow v1 is available at runtime.
|
|
73
|
+
*/
|
|
74
|
+
export async function isAvailable() {
|
|
75
|
+
const rb = await getReasoningBank();
|
|
76
|
+
return rb !== null;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Return a summary of available agentic-flow v1 capabilities.
|
|
80
|
+
*/
|
|
81
|
+
export async function capabilities() {
|
|
82
|
+
const [rb, router, orch] = await Promise.all([
|
|
83
|
+
getReasoningBank(),
|
|
84
|
+
getRouter(),
|
|
85
|
+
getOrchestration(),
|
|
86
|
+
]);
|
|
87
|
+
return {
|
|
88
|
+
available: rb !== null || router !== null || orch !== null,
|
|
89
|
+
reasoningBank: rb !== null,
|
|
90
|
+
router: router !== null,
|
|
91
|
+
orchestration: orch !== null,
|
|
92
|
+
version: rb?.VERSION ?? null,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=agentic-flow-bridge.js.map
|