feat: dual execution model (SSH CLI + HTTP pull)
- ExecutionMode enum: SshCli (orchestrator dispatches) | HttpPull (agent pulls) - SSH CLI executor: spawn remote agents via ssh + CLI template - Local subprocess as SSH special case (localhost) - HostConfig with capability matching and load-based selection - Dispatch loop: scan created tasks → select host → execute → update - CliAdapterConfig: CLI templates for Codex and Claude Code - Structured prompt construction (Issue → goal/constraints/validation) - Output parsers: Codex JSON, Claude Code JSON, raw fallback - TaskStatus::ReviewPending + review_count loop limit - Forgejo webhook: pull_request (opened→review_pending, merged→completed) - Forgejo webhook: push events (task/* branch → last_activity_at) - HTTP API: dequeue only returns http_pull tasks - HTTP API: status update only for http_pull mode - Token auth config for http_pull agents - Adapter module rewritten: AgentAdapter trait removed → config-driven CLI templates - New fields: execution_mode, assigned_host, branch_name, pr_title, last_activity_at, review_count - 30/30 tests pass
This commit is contained in:
parent
1bc7580ecc
commit
e39a16498c
34 changed files with 2541 additions and 1555 deletions
46
openspec/changes/dual-execution-model/proposal.md
Normal file
46
openspec/changes/dual-execution-model/proposal.md
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
## Why
|
||||
|
||||
当前 `adapter-cross-machine-revision` change 设计了纯 Pull 模型(Agent 主动调 HTTP API 拉取任务),但这不是 subprocess CLI 的真正跨机等价:
|
||||
|
||||
- **subprocess CLI**:Orchestrator 主动拉起 Agent,构造上下文,控制生命周期。Agent 跑完退出。
|
||||
- **HTTP Pull**:Agent 必须自己已经在运行,自己来拉任务,自己管生命周期。控制权反转。
|
||||
|
||||
Pull 模型无法解决:
|
||||
1. **上下文传递**:Agent 拉到 task JSON 后要自己构建 prompt、加载仓库、决定怎么执行
|
||||
2. **Agent 不在运行**:Orchestrator 无法启动远程机器上的 Agent
|
||||
3. **生命周期管理**:Orchestrator 无法控制 Agent 启停
|
||||
|
||||
而 **SSH + CLI 才是 subprocess 的真正跨机等价**:控制流、上下文传递、生命周期管理与本地 spawn 完全一致。
|
||||
|
||||
同时,HTTP Pull 模式对**外部 Agent**(OpenClaw/Jeeves、Hermes 等)仍有价值——这些 Agent 有自己的调度和运行时,只需要通过 API 查询/更新状态。
|
||||
|
||||
因此需要设计**双执行模型**。
|
||||
|
||||
## What Changes
|
||||
|
||||
- 新增 **SSH + CLI 执行模式**:Orchestrator 通过 SSH 在远程机器上 spawn Agent CLI,传入结构化 prompt,收集输出
|
||||
- **保留 HTTP API**:供外部 Agent(OpenClaw/Jeeves、Hermes 等)自主接入
|
||||
- Task 模型新增 `execution_mode` 字段:`ssh_cli` | `http_pull`
|
||||
- Orchestrator 根据执行模式选择调度策略:
|
||||
- `ssh_cli`:Orchestrator 主动 spawn → 等待完成 → 解析输出 → 生成 receipt
|
||||
- `http_pull`:Agent 自主 dequeue → 自行执行 → 提交 receipt
|
||||
- 新增 **SSH host 配置**:每台远程机器的 SSH 连接信息
|
||||
- 新增 **CLI 命令模板**:每种 Agent 类型的 CLI 调用模板(claude、codex、opencode)
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
- `ssh-cli-execution`: Orchestrator 通过 SSH + CLI 在远程机器上执行 Agent,是 subprocess 的跨机等价
|
||||
- `host-management`: 远程主机管理(SSH 连接、Agent CLI 可用性检查)
|
||||
|
||||
### Modified Capabilities
|
||||
- `task-assignment-protocol`: 补充双执行模式——`ssh_cli`(Orchestrator 主动调度)和 `http_pull`(Agent 自主拉取)
|
||||
- `agent-adapter`: Adapter 定义为 CLI 命令模板 + 输出解析器,不再是 trait 或 protocol 描述
|
||||
- `notification-via-forgejo`: 通知机制在两种模式下都适用(SSH CLI 模式的 Agent 也会创建 PR)
|
||||
|
||||
## Impact
|
||||
|
||||
- **代码**:新增 `src/execution/` 模块(SSH executor + CLI template + output parser)
|
||||
- **配置**:新增 `[hosts]` section(远程机器 SSH 信息)和 agent CLI 模板
|
||||
- **Task 模型**:新增 `execution_mode` 字段
|
||||
- **依赖**:新增 `ssh2` 或 `tokio-process` + SSH 相关 crate
|
||||
Loading…
Add table
Add a link
Reference in a new issue