Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
9a3d715
feat(proxy): add configurable timeout settings for providers
sususu98 Nov 12, 2025
4b0d96c
Merge branch 'ding113:dev' into dev
sususu98 Nov 12, 2025
5a3949d
fix(proxy): improve error logging for timeout issues in ProxyForwarder
sususu98 Nov 12, 2025
e3b24d2
fix(error): add new thinking format error pattern
sususu98 Nov 14, 2025
21d584b
Merge pull request #108 from sususu98/dev
ding113 Nov 14, 2025
844270c
feat(providers): add API connectivity test for Anthropic, OpenAI, and…
cto-new[bot] Nov 16, 2025
e53fae9
Update litellm-prices.json
ding113 Nov 16, 2025
ece321a
refactor: extract reusable ActiveSessionsList component
ding113 Nov 16, 2025
7fbf2ab
feat(settings): 添加供应商 URL 有效性校验并优化 API 测试逻辑
Silentely Nov 16, 2025
ee7e264
fix(i18n): import and export users translations across locales
cto-new[bot] Nov 16, 2025
16592b5
feat(i18n): import users; feat(security): harden proxy tests
cto-new[bot] Nov 16, 2025
7d13737
Merge branch 'dev' into fix-i18n-missing-users-zh-cn
Silentely Nov 16, 2025
5adf30f
refactor(providers): 提取供应商 URL 验证逻辑到独立函数
Silentely Nov 16, 2025
eb7a01e
chore: migrate from pnpm to Bun 1.3.2
ding113 Nov 16, 2025
abe81b4
feat(actions): 添加 ProviderApiResponse 类型定义
Silentely Nov 16, 2025
8a365be
feat(providers): 更新内容提取逻辑以支持多种数据类型
Silentely Nov 16, 2025
8c3fd13
fix(useCallback): 修复多个组件中 useCallback 依赖数组缺失 t 和其他函数的问题
Silentely Nov 16, 2025
4321cb0
fix: move undici from devDependencies to dependencies
ding113 Nov 16, 2025
974b792
feat(settings): 更新供应商模型测试功能并优化相关 UI 交互
Silentely Nov 16, 2025
176ecee
Update bun.lock
ding113 Nov 16, 2025
8ee0dbc
feat: add cache_control limit error to non-retryable client errors
ding113 Nov 16, 2025
6ecf501
feat(settings): 更新 OpenAI 兼容接口状态并优化模型选择逻辑
Silentely Nov 16, 2025
a2ccddb
feat(settings): 回退模型测试配置逻辑并更新多语言描述
Silentely Nov 16, 2025
6721622
feat: add extra inputs validation error to non-retryable list
ding113 Nov 16, 2025
94cd5db
feat(providers): 修复OpenAI 响应测试输入错误格式
Silentely Nov 16, 2025
d61717f
fix(settings): 移除 API 测试按钮组件中不必要的最大宽度限制
Silentely Nov 16, 2025
47930ed
feat(providers): 修复OpenAI Responses API测试输入格式
Silentely Nov 16, 2025
c57a6f1
refactor: migrate error rules to database-driven system with ReDoS pr…
ding113 Nov 16, 2025
0c095b0
chore: adjust usage logs spacing
Silentely Nov 16, 2025
1d4204e
Merge pull request #10 from Silentely/chore/usage-filters-spacing
Silentely Nov 16, 2025
bcd4608
fix: replace require() with ES6 imports to resolve build errors
ding113 Nov 17, 2025
56742aa
feat: 重构 NON_RETRYABLE_CLIENT_ERROR 为数据库驱动配置系统
ding113 Nov 17, 2025
8b20da1
chore: format code (dev-56742aa)
github-actions[bot] Nov 17, 2025
bcbc335
Merge pull request #132 from Silentely/dev
ding113 Nov 17, 2025
305405d
chore: format code (feat-test-provider-bcbc335)
github-actions[bot] Nov 17, 2025
25eeb40
fix: auto-fix CI failures in PR Build Check
claude Nov 17, 2025
cc1fcc2
fix: resolve File is not defined error during Next.js build
ding113 Nov 17, 2025
8984b1b
chore: format code (dev-cc1fcc2)
github-actions[bot] Nov 17, 2025
08b1789
fix: initialize default error rules on application startup
ding113 Nov 17, 2025
d4081d3
fix: add missing i18n keys for error rules settings
ding113 Nov 17, 2025
e5e2ae8
fix(proxy): 修复流式请求错误处理时的 orphan records 问题
sususu98 Nov 17, 2025
44ab617
feat: improve rate limit error reporting with detailed HTTP 429 respo…
ding113 Nov 17, 2025
9d87877
chore: format code (dev-44ab617)
github-actions[bot] Nov 17, 2025
6582b90
feat(settings.providers.form.modelRedirect): enable inline editing of…
cto-new[bot] Nov 17, 2025
181ec13
fix(i18n): register users namespace across locales to fix MISSING_MES…
cto-new[bot] Nov 17, 2025
316aafa
fix: resolve all PR review issues - security, UX, and code quality
ding113 Nov 17, 2025
6597474
Merge pull request #135 from ding113/feat-edit-model-redirect-117
ding113 Nov 17, 2025
8ea0488
Merge pull request #136 from ding113/fix-missing-message-users-zh-cn
ding113 Nov 17, 2025
2722f43
Merge pull request #134 from ding113/feat/test-provider
ding113 Nov 17, 2025
5e119c6
Merge remote-tracking branch 'upstream/main' into dev
sususu98 Nov 17, 2025
7849323
fix: resolve TypeScript and ESLint errors
ding113 Nov 17, 2025
016c2ef
Merge branch 'dev' into feat/timeout-settings
sususu98 Nov 17, 2025
eb6b2e7
Merge pull request #137 from sususu98/feat/timeout-settings
ding113 Nov 17, 2025
d1fc53d
fix: improve error rules UI with dropdown category selector and compl…
ding113 Nov 17, 2025
d90029f
chore: remove conflicting migration 0018_mature_nextwave
ding113 Nov 17, 2025
95fbf3d
chore: merge dev branch and resolve conflicts
ding113 Nov 17, 2025
7ca44fc
fix: regenerate timeout migration as 0019 to resolve conflict
ding113 Nov 17, 2025
19fea46
Merge pull request #126 from ding113/feat/timeout-settings
ding113 Nov 17, 2025
83366f0
fix: resolve undici module not found in Next.js standalone build
ding113 Nov 18, 2025
10bca98
docs: update Codex configuration to use gpt-5.1-codex and new feature…
ding113 Nov 18, 2025
7a141ba
fix: 将 API 测试按钮详情展示从 Sheet 改为 Dialog
ding113 Nov 18, 2025
249a222
feat: update provider test models and add Claude CLI User-Agent
ding113 Nov 18, 2025
c039542
refactor(i18n): update UI copy and remove duplicate descriptions
ding113 Nov 18, 2025
e9c504e
fix: 修复 HTTP 访问时无法复制密钥的问题
ding113 Nov 18, 2025
5d6a22a
feat(ui): 实现分组管理的可视化标签输入功能
ding113 Nov 18, 2025
b92ab9c
feat: 实现独立的用户管理页面与用户级配额系统
ding113 Nov 18, 2025
82a77ca
chore: format code (dev-b92ab9c)
github-actions[bot] Nov 18, 2025
953cf2d
feat: 完善用户管理功能和首页用户概览
ding113 Nov 18, 2025
d6d5f8b
feat(docs): 添加 Gemini CLI 使用指南
ding113 Nov 18, 2025
477c86e
chore: format code (dev-d6d5f8b)
github-actions[bot] Nov 18, 2025
7962526
Update page.tsx
ding113 Nov 18, 2025
4411f6f
feat: add support for Google Gemini API
ding113 Nov 18, 2025
f4f51bd
feat: enhance Gemini API support and update UI components
ding113 Nov 18, 2025
cebfa99
chore: format code (dev-f4f51bd)
github-actions[bot] Nov 18, 2025
c0b8d21
fix: resolve TypeScript any type errors and add Gemini provider type
ding113 Nov 18, 2025
2efc473
feat(user-form): 更新用户限制并增强错误处理
sususu98 Nov 19, 2025
18e8cf2
Merge branch 'dev' of https://github.com/sususu98/claude-code-hub int…
sususu98 Nov 19, 2025
0c875a3
fix: resolve build errors in CI/CD pipeline
ding113 Nov 19, 2025
3944f91
feat: add Gemini provider support with i18n and model filtering
ding113 Nov 19, 2025
2f4993d
fix: add missing 'gemini' provider type to validation schemas
ding113 Nov 19, 2025
4f81c54
fix: add missing 'gemini' provider type translations
ding113 Nov 19, 2025
e73798c
feat: add Gemini API direct format support
ding113 Nov 19, 2025
9514331
fix: add Gemini API authentication support (x-goog-api-key)
ding113 Nov 19, 2025
c8db403
fix: Gemini Model name detection
ding113 Nov 19, 2025
1f056ff
fix: correct Gemini CLI URL construction to include /models/{model} path
ding113 Nov 19, 2025
fe32f8e
fix: complete Gemini integration - support message parsing and token …
ding113 Nov 19, 2025
a4de075
fix(provider-selector): 增强CCR提供商代理模型匹配能力
sususu98 Nov 19, 2025
df1f0fa
Merge branch 'ding113:dev' into dev
sususu98 Nov 19, 2025
145235d
refactor: optimize quota edit dialogs with scrollable layout and dual…
ding113 Nov 19, 2025
693d219
Merge pull request #141 from sususu98/dev
ding113 Nov 19, 2025
7f2a2cf
chore: format code (dev-693d219)
github-actions[bot] Nov 19, 2025
598102a
Merge branch 'main' into dev
ding113 Nov 19, 2025
b718819
fix: 修复 Gemini adapter 类型错误并删除未使用的翻译
ding113 Nov 19, 2025
f6fb18b
Update response-handler.ts
ding113 Nov 19, 2025
e631b2b
chore: format code
ding113 Nov 19, 2025
1d6d067
feat: 端点优先格式检测 + 智能 URL 拼接预览
ding113 Nov 19, 2025
1109253
refactor: 优化 URL 预览组件
ding113 Nov 19, 2025
8aba042
Update litellm-prices.json
ding113 Nov 19, 2025
419b733
fix: 优化价格表导入和同步提示
ding113 Nov 19, 2025
f81d72e
feat: 添加开发环境 Dockerfile.dev
sususu98 Nov 19, 2025
c3055c9
Merge pull request #143 from sususu98/dev
ding113 Nov 19, 2025
b8f3abe
fix: 修复 notifications i18n 翻译问题
ding113 Nov 20, 2025
de97c7c
refactor: 优化用户创建弹框 UI 布局
ding113 Nov 20, 2025
53d1e84
fix: 修复模型重定向标记不显示的 bug 并在决策链中记录重定向信息
ding113 Nov 20, 2025
02db1de
bump version
ding113 Nov 20, 2025
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ dist
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Data directories (PostgreSQL, Redis persistent data)
data/redis
data/postgres
2 changes: 1 addition & 1 deletion .github/workflows/claude-assistant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ jobs:
# Claude 配置参数
claude_args: |
--max-turns 999
--allowedTools "Read,Write,Edit,Bash(gh:*),Bash(git:*),Bash(npm:*),Bash(pnpm:*),Bash(yarn:*),mcp__github_inline_comment__create_inline_comment"
--allowedTools "Read,Write,Edit,Bash(gh:*),Bash(git:*),Bash(npm:*),Bash(bun:*),Bash(yarn:*),mcp__github_inline_comment__create_inline_comment"

