monomind 1.11.3 → 1.11.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monomind",
3
- "version": "1.11.3",
3
+ "version": "1.11.5",
4
4
  "description": "Monomind - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -13,7 +13,7 @@ import { BenchmarkRunner } from '../benchmarks/benchmark-runner.js';
13
13
  // ============================================================================
14
14
  const pretrainCommand = {
15
15
  name: 'pretrain',
16
- description: 'Benchmark self-learning pre-training system (SONA, EWC++, MoE)',
16
+ description: 'Benchmark pattern-learning pre-training system',
17
17
  options: [
18
18
  { name: 'iterations', short: 'i', type: 'number', description: 'Benchmark iterations', default: '100' },
19
19
  { name: 'warmup', short: 'w', type: 'number', description: 'Warmup iterations', default: '10' },
@@ -554,7 +554,7 @@ export const benchmarkCommand = {
554
554
  output.writeln(output.dim('─'.repeat(50)));
555
555
  output.writeln();
556
556
  output.writeln('Available subcommands:');
557
- output.writeln(` ${output.highlight('pretrain')} - Benchmark self-learning pre-training (SONA, EWC++, MoE)`);
557
+ output.writeln(` ${output.highlight('pretrain')} - Benchmark pattern-learning pre-training`);
558
558
  output.writeln(` ${output.highlight('neural')} - Benchmark neural operations (embeddings, WASM)`);
559
559
  output.writeln(` ${output.highlight('memory')} - Benchmark memory operations (HNSW, store, search)`);
560
560
  output.writeln(` ${output.highlight('all')} - Run all benchmark suites`);
@@ -55,16 +55,10 @@ export function systemConfigToMonomindConfig(systemConfig) {
55
55
  autoExecute: false,
56
56
  hooks: [],
57
57
  },
58
- // Neural / SONA learning configuration
58
+ // Neural pattern-learning configuration
59
59
  neural: {
60
60
  enabled: systemConfig.neural?.enabled ?? true,
61
61
  disableNative: systemConfig.neural?.disableNative ?? false,
62
- sona: {
63
- mode: systemConfig.neural?.sona?.mode ?? 'balanced',
64
- learningRate: systemConfig.neural?.sona?.learningRate,
65
- ewcLambda: systemConfig.neural?.sona?.ewcLambda,
66
- embeddingDim: systemConfig.neural?.sona?.embeddingDim,
67
- },
68
62
  },
69
63
  };
70
64
  }
@@ -143,19 +137,12 @@ export function configToSystemConfig(config) {
143
137
  logging: true,
144
138
  },
145
139
  },
146
- // Neural / SONA learning configuration — only emit when present so we don't
147
- // synthesize a neural block for configs that never had one.
140
+ // Neural pattern-learning configuration — only emit when present
148
141
  ...(config.neural
149
142
  ? {
150
143
  neural: {
151
144
  enabled: config.neural.enabled ?? true,
152
145
  disableNative: config.neural.disableNative ?? false,
153
- sona: {
154
- mode: config.neural.sona?.mode ?? 'balanced',
155
- learningRate: config.neural.sona?.learningRate,
156
- ewcLambda: config.neural.sona?.ewcLambda,
157
- embeddingDim: config.neural.sona?.embeddingDim,
158
- },
159
146
  },
160
147
  }
161
148
  : {}),
@@ -66,8 +66,6 @@ export * from './commands/index.js';
66
66
  export { MCPServerManager, createMCPServerManager, getServerManager, startMCPServer, stopMCPServer, getMCPServerStatus, type MCPServerOptions, type MCPServerStatus, } from './mcp-server.js';
67
67
  export { initializeMemoryDatabase, generateEmbedding, generateBatchEmbeddings, storeEntry, searchEntries, getHNSWIndex, addToHNSWIndex, searchHNSWIndex, getHNSWStatus, clearHNSWIndex, quantizeInt8, dequantizeInt8, quantizedCosineSim, getQuantizationStats, batchCosineSim, softmaxAttention, topKIndices, flashAttentionSearch, type MemoryInitResult, } from './memory/memory-initializer.js';
68
68
  export { initializeIntelligence, recordStep, recordTrajectory, findSimilarPatterns, getIntelligenceStats, getSonaCoordinator, getReasoningBank, clearIntelligence, benchmarkAdaptation, endTrajectoryWithVerdict, distillLearning, getAllPatterns, getPatternsByType, flushPatterns, deletePattern, clearAllPatterns, getNeuralDataDir, getPersistenceStatus, type SonaConfig, type TrajectoryStep, type Pattern, type IntelligenceStats, } from './memory/intelligence.js';
