Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# syntax=docker/dockerfile:1
FROM oven/bun:debian AS deps
WORKDIR /app
COPY package.json bun.lockb* ./
RUN bun install --frozen-lockfile

FROM oven/bun:debian AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
ENV CI=true
RUN bun run build

FROM node:20-slim AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=8080
EXPOSE 8080
Comment on lines +18 to +19
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# 查找所有端口相关的配置
rg -n "PORT|8080|23000" --type-list | head -5
fd -type f -name "README*" -o -name "docker-compose*" -o -name ".env*" -o -name "Dockerfile*" | head -20

Repository: ding113/claude-code-hub

Length of output: 627


🏁 Script executed:

#!/bin/bash
# 在配置文件中查找端口配置
rg "8080|23000|APP_PORT|PORT" . --type md --type yml --type yaml --type dockerfile -A 2 -B 2 | head -50

Repository: ding113/claude-code-hub

Length of output: 94


🏁 Script executed:

#!/bin/bash
# 找到配置相关文件
fd -type f \( -name "README*" -o -name "docker-compose*" -o -name ".env*" -o -name "Dockerfile*" \)

Repository: ding113/claude-code-hub

Length of output: 237


🏁 Script executed:

#!/bin/bash
# 在Dockerfile中查找端口配置
cat Dockerfile | grep -n "PORT\|EXPOSE\|8080\|23000"

Repository: ding113/claude-code-hub

Length of output: 98


🏁 Script executed:

#!/bin/bash
# 在README和其他配置文件中查找端口
rg "PORT|8080|23000" . -A 2 -B 2 2>/dev/null | head -100

Repository: ding113/claude-code-hub

Length of output: 7556


🏁 Script executed:

#!/bin/bash
# 查找README文件
fd -type f -name "README*" | head -10

Repository: ding113/claude-code-hub

Length of output: 237


🏁 Script executed:

#!/bin/bash
# 查找所有提及APP_PORT的文件
rg "APP_PORT" . 2>/dev/null | head -20

Repository: ding113/claude-code-hub

Length of output: 1499


🏁 Script executed:

#!/bin/bash
# 查找所有提及23000的文件
rg "23000" . 2>/dev/null | head -20

Repository: ding113/claude-code-hub

Length of output: 2016


🏁 Script executed:

#!/bin/bash
# 读取docker-compose.yaml文件了解端口配置
cat docker-compose.yaml | head -100

Repository: ding113/claude-code-hub

Length of output: 2149


🏁 Script executed:

#!/bin/bash
# 检查应用代码中PORT的使用方式
rg "process.env.PORT|process.env.APP_PORT" src --type ts --type tsx -B 2 -A 2

Repository: ding113/claude-code-hub

Length of output: 94


🏁 Script executed:

#!/bin/bash
# 查看Dockerfile完整内容
cat Dockerfile

Repository: ding113/claude-code-hub

Length of output: 774


🏁 Script executed:

#!/bin/bash
# 查看src目录下env schema配置
cat src/lib/config/env.schema.ts | grep -A 5 -B 5 "PORT"

Repository: ding113/claude-code-hub

Length of output: 721


Dockerfile 端口配置错误:应为 3000 而非 8080

Dockerfile 第 18-19 行设置 PORT=8080 与实际部署配置不一致。根据 docker-compose.yaml,容器内部应监听端口 3000(对外通过 APP_PORT 映射为 23000)。健康检查亦使用 http://localhost:3000/api/actions/health。建议改为:

ENV PORT=3000
EXPOSE 3000
🤖 Prompt for AI Agents
In `@Dockerfile` around lines 18 - 19, The Dockerfile sets the container port to
8080 but the app and health checks expect port 3000; update the ENV PORT value
and the EXPOSE directive so they match the runtime configuration by changing ENV
PORT to 3000 and EXPOSE to 3000 (adjust the ENV PORT and EXPOSE lines
accordingly).


# 关键:确保复制了所有必要的文件,特别是 drizzle 文件夹
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The runner stage copies the node_modules directory from the builder stage. The builder stage installs all dependencies, including devDependencies, by running bun install. This means the final production image contains development dependencies, which increases its size and potential security surface.

It's a best practice to only include production dependencies in the final image. You can achieve this by adding a new stage specifically for production dependencies:

# After the 'builder' stage
FROM oven/bun:debian AS prod-deps
WORKDIR /app
COPY package.json bun.lockb* ./
RUN bun install --frozen-lockfile --production

# In the 'runner' stage
# ...
COPY --from=prod-deps /app/node_modules ./node_modules
# ...

This change will result in a smaller and more secure production image.

COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/drizzle ./drizzle
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trailing whitespace after ./drizzle

Prompt To Fix With AI
This is a comment left during a code review.
Path: Dockerfile
Line: 26:26

Comment:
trailing whitespace after `./drizzle`

How can I resolve this? If you propose a fix, please make it concise.


