ruvector 0.1.94 → 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/pkg/ruvector_onnx_embeddings_wasm_cjs.js +127 -0
- package/package.json +1 -2
package/bin/cli.js
CHANGED
|
@@ -7007,825 +7007,6 @@ nativeCmd.command('compare')
|
|
|
7007
7007
|
}
|
|
7008
7008
|
});
|
|
7009
7009
|
|
|
7010
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
7011
|
-
// Edge-Net Commands - Distributed Agent/Worker Network
|
|
7012
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
7013
|
-
|
|
7014
|
-
const edgeNetCmd = program.command('edge-net').description('Distributed AI agent/worker network');
|
|
7015
|
-
|
|
7016
|
-
// Edge-net info
|
|
7017
|
-
edgeNetCmd.command('info')
|
|
7018
|
-
.description('Show Edge-Net information and capabilities')
|
|
7019
|
-
.action(() => {
|
|
7020
|
-
console.log(chalk.bold.cyan('\n🌐 Edge-Net: Distributed AI Agent Network\n'));
|
|
7021
|
-
console.log(chalk.white('Spawn AI agents and workers across the collective compute network.'));
|
|
7022
|
-
console.log(chalk.white('Contribute idle compute, earn rUv credits, run distributed workloads.\n'));
|
|
7023
|
-
|
|
7024
|
-
console.log(chalk.bold('Agent Types:'));
|
|
7025
|
-
console.log(chalk.dim(' researcher - Analyzes and researches information'));
|
|
7026
|
-
console.log(chalk.dim(' coder - Writes and improves code'));
|
|
7027
|
-
console.log(chalk.dim(' reviewer - Reviews code and provides feedback'));
|
|
7028
|
-
console.log(chalk.dim(' tester - Tests and validates implementations'));
|
|
7029
|
-
console.log(chalk.dim(' analyst - Analyzes data and generates reports'));
|
|
7030
|
-
console.log(chalk.dim(' optimizer - Optimizes performance and efficiency'));
|
|
7031
|
-
console.log(chalk.dim(' coordinator - Coordinates multi-agent workflows'));
|
|
7032
|
-
console.log(chalk.dim(' embedder - Generates embeddings and vector ops'));
|
|
7033
|
-
|
|
7034
|
-
console.log(chalk.bold('\nCommands:'));
|
|
7035
|
-
console.log(chalk.dim(' ruvector edge-net spawn <type> "<task>" - Spawn an agent'));
|
|
7036
|
-
console.log(chalk.dim(' ruvector edge-net pool create - Create worker pool'));
|
|
7037
|
-
console.log(chalk.dim(' ruvector edge-net pool execute - Execute on pool'));
|
|
7038
|
-
console.log(chalk.dim(' ruvector edge-net workflow run - Run a workflow'));
|
|
7039
|
-
console.log(chalk.dim(' ruvector edge-net status - Show network status'));
|
|
7040
|
-
|
|
7041
|
-
console.log(chalk.bold.yellow('\n📦 Install Edge-Net package:'));
|
|
7042
|
-
console.log(chalk.cyan(' npm install @ruvector/edge-net\n'));
|
|
7043
|
-
});
|
|
7044
|
-
|
|
7045
|
-
// Spawn agent
|
|
7046
|
-
edgeNetCmd.command('spawn')
|
|
7047
|
-
.description('Spawn a distributed AI agent')
|
|
7048
|
-
.argument('<type>', 'Agent type (researcher, coder, reviewer, tester, analyst, optimizer)')
|
|
7049
|
-
.argument('<task>', 'Task description for the agent')
|
|
7050
|
-
.option('--max-ruv <amount>', 'Maximum rUv to spend', '20')
|
|
7051
|
-
.option('--priority <level>', 'Priority (low, medium, high, critical)', 'medium')
|
|
7052
|
-
.option('--timeout <ms>', 'Timeout in milliseconds', '300000')
|
|
7053
|
-
.option('--json', 'Output as JSON')
|
|
7054
|
-
.action(async (type, task, opts) => {
|
|
7055
|
-
const spinner = ora('Spawning agent...').start();
|
|
7056
|
-
|
|
7057
|
-
try {
|
|
7058
|
-
// Try to load edge-net
|
|
7059
|
-
let edgeNet;
|
|
7060
|
-
try {
|
|
7061
|
-
edgeNet = require('@ruvector/edge-net/agents.js');
|
|
7062
|
-
} catch (e) {
|
|
7063
|
-
// Use inline implementation if package not available
|
|
7064
|
-
const agentTypes = {
|
|
7065
|
-
researcher: { name: 'Researcher', baseRuv: 10 },
|
|
7066
|
-
coder: { name: 'Coder', baseRuv: 15 },
|
|
7067
|
-
reviewer: { name: 'Reviewer', baseRuv: 12 },
|
|
7068
|
-
tester: { name: 'Tester', baseRuv: 10 },
|
|
7069
|
-
analyst: { name: 'Analyst', baseRuv: 8 },
|
|
7070
|
-
optimizer: { name: 'Optimizer', baseRuv: 15 },
|
|
7071
|
-
coordinator: { name: 'Coordinator', baseRuv: 20 },
|
|
7072
|
-
embedder: { name: 'Embedder', baseRuv: 5 },
|
|
7073
|
-
};
|
|
7074
|
-
|
|
7075
|
-
if (!agentTypes[type]) {
|
|
7076
|
-
spinner.fail(`Unknown agent type: ${type}`);
|
|
7077
|
-
console.log(chalk.dim('Available: researcher, coder, reviewer, tester, analyst, optimizer, coordinator, embedder'));
|
|
7078
|
-
return;
|
|
7079
|
-
}
|
|
7080
|
-
|
|
7081
|
-
const agentId = `agent-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
7082
|
-
const agentConfig = agentTypes[type];
|
|
7083
|
-
|
|
7084
|
-
spinner.succeed(`Agent spawned: ${agentId}`);
|
|
7085
|
-
|
|
7086
|
-
const result = {
|
|
7087
|
-
agentId,
|
|
7088
|
-
type,
|
|
7089
|
-
name: agentConfig.name,
|
|
7090
|
-
task,
|
|
7091
|
-
maxRuv: parseInt(opts.maxRuv) || agentConfig.baseRuv,
|
|
7092
|
-
priority: opts.priority,
|
|
7093
|
-
status: 'queued',
|
|
7094
|
-
message: 'Agent queued for execution. Install @ruvector/edge-net for full distributed execution.',
|
|
7095
|
-
};
|
|
7096
|
-
|
|
7097
|
-
if (opts.json) {
|
|
7098
|
-
console.log(JSON.stringify(result, null, 2));
|
|
7099
|
-
} else {
|
|
7100
|
-
console.log(chalk.bold(`\n${chalk.cyan('Agent ID:')} ${result.agentId}`));
|
|
7101
|
-
console.log(`${chalk.cyan('Type:')} ${result.name} (${type})`);
|
|
7102
|
-
console.log(`${chalk.cyan('Task:')} ${task}`);
|
|
7103
|
-
console.log(`${chalk.cyan('Max rUv:')} ${result.maxRuv}`);
|
|
7104
|
-
console.log(`${chalk.cyan('Priority:')} ${result.priority}`);
|
|
7105
|
-
console.log(`${chalk.cyan('Status:')} ${chalk.yellow(result.status)}`);
|
|
7106
|
-
console.log(chalk.dim(`\nTip: npm install @ruvector/edge-net for distributed execution\n`));
|
|
7107
|
-
}
|
|
7108
|
-
return;
|
|
7109
|
-
}
|
|
7110
|
-
|
|
7111
|
-
// Use edge-net package if available
|
|
7112
|
-
const { AgentSpawner, AGENT_TYPES } = edgeNet;
|
|
7113
|
-
|
|
7114
|
-
if (!AGENT_TYPES[type]) {
|
|
7115
|
-
spinner.fail(`Unknown agent type: ${type}`);
|
|
7116
|
-
console.log(chalk.dim('Available: ' + Object.keys(AGENT_TYPES).join(', ')));
|
|
7117
|
-
return;
|
|
7118
|
-
}
|
|
7119
|
-
|
|
7120
|
-
const spawner = new AgentSpawner(null, {});
|
|
7121
|
-
const agent = await spawner.spawn({
|
|
7122
|
-
type,
|
|
7123
|
-
task,
|
|
7124
|
-
maxRuv: parseInt(opts.maxRuv),
|
|
7125
|
-
priority: opts.priority,
|
|
7126
|
-
timeout: parseInt(opts.timeout),
|
|
7127
|
-
});
|
|
7128
|
-
|
|
7129
|
-
spinner.succeed(`Agent spawned: ${agent.id}`);
|
|
7130
|
-
|
|
7131
|
-
if (opts.json) {
|
|
7132
|
-
console.log(JSON.stringify(agent.getInfo(), null, 2));
|
|
7133
|
-
} else {
|
|
7134
|
-
console.log(chalk.bold(`\n${chalk.cyan('Agent ID:')} ${agent.id}`));
|
|
7135
|
-
console.log(`${chalk.cyan('Type:')} ${agent.config.name} (${type})`);
|
|
7136
|
-
console.log(`${chalk.cyan('Task:')} ${task}`);
|
|
7137
|
-
console.log(`${chalk.cyan('Max rUv:')} ${agent.maxRuv}`);
|
|
7138
|
-
console.log(`${chalk.cyan('Status:')} ${chalk.green(agent.status)}`);
|
|
7139
|
-
console.log();
|
|
7140
|
-
}
|
|
7141
|
-
|
|
7142
|
-
} catch (e) {
|
|
7143
|
-
spinner.fail(`Failed to spawn agent: ${e.message}`);
|
|
7144
|
-
}
|
|
7145
|
-
});
|
|
7146
|
-
|
|
7147
|
-
// Worker pool commands
|
|
7148
|
-
const poolCmd = edgeNetCmd.command('pool').description('Worker pool management');
|
|
7149
|
-
|
|
7150
|
-
poolCmd.command('create')
|
|
7151
|
-
.description('Create a distributed worker pool')
|
|
7152
|
-
.option('--size <n>', 'Number of workers', '5')
|
|
7153
|
-
.option('--capabilities <list>', 'Comma-separated capabilities', 'compute,embed,analyze')
|
|
7154
|
-
.option('--json', 'Output as JSON')
|
|
7155
|
-
.action(async (opts) => {
|
|
7156
|
-
const spinner = ora('Creating worker pool...').start();
|
|
7157
|
-
|
|
7158
|
-
try {
|
|
7159
|
-
const poolId = `pool-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`;
|
|
7160
|
-
const capabilities = opts.capabilities.split(',').map(c => c.trim());
|
|
7161
|
-
|
|
7162
|
-
spinner.succeed(`Worker pool created: ${poolId}`);
|
|
7163
|
-
|
|
7164
|
-
const result = {
|
|
7165
|
-
poolId,
|
|
7166
|
-
size: parseInt(opts.size),
|
|
7167
|
-
capabilities,
|
|
7168
|
-
status: 'ready',
|
|
7169
|
-
workers: parseInt(opts.size),
|
|
7170
|
-
idleWorkers: parseInt(opts.size),
|
|
7171
|
-
};
|
|
7172
|
-
|
|
7173
|
-
if (opts.json) {
|
|
7174
|
-
console.log(JSON.stringify(result, null, 2));
|
|
7175
|
-
} else {
|
|
7176
|
-
console.log(chalk.bold(`\n${chalk.cyan('Pool ID:')} ${result.poolId}`));
|
|
7177
|
-
console.log(`${chalk.cyan('Size:')} ${result.size} workers`);
|
|
7178
|
-
console.log(`${chalk.cyan('Capabilities:')} ${capabilities.join(', ')}`);
|
|
7179
|
-
console.log(`${chalk.cyan('Status:')} ${chalk.green(result.status)}`);
|
|
7180
|
-
console.log();
|
|
7181
|
-
}
|
|
7182
|
-
|
|
7183
|
-
} catch (e) {
|
|
7184
|
-
spinner.fail(`Failed to create pool: ${e.message}`);
|
|
7185
|
-
}
|
|
7186
|
-
});
|
|
7187
|
-
|
|
7188
|
-
poolCmd.command('execute')
|
|
7189
|
-
.description('Execute task on worker pool')
|
|
7190
|
-
.argument('<task>', 'Task type (embed, process, analyze)')
|
|
7191
|
-
.option('--data <json>', 'Input data as JSON', '[]')
|
|
7192
|
-
.option('--strategy <type>', 'Execution strategy (parallel, sequential, race)', 'parallel')
|
|
7193
|
-
.option('--json', 'Output as JSON')
|
|
7194
|
-
.action(async (task, opts) => {
|
|
7195
|
-
const spinner = ora(`Executing ${task}...`).start();
|
|
7196
|
-
|
|
7197
|
-
try {
|
|
7198
|
-
let data;
|
|
7199
|
-
try {
|
|
7200
|
-
data = JSON.parse(opts.data);
|
|
7201
|
-
} catch (e) {
|
|
7202
|
-
data = [opts.data];
|
|
7203
|
-
}
|
|
7204
|
-
|
|
7205
|
-
const startTime = Date.now();
|
|
7206
|
-
|
|
7207
|
-
// Simulate execution
|
|
7208
|
-
let result;
|
|
7209
|
-
switch (task) {
|
|
7210
|
-
case 'embed':
|
|
7211
|
-
result = (Array.isArray(data) ? data : [data]).map(() =>
|
|
7212
|
-
new Array(384).fill(0).map(() => Math.random().toFixed(6))
|
|
7213
|
-
);
|
|
7214
|
-
break;
|
|
7215
|
-
case 'process':
|
|
7216
|
-
result = (Array.isArray(data) ? data : [data]).map(item => ({
|
|
7217
|
-
processed: true,
|
|
7218
|
-
item,
|
|
7219
|
-
timestamp: Date.now(),
|
|
7220
|
-
}));
|
|
7221
|
-
break;
|
|
7222
|
-
case 'analyze':
|
|
7223
|
-
result = {
|
|
7224
|
-
analyzed: true,
|
|
7225
|
-
itemCount: Array.isArray(data) ? data.length : 1,
|
|
7226
|
-
summary: 'Analysis complete',
|
|
7227
|
-
};
|
|
7228
|
-
break;
|
|
7229
|
-
default:
|
|
7230
|
-
result = { task, data, executed: true };
|
|
7231
|
-
}
|
|
7232
|
-
|
|
7233
|
-
const duration = Date.now() - startTime;
|
|
7234
|
-
spinner.succeed(`Executed ${task} in ${duration}ms`);
|
|
7235
|
-
|
|
7236
|
-
if (opts.json) {
|
|
7237
|
-
console.log(JSON.stringify({ result, duration }, null, 2));
|
|
7238
|
-
} else {
|
|
7239
|
-
console.log(chalk.bold(`\n${chalk.cyan('Task:')} ${task}`));
|
|
7240
|
-
console.log(`${chalk.cyan('Strategy:')} ${opts.strategy}`);
|
|
7241
|
-
console.log(`${chalk.cyan('Duration:')} ${duration}ms`);
|
|
7242
|
-
console.log(`${chalk.cyan('Result:')} ${JSON.stringify(result).slice(0, 100)}...`);
|
|
7243
|
-
console.log();
|
|
7244
|
-
}
|
|
7245
|
-
|
|
7246
|
-
} catch (e) {
|
|
7247
|
-
spinner.fail(`Execution failed: ${e.message}`);
|
|
7248
|
-
}
|
|
7249
|
-
});
|
|
7250
|
-
|
|
7251
|
-
// Workflow commands
|
|
7252
|
-
edgeNetCmd.command('workflow')
|
|
7253
|
-
.description('Run a multi-agent workflow')
|
|
7254
|
-
.argument('<name>', 'Workflow name or JSON file')
|
|
7255
|
-
.option('--input <json>', 'Input data as JSON', '{}')
|
|
7256
|
-
.option('--json', 'Output as JSON')
|
|
7257
|
-
.action(async (name, opts) => {
|
|
7258
|
-
const spinner = ora(`Running workflow: ${name}...`).start();
|
|
7259
|
-
|
|
7260
|
-
try {
|
|
7261
|
-
let input;
|
|
7262
|
-
try {
|
|
7263
|
-
input = JSON.parse(opts.input);
|
|
7264
|
-
} catch (e) {
|
|
7265
|
-
input = {};
|
|
7266
|
-
}
|
|
7267
|
-
|
|
7268
|
-
// Built-in workflows
|
|
7269
|
-
const workflows = {
|
|
7270
|
-
'code-review': [
|
|
7271
|
-
{ type: 'agent', agentType: 'analyst', task: 'Analyze code structure' },
|
|
7272
|
-
{ type: 'agent', agentType: 'reviewer', task: 'Review code quality' },
|
|
7273
|
-
{ type: 'agent', agentType: 'tester', task: 'Suggest tests' },
|
|
7274
|
-
],
|
|
7275
|
-
'research': [
|
|
7276
|
-
{ type: 'agent', agentType: 'researcher', task: 'Research topic' },
|
|
7277
|
-
{ type: 'agent', agentType: 'analyst', task: 'Analyze findings' },
|
|
7278
|
-
],
|
|
7279
|
-
'optimize': [
|
|
7280
|
-
{ type: 'agent', agentType: 'analyst', task: 'Profile performance' },
|
|
7281
|
-
{ type: 'agent', agentType: 'optimizer', task: 'Suggest optimizations' },
|
|
7282
|
-
{ type: 'agent', agentType: 'tester', task: 'Validate improvements' },
|
|
7283
|
-
],
|
|
7284
|
-
};
|
|
7285
|
-
|
|
7286
|
-
const steps = workflows[name] || [{ type: 'agent', agentType: 'researcher', task: name }];
|
|
7287
|
-
|
|
7288
|
-
spinner.text = `Executing ${steps.length} workflow steps...`;
|
|
7289
|
-
|
|
7290
|
-
const results = [];
|
|
7291
|
-
for (let i = 0; i < steps.length; i++) {
|
|
7292
|
-
const step = steps[i];
|
|
7293
|
-
spinner.text = `Step ${i + 1}/${steps.length}: ${step.agentType || step.type}`;
|
|
7294
|
-
await new Promise(r => setTimeout(r, 500)); // Simulate execution
|
|
7295
|
-
results.push({
|
|
7296
|
-
step: i + 1,
|
|
7297
|
-
type: step.agentType || step.type,
|
|
7298
|
-
status: 'completed',
|
|
7299
|
-
});
|
|
7300
|
-
}
|
|
7301
|
-
|
|
7302
|
-
spinner.succeed(`Workflow completed: ${results.length} steps`);
|
|
7303
|
-
|
|
7304
|
-
if (opts.json) {
|
|
7305
|
-
console.log(JSON.stringify({ workflow: name, results }, null, 2));
|
|
7306
|
-
} else {
|
|
7307
|
-
console.log(chalk.bold(`\n${chalk.cyan('Workflow:')} ${name}`));
|
|
7308
|
-
console.log(`${chalk.cyan('Steps:')} ${results.length}`);
|
|
7309
|
-
results.forEach(r => {
|
|
7310
|
-
console.log(` ${chalk.green('✓')} Step ${r.step}: ${r.type}`);
|
|
7311
|
-
});
|
|
7312
|
-
console.log();
|
|
7313
|
-
}
|
|
7314
|
-
|
|
7315
|
-
} catch (e) {
|
|
7316
|
-
spinner.fail(`Workflow failed: ${e.message}`);
|
|
7317
|
-
}
|
|
7318
|
-
});
|
|
7319
|
-
|
|
7320
|
-
// Network status
|
|
7321
|
-
edgeNetCmd.command('status')
|
|
7322
|
-
.description('Show Edge-Net network status')
|
|
7323
|
-
.option('--json', 'Output as JSON')
|
|
7324
|
-
.action(async (opts) => {
|
|
7325
|
-
const spinner = ora('Fetching network status...').start();
|
|
7326
|
-
|
|
7327
|
-
try {
|
|
7328
|
-
// Check if edge-net is installed
|
|
7329
|
-
let edgeNetInstalled = false;
|
|
7330
|
-
try {
|
|
7331
|
-
require.resolve('@ruvector/edge-net');
|
|
7332
|
-
edgeNetInstalled = true;
|
|
7333
|
-
} catch (e) {}
|
|
7334
|
-
|
|
7335
|
-
spinner.stop();
|
|
7336
|
-
|
|
7337
|
-
const status = {
|
|
7338
|
-
installed: edgeNetInstalled,
|
|
7339
|
-
version: edgeNetInstalled ? require('@ruvector/edge-net/package.json').version : 'not installed',
|
|
7340
|
-
network: {
|
|
7341
|
-
peers: 0,
|
|
7342
|
-
activeAgents: 0,
|
|
7343
|
-
workerPools: 0,
|
|
7344
|
-
},
|
|
7345
|
-
balance: {
|
|
7346
|
-
ruvEarned: 0,
|
|
7347
|
-
ruvSpent: 0,
|
|
7348
|
-
},
|
|
7349
|
-
};
|
|
7350
|
-
|
|
7351
|
-
if (opts.json) {
|
|
7352
|
-
console.log(JSON.stringify(status, null, 2));
|
|
7353
|
-
} else {
|
|
7354
|
-
console.log(chalk.bold.cyan('\n🌐 Edge-Net Status\n'));
|
|
7355
|
-
|
|
7356
|
-
if (!edgeNetInstalled) {
|
|
7357
|
-
console.log(chalk.yellow('⚠️ @ruvector/edge-net not installed'));
|
|
7358
|
-
console.log(chalk.dim(' Install: npm install @ruvector/edge-net\n'));
|
|
7359
|
-
} else {
|
|
7360
|
-
console.log(chalk.green(`✓ Package installed: v${status.version}`));
|
|
7361
|
-
}
|
|
7362
|
-
|
|
7363
|
-
console.log(chalk.bold('\nNetwork:'));
|
|
7364
|
-
console.log(chalk.dim(` Peers: ${status.network.peers}`));
|
|
7365
|
-
console.log(chalk.dim(` Active Agents: ${status.network.activeAgents}`));
|
|
7366
|
-
console.log(chalk.dim(` Worker Pools: ${status.network.workerPools}`));
|
|
7367
|
-
|
|
7368
|
-
console.log(chalk.bold('\nBalance:'));
|
|
7369
|
-
console.log(chalk.dim(` rUv Earned: ${status.balance.ruvEarned}`));
|
|
7370
|
-
console.log(chalk.dim(` rUv Spent: ${status.balance.ruvSpent}`));
|
|
7371
|
-
console.log();
|
|
7372
|
-
}
|
|
7373
|
-
|
|
7374
|
-
} catch (e) {
|
|
7375
|
-
spinner.fail(`Failed to get status: ${e.message}`);
|
|
7376
|
-
}
|
|
7377
|
-
});
|
|
7378
|
-
|
|
7379
|
-
// ============================================
|
|
7380
|
-
// REAL AGENT COMMANDS (Actual LLM Execution)
|
|
7381
|
-
// ============================================
|
|
7382
|
-
|
|
7383
|
-
const agentCmd = program.command('agent').description('Real AI agent execution - local ruvllm by default, or cloud APIs (Anthropic/OpenAI)');
|
|
7384
|
-
|
|
7385
|
-
agentCmd.command('run')
|
|
7386
|
-
.description('Execute a task with a real AI agent (local ruvllm by default, no API key needed)')
|
|
7387
|
-
.argument('<type>', 'Agent type: researcher, coder, reviewer, tester, analyst, optimizer, coordinator, embedder')
|
|
7388
|
-
.argument('<task>', 'Task description for the agent to execute')
|
|
7389
|
-
.option('-p, --provider <provider>', 'LLM provider: local (default), anthropic, openai', 'local')
|
|
7390
|
-
.option('-m, --model <model>', 'Model tier: fast, balanced, powerful', 'balanced')
|
|
7391
|
-
.option('-f, --files <files...>', 'Files to include as context')
|
|
7392
|
-
.option('-c, --context <context>', 'Additional context string')
|
|
7393
|
-
.option('--max-tokens <tokens>', 'Maximum tokens in response', '4096')
|
|
7394
|
-
.option('--relay <url>', 'Relay server URL for sync')
|
|
7395
|
-
.option('--json', 'Output as JSON')
|
|
7396
|
-
.action(async (type, task, opts) => {
|
|
7397
|
-
const spinner = ora('Initializing real agent...').start();
|
|
7398
|
-
|
|
7399
|
-
// Check for API key (only required for cloud providers)
|
|
7400
|
-
const apiKey = process.env.ANTHROPIC_API_KEY || process.env.OPENAI_API_KEY;
|
|
7401
|
-
const isLocal = opts.provider === 'local' || opts.provider === 'ruvllm';
|
|
7402
|
-
|
|
7403
|
-
if (!isLocal && !apiKey && type !== 'embedder') {
|
|
7404
|
-
spinner.fail('No API key found for cloud provider');
|
|
7405
|
-
console.log(chalk.red('\n❌ Cloud provider requires an API key.\n'));
|
|
7406
|
-
console.log(chalk.bold('Options:'));
|
|
7407
|
-
console.log(chalk.green(' 1. Use local ruvllm (default, no key needed):'));
|
|
7408
|
-
console.log(chalk.cyan(' ruvector agent run coder "task" -p local\n'));
|
|
7409
|
-
console.log(chalk.yellow(' 2. Or set a cloud API key:'));
|
|
7410
|
-
console.log(chalk.cyan(' export ANTHROPIC_API_KEY=your-key-here'));
|
|
7411
|
-
console.log(chalk.cyan(' export OPENAI_API_KEY=your-key-here'));
|
|
7412
|
-
console.log(chalk.dim('\nGet an API key:'));
|
|
7413
|
-
console.log(chalk.dim(' Anthropic: https://console.anthropic.com/'));
|
|
7414
|
-
console.log(chalk.dim(' OpenAI: https://platform.openai.com/api-keys\n'));
|
|
7415
|
-
return;
|
|
7416
|
-
}
|
|
7417
|
-
|
|
7418
|
-
try {
|
|
7419
|
-
// Try to load real-agents module
|
|
7420
|
-
let RealAgentManager;
|
|
7421
|
-
try {
|
|
7422
|
-
const realAgents = await import('@ruvector/edge-net/real-agents');
|
|
7423
|
-
RealAgentManager = realAgents.RealAgentManager;
|
|
7424
|
-
} catch (e) {
|
|
7425
|
-
// Fallback to local path for development
|
|
7426
|
-
try {
|
|
7427
|
-
const realAgentsPath = path.resolve(__dirname, '../../../../examples/edge-net/pkg/real-agents.js');
|
|
7428
|
-
const realAgents = await import(realAgentsPath);
|
|
7429
|
-
RealAgentManager = realAgents.RealAgentManager;
|
|
7430
|
-
} catch (e2) {
|
|
7431
|
-
spinner.fail('Real agents module not found');
|
|
7432
|
-
console.log(chalk.yellow('\nInstall @ruvector/edge-net for real agent execution:'));
|
|
7433
|
-
console.log(chalk.cyan(' npm install @ruvector/edge-net\n'));
|
|
7434
|
-
return;
|
|
7435
|
-
}
|
|
7436
|
-
}
|
|
7437
|
-
|
|
7438
|
-
// Determine provider from API key if not specified
|
|
7439
|
-
const provider = opts.provider || (process.env.ANTHROPIC_API_KEY ? 'anthropic' : 'openai');
|
|
7440
|
-
|
|
7441
|
-
spinner.text = `Spawning ${type} agent (${provider})...`;
|
|
7442
|
-
|
|
7443
|
-
// Initialize manager
|
|
7444
|
-
const manager = new RealAgentManager({
|
|
7445
|
-
provider,
|
|
7446
|
-
apiKey,
|
|
7447
|
-
relayUrl: opts.relay,
|
|
7448
|
-
enableSync: !!opts.relay,
|
|
7449
|
-
});
|
|
7450
|
-
await manager.initialize();
|
|
7451
|
-
|
|
7452
|
-
// Spawn agent
|
|
7453
|
-
const agent = await manager.spawn(type, {
|
|
7454
|
-
provider,
|
|
7455
|
-
model: opts.model,
|
|
7456
|
-
});
|
|
7457
|
-
|
|
7458
|
-
spinner.text = `Executing task with ${type} agent...`;
|
|
7459
|
-
|
|
7460
|
-
// Build context
|
|
7461
|
-
const context = {
|
|
7462
|
-
model: opts.model,
|
|
7463
|
-
files: opts.files || [],
|
|
7464
|
-
additionalContext: opts.context,
|
|
7465
|
-
maxTokens: parseInt(opts.maxTokens) || 4096,
|
|
7466
|
-
};
|
|
7467
|
-
|
|
7468
|
-
// Execute task
|
|
7469
|
-
const startTime = Date.now();
|
|
7470
|
-
const result = await agent.execute(task, context);
|
|
7471
|
-
const duration = Date.now() - startTime;
|
|
7472
|
-
|
|
7473
|
-
spinner.succeed(`Task completed in ${(duration / 1000).toFixed(2)}s`);
|
|
7474
|
-
|
|
7475
|
-
if (opts.json) {
|
|
7476
|
-
console.log(JSON.stringify({
|
|
7477
|
-
success: true,
|
|
7478
|
-
agentId: agent.id,
|
|
7479
|
-
type,
|
|
7480
|
-
provider,
|
|
7481
|
-
model: result.model,
|
|
7482
|
-
duration,
|
|
7483
|
-
result,
|
|
7484
|
-
}, null, 2));
|
|
7485
|
-
} else {
|
|
7486
|
-
console.log(chalk.bold.cyan(`\n🤖 Real Agent Execution Complete\n`));
|
|
7487
|
-
console.log(`${chalk.cyan('Agent ID:')} ${agent.id}`);
|
|
7488
|
-
console.log(`${chalk.cyan('Type:')} ${type}`);
|
|
7489
|
-
console.log(`${chalk.cyan('Provider:')} ${provider}`);
|
|
7490
|
-
console.log(`${chalk.cyan('Model:')} ${result.model}`);
|
|
7491
|
-
console.log(`${chalk.cyan('Duration:')} ${(duration / 1000).toFixed(2)}s`);
|
|
7492
|
-
|
|
7493
|
-
if (agent.cost.inputTokens || agent.cost.outputTokens) {
|
|
7494
|
-
console.log(`${chalk.cyan('Tokens:')} ${agent.cost.inputTokens} in / ${agent.cost.outputTokens} out`);
|
|
7495
|
-
}
|
|
7496
|
-
|
|
7497
|
-
console.log(chalk.bold('\n📝 Response:\n'));
|
|
7498
|
-
console.log(result.content || JSON.stringify(result, null, 2));
|
|
7499
|
-
console.log();
|
|
7500
|
-
}
|
|
7501
|
-
|
|
7502
|
-
await manager.close();
|
|
7503
|
-
|
|
7504
|
-
} catch (e) {
|
|
7505
|
-
spinner.fail(`Agent execution failed: ${e.message}`);
|
|
7506
|
-
if (e.message.includes('401') || e.message.includes('Unauthorized')) {
|
|
7507
|
-
console.log(chalk.yellow('\nCheck your API key is valid and has sufficient credits.'));
|
|
7508
|
-
}
|
|
7509
|
-
}
|
|
7510
|
-
});
|
|
7511
|
-
|
|
7512
|
-
agentCmd.command('types')
|
|
7513
|
-
.description('List available agent types')
|
|
7514
|
-
.action(() => {
|
|
7515
|
-
console.log(chalk.bold.cyan('\n🤖 Available Real Agent Types\n'));
|
|
7516
|
-
|
|
7517
|
-
const types = [
|
|
7518
|
-
{ type: 'researcher', desc: 'Analyze, search, summarize information', cost: '~$0.01-0.05/task' },
|
|
7519
|
-
{ type: 'coder', desc: 'Write, refactor, debug code', cost: '~$0.02-0.10/task' },
|
|
7520
|
-
{ type: 'reviewer', desc: 'Review code quality and security', cost: '~$0.01-0.05/task' },
|
|
7521
|
-
{ type: 'tester', desc: 'Write tests and validate functionality', cost: '~$0.01-0.05/task' },
|
|
7522
|
-
{ type: 'analyst', desc: 'Analyze data and generate reports', cost: '~$0.01-0.05/task' },
|
|
7523
|
-
{ type: 'optimizer', desc: 'Profile and improve performance', cost: '~$0.02-0.10/task' },
|
|
7524
|
-
{ type: 'coordinator', desc: 'Orchestrate workflows and tasks', cost: '~$0.02-0.10/task' },
|
|
7525
|
-
{ type: 'embedder', desc: 'Generate semantic embeddings (no API key needed)', cost: 'Free (local)' },
|
|
7526
|
-
];
|
|
7527
|
-
|
|
7528
|
-
types.forEach(t => {
|
|
7529
|
-
console.log(` ${chalk.green('•')} ${chalk.bold(t.type.padEnd(12))} ${t.desc}`);
|
|
7530
|
-
console.log(` ${chalk.dim('Estimated cost: ' + t.cost)}`);
|
|
7531
|
-
});
|
|
7532
|
-
|
|
7533
|
-
console.log(chalk.bold('\n📋 Model Tiers:\n'));
|
|
7534
|
-
console.log(` ${chalk.cyan('fast')} - Quick responses, lower cost (Haiku/GPT-4o-mini)`);
|
|
7535
|
-
console.log(` ${chalk.cyan('balanced')} - Good quality/speed balance (Sonnet/GPT-4o)`);
|
|
7536
|
-
console.log(` ${chalk.cyan('powerful')} - Best quality, higher cost (Opus/GPT-4-turbo)`);
|
|
7537
|
-
|
|
7538
|
-
console.log(chalk.bold('\n🔧 Example:\n'));
|
|
7539
|
-
console.log(chalk.dim(' export ANTHROPIC_API_KEY=your-key'));
|
|
7540
|
-
console.log(chalk.cyan(' ruvector agent run coder "Write a function to validate emails" -m fast'));
|
|
7541
|
-
console.log();
|
|
7542
|
-
});
|
|
7543
|
-
|
|
7544
|
-
agentCmd.command('balance')
|
|
7545
|
-
.description('Show rUv balance and sync status')
|
|
7546
|
-
.option('--relay <url>', 'Relay server URL', 'ws://localhost:8080')
|
|
7547
|
-
.action(async (opts) => {
|
|
7548
|
-
const spinner = ora('Connecting to relay...').start();
|
|
7549
|
-
|
|
7550
|
-
try {
|
|
7551
|
-
let RelaySyncClient;
|
|
7552
|
-
try {
|
|
7553
|
-
const realAgents = await import('@ruvector/edge-net/real-agents');
|
|
7554
|
-
RelaySyncClient = realAgents.RelaySyncClient;
|
|
7555
|
-
} catch (e) {
|
|
7556
|
-
const realAgentsPath = path.resolve(__dirname, '../../../../examples/edge-net/pkg/real-agents.js');
|
|
7557
|
-
const realAgents = await import(realAgentsPath);
|
|
7558
|
-
RelaySyncClient = realAgents.RelaySyncClient;
|
|
7559
|
-
}
|
|
7560
|
-
|
|
7561
|
-
const client = new RelaySyncClient({ relayUrl: opts.relay });
|
|
7562
|
-
|
|
7563
|
-
await Promise.race([
|
|
7564
|
-
client.connect(),
|
|
7565
|
-
new Promise((_, reject) => setTimeout(() => reject(new Error('Connection timeout')), 5000)),
|
|
7566
|
-
]);
|
|
7567
|
-
|
|
7568
|
-
spinner.succeed('Connected to relay');
|
|
7569
|
-
|
|
7570
|
-
console.log(chalk.bold.cyan('\n💰 rUv Balance\n'));
|
|
7571
|
-
console.log(`${chalk.cyan('Balance:')} ${client.getBalance()} rUv`);
|
|
7572
|
-
console.log(`${chalk.cyan('Relay:')} ${opts.relay}`);
|
|
7573
|
-
console.log(`${chalk.cyan('Node ID:')} ${client.nodeId}`);
|
|
7574
|
-
console.log(`${chalk.cyan('Status:')} ${chalk.green('Connected')}`);
|
|
7575
|
-
console.log();
|
|
7576
|
-
|
|
7577
|
-
client.close();
|
|
7578
|
-
|
|
7579
|
-
} catch (e) {
|
|
7580
|
-
spinner.fail(`Connection failed: ${e.message}`);
|
|
7581
|
-
console.log(chalk.dim('\nMake sure the relay server is running:'));
|
|
7582
|
-
console.log(chalk.cyan(' cd examples/edge-net/relay && node index.js\n'));
|
|
7583
|
-
}
|
|
7584
|
-
});
|
|
7585
|
-
|
|
7586
|
-
// ============================================
|
|
7587
|
-
// REAL WORKER POOL COMMANDS
|
|
7588
|
-
// ============================================
|
|
7589
|
-
|
|
7590
|
-
const workerCmd = program.command('worker').description('Real worker pool execution with Node.js worker_threads');
|
|
7591
|
-
|
|
7592
|
-
workerCmd.command('create')
|
|
7593
|
-
.description('Create a real worker pool for parallel task execution')
|
|
7594
|
-
.option('-s, --size <size>', 'Pool size (number of workers)', String(require('os').cpus().length - 1))
|
|
7595
|
-
.option('--relay <url>', 'Relay server URL for distributed mode')
|
|
7596
|
-
.option('--json', 'Output as JSON')
|
|
7597
|
-
.action(async (opts) => {
|
|
7598
|
-
const spinner = ora('Creating worker pool...').start();
|
|
7599
|
-
|
|
7600
|
-
try {
|
|
7601
|
-
let RealWorkerPool;
|
|
7602
|
-
try {
|
|
7603
|
-
const realWorkers = await import('@ruvector/edge-net/real-workers');
|
|
7604
|
-
RealWorkerPool = realWorkers.RealWorkerPool;
|
|
7605
|
-
} catch (e) {
|
|
7606
|
-
const realWorkersPath = path.resolve(__dirname, '../../../../examples/edge-net/pkg/real-workers.js');
|
|
7607
|
-
const realWorkers = await import(realWorkersPath);
|
|
7608
|
-
RealWorkerPool = realWorkers.RealWorkerPool;
|
|
7609
|
-
}
|
|
7610
|
-
|
|
7611
|
-
const pool = new RealWorkerPool({
|
|
7612
|
-
size: parseInt(opts.size) || require('os').cpus().length - 1,
|
|
7613
|
-
});
|
|
7614
|
-
|
|
7615
|
-
await pool.initialize();
|
|
7616
|
-
|
|
7617
|
-
spinner.succeed(`Worker pool created: ${pool.id}`);
|
|
7618
|
-
|
|
7619
|
-
const info = {
|
|
7620
|
-
id: pool.id,
|
|
7621
|
-
size: pool.size,
|
|
7622
|
-
workers: pool.workers.map(w => ({ id: w.id, status: w.status })),
|
|
7623
|
-
ready: pool.workers.filter(w => w.status === 'ready').length,
|
|
7624
|
-
};
|
|
7625
|
-
|
|
7626
|
-
if (opts.json) {
|
|
7627
|
-
console.log(JSON.stringify(info, null, 2));
|
|
7628
|
-
} else {
|
|
7629
|
-
console.log(chalk.bold.cyan('\n⚡ Real Worker Pool Created\n'));
|
|
7630
|
-
console.log(`${chalk.cyan('Pool ID:')} ${info.id}`);
|
|
7631
|
-
console.log(`${chalk.cyan('Size:')} ${info.size} workers`);
|
|
7632
|
-
console.log(`${chalk.cyan('Ready:')} ${info.ready}/${info.size}`);
|
|
7633
|
-
console.log();
|
|
7634
|
-
}
|
|
7635
|
-
|
|
7636
|
-
if (pool.shutdown) await pool.shutdown();
|
|
7637
|
-
else if (pool.close) await pool.close();
|
|
7638
|
-
|
|
7639
|
-
} catch (e) {
|
|
7640
|
-
spinner.fail(`Failed to create pool: ${e.message}`);
|
|
7641
|
-
}
|
|
7642
|
-
});
|
|
7643
|
-
|
|
7644
|
-
workerCmd.command('execute')
|
|
7645
|
-
.description('Execute a task on worker pool')
|
|
7646
|
-
.argument('<type>', 'Task type: compute, analyze, transform, batch')
|
|
7647
|
-
.argument('<data>', 'Task data (JSON string or simple value)')
|
|
7648
|
-
.option('-s, --size <size>', 'Pool size', '4')
|
|
7649
|
-
.option('--timeout <ms>', 'Task timeout in milliseconds', '30000')
|
|
7650
|
-
.option('--json', 'Output as JSON')
|
|
7651
|
-
.action(async (type, data, opts) => {
|
|
7652
|
-
const spinner = ora(`Executing ${type} task...`).start();
|
|
7653
|
-
|
|
7654
|
-
try {
|
|
7655
|
-
let RealWorkerPool;
|
|
7656
|
-
try {
|
|
7657
|
-
const realWorkers = await import('@ruvector/edge-net/real-workers');
|
|
7658
|
-
RealWorkerPool = realWorkers.RealWorkerPool;
|
|
7659
|
-
} catch (e) {
|
|
7660
|
-
const realWorkersPath = path.resolve(__dirname, '../../../../examples/edge-net/pkg/real-workers.js');
|
|
7661
|
-
const realWorkers = await import(realWorkersPath);
|
|
7662
|
-
RealWorkerPool = realWorkers.RealWorkerPool;
|
|
7663
|
-
}
|
|
7664
|
-
|
|
7665
|
-
const pool = new RealWorkerPool({ size: parseInt(opts.size) || 4 });
|
|
7666
|
-
await pool.initialize();
|
|
7667
|
-
|
|
7668
|
-
let taskData;
|
|
7669
|
-
try {
|
|
7670
|
-
taskData = JSON.parse(data);
|
|
7671
|
-
} catch {
|
|
7672
|
-
taskData = { input: data };
|
|
7673
|
-
}
|
|
7674
|
-
|
|
7675
|
-
const startTime = Date.now();
|
|
7676
|
-
const result = await pool.execute(type, taskData, {
|
|
7677
|
-
timeout: parseInt(opts.timeout) || 30000,
|
|
7678
|
-
});
|
|
7679
|
-
const duration = Date.now() - startTime;
|
|
7680
|
-
|
|
7681
|
-
spinner.succeed(`Task completed in ${(duration / 1000).toFixed(2)}s`);
|
|
7682
|
-
|
|
7683
|
-
if (opts.json) {
|
|
7684
|
-
console.log(JSON.stringify({ success: true, duration, result }, null, 2));
|
|
7685
|
-
} else {
|
|
7686
|
-
console.log(chalk.bold.cyan('\n⚡ Worker Execution Complete\n'));
|
|
7687
|
-
console.log(`${chalk.cyan('Type:')} ${type}`);
|
|
7688
|
-
console.log(`${chalk.cyan('Duration:')} ${(duration / 1000).toFixed(2)}s`);
|
|
7689
|
-
console.log(`${chalk.cyan('Worker:')} ${result.workerId || 'pool'}`);
|
|
7690
|
-
console.log(chalk.bold('\n📝 Result:\n'));
|
|
7691
|
-
console.log(JSON.stringify(result, null, 2));
|
|
7692
|
-
console.log();
|
|
7693
|
-
}
|
|
7694
|
-
|
|
7695
|
-
if (pool.shutdown) await pool.shutdown();
|
|
7696
|
-
else if (pool.close) await pool.close();
|
|
7697
|
-
|
|
7698
|
-
} catch (e) {
|
|
7699
|
-
spinner.fail(`Execution failed: ${e.message}`);
|
|
7700
|
-
}
|
|
7701
|
-
});
|
|
7702
|
-
|
|
7703
|
-
workerCmd.command('info')
|
|
7704
|
-
.description('Show worker pool information')
|
|
7705
|
-
.action(() => {
|
|
7706
|
-
console.log(chalk.bold.cyan('\n⚡ Real Worker Pool System\n'));
|
|
7707
|
-
console.log(chalk.white('Execute parallel tasks using Node.js worker_threads.\n'));
|
|
7708
|
-
|
|
7709
|
-
console.log(chalk.bold('Task Types:'));
|
|
7710
|
-
console.log(chalk.dim(' compute - CPU-intensive computations'));
|
|
7711
|
-
console.log(chalk.dim(' analyze - Data analysis tasks'));
|
|
7712
|
-
console.log(chalk.dim(' transform - Data transformation'));
|
|
7713
|
-
console.log(chalk.dim(' batch - Batch processing'));
|
|
7714
|
-
|
|
7715
|
-
console.log(chalk.bold('\n📋 Examples:\n'));
|
|
7716
|
-
console.log(chalk.cyan(' ruvector worker create --size 8'));
|
|
7717
|
-
console.log(chalk.cyan(' ruvector worker execute compute \'{"n": 1000000}\''));
|
|
7718
|
-
console.log(chalk.cyan(' ruvector worker execute analyze \'{"data": [1,2,3,4,5]}\''));
|
|
7719
|
-
console.log();
|
|
7720
|
-
});
|
|
7721
|
-
|
|
7722
|
-
// ============================================
|
|
7723
|
-
// REAL WORKFLOW COMMANDS
|
|
7724
|
-
// ============================================
|
|
7725
|
-
|
|
7726
|
-
const workflowCmd = program.command('workflow').description('Real multi-agent workflow orchestration with LLM execution');
|
|
7727
|
-
|
|
7728
|
-
workflowCmd.command('run')
|
|
7729
|
-
.description('Run a multi-agent workflow (uses local ruvllm by default)')
|
|
7730
|
-
.argument('<template>', 'Workflow template: code-review, feature-dev, bug-fix, optimization, research')
|
|
7731
|
-
.argument('<input>', 'Input/context for the workflow')
|
|
7732
|
-
.option('-p, --provider <provider>', 'LLM provider: local (default), anthropic, openai', 'local')
|
|
7733
|
-
.option('-m, --model <model>', 'Model tier: fast, balanced, powerful', 'balanced')
|
|
7734
|
-
.option('--max-steps <n>', 'Maximum workflow steps', '10')
|
|
7735
|
-
.option('--json', 'Output as JSON')
|
|
7736
|
-
.action(async (template, input, opts) => {
|
|
7737
|
-
const spinner = ora(`Running ${template} workflow...`).start();
|
|
7738
|
-
|
|
7739
|
-
try {
|
|
7740
|
-
let RealWorkflowOrchestrator;
|
|
7741
|
-
try {
|
|
7742
|
-
const realWorkflows = await import('@ruvector/edge-net/real-workflows');
|
|
7743
|
-
RealWorkflowOrchestrator = realWorkflows.RealWorkflowOrchestrator;
|
|
7744
|
-
} catch (e) {
|
|
7745
|
-
const realWorkflowsPath = path.resolve(__dirname, '../../../../examples/edge-net/pkg/real-workflows.js');
|
|
7746
|
-
const realWorkflows = await import(realWorkflowsPath);
|
|
7747
|
-
RealWorkflowOrchestrator = realWorkflows.RealWorkflowOrchestrator;
|
|
7748
|
-
}
|
|
7749
|
-
|
|
7750
|
-
// Check for API key if using cloud provider
|
|
7751
|
-
const isLocal = opts.provider === 'local' || opts.provider === 'ruvllm';
|
|
7752
|
-
const apiKey = process.env.ANTHROPIC_API_KEY || process.env.OPENAI_API_KEY;
|
|
7753
|
-
|
|
7754
|
-
if (!isLocal && !apiKey) {
|
|
7755
|
-
spinner.fail('No API key found for cloud provider');
|
|
7756
|
-
console.log(chalk.yellow('\n Use local provider (default) or set API key:'));
|
|
7757
|
-
console.log(chalk.cyan(' ruvector workflow run code-review "my code" -p local'));
|
|
7758
|
-
return;
|
|
7759
|
-
}
|
|
7760
|
-
|
|
7761
|
-
const orchestrator = new RealWorkflowOrchestrator({
|
|
7762
|
-
provider: isLocal ? 'local' : (process.env.ANTHROPIC_API_KEY ? 'anthropic' : 'openai'),
|
|
7763
|
-
apiKey: isLocal ? undefined : apiKey,
|
|
7764
|
-
maxConcurrency: 2,
|
|
7765
|
-
});
|
|
7766
|
-
|
|
7767
|
-
await orchestrator.initialize();
|
|
7768
|
-
|
|
7769
|
-
const startTime = Date.now();
|
|
7770
|
-
const result = await orchestrator.run(template, input, {
|
|
7771
|
-
maxSteps: parseInt(opts.maxSteps) || 10,
|
|
7772
|
-
modelTier: opts.model,
|
|
7773
|
-
});
|
|
7774
|
-
const duration = Date.now() - startTime;
|
|
7775
|
-
|
|
7776
|
-
spinner.succeed(`Workflow completed in ${(duration / 1000).toFixed(2)}s`);
|
|
7777
|
-
|
|
7778
|
-
if (opts.json) {
|
|
7779
|
-
console.log(JSON.stringify({ success: true, duration, ...result }, null, 2));
|
|
7780
|
-
} else {
|
|
7781
|
-
console.log(chalk.bold.cyan(`\n🔄 Workflow: ${template}\n`));
|
|
7782
|
-
console.log(`${chalk.cyan('Duration:')} ${(duration / 1000).toFixed(2)}s`);
|
|
7783
|
-
console.log(`${chalk.cyan('Provider:')} ${opts.provider}`);
|
|
7784
|
-
const steps = result.steps || [];
|
|
7785
|
-
const completedSteps = steps.filter(s => s.status === 'completed').length;
|
|
7786
|
-
console.log(`${chalk.cyan('Steps:')} ${completedSteps}/${steps.length}`);
|
|
7787
|
-
|
|
7788
|
-
console.log(chalk.bold('\n📝 Results by Step:\n'));
|
|
7789
|
-
for (const [stepName, stepResult] of Object.entries(result.results || {})) {
|
|
7790
|
-
console.log(chalk.bold.green(` ${stepName}:`));
|
|
7791
|
-
const preview = typeof stepResult === 'string'
|
|
7792
|
-
? stepResult.slice(0, 200) + (stepResult.length > 200 ? '...' : '')
|
|
7793
|
-
: JSON.stringify(stepResult).slice(0, 200);
|
|
7794
|
-
console.log(chalk.dim(` ${preview}\n`));
|
|
7795
|
-
}
|
|
7796
|
-
}
|
|
7797
|
-
|
|
7798
|
-
await orchestrator.close();
|
|
7799
|
-
|
|
7800
|
-
} catch (e) {
|
|
7801
|
-
spinner.fail(`Workflow failed: ${e.message}`);
|
|
7802
|
-
}
|
|
7803
|
-
});
|
|
7804
|
-
|
|
7805
|
-
workflowCmd.command('templates')
|
|
7806
|
-
.description('List available workflow templates')
|
|
7807
|
-
.action(() => {
|
|
7808
|
-
console.log(chalk.bold.cyan('\n🔄 Workflow Templates\n'));
|
|
7809
|
-
|
|
7810
|
-
const templates = [
|
|
7811
|
-
{ name: 'code-review', desc: 'Analyze, review, test coverage, and optimize code', steps: 4 },
|
|
7812
|
-
{ name: 'feature-dev', desc: 'Research, implement, test, and review a feature', steps: 4 },
|
|
7813
|
-
{ name: 'bug-fix', desc: 'Analyze, fix, and verify a bug', steps: 3 },
|
|
7814
|
-
{ name: 'optimization', desc: 'Profile, identify bottlenecks, optimize, benchmark', steps: 4 },
|
|
7815
|
-
{ name: 'research', desc: 'Research, analyze, and create knowledge embeddings', steps: 3 },
|
|
7816
|
-
];
|
|
7817
|
-
|
|
7818
|
-
templates.forEach(t => {
|
|
7819
|
-
console.log(` ${chalk.green('•')} ${chalk.bold(t.name.padEnd(14))} ${t.desc}`);
|
|
7820
|
-
console.log(` ${chalk.dim(`Steps: ${t.steps}`)}`);
|
|
7821
|
-
});
|
|
7822
|
-
|
|
7823
|
-
console.log(chalk.bold('\n📋 Example:\n'));
|
|
7824
|
-
console.log(chalk.cyan(' ruvector workflow run code-review "Review my authentication module"'));
|
|
7825
|
-
console.log(chalk.cyan(' ruvector workflow run feature-dev "Add user profile page" -p anthropic'));
|
|
7826
|
-
console.log();
|
|
7827
|
-
});
|
|
7828
|
-
|
|
7829
7010
|
// MCP Server command
|
|
7830
7011
|
const mcpCmd = program.command('mcp').description('MCP (Model Context Protocol) server for Claude Code integration');
|
|
7831
7012
|
|