69
- export { EWCConsolidator, getEWCConsolidator, resetEWCConsolidator, consolidatePatterns, recordPatternOutcome, getEWCStats, type PatternWeights, type EWCConfig, type ConsolidationResult, type EWCStats, } from './memory/ewc-consolidation.js';
70
- export { SONAOptimizer, getSONAOptimizer, resetSONAOptimizer, processTrajectory, getSuggestion, getSONAStats, type TrajectoryOutcome, type LearnedPattern, type RoutingSuggestion, type SONAStats, } from './memory/sona-optimizer.js';
71
69
  export { ErrorHandler, withErrorHandling, } from './production/error-handler.js';
72
70
  export type { ErrorContext, ErrorHandlerConfig, } from './production/error-handler.js';
73
71
  export { RateLimiter, createRateLimiter, } from './production/rate-limiter.js';
@@ -565,10 +565,6 @@ export { initializeIntelligence, recordStep, recordTrajectory, findSimilarPatter
565
565
  endTrajectoryWithVerdict, distillLearning,
566
566
  // Pattern persistence API
567
567
  getAllPatterns, getPatternsByType, flushPatterns, deletePattern, clearAllPatterns, getNeuralDataDir, getPersistenceStatus, } from './memory/intelligence.js';
568
- // EWC++ Consolidation (Prevents Catastrophic Forgetting)
569
- export { EWCConsolidator, getEWCConsolidator, resetEWCConsolidator, consolidatePatterns, recordPatternOutcome, getEWCStats, } from './memory/ewc-consolidation.js';
570
- // SONA Optimizer (Adaptive Routing via Trajectory Learning)
571
- export { SONAOptimizer, getSONAOptimizer, resetSONAOptimizer, processTrajectory, getSuggestion, getSONAStats, } from './memory/sona-optimizer.js';
572
568
  // Production Hardening
573
569
  export { ErrorHandler, withErrorHandling, } from './production/error-handler.js';
574
570
  export { RateLimiter, createRateLimiter, } from './production/rate-limiter.js';