# 其他配置
use_commit_signing: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/claude-ci-autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
### 修复策略:

1. **分析错误类型**:
- ESLint/Prettier 错误 → 运行 `npm run lint:fix` 或 `pnpm lint:fix`
- ESLint/Prettier 错误 → 运行 `npm run lint:fix` 或 `bun run lint:fix`
- TypeScript 类型错误 → 修复类型定义
- 测试失败 → 分析并修复测试或代码
- 构建失败 → 检查依赖和配置
Expand All @@ -130,7 +130,7 @@ jobs:
- 使用 Read 工具查看相关文件
- 使用 Edit 工具修复问题
- 如果是格式化问题,运行相应的 lint/format 命令
- 使用 Bash(npm:*) 或 Bash(pnpm:*) 运行修复命令
- 使用 Bash(npm:*) 或 Bash(bun:*) 运行修复命令

3. **验证修复**:
- 如果可能,运行相关的测试或 lint 命令验证修复
Expand Down Expand Up @@ -180,7 +180,7 @@ jobs:

claude_args: |
--max-turns 999
--allowedTools "Read,Write,Edit,Bash(git:*),Bash(gh:*),Bash(npm:*),Bash(pnpm:*),Bash(yarn:*),Bash(bun:*),Bash(npx:*)"
--allowedTools "Read,Write,Edit,Bash(git:*),Bash(gh:*),Bash(npm:*),Bash(bun:*),Bash(yarn:*),Bash(npx:*)"

