pi-rust README

项目的 README,来自 github.com/bigfish1913/pi-rust。合并为一个 markdown 文件:README.md。

rpi — a Rust-native coding-agent runtime

English | 简体中文

rpi project logo

crates.io downloads docs.rs license MSRV CI GitHub stars Latest release Best of Agent Harnesses

rpi is a library-first coding-agent runtime written in Rust, plus a terminal agent built on top of it. Eleven composable crates span provider adapters, a durable crash-resumable agent loop, a reusable runtime, a terminal UI, and a stable plugin ABI — so the same code works as an embedded SDK or as a ready-to-run rpi command.

rpi began as a Rust reimplementation of the Pi TypeScript SDK by Mario Zechner. It now includes its own Rust-native plugin ABI and execution infrastructure. See Acknowledgements and NOTICE for upstream attribution.

Quick start · Website · Docs · Extension catalog and submissions · rpi-extension

See it in action

rpi TUI reading a project README and displaying the run and test commands

Terminal. Run rpi in a project directory. The screenshot shows an isolated sample session and a read tool call. User guide

rpi-web with a project sidebar, tool activity and a Markdown reply

Web. Install with rpi install rpi-web, then run rpi --webserver in your project directory and open the address it prints. Web setup guide

RPI Work desktop preview with a conversation and a Git diff side by side

Desktop. RPI Work’s GPUI preview shows project sessions, conversation and Git diffs in a native window. RPI Work

Terminal and SDK recordings

rpi terminal demo — opening the built-in help without a model request

Open the terminal agent and explore /help, with no real API key or model request. Recording script: demo/tui.tape.

rpi SDK demo — an agent loop and a real tool round-trip, offline with the faux provider

The agent loop and a real write tool round-trip, recorded with no API key and no network — the same path the tests take. Source of truth is demo/sdk.tape; regenerate with task demo.

Three ways to use it

You want Depend on Start at
A working terminal coding agent nothing cargo install rpi-cli
Your own agent inside your process rpi-agent (+ rpi-ai, rpi-tools) examples/minimal
A tool/provider that extends every session rpi-plugin-sdk examples/plugin-stub

The three share one implementation. Build your tools once, debug them inside an embedded agent, and ship the same code as a cdylib plugin that the global rpi loads. See docs/agent/project-structure.md for the recommended project layout.

Install

Prebuilt binary (no Rust toolchain needed):

curl -fsSL https://raw.githubusercontent.com/bigfish1913/pi-rust/main/scripts/install.sh | sh

Verifies the published SHA-256 checksum and installs to /usr/local/bin or ~/.local/bin. Preview first with --dry-run.

On Windows (x64), run in PowerShell 5.1 or later:

