Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ Close coordinators that are holding Bridge, then `agent-bridge upgrade`, then re
| `list_agents` | Probe workers, report remaining quota, proxy/env + coordinator policy |
| `set_preferences` | Persist coordinator mode / routing preferences |
| `dispatch_task` | Start or resume a turn in the project `cwd` |
| `create_baseline` | Save a named, immutable DSH fork point from a completed session |
| `list_baselines` | Find saved fork points and the project default |
| `set_default_baseline` | Select or clear the default for new DSH sessions |
| `wait_task` | Block up to `timeout_sec` (default 180) |
| `check_task` | Non-blocking status |
| `get_result` | Complete final result in pages + changed files |
Expand All @@ -112,6 +115,20 @@ Close coordinators that are holding Bridge, then `agent-bridge upgrade`, then re
| `list_sessions` | Known sessions |
| `end_session` | Shut down a worker process |

For DSH, finish the shared investigation in one session, then call
`create_baseline(session_id, name)` to save that point. Its returned
`baseline_id` is stable; `name` labels the fork point. Set it as the default
with `set_default_baseline(cwd, baseline_id)`. A new `dispatch_task` can override
this once with `baseline=<baseline_id>`, or use `baseline="empty"` to start
without history. Give each new branch a `fork_label`; `list_sessions` and task
results show both the branch label and its baseline. Passing `session_id`
continues that branch. Clearing the default with
`set_default_baseline(cwd, null)` keeps saved baselines available. Forking
requires the official DSH Desktop connector and a reachable Desktop Host.
`list_agents` reports `desktop.connected` and `desktop.fork_available`.
When Desktop is unavailable, new ordinary DSH tasks use ACP; fork requests fail
clearly. Existing sessions stay on their original backend.

`get_result` returns up to 60,000 characters per call. Continue with
`next_cursor` while `has_more` is true. Detailed work events remain available
through `get_transcript` and `~/.agent-bridge/transcripts/`; sparse task
Expand Down Expand Up @@ -255,6 +272,9 @@ revivable = true
| `list_agents` | 探测 worker,报告剩余额度、代理 / 环境 + 协调者策略 |
| `set_preferences` | 持久化协调者模式 / 路由偏好 |
| `dispatch_task` | 在项目 `cwd` 里开始或续上一次回合 |
| `create_baseline` | 从已完成的 DSH 会话保存带名称的不可变分叉点 |
| `list_baselines` | 查找已保存的分叉点与项目默认基线 |
| `set_default_baseline` | 为新 DSH 会话设置或清空默认基线 |
| `wait_task` | 最多等待 `timeout_sec`(默认 180) |
| `check_task` | 非阻塞状态查询 |
| `get_result` | 分页读取完整结果 + 改过的文件 |
Expand All @@ -263,6 +283,17 @@ revivable = true
| `list_sessions` | 已知会话 |
| `end_session` | 关掉 worker 进程 |

使用 DSH 时,先在一个会话中完成共同排查,再调用
`create_baseline(session_id, name)` 保存分叉点。返回的 `baseline_id` 是稳定标识,
`name` 是方便查找的标签。`set_default_baseline(cwd, baseline_id)` 将它设为项目默认基线。
新任务可用 `baseline=<baseline_id>` 临时指定其他版本,或用 `baseline="empty"`
从空白开始;用 `fork_label` 给每条新分支命名。`list_sessions` 和任务结果会同时显示
分支标签及来源基线。传入 `session_id` 会继续已有分支。
`set_default_baseline(cwd, null)` 只清空默认选择,不删除已保存的版本。
分叉需要安装官方 DSH Desktop 连接插件并保持桌面 Host 连通。
`list_agents` 会显示 `desktop.connected` 和 `desktop.fork_available`。
桌面断连时,新建普通 DSH 任务回退 ACP,分叉会明确报错;已有会话沿用原后端。

