Skip to content

Commit 8d8a91b

Browse files
LegnaOSclaude
andcommitted
fix: v3.1.2 — 修复 HTTP 接口 SSL WRONG_VERSION_NUMBER 错误
anthropic.ts 和 openai.ts 硬编码 https.request(),当 baseUrl 使用 http:// 协议时 TLS 握手失败。现在根据 URL 协议自动选择 http/https 模块。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d954d61 commit 8d8a91b

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "augment-proxy-manager",
33
"displayName": "Augment Proxy Manager",
44
"description": "管理 Augment API 代理服务器,支持自定义 API 端点和多种 AI 供应商",
5-
"version": "3.1.1",
5+
"version": "3.1.2",
66
"publisher": "legna",
77
"repository": {
88
"type": "git",

src/providers/anthropic.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ===== Anthropic 格式 API 转发(Anthropic / MiniMax / DeepSeek)=====
22

33
import * as https from 'https';
4+
import * as http from 'http';
45
import { URL } from 'url';
56
import { state, log } from '../globals';
67
import { augmentToAnthropicMessages, buildSystemPrompt, extractWorkspaceInfo } from '../messages';
@@ -31,7 +32,8 @@ function executeAnthropicRequest(
3132
if (state.currentConfig.provider === 'kimi-anthropic') {
3233
headers['User-Agent'] = 'KimiCLI/0.77';
3334
}
34-
const options = { hostname: url.hostname, port: url.port || 443, path: url.pathname, method: 'POST', headers };
35+
const isHttps = url.protocol === 'https:';
36+
const options = { hostname: url.hostname, port: url.port || (isHttps ? 443 : 80), path: url.pathname, method: 'POST', headers };
3537
log(`[API] Sending to ${state.currentConfig.baseUrl} with ${messages.length} messages`);
3638

3739
const result: AnthropicResult = { text: '', toolCalls: [], stopReason: '' };
@@ -41,7 +43,8 @@ function executeAnthropicRequest(
4143
const shouldShowThinking = (state.currentConfig.provider === 'minimax' && state.currentConfig.enableInterleavedThinking) ||
4244
(state.currentConfig.provider === 'deepseek' && state.currentConfig.enableThinking);
4345

44-
const apiReq = https.request(options, (apiRes) => {
46+
const httpModule = isHttps ? https : http;
47+
const apiReq = httpModule.request(options, (apiRes) => {
4548
if (apiRes.statusCode !== 200) {
4649
let errorBody = '';
4750
apiRes.on('data', (c: any) => errorBody += c);

src/providers/openai.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ===== OpenAI 格式 API 转发(OpenAI / GLM)=====
22

33
import * as https from 'https';
4+
import * as http from 'http';
45
import { URL } from 'url';
56
import { state, log } from '../globals';
67
import { OpenAIRequestResult } from '../types';
@@ -54,7 +55,7 @@ export async function executeOpenAIRequest(
5455

5556
const options = {
5657
hostname: url.hostname,
57-
port: url.port || 443,
58+
port: url.port || (url.protocol === 'https:' ? 443 : 80),
5859
path: url.pathname,
5960
method: 'POST',
6061
headers
@@ -65,7 +66,8 @@ export async function executeOpenAIRequest(
6566
let inThinking = false;
6667
const toolCallsMap = new Map<number, { id: string; name: string; arguments: string }>();
6768

68-
const apiReq = https.request(options, (apiRes: any) => {
69+
const httpModule = url.protocol === 'https:' ? https : http;
70+
const apiReq = httpModule.request(options, (apiRes: any) => {
6971
if (apiRes.statusCode !== 200) {
7072
let errorBody = '';
7173
apiRes.on('data', (c: any) => errorBody += c);

0 commit comments

Comments
 (0)