agentic-flow 2.1.1 → 2.1.3

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.
Files changed (36) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/agents/claudeAgentDirect.js +4 -4
  3. package/dist/agents/claudeAgentDirect.js.map +1 -1
  4. package/dist/billing/cli.js +0 -0
  5. package/dist/cli/agentdb-proxy.d.ts +3 -0
  6. package/dist/cli/agentdb-proxy.d.ts.map +1 -0
  7. package/dist/cli/agentdb-proxy.js +8 -0
  8. package/dist/cli/agentdb-proxy.js.map +1 -0
  9. package/dist/cli-proxy.js +67 -3
  10. package/dist/cli-proxy.js.map +1 -1
  11. package/dist/router/providers/onnx-local-optimized.d.ts +10 -1
  12. package/dist/router/providers/onnx-local-optimized.d.ts.map +1 -1
  13. package/dist/router/providers/onnx-local-optimized.js +12 -10
  14. package/dist/router/providers/onnx-local-optimized.js.map +1 -1
  15. package/dist/router/providers/onnx-local.d.ts +9 -0
  16. package/dist/router/providers/onnx-local.d.ts.map +1 -1
  17. package/dist/router/providers/onnx-local.js +24 -9
  18. package/dist/router/providers/onnx-local.js.map +1 -1
  19. package/dist/router/providers/onnx-phi4.d.ts.map +1 -1
  20. package/dist/router/providers/onnx-phi4.js +2 -1
  21. package/dist/router/providers/onnx-phi4.js.map +1 -1
  22. package/dist/router/router.d.ts.map +1 -1
  23. package/dist/router/router.js +2 -1
  24. package/dist/router/router.js.map +1 -1
  25. package/dist/router/test-onnx-benchmark.js +2 -1
  26. package/dist/router/test-onnx-benchmark.js.map +1 -1
  27. package/dist/router/test-onnx-local.js +2 -1
  28. package/dist/router/test-onnx-local.js.map +1 -1
  29. package/dist/utils/model-downloader.d.ts +14 -0
  30. package/dist/utils/model-downloader.d.ts.map +1 -1
  31. package/dist/utils/model-downloader.js +19 -3
  32. package/dist/utils/model-downloader.js.map +1 -1
  33. package/package.json +4 -4
  34. package/wasm/reasoningbank/reasoningbank_wasm_bg.js +32 -32
  35. package/wasm/reasoningbank/reasoningbank_wasm_bg.wasm +0 -0
  36. package/wasm/reasoningbank/reasoningbank_wasm_bg.wasm.d.ts +3 -3
