diff --git a/docs/rust-replatform.md b/docs/rust-replatform.md index 522e04c9..2b708415 100644 --- a/docs/rust-replatform.md +++ b/docs/rust-replatform.md @@ -46,6 +46,18 @@ cargo run -p proxypilot-rs -- account remove --name old-account cargo run -p proxypilot-rs -- run --config proxypilot-rs.toml ``` +Run the local Codex-compatible smoke check without touching real provider +accounts: + +```bash +cd rust +./scripts/codex-smoke.sh +``` + +The smoke check starts a local mock upstream, saves a temporary Codex account, +starts the Rust proxy, and verifies `/healthz`, `/v0/runtime/stats`, +`/v1/models`, `/v1/chat/completions`, and `/v1/responses`. + Open the TUI with: ```bash diff --git a/rust/.gitignore b/rust/.gitignore new file mode 100644 index 00000000..2f7896d1 --- /dev/null +++ b/rust/.gitignore @@ -0,0 +1 @@ +target/ diff --git a/rust/proxypilot-rs/src/cli.rs b/rust/proxypilot-rs/src/cli.rs index 9e1aa422..f8066951 100644 --- a/rust/proxypilot-rs/src/cli.rs +++ b/rust/proxypilot-rs/src/cli.rs @@ -32,8 +32,6 @@ pub enum Command { }, /// Manage local account state for the Rust rewrite. Account { - #[command(flatten)] - shared: SharedConfig, #[command(subcommand)] command: AccountCommand, }, diff --git a/rust/scripts/codex-smoke.sh b/rust/scripts/codex-smoke.sh new file mode 100755 index 00000000..98f45f56 --- /dev/null +++ b/rust/scripts/codex-smoke.sh @@ -0,0 +1,128 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +RUST_DIR="$ROOT_DIR/rust" +TMP_DIR="$(mktemp -d)" +MOCK_PORT=18318 +PROXY_PORT=18319 +MOCK_PID="" +PROXY_PID="" +BIN="$RUST_DIR/target/debug/proxypilot-rs" + +cleanup() { + if [[ -n "$PROXY_PID" ]]; then + kill "$PROXY_PID" 2>/dev/null || true + wait "$PROXY_PID" 2>/dev/null || true + fi + if [[ -n "$MOCK_PID" ]]; then + kill "$MOCK_PID" 2>/dev/null || true + wait "$MOCK_PID" 2>/dev/null || true + fi + rm -rf "$TMP_DIR" +} +trap cleanup EXIT + +cat > "$TMP_DIR/mock_codex.py" <<'PY' +import json +from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer + + +class Handler(BaseHTTPRequestHandler): + def _send(self, payload): + body = json.dumps(payload).encode("utf-8") + self.send_response(200) + self.send_header("content-type", "application/json") + self.send_header("content-length", str(len(body))) + self.end_headers() + self.wfile.write(body) + + def do_GET(self): + if self.path == "/v1/models": + self._send({"object": "list", "data": [{"id": "gpt-5.1-codex-smoke"}]}) + return + self.send_error(404) + + def do_POST(self): + length = int(self.headers.get("content-length", "0")) + self.rfile.read(length) + if self.path == "/v1/chat/completions": + self._send({ + "id": "chatcmpl-smoke", + "object": "chat.completion", + "choices": [{"message": {"role": "assistant", "content": "ok"}}], + }) + return + if self.path == "/v1/responses": + self._send({ + "id": "resp_smoke", + "object": "response", + "output": [{"type": "message", "content": [{"type": "output_text", "text": "ok"}]}], + }) + return + self.send_error(404) + + def log_message(self, format, *args): + return + + +ThreadingHTTPServer(("127.0.0.1", 18318), Handler).serve_forever() +PY + +python3 "$TMP_DIR/mock_codex.py" & +MOCK_PID="$!" + +( + cd "$RUST_DIR" + cargo build -q -p proxypilot-rs +) + +cat > "$TMP_DIR/proxypilot-rs.toml" </dev/null 2>&1; then + break + fi + sleep 0.1 +done + +curl -fsS "http://127.0.0.1:${PROXY_PORT}/healthz" >/dev/null +curl -fsS "http://127.0.0.1:${PROXY_PORT}/v0/runtime/stats" | grep -q '"active_account_name":"smoke"' +curl -fsS "http://127.0.0.1:${PROXY_PORT}/v1/models" | grep -q "gpt-5.1-codex-smoke" +curl -fsS \ + -H "content-type: application/json" \ + -d '{"model":"gpt-5.1-codex-smoke","messages":[{"role":"user","content":"ping"}]}' \ + "http://127.0.0.1:${PROXY_PORT}/v1/chat/completions" | grep -q "chatcmpl-smoke" +curl -fsS \ + -H "content-type: application/json" \ + -d '{"model":"gpt-5.1-codex-smoke","input":"ping"}' \ + "http://127.0.0.1:${PROXY_PORT}/v1/responses" | grep -q "resp_smoke" + +echo "Codex Rust smoke passed"