dsh-unified-router 0.8.7 → 0.8.9
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/docs/QODER-CLI.md +6 -0
- package/lib/backend.js +153 -70
- package/lib/channel-contract.js +13 -0
- package/lib/client.js +134 -42
- package/lib/cot-loop-guard/stream.js +4 -4
- package/lib/daily-checkin.js +10 -2
- package/lib/managed-channel.js +1 -0
- package/lib/managed-providers/astudio.js +3 -3
- package/lib/managed-providers/codearts.js +17 -9
- package/lib/managed-providers/loomy-route.js +2 -3
- package/lib/managed-providers/loomy.js +34 -11
- package/lib/model-catalog.js +7 -9
- package/lib/settings-providers.js +5 -3
- package/lib/web-host.js +9 -7
- package/lib/workbuddy.js +5 -0
- package/package.json +1 -1
package/docs/QODER-CLI.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Qoder CN:官方 CLI 取目录可行性与集成方案
|
|
2
2
|
|
|
3
|
+
## 上下文档位
|
|
4
|
+
|
|
5
|
+
Qoder 中国版的富目录将默认上下文和逐模型可选档位分开保存。目录给出 200K(默认)、400K、1M 时才会显示这三档;只有单一档或没有档位信息时,不从其他模型推断。旧版缓存只有模型名称和 ID,升级后在「Qoder 中国版 → 模型 → 刷新目录」重新读取富目录。单纯的 CLI 文本列表不提供这些字段。
|
|
6
|
+
|
|
7
|
+
设置页和独立后端的输入栏快捷档共用模型设置。切换后,DSH 的预算和 Qoder 请求的 `parameters.context_length` 使用同一个已确认档位;不会改写账号、模型 ID 或其他模型参数。共用外部后端仍不提供快捷写入。
|
|
8
|
+
|
|
3
9
|
2026-11-19 本机官方 CLI 的 `--list-models` 返回 14 条,已按实际名单更新内置目录。已知展示名继续对应原调用 ID。本次新增的 Qwen4 Max、Qwen4 Max Preview 和 Step 5 Preview 只有展示名,CLI 富字段接口要求独立登录,当前保留展示名与已确认的元数据。成功刷新会保存目录,下一次启动和刷新失败时沿用上次成功结果。
|
|
4
10
|
|
|
5
11
|
> 2026-11-17 只读勘察(qoder-feasibility 子代理)。方向由用户拍板:**直接用官方 CLI 登录/拉取,不重实现签名、不造轮子**。
|
package/lib/backend.js
CHANGED
|
@@ -2244,7 +2244,7 @@ var modelBrands = {
|
|
|
2244
2244
|
};
|
|
2245
2245
|
var modelAliases = /* @__PURE__ */ new Map([
|
|
2246
2246
|
["qmodel_38max", "Qwen 3.8 Max"],
|
|
2247
|
-
["qmodel_latest", "Qwen
|
|
2247
|
+
["qmodel_latest", "Qwen 4 Max"],
|
|
2248
2248
|
["qfmodel", "Qwen 3.8 Flash"],
|
|
2249
2249
|
["dmodel", "DeepSeek V4 Pro"],
|
|
2250
2250
|
["dfmodel", "DeepSeek Flash"],
|
|
@@ -2350,10 +2350,12 @@ var catalogIdentities = {
|
|
|
2350
2350
|
qodercn: {
|
|
2351
2351
|
qmodel_38max: "qwen-3-8-max",
|
|
2352
2352
|
qfmodel: "qwen-3-8-flash",
|
|
2353
|
+
qmodel_latest: "qwen-4-max",
|
|
2353
2354
|
dmodel: "deepseek-v4-pro",
|
|
2354
2355
|
dfmodel: "deepseek-flash",
|
|
2355
2356
|
gmodel: "glm-5-3",
|
|
2356
2357
|
gfmodel: "glm-5-3-flash",
|
|
2358
|
+
gmodel_latest: "glm-5-4",
|
|
2357
2359
|
kmodel_latest: "kimi-k3-1-pro",
|
|
2358
2360
|
kmodel: "kimi-k2-8-preview",
|
|
2359
2361
|
mmodel: "minimax-m3-1-flash"
|
|
@@ -2419,10 +2421,6 @@ var providerNamedSuccessors = {
|
|
|
2419
2421
|
["qwen-3-6-plus", "qwen-3-8-max"],
|
|
2420
2422
|
["minimax-m2-7", "minimax-m3-1-flash"],
|
|
2421
2423
|
["kimi-k2-6", "kimi-k3-1-pro"]
|
|
2422
|
-
]),
|
|
2423
|
-
workbuddy: /* @__PURE__ */ new Map([
|
|
2424
|
-
// 同目录存在完全同型号的免费版 hy4flash-free,收费版 hy4flash 不再默认启用。
|
|
2425
|
-
["hy4flash", "hy4flash-free"]
|
|
2426
2424
|
])
|
|
2427
2425
|
};
|
|
2428
2426
|
var obsoleteIdentities = /* @__PURE__ */ new Set([
|
|
@@ -2520,11 +2518,12 @@ function modelRecommendationExclusions(models, provider) {
|
|
|
2520
2518
|
const exclusions = /* @__PURE__ */ new Map();
|
|
2521
2519
|
const candidates = [];
|
|
2522
2520
|
const aliveModels = models.filter((model) => !model.dead);
|
|
2521
|
+
const obsolete = (identity) => obsoleteIdentities.has(identity) || provider === "qodercn" && /^qwen-3-8(?:-|$)/.test(identity);
|
|
2523
2522
|
const hasModernSurvivor = aliveModels.some((model) => {
|
|
2524
2523
|
if (older.has(model.id) || model.stale) return false;
|
|
2525
2524
|
const identity = catalogIdentity(model.id, provider);
|
|
2526
2525
|
const baseIdentity = stripReleaseSuffix(identity);
|
|
2527
|
-
return !
|
|
2526
|
+
return !obsolete(identity) && !obsolete(baseIdentity);
|
|
2528
2527
|
});
|
|
2529
2528
|
for (const model of aliveModels) {
|
|
2530
2529
|
const identity = catalogIdentity(model.id, provider);
|
|
@@ -2533,7 +2532,7 @@ function modelRecommendationExclusions(models, provider) {
|
|
|
2533
2532
|
exclusions.set(model.id, { kind: "older", alternative: older.get(model.id) });
|
|
2534
2533
|
continue;
|
|
2535
2534
|
}
|
|
2536
|
-
if (hasModernSurvivor && (
|
|
2535
|
+
if (hasModernSurvivor && (obsolete(identity) || obsolete(baseIdentity))) {
|
|
2537
2536
|
exclusions.set(model.id, { kind: "older", alternative: void 0 });
|
|
2538
2537
|
continue;
|
|
2539
2538
|
}
|
|
@@ -4396,15 +4395,16 @@ function parseClaimResult(body) {
|
|
|
4396
4395
|
async function claimQoderCampaign(credential, product, campaignId, fetcher = fetch) {
|
|
4397
4396
|
const url = `${product.openApiBase}${QODER_CAMPAIGNS_PATH}/${encodeURIComponent(campaignId)}/claim`;
|
|
4398
4397
|
let response;
|
|
4398
|
+
const headers = { ...await creditsHeaders(credential, product), "Content-Type": "application/json" };
|
|
4399
4399
|
try {
|
|
4400
4400
|
response = await fetcher(url, {
|
|
4401
4401
|
method: "POST",
|
|
4402
|
-
headers
|
|
4402
|
+
headers,
|
|
4403
4403
|
body: "",
|
|
4404
4404
|
signal: AbortSignal.timeout(QODER_CREDITS_TIMEOUT_MS)
|
|
4405
4405
|
});
|
|
4406
|
-
} catch
|
|
4407
|
-
return { kind: "
|
|
4406
|
+
} catch {
|
|
4407
|
+
return { kind: "pending", pendingReason: "no-response", message: "\u672A\u6536\u5230\u7B7E\u5230\u7ED3\u679C" };
|
|
4408
4408
|
}
|
|
4409
4409
|
const text = await response.text().catch(() => "");
|
|
4410
4410
|
let body;
|
|
@@ -4423,6 +4423,9 @@ async function claimQoderCampaign(credential, product, campaignId, fetcher = fet
|
|
|
4423
4423
|
if (result.status !== void 0 && result.status !== "CLAIMED") {
|
|
4424
4424
|
return { kind: "failed", code: -1, message: `\u9886\u53D6\u672A\u6210\u529F\uFF08status=${result.status}\uFF09` };
|
|
4425
4425
|
}
|
|
4426
|
+
if (result.status !== "CLAIMED" && !(result.amount !== void 0 && result.amount > 0)) {
|
|
4427
|
+
return { kind: "pending", pendingReason: "response-unconfirmed", message: "\u5DF2\u6536\u5230\u56DE\u5305\uFF0C\u672A\u786E\u8BA4\u9886\u53D6" };
|
|
4428
|
+
}
|
|
4426
4429
|
return { kind: "claimed", credit: result.amount ?? 0, streakDays: 0, isStreakDay: false };
|
|
4427
4430
|
}
|
|
4428
4431
|
function describeNonJson(status, text) {
|
|
@@ -4452,14 +4455,28 @@ async function claimQoderDailyCheckin(credential, product, fetcher = fetch, nowM
|
|
|
4452
4455
|
}
|
|
4453
4456
|
return { kind: "inactive", message: "\u5F53\u524D\u6CA1\u6709\u53EF\u9886\u53D6\u7684\u6D3B\u52A8", unsubmitted: true };
|
|
4454
4457
|
}
|
|
4455
|
-
let total = 0;
|
|
4458
|
+
let total = 0, acknowledged = 0;
|
|
4459
|
+
const unresolved = [];
|
|
4456
4460
|
let firstError;
|
|
4457
4461
|
for (const target of targets) {
|
|
4458
4462
|
const outcome = await claimQoderCampaign(credential, product, target.campaignId, fetcher);
|
|
4459
|
-
if (outcome.kind === "claimed")
|
|
4463
|
+
if (outcome.kind === "claimed") {
|
|
4464
|
+
total += outcome.credit;
|
|
4465
|
+
acknowledged++;
|
|
4466
|
+
} else if (outcome.kind === "pending") unresolved.push(outcome);
|
|
4460
4467
|
else if (outcome.kind === "failed" && firstError === void 0) firstError = outcome.message;
|
|
4461
4468
|
}
|
|
4462
4469
|
if (total > 0) return { kind: "claimed", credit: total, streakDays: 0, isStreakDay: false, ...stale };
|
|
4470
|
+
if (unresolved.length) {
|
|
4471
|
+
const reason = unresolved[0].pendingReason;
|
|
4472
|
+
return {
|
|
4473
|
+
kind: "pending",
|
|
4474
|
+
...unresolved.every((row) => row.pendingReason === reason) && !acknowledged && !firstError ? { pendingReason: reason } : {},
|
|
4475
|
+
message: "\u7B7E\u5230\u7ED3\u679C\u672A\u6838\u5B9E",
|
|
4476
|
+
...stale
|
|
4477
|
+
};
|
|
4478
|
+
}
|
|
4479
|
+
if (acknowledged) return { kind: "claimed", credit: 0, pendingReason: "response-unconfirmed", streakDays: 0, isStreakDay: false, ...stale };
|
|
4463
4480
|
if (firstError !== void 0) return { kind: "failed", code: -1, message: firstError };
|
|
4464
4481
|
return { kind: "already-claimed", message: "\u4ECA\u5929\u5DF2\u9886\u53D6", ...stale };
|
|
4465
4482
|
}
|
|
@@ -4742,7 +4759,7 @@ function readContextWindowField(entry) {
|
|
|
4742
4759
|
const raw = entry.context_window_tokens ?? entry.ContextWindowTokens;
|
|
4743
4760
|
if (typeof raw !== "object" || raw === null) return void 0;
|
|
4744
4761
|
const record = raw;
|
|
4745
|
-
const value = readNumberField(record, "dev") ?? readNumberField(record, "Dev")
|
|
4762
|
+
const value = readNumberField(record, "dev") ?? readNumberField(record, "Dev");
|
|
4746
4763
|
return value !== void 0 && value > 0 ? Math.trunc(value) : void 0;
|
|
4747
4764
|
}
|
|
4748
4765
|
function readMaxContextWindowField(entry) {
|
|
@@ -4758,8 +4775,9 @@ function readDetailMaxTokens(entry, preferredSuffix = "__dev") {
|
|
|
4758
4775
|
const details = raw.filter(
|
|
4759
4776
|
(item) => typeof item === "object" && item !== null
|
|
4760
4777
|
);
|
|
4761
|
-
const
|
|
4762
|
-
const
|
|
4778
|
+
const nameOf = (item) => readStringField(item, "model_name") || readStringField(item, "ModelName");
|
|
4779
|
+
const preferred = details.find((item) => nameOf(item).endsWith(preferredSuffix));
|
|
4780
|
+
const chosen = preferred ?? (preferredSuffix === "__dev" ? details.find((item) => !nameOf(item).endsWith("__max")) : void 0);
|
|
4763
4781
|
if (chosen === void 0) return void 0;
|
|
4764
4782
|
const value = readNumberField(chosen, "max_tokens") ?? readNumberField(chosen, "MaxTokens");
|
|
4765
4783
|
return value !== void 0 && value > 0 ? Math.trunc(value) : void 0;
|
|
@@ -4995,7 +5013,8 @@ var TRAE_MAX_PROMPT_TOKENS = 936e3;
|
|
|
4995
5013
|
var TRAE_MAX_OUTPUT_TOKENS = 64e3;
|
|
4996
5014
|
var TRAE_MAX_MODE_TYPE = 1;
|
|
4997
5015
|
function traeMaxModeFields(maxContext, outputMax) {
|
|
4998
|
-
const context = maxContext >
|
|
5016
|
+
const context = maxContext > 1 ? maxContext : TRAE_MAX_CONTEXT_TOKENS;
|
|
5017
|
+
const output = Math.min(context - 1, outputMax !== void 0 && outputMax > 0 ? outputMax : TRAE_MAX_OUTPUT_TOKENS);
|
|
4999
5018
|
return {
|
|
5000
5019
|
model_auto_selection: {
|
|
5001
5020
|
strategy: "max",
|
|
@@ -5005,8 +5024,8 @@ function traeMaxModeFields(maxContext, outputMax) {
|
|
|
5005
5024
|
model_selection_strategy: "max",
|
|
5006
5025
|
mode_type: TRAE_MAX_MODE_TYPE,
|
|
5007
5026
|
context_window_size: context,
|
|
5008
|
-
prompt_max_tokens: TRAE_MAX_PROMPT_TOKENS,
|
|
5009
|
-
max_tokens:
|
|
5027
|
+
prompt_max_tokens: Math.min(TRAE_MAX_PROMPT_TOKENS, context - output),
|
|
5028
|
+
max_tokens: output
|
|
5010
5029
|
};
|
|
5011
5030
|
}
|
|
5012
5031
|
function transformToSOLOBody(openaiBody, modelMapping, channel) {
|
|
@@ -5271,6 +5290,7 @@ async function fetchTraeCheckinStatus(credential, _product, fetcher = fetch) {
|
|
|
5271
5290
|
}
|
|
5272
5291
|
async function claimTraeDailyCheckin(credential, product, fetcher = fetch, generation = 0, onRotate, userId, retryCount = 3) {
|
|
5273
5292
|
const uid = userId ?? credential.uid;
|
|
5293
|
+
if (!uid) return { kind: "failed", code: -1, message: "\u7F3A\u5C11\u8D26\u53F7\u8EAB\u4EFD", unsubmitted: true };
|
|
5274
5294
|
const doClaim = async () => {
|
|
5275
5295
|
let lastError = { ok: false, httpStatus: 0, message: "", code: 0 };
|
|
5276
5296
|
for (let attempt = 0; attempt <= Math.max(0, retryCount); attempt++) {
|
|
@@ -5291,6 +5311,7 @@ async function claimTraeDailyCheckin(credential, product, fetcher = fetch, gener
|
|
|
5291
5311
|
};
|
|
5292
5312
|
const response = await doClaim();
|
|
5293
5313
|
if (!response.ok) {
|
|
5314
|
+
if (response.httpStatus === 0) return { kind: "pending", pendingReason: "no-response", message: "\u672A\u6536\u5230\u7B7E\u5230\u7ED3\u679C" };
|
|
5294
5315
|
return { kind: "failed", code: -1, message: response.message, errorType: "Unknown", cooldownSecs: 0 };
|
|
5295
5316
|
}
|
|
5296
5317
|
const body = response.body;
|
|
@@ -5307,10 +5328,11 @@ async function claimTraeDailyCheckin(credential, product, fetcher = fetch, gener
|
|
|
5307
5328
|
const msg = readString3(body, "message") || readString3(body, "msg") || "";
|
|
5308
5329
|
if (code === 0) {
|
|
5309
5330
|
const status = await fetchTraeCheckinStatus(credential, product, fetcher);
|
|
5331
|
+
if (!status?.todayCheckedIn) return { kind: "pending", pendingReason: "response-unconfirmed", message: "\u6536\u5230\u7B7E\u5230\u56DE\u5305\uFF0C\u79EF\u5206\u672A\u786E\u8BA4" };
|
|
5310
5332
|
return {
|
|
5311
5333
|
kind: "claimed",
|
|
5312
|
-
credit: status?.dailyCredit ?? 0,
|
|
5313
|
-
streakDays: status?.streakDays ?? 0,
|
|
5334
|
+
credit: status?.todayCheckedIn ? status.dailyCredit ?? 0 : 0,
|
|
5335
|
+
streakDays: status?.todayCheckedIn ? status.streakDays ?? 0 : 0,
|
|
5314
5336
|
isStreakDay: false
|
|
5315
5337
|
};
|
|
5316
5338
|
}
|
|
@@ -5970,11 +5992,29 @@ function mergeQoderCatalog(cli, fallback, requireKey = true) {
|
|
|
5970
5992
|
}
|
|
5971
5993
|
return out;
|
|
5972
5994
|
}
|
|
5995
|
+
function qoderCachedCapabilities(row) {
|
|
5996
|
+
const validToken = (n) => typeof n === "number" && Number.isSafeInteger(n) && n > 0 && n <= 1e7;
|
|
5997
|
+
const options = Array.isArray(row?.contextOptions) ? [...new Set(row.contextOptions.filter(validToken))].sort((a, b) => a - b).slice(0, 16) : [];
|
|
5998
|
+
const context = row?.contextWindow;
|
|
5999
|
+
const efforts = Array.isArray(row?.efforts) ? [...new Set(row.efforts.filter((e) => typeof e === "string" && /^[a-z0-9_-]{1,32}$/i.test(e)))].slice(0, 16) : void 0;
|
|
6000
|
+
return {
|
|
6001
|
+
...validToken(context) ? { contextWindow: context } : {},
|
|
6002
|
+
...validToken(context) && options.includes(context) ? { contextOptions: options } : {},
|
|
6003
|
+
...typeof row?.supportsImage === "boolean" ? { supportsImage: row.supportsImage } : {},
|
|
6004
|
+
...typeof row?.supportsThinking === "boolean" ? { supportsThinking: row.supportsThinking } : {},
|
|
6005
|
+
...typeof row?.supportsDisable === "boolean" ? { supportsDisable: row.supportsDisable } : {},
|
|
6006
|
+
...efforts !== void 0 ? { efforts } : {},
|
|
6007
|
+
...typeof row?.defaultEffort === "string" && efforts?.includes(row.defaultEffort) ? { defaultEffort: row.defaultEffort } : {},
|
|
6008
|
+
...validToken(row?.maxTokens) ? { maxTokens: row.maxTokens } : {}
|
|
6009
|
+
};
|
|
6010
|
+
}
|
|
5973
6011
|
function readQoderCatalog(file, fallback) {
|
|
5974
6012
|
try {
|
|
5975
6013
|
const rows = JSON.parse(readFileSync6(file, "utf8"));
|
|
5976
6014
|
if (!Array.isArray(rows)) return null;
|
|
5977
|
-
const
|
|
6015
|
+
const input = rows.filter((row) => typeof row?.id === "string" && row.id.length <= 256 && typeof row.name === "string" && row.name.length <= 160).slice(0, 512);
|
|
6016
|
+
const byId = new Map(input.map((row) => [row.id, row]));
|
|
6017
|
+
const catalog = mergeQoderCatalog(input, fallback).map((model) => ({ ...model, ...qoderCachedCapabilities(byId.get(model.id)) }));
|
|
5978
6018
|
return catalog.length ? catalog : null;
|
|
5979
6019
|
} catch {
|
|
5980
6020
|
return null;
|
|
@@ -5984,7 +6024,11 @@ async function saveQoderCatalog(file, catalog) {
|
|
|
5984
6024
|
const temporary = file + "." + randomUUID2() + ".tmp";
|
|
5985
6025
|
try {
|
|
5986
6026
|
await mkdir(dirname2(file), { recursive: true, mode: 448 });
|
|
5987
|
-
await writeFile(temporary, JSON.stringify(catalog.map((
|
|
6027
|
+
await writeFile(temporary, JSON.stringify(catalog.map((model) => ({
|
|
6028
|
+
id: model.id,
|
|
6029
|
+
name: model.name,
|
|
6030
|
+
...qoderCachedCapabilities(model)
|
|
6031
|
+
}))), { mode: 384 });
|
|
5988
6032
|
await rename(temporary, file);
|
|
5989
6033
|
} finally {
|
|
5990
6034
|
await unlink(temporary).catch(() => {
|
|
@@ -6067,23 +6111,29 @@ function toQoderModelRow(entry) {
|
|
|
6067
6111
|
const value = (row.thinking_config?.enabled?.efforts)[effort];
|
|
6068
6112
|
return value?.is_default === true;
|
|
6069
6113
|
});
|
|
6070
|
-
const
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6114
|
+
const sizes = object(row.context_config) ? Object.values(row.context_config).flatMap((cfg) => {
|
|
6115
|
+
if (!object(cfg)) return [];
|
|
6116
|
+
const tokens = typeof cfg.token_count === "string" && /^\d+$/.test(cfg.token_count) ? Number(cfg.token_count) : cfg.token_count;
|
|
6117
|
+
return typeof tokens === "number" && Number.isSafeInteger(tokens) && tokens > 0 && tokens <= 1e7 ? [{ tokens, preferred: cfg.is_default === true }] : [];
|
|
6118
|
+
}) : [];
|
|
6119
|
+
const contextOptions = [...new Set(sizes.map((cfg) => cfg.tokens))].sort((a, b) => a - b).slice(0, 16);
|
|
6120
|
+
const contextWindow = sizes.find((cfg) => cfg.preferred && contextOptions.includes(cfg.tokens))?.tokens ?? contextOptions[0] ?? Number(row.max_input_tokens);
|
|
6121
|
+
const rawPrice = row.price_factor;
|
|
6122
|
+
const priceFactor = typeof rawPrice === "number" || typeof rawPrice === "string" && rawPrice.trim() !== "" ? Number(rawPrice) : NaN;
|
|
6074
6123
|
return {
|
|
6075
6124
|
id: row.key,
|
|
6076
6125
|
name: nonEmptyString(row.display_name) ? row.display_name : row.key,
|
|
6077
6126
|
// `0` 是「未知窗口」哨兵(宿主投影按 `> 0` 过滤),不编造。
|
|
6078
|
-
contextWindow: Number.
|
|
6127
|
+
contextWindow: Number.isSafeInteger(contextWindow) && contextWindow > 0 && contextWindow <= 1e7 ? contextWindow : 0,
|
|
6128
|
+
...contextOptions.length ? { contextOptions } : {},
|
|
6079
6129
|
supportsImage: row.is_vl === true,
|
|
6080
6130
|
// ⚠️ 上游 `is_reasoning` 与「是否产出 reasoning_content」不完全一致:
|
|
6081
6131
|
// `dfmodel` 报 `is_reasoning:false` 但实测 50/57 帧有思考,且目录给了
|
|
6082
6132
|
// 三个档位。有档位即可思考 —— 不要用 `is_reasoning:false` 把档位选择器关掉。
|
|
6083
6133
|
supportsThinking: row.is_reasoning === true || efforts.length > 0,
|
|
6084
|
-
|
|
6134
|
+
efforts,
|
|
6085
6135
|
...defaultEffort !== void 0 ? { defaultEffort } : {},
|
|
6086
|
-
|
|
6136
|
+
supportsDisable: row.thinking_config?.disabled !== void 0,
|
|
6087
6137
|
// ⚠️ `0` 是合法的「免费」倍率,不能当缺失处理(`Number.isFinite` 判据)。
|
|
6088
6138
|
...Number.isFinite(priceFactor) && priceFactor >= 0 ? { priceFactor } : {}
|
|
6089
6139
|
};
|
|
@@ -7505,6 +7555,16 @@ var QoderAdapter = class extends LlmAdapter {
|
|
|
7505
7555
|
const override = this.options.accountPool?.modelParamsFor?.(this.product.id, model)?.supportsImage;
|
|
7506
7556
|
return (override ?? this.modelEntry(model)?.supportsImage) === true ? ["text", "image"] : ["text"];
|
|
7507
7557
|
}
|
|
7558
|
+
outputBudget(entry, contextWindow, requested) {
|
|
7559
|
+
const budget = requested ?? defaultModelOutputTokens(entry?.maxTokens, contextWindow);
|
|
7560
|
+
if (contextWindow === void 0 || budget < contextWindow) return budget;
|
|
7561
|
+
return Math.max(1, Math.min(32768, contextWindow - 1));
|
|
7562
|
+
}
|
|
7563
|
+
contextFor(model, entry = this.modelEntry(model)) {
|
|
7564
|
+
const override = this.options.accountPool?.modelParamsFor?.(this.product.id, model)?.contextWindow;
|
|
7565
|
+
if (override !== void 0 && entry?.contextOptions?.includes(override)) return override;
|
|
7566
|
+
return entry && entry.contextWindow > 0 ? entry.contextWindow : void 0;
|
|
7567
|
+
}
|
|
7508
7568
|
modelEntry(id) {
|
|
7509
7569
|
return this.cliCatalog?.find((model) => model.id === id) ?? this.fallbackIndex.get(id);
|
|
7510
7570
|
}
|
|
@@ -7546,10 +7606,11 @@ var QoderAdapter = class extends LlmAdapter {
|
|
|
7546
7606
|
return {
|
|
7547
7607
|
id: model.id,
|
|
7548
7608
|
name: readableModelName(model.id, qoderDisplayName(model)),
|
|
7549
|
-
defaultMaxTokens:
|
|
7609
|
+
defaultMaxTokens: this.outputBudget(model, model.contextWindow || void 0),
|
|
7550
7610
|
rateBadge: qoderRateBadge(model),
|
|
7551
7611
|
...model.subscriptionOnly === true || fallback?.subscriptionOnly === true ? { subscriptionOnly: true } : {},
|
|
7552
|
-
|
|
7612
|
+
contextWindow: model.contextWindow,
|
|
7613
|
+
contextOptions: model.contextOptions ?? (model.contextWindow > 0 ? [model.contextWindow] : []),
|
|
7553
7614
|
...typeof model.maxTokens === "number" ? { maxTokens: model.maxTokens } : {},
|
|
7554
7615
|
efforts: qoderEffortsFor(model),
|
|
7555
7616
|
defaultEffort: qoderDefaultEffort(model),
|
|
@@ -7586,9 +7647,13 @@ var QoderAdapter = class extends LlmAdapter {
|
|
|
7586
7647
|
);
|
|
7587
7648
|
this.catalogIssue = result.issue;
|
|
7588
7649
|
if (catalog) {
|
|
7589
|
-
this.cliCatalog
|
|
7650
|
+
const previous = new Map(this.cliCatalog?.map((model) => [model.id, model]));
|
|
7651
|
+
this.cliCatalog = catalog.map((model) => {
|
|
7652
|
+
const old = previous.get(model.id);
|
|
7653
|
+
return { ...model, ...qoderCachedCapabilities(old) };
|
|
7654
|
+
});
|
|
7590
7655
|
this.catalogSource = "remote";
|
|
7591
|
-
if (this.options.cliCatalogFile) await saveQoderCatalog(this.options.cliCatalogFile,
|
|
7656
|
+
if (this.options.cliCatalogFile) await saveQoderCatalog(this.options.cliCatalogFile, this.cliCatalog).catch(() => {
|
|
7592
7657
|
});
|
|
7593
7658
|
} else {
|
|
7594
7659
|
this.catalogSource = this.cliCatalog ? "cached" : "fallback";
|
|
@@ -7651,14 +7716,16 @@ var QoderAdapter = class extends LlmAdapter {
|
|
|
7651
7716
|
*/
|
|
7652
7717
|
async resolveModel(provider, model, _signal) {
|
|
7653
7718
|
const entry = this.modelEntry(model);
|
|
7719
|
+
const contextWindow = this.contextFor(model, entry);
|
|
7720
|
+
const override = this.options.accountPool?.modelParamsFor?.(provider, model)?.maxTokens;
|
|
7654
7721
|
const resolved = {
|
|
7655
7722
|
provider,
|
|
7656
7723
|
id: model,
|
|
7657
7724
|
name: readableModelName(model, entry?.name),
|
|
7658
7725
|
inputModalities: this.inputModalitiesFor(model),
|
|
7659
|
-
defaultMaxTokens:
|
|
7726
|
+
defaultMaxTokens: this.outputBudget(entry, contextWindow, override)
|
|
7660
7727
|
};
|
|
7661
|
-
if (
|
|
7728
|
+
if (contextWindow !== void 0) resolved.context = { contextWindow };
|
|
7662
7729
|
if (entry !== void 0) {
|
|
7663
7730
|
const efforts = qoderEffortsFor(entry);
|
|
7664
7731
|
if (efforts.length > 0) {
|
|
@@ -7730,10 +7797,12 @@ var QoderAdapter = class extends LlmAdapter {
|
|
|
7730
7797
|
const history = buildQoderHistory(messages);
|
|
7731
7798
|
const tools = buildQoderTools(options.tools);
|
|
7732
7799
|
const fallback = this.modelEntry(options.model);
|
|
7733
|
-
const
|
|
7800
|
+
const contextWindow = this.contextFor(options.model, fallback);
|
|
7801
|
+
const configuredMax = this.options.accountPool?.modelParamsFor?.(this.product.id, options.model)?.maxTokens;
|
|
7802
|
+
const maxTokens = this.outputBudget(fallback, contextWindow, options.maxTokens ?? configuredMax);
|
|
7734
7803
|
const reasoningEffort = options.reasoningEffort ?? (fallback && qoderDefaultEffort(fallback));
|
|
7735
7804
|
const buildRequest = async (c) => {
|
|
7736
|
-
const client = await QoderEncryptedInfer.create({
|
|
7805
|
+
const client = await (this.options.createEncryptedInfer ?? QoderEncryptedInfer.create)({
|
|
7737
7806
|
user: {
|
|
7738
7807
|
uid: c.uid,
|
|
7739
7808
|
securityOauthToken: c.security_oauth_token ?? c.access_token
|
|
@@ -7762,6 +7831,7 @@ var QoderAdapter = class extends LlmAdapter {
|
|
|
7762
7831
|
...this.inputModalitiesFor(options.model).includes("image") ? { isVl: true } : fallback?.supportsImage === false ? { isVl: false } : {},
|
|
7763
7832
|
// 官方 `model_config` 的 display_name / max_input_tokens 必须带上。
|
|
7764
7833
|
...fallback?.name !== void 0 ? { displayName: fallback.name } : {},
|
|
7834
|
+
...fallback?.contextOptions?.includes(contextWindow ?? 0) ? { contextWindow } : {},
|
|
7765
7835
|
...fallback && fallback.contextWindow > 0 ? { maxInputTokens: fallback.contextWindow } : {},
|
|
7766
7836
|
// ⚠️ **`business` 必填**,否则服务端把请求路由到错误的后端节点。
|
|
7767
7837
|
//
|
|
@@ -8915,10 +8985,7 @@ var TraeAdapter = class extends LlmAdapter2 {
|
|
|
8915
8985
|
*/
|
|
8916
8986
|
contextWindowFor(model) {
|
|
8917
8987
|
const meta = this.remoteMeta.get(model);
|
|
8918
|
-
|
|
8919
|
-
return meta?.maxContextWindow ?? TRAE_MAX_CONTEXT_TOKENS;
|
|
8920
|
-
}
|
|
8921
|
-
return meta?.contextWindow ?? this.fallbackIndex.get(model)?.contextWindow;
|
|
8988
|
+
return this.maxModeContextFor(model) ?? meta?.contextWindow ?? this.fallbackIndex.get(model)?.contextWindow;
|
|
8922
8989
|
}
|
|
8923
8990
|
/**
|
|
8924
8991
|
* 该模型本次是否启用 **Max 模式**(1M 上下文)。
|
|
@@ -8931,15 +8998,15 @@ var TraeAdapter = class extends LlmAdapter2 {
|
|
|
8931
8998
|
* "Never fabricate max limits for a model the account config does not mark");
|
|
8932
8999
|
* 3. 若配置了白名单,模型须在其中。
|
|
8933
9000
|
*/
|
|
8934
|
-
|
|
8935
|
-
if (this.product.maxMode !== true) return
|
|
9001
|
+
maxModeContextFor(model) {
|
|
9002
|
+
if (this.product.maxMode !== true) return void 0;
|
|
8936
9003
|
const meta = this.remoteMeta.get(model);
|
|
8937
|
-
|
|
9004
|
+
const max = meta?.maxContextWindow;
|
|
9005
|
+
const regular = meta?.contextWindow ?? this.fallbackIndex.get(model)?.contextWindow;
|
|
9006
|
+
if (meta?.maxMode !== true || typeof max !== "number" || !Number.isSafeInteger(max) || max <= 1 || regular !== void 0 && max <= regular) return void 0;
|
|
8938
9007
|
const whitelist = this.product.maxModeModels;
|
|
8939
|
-
if (whitelist
|
|
8940
|
-
|
|
8941
|
-
}
|
|
8942
|
-
return true;
|
|
9008
|
+
if (whitelist?.length && !whitelist.includes("*") && !whitelist.includes(model)) return void 0;
|
|
9009
|
+
return max;
|
|
8943
9010
|
}
|
|
8944
9011
|
/**
|
|
8945
9012
|
* 模型可选的推理强度档位(`reasoning_effort_config`)。
|
|
@@ -8981,7 +9048,7 @@ var TraeAdapter = class extends LlmAdapter2 {
|
|
|
8981
9048
|
*/
|
|
8982
9049
|
maxOutputTokensFor(model) {
|
|
8983
9050
|
const meta = this.remoteMeta.get(model);
|
|
8984
|
-
if (this.
|
|
9051
|
+
if (this.maxModeContextFor(model) !== void 0 && meta?.maxModeOutputTokens !== void 0) {
|
|
8985
9052
|
return meta.maxModeOutputTokens;
|
|
8986
9053
|
}
|
|
8987
9054
|
return meta?.maxOutputTokens ?? this.product.fallbackMaxOutputTokens;
|
|
@@ -9156,8 +9223,6 @@ var TraeAdapter = class extends LlmAdapter2 {
|
|
|
9156
9223
|
}));
|
|
9157
9224
|
}
|
|
9158
9225
|
if (options.temperature !== void 0) openaiBody.temperature = options.temperature;
|
|
9159
|
-
const maxTokens = clampTraeMaxTokens(options.maxTokens ?? defaultModelOutputTokens(this.maxOutputTokensFor(options.model)));
|
|
9160
|
-
if (maxTokens !== void 0) openaiBody.max_tokens = maxTokens;
|
|
9161
9226
|
if (options.stop !== void 0 && options.stop.length > 0) openaiBody.stop = options.stop;
|
|
9162
9227
|
const reasoningCfg = this.remoteMeta.get(options.model)?.reasoningConfig ?? this.fallbackIndex.get(options.model)?.reasoningConfig;
|
|
9163
9228
|
const requestedEffort = options.reasoningEffort ?? this.reasoningFor(options.model)?.defaultEffort;
|
|
@@ -9167,16 +9232,14 @@ var TraeAdapter = class extends LlmAdapter2 {
|
|
|
9167
9232
|
}
|
|
9168
9233
|
const buildSoloBody = (useMaxMode, channel) => {
|
|
9169
9234
|
const payload = { ...openaiBody };
|
|
9170
|
-
|
|
9171
|
-
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
|
|
9178
|
-
);
|
|
9179
|
-
}
|
|
9235
|
+
const meta = this.remoteMeta.get(options.model);
|
|
9236
|
+
const maxContext = useMaxMode ? this.maxModeContextFor(options.model) : void 0;
|
|
9237
|
+
const regularOutput = defaultModelOutputTokens(meta?.maxOutputTokens ?? this.product.fallbackMaxOutputTokens);
|
|
9238
|
+
const output = maxContext === void 0 ? regularOutput : meta?.maxModeOutputTokens ?? regularOutput;
|
|
9239
|
+
const requested = typeof options.maxTokens === "number" && options.maxTokens > 0 ? options.maxTokens : output;
|
|
9240
|
+
const bounded = Math.min(requested, output);
|
|
9241
|
+
if (maxContext !== void 0) Object.assign(payload, traeMaxModeFields(maxContext, bounded));
|
|
9242
|
+
else payload.max_tokens = clampTraeMaxTokens(bounded);
|
|
9180
9243
|
if (options.system !== void 0 && options.system.length > 0) {
|
|
9181
9244
|
payload.messages = [
|
|
9182
9245
|
{ role: "system", content: options.system },
|
|
@@ -9191,7 +9254,7 @@ var TraeAdapter = class extends LlmAdapter2 {
|
|
|
9191
9254
|
}
|
|
9192
9255
|
return JSON.stringify(solo);
|
|
9193
9256
|
};
|
|
9194
|
-
let usingMaxMode = this.
|
|
9257
|
+
let usingMaxMode = this.maxModeContextFor(options.model) !== void 0;
|
|
9195
9258
|
let activeChannel = this.channelFor(options.model);
|
|
9196
9259
|
const fallbackChannels = ["solo_agent", "chat_v3", "solo_work_lite", "solo_coder"].filter((fn) => fn !== activeChannel);
|
|
9197
9260
|
let fallbackChannelIndex = 0;
|
|
@@ -10638,6 +10701,8 @@ function computeClaimSummary(outcomes) {
|
|
|
10638
10701
|
case "inactive":
|
|
10639
10702
|
summary.inactive += 1;
|
|
10640
10703
|
break;
|
|
10704
|
+
case "pending":
|
|
10705
|
+
break;
|
|
10641
10706
|
case "failed":
|
|
10642
10707
|
summary.failed += 1;
|
|
10643
10708
|
break;
|
|
@@ -11260,7 +11325,7 @@ function registerChannelPackEndpoints(ctx, pool, qoder, qoderCn, trae, raccoon,
|
|
|
11260
11325
|
}
|
|
11261
11326
|
return {
|
|
11262
11327
|
ok: true,
|
|
11263
|
-
value: outcome.kind === "claimed" ? { outcome: "claimed", credit: outcome.credit, message: outcome.delayedMessage ?? "" } : { outcome: outcome.kind === "already-claimed" ? "done" : outcome.kind, message: outcome.message }
|
|
11328
|
+
value: outcome.kind === "claimed" ? { outcome: "claimed", credit: outcome.credit, message: outcome.delayedMessage ?? "" } : { outcome: outcome.kind === "already-claimed" ? "done" : outcome.kind, message: outcome.message, ...outcome.pendingReason ? { pendingReason: outcome.pendingReason } : {} }
|
|
11264
11329
|
};
|
|
11265
11330
|
}
|
|
11266
11331
|
// ── 限流标记:重测(发真实请求验证)──
|
|
@@ -11548,6 +11613,7 @@ function registerChannelPackEndpoints(ctx, pool, qoder, qoderCn, trae, raccoon,
|
|
|
11548
11613
|
...model.rateBadge === void 0 ? {} : { rateBadge: model.rateBadge },
|
|
11549
11614
|
// 能力元数据:界面据此只渲染该模型真正支持的档位(不猜、不给做不到的选项)。
|
|
11550
11615
|
...model.contextWindow === void 0 ? {} : { contextWindow: model.contextWindow },
|
|
11616
|
+
...model.contextOptions === void 0 ? {} : { contextOptions: [...model.contextOptions] },
|
|
11551
11617
|
...model.maxTokens === void 0 ? {} : { maxTokens: model.maxTokens },
|
|
11552
11618
|
...model.defaultMaxTokens === void 0 ? {} : { defaultMaxTokens: model.defaultMaxTokens },
|
|
11553
11619
|
...model.stale === true ? { stale: true } : {},
|
|
@@ -11677,7 +11743,8 @@ function registerChannelPackEndpoints(ctx, pool, qoder, qoderCn, trae, raccoon,
|
|
|
11677
11743
|
const capacity = row?.contextWindow;
|
|
11678
11744
|
const output = previous?.maxTokens ?? row?.defaultMaxTokens;
|
|
11679
11745
|
const target = value2 ?? capacity;
|
|
11680
|
-
|
|
11746
|
+
const supported = target !== void 0 && (row?.contextOptions !== void 0 ? row.contextOptions.includes(target) : capacity !== void 0 && capacity > 0 && target <= capacity);
|
|
11747
|
+
if (!supported || target !== void 0 && output !== void 0 && target <= output) {
|
|
11681
11748
|
return { ok: false, error: { code: "bad-request", message: "\u4E0A\u4E0B\u6587\u7A97\u53E3\u8D85\u51FA\u76EE\u5F55\u5BB9\u91CF\u8303\u56F4\u6216\u5C0F\u4E8E\u7B49\u4E8E\u8F93\u51FA\u9884\u7559" } };
|
|
11682
11749
|
}
|
|
11683
11750
|
const merged = { ...previous };
|
|
@@ -11687,6 +11754,17 @@ function registerChannelPackEndpoints(ctx, pool, qoder, qoderCn, trae, raccoon,
|
|
|
11687
11754
|
} else {
|
|
11688
11755
|
const params = req.contextOnly === true ? void 0 : req.params;
|
|
11689
11756
|
const next2 = field === void 0 ? params : { ...previous, [field]: params?.[field] };
|
|
11757
|
+
if (req.provider === "qodercn" && (field === void 0 || field === "maxTokens")) {
|
|
11758
|
+
const row = modelAdapters?.[req.provider]?.listAllModels().find((model) => model.id === req.modelId);
|
|
11759
|
+
const requestedContext = next2?.contextWindow;
|
|
11760
|
+
const explicitlyWritten = field === void 0 && requestedContext !== void 0;
|
|
11761
|
+
const supported = requestedContext !== void 0 && row?.contextOptions?.includes(requestedContext);
|
|
11762
|
+
const context = supported ? requestedContext : row?.contextWindow;
|
|
11763
|
+
const output = next2?.maxTokens ?? row?.defaultMaxTokens;
|
|
11764
|
+
if (explicitlyWritten && !supported || context !== void 0 && context > 0 && output !== void 0 && output >= context) {
|
|
11765
|
+
return { ok: false, error: { code: "bad-request", message: "\u4E0A\u4E0B\u6587\u6863\u4F4D\u672A\u83B7\u76EE\u5F55\u786E\u8BA4\uFF0C\u6216\u7A97\u53E3\u5C0F\u4E8E\u7B49\u4E8E\u8F93\u51FA\u9884\u7559" } };
|
|
11766
|
+
}
|
|
11767
|
+
}
|
|
11690
11768
|
const requestedEffort = field === void 0 || field === "reasoningEffort" ? next2?.reasoningEffort : void 0;
|
|
11691
11769
|
if (typeof requestedEffort === "string" && requestedEffort.length > 0) {
|
|
11692
11770
|
const row = modelAdapters?.[req.provider]?.listAllModels().find((model) => model.id === req.modelId);
|
|
@@ -12213,6 +12291,7 @@ function readNumber3(value) {
|
|
|
12213
12291
|
}
|
|
12214
12292
|
async function requestJson(url, credential, product, init, fetcher, signal) {
|
|
12215
12293
|
const timeout = AbortSignal.timeout(RACCOON_REQUEST_TIMEOUT_MS);
|
|
12294
|
+
let receivedResponse = false;
|
|
12216
12295
|
try {
|
|
12217
12296
|
const response = await fetcher(url, {
|
|
12218
12297
|
method: init.method,
|
|
@@ -12223,6 +12302,7 @@ async function requestJson(url, credential, product, init, fetcher, signal) {
|
|
|
12223
12302
|
...init.body === void 0 ? {} : { body: init.body },
|
|
12224
12303
|
signal: signal ? AbortSignal.any([signal, timeout]) : timeout
|
|
12225
12304
|
});
|
|
12305
|
+
receivedResponse = true;
|
|
12226
12306
|
const parsed = await response.json();
|
|
12227
12307
|
return parseEnvelope(parsed, response.status);
|
|
12228
12308
|
} catch (error) {
|
|
@@ -12230,7 +12310,8 @@ async function requestJson(url, credential, product, init, fetcher, signal) {
|
|
|
12230
12310
|
ok: false,
|
|
12231
12311
|
code: -1,
|
|
12232
12312
|
message: error instanceof Error ? error.message : String(error),
|
|
12233
|
-
data: void 0
|
|
12313
|
+
data: void 0,
|
|
12314
|
+
receivedResponse
|
|
12234
12315
|
};
|
|
12235
12316
|
}
|
|
12236
12317
|
}
|
|
@@ -12344,16 +12425,18 @@ async function checkInRaccoon(product, credential, fetcher = fetch) {
|
|
|
12344
12425
|
fetcher
|
|
12345
12426
|
);
|
|
12346
12427
|
if (!trigger.ok) {
|
|
12428
|
+
if (beforeKeys?.size) return { kind: "already-claimed", message: "\u4ECA\u65E5\u5DF2\u7B7E\u5230" };
|
|
12429
|
+
if (trigger.code === -1) return { kind: "pending", pendingReason: trigger.receivedResponse ? "response-unconfirmed" : "no-response", message: "\u6B64\u6B21\u7B7E\u5230\u672A\u80FD\u6838\u5B9E" };
|
|
12347
12430
|
return {
|
|
12348
12431
|
kind: "failed",
|
|
12349
12432
|
code: trigger.code,
|
|
12350
12433
|
message: trigger.message.length > 0 ? trigger.message : "\u7B7E\u5230\u8BF7\u6C42\u5931\u8D25"
|
|
12351
12434
|
};
|
|
12352
12435
|
}
|
|
12353
|
-
const unsettled = { kind: "
|
|
12436
|
+
const unsettled = { kind: "pending", pendingReason: "response-unconfirmed", message: "\u5DF2\u6536\u5230\u56DE\u5305\uFF0C\u79EF\u5206\u672A\u786E\u8BA4" };
|
|
12354
12437
|
if (beforeKeys === null) return unsettled;
|
|
12355
12438
|
const after = await readBills(product, credential, fetcher);
|
|
12356
|
-
if (after === null) return unsettled;
|
|
12439
|
+
if (after === null) return beforeKeys.size ? { kind: "already-claimed", message: "\u4ECA\u65E5\u5DF2\u7B7E\u5230" } : unsettled;
|
|
12357
12440
|
let credit = 0;
|
|
12358
12441
|
const names = [];
|
|
12359
12442
|
for (const item of after) {
|
|
@@ -12373,7 +12456,7 @@ async function checkInRaccoon(product, credential, fetcher = fetch) {
|
|
|
12373
12456
|
...names.length > 0 ? { delayedMessage: names.join(" + ") } : {}
|
|
12374
12457
|
};
|
|
12375
12458
|
}
|
|
12376
|
-
return { kind: "already-claimed", message: "\u4ECA\u65E5\u5DF2\u7B7E\u5230" };
|
|
12459
|
+
return beforeKeys.size ? { kind: "already-claimed", message: "\u4ECA\u65E5\u5DF2\u7B7E\u5230" } : unsettled;
|
|
12377
12460
|
}
|
|
12378
12461
|
async function fetchRaccoonOnboardingStatus(product, credential, fetcher = fetch) {
|
|
12379
12462
|
const envelope = await requestJson(
|
|
@@ -16532,8 +16615,8 @@ function mountBackend(ctx, onRpc, options = {}) {
|
|
|
16532
16615
|
if (!info || override === void 0) return info;
|
|
16533
16616
|
const next = {
|
|
16534
16617
|
...info,
|
|
16535
|
-
...override.contextWindow === void 0 ? {} : { context: { ...info.context, contextWindow: override.contextWindow } },
|
|
16536
|
-
...override.maxTokens === void 0 ? {} : { defaultMaxTokens: override.maxTokens }
|
|
16618
|
+
...args[0] === "qodercn" || override.contextWindow === void 0 ? {} : { context: { ...info.context, contextWindow: override.contextWindow } },
|
|
16619
|
+
...args[0] === "qodercn" || override.maxTokens === void 0 ? {} : { defaultMaxTokens: override.maxTokens }
|
|
16537
16620
|
};
|
|
16538
16621
|
const effort = override.reasoningEffort;
|
|
16539
16622
|
const efforts = next.reasoning?.efforts;
|
package/lib/channel-contract.js
CHANGED
|
@@ -27,6 +27,10 @@ const wireFinite = (value) => typeof value === 'number' && Number.isFinite(value
|
|
|
27
27
|
/** 套餐档位白名单(Raccoon 家族按它分流;缺省不是错误)。 */
|
|
28
28
|
const WIRE_PLANS = ['free', 'pro', 'unknown']
|
|
29
29
|
|
|
30
|
+
export function checkinPendingReason(value) {
|
|
31
|
+
return value === 'response-unconfirmed' || value === 'no-response' ? value : undefined
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
export function projectRouteObservation(value) {
|
|
31
35
|
return ['ready', 'catalog-missing', 'restricted', 'exhausted', 'expired', 'unknown', 'rate-limited'].includes(value?.status)
|
|
32
36
|
&& Number.isSafeInteger(value?.checkedAt) && value.checkedAt > 0
|
|
@@ -92,6 +96,13 @@ export function accountView(wire, provider) {
|
|
|
92
96
|
* ⚠️ 能力字段(`contextWindow` / `maxTokens` / `efforts` / `supportsImage`)**缺席即未知**:
|
|
93
97
|
* 界面据此不给对应控件,不猜模型有什么能力。`stale` / `subscriptionOnly` 同理。
|
|
94
98
|
*/
|
|
99
|
+
function modelContextOptions(value, defaultValue) {
|
|
100
|
+
if (!Array.isArray(value)) return null
|
|
101
|
+
const sizes = [...new Set(value.filter(n => Number.isSafeInteger(n) && n > 0 && n <= 10_000_000))]
|
|
102
|
+
.sort((a, b) => a - b).slice(0, 16)
|
|
103
|
+
return sizes.includes(defaultValue) ? sizes : []
|
|
104
|
+
}
|
|
105
|
+
|
|
95
106
|
export function modelWire(raw) {
|
|
96
107
|
const source = raw && typeof raw === 'object' ? raw : {}
|
|
97
108
|
const contextWindow = wireFinite(source.contextWindow)
|
|
@@ -110,6 +121,7 @@ export function modelWire(raw) {
|
|
|
110
121
|
isFree: source.isFree === true,
|
|
111
122
|
...(source.subscriptionOnly === true ? { subscriptionOnly: true } : {}),
|
|
112
123
|
...(contextWindow !== null && contextWindow > 0 ? { contextWindow } : {}),
|
|
124
|
+
...(Array.isArray(source.contextOptions) ? { contextOptions: modelContextOptions(source.contextOptions, contextWindow) } : {}),
|
|
113
125
|
...(maxTokens !== null && maxTokens > 0 ? { maxTokens } : {}),
|
|
114
126
|
...(defaultMaxTokens !== null && defaultMaxTokens > 0 ? { defaultMaxTokens } : {}),
|
|
115
127
|
...(Array.isArray(source.efforts) ? { efforts: source.efforts.filter(x => typeof x === 'string').slice(0, 8) } : {}),
|
|
@@ -161,6 +173,7 @@ export function modelView(wire, provider) {
|
|
|
161
173
|
isFree: source.isFree === true,
|
|
162
174
|
subscriptionOnly: source.subscriptionOnly === true,
|
|
163
175
|
contextWindow: wireFinite(source.contextWindow),
|
|
176
|
+
...(Array.isArray(source.contextOptions) ? { contextOptions: modelContextOptions(source.contextOptions, wireFinite(source.contextWindow)) } : {}),
|
|
164
177
|
maxTokens: wireFinite(source.maxTokens),
|
|
165
178
|
defaultMaxTokens: wireFinite(source.defaultMaxTokens),
|
|
166
179
|
efforts: Array.isArray(source.efforts) ? source.efforts.filter(x => typeof x === 'string').slice(0, 8) : [],
|