运行时Provider CLI

OpenCode

使用 OpenCode CLI 运行 Mopheus 智能体任务。

Mopheus 通过原生 Provider 运行 SST 的 opencode CLI。将 CLI 安装在守护进程主机上,守护进程会自动发现它。

项目值
二进制文件opencode
路径覆盖变量MOPHEUS_OPENCODE_PATH
验证命令opencode --version
协议原生
任务 Skill 路径.opencode/skills/
文件系统沙箱Linux 支持

请参考 OpenCode 安装指南。二进制文件不在标准路径时:

export MOPHEUS_OPENCODE_PATH=/opt/opencode/bin/opencode
mopheus daemon start

配置模型

OpenCode 的模型 ID 格式为 provider/model。

如果需要为手动运行的 OpenCode 设置默认模型,可创建 ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "gateway/qwen3-coder",
  "small_model": "gateway/qwen3-coder"
}

使用 OpenAI-compatible 接口时,在同一个文件中配置 Provider 和模型:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "gateway/qwen3-coder",
  "provider": {
    "gateway": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "OpenAI Compatible Gateway",
      "options": {
        "baseURL": "https://api.example.com/v1",
        "apiKey": "{env:OPENCODE_API_KEY}"
      },
      "models": {
        "qwen3-coder": {
          "name": "Qwen3 Coder"
        }
      }
    }
  }
}

启动守护进程前,在其环境中设置 API 密钥:

export OPENCODE_API_KEY=your-api-key

使用 vLLM 的千问 3 模型

在 ~/.config/opencode/opencode.json 中配置 vLLM 的 OpenAI-compatible 接口:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "local/qwen3-8b",
  "provider": {
    "local": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Local vLLM",
      "options": {
        "baseURL": "http://127.0.0.1:8000/v1",
        "apiKey": "EMPTY"
      },
      "models": {
        "qwen3-8b": {
          "name": "Qwen3 8B"
        }
      }
    }
  }
}

可在 OpenCode 中运行 /models 验证模型配置。更多 Provider 选项请参考 OpenCode 模型配置指南 和 Provider 配置指南。

通用的文件系统沙箱和 workspace 会话历史说明见文件系统沙箱和 Provider CLI。