monomind 1.10.56 → 1.11.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/coordinator.md +71 -0
- package/.claude/agents/generated/case-analyst.md +50 -0
- package/.claude/agents/generated/copy-editor.md +45 -0
- package/.claude/agents/generated/court-reporter.md +50 -0
- package/.claude/agents/generated/defender.md +51 -0
- package/.claude/agents/generated/editor-in-chief.md +45 -0
- package/.claude/agents/generated/fact-checker.md +45 -0
- package/.claude/agents/generated/judge.md +51 -0
- package/.claude/agents/generated/prosecutor.md +51 -0
- package/.claude/agents/generated/reporter.md +45 -0
- package/.claude/commands/hooks/README.md +1 -1
- package/.claude/commands/hooks/overview.md +1 -1
- package/.claude/commands/mastermind/_repeat.md +1 -1
- package/.claude/commands/mastermind/do.md +3 -1
- package/.claude/commands/mastermind/help.md +2 -2
- package/.claude/commands/mastermind/master.md +39 -6
- package/.claude/commands/mastermind/memory.md +1 -1
- package/.claude/commands/memory/memory-search.md +2 -2
- package/.claude/commands/monitoring/status.md +1 -1
- package/.claude/commands/{browse.md → monobrowse.md} +2 -2
- package/.claude/commands/sparc.md +1 -1
- package/.claude/helpers/handlers/graph-status-handler.cjs +1 -1
- package/.claude/helpers/loop-tracker.cjs +1 -1
- package/.claude/scheduled_tasks.lock +1 -1
- package/.claude/skills/agent-browser-testing/SKILL.md +1 -1
- package/.claude/skills/hooks-automation/SKILL.md +0 -3
- package/.claude/skills/mastermind/build.md +1 -1
- package/.claude/skills/mastermind/code-quality-reviewer-prompt.md +60 -0
- package/.claude/skills/mastermind/content.md +1 -1
- package/.claude/skills/mastermind/createorg.md +79 -2
- package/.claude/skills/mastermind/design.md +3 -1
- package/.claude/skills/mastermind/finance.md +1 -1
- package/.claude/skills/mastermind/implementer-prompt.md +109 -0
- package/.claude/skills/mastermind/marketing.md +1 -1
- package/.claude/skills/mastermind/ops.md +1 -1
- package/.claude/skills/mastermind/plan.md +20 -2
- package/.claude/skills/mastermind/release.md +1 -1
- package/.claude/skills/mastermind/research.md +1 -1
- package/.claude/skills/mastermind/review.md +1 -1
- package/.claude/skills/mastermind/sales.md +1 -1
- package/.claude/skills/mastermind/spec-reviewer-prompt.md +63 -0
- package/.claude/skills/sparc-methodology/SKILL.md +3 -3
- package/.claude/skills/swarm-advanced/SKILL.md +1 -4
- package/.claude-plugin/README.md +1 -2
- package/.claude-plugin/docs/PLUGIN_SUMMARY.md +0 -1
- package/README.md +18 -32
- package/package.json +1 -1
- package/packages/@monomind/cli/README.md +18 -32
- package/packages/@monomind/cli/dist/src/agents/registry-builder.d.ts +1 -7
- package/packages/@monomind/cli/dist/src/agents/registry-builder.js +10 -6
- package/packages/@monomind/cli/dist/src/benchmarks/benchmark-runner.d.ts +59 -12
- package/packages/@monomind/cli/dist/src/benchmarks/benchmark-runner.js +67 -13
- package/packages/@monomind/cli/dist/src/benchmarks/pretrain/index.d.ts +0 -13
- package/packages/@monomind/cli/dist/src/commands/agent-wasm.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/commands/agent-wasm.js +5 -5
- package/packages/@monomind/cli/dist/src/commands/agent.js +1 -6
- package/packages/@monomind/cli/dist/src/commands/analyze.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/analyze.js +8 -18
- package/packages/@monomind/cli/dist/src/commands/doctor.js +53 -3
- package/packages/@monomind/cli/dist/src/commands/embeddings.js +9 -33
- package/packages/@monomind/cli/dist/src/commands/hooks.js +24 -76
- package/packages/@monomind/cli/dist/src/commands/index.d.ts +4 -6
- package/packages/@monomind/cli/dist/src/commands/index.js +8 -15
- package/packages/@monomind/cli/dist/src/commands/init.js +2 -2
- package/packages/@monomind/cli/dist/src/commands/issues.js +16 -11
- package/packages/@monomind/cli/dist/src/commands/mcp.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/memory.js +6 -6
- package/packages/@monomind/cli/dist/src/commands/migrate.js +1 -2
- package/packages/@monomind/cli/dist/src/commands/monograph.js +18 -11
- package/packages/@monomind/cli/dist/src/commands/monovector/backup.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/backup.js +25 -25
- package/packages/@monomind/cli/dist/src/commands/monovector/benchmark.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/benchmark.js +14 -14
- package/packages/@monomind/cli/dist/src/commands/monovector/import.d.ts +18 -0
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/import.js +21 -21
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/index.d.ts +6 -6
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/index.js +22 -22
- package/packages/@monomind/cli/dist/src/commands/monovector/init.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/init.js +36 -36
- package/packages/@monomind/cli/dist/src/commands/monovector/migrate.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/migrate.js +16 -16
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/optimize.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/optimize.js +10 -10
- package/packages/@monomind/cli/dist/src/commands/monovector/setup.d.ts +18 -0
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/setup.js +77 -77
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/status.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/status.js +34 -34
- package/packages/@monomind/cli/dist/src/commands/neural.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/neural.js +31 -608
- package/packages/@monomind/cli/dist/src/commands/performance.js +7 -10
- package/packages/@monomind/cli/dist/src/commands/plugins.js +3 -4
- package/packages/@monomind/cli/dist/src/commands/process.js +5 -12
- package/packages/@monomind/cli/dist/src/commands/progress.js +16 -16
- package/packages/@monomind/cli/dist/src/commands/route.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/commands/route.js +23 -23
- package/packages/@monomind/cli/dist/src/commands/status.js +0 -3
- package/packages/@monomind/cli/dist/src/commands/swarm.js +2 -3
- package/packages/@monomind/cli/dist/src/commands/update.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/config-adapter.js +27 -0
- package/packages/@monomind/cli/dist/src/consensus/audit-writer.d.ts +44 -17
- package/packages/@monomind/cli/dist/src/dlq/dlq-replayer.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/index.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/index.js +5 -5
- package/packages/@monomind/cli/dist/src/init/claudemd-generator.js +10 -14
- package/packages/@monomind/cli/dist/src/init/executor.js +17 -27
- package/packages/@monomind/cli/dist/src/init/helpers-generator.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/init/helpers-generator.js +2 -2
- package/packages/@monomind/cli/dist/src/init/types.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-client.js +1 -7
- package/packages/@monomind/cli/dist/src/mcp-server.js +9 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.js +1 -52
- package/packages/@monomind/cli/dist/src/mcp-tools/analyze-tools.js +5 -5
- package/packages/@monomind/cli/dist/src/mcp-tools/auto-install.d.ts +4 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/autopilot-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/browser-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/browser-tools.js +6 -5
- package/packages/@monomind/cli/dist/src/mcp-tools/claims-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/coordination-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/coordination-tools.js +51 -54
- package/packages/@monomind/cli/dist/src/mcp-tools/daa-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/embeddings-tools.js +10 -10
- package/packages/@monomind/cli/dist/src/mcp-tools/guidance-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/guidance-tools.js +0 -24
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-tools.js +189 -446
- package/packages/@monomind/cli/dist/src/mcp-tools/index.d.ts +0 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/index.js +0 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-compat.d.ts +334 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-compat.js +1108 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +76 -34
- package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.js +2 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/progress-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/ruvllm-tools.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/ruvllm-tools.js +3 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/terminal-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/terminal-tools.js +29 -19
- package/packages/@monomind/cli/dist/src/mcp-tools/transfer-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/wasm-agent-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/wasm-agent-tools.js +2 -2
- package/packages/@monomind/cli/dist/src/memory/intelligence.js +14 -8
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.d.ts +17 -2
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +76 -23
- package/packages/@monomind/cli/dist/src/memory/memory-initializer.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/memory/memory-initializer.js +37 -39
- 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.d.ts +37 -0
- package/packages/@monomind/cli/dist/src/monovector/command-outcomes.js +87 -0
- package/packages/@monomind/cli/dist/src/monovector/coverage-router.d.ts +103 -0
- package/packages/@monomind/cli/dist/src/monovector/coverage-router.js +337 -0
- package/packages/@monomind/cli/dist/src/monovector/coverage-tools.d.ts +14 -0
- package/packages/@monomind/cli/dist/src/monovector/coverage-tools.js +112 -0
- package/packages/@monomind/cli/dist/src/{ruvector → monovector}/diff-classifier.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/monovector/index.d.ts +61 -0
- package/packages/@monomind/cli/dist/src/monovector/index.js +67 -0
- package/packages/@monomind/cli/dist/src/monovector/init-state.d.ts +35 -0
- package/packages/@monomind/cli/dist/src/monovector/init-state.js +36 -0
- package/packages/@monomind/cli/dist/src/monovector/route-outcomes.d.ts +55 -0
- package/packages/@monomind/cli/dist/src/monovector/route-outcomes.js +137 -0
- package/packages/@monomind/cli/dist/src/parser.js +3 -3
- package/packages/@monomind/cli/dist/src/plugins/store/discovery.js +0 -31
- package/packages/@monomind/cli/dist/src/production/circuit-breaker.d.ts +26 -6
- package/packages/@monomind/cli/dist/src/production/error-handler.d.ts +55 -30
- package/packages/@monomind/cli/dist/src/production/index.d.ts +3 -20
- package/packages/@monomind/cli/dist/src/production/index.js +3 -15
- package/packages/@monomind/cli/dist/src/production/monitoring.d.ts +54 -34
- package/packages/@monomind/cli/dist/src/production/monitoring.js +12 -14
- package/packages/@monomind/cli/dist/src/production/rate-limiter.d.ts +64 -19
- package/packages/@monomind/cli/dist/src/production/rate-limiter.js +5 -5
- package/packages/@monomind/cli/dist/src/production/retry.js +4 -2
- package/packages/@monomind/cli/dist/src/runtime/headless.d.ts +3 -3
- package/packages/@monomind/cli/dist/src/services/claim-service.d.ts +50 -59
- package/packages/@monomind/cli/dist/src/services/claim-service.js +83 -50
- package/packages/@monomind/cli/dist/src/services/config-file-manager.js +8 -1
- package/packages/@monomind/cli/dist/src/services/worker-daemon.js +4 -0
- package/packages/@monomind/cli/dist/src/transfer/ipfs/upload.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/transfer/storage/gcs.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/types.d.ts +13 -0
- package/packages/@monomind/cli/dist/src/update/checker.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/update/index.d.ts +1 -1
- package/packages/@monomind/cli/package.json +13 -13
- package/packages/@monomind/guidance/dist/index.d.ts +1 -1
- package/packages/@monomind/guidance/dist/index.js +1 -1
- package/packages/@monomind/guidance/package.json +1 -2
- package/scripts/build-monovector.sh +10 -0
- package/scripts/publish-monovector.sh +20 -0
- package/.claude/commands/monomind/adr.md +0 -11
- package/.claude/commands/monomind/budget.md +0 -7
- package/.claude/commands/monomind/createtask.md +0 -277
- package/.claude/commands/monomind/do.md +0 -498
- package/.claude/commands/monomind/graph-status.md +0 -7
- package/.claude/commands/monomind/help.md +0 -118
- package/.claude/commands/monomind/idea.md +0 -273
- package/.claude/commands/monomind/improve.md +0 -352
- package/.claude/commands/monomind/loops.md +0 -7
- package/.claude/commands/monomind/memory.md +0 -230
- package/.claude/commands/monomind/repeat.md +0 -257
- package/.claude/commands/monomind/review.md +0 -317
- package/.claude/commands/monomind/specialagents.md +0 -125
- package/.claude/commands/monomind/swarm.md +0 -161
- package/.claude/commands/monomind/understand.md +0 -139
- package/.claude/commands/training/README.md +0 -39
- package/.claude/commands/training/neural-patterns.md +0 -73
- package/.claude/commands/training/neural-train.md +0 -79
- package/packages/@monomind/cli/dist/src/commands/appliance-advanced.d.ts +0 -9
- package/packages/@monomind/cli/dist/src/commands/appliance-advanced.js +0 -238
- package/packages/@monomind/cli/dist/src/commands/appliance.d.ts +0 -8
- package/packages/@monomind/cli/dist/src/commands/appliance.js +0 -406
- package/packages/@monomind/cli/dist/src/commands/ruvector/backup.d.ts +0 -11
- package/packages/@monomind/cli/dist/src/commands/ruvector/benchmark.d.ts +0 -11
- package/packages/@monomind/cli/dist/src/commands/ruvector/import.d.ts +0 -18
- package/packages/@monomind/cli/dist/src/commands/ruvector/init.d.ts +0 -11
- package/packages/@monomind/cli/dist/src/commands/ruvector/migrate.d.ts +0 -11
- package/packages/@monomind/cli/dist/src/commands/ruvector/setup.d.ts +0 -18
- package/packages/@monomind/cli/dist/src/ruvector/agent-wasm.d.ts +0 -182
- package/packages/@monomind/cli/dist/src/ruvector/agent-wasm.js +0 -316
- package/packages/@monomind/cli/dist/src/ruvector/ast-analyzer.d.ts +0 -67
- package/packages/@monomind/cli/dist/src/ruvector/ast-analyzer.js +0 -277
- package/packages/@monomind/cli/dist/src/ruvector/coverage-router.d.ts +0 -160
- package/packages/@monomind/cli/dist/src/ruvector/coverage-router.js +0 -539
- package/packages/@monomind/cli/dist/src/ruvector/coverage-tools.d.ts +0 -33
- package/packages/@monomind/cli/dist/src/ruvector/coverage-tools.js +0 -157
- package/packages/@monomind/cli/dist/src/ruvector/enhanced-model-router.d.ts +0 -146
- package/packages/@monomind/cli/dist/src/ruvector/enhanced-model-router.js +0 -551
- package/packages/@monomind/cli/dist/src/ruvector/flash-attention.d.ts +0 -195
- package/packages/@monomind/cli/dist/src/ruvector/flash-attention.js +0 -643
- package/packages/@monomind/cli/dist/src/ruvector/graph-analyzer.d.ts +0 -187
- package/packages/@monomind/cli/dist/src/ruvector/graph-analyzer.js +0 -929
- package/packages/@monomind/cli/dist/src/ruvector/index.d.ts +0 -56
- package/packages/@monomind/cli/dist/src/ruvector/index.js +0 -58
- package/packages/@monomind/cli/dist/src/ruvector/lora-adapter.d.ts +0 -218
- package/packages/@monomind/cli/dist/src/ruvector/lora-adapter.js +0 -455
- package/packages/@monomind/cli/dist/src/ruvector/model-router.d.ts +0 -222
- package/packages/@monomind/cli/dist/src/ruvector/model-router.js +0 -512
- package/packages/@monomind/cli/dist/src/ruvector/moe-router.d.ts +0 -213
- package/packages/@monomind/cli/dist/src/ruvector/moe-router.js +0 -649
- package/packages/@monomind/cli/dist/src/ruvector/q-learning-router.d.ts +0 -217
- package/packages/@monomind/cli/dist/src/ruvector/q-learning-router.js +0 -712
- package/packages/@monomind/cli/dist/src/ruvector/ruvllm-wasm.d.ts +0 -179
- package/packages/@monomind/cli/dist/src/ruvector/ruvllm-wasm.js +0 -363
- package/packages/@monomind/cli/dist/src/ruvector/semantic-router.d.ts +0 -77
- package/packages/@monomind/cli/dist/src/ruvector/semantic-router.js +0 -178
- package/packages/@monomind/cli/dist/src/ruvector/vector-db.d.ts +0 -69
- package/packages/@monomind/cli/dist/src/ruvector/vector-db.js +0 -243
- package/packages/@monomind/cli/dist/src/services/ruvector-training.d.ts +0 -222
- package/packages/@monomind/cli/dist/src/services/ruvector-training.js +0 -696
- /package/packages/@monomind/cli/dist/src/{ruvector → monovector}/diff-classifier.js +0 -0
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure JavaScript SemanticRouter implementation
|
|
3
|
-
*
|
|
4
|
-
* Provides intent routing using cosine similarity.
|
|
5
|
-
* This is a fallback implementation since @ruvector/router's native VectorDb has bugs.
|
|
6
|
-
*
|
|
7
|
-
* Performance: ~50,000 routes/sec with 100 intents (sufficient for agent routing)
|
|
8
|
-
*/
|
|
9
|
-
export class SemanticRouter {
|
|
10
|
-
dimension;
|
|
11
|
-
metric;
|
|
12
|
-
intents = new Map();
|
|
13
|
-
totalVectors = 0;
|
|
14
|
-
constructor(config) {
|
|
15
|
-
if (!config || typeof config.dimension !== 'number') {
|
|
16
|
-
throw new Error('SemanticRouter requires a dimension in config');
|
|
17
|
-
}
|
|
18
|
-
this.dimension = config.dimension;
|
|
19
|
-
this.metric = config.metric ?? 'cosine';
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Add an intent with pre-computed embeddings
|
|
23
|
-
*/
|
|
24
|
-
addIntentWithEmbeddings(name, embeddings, metadata = {}) {
|
|
25
|
-
if (!name || !Array.isArray(embeddings)) {
|
|
26
|
-
throw new Error('Must provide name and embeddings array');
|
|
27
|
-
}
|
|
28
|
-
// Validate embeddings
|
|
29
|
-
for (const emb of embeddings) {
|
|
30
|
-
if (!(emb instanceof Float32Array) || emb.length !== this.dimension) {
|
|
31
|
-
throw new Error(`Embedding must be Float32Array of length ${this.dimension}`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
// Normalize embeddings for cosine similarity
|
|
35
|
-
const normalizedEmbeddings = embeddings.map(emb => this.normalize(emb));
|
|
36
|
-
this.intents.set(name, {
|
|
37
|
-
name,
|
|
38
|
-
embeddings: normalizedEmbeddings,
|
|
39
|
-
metadata,
|
|
40
|
-
});
|
|
41
|
-
this.totalVectors += embeddings.length;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Route a query using a pre-computed embedding
|
|
45
|
-
*/
|
|
46
|
-
routeWithEmbedding(embedding, k = 5) {
|
|
47
|
-
if (!(embedding instanceof Float32Array) || embedding.length !== this.dimension) {
|
|
48
|
-
throw new Error(`Embedding must be Float32Array of length ${this.dimension}`);
|
|
49
|
-
}
|
|
50
|
-
const normalizedQuery = this.normalize(embedding);
|
|
51
|
-
const scores = [];
|
|
52
|
-
// Calculate best score for each intent
|
|
53
|
-
for (const [intentName, intent] of this.intents) {
|
|
54
|
-
let bestScore = -Infinity;
|
|
55
|
-
for (const storedEmb of intent.embeddings) {
|
|
56
|
-
const score = this.similarity(normalizedQuery, storedEmb);
|
|
57
|
-
if (score > bestScore) {
|
|
58
|
-
bestScore = score;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
scores.push({
|
|
62
|
-
intent: intentName,
|
|
63
|
-
score: bestScore,
|
|
64
|
-
metadata: intent.metadata,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
// Sort by score descending and take top k
|
|
68
|
-
return scores
|
|
69
|
-
.sort((a, b) => b.score - a.score)
|
|
70
|
-
.slice(0, k);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Remove an intent
|
|
74
|
-
*/
|
|
75
|
-
removeIntent(name) {
|
|
76
|
-
const intent = this.intents.get(name);
|
|
77
|
-
if (!intent)
|
|
78
|
-
return false;
|
|
79
|
-
this.totalVectors -= intent.embeddings.length;
|
|
80
|
-
this.intents.delete(name);
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Get all intent names
|
|
85
|
-
*/
|
|
86
|
-
getIntents() {
|
|
87
|
-
return Array.from(this.intents.keys());
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Get intent details
|
|
91
|
-
*/
|
|
92
|
-
getIntent(name) {
|
|
93
|
-
const data = this.intents.get(name);
|
|
94
|
-
if (!data)
|
|
95
|
-
return null;
|
|
96
|
-
return {
|
|
97
|
-
name: data.name,
|
|
98
|
-
utterances: [], // We don't store utterances, only embeddings
|
|
99
|
-
metadata: data.metadata,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Clear all intents
|
|
104
|
-
*/
|
|
105
|
-
clear() {
|
|
106
|
-
this.intents.clear();
|
|
107
|
-
this.totalVectors = 0;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Get total vector count
|
|
111
|
-
*/
|
|
112
|
-
count() {
|
|
113
|
-
return this.totalVectors;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Get number of intents
|
|
117
|
-
*/
|
|
118
|
-
intentCount() {
|
|
119
|
-
return this.intents.size;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Normalize a vector for cosine similarity
|
|
123
|
-
*/
|
|
124
|
-
normalize(vec) {
|
|
125
|
-
let norm = 0;
|
|
126
|
-
for (let i = 0; i < vec.length; i++) {
|
|
127
|
-
norm += vec[i] * vec[i];
|
|
128
|
-
}
|
|
129
|
-
norm = Math.sqrt(norm);
|
|
130
|
-
if (norm === 0)
|
|
131
|
-
return vec;
|
|
132
|
-
const normalized = new Float32Array(vec.length);
|
|
133
|
-
for (let i = 0; i < vec.length; i++) {
|
|
134
|
-
normalized[i] = vec[i] / norm;
|
|
135
|
-
}
|
|
136
|
-
return normalized;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Calculate similarity between two normalized vectors
|
|
140
|
-
*/
|
|
141
|
-
similarity(a, b) {
|
|
142
|
-
switch (this.metric) {
|
|
143
|
-
case 'cosine':
|
|
144
|
-
// For normalized vectors, cosine similarity = dot product
|
|
145
|
-
return this.dotProduct(a, b);
|
|
146
|
-
case 'dotProduct':
|
|
147
|
-
return this.dotProduct(a, b);
|
|
148
|
-
case 'euclidean':
|
|
149
|
-
// Convert Euclidean distance to similarity
|
|
150
|
-
return 1 / (1 + this.euclideanDistance(a, b));
|
|
151
|
-
default:
|
|
152
|
-
return this.dotProduct(a, b);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
dotProduct(a, b) {
|
|
156
|
-
let sum = 0;
|
|
157
|
-
for (let i = 0; i < a.length; i++) {
|
|
158
|
-
sum += a[i] * b[i];
|
|
159
|
-
}
|
|
160
|
-
return sum;
|
|
161
|
-
}
|
|
162
|
-
euclideanDistance(a, b) {
|
|
163
|
-
let sum = 0;
|
|
164
|
-
for (let i = 0; i < a.length; i++) {
|
|
165
|
-
const diff = a[i] - b[i];
|
|
166
|
-
sum += diff * diff;
|
|
167
|
-
}
|
|
168
|
-
return Math.sqrt(sum);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Create a SemanticRouter with the given configuration
|
|
173
|
-
*/
|
|
174
|
-
export function createSemanticRouter(config) {
|
|
175
|
-
return new SemanticRouter(config);
|
|
176
|
-
}
|
|
177
|
-
export default SemanticRouter;
|
|
178
|
-
//# sourceMappingURL=semantic-router.js.map
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vector Database Module
|
|
3
|
-
*
|
|
4
|
-
* Provides optional ruvector WASM-accelerated vector operations for:
|
|
5
|
-
* - Semantic similarity search
|
|
6
|
-
* - HNSW indexing (150x faster)
|
|
7
|
-
* - Embedding generation
|
|
8
|
-
*
|
|
9
|
-
* Gracefully degrades when ruvector is not installed.
|
|
10
|
-
*
|
|
11
|
-
* github.com/nokhodian/monomind
|
|
12
|
-
*/
|
|
13
|
-
export interface VectorDB {
|
|
14
|
-
insert(embedding: Float32Array, id: string, metadata?: Record<string, unknown>): void | Promise<void>;
|
|
15
|
-
search(query: Float32Array, k?: number): Array<{
|
|
16
|
-
id: string;
|
|
17
|
-
score: number;
|
|
18
|
-
metadata?: Record<string, unknown>;
|
|
19
|
-
}> | Promise<Array<{
|
|
20
|
-
id: string;
|
|
21
|
-
score: number;
|
|
22
|
-
metadata?: Record<string, unknown>;
|
|
23
|
-
}>>;
|
|
24
|
-
remove(id: string): boolean | Promise<boolean>;
|
|
25
|
-
size(): number | Promise<number>;
|
|
26
|
-
clear(): void | Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
export interface RuVectorModule {
|
|
29
|
-
createVectorDB(dimensions: number): Promise<VectorDB>;
|
|
30
|
-
generateEmbedding(text: string, dimensions?: number): Float32Array;
|
|
31
|
-
cosineSimilarity(a: Float32Array, b: Float32Array): number;
|
|
32
|
-
isWASMAccelerated(): boolean;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Attempt to load the ruvector module
|
|
36
|
-
* Returns true if successfully loaded, false otherwise
|
|
37
|
-
*/
|
|
38
|
-
export declare function loadRuVector(): Promise<boolean>;
|
|
39
|
-
/**
|
|
40
|
-
* Check if ruvector is available
|
|
41
|
-
*/
|
|
42
|
-
export declare function isRuVectorAvailable(): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Check if WASM acceleration is enabled
|
|
45
|
-
*/
|
|
46
|
-
export declare function isWASMAccelerated(): boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Create a vector database
|
|
49
|
-
* Uses ruvector HNSW if available, falls back to brute-force search
|
|
50
|
-
*/
|
|
51
|
-
export declare function createVectorDB(dimensions?: number): Promise<VectorDB>;
|
|
52
|
-
/**
|
|
53
|
-
* Generate an embedding for text
|
|
54
|
-
* Uses ruvector if available, falls back to hash-based embedding
|
|
55
|
-
*/
|
|
56
|
-
export declare function generateEmbedding(text: string, dimensions?: number): Float32Array;
|
|
57
|
-
/**
|
|
58
|
-
* Compute cosine similarity between two vectors
|
|
59
|
-
*/
|
|
60
|
-
export declare function computeSimilarity(a: Float32Array, b: Float32Array): number;
|
|
61
|
-
/**
|
|
62
|
-
* Get status information about the ruvector module
|
|
63
|
-
*/
|
|
64
|
-
export declare function getStatus(): {
|
|
65
|
-
available: boolean;
|
|
66
|
-
wasmAccelerated: boolean;
|
|
67
|
-
backend: 'ruvector-wasm' | 'ruvector' | 'fallback';
|
|
68
|
-
};
|
|
69
|
-
//# sourceMappingURL=vector-db.d.ts.map
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vector Database Module
|
|
3
|
-
*
|
|
4
|
-
* Provides optional ruvector WASM-accelerated vector operations for:
|
|
5
|
-
* - Semantic similarity search
|
|
6
|
-
* - HNSW indexing (150x faster)
|
|
7
|
-
* - Embedding generation
|
|
8
|
-
*
|
|
9
|
-
* Gracefully degrades when ruvector is not installed.
|
|
10
|
-
*
|
|
11
|
-
* github.com/nokhodian/monomind
|
|
12
|
-
*/
|
|
13
|
-
// ============================================================================
|
|
14
|
-
// Fallback Implementation (when ruvector not available)
|
|
15
|
-
// ============================================================================
|
|
16
|
-
class FallbackVectorDB {
|
|
17
|
-
vectors = new Map();
|
|
18
|
-
dimensions;
|
|
19
|
-
constructor(dimensions) {
|
|
20
|
-
this.dimensions = dimensions;
|
|
21
|
-
}
|
|
22
|
-
insert(embedding, id, metadata) {
|
|
23
|
-
this.vectors.set(id, { embedding, metadata });
|
|
24
|
-
}
|
|
25
|
-
search(query, k = 10) {
|
|
26
|
-
const results = [];
|
|
27
|
-
for (const [id, { embedding, metadata }] of this.vectors) {
|
|
28
|
-
const score = cosineSimilarity(query, embedding);
|
|
29
|
-
results.push({ id, score, metadata });
|
|
30
|
-
}
|
|
31
|
-
return results
|
|
32
|
-
.sort((a, b) => b.score - a.score)
|
|
33
|
-
.slice(0, k);
|
|
34
|
-
}
|
|
35
|
-
remove(id) {
|
|
36
|
-
return this.vectors.delete(id);
|
|
37
|
-
}
|
|
38
|
-
size() {
|
|
39
|
-
return this.vectors.size;
|
|
40
|
-
}
|
|
41
|
-
clear() {
|
|
42
|
-
this.vectors.clear();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Compute cosine similarity between two vectors
|
|
47
|
-
*/
|
|
48
|
-
function cosineSimilarity(a, b) {
|
|
49
|
-
if (a.length !== b.length) {
|
|
50
|
-
throw new Error(`Vector dimension mismatch: ${a.length} vs ${b.length}`);
|
|
51
|
-
}
|
|
52
|
-
let dotProduct = 0;
|
|
53
|
-
let normA = 0;
|
|
54
|
-
let normB = 0;
|
|
55
|
-
for (let i = 0; i < a.length; i++) {
|
|
56
|
-
dotProduct += a[i] * b[i];
|
|
57
|
-
normA += a[i] * a[i];
|
|
58
|
-
normB += b[i] * b[i];
|
|
59
|
-
}
|
|
60
|
-
const denom = Math.sqrt(normA) * Math.sqrt(normB);
|
|
61
|
-
return denom === 0 ? 0 : dotProduct / denom;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Generate a simple hash-based embedding (fallback when ruvector not available)
|
|
65
|
-
*/
|
|
66
|
-
function generateHashEmbedding(text, dimensions = 768) {
|
|
67
|
-
const embedding = new Float32Array(dimensions);
|
|
68
|
-
const normalized = text.toLowerCase().trim();
|
|
69
|
-
// Simple hash function
|
|
70
|
-
let hash = 0;
|
|
71
|
-
for (let i = 0; i < normalized.length; i++) {
|
|
72
|
-
hash = ((hash << 5) - hash) + normalized.charCodeAt(i);
|
|
73
|
-
hash = hash & hash; // Convert to 32bit integer
|
|
74
|
-
}
|
|
75
|
-
// Generate pseudo-random embedding based on hash
|
|
76
|
-
for (let i = 0; i < dimensions; i++) {
|
|
77
|
-
embedding[i] = Math.sin(hash * (i + 1) * 0.001) * 0.5 + 0.5;
|
|
78
|
-
}
|
|
79
|
-
// Normalize
|
|
80
|
-
let norm = 0;
|
|
81
|
-
for (let i = 0; i < dimensions; i++) {
|
|
82
|
-
norm += embedding[i] * embedding[i];
|
|
83
|
-
}
|
|
84
|
-
norm = Math.sqrt(norm);
|
|
85
|
-
for (let i = 0; i < dimensions; i++) {
|
|
86
|
-
embedding[i] /= norm;
|
|
87
|
-
}
|
|
88
|
-
return embedding;
|
|
89
|
-
}
|
|
90
|
-
// ============================================================================
|
|
91
|
-
// Module State
|
|
92
|
-
// ============================================================================
|
|
93
|
-
let ruvectorModule = null;
|
|
94
|
-
let loadAttempted = false;
|
|
95
|
-
let isAvailable = false;
|
|
96
|
-
// ============================================================================
|
|
97
|
-
// Public API
|
|
98
|
-
// ============================================================================
|
|
99
|
-
/**
|
|
100
|
-
* Attempt to load the ruvector module
|
|
101
|
-
* Returns true if successfully loaded, false otherwise
|
|
102
|
-
*/
|
|
103
|
-
export async function loadRuVector() {
|
|
104
|
-
if (loadAttempted) {
|
|
105
|
-
return isAvailable;
|
|
106
|
-
}
|
|
107
|
-
loadAttempted = true;
|
|
108
|
-
try {
|
|
109
|
-
// Dynamic import to handle missing dependency gracefully
|
|
110
|
-
const ruvector = await import('ruvector').catch(() => null);
|
|
111
|
-
// ruvector exports VectorDB class, not createVectorDB function
|
|
112
|
-
if (ruvector && (typeof ruvector.VectorDB === 'function' || typeof ruvector.VectorDb === 'function')) {
|
|
113
|
-
// Create adapter module that matches our expected interface
|
|
114
|
-
const VectorDBClass = ruvector.VectorDB || ruvector.VectorDb;
|
|
115
|
-
ruvectorModule = {
|
|
116
|
-
createVectorDB: async (dimensions) => {
|
|
117
|
-
const db = new VectorDBClass({ dimensions });
|
|
118
|
-
// Wrap ruvector's VectorDB to match our interface
|
|
119
|
-
return {
|
|
120
|
-
insert: (embedding, id, metadata) => {
|
|
121
|
-
db.insert({ id, vector: embedding, metadata });
|
|
122
|
-
},
|
|
123
|
-
search: async (query, k = 10) => {
|
|
124
|
-
const results = await db.search({ vector: query, k });
|
|
125
|
-
return results.map((r) => ({
|
|
126
|
-
id: r.id,
|
|
127
|
-
score: r.score,
|
|
128
|
-
metadata: r.metadata,
|
|
129
|
-
}));
|
|
130
|
-
},
|
|
131
|
-
remove: (id) => {
|
|
132
|
-
db.delete(id);
|
|
133
|
-
return true;
|
|
134
|
-
},
|
|
135
|
-
size: async () => {
|
|
136
|
-
const len = await db.len();
|
|
137
|
-
return len;
|
|
138
|
-
},
|
|
139
|
-
clear: () => {
|
|
140
|
-
// Not directly supported - would need to recreate
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
},
|
|
144
|
-
generateEmbedding: (text, dimensions = 768) => {
|
|
145
|
-
// ruvector may not have this - use fallback
|
|
146
|
-
return generateHashEmbedding(text, dimensions);
|
|
147
|
-
},
|
|
148
|
-
cosineSimilarity: (a, b) => {
|
|
149
|
-
return cosineSimilarity(a, b);
|
|
150
|
-
},
|
|
151
|
-
isWASMAccelerated: () => {
|
|
152
|
-
return ruvector.isWasm?.() ?? false;
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
isAvailable = true;
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
catch {
|
|
160
|
-
// Silently fail - ruvector is optional
|
|
161
|
-
}
|
|
162
|
-
isAvailable = false;
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Check if ruvector is available
|
|
167
|
-
*/
|
|
168
|
-
export function isRuVectorAvailable() {
|
|
169
|
-
return isAvailable;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Check if WASM acceleration is enabled
|
|
173
|
-
*/
|
|
174
|
-
export function isWASMAccelerated() {
|
|
175
|
-
if (ruvectorModule && typeof ruvectorModule.isWASMAccelerated === 'function') {
|
|
176
|
-
return ruvectorModule.isWASMAccelerated();
|
|
177
|
-
}
|
|
178
|
-
return false;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Create a vector database
|
|
182
|
-
* Uses ruvector HNSW if available, falls back to brute-force search
|
|
183
|
-
*/
|
|
184
|
-
export async function createVectorDB(dimensions = 768) {
|
|
185
|
-
await loadRuVector();
|
|
186
|
-
if (ruvectorModule && typeof ruvectorModule.createVectorDB === 'function') {
|
|
187
|
-
try {
|
|
188
|
-
return await ruvectorModule.createVectorDB(dimensions);
|
|
189
|
-
}
|
|
190
|
-
catch {
|
|
191
|
-
// Fall back to simple implementation
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return new FallbackVectorDB(dimensions);
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Generate an embedding for text
|
|
198
|
-
* Uses ruvector if available, falls back to hash-based embedding
|
|
199
|
-
*/
|
|
200
|
-
export function generateEmbedding(text, dimensions = 768) {
|
|
201
|
-
if (ruvectorModule && typeof ruvectorModule.generateEmbedding === 'function') {
|
|
202
|
-
try {
|
|
203
|
-
return ruvectorModule.generateEmbedding(text, dimensions);
|
|
204
|
-
}
|
|
205
|
-
catch {
|
|
206
|
-
// Fall back to hash-based embedding
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return generateHashEmbedding(text, dimensions);
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Compute cosine similarity between two vectors
|
|
213
|
-
*/
|
|
214
|
-
export function computeSimilarity(a, b) {
|
|
215
|
-
if (ruvectorModule && typeof ruvectorModule.cosineSimilarity === 'function') {
|
|
216
|
-
try {
|
|
217
|
-
return ruvectorModule.cosineSimilarity(a, b);
|
|
218
|
-
}
|
|
219
|
-
catch {
|
|
220
|
-
// Fall back to JS implementation
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return cosineSimilarity(a, b);
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Get status information about the ruvector module
|
|
227
|
-
*/
|
|
228
|
-
export function getStatus() {
|
|
229
|
-
if (!isAvailable) {
|
|
230
|
-
return {
|
|
231
|
-
available: false,
|
|
232
|
-
wasmAccelerated: false,
|
|
233
|
-
backend: 'fallback',
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
const wasmAccelerated = isWASMAccelerated();
|
|
237
|
-
return {
|
|
238
|
-
available: true,
|
|
239
|
-
wasmAccelerated,
|
|
240
|
-
backend: wasmAccelerated ? 'ruvector-wasm' : 'ruvector',
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
//# sourceMappingURL=vector-db.js.map
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RuVector Training Service
|
|
3
|
-
* Real WASM-accelerated neural training using @ruvector packages
|
|
4
|
-
*
|
|
5
|
-
* Features:
|
|
6
|
-
* - MicroLoRA: <1µs adaptation with rank-2 LoRA (2.3M ops/s)
|
|
7
|
-
* - SONA: Self-Optimizing Neural Architecture (624k learn/s, 60k search/s)
|
|
8
|
-
* - Flash Attention: 2.49x-7.47x speedup (9k ops/s)
|
|
9
|
-
* - Trajectory Buffer: Learning from success/failure
|
|
10
|
-
* - Contrastive Learning: InfoNCE loss
|
|
11
|
-
*
|
|
12
|
-
* Backward Compatible: All v1 APIs preserved, SONA adds new capabilities
|
|
13
|
-
*
|
|
14
|
-
* github.com/nokhodian/monomind
|
|
15
|
-
*/
|
|
16
|
-
type BenchmarkResult = any;
|
|
17
|
-
/**
|
|
18
|
-
* Get which backend is active for training
|
|
19
|
-
*/
|
|
20
|
-
export declare function getActiveBackend(): 'wasm' | 'js-fallback';
|
|
21
|
-
export interface TrainingConfig {
|
|
22
|
-
dim?: number;
|
|
23
|
-
learningRate?: number;
|
|
24
|
-
alpha?: number;
|
|
25
|
-
trajectoryCapacity?: number;
|
|
26
|
-
useFlashAttention?: boolean;
|
|
27
|
-
useMoE?: boolean;
|
|
28
|
-
useHyperbolic?: boolean;
|
|
29
|
-
totalSteps?: number;
|
|
30
|
-
warmupSteps?: number;
|
|
31
|
-
useSona?: boolean;
|
|
32
|
-
sonaRank?: number;
|
|
33
|
-
}
|
|
34
|
-
export interface TrainingResult {
|
|
35
|
-
success: boolean;
|
|
36
|
-
adaptationCount: bigint;
|
|
37
|
-
forwardCount: bigint;
|
|
38
|
-
deltaNorm: number;
|
|
39
|
-
trajectoryStats?: {
|
|
40
|
-
successRate: number;
|
|
41
|
-
meanImprovement: number;
|
|
42
|
-
bestImprovement: number;
|
|
43
|
-
totalCount: bigint;
|
|
44
|
-
};
|
|
45
|
-
benchmark?: BenchmarkResult[];
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Initialize the RuVector training system.
|
|
49
|
-
* Attempts to load @ruvector/learning-wasm for WASM-accelerated training.
|
|
50
|
-
* Falls back to a pure-JS implementation if WASM is unavailable.
|
|
51
|
-
*/
|
|
52
|
-
export declare function initializeTraining(config?: TrainingConfig): Promise<{
|
|
53
|
-
success: boolean;
|
|
54
|
-
features: string[];
|
|
55
|
-
backend: 'wasm' | 'js-fallback';
|
|
56
|
-
error?: string;
|
|
57
|
-
}>;
|
|
58
|
-
/**
|
|
59
|
-
* Operator types for scoped LoRA (0-16)
|
|
60
|
-
*/
|
|
61
|
-
export declare const OperatorType: {
|
|
62
|
-
readonly GENERAL: 0;
|
|
63
|
-
readonly ATTENTION: 1;
|
|
64
|
-
readonly MLP: 2;
|
|
65
|
-
readonly EMBEDDING: 3;
|
|
66
|
-
readonly NORMALIZATION: 4;
|
|
67
|
-
readonly PROJECTION: 5;
|
|
68
|
-
readonly POOLING: 6;
|
|
69
|
-
readonly CONVOLUTION: 7;
|
|
70
|
-
readonly RECURRENT: 8;
|
|
71
|
-
readonly ROUTING: 9;
|
|
72
|
-
readonly MEMORY: 10;
|
|
73
|
-
readonly REASONING: 11;
|
|
74
|
-
readonly COORDINATION: 12;
|
|
75
|
-
readonly OPTIMIZATION: 13;
|
|
76
|
-
readonly SECURITY: 14;
|
|
77
|
-
readonly TESTING: 15;
|
|
78
|
-
readonly DEBUGGING: 16;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Train a pattern with MicroLoRA
|
|
82
|
-
*/
|
|
83
|
-
export declare function trainPattern(embedding: Float32Array, gradient: Float32Array, operatorType?: number): Promise<{
|
|
84
|
-
deltaNorm: number;
|
|
85
|
-
adaptCount: bigint;
|
|
86
|
-
}>;
|
|
87
|
-
/**
|
|
88
|
-
* Forward pass through LoRA
|
|
89
|
-
*/
|
|
90
|
-
export declare function forward(input: Float32Array, operatorType?: number): Float32Array;
|
|
91
|
-
/**
|
|
92
|
-
* Reward-based adaptation (reinforcement learning)
|
|
93
|
-
*/
|
|
94
|
-
export declare function adaptWithReward(improvement: number, operatorType?: number): void;
|
|
95
|
-
/**
|
|
96
|
-
* Record a learning trajectory
|
|
97
|
-
*/
|
|
98
|
-
export declare function recordTrajectory(embedding: Float32Array, operatorType: number, attentionType: number, executionMs: number, baselineMs: number): void;
|
|
99
|
-
/**
|
|
100
|
-
* Get trajectory statistics
|
|
101
|
-
*/
|
|
102
|
-
export declare function getTrajectoryStats(): {
|
|
103
|
-
successRate: number;
|
|
104
|
-
meanImprovement: number;
|
|
105
|
-
bestImprovement: number;
|
|
106
|
-
totalCount: bigint;
|
|
107
|
-
highQualityCount: number;
|
|
108
|
-
variance: number;
|
|
109
|
-
} | null;
|
|
110
|
-
/**
|
|
111
|
-
* Compute attention with Flash Attention (2.49x-7.47x faster)
|
|
112
|
-
*/
|
|
113
|
-
export declare function computeFlashAttention(query: Float32Array, keys: Float32Array[], values: Float32Array[]): Float32Array;
|
|
114
|
-
/**
|
|
115
|
-
* Compute MoE routing
|
|
116
|
-
*/
|
|
117
|
-
export declare function computeMoEAttention(query: Float32Array, keys: Float32Array[], values: Float32Array[]): Float32Array;
|
|
118
|
-
/**
|
|
119
|
-
* Compute hyperbolic attention (for hierarchical patterns)
|
|
120
|
-
*/
|
|
121
|
-
export declare function computeHyperbolicAttention(query: Float32Array, keys: Float32Array[], values: Float32Array[]): Float32Array;
|
|
122
|
-
/**
|
|
123
|
-
* Compute contrastive loss for training
|
|
124
|
-
*/
|
|
125
|
-
export declare function computeContrastiveLoss(anchor: Float32Array, positives: Float32Array[], negatives: Float32Array[]): {
|
|
126
|
-
loss: number;
|
|
127
|
-
gradient: Float32Array;
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Optimizer step
|
|
131
|
-
*/
|
|
132
|
-
export declare function optimizerStep(params: Float32Array, gradients: Float32Array): Float32Array;
|
|
133
|
-
/**
|
|
134
|
-
* Get curriculum difficulty for current step
|
|
135
|
-
*/
|
|
136
|
-
export declare function getCurriculumDifficulty(step: number): number;
|
|
137
|
-
/**
|
|
138
|
-
* Mine hard negatives for better training
|
|
139
|
-
*/
|
|
140
|
-
export declare function mineHardNegatives(anchor: Float32Array, candidates: Float32Array[]): number[];
|
|
141
|
-
/**
|
|
142
|
-
* Benchmark the training system
|
|
143
|
-
*/
|
|
144
|
-
export declare function benchmarkTraining(dim?: number, iterations?: number): Promise<BenchmarkResult[]>;
|
|
145
|
-
/**
|
|
146
|
-
* Check if SONA is available
|
|
147
|
-
*/
|
|
148
|
-
export declare function isSonaAvailable(): boolean;
|
|
149
|
-
/**
|
|
150
|
-
* Force-learn a pattern with SONA (1.6μs, 624k ops/s)
|
|
151
|
-
* This is a one-shot learning mechanism for immediate pattern storage
|
|
152
|
-
*/
|
|
153
|
-
export declare function sonaForceLearn(embedding: Float32Array, reward: number): void;
|
|
154
|
-
/**
|
|
155
|
-
* Search for similar patterns with SONA (16.7μs, 60k searches/s)
|
|
156
|
-
* Returns the k most similar patterns from the pattern bank
|
|
157
|
-
*/
|
|
158
|
-
export declare function sonaFindPatterns(embedding: Float32Array, k?: number): unknown[];
|
|
159
|
-
/**
|
|
160
|
-
* Process SONA background tasks (0.13μs, 7.5M ticks/s)
|
|
161
|
-
* Call periodically to process background learning and consolidation
|
|
162
|
-
*/
|
|
163
|
-
export declare function sonaTick(): void;
|
|
164
|
-
/**
|
|
165
|
-
* Get SONA statistics
|
|
166
|
-
*/
|
|
167
|
-
export declare function getSonaStats(): {
|
|
168
|
-
available: boolean;
|
|
169
|
-
enabled: boolean;
|
|
170
|
-
stats: Record<string, unknown> | null;
|
|
171
|
-
totalLearns: number;
|
|
172
|
-
totalSearches: number;
|
|
173
|
-
};
|
|
174
|
-
/**
|
|
175
|
-
* Enable/disable SONA learning
|
|
176
|
-
*/
|
|
177
|
-
export declare function setSonaEnabled(enabled: boolean): void;
|
|
178
|
-
/**
|
|
179
|
-
* Flush SONA buffers (persist any pending patterns)
|
|
180
|
-
*/
|
|
181
|
-
export declare function sonaFlush(): void;
|
|
182
|
-
/**
|
|
183
|
-
* Get training statistics
|
|
184
|
-
*/
|
|
185
|
-
export declare function getTrainingStats(): {
|
|
186
|
-
initialized: boolean;
|
|
187
|
-
backend: 'wasm' | 'js-fallback';
|
|
188
|
-
totalAdaptations: number;
|
|
189
|
-
totalForwards: number;
|
|
190
|
-
microLoraStats?: {
|
|
191
|
-
paramCount: number;
|
|
192
|
-
adaptCount: bigint;
|
|
193
|
-
forwardCount: bigint;
|
|
194
|
-
deltaNorm: number;
|
|
195
|
-
};
|
|
196
|
-
scopedLoraStats?: {
|
|
197
|
-
totalAdaptCount: bigint;
|
|
198
|
-
totalForwardCount: bigint;
|
|
199
|
-
};
|
|
200
|
-
trajectoryStats?: ReturnType<typeof getTrajectoryStats>;
|
|
201
|
-
sonaStats?: ReturnType<typeof getSonaStats>;
|
|
202
|
-
lastBenchmark?: BenchmarkResult[];
|
|
203
|
-
};
|
|
204
|
-
/**
|
|
205
|
-
* Reset the training system
|
|
206
|
-
*/
|
|
207
|
-
export declare function resetTraining(): void;
|
|
208
|
-
/**
|
|
209
|
-
* Export trained weights
|
|
210
|
-
*/
|
|
211
|
-
export declare function exportWeights(): {
|
|
212
|
-
dim: number;
|
|
213
|
-
deltaNorm: number;
|
|
214
|
-
adaptCount: bigint;
|
|
215
|
-
trajectoryStats: ReturnType<typeof getTrajectoryStats>;
|
|
216
|
-
} | null;
|
|
217
|
-
/**
|
|
218
|
-
* Cleanup resources
|
|
219
|
-
*/
|
|
220
|
-
export declare function cleanup(): void;
|
|
221
|
-
export {};
|
|
222
|
-
//# sourceMappingURL=ruvector-training.d.ts.map
|