Skip to content
Merged
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
68 changes: 66 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,77 @@

## Quick start

### Step 1: Install ccb (MetaInfer currently uses the open-source Claude Code CLI; other coding agents are not yet supported — contributions welcome)
### Step 1: Install a coding agent CLI

MetaInfer launches phase-specific coding agents through a shared
`SubAgentManager`. The backend is selected by `METAINFER_AGENT_BACKEND`.

#### Claude/ccb backend

Install ccb if you want to use the Claude-compatible backend:

Open-source ccb repository: https://github.com/claude-code-best/claude-code
```
npm i -g claude-code-best
```

Run MetaInfer with:

```bash
METAINFER_AGENT_BACKEND=claude ./serve.py
```

#### Codex backend

Install the Codex CLI and configure it before starting MetaInfer. MetaInfer
does not store or pass API keys; it invokes `codex exec` and reuses your local
Codex login, environment, and config such as `$CODEX_HOME/config.toml`.

```bash
codex login
codex doctor
```

Then start MetaInfer with the Codex backend:

```bash
METAINFER_AGENT_BACKEND=codex ./serve.py
```

If the Codex binary is not named `codex` or is not on `PATH`, set:

```bash
METAINFER_AGENT_BACKEND=codex METAINFER_CODEX_BIN=/path/to/codex ./serve.py
```

#### pi backend

Install the [pi](https://pi.dev) coding agent CLI and configure a provider
before starting MetaInfer. MetaInfer does not store or pass API keys; it
invokes `pi --mode json -p` and reuses your local `~/.pi` settings and
environment variables (`PI_PROVIDER`, `PI_MODEL`, provider API keys, etc.).

```bash
npm i -g @earendil-works/pi-coding-agent
pi auth status # verify a provider is configured
```

Then start MetaInfer with the pi backend:

```bash
METAINFER_AGENT_BACKEND=pi ./serve.py
```

If the pi binary is not named `pi` or is not on `PATH`, set:

```bash
METAINFER_AGENT_BACKEND=pi METAINFER_PI_BIN=/path/to/pi ./serve.py
```

The pi backend maps the orchestrator's `effort` knob onto pi's `--thinking`
level (`low` / `medium` / `high` / `max`). Session continuation uses
`--session <id> --continue`; the session id is captured from pi's leading
`session` event so later turns can resume it.

### Step 2: Install MetaInfer
```bash
git clone https://github.com/MetaInfer/MetaInfer.git
Expand Down
67 changes: 65 additions & 2 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,76 @@

## 快速开始

### 第一步,安装ccb。(本项目目前使开源的claude code版本,暂不支持其他coding agent,欢迎贡献代码以支持更多coding agent)
### 第一步,安装一个 coding agent CLI

MetaInfer 通过统一的 `SubAgentManager` 拉起各阶段 coding agent。
后端通过 `METAINFER_AGENT_BACKEND` 选择。

#### Claude/ccb 后端

如果使用 Claude-compatible 后端,先安装 ccb:

开源ccb项目地址:https://github.com/claude-code-best/claude-code
```
npm i -g claude-code-best
```

启动时指定:

```bash
METAINFER_AGENT_BACKEND=claude ./serve.py
```

#### Codex 后端

如果使用 Codex 后端,需要先在本机安装并配置 Codex CLI。MetaInfer
不会保存或传递 API key;它只调用 `codex exec`,复用你本机已有的
Codex 登录状态、环境变量和 `$CODEX_HOME/config.toml` 等配置。

```bash
codex login
codex doctor
```

然后用 Codex 后端启动 MetaInfer:

```bash
METAINFER_AGENT_BACKEND=codex ./serve.py
```

如果 Codex 二进制不叫 `codex`,或者不在 `PATH` 里,可以显式指定:

```bash
METAINFER_AGENT_BACKEND=codex METAINFER_CODEX_BIN=/path/to/codex ./serve.py
```

#### pi 后端

如果使用 [pi](https://pi.dev) 后端,需要先在本机安装 pi 编码代理 CLI
并配置好 provider。MetaInfer 不会保存或传递 API key;它只调用
`pi --mode json -p`,复用你本机已有的 `~/.pi` 设置和环境变量
(`PI_PROVIDER`、`PI_MODEL`、各 provider 的 API key 等)。

```bash
npm i -g @earendil-works/pi-coding-agent
pi auth status # 确认已配置某个 provider
```

然后用 pi 后端启动 MetaInfer:

```bash
METAINFER_AGENT_BACKEND=pi ./serve.py
```

如果 pi 二进制不叫 `pi`,或者不在 `PATH` 里,可以显式指定:

```bash
METAINFER_AGENT_BACKEND=pi METAINFER_PI_BIN=/path/to/pi ./serve.py
```

pi 后端会把 orchestrator 的 `effort` 旋钮映射到 pi 的 `--thinking` 等级
(`low` / `medium` / `high` / `max`)。会话续接使用 `--session <id> --continue`;
session id 从 pi 流首的 `session` 事件中捕获,供后续轮次续接。

### 第二步,安装MetaInfer
```bash
git clone https://github.com/MetaInfer/MetaInfer.git
Expand Down
28 changes: 28 additions & 0 deletions metainfer/orchestrator/_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,17 @@ def restore() -> None:
def make_subagent_manager(
*,
claude_bin: str,
codex_bin: Optional[str] = None,
pi_bin: Optional[str] = None,
agent_backend: Optional[str] = None,
model: Optional[str],
permission_mode: str,
effort: str,
extra_add_dirs: List[Path],
snapshot_file: Path,
max_concurrent: int = 4,
budget: Any = None,
state_dir: Optional[Path] = None,
) -> SubAgentManager:
"""Build a SubAgentManager with the standard settings shared by every
orchestrator. Per-orchestrator customization happens via
Expand All @@ -189,16 +193,40 @@ def make_subagent_manager(

``budget`` (optional) wires the per-task :class:`TokenBudget` so
every agent launch is gated + every result's cost is recorded.

``state_dir`` (optional) scopes the pi backend's session storage to a
per-task directory (``<state_dir>/pi-sessions``) so orchestrator
sessions are invisible to a user running ``pi --continue`` from their
shell. Other backends ignore it. See ``SubAgentManager.pi_session_dir``.
"""
resolved_agent_backend = (
agent_backend
or os.environ.get("METAINFER_AGENT_BACKEND")
or "claude"
)
resolved_codex_bin = (
codex_bin
or os.environ.get("METAINFER_CODEX_BIN")
or "codex"
)
resolved_pi_bin = (
pi_bin
or os.environ.get("METAINFER_PI_BIN")
or "pi"
)
return SubAgentManager(
claude_bin=claude_bin,
codex_bin=resolved_codex_bin,
pi_bin=resolved_pi_bin,
agent_backend=resolved_agent_backend,
default_model=model,
permission_mode=permission_mode,
effort=effort,
extra_add_dirs=list(extra_add_dirs),
snapshot_file=snapshot_file,
max_concurrent=max_concurrent,
budget=budget,
pi_session_dir=(Path(state_dir) / "pi-sessions") if state_dir else None,
)


Expand Down
Loading