agentic-flow 2.0.7 → 2.0.8
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/settings.json +133 -9
- package/.claude/skills/agentic-flow-quickstart/skill.md +69 -0
- package/.claude/skills/hooks-automation/skill.md +155 -0
- package/.claude/skills/memory-patterns/skill.md +110 -0
- package/.claude/skills/sparc-methodology/skill.md +137 -0
- package/.claude/skills/swarm-coordination/skill.md +94 -0
- package/.claude/skills/worker-benchmarks/skill.md +135 -0
- package/.claude/skills/worker-integration/skill.md +154 -0
- package/.claude/statusline.mjs +109 -0
- package/.claude/statusline.sh +71 -0
- package/README.md +1797 -624
- package/dist/.tsbuildinfo +1 -1
- package/dist/agentdb/index.d.ts +2 -0
- package/dist/agentdb/index.d.ts.map +1 -1
- package/dist/agentdb/index.js +5 -0
- package/dist/agentdb/index.js.map +1 -1
- package/dist/agentdb/prerequisites.d.ts +25 -0
- package/dist/agentdb/prerequisites.d.ts.map +1 -0
- package/dist/agentdb/prerequisites.js +180 -0
- package/dist/agentdb/prerequisites.js.map +1 -0
- package/dist/benchmarks/embeddings-benchmark.d.ts +38 -0
- package/dist/benchmarks/embeddings-benchmark.d.ts.map +1 -0
- package/dist/benchmarks/embeddings-benchmark.js +282 -0
- package/dist/benchmarks/embeddings-benchmark.js.map +1 -0
- package/dist/billing/mcp/tools.js +1 -0
- package/dist/billing/mcp/tools.js.map +1 -1
- package/dist/cli/commands/embeddings.d.ts +12 -0
- package/dist/cli/commands/embeddings.d.ts.map +1 -0
- package/dist/cli/commands/embeddings.js +386 -0
- package/dist/cli/commands/embeddings.js.map +1 -0
- package/dist/cli/commands/hooks.d.ts.map +1 -1
- package/dist/cli/commands/hooks.js +79 -4
- package/dist/cli/commands/hooks.js.map +1 -1
- package/dist/cli/commands/init.d.ts +8 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +514 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/workers.d.ts +9 -0
- package/dist/cli/commands/workers.d.ts.map +1 -0
- package/dist/cli/commands/workers.js +991 -0
- package/dist/cli/commands/workers.js.map +1 -0
- package/dist/cli/config-wizard.d.ts.map +1 -1
- package/dist/cli/config-wizard.js +47 -25
- package/dist/cli/config-wizard.js.map +1 -1
- package/dist/cli-proxy.js +89 -1
- package/dist/cli-proxy.js.map +1 -1
- package/dist/core/agentdb-fast.js +3 -3
- package/dist/core/agentdb-fast.js.map +1 -1
- package/dist/core/agentdb-wrapper-enhanced.d.ts.map +1 -1
- package/dist/core/agentdb-wrapper-enhanced.js +37 -11
- package/dist/core/agentdb-wrapper-enhanced.js.map +1 -1
- package/dist/core/agentdb-wrapper.d.ts +3 -2
- package/dist/core/agentdb-wrapper.d.ts.map +1 -1
- package/dist/core/agentdb-wrapper.js +15 -1
- package/dist/core/agentdb-wrapper.js.map +1 -1
- package/dist/core/attention-native.d.ts +4 -0
- package/dist/core/attention-native.d.ts.map +1 -1
- package/dist/core/attention-native.js +14 -2
- package/dist/core/attention-native.js.map +1 -1
- package/dist/core/gnn-wrapper.d.ts.map +1 -1
- package/dist/core/gnn-wrapper.js +14 -0
- package/dist/core/gnn-wrapper.js.map +1 -1
- package/dist/embeddings/index.d.ts +17 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/index.js +17 -0
- package/dist/embeddings/index.js.map +1 -0
- package/dist/embeddings/neural-substrate.d.ts +206 -0
- package/dist/embeddings/neural-substrate.d.ts.map +1 -0
- package/dist/embeddings/neural-substrate.js +629 -0
- package/dist/embeddings/neural-substrate.js.map +1 -0
- package/dist/embeddings/optimized-embedder.d.ts +103 -0
- package/dist/embeddings/optimized-embedder.d.ts.map +1 -0
- package/dist/embeddings/optimized-embedder.js +730 -0
- package/dist/embeddings/optimized-embedder.js.map +1 -0
- package/dist/examples/embedding-geometry.d.ts +105 -0
- package/dist/examples/embedding-geometry.d.ts.map +1 -0
- package/dist/examples/embedding-geometry.js +528 -0
- package/dist/examples/embedding-geometry.js.map +1 -0
- package/dist/federation/SecurityManager.d.ts +11 -2
- package/dist/federation/SecurityManager.d.ts.map +1 -1
- package/dist/federation/SecurityManager.js +50 -17
- package/dist/federation/SecurityManager.js.map +1 -1
- package/dist/federation/integrations/supabase-adapter-debug.js +3 -3
- package/dist/federation/integrations/supabase-adapter-debug.js.map +1 -1
- package/dist/hooks/swarm-learning-optimizer.js +5 -5
- package/dist/hooks/swarm-learning-optimizer.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +89 -51
- package/dist/index.js.map +1 -1
- package/dist/intelligence/IntelligenceStore.d.ts +35 -26
- package/dist/intelligence/IntelligenceStore.d.ts.map +1 -1
- package/dist/intelligence/IntelligenceStore.js +308 -123
- package/dist/intelligence/IntelligenceStore.js.map +1 -1
- package/dist/intelligence/RuVectorIntelligence.d.ts +26 -1
- package/dist/intelligence/RuVectorIntelligence.d.ts.map +1 -1
- package/dist/intelligence/RuVectorIntelligence.js +49 -10
- package/dist/intelligence/RuVectorIntelligence.js.map +1 -1
- package/dist/intelligence/agent-booster-enhanced.d.ts +1 -0
- package/dist/intelligence/agent-booster-enhanced.d.ts.map +1 -1
- package/dist/intelligence/agent-booster-enhanced.js +24 -3
- package/dist/intelligence/agent-booster-enhanced.js.map +1 -1
- package/dist/intelligence/index.d.ts +29 -3
- package/dist/intelligence/index.d.ts.map +1 -1
- package/dist/intelligence/index.js +13 -3
- package/dist/intelligence/index.js.map +1 -1
- package/dist/mcp/claudeFlowSdkServer.d.ts.map +1 -1
- package/dist/mcp/claudeFlowSdkServer.js +162 -115
- package/dist/mcp/claudeFlowSdkServer.js.map +1 -1
- package/dist/mcp/fastmcp/tools/hooks/intelligence-bridge.js +5 -5
- package/dist/mcp/fastmcp/tools/hooks/intelligence-bridge.js.map +1 -1
- package/dist/mcp/fastmcp/tools/swarm/init.d.ts.map +1 -1
- package/dist/mcp/fastmcp/tools/swarm/init.js +36 -7
- package/dist/mcp/fastmcp/tools/swarm/init.js.map +1 -1
- package/dist/mcp/fastmcp/tools/swarm/spawn.d.ts.map +1 -1
- package/dist/mcp/fastmcp/tools/swarm/spawn.js +47 -8
- package/dist/mcp/fastmcp/tools/swarm/spawn.js.map +1 -1
- package/dist/mcp/tools/agent-booster-tools.d.ts +15 -1
- package/dist/mcp/tools/agent-booster-tools.d.ts.map +1 -1
- package/dist/mcp/tools/agent-booster-tools.js +79 -63
- package/dist/mcp/tools/agent-booster-tools.js.map +1 -1
- package/dist/mcp/tools/sona-tools.d.ts.map +1 -1
- package/dist/mcp/tools/sona-tools.js +6 -0
- package/dist/mcp/tools/sona-tools.js.map +1 -1
- package/dist/memory/SharedMemoryPool.d.ts +103 -0
- package/dist/memory/SharedMemoryPool.d.ts.map +1 -0
- package/dist/memory/SharedMemoryPool.js +263 -0
- package/dist/memory/SharedMemoryPool.js.map +1 -0
- package/dist/optimizations/agent-booster-migration.d.ts +2 -1
- package/dist/optimizations/agent-booster-migration.d.ts.map +1 -1
- package/dist/optimizations/agent-booster-migration.js +69 -45
- package/dist/optimizations/agent-booster-migration.js.map +1 -1
- package/dist/orchestration/index.d.ts +11 -0
- package/dist/orchestration/index.d.ts.map +1 -0
- package/dist/orchestration/index.js +10 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/memory-plane-types.d.ts +23 -0
- package/dist/orchestration/memory-plane-types.d.ts.map +1 -0
- package/dist/orchestration/memory-plane-types.js +5 -0
- package/dist/orchestration/memory-plane-types.js.map +1 -0
- package/dist/orchestration/memory-plane.d.ts +41 -0
- package/dist/orchestration/memory-plane.d.ts.map +1 -0
- package/dist/orchestration/memory-plane.js +84 -0
- package/dist/orchestration/memory-plane.js.map +1 -0
- package/dist/orchestration/orchestration-client.d.ts +104 -0
- package/dist/orchestration/orchestration-client.d.ts.map +1 -0
- package/dist/orchestration/orchestration-client.js +94 -0
- package/dist/orchestration/orchestration-client.js.map +1 -0
- package/dist/orchestration/orchestration-runtime.d.ts +26 -0
- package/dist/orchestration/orchestration-runtime.d.ts.map +1 -0
- package/dist/orchestration/orchestration-runtime.js +78 -0
- package/dist/orchestration/orchestration-runtime.js.map +1 -0
- package/dist/orchestration/orchestration-types.d.ts +124 -0
- package/dist/orchestration/orchestration-types.d.ts.map +1 -0
- package/dist/orchestration/orchestration-types.js +7 -0
- package/dist/orchestration/orchestration-types.js.map +1 -0
- package/dist/proxy/anthropic-to-openrouter.js.map +1 -1
- package/dist/proxy/anthropic-to-requesty.js.map +1 -1
- package/dist/proxy/quic-proxy.d.ts +0 -1
- package/dist/proxy/quic-proxy.d.ts.map +1 -1
- package/dist/proxy/quic-proxy.js +2 -2
- package/dist/proxy/quic-proxy.js.map +1 -1
- package/dist/reasoningbank/AdvancedMemory.js +1 -1
- package/dist/reasoningbank/AdvancedMemory.js.map +1 -1
- package/dist/reasoningbank/HybridBackend.d.ts.map +1 -1
- package/dist/reasoningbank/HybridBackend.js +2 -5
- package/dist/reasoningbank/HybridBackend.js.map +1 -1
- package/dist/reasoningbank/backend-selector.d.ts +10 -0
- package/dist/reasoningbank/backend-selector.d.ts.map +1 -1
- package/dist/reasoningbank/backend-selector.js +45 -5
- package/dist/reasoningbank/backend-selector.js.map +1 -1
- package/dist/reasoningbank/core/consolidate.d.ts.map +1 -1
- package/dist/reasoningbank/core/consolidate.js +113 -45
- package/dist/reasoningbank/core/consolidate.js.map +1 -1
- package/dist/reasoningbank/index-new.d.ts +1 -6
- package/dist/reasoningbank/index-new.d.ts.map +1 -1
- package/dist/reasoningbank/index-new.js +1 -6
- package/dist/reasoningbank/index-new.js.map +1 -1
- package/dist/reasoningbank/index.d.ts +6 -0
- package/dist/reasoningbank/index.d.ts.map +1 -1
- package/dist/reasoningbank/index.js +6 -13
- package/dist/reasoningbank/index.js.map +1 -1
- package/dist/reasoningbank/utils/embeddings.d.ts +1 -0
- package/dist/reasoningbank/utils/embeddings.d.ts.map +1 -1
- package/dist/reasoningbank/utils/embeddings.js +53 -26
- package/dist/reasoningbank/utils/embeddings.js.map +1 -1
- package/dist/router/index.d.ts +2 -1
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +1 -0
- package/dist/router/index.js.map +1 -1
- package/dist/router/providers/ollama.d.ts +20 -0
- package/dist/router/providers/ollama.d.ts.map +1 -0
- package/dist/router/providers/ollama.js +242 -0
- package/dist/router/providers/ollama.js.map +1 -0
- package/dist/router/providers/onnx-local-optimized.d.ts +2 -0
- package/dist/router/providers/onnx-local-optimized.d.ts.map +1 -1
- package/dist/router/providers/onnx-local-optimized.js +10 -0
- package/dist/router/providers/onnx-local-optimized.js.map +1 -1
- package/dist/router/providers/onnx-local.d.ts +1 -0
- package/dist/router/providers/onnx-local.d.ts.map +1 -1
- package/dist/router/providers/onnx-local.js +22 -5
- package/dist/router/providers/onnx-local.js.map +1 -1
- package/dist/router/router.d.ts.map +1 -1
- package/dist/router/router.js +39 -23
- package/dist/router/router.js.map +1 -1
- package/dist/sdk/index.d.ts +2 -1
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +3 -1
- package/dist/sdk/index.js.map +1 -1
- package/dist/services/embedding-service.js.map +1 -1
- package/dist/services/sona-agent-training.d.ts +1 -0
- package/dist/services/sona-agent-training.d.ts.map +1 -1
- package/dist/services/sona-agent-training.js.map +1 -1
- package/dist/services/sona-agentdb-integration.d.ts.map +1 -1
- package/dist/services/sona-agentdb-integration.js +9 -6
- package/dist/services/sona-agentdb-integration.js.map +1 -1
- package/dist/services/sona-service.d.ts.map +1 -1
- package/dist/services/sona-service.js +6 -5
- package/dist/services/sona-service.js.map +1 -1
- package/dist/utils/cli.d.ts +1 -1
- package/dist/utils/cli.d.ts.map +1 -1
- package/dist/utils/cli.js +21 -0
- package/dist/utils/cli.js.map +1 -1
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/model-cache.d.ts +61 -0
- package/dist/utils/model-cache.d.ts.map +1 -0
- package/dist/utils/model-cache.js +176 -0
- package/dist/utils/model-cache.js.map +1 -0
- package/dist/utils/suppress-warnings.d.ts +19 -0
- package/dist/utils/suppress-warnings.d.ts.map +1 -0
- package/dist/utils/suppress-warnings.js +59 -0
- package/dist/utils/suppress-warnings.js.map +1 -0
- package/dist/workers/consolidated-phases.d.ts +40 -0
- package/dist/workers/consolidated-phases.d.ts.map +1 -0
- package/dist/workers/consolidated-phases.js +497 -0
- package/dist/workers/consolidated-phases.js.map +1 -0
- package/dist/workers/custom-worker-config.d.ts +133 -0
- package/dist/workers/custom-worker-config.d.ts.map +1 -0
- package/dist/workers/custom-worker-config.js +215 -0
- package/dist/workers/custom-worker-config.js.map +1 -0
- package/dist/workers/custom-worker-factory.d.ts +89 -0
- package/dist/workers/custom-worker-factory.d.ts.map +1 -0
- package/dist/workers/custom-worker-factory.js +404 -0
- package/dist/workers/custom-worker-factory.js.map +1 -0
- package/dist/workers/dispatch-service.d.ts +123 -0
- package/dist/workers/dispatch-service.d.ts.map +1 -0
- package/dist/workers/dispatch-service.js +1024 -0
- package/dist/workers/dispatch-service.js.map +1 -0
- package/dist/workers/hooks-integration.d.ts +79 -0
- package/dist/workers/hooks-integration.d.ts.map +1 -0
- package/dist/workers/hooks-integration.js +286 -0
- package/dist/workers/hooks-integration.js.map +1 -0
- package/dist/workers/index.d.ts +42 -0
- package/dist/workers/index.d.ts.map +1 -0
- package/dist/workers/index.js +52 -0
- package/dist/workers/index.js.map +1 -0
- package/dist/workers/mcp-tools.d.ts +56 -0
- package/dist/workers/mcp-tools.d.ts.map +1 -0
- package/dist/workers/mcp-tools.js +359 -0
- package/dist/workers/mcp-tools.js.map +1 -0
- package/dist/workers/phase-executors.d.ts +22 -0
- package/dist/workers/phase-executors.d.ts.map +1 -0
- package/dist/workers/phase-executors.js +445 -0
- package/dist/workers/phase-executors.js.map +1 -0
- package/dist/workers/resource-governor.d.ts +75 -0
- package/dist/workers/resource-governor.d.ts.map +1 -0
- package/dist/workers/resource-governor.js +187 -0
- package/dist/workers/resource-governor.js.map +1 -0
- package/dist/workers/ruvector-integration.d.ts +163 -0
- package/dist/workers/ruvector-integration.d.ts.map +1 -0
- package/dist/workers/ruvector-integration.js +543 -0
- package/dist/workers/ruvector-integration.js.map +1 -0
- package/dist/workers/ruvector-native-integration.d.ts +91 -0
- package/dist/workers/ruvector-native-integration.d.ts.map +1 -0
- package/dist/workers/ruvector-native-integration.js +254 -0
- package/dist/workers/ruvector-native-integration.js.map +1 -0
- package/dist/workers/trigger-detector.d.ts +68 -0
- package/dist/workers/trigger-detector.d.ts.map +1 -0
- package/dist/workers/trigger-detector.js +281 -0
- package/dist/workers/trigger-detector.js.map +1 -0
- package/dist/workers/types.d.ts +145 -0
- package/dist/workers/types.d.ts.map +1 -0
- package/dist/workers/types.js +6 -0
- package/dist/workers/types.js.map +1 -0
- package/dist/workers/worker-agent-integration.d.ts +140 -0
- package/dist/workers/worker-agent-integration.d.ts.map +1 -0
- package/dist/workers/worker-agent-integration.js +471 -0
- package/dist/workers/worker-agent-integration.js.map +1 -0
- package/dist/workers/worker-benchmarks.d.ts +88 -0
- package/dist/workers/worker-benchmarks.d.ts.map +1 -0
- package/dist/workers/worker-benchmarks.js +452 -0
- package/dist/workers/worker-benchmarks.js.map +1 -0
- package/dist/workers/worker-registry.d.ts +85 -0
- package/dist/workers/worker-registry.d.ts.map +1 -0
- package/dist/workers/worker-registry.js +547 -0
- package/dist/workers/worker-registry.js.map +1 -0
- package/docs/embeddings/EMBEDDING_GEOMETRY.md +935 -0
- package/package.json +27 -9
- package/scripts/postinstall.js +45 -4
- package/wasm/reasoningbank/reasoningbank_wasm.js +1 -1
- package/wasm/reasoningbank/reasoningbank_wasm_bg.js +54 -54
- package/wasm/reasoningbank/reasoningbank_wasm_bg.wasm +0 -0
- package/wasm/reasoningbank/reasoningbank_wasm_bg.wasm.d.ts +4 -3
- package/.claude/agents/test-neural.md +0 -14
- /package/.claude/agents/analysis/{code-review/analyze-code-quality.md → analyze-code-quality.md} +0 -0
- /package/.claude/agents/architecture/{system-design/arch-system-design.md → arch-system-design.md} +0 -0
- /package/.claude/agents/data/{ml/data-ml-model.md → data-ml-model.md} +0 -0
- /package/.claude/agents/development/{backend/dev-backend-api.md → dev-backend-api.md} +0 -0
- /package/.claude/agents/devops/{ci-cd/ops-cicd-github.md → ops-cicd-github.md} +0 -0
- /package/.claude/agents/documentation/{api-docs/docs-api-openapi.md → docs-api-openapi.md} +0 -0
- /package/.claude/agents/specialized/{mobile/spec-mobile-react-native.md → spec-mobile-react-native.md} +0 -0
- /package/.claude/agents/testing/{validation/production-validator.md → production-validator.md} +0 -0
- /package/.claude/agents/testing/{unit/tdd-london-swarm.md → tdd-london-swarm.md} +0 -0
|
@@ -4,7 +4,20 @@
|
|
|
4
4
|
* Ultra-fast code editing (352x faster than cloud APIs, $0 cost)
|
|
5
5
|
* Uses Agent Booster's local WASM engine for sub-millisecond transformations
|
|
6
6
|
*/
|
|
7
|
-
import { MCPTool } from '
|
|
7
|
+
import type { MCPTool } from './sona-tools.js';
|
|
8
|
+
type MorphApplyResponse = {
|
|
9
|
+
output: string;
|
|
10
|
+
success: boolean;
|
|
11
|
+
latency: number;
|
|
12
|
+
tokens?: {
|
|
13
|
+
input: number;
|
|
14
|
+
output: number;
|
|
15
|
+
};
|
|
16
|
+
confidence: number;
|
|
17
|
+
strategy: string;
|
|
18
|
+
error?: string;
|
|
19
|
+
metadata?: any;
|
|
20
|
+
};
|
|
8
21
|
/**
|
|
9
22
|
* Agent Booster MCP Tools
|
|
10
23
|
*/
|
|
@@ -64,4 +77,5 @@ export declare function getAgentBoosterStats(): {
|
|
|
64
77
|
languages: string[];
|
|
65
78
|
};
|
|
66
79
|
};
|
|
80
|
+
export {};
|
|
67
81
|
//# sourceMappingURL=agent-booster-tools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-booster-tools.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/agent-booster-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"agent-booster-tools.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/agent-booster-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C,KAAK,kBAAkB,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,CAAC;AA0BF;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,OAAO,EAkFzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB;IAClC;;OAEG;sCACqC;QACtC,eAAe,EAAE,MAAM,CAAC;QACxB,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,KAAG,OAAO,CAAC,kBAAkB,CAAC;IAgD/B;;OAEG;uCACsC;QACvC,KAAK,EAAE,KAAK,CAAC;YACX,eAAe,EAAE,MAAM,CAAC;YACxB,YAAY,EAAE,MAAM,CAAC;YACrB,SAAS,EAAE,MAAM,CAAC;YAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;SACnB,CAAC,CAAC;KACJ,KAAG,OAAO,CAAC;QAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;QAAC,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC;IAwE5D;;OAEG;2CAC0C;QAC3C,QAAQ,EAAE,MAAM,CAAC;KAClB,KAAG,OAAO,CAAC;QAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;QAAC,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC;CAoC7D,CAAC;AAEF;;GAEG;AACH,wBAAgB,oBAAoB;;;;;;;;;;;;;;EA6BnC"}
|
|
@@ -4,23 +4,25 @@
|
|
|
4
4
|
* Ultra-fast code editing (352x faster than cloud APIs, $0 cost)
|
|
5
5
|
* Uses Agent Booster's local WASM engine for sub-millisecond transformations
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import * as fs from 'node:fs/promises';
|
|
8
|
+
import * as path from 'node:path';
|
|
9
|
+
let _booster = null;
|
|
9
10
|
async function getBooster() {
|
|
10
|
-
if (
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return booster;
|
|
20
|
-
}
|
|
21
|
-
catch {
|
|
22
|
-
return null;
|
|
11
|
+
if (_booster)
|
|
12
|
+
return _booster;
|
|
13
|
+
const mod = await import('agent-booster').catch((err) => {
|
|
14
|
+
throw new Error(`Agent Booster optional package not installed: ${err?.message || err}. ` +
|
|
15
|
+
`Run: npm install agent-booster`);
|
|
16
|
+
});
|
|
17
|
+
const Ctor = mod.AgentBooster ?? mod.default?.AgentBooster ?? mod.default;
|
|
18
|
+
if (!Ctor) {
|
|
19
|
+
throw new Error("'agent-booster' loaded but does not export AgentBooster");
|
|
23
20
|
}
|
|
21
|
+
_booster = new Ctor({
|
|
22
|
+
confidenceThreshold: 0.5,
|
|
23
|
+
maxChunks: 100,
|
|
24
|
+
});
|
|
25
|
+
return _booster;
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* Agent Booster MCP Tools
|
|
@@ -34,23 +36,23 @@ export const agentBoosterMCPTools = [
|
|
|
34
36
|
properties: {
|
|
35
37
|
target_filepath: {
|
|
36
38
|
type: 'string',
|
|
37
|
-
description: 'Path of the file to modify'
|
|
39
|
+
description: 'Path of the file to modify',
|
|
38
40
|
},
|
|
39
41
|
instructions: {
|
|
40
42
|
type: 'string',
|
|
41
|
-
description: 'First-person instruction (e.g., "I will add error handling")'
|
|
43
|
+
description: 'First-person instruction (e.g., "I will add error handling")',
|
|
42
44
|
},
|
|
43
45
|
code_edit: {
|
|
44
46
|
type: 'string',
|
|
45
|
-
description: 'Precise code lines to edit, using "// ... existing code ..." for unchanged sections'
|
|
47
|
+
description: 'Precise code lines to edit, using "// ... existing code ..." for unchanged sections',
|
|
46
48
|
},
|
|
47
49
|
language: {
|
|
48
50
|
type: 'string',
|
|
49
|
-
description: 'Programming language (auto-detected from file extension if not provided)'
|
|
50
|
-
}
|
|
51
|
+
description: 'Programming language (auto-detected from file extension if not provided)',
|
|
52
|
+
},
|
|
51
53
|
},
|
|
52
|
-
required: ['target_filepath', 'instructions', 'code_edit']
|
|
53
|
-
}
|
|
54
|
+
required: ['target_filepath', 'instructions', 'code_edit'],
|
|
55
|
+
},
|
|
54
56
|
},
|
|
55
57
|
{
|
|
56
58
|
name: 'agent_booster_batch_edit',
|
|
@@ -66,27 +68,27 @@ export const agentBoosterMCPTools = [
|
|
|
66
68
|
properties: {
|
|
67
69
|
target_filepath: {
|
|
68
70
|
type: 'string',
|
|
69
|
-
description: 'File path'
|
|
71
|
+
description: 'File path',
|
|
70
72
|
},
|
|
71
73
|
instructions: {
|
|
72
74
|
type: 'string',
|
|
73
|
-
description: 'First-person instruction'
|
|
75
|
+
description: 'First-person instruction',
|
|
74
76
|
},
|
|
75
77
|
code_edit: {
|
|
76
78
|
type: 'string',
|
|
77
|
-
description: 'Code edit with markers'
|
|
79
|
+
description: 'Code edit with markers',
|
|
78
80
|
},
|
|
79
81
|
language: {
|
|
80
82
|
type: 'string',
|
|
81
|
-
description: 'Programming language'
|
|
82
|
-
}
|
|
83
|
+
description: 'Programming language',
|
|
84
|
+
},
|
|
83
85
|
},
|
|
84
|
-
required: ['target_filepath', 'instructions', 'code_edit']
|
|
85
|
-
}
|
|
86
|
-
}
|
|
86
|
+
required: ['target_filepath', 'instructions', 'code_edit'],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
87
89
|
},
|
|
88
|
-
required: ['edits']
|
|
89
|
-
}
|
|
90
|
+
required: ['edits'],
|
|
91
|
+
},
|
|
90
92
|
},
|
|
91
93
|
{
|
|
92
94
|
name: 'agent_booster_parse_markdown',
|
|
@@ -96,12 +98,12 @@ export const agentBoosterMCPTools = [
|
|
|
96
98
|
properties: {
|
|
97
99
|
markdown: {
|
|
98
100
|
type: 'string',
|
|
99
|
-
description: 'Markdown text containing code blocks with filepath= and instruction= metadata'
|
|
100
|
-
}
|
|
101
|
+
description: 'Markdown text containing code blocks with filepath= and instruction= metadata',
|
|
102
|
+
},
|
|
101
103
|
},
|
|
102
|
-
required: ['markdown']
|
|
103
|
-
}
|
|
104
|
-
}
|
|
104
|
+
required: ['markdown'],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
105
107
|
];
|
|
106
108
|
/**
|
|
107
109
|
* Agent Booster MCP Tool Handlers
|
|
@@ -111,18 +113,20 @@ export const agentBoosterMCPHandlers = {
|
|
|
111
113
|
* Edit a single file with Agent Booster
|
|
112
114
|
*/
|
|
113
115
|
agent_booster_edit_file: async (params) => {
|
|
114
|
-
const fs = require('fs/promises');
|
|
115
|
-
const path = require('path');
|
|
116
116
|
try {
|
|
117
117
|
// Read current file content
|
|
118
118
|
const originalCode = await fs.readFile(params.target_filepath, 'utf8');
|
|
119
119
|
// Auto-detect language from file extension if not provided
|
|
120
120
|
const language = params.language || path.extname(params.target_filepath).slice(1);
|
|
121
|
-
// Apply edit using Agent Booster
|
|
121
|
+
// Apply edit using Agent Booster - use any for flexible signature
|
|
122
|
+
const booster = await getBooster();
|
|
122
123
|
const result = await booster.apply({
|
|
123
124
|
code: originalCode,
|
|
124
125
|
edit: params.code_edit,
|
|
125
|
-
language
|
|
126
|
+
language,
|
|
127
|
+
target_filepath: params.target_filepath,
|
|
128
|
+
instructions: params.code_edit,
|
|
129
|
+
code_edit: params.code_edit,
|
|
126
130
|
});
|
|
127
131
|
// Write modified code if successful
|
|
128
132
|
if (result.success) {
|
|
@@ -136,8 +140,8 @@ export const agentBoosterMCPHandlers = {
|
|
|
136
140
|
instructions: params.instructions,
|
|
137
141
|
language,
|
|
138
142
|
originalSize: originalCode.length,
|
|
139
|
-
modifiedSize: result.output.length
|
|
140
|
-
}
|
|
143
|
+
modifiedSize: result.output.length,
|
|
144
|
+
},
|
|
141
145
|
};
|
|
142
146
|
}
|
|
143
147
|
catch (error) {
|
|
@@ -148,7 +152,7 @@ export const agentBoosterMCPHandlers = {
|
|
|
148
152
|
tokens: { input: 0, output: 0 },
|
|
149
153
|
confidence: 0,
|
|
150
154
|
strategy: 'failed',
|
|
151
|
-
error: error.message
|
|
155
|
+
error: error.message,
|
|
152
156
|
};
|
|
153
157
|
}
|
|
154
158
|
},
|
|
@@ -157,8 +161,6 @@ export const agentBoosterMCPHandlers = {
|
|
|
157
161
|
*/
|
|
158
162
|
agent_booster_batch_edit: async (params) => {
|
|
159
163
|
const results = [];
|
|
160
|
-
const fs = require('fs/promises');
|
|
161
|
-
const path = require('path');
|
|
162
164
|
let totalLatency = 0;
|
|
163
165
|
let successCount = 0;
|
|
164
166
|
let totalBytes = 0;
|
|
@@ -168,11 +170,15 @@ export const agentBoosterMCPHandlers = {
|
|
|
168
170
|
const originalCode = await fs.readFile(edit.target_filepath, 'utf8');
|
|
169
171
|
// Auto-detect language
|
|
170
172
|
const language = edit.language || path.extname(edit.target_filepath).slice(1);
|
|
171
|
-
// Apply edit using Agent Booster
|
|
173
|
+
// Apply edit using Agent Booster - use any for flexible signature
|
|
174
|
+
const booster = await getBooster();
|
|
172
175
|
const result = await booster.apply({
|
|
173
176
|
code: originalCode,
|
|
174
177
|
edit: edit.code_edit,
|
|
175
|
-
language
|
|
178
|
+
language,
|
|
179
|
+
target_filepath: edit.target_filepath,
|
|
180
|
+
instructions: edit.code_edit,
|
|
181
|
+
code_edit: edit.code_edit,
|
|
176
182
|
});
|
|
177
183
|
// Write modified code if successful
|
|
178
184
|
if (result.success) {
|
|
@@ -185,8 +191,8 @@ export const agentBoosterMCPHandlers = {
|
|
|
185
191
|
...result,
|
|
186
192
|
metadata: {
|
|
187
193
|
filepath: edit.target_filepath,
|
|
188
|
-
instructions: edit.instructions
|
|
189
|
-
}
|
|
194
|
+
instructions: edit.instructions,
|
|
195
|
+
},
|
|
190
196
|
});
|
|
191
197
|
}
|
|
192
198
|
catch (error) {
|
|
@@ -199,8 +205,8 @@ export const agentBoosterMCPHandlers = {
|
|
|
199
205
|
strategy: 'failed',
|
|
200
206
|
error: error.message,
|
|
201
207
|
metadata: {
|
|
202
|
-
filepath: edit.target_filepath
|
|
203
|
-
}
|
|
208
|
+
filepath: edit.target_filepath,
|
|
209
|
+
},
|
|
204
210
|
});
|
|
205
211
|
}
|
|
206
212
|
}
|
|
@@ -213,8 +219,8 @@ export const agentBoosterMCPHandlers = {
|
|
|
213
219
|
totalLatency,
|
|
214
220
|
avgLatency: totalLatency / params.edits.length,
|
|
215
221
|
totalBytes,
|
|
216
|
-
speedupVsCloud: Math.round(352 / (totalLatency / params.edits.length))
|
|
217
|
-
}
|
|
222
|
+
speedupVsCloud: Math.round(352 / (totalLatency / params.edits.length)),
|
|
223
|
+
},
|
|
218
224
|
};
|
|
219
225
|
},
|
|
220
226
|
/**
|
|
@@ -230,7 +236,7 @@ export const agentBoosterMCPHandlers = {
|
|
|
230
236
|
language: match[1],
|
|
231
237
|
target_filepath: match[2],
|
|
232
238
|
instructions: match[3],
|
|
233
|
-
code_edit: match[4].trim()
|
|
239
|
+
code_edit: match[4].trim(),
|
|
234
240
|
});
|
|
235
241
|
}
|
|
236
242
|
if (edits.length === 0) {
|
|
@@ -240,13 +246,13 @@ export const agentBoosterMCPHandlers = {
|
|
|
240
246
|
total: 0,
|
|
241
247
|
successful: 0,
|
|
242
248
|
failed: 0,
|
|
243
|
-
error: 'No code blocks found with required metadata'
|
|
244
|
-
}
|
|
249
|
+
error: 'No code blocks found with required metadata',
|
|
250
|
+
},
|
|
245
251
|
};
|
|
246
252
|
}
|
|
247
253
|
// Apply all edits
|
|
248
254
|
return agentBoosterMCPHandlers.agent_booster_batch_edit({ edits });
|
|
249
|
-
}
|
|
255
|
+
},
|
|
250
256
|
};
|
|
251
257
|
/**
|
|
252
258
|
* Get Agent Booster statistics
|
|
@@ -258,17 +264,27 @@ export function getAgentBoosterStats() {
|
|
|
258
264
|
performance: {
|
|
259
265
|
avgLatency: '1ms',
|
|
260
266
|
speedup: '352x vs cloud APIs',
|
|
261
|
-
costSavings: '$240/month'
|
|
267
|
+
costSavings: '$240/month',
|
|
262
268
|
},
|
|
263
269
|
features: {
|
|
264
270
|
local: true,
|
|
265
271
|
offline: true,
|
|
266
272
|
privacy: 'Complete (no data sent to cloud)',
|
|
267
273
|
languages: [
|
|
268
|
-
'javascript',
|
|
269
|
-
'
|
|
270
|
-
|
|
271
|
-
|
|
274
|
+
'javascript',
|
|
275
|
+
'typescript',
|
|
276
|
+
'python',
|
|
277
|
+
'rust',
|
|
278
|
+
'go',
|
|
279
|
+
'java',
|
|
280
|
+
'c',
|
|
281
|
+
'cpp',
|
|
282
|
+
'ruby',
|
|
283
|
+
'php',
|
|
284
|
+
'swift',
|
|
285
|
+
'kotlin',
|
|
286
|
+
],
|
|
287
|
+
},
|
|
272
288
|
};
|
|
273
289
|
}
|
|
274
290
|
//# sourceMappingURL=agent-booster-tools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-booster-tools.js","sourceRoot":"","sources":["../../../src/mcp/tools/agent-booster-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,IAAI,YAAY,GAAQ,IAAI,CAAC;AAC7B,IAAI,OAAO,GAAQ,IAAI,CAAC;AAExB,KAAK,UAAU,UAAU;IACvB,IAAI,OAAO;QAAE,OAAO,O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rD;aACF,CAAC;QACJ,CAAC;QAED,kBAAkB;QAClB,OAAO,uBAAuB,CAAC,wBAAwB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACrE,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO;QACL,MAAM,EAAE,oBAAoB;QAC5B,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE;YACX,UAAU,EAAE,KAAK;YACjB,OAAO,EAAE,oBAAoB;YAC7B,WAAW,EAAE,YAAY;SAC1B;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,kCAAkC;YAC3C,SAAS,EAAE;gBACT,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI;gBAClD,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ;aACrD;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Agent Booster MCP Tools\n *\n * Ultra-fast code editing (352x faster than cloud APIs, $0 cost)\n * Uses Agent Booster's local WASM engine for sub-millisecond transformations\n */\n\n// Optional: Agent Booster for local code editing (lazy loaded)\nimport { MCPTool } from '../types';\n\nlet AgentBooster: any = null;\nlet booster: any = null;\n\nasync function getBooster(): Promise<any> {\n if (booster) return booster;\n try {\n const mod = await import('agent-booster');\n AgentBooster = mod.AgentBooster;\n booster = new AgentBooster({\n confidenceThreshold: 0.5,\n maxChunks: 100\n });\n return booster;\n } catch {\n return null;\n }\n}\n\n/**\n * Agent Booster MCP Tools\n */\nexport const agentBoosterMCPTools: MCPTool[] = [\n {\n name: 'agent_booster_edit_file',\n description: 'Ultra-fast code editing (352x faster than cloud APIs, $0 cost). Apply precise code edits using Agent Booster\\'s local WASM engine. Use \"// ... existing code ...\" markers for unchanged sections.',\n inputSchema: {\n type: 'object',\n properties: {\n target_filepath: {\n type: 'string',\n description: 'Path of the file to modify'\n },\n instructions: {\n type: 'string',\n description: 'First-person instruction (e.g., \"I will add error handling\")'\n },\n code_edit: {\n type: 'string',\n description: 'Precise code lines to edit, using \"// ... existing code ...\" for unchanged sections'\n },\n language: {\n type: 'string',\n description: 'Programming language (auto-detected from file extension if not provided)'\n }\n },\n required: ['target_filepath', 'instructions', 'code_edit']\n }\n },\n {\n name: 'agent_booster_batch_edit',\n description: 'Apply multiple code edits in a single operation (ultra-fast batch processing). Perfect for multi-file refactoring.',\n inputSchema: {\n type: 'object',\n properties: {\n edits: {\n type: 'array',\n description: 'Array of edit requests',\n items: {\n type: 'object',\n properties: {\n target_filepath: {\n type: 'string',\n description: 'File path'\n },\n instructions: {\n type: 'string',\n description: 'First-person instruction'\n },\n code_edit: {\n type: 'string',\n description: 'Code edit with markers'\n },\n language: {\n type: 'string',\n description: 'Programming language'\n }\n },\n required: ['target_filepath', 'instructions', 'code_edit']\n }\n }\n },\n required: ['edits']\n }\n },\n {\n name: 'agent_booster_parse_markdown',\n description: 'Parse markdown code blocks with filepath= and instruction= metadata, then apply all edits. Compatible with LLM-generated multi-file refactoring outputs.',\n inputSchema: {\n type: 'object',\n properties: {\n markdown: {\n type: 'string',\n description: 'Markdown text containing code blocks with filepath= and instruction= metadata'\n }\n },\n required: ['markdown']\n }\n }\n];\n\n/**\n * Agent Booster MCP Tool Handlers\n */\nexport const agentBoosterMCPHandlers = {\n /**\n * Edit a single file with Agent Booster\n */\n agent_booster_edit_file: async (params: {\n target_filepath: string;\n instructions: string;\n code_edit: string;\n language?: string;\n }): Promise<MorphApplyResponse> => {\n const fs = require('fs/promises');\n const path = require('path');\n\n try {\n // Read current file content\n const originalCode = await fs.readFile(params.target_filepath, 'utf8');\n\n // Auto-detect language from file extension if not provided\n const language = params.language || path.extname(params.target_filepath).slice(1);\n\n // Apply edit using Agent Booster\n const result = await booster.apply({\n code: originalCode,\n edit: params.code_edit,\n language\n });\n\n // Write modified code if successful\n if (result.success) {\n await fs.writeFile(params.target_filepath, result.output, 'utf8');\n }\n\n return {\n ...result,\n // Add metadata\n metadata: {\n filepath: params.target_filepath,\n instructions: params.instructions,\n language,\n originalSize: originalCode.length,\n modifiedSize: result.output.length\n }\n } as any;\n } catch (error: any) {\n return {\n output: '',\n success: false,\n latency: 0,\n tokens: { input: 0, output: 0 },\n confidence: 0,\n strategy: 'failed',\n error: error.message\n } as any;\n }\n },\n\n /**\n * Apply multiple edits in batch\n */\n agent_booster_batch_edit: async (params: {\n edits: Array<{\n target_filepath: string;\n instructions: string;\n code_edit: string;\n language?: string;\n }>;\n }): Promise<{ results: MorphApplyResponse[]; summary: any }> => {\n const results: MorphApplyResponse[] = [];\n const fs = require('fs/promises');\n const path = require('path');\n\n let totalLatency = 0;\n let successCount = 0;\n let totalBytes = 0;\n\n for (const edit of params.edits) {\n try {\n // Read current file content\n const originalCode = await fs.readFile(edit.target_filepath, 'utf8');\n\n // Auto-detect language\n const language = edit.language || path.extname(edit.target_filepath).slice(1);\n\n // Apply edit using Agent Booster\n const result = await booster.apply({\n code: originalCode,\n edit: edit.code_edit,\n language\n });\n\n // Write modified code if successful\n if (result.success) {\n await fs.writeFile(edit.target_filepath, result.output, 'utf8');\n successCount++;\n }\n\n totalLatency += result.latency;\n totalBytes += Buffer.byteLength(result.output, 'utf8');\n\n results.push({\n ...result,\n metadata: {\n filepath: edit.target_filepath,\n instructions: edit.instructions\n }\n } as any);\n } catch (error: any) {\n results.push({\n output: '',\n success: false,\n latency: 0,\n tokens: { input: 0, output: 0 },\n confidence: 0,\n strategy: 'failed',\n error: error.message,\n metadata: {\n filepath: edit.target_filepath\n }\n } as any);\n }\n }\n\n return {\n results,\n summary: {\n total: params.edits.length,\n successful: successCount,\n failed: params.edits.length - successCount,\n totalLatency,\n avgLatency: totalLatency / params.edits.length,\n totalBytes,\n speedupVsCloud: Math.round(352 / (totalLatency / params.edits.length))\n }\n };\n },\n\n /**\n * Parse markdown and apply edits\n */\n agent_booster_parse_markdown: async (params: {\n markdown: string;\n }): Promise<{ results: MorphApplyResponse[]; summary: any }> => {\n // Parse markdown code blocks\n const codeBlockRegex = /```(\\w+)?\\s+filepath=[\"']([^\"']+)[\"']\\s+instruction=[\"']([^\"']+)[\"']\\s*\\n([\\s\\S]*?)```/g;\n const edits: Array<{\n target_filepath: string;\n instructions: string;\n code_edit: string;\n language?: string;\n }> = [];\n\n let match;\n while ((match = codeBlockRegex.exec(params.markdown)) !== null) {\n edits.push({\n language: match[1],\n target_filepath: match[2],\n instructions: match[3],\n code_edit: match[4].trim()\n });\n }\n\n if (edits.length === 0) {\n return {\n results: [],\n summary: {\n total: 0,\n successful: 0,\n failed: 0,\n error: 'No code blocks found with required metadata'\n }\n };\n }\n\n // Apply all edits\n return agentBoosterMCPHandlers.agent_booster_batch_edit({ edits });\n }\n};\n\n/**\n * Get Agent Booster statistics\n */\nexport function getAgentBoosterStats() {\n return {\n engine: 'Agent Booster WASM',\n version: '0.2.2',\n performance: {\n avgLatency: '1ms',\n speedup: '352x vs cloud APIs',\n costSavings: '$240/month'\n },\n features: {\n local: true,\n offline: true,\n privacy: 'Complete (no data sent to cloud)',\n languages: [\n 'javascript', 'typescript', 'python', 'rust', 'go',\n 'java', 'c', 'cpp', 'ruby', 'php', 'swift', 'kotlin'\n ]\n }\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"agent-booster-tools.js","sourceRoot":"","sources":["../../../src/mcp/tools/agent-booster-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAmBlC,IAAI,QAAQ,GAAgC,IAAI,CAAC;AACjD,KAAK,UAAU,UAAU;IACvB,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,MAAM,GAAG,GAAQ,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,GAAQ,EAAE,EAAE;QAChE,MAAM,IAAI,KAAK,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AAC;QAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO;gBACL,OAAO,EAAE,EAAE;gBACX,OAAO,EAAE;oBACP,KAAK,EAAE,CAAC;oBACR,UAAU,EAAE,CAAC;oBACb,MAAM,EAAE,CAAC;oBACT,KAAK,EAAE,6CAA6C;iBACrD;aACF,CAAC;QACJ,CAAC;QAED,kBAAkB;QAClB,OAAO,uBAAuB,CAAC,wBAAwB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACrE,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO;QACL,MAAM,EAAE,oBAAoB;QAC5B,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE;YACX,UAAU,EAAE,KAAK;YACjB,OAAO,EAAE,oBAAoB;YAC7B,WAAW,EAAE,YAAY;SAC1B;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,kCAAkC;YAC3C,SAAS,EAAE;gBACT,YAAY;gBACZ,YAAY;gBACZ,QAAQ;gBACR,MAAM;gBACN,IAAI;gBACJ,MAAM;gBACN,GAAG;gBACH,KAAK;gBACL,MAAM;gBACN,KAAK;gBACL,OAAO;gBACP,QAAQ;aACT;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Agent Booster MCP Tools\n *\n * Ultra-fast code editing (352x faster than cloud APIs, $0 cost)\n * Uses Agent Booster's local WASM engine for sub-millisecond transformations\n */\n\nimport * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\nimport type { MCPTool } from './sona-tools.js';\n// agent-booster types are optional — we re-declare a structural subset so this\n// file builds even when the optional sibling package is not installed (#102).\ntype MorphApplyResponse = {\n output: string;\n success: boolean;\n latency: number;\n tokens?: { input: number; output: number };\n confidence: number;\n strategy: string;\n error?: string;\n metadata?: any;\n};\n\ntype AgentBoosterInstance = {\n apply(input: any): Promise<MorphApplyResponse>;\n};\n\nlet _booster: AgentBoosterInstance | null = null;\nasync function getBooster(): Promise<AgentBoosterInstance> {\n if (_booster) return _booster;\n const mod: any = await import('agent-booster').catch((err: any) => {\n throw new Error(\n `Agent Booster optional package not installed: ${err?.message || err}. ` +\n `Run: npm install agent-booster`\n );\n });\n const Ctor = mod.AgentBooster ?? mod.default?.AgentBooster ?? mod.default;\n if (!Ctor) {\n throw new Error(\"'agent-booster' loaded but does not export AgentBooster\");\n }\n _booster = new Ctor({\n confidenceThreshold: 0.5,\n maxChunks: 100,\n });\n return _booster;\n}\n\n/**\n * Agent Booster MCP Tools\n */\nexport const agentBoosterMCPTools: MCPTool[] = [\n {\n name: 'agent_booster_edit_file',\n description:\n 'Ultra-fast code editing (352x faster than cloud APIs, $0 cost). Apply precise code edits using Agent Booster\\'s local WASM engine. Use \"// ... existing code ...\" markers for unchanged sections.',\n inputSchema: {\n type: 'object',\n properties: {\n target_filepath: {\n type: 'string',\n description: 'Path of the file to modify',\n },\n instructions: {\n type: 'string',\n description: 'First-person instruction (e.g., \"I will add error handling\")',\n },\n code_edit: {\n type: 'string',\n description:\n 'Precise code lines to edit, using \"// ... existing code ...\" for unchanged sections',\n },\n language: {\n type: 'string',\n description: 'Programming language (auto-detected from file extension if not provided)',\n },\n },\n required: ['target_filepath', 'instructions', 'code_edit'],\n },\n },\n {\n name: 'agent_booster_batch_edit',\n description:\n 'Apply multiple code edits in a single operation (ultra-fast batch processing). Perfect for multi-file refactoring.',\n inputSchema: {\n type: 'object',\n properties: {\n edits: {\n type: 'array',\n description: 'Array of edit requests',\n items: {\n type: 'object',\n properties: {\n target_filepath: {\n type: 'string',\n description: 'File path',\n },\n instructions: {\n type: 'string',\n description: 'First-person instruction',\n },\n code_edit: {\n type: 'string',\n description: 'Code edit with markers',\n },\n language: {\n type: 'string',\n description: 'Programming language',\n },\n },\n required: ['target_filepath', 'instructions', 'code_edit'],\n },\n },\n },\n required: ['edits'],\n },\n },\n {\n name: 'agent_booster_parse_markdown',\n description:\n 'Parse markdown code blocks with filepath= and instruction= metadata, then apply all edits. Compatible with LLM-generated multi-file refactoring outputs.',\n inputSchema: {\n type: 'object',\n properties: {\n markdown: {\n type: 'string',\n description:\n 'Markdown text containing code blocks with filepath= and instruction= metadata',\n },\n },\n required: ['markdown'],\n },\n },\n];\n\n/**\n * Agent Booster MCP Tool Handlers\n */\nexport const agentBoosterMCPHandlers = {\n /**\n * Edit a single file with Agent Booster\n */\n agent_booster_edit_file: async (params: {\n target_filepath: string;\n instructions: string;\n code_edit: string;\n language?: string;\n }): Promise<MorphApplyResponse> => {\n try {\n // Read current file content\n const originalCode = await fs.readFile(params.target_filepath, 'utf8');\n\n // Auto-detect language from file extension if not provided\n const language = params.language || path.extname(params.target_filepath).slice(1);\n\n // Apply edit using Agent Booster - use any for flexible signature\n const booster = await getBooster();\n const result = await booster.apply({\n code: originalCode,\n edit: params.code_edit,\n language,\n target_filepath: params.target_filepath,\n instructions: params.code_edit,\n code_edit: params.code_edit,\n } as any);\n\n // Write modified code if successful\n if (result.success) {\n await fs.writeFile(params.target_filepath, result.output, 'utf8');\n }\n\n return {\n ...result,\n // Add metadata\n metadata: {\n filepath: params.target_filepath,\n instructions: params.instructions,\n language,\n originalSize: originalCode.length,\n modifiedSize: result.output.length,\n },\n } as any;\n } catch (error: any) {\n return {\n output: '',\n success: false,\n latency: 0,\n tokens: { input: 0, output: 0 },\n confidence: 0,\n strategy: 'failed',\n error: error.message,\n } as any;\n }\n },\n\n /**\n * Apply multiple edits in batch\n */\n agent_booster_batch_edit: async (params: {\n edits: Array<{\n target_filepath: string;\n instructions: string;\n code_edit: string;\n language?: string;\n }>;\n }): Promise<{ results: MorphApplyResponse[]; summary: any }> => {\n const results: MorphApplyResponse[] = [];\n\n let totalLatency = 0;\n let successCount = 0;\n let totalBytes = 0;\n\n for (const edit of params.edits) {\n try {\n // Read current file content\n const originalCode = await fs.readFile(edit.target_filepath, 'utf8');\n\n // Auto-detect language\n const language = edit.language || path.extname(edit.target_filepath).slice(1);\n\n // Apply edit using Agent Booster - use any for flexible signature\n const booster = await getBooster();\n const result = await booster.apply({\n code: originalCode,\n edit: edit.code_edit,\n language,\n target_filepath: edit.target_filepath,\n instructions: edit.code_edit,\n code_edit: edit.code_edit,\n } as any);\n\n // Write modified code if successful\n if (result.success) {\n await fs.writeFile(edit.target_filepath, result.output, 'utf8');\n successCount++;\n }\n\n totalLatency += result.latency;\n totalBytes += Buffer.byteLength(result.output, 'utf8');\n\n results.push({\n ...result,\n metadata: {\n filepath: edit.target_filepath,\n instructions: edit.instructions,\n },\n } as any);\n } catch (error: any) {\n results.push({\n output: '',\n success: false,\n latency: 0,\n tokens: { input: 0, output: 0 },\n confidence: 0,\n strategy: 'failed',\n error: error.message,\n metadata: {\n filepath: edit.target_filepath,\n },\n } as any);\n }\n }\n\n return {\n results,\n summary: {\n total: params.edits.length,\n successful: successCount,\n failed: params.edits.length - successCount,\n totalLatency,\n avgLatency: totalLatency / params.edits.length,\n totalBytes,\n speedupVsCloud: Math.round(352 / (totalLatency / params.edits.length)),\n },\n };\n },\n\n /**\n * Parse markdown and apply edits\n */\n agent_booster_parse_markdown: async (params: {\n markdown: string;\n }): Promise<{ results: MorphApplyResponse[]; summary: any }> => {\n // Parse markdown code blocks\n const codeBlockRegex =\n /```(\\w+)?\\s+filepath=[\"']([^\"']+)[\"']\\s+instruction=[\"']([^\"']+)[\"']\\s*\\n([\\s\\S]*?)```/g;\n const edits: Array<{\n target_filepath: string;\n instructions: string;\n code_edit: string;\n language?: string;\n }> = [];\n\n let match;\n while ((match = codeBlockRegex.exec(params.markdown)) !== null) {\n edits.push({\n language: match[1],\n target_filepath: match[2],\n instructions: match[3],\n code_edit: match[4].trim(),\n });\n }\n\n if (edits.length === 0) {\n return {\n results: [],\n summary: {\n total: 0,\n successful: 0,\n failed: 0,\n error: 'No code blocks found with required metadata',\n },\n };\n }\n\n // Apply all edits\n return agentBoosterMCPHandlers.agent_booster_batch_edit({ edits });\n },\n};\n\n/**\n * Get Agent Booster statistics\n */\nexport function getAgentBoosterStats() {\n return {\n engine: 'Agent Booster WASM',\n version: '0.2.2',\n performance: {\n avgLatency: '1ms',\n speedup: '352x vs cloud APIs',\n costSavings: '$240/month',\n },\n features: {\n local: true,\n offline: true,\n privacy: 'Complete (no data sent to cloud)',\n languages: [\n 'javascript',\n 'typescript',\n 'python',\n 'rust',\n 'go',\n 'java',\n 'c',\n 'cpp',\n 'ruby',\n 'php',\n 'swift',\n 'kotlin',\n ],\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sona-tools.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools/sona-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAIL,WAAW,EACZ,MAAM,6BAA6B,CAAC;AAErC,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAChC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;CACH;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,EAySjC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;oCACY;QACpC,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,WAAW,CAAC;KACvB;;;;;;mCAYoC;QACnC,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,gBAAgB,EAAE,MAAM,EAAE,CAAC;QAC3B,MAAM,EAAE,MAAM,CAAC;KAChB;;;;;sCAeuC;QACtC,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;KACnB;;;;;kCAUmC;QAClC,YAAY,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B,OAAO,CAAC,EAAE,WAAW,CAAC;KACvB;;;;;6BAW8B;QAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,WAAW,CAAC;KACvB;;;;;;;;;;;;;;;;;;;;CAgDF,CAAC;AAgDF,eAAe,YAAY,CAAC"}
|
|
@@ -552,6 +552,12 @@ function getProfileCharacteristics(profile) {
|
|
|
552
552
|
latency: '~1ms',
|
|
553
553
|
memory: '~50MB',
|
|
554
554
|
qualityGain: '+25%'
|
|
555
|
+
},
|
|
556
|
+
'custom': {
|
|
557
|
+
throughput: 'configurable',
|
|
558
|
+
latency: 'configurable',
|
|
559
|
+
memory: 'configurable',
|
|
560
|
+
qualityGain: 'configurable'
|
|
555
561
|
}
|
|
556
562
|
};
|
|
557
563
|
return characteristics[profile];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sona-tools.js","sourceRoot":"","sources":["../../../src/mcp/tools/sona-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,WAAW,EACX,YAAY,EAGb,MAAM,6BAA6B,CAAC;AAYrC;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAc;IACrC,wBAAwB;IACxB;QACE,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EAAE,wFAAwF;QACrG,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE;oBACT,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,WAAW,EAAE,sDAAsD;iBACpE;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,wDAAwD;iBACtE;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC;oBAC5D,WAAW,EAAE,yCAAyC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BACR,WAAW,EAAE,QAAQ;gBACrB,YAAY,EAAE,WAAW;gBACzB,SAAS,EAAE,aAAa;aACzB;YACD,QAAQ,EAAE;gBACR,gBAAgB,EAAE,IAAI;gBACtB,aAAa,EAAE,GAAG;gBAClB,YAAY,EAAE,KAAK;aACpB;YACD,WAAW,EAAE,cAAc,IAAI,IAAI;SACpC,CAAC;IACJ,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,SAAS,yBAAyB,CAAC,OAAoB;IACrD,MAAM,eAAe,GAA6B;QAChD,WAAW,EAAE;YACX,UAAU,EAAE,cAAc;YAC1B,OAAO,EAAE,QAAQ;YACjB,MAAM,EAAE,OAAO;YACf,WAAW,EAAE,MAAM;SACpB;QACD,OAAO,EAAE;YACP,UAAU,EAAE,cAAc;YAC1B,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,OAAO;YACf,WAAW,EAAE,MAAM;SACpB;QACD,UAAU,EAAE;YACV,UAAU,EAAE,cAAc;YAC1B,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,QAAQ;YAChB,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE;YACN,UAAU,EAAE,aAAa;YACzB,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,MAAM;YACd,WAAW,EAAE,MAAM;SACpB;QACD,UAAU,EAAE;YACV,UAAU,EAAE,cAAc;YAC1B,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,OAAO;YACf,WAAW,EAAE,MAAM;SACpB;KACF,CAAC;IAEF,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAED,eAAe,YAAY,CAAC","sourcesContent":["/**\n * SONA MCP Tools\n *\n * Model Context Protocol tools for SONA (Self-Optimizing Neural Architecture)\n * Provides trajectory management, pattern discovery, and learning operations\n */\n\nimport {\n sonaService,\n sonaServices,\n createSONAService,\n SONAProfile\n} from '../../services/sona-service';\n\nexport interface MCPTool {\n name: string;\n description: string;\n inputSchema: {\n type: string;\n properties: Record<string, any>;\n required?: string[];\n };\n}\n\n/**\n * SONA MCP Tools\n */\nexport const sonaMCPTools: MCPTool[] = [\n // Trajectory Management\n {\n name: 'sona_trajectory_begin',\n description: 'Begin a new SONA learning trajectory. Returns trajectory ID for subsequent operations.',\n inputSchema: {\n type: 'object',\n properties: {\n embedding: {\n type: 'array',\n items: { type: 'number' },\n description: 'Embedding vector (1536D for OpenAI, 3072D for Phi-4)'\n },\n route: {\n type: 'string',\n description: 'LLM model route (e.g., claude-sonnet-4-5, gpt-4-turbo)'\n },\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'SONA profile to use (default: balanced)'\n }\n },\n required: ['embedding']\n }\n },\n\n {\n name: 'sona_trajectory_step',\n description: 'Add a step to an active trajectory with activations, attention weights, and reward.',\n inputSchema: {\n type: 'object',\n properties: {\n trajectoryId: {\n type: 'string',\n description: 'Trajectory ID from sona_trajectory_begin'\n },\n activations: {\n type: 'array',\n items: { type: 'number' },\n description: 'Layer activations (3072D for Phi-4)'\n },\n attentionWeights: {\n type: 'array',\n items: { type: 'number' },\n description: 'Attention weights (40 layers for Phi-4)'\n },\n reward: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n description: 'Reward score (0-1)'\n }\n },\n required: ['trajectoryId', 'activations', 'attentionWeights', 'reward']\n }\n },\n\n {\n name: 'sona_trajectory_context',\n description: 'Add context metadata to a trajectory (e.g., task type, domain).',\n inputSchema: {\n type: 'object',\n properties: {\n trajectoryId: {\n type: 'string',\n description: 'Trajectory ID'\n },\n contextId: {\n type: 'string',\n description: 'Context identifier (e.g., code-review, data-analysis)'\n }\n },\n required: ['trajectoryId', 'contextId']\n }\n },\n\n {\n name: 'sona_trajectory_end',\n description: 'End a trajectory with final quality score. Triggers learning if capacity threshold reached.',\n inputSchema: {\n type: 'object',\n properties: {\n trajectoryId: {\n type: 'string',\n description: 'Trajectory ID'\n },\n qualityScore: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n description: 'Overall quality score (0-1)'\n }\n },\n required: ['trajectoryId', 'qualityScore']\n }\n },\n\n {\n name: 'sona_trajectory_list',\n description: 'List all active trajectories.',\n inputSchema: {\n type: 'object',\n properties: {\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'Filter by profile (optional)'\n }\n }\n }\n },\n\n // Pattern Discovery\n {\n name: 'sona_pattern_find',\n description: 'Find similar patterns using k-NN search. Recommended k=3 for 761 decisions/sec throughput.',\n inputSchema: {\n type: 'object',\n properties: {\n query: {\n type: 'array',\n items: { type: 'number' },\n description: 'Query embedding vector'\n },\n k: {\n type: 'number',\n default: 3,\n minimum: 1,\n maximum: 20,\n description: 'Number of patterns to retrieve (default: 3)'\n },\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'SONA profile (default: balanced)'\n }\n },\n required: ['query']\n }\n },\n\n // LoRA Application\n {\n name: 'sona_apply_micro_lora',\n description: 'Apply Micro-LoRA adaptation to input vector. Sub-millisecond latency.',\n inputSchema: {\n type: 'object',\n properties: {\n input: {\n type: 'array',\n items: { type: 'number' },\n description: 'Input vector (3072D for Phi-4)'\n },\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'SONA profile (default: balanced)'\n }\n },\n required: ['input']\n }\n },\n\n {\n name: 'sona_apply_base_lora',\n description: 'Apply Base-LoRA adaptation to layer. 0.452ms per-layer cost.',\n inputSchema: {\n type: 'object',\n properties: {\n layerIndex: {\n type: 'number',\n minimum: 0,\n maximum: 39,\n description: 'Layer index (0-39 for Phi-4)'\n },\n input: {\n type: 'array',\n items: { type: 'number' },\n description: 'Input vector (3072D for Phi-4)'\n },\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'SONA profile (default: balanced)'\n }\n },\n required: ['layerIndex', 'input']\n }\n },\n\n // Learning Control\n {\n name: 'sona_force_learn',\n description: 'Force learning cycle. Recommended when trajectory capacity reaches 80% utilization.',\n inputSchema: {\n type: 'object',\n properties: {\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'SONA profile (default: balanced)'\n }\n }\n }\n },\n\n // Statistics & Monitoring\n {\n name: 'sona_get_stats',\n description: 'Get SONA service statistics including trajectories, performance, and configuration.',\n inputSchema: {\n type: 'object',\n properties: {\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'SONA profile (default: balanced)'\n },\n engineStats: {\n type: 'boolean',\n default: false,\n description: 'Include engine-level statistics'\n }\n }\n }\n },\n\n // Profile Management\n {\n name: 'sona_get_profile',\n description: 'Get SONA profile configuration details.',\n inputSchema: {\n type: 'object',\n properties: {\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'Profile name'\n }\n },\n required: ['profile']\n }\n },\n\n {\n name: 'sona_list_profiles',\n description: 'List all available SONA profiles with their characteristics.',\n inputSchema: {\n type: 'object',\n properties: {}\n }\n },\n\n // Engine Control\n {\n name: 'sona_set_enabled',\n description: 'Enable or disable SONA engine.',\n inputSchema: {\n type: 'object',\n properties: {\n enabled: {\n type: 'boolean',\n description: 'Enable (true) or disable (false)'\n },\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'SONA profile (default: balanced)'\n }\n },\n required: ['enabled']\n }\n },\n\n // Benchmarking\n {\n name: 'sona_benchmark',\n description: 'Run SONA performance benchmark. Expected: 2211 ops/sec, <0.5ms latency.',\n inputSchema: {\n type: 'object',\n properties: {\n iterations: {\n type: 'number',\n default: 1000,\n minimum: 100,\n maximum: 10000,\n description: 'Number of benchmark iterations'\n },\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'SONA profile (default: balanced)'\n }\n }\n }\n }\n];\n\n/**\n * MCP Tool Handlers\n */\nexport const sonaMCPHandlers = {\n sona_trajectory_begin: async (params: {\n embedding: number[];\n route?: string;\n profile?: SONAProfile;\n }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n const trajectoryId = service.beginTrajectory(params.embedding, params.route);\n\n return {\n success: true,\n trajectoryId,\n route: params.route,\n profile: params.profile || 'balanced'\n };\n },\n\n sona_trajectory_step: async (params: {\n trajectoryId: string;\n activations: number[];\n attentionWeights: number[];\n reward: number;\n }) => {\n sonaService.addTrajectoryStep(\n params.trajectoryId,\n params.activations,\n params.attentionWeights,\n params.reward\n );\n\n return {\n success: true,\n trajectoryId: params.trajectoryId,\n reward: params.reward\n };\n },\n\n sona_trajectory_context: async (params: {\n trajectoryId: string;\n contextId: string;\n }) => {\n sonaService.addTrajectoryContext(params.trajectoryId, params.contextId);\n\n return {\n success: true,\n trajectoryId: params.trajectoryId,\n contextId: params.contextId\n };\n },\n\n sona_trajectory_end: async (params: {\n trajectoryId: string;\n qualityScore: number;\n }) => {\n sonaService.endTrajectory(params.trajectoryId, params.qualityScore);\n\n const stats = sonaService.getStats();\n\n return {\n success: true,\n trajectoryId: params.trajectoryId,\n qualityScore: params.qualityScore,\n learningTriggered: stats.trajectoryUtilization >= 0.8\n };\n },\n\n sona_trajectory_list: async (params: { profile?: SONAProfile }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n const active = service.getActiveTrajectories();\n\n return {\n count: active.length,\n trajectories: active.map(t => ({\n id: t.id,\n route: t.route,\n steps: t.steps.length,\n contexts: t.contexts.length,\n durationMs: Date.now() - t.startTime\n }))\n };\n },\n\n sona_pattern_find: async (params: {\n query: number[];\n k?: number;\n profile?: SONAProfile;\n }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n const patterns = service.findPatterns(params.query, params.k || 3);\n\n return {\n count: patterns.length,\n patterns: patterns.map(p => ({\n id: p.id,\n patternType: p.patternType,\n clusterSize: p.clusterSize,\n avgQuality: p.avgQuality,\n similarity: p.similarity\n }))\n };\n },\n\n sona_apply_micro_lora: async (params: {\n input: number[];\n profile?: SONAProfile;\n }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n const start = Date.now();\n const output = service.applyMicroLora(params.input);\n const latencyMs = Date.now() - start;\n\n return {\n output,\n latencyMs,\n inputDim: params.input.length,\n outputDim: output.length\n };\n },\n\n sona_apply_base_lora: async (params: {\n layerIndex: number;\n input: number[];\n profile?: SONAProfile;\n }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n const start = Date.now();\n const output = service.applyBaseLora(params.layerIndex, params.input);\n const latencyMs = Date.now() - start;\n\n return {\n output,\n latencyMs,\n layerIndex: params.layerIndex,\n inputDim: params.input.length,\n outputDim: output.length\n };\n },\n\n sona_force_learn: async (params: { profile?: SONAProfile }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n const result = service.forceLearn();\n\n return {\n success: result.success,\n patternsLearned: result.patternsLearned,\n profile: params.profile || 'balanced'\n };\n },\n\n sona_get_stats: async (params: {\n profile?: SONAProfile;\n engineStats?: boolean;\n }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n const stats = service.getStats();\n\n const result: any = {\n profile: params.profile || 'balanced',\n trajectories: {\n total: stats.totalTrajectories,\n active: stats.activeTrajectories,\n completed: stats.completedTrajectories,\n utilization: stats.trajectoryUtilization\n },\n performance: {\n avgQualityScore: stats.avgQualityScore,\n totalOpsProcessed: stats.totalOpsProcessed,\n opsPerSecond: stats.opsPerSecond,\n learningCycles: stats.totalLearningCycles\n },\n configuration: stats.config\n };\n\n if (params.engineStats) {\n result.engineStats = service.getEngineStats();\n }\n\n return result;\n },\n\n sona_get_profile: async (params: { profile: SONAProfile }) => {\n const service = sonaServices[params.profile];\n if (!service) {\n throw new Error(`Unknown profile: ${params.profile}`);\n }\n\n const stats = service.getStats();\n\n return {\n profile: params.profile,\n configuration: stats.config,\n characteristics: getProfileCharacteristics(params.profile)\n };\n },\n\n sona_list_profiles: async () => {\n return {\n profiles: [\n {\n name: 'real-time',\n description: '2200 ops/sec, <0.5ms latency',\n config: 'Rank-2, 25 clusters, 0.7 threshold',\n useCase: 'Low-latency applications'\n },\n {\n name: 'batch',\n description: 'Balance throughput and adaptation',\n config: 'Rank-2, rank-8, 5000 capacity',\n useCase: 'Batch processing workflows'\n },\n {\n name: 'research',\n description: '+55% quality improvement',\n config: 'Rank-16 base, LR 0.002, 0.2 threshold',\n useCase: 'Maximum quality, research'\n },\n {\n name: 'edge',\n description: '<5MB memory footprint',\n config: 'Rank-1, 200 capacity, 15 clusters',\n useCase: 'Edge devices, mobile'\n },\n {\n name: 'balanced',\n description: '18ms overhead, +25% quality',\n config: 'Rank-2, rank-8, 0.4 threshold',\n useCase: 'General-purpose (default)'\n }\n ]\n };\n },\n\n sona_set_enabled: async (params: {\n enabled: boolean;\n profile?: SONAProfile;\n }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n service.setEnabled(params.enabled);\n\n return {\n success: true,\n enabled: params.enabled,\n profile: params.profile || 'balanced'\n };\n },\n\n sona_benchmark: async (params: {\n iterations?: number;\n profile?: SONAProfile;\n }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n const iterations = params.iterations || 1000;\n\n // Benchmark Micro-LoRA\n const input = Array.from({ length: 3072 }, () => Math.random());\n const startMicro = Date.now();\n\n for (let i = 0; i < iterations; i++) {\n service.applyMicroLora(input);\n }\n\n const microTime = Date.now() - startMicro;\n const microLatency = microTime / iterations;\n const microOpsPerSec = (iterations / microTime) * 1000;\n\n // Benchmark Base-LoRA\n const startBase = Date.now();\n\n for (let i = 0; i < iterations; i++) {\n service.applyBaseLora(10, input);\n }\n\n const baseTime = Date.now() - startBase;\n const baseLatency = baseTime / iterations;\n const baseOpsPerSec = (iterations / baseTime) * 1000;\n\n return {\n iterations,\n profile: params.profile || 'balanced',\n microLora: {\n totalTimeMs: microTime,\n avgLatencyMs: microLatency,\n opsPerSec: microOpsPerSec\n },\n baseLora: {\n totalTimeMs: baseTime,\n avgLatencyMs: baseLatency,\n opsPerSec: baseOpsPerSec\n },\n expected: {\n targetThroughput: 2211,\n targetLatency: 0.5,\n perLayerCost: 0.452\n },\n meetsTarget: microOpsPerSec >= 1000\n };\n }\n};\n\n/**\n * Get profile characteristics\n */\nfunction getProfileCharacteristics(profile: SONAProfile): any {\n const characteristics: Record<SONAProfile, any> = {\n 'real-time': {\n throughput: '2200 ops/sec',\n latency: '<0.5ms',\n memory: '~20MB',\n qualityGain: '+15%'\n },\n 'batch': {\n throughput: '1800 ops/sec',\n latency: '~1ms',\n memory: '~50MB',\n qualityGain: '+25%'\n },\n 'research': {\n throughput: '1000 ops/sec',\n latency: '~2ms',\n memory: '~100MB',\n qualityGain: '+55%'\n },\n 'edge': {\n throughput: '500 ops/sec',\n latency: '~2ms',\n memory: '<5MB',\n qualityGain: '+10%'\n },\n 'balanced': {\n throughput: '1500 ops/sec',\n latency: '~1ms',\n memory: '~50MB',\n qualityGain: '+25%'\n }\n };\n\n return characteristics[profile];\n}\n\nexport default sonaMCPTools;\n"]}
|
|
1
|
+
{"version":3,"file":"sona-tools.js","sourceRoot":"","sources":["../../../src/mcp/tools/sona-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,WAAW,EACX,YAAY,EAGb,MAAM,6BAA6B,CAAC;AAYrC;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAc;IACrC,wBAAwB;IACxB;QACE,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EAAE,wFAAwF;QACrG,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE;oBACT,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,WAAW,EAAE,sDAAsD;iBACpE;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,wDAAwD;iBACtE;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,WAAW,EAA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Model Context Protocol tools for SONA (Self-Optimizing Neural Architecture)\n * Provides trajectory management, pattern discovery, and learning operations\n */\n\nimport {\n sonaService,\n sonaServices,\n createSONAService,\n SONAProfile\n} from '../../services/sona-service';\n\nexport interface MCPTool {\n name: string;\n description: string;\n inputSchema: {\n type: string;\n properties: Record<string, any>;\n required?: string[];\n };\n}\n\n/**\n * SONA MCP Tools\n */\nexport const sonaMCPTools: MCPTool[] = [\n // Trajectory Management\n {\n name: 'sona_trajectory_begin',\n description: 'Begin a new SONA learning trajectory. Returns trajectory ID for subsequent operations.',\n inputSchema: {\n type: 'object',\n properties: {\n embedding: {\n type: 'array',\n items: { type: 'number' },\n description: 'Embedding vector (1536D for OpenAI, 3072D for Phi-4)'\n },\n route: {\n type: 'string',\n description: 'LLM model route (e.g., claude-sonnet-4-5, gpt-4-turbo)'\n },\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'SONA profile to use (default: balanced)'\n }\n },\n required: ['embedding']\n }\n },\n\n {\n name: 'sona_trajectory_step',\n description: 'Add a step to an active trajectory with activations, attention weights, and reward.',\n inputSchema: {\n type: 'object',\n properties: {\n trajectoryId: {\n type: 'string',\n description: 'Trajectory ID from sona_trajectory_begin'\n },\n activations: {\n type: 'array',\n items: { type: 'number' },\n description: 'Layer activations (3072D for Phi-4)'\n },\n attentionWeights: {\n type: 'array',\n items: { type: 'number' },\n description: 'Attention weights (40 layers for Phi-4)'\n },\n reward: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n description: 'Reward score (0-1)'\n }\n },\n required: ['trajectoryId', 'activations', 'attentionWeights', 'reward']\n }\n },\n\n {\n name: 'sona_trajectory_context',\n description: 'Add context metadata to a trajectory (e.g., task type, domain).',\n inputSchema: {\n type: 'object',\n properties: {\n trajectoryId: {\n type: 'string',\n description: 'Trajectory ID'\n },\n contextId: {\n type: 'string',\n description: 'Context identifier (e.g., code-review, data-analysis)'\n }\n },\n required: ['trajectoryId', 'contextId']\n }\n },\n\n {\n name: 'sona_trajectory_end',\n description: 'End a trajectory with final quality score. Triggers learning if capacity threshold reached.',\n inputSchema: {\n type: 'object',\n properties: {\n trajectoryId: {\n type: 'string',\n description: 'Trajectory ID'\n },\n qualityScore: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n description: 'Overall quality score (0-1)'\n }\n },\n required: ['trajectoryId', 'qualityScore']\n }\n },\n\n {\n name: 'sona_trajectory_list',\n description: 'List all active trajectories.',\n inputSchema: {\n type: 'object',\n properties: {\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'Filter by profile (optional)'\n }\n }\n }\n },\n\n // Pattern Discovery\n {\n name: 'sona_pattern_find',\n description: 'Find similar patterns using k-NN search. Recommended k=3 for 761 decisions/sec throughput.',\n inputSchema: {\n type: 'object',\n properties: {\n query: {\n type: 'array',\n items: { type: 'number' },\n description: 'Query embedding vector'\n },\n k: {\n type: 'number',\n default: 3,\n minimum: 1,\n maximum: 20,\n description: 'Number of patterns to retrieve (default: 3)'\n },\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'SONA profile (default: balanced)'\n }\n },\n required: ['query']\n }\n },\n\n // LoRA Application\n {\n name: 'sona_apply_micro_lora',\n description: 'Apply Micro-LoRA adaptation to input vector. Sub-millisecond latency.',\n inputSchema: {\n type: 'object',\n properties: {\n input: {\n type: 'array',\n items: { type: 'number' },\n description: 'Input vector (3072D for Phi-4)'\n },\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'SONA profile (default: balanced)'\n }\n },\n required: ['input']\n }\n },\n\n {\n name: 'sona_apply_base_lora',\n description: 'Apply Base-LoRA adaptation to layer. 0.452ms per-layer cost.',\n inputSchema: {\n type: 'object',\n properties: {\n layerIndex: {\n type: 'number',\n minimum: 0,\n maximum: 39,\n description: 'Layer index (0-39 for Phi-4)'\n },\n input: {\n type: 'array',\n items: { type: 'number' },\n description: 'Input vector (3072D for Phi-4)'\n },\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'SONA profile (default: balanced)'\n }\n },\n required: ['layerIndex', 'input']\n }\n },\n\n // Learning Control\n {\n name: 'sona_force_learn',\n description: 'Force learning cycle. Recommended when trajectory capacity reaches 80% utilization.',\n inputSchema: {\n type: 'object',\n properties: {\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'SONA profile (default: balanced)'\n }\n }\n }\n },\n\n // Statistics & Monitoring\n {\n name: 'sona_get_stats',\n description: 'Get SONA service statistics including trajectories, performance, and configuration.',\n inputSchema: {\n type: 'object',\n properties: {\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'SONA profile (default: balanced)'\n },\n engineStats: {\n type: 'boolean',\n default: false,\n description: 'Include engine-level statistics'\n }\n }\n }\n },\n\n // Profile Management\n {\n name: 'sona_get_profile',\n description: 'Get SONA profile configuration details.',\n inputSchema: {\n type: 'object',\n properties: {\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'Profile name'\n }\n },\n required: ['profile']\n }\n },\n\n {\n name: 'sona_list_profiles',\n description: 'List all available SONA profiles with their characteristics.',\n inputSchema: {\n type: 'object',\n properties: {}\n }\n },\n\n // Engine Control\n {\n name: 'sona_set_enabled',\n description: 'Enable or disable SONA engine.',\n inputSchema: {\n type: 'object',\n properties: {\n enabled: {\n type: 'boolean',\n description: 'Enable (true) or disable (false)'\n },\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'SONA profile (default: balanced)'\n }\n },\n required: ['enabled']\n }\n },\n\n // Benchmarking\n {\n name: 'sona_benchmark',\n description: 'Run SONA performance benchmark. Expected: 2211 ops/sec, <0.5ms latency.',\n inputSchema: {\n type: 'object',\n properties: {\n iterations: {\n type: 'number',\n default: 1000,\n minimum: 100,\n maximum: 10000,\n description: 'Number of benchmark iterations'\n },\n profile: {\n type: 'string',\n enum: ['real-time', 'batch', 'research', 'edge', 'balanced'],\n description: 'SONA profile (default: balanced)'\n }\n }\n }\n }\n];\n\n/**\n * MCP Tool Handlers\n */\nexport const sonaMCPHandlers = {\n sona_trajectory_begin: async (params: {\n embedding: number[];\n route?: string;\n profile?: SONAProfile;\n }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n const trajectoryId = service.beginTrajectory(params.embedding, params.route);\n\n return {\n success: true,\n trajectoryId,\n route: params.route,\n profile: params.profile || 'balanced'\n };\n },\n\n sona_trajectory_step: async (params: {\n trajectoryId: string;\n activations: number[];\n attentionWeights: number[];\n reward: number;\n }) => {\n sonaService.addTrajectoryStep(\n params.trajectoryId,\n params.activations,\n params.attentionWeights,\n params.reward\n );\n\n return {\n success: true,\n trajectoryId: params.trajectoryId,\n reward: params.reward\n };\n },\n\n sona_trajectory_context: async (params: {\n trajectoryId: string;\n contextId: string;\n }) => {\n sonaService.addTrajectoryContext(params.trajectoryId, params.contextId);\n\n return {\n success: true,\n trajectoryId: params.trajectoryId,\n contextId: params.contextId\n };\n },\n\n sona_trajectory_end: async (params: {\n trajectoryId: string;\n qualityScore: number;\n }) => {\n sonaService.endTrajectory(params.trajectoryId, params.qualityScore);\n\n const stats = sonaService.getStats();\n\n return {\n success: true,\n trajectoryId: params.trajectoryId,\n qualityScore: params.qualityScore,\n learningTriggered: stats.trajectoryUtilization >= 0.8\n };\n },\n\n sona_trajectory_list: async (params: { profile?: SONAProfile }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n const active = service.getActiveTrajectories();\n\n return {\n count: active.length,\n trajectories: active.map(t => ({\n id: t.id,\n route: t.route,\n steps: t.steps.length,\n contexts: t.contexts.length,\n durationMs: Date.now() - t.startTime\n }))\n };\n },\n\n sona_pattern_find: async (params: {\n query: number[];\n k?: number;\n profile?: SONAProfile;\n }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n const patterns = service.findPatterns(params.query, params.k || 3);\n\n return {\n count: patterns.length,\n patterns: patterns.map(p => ({\n id: p.id,\n patternType: p.patternType,\n clusterSize: p.clusterSize,\n avgQuality: p.avgQuality,\n similarity: p.similarity\n }))\n };\n },\n\n sona_apply_micro_lora: async (params: {\n input: number[];\n profile?: SONAProfile;\n }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n const start = Date.now();\n const output = service.applyMicroLora(params.input);\n const latencyMs = Date.now() - start;\n\n return {\n output,\n latencyMs,\n inputDim: params.input.length,\n outputDim: output.length\n };\n },\n\n sona_apply_base_lora: async (params: {\n layerIndex: number;\n input: number[];\n profile?: SONAProfile;\n }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n const start = Date.now();\n const output = service.applyBaseLora(params.layerIndex, params.input);\n const latencyMs = Date.now() - start;\n\n return {\n output,\n latencyMs,\n layerIndex: params.layerIndex,\n inputDim: params.input.length,\n outputDim: output.length\n };\n },\n\n sona_force_learn: async (params: { profile?: SONAProfile }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n const result = service.forceLearn();\n\n return {\n success: result.success,\n patternsLearned: result.patternsLearned,\n profile: params.profile || 'balanced'\n };\n },\n\n sona_get_stats: async (params: {\n profile?: SONAProfile;\n engineStats?: boolean;\n }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n const stats = service.getStats();\n\n const result: any = {\n profile: params.profile || 'balanced',\n trajectories: {\n total: stats.totalTrajectories,\n active: stats.activeTrajectories,\n completed: stats.completedTrajectories,\n utilization: stats.trajectoryUtilization\n },\n performance: {\n avgQualityScore: stats.avgQualityScore,\n totalOpsProcessed: stats.totalOpsProcessed,\n opsPerSecond: stats.opsPerSecond,\n learningCycles: stats.totalLearningCycles\n },\n configuration: stats.config\n };\n\n if (params.engineStats) {\n result.engineStats = service.getEngineStats();\n }\n\n return result;\n },\n\n sona_get_profile: async (params: { profile: SONAProfile }) => {\n const service = sonaServices[params.profile];\n if (!service) {\n throw new Error(`Unknown profile: ${params.profile}`);\n }\n\n const stats = service.getStats();\n\n return {\n profile: params.profile,\n configuration: stats.config,\n characteristics: getProfileCharacteristics(params.profile)\n };\n },\n\n sona_list_profiles: async () => {\n return {\n profiles: [\n {\n name: 'real-time',\n description: '2200 ops/sec, <0.5ms latency',\n config: 'Rank-2, 25 clusters, 0.7 threshold',\n useCase: 'Low-latency applications'\n },\n {\n name: 'batch',\n description: 'Balance throughput and adaptation',\n config: 'Rank-2, rank-8, 5000 capacity',\n useCase: 'Batch processing workflows'\n },\n {\n name: 'research',\n description: '+55% quality improvement',\n config: 'Rank-16 base, LR 0.002, 0.2 threshold',\n useCase: 'Maximum quality, research'\n },\n {\n name: 'edge',\n description: '<5MB memory footprint',\n config: 'Rank-1, 200 capacity, 15 clusters',\n useCase: 'Edge devices, mobile'\n },\n {\n name: 'balanced',\n description: '18ms overhead, +25% quality',\n config: 'Rank-2, rank-8, 0.4 threshold',\n useCase: 'General-purpose (default)'\n }\n ]\n };\n },\n\n sona_set_enabled: async (params: {\n enabled: boolean;\n profile?: SONAProfile;\n }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n service.setEnabled(params.enabled);\n\n return {\n success: true,\n enabled: params.enabled,\n profile: params.profile || 'balanced'\n };\n },\n\n sona_benchmark: async (params: {\n iterations?: number;\n profile?: SONAProfile;\n }) => {\n const service = params.profile ? sonaServices[params.profile] : sonaService;\n const iterations = params.iterations || 1000;\n\n // Benchmark Micro-LoRA\n const input = Array.from({ length: 3072 }, () => Math.random());\n const startMicro = Date.now();\n\n for (let i = 0; i < iterations; i++) {\n service.applyMicroLora(input);\n }\n\n const microTime = Date.now() - startMicro;\n const microLatency = microTime / iterations;\n const microOpsPerSec = (iterations / microTime) * 1000;\n\n // Benchmark Base-LoRA\n const startBase = Date.now();\n\n for (let i = 0; i < iterations; i++) {\n service.applyBaseLora(10, input);\n }\n\n const baseTime = Date.now() - startBase;\n const baseLatency = baseTime / iterations;\n const baseOpsPerSec = (iterations / baseTime) * 1000;\n\n return {\n iterations,\n profile: params.profile || 'balanced',\n microLora: {\n totalTimeMs: microTime,\n avgLatencyMs: microLatency,\n opsPerSec: microOpsPerSec\n },\n baseLora: {\n totalTimeMs: baseTime,\n avgLatencyMs: baseLatency,\n opsPerSec: baseOpsPerSec\n },\n expected: {\n targetThroughput: 2211,\n targetLatency: 0.5,\n perLayerCost: 0.452\n },\n meetsTarget: microOpsPerSec >= 1000\n };\n }\n};\n\n/**\n * Get profile characteristics\n */\nfunction getProfileCharacteristics(profile: SONAProfile): any {\n const characteristics: Record<SONAProfile, any> = {\n 'real-time': {\n throughput: '2200 ops/sec',\n latency: '<0.5ms',\n memory: '~20MB',\n qualityGain: '+15%'\n },\n 'batch': {\n throughput: '1800 ops/sec',\n latency: '~1ms',\n memory: '~50MB',\n qualityGain: '+25%'\n },\n 'research': {\n throughput: '1000 ops/sec',\n latency: '~2ms',\n memory: '~100MB',\n qualityGain: '+55%'\n },\n 'edge': {\n throughput: '500 ops/sec',\n latency: '~2ms',\n memory: '<5MB',\n qualityGain: '+10%'\n },\n 'balanced': {\n throughput: '1500 ops/sec',\n latency: '~1ms',\n memory: '~50MB',\n qualityGain: '+25%'\n },\n 'custom': {\n throughput: 'configurable',\n latency: 'configurable',\n memory: 'configurable',\n qualityGain: 'configurable'\n }\n };\n\n return characteristics[profile];\n}\n\nexport default sonaMCPTools;\n"]}
|