Files
MoneyPrinterTurbo/docker-compose.claude.yml
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

43 lines
1.7 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 使用 Claude 订阅(Pro / Max / Team)作为 LLM Provider 的运行方式。
#
# 与 docker-compose.release.yml 的区别:
# 1. 构建 Dockerfile.claude,容器内包含 claude CLI;
# 2. 挂载整个项目目录,使 claude_code Provider 的代码生效;
# 3. 注入 CLAUDE_CODE_OAUTH_TOKEN,容器内没有 keychain,CLI 只能用
# `claude setup-token` 生成的长期令牌完成鉴权。
#
# 启动前先导出令牌:
# export CLAUDE_CODE_OAUTH_TOKEN="$(claude setup-token)"
# docker compose -f docker-compose.claude.yml up -d --build
x-common-build: &common-build
context: .
dockerfile: Dockerfile.claude
x-common-volumes: &common-volumes
- ./:/MoneyPrinterTurbo
x-common-environment: &common-environment
# 未设置令牌时直接让 compose 报错,避免容器起来后才在生成阶段失败。
CLAUDE_CODE_OAUTH_TOKEN: ${CLAUDE_CODE_OAUTH_TOKEN:?run 'export CLAUDE_CODE_OAUTH_TOKEN="$(claude setup-token)"' first}
services:
webui:
build: *common-build
container_name: "moneyprinterturbo-webui"
ports:
- "127.0.0.1:8501:8501"
command: [ "streamlit", "run", "./webui/Main.py", "--server.address=0.0.0.0", "--server.port=8501", "--browser.serverAddress=127.0.0.1", "--server.enableCORS=True", "--browser.gatherUsageStats=False", "--client.toolbarMode=minimal", "--logger.hideWelcomeMessage=True", "--server.showEmailPrompt=False" ]
volumes: *common-volumes
environment: *common-environment
restart: always
api:
build: *common-build
container_name: "moneyprinterturbo-api"
ports:
- "127.0.0.1:8080:8080"
command: [ "python3", "main.py" ]
volumes: *common-volumes
environment: *common-environment
restart: always