cc-x10ded 3.0.12 → 3.0.14
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/README.md +2 -1
- package/package.json +1 -1
- package/src/commands/run.ts +39 -26
- package/src/core/shell.ts +0 -3
- package/src/proxy/map.ts +2 -1
package/README.md
CHANGED
|
@@ -58,9 +58,10 @@ Run `ccx setup` to:
|
|
|
58
58
|
|
|
59
59
|
If you enabled aliases during setup:
|
|
60
60
|
|
|
61
|
+
|
|
62
|
+
**🆕 New: ccx Multi-Provider Proxy**
|
|
61
63
|
| Alias | Equivalent Command |
|
|
62
64
|
|-------|-------------------|
|
|
63
|
-
| `cc` | `bunx cc-x10ded` (default model) |
|
|
64
65
|
| `ccx` | `bunx cc-x10ded` |
|
|
65
66
|
| `ccg` | `bunx cc-x10ded --model=glm-4.7` |
|
|
66
67
|
| `ccg45` | `bunx cc-x10ded --model=glm-4.5` |
|
package/package.json
CHANGED
package/src/commands/run.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { spawn } from "bun";
|
|
|
2
2
|
import { ConfigManager } from "../core/config";
|
|
3
3
|
import { startProxyServer } from "../proxy/server";
|
|
4
4
|
import { ShellIntegrator } from "../core/shell";
|
|
5
|
+
import { parseProviderModel } from "../proxy/map";
|
|
5
6
|
import * as pc from "picocolors";
|
|
6
7
|
|
|
7
8
|
export async function runCommand(args: string[], options: { model?: string; port?: number }) {
|
|
@@ -16,31 +17,40 @@ export async function runCommand(args: string[], options: { model?: string; port
|
|
|
16
17
|
Object.assign(config, await configManager.read());
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
const model = options.model || config.defaults.model || "glm-4.7";
|
|
21
|
+
const { provider } = parseProviderModel(model);
|
|
22
|
+
|
|
23
|
+
// Check if we should use the proxy or fallback to native Claude (for Anthropic without API Key)
|
|
24
|
+
let useProxy = true;
|
|
25
|
+
if (provider === "anthropic" && !config.providers.anthropic?.apiKey) {
|
|
26
|
+
useProxy = false;
|
|
27
|
+
}
|
|
28
|
+
|
|
19
29
|
// Port hunting logic
|
|
20
30
|
let port = options.port || 17870;
|
|
21
31
|
let server;
|
|
22
|
-
let retries = 0;
|
|
23
32
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (useProxy) {
|
|
34
|
+
let retries = 0;
|
|
35
|
+
while (retries < 10) {
|
|
36
|
+
try {
|
|
37
|
+
server = startProxyServer(config, port);
|
|
38
|
+
break;
|
|
39
|
+
} catch (e: any) {
|
|
40
|
+
if (e.code === "EADDRINUSE" || e.message.includes("EADDRINUSE")) {
|
|
41
|
+
port++;
|
|
42
|
+
retries++;
|
|
43
|
+
} else {
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!server) {
|
|
50
|
+
console.error(pc.red(`Failed to start proxy server after 10 attempts (ports ${options.port || 17870}-${port}).`));
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
36
53
|
}
|
|
37
|
-
|
|
38
|
-
if (!server) {
|
|
39
|
-
console.error(pc.red(`Failed to start proxy server after 10 attempts (ports ${options.port || 17870}-${port}).`));
|
|
40
|
-
process.exit(1);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const model = options.model || config.defaults.model || "glm-4.7";
|
|
44
54
|
|
|
45
55
|
// Robust binary finding
|
|
46
56
|
const shellInt = new ShellIntegrator();
|
|
@@ -52,16 +62,19 @@ export async function runCommand(args: string[], options: { model?: string; port
|
|
|
52
62
|
process.exit(1);
|
|
53
63
|
}
|
|
54
64
|
|
|
55
|
-
const env = {
|
|
65
|
+
const env: Record<string, string | undefined> = {
|
|
56
66
|
...process.env,
|
|
57
|
-
ANTHROPIC_BASE_URL: `http://127.0.0.1:${port}`,
|
|
58
|
-
ANTHROPIC_AUTH_TOKEN: "ccx-proxy-token", // Dummy token for the client
|
|
59
|
-
ANTHROPIC_MODEL: model,
|
|
60
67
|
};
|
|
61
68
|
|
|
69
|
+
if (useProxy) {
|
|
70
|
+
env.ANTHROPIC_BASE_URL = `http://127.0.0.1:${port}`;
|
|
71
|
+
env.ANTHROPIC_AUTH_TOKEN = "ccx-proxy-token"; // Dummy token for the client
|
|
72
|
+
env.ANTHROPIC_MODEL = model;
|
|
73
|
+
}
|
|
74
|
+
|
|
62
75
|
try {
|
|
63
76
|
const proc = spawn([claudePath, ...args], {
|
|
64
|
-
env,
|
|
77
|
+
env: env as any,
|
|
65
78
|
stdio: ["inherit", "inherit", "inherit"],
|
|
66
79
|
});
|
|
67
80
|
|
|
@@ -71,6 +84,6 @@ export async function runCommand(args: string[], options: { model?: string; port
|
|
|
71
84
|
console.error(pc.red(`Error starting Claude: ${e.message}`));
|
|
72
85
|
process.exit(1);
|
|
73
86
|
} finally {
|
|
74
|
-
server.stop();
|
|
87
|
+
if (server) server.stop();
|
|
75
88
|
}
|
|
76
89
|
}
|
package/src/core/shell.ts
CHANGED
|
@@ -89,7 +89,6 @@ export class ShellIntegrator {
|
|
|
89
89
|
if (shell === "zsh" || shell === "bash") {
|
|
90
90
|
return `
|
|
91
91
|
alias ccx='${cmd}'
|
|
92
|
-
alias cc='${cmd}'
|
|
93
92
|
alias ccg='${cmd} --model=glm-4.7'
|
|
94
93
|
alias ccg46='${cmd} --model=glm-4.6'
|
|
95
94
|
alias ccg45='${cmd} --model=glm-4.5'
|
|
@@ -100,7 +99,6 @@ alias ccm='${cmd} --model=MiniMax-M2.1'
|
|
|
100
99
|
if (shell === "fish") {
|
|
101
100
|
return `
|
|
102
101
|
alias ccx '${cmd}'
|
|
103
|
-
alias cc '${cmd}'
|
|
104
102
|
alias ccg '${cmd} --model=glm-4.7'
|
|
105
103
|
alias ccg46 '${cmd} --model=glm-4.6'
|
|
106
104
|
alias ccg45 '${cmd} --model=glm-4.5'
|
|
@@ -111,7 +109,6 @@ alias ccm '${cmd} --model=MiniMax-M2.1'
|
|
|
111
109
|
if (shell === "powershell") {
|
|
112
110
|
return `
|
|
113
111
|
Function ccx { ${cmd} @args }
|
|
114
|
-
Function cc { ${cmd} @args }
|
|
115
112
|
Function ccg { ${cmd} --model=glm-4.7 @args }
|
|
116
113
|
Function ccg46 { ${cmd} --model=glm-4.6 @args }
|
|
117
114
|
Function ccg45 { ${cmd} --model=glm-4.5 @args }
|
package/src/proxy/map.ts
CHANGED
|
@@ -33,7 +33,8 @@ export function parseProviderModel(modelField: string, defaults?: ProviderModel)
|
|
|
33
33
|
if (lower.startsWith("gemini")) return { provider: "gemini", model: modelField };
|
|
34
34
|
if (lower.startsWith("claude")) return { provider: "anthropic", model: modelField };
|
|
35
35
|
if (lower.startsWith("glm")) return { provider: "glm", model: modelField };
|
|
36
|
-
|
|
36
|
+
if (lower.startsWith("minimax")) return { provider: "minimax", model: modelField };
|
|
37
|
+
|
|
37
38
|
return defaults ?? { provider: "glm", model: modelField };
|
|
38
39
|
}
|
|
39
40
|
|