@nextclaw/server 0.5.22 → 0.5.23
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/dist/index.d.ts +4 -0
- package/dist/index.js +62 -12
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -20,12 +20,14 @@ type ProviderConfigView = {
|
|
|
20
20
|
apiBase?: string | null;
|
|
21
21
|
extraHeaders?: Record<string, string> | null;
|
|
22
22
|
wireApi?: "auto" | "chat" | "responses" | null;
|
|
23
|
+
models?: string[];
|
|
23
24
|
};
|
|
24
25
|
type ProviderConfigUpdate = {
|
|
25
26
|
apiKey?: string | null;
|
|
26
27
|
apiBase?: string | null;
|
|
27
28
|
extraHeaders?: Record<string, string> | null;
|
|
28
29
|
wireApi?: "auto" | "chat" | "responses" | null;
|
|
30
|
+
models?: string[] | null;
|
|
29
31
|
};
|
|
30
32
|
type ProviderConnectionTestRequest = ProviderConfigUpdate & {
|
|
31
33
|
model?: string | null;
|
|
@@ -286,11 +288,13 @@ type ConfigView = {
|
|
|
286
288
|
type ProviderSpecView = {
|
|
287
289
|
name: string;
|
|
288
290
|
displayName?: string;
|
|
291
|
+
modelPrefix?: string;
|
|
289
292
|
keywords: string[];
|
|
290
293
|
envKey: string;
|
|
291
294
|
isGateway?: boolean;
|
|
292
295
|
isLocal?: boolean;
|
|
293
296
|
defaultApiBase?: string;
|
|
297
|
+
defaultModels?: string[];
|
|
294
298
|
supportsWireApi?: boolean;
|
|
295
299
|
wireApiOptions?: Array<"auto" | "chat" | "responses">;
|
|
296
300
|
defaultWireApi?: "auto" | "chat" | "responses";
|
package/dist/index.js
CHANGED
|
@@ -33,18 +33,32 @@ import {
|
|
|
33
33
|
var MASK_MIN_LENGTH = 8;
|
|
34
34
|
var EXTRA_SENSITIVE_PATH_PATTERNS = [/authorization/i, /cookie/i, /session/i, /bearer/i];
|
|
35
35
|
var PROVIDER_TEST_MODEL_FALLBACKS = {
|
|
36
|
-
openai: "gpt-
|
|
37
|
-
deepseek: "deepseek-
|
|
38
|
-
gemini: "gemini-
|
|
39
|
-
zhipu: "glm-
|
|
40
|
-
dashscope: "
|
|
41
|
-
moonshot: "
|
|
42
|
-
minimax: "
|
|
36
|
+
openai: "gpt-5-mini",
|
|
37
|
+
deepseek: "deepseek-v3.2",
|
|
38
|
+
gemini: "gemini-3-flash-preview",
|
|
39
|
+
zhipu: "glm-5",
|
|
40
|
+
dashscope: "qwen3.5-flash",
|
|
41
|
+
moonshot: "kimi-k2.5",
|
|
42
|
+
minimax: "MiniMax-M2.5",
|
|
43
43
|
groq: "llama-3.1-8b-instant",
|
|
44
|
-
openrouter: "openai/gpt-
|
|
45
|
-
aihubmix: "gpt-
|
|
46
|
-
anthropic: "claude-
|
|
44
|
+
openrouter: "openai/gpt-5.3-codex",
|
|
45
|
+
aihubmix: "gpt-5.3-codex",
|
|
46
|
+
anthropic: "claude-opus-4-6"
|
|
47
47
|
};
|
|
48
|
+
var PREFERRED_PROVIDER_ORDER = [
|
|
49
|
+
"openai",
|
|
50
|
+
"anthropic",
|
|
51
|
+
"gemini",
|
|
52
|
+
"openrouter",
|
|
53
|
+
"dashscope",
|
|
54
|
+
"deepseek",
|
|
55
|
+
"minimax",
|
|
56
|
+
"moonshot",
|
|
57
|
+
"zhipu"
|
|
58
|
+
];
|
|
59
|
+
var PREFERRED_PROVIDER_ORDER_INDEX = new Map(
|
|
60
|
+
PREFERRED_PROVIDER_ORDER.map((name, index) => [name, index])
|
|
61
|
+
);
|
|
48
62
|
function matchesExtraSensitivePath(path) {
|
|
49
63
|
if (path === "session" || path.startsWith("session.")) {
|
|
50
64
|
return false;
|
|
@@ -246,6 +260,23 @@ function maskApiKey(value) {
|
|
|
246
260
|
apiKeyMasked: `${value.slice(0, 2)}****${value.slice(-4)}`
|
|
247
261
|
};
|
|
248
262
|
}
|
|
263
|
+
function normalizeModelList(input) {
|
|
264
|
+
if (!input || input.length === 0) {
|
|
265
|
+
return [];
|
|
266
|
+
}
|
|
267
|
+
const deduped = /* @__PURE__ */ new Set();
|
|
268
|
+
for (const item of input) {
|
|
269
|
+
if (typeof item !== "string") {
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
const trimmed = item.trim();
|
|
273
|
+
if (!trimmed) {
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
deduped.add(trimmed);
|
|
277
|
+
}
|
|
278
|
+
return [...deduped];
|
|
279
|
+
}
|
|
249
280
|
function toProviderView(config, provider, providerName, uiHints, spec) {
|
|
250
281
|
const apiKeyPath = `providers.${providerName}.apiKey`;
|
|
251
282
|
const apiKeyRefSet = hasSecretRef(config, apiKeyPath);
|
|
@@ -259,7 +290,8 @@ function toProviderView(config, provider, providerName, uiHints, spec) {
|
|
|
259
290
|
apiKeySet: masked.apiKeySet || apiKeyRefSet,
|
|
260
291
|
apiKeyMasked: masked.apiKeyMasked ?? (apiKeyRefSet ? "****" : void 0),
|
|
261
292
|
apiBase: provider.apiBase ?? null,
|
|
262
|
-
extraHeaders: extraHeaders && Object.keys(extraHeaders).length > 0 ? extraHeaders : null
|
|
293
|
+
extraHeaders: extraHeaders && Object.keys(extraHeaders).length > 0 ? extraHeaders : null,
|
|
294
|
+
models: normalizeModelList(provider.models ?? [])
|
|
263
295
|
};
|
|
264
296
|
if (spec?.supportsWireApi) {
|
|
265
297
|
view.wireApi = provider.wireApi ?? spec.defaultWireApi ?? "auto";
|
|
@@ -303,15 +335,30 @@ function buildConfigMeta(config) {
|
|
|
303
335
|
const providers = PROVIDERS.map((spec) => ({
|
|
304
336
|
name: spec.name,
|
|
305
337
|
displayName: spec.displayName,
|
|
338
|
+
modelPrefix: spec.modelPrefix,
|
|
306
339
|
keywords: spec.keywords,
|
|
307
340
|
envKey: spec.envKey,
|
|
308
341
|
isGateway: spec.isGateway,
|
|
309
342
|
isLocal: spec.isLocal,
|
|
310
343
|
defaultApiBase: spec.defaultApiBase,
|
|
344
|
+
defaultModels: normalizeModelList(spec.defaultModels ?? []),
|
|
311
345
|
supportsWireApi: spec.supportsWireApi,
|
|
312
346
|
wireApiOptions: spec.wireApiOptions,
|
|
313
347
|
defaultWireApi: spec.defaultWireApi
|
|
314
|
-
}))
|
|
348
|
+
})).sort((left, right) => {
|
|
349
|
+
const leftRank = PREFERRED_PROVIDER_ORDER_INDEX.get(left.name);
|
|
350
|
+
const rightRank = PREFERRED_PROVIDER_ORDER_INDEX.get(right.name);
|
|
351
|
+
if (leftRank !== void 0 && rightRank !== void 0) {
|
|
352
|
+
return leftRank - rightRank;
|
|
353
|
+
}
|
|
354
|
+
if (leftRank !== void 0) {
|
|
355
|
+
return -1;
|
|
356
|
+
}
|
|
357
|
+
if (rightRank !== void 0) {
|
|
358
|
+
return 1;
|
|
359
|
+
}
|
|
360
|
+
return left.name.localeCompare(right.name);
|
|
361
|
+
});
|
|
315
362
|
const channels = Object.keys(config.channels).map((name) => ({
|
|
316
363
|
name,
|
|
317
364
|
displayName: name,
|
|
@@ -409,6 +456,9 @@ function updateProvider(configPath, providerName, patch) {
|
|
|
409
456
|
if (Object.prototype.hasOwnProperty.call(patch, "wireApi") && spec?.supportsWireApi) {
|
|
410
457
|
provider.wireApi = patch.wireApi ?? spec.defaultWireApi ?? "auto";
|
|
411
458
|
}
|
|
459
|
+
if (Object.prototype.hasOwnProperty.call(patch, "models")) {
|
|
460
|
+
provider.models = normalizeModelList(patch.models ?? []);
|
|
461
|
+
}
|
|
412
462
|
const next = ConfigSchema.parse(config);
|
|
413
463
|
saveConfig(next, configPath);
|
|
414
464
|
const uiHints = buildUiHints(next);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/server",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.23",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Nextclaw UI/API server.",
|
|
6
6
|
"type": "module",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@hono/node-server": "^1.13.3",
|
|
18
|
-
"@nextclaw/openclaw-compat": "^0.1.
|
|
18
|
+
"@nextclaw/openclaw-compat": "^0.1.30",
|
|
19
19
|
"hono": "^4.6.2",
|
|
20
20
|
"ws": "^8.18.0",
|
|
21
|
-
"@nextclaw/core": "^0.6.
|
|
21
|
+
"@nextclaw/core": "^0.6.39"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^20.17.6",
|