UNPKG

mcp-subagents

Version:

Multi-Agent AI Orchestration via Model Context Protocol - Access specialized CLI AI agents (Aider, Qwen, Gemini, Goose, etc.) with intelligent fallback and configuration

34 lines 1.5 kB
import { BaseAgent } from './base.js'; export class OpenCodeAgent extends BaseAgent { buildCommand(_task, taskConfig) { const cmd = ['opencode', 'run']; // Get custom flags to check for duplicates const customFlags = taskConfig.flags || []; // Only add internal model if no model flags are in custom flags const hasModelFlag = customFlags.some(flag => flag === '--model' || flag === '-m' || flag.startsWith('--model=') || flag.startsWith('-m=')); if (!hasModelFlag) { // Model selection with proper priority: // 1. Task config model (highest priority) // 2. OPENCODE_MODEL from task env (config file/MCP config) // 3. OPENCODE_MODEL from process env (system environment) // 4. Config file model (from this.config.defaults) // 5. Built-in default (lowest priority, handled in registry) const model = taskConfig.model || taskConfig.env?.['OPENCODE_MODEL'] || process.env['OPENCODE_MODEL'] || this.config.defaults['model']; if (model) { cmd.push('-m', String(model)); } } // Add custom flags (overrides defaults) if (taskConfig.flags && taskConfig.flags.length > 0) { cmd.push(...taskConfig.flags); } return this.validateCommand(cmd); } getInputMethod() { return 'stdin'; } } //# sourceMappingURL=opencode.js.map