kynjal-cli 3.1.3 → 4.0.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/core/coder.md +1 -1
- package/.claude/agents/core/planner.md +2 -2
- package/.claude/agents/core/researcher.md +1 -1
- package/.claude/agents/core/reviewer.md +1 -1
- package/.claude/agents/core/tester.md +1 -1
- package/.claude/agents/data/data-ml-model.md +4 -4
- package/.claude/agents/development/dev-backend-api.md +4 -4
- package/.claude/agents/documentation/docs-api-openapi.md +4 -4
- package/.claude/agents/github/code-review-swarm.md +2 -2
- package/.claude/agents/github/issue-tracker.md +2 -2
- package/.claude/agents/github/pr-manager.md +2 -2
- package/.claude/agents/github/release-manager.md +2 -2
- package/.claude/agents/github/workflow-automation.md +2 -2
- package/.claude/agents/sparc/architecture.md +3 -3
- package/.claude/agents/sparc/pseudocode.md +2 -2
- package/.claude/agents/sparc/refinement.md +3 -3
- package/.claude/agents/sparc/specification.md +2 -2
- package/.claude/agents/swarm/adaptive-coordinator.md +1 -1
- package/.claude/agents/swarm/hierarchical-coordinator.md +1 -1
- package/.claude/agents/swarm/mesh-coordinator.md +1 -1
- package/.claude/agents/templates/base-template-generator.md +25 -4
- package/.claude/agents/templates/sparc-coordinator.md +3 -3
- package/.claude/helpers/auto-commit.sh +1 -1
- package/.claude/helpers/auto-memory-hook.mjs +27 -9
- package/.claude/helpers/hook-handler.cjs +58 -18
- package/.claude/helpers/statusline.cjs +14 -33
- package/.claude/helpers/statusline.js +3 -3
- package/.claude/settings.json +9 -9
- package/.claude/skills/reasoningbank-intelligence/SKILL.md +2 -2
- package/.claude/skills/swarm-orchestration/SKILL.md +1 -1
- package/README.md +383 -170
- package/bin/cli.js +6 -6
- package/bin/mcp-server.js +1 -1
- package/bin/preinstall.cjs +2 -0
- package/dist/src/appliance/gguf-engine.js +664 -0
- package/dist/src/appliance/gguf-engine.js.map +1 -0
- package/dist/src/appliance/ruvllm-bridge.js +492 -0
- package/dist/src/appliance/ruvllm-bridge.js.map +1 -0
- package/dist/src/appliance/rvfa-builder.js +383 -0
- package/dist/src/appliance/rvfa-builder.js.map +1 -0
- package/dist/src/appliance/rvfa-distribution.js +533 -0
- package/dist/src/appliance/rvfa-distribution.js.map +1 -0
- package/dist/src/appliance/rvfa-format.js +465 -0
- package/dist/src/appliance/rvfa-format.js.map +1 -0
- package/dist/src/appliance/rvfa-runner.js +373 -0
- package/dist/src/appliance/rvfa-runner.js.map +1 -0
- package/dist/src/appliance/rvfa-signing.js +469 -0
- package/dist/src/appliance/rvfa-signing.js.map +1 -0
- package/dist/src/benchmarks/pretrain/index.js +542 -331
- package/dist/src/benchmarks/pretrain/index.js.map +1 -1
- package/dist/src/commands/agent.d.ts.map +1 -1
- package/dist/src/commands/agent.js +725 -502
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/analyze.js +1548 -1218
- package/dist/src/commands/analyze.js.map +1 -1
- package/dist/src/commands/appliance-advanced.d.ts +9 -0
- package/dist/src/commands/appliance-advanced.d.ts.map +1 -0
- package/dist/src/commands/appliance-advanced.js +324 -0
- package/dist/src/commands/appliance-advanced.js.map +1 -0
- package/dist/src/commands/appliance.d.ts +8 -0
- package/dist/src/commands/appliance.d.ts.map +1 -0
- package/dist/src/commands/appliance.js +581 -0
- package/dist/src/commands/appliance.js.map +1 -0
- package/dist/src/commands/benchmark.js +523 -372
- package/dist/src/commands/benchmark.js.map +1 -1
- package/dist/src/commands/claims.js +364 -274
- package/dist/src/commands/claims.js.map +1 -1
- package/dist/src/commands/cleanup.d.ts +13 -0
- package/dist/src/commands/cleanup.d.ts.map +1 -0
- package/dist/src/commands/cleanup.js +262 -0
- package/dist/src/commands/cleanup.js.map +1 -0
- package/dist/src/commands/completions.js +118 -477
- package/dist/src/commands/completions.js.map +1 -1
- package/dist/src/commands/config.js +303 -237
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/daemon.d.ts.map +1 -1
- package/dist/src/commands/daemon.js +597 -425
- package/dist/src/commands/daemon.js.map +1 -1
- package/dist/src/commands/deployment.js +275 -194
- package/dist/src/commands/deployment.js.map +1 -1
- package/dist/src/commands/doctor.d.ts.map +1 -1
- package/dist/src/commands/doctor.js +690 -460
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/embeddings.js +1543 -1293
- package/dist/src/commands/embeddings.js.map +1 -1
- package/dist/src/commands/guidance.js +596 -449
- package/dist/src/commands/guidance.js.map +1 -1
- package/dist/src/commands/hive-mind.js +938 -854
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +3677 -2570
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.js +322 -122
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init.d.ts +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +943 -787
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/issues.js +558 -383
- package/dist/src/commands/issues.js.map +1 -1
- package/dist/src/commands/mcp.d.ts.map +1 -1
- package/dist/src/commands/mcp.js +605 -475
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory.d.ts.map +1 -1
- package/dist/src/commands/memory.js +1031 -814
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/migrate.js +347 -282
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/neural.d.ts.map +1 -1
- package/dist/src/commands/neural.js +1563 -1283
- package/dist/src/commands/neural.js.map +1 -1
- package/dist/src/commands/performance.js +643 -497
- package/dist/src/commands/performance.js.map +1 -1
- package/dist/src/commands/plugins.js +841 -668
- package/dist/src/commands/plugins.js.map +1 -1
- package/dist/src/commands/process.js +447 -392
- package/dist/src/commands/process.js.map +1 -1
- package/dist/src/commands/progress.js +256 -162
- package/dist/src/commands/progress.js.map +1 -1
- package/dist/src/commands/providers.js +220 -150
- package/dist/src/commands/providers.js.map +1 -1
- package/dist/src/commands/route.js +665 -520
- package/dist/src/commands/route.js.map +1 -1
- package/dist/src/commands/ruvector/backup.js +651 -505
- package/dist/src/commands/ruvector/backup.js.map +1 -1
- package/dist/src/commands/ruvector/benchmark.js +401 -349
- package/dist/src/commands/ruvector/benchmark.js.map +1 -1
- package/dist/src/commands/ruvector/import.js +267 -225
- package/dist/src/commands/ruvector/import.js.map +1 -1
- package/dist/src/commands/ruvector/index.js +75 -37
- package/dist/src/commands/ruvector/index.js.map +1 -1
- package/dist/src/commands/ruvector/init.js +359 -336
- package/dist/src/commands/ruvector/init.js.map +1 -1
- package/dist/src/commands/ruvector/migrate.js +322 -335
- package/dist/src/commands/ruvector/migrate.js.map +1 -1
- package/dist/src/commands/ruvector/optimize.js +431 -375
- package/dist/src/commands/ruvector/optimize.js.map +1 -1
- package/dist/src/commands/ruvector/setup.js +117 -703
- package/dist/src/commands/ruvector/setup.js.map +1 -1
- package/dist/src/commands/ruvector/status.js +419 -364
- package/dist/src/commands/ruvector/status.js.map +1 -1
- package/dist/src/commands/security.d.ts.map +1 -1
- package/dist/src/commands/security.js +610 -456
- package/dist/src/commands/security.js.map +1 -1
- package/dist/src/commands/session.d.ts +1 -1
- package/dist/src/commands/session.js +627 -505
- package/dist/src/commands/session.js.map +1 -1
- package/dist/src/commands/start.d.ts +1 -1
- package/dist/src/commands/start.js +368 -271
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.d.ts +1 -1
- package/dist/src/commands/status.d.ts.map +1 -1
- package/dist/src/commands/status.js +492 -379
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.js +488 -408
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/commands/task.d.ts +1 -1
- package/dist/src/commands/task.js +539 -424
- package/dist/src/commands/task.js.map +1 -1
- package/dist/src/commands/transfer-store.js +412 -322
- package/dist/src/commands/transfer-store.js.map +1 -1
- package/dist/src/commands/update.js +291 -196
- package/dist/src/commands/update.js.map +1 -1
- package/dist/src/commands/workflow.js +486 -386
- package/dist/src/commands/workflow.js.map +1 -1
- package/dist/src/config-adapter.js +40 -39
- package/dist/src/config-adapter.js.map +1 -1
- package/dist/src/index.js +416 -312
- package/dist/src/index.js.map +1 -1
- package/dist/src/infrastructure/in-memory-repositories.js +507 -246
- package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
- package/dist/src/init/claudemd-generator.js +78 -368
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/executor.js +1019 -1345
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/helpers-generator.js +60 -635
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/init/index.d.ts +1 -1
- package/dist/src/init/index.d.ts.map +1 -1
- package/dist/src/init/index.js +1 -1
- package/dist/src/init/index.js.map +1 -1
- package/dist/src/init/mcp-generator.d.ts +0 -1
- package/dist/src/init/mcp-generator.d.ts.map +1 -1
- package/dist/src/init/mcp-generator.js +62 -42
- package/dist/src/init/mcp-generator.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +167 -100
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/statusline-generator.d.ts +16 -8
- package/dist/src/init/statusline-generator.d.ts.map +1 -1
- package/dist/src/init/statusline-generator.js +20 -1300
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +15 -5
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/types.js +66 -76
- package/dist/src/init/types.js.map +1 -1
- package/dist/src/mcp-client.js +130 -76
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.js +758 -445
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +492 -391
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/agentdb-tools.d.ts +30 -0
- package/dist/src/mcp-tools/agentdb-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/agentdb-tools.js +758 -0
- package/dist/src/mcp-tools/agentdb-tools.js.map +1 -0
- package/dist/src/mcp-tools/analyze-tools.js +236 -172
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
- package/dist/src/mcp-tools/auto-install.js +142 -80
- package/dist/src/mcp-tools/auto-install.js.map +1 -1
- package/dist/src/mcp-tools/browser-tools.js +375 -252
- package/dist/src/mcp-tools/browser-tools.js.map +1 -1
- package/dist/src/mcp-tools/claims-tools.js +565 -473
- package/dist/src/mcp-tools/claims-tools.js.map +1 -1
- package/dist/src/mcp-tools/config-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +284 -190
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/coordination-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/coordination-tools.js +600 -349
- package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
- package/dist/src/mcp-tools/daa-tools.js +367 -289
- package/dist/src/mcp-tools/daa-tools.js.map +1 -1
- package/dist/src/mcp-tools/embeddings-tools.js +693 -582
- package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
- package/dist/src/mcp-tools/github-tools.js +312 -261
- package/dist/src/mcp-tools/github-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.js +718 -423
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +2726 -1978
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/index.d.ts +2 -0
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +2 -0
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +514 -329
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/neural-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/neural-tools.js +428 -326
- package/dist/src/mcp-tools/neural-tools.js.map +1 -1
- package/dist/src/mcp-tools/performance-tools.js +480 -420
- package/dist/src/mcp-tools/performance-tools.js.map +1 -1
- package/dist/src/mcp-tools/progress-tools.js +278 -204
- package/dist/src/mcp-tools/progress-tools.js.map +1 -1
- package/dist/src/mcp-tools/ruvllm-tools.d.ts +9 -0
- package/dist/src/mcp-tools/ruvllm-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/ruvllm-tools.js +399 -0
- package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -0
- package/dist/src/mcp-tools/security-tools.js +429 -297
- package/dist/src/mcp-tools/security-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.js +234 -185
- package/dist/src/mcp-tools/session-tools.js.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.d.ts +2 -1
- package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.js +303 -64
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/system-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/system-tools.js +352 -200
- package/dist/src/mcp-tools/system-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/task-tools.js +357 -189
- package/dist/src/mcp-tools/task-tools.js.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.js +196 -148
- package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
- package/dist/src/mcp-tools/transfer-tools.js +333 -186
- package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
- package/dist/src/mcp-tools/wasm-agent-tools.d.ts +9 -0
- package/dist/src/mcp-tools/wasm-agent-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/wasm-agent-tools.js +377 -0
- package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -0
- package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/workflow-tools.js +471 -335
- package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
- package/dist/src/memory/ewc-consolidation.js +345 -173
- package/dist/src/memory/ewc-consolidation.js.map +1 -1
- package/dist/src/memory/intelligence.js +841 -359
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.js +1964 -0
- package/dist/src/memory/memory-bridge.js.map +1 -0
- package/dist/src/memory/memory-initializer.js +1895 -1602
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/sona-optimizer.js +329 -199
- package/dist/src/memory/sona-optimizer.js.map +1 -1
- package/dist/src/output.d.ts +2 -2
- package/dist/src/output.d.ts.map +1 -1
- package/dist/src/output.js +273 -242
- package/dist/src/output.js.map +1 -1
- package/dist/src/parser.js +217 -124
- package/dist/src/parser.js.map +1 -1
- package/dist/src/plugins/manager.js +531 -278
- package/dist/src/plugins/manager.js.map +1 -1
- package/dist/src/plugins/store/discovery.js +362 -275
- package/dist/src/plugins/store/discovery.js.map +1 -1
- package/dist/src/plugins/store/index.js +105 -48
- package/dist/src/plugins/store/index.js.map +1 -1
- package/dist/src/plugins/store/search.js +107 -69
- package/dist/src/plugins/store/search.js.map +1 -1
- package/dist/src/plugins/tests/demo-plugin-store.js +160 -113
- package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
- package/dist/src/plugins/tests/standalone-test.js +223 -172
- package/dist/src/plugins/tests/standalone-test.js.map +1 -1
- package/dist/src/plugins/tests/test-plugin-store.js +228 -190
- package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
- package/dist/src/production/circuit-breaker.js +126 -62
- package/dist/src/production/circuit-breaker.js.map +1 -1
- package/dist/src/production/error-handler.js +156 -86
- package/dist/src/production/error-handler.js.map +1 -1
- package/dist/src/production/monitoring.js +220 -139
- package/dist/src/production/monitoring.js.map +1 -1
- package/dist/src/production/rate-limiter.js +93 -74
- package/dist/src/production/rate-limiter.js.map +1 -1
- package/dist/src/production/retry.js +167 -75
- package/dist/src/production/retry.js.map +1 -1
- package/dist/src/prompt.js +560 -436
- package/dist/src/prompt.js.map +1 -1
- package/dist/src/runtime/headless.js +289 -200
- package/dist/src/runtime/headless.js.map +1 -1
- package/dist/src/ruvector/agent-wasm.js +511 -0
- package/dist/src/ruvector/agent-wasm.js.map +1 -0
- package/dist/src/ruvector/ast-analyzer.js +232 -145
- package/dist/src/ruvector/ast-analyzer.js.map +1 -1
- package/dist/src/ruvector/coverage-router.js +419 -287
- package/dist/src/ruvector/coverage-router.js.map +1 -1
- package/dist/src/ruvector/coverage-tools.js +101 -56
- package/dist/src/ruvector/coverage-tools.js.map +1 -1
- package/dist/src/ruvector/diff-classifier.js +451 -324
- package/dist/src/ruvector/diff-classifier.js.map +1 -1
- package/dist/src/ruvector/enhanced-model-router.js +337 -251
- package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
- package/dist/src/ruvector/flash-attention.js +254 -223
- package/dist/src/ruvector/flash-attention.js.map +1 -1
- package/dist/src/ruvector/graph-analyzer.js +680 -486
- package/dist/src/ruvector/graph-analyzer.js.map +1 -1
- package/dist/src/ruvector/index.js +113 -27
- package/dist/src/ruvector/index.js.map +1 -1
- package/dist/src/ruvector/lora-adapter.js +248 -155
- package/dist/src/ruvector/lora-adapter.js.map +1 -1
- package/dist/src/ruvector/model-router.js +248 -175
- package/dist/src/ruvector/model-router.js.map +1 -1
- package/dist/src/ruvector/moe-router.js +286 -228
- package/dist/src/ruvector/moe-router.js.map +1 -1
- package/dist/src/ruvector/q-learning-router.js +338 -257
- package/dist/src/ruvector/q-learning-router.js.map +1 -1
- package/dist/src/ruvector/ruvllm-wasm.js +527 -0
- package/dist/src/ruvector/ruvllm-wasm.js.map +1 -0
- package/dist/src/ruvector/semantic-router.js +67 -60
- package/dist/src/ruvector/semantic-router.js.map +1 -1
- package/dist/src/ruvector/vector-db.js +205 -119
- package/dist/src/ruvector/vector-db.js.map +1 -1
- package/dist/src/services/agentic-flow-bridge.js +168 -0
- package/dist/src/services/agentic-flow-bridge.js.map +1 -0
- package/dist/src/services/claim-service.js +940 -615
- package/dist/src/services/claim-service.js.map +1 -1
- package/dist/src/services/container-worker-pool.js +669 -399
- package/dist/src/services/container-worker-pool.js.map +1 -1
- package/dist/src/services/headless-worker-executor.js +467 -441
- package/dist/src/services/headless-worker-executor.js.map +1 -1
- package/dist/src/services/index.d.ts +5 -5
- package/dist/src/services/index.d.ts.map +1 -1
- package/dist/src/services/index.js +4 -4
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/registry-api.js +201 -93
- package/dist/src/services/registry-api.js.map +1 -1
- package/dist/src/services/ruvector-training.js +414 -144
- package/dist/src/services/ruvector-training.js.map +1 -1
- package/dist/src/services/worker-daemon.js +928 -531
- package/dist/src/services/worker-daemon.js.map +1 -1
- package/dist/src/services/worker-queue.js +550 -331
- package/dist/src/services/worker-queue.js.map +1 -1
- package/dist/src/suggest.js +55 -45
- package/dist/src/suggest.js.map +1 -1
- package/dist/src/transfer/anonymization/index.js +37 -29
- package/dist/src/transfer/anonymization/index.js.map +1 -1
- package/dist/src/transfer/deploy-seraphine.d.ts +1 -1
- package/dist/src/transfer/deploy-seraphine.js +156 -129
- package/dist/src/transfer/deploy-seraphine.js.map +1 -1
- package/dist/src/transfer/export.js +142 -84
- package/dist/src/transfer/export.js.map +1 -1
- package/dist/src/transfer/index.d.ts +1 -1
- package/dist/src/transfer/index.d.ts.map +1 -1
- package/dist/src/transfer/index.js +2 -0
- package/dist/src/transfer/index.js.map +1 -1
- package/dist/src/transfer/ipfs/client.js +337 -179
- package/dist/src/transfer/ipfs/client.js.map +1 -1
- package/dist/src/transfer/ipfs/upload.js +434 -290
- package/dist/src/transfer/ipfs/upload.js.map +1 -1
- package/dist/src/transfer/models/seraphine.js +58 -58
- package/dist/src/transfer/models/seraphine.js.map +1 -1
- package/dist/src/transfer/serialization/cfp.js +37 -33
- package/dist/src/transfer/serialization/cfp.js.map +1 -1
- package/dist/src/transfer/storage/gcs.js +248 -139
- package/dist/src/transfer/storage/gcs.js.map +1 -1
- package/dist/src/transfer/store/discovery.js +353 -243
- package/dist/src/transfer/store/discovery.js.map +1 -1
- package/dist/src/transfer/store/download.js +365 -243
- package/dist/src/transfer/store/download.js.map +1 -1
- package/dist/src/transfer/store/index.js +130 -63
- package/dist/src/transfer/store/index.js.map +1 -1
- package/dist/src/transfer/store/publish.js +258 -184
- package/dist/src/transfer/store/publish.js.map +1 -1
- package/dist/src/transfer/store/registry.js +73 -51
- package/dist/src/transfer/store/registry.js.map +1 -1
- package/dist/src/transfer/store/search.js +96 -64
- package/dist/src/transfer/store/search.js.map +1 -1
- package/dist/src/transfer/store/tests/standalone-test.js +231 -174
- package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
- package/dist/src/transfer/test-seraphine.js +130 -95
- package/dist/src/transfer/test-seraphine.js.map +1 -1
- package/dist/src/transfer/tests/test-store.js +239 -194
- package/dist/src/transfer/tests/test-store.js.map +1 -1
- package/dist/src/types.js +56 -27
- package/dist/src/types.js.map +1 -1
- package/dist/src/update/checker.js +183 -106
- package/dist/src/update/checker.js.map +1 -1
- package/dist/src/update/executor.js +198 -135
- package/dist/src/update/executor.js.map +1 -1
- package/dist/src/update/index.js +85 -38
- package/dist/src/update/index.js.map +1 -1
- package/dist/src/update/rate-limiter.js +31 -19
- package/dist/src/update/rate-limiter.js.map +1 -1
- package/dist/src/update/validator.js +64 -38
- package/dist/src/update/validator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -10
- package/.claude/agents/custom/accessibility-auditor.yaml +0 -56
- package/.claude/agents/custom/design-architect.yaml +0 -48
- package/.claude/agents/custom/ui-developer.yaml +0 -46
- package/.claude/agents/custom/ux-researcher.yaml +0 -60
- package/dist/src/benchmarks/pretrain/index.d.ts +0 -58
- package/dist/src/benchmarks/pretrain/index.d.ts.map +0 -1
- package/dist/src/commands/index.d.ts +0 -108
- package/dist/src/commands/index.d.ts.map +0 -1
- package/dist/src/config-adapter.d.ts +0 -15
- package/dist/src/config-adapter.d.ts.map +0 -1
- package/dist/src/index.d.ts +0 -76
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/infrastructure/in-memory-repositories.d.ts +0 -68
- package/dist/src/infrastructure/in-memory-repositories.d.ts.map +0 -1
- package/dist/src/init/claudemd-generator.d.ts +0 -25
- package/dist/src/init/claudemd-generator.d.ts.map +0 -1
- package/dist/src/init/executor.d.ts +0 -41
- package/dist/src/init/executor.d.ts.map +0 -1
- package/dist/src/init/helpers-generator.d.ts +0 -60
- package/dist/src/init/helpers-generator.d.ts.map +0 -1
- package/dist/src/mcp-client.d.ts +0 -92
- package/dist/src/mcp-client.d.ts.map +0 -1
- package/dist/src/mcp-server.d.ts +0 -161
- package/dist/src/mcp-server.d.ts.map +0 -1
- package/dist/src/mcp-tools/auto-install.d.ts +0 -83
- package/dist/src/mcp-tools/auto-install.d.ts.map +0 -1
- package/dist/src/mcp-tools/types.d.ts +0 -31
- package/dist/src/mcp-tools/types.d.ts.map +0 -1
- package/dist/src/memory/ewc-consolidation.d.ts +0 -271
- package/dist/src/memory/ewc-consolidation.d.ts.map +0 -1
- package/dist/src/memory/intelligence.d.ts +0 -285
- package/dist/src/memory/intelligence.d.ts.map +0 -1
- package/dist/src/memory/memory-initializer.d.ts +0 -396
- package/dist/src/memory/memory-initializer.d.ts.map +0 -1
- package/dist/src/memory/sona-optimizer.d.ts +0 -227
- package/dist/src/memory/sona-optimizer.d.ts.map +0 -1
- package/dist/src/parser.d.ts +0 -41
- package/dist/src/parser.d.ts.map +0 -1
- package/dist/src/plugins/manager.d.ts +0 -133
- package/dist/src/plugins/manager.d.ts.map +0 -1
- package/dist/src/plugins/store/discovery.d.ts +0 -88
- package/dist/src/plugins/store/discovery.d.ts.map +0 -1
- package/dist/src/plugins/store/index.d.ts +0 -76
- package/dist/src/plugins/store/index.d.ts.map +0 -1
- package/dist/src/plugins/store/search.d.ts +0 -46
- package/dist/src/plugins/store/search.d.ts.map +0 -1
- package/dist/src/plugins/store/types.d.ts +0 -274
- package/dist/src/plugins/store/types.d.ts.map +0 -1
- package/dist/src/production/circuit-breaker.d.ts +0 -101
- package/dist/src/production/circuit-breaker.d.ts.map +0 -1
- package/dist/src/production/error-handler.d.ts +0 -92
- package/dist/src/production/error-handler.d.ts.map +0 -1
- package/dist/src/production/monitoring.d.ts +0 -161
- package/dist/src/production/monitoring.d.ts.map +0 -1
- package/dist/src/production/rate-limiter.d.ts +0 -80
- package/dist/src/production/rate-limiter.d.ts.map +0 -1
- package/dist/src/production/retry.d.ts +0 -48
- package/dist/src/production/retry.d.ts.map +0 -1
- package/dist/src/prompt.d.ts +0 -44
- package/dist/src/prompt.d.ts.map +0 -1
- package/dist/src/runtime/headless.d.ts +0 -60
- package/dist/src/runtime/headless.d.ts.map +0 -1
- package/dist/src/ruvector/ast-analyzer.d.ts +0 -67
- package/dist/src/ruvector/ast-analyzer.d.ts.map +0 -1
- package/dist/src/ruvector/coverage-router.d.ts +0 -160
- package/dist/src/ruvector/coverage-router.d.ts.map +0 -1
- package/dist/src/ruvector/diff-classifier.d.ts +0 -175
- package/dist/src/ruvector/diff-classifier.d.ts.map +0 -1
- package/dist/src/ruvector/enhanced-model-router.d.ts +0 -146
- package/dist/src/ruvector/enhanced-model-router.d.ts.map +0 -1
- package/dist/src/ruvector/flash-attention.d.ts +0 -195
- package/dist/src/ruvector/flash-attention.d.ts.map +0 -1
- package/dist/src/ruvector/graph-analyzer.d.ts +0 -187
- package/dist/src/ruvector/graph-analyzer.d.ts.map +0 -1
- package/dist/src/ruvector/index.d.ts +0 -34
- package/dist/src/ruvector/index.d.ts.map +0 -1
- package/dist/src/ruvector/lora-adapter.d.ts +0 -218
- package/dist/src/ruvector/lora-adapter.d.ts.map +0 -1
- package/dist/src/ruvector/model-router.d.ts +0 -220
- package/dist/src/ruvector/model-router.d.ts.map +0 -1
- package/dist/src/ruvector/moe-router.d.ts +0 -206
- package/dist/src/ruvector/moe-router.d.ts.map +0 -1
- package/dist/src/ruvector/q-learning-router.d.ts +0 -211
- package/dist/src/ruvector/q-learning-router.d.ts.map +0 -1
- package/dist/src/ruvector/semantic-router.d.ts +0 -77
- package/dist/src/ruvector/semantic-router.d.ts.map +0 -1
- package/dist/src/ruvector/vector-db.d.ts +0 -69
- package/dist/src/ruvector/vector-db.d.ts.map +0 -1
- package/dist/src/services/claim-service.d.ts +0 -204
- package/dist/src/services/claim-service.d.ts.map +0 -1
- package/dist/src/services/container-worker-pool.d.ts +0 -197
- package/dist/src/services/container-worker-pool.d.ts.map +0 -1
- package/dist/src/services/headless-worker-executor.d.ts +0 -304
- package/dist/src/services/headless-worker-executor.d.ts.map +0 -1
- package/dist/src/services/registry-api.d.ts +0 -58
- package/dist/src/services/registry-api.d.ts.map +0 -1
- package/dist/src/services/ruvector-training.d.ts +0 -213
- package/dist/src/services/ruvector-training.d.ts.map +0 -1
- package/dist/src/services/worker-daemon.d.ts +0 -203
- package/dist/src/services/worker-daemon.d.ts.map +0 -1
- package/dist/src/services/worker-queue.d.ts +0 -194
- package/dist/src/services/worker-queue.d.ts.map +0 -1
- package/dist/src/suggest.d.ts +0 -53
- package/dist/src/suggest.d.ts.map +0 -1
- package/dist/src/transfer/export.d.ts +0 -25
- package/dist/src/transfer/export.d.ts.map +0 -1
- package/dist/src/transfer/ipfs/client.d.ts +0 -109
- package/dist/src/transfer/ipfs/client.d.ts.map +0 -1
- package/dist/src/transfer/ipfs/upload.d.ts +0 -95
- package/dist/src/transfer/ipfs/upload.d.ts.map +0 -1
- package/dist/src/transfer/models/seraphine.d.ts +0 -72
- package/dist/src/transfer/models/seraphine.d.ts.map +0 -1
- package/dist/src/transfer/serialization/cfp.d.ts +0 -49
- package/dist/src/transfer/serialization/cfp.d.ts.map +0 -1
- package/dist/src/transfer/storage/gcs.d.ts +0 -82
- package/dist/src/transfer/storage/gcs.d.ts.map +0 -1
- package/dist/src/transfer/store/discovery.d.ts +0 -84
- package/dist/src/transfer/store/discovery.d.ts.map +0 -1
- package/dist/src/transfer/store/download.d.ts +0 -70
- package/dist/src/transfer/store/download.d.ts.map +0 -1
- package/dist/src/transfer/store/index.d.ts +0 -84
- package/dist/src/transfer/store/index.d.ts.map +0 -1
- package/dist/src/transfer/store/publish.d.ts +0 -76
- package/dist/src/transfer/store/publish.d.ts.map +0 -1
- package/dist/src/transfer/store/search.d.ts +0 -54
- package/dist/src/transfer/store/search.d.ts.map +0 -1
- package/dist/src/transfer/types.d.ts +0 -245
- package/dist/src/transfer/types.d.ts.map +0 -1
- package/dist/src/types.d.ts +0 -198
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/update/checker.d.ts +0 -34
- package/dist/src/update/checker.d.ts.map +0 -1
- package/dist/src/update/executor.d.ts +0 -32
- package/dist/src/update/executor.d.ts.map +0 -1
- package/dist/src/update/index.d.ts +0 -33
- package/dist/src/update/index.d.ts.map +0 -1
- package/dist/src/update/rate-limiter.d.ts +0 -20
- package/dist/src/update/rate-limiter.d.ts.map +0 -1
- package/dist/src/update/validator.d.ts +0 -17
- package/dist/src/update/validator.d.ts.map +0 -1
|
@@ -4,29 +4,65 @@
|
|
|
4
4
|
* Tool definitions for ONNX embeddings with hyperbolic support and neural substrate.
|
|
5
5
|
* Implements ADR-024: Embeddings MCP Tools
|
|
6
6
|
*/
|
|
7
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
17
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
18
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
19
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
20
|
+
function step(op) {
|
|
21
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
22
|
+
while (_) try {
|
|
23
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
24
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
25
|
+
switch (op[0]) {
|
|
26
|
+
case 0: case 1: t = op; break;
|
|
27
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
28
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
29
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
30
|
+
default:
|
|
31
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
32
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
33
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
34
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
35
|
+
if (t[2]) _.ops.pop();
|
|
36
|
+
_.trys.pop(); continue;
|
|
37
|
+
}
|
|
38
|
+
op = body.call(thisArg, _);
|
|
39
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
40
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
41
|
+
}
|
|
42
|
+
};
|
|
7
43
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
8
44
|
import { join, resolve } from 'path';
|
|
9
45
|
// Configuration paths
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
46
|
+
var CONFIG_DIR = '.claude-flow';
|
|
47
|
+
var EMBEDDINGS_CONFIG = 'embeddings.json';
|
|
48
|
+
var MODELS_DIR = 'models';
|
|
13
49
|
function getConfigPath() {
|
|
14
50
|
return resolve(join(CONFIG_DIR, EMBEDDINGS_CONFIG));
|
|
15
51
|
}
|
|
16
52
|
function ensureConfigDir() {
|
|
17
|
-
|
|
53
|
+
var dir = resolve(CONFIG_DIR);
|
|
18
54
|
if (!existsSync(dir)) {
|
|
19
55
|
mkdirSync(dir, { recursive: true });
|
|
20
56
|
}
|
|
21
57
|
}
|
|
22
58
|
function loadConfig() {
|
|
23
59
|
try {
|
|
24
|
-
|
|
60
|
+
var path = getConfigPath();
|
|
25
61
|
if (existsSync(path)) {
|
|
26
62
|
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
27
63
|
}
|
|
28
64
|
}
|
|
29
|
-
catch {
|
|
65
|
+
catch (_a) {
|
|
30
66
|
// Return null on error
|
|
31
67
|
}
|
|
32
68
|
return null;
|
|
@@ -36,73 +72,96 @@ function saveConfig(config) {
|
|
|
36
72
|
writeFileSync(getConfigPath(), JSON.stringify(config, null, 2), 'utf-8');
|
|
37
73
|
}
|
|
38
74
|
// Real ONNX embedding generation via memory-initializer
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
75
|
+
var realEmbeddingFn = null;
|
|
76
|
+
function getRealEmbeddingFunction() {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
+
var generateEmbedding, _a;
|
|
79
|
+
return __generator(this, function (_b) {
|
|
80
|
+
switch (_b.label) {
|
|
81
|
+
case 0:
|
|
82
|
+
if (!!realEmbeddingFn) return [3 /*break*/, 4];
|
|
83
|
+
_b.label = 1;
|
|
84
|
+
case 1:
|
|
85
|
+
_b.trys.push([1, 3, , 4]);
|
|
86
|
+
return [4 /*yield*/, import('../memory/memory-initializer.js')];
|
|
87
|
+
case 2:
|
|
88
|
+
generateEmbedding = (_b.sent()).generateEmbedding;
|
|
89
|
+
realEmbeddingFn = generateEmbedding;
|
|
90
|
+
return [3 /*break*/, 4];
|
|
91
|
+
case 3:
|
|
92
|
+
_a = _b.sent();
|
|
93
|
+
realEmbeddingFn = null;
|
|
94
|
+
return [3 /*break*/, 4];
|
|
95
|
+
case 4: return [2 /*return*/, realEmbeddingFn];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
51
99
|
}
|
|
52
100
|
// Generate real ONNX embedding (falls back to deterministic hash if ONNX unavailable)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
101
|
+
function generateRealEmbedding(text, dimension) {
|
|
102
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
103
|
+
var realFn, result, _a, embedding, hash, i, i, seed, norm;
|
|
104
|
+
return __generator(this, function (_b) {
|
|
105
|
+
switch (_b.label) {
|
|
106
|
+
case 0: return [4 /*yield*/, getRealEmbeddingFunction()];
|
|
107
|
+
case 1:
|
|
108
|
+
realFn = _b.sent();
|
|
109
|
+
if (!realFn) return [3 /*break*/, 5];
|
|
110
|
+
_b.label = 2;
|
|
111
|
+
case 2:
|
|
112
|
+
_b.trys.push([2, 4, , 5]);
|
|
113
|
+
return [4 /*yield*/, realFn(text)];
|
|
114
|
+
case 3:
|
|
115
|
+
result = _b.sent();
|
|
116
|
+
return [2 /*return*/, result.embedding];
|
|
117
|
+
case 4:
|
|
118
|
+
_a = _b.sent();
|
|
119
|
+
return [3 /*break*/, 5];
|
|
120
|
+
case 5:
|
|
121
|
+
// Fallback: deterministic hash-based (only if ONNX truly unavailable)
|
|
122
|
+
console.warn('[MCP] ONNX unavailable, using fallback embedding');
|
|
123
|
+
embedding = [];
|
|
124
|
+
hash = 0;
|
|
125
|
+
for (i = 0; i < text.length; i++) {
|
|
126
|
+
hash = ((hash << 5) - hash + text.charCodeAt(i)) | 0;
|
|
127
|
+
}
|
|
128
|
+
for (i = 0; i < dimension; i++) {
|
|
129
|
+
seed = hash + i * 1337;
|
|
130
|
+
embedding.push(Math.sin(seed) * Math.cos(seed * 0.5));
|
|
131
|
+
}
|
|
132
|
+
norm = Math.sqrt(embedding.reduce(function (sum, x) { return sum + x * x; }, 0));
|
|
133
|
+
return [2 /*return*/, embedding.map(function (x) { return x / norm; })];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
78
137
|
}
|
|
79
138
|
// Convert Euclidean embedding to Poincaré ball
|
|
80
139
|
function toPoincare(euclidean, curvature) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
140
|
+
var c = Math.abs(curvature);
|
|
141
|
+
var sqrtC = Math.sqrt(c);
|
|
142
|
+
var norm = Math.sqrt(euclidean.reduce(function (sum, x) { return sum + x * x; }, 0));
|
|
84
143
|
// Exponential map at origin
|
|
85
|
-
|
|
86
|
-
return euclidean.map(x
|
|
144
|
+
var factor = Math.tanh(sqrtC * norm / 2) / (sqrtC * norm + 1e-15);
|
|
145
|
+
return euclidean.map(function (x) { return x * factor; });
|
|
87
146
|
}
|
|
88
147
|
// Poincaré distance
|
|
89
148
|
function poincareDistance(a, b, curvature) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
149
|
+
var c = Math.abs(curvature);
|
|
150
|
+
var diffSq = a.reduce(function (sum, _, i) { return sum + Math.pow((a[i] - b[i]), 2); }, 0);
|
|
151
|
+
var normASq = a.reduce(function (sum, x) { return sum + x * x; }, 0);
|
|
152
|
+
var normBSq = b.reduce(function (sum, x) { return sum + x * x; }, 0);
|
|
153
|
+
var denom = (1 - normASq) * (1 - normBSq);
|
|
154
|
+
var delta = 2 * diffSq / (denom + 1e-15);
|
|
96
155
|
return (1 / Math.sqrt(c)) * Math.acosh(1 + delta);
|
|
97
156
|
}
|
|
98
157
|
// Cosine similarity
|
|
99
158
|
function cosineSimilarity(a, b) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
159
|
+
var dot = a.reduce(function (sum, _, i) { return sum + a[i] * b[i]; }, 0);
|
|
160
|
+
var normA = Math.sqrt(a.reduce(function (sum, x) { return sum + x * x; }, 0));
|
|
161
|
+
var normB = Math.sqrt(b.reduce(function (sum, x) { return sum + x * x; }, 0));
|
|
103
162
|
return dot / (normA * normB + 1e-15);
|
|
104
163
|
}
|
|
105
|
-
export
|
|
164
|
+
export var embeddingsTools = [
|
|
106
165
|
{
|
|
107
166
|
name: 'embeddings_init',
|
|
108
167
|
description: 'Initialize the ONNX embedding subsystem with hyperbolic support',
|
|
@@ -113,89 +172,92 @@ export const embeddingsTools = [
|
|
|
113
172
|
model: {
|
|
114
173
|
type: 'string',
|
|
115
174
|
description: 'ONNX model ID',
|
|
116
|
-
enum: ['all-MiniLM-L6-v2', 'all-mpnet-base-v2'],
|
|
117
|
-
default: 'all-MiniLM-L6-v2'
|
|
175
|
+
"enum": ['all-MiniLM-L6-v2', 'all-mpnet-base-v2'],
|
|
176
|
+
"default": 'all-MiniLM-L6-v2'
|
|
118
177
|
},
|
|
119
178
|
hyperbolic: {
|
|
120
179
|
type: 'boolean',
|
|
121
180
|
description: 'Enable hyperbolic (Poincaré ball) embeddings',
|
|
122
|
-
default: true
|
|
181
|
+
"default": true
|
|
123
182
|
},
|
|
124
183
|
curvature: {
|
|
125
184
|
type: 'number',
|
|
126
185
|
description: 'Poincaré ball curvature (negative)',
|
|
127
|
-
default: -1
|
|
186
|
+
"default": -1
|
|
128
187
|
},
|
|
129
188
|
cacheSize: {
|
|
130
189
|
type: 'number',
|
|
131
190
|
description: 'LRU cache size',
|
|
132
|
-
default: 256
|
|
191
|
+
"default": 256
|
|
133
192
|
},
|
|
134
193
|
force: {
|
|
135
194
|
type: 'boolean',
|
|
136
195
|
description: 'Overwrite existing configuration',
|
|
137
|
-
default: false
|
|
138
|
-
}
|
|
139
|
-
}
|
|
196
|
+
"default": false
|
|
197
|
+
}
|
|
198
|
+
}
|
|
140
199
|
},
|
|
141
|
-
handler:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
200
|
+
handler: function (input) { return __awaiter(void 0, void 0, void 0, function () {
|
|
201
|
+
var model, hyperbolic, curvature, cacheSize, force, existingConfig, dimension, modelPath, config;
|
|
202
|
+
return __generator(this, function (_a) {
|
|
203
|
+
model = input.model || 'all-MiniLM-L6-v2';
|
|
204
|
+
hyperbolic = input.hyperbolic !== false;
|
|
205
|
+
curvature = input.curvature || -1;
|
|
206
|
+
cacheSize = input.cacheSize || 256;
|
|
207
|
+
force = input.force === true;
|
|
208
|
+
existingConfig = loadConfig();
|
|
209
|
+
if (existingConfig && !force) {
|
|
210
|
+
return [2 /*return*/, {
|
|
211
|
+
success: false,
|
|
212
|
+
error: 'Embeddings already initialized. Use force=true to overwrite.',
|
|
213
|
+
existingConfig: {
|
|
214
|
+
model: existingConfig.model,
|
|
215
|
+
initialized: existingConfig.initialized
|
|
216
|
+
}
|
|
217
|
+
}];
|
|
218
|
+
}
|
|
219
|
+
dimension = model.includes('mpnet') ? 768 : 384;
|
|
220
|
+
modelPath = resolve(join(CONFIG_DIR, MODELS_DIR));
|
|
221
|
+
// Create models directory
|
|
222
|
+
if (!existsSync(modelPath)) {
|
|
223
|
+
mkdirSync(modelPath, { recursive: true });
|
|
224
|
+
}
|
|
225
|
+
config = {
|
|
226
|
+
model: model,
|
|
227
|
+
modelPath: modelPath,
|
|
228
|
+
dimension: dimension,
|
|
229
|
+
cacheSize: cacheSize,
|
|
230
|
+
hyperbolic: {
|
|
231
|
+
enabled: hyperbolic,
|
|
232
|
+
curvature: curvature,
|
|
233
|
+
epsilon: 1e-15,
|
|
234
|
+
maxNorm: 1 - 1e-5
|
|
235
|
+
},
|
|
236
|
+
neural: {
|
|
237
|
+
enabled: true,
|
|
238
|
+
driftThreshold: 0.3,
|
|
239
|
+
decayRate: 0.01
|
|
155
240
|
},
|
|
241
|
+
initialized: new Date().toISOString()
|
|
156
242
|
};
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
neural: {
|
|
176
|
-
enabled: true,
|
|
177
|
-
driftThreshold: 0.3,
|
|
178
|
-
decayRate: 0.01,
|
|
179
|
-
},
|
|
180
|
-
initialized: new Date().toISOString(),
|
|
181
|
-
};
|
|
182
|
-
saveConfig(config);
|
|
183
|
-
return {
|
|
184
|
-
success: true,
|
|
185
|
-
config: {
|
|
186
|
-
model,
|
|
187
|
-
dimension,
|
|
188
|
-
cacheSize,
|
|
189
|
-
hyperbolic: hyperbolic ? { enabled: true, curvature } : { enabled: false },
|
|
190
|
-
neural: { enabled: true },
|
|
191
|
-
},
|
|
192
|
-
paths: {
|
|
193
|
-
config: getConfigPath(),
|
|
194
|
-
models: modelPath,
|
|
195
|
-
},
|
|
196
|
-
message: 'Embedding subsystem initialized successfully',
|
|
197
|
-
};
|
|
198
|
-
},
|
|
243
|
+
saveConfig(config);
|
|
244
|
+
return [2 /*return*/, {
|
|
245
|
+
success: true,
|
|
246
|
+
config: {
|
|
247
|
+
model: model,
|
|
248
|
+
dimension: dimension,
|
|
249
|
+
cacheSize: cacheSize,
|
|
250
|
+
hyperbolic: hyperbolic ? { enabled: true, curvature: curvature } : { enabled: false },
|
|
251
|
+
neural: { enabled: true }
|
|
252
|
+
},
|
|
253
|
+
paths: {
|
|
254
|
+
config: getConfigPath(),
|
|
255
|
+
models: modelPath
|
|
256
|
+
},
|
|
257
|
+
message: 'Embedding subsystem initialized successfully'
|
|
258
|
+
}];
|
|
259
|
+
});
|
|
260
|
+
}); }
|
|
199
261
|
},
|
|
200
262
|
{
|
|
201
263
|
name: 'embeddings_generate',
|
|
@@ -206,56 +268,61 @@ export const embeddingsTools = [
|
|
|
206
268
|
properties: {
|
|
207
269
|
text: {
|
|
208
270
|
type: 'string',
|
|
209
|
-
description: 'Text to embed'
|
|
271
|
+
description: 'Text to embed'
|
|
210
272
|
},
|
|
211
273
|
hyperbolic: {
|
|
212
274
|
type: 'boolean',
|
|
213
275
|
description: 'Return hyperbolic (Poincaré) embedding',
|
|
214
|
-
default: false
|
|
276
|
+
"default": false
|
|
215
277
|
},
|
|
216
278
|
normalize: {
|
|
217
279
|
type: 'boolean',
|
|
218
280
|
description: 'L2 normalize the embedding',
|
|
219
|
-
default: true
|
|
220
|
-
}
|
|
281
|
+
"default": true
|
|
282
|
+
}
|
|
221
283
|
},
|
|
222
|
-
required: ['text']
|
|
223
|
-
},
|
|
224
|
-
handler: async (input) => {
|
|
225
|
-
const config = loadConfig();
|
|
226
|
-
if (!config) {
|
|
227
|
-
return {
|
|
228
|
-
success: false,
|
|
229
|
-
error: 'Embeddings not initialized. Run embeddings/init first.',
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
const text = input.text;
|
|
233
|
-
const useHyperbolic = input.hyperbolic === true && config.hyperbolic.enabled;
|
|
234
|
-
// Generate real ONNX embedding
|
|
235
|
-
const embedding = await generateRealEmbedding(text, config.dimension);
|
|
236
|
-
let result;
|
|
237
|
-
let geometry;
|
|
238
|
-
if (useHyperbolic) {
|
|
239
|
-
result = toPoincare(embedding, config.hyperbolic.curvature);
|
|
240
|
-
geometry = 'poincare';
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
result = embedding;
|
|
244
|
-
geometry = 'euclidean';
|
|
245
|
-
}
|
|
246
|
-
return {
|
|
247
|
-
success: true,
|
|
248
|
-
embedding: result,
|
|
249
|
-
metadata: {
|
|
250
|
-
model: config.model,
|
|
251
|
-
dimension: config.dimension,
|
|
252
|
-
geometry,
|
|
253
|
-
curvature: useHyperbolic ? config.hyperbolic.curvature : null,
|
|
254
|
-
textLength: text.length,
|
|
255
|
-
norm: Math.sqrt(result.reduce((sum, x) => sum + x * x, 0)),
|
|
256
|
-
},
|
|
257
|
-
};
|
|
284
|
+
required: ['text']
|
|
258
285
|
},
|
|
286
|
+
handler: function (input) { return __awaiter(void 0, void 0, void 0, function () {
|
|
287
|
+
var config, text, useHyperbolic, embedding, result, geometry;
|
|
288
|
+
return __generator(this, function (_a) {
|
|
289
|
+
switch (_a.label) {
|
|
290
|
+
case 0:
|
|
291
|
+
config = loadConfig();
|
|
292
|
+
if (!config) {
|
|
293
|
+
return [2 /*return*/, {
|
|
294
|
+
success: false,
|
|
295
|
+
error: 'Embeddings not initialized. Run embeddings/init first.'
|
|
296
|
+
}];
|
|
297
|
+
}
|
|
298
|
+
text = input.text;
|
|
299
|
+
useHyperbolic = input.hyperbolic === true && config.hyperbolic.enabled;
|
|
300
|
+
return [4 /*yield*/, generateRealEmbedding(text, config.dimension)];
|
|
301
|
+
case 1:
|
|
302
|
+
embedding = _a.sent();
|
|
303
|
+
if (useHyperbolic) {
|
|
304
|
+
result = toPoincare(embedding, config.hyperbolic.curvature);
|
|
305
|
+
geometry = 'poincare';
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
result = embedding;
|
|
309
|
+
geometry = 'euclidean';
|
|
310
|
+
}
|
|
311
|
+
return [2 /*return*/, {
|
|
312
|
+
success: true,
|
|
313
|
+
embedding: result,
|
|
314
|
+
metadata: {
|
|
315
|
+
model: config.model,
|
|
316
|
+
dimension: config.dimension,
|
|
317
|
+
geometry: geometry,
|
|
318
|
+
curvature: useHyperbolic ? config.hyperbolic.curvature : null,
|
|
319
|
+
textLength: text.length,
|
|
320
|
+
norm: Math.sqrt(result.reduce(function (sum, x) { return sum + x * x; }, 0))
|
|
321
|
+
}
|
|
322
|
+
}];
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
}); }
|
|
259
326
|
},
|
|
260
327
|
{
|
|
261
328
|
name: 'embeddings_compare',
|
|
@@ -266,75 +333,80 @@ export const embeddingsTools = [
|
|
|
266
333
|
properties: {
|
|
267
334
|
text1: {
|
|
268
335
|
type: 'string',
|
|
269
|
-
description: 'First text'
|
|
336
|
+
description: 'First text'
|
|
270
337
|
},
|
|
271
338
|
text2: {
|
|
272
339
|
type: 'string',
|
|
273
|
-
description: 'Second text'
|
|
340
|
+
description: 'Second text'
|
|
274
341
|
},
|
|
275
342
|
metric: {
|
|
276
343
|
type: 'string',
|
|
277
344
|
description: 'Similarity metric',
|
|
278
|
-
enum: ['cosine', 'euclidean', 'poincare'],
|
|
279
|
-
default: 'cosine'
|
|
280
|
-
}
|
|
345
|
+
"enum": ['cosine', 'euclidean', 'poincare'],
|
|
346
|
+
"default": 'cosine'
|
|
347
|
+
}
|
|
281
348
|
},
|
|
282
|
-
required: ['text1', 'text2']
|
|
283
|
-
},
|
|
284
|
-
handler: async (input) => {
|
|
285
|
-
const config = loadConfig();
|
|
286
|
-
if (!config) {
|
|
287
|
-
return {
|
|
288
|
-
success: false,
|
|
289
|
-
error: 'Embeddings not initialized. Run embeddings/init first.',
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
const text1 = input.text1;
|
|
293
|
-
const text2 = input.text2;
|
|
294
|
-
const metric = input.metric || 'cosine';
|
|
295
|
-
// Generate real ONNX embeddings for both texts
|
|
296
|
-
const [emb1, emb2] = await Promise.all([
|
|
297
|
-
generateRealEmbedding(text1, config.dimension),
|
|
298
|
-
generateRealEmbedding(text2, config.dimension)
|
|
299
|
-
]);
|
|
300
|
-
let similarity;
|
|
301
|
-
let distance;
|
|
302
|
-
switch (metric) {
|
|
303
|
-
case 'poincare':
|
|
304
|
-
if (!config.hyperbolic.enabled) {
|
|
305
|
-
return {
|
|
306
|
-
success: false,
|
|
307
|
-
error: 'Hyperbolic mode not enabled. Initialize with hyperbolic=true.',
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
const poinc1 = toPoincare(emb1, config.hyperbolic.curvature);
|
|
311
|
-
const poinc2 = toPoincare(emb2, config.hyperbolic.curvature);
|
|
312
|
-
distance = poincareDistance(poinc1, poinc2, config.hyperbolic.curvature);
|
|
313
|
-
similarity = 1 / (1 + distance);
|
|
314
|
-
break;
|
|
315
|
-
case 'euclidean':
|
|
316
|
-
distance = Math.sqrt(emb1.reduce((sum, _, i) => sum + (emb1[i] - emb2[i]) ** 2, 0));
|
|
317
|
-
similarity = 1 / (1 + distance);
|
|
318
|
-
break;
|
|
319
|
-
default: // cosine
|
|
320
|
-
similarity = cosineSimilarity(emb1, emb2);
|
|
321
|
-
distance = 1 - similarity;
|
|
322
|
-
}
|
|
323
|
-
return {
|
|
324
|
-
success: true,
|
|
325
|
-
similarity,
|
|
326
|
-
distance,
|
|
327
|
-
metric,
|
|
328
|
-
texts: {
|
|
329
|
-
text1: { length: text1.length, preview: text1.slice(0, 50) },
|
|
330
|
-
text2: { length: text2.length, preview: text2.slice(0, 50) },
|
|
331
|
-
},
|
|
332
|
-
interpretation: similarity > 0.8 ? 'very similar' :
|
|
333
|
-
similarity > 0.6 ? 'similar' :
|
|
334
|
-
similarity > 0.4 ? 'somewhat similar' :
|
|
335
|
-
similarity > 0.2 ? 'different' : 'very different',
|
|
336
|
-
};
|
|
349
|
+
required: ['text1', 'text2']
|
|
337
350
|
},
|
|
351
|
+
handler: function (input) { return __awaiter(void 0, void 0, void 0, function () {
|
|
352
|
+
var config, text1, text2, metric, _a, emb1, emb2, similarity, distance, poinc1, poinc2;
|
|
353
|
+
return __generator(this, function (_b) {
|
|
354
|
+
switch (_b.label) {
|
|
355
|
+
case 0:
|
|
356
|
+
config = loadConfig();
|
|
357
|
+
if (!config) {
|
|
358
|
+
return [2 /*return*/, {
|
|
359
|
+
success: false,
|
|
360
|
+
error: 'Embeddings not initialized. Run embeddings/init first.'
|
|
361
|
+
}];
|
|
362
|
+
}
|
|
363
|
+
text1 = input.text1;
|
|
364
|
+
text2 = input.text2;
|
|
365
|
+
metric = input.metric || 'cosine';
|
|
366
|
+
return [4 /*yield*/, Promise.all([
|
|
367
|
+
generateRealEmbedding(text1, config.dimension),
|
|
368
|
+
generateRealEmbedding(text2, config.dimension)
|
|
369
|
+
])];
|
|
370
|
+
case 1:
|
|
371
|
+
_a = _b.sent(), emb1 = _a[0], emb2 = _a[1];
|
|
372
|
+
switch (metric) {
|
|
373
|
+
case 'poincare':
|
|
374
|
+
if (!config.hyperbolic.enabled) {
|
|
375
|
+
return [2 /*return*/, {
|
|
376
|
+
success: false,
|
|
377
|
+
error: 'Hyperbolic mode not enabled. Initialize with hyperbolic=true.'
|
|
378
|
+
}];
|
|
379
|
+
}
|
|
380
|
+
poinc1 = toPoincare(emb1, config.hyperbolic.curvature);
|
|
381
|
+
poinc2 = toPoincare(emb2, config.hyperbolic.curvature);
|
|
382
|
+
distance = poincareDistance(poinc1, poinc2, config.hyperbolic.curvature);
|
|
383
|
+
similarity = 1 / (1 + distance);
|
|
384
|
+
break;
|
|
385
|
+
case 'euclidean':
|
|
386
|
+
distance = Math.sqrt(emb1.reduce(function (sum, _, i) { return sum + Math.pow((emb1[i] - emb2[i]), 2); }, 0));
|
|
387
|
+
similarity = 1 / (1 + distance);
|
|
388
|
+
break;
|
|
389
|
+
default: // cosine
|
|
390
|
+
similarity = cosineSimilarity(emb1, emb2);
|
|
391
|
+
distance = 1 - similarity;
|
|
392
|
+
}
|
|
393
|
+
return [2 /*return*/, {
|
|
394
|
+
success: true,
|
|
395
|
+
similarity: similarity,
|
|
396
|
+
distance: distance,
|
|
397
|
+
metric: metric,
|
|
398
|
+
texts: {
|
|
399
|
+
text1: { length: text1.length, preview: text1.slice(0, 50) },
|
|
400
|
+
text2: { length: text2.length, preview: text2.slice(0, 50) }
|
|
401
|
+
},
|
|
402
|
+
interpretation: similarity > 0.8 ? 'very similar' :
|
|
403
|
+
similarity > 0.6 ? 'similar' :
|
|
404
|
+
similarity > 0.4 ? 'somewhat similar' :
|
|
405
|
+
similarity > 0.2 ? 'different' : 'very different'
|
|
406
|
+
}];
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
}); }
|
|
338
410
|
},
|
|
339
411
|
{
|
|
340
412
|
name: 'embeddings_search',
|
|
@@ -345,89 +417,103 @@ export const embeddingsTools = [
|
|
|
345
417
|
properties: {
|
|
346
418
|
query: {
|
|
347
419
|
type: 'string',
|
|
348
|
-
description: 'Search query'
|
|
420
|
+
description: 'Search query'
|
|
349
421
|
},
|
|
350
422
|
topK: {
|
|
351
423
|
type: 'number',
|
|
352
424
|
description: 'Number of results to return',
|
|
353
|
-
default: 5
|
|
425
|
+
"default": 5
|
|
354
426
|
},
|
|
355
427
|
threshold: {
|
|
356
428
|
type: 'number',
|
|
357
429
|
description: 'Minimum similarity threshold (0-1)',
|
|
358
|
-
default: 0.5
|
|
430
|
+
"default": 0.5
|
|
359
431
|
},
|
|
360
432
|
namespace: {
|
|
361
433
|
type: 'string',
|
|
362
|
-
description: 'Search in specific namespace'
|
|
363
|
-
}
|
|
434
|
+
description: 'Search in specific namespace'
|
|
435
|
+
}
|
|
364
436
|
},
|
|
365
|
-
required: ['query']
|
|
366
|
-
},
|
|
367
|
-
handler: async (input) => {
|
|
368
|
-
const config = loadConfig();
|
|
369
|
-
if (!config) {
|
|
370
|
-
return {
|
|
371
|
-
success: false,
|
|
372
|
-
error: 'Embeddings not initialized. Run embeddings/init first.',
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
const query = input.query;
|
|
376
|
-
const topK = input.topK || 5;
|
|
377
|
-
const threshold = input.threshold || 0.5;
|
|
378
|
-
const namespace = input.namespace;
|
|
379
|
-
const startTime = performance.now();
|
|
380
|
-
// Generate real ONNX embedding for query
|
|
381
|
-
const queryEmbedding = await generateRealEmbedding(query, config.dimension);
|
|
382
|
-
// Try to search using real memory search
|
|
383
|
-
try {
|
|
384
|
-
const { searchEntries } = await import('../memory/memory-initializer.js');
|
|
385
|
-
const searchResult = await searchEntries({
|
|
386
|
-
query,
|
|
387
|
-
limit: topK,
|
|
388
|
-
threshold,
|
|
389
|
-
namespace: namespace || 'default'
|
|
390
|
-
});
|
|
391
|
-
const searchTime = (performance.now() - startTime).toFixed(2);
|
|
392
|
-
return {
|
|
393
|
-
success: true,
|
|
394
|
-
query,
|
|
395
|
-
results: searchResult.results.map((r) => ({
|
|
396
|
-
key: r.key,
|
|
397
|
-
content: r.content?.substring(0, 100),
|
|
398
|
-
similarity: r.score,
|
|
399
|
-
namespace: r.namespace
|
|
400
|
-
})),
|
|
401
|
-
metadata: {
|
|
402
|
-
model: config.model,
|
|
403
|
-
topK,
|
|
404
|
-
threshold,
|
|
405
|
-
namespace: namespace || 'default',
|
|
406
|
-
searchTime: `${searchTime}ms`,
|
|
407
|
-
indexType: config.hyperbolic.enabled ? 'HNSW (hyperbolic)' : 'HNSW (euclidean)',
|
|
408
|
-
resultCount: searchResult.results.length
|
|
409
|
-
},
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
catch {
|
|
413
|
-
// Database not available - return empty but truthful
|
|
414
|
-
const searchTime = (performance.now() - startTime).toFixed(2);
|
|
415
|
-
return {
|
|
416
|
-
success: true,
|
|
417
|
-
query,
|
|
418
|
-
results: [],
|
|
419
|
-
metadata: {
|
|
420
|
-
model: config.model,
|
|
421
|
-
topK,
|
|
422
|
-
threshold,
|
|
423
|
-
namespace: namespace || 'default',
|
|
424
|
-
searchTime: `${searchTime}ms`,
|
|
425
|
-
indexType: config.hyperbolic.enabled ? 'HNSW (hyperbolic)' : 'HNSW (euclidean)',
|
|
426
|
-
},
|
|
427
|
-
message: 'No embeddings indexed yet. Use memory store to add documents.',
|
|
428
|
-
};
|
|
429
|
-
}
|
|
437
|
+
required: ['query']
|
|
430
438
|
},
|
|
439
|
+
handler: function (input) { return __awaiter(void 0, void 0, void 0, function () {
|
|
440
|
+
var config, query, topK, threshold, namespace, startTime, queryEmbedding, searchEntries, searchResult, searchTime, _a, searchTime;
|
|
441
|
+
return __generator(this, function (_b) {
|
|
442
|
+
switch (_b.label) {
|
|
443
|
+
case 0:
|
|
444
|
+
config = loadConfig();
|
|
445
|
+
if (!config) {
|
|
446
|
+
return [2 /*return*/, {
|
|
447
|
+
success: false,
|
|
448
|
+
error: 'Embeddings not initialized. Run embeddings/init first.'
|
|
449
|
+
}];
|
|
450
|
+
}
|
|
451
|
+
query = input.query;
|
|
452
|
+
topK = input.topK || 5;
|
|
453
|
+
threshold = input.threshold || 0.5;
|
|
454
|
+
namespace = input.namespace;
|
|
455
|
+
startTime = performance.now();
|
|
456
|
+
return [4 /*yield*/, generateRealEmbedding(query, config.dimension)];
|
|
457
|
+
case 1:
|
|
458
|
+
queryEmbedding = _b.sent();
|
|
459
|
+
_b.label = 2;
|
|
460
|
+
case 2:
|
|
461
|
+
_b.trys.push([2, 5, , 6]);
|
|
462
|
+
return [4 /*yield*/, import('../memory/memory-initializer.js')];
|
|
463
|
+
case 3:
|
|
464
|
+
searchEntries = (_b.sent()).searchEntries;
|
|
465
|
+
return [4 /*yield*/, searchEntries({
|
|
466
|
+
query: query,
|
|
467
|
+
limit: topK,
|
|
468
|
+
threshold: threshold,
|
|
469
|
+
namespace: namespace || 'default'
|
|
470
|
+
})];
|
|
471
|
+
case 4:
|
|
472
|
+
searchResult = _b.sent();
|
|
473
|
+
searchTime = (performance.now() - startTime).toFixed(2);
|
|
474
|
+
return [2 /*return*/, {
|
|
475
|
+
success: true,
|
|
476
|
+
query: query,
|
|
477
|
+
results: searchResult.results.map(function (r) {
|
|
478
|
+
var _a;
|
|
479
|
+
return ({
|
|
480
|
+
key: r.key,
|
|
481
|
+
content: (_a = r.content) === null || _a === void 0 ? void 0 : _a.substring(0, 100),
|
|
482
|
+
similarity: r.score,
|
|
483
|
+
namespace: r.namespace
|
|
484
|
+
});
|
|
485
|
+
}),
|
|
486
|
+
metadata: {
|
|
487
|
+
model: config.model,
|
|
488
|
+
topK: topK,
|
|
489
|
+
threshold: threshold,
|
|
490
|
+
namespace: namespace || 'default',
|
|
491
|
+
searchTime: searchTime + "ms",
|
|
492
|
+
indexType: config.hyperbolic.enabled ? 'HNSW (hyperbolic)' : 'HNSW (euclidean)',
|
|
493
|
+
resultCount: searchResult.results.length
|
|
494
|
+
}
|
|
495
|
+
}];
|
|
496
|
+
case 5:
|
|
497
|
+
_a = _b.sent();
|
|
498
|
+
searchTime = (performance.now() - startTime).toFixed(2);
|
|
499
|
+
return [2 /*return*/, {
|
|
500
|
+
success: true,
|
|
501
|
+
query: query,
|
|
502
|
+
results: [],
|
|
503
|
+
metadata: {
|
|
504
|
+
model: config.model,
|
|
505
|
+
topK: topK,
|
|
506
|
+
threshold: threshold,
|
|
507
|
+
namespace: namespace || 'default',
|
|
508
|
+
searchTime: searchTime + "ms",
|
|
509
|
+
indexType: config.hyperbolic.enabled ? 'HNSW (hyperbolic)' : 'HNSW (euclidean)'
|
|
510
|
+
},
|
|
511
|
+
message: 'No embeddings indexed yet. Use memory store to add documents.'
|
|
512
|
+
}];
|
|
513
|
+
case 6: return [2 /*return*/];
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
}); }
|
|
431
517
|
},
|
|
432
518
|
{
|
|
433
519
|
name: 'embeddings_neural',
|
|
@@ -439,189 +525,207 @@ export const embeddingsTools = [
|
|
|
439
525
|
action: {
|
|
440
526
|
type: 'string',
|
|
441
527
|
description: 'Neural action',
|
|
442
|
-
enum: ['status', 'init', 'drift', 'consolidate', 'adapt'],
|
|
443
|
-
default: 'status'
|
|
528
|
+
"enum": ['status', 'init', 'drift', 'consolidate', 'adapt'],
|
|
529
|
+
"default": 'status'
|
|
444
530
|
},
|
|
445
531
|
driftThreshold: {
|
|
446
532
|
type: 'number',
|
|
447
533
|
description: 'Semantic drift detection threshold',
|
|
448
|
-
default: 0.3
|
|
534
|
+
"default": 0.3
|
|
449
535
|
},
|
|
450
536
|
decayRate: {
|
|
451
537
|
type: 'number',
|
|
452
538
|
description: 'Memory decay rate (hippocampal dynamics)',
|
|
453
|
-
default: 0.01
|
|
454
|
-
}
|
|
455
|
-
},
|
|
456
|
-
},
|
|
457
|
-
handler: async (input) => {
|
|
458
|
-
const config = loadConfig();
|
|
459
|
-
if (!config) {
|
|
460
|
-
return {
|
|
461
|
-
success: false,
|
|
462
|
-
error: 'Embeddings not initialized. Run embeddings/init first.',
|
|
463
|
-
};
|
|
539
|
+
"default": 0.01
|
|
540
|
+
}
|
|
464
541
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
542
|
+
},
|
|
543
|
+
handler: function (input) { return __awaiter(void 0, void 0, void 0, function () {
|
|
544
|
+
var config, action, _a, getIntelligenceStats, stats, _b, getIntelligenceStats, stats, _c, _d, benchmarkAdaptation, initializeIntelligence, benchmark, _e, _f, getIntelligenceStats, benchmarkAdaptation, initializeIntelligence, stats, benchmark, _g;
|
|
545
|
+
var _h, _j, _k, _l;
|
|
546
|
+
return __generator(this, function (_m) {
|
|
547
|
+
switch (_m.label) {
|
|
548
|
+
case 0:
|
|
549
|
+
config = loadConfig();
|
|
550
|
+
if (!config) {
|
|
551
|
+
return [2 /*return*/, {
|
|
552
|
+
success: false,
|
|
553
|
+
error: 'Embeddings not initialized. Run embeddings/init first.'
|
|
554
|
+
}];
|
|
555
|
+
}
|
|
556
|
+
action = input.action || 'status';
|
|
557
|
+
_a = action;
|
|
558
|
+
switch (_a) {
|
|
559
|
+
case 'init': return [3 /*break*/, 1];
|
|
560
|
+
case 'drift': return [3 /*break*/, 2];
|
|
561
|
+
case 'consolidate': return [3 /*break*/, 5];
|
|
562
|
+
case 'adapt': return [3 /*break*/, 8];
|
|
563
|
+
}
|
|
564
|
+
return [3 /*break*/, 12];
|
|
565
|
+
case 1:
|
|
566
|
+
config.neural = {
|
|
473
567
|
enabled: true,
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
stateMachine: true,
|
|
482
|
-
swarmCoordination: true,
|
|
483
|
-
coherenceMonitor: true,
|
|
484
|
-
},
|
|
485
|
-
};
|
|
486
|
-
saveConfig(config);
|
|
487
|
-
return {
|
|
488
|
-
success: true,
|
|
489
|
-
action: 'init',
|
|
490
|
-
neural: config.neural,
|
|
491
|
-
message: 'Neural substrate initialized with RuVector integration',
|
|
492
|
-
};
|
|
493
|
-
case 'drift':
|
|
494
|
-
// Get real drift metrics if available
|
|
495
|
-
try {
|
|
496
|
-
const { getIntelligenceStats } = await import('../memory/intelligence.js');
|
|
497
|
-
const stats = getIntelligenceStats();
|
|
498
|
-
return {
|
|
499
|
-
success: true,
|
|
500
|
-
action: 'drift',
|
|
501
|
-
status: {
|
|
502
|
-
semanticDrift: {
|
|
503
|
-
enabled: config.neural.features?.semanticDrift ?? false,
|
|
504
|
-
threshold: config.neural.driftThreshold,
|
|
505
|
-
patternsTracked: stats.patternsLearned,
|
|
506
|
-
status: stats.patternsLearned > 0 ? 'tracking' : 'no patterns',
|
|
507
|
-
},
|
|
568
|
+
driftThreshold: input.driftThreshold || 0.3,
|
|
569
|
+
decayRate: input.decayRate || 0.01,
|
|
570
|
+
ruvector: {
|
|
571
|
+
enabled: true,
|
|
572
|
+
sona: true,
|
|
573
|
+
flashAttention: true,
|
|
574
|
+
ewcPlusPlus: true
|
|
508
575
|
},
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
:
|
|
576
|
+
features: {
|
|
577
|
+
semanticDrift: true,
|
|
578
|
+
memoryPhysics: true,
|
|
579
|
+
stateMachine: true,
|
|
580
|
+
swarmCoordination: true,
|
|
581
|
+
coherenceMonitor: true
|
|
582
|
+
}
|
|
512
583
|
};
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
return {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
584
|
+
saveConfig(config);
|
|
585
|
+
return [2 /*return*/, {
|
|
586
|
+
success: true,
|
|
587
|
+
action: 'init',
|
|
588
|
+
neural: config.neural,
|
|
589
|
+
message: 'Neural substrate initialized with RuVector integration'
|
|
590
|
+
}];
|
|
591
|
+
case 2:
|
|
592
|
+
_m.trys.push([2, 4, , 5]);
|
|
593
|
+
return [4 /*yield*/, import('../memory/intelligence.js')];
|
|
594
|
+
case 3:
|
|
595
|
+
getIntelligenceStats = (_m.sent()).getIntelligenceStats;
|
|
596
|
+
stats = getIntelligenceStats();
|
|
597
|
+
return [2 /*return*/, {
|
|
598
|
+
success: true,
|
|
599
|
+
action: 'drift',
|
|
600
|
+
status: {
|
|
601
|
+
semanticDrift: {
|
|
602
|
+
enabled: (_j = (_h = config.neural.features) === null || _h === void 0 ? void 0 : _h.semanticDrift) !== null && _j !== void 0 ? _j : false,
|
|
603
|
+
threshold: config.neural.driftThreshold,
|
|
604
|
+
patternsTracked: stats.patternsLearned,
|
|
605
|
+
status: stats.patternsLearned > 0 ? 'tracking' : 'no patterns'
|
|
606
|
+
}
|
|
535
607
|
},
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
return {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
608
|
+
message: stats.patternsLearned > 0
|
|
609
|
+
? "Tracking " + stats.patternsLearned + " patterns for drift"
|
|
610
|
+
: 'No patterns stored yet - drift detection inactive'
|
|
611
|
+
}];
|
|
612
|
+
case 4:
|
|
613
|
+
_b = _m.sent();
|
|
614
|
+
return [2 /*return*/, {
|
|
615
|
+
success: true,
|
|
616
|
+
action: 'drift',
|
|
617
|
+
status: { semanticDrift: { enabled: false, reason: 'Intelligence module unavailable' } }
|
|
618
|
+
}];
|
|
619
|
+
case 5:
|
|
620
|
+
_m.trys.push([5, 7, , 8]);
|
|
621
|
+
return [4 /*yield*/, import('../memory/intelligence.js')];
|
|
622
|
+
case 6:
|
|
623
|
+
getIntelligenceStats = (_m.sent()).getIntelligenceStats;
|
|
624
|
+
stats = getIntelligenceStats();
|
|
625
|
+
return [2 /*return*/, {
|
|
626
|
+
success: true,
|
|
627
|
+
action: 'consolidate',
|
|
628
|
+
status: {
|
|
629
|
+
memoryPhysics: {
|
|
630
|
+
enabled: (_l = (_k = config.neural.features) === null || _k === void 0 ? void 0 : _k.memoryPhysics) !== null && _l !== void 0 ? _l : false,
|
|
631
|
+
decayRate: config.neural.decayRate,
|
|
632
|
+
patternsStored: stats.reasoningBankSize,
|
|
633
|
+
trajectoriesRecorded: stats.trajectoriesRecorded
|
|
634
|
+
}
|
|
563
635
|
},
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
patternsLearned: stats.patternsLearned,
|
|
594
|
-
trajectoriesRecorded: stats.trajectoriesRecorded,
|
|
595
|
-
reasoningBankSize: stats.reasoningBankSize,
|
|
596
|
-
adaptationTime: `${(benchmark.avgMs * 1000).toFixed(2)}μs`,
|
|
597
|
-
targetMet: benchmark.targetMet,
|
|
598
|
-
lastAdaptation: stats.lastAdaptation
|
|
599
|
-
? new Date(stats.lastAdaptation).toISOString()
|
|
600
|
-
: null,
|
|
636
|
+
message: "ReasoningBank: " + stats.reasoningBankSize + " patterns, " + stats.trajectoriesRecorded + " trajectories"
|
|
637
|
+
}];
|
|
638
|
+
case 7:
|
|
639
|
+
_c = _m.sent();
|
|
640
|
+
return [2 /*return*/, {
|
|
641
|
+
success: true,
|
|
642
|
+
action: 'consolidate',
|
|
643
|
+
status: { memoryPhysics: { enabled: false, reason: 'Intelligence module unavailable' } }
|
|
644
|
+
}];
|
|
645
|
+
case 8:
|
|
646
|
+
_m.trys.push([8, 11, , 12]);
|
|
647
|
+
return [4 /*yield*/, import('../memory/intelligence.js')];
|
|
648
|
+
case 9:
|
|
649
|
+
_d = _m.sent(), benchmarkAdaptation = _d.benchmarkAdaptation, initializeIntelligence = _d.initializeIntelligence;
|
|
650
|
+
return [4 /*yield*/, initializeIntelligence()];
|
|
651
|
+
case 10:
|
|
652
|
+
_m.sent();
|
|
653
|
+
benchmark = benchmarkAdaptation(100);
|
|
654
|
+
return [2 /*return*/, {
|
|
655
|
+
success: true,
|
|
656
|
+
action: 'adapt',
|
|
657
|
+
status: {
|
|
658
|
+
sona: {
|
|
659
|
+
enabled: true,
|
|
660
|
+
adaptationTime: (benchmark.avgMs * 1000).toFixed(2) + "\u03BCs",
|
|
661
|
+
targetMet: benchmark.targetMet,
|
|
662
|
+
minTime: (benchmark.minMs * 1000).toFixed(2) + "\u03BCs",
|
|
663
|
+
maxTime: (benchmark.maxMs * 1000).toFixed(2) + "\u03BCs"
|
|
664
|
+
}
|
|
601
665
|
},
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
666
|
+
message: benchmark.targetMet
|
|
667
|
+
? "SONA adaptation: " + (benchmark.avgMs * 1000).toFixed(2) + "\u03BCs (target <50\u03BCs met)"
|
|
668
|
+
: "SONA adaptation: " + (benchmark.avgMs * 1000).toFixed(2) + "\u03BCs (target not met)"
|
|
669
|
+
}];
|
|
670
|
+
case 11:
|
|
671
|
+
_e = _m.sent();
|
|
672
|
+
return [2 /*return*/, {
|
|
673
|
+
success: true,
|
|
674
|
+
action: 'adapt',
|
|
675
|
+
status: { sona: { enabled: false, reason: 'Intelligence module unavailable' } }
|
|
676
|
+
}];
|
|
677
|
+
case 12:
|
|
678
|
+
_m.trys.push([12, 15, , 16]);
|
|
679
|
+
return [4 /*yield*/, import('../memory/intelligence.js')];
|
|
680
|
+
case 13:
|
|
681
|
+
_f = _m.sent(), getIntelligenceStats = _f.getIntelligenceStats, benchmarkAdaptation = _f.benchmarkAdaptation, initializeIntelligence = _f.initializeIntelligence;
|
|
682
|
+
return [4 /*yield*/, initializeIntelligence()];
|
|
683
|
+
case 14:
|
|
684
|
+
_m.sent();
|
|
685
|
+
stats = getIntelligenceStats();
|
|
686
|
+
benchmark = benchmarkAdaptation(50);
|
|
687
|
+
return [2 /*return*/, {
|
|
688
|
+
success: true,
|
|
689
|
+
action: 'status',
|
|
690
|
+
neural: {
|
|
691
|
+
enabled: config.neural.enabled,
|
|
692
|
+
sonaEnabled: stats.sonaEnabled,
|
|
693
|
+
ruvector: config.neural.ruvector || { enabled: false },
|
|
694
|
+
features: config.neural.features || {},
|
|
695
|
+
realMetrics: {
|
|
696
|
+
patternsLearned: stats.patternsLearned,
|
|
697
|
+
trajectoriesRecorded: stats.trajectoriesRecorded,
|
|
698
|
+
reasoningBankSize: stats.reasoningBankSize,
|
|
699
|
+
adaptationTime: (benchmark.avgMs * 1000).toFixed(2) + "\u03BCs",
|
|
700
|
+
targetMet: benchmark.targetMet,
|
|
701
|
+
lastAdaptation: stats.lastAdaptation
|
|
702
|
+
? new Date(stats.lastAdaptation).toISOString()
|
|
703
|
+
: null
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
capabilities: [
|
|
707
|
+
stats.sonaEnabled ? '✅ SONA Active' : '❌ SONA Inactive',
|
|
708
|
+
benchmark.targetMet ? '✅ <0.05ms Target Met' : '⚠️ Target Not Met',
|
|
709
|
+
stats.patternsLearned + " patterns learned",
|
|
710
|
+
stats.trajectoriesRecorded + " trajectories recorded",
|
|
711
|
+
]
|
|
712
|
+
}];
|
|
713
|
+
case 15:
|
|
714
|
+
_g = _m.sent();
|
|
715
|
+
return [2 /*return*/, {
|
|
716
|
+
success: true,
|
|
717
|
+
action: 'status',
|
|
718
|
+
neural: {
|
|
719
|
+
enabled: config.neural.enabled,
|
|
720
|
+
ruvector: config.neural.ruvector || { enabled: false },
|
|
721
|
+
features: config.neural.features || {}
|
|
722
|
+
},
|
|
723
|
+
message: 'Intelligence module not available - showing config only'
|
|
724
|
+
}];
|
|
725
|
+
case 16: return [2 /*return*/];
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
}); }
|
|
625
729
|
},
|
|
626
730
|
{
|
|
627
731
|
name: 'embeddings_hyperbolic',
|
|
@@ -633,106 +737,109 @@ export const embeddingsTools = [
|
|
|
633
737
|
action: {
|
|
634
738
|
type: 'string',
|
|
635
739
|
description: 'Hyperbolic action',
|
|
636
|
-
enum: ['status', 'convert', 'distance', 'midpoint'],
|
|
637
|
-
default: 'status'
|
|
740
|
+
"enum": ['status', 'convert', 'distance', 'midpoint'],
|
|
741
|
+
"default": 'status'
|
|
638
742
|
},
|
|
639
743
|
embedding: {
|
|
640
744
|
type: 'array',
|
|
641
745
|
description: 'Euclidean embedding to convert',
|
|
642
|
-
items: { type: 'number' }
|
|
746
|
+
items: { type: 'number' }
|
|
643
747
|
},
|
|
644
748
|
embedding1: {
|
|
645
749
|
type: 'array',
|
|
646
750
|
description: 'First embedding for distance/midpoint',
|
|
647
|
-
items: { type: 'number' }
|
|
751
|
+
items: { type: 'number' }
|
|
648
752
|
},
|
|
649
753
|
embedding2: {
|
|
650
754
|
type: 'array',
|
|
651
755
|
description: 'Second embedding for distance/midpoint',
|
|
652
|
-
items: { type: 'number' }
|
|
653
|
-
}
|
|
654
|
-
},
|
|
655
|
-
},
|
|
656
|
-
handler: async (input) => {
|
|
657
|
-
const config = loadConfig();
|
|
658
|
-
if (!config) {
|
|
659
|
-
return {
|
|
660
|
-
success: false,
|
|
661
|
-
error: 'Embeddings not initialized. Run embeddings/init first.',
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
if (!config.hyperbolic.enabled) {
|
|
665
|
-
return {
|
|
666
|
-
success: false,
|
|
667
|
-
error: 'Hyperbolic mode not enabled. Initialize with hyperbolic=true.',
|
|
668
|
-
};
|
|
669
|
-
}
|
|
670
|
-
const action = input.action || 'status';
|
|
671
|
-
const curvature = config.hyperbolic.curvature;
|
|
672
|
-
switch (action) {
|
|
673
|
-
case 'convert':
|
|
674
|
-
const embedding = input.embedding;
|
|
675
|
-
if (!embedding || !Array.isArray(embedding)) {
|
|
676
|
-
return { success: false, error: 'Embedding array required for convert action' };
|
|
677
|
-
}
|
|
678
|
-
const poincare = toPoincare(embedding, curvature);
|
|
679
|
-
return {
|
|
680
|
-
success: true,
|
|
681
|
-
action: 'convert',
|
|
682
|
-
euclidean: embedding,
|
|
683
|
-
poincare,
|
|
684
|
-
curvature,
|
|
685
|
-
poincareNorm: Math.sqrt(poincare.reduce((sum, x) => sum + x * x, 0)),
|
|
686
|
-
};
|
|
687
|
-
case 'distance':
|
|
688
|
-
const emb1 = input.embedding1;
|
|
689
|
-
const emb2 = input.embedding2;
|
|
690
|
-
if (!emb1 || !emb2) {
|
|
691
|
-
return { success: false, error: 'embedding1 and embedding2 required for distance action' };
|
|
692
|
-
}
|
|
693
|
-
const dist = poincareDistance(emb1, emb2, curvature);
|
|
694
|
-
return {
|
|
695
|
-
success: true,
|
|
696
|
-
action: 'distance',
|
|
697
|
-
distance: dist,
|
|
698
|
-
curvature,
|
|
699
|
-
interpretation: dist < 1 ? 'close' : dist < 2 ? 'moderate' : 'far',
|
|
700
|
-
};
|
|
701
|
-
case 'midpoint':
|
|
702
|
-
const e1 = input.embedding1;
|
|
703
|
-
const e2 = input.embedding2;
|
|
704
|
-
if (!e1 || !e2) {
|
|
705
|
-
return { success: false, error: 'embedding1 and embedding2 required for midpoint action' };
|
|
706
|
-
}
|
|
707
|
-
// Simplified midpoint (proper Möbius midpoint is more complex)
|
|
708
|
-
const mid = e1.map((_, i) => (e1[i] + e2[i]) / 2);
|
|
709
|
-
const norm = Math.sqrt(mid.reduce((sum, x) => sum + x * x, 0));
|
|
710
|
-
const scaledMid = mid.map(x => x * (config.hyperbolic.maxNorm / Math.max(norm, config.hyperbolic.maxNorm)));
|
|
711
|
-
return {
|
|
712
|
-
success: true,
|
|
713
|
-
action: 'midpoint',
|
|
714
|
-
midpoint: scaledMid,
|
|
715
|
-
curvature,
|
|
716
|
-
};
|
|
717
|
-
default: // status
|
|
718
|
-
return {
|
|
719
|
-
success: true,
|
|
720
|
-
action: 'status',
|
|
721
|
-
hyperbolic: {
|
|
722
|
-
enabled: true,
|
|
723
|
-
curvature,
|
|
724
|
-
epsilon: config.hyperbolic.epsilon,
|
|
725
|
-
maxNorm: config.hyperbolic.maxNorm,
|
|
726
|
-
},
|
|
727
|
-
benefits: [
|
|
728
|
-
'Better hierarchical data representation',
|
|
729
|
-
'Exponential capacity in low dimensions',
|
|
730
|
-
'Preserves tree-like structures',
|
|
731
|
-
'Natural for taxonomy embeddings',
|
|
732
|
-
],
|
|
733
|
-
};
|
|
756
|
+
items: { type: 'number' }
|
|
757
|
+
}
|
|
734
758
|
}
|
|
735
759
|
},
|
|
760
|
+
handler: function (input) { return __awaiter(void 0, void 0, void 0, function () {
|
|
761
|
+
var config, action, curvature, embedding, poincare, emb1, emb2, dist, e1_1, e2_1, mid, norm_1, scaledMid;
|
|
762
|
+
return __generator(this, function (_a) {
|
|
763
|
+
config = loadConfig();
|
|
764
|
+
if (!config) {
|
|
765
|
+
return [2 /*return*/, {
|
|
766
|
+
success: false,
|
|
767
|
+
error: 'Embeddings not initialized. Run embeddings/init first.'
|
|
768
|
+
}];
|
|
769
|
+
}
|
|
770
|
+
if (!config.hyperbolic.enabled) {
|
|
771
|
+
return [2 /*return*/, {
|
|
772
|
+
success: false,
|
|
773
|
+
error: 'Hyperbolic mode not enabled. Initialize with hyperbolic=true.'
|
|
774
|
+
}];
|
|
775
|
+
}
|
|
776
|
+
action = input.action || 'status';
|
|
777
|
+
curvature = config.hyperbolic.curvature;
|
|
778
|
+
switch (action) {
|
|
779
|
+
case 'convert':
|
|
780
|
+
embedding = input.embedding;
|
|
781
|
+
if (!embedding || !Array.isArray(embedding)) {
|
|
782
|
+
return [2 /*return*/, { success: false, error: 'Embedding array required for convert action' }];
|
|
783
|
+
}
|
|
784
|
+
poincare = toPoincare(embedding, curvature);
|
|
785
|
+
return [2 /*return*/, {
|
|
786
|
+
success: true,
|
|
787
|
+
action: 'convert',
|
|
788
|
+
euclidean: embedding,
|
|
789
|
+
poincare: poincare,
|
|
790
|
+
curvature: curvature,
|
|
791
|
+
poincareNorm: Math.sqrt(poincare.reduce(function (sum, x) { return sum + x * x; }, 0))
|
|
792
|
+
}];
|
|
793
|
+
case 'distance':
|
|
794
|
+
emb1 = input.embedding1;
|
|
795
|
+
emb2 = input.embedding2;
|
|
796
|
+
if (!emb1 || !emb2) {
|
|
797
|
+
return [2 /*return*/, { success: false, error: 'embedding1 and embedding2 required for distance action' }];
|
|
798
|
+
}
|
|
799
|
+
dist = poincareDistance(emb1, emb2, curvature);
|
|
800
|
+
return [2 /*return*/, {
|
|
801
|
+
success: true,
|
|
802
|
+
action: 'distance',
|
|
803
|
+
distance: dist,
|
|
804
|
+
curvature: curvature,
|
|
805
|
+
interpretation: dist < 1 ? 'close' : dist < 2 ? 'moderate' : 'far'
|
|
806
|
+
}];
|
|
807
|
+
case 'midpoint':
|
|
808
|
+
e1_1 = input.embedding1;
|
|
809
|
+
e2_1 = input.embedding2;
|
|
810
|
+
if (!e1_1 || !e2_1) {
|
|
811
|
+
return [2 /*return*/, { success: false, error: 'embedding1 and embedding2 required for midpoint action' }];
|
|
812
|
+
}
|
|
813
|
+
mid = e1_1.map(function (_, i) { return (e1_1[i] + e2_1[i]) / 2; });
|
|
814
|
+
norm_1 = Math.sqrt(mid.reduce(function (sum, x) { return sum + x * x; }, 0));
|
|
815
|
+
scaledMid = mid.map(function (x) { return x * (config.hyperbolic.maxNorm / Math.max(norm_1, config.hyperbolic.maxNorm)); });
|
|
816
|
+
return [2 /*return*/, {
|
|
817
|
+
success: true,
|
|
818
|
+
action: 'midpoint',
|
|
819
|
+
midpoint: scaledMid,
|
|
820
|
+
curvature: curvature
|
|
821
|
+
}];
|
|
822
|
+
default: // status
|
|
823
|
+
return [2 /*return*/, {
|
|
824
|
+
success: true,
|
|
825
|
+
action: 'status',
|
|
826
|
+
hyperbolic: {
|
|
827
|
+
enabled: true,
|
|
828
|
+
curvature: curvature,
|
|
829
|
+
epsilon: config.hyperbolic.epsilon,
|
|
830
|
+
maxNorm: config.hyperbolic.maxNorm
|
|
831
|
+
},
|
|
832
|
+
benefits: [
|
|
833
|
+
'Better hierarchical data representation',
|
|
834
|
+
'Exponential capacity in low dimensions',
|
|
835
|
+
'Preserves tree-like structures',
|
|
836
|
+
'Natural for taxonomy embeddings',
|
|
837
|
+
]
|
|
838
|
+
}];
|
|
839
|
+
}
|
|
840
|
+
return [2 /*return*/];
|
|
841
|
+
});
|
|
842
|
+
}); }
|
|
736
843
|
},
|
|
737
844
|
{
|
|
738
845
|
name: 'embeddings_status',
|
|
@@ -740,43 +847,47 @@ export const embeddingsTools = [
|
|
|
740
847
|
category: 'embeddings',
|
|
741
848
|
inputSchema: {
|
|
742
849
|
type: 'object',
|
|
743
|
-
properties: {}
|
|
744
|
-
},
|
|
745
|
-
handler: async () => {
|
|
746
|
-
const config = loadConfig();
|
|
747
|
-
if (!config) {
|
|
748
|
-
return {
|
|
749
|
-
success: false,
|
|
750
|
-
initialized: false,
|
|
751
|
-
message: 'Embeddings not initialized. Run embeddings/init first.',
|
|
752
|
-
};
|
|
753
|
-
}
|
|
754
|
-
return {
|
|
755
|
-
success: true,
|
|
756
|
-
initialized: true,
|
|
757
|
-
config: {
|
|
758
|
-
model: config.model,
|
|
759
|
-
dimension: config.dimension,
|
|
760
|
-
cacheSize: config.cacheSize,
|
|
761
|
-
hyperbolic: config.hyperbolic,
|
|
762
|
-
neural: {
|
|
763
|
-
enabled: config.neural.enabled,
|
|
764
|
-
ruvector: config.neural.ruvector?.enabled ?? false,
|
|
765
|
-
},
|
|
766
|
-
},
|
|
767
|
-
paths: {
|
|
768
|
-
config: getConfigPath(),
|
|
769
|
-
models: config.modelPath,
|
|
770
|
-
},
|
|
771
|
-
initializedAt: config.initialized,
|
|
772
|
-
capabilities: {
|
|
773
|
-
onnxModels: ['all-MiniLM-L6-v2', 'all-mpnet-base-v2'],
|
|
774
|
-
geometries: ['euclidean', 'poincare'],
|
|
775
|
-
normalizations: ['L2', 'L1', 'minmax', 'zscore'],
|
|
776
|
-
features: ['semantic search', 'hyperbolic projection', 'neural substrate'],
|
|
777
|
-
},
|
|
778
|
-
};
|
|
850
|
+
properties: {}
|
|
779
851
|
},
|
|
852
|
+
handler: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
853
|
+
var config;
|
|
854
|
+
var _a, _b;
|
|
855
|
+
return __generator(this, function (_c) {
|
|
856
|
+
config = loadConfig();
|
|
857
|
+
if (!config) {
|
|
858
|
+
return [2 /*return*/, {
|
|
859
|
+
success: false,
|
|
860
|
+
initialized: false,
|
|
861
|
+
message: 'Embeddings not initialized. Run embeddings/init first.'
|
|
862
|
+
}];
|
|
863
|
+
}
|
|
864
|
+
return [2 /*return*/, {
|
|
865
|
+
success: true,
|
|
866
|
+
initialized: true,
|
|
867
|
+
config: {
|
|
868
|
+
model: config.model,
|
|
869
|
+
dimension: config.dimension,
|
|
870
|
+
cacheSize: config.cacheSize,
|
|
871
|
+
hyperbolic: config.hyperbolic,
|
|
872
|
+
neural: {
|
|
873
|
+
enabled: config.neural.enabled,
|
|
874
|
+
ruvector: (_b = (_a = config.neural.ruvector) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : false
|
|
875
|
+
}
|
|
876
|
+
},
|
|
877
|
+
paths: {
|
|
878
|
+
config: getConfigPath(),
|
|
879
|
+
models: config.modelPath
|
|
880
|
+
},
|
|
881
|
+
initializedAt: config.initialized,
|
|
882
|
+
capabilities: {
|
|
883
|
+
onnxModels: ['all-MiniLM-L6-v2', 'all-mpnet-base-v2'],
|
|
884
|
+
geometries: ['euclidean', 'poincare'],
|
|
885
|
+
normalizations: ['L2', 'L1', 'minmax', 'zscore'],
|
|
886
|
+
features: ['semantic search', 'hyperbolic projection', 'neural substrate']
|
|
887
|
+
}
|
|
888
|
+
}];
|
|
889
|
+
});
|
|
890
|
+
}); }
|
|
780
891
|
},
|
|
781
892
|
];
|
|
782
893
|
//# sourceMappingURL=embeddings-tools.js.map
|