@@ -900,12 +900,9 @@ export function getServerManager(options) {
900
900
  * Quick start MCP server
901
901
  */
902
902
  export async function startMCPServer(options) {
903
- // A2: mark this as a long-lived host so the SONA write-path (trajectory record +
904
- // consolidation) stays enabled. In one-shot CLI mode this env var is absent and
905
- // the per-call SONA trajectory which would never reach the consolidation
906
- // threshold and is discarded on process exit — is skipped to avoid wasted
907
- // ONNX/embedding overhead. Across MCP calls the registry singleton persists, so
908
- // trajectories accumulate and DO reach threshold here.
903
+ // Mark as long-lived host so the intelligence/trajectory system stays enabled.
904
+ // In one-shot CLI mode trajectories are discarded on process exit; across
905
+ // MCP calls the registry singleton persists so patterns accumulate correctly.
909
906
  process.env.MONOMIND_PERSISTENT_HOST = '1';
910
907
  const manager = getServerManager(options);
911
908
  return await manager.start();
@@ -1475,7 +1475,7 @@ export const hooksBuildAgents = {
1475
1475
  const format = formatRaw;
1476
1476
  const persist = params.persist !== false; // Default to true
1477
1477
  const agents = [
1478
- { type: 'coder', configFile: join(outputDir, `coder.${format}`), capabilities: ['code-generation', 'refactoring', 'debugging'], optimizations: ['flash-attention', 'token-reduction'] },
1478
+ { type: 'coder', configFile: join(outputDir, `coder.${format}`), capabilities: ['code-generation', 'refactoring', 'debugging'], optimizations: ['token-reduction', 'context-caching'] },
1479
1479
  { type: 'architect', configFile: join(outputDir, `architect.${format}`), capabilities: ['system-design', 'api-design', 'documentation'], optimizations: ['context-caching', 'memory-persistence'] },
1480
1480
  { type: 'tester', configFile: join(outputDir, `tester.${format}`), capabilities: ['unit-testing', 'integration-testing', 'coverage'], optimizations: ['parallel-execution'] },
1481
1481
  { type: 'security-architect', configFile: join(outputDir, `security-architect.${format}`), capabilities: ['threat-modeling', 'vulnerability-analysis', 'security-review'], optimizations: ['pattern-matching'] },
@@ -1971,7 +1971,8 @@ export const hooksIntelligence = {
1971
1971
  partial: [],
1972
1972
  notImplemented: [],
1973
1973
  removed: [
1974
- 'sona-optimizer', 'ewc-consolidation', 'moe-routing', 'flash-attention', 'lora-adapter'
1974
+ 'moe-routing', 'flash-attention', 'lora-adapter',
1975
+ 'native-sona-engine', 'native-router', 'native-attention',
1975
1976
  ],
1976
1977
  },
1977
1978
  version: '3.0.0-alpha.102',
@@ -229,10 +229,9 @@ export function detectMonographChanges(db, opts, repoPath) {
229
229
  const affectedSymbols = [];
230
230
  const seenIds = new Set();
231
231
  for (const rel of changedFiles) {
232
- // DB stores relative paths; try both relative and absolute to be safe
233
- const nodes = getNodesForFile(db, rel).length > 0
234
- ? getNodesForFile(db, rel)
235
- : getNodesForFile(db, join(repoPath, rel));
232
+ // DB stores relative paths; try relative first, fall back to absolute
233
+ const relNodes = getNodesForFile(db, rel);
234
+ const nodes = relNodes.length > 0 ? relNodes : getNodesForFile(db, join(repoPath, rel));
236
235
  for (const n of nodes) {
237
236
  if (!seenIds.has(n.id)) {
238
237
  seenIds.add(n.id);
@@ -56,16 +56,10 @@ export interface MonomindConfig {
56
56
  neural?: NeuralConfig;
57
57
  }
58
58
  export interface NeuralConfig {
59
- /** Enable neural/SONA learning (default: true) */
59
+ /** Enable pattern learning (default: true) */
60
60
  enabled?: boolean;
61
61
  /** Force pure-JS fallback, skip all native @monoes packages (default: false) */
62
62
  disableNative?: boolean;
63
- sona?: {
64
- mode?: 'real-time' | 'balanced' | 'research' | 'edge' | 'batch';
65
- learningRate?: number;
66
- ewcLambda?: number;
67
- embeddingDim?: number;
68
- };
69
63
  }
70
64
  export interface AgentConfig {
71
65
  defaultType: string;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monoes/monomindcli",
3
- "version": "1.11.3",
3
+ "version": "1.11.5",
4
4
  "type": "module",
5
5
  "description": "Monomind CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",
@@ -1,7 +1,7 @@
1
1
  #!/bin/bash
2
2
  set -e
3
3
  REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
4
- PACKAGES=(learning-wasm exotic-wasm attention-wasm gnn-wasm ruvllm-wasm rvagent-wasm)
4
+ PACKAGES=(learning-wasm exotic-wasm attention-wasm gnn-wasm)
5
5
  for pkg in "${PACKAGES[@]}"; do
6
6
  echo "Building @monovector/$pkg..."
7
7
  (cd "$REPO_ROOT/packages/@monoes/$pkg" && npm run build)
@@ -6,7 +6,7 @@
6
6
  set -e
7
7
  REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
8
8
 
9
- PACKAGES=(learning-wasm exotic-wasm attention-wasm gnn-wasm ruvllm-wasm rvagent-wasm)
9
+ PACKAGES=(learning-wasm exotic-wasm attention-wasm gnn-wasm)
10
10
 
11
11
  for pkg in "${PACKAGES[@]}"; do
12
12
  PKG_DIR="$REPO_ROOT/packages/@monoes/$pkg/pkg"
@@ -423,24 +423,7 @@ if should_run "rvf"; then
423
423
  rm -rf "$RVF_DIR"
424
424
  fi
425
425
 
426
- # ── 27. Local Model Inference (ruvLLM from RuVector) ──────────
427
- if should_run "ruvllm"; then
428
- section 27 "Local Model Inference (ruvLLM / RuVector)"
429
- if [ "${SKIP_MODELS:-0}" = "1" ]; then
430
- check_skip "ruvllm: model load" "SKIP_MODELS=1"
431
- check_skip "ruvllm: tokenize" "SKIP_MODELS=1"
432
- check_skip "ruvllm: generate" "SKIP_MODELS=1"
433
- check_skip "ruvllm: stream" "SKIP_MODELS=1"
434
- elif command -v monomind-ruvllm >/dev/null 2>&1; then
435
- check_warn "ruvllm: engine available" monomind-ruvllm --version
436
- check_warn "ruvllm: model list" monomind-ruvllm models list
437
- check_warn "ruvllm: tokenize" monomind-ruvllm tokenize --text "Hello world"
438
- check_warn "ruvllm: generate" monomind-ruvllm generate --prompt "2+2=" --max-tokens 10
439
- else
440
- check_skip "ruvllm: engine" "monomind-ruvllm not installed (future: ADR-058 Phase 3)"
441
- check_skip "ruvllm: inference" "monomind-ruvllm not installed"
442
- fi
443
- fi
426
+ # Section 27 (local model inference) was removed native LLM module not in lean build
444
427
 
445
428
  # ── 28. API Key Vault ─────────────────────────────────────────
446
429
  if should_run "vault"; then
@@ -1,9 +0,0 @@
1
- /**
2
- * MonoVector LLM WASM MCP Tools
3
- *
4
- * Exposes @monoes/ruvllm-wasm operations via MCP protocol.
5
- * All tools gracefully degrade when the WASM package is not installed.
6
- */
7
- import type { MCPTool } from './types.js';
8
- export declare const ruvllmWasmTools: MCPTool[];
9
- //# sourceMappingURL=ruvllm-tools.d.ts.map
@@ -1,295 +0,0 @@
1
- /**
2
- * MonoVector LLM WASM MCP Tools
3
- *
4
- * Exposes @monoes/ruvllm-wasm operations via MCP protocol.
5
- * All tools gracefully degrade when the WASM package is not installed.
6
- */
7
- async function loadRuvllmWasm() {
8
- return import('../monovector/ruvllm-wasm.js');
9
- }
10
- // ── Instance Registries ──────────────────────────────────────
11
- const hnswRouters = new Map();
12
- const sonaInstances = new Map();
13
- const loraInstances = new Map();
14
- // ── Map eviction (prevents WASM object leaks in long-running MCP servers) ────
15
- const MAX_MAP_SIZE = 50;
16
- function setWithEviction(map, key, value) {
17
- if (map.size >= MAX_MAP_SIZE) {
18
- // Evict the oldest entry (first inserted)
19
- const firstKey = map.keys().next().value;
20
- map.delete(firstKey);
21
- }
22
- map.set(key, value);
23
- }
24
- export const ruvllmWasmTools = [
25
- {
26
- name: 'ruvllm_status',
27
- description: 'Get ruvllm-wasm availability and initialization status.',
28
- inputSchema: { type: 'object', properties: {} },
29
- handler: async () => {
30
- try {
31
- const mod = await loadRuvllmWasm();
32
- const status = await mod.getRuvllmStatus();
33
- return { content: [{ type: 'text', text: JSON.stringify(status, null, 2) }] };
34
- }
35
- catch (err) {
36
- return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
37
- }
38
- },
39
- },
40
- {
41
- name: 'ruvllm_hnsw_create',
42
- description: 'Create a WASM HNSW router for semantic pattern routing. Max ~11 patterns (v2.0.1 limit).',
43
- inputSchema: {
44
- type: 'object',
45
- properties: {
46
- dimensions: { type: 'number', description: 'Embedding dimensions (e.g., 64, 128, 384)' },
47
- maxPatterns: { type: 'number', description: 'Max patterns capacity (limit ~11 in v2.0.1)' },
48
- efSearch: { type: 'number', description: 'HNSW ef search parameter (higher = more accurate, slower)' },
49
- },
50
- required: ['dimensions', 'maxPatterns'],
51
- },
52
- handler: async (args) => {
53
- try {
54
- const mod = await loadRuvllmWasm();
55
- const router = await mod.createHnswRouter({
56
- dimensions: args.dimensions,
57
- maxPatterns: args.maxPatterns,
58
- efSearch: args.efSearch,
59
- });
60
- // Store router in module-level registry
61
- const id = `hnsw-${Date.now().toString(36)}`;
62
- setWithEviction(hnswRouters, id, router);
63
- return { content: [{ type: 'text', text: JSON.stringify({ success: true, routerId: id, dimensions: args.dimensions, maxPatterns: args.maxPatterns }) }] };
64
- }
65
- catch (err) {
66
- return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
67
- }
68
- },
69
- },
70
- {
71
- name: 'ruvllm_hnsw_add',
72
- description: 'Add a pattern to an HNSW router. Embedding must match router dimensions.',
73
- inputSchema: {
74
- type: 'object',
75
- properties: {
76
- routerId: { type: 'string', description: 'HNSW router ID from ruvllm_hnsw_create' },
77
- name: { type: 'string', description: 'Pattern name/label' },
78
- embedding: { type: 'array', items: { type: 'number' }, description: 'Float array embedding vector' },
79
- metadata: { type: 'object', description: 'Optional metadata object' },
80
- },
81
- required: ['routerId', 'name', 'embedding'],
82
- },
83
- handler: async (args) => {
84
- try {
85
- const router = hnswRouters.get(args.routerId);
86
- if (!router)
87
- return { content: [{ type: 'text', text: JSON.stringify({ error: `Router not found: ${args.routerId}` }) }], isError: true };
88
- const embedding = new Float32Array(args.embedding);
89
- const ok = router.addPattern({
90
- name: args.name,
91
- embedding,
92
- metadata: args.metadata,
93
- });
94
- return { content: [{ type: 'text', text: JSON.stringify({ success: ok, patternCount: router.patternCount() }) }] };
95
- }
96
- catch (err) {
97
- return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
98
- }
99
- },
100
- },
101
- {
102
- name: 'ruvllm_hnsw_route',
103
- description: 'Route a query embedding to nearest patterns in HNSW index.',
104
- inputSchema: {
105
- type: 'object',
106
- properties: {
107
- routerId: { type: 'string', description: 'HNSW router ID' },
108
- query: { type: 'array', items: { type: 'number' }, description: 'Query embedding vector' },
109
- k: { type: 'number', description: 'Number of nearest neighbors (default: 3)' },
110
- },
111
- required: ['routerId', 'query'],
112
- },
113
- handler: async (args) => {
114
- try {
115
- const router = hnswRouters.get(args.routerId);
116
- if (!router)
117
- return { content: [{ type: 'text', text: JSON.stringify({ error: `Router not found: ${args.routerId}` }) }], isError: true };
118
- const query = new Float32Array(args.query);
119
- const k = typeof args.k === 'number' && args.k > 0 ? Math.floor(args.k) : 3;
120
- const results = router.route(query, k);
121
- return { content: [{ type: 'text', text: JSON.stringify({ results }) }] };
122
- }
123
- catch (err) {
124
- return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
125
- }
126
- },
127
- },
128
- {
129
- name: 'ruvllm_sona_create',
130
- description: 'Create a SONA instant adaptation loop (<1ms adaptation cycles).',
131
- inputSchema: {
132
- type: 'object',
133
- properties: {
134
- hiddenDim: { type: 'number', description: 'Hidden dimension (default: 64)' },
135
- learningRate: { type: 'number', description: 'Learning rate (default: 0.01)' },
136
- patternCapacity: { type: 'number', description: 'Max stored patterns' },
137
- },
138
- },
139
- handler: async (args) => {
140
- try {
141
- const mod = await loadRuvllmWasm();
142
- const sona = await mod.createSonaInstant({
143
- hiddenDim: args.hiddenDim,
144
- learningRate: args.learningRate,
145
- patternCapacity: args.patternCapacity,
146
- });
147
- const id = `sona-${Date.now().toString(36)}`;
148
- setWithEviction(sonaInstances, id, sona);
149
- return { content: [{ type: 'text', text: JSON.stringify({ success: true, sonaId: id }) }] };
150
- }
151
- catch (err) {
152
- return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
153
- }
154
- },
155
- },
156
- {
157
- name: 'ruvllm_sona_adapt',
158
- description: 'Run SONA instant adaptation with a quality signal.',
159
- inputSchema: {
160
- type: 'object',
161
- properties: {
162
- sonaId: { type: 'string', description: 'SONA instance ID' },
163
- quality: { type: 'number', description: 'Quality signal (0.0-1.0)' },
164
- },
165
- required: ['sonaId', 'quality'],
166
- },
167
- handler: async (args) => {
168
- try {
169
- const sona = sonaInstances.get(args.sonaId);
170
- if (!sona)
171
- return { content: [{ type: 'text', text: JSON.stringify({ error: `SONA not found: ${args.sonaId}` }) }], isError: true };
172
- sona.adapt(args.quality);
173
- return { content: [{ type: 'text', text: JSON.stringify({ success: true, stats: sona.stats() }) }] };
174
- }
175
- catch (err) {
176
- return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
177
- }
178
- },
179
- },
180
- {
181
- name: 'ruvllm_microlora_create',
182
- description: 'Create a MicroLoRA adapter (ultra-lightweight LoRA, ranks 1-4).',
183
- inputSchema: {
184
- type: 'object',
185
- properties: {
186
- inputDim: { type: 'number', description: 'Input dimension' },
187
- outputDim: { type: 'number', description: 'Output dimension' },
188
- rank: { type: 'number', description: 'LoRA rank (1-4, default: 2)' },
189
- alpha: { type: 'number', description: 'LoRA alpha scaling (default: 1.0)' },
190
- },
191
- required: ['inputDim', 'outputDim'],
192
- },
193
- handler: async (args) => {
194
- try {
195
- const mod = await loadRuvllmWasm();
196
- const lora = await mod.createMicroLora({
197
- inputDim: args.inputDim,
198
- outputDim: args.outputDim,
199
- rank: args.rank,
200
- alpha: args.alpha,
201
- });
202
- const id = `lora-${Date.now().toString(36)}`;
203
- setWithEviction(loraInstances, id, lora);
204
- return { content: [{ type: 'text', text: JSON.stringify({ success: true, loraId: id }) }] };
205
- }
206
- catch (err) {
207
- return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
208
- }
209
- },
210
- },
211
- {
212
- name: 'ruvllm_microlora_adapt',
213
- description: 'Adapt MicroLoRA weights with quality feedback.',
214
- inputSchema: {
215
- type: 'object',
216
- properties: {
217
- loraId: { type: 'string', description: 'MicroLoRA instance ID' },
218
- quality: { type: 'number', description: 'Quality signal (0.0-1.0)' },
219
- learningRate: { type: 'number', description: 'Learning rate (default: 0.01)' },
220
- success: { type: 'boolean', description: 'Whether the adaptation was successful (default: true)' },
221
- },
222
- required: ['loraId', 'quality'],
223
- },
224
- handler: async (args) => {
225
- try {
226
- const lora = loraInstances.get(args.loraId);
227
- if (!lora)
228
- return { content: [{ type: 'text', text: JSON.stringify({ error: `MicroLoRA not found: ${args.loraId}` }) }], isError: true };
229
- lora.adapt(args.quality, args.learningRate, args.success);
230
- return { content: [{ type: 'text', text: JSON.stringify({ success: true, stats: lora.stats() }) }] };
231
- }
232
- catch (err) {
233
- return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
234
- }
235
- },
236
- },
237
- {
238
- name: 'ruvllm_chat_format',
239
- description: 'Format chat messages using a template (llama3, mistral, chatml, phi, gemma, or auto-detect).',
240
- inputSchema: {
241
- type: 'object',
242
- properties: {
243
- messages: {
244
- type: 'array',
245
- items: { type: 'object', properties: { role: { type: 'string' }, content: { type: 'string' } }, required: ['role', 'content'] },
246
- description: 'Array of {role, content} message objects',
247
- },
248
- template: { type: 'string', description: 'Template preset (llama3, mistral, chatml, phi, gemma) or model ID for auto-detection' },
249
- },
250
- required: ['messages', 'template'],
251
- },
252
- handler: async (args) => {
253
- try {
254
- const mod = await loadRuvllmWasm();
255
- const messages = args.messages;
256
- const templateStr = args.template;
257
- const presets = ['llama3', 'mistral', 'chatml', 'phi', 'gemma'];
258
- const template = presets.includes(templateStr)
259
- ? templateStr
260
- : { modelId: templateStr };
261
- const formatted = await mod.formatChat(messages, template);
262
- return { content: [{ type: 'text', text: formatted }] };
263
- }
264
- catch (err) {
265
- return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
266
- }
267
- },
268
- },
269
- {
270
- name: 'ruvllm_generate_config',
271
- description: 'Create a generation config (maxTokens, temperature, topP, etc.) as JSON.',
272
- inputSchema: {
273
- type: 'object',
274
- properties: {
275
- maxTokens: { type: 'number', description: 'Max tokens to generate' },
276
- temperature: { type: 'number', description: 'Sampling temperature (note: f32 precision)' },
277
- topP: { type: 'number', description: 'Top-p sampling' },
278
- topK: { type: 'number', description: 'Top-k sampling' },
279
- repetitionPenalty: { type: 'number', description: 'Repetition penalty' },
280
- stopSequences: { type: 'array', items: { type: 'string' }, description: 'Stop sequences' },
281
- },
282
- },
283
- handler: async (args) => {
284
- try {
285
- const mod = await loadRuvllmWasm();
286
- const config = await mod.createGenerateConfig(args);
287
- return { content: [{ type: 'text', text: config }] };
288
- }
289
- catch (err) {
290
- return { content: [{ type: 'text', text: JSON.stringify({ error: String(err) }) }], isError: true };
291
- }
292
- },
293
- },
294
- ];
295
- //# sourceMappingURL=ruvllm-tools.js.map