@ghenya/clinn 0.7.14 → 0.7.15
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/Logos/StartLogo.txt +1 -1
- package/Src/index.js +7 -0
- package/Src/llm.js +29 -0
- package/config.json +1 -1
- package/package.json +1 -1
package/Logos/StartLogo.txt
CHANGED
package/Src/index.js
CHANGED
|
@@ -933,6 +933,13 @@ async function main() {
|
|
|
933
933
|
showLogo();
|
|
934
934
|
buildAgent();
|
|
935
935
|
|
|
936
|
+
if (!config.llm.apiKey || config.llm.apiKey.startsWith("YOUR_")) {
|
|
937
|
+
console.log(` ${C.yellow}⚠ 未配置 API Key${C.reset}`);
|
|
938
|
+
console.log(` 设置: ${C.cyan}/api key <你的DeepSeek Key>${C.reset}`);
|
|
939
|
+
console.log(` 获取: ${C.dim}https://platform.deepseek.com/${C.reset}`);
|
|
940
|
+
console.log(div("="));
|
|
941
|
+
}
|
|
942
|
+
|
|
936
943
|
readline.emitKeypressEvents(process.stdin);
|
|
937
944
|
if (process.stdin.isTTY) process.stdin.setRawMode(true);
|
|
938
945
|
|
package/Src/llm.js
CHANGED
|
@@ -88,6 +88,14 @@ class LLMClient {
|
|
|
88
88
|
let data = "";
|
|
89
89
|
res.on("data", (chunk) => (data += chunk));
|
|
90
90
|
res.on("end", () => {
|
|
91
|
+
if (res.statusCode === 401) {
|
|
92
|
+
reject(new Error("API Key 无效或未设置 — 请用 /api key <你的Key> 设置"));
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (res.statusCode === 403) {
|
|
96
|
+
reject(new Error("API Key 无权限 (403 Forbidden)"));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
91
99
|
try {
|
|
92
100
|
const json = JSON.parse(data);
|
|
93
101
|
if (json.error) {
|
|
@@ -123,6 +131,27 @@ class LLMClient {
|
|
|
123
131
|
|
|
124
132
|
return new Promise((resolve, reject) => {
|
|
125
133
|
const req = https.request(options, (res) => {
|
|
134
|
+
if (res.statusCode === 401) {
|
|
135
|
+
reject(new Error("API Key 无效或未设置 — 请用 /api key <你的Key> 设置"));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (res.statusCode === 403) {
|
|
139
|
+
reject(new Error("API Key 无权限 (403 Forbidden)"));
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (res.statusCode >= 400) {
|
|
143
|
+
let body = "";
|
|
144
|
+
res.on("data", (c) => (body += c));
|
|
145
|
+
res.on("end", () => {
|
|
146
|
+
try {
|
|
147
|
+
const j = JSON.parse(body);
|
|
148
|
+
reject(new Error(j.error?.message || `HTTP ${res.statusCode}`));
|
|
149
|
+
} catch (_) {
|
|
150
|
+
reject(new Error(`HTTP ${res.statusCode}: ${body.slice(0, 200)}`));
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
126
155
|
let buffer = "";
|
|
127
156
|
const toolCallsMap = {};
|
|
128
157
|
let content = "";
|
package/config.json
CHANGED