gpt走代理
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@ dangerously_skip_permissions: true
|
|||||||
|
|
||||||
models:
|
models:
|
||||||
command-default:
|
command-default:
|
||||||
cli_model: deepseek/deepseek-v4-flash
|
cli_model: gpt-5.6-luna
|
||||||
effort: max
|
effort: max
|
||||||
command-pro:
|
command-pro:
|
||||||
cli_model: deepseek/deepseek-v4-pro
|
cli_model: deepseek/deepseek-v4-pro
|
||||||
|
|||||||
+24
-2
@@ -72,6 +72,27 @@ function parseFrame(line: string): Record<string, unknown> | undefined {
|
|||||||
return value as Record<string, unknown>;
|
return value as Record<string, unknown>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Actual CLI models starting with "gpt" (e.g. gpt-5.6-luna) use the local HTTP proxy. */
|
||||||
|
const GPT_MODEL_PROXY = "http://127.0.0.1:7890";
|
||||||
|
|
||||||
|
function buildCommandEnv(cliModel: string): NodeJS.ProcessEnv {
|
||||||
|
if (!cliModel.startsWith("gpt")) return process.env;
|
||||||
|
|
||||||
|
const proxy = GPT_MODEL_PROXY;
|
||||||
|
// Command Code uses Node's built-in fetch, which ignores HTTP(S)_PROXY unless
|
||||||
|
// NODE_USE_ENV_PROXY=1 is set (Node >= 22.21 / 24).
|
||||||
|
return {
|
||||||
|
...process.env,
|
||||||
|
NODE_USE_ENV_PROXY: "1",
|
||||||
|
HTTP_PROXY: proxy,
|
||||||
|
HTTPS_PROXY: proxy,
|
||||||
|
ALL_PROXY: proxy,
|
||||||
|
http_proxy: proxy,
|
||||||
|
https_proxy: proxy,
|
||||||
|
all_proxy: proxy,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export async function runCommandCode(
|
export async function runCommandCode(
|
||||||
config: BridgeConfig,
|
config: BridgeConfig,
|
||||||
cliModel: string,
|
cliModel: string,
|
||||||
@@ -101,7 +122,8 @@ export async function runCommandCode(
|
|||||||
else args.push("--permission-mode", config.permission_mode);
|
else args.push("--permission-mode", config.permission_mode);
|
||||||
|
|
||||||
const renderer = new TerminalRenderer();
|
const renderer = new TerminalRenderer();
|
||||||
renderer.begin(cliModel, effort);
|
const useProxy = cliModel.startsWith("gpt");
|
||||||
|
renderer.begin(cliModel, effort, useProxy ? GPT_MODEL_PROXY : undefined);
|
||||||
|
|
||||||
return new Promise<CommandResult>((resolve, reject) => {
|
return new Promise<CommandResult>((resolve, reject) => {
|
||||||
const startedAt = Date.now();
|
const startedAt = Date.now();
|
||||||
@@ -109,7 +131,7 @@ export async function runCommandCode(
|
|||||||
try {
|
try {
|
||||||
child = spawn(config.command_code_executable, args, {
|
child = spawn(config.command_code_executable, args, {
|
||||||
cwd: config.resolvedWorkingDirectory,
|
cwd: config.resolvedWorkingDirectory,
|
||||||
env: process.env,
|
env: buildCommandEnv(cliModel),
|
||||||
detached: process.platform !== "win32",
|
detached: process.platform !== "win32",
|
||||||
stdio: ["pipe", "pipe", "pipe"],
|
stdio: ["pipe", "pipe", "pipe"],
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-1
@@ -52,12 +52,13 @@ export class TerminalRenderer {
|
|||||||
private answerStarted = false;
|
private answerStarted = false;
|
||||||
private thinkingShown = false;
|
private thinkingShown = false;
|
||||||
|
|
||||||
begin(model: string, effort: string): void {
|
begin(model: string, effort: string, proxy?: string): void {
|
||||||
this.answerStarted = false;
|
this.answerStarted = false;
|
||||||
this.thinkingShown = false;
|
this.thinkingShown = false;
|
||||||
process.stdout.write(`\n${cyan("━━━━━━━━ Command Code 请求 ━━━━━━━━")}\n`);
|
process.stdout.write(`\n${cyan("━━━━━━━━ Command Code 请求 ━━━━━━━━")}\n`);
|
||||||
process.stdout.write(`${dim("模型")} ${model}\n`);
|
process.stdout.write(`${dim("模型")} ${model}\n`);
|
||||||
process.stdout.write(`${dim("思考深度")} ${effort}\n`);
|
process.stdout.write(`${dim("思考深度")} ${effort}\n`);
|
||||||
|
if (proxy) process.stdout.write(`${dim("代理")} ${proxy}\n`);
|
||||||
}
|
}
|
||||||
|
|
||||||
event(event: Record<string, unknown>): void {
|
event(event: Record<string, unknown>): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user