@@ -26,25 +26,25 @@ function getModelForProvider(provider) {
26
26
  return {
27
27
  model: envModel || 'gemini-2.0-flash-exp',
28
28
  apiKey: process.env.GOOGLE_GEMINI_API_KEY || '',
29
- baseURL: process.env.GEMINI_PROXY_URL || 'http://localhost:3000'
29
+ baseURL: process.env.GEMINI_PROXY_URL || `http://localhost:${process.env.PROXY_PORT || '3000'}`
30
30
  };
31
31
  case 'requesty':
32
32
  return {
33
33
  model: envModel || 'deepseek/deepseek-chat',
34
34
  apiKey: process.env.REQUESTY_API_KEY || '',
35
- baseURL: process.env.REQUESTY_PROXY_URL || 'http://localhost:3000'
35
+ baseURL: process.env.REQUESTY_PROXY_URL || `http://localhost:${process.env.PROXY_PORT || '3000'}`
36
36
  };
37
37
  case 'openrouter':
38
38
  return {
39
39
  model: envModel || 'deepseek/deepseek-chat',
40
40
  apiKey: process.env.OPENROUTER_API_KEY || '',
41
- baseURL: process.env.OPENROUTER_PROXY_URL || 'http://localhost:3000'
41
+ baseURL: process.env.OPENROUTER_PROXY_URL || `http://localhost:${process.env.PROXY_PORT || '3000'}`
42
42
  };
43
43
  case 'onnx':
44
44
  return {
45
45
  model: 'onnx-local',
46
46
  apiKey: 'local',
47
- baseURL: process.env.ONNX_PROXY_URL || 'http://localhost:3001'
47
+ baseURL: process.env.ONNX_PROXY_URL || `http://localhost:${process.env.ONNX_PROXY_PORT || '3001'}`
48
48
  };
49
49
  case 'anthropic':
50
50
  default:
@@ -1 +1 @@
1
- {"version":3,"file":"claudeAgentDirect.js","sourceRoot":"","sources":["../../src/agents/claudeAgentDirect.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,SAA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AAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;wBAEhC,IAAI,QAAQ,EAAE,CAAC;4BACb,QAAQ,CAAC,SAAS,CAAC,CAAC;wBACtB,CAAC;oBACH,CAAC;gBACH,CAAC;qBAAM,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;oBACzC,kBAAkB;oBAClB,MAAM;gBACR,CAAC;gBAED,wCAAwC;gBACxC,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;oBAC1B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBAC1B,CAAC;gBACD,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;oBAC1B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBAC1B,CAAC;YACH,CAAC;YAED,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;YACxC,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAE;gBAClC,KAAK,EAAE,KAAK,CAAC,IAAI;gBACjB,QAAQ;gBACR,QAAQ;gBACR,YAAY,EAAE,MAAM,CAAC,MAAM;aAC5B,CAAC,CAAC;YAEH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;QACvC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,CAAC,KAAK,CAAC,6BAA6B,EAAE;gBAC1C,QAAQ;gBACR,KAAK,EAAE,UAAU;gBACjB,KAAK,EAAE,KAAK,CAAC,OAAO;aACrB,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Direct API agent that uses Anthropic SDK without Claude Code dependency\nimport Anthropic from '@anthropic-ai/sdk';\nimport { logger } from \"../utils/logger.js\";\nimport { withRetry } from \"../utils/retry.js\";\nimport { AgentDefinition } from \"../utils/agentLoader.js\";\n\nfunction getCurrentProvider(): string {\n // Determine provider from environment\n if (process.env.PROVIDER === 'gemini' || process.env.USE_GEMINI === 'true') {\n return 'gemini';\n }\n if (process.env.PROVIDER === 'requesty' || process.env.USE_REQUESTY === 'true') {\n return 'requesty';\n }\n if (process.env.PROVIDER === 'openrouter' || process.env.USE_OPENROUTER === 'true') {\n return 'openrouter';\n }\n if (process.env.PROVIDER === 'onnx' || process.env.USE_ONNX === 'true') {\n return 'onnx';\n }\n return 'anthropic'; // Default\n}\n\nfunction getModelForProvider(provider: string): {\n model: string;\n apiKey: string;\n baseURL?: string;\n} {\n // Use DEFAULT_MODEL or COMPLETION_MODEL from environment (both supported for backward compatibility)\n const envModel = process.env.DEFAULT_MODEL || process.env.COMPLETION_MODEL;\n\n switch (provider) {\n case 'gemini':\n return {\n model: envModel || 'gemini-2.0-flash-exp',\n apiKey: process.env.GOOGLE_GEMINI_API_KEY || '',\n baseURL: process.env.GEMINI_PROXY_URL || 'http://localhost:3000'\n };\n\n case 'requesty':\n return {\n model: envModel || 'deepseek/deepseek-chat',\n apiKey: process.env.REQUESTY_API_KEY || '',\n baseURL: process.env.REQUESTY_PROXY_URL || 'http://localhost:3000'\n };\n\n case 'openrouter':\n return {\n model: envModel || 'deepseek/deepseek-chat',\n apiKey: process.env.OPENROUTER_API_KEY || '',\n baseURL: process.env.OPENROUTER_PROXY_URL || 'http://localhost:3000'\n };\n\n case 'onnx':\n return {\n model: 'onnx-local',\n apiKey: 'local',\n baseURL: process.env.ONNX_PROXY_URL || 'http://localhost:3001'\n };\n\n case 'anthropic':\n default:\n const apiKey = process.env.ANTHROPIC_API_KEY;\n if (!apiKey) {\n throw new Error('ANTHROPIC_API_KEY is required for Anthropic provider');\n }\n return {\n model: envModel || 'claude-sonnet-4-5-20250929',\n apiKey,\n // Direct Anthropic API - no baseURL needed\n };\n }\n}\n\nexport async function claudeAgentDirect(\n agent: AgentDefinition,\n input: string,\n onStream?: (chunk: string) => void,\n modelOverride?: string\n) {\n const startTime = Date.now();\n const provider = getCurrentProvider();\n\n logger.info('Starting Direct Anthropic SDK (no Claude Code dependency)', {\n agent: agent.name,\n provider,\n input: input.substring(0, 100),\n model: modelOverride || 'default'\n });\n\n return withRetry(async () => {\n const modelConfig = getModelForProvider(provider);\n const finalModel = modelOverride || modelConfig.model;\n\n // Create Anthropic client with provider-specific configuration\n const anthropic = new Anthropic({\n apiKey: modelConfig.apiKey,\n baseURL: modelConfig.baseURL, // undefined for direct Anthropic, proxy URL for others\n timeout: 120000,\n maxRetries: 3\n });\n\n logger.info('Direct API configuration', {\n provider,\n model: finalModel,\n hasApiKey: !!modelConfig.apiKey,\n hasBaseURL: !!modelConfig.baseURL\n });\n\n try {\n // Build messages array\n const messages: Array<{ role: 'user' | 'assistant'; content: string }> = [\n { role: 'user', content: input }\n ];\n\n // Call Anthropic API directly (no Claude Code subprocess)\n const stream = await anthropic.messages.create({\n model: finalModel,\n max_tokens: 4096,\n system: agent.systemPrompt,\n messages,\n stream: true\n });\n\n let output = '';\n let toolCallCount = 0;\n\n // Process streaming response\n for await (const event of stream) {\n if (event.type === 'content_block_start') {\n if (event.content_block.type === 'text') {\n // Text content start\n continue;\n } else if (event.content_block.type === 'tool_use') {\n // Tool use detected\n toolCallCount++;\n const toolName = event.content_block.name || 'unknown';\n const timestamp = new Date().toISOString().split('T')[1].split('.')[0];\n const progressMsg = `\\n[${timestamp}] šŸ” Tool call #${toolCallCount}: ${toolName}\\n`;\n process.stderr.write(progressMsg);\n\n if (onStream) {\n onStream(progressMsg);\n }\n }\n } else if (event.type === 'content_block_delta') {\n if (event.delta.type === 'text_delta') {\n const chunk = event.delta.text;\n output += chunk;\n\n if (onStream && chunk) {\n onStream(chunk);\n }\n }\n } else if (event.type === 'content_block_stop') {\n if (toolCallCount > 0) {\n const timestamp = new Date().toISOString().split('T')[1].split('.')[0];\n const resultMsg = `[${timestamp}] āœ… Tool completed\\n`;\n process.stderr.write(resultMsg);\n\n if (onStream) {\n onStream(resultMsg);\n }\n }\n } else if (event.type === 'message_stop') {\n // Stream complete\n break;\n }\n\n // Flush output for immediate visibility\n if (process.stderr.uncork) {\n process.stderr.uncork();\n }\n if (process.stdout.uncork) {\n process.stdout.uncork();\n }\n }\n\n const duration = Date.now() - startTime;\n logger.info('Direct SDK completed', {\n agent: agent.name,\n provider,\n duration,\n outputLength: output.length\n });\n\n return { output, agent: agent.name };\n } catch (error: any) {\n logger.error('Direct SDK execution failed', {\n provider,\n model: finalModel,\n error: error.message\n });\n throw error;\n }\n });\n}\n"]}
1
+ {"version":3,"file":"claudeAgentDirect.js","sourceRoot":"","sources":["../../src/agents/claudeAgentDirect.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,SAAS,kBAAkB;IACzB,sCAAsC;IACtC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,KAAK,MAAM,EAAE,CAAC;QAC3E,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,MAAM,EAAE,CAAC;QAC/E,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,MAAM,EAAE,CAAC;QACnF,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;QACvE,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,WAAW,CAAC,C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AC;YAED,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;YACxC,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAE;gBAClC,KAAK,EAAE,KAAK,CAAC,IAAI;gBACjB,QAAQ;gBACR,QAAQ;gBACR,YAAY,EAAE,MAAM,CAAC,MAAM;aAC5B,CAAC,CAAC;YAEH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;QACvC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,CAAC,KAAK,CAAC,6BAA6B,EAAE;gBAC1C,QAAQ;gBACR,KAAK,EAAE,UAAU;gBACjB,KAAK,EAAE,KAAK,CAAC,OAAO;aACrB,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Direct API agent that uses Anthropic SDK without Claude Code dependency\nimport Anthropic from '@anthropic-ai/sdk';\nimport { logger } from \"../utils/logger.js\";\nimport { withRetry } from \"../utils/retry.js\";\nimport { AgentDefinition } from \"../utils/agentLoader.js\";\n\nfunction getCurrentProvider(): string {\n // Determine provider from environment\n if (process.env.PROVIDER === 'gemini' || process.env.USE_GEMINI === 'true') {\n return 'gemini';\n }\n if (process.env.PROVIDER === 'requesty' || process.env.USE_REQUESTY === 'true') {\n return 'requesty';\n }\n if (process.env.PROVIDER === 'openrouter' || process.env.USE_OPENROUTER === 'true') {\n return 'openrouter';\n }\n if (process.env.PROVIDER === 'onnx' || process.env.USE_ONNX === 'true') {\n return 'onnx';\n }\n return 'anthropic'; // Default\n}\n\nfunction getModelForProvider(provider: string): {\n model: string;\n apiKey: string;\n baseURL?: string;\n} {\n // Use DEFAULT_MODEL or COMPLETION_MODEL from environment (both supported for backward compatibility)\n const envModel = process.env.DEFAULT_MODEL || process.env.COMPLETION_MODEL;\n\n switch (provider) {\n case 'gemini':\n return {\n model: envModel || 'gemini-2.0-flash-exp',\n apiKey: process.env.GOOGLE_GEMINI_API_KEY || '',\n baseURL: process.env.GEMINI_PROXY_URL || `http://localhost:${process.env.PROXY_PORT || '3000'}`\n };\n\n case 'requesty':\n return {\n model: envModel || 'deepseek/deepseek-chat',\n apiKey: process.env.REQUESTY_API_KEY || '',\n baseURL: process.env.REQUESTY_PROXY_URL || `http://localhost:${process.env.PROXY_PORT || '3000'}`\n };\n\n case 'openrouter':\n return {\n model: envModel || 'deepseek/deepseek-chat',\n apiKey: process.env.OPENROUTER_API_KEY || '',\n baseURL: process.env.OPENROUTER_PROXY_URL || `http://localhost:${process.env.PROXY_PORT || '3000'}`\n };\n\n case 'onnx':\n return {\n model: 'onnx-local',\n apiKey: 'local',\n baseURL: process.env.ONNX_PROXY_URL || `http://localhost:${process.env.ONNX_PROXY_PORT || '3001'}`\n };\n\n case 'anthropic':\n default:\n const apiKey = process.env.ANTHROPIC_API_KEY;\n if (!apiKey) {\n throw new Error('ANTHROPIC_API_KEY is required for Anthropic provider');\n }\n return {\n model: envModel || 'claude-sonnet-4-5-20250929',\n apiKey,\n // Direct Anthropic API - no baseURL needed\n };\n }\n}\n\nexport async function claudeAgentDirect(\n agent: AgentDefinition,\n input: string,\n onStream?: (chunk: string) => void,\n modelOverride?: string\n) {\n const startTime = Date.now();\n const provider = getCurrentProvider();\n\n logger.info('Starting Direct Anthropic SDK (no Claude Code dependency)', {\n agent: agent.name,\n provider,\n input: input.substring(0, 100),\n model: modelOverride || 'default'\n });\n\n return withRetry(async () => {\n const modelConfig = getModelForProvider(provider);\n const finalModel = modelOverride || modelConfig.model;\n\n // Create Anthropic client with provider-specific configuration\n const anthropic = new Anthropic({\n apiKey: modelConfig.apiKey,\n baseURL: modelConfig.baseURL, // undefined for direct Anthropic, proxy URL for others\n timeout: 120000,\n maxRetries: 3\n });\n\n logger.info('Direct API configuration', {\n provider,\n model: finalModel,\n hasApiKey: !!modelConfig.apiKey,\n hasBaseURL: !!modelConfig.baseURL\n });\n\n try {\n // Build messages array\n const messages: Array<{ role: 'user' | 'assistant'; content: string }> = [\n { role: 'user', content: input }\n ];\n\n // Call Anthropic API directly (no Claude Code subprocess)\n const stream = await anthropic.messages.create({\n model: finalModel,\n max_tokens: 4096,\n system: agent.systemPrompt,\n messages,\n stream: true\n });\n\n let output = '';\n let toolCallCount = 0;\n\n // Process streaming response\n for await (const event of stream) {\n if (event.type === 'content_block_start') {\n if (event.content_block.type === 'text') {\n // Text content start\n continue;\n } else if (event.content_block.type === 'tool_use') {\n // Tool use detected\n toolCallCount++;\n const toolName = event.content_block.name || 'unknown';\n const timestamp = new Date().toISOString().split('T')[1].split('.')[0];\n const progressMsg = `\\n[${timestamp}] šŸ” Tool call #${toolCallCount}: ${toolName}\\n`;\n process.stderr.write(progressMsg);\n\n if (onStream) {\n onStream(progressMsg);\n }\n }\n } else if (event.type === 'content_block_delta') {\n if (event.delta.type === 'text_delta') {\n const chunk = event.delta.text;\n output += chunk;\n\n if (onStream && chunk) {\n onStream(chunk);\n }\n }\n } else if (event.type === 'content_block_stop') {\n if (toolCallCount > 0) {\n const timestamp = new Date().toISOString().split('T')[1].split('.')[0];\n const resultMsg = `[${timestamp}] āœ… Tool completed\\n`;\n process.stderr.write(resultMsg);\n\n if (onStream) {\n onStream(resultMsg);\n }\n }\n } else if (event.type === 'message_stop') {\n // Stream complete\n break;\n }\n\n // Flush output for immediate visibility\n if (process.stderr.uncork) {\n process.stderr.uncork();\n }\n if (process.stdout.uncork) {\n process.stdout.uncork();\n }\n }\n\n const duration = Date.now() - startTime;\n logger.info('Direct SDK completed', {\n agent: agent.name,\n provider,\n duration,\n outputLength: output.length\n });\n\n return { output, agent: agent.name };\n } catch (error: any) {\n logger.error('Direct SDK execution failed', {\n provider,\n model: finalModel,\n error: error.message\n });\n throw error;\n }\n });\n}\n"]}
File without changes
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=agentdb-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentdb-proxy.d.ts","sourceRoot":"","sources":["../../src/cli/agentdb-proxy.ts"],"names":[],"mappings":";AAQA,OAAO,EAAE,CAAC"}
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Stable agentic-flow bin surface for the separately versioned AgentDB CLI.
4
+ * AgentDB remains the single implementation authority.
5
+ */
6
+ await import('agentdb/cli');
7
+ export {};
8
+ //# sourceMappingURL=agentdb-proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentdb-proxy.js","sourceRoot":"","sources":["../../src/cli/agentdb-proxy.ts"],"names":[],"mappings":";AAEA;;;GAGG;AACH,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\n/**\n * Stable agentic-flow bin surface for the separately versioned AgentDB CLI.\n * AgentDB remains the single implementation authority.\n */\nawait import('agentdb/cli');\n\nexport {};\n"]}
package/dist/cli-proxy.js CHANGED
@@ -44,7 +44,7 @@ const packageJson = JSON.parse(readFileSync(pathResolve(__dirname, '../package.j
44
44
  const VERSION = packageJson.version;
45
45
  class AgenticFlowCLI {
46
46
  proxyServer = null;
47
- proxyPort = 3000;
47
+ proxyPort = parseInt(process.env.PROXY_PORT || '3000', 10);
48
48
  async start() {
49
49
  const options = parseArgs();
50
50
  if (options.version) {
@@ -226,6 +226,7 @@ class AgenticFlowCLI {
226
226
  }
227
227
  // Determine which provider to use
228
228
  const useONNX = this.shouldUseONNX(options);
229
+ const useOllama = this.shouldUseOllama(options);
229
230
  const useOpenRouter = this.shouldUseOpenRouter(options);
230
231
  const useGemini = this.shouldUseGemini(options);
231
232
  // Requesty temporarily disabled - keep proxy files for future use
@@ -254,6 +255,10 @@ class AgenticFlowCLI {
254
255
  console.log('šŸš€ Initializing Requesty proxy...');
255
256
  await this.startRequestyProxy(options.model);
256
257
  }
258
+ else if (useOllama) {
259
+ console.log('šŸš€ Initializing Ollama local proxy...');
260
+ await this.startOllamaProxy(options.model);
261
+ }
257
262
  else if (useOpenRouter) {
258
263
  console.log('šŸš€ Initializing OpenRouter proxy...');
259
264
  await this.startOpenRouterProxy(options.model);
@@ -292,6 +297,19 @@ class AgenticFlowCLI {
292
297
  }
293
298
  return false;
294
299
  }
300
+ shouldUseOllama(options) {
301
+ // Use Ollama if:
302
+ // 1. Provider is explicitly set to ollama
303
+ // 2. PROVIDER env var is set to ollama
304
+ // 3. USE_OLLAMA env var is set
305
+ if (options.provider === 'ollama' || process.env.PROVIDER === 'ollama') {
306
+ return true;
307
+ }
308
+ if (process.env.USE_OLLAMA === 'true') {
309
+ return true;
310
+ }
311
+ return false;
312
+ }
295
313
  shouldUseGemini(options) {
296
314
  // Use Gemini if:
297
315
  // 1. Provider is explicitly set to gemini
@@ -330,6 +348,12 @@ class AgenticFlowCLI {
330
348
  return false;
331
349
  }
332
350
  shouldUseOpenRouter(options) {
351
+ // Don't use OpenRouter if Ollama is explicitly requested — otherwise a stray
352
+ // OPENROUTER_API_KEY in the environment captures the run via the key-based
353
+ // auto-selection below.
354
+ if (options.provider === 'ollama' || process.env.PROVIDER === 'ollama' || process.env.USE_OLLAMA === 'true') {
355
+ return false;
356
+ }
333
357
  // Don't use OpenRouter if ONNX, Gemini, or Requesty is explicitly requested
334
358
  if (options.provider === 'onnx' || process.env.USE_ONNX === 'true' || process.env.PROVIDER === 'onnx') {
335
359
  return false;
@@ -359,6 +383,38 @@ class AgenticFlowCLI {
359
383
  }
360
384
  return false;
361
385
  }
386
+ async startOllamaProxy(modelOverride) {
387
+ // Ollama exposes an OpenAI-compatible /v1/chat/completions, which is exactly
388
+ // what AnthropicToOpenRouterProxy speaks — so this needs no new proxy class.
389
+ // The key below is a placeholder, not a credential: Ollama ignores
390
+ // Authorization entirely, and requiring a real one would defeat the point of
391
+ // a local provider.
392
+ const host = (process.env.OLLAMA_HOST || 'http://localhost:11434').replace(/\/+$/, '');
393
+ logger.info('Starting integrated Ollama proxy', { host });
394
+ const defaultModel = modelOverride ||
395
+ process.env.OLLAMA_MODEL ||
396
+ process.env.COMPLETION_MODEL ||
397
+ 'qwen2.5-coder:7b';
398
+ const capabilities = detectModelCapabilities(defaultModel);
399
+ const proxy = new AnthropicToOpenRouterProxy({
400
+ openrouterApiKey: 'ollama-local-placeholder',
401
+ openrouterBaseUrl: `${host}/v1`,
402
+ defaultModel,
403
+ capabilities: capabilities
404
+ });
405
+ proxy.start(this.proxyPort);
406
+ this.proxyServer = proxy;
407
+ process.env.ANTHROPIC_BASE_URL = `http://localhost:${this.proxyPort}`;
408
+ if (!process.env.ANTHROPIC_API_KEY) {
409
+ process.env.ANTHROPIC_API_KEY = 'sk-ant-proxy-dummy-key';
410
+ }
411
+ console.log(`šŸ”— Proxy Mode: Ollama (local, no API key)`);
412
+ console.log(`šŸ”§ Proxy URL: http://localhost:${this.proxyPort}`);
413
+ console.log(`šŸ”§ Ollama: ${host}/v1`);
414
+ console.log(`šŸ¤– Model: ${defaultModel}\n`);
415
+ // Wait for proxy to be ready
416
+ await new Promise(resolve => setTimeout(resolve, 1500));
417
+ }
362
418
  async startOpenRouterProxy(modelOverride) {
363
419
  const openrouterKey = process.env.OPENROUTER_API_KEY;
364
420
  if (!openrouterKey) {
@@ -582,6 +638,7 @@ Get your key at: https://openrouter.ai/keys
582
638
  const { AnthropicToOpenRouterProxy } = await import('./proxy/anthropic-to-openrouter.js');
583
639
  const proxy = new AnthropicToOpenRouterProxy({
584
640
  openrouterApiKey: apiKey,
641
+ openrouterBaseUrl: process.env.ANTHROPIC_PROXY_BASE_URL,
585
642
  defaultModel: finalModel
586
643
  });
587
644
  proxy.start(port);
@@ -799,13 +856,15 @@ PERFORMANCE:
799
856
  }
800
857
  // Check for API key (unless using ONNX)
801
858
  const isOnnx = options.provider === 'onnx' || process.env.USE_ONNX === 'true' || process.env.PROVIDER === 'onnx';
802
- if (!isOnnx && !useOpenRouter && !useGemini && !useRequesty && !process.env.ANTHROPIC_API_KEY) {
859
+ const isOllama = options.provider === 'ollama' || process.env.USE_OLLAMA === 'true' || process.env.PROVIDER === 'ollama';
860
+ if (!isOnnx && !isOllama && !useOpenRouter && !useGemini && !useRequesty && !process.env.ANTHROPIC_API_KEY) {
803
861
  console.error('\nāŒ Error: ANTHROPIC_API_KEY is required\n');
804
862
  console.error('Please set your API key:');
805
863
  console.error(' export ANTHROPIC_API_KEY=sk-ant-xxxxx\n');
806
864
  console.error('Or use alternative providers:');
807
865
  console.error(' --provider openrouter (requires OPENROUTER_API_KEY)');
808
866
  console.error(' --provider gemini (requires GOOGLE_GEMINI_API_KEY)');
867
+ console.error(' --provider ollama (free local inference via Ollama, no key)');
809
868
  console.error(' --provider onnx (free local inference)\n');
810
869
  process.exit(1);
811
870
  }
@@ -863,6 +922,11 @@ PERFORMANCE:
863
922
  console.log(`šŸ”§ Provider: Google Gemini`);
864
923
  console.log(`šŸ”§ Model: ${model}\n`);
865
924
  }
925
+ else if (isOllama) {
926
+ const model = options.model || process.env.OLLAMA_MODEL || process.env.COMPLETION_MODEL || 'qwen2.5-coder:7b';
927
+ console.log(`šŸ”§ Provider: Ollama (local, no API key)`);
928
+ console.log(`šŸ”§ Model: ${model}\n`);
929
+ }
866
930
  else if (options.provider === 'onnx' || process.env.USE_ONNX === 'true' || process.env.PROVIDER === 'onnx') {
867
931
  console.log(`šŸ”§ Provider: ONNX Local (Phi-4-mini)`);
868
932
  console.log(`šŸ’¾ Free local inference - no API costs`);
@@ -1048,7 +1112,7 @@ WORKERS COMMANDS:
1048
1112
  OPTIONS:
1049
1113
  --task, -t <task> Task description for agent mode
1050
1114
  --model, -m <model> Model to use (triggers OpenRouter if contains "/")
1051
- --provider, -p <name> Provider to use (anthropic, openrouter, gemini, onnx)
1115
+ --provider, -p <name> Provider to use (anthropic, openrouter, gemini, onnx, ollama)
1052
1116
  --stream, -s Enable real-time streaming output
1053
1117
  --help, -h Show this help message
1054
1118