glmproxy 2.5.1 → 2.6.1
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 +244 -270
- package/anthropic.js +734 -734
- package/bin/cli.js +406 -406
- package/lib/core.js +1486 -1434
- package/lib/fallback-models.json +2 -2
- package/lib/prompts.js +113 -113
- package/openai.js +425 -425
- package/package.json +1 -1
package/lib/fallback-models.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"models": [
|
|
3
|
-
{ "id": "zai_auto", "name": "Auto", "contextWindow": 1048576, "maxTokens":
|
|
4
|
-
{ "id": "zaicoding_glm-5.3", "name": "GLM-5.3", "contextWindow": 1048576, "maxTokens":
|
|
3
|
+
{ "id": "zai_auto", "name": "Auto", "contextWindow": 1048576, "maxTokens": 131072 },
|
|
4
|
+
{ "id": "zaicoding_glm-5.3", "name": "GLM-5.3", "contextWindow": 1048576, "maxTokens": 131072 },
|
|
5
5
|
{ "id": "zai_glm-5-turbo", "name": "GLM-5-Turbo", "contextWindow": 204800, "maxTokens": 131072 },
|
|
6
6
|
{ "id": "zai_glm-5.3-flash", "name": "GLM-5.3-Flash", "contextWindow": 1048576, "maxTokens": 131072 },
|
|
7
7
|
{ "id": "tdpsk_deepseek-v4-flash-202605", "name": "Deepseek-V4-Flash", "contextWindow": 1048576, "maxTokens": 393216 },
|
package/lib/prompts.js
CHANGED
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
// Zero-dep interactive prompts: raw-mode readline, arrows + enter
|
|
2
|
-
|
|
3
|
-
import readline from "readline";
|
|
4
|
-
|
|
5
|
-
const HIDE_CURSOR = "\x1b[?25l";
|
|
6
|
-
const SHOW_CURSOR = "\x1b[?25h";
|
|
7
|
-
const RESET = "\x1b[0m";
|
|
8
|
-
const DIM = "\x1b[2m";
|
|
9
|
-
const GREEN = "\x1b[32m";
|
|
10
|
-
const CYAN = "\x1b[36m";
|
|
11
|
-
const RED = "\x1b[31m";
|
|
12
|
-
|
|
13
|
-
let onKeypress = null;
|
|
14
|
-
|
|
15
|
-
function start() {
|
|
16
|
-
readline.emitKeypressEvents(process.stdin);
|
|
17
|
-
process.stdin.setRawMode(true);
|
|
18
|
-
process.stdin.resume();
|
|
19
|
-
process.stdin.on("keypress", handleKeypress);
|
|
20
|
-
process.stdout.write(HIDE_CURSOR);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function stop() {
|
|
24
|
-
process.stdout.write(SHOW_CURSOR);
|
|
25
|
-
process.stdin.setRawMode(false);
|
|
26
|
-
process.stdin.pause();
|
|
27
|
-
process.stdin.removeListener("keypress", handleKeypress);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function handleKeypress(str, key) {
|
|
31
|
-
if (key?.ctrl && key.name === "c") {
|
|
32
|
-
stop();
|
|
33
|
-
process.stdout.write("\n");
|
|
34
|
-
process.exit(0);
|
|
35
|
-
}
|
|
36
|
-
if (onKeypress) onKeypress(key);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function question(message) {
|
|
40
|
-
return `${GREEN}?${RESET} ${message}`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function confirmed(message, value) {
|
|
44
|
-
return `${GREEN}✔${RESET} ${message}: ${value}`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export async function promptSelect({ message, hint, choices, default: def }) {
|
|
48
|
-
let index = Math.max(0, choices.findIndex((choice) => choice.value === def));
|
|
49
|
-
const hintLines = hint ? hint.split("\n").length : 0;
|
|
50
|
-
const lines = choices.length + 1 + hintLines;
|
|
51
|
-
const render = (clear = false) => {
|
|
52
|
-
if (clear) process.stdout.write(`\x1b[${lines}A\r\x1b[J`);
|
|
53
|
-
process.stdout.write(`${question(message)}${hint ? `\n${hint}` : ""}\n`);
|
|
54
|
-
for (let i = 0; i < choices.length; i++) {
|
|
55
|
-
const selected = i === index;
|
|
56
|
-
process.stdout.write(` ${selected ? `${CYAN}❯${RESET}` : " "} ${selected ? `${CYAN}${choices[i].name}${RESET}` : choices[i].name}\n`);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
start();
|
|
61
|
-
render();
|
|
62
|
-
return new Promise((resolve) => {
|
|
63
|
-
onKeypress = (key) => {
|
|
64
|
-
if (key.name === "up") {
|
|
65
|
-
index = (index - 1 + choices.length) % choices.length;
|
|
66
|
-
render(true);
|
|
67
|
-
} else if (key.name === "down") {
|
|
68
|
-
index = (index + 1) % choices.length;
|
|
69
|
-
render(true);
|
|
70
|
-
} else if (key.name === "return") {
|
|
71
|
-
const choice = choices[index];
|
|
72
|
-
process.stdout.write(`\x1b[${lines}A\r\x1b[J${confirmed(message, choice.name)}\n`);
|
|
73
|
-
stop();
|
|
74
|
-
resolve(choice.value);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export async function promptInput({ message, default: def = "" }) {
|
|
81
|
-
let buf = "";
|
|
82
|
-
const render = () => {
|
|
83
|
-
process.stdout.write(`\r\x1b[2K${question(message)}${def ? ` ${DIM}(${def})${RESET}` : ""} ${buf}`);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
start();
|
|
87
|
-
render();
|
|
88
|
-
return new Promise((resolve) => {
|
|
89
|
-
onKeypress = (key) => {
|
|
90
|
-
if (key.name === "return") {
|
|
91
|
-
const value = buf || def;
|
|
92
|
-
process.stdout.write(`\r\x1b[2K${confirmed(message, value)}\n`);
|
|
93
|
-
stop();
|
|
94
|
-
resolve(value);
|
|
95
|
-
} else if (key.name === "backspace") {
|
|
96
|
-
buf = buf.slice(0, -1);
|
|
97
|
-
render();
|
|
98
|
-
} else if (key.sequence && !key.ctrl && !key.meta && key.sequence.length === 1 && key.sequence.charCodeAt(0) >= 32) {
|
|
99
|
-
buf += key.sequence;
|
|
100
|
-
render();
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export async function promptNumber({ message, default: def }) {
|
|
107
|
-
for (;;) {
|
|
108
|
-
const raw = await promptInput({ message, default: String(def) });
|
|
109
|
-
const n = Number(raw);
|
|
110
|
-
if (Number.isInteger(n) && n >= 1 && n <= 65535) return n;
|
|
111
|
-
process.stdout.write(` ${RED}✗ must be a number (1-65535)${RESET}\n`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
1
|
+
// Zero-dep interactive prompts: raw-mode readline, arrows + enter
|
|
2
|
+
|
|
3
|
+
import readline from "readline";
|
|
4
|
+
|
|
5
|
+
const HIDE_CURSOR = "\x1b[?25l";
|
|
6
|
+
const SHOW_CURSOR = "\x1b[?25h";
|
|
7
|
+
const RESET = "\x1b[0m";
|
|
8
|
+
const DIM = "\x1b[2m";
|
|
9
|
+
const GREEN = "\x1b[32m";
|
|
10
|
+
const CYAN = "\x1b[36m";
|
|
11
|
+
const RED = "\x1b[31m";
|
|
12
|
+
|
|
13
|
+
let onKeypress = null;
|
|
14
|
+
|
|
15
|
+
function start() {
|
|
16
|
+
readline.emitKeypressEvents(process.stdin);
|
|
17
|
+
process.stdin.setRawMode(true);
|
|
18
|
+
process.stdin.resume();
|
|
19
|
+
process.stdin.on("keypress", handleKeypress);
|
|
20
|
+
process.stdout.write(HIDE_CURSOR);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function stop() {
|
|
24
|
+
process.stdout.write(SHOW_CURSOR);
|
|
25
|
+
process.stdin.setRawMode(false);
|
|
26
|
+
process.stdin.pause();
|
|
27
|
+
process.stdin.removeListener("keypress", handleKeypress);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function handleKeypress(str, key) {
|
|
31
|
+
if (key?.ctrl && key.name === "c") {
|
|
32
|
+
stop();
|
|
33
|
+
process.stdout.write("\n");
|
|
34
|
+
process.exit(0);
|
|
35
|
+
}
|
|
36
|
+
if (onKeypress) onKeypress(key);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function question(message) {
|
|
40
|
+
return `${GREEN}?${RESET} ${message}`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function confirmed(message, value) {
|
|
44
|
+
return `${GREEN}✔${RESET} ${message}: ${value}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function promptSelect({ message, hint, choices, default: def }) {
|
|
48
|
+
let index = Math.max(0, choices.findIndex((choice) => choice.value === def));
|
|
49
|
+
const hintLines = hint ? hint.split("\n").length : 0;
|
|
50
|
+
const lines = choices.length + 1 + hintLines;
|
|
51
|
+
const render = (clear = false) => {
|
|
52
|
+
if (clear) process.stdout.write(`\x1b[${lines}A\r\x1b[J`);
|
|
53
|
+
process.stdout.write(`${question(message)}${hint ? `\n${hint}` : ""}\n`);
|
|
54
|
+
for (let i = 0; i < choices.length; i++) {
|
|
55
|
+
const selected = i === index;
|
|
56
|
+
process.stdout.write(` ${selected ? `${CYAN}❯${RESET}` : " "} ${selected ? `${CYAN}${choices[i].name}${RESET}` : choices[i].name}\n`);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
start();
|
|
61
|
+
render();
|
|
62
|
+
return new Promise((resolve) => {
|
|
63
|
+
onKeypress = (key) => {
|
|
64
|
+
if (key.name === "up") {
|
|
65
|
+
index = (index - 1 + choices.length) % choices.length;
|
|
66
|
+
render(true);
|
|
67
|
+
} else if (key.name === "down") {
|
|
68
|
+
index = (index + 1) % choices.length;
|
|
69
|
+
render(true);
|
|
70
|
+
} else if (key.name === "return") {
|
|
71
|
+
const choice = choices[index];
|
|
72
|
+
process.stdout.write(`\x1b[${lines}A\r\x1b[J${confirmed(message, choice.name)}\n`);
|
|
73
|
+
stop();
|
|
74
|
+
resolve(choice.value);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export async function promptInput({ message, default: def = "" }) {
|
|
81
|
+
let buf = "";
|
|
82
|
+
const render = () => {
|
|
83
|
+
process.stdout.write(`\r\x1b[2K${question(message)}${def ? ` ${DIM}(${def})${RESET}` : ""} ${buf}`);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
start();
|
|
87
|
+
render();
|
|
88
|
+
return new Promise((resolve) => {
|
|
89
|
+
onKeypress = (key) => {
|
|
90
|
+
if (key.name === "return") {
|
|
91
|
+
const value = buf || def;
|
|
92
|
+
process.stdout.write(`\r\x1b[2K${confirmed(message, value)}\n`);
|
|
93
|
+
stop();
|
|
94
|
+
resolve(value);
|
|
95
|
+
} else if (key.name === "backspace") {
|
|
96
|
+
buf = buf.slice(0, -1);
|
|
97
|
+
render();
|
|
98
|
+
} else if (key.sequence && !key.ctrl && !key.meta && key.sequence.length === 1 && key.sequence.charCodeAt(0) >= 32) {
|
|
99
|
+
buf += key.sequence;
|
|
100
|
+
render();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export async function promptNumber({ message, default: def }) {
|
|
107
|
+
for (;;) {
|
|
108
|
+
const raw = await promptInput({ message, default: String(def) });
|
|
109
|
+
const n = Number(raw);
|
|
110
|
+
if (Number.isInteger(n) && n >= 1 && n <= 65535) return n;
|
|
111
|
+
process.stdout.write(` ${RED}✗ must be a number (1-65535)${RESET}\n`);
|
|
112
|
+
}
|
|
113
|
+
}
|