ruvector 0.1.95 → 0.1.96
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/bin/cli.js +0 -819
- package/bin/mcp-server.js +1 -512
- package/dist/core/index.d.ts +0 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -4
- package/dist/core/onnx-embedder.d.ts +0 -84
- package/dist/core/onnx-embedder.d.ts.map +1 -1
- package/dist/core/onnx-embedder.js +12 -167
- package/package.json +2 -3
package/bin/mcp-server.js
CHANGED
|
@@ -294,7 +294,7 @@ class Intelligence {
|
|
|
294
294
|
const server = new Server(
|
|
295
295
|
{
|
|
296
296
|
name: 'ruvector',
|
|
297
|
-
version: '0.1.
|
|
297
|
+
version: '0.1.58',
|
|
298
298
|
},
|
|
299
299
|
{
|
|
300
300
|
capabilities: {
|
|
@@ -1045,116 +1045,6 @@ const TOOLS = [
|
|
|
1045
1045
|
},
|
|
1046
1046
|
required: []
|
|
1047
1047
|
}
|
|
1048
|
-
},
|
|
1049
|
-
// ============================================
|
|
1050
|
-
// EDGE-NET DISTRIBUTED AGENT/WORKER TOOLS
|
|
1051
|
-
// ============================================
|
|
1052
|
-
{
|
|
1053
|
-
name: 'edge_net_info',
|
|
1054
|
-
description: 'Get Edge-Net distributed network information and capabilities',
|
|
1055
|
-
inputSchema: {
|
|
1056
|
-
type: 'object',
|
|
1057
|
-
properties: {},
|
|
1058
|
-
required: []
|
|
1059
|
-
}
|
|
1060
|
-
},
|
|
1061
|
-
{
|
|
1062
|
-
name: 'edge_net_spawn',
|
|
1063
|
-
description: 'Spawn a distributed AI agent on the Edge-Net network. Agent types: researcher, coder, reviewer, tester, analyst, optimizer, coordinator, embedder',
|
|
1064
|
-
inputSchema: {
|
|
1065
|
-
type: 'object',
|
|
1066
|
-
properties: {
|
|
1067
|
-
type: {
|
|
1068
|
-
type: 'string',
|
|
1069
|
-
description: 'Agent type',
|
|
1070
|
-
enum: ['researcher', 'coder', 'reviewer', 'tester', 'analyst', 'optimizer', 'coordinator', 'embedder']
|
|
1071
|
-
},
|
|
1072
|
-
task: { type: 'string', description: 'Task for the agent to perform' },
|
|
1073
|
-
max_ruv: { type: 'number', description: 'Maximum rUv credits to spend', default: 20 },
|
|
1074
|
-
priority: { type: 'string', enum: ['low', 'medium', 'high', 'critical'], default: 'medium' }
|
|
1075
|
-
},
|
|
1076
|
-
required: ['type', 'task']
|
|
1077
|
-
}
|
|
1078
|
-
},
|
|
1079
|
-
{
|
|
1080
|
-
name: 'edge_net_pool_create',
|
|
1081
|
-
description: 'Create a distributed worker pool on Edge-Net for parallel task execution',
|
|
1082
|
-
inputSchema: {
|
|
1083
|
-
type: 'object',
|
|
1084
|
-
properties: {
|
|
1085
|
-
min_workers: { type: 'number', description: 'Minimum workers', default: 2 },
|
|
1086
|
-
max_workers: { type: 'number', description: 'Maximum workers', default: 10 }
|
|
1087
|
-
},
|
|
1088
|
-
required: []
|
|
1089
|
-
}
|
|
1090
|
-
},
|
|
1091
|
-
{
|
|
1092
|
-
name: 'edge_net_pool_execute',
|
|
1093
|
-
description: 'Execute a task on a distributed worker pool',
|
|
1094
|
-
inputSchema: {
|
|
1095
|
-
type: 'object',
|
|
1096
|
-
properties: {
|
|
1097
|
-
task: { type: 'string', description: 'Task to execute' },
|
|
1098
|
-
pool_id: { type: 'string', description: 'Pool ID (optional, auto-assigns if not provided)' }
|
|
1099
|
-
},
|
|
1100
|
-
required: ['task']
|
|
1101
|
-
}
|
|
1102
|
-
},
|
|
1103
|
-
{
|
|
1104
|
-
name: 'edge_net_workflow',
|
|
1105
|
-
description: 'Run a multi-agent workflow on Edge-Net. Built-in workflows: code-review, feature-dev, bug-fix, optimization, research',
|
|
1106
|
-
inputSchema: {
|
|
1107
|
-
type: 'object',
|
|
1108
|
-
properties: {
|
|
1109
|
-
name: {
|
|
1110
|
-
type: 'string',
|
|
1111
|
-
description: 'Workflow name',
|
|
1112
|
-
enum: ['code-review', 'feature-dev', 'bug-fix', 'optimization', 'research', 'custom']
|
|
1113
|
-
},
|
|
1114
|
-
task: { type: 'string', description: 'Custom task description (for custom workflow)' }
|
|
1115
|
-
},
|
|
1116
|
-
required: ['name']
|
|
1117
|
-
}
|
|
1118
|
-
},
|
|
1119
|
-
{
|
|
1120
|
-
name: 'edge_net_status',
|
|
1121
|
-
description: 'Get Edge-Net network status including connected peers, capacity, active agents, and credits',
|
|
1122
|
-
inputSchema: {
|
|
1123
|
-
type: 'object',
|
|
1124
|
-
properties: {},
|
|
1125
|
-
required: []
|
|
1126
|
-
}
|
|
1127
|
-
},
|
|
1128
|
-
{
|
|
1129
|
-
name: 'agent_execute',
|
|
1130
|
-
description: 'REAL agent execution using local ruvllm (default, no API key), or cloud APIs (Anthropic/OpenAI). Local runs without needing any API key.',
|
|
1131
|
-
inputSchema: {
|
|
1132
|
-
type: 'object',
|
|
1133
|
-
properties: {
|
|
1134
|
-
type: {
|
|
1135
|
-
type: 'string',
|
|
1136
|
-
description: 'Agent type',
|
|
1137
|
-
enum: ['researcher', 'coder', 'reviewer', 'tester', 'analyst', 'optimizer', 'coordinator', 'embedder']
|
|
1138
|
-
},
|
|
1139
|
-
task: { type: 'string', description: 'Task for the agent to execute' },
|
|
1140
|
-
provider: { type: 'string', enum: ['local', 'ruvllm', 'anthropic', 'openai'], default: 'local', description: 'LLM provider (local by default, no API key needed)' },
|
|
1141
|
-
model: { type: 'string', enum: ['fast', 'balanced', 'powerful'], default: 'balanced', description: 'Model tier' },
|
|
1142
|
-
context: { type: 'string', description: 'Additional context for the agent' },
|
|
1143
|
-
max_tokens: { type: 'number', default: 4096, description: 'Maximum tokens in response' }
|
|
1144
|
-
},
|
|
1145
|
-
required: ['type', 'task']
|
|
1146
|
-
}
|
|
1147
|
-
},
|
|
1148
|
-
{
|
|
1149
|
-
name: 'agent_balance',
|
|
1150
|
-
description: 'Get rUv credit balance from relay server with multi-device sync status',
|
|
1151
|
-
inputSchema: {
|
|
1152
|
-
type: 'object',
|
|
1153
|
-
properties: {
|
|
1154
|
-
relay_url: { type: 'string', description: 'Relay server URL', default: 'ws://localhost:8080' }
|
|
1155
|
-
},
|
|
1156
|
-
required: []
|
|
1157
|
-
}
|
|
1158
1048
|
}
|
|
1159
1049
|
];
|
|
1160
1050
|
|
|
@@ -2578,407 +2468,6 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
2578
2468
|
}
|
|
2579
2469
|
}
|
|
2580
2470
|
|
|
2581
|
-
// ============================================
|
|
2582
|
-
// EDGE-NET DISTRIBUTED AGENT/WORKER TOOLS
|
|
2583
|
-
// ============================================
|
|
2584
|
-
|
|
2585
|
-
case 'edge_net_info': {
|
|
2586
|
-
const info = {
|
|
2587
|
-
name: '@ruvector/edge-net',
|
|
2588
|
-
version: '0.1.2',
|
|
2589
|
-
description: 'Distributed AI agent and worker network',
|
|
2590
|
-
capabilities: {
|
|
2591
|
-
agents: ['researcher', 'coder', 'reviewer', 'tester', 'analyst', 'optimizer', 'coordinator', 'embedder'],
|
|
2592
|
-
workers: 'Distributed browser/node worker pools',
|
|
2593
|
-
orchestration: 'Multi-agent task workflows',
|
|
2594
|
-
credits: 'rUv (Resource Utility Vouchers) for compute'
|
|
2595
|
-
},
|
|
2596
|
-
features: [
|
|
2597
|
-
'WebRTC P2P data channels',
|
|
2598
|
-
'QDAG synchronization',
|
|
2599
|
-
'Time Crystal coordination',
|
|
2600
|
-
'Neural DAG attention',
|
|
2601
|
-
'Swarm intelligence'
|
|
2602
|
-
],
|
|
2603
|
-
install: 'npm install @ruvector/edge-net',
|
|
2604
|
-
cli: 'npx edge-net start'
|
|
2605
|
-
};
|
|
2606
|
-
return { content: [{ type: 'text', text: JSON.stringify({ success: true, ...info }, null, 2) }] };
|
|
2607
|
-
}
|
|
2608
|
-
|
|
2609
|
-
case 'edge_net_spawn': {
|
|
2610
|
-
// Input validation
|
|
2611
|
-
const validAgentTypes = ['researcher', 'coder', 'reviewer', 'tester', 'analyst', 'optimizer', 'coordinator', 'embedder'];
|
|
2612
|
-
const validPriorities = ['low', 'medium', 'high', 'critical'];
|
|
2613
|
-
|
|
2614
|
-
const agentType = validAgentTypes.includes(args.type) ? args.type : 'coder';
|
|
2615
|
-
const task = typeof args.task === 'string' ? args.task.slice(0, 1000).trim() : '';
|
|
2616
|
-
const maxRuv = Math.min(Math.max(parseInt(args.max_ruv) || 20, 1), 1000);
|
|
2617
|
-
const priority = validPriorities.includes(args.priority) ? args.priority : 'medium';
|
|
2618
|
-
|
|
2619
|
-
const agentTypes = {
|
|
2620
|
-
researcher: { name: 'Researcher', capabilities: ['search', 'analyze', 'summarize'], baseRuv: 10 },
|
|
2621
|
-
coder: { name: 'Coder', capabilities: ['code', 'refactor', 'debug'], baseRuv: 15 },
|
|
2622
|
-
reviewer: { name: 'Reviewer', capabilities: ['review', 'audit', 'validate'], baseRuv: 12 },
|
|
2623
|
-
tester: { name: 'Tester', capabilities: ['test', 'benchmark', 'validate'], baseRuv: 10 },
|
|
2624
|
-
analyst: { name: 'Analyst', capabilities: ['analyze', 'metrics', 'report'], baseRuv: 8 },
|
|
2625
|
-
optimizer: { name: 'Optimizer', capabilities: ['optimize', 'profile', 'improve'], baseRuv: 15 },
|
|
2626
|
-
coordinator: { name: 'Coordinator', capabilities: ['orchestrate', 'route', 'schedule'], baseRuv: 20 },
|
|
2627
|
-
embedder: { name: 'Embedder', capabilities: ['embed', 'vectorize', 'similarity'], baseRuv: 5 }
|
|
2628
|
-
};
|
|
2629
|
-
|
|
2630
|
-
const typeInfo = agentTypes[agentType] || agentTypes.coder;
|
|
2631
|
-
const agentId = `agent-${agentType}-${Date.now()}-${Math.random().toString(36).substr(2, 6)}`;
|
|
2632
|
-
|
|
2633
|
-
// Simulate agent spawn
|
|
2634
|
-
const result = {
|
|
2635
|
-
success: true,
|
|
2636
|
-
agent: {
|
|
2637
|
-
id: agentId,
|
|
2638
|
-
type: agentType,
|
|
2639
|
-
name: typeInfo.name,
|
|
2640
|
-
capabilities: typeInfo.capabilities,
|
|
2641
|
-
task,
|
|
2642
|
-
priority,
|
|
2643
|
-
maxRuv: parseInt(maxRuv),
|
|
2644
|
-
baseRuv: typeInfo.baseRuv,
|
|
2645
|
-
status: 'spawned',
|
|
2646
|
-
estimatedCost: Math.ceil(typeInfo.baseRuv * (task.length / 100 + 1))
|
|
2647
|
-
},
|
|
2648
|
-
network: {
|
|
2649
|
-
peers: Math.floor(Math.random() * 50) + 10,
|
|
2650
|
-
availableWorkers: Math.floor(Math.random() * 20) + 5
|
|
2651
|
-
},
|
|
2652
|
-
message: `${typeInfo.name} agent spawned on edge-net`
|
|
2653
|
-
};
|
|
2654
|
-
|
|
2655
|
-
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
2656
|
-
}
|
|
2657
|
-
|
|
2658
|
-
case 'edge_net_pool_create': {
|
|
2659
|
-
const poolId = `pool-${Date.now()}-${Math.random().toString(36).substr(2, 6)}`;
|
|
2660
|
-
// Input validation with bounds
|
|
2661
|
-
const minWorkers = Math.min(Math.max(parseInt(args.min_workers) || 2, 1), 50);
|
|
2662
|
-
const maxWorkers = Math.min(Math.max(parseInt(args.max_workers) || 10, minWorkers), 100);
|
|
2663
|
-
|
|
2664
|
-
const result = {
|
|
2665
|
-
success: true,
|
|
2666
|
-
pool: {
|
|
2667
|
-
id: poolId,
|
|
2668
|
-
status: 'created',
|
|
2669
|
-
minWorkers,
|
|
2670
|
-
maxWorkers,
|
|
2671
|
-
currentWorkers: minWorkers,
|
|
2672
|
-
pendingTasks: 0
|
|
2673
|
-
},
|
|
2674
|
-
network: {
|
|
2675
|
-
connectedPeers: Math.floor(Math.random() * 30) + 10,
|
|
2676
|
-
totalCapacity: Math.floor(Math.random() * 100) + 50
|
|
2677
|
-
},
|
|
2678
|
-
message: 'Worker pool created on edge-net'
|
|
2679
|
-
};
|
|
2680
|
-
|
|
2681
|
-
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
2682
|
-
}
|
|
2683
|
-
|
|
2684
|
-
case 'edge_net_pool_execute': {
|
|
2685
|
-
// Input validation
|
|
2686
|
-
const task = typeof args.task === 'string' ? args.task.slice(0, 1000).trim() : '';
|
|
2687
|
-
const poolId = typeof args.pool_id === 'string' ? args.pool_id.replace(/[^a-zA-Z0-9-_]/g, '').slice(0, 50) : null;
|
|
2688
|
-
|
|
2689
|
-
if (!task) {
|
|
2690
|
-
return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: 'Task is required' }, null, 2) }] };
|
|
2691
|
-
}
|
|
2692
|
-
|
|
2693
|
-
const taskId = `task-${Date.now()}-${Math.random().toString(36).substr(2, 6)}`;
|
|
2694
|
-
const result = {
|
|
2695
|
-
success: true,
|
|
2696
|
-
execution: {
|
|
2697
|
-
taskId,
|
|
2698
|
-
task,
|
|
2699
|
-
poolId: poolId || 'auto-assigned',
|
|
2700
|
-
status: 'queued',
|
|
2701
|
-
workersAssigned: Math.floor(Math.random() * 5) + 1,
|
|
2702
|
-
estimatedDuration: `${Math.floor(Math.random() * 30) + 5}s`,
|
|
2703
|
-
estimatedRuv: Math.floor(Math.random() * 10) + 3
|
|
2704
|
-
},
|
|
2705
|
-
message: 'Task queued for distributed execution'
|
|
2706
|
-
};
|
|
2707
|
-
|
|
2708
|
-
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
2709
|
-
}
|
|
2710
|
-
|
|
2711
|
-
case 'edge_net_workflow': {
|
|
2712
|
-
// Input validation
|
|
2713
|
-
const validWorkflows = ['code-review', 'feature-dev', 'bug-fix', 'optimization', 'research', 'custom'];
|
|
2714
|
-
const name = validWorkflows.includes(args.name) ? args.name : 'custom';
|
|
2715
|
-
const task = typeof args.task === 'string' ? args.task.slice(0, 1000).trim() : '';
|
|
2716
|
-
|
|
2717
|
-
const workflows = {
|
|
2718
|
-
'code-review': {
|
|
2719
|
-
steps: [
|
|
2720
|
-
{ agent: 'analyst', action: 'Analyze code structure' },
|
|
2721
|
-
{ agent: 'reviewer', action: 'Security and quality review' },
|
|
2722
|
-
{ agent: 'tester', action: 'Run test coverage analysis' },
|
|
2723
|
-
{ agent: 'optimizer', action: 'Suggest optimizations' }
|
|
2724
|
-
],
|
|
2725
|
-
estimatedRuv: 45
|
|
2726
|
-
},
|
|
2727
|
-
'feature-dev': {
|
|
2728
|
-
steps: [
|
|
2729
|
-
{ agent: 'researcher', action: 'Research requirements' },
|
|
2730
|
-
{ agent: 'coder', action: 'Implement feature' },
|
|
2731
|
-
{ agent: 'tester', action: 'Write and run tests' },
|
|
2732
|
-
{ agent: 'reviewer', action: 'Code review' }
|
|
2733
|
-
],
|
|
2734
|
-
estimatedRuv: 60
|
|
2735
|
-
},
|
|
2736
|
-
'bug-fix': {
|
|
2737
|
-
steps: [
|
|
2738
|
-
{ agent: 'analyst', action: 'Analyze bug report' },
|
|
2739
|
-
{ agent: 'coder', action: 'Implement fix' },
|
|
2740
|
-
{ agent: 'tester', action: 'Verify fix' }
|
|
2741
|
-
],
|
|
2742
|
-
estimatedRuv: 35
|
|
2743
|
-
},
|
|
2744
|
-
'optimization': {
|
|
2745
|
-
steps: [
|
|
2746
|
-
{ agent: 'analyst', action: 'Profile performance' },
|
|
2747
|
-
{ agent: 'optimizer', action: 'Identify bottlenecks' },
|
|
2748
|
-
{ agent: 'coder', action: 'Apply optimizations' },
|
|
2749
|
-
{ agent: 'tester', action: 'Benchmark results' }
|
|
2750
|
-
],
|
|
2751
|
-
estimatedRuv: 50
|
|
2752
|
-
},
|
|
2753
|
-
'research': {
|
|
2754
|
-
steps: [
|
|
2755
|
-
{ agent: 'researcher', action: 'Deep research' },
|
|
2756
|
-
{ agent: 'analyst', action: 'Analyze findings' },
|
|
2757
|
-
{ agent: 'embedder', action: 'Create knowledge embeddings' }
|
|
2758
|
-
],
|
|
2759
|
-
estimatedRuv: 30
|
|
2760
|
-
}
|
|
2761
|
-
};
|
|
2762
|
-
|
|
2763
|
-
const workflow = workflows[name] || {
|
|
2764
|
-
steps: [{ agent: 'coordinator', action: task || 'Custom task' }],
|
|
2765
|
-
estimatedRuv: 20
|
|
2766
|
-
};
|
|
2767
|
-
|
|
2768
|
-
const workflowId = `workflow-${name}-${Date.now()}`;
|
|
2769
|
-
|
|
2770
|
-
const result = {
|
|
2771
|
-
success: true,
|
|
2772
|
-
workflow: {
|
|
2773
|
-
id: workflowId,
|
|
2774
|
-
name,
|
|
2775
|
-
status: 'initiated',
|
|
2776
|
-
steps: workflow.steps.map((s, i) => ({
|
|
2777
|
-
step: i + 1,
|
|
2778
|
-
agent: s.agent,
|
|
2779
|
-
action: s.action,
|
|
2780
|
-
status: i === 0 ? 'in_progress' : 'pending'
|
|
2781
|
-
})),
|
|
2782
|
-
totalSteps: workflow.steps.length,
|
|
2783
|
-
estimatedRuv: workflow.estimatedRuv
|
|
2784
|
-
},
|
|
2785
|
-
message: `Multi-agent workflow '${name}' initiated`
|
|
2786
|
-
};
|
|
2787
|
-
|
|
2788
|
-
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
2789
|
-
}
|
|
2790
|
-
|
|
2791
|
-
case 'edge_net_status': {
|
|
2792
|
-
const status = {
|
|
2793
|
-
success: true,
|
|
2794
|
-
network: {
|
|
2795
|
-
status: 'online',
|
|
2796
|
-
connectedPeers: Math.floor(Math.random() * 100) + 20,
|
|
2797
|
-
totalCapacity: Math.floor(Math.random() * 500) + 100,
|
|
2798
|
-
activeAgents: Math.floor(Math.random() * 15) + 2,
|
|
2799
|
-
pendingTasks: Math.floor(Math.random() * 10),
|
|
2800
|
-
completedTasks24h: Math.floor(Math.random() * 200) + 50
|
|
2801
|
-
},
|
|
2802
|
-
credits: {
|
|
2803
|
-
balance: Math.floor(Math.random() * 1000) + 100,
|
|
2804
|
-
earned24h: Math.floor(Math.random() * 50) + 5,
|
|
2805
|
-
spent24h: Math.floor(Math.random() * 30) + 2
|
|
2806
|
-
},
|
|
2807
|
-
nodes: {
|
|
2808
|
-
genesis: 3,
|
|
2809
|
-
regions: ['us-central1', 'europe-west1', 'asia-east1'],
|
|
2810
|
-
p2pConnections: Math.floor(Math.random() * 50) + 10
|
|
2811
|
-
},
|
|
2812
|
-
webrtc: {
|
|
2813
|
-
dataChannelsActive: Math.floor(Math.random() * 20) + 5,
|
|
2814
|
-
avgLatency: `${Math.floor(Math.random() * 50) + 10}ms`
|
|
2815
|
-
}
|
|
2816
|
-
};
|
|
2817
|
-
|
|
2818
|
-
return { content: [{ type: 'text', text: JSON.stringify(status, null, 2) }] };
|
|
2819
|
-
}
|
|
2820
|
-
|
|
2821
|
-
case 'agent_execute': {
|
|
2822
|
-
// REAL agent execution with local ruvllm by default, or cloud APIs
|
|
2823
|
-
const validTypes = ['researcher', 'coder', 'reviewer', 'tester', 'analyst', 'optimizer', 'coordinator', 'embedder'];
|
|
2824
|
-
const validModels = ['fast', 'balanced', 'powerful'];
|
|
2825
|
-
|
|
2826
|
-
const agentType = validTypes.includes(args.type) ? args.type : 'coder';
|
|
2827
|
-
const task = typeof args.task === 'string' ? args.task.slice(0, 10000).trim() : '';
|
|
2828
|
-
const model = validModels.includes(args.model) ? args.model : 'balanced';
|
|
2829
|
-
const maxTokens = Math.min(Math.max(parseInt(args.max_tokens) || 4096, 100), 8192);
|
|
2830
|
-
|
|
2831
|
-
// Determine provider (local by default)
|
|
2832
|
-
const provider = args.provider || 'local';
|
|
2833
|
-
const isLocal = provider === 'local' || provider === 'ruvllm';
|
|
2834
|
-
|
|
2835
|
-
// Check for API key (only required for cloud providers)
|
|
2836
|
-
const apiKey = process.env.ANTHROPIC_API_KEY || process.env.OPENAI_API_KEY;
|
|
2837
|
-
if (!isLocal && !apiKey && agentType !== 'embedder') {
|
|
2838
|
-
return {
|
|
2839
|
-
content: [{
|
|
2840
|
-
type: 'text',
|
|
2841
|
-
text: JSON.stringify({
|
|
2842
|
-
success: false,
|
|
2843
|
-
error: 'No API key configured for cloud provider',
|
|
2844
|
-
message: 'Set ANTHROPIC_API_KEY or OPENAI_API_KEY, or use local provider (default)',
|
|
2845
|
-
options: {
|
|
2846
|
-
local: 'Use provider=local (no API key needed)',
|
|
2847
|
-
anthropic: 'https://console.anthropic.com/',
|
|
2848
|
-
openai: 'https://platform.openai.com/api-keys'
|
|
2849
|
-
}
|
|
2850
|
-
}, null, 2)
|
|
2851
|
-
}],
|
|
2852
|
-
isError: true
|
|
2853
|
-
};
|
|
2854
|
-
}
|
|
2855
|
-
|
|
2856
|
-
try {
|
|
2857
|
-
// Try to load real-agents module
|
|
2858
|
-
let RealAgentManager;
|
|
2859
|
-
try {
|
|
2860
|
-
const realAgents = await import('@ruvector/edge-net/real-agents');
|
|
2861
|
-
RealAgentManager = realAgents.RealAgentManager;
|
|
2862
|
-
} catch (e) {
|
|
2863
|
-
// Fallback to local path for development
|
|
2864
|
-
const realAgentsPath = path.resolve(__dirname, '../../../../examples/edge-net/pkg/real-agents.js');
|
|
2865
|
-
const realAgents = await import(realAgentsPath);
|
|
2866
|
-
RealAgentManager = realAgents.RealAgentManager;
|
|
2867
|
-
}
|
|
2868
|
-
|
|
2869
|
-
// Initialize manager with selected provider
|
|
2870
|
-
const manager = new RealAgentManager({
|
|
2871
|
-
provider: isLocal ? 'local' : (apiKey && process.env.ANTHROPIC_API_KEY ? 'anthropic' : 'openai'),
|
|
2872
|
-
apiKey: isLocal ? undefined : apiKey,
|
|
2873
|
-
});
|
|
2874
|
-
await manager.initialize();
|
|
2875
|
-
|
|
2876
|
-
// Spawn and execute
|
|
2877
|
-
const effectiveProvider = isLocal ? 'local' : (apiKey && process.env.ANTHROPIC_API_KEY ? 'anthropic' : 'openai');
|
|
2878
|
-
const agent = await manager.spawn(agentType, { provider: effectiveProvider, model });
|
|
2879
|
-
|
|
2880
|
-
const context = {
|
|
2881
|
-
model,
|
|
2882
|
-
additionalContext: args.context,
|
|
2883
|
-
maxTokens,
|
|
2884
|
-
};
|
|
2885
|
-
|
|
2886
|
-
const startTime = Date.now();
|
|
2887
|
-
const result = await agent.execute(task, context);
|
|
2888
|
-
const duration = Date.now() - startTime;
|
|
2889
|
-
|
|
2890
|
-
await manager.close();
|
|
2891
|
-
|
|
2892
|
-
return {
|
|
2893
|
-
content: [{
|
|
2894
|
-
type: 'text',
|
|
2895
|
-
text: JSON.stringify({
|
|
2896
|
-
success: true,
|
|
2897
|
-
real_execution: true,
|
|
2898
|
-
local_mode: isLocal,
|
|
2899
|
-
agent: {
|
|
2900
|
-
id: agent.id,
|
|
2901
|
-
type: agentType,
|
|
2902
|
-
provider: effectiveProvider,
|
|
2903
|
-
model: result.model || (isLocal ? 'ruvllm-balanced' : model)
|
|
2904
|
-
},
|
|
2905
|
-
execution: {
|
|
2906
|
-
duration_ms: duration,
|
|
2907
|
-
tokens: agent.cost,
|
|
2908
|
-
fallback: result.fallback || false
|
|
2909
|
-
},
|
|
2910
|
-
response: result.content
|
|
2911
|
-
}, null, 2)
|
|
2912
|
-
}]
|
|
2913
|
-
};
|
|
2914
|
-
|
|
2915
|
-
} catch (execError) {
|
|
2916
|
-
return {
|
|
2917
|
-
content: [{
|
|
2918
|
-
type: 'text',
|
|
2919
|
-
text: JSON.stringify({
|
|
2920
|
-
success: false,
|
|
2921
|
-
error: execError.message,
|
|
2922
|
-
real_execution: true,
|
|
2923
|
-
hint: execError.message.includes('401') ? 'Check your API key is valid' : 'Check error message for details'
|
|
2924
|
-
}, null, 2)
|
|
2925
|
-
}],
|
|
2926
|
-
isError: true
|
|
2927
|
-
};
|
|
2928
|
-
}
|
|
2929
|
-
}
|
|
2930
|
-
|
|
2931
|
-
case 'agent_balance': {
|
|
2932
|
-
const relayUrl = args.relay_url || 'ws://localhost:8080';
|
|
2933
|
-
|
|
2934
|
-
try {
|
|
2935
|
-
// Try to load real-agents module
|
|
2936
|
-
let RelaySyncClient;
|
|
2937
|
-
try {
|
|
2938
|
-
const realAgents = await import('@ruvector/edge-net/real-agents');
|
|
2939
|
-
RelaySyncClient = realAgents.RelaySyncClient;
|
|
2940
|
-
} catch (e) {
|
|
2941
|
-
const realAgentsPath = path.resolve(__dirname, '../../../../examples/edge-net/pkg/real-agents.js');
|
|
2942
|
-
const realAgents = await import(realAgentsPath);
|
|
2943
|
-
RelaySyncClient = realAgents.RelaySyncClient;
|
|
2944
|
-
}
|
|
2945
|
-
|
|
2946
|
-
const client = new RelaySyncClient({ relayUrl });
|
|
2947
|
-
|
|
2948
|
-
await Promise.race([
|
|
2949
|
-
client.connect(),
|
|
2950
|
-
new Promise((_, reject) => setTimeout(() => reject(new Error('Connection timeout')), 5000)),
|
|
2951
|
-
]);
|
|
2952
|
-
|
|
2953
|
-
const balance = {
|
|
2954
|
-
success: true,
|
|
2955
|
-
balance: client.getBalance(),
|
|
2956
|
-
nodeId: client.nodeId,
|
|
2957
|
-
relayUrl,
|
|
2958
|
-
connected: true,
|
|
2959
|
-
ledgerState: client.ledgerState
|
|
2960
|
-
};
|
|
2961
|
-
|
|
2962
|
-
client.close();
|
|
2963
|
-
|
|
2964
|
-
return { content: [{ type: 'text', text: JSON.stringify(balance, null, 2) }] };
|
|
2965
|
-
|
|
2966
|
-
} catch (connError) {
|
|
2967
|
-
return {
|
|
2968
|
-
content: [{
|
|
2969
|
-
type: 'text',
|
|
2970
|
-
text: JSON.stringify({
|
|
2971
|
-
success: false,
|
|
2972
|
-
error: connError.message,
|
|
2973
|
-
relayUrl,
|
|
2974
|
-
hint: 'Start the relay server: cd examples/edge-net/relay && node index.js'
|
|
2975
|
-
}, null, 2)
|
|
2976
|
-
}],
|
|
2977
|
-
isError: true
|
|
2978
|
-
};
|
|
2979
|
-
}
|
|
2980
|
-
}
|
|
2981
|
-
|
|
2982
2471
|
default:
|
|
2983
2472
|
return {
|
|
2984
2473
|
content: [{
|
package/dist/core/index.d.ts
CHANGED
|
@@ -25,7 +25,6 @@ export * from './learning-engine';
|
|
|
25
25
|
export * from './adaptive-embedder';
|
|
26
26
|
export * from './neural-embeddings';
|
|
27
27
|
export * from './neural-perf';
|
|
28
|
-
export * from './onnx-llm';
|
|
29
28
|
export * from '../analysis';
|
|
30
29
|
export { default as gnnWrapper } from './gnn-wrapper';
|
|
31
30
|
export { default as attentionFallbacks } from './attention-fallbacks';
|
|
@@ -45,5 +44,4 @@ export { default as TensorCompress } from './tensor-compress';
|
|
|
45
44
|
export { default as LearningEngine } from './learning-engine';
|
|
46
45
|
export { default as AdaptiveEmbedder } from './adaptive-embedder';
|
|
47
46
|
export { default as NeuralSubstrate } from './neural-embeddings';
|
|
48
|
-
export { default as OnnxLLM } from './onnx-llm';
|
|
49
47
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAG9B,cAAc,aAAa,CAAC;AAG5B,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AAGvD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/core/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.NeuralSubstrate = exports.AdaptiveEmbedder = exports.LearningEngine = exports.TensorCompress = exports.ASTParser = exports.CodeParser = exports.RuvectorCluster = exports.CodeGraph = exports.SemanticRouter = exports.ExtendedWorkerPool = exports.ParallelIntelligence = exports.OptimizedOnnxEmbedder = exports.OnnxEmbedder = exports.IntelligenceEngine = exports.Sona = exports.agentdbFast = exports.attentionFallbacks = exports.gnnWrapper = void 0;
|
|
27
27
|
__exportStar(require("./gnn-wrapper"), exports);
|
|
28
28
|
__exportStar(require("./attention-fallbacks"), exports);
|
|
29
29
|
__exportStar(require("./agentdb-fast"), exports);
|
|
@@ -45,7 +45,6 @@ __exportStar(require("./learning-engine"), exports);
|
|
|
45
45
|
__exportStar(require("./adaptive-embedder"), exports);
|
|
46
46
|
__exportStar(require("./neural-embeddings"), exports);
|
|
47
47
|
__exportStar(require("./neural-perf"), exports);
|
|
48
|
-
__exportStar(require("./onnx-llm"), exports);
|
|
49
48
|
// Analysis module (consolidated security, complexity, patterns)
|
|
50
49
|
__exportStar(require("../analysis"), exports);
|
|
51
50
|
// Re-export default objects for convenience
|
|
@@ -87,5 +86,3 @@ var adaptive_embedder_1 = require("./adaptive-embedder");
|
|
|
87
86
|
Object.defineProperty(exports, "AdaptiveEmbedder", { enumerable: true, get: function () { return __importDefault(adaptive_embedder_1).default; } });
|
|
88
87
|
var neural_embeddings_1 = require("./neural-embeddings");
|
|
89
88
|
Object.defineProperty(exports, "NeuralSubstrate", { enumerable: true, get: function () { return __importDefault(neural_embeddings_1).default; } });
|
|
90
|
-
var onnx_llm_1 = require("./onnx-llm");
|
|
91
|
-
Object.defineProperty(exports, "OnnxLLM", { enumerable: true, get: function () { return __importDefault(onnx_llm_1).default; } });
|
|
@@ -12,26 +12,6 @@
|
|
|
12
12
|
* - Cached model loading (downloads from HuggingFace on first use)
|
|
13
13
|
* - Batch embedding support
|
|
14
14
|
* - Optional parallel workers for 3.8x batch speedup
|
|
15
|
-
* - CommonJS-compatible: No --experimental-wasm-modules flag required
|
|
16
|
-
*
|
|
17
|
-
* Quick Start (Simple API - returns arrays directly):
|
|
18
|
-
* ```javascript
|
|
19
|
-
* const { embedText, embedTexts } = require('ruvector');
|
|
20
|
-
*
|
|
21
|
-
* // Single embedding - returns number[]
|
|
22
|
-
* const vector = await embedText("hello world");
|
|
23
|
-
*
|
|
24
|
-
* // Batch embeddings - returns number[][]
|
|
25
|
-
* const vectors = await embedTexts(["hello", "world"]);
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* Full API (returns metadata):
|
|
29
|
-
* ```javascript
|
|
30
|
-
* const { embed, embedBatch } = require('ruvector');
|
|
31
|
-
*
|
|
32
|
-
* // Returns { embedding: number[], dimension: number, timeMs: number }
|
|
33
|
-
* const result = await embed("hello world");
|
|
34
|
-
* ```
|
|
35
15
|
*/
|
|
36
16
|
declare global {
|
|
37
17
|
var __ruvector_require: NodeRequire | undefined;
|
|
@@ -79,70 +59,6 @@ export declare function embed(text: string): Promise<EmbeddingResult>;
|
|
|
79
59
|
* Uses parallel workers automatically for batches >= parallelThreshold
|
|
80
60
|
*/
|
|
81
61
|
export declare function embedBatch(texts: string[]): Promise<EmbeddingResult[]>;
|
|
82
|
-
/**
|
|
83
|
-
* ============================================================================
|
|
84
|
-
* SIMPLE API - Returns arrays directly (for easy integration)
|
|
85
|
-
* ============================================================================
|
|
86
|
-
*/
|
|
87
|
-
/**
|
|
88
|
-
* Generate embedding for a single text - returns array directly
|
|
89
|
-
*
|
|
90
|
-
* This is the simplified API that returns just the embedding array,
|
|
91
|
-
* making it easy to use for vector operations, PostgreSQL insertion,
|
|
92
|
-
* and similarity calculations.
|
|
93
|
-
*
|
|
94
|
-
* @param text - The text to embed
|
|
95
|
-
* @returns A 384-dimensional embedding array
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* ```javascript
|
|
99
|
-
* const { embedText } = require('ruvector');
|
|
100
|
-
*
|
|
101
|
-
* const vector = await embedText("hello world");
|
|
102
|
-
* console.log(vector.length); // 384
|
|
103
|
-
* console.log(Array.isArray(vector)); // true
|
|
104
|
-
*
|
|
105
|
-
* // Use directly with PostgreSQL
|
|
106
|
-
* await pool.query(
|
|
107
|
-
* 'INSERT INTO docs (content, embedding) VALUES ($1, $2)',
|
|
108
|
-
* [text, JSON.stringify(vector)]
|
|
109
|
-
* );
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
export declare function embedText(text: string): Promise<number[]>;
|
|
113
|
-
/**
|
|
114
|
-
* Generate embeddings for multiple texts - returns array of arrays
|
|
115
|
-
*
|
|
116
|
-
* This is the simplified batch API that returns just the embedding arrays.
|
|
117
|
-
* Uses optimized batch processing for much faster throughput than
|
|
118
|
-
* calling embedText() in a loop.
|
|
119
|
-
*
|
|
120
|
-
* @param texts - Array of texts to embed
|
|
121
|
-
* @param options - Optional batch processing options
|
|
122
|
-
* @returns Array of 384-dimensional embedding arrays
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```javascript
|
|
126
|
-
* const { embedTexts } = require('ruvector');
|
|
127
|
-
*
|
|
128
|
-
* // Batch embed 8000 documents in ~30 seconds (vs 53 min sequentially)
|
|
129
|
-
* const vectors = await embedTexts(documents);
|
|
130
|
-
*
|
|
131
|
-
* // With options for very large batches
|
|
132
|
-
* const vectors = await embedTexts(documents, { batchSize: 256 });
|
|
133
|
-
*
|
|
134
|
-
* // Bulk insert into PostgreSQL
|
|
135
|
-
* for (let i = 0; i < documents.length; i++) {
|
|
136
|
-
* await pool.query(
|
|
137
|
-
* 'INSERT INTO docs (content, embedding) VALUES ($1, $2)',
|
|
138
|
-
* [documents[i], JSON.stringify(vectors[i])]
|
|
139
|
-
* );
|
|
140
|
-
* }
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
|
-
export declare function embedTexts(texts: string[], options?: {
|
|
144
|
-
batchSize?: number;
|
|
145
|
-
}): Promise<number[][]>;
|
|
146
62
|
/**
|
|
147
63
|
* Calculate cosine similarity between two texts
|
|
148
64
|
*/
|