diff --git a/USAGE.md b/USAGE.md index d68c0b5..5cb5943 100644 --- a/USAGE.md +++ b/USAGE.md @@ -21,7 +21,7 @@ cargo build --workspace - Rust toolchain with `cargo` - One of: - `ANTHROPIC_API_KEY` for direct API access - - `claw login` for OAuth-based auth + - `ANTHROPIC_AUTH_TOKEN` for bearer-token auth - Optional: `ANTHROPIC_BASE_URL` when targeting a proxy or local service ## Install / build the workspace @@ -105,8 +105,7 @@ export ANTHROPIC_API_KEY="sk-ant-..." ```bash cd rust -./target/debug/claw login -./target/debug/claw logout +export ANTHROPIC_AUTH_TOKEN="anthropic-oauth-or-proxy-bearer-token" ``` ### Which env var goes where @@ -116,7 +115,7 @@ cd rust | Credential shape | Env var | HTTP header | Typical source | |---|---|---|---| | `sk-ant-*` API key | `ANTHROPIC_API_KEY` | `x-api-key: sk-ant-...` | [console.anthropic.com](https://console.anthropic.com) | -| OAuth access token (opaque) | `ANTHROPIC_AUTH_TOKEN` | `Authorization: Bearer ...` | `claw login` or an Anthropic-compatible proxy that mints Bearer tokens | +| OAuth access token (opaque) | `ANTHROPIC_AUTH_TOKEN` | `Authorization: Bearer ...` | an Anthropic-compatible proxy or OAuth flow that mints bearer tokens | | OpenRouter key (`sk-or-v1-*`) | `OPENAI_API_KEY` + `OPENAI_BASE_URL=https://openrouter.ai/api/v1` | `Authorization: Bearer ...` | [openrouter.ai/keys](https://openrouter.ai/keys) | **Why this matters:** if you paste an `sk-ant-*` key into `ANTHROPIC_AUTH_TOKEN`, Anthropic's API will return `401 Invalid bearer token` because `sk-ant-*` keys are rejected over the Bearer header. The fix is a one-line env var swap — move the key to `ANTHROPIC_API_KEY`. Recent `claw` builds detect this exact shape (401 + `sk-ant-*` in the Bearer slot) and append a hint to the error message pointing at the fix. @@ -125,7 +124,7 @@ cd rust ## Local Models -`claw` can talk to local servers and provider gateways through either Anthropic-compatible or OpenAI-compatible endpoints. Use `ANTHROPIC_BASE_URL` with `ANTHROPIC_AUTH_TOKEN` for Anthropic-compatible services, or `OPENAI_BASE_URL` with `OPENAI_API_KEY` for OpenAI-compatible services. OAuth is Anthropic-only, so when `OPENAI_BASE_URL` is set you should use API-key style auth instead of `claw login`. +`claw` can talk to local servers and provider gateways through either Anthropic-compatible or OpenAI-compatible endpoints. Use `ANTHROPIC_BASE_URL` with `ANTHROPIC_AUTH_TOKEN` for Anthropic-compatible services, or `OPENAI_BASE_URL` with `OPENAI_API_KEY` for OpenAI-compatible services. ### Anthropic-compatible endpoint @@ -192,7 +191,7 @@ Reasoning variants (`qwen-qwq-*`, `qwq-*`, `*-thinking`) automatically strip `te | Provider | Protocol | Auth env var(s) | Base URL env var | Default base URL | |---|---|---|---|---| -| **Anthropic** (direct) | Anthropic Messages API | `ANTHROPIC_API_KEY` or `ANTHROPIC_AUTH_TOKEN` or OAuth (`claw login`) | `ANTHROPIC_BASE_URL` | `https://api.anthropic.com` | +| **Anthropic** (direct) | Anthropic Messages API | `ANTHROPIC_API_KEY` or `ANTHROPIC_AUTH_TOKEN` | `ANTHROPIC_BASE_URL` | `https://api.anthropic.com` | | **xAI** | OpenAI-compatible | `XAI_API_KEY` | `XAI_BASE_URL` | `https://api.x.ai/v1` | | **OpenAI-compatible** | OpenAI Chat Completions | `OPENAI_API_KEY` | `OPENAI_BASE_URL` | `https://api.openai.com/v1` | | **DashScope** (Alibaba) | OpenAI-compatible | `DASHSCOPE_API_KEY` | `DASHSCOPE_BASE_URL` | `https://dashscope.aliyuncs.com/compatible-mode/v1` | diff --git a/rust/README.md b/rust/README.md index 40eea01..e8269de 100644 --- a/rust/README.md +++ b/rust/README.md @@ -34,10 +34,10 @@ export ANTHROPIC_API_KEY="sk-ant-..." export ANTHROPIC_BASE_URL="https://your-proxy.com" ``` -Or authenticate via OAuth and let the CLI persist credentials locally: +Or provide an OAuth bearer token directly: ```bash -cargo run -p rusty-claude-cli -- login +export ANTHROPIC_AUTH_TOKEN="anthropic-oauth-or-proxy-bearer-token" ``` ## Mock parity harness @@ -80,7 +80,7 @@ Primary artifacts: | Feature | Status | |---------|--------| | Anthropic / OpenAI-compatible provider flows + streaming | ✅ | -| OAuth login/logout | ✅ | +| Direct bearer-token auth via `ANTHROPIC_AUTH_TOKEN` | ✅ | | Interactive REPL (rustyline) | ✅ | | Tool system (bash, read, write, edit, grep, glob) | ✅ | | Web tools (search, fetch) | ✅ | @@ -141,8 +141,6 @@ Top-level commands: mcp skills system-prompt - login - logout init ``` @@ -159,8 +157,8 @@ Tab completion expands slash commands, model aliases, permission modes, and rece The REPL now exposes a much broader surface than the original minimal shell: - session / visibility: `/help`, `/status`, `/sandbox`, `/cost`, `/resume`, `/session`, `/version`, `/usage`, `/stats` -- workspace / git: `/compact`, `/clear`, `/config`, `/memory`, `/init`, `/diff`, `/commit`, `/pr`, `/issue`, `/export`, `/hooks`, `/files`, `/branch`, `/release-notes`, `/add-dir` -- discovery / debugging: `/mcp`, `/agents`, `/skills`, `/doctor`, `/tasks`, `/context`, `/desktop`, `/ide` +- workspace / git: `/compact`, `/clear`, `/config`, `/memory`, `/init`, `/diff`, `/commit`, `/pr`, `/issue`, `/export`, `/hooks`, `/files`, `/release-notes` +- discovery / debugging: `/mcp`, `/agents`, `/skills`, `/doctor`, `/tasks`, `/context`, `/desktop` - automation / analysis: `/review`, `/advisor`, `/insights`, `/security-review`, `/subagent`, `/team`, `/telemetry`, `/providers`, `/cron`, and more - plugin management: `/plugin` (with aliases `/plugins`, `/marketplace`) @@ -194,7 +192,7 @@ rust/ ### Crate Responsibilities -- **api** — provider clients, SSE streaming, request/response types, auth (API key + OAuth bearer), request-size/context-window preflight +- **api** — provider clients, SSE streaming, request/response types, auth (`ANTHROPIC_API_KEY` + bearer-token support), request-size/context-window preflight - **commands** — slash command definitions, parsing, help text generation, JSON/text command rendering - **compat-harness** — extracts tool/prompt manifests from upstream TS source - **mock-anthropic-service** — deterministic `/v1/messages` mock for CLI parity tests and local harness runs