π The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
feat(providers): add Ollama (Tier-2) β closes #1725 + workflow_execute fix
Reuven9c1a71f00906
diff --git a/package.json b/package.jsonindex 8bf5859e3e..cbb01954dc 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "claude-flow",- "version": "3.6.26",+ "version": "3.6.27","description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration","main": "dist/index.js","type": "module",diff --git a/ruflo/package.json b/ruflo/package.jsonindex 1385aa3b54..5dad5369d2 100644--- a/ruflo/package.json+++ b/ruflo/package.json@@ -1,6 +1,6 @@{"name": "ruflo",- "version": "3.6.26",+ "version": "3.6.27","description": "Ruflo - Enterprise AI agent orchestration platform. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration","main": "bin/ruflo.js","type": "module",diff --git a/v3/@claude-flow/cli/package.json b/v3/@claude-flow/cli/package.jsonindex 61e70d880d..8268f0a70f 100644--- a/v3/@claude-flow/cli/package.json+++ b/v3/@claude-flow/cli/package.json@@ -1,6 +1,6 @@{"name": "@claude-flow/cli",- "version": "3.6.26",+ "version": "3.6.27","type": "module","description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code","main": "dist/src/index.js",diff --git a/v3/@claude-flow/cli/src/commands/providers.ts b/v3/@claude-flow/cli/src/commands/providers.tsindex db7e9a9acd..1efd9499d2 100644--- a/v3/@claude-flow/cli/src/commands/providers.ts+++ b/v3/@claude-flow/cli/src/commands/providers.ts@@ -23,6 +23,9 @@ const PROVIDER_CATALOG: ProviderCatalogEntry[] = [{ name: 'OpenAI', type: 'LLM', models: 'gpt-4o, gpt-4-turbo', envVar: 'OPENAI_API_KEY', configName: 'openai' },{ name: 'OpenAI', type: 'Embedding', models: 'text-embedding-3-small/large', envVar: 'OPENAI_API_KEY', configName: 'openai' },{ name: 'Google', type: 'LLM', models: 'gemini-pro, gemini-ultra', envVar: 'GOOGLE_API_KEY', configName: 'google' },+ // #1725: Ollama Cloud β Tier-2 default per ADR-026 (~$100/mo flat-rate alternative+ // to per-token pricing). OpenAI-compat API at https://ollama.com/v1/chat/completions.+ { name: 'Ollama', type: 'LLM', models: 'gpt-oss:120b-cloud, llama3:70b-cloud, qwen2.5-coder:32b-cloud', envVar: 'OLLAMA_API_KEY', configName: 'ollama' },{ name: 'Transformers.js', type: 'Embedding', models: 'Xenova/all-MiniLM-L6-v2' },{ name: 'Agentic Flow', type: 'Embedding', models: 'ONNX optimized' },{ name: 'Mock', type: 'All', models: 'mock-*' },@@ -49,6 +52,7 @@ function resolveApiKey(anthropic: 'ANTHROPIC_API_KEY',openai: 'OPENAI_API_KEY',google: 'GOOGLE_API_KEY',+ ollama: 'OLLAMA_API_KEY', // #1725 β Tier-2 routing};const envVar = envMapping[providerName.toLowerCase()];if (envVar && process.env[envVar]) {@@ -84,6 +88,13 @@ async function testProviderConnectivity(url: `https://generativelanguage.googleapis.com/v1beta/models?key=${apiKey}`,headers: {},},+ // #1725 β Ollama Cloud uses an OpenAI-compatible /v1 surface.+ ollama: {+ url: 'https://ollama.com/api/tags',+ headers: {+ 'Authorization': `Bearer ${apiKey}`,+ },+ },};const endpointConfig = endpoints[providerName.toLowerCase()];diff --git a/v3/@claude-flow/cli/src/mcp-tools/agent-execute-core.ts b/v3/@claude-flow/cli/src/mcp-tools/agent-execute-core.tsindex 1aab4bc087..57a670cac8 100644--- a/v3/@claude-flow/cli/src/mcp-tools/agent-execute-core.ts+++ b/v3/@claude-flow/cli/src/mcp-tools/agent-execute-core.ts@@ -85,11 +85,29 @@ export interface AnthropicCallResult {* Generic Anthropic Messages API call. No agent registry coupling β used* by agent_execute (with the agent's configured model) and by the WASM* agent runtime (G4) when the bundled WASM only echoes input.+ *+ * #1725 β falls back to Ollama Cloud (Tier-2, OpenAI-compat) when+ * ANTHROPIC_API_KEY is unset and OLLAMA_API_KEY is present, or when+ * RUFLO_PROVIDER=ollama is explicitly set. Response shape is normalized+ * to the Anthropic-flavored AnthropicCallResult so existing callers+ * don't need to know which provider answered.*/export async function callAnthropicMessages(input: AnthropicCallInput): Promise<AnthropicCallResult> {- const apiKey = process.env.ANTHROPIC_API_KEY;- if (!apiKey) {- return { success: false, error: 'ANTHROPIC_API_KEY not set in environment' };+ const explicitProvider = (process.env.RUFLO_PROVIDER || '').toLowerCase();+ const ollamaKey = process.env.OLLAMA_API_KEY;+ const anthropicKey = process.env.ANTHROPIC_API_KEY;+ const useOllama =+ explicitProvider === 'ollama' || (!anthropicKey && !!ollamaKey);++ if (useOllama && ollamaKey) {+ return callOllamaCompat({ ...input, apiKey: ollamaKey });+ }+ if (!anthropicKey) {+ return {+ success: false,+ error:+ 'No LLM provider configured. Set ANTHROPIC_API_KEY (Tier-3) or OLLAMA_API_KEY (Tier-2 Ollama Cloud β see issue #1725).',+ };}const model = input.model || 'claude-3-5-sonnet-latest';const startedAt = Date.now();@@ -99,7 +117,7 @@ export async function callAnthropicMessages(input: AnthropicCallInput): Promise<const res = await fetch('https://api.anthropic.com/v1/messages', {method: 'POST',headers: {- 'x-api-key': apiKey,+ 'x-api-key': anthropicKey,'anthropic-version': '2023-06-01','content-type': 'application/json',},@@ -151,6 +169,111 @@ export async function callAnthropicMessages(input: AnthropicCallInput): Promise<}}+/**+ * Ollama Cloud / OpenAI-compat provider β Tier-2 routing per ADR-026 + #1725.+ *+ * Endpoint: https://ollama.com/v1/chat/completions+ * Auth: Authorization: Bearer <OLLAMA_API_KEY>+ *+ * Translates the Anthropic-flavored input shape onto OpenAI chat-completions+ * and translates the response back so callers never see provider-specific+ * fields. Logical model names are mapped to Ollama Cloud defaults:+ * - 'haiku' / 'sonnet' β 'gpt-oss:120b-cloud' (sensible single default)+ * - 'opus' β 'gpt-oss:120b-cloud' (no opus tier on Ollama)+ * - explicit 'ollama:<model>' or bare provider-native name β passed through+ */+async function callOllamaCompat(+ input: AnthropicCallInput & { apiKey: string },+): Promise<AnthropicCallResult> {+ const model = resolveOllamaModel(input.model);+ const startedAt = Date.now();+ // OLLAMA_BASE_URL lets users point at local/self-hosted endpoints+ // (e.g. http://ruvultra:11434, http://localhost:11434) instead of+ // Ollama Cloud. Default is the public cloud endpoint.+ const base = (process.env.OLLAMA_BASE_URL || 'https://ollama.com').replace(/\/+$/, '');+ const url = `${base}/v1/chat/completions`;+ // Self-hosted endpoints typically don't need an Authorization header+ // (the daemon binds to 11434 with no auth by default), but Ollama Cloud+ // does. Send the bearer when the key is non-empty AND looks cloud-shaped.+ const sendAuth = input.apiKey && input.apiKey !== 'local';+ try {+ const controller = new AbortController();+ const timer = setTimeout(() => controller.abort(), input.timeoutMs || 60000);+ const res = await fetch(url, {+ method: 'POST',+ headers: {+ ...(sendAuth ? { Authorization: `Bearer ${input.apiKey}` } : {}),+ 'content-type': 'application/json',+ },+ body: JSON.stringify({+ model,+ max_tokens: input.maxTokens || 1024,+ temperature: typeof input.temperature === 'number' ? input.temperature : 0.7,+ messages: [+ ...(input.systemPrompt+ ? [{ role: 'system' as const, content: input.systemPrompt }]+ : []),+ { role: 'user' as const, content: input.prompt },+ ],+ }),+ signal: controller.signal,+ });+ clearTimeout(timer);+ if (!res.ok) {+ const errText = await res.text().catch(() => '<unreadable error body>');+ return { success: false, model, error: `Ollama API error ${res.status} at ${url}: ${errText.slice(0, 400)}` };+ }+ const data = (await res.json()) as {+ id?: string;+ model?: string;+ choices: Array<{+ message: { role: string; content: string };+ finish_reason?: string;+ }>;+ usage?: {+ prompt_tokens?: number;+ completion_tokens?: number;+ total_tokens?: number;+ };+ };+ const textOut = data.choices?.[0]?.message?.content ?? '';+ const usage = data.usage ?? {};+ return {+ success: true,+ model: data.model ?? model,+ messageId: data.id ?? `ollama-${Date.now()}`,+ stopReason: data.choices?.[0]?.finish_reason ?? 'end_turn',+ output: textOut,+ usage: {+ inputTokens: usage.prompt_tokens ?? 0,+ outputTokens: usage.completion_tokens ?? 0,+ totalTokens: usage.total_tokens ?? 0,+ },+ durationMs: Date.now() - startedAt,+ };+ } catch (err) {+ return {+ success: false,+ model,+ error: err instanceof Error ? err.message : String(err),+ durationMs: Date.now() - startedAt,+ };+ }+}++function resolveOllamaModel(input: string | undefined): string {+ const DEFAULT = 'gpt-oss:120b-cloud';+ if (!input) return DEFAULT;+ // Logical β cloud default+ if (input === 'haiku' || input === 'sonnet' || input === 'opus' || input === 'inherit') {+ return DEFAULT;+ }+ // Explicit provider prefix+ if (input.startsWith('ollama:')) return input.slice('ollama:'.length);+ // Bare name with cloud suffix (e.g. 'llama3:70b-cloud') passes through+ return input;+}+/*** Resolve a model identifier to an Anthropic model ID. Accepts:* - logical names: 'haiku', 'sonnet', 'opus', 'inherit'