@adversity/coding-tool-x 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@
4
4
 
5
5
  该项目遵循 [Semantic Versioning](https://semver.org/)。
6
6
 
7
+ ## [3.0.2] - 2026-02-01
8
+
9
+ ### Fixed
10
+ - 🐛 **修复渠道类型检测错误** - 修复第三方代理 URL 路径包含 "claude" 时被误判为官方 Claude API 的问题
11
+ - 修改 `detectChannelType()` 函数,仅检查域名而非完整 URL 路径
12
+ - 修复 `https://code.newcli.com/claude/aws` 等第三方代理无法获取模型列表的问题
13
+ - 添加 URL 解析错误处理,增强容错性
14
+
7
15
  ## [3.0.1] - 2026-02-01
8
16
 
9
17
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adversity/coding-tool-x",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "Vibe Coding 增强工作助手 - 智能会话管理、动态渠道切换、全局搜索、实时监控",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -52,26 +52,47 @@ const PROVIDER_CAPABILITIES = {
52
52
  * @returns {string} - 'claude' | 'codex' | 'gemini' | 'openai_compatible'
53
53
  */
54
54
  function detectChannelType(channel) {
55
- const baseUrl = channel.baseUrl.toLowerCase();
55
+ try {
56
+ // Parse the URL to extract hostname
57
+ const parsedUrl = new URL(channel.baseUrl);
58
+ const hostname = parsedUrl.hostname.toLowerCase();
56
59
 
57
- // Check if it's official Anthropic API
58
- if (baseUrl.includes('anthropic.com') || baseUrl.includes('claude.ai')) {
59
- return 'claude';
60
- }
60
+ // Check if it's official Anthropic API (hostname only, not path)
61
+ if (hostname.includes('anthropic.com') || hostname.includes('claude.ai')) {
62
+ return 'claude';
63
+ }
61
64
 
62
- // Check if it's Gemini
63
- if (baseUrl.includes('generativelanguage.googleapis.com') || baseUrl.includes('gemini')) {
64
- return 'gemini';
65
- }
65
+ // Check if it's Gemini (hostname only)
66
+ if (hostname.includes('generativelanguage.googleapis.com') || hostname.includes('gemini')) {
67
+ return 'gemini';
68
+ }
66
69
 
67
- // Check if it's OpenAI official
68
- if (baseUrl.includes('api.openai.com')) {
69
- return 'codex';
70
- }
70
+ // Check if it's OpenAI official (hostname only)
71
+ if (hostname.includes('api.openai.com')) {
72
+ return 'codex';
73
+ }
71
74
 
72
- // All other third-party proxies default to OpenAI compatible
73
- // Including: 88code, anyrouter, internal proxies, etc.
74
- return 'openai_compatible';
75
+ // All other third-party proxies default to OpenAI compatible
76
+ // Including: 88code, anyrouter, internal proxies, etc.
77
+ // This correctly handles URLs like https://code.newcli.com/claude/aws
78
+ return 'openai_compatible';
79
+ } catch (error) {
80
+ // If URL parsing fails, fall back to string matching on full URL
81
+ console.warn(`[ModelDetector] Failed to parse URL ${channel.baseUrl}: ${error.message}`);
82
+ const baseUrl = channel.baseUrl.toLowerCase();
83
+
84
+ if (baseUrl.includes('anthropic.com') || baseUrl.includes('claude.ai')) {
85
+ return 'claude';
86
+ }
87
+ if (baseUrl.includes('generativelanguage.googleapis.com')) {
88
+ return 'gemini';
89
+ }
90
+ if (baseUrl.includes('api.openai.com')) {
91
+ return 'codex';
92
+ }
93
+
94
+ return 'openai_compatible';
95
+ }
75
96
  }
76
97
 
77
98
  // Model name normalization mapping