CMD ["node", "node_modules/.bin/next", "start"]
4 changes: 2 additions & 2 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Register via this link to get started → <a href="https://co.yes.vg/register?re
- 📊 **Real-time monitoring & analytics**: Dashboards, active sessions, consumption leaderboards, decision-chain tracing, and proxy health tracking provide second-level visibility.
- 💰 **Price sheet management**: Paginated SQL queries with debounce search and LiteLLM sync keep thousands of model prices searchable in milliseconds.
- 🔁 **Session management**: Five-minute context cache preserves decision trails, reduces vendor switches, and maintains full auditability.
- 🔄 **OpenAI compatibility layer**: Supports `/v1/chat/completions`, handles format conversions, tool calls, reasoning fields, and Codex CLI instruction injection automatically.
- 🔄 **OpenAI-compatible endpoint**: Supports `/v1/chat/completions` (OpenAI-compatible format), passes through tool calls and reasoning fields, enforces strict same-format routing with no cross-format conversion.

## ⚡️ Quick Start

Expand Down Expand Up @@ -217,7 +217,7 @@ Multi-provider pool (Claude / OpenAI / Gemini / others) + PostgreSQL + Redis
2. **Context control**: `SessionManager` fetches the five-minute cache from Redis, enforces concurrency, and records the decision chain.
3. **Rate limiting**: `RateLimitService` applies Lua-driven atomic counters for RPM, spend, and session caps, falling back gracefully if Redis is unavailable.
4. **Routing**: `ProxyProviderResolver` scores vendors with weights, priorities, breaker states, and session reuse, retrying up to three times.
5. **Forwarding & compatibility**: `ProxyForwarder` plus `ResponseTransformer` adapt Claude/OpenAI/Response formats, handle proxies, and honor model redirects.
5. **Forwarding & response handling**: `ProxyForwarder` sends requests upstream; `ProxyResponseHandler` processes response streams while preserving endpoint-native formats, with proxy support and model redirects.
6. **Observability**: Dashboards, leaderboards, and price sheets query PostgreSQL via repositories with hourly aggregations.

## 🚢 Deployment
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ PackyCode 为本软件的用户提供了特别优惠,使用此链接注册并
- 📊 **实时监控与统计**:仪表盘、活跃 Session、消耗排行榜、决策链记录、代理状态追踪,秒级掌控运行态势。
- 💰 **价格表管理**:分页查询 + SQL 优化,支持搜索防抖、LiteLLM 同步,千级模型也能快速检索。
- 🔁 **Session 管理**:5 分钟上下文缓存,记录决策链,避免频繁切换供应商并保留全链路审计。
- 🔄 **OpenAI 兼容层**:支持 `/v1/chat/completions`,自动格式转换、工具调用、reasoning 字段与 Codex CLI 指令注入
- 🔄 **OpenAI 兼容端点**:支持 `/v1/chat/completions`(OpenAI 兼容格式),工具调用与 reasoning 字段透传,严格同格式路由,无跨格式转换

## ⚡️ 快速开始 Quick Start

Expand Down Expand Up @@ -220,7 +220,7 @@ Hono + Proxy Pipeline (认证 → Session 分配 → 限流 → 供应商选择
2. **上下文管理**:`SessionManager` 从 Redis 读取 5 分钟缓存,控制并发并记录决策链。
3. **限流**:`RateLimitService` 使用 Lua 脚本原子写入 RPM/金额/并发指标,Redis 不可用则 Fail-Open 降级。
4. **调度**:`ProviderResolver` 根据权重、优先级、熔断状态与 Session 复用策略选择最佳供应商,至多 3 次重试。
5. **转发与兼容**:`ProxyForwarder` + `ResponseTransformer` 适配 Claude/OpenAI/Response API,支持代理与模型重定向。
5. **转发与响应处理**:`ProxyForwarder` 负责上游请求转发,`ProxyResponseHandler` 处理响应流并保留端点原生格式,支持代理与模型重定向。
6. **监控**:日志、排行榜、价格表等 UI 通过 `repository` 查询 PostgreSQL,以小时级聚合呈现指标。

## 🚢 部署指南 Deployment
Expand Down
3 changes: 3 additions & 0 deletions drizzle/0060_bored_gertrude_yorkes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE "notification_target_bindings" ALTER COLUMN "schedule_timezone" DROP DEFAULT;--> statement-breakpoint
ALTER TABLE "providers" ADD COLUMN "anthropic_max_tokens_preference" varchar(20);--> statement-breakpoint
ALTER TABLE "providers" ADD COLUMN "anthropic_thinking_budget_preference" varchar(20);
Comment on lines +1 to +3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verify this migration includes DROP COLUMN statements for removed join_claude_pool and codex_instructions_strategy fields - current migration only adds new columns without cleaning up deprecated ones

Prompt To Fix With AI
This is a comment left during a code review.
Path: drizzle/0060_bored_gertrude_yorkes.sql
Line: 1:3

Comment:
verify this migration includes DROP COLUMN statements for removed `join_claude_pool` and `codex_instructions_strategy` fields - current migration only adds new columns without cleaning up deprecated ones

How can I resolve this? If you propose a fix, please make it concise.

1 change: 1 addition & 0 deletions drizzle/0061_exotic_trauma.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "system_settings" ADD COLUMN "enable_thinking_budget_rectifier" boolean DEFAULT true NOT NULL;
Loading
Loading