mirror of
https://github.com/katanemo/plano.git
synced 2026-06-14 15:15:15 +02:00
feat(claude-cli): add local Claude Code CLI provider bridge
Spawn the local `claude` binary as a subprocess and expose it as an
Anthropic Messages-compatible provider. Hosted in brightstaff
(`CLAUDE_CLI_LISTEN_ADDR`), with session reuse, idle TTL, and watchdog.
User-facing surface is `model_providers: [{ model: claude-cli/* }]` —
the Python CLI auto-fills name/provider_interface/base_url/access_key
and the launcher (native + supervisord) enables the bridge listener
only when at least one claude-cli provider is present.
This commit is contained in:
parent
b71a555f19
commit
9fdfeb7cbf
26 changed files with 2847 additions and 2 deletions
49
demos/integrations/claude_cli/README.md
Normal file
49
demos/integrations/claude_cli/README.md
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# Claude Code CLI as a Plano provider
|
||||
|
||||
This demo wires the locally installed `claude` binary as a Plano
|
||||
`model_provider`. The single line under `model_providers:`
|
||||
|
||||
```yaml
|
||||
model_providers:
|
||||
- model: claude-cli/*
|
||||
default: true
|
||||
```
|
||||
|
||||
is enough to:
|
||||
|
||||
1. Auto-fill `provider_interface: claude-cli`, `base_url: http://127.0.0.1:14001`
|
||||
and a placeholder `access_key` (the CLI uses its own login keychain).
|
||||
2. Start a localhost bridge inside `brightstaff` that spawns `claude -p
|
||||
--output-format stream-json --input-format stream-json` for each
|
||||
conversation.
|
||||
3. Expose every Claude Code model — `claude-cli/sonnet`, `claude-cli/opus`,
|
||||
`claude-cli/haiku`, plus dated full ids — at `GET /v1/models`.
|
||||
|
||||
## Running
|
||||
|
||||
```bash
|
||||
# Make sure the CLI is logged in. You can use API krey billing or a paid Claude subscription.
|
||||
claude auth login
|
||||
|
||||
# Start Plano in native mode.
|
||||
planoai up demos/integrations/claude_cli/config.yaml
|
||||
```
|
||||
|
||||
Then point any OpenAI- or Anthropic-style client at `http://localhost:12000`
|
||||
and pick any `claude-cli/...` model. Plano routes the request through Envoy
|
||||
to the brightstaff bridge, which asks the local `claude` binary to handle
|
||||
it.
|
||||
|
||||
## Optional overrides
|
||||
|
||||
Set these env vars before `planoai up` if you need to tweak the bridge:
|
||||
|
||||
|
||||
| Env var | Default | Meaning |
|
||||
| ----------------------------- | ------------------- | -------------------------------------- |
|
||||
| `CLAUDE_CLI_BIN` | `claude` | Path to the CLI binary. |
|
||||
| `CLAUDE_CLI_PERMISSION_MODE` | `bypassPermissions` | `--permission-mode` flag value. |
|
||||
| `CLAUDE_CLI_LISTEN_ADDR` | `127.0.0.1:14001` | Bridge listen address. |
|
||||
| `CLAUDE_CLI_SESSION_TTL_SECS` | `600` | Idle TTL before a child is killed. |
|
||||
| `CLAUDE_CLI_WATCHDOG_SECS` | `120` | Per-line watchdog inside one CLI turn. |
|
||||
| `CLAUDE_CLI_MAX_SESSIONS` | `64` | Hard cap on concurrent CLI children. |
|
||||
27
demos/integrations/claude_cli/config.yaml
Normal file
27
demos/integrations/claude_cli/config.yaml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
version: v0.4.0
|
||||
|
||||
# Claude Code CLI as a Plano model_provider.
|
||||
#
|
||||
# The single line below is everything you need: Plano detects the
|
||||
# `claude-cli/*` namespace, auto-fills the provider_interface, base_url and
|
||||
# placeholder access_key, and starts a localhost bridge inside brightstaff
|
||||
# that shells out to the `claude` binary on your $PATH for each request.
|
||||
#
|
||||
# Requirements:
|
||||
# - `claude --version` must work in the same shell as `planoai up`.
|
||||
# - Auth happens via the CLI's own `claude auth login` (no API key needed
|
||||
# in Plano).
|
||||
#
|
||||
# Optional overrides via env (set before `planoai up`):
|
||||
# CLAUDE_CLI_BIN=/custom/path/to/claude
|
||||
# CLAUDE_CLI_PERMISSION_MODE=default
|
||||
# CLAUDE_CLI_LISTEN_ADDR=127.0.0.1:14001
|
||||
|
||||
listeners:
|
||||
- type: model
|
||||
name: model_listener
|
||||
port: 12000
|
||||
|
||||
model_providers:
|
||||
- model: claude-cli/*
|
||||
default: true
|
||||
Loading…
Add table
Add a link
Reference in a new issue