& ([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing https://raw.githubusercontent.com/bigfish1913/pi-rust/main/scripts/install.ps1).Content))

Verifies the published SHA-256 checksum and installs to $env:LOCALAPPDATA\Programs\rpi. Follow the printed instructions to add it to PATH, then run rpi --version. Append -DryRun to preview, or use -Version <version> and -Dir 'C:\Tools\rpi' to select a version and directory.

From npm (requires Node.js 20+; no Rust toolchain needed):

npm install -g @bigfishnpm/rpi
rpi --version

The npm installer downloads the matching GitHub Release binary and verifies both archive and executable SHA-256 checksums pinned in the package. It supports macOS (x64/ARM64), Windows (x64), and Linux (x64 glibc/musl and ARM64 glibc).

From crates.io (requires Rust 1.88+):

cargo install rpi-cli
rpi --version

Package managers:

brew tap bigfish1913/tap && brew install rpi          # macOS (Apple silicon), Linux
scoop bucket add bigfish1913 https://github.com/bigfish1913/scoop-bucket
scoop install rpi                                     # Windows

The Homebrew formula currently supports Apple silicon on macOS. Intel Macs can use the prebuilt installer for releases with an x86_64-apple-darwin asset, or cargo install rpi-cli. A winget manifest is open for review.

From source:

git clone https://github.com/bigfish1913/pi-rust.git
cd pi-rust && cargo run -p minimal   # offline agent, no API key required

Real output of the two offline examples — no credentials, no network, identical bytes every run. Regenerate with task demo-transcript:

$ cargo run -q -p minimal
minimal example: 2 messages after run
  - user
  - assistant
assistant reply: Hello from the faux provider!
AgentEnd observed.

$ cargo run -q -p tools-example
tools example: 4 messages after run
wrote out.txt (28 bytes): "hello from the tools example"
AgentEnd observed; tool ran against OsExecutionEnv.

Quick start

The CLI

export ANTHROPIC_API_KEY=...          # or OPENAI_API_KEY for OpenAI
rpi                                   # interactive TUI
rpi -p "summarize the README"         # one-shot
rpi --mode json -p "list the crates"  # machine-readable event stream
rpi --mini -p "explain this error"    # one-shot without saving the session

--mini uses in-memory sessions and disables native durable execution. The conversation ends with the process, and session import, export, fork, and resume are unavailable. Context compaction, tools, and resource discovery work as usual. Use --tools read to limit the tool set to read, or -p for a one-shot reply.

Sessions persist as JSONL and survive a crash mid-run; rpi resumes from the last committed frame rather than replaying the turn.

Model configuration

For a custom OpenAI-compatible gateway, save the example JSON as models.json in your agent directory. Create the directory if needed. If models.json already exists, add the gateway entry under its providers object.

Environment models.json path
macOS / Linux ~/.rpi/agent/models.json
Windows %USERPROFILE%\.rpi\agent\models.json
Custom agent directory models.json inside the absolute directory set by RPI_CODING_AGENT_DIR
{
  "providers": {
    "gateway": {
      "api": "openai-completions",
      "baseUrl": "https://api.example.com/v1",
      "apiKey": "$RPI_GATEWAY_API_KEY",
      "models": [
        { "id": "your-model-id", "name": "My Gateway Model" }
      ]
    }
  }
}

Replace baseUrl and your-model-id with the values from your provider. Set the key in the shell where you launch rpi.

rpi auth check --provider gateway
rpi --model gateway/your-model-id

Use the same model ID in the launch command and in the JSON file. The user guide also covers Anthropic-compatible gateways.

Runtime diagnostics

To investigate slow model preparation, context construction, tool execution, or persistent assistant-frame writes, temporarily enable stderr diagnostics:

RPI_AGENT_DIAGNOSTICS=1 RPI_FRAME_DIAGNOSTICS=1 \
  rpi -p "reproduce the issue" 2>rpi-diagnostics.log

RPI_AGENT_DIAGNOSTICS reports context, request, tool, and session append latencies. RPI_FRAME_DIAGNOSTICS reports durable frame batching, flush barriers, and writer failures. Diagnostics are disabled when the variables are unset or set to 0; they do not change the JSONL format. See docs/debugging/rust-debugging.md for the field reference. The built-in read-only docs tool can retrieve it with {"topic":"debugging","query":"RPI_FRAME_DIAGNOSTICS"}.

Request timeouts and model compatibility

--timeout 600 limits a whole LLM request, including its streamed response. --stream-idle-timeout 300 independently limits silence between response body bytes after the response starts. Every non-empty chunk resets the idle timer, including SSE keepalives and partial frames. A stalled stream produces a retryable error; the configured retry policy controls whether it is retried. Healthy streams may run longer than the idle timeout, up to the total deadline. For HTTP error responses, rpi keeps up to 16 KiB of the body for diagnostics. If the error body stalls, rpi reports the original status and any text received within that limit. Use --stream-idle-timeout 0 to disable the idle timer. You can also set "streamIdleTimeout": 300 (seconds) in ~/.rpi/agent/settings.json; the CLI flag takes precedence. httpIdleTimeout only expires unused pooled connections and does not control an active response.

For providers with "api": "openai-completions", put compatibility flags in each model's compat object in ~/.rpi/agent/models.json, for example:

"compat": {
  "thinkingFormat": "deepseek",
  "requiresReasoningContent": true
}

requiresReasoningContent replays assistant thinking in reasoning_content, including an empty string for assistant messages without thinking. The pi name requiresReasoningContentOnAssistantMessages is accepted as an alias; if both are present, the rpi spelling wins and conflicting values produce a warning. thinkingFormat supports "openai" (the default request shape) and "deepseek" (also sends thinking: { "type": "enabled" | "disabled" } for reasoning-capable models). supportsReasoningEffort: false suppresses reasoning_effort if the gateway does not accept it. requiresThinkingAsText instead places thinking in ordinary text content. Unknown compat fields and invalid values produce warnings naming the provider and model; invalid compat objects are ignored. Other pi thinking formats are not currently supported.

The SDK

Build an agent against a deterministic in-process provider — no API key, no network, no flakiness:

use rpi_agent::AgentBuilder;
use rpi_ai::providers::faux::{FauxProvider, FauxScript};
use rpi_ai::Provider;

#[tokio::main]
async fn main() {
    // `FauxProvider::new` already returns an `Arc<Self>`.
    let provider = FauxProvider::new(FauxScript::new().with_text("Hello from the faux provider!"));
    let model = provider.default_model().clone();

    let agent = AgentBuilder::new()
        .model(model)
        .system_prompt("You are a helpful assistant.")
        .stream_fn(make_stream_fn(provider))
        .build()
        .expect("agent builds");

    let mut events = agent.subscribe();
    agent.prompt("hi").await.expect("prompt completes");

    while let Ok(ev) = events.try_recv() {
        let _ = ev; // AgentEvent::{MessageUpdate, ToolEnd, AgentEnd, …}
    }
    println!("{} messages after the run", agent.state().messages.len());
}

make_stream_fn bridges the synchronous StreamFn contract to the async provider — the full version is in examples/minimal/src/main.rs (cargo run -p minimal).

Crates

Eleven workspace crates, one shared version. Dependency direction is one-way and enforced in review:

rpi-telemetry → rpi-ai → rpi-agent → rpi-tools → rpi-harness
                    ↘ rpi-runtime

Six crates sit outside that chain:

Crate What it is
rpi-telemetry Span/event contracts with a no-op default — instrumentation is opt-in, and pulls in no tracing or OpenTelemetry backend
rpi-ai Provider-agnostic message, streaming and tool-schema types; Anthropic + OpenAI-compatible + faux providers
rpi-runtime Embeddable model catalog, credential resolution, model selection and execution bindings
rpi-agent The agent loop: AgentTool, events, hooks, queues, cancellation
rpi-tools read/write/edit/bash/powershell and the ExecutionEnv seam
rpi-durable Backend-independent checkpoint validation and assistant-progress projection; no tool execution or storage backend
rpi-harness Session tree, JSONL persistence, compaction, crash recovery, the run loop
rpi-tui Terminal UI primitives: components, layout, editor, transcript rendering
rpi-cli The rpi binary: TUI, one-shot and JSON modes, config, plugin loading
rpi-plugin-sdk The stable #[repr(C)] ABI contract for plugins. No rpi-* deps; only serde_json, behind a default json feature that can be turned off
rpi-extensions Host-side plugin loader and the async-across-ABI tool bridge

Every crate has its own README and docs.rs page. The crates/rpi-* directories and the published crate names use the same rpi- prefix.

Why rpi

Most coding agents are CLIs. rpi is a runtime with a CLI attached, which changes what you can build with it:

How it compares

Structural differences against other terminal coding agents. Facts about other tools are as of 2026-09 and change often — check their documentation; only the rpi column is maintained here.

rpi Claude Code Codex CLI opencode aider
Language Rust TypeScript Rust TypeScript/Go Python
Source available ✅ MIT ❌ ✅ ✅ ✅
Usable as an embedded library ✅ ❌ ❌ ⚠️ ⚠️
First-class plugin ABI ✅ hooks/MCP ❌ plugin API ❌
Headless server + remote client ✅ ⚠️ ✅ ✅ ⚠️
Provider-agnostic gateways ✅ ❌ ❌ ✅ ✅

If you want the most polished single-vendor experience, use the vendor's tool. rpi is for people who want to own the loop.

rpi is listed in Best of Agent Harnesses under Coding agent products, scored bounded and durable — the durable score comes from the crash-resumable JSONL sessions.

Performance

Measured on Windows 11 (x86_64), rustc 1.97.1, --release. Both scripts rebuild and re-measure on your own machine.

sh scripts/bench.sh — standalone numbers:

Metric Value
Release binary size 21.8 MiB
rpi --version wall time ~17 ms median
RSS once the agent is ready 12.0 MiB

node scripts/bench-vs-pi.mjs --pi <path-to-pi> — against native Pi on the same machine, both offline, each with a fresh isolated config directory:

Metric rpi (Rust) pi (TypeScript) Difference
--version 17.5 ms 169.5 ms 9.7× faster
Cold start 17.7 ms 189.5 ms 10.7× faster
RSS at ready 12.0 MiB 91.5 MiB 7.6× smaller
Install footprint 21.8 MiB (one binary) ~385 MiB (+ ~91 MiB Node) ~18–22× smaller

Cold start is spawn → the agent answering its first command: process creation plus full initialisation, excluding teardown and any LLM work. rpi's --version (17.5 ms) and cold start (17.7 ms) are effectively equal, so startup is process creation, not initialisation; Pi is dominated by Node boot.

Isolation caveat: rpi reads RPI_CODING_AGENT_DIR / RPI_OFFLINE, native Pi reads PI_CODING_AGENT_DIR / PI_OFFLINE. Set the matching pair for each, or rpi silently loads the machine's global plugins.

Method, raw per-run numbers, and what is not measured (LLM latency, tool-loop throughput, long sessions, TUI frame cost) are in docs/performance/benchmark-vs-pi.md.

Plugins

Plugins are Rust cdylib libraries behind a stable #[repr(C)] ABI. A plugin can register tools, providers, slash commands, event handlers, markdown renderers and discovered resources.

rpi install rpi-todo                    # prebuilt extension; no Rust toolchain needed
rpi install my-ext --path ../my-ext     # local, for development
rpi extension update [name]             # all eligible extensions, or one by name
rpi dev                                 # build + watch + live reload

Use rpi extension update to update all project-linked extensions and globally installed registry/prebuilt extensions, or rpi extension update <name> to select one by name. Updates preserve the original Cargo build backend or explicit GitHub source. Global development installs made with --path are excluded. The old rpi package update [name] remains compatible; prefer extension update for extension updates. Project linking commands remain rpi package link, rpi package list, and rpi package unlink.

The host loads project .rpi/extensions, then global ~/.rpi/agent/extensions, then any --extensions-dir.

For a new Rust plugin, start with docs/extensions/authoring.md and examples/plugin-stub. Use rpi-plugin-sdk for the cdylib ABI. If the plugin project also needs reusable session, workspace, native RPC or durable-runtime logic for a Web/ACP adapter, add rpi-extcore (rpi-extcore = "0.1"). It is a normal Rust library, not the cdylib entry point, and it does not replace rpi-plugin-sdk; a simple tool plugin should not add it unnecessarily.

Ready-to-install extensions live in the companion pi-rust/rpi-extension repository, with an online catalog.

The catalog moved from pi-rust/rpi-package to pi-rust/rpi-extension. Both spellings identify the same publisher: existing installs (including records that only stored a prebuilt:<repository> marker), --github pi-rust/rpi-package invocations, and the previous CDN prefix keep working, while version discovery and startup update checks follow the move and rewrite the recorded source.

Browse the catalog for install commands, or open the packages/ source directory for extension READMEs and examples. Start with rpi install rpi-todo above, then use the extension authoring guide to build your own.

Web access

Web access is optional, not part of the CLI's default tool set:

rpi install rpi-websearch                # websearch: titles, URLs and snippets
rpi install rpi-webfetch                 # webfetch: readable text from public pages

Restart rpi after installation to load the tools. These extensions do not provide an interactive browser: clicking, login flows and page JavaScript execution require separate browser tooling.

Subagents with inherited configuration

Install the companion rpi-subagents extension to expose delegate_task:

rpi install rpi-subagents

The host snapshots the parent's effective model/provider binding, thinking level, system prompt, resources, request options, active tools, project cwd and approval hooks. It does not reconstruct CLI defaults or pass credentials through plugin JSON. Each child runs in a separate in-memory session without copying or modifying the parent's conversation history.

The host API can narrow the inherited tool set, never expand it; delegate_task is excluded and recursive delegation is rejected. Approvals use the parent's UI, and parent completion or cancellation stops the child. This is capability inheritance and session isolation, not an OS sandbox.

Use a subagent extension that supports IndependentRun. Rust callers use AgentHarness::create_independent_run. Extensions read the active bindings with GetExecutionContext and manage runs with IndependentRun. See the subagent protocol for lifecycle and limits.

Authoring an extension

use rpi_plugin_sdk::{export_plugin, StbStringRef};

export_plugin!(|api| {
    if let Some(declare) = api.declare {
        declare(StbStringRef::from_str(r#"{"priority":60,"platforms":["linux"]}"#));
    }
    // register tools / handlers through `api`
    0
});

Start from examples/plugin-stub — a complete plugin with the full execute→poll→cancel→destroy lifecycle — and read docs/extensions/authoring.md for the safety rules, which are load-bearing rather than stylistic.

Shared local Host on Unix

rpi --host [area] runs independent Agent Sessions in one local Host process per area. It supports the ordinary interactive TUI, stdio RPC, and one-shot Mini with rpi --host [area] --mini "prompt". The default area uses ordinary Session storage. Other areas use local-host-v1/area-<name>/sessions under the agent home unless an explicit Session directory is supplied. A named area can set maxAgents (default 32, range 1–256) and idleTimeoutSeconds (default 0, disabled).

Persistent Shared Host areas on macOS

rpi --native-host                 # Open the default area's Session in the terminal
rpi --native-host work            # Open a separate area and Session
rpi --native-host --mode json     # Inspect the selected area, Host and Session IDs

First entry creates $RPI_CODING_AGENT_DIR/host.json (normally ~/.rpi/agent/host.json) and starts a detached Host. With the default settings, it starts one Persistent Agent. Clients that select the same Agent share its Session. Start each client from the workspace configured for its Agent.

The settings file starts with {"defaultArea":"default","areas":{"default":{}}}. Each area can set provider, model, tools, and maxAgents. The optional recovery object accepts restore_on_start and restart_on_crash, for example {"restore_on_start":true,"restart_on_crash":false}. Omitting recovery enables both for a named area. Within an explicit object, omitted switches default to false. The capacity and recovery settings are written when the private area configuration is first generated. The initial profile uses global model settings and available non-OAuth credentials. Its tool list defaults to read. The generated private profile and Host configuration live under hosts/<area>/ and are reused on restart. --mode json prints the configuration path for the Host control commands, including status and administrative-stop.

Set an area's runTimeoutMs before first entry to give each Persistent operation an execution deadline in milliseconds. The deadline starts after admission. The daemon signals cancellation at the deadline, then waits for the operation and its Session writes to settle. The generated private Host configuration stores the value at host.default_timeouts.run_ms and accepts an optional host.hard_timeout_limits.run_ms. Set shutdownGraceMs before first entry to report a Persistent Agent that is still closing after that many milliseconds during signal or administrative shutdown. The daemon continues waiting for settlement before completing shutdown. The private Host configuration stores the value at host.default_timeouts.shutdown_grace_ms and accepts an optional host.hard_timeout_limits.shutdown_grace_ms. A daemon with Mini control enabled requires shared Agent timer defaults to be unset.

Set idleTimeoutMs or disconnectedTimeoutMs in an area before first entry. The generated private configuration stores these values as host.default_timeouts.idle_ms and host.default_timeouts.disconnected_ms. On expiry, the idle timer can release a Persistent Agent's Session writer and capacity slot after settlement. An authenticated area Session connection keeps its Agent loaded. Set host.default_timeouts.disconnected_ms for an Agent with an area Session route to start a separate deadline when its last authenticated Session connection leaves. A new connection clears that deadline. If both timers are set, the first expired deadline applies once the Agent has settled and no Session peers remain. Running work and pending Session work retain the owner. Optional caps use the corresponding host.hard_timeout_limits fields.

The timers and restoreOnAttach require restore permission. When any of these area settings is enabled, the generated administrative policy grants restore and cancel to all declared members. Use host inspect and host profiles to get the current Unloaded revision and frozen profile reference, then run host administrative-restore to reopen the original Agent and Session. Area terminal and stdio RPC clients can then reconnect to that Session in the same daemon. Set restoreOnAttach: true before first entry to let an authenticated Session connection restore an Unloaded member directly from its frozen profile. This option is off by default. It uses the same capacity and Session writer checks as explicit Restore and leaves the administrative receipt journal for explicit requests. An administratively Closed member still requires explicit Restore. Administrative Close accepts an Unloaded revision, ends any Session connections on a loaded owner, and removes the member from configured recovery.

For a daemon that can run without loaded Agents, set host.host_idle_timeout_ms in its private configuration. It shuts down after that many consecutive milliseconds with zero resident Agents and zero control or Session connections. An in-progress lifecycle transaction can delay shutdown.

To configure more Persistent Agents in one area, add "agentProfiles":[{"name":"review","path":"/absolute/private/review.json"}] to its settings before first entry. Each private Agent profile supplies its own Agent ID, Session ID and path, and workspace. The default Agent counts toward maxAgents. Initialize the area from the default Agent's workspace. Open a declared member from its own workspace with rpi --native-host work --agent review, adding --mode json or --mode rpc as needed. The private area configuration stores those profile references and starts the declared Agents with the default member.

Set "restoreAreas":["default","work"] in the top-level host.json and declare each listed area under areas. Run rpi --native-host --restore-areas to bring the listed daemons up together from any workspace. Each area must already have a private daemon configuration with restore_on_start enabled. The command validates all listed configurations before starting any daemon, reuses running areas, and reports each result as JSON. The list is an explicit recovery policy. An area stopped with administrative-stop starts again on the next group restore if it is still listed.

Set "defaultTerminal":true in the top-level host.json to open the default area's Agent when you run bare rpi from that Agent's workspace in a terminal. Initialize the area with rpi --native-host first. Calls with arguments, redirected input or output, and other workspaces continue through the ordinary CLI. The Host terminal provides shared chat, history, and cancellation. Use the ordinary CLI entry points for the local session picker and extension UI.

The terminal supports shared text prompts, live responses, saved history, and cancellation. Use /thinking <level> while the Agent is idle to change the thinking level for subsequent prompts. All connected terminals for that Agent show the new level. Stdio RPC clients can use set_thinking_level and receive thinking_level_changed. The setting lasts while the Agent stays loaded. Restoring the Agent uses its frozen profile again. Closing a terminal disconnects its view.

Remote mode

rpi --server                        # headless agent over TCP, prints an auth token
rpi --connect host:port --token T   # TUI client with zero local agent resources

The client holds no provider, tools, extensions or session files — all agent work happens on the server, so a thin terminal anywhere can drive a beefy machine. See docs/remote/user-guide.md.

Project status

Current release 0.33.0 (eleven workspace crates, one shared version)
Stability rpi-ai, rpi-agent, rpi-tools, rpi-harness, rpi-plugin-sdk are the intended stable surface
MSRV 1.88
Platforms Linux (GNU and musl), macOS, Windows (CI runs the suite on Linux)
Binary release targets Linux (x86_64 GNU/musl, aarch64 GNU), macOS (Intel/Apple silicon), Windows (x86_64)

rpi is a self-contained Rust coding-agent stack. No Node component is required and none is loaded.

Documentation

Start with the documentation index, grouped by feature.

Contributing

Issues and PRs are welcome. Start with CONTRIBUTING.md for the build/test commands and the repository layout, and the roadmap for what is already planned. Security problems should go through SECURITY.md, not a public issue.

To submit a Rust extension from your own GitHub repository, open the extension catalog and select Get listed.

The whole test suite runs offline: cargo test --workspace --locked.

Acknowledgements

Thank you to Mario Zechner and the Pi contributors for the original TypeScript SDK and the agent, tool and session designs that formed rpi's starting point. rpi reimplements that foundation in Rust and adds its own runtime and extension infrastructure; it does not load the TypeScript SDK or its npm extensions. Upstream copyright and MIT license notices are retained in LICENSE and NOTICE.

License

MIT. See LICENSE and NOTICE.

The rpi-* crates are a Rust-native coding-agent stack.

Support

If rpi helps you, consider buying the author a coffee. Donations support continued development and maintenance. Thank you!

WeChat Pay Alipay Binance Pay
WeChat Pay donation QR code Alipay donation QR code Binance Pay donation QR code

Scan a code or click an image to view the original. On mobile, save the image and scan it from the matching app’s photo library.

Community

Join us to ask questions, share ideas and try early builds.

WeChat group QR code
WeChat — Scan to join
Telegram group QR code
Telegram — t.me/+7YfN4TZPP7Y0M2Q1

The README image refresh workflow updates the WeChat image URL daily (UTC+8) to keep the cached image current. Please open an issue if the group invitation expires.

Star history

Star History Chart

Contributors

Thank you to everyone who contributes code, documentation, bug reports and ideas.

Contributors to pi-rust

View the full contributor list · How to contribute

pi-rust (bigfish1913/pi-rust)

正在搜索数据库…

这是干什么的?rpi 是一个以 Rust 原生、库优先的方式构建的编码代理运行时,并在其之上提供了一个终端 CLI(rpi)——同一套代码既可以作为内嵌 SDK 集成到你的应用里,也可以作为一个开箱即用的终端代理,或者作为一个插件来运行。
它是命令行工具,还是可以嵌入到我代码里的库?两者都是——它提供九个可组合的 Rust crate(rpi-ai、rpi-agent、rpi-tools 等)可以直接嵌入,同时还用同一批 crate 构建了一个现成的 rpi 终端 CLI,所以你在本地调试的那套流程,和最终以二进制文件或插件形式交付的完全是同一套。
我怎么把它跑起来?下载适合你操作系统的预构建二进制文件(经过 SHA-256 校验,安装程序支持 --dry-run),或者如果你有 Rust 1.78+,运行 `cargo install rpi-cli`;Apple Silicon Mac 用户也可以用 Homebrew formula。安装完成后,`rpi --version` 可以确认安装成功,运行 `rpi` 则会启动终端界面。
只是想试试的话,需要装 Rust 工具链或者 API 密钥吗?不需要——预构建的二进制文件不需要 Rust 工具链,SDK 示例可以直接跑在一个进程内的确定性 'faux' 提供方上,不需要 API 密钥,也完全不需要联网。要真正使用时,你可以通过 ~/.rpi/agent/models.json 把它指向 Anthropic 或兼容 OpenAI 的网关。
安装上有什么坑需要提前知道?Homebrew formula 目前只在 Apple Silicon Mac 上可用——Intel Mac 用户需要改用预构建的 x86_64-apple-darwin 安装程序,或者用 `cargo install rpi-cli`。另外,rpi 和原生的 Pi 读取的环境变量名不同(RPI_* 对应 PI_*),如果没有设置配套的那一组变量,rpi 可能会静默加载机器上的全局插件。
Windows 的支持和 Linux、macOS 一样稳吗?Windows 是官方支持的发布目标,有预构建的 x86_64 二进制文件和 PowerShell 安装程序,但该项目的 CI 只在 Linux 上运行完整测试套件,所以 Windows 和 macOS 的二进制文件没有同等的自动化测试覆盖。
rpi 的插件系统和常见的插件 API 有什么不同?插件是 Rust cdylib 动态库,背后是一套手写的、带版本号的 #[repr(C)] ABI,并支持版本协商,因此即使编译器版本或 crate 版本不一致,编译好的扩展也能继续正常工作,不会每次发版就坏掉。
rpi 比它所基于的原始 TypeScript Pi 快多少?在同一台机器上测试,rpi 的冷启动大约快 10.7 倍(17.7ms 对 189.5ms),内存占用大约少 7.6 倍(12MiB 对 91.5MiB RSS),安装体积大约小 18-22 倍。
如果代理在任务执行到一半时崩溃了会怎样?会话以 JSONL 格式持久保存,并记录每一帧的进度,所以即使在工具调用中途崩溃,也会从最后一个已提交的帧恢复,不会丢失这一轮对话,也不会重复执行工具。
远程模式是什么?在远程模式下,终端客户端不持有任何提供方、工具、扩展或会话文件——所有代理工作都在服务器上进行,这样一台轻量客户端无论在哪里都能驱动一台更强大的远程机器。
大小
16.6 MB
星标
282
时长
3个月
提交 · 90 天