use_commit_signing: true
# workflow_run 事件不支持 track_progress,禁用以确保正常执行
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ jobs:
with:
node-version: "20"

- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
version: 9.15.0
bun-version: '1.3.2'

- name: Install dependencies and format code
run: |
pnpm install --frozen-lockfile
pnpm format
bun install --frozen-lockfile
bun run format

- name: Commit formatted code
run: |
Expand Down Expand Up @@ -131,7 +131,7 @@ jobs:

- name: Build summary
run: |
echo "Build completed successfully!"
echo "Build completed successfully!"
echo ""
echo "📦 Branch: ${{ steps.branch_info.outputs.branch_name }}"
echo "📦 Docker Images:"
Expand Down
19 changes: 9 additions & 10 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,31 @@ jobs:
- name: 📥 Checkout repository
uses: actions/checkout@v4

- name: 📦 Setup pnpm
uses: pnpm/action-setup@v4
- name: 📦 Setup Bun
uses: oven-sh/setup-bun@v1
with:
version: 9.15.0
bun-version: '1.3.2'

- name: 🟢 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'

- name: 📦 Install dependencies
run: pnpm install --frozen-lockfile
run: bun install --frozen-lockfile

- name: 🔍 Type check
run: pnpm typecheck
run: bun run typecheck

