Files
Tuan NguyenandClaude Opus 5 4f469431ab feat(llm): add Claude Code provider using a Claude subscription
Claude Pro / Max / Team subscriptions do not issue API keys, and their
credentials are only usable by Anthropic's own clients, so the existing
`anthropic` provider is unavailable to subscription-only users.

This adds a `claude_code` provider that shells out to the locally installed,
logged-in `claude` CLI in headless mode (`claude -p --output-format json`)
instead of calling the HTTP API, letting the CLI perform authentication.
Requests consume subscription usage rather than API credit.

Details:
- Registry entry needs no API key, no base URL, and no model name; an empty
  model name follows whatever default the CLI currently uses.
- The adapter replaces Claude Code's coding-agent system prompt with a
  copywriter prompt, disables all tools and external MCP config, and runs in
  a temporary working directory so a stray CLAUDE.md cannot leak into script
  output. Each call is a deterministic single-turn text generation.
- Failures are reported from the CLI's JSON payload (`is_error` / `result`)
  rather than the exit code alone, since auth and quota errors arrive as a
  non-zero exit with a readable message on stdout.
- Dockerfile.claude layers Node.js and the claude CLI onto the published
  image; docker-compose.claude.yml mounts the project and injects
  CLAUDE_CODE_OAUTH_TOKEN, which is how the CLI authenticates in a container
  where no keychain is available.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 23:59:03 +07:00

25 lines
1.1 KiB
Docker

# Claude Code 变体镜像:在官方发布镜像的基础上安装 claude CLI。
#
# Claude 订阅(Pro / Max / Team)不签发 API Key,只有 Claude Code 官方客户端
# 能使用订阅凭证,所以 `claude_code` Provider 依赖容器内存在可执行的 claude
# CLI。这里复用发布镜像,避免重新安装 Python 依赖。
FROM ghcr.io/harry0703/moneyprinterturbo:latest
# CLI 版本固定,避免镜像重建时行为漂移;升级时改这里的版本号即可。
ARG CLAUDE_CODE_VERSION=2.1.260
ARG NODE_MAJOR=22
# claude CLI 通过 npm 分发,发布镜像里没有 Node.js,需要先装 NodeSource 源。
RUN set -eu; \
apt-get update; \
apt-get install -y --no-install-recommends ca-certificates curl gnupg; \
curl -fsSL "https://deb.nodesource.com/setup_${NODE_MAJOR}.x" | bash -; \
apt-get install -y --no-install-recommends nodejs; \
npm install -g "@anthropic-ai/claude-code@${CLAUDE_CODE_VERSION}"; \
npm cache clean --force; \
apt-get purge -y gnupg; \
apt-get autoremove -y; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*; \
claude --version