Commit Graph

877 Commits

Author SHA1 Message Date
huangzhenpc
38e17d621d feat(claude): 实现智能请求头管理系统
核心功能:
- 支持渠道级透传设置 (修复 killcode 客户端兼容性)
- 智能客户端检测 (Claude Code、killcode、其他客户端)
- 动态请求头策略 (透传 vs 伪装)

客户端处理策略:
- Claude Code (claude-cli/*): 完全透传原始请求头
- killcode (B2/JS + Stainless SDK): 完全透传原始请求头
- 其他客户端: 伪装成 killcode 格式绕过上游限制

技术改进:
- 防止显示 Go-http-client/2.0 User-Agent
- 保留重要认证头部 (anthropic-version, anthropic-beta)
- 兼容全局透传和渠道透传设置

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-26 16:24:51 +08:00
huangzhenpc
a8b11912df fix(claude): 修复 Claude 适配器不支持渠道透传的问题
- 将条件从只检查全局透传改为全局透传或渠道透传
- 与其他适配器保持一致的透传逻辑
- 修复 killcode 客户端在仅开启渠道透传时无法正常工作的问题

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-26 15:31:56 +08:00
huangzhenpc
60af0d1682 更新到官方v0.9.0-alpha.8真正最新版本并恢复自定义功能
 更新到官方真正的最新版本 v0.9.0-alpha.8
 恢复 Footer.jsx 自定义页脚 (听泉claude提供)
 恢复 Claude 穿透功能到 adaptor.go
 恢复 Docker 自定义配置 (端口3099)
 添加 service/channel_state_reporter.go

关键更新:
- 文件格式从 .js 更新为 .jsx (官方最新格式)
- Claude adaptor 保持穿透功能兼容性
- 全新的界面和功能改进

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-25 16:32:58 +08:00
CaIon
7fbf9c4851 feat: enhance image request handling and add async support 2025-08-24 21:52:56 +08:00
Nekohy
abcb353793 feats:add custom headers override 2025-08-24 01:02:23 +08:00
Calcium-Ion
e3a38d27f5 Merge pull request #1611 from nekohy/feats-zhipu_4v-anthropic
Feats:Standardize ClaudeHandler, add Zhipu_4v Anthropic native channel support
2025-08-23 13:48:18 +08:00
Calcium-Ion
754498a012 Merge pull request #1635 from feitianbubu/pr/fix-task-info-channel-type
Pr/fix task info channel type
2025-08-23 13:46:52 +08:00
CaIon
94536be9be fix: enhance error handling for invalid request types in relay handlers 2025-08-23 13:34:56 +08:00
CaIon
2c6a9245ee refactor: rename relay-text.go to compatible_handler.go for clarity 2025-08-23 13:13:57 +08:00
CaIon
fc18a3c89e fix: improve request handling by deep copying OpenAIResponsesRequest 2025-08-23 13:13:10 +08:00
CaIon
4f23e53002 feat: 修复重试后请求结构混乱,修复rerank端点无法使用 2025-08-23 13:12:15 +08:00
CaIon
e581422810 fix: update response body handling in OpenAI relay format 2025-08-22 17:33:20 +08:00
Calcium-Ion
ad151bb919 Merge pull request #1606 from funnycups/patch-1
fix: prompt calculation
2025-08-22 17:30:53 +08:00
feitianbubu
b5040e0182 fix: channel type nil point 2025-08-22 15:55:25 +08:00
creamlike1024
e02e1e8d4a fix: Guard against negative or zero n from ExtraBody to prevent uint underflow 2025-08-18 23:35:01 +08:00
Sh1n3zZ
974b93a8be feat: imagen for vertex channel 2025-08-18 21:49:55 +08:00
Nekohy
652d71d799 feats:Standardize ClaudeHandler, add zhipu_4v Anthropic native support 2025-08-18 13:14:48 +08:00
CaIon
f6d4c586eb fix: add nil check for Writer in FlushWriter function 2025-08-18 12:48:56 +08:00
CaIon
0a053ee633 feat: 完善gemini格式转换 2025-08-17 19:08:06 +08:00
CaIon
c18414cbe4 refactor: extract FlushWriter function for improved stream flushing 2025-08-17 15:30:31 +08:00
CaIon
998305fd00 fix: improve error handling for image edit form request parsing 2025-08-17 15:18:57 +08:00
CaIon
49ab1a3b38 fix: remove unnecessary option from error handling in image request conversion 2025-08-17 15:13:17 +08:00
funnycups
e3473e3c39 fix: prompt calculation
User will correctly get estimated prompt usage when upstream returns either zero or nothing.
2025-08-16 22:54:00 +08:00
CaIon
c834694992 fix: update token usage calculation 2025-08-16 19:11:15 +08:00
Calcium-Ion
206ed55db4 Merge pull request #1605 from nekohy/feats-the-flexable-params-override
Feats: use the types of gjson,the error expection,the invert and the key missing process  of the condition
2025-08-16 18:27:22 +08:00
CaIon
9b0913343c feat: add support for Midjourney relay mode based on path prefix 2025-08-16 18:26:26 +08:00
Nekohy
5696a62c27 feats:the error of gjson.True and gjson.False 2025-08-16 17:16:46 +08:00
Nekohy
11a7ac9b10 feats:custom the key missing condition 2025-08-16 16:37:09 +08:00
Nekohy
cbce487362 feats:use the types of gjson,the error expection,the invert of the condition 2025-08-16 16:31:17 +08:00
CaIon
5654d08086 feat: set API version for Azure and Vertex AI channel types 2025-08-16 14:56:19 +08:00
Calcium-Ion
73a7b33864 Merge pull request #1603 from nekohy/feats-the-flexable-params-override
feats: the flexable params override and compatible format
2025-08-16 12:32:15 +08:00
Calcium-Ion
5829bc69ca Merge pull request #1597 from wzxjohn/feature/add_openai_models
feat(relay): add OpenAI gpt-4.1 o3 o4 gpt-image-1 models
2025-08-16 12:27:20 +08:00
Nekohy
b591b4ebdf fix:moveValue bug 2025-08-16 11:58:40 +08:00
Nekohy
dd497d5bd8 feats: the flexable params override and compatible format 2025-08-16 11:27:47 +08:00
CaIon
f6a48434c1 feat: initialize channel metadata in mjproxy and relay processing 2025-08-15 19:14:29 +08:00
CaIon
0bb43aa464 refactor: update function signatures to include context and improve file handling #1599 2025-08-15 18:40:54 +08:00
wzxjohn
68b7badb80 feat(relay): add OpenAI gpt-4.1 o3 o4 gpt-image-1 models 2025-08-15 17:10:16 +08:00
CaIon
eeb421513b Merge remote-tracking branch 'origin/alpha' into alpha 2025-08-15 16:47:36 +08:00
Calcium-Ion
ef1e380bbc Merge pull request #1577 from nekohy/feats-better-adaptor-for-openrouter
Fix reasoning adaptor for openrouter
2025-08-15 16:19:24 +08:00
CaIon
d646a922ee refactor: set prompt tokens when not provided in usage 2025-08-15 15:55:01 +08:00
CaIon
8b2afcec90 fix panic 2025-08-15 15:15:21 +08:00
CaIon
726f1632b0 refactor: ensure graceful closure of response body in relay responses 2025-08-15 15:10:54 +08:00
CaIon
1cb63063f7 refactor: replace json.Marshal and json.Unmarshal with common.Marshal and common.Unmarshal 2025-08-15 14:52:17 +08:00
CaIon
5fe1ce89ec refactor: improve request type validation and enhance sensitive information masking 2025-08-15 13:20:36 +08:00
CaIon
03fc89da00 refactor: add email masking function and enhance RelayInfo logging
This commit introduces a new function, MaskEmail, to mask user email addresses in logs, preventing PII leakage. Additionally, the RelayInfo logging has been updated to utilize this new masking function, ensuring sensitive information is properly handled. The channel test logic has also been improved to dynamically determine the relay format based on the request path.
2025-08-15 12:50:27 +08:00
CaIon
7f1f368065 refactor: improve channel base URL handling and enhance RelayInfo logging 2025-08-14 22:15:18 +08:00
CaIon
89caccd4e0 refactor: enhance quota handling and logging for pre-consume operations 2025-08-14 21:30:03 +08:00
CaIon
6748b006b7 refactor: centralize logging and update resource initialization
This commit refactors the logging mechanism across the application by replacing direct logger calls with a centralized logging approach using the `common` package. Key changes include:

- Replaced instances of `logger.SysLog` and `logger.FatalLog` with `common.SysLog` and `common.FatalLog` for consistent logging practices.
- Updated resource initialization error handling to utilize the new logging structure, enhancing maintainability and readability.
- Minor adjustments to improve code clarity and organization throughout various modules.

This change aims to streamline logging and improve the overall architecture of the codebase.
2025-08-14 21:10:04 +08:00
CaIon
e2037ad756 refactor: Introduce pre-consume quota and unify relay handlers
This commit introduces a major architectural refactoring to improve quota management, centralize logging, and streamline the relay handling logic.

Key changes:
- **Pre-consume Quota:** Implements a new mechanism to check and reserve user quota *before* making the request to the upstream provider. This ensures more accurate quota deduction and prevents users from exceeding their limits due to concurrent requests.

- **Unified Relay Handlers:** Refactors the relay logic to use generic handlers (e.g., `ChatHandler`, `ImageHandler`) instead of provider-specific implementations. This significantly reduces code duplication and simplifies adding new channels.

- **Centralized Logger:** A new dedicated `logger` package is introduced, and all system logging calls are migrated to use it, moving this responsibility out of the `common` package.

- **Code Reorganization:** DTOs are generalized (e.g., `dalle.go` -> `openai_image.go`) and utility code is moved to more appropriate packages (e.g., `common/http.go` -> `service/http.go`) for better code structure.
2025-08-14 20:05:06 +08:00
Nekohy
c1a545ac23 feats:the Openrouter Claude thinking 2025-08-12 22:39:32 +08:00