- name: 🎨 Format check
run: pnpm format:check
run: bun run format:check

- name: 🛡️ Validate migrations
run: pnpm validate:migrations
run: bun run validate:migrations

- name: Code quality checks passed
- name: Code quality checks passed
run: |
echo "All code quality checks passed!"
echo "All code quality checks passed!"
echo "📝 Type checking: OK"
echo "🎨 Code formatting: OK"
echo "🛡️ Migration validation: OK"
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,17 @@ jobs:
with:
node-version: "20"

- name: Setup pnpm
- name: Setup Bun
if: steps.check.outputs.needs_bump == 'true'
uses: pnpm/action-setup@v4
uses: oven-sh/setup-bun@v1
with:
version: 9.15.0
bun-version: '1.3.2'

- name: Install dependencies and format code
if: steps.check.outputs.needs_bump == 'true'
run: |
pnpm install --frozen-lockfile
pnpm format
bun install --frozen-lockfile
bun run format

- name: Update seed price table
if: steps.check.outputs.needs_bump == 'true'
Expand All @@ -157,11 +157,11 @@ jobs:

# 下载最新价格表
if curl -sSL -f "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json" -o public/seed/litellm-prices.json; then
echo "价格表下载成功"
echo "价格表下载成功"

# 验证 JSON 格式
if node -e "JSON.parse(require('fs').readFileSync('public/seed/litellm-prices.json', 'utf-8'))"; then
echo "JSON 格式验证通过"
echo "JSON 格式验证通过"

# 显示统计信息
TOTAL_MODELS=$(node -e "console.log(Object.keys(JSON.parse(require('fs').readFileSync('public/seed/litellm-prices.json', 'utf-8'))).length)")
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
.bun-debug.log*
.workflow/

# env files (can opt-in for committing if needed)
Expand Down
4 changes: 2 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
.bun-debug.log*

# Environment files
.env*
Expand Down Expand Up @@ -51,7 +51,7 @@ data
public/seed/litellm-prices.json

# Package manager
pnpm-lock.yaml
bun.lock
package-lock.json
yarn.lock

Expand Down
16 changes: 8 additions & 8 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@

## Build, Test, and Development Commands

- `pnpm dev` — starts Next.js (port 13500) with Turbo for local work.
- `pnpm build` / `pnpm start` — compiles the standalone production bundle and serves it.
- `pnpm lint`, `pnpm typecheck`, `pnpm format:check` — run ESLint 9, TypeScript `--noEmit`, and Prettier verification; treat failures as blockers.
- `pnpm db:generate`, `pnpm db:migrate`, `pnpm db:push`, `pnpm db:studio` — Drizzle Kit for schema evolution.
- `bun run dev` — starts Next.js (port 13500) with Turbo for local work.
- `bun run build` / `bun run start` — compiles the standalone production bundle and serves it.
- `bun run lint`, `bun run typecheck`, `bun run format:check` — run ESLint 9, TypeScript `--noEmit`, and Prettier verification; treat failures as blockers.
- `bun run db:generate`, `bun run db:migrate`, `bun run db:push`, `bun run db:studio` — Drizzle Kit for schema evolution.
- `docker compose up -d` — spins up the full stack (app, Postgres, Redis) for parity testing.

## Coding Style & Naming Conventions

- 2-space indentation, trailing commas, and single quotes follow Prettier and `eslint.config.mjs`.
- React components use PascalCase (`UsageChart.tsx`); hooks and utilities stay camelCase; route folders remain kebab-case.
- Prefer `async/await`, keep server actions inside `src/actions`, and co-locate Tailwind classes with the JSX they style.
- Run `pnpm format` before submitting wide-ranging edits.
- Run `bun run format` before submitting wide-ranging edits.

## Testing Guidelines

- Today we rely on `pnpm lint` and `pnpm typecheck` plus manual checks through `/admin`.
- Today we rely on `bun run lint` and `bun run typecheck` plus manual checks through `/admin`.
- Smoke API changes with `curl -H "Authorization: Bearer <ADMIN_TOKEN>" http://localhost:13500/api/providers`.
- New automated tests should follow `*.spec.ts` naming, live next to the feature, and wire into `package.json` scripts.
- Note any seed data or feature flags in the PR description so reviewers can reproduce your scenario.
Expand All @@ -35,10 +35,10 @@
- Follow Conventional commits (`fix:`, `chore:`, `feat:`) as seen in `git log`; keep subjects under 72 characters.
- Body text should note user impact plus migration or environment changes.
- PRs must include a short summary, screenshots or JSON samples for UI/API updates, links to issues, and migration callouts.
- Rebase onto `main`, run `pnpm lint && pnpm typecheck`, and flag anything that blocks deploy parity.
- Rebase onto `main`, run `bun run lint && bun run typecheck`, and flag anything that blocks deploy parity.

## Security & Configuration Tips