`get_result` 每次最多返回 60,000 个字符;`has_more` 为 true 时,用
`next_cursor` 继续读取。详细工作事件仍可通过 `get_transcript` 和
`~/.agent-bridge/transcripts/` 查询;任务生命周期及错误摘要写入
Expand Down
11 changes: 11 additions & 0 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,17 @@ Auth is `devin auth login` on disk or `WINDSURF_API_KEY`. `list_agents` runs `de

`dispatch_task.model` is a model id the live session advertises (`devin models list`): the level is part of the id (`swe-1-7`, `swe-1-7-medium`, `claude-opus-5-high`), so there is no `effort` option — a Bridge `effort` is ignored with a warning. An unknown id fails the turn and lists the real options. Bridge forces `bypass` after `session/new` (a fresh session starts in `accept-edits`; `DEVIN_PERMISSION_MODE` is parsed but not applied to ACP sessions). Revive uses `session/load` — Devin has no `session/resume` — and Devin ignores `noReplay`, so the persisted history is replayed as `session/update` notifications before `load` answers. Bridge resets its turn state before prompting, so `get_result` and `files_changed` for the new turn are clean, but `get_transcript` will show the replayed history again after a revive; that is a side effect, not the way to fetch history. Mode and model survive the reload. A long session may take longer than the 60 s handshake timeout to replay; if that bites, lower `idle_unload_sec` for devin or open a new session.

## Worker: DeepSeek Harness (DSH)

Install the [Desktop connector](https://github.com/renjieah/agent-bridge-dsh-desktop-connector) through the official DSH Desktop Plugins page. The bundle publishes an authenticated loopback handoff at `~/.agent-bridge/dsh-desktop.json`; this file is a credential and must stay in the user's profile. Bridge verifies it with the official `session.list` Remote. When connected, all new DSH tasks use Desktop Session Controller (`create`/`fork`, then `prompt`/`follow`). When disconnected, new ordinary tasks use ACP and forks are disabled. Existing sessions remain on their original backend. `list_agents` shows the current `desktop.connected`, `desktop.fork_available`, and `desktop.new_task_backend` values.

`dsh --profile acp` remains the ordinary-task fallback. Bridge prefers it when the installed dsh package ships `@deepseek-ai/dsh-acp-app`; older releases use `@deepseek-ai/dsh-acp-demo` (see the install note above). Auth and providers come from `$DSH_HOME` — Bridge pins no vendor.

- **Model/effort**: Desktop accepts an explicit `provider/model` and reasoning effort through `session.selectModel`. The ACP fallback keeps its existing `session/set_config_option` behavior.
- **Resume**: Desktop sessions retain their native Session ID in Bridge state. A later turn reads a fresh connector handoff after Desktop restarts and `session.prompt` restores the cold Agent. An interrupted in-flight turn is not replayed automatically.
- **Baselines/fork**: `create_baseline(session_id, name)` saves an immutable `baseline_id` from a completed Desktop session. A later `dispatch_task` with `baseline="default"`/an ID (or an omitted baseline, which follows the saved project default) calls the official `session.fork` Remote. `baseline="empty"` starts a blank session. A saved ACP baseline cannot be reused on Desktop; create a new Desktop baseline.
- **When Desktop is unavailable**: `create_baseline` and baseline dispatch fail with a clear error; ordinary new sessions fall back to ACP. When it reconnects, subsequent new sessions use Desktop again.

## Permissions

Most worker CLIs run in always-approve / skip-permissions mode. Codex CLI defaults to `--approve-for-me` (auto review + workspace-write); `--yolo` is opt-in via `[agents.codex] session_meta = { yolo = true }`. Review is the coordinator's job: `git diff`, build, tests. Cap follow-up turns at three, then the coordinator patches the rest.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ dependencies = [
"mcp>=2.0.0",
"agent-client-protocol>=0.12.0",
"httpx2>=2.5.0",
"httpx>=0.28",
"websockets>=14",
"pydantic>=2.7",
"psutil>=6.0",
]
Expand Down
6 changes: 5 additions & 1 deletion src/agent_bridge/adapters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
from agent_bridge.adapters.antigravity import AgyAdapter
from agent_bridge.adapters.base import Adapter
from agent_bridge.adapters.codex import CodexAdapter
from agent_bridge.adapters.dsh_desktop import DesktopAdapter
from agent_bridge.adapters.fake import FakeAdapter
from agent_bridge.config import AgentConfig, EnvConfig


def build_adapter(cfg: AgentConfig, home: Path, env_config: EnvConfig | None = None) -> Adapter:
def build_adapter(cfg: AgentConfig, home: Path, env_config: EnvConfig | None = None,
*, backend: str | None = None) -> Adapter:
if cfg.name == "dsh" and backend == "desktop":
return DesktopAdapter(cfg, home, env_config)
if cfg.protocol == "fake":
return FakeAdapter(cfg, home, env_config)
if cfg.protocol == "agy":
Expand Down
10 changes: 10 additions & 0 deletions src/agent_bridge/adapters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ def __init__(self, agent: AgentConfig, home: Path, env_config: EnvConfig | None
def can_revive(self) -> bool:
return self.agent.revivable

def can_fork(self) -> bool:
"""Whether this worker can create a derived session from a source one.

Defaults to False so a worker never silently produces a blank session
where the coordinator asked for an inherited one. Adapters that
implement forking override this and must still verify the capability
with the running worker before they fork.
"""
return False

@abstractmethod
async def ensure_session(self, session: Session) -> None: ...

Expand Down
Loading