# wrangler.rs **Repository Path**: agentskillmania/wrangler.rs ## Basic Information - **Project Name**: wrangler.rs - **Description**: 智能体引擎及其驾驭工具(Rust版) - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-08-02 - **Last Updated**: 2026-11-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # wrangler.rs — Rust port of colts / wrangler / sandbox A Rust rewrite of the three sibling TypeScript projects (`colts`, `wrangler`, `sandbox`) into a single cargo workspace. The goal: **a wrangler with usage identical to the original** — the same CLI binaries, flags, and behaviour. ``` wrangler.rs/ ├── Cargo.toml # workspace manifest └── crates/ ├── settings-yaml/ # ← colts/packages/settings-yaml (YAML config + deep merge) ├── llm-client/ # ← colts/packages/llm-client (LLM client + 3-level scheduler) ├── colts/ # ← colts/packages/colts (ReAct runner, state, tools, events) ├── sandbox/ # ← sandbox/sandbox/.../sandbox (wasmtime launcher + exec-in-sandbox bin) ├── sandbox-mcp/ # ← sandbox/sandbox/.../sandbox-mcp (stdio MCP server for the sandbox) ├── wrangler/ # ← wrangler/packages/wrangler (EnhancedRunner + builtin tools) ├── wrangler-devtool/ # ← wrangler/packages/wrangler-devtool (init/create/eval CLI) └── wrangler-daemon/ # ← wrangler/packages/wrangler-daemon (start/stop/status + axum HTTP) ``` The dependency graph is preserved bottom-up: `sandbox → colts (settings-yaml, llm-client) → wrangler → devtool/daemon`. ## The three CLI binaries (usage-identical to the TS originals) | Binary | Usage | Mirrors | |---|---|---| | `exec-in-sandbox` | `exec-in-sandbox [options] [--] ` (+ `version`, `install-runtime` subcommands) | `@agentskillmania/sandbox` CLI | | `wrangler-devtool` | `wrangler-devtool [options]` | `@agentskillmania/wrangler-devtool` CLI | | `wrangler-daemon` | `wrangler-daemon [--port PORT] [--host HOST]` | `@agentskillmania/wrangler-daemon` CLI | ## Build ```bash cd wrangler.rs cargo build --release # binaries land in target/release/{exec-in-sandbox,wrangler-devtool,wrangler-daemon} ``` ## Key dependency replacements (TS → Rust) These were the hard dependencies with no direct Rust equivalent; each was replaced with a native Rust solution: | TS dependency | Rust replacement | Notes | |---|---|---| | `@mariozechner/pi-ai` (multi-provider LLM gateway) | **native OpenAI-compatible HTTP client** (`reqwest`) in `llm-client/adapter.rs` | Covers OpenAI + any OpenAI-compatible base URL (ZhiPu GLM, DeepSeek, Moonshot). Replaces pi-ai's bundled openai/anthropic/genai SDKs with direct `/chat/completions` calls. | | `js-yaml` / `yaml` | `serde_yaml` | | | `immer` (immutability) | idiomatic `Clone` / `Arc` | State ops return new owned values. | | `eventemitter3` | `tokio::sync::broadcast` | Typed `RunnerEvent` enum replaces the `RunnerEventMap`. | | `p-queue` / `p-retry` / `p-timeout` | `tokio::sync::Semaphore` (FIFO) + in-flight/waiting counters + `tokio::time` | Three-level (provider→key→model) semaphore gates; no queue structure — waiters park on the semaphores. | | `zod` + `zod-to-json-schema` | `serde_json::Value` + `schemars`-style schemas | Tool params carried as JSON Schema values. | | `commander` (sandbox CLI) | hand-rolled argv parser | Matches commander's `--flag`, `--flag=val`, positional, subcommand behaviour. | | `fastify` (daemon HTTP) | `axum` | Same route structure under `/api/*`. | | `node:child_process` spawn (sandbox) | `std::process::Command` + `wasmtime` binary | Faithful: same argv, AOT `.cwasm` cache, stdout/stderr merge. | | `chalk` | ANSI/none | (CLI output kept plain where colour was cosmetic.) | | `ink`/`react` TUI | **dropped** | The `colts-cli`/`wrangler-cli` TUI packages were already deleted in the TS projects — no port needed. | ## Verifying behavioural equivalence ```bash # 1. sandbox: run a command through wasmtime (identical to the TS binary) SANDBOX_WASM_DIR=../sandbox/sandbox/packages/sandbox/wasm \ cargo run -p sandbox -- "echo hello-from-wasm-sandbox" # 2. devtool: scaffold a project (identical JSON output to the TS CLI) cargo run -p wrangler-devtool -- init --type agent /tmp/my-agent cargo run -p wrangler-devtool -- create --type skill --name my-skill # 3. daemon: full start/status/stop lifecycle cargo run -p wrangler-daemon -- start --port 3196 curl -s http://127.0.0.1:3196/api/health # {"status":"ok","version":"1.2.0"} cargo run -p wrangler-daemon -- status cargo run -p wrangler-daemon -- stop ``` ## Status - **Compiles clean**: `cargo build --release` succeeds across all 8 crates. - **Tests pass**: `cargo test --workspace` green — 2731 cases across 20 targets (each crate's integration tests are consolidated into a single `tests/suite.rs` target, so a full run finishes in minutes, not tens of minutes). 另外 127 个依赖真实 API 的集成测试由 `ENABLE_INTEGRATION_TESTS` 门控、 `cargo test` 默认静默跳过;要真跑用 `bash scripts/intg.sh`(花钱、需网络, key 从根目录 `.env` 读入)。多模态档是独立开关 `ENABLE_MULTIMODEL_INTEGRATION_TESTS`(配 `_MULTIMODEL` 系列 key)。 - **Quality gates**: `cargo fmt --check` + `cargo clippy --workspace --all-targets -- -D warnings` clean; CI runs fmt/clippy/test on every push (`.github/workflows/ci.yml`). - **Multimodal**: `llm-client` supports image input (OpenAI content-parts shape) end to end — daemon `POST /chat` accepts `attachments`, session history and persistence carry parts; plain-text wire format is unchanged. - **CLIs verified equivalent**: side-by-side `version`/`help`/`echo`/`init`/`eval`/`start-stop-status` match the TS originals. - **Out of scope (by design)**: native Anthropic/Gemini/Bedrock/Mistral provider SDKs (only the OpenAI-compatible path is ported — extensible behind the `LLMProvider`/adapter). These are additive on top of the compiled foundation; the CLI usage does not change. ```