- Start from `.env.example`, rotate `ADMIN_TOKEN` before sharing previews, and scope provider keys to least privilege.
- Keep Redis, Postgres, and upstream tokens in secrets management—never in Git commits.
- Prefer `pnpm dev` with mock providers when debugging rather than production credentials.
- Prefer `bun run dev` with mock providers when debugging rather than production credentials.
105 changes: 85 additions & 20 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ Claude Code Hub 是一个 Claude Code API 代理中转服务平台,用于统
### 开发命令

```bash
pnpm dev # 启动开发服务器 (http://localhost:13500, 使用 Turbopack)
pnpm build # 构建生产版本 (自动复制 VERSION 文件)
pnpm start # 启动生产服务器
pnpm lint # 运行 ESLint
pnpm typecheck # TypeScript 类型检查
pnpm format # 格式化代码
pnpm format:check # 检查代码格式
bun run dev # 启动开发服务器 (http://localhost:13500, 使用 Turbopack)
bun run build # 构建生产版本 (自动复制 VERSION 文件)
bun run start # 启动生产服务器
bun run lint # 运行 ESLint
bun run typecheck # TypeScript 类型检查
bun run format # 格式化代码
bun run format:check # 检查代码格式
```

### 数据库命令

```bash
pnpm db:generate # 生成 Drizzle 迁移文件
pnpm db:migrate # 执行数据库迁移
pnpm db:push # 直接推送 schema 到数据库(开发环境)
pnpm db:studio # 启动 Drizzle Studio 可视化管理界面
bun run db:generate # 生成 Drizzle 迁移文件
bun run db:migrate # 执行数据库迁移
bun run db:push # 直接推送 schema 到数据库(开发环境)
bun run db:studio # 启动 Drizzle Studio 可视化管理界面
```

### Docker 部署
Expand Down Expand Up @@ -64,7 +64,7 @@ make dev # 一键启动完整开发环境

```bash
# 环境管理
make dev # 启动完整开发环境 (DB + pnpm dev)
make dev # 启动完整开发环境 (DB + bun dev)
make db # 仅启动数据库和 Redis
make stop # 停止所有服务
make status # 查看服务状态
Expand Down Expand Up @@ -118,7 +118,7 @@ curl http://localhost:13500/api/actions/health
- **Redis** + **ioredis** - 限流、会话追踪、熔断器
- **Tailwind CSS v4** + **Shadcn UI** (orange 主题) - UI 框架
- **Pino** - 结构化日志
- **包管理器**: pnpm 9.15.0
- **包管理器**: Bun 1.3+

## 架构概览

Expand Down Expand Up @@ -278,6 +278,70 @@ if (proxyConfig) {
- 企业内网环境,需要通过公司代理访问外网
- IP 限制场景,通过代理绕过 IP 封锁

### API 连通性测试

供应商管理页面提供 API 连通性测试功能,用于验证供应商 API 的可用性和配置正确性。

**功能位置**:

- 路径:设置 → 供应商管理 → 编辑/创建供应商
- 权限:仅管理员可执行

**支持的 API 格式**:

1. **Anthropic Messages API** (`/v1/messages`)
- 标准 Anthropic 格式
- 支持 cache tokens 统计

2. **OpenAI Chat Completions API** (`/v1/chat/completions`)
- OpenAI 聊天完成格式
- 支持 reasoning tokens 统计

3. **OpenAI Responses API** (`/v1/responses`)
- OpenAI Response API 格式(Claude 4 Sonnet 同款)
- 支持 input/output tokens 统计

**测试内容**:

- API 连通性(网络连接、认证)
- 响应时间测量(超时 10 秒)
- Token 用量统计
- 模型可用性验证
- 代理配置测试(如果配置了代理)

**安全限制**:

- 🔒 仅管理员可执行测试(需要登录管理后台)
- 🔒 阻止访问内部网络地址(防止 SSRF 攻击)
- localhost, 127.0.0.1
- 内网地址段:10.x.x.x, 172.16-31.x.x, 192.168.x.x
- 链路本地地址:169.254.x.x, fe80::/10
- 🔒 阻止访问危险端口
- SSH (22), Telnet (23)
- 数据库端口:MySQL (3306), PostgreSQL (5432), MongoDB (27017), Redis (6379)
- 内部服务端口

**使用场景**:

1. **新增供应商**:验证 API 配置是否正确
2. **故障排查**:诊断供应商连接问题
3. **代理测试**:验证代理配置是否生效
4. **模型验证**:确认供应商支持的模型

**测试流程**:

1. 填写供应商基本信息(URL、API 密钥、模型)
2. 选择 API 格式(根据供应商类型自动选择)
3. 点击"测试连接"按钮
4. 等待测试结果(最长 10 秒)
5. 查看详细结果(响应时间、Token 用量、响应内容)

**注意事项**:

- 测试会消耗少量 Token(约 100 tokens)
- 测试失败不影响供应商保存
- 建议在保存前先测试,确保配置正确

### 数据库 Schema

核心表结构 (`src/drizzle/schema.ts`):
Expand Down Expand Up @@ -442,16 +506,16 @@ LOG_LEVEL=info # 日志级别

**重要**: 所有布尔类型的环境变量(如 `ENABLE_SECURE_COOKIES`, `AUTO_MIGRATE`, `ENABLE_RATE_LIMIT` 等)必须使用以下值:

- **表示 `true`**: `true`, `1`, `yes`, `on` 或任何非 `false`/`0` 的值
- **表示 `false`**: `false`, `0`
- **表示 `true`**: `true`, `1`, `yes`, `on` 或任何非 `false`/`0` 的值
- **表示 `false`**: `false`, `0`

**常见错误**:

```bash
# ❌ 错误 - 字符串 "false" 会被解析为 true!
ENABLE_SECURE_COOKIES="false" # 错误:引号导致字符串被当作 true

