mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-12-04 06:21:59 +09:00
* feat(cli,codex): wire ecosystem packages into real code paths + ecosystem skills
Every integration here has a reachable path (optional dep or lazy import,
graceful fallback) and a test that drives the real package.
- @ruvector/learning-wasm 0.1.29 (new optional dep): it was imported by
ruvector-training.ts, neural.ts and ruvector/index.ts but never declared,
so MicroLoRA always ran on the JS fallback. Now initializeTraining()
reports backend 'wasm'; `neural benchmark` measures ~2 us/adaptation at
256-dim. The benchmark's attention section (broken against
@ruvector/attention 2.x) no longer aborts the MicroLoRA numbers.
- ruvector ^0.2.27 -> ^0.3.11. ruvector 0.3 ships @ruvector/mincut-wasm and
its DynamicMinCut wrapper. New ruvector/mincut-bridge.ts folds duplicate and
reversed edges (the solver rejects them) and backs:
- agentdb_graph-pathfinder `dynamic-mincut`, previously a k-hop stub: exact
min cut of the seed's depth-hop neighbourhood, returns the seed's side
plus cut metadata (cutValue, cutEdges, backend). JS Stoer-Wagner
fallback for neighbourhoods <= 300 nodes.
- graph-analyzer loadRuVector(), which probed a nonexistent
ruvector.hooks_graph_mincut and @ruvector/wasm GraphAnalyzer. Measured
187 ms vs 6 s (JS) at 1,000 nodes, same cut value.
spectral-sparsify / connected-component-churn stay k-hop approximations
and now say so in the response (`implementation`).
- @ruvector/rabitq-wasm 0.1.0 -> 0.1.2: ruvector 0.3.11 declares an optional
peer >=0.1.1, and npm raises ERESOLVE against an exact 0.1.0 pin. Same API.
- agent-booster ^0.2.2 (new optional dep) backs a new hooks_fast-apply MCP
tool: merges a code snippet into a file or string (~ms, no LLM), with
project-root and symlink containment, dryRun and minConfidence. ADR-143
is respected: it is an applier for caller-supplied snippets, not a Tier-1
intent engine. The appliance bridge's tier-1 hint, labelled
'agent-booster' while being two regexes, is now labelled 'codemod' and
points at hooks_codemod. Path-containment helpers move from hooks-tools.ts
to realpath-containment.ts so both tools share them.
- ast-analyzer / diff-classifier / coverage-router imported @ruvector/ast,
@ruvector/diff, @ruvector/coverage, which were never published (npm 404).
ruvector 0.3's ASTParser needs native tree-sitter and is async-only;
parseDiff / parseIstanbulCoverage are plain JS equivalent to the local
parsers. The phantom imports are removed rather than swapped for a no-op hop.
- Skills: six new Claude Code skills (vector-quantization, graph-mincut,
sublinear-solver, injection-defense, fast-code-edits, lora-learning) in a
new SKILLS_MAP.ecosystem group, installed by default `ruflo init`
(`init skills --ecosystem`), and the Codex equivalents bundled in
@claude-flow/codex .agents/skills (built-in, installed by --full).
@claude-flow/codex 3.0.5 -> 3.0.6.
- no-cli-optdep-bloat-2561 guard: CLI_MAX 13 -> 17 and learning-wasm off the
FORBIDDEN list, with cold-install measurements (learning-wasm 0.38 s / 1
pkg / 104K; agent-booster 0.98 s / 67 pkgs / 5.8M).
Evaluated and not wired: sublinear-time-solver as a PPR accelerator (its
computePageRank took 1.2 s at 500 nodes and 68 s at 2,000, vs ms for the
built-in power iteration; 184 deps / 123 MB), strange-loops (pulls the same
tree), @ruvector/kge, @ruvector/cnn, @ruvector/rvlite, @ruvector/graph-wasm,
@ruvector/emergent-time, agentic-jujutsu, @ruvector/pi-brain (no existing
caller doing the job badly); @ruvector/diskann (see the memory PR).
Co-Authored-By: claude-flow <ruv@ruv.net>
* fix(deps): bound @ruvector/ruvllm away from the broken 4.0.x; ruvector override to ^0.3.11
@ruvector/ruvllm 4.0.0/4.0.1 were published from the wrong repository: an
ESM-only GPU-loop harness with no main entry and none of SonaCoordinator,
ContrastiveTrainer, TrainingPipeline or LoraAdapter. The open `>=2.6.0`
ranges in the root and ruflo overrides and the v3 pnpm.overrides let it
resolve, and every createRequire('@ruvector/ruvllm') caller (intelligence.ts,
sona-optimizer.ts, native-training.ts) then fell back to JS silently.
- root/ruflo overrides, v3 pnpm.overrides, providers peer:
`>=2.6.0 <4.0.0 || ^4.1.0` (2.6-3.x all export the four classes; 4.1.0 is
the restored runtime). Narrow to ^4.1.0 once it is on the registry.
- root/ruflo overrides: ruvector ^0.2.41 -> ^0.3.11. agentdb 3.3.0 itself
depends on ruvector ^0.3.5 and the CLI now on ^0.3.11, so the old override
forced both below their own ranges inside this repo's tree.
- ruflo overrides: agentdb `>=3.3.0` -> `^3.3.0`, agentic-flow `>=2.0.14` ->
`^2.0.14 || ^3.0.0` (no open-ended ecosystem ranges).
- providers/src/__tests__/ruvllm-runtime-contract.test.ts loads the installed
package through createRequire, asserts the four classes, constructs a
SonaCoordinator the way the CLI does, and checks the resolved version is in
range. Against 4.0.1, require() itself fails (no CJS entry).
Co-Authored-By: claude-flow <ruv@ruv.net>
* test: run ecosystem and ruvllm contract tests where the packages are installed
ci.yml's repo-root npm layout does not install the CLI's optional
dependencies, so those blocks skip there; the pnpm workspace that Test V3
Packages uses installs every one of them, so they run. The probe walks
node_modules only up to the repository root. A @ruvector/ruvllm that is
installed but does not load through require() still fails, and says which
copy and why.
Co-Authored-By: claude-flow <ruv@ruv.net>
* fix(umbrella): claude-flow carries the CLI's new optional deps; rabitq-wasm 0.1.2
The claude-flow umbrella ships the CLI dist with its own dependency list.
With @ruvector/rabitq-wasm pinned at 0.1.0, npm could not hoist ruvector 0.3
(optional peer rabitq-wasm >=0.1.1) and nested it under agentdb/agentic-flow,
so the umbrella's copy of the CLI could not import('ruvector') and the mincut
path was dead there. rabitq-wasm -> 0.1.2 (same API) puts ruvector back at
the top level; ruvector ^0.3.11, @ruvector/learning-wasm 0.1.29 and
agent-booster ^0.2.2 join the umbrella's optionalDependencies so the WASM
MicroLoRA, min-cut and fast-apply paths are reachable from npx claude-flow too.
Co-Authored-By: claude-flow <ruv@ruv.net>
* fix(security): @metaharness/darwin ^0.13.0 (GHSA-mjwg-5fm3-fx2p), metaharness ^0.4.20
@metaharness/darwin 0.13.0 fixes a high-severity sandbox bypass
(GHSA-mjwg-5fm3-fx2p); the CLI's `~0.12.0` could never resolve it.
- cli optionalDependencies @metaharness/darwin ~0.12.0 -> ^0.13.0; peer
metaharness ^0.4.1 -> ^0.4.20
- distill-oracle MH_DARWIN_PIN 0.12.0 -> 0.13.0 (npx tier-1 oracle calls)
- ruflo-metaharness helper pins: _darwin.mjs ~0.12.0 -> ~0.13.0,
_harness.mjs ~0.4.1 -> ~0.4.20 (tilde, as check-metaharness-pins requires);
plugin 0.4.0 -> 0.4.1
Checked against 0.13.0 before bumping (0.x minor): same exports
(., ./contrastive, ./gepa), same metaharness-darwin verbs ruflo surfaces
(evolve, evolve-numeric, bench create|verify, security bench), and the gepa
library calls (loadCand6Genome, validateGenome, buildSystemFromGenome)
return identical results to 0.12.0. Tier-2 evolution now runs in an isolated
child process upstream; ruflo already drives darwin as a subprocess. Note:
0.13.0 adds one runtime dependency (@babel/parser), where 0.12 had none.
check-metaharness-pins, metaharness-clean-install-test and the CLI's
metaharness/distill/darwin tests (80) pass.
Co-Authored-By: claude-flow <ruv@ruv.net>
* fix(deps): @ruvector/ruvllm ^4.1.0 now that the restored runtime is published
4.1.0 is the dual CJS/ESM runtime again. Root and ruflo overrides, v3
pnpm.overrides and the providers peer move from `>=2.6.0 <4.0.0 || ^4.1.0`
to `^4.1.0`; both lockfiles now resolve 4.1.0. The contract test requires
>=4.1 <5 and passed against 4.1.0 (SonaCoordinator, ContrastiveTrainer,
TrainingPipeline, LoraAdapter, DEFAULT_SONA_CONFIG; SonaCoordinator
constructs), as did the CLI's neural-status/trajectory/learning tests.
Co-Authored-By: claude-flow <ruv@ruv.net>
* release: 3.72.1
@claude-flow/cli, claude-flow and ruflo 3.72.1 (ruflo pins cli 3.72.1),
carrying the ecosystem integrations, @claude-flow/memory 3.2.3, codex 3.0.6,
@ruvector/ruvllm ^4.1.0 and @metaharness/darwin ^0.13.0.
Co-Authored-By: claude-flow <ruv@ruv.net>
* fix(metaharness): tilde-pin darwin ~0.13.0; smoke expects plugin 0.4.1
ruflo-metaharness smoke step 17z73 enforces tilde pins for @metaharness/*
(ADR-150 review: tilde stays on one minor). ~0.13.0 admits the same versions
as ^0.13.0 on a 0.x line and still resolves the GHSA-mjwg-5fm3-fx2p fix.
Smoke step 1 hard-codes the plugin version; it moves to 0.4.1 with the bump
that plugin-version-bump requires. smoke.sh: 128/128 locally.
Co-Authored-By: claude-flow <ruv@ruv.net>
---------
Co-authored-by: r <r@x>
@claude-flow/providers
Multi-LLM Provider System for Claude Flow V3 - unified interface for Anthropic, OpenAI, Google, Cohere, Ollama, and RuVector with intelligent load balancing, automatic failover, and cost optimization.
Features
- 6+ LLM Providers - Anthropic, OpenAI, Google, Cohere, Ollama, RuVector
- Load Balancing - Round-robin, latency-based, least-loaded, cost-based strategies
- Automatic Failover - Seamless provider switching on failures
- Request Caching - LRU cache with configurable TTL
- Cost Optimization - Up to 85%+ savings with intelligent routing
- Streaming Support - Full streaming for all providers
- Tool Calling - Unified tool/function calling interface
- Health Monitoring - Real-time provider health checks
- Cost Tracking - Per-request and aggregate cost metrics
Supported Providers & Models
Anthropic (Claude)
claude-3-5-sonnet-20241022,claude-3-5-sonnet-latestclaude-3-opus-20240229claude-3-sonnet-20240229claude-3-haiku-20240307
OpenAI (GPT)
gpt-4o,gpt-4o-minigpt-4-turbo,gpt-4gpt-3.5-turboo1-preview,o1-mini,o3-mini
Google (Gemini)
gemini-2.0-flashgemini-1.5-pro,gemini-1.5-flashgemini-pro
Cohere
command-r-plus,command-rcommand-light,command
Ollama (Local)
llama3.2,llama3.1mistral,mixtralcodellama,phi-4deepseek-coder
RuVector
- Custom models via @ruvector/ruvllm
Installation
npm install @claude-flow/providers
Quick Start
import { createProviderManager } from '@claude-flow/providers';
// Create provider manager with multiple providers
const manager = await createProviderManager({
providers: [
{
provider: 'anthropic',
apiKey: process.env.ANTHROPIC_API_KEY!,
model: 'claude-3-5-sonnet-latest',
},
{
provider: 'openai',
apiKey: process.env.OPENAI_API_KEY!,
model: 'gpt-4o',
},
],
loadBalancing: {
enabled: true,
strategy: 'cost-based',
},
fallback: {
enabled: true,
maxAttempts: 2,
},
cache: {
enabled: true,
ttl: 300000,
maxSize: 1000,
},
});
// Make a completion request
const response = await manager.complete({
messages: [
{ role: 'user', content: 'Hello, how are you?' }
],
maxTokens: 100,
});
console.log('Response:', response.content);
console.log('Provider:', response.provider);
console.log('Cost:', response.cost?.totalCost);
API Reference
ProviderManager
import { ProviderManager, createProviderManager } from '@claude-flow/providers';
// Create and initialize
const manager = await createProviderManager(config);
// Or manually initialize
const manager = new ProviderManager(config);
await manager.initialize();
Methods
// Complete a request
const response = await manager.complete(request, preferredProvider?);
// Stream completion
for await (const event of manager.streamComplete(request, preferredProvider?)) {
if (event.type === 'content') {
process.stdout.write(event.delta?.content || '');
}
}
// Health check all providers
const health = await manager.healthCheck();
health.forEach((result, provider) => {
console.log(`${provider}: ${result.healthy ? 'OK' : 'FAIL'}`);
});
// Estimate costs across providers
const estimates = await manager.estimateCost(request);
estimates.forEach((estimate, provider) => {
console.log(`${provider}: $${estimate.estimatedCost.total.toFixed(4)}`);
});
// Get aggregated usage
const usage = await manager.getUsage('day');
console.log(`Total cost: $${usage.cost.total}`);
// Get provider metrics
const metrics = manager.getMetrics();
metrics.forEach((m, provider) => {
console.log(`${provider}: ${m.latency}ms avg, ${m.errorRate * 100}% errors`);
});
// List available providers
const providers = manager.listProviders();
// Get specific provider
const anthropic = manager.getProvider('anthropic');
// Clear cache
manager.clearCache();
// Shutdown
manager.destroy();
Individual Providers
import {
AnthropicProvider,
OpenAIProvider,
GoogleProvider,
CohereProvider,
OllamaProvider,
RuVectorProvider,
} from '@claude-flow/providers';
// Create provider directly
const anthropic = new AnthropicProvider({
config: {
provider: 'anthropic',
apiKey: process.env.ANTHROPIC_API_KEY!,
model: 'claude-3-5-sonnet-latest',
temperature: 0.7,
maxTokens: 1000,
},
});
await anthropic.initialize();
const response = await anthropic.complete({
messages: [{ role: 'user', content: 'Hello!' }],
});
// Stream response
for await (const event of anthropic.streamComplete({
messages: [{ role: 'user', content: 'Tell me a story' }],
})) {
if (event.type === 'content') {
process.stdout.write(event.delta?.content || '');
}
}
Load Balancing Strategies
const manager = await createProviderManager({
providers: [...],
loadBalancing: {
enabled: true,
strategy: 'round-robin', // or 'least-loaded', 'latency-based', 'cost-based'
},
});
| Strategy | Description | Best For |
|---|---|---|
round-robin |
Rotate through providers | Even distribution |
least-loaded |
Use provider with lowest load | High throughput |
latency-based |
Use fastest provider | Low latency |
cost-based |
Use cheapest provider | Cost optimization |
Automatic Failover
const manager = await createProviderManager({
providers: [...],
fallback: {
enabled: true,
maxAttempts: 3, // Try up to 3 providers
},
});
// Events for monitoring
manager.on('fallback_success', ({ originalProvider, fallbackProvider, attempts }) => {
console.log(`Fallback from ${originalProvider} to ${fallbackProvider}`);
});
manager.on('fallback_exhausted', ({ originalProvider, attempts }) => {
console.error(`All ${attempts} fallback attempts failed`);
});
Request Caching
const manager = await createProviderManager({
providers: [...],
cache: {
enabled: true,
ttl: 300000, // 5 minutes
maxSize: 1000, // Max cached responses
},
});
// Cache is keyed by: messages + model + temperature + maxTokens
// Identical requests return cached responses
// Clear cache when needed
manager.clearCache();
Cost Optimization
const manager = await createProviderManager({
providers: [...],
costOptimization: {
enabled: true,
maxCostPerRequest: 0.10, // Max $0.10 per request
},
});
// Request with cost constraints
const response = await manager.complete({
messages: [...],
costConstraints: {
maxCost: 0.05,
preferredModels: ['gpt-4o-mini', 'claude-3-haiku-20240307'],
},
});
// Get cost breakdown
console.log('Cost:', {
prompt: response.cost?.promptCost,
completion: response.cost?.completionCost,
total: response.cost?.totalCost,
currency: response.cost?.currency,
});
Tool Calling
const response = await manager.complete({
messages: [
{ role: 'user', content: 'What is the weather in San Francisco?' }
],
tools: [
{
type: 'function',
function: {
name: 'get_weather',
description: 'Get weather for a location',
parameters: {
type: 'object',
properties: {
location: { type: 'string', description: 'City name' },
unit: { type: 'string', enum: ['celsius', 'fahrenheit'] },
},
required: ['location'],
},
},
},
],
toolChoice: 'auto',
});
// Check for tool calls
if (response.toolCalls) {
for (const call of response.toolCalls) {
console.log('Tool:', call.function.name);
console.log('Args:', JSON.parse(call.function.arguments));
}
}
Streaming
// Async iterator streaming
for await (const event of manager.streamComplete(request)) {
switch (event.type) {
case 'content':
process.stdout.write(event.delta?.content || '');
break;
case 'tool_call':
console.log('Tool call:', event.delta?.toolCall);
break;
case 'error':
console.error('Error:', event.error);
break;
case 'done':
console.log('\nUsage:', event.usage);
console.log('Cost:', event.cost);
break;
}
}
Multimodal (Vision/Audio)
// Image input (OpenAI, Anthropic, Google)
const response = await manager.complete({
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'What is in this image?' },
{ type: 'image', imageUrl: 'https://example.com/image.jpg' },
// or imageBase64: 'base64-encoded-image'
],
},
],
});
TypeScript Types
import type {
// Provider types
LLMProvider,
LLMModel,
LLMProviderConfig,
ILLMProvider,
ProviderCapabilities,
// Message types
LLMMessage,
LLMContentPart,
LLMToolCall,
LLMTool,
// Request/Response
LLMRequest,
LLMResponse,
LLMStreamEvent,
// Manager types
ProviderManagerConfig,
LoadBalancingStrategy,
// Status types
HealthCheckResult,
ProviderStatus,
CostEstimate,
UsageStats,
// Error types
LLMProviderError,
RateLimitError,
AuthenticationError,
ModelNotFoundError,
ProviderUnavailableError,
} from '@claude-flow/providers';
Error Handling
import {
LLMProviderError,
RateLimitError,
AuthenticationError,
isLLMProviderError,
isRateLimitError,
} from '@claude-flow/providers';
try {
const response = await manager.complete(request);
} catch (error) {
if (isRateLimitError(error)) {
console.log(`Rate limited. Retry after: ${error.retryAfter}ms`);
} else if (isLLMProviderError(error)) {
console.log(`Provider error: ${error.code}`);
console.log(`Retryable: ${error.retryable}`);
}
}
Error Types
| Error | Code | HTTP | Retryable |
|---|---|---|---|
RateLimitError |
RATE_LIMIT |
429 | Yes |
AuthenticationError |
AUTHENTICATION |
401 | No |
ModelNotFoundError |
MODEL_NOT_FOUND |
404 | No |
ProviderUnavailableError |
PROVIDER_UNAVAILABLE |
503 | Yes |
Environment Variables
# API Keys
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
GOOGLE_API_KEY=...
COHERE_API_KEY=...
# Ollama (local)
OLLAMA_BASE_URL=http://localhost:11434
# Optional overrides
ANTHROPIC_BASE_URL=https://api.anthropic.com
OPENAI_BASE_URL=https://api.openai.com/v1
Provider Configuration
Anthropic
{
provider: 'anthropic',
apiKey: process.env.ANTHROPIC_API_KEY!,
model: 'claude-3-5-sonnet-latest',
temperature: 0.7,
maxTokens: 4096,
timeout: 60000,
retryAttempts: 3,
}
OpenAI
{
provider: 'openai',
apiKey: process.env.OPENAI_API_KEY!,
model: 'gpt-4o',
temperature: 0.7,
maxTokens: 4096,
frequencyPenalty: 0,
presencePenalty: 0,
}
{
provider: 'google',
apiKey: process.env.GOOGLE_API_KEY!,
model: 'gemini-1.5-pro',
temperature: 0.7,
maxTokens: 8192,
topK: 40,
}
Cohere
{
provider: 'cohere',
apiKey: process.env.COHERE_API_KEY!,
model: 'command-r-plus',
temperature: 0.7,
maxTokens: 4000,
}
Ollama (Local)
{
provider: 'ollama',
apiUrl: 'http://localhost:11434',
model: 'llama3.2',
temperature: 0.7,
maxTokens: 4096,
}
Performance
| Metric | Target |
|---|---|
| Provider initialization | <500ms |
| Request routing | <5ms |
| Cache lookup | <1ms |
| Health check | <2s |
Integration with Claude Flow
import { createProviderManager } from '@claude-flow/providers';
import { createUnifiedSwarmCoordinator } from '@claude-flow/swarm';
// Create provider manager
const providers = await createProviderManager({
providers: [
{ provider: 'anthropic', apiKey: '...', model: 'claude-3-5-sonnet-latest' },
{ provider: 'openai', apiKey: '...', model: 'gpt-4o' },
],
loadBalancing: { enabled: true, strategy: 'cost-based' },
});
// Use with swarm coordinator
const coordinator = createUnifiedSwarmCoordinator({
// Agents can use provider manager for LLM calls
extensions: {
providers,
},
});
Related Packages
- @claude-flow/embeddings - Embedding generation
- @claude-flow/memory - Vector storage and retrieval
- @claude-flow/swarm - Multi-agent coordination
- @claude-flow/neural - SONA learning integration
License
MIT