# 正确 - 不带引号
# 正确 - 不带引号
ENABLE_SECURE_COOKIES=false # 正确:直接写 false
ENABLE_SECURE_COOKIES=0 # 正确:也可以用 0
```
Expand Down Expand Up @@ -507,8 +571,9 @@ OpenAPI 文档(`/api/actions/scalar` 和 `/api/actions/docs`)中的 server U

### 3. 数据库迁移

- 使用 `pnpm db:generate` 生成迁移文件
- 使用 `bun run db:generate` 生成迁移文件
- 生产环境使用 `AUTO_MIGRATE=true` 自动执行迁移
- `bun run db:push` (开发) 或 `bun run db:migrate` (生产)
- 索引优化: 所有查询都有对应的复合索引(参见 schema.ts 中的 index 定义)
- 时区处理: 所有 timestamp 字段使用 `withTimezone: true`

Expand All @@ -535,7 +600,7 @@ OpenAPI 文档(`/api/actions/scalar` 和 `/api/actions/docs`)中的 server U
### 7. 代码风格

- 使用 ESLint + Prettier
- 提交前运行 `pnpm typecheck` 确保类型正确
- 提交前运行 `bun run typecheck` 确保类型正确
- 遵循现有代码风格(参考 `src/app/v1/_lib/proxy/` 中的代码)

### 8. 添加新的 API 端点
Expand Down Expand Up @@ -616,9 +681,9 @@ SELECT ... LIMIT 50 OFFSET 0;
### 修改数据库 Schema

1. 修改 `src/drizzle/schema.ts`
2. 运行 `pnpm db:generate` 生成迁移文件
2. 运行 `bun run db:generate` 生成迁移文件
3. 检查生成的 SQL 文件 (`drizzle/` 目录)
4. 运行 `pnpm db:push` (开发) 或 `pnpm db:migrate` (生产)
4. 运行 `bun run db:push` (开发) 或 `bun run db:migrate` (生产)

## 故障排查

Expand Down
Loading
Loading