dsh-xdpool 3.0.6 → 3.0.8
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/CHANGELOG.md +2432 -2334
- package/LICENSE +21 -21
- package/README.en.md +308 -308
- package/README.md +33 -0
- package/cordis.patch.yml +24 -24
- package/lib/bin.js +787 -36
- package/lib/client.js +1199 -198
- package/lib/index.d.ts +481 -8
- package/lib/index.js +5918 -765
- package/package.json +1 -1
- package/screenshots.json +9 -9
- package/scripts/extract-design-css.mjs +322 -322
- package/scripts/link-host-peers.mjs +359 -359
- package/scripts/make-rail-icons.mjs +46 -46
- package/scripts/probe-channels.mjs +142 -142
- package/vendor/channel-pack/LICENSE +21 -21
- package/vendor/channel-pack/NOTICE.md +53 -53
- package/vendor/channel-pack/pack.js +257 -65
|
@@ -1299,6 +1299,21 @@ var init_oauth = __esm({
|
|
|
1299
1299
|
});
|
|
1300
1300
|
|
|
1301
1301
|
// vendor/channel-pack/src/login.ts
|
|
1302
|
+
/**
|
|
1303
|
+
* CodeArts 国际站主机名切换(issue #244)。
|
|
1304
|
+
*
|
|
1305
|
+
* 大陆站与国际站是两套完全独立的账号体系,包里所有华为端点都写死大陆字面量,
|
|
1306
|
+
* 国际站账号在登录门户就被拒。这里按环境变量把主机名换成 ap-southeast-1;
|
|
1307
|
+
* 未设置时逐字节保持现状(默认行为不变)。
|
|
1308
|
+
* STS token 交换端点两站共享(magpie 实测),**刻意不改写**。
|
|
1309
|
+
*/
|
|
1310
|
+
function codeartsSiteHost(base) {
|
|
1311
|
+
if (process.env.DSH_XDPOOL_CODEARTS_INTL !== "1") return base;
|
|
1312
|
+
return base
|
|
1313
|
+
.replace("snap-access.cn-north-4.myhuaweicloud.com", "snap-access.ap-southeast-1.myhuaweicloud.com")
|
|
1314
|
+
.replace("codearts.huaweicloud.com", "codearts.ap-southeast-1.huaweicloud.com")
|
|
1315
|
+
.replace("opengw.developer.huaweicloud.com", "opengw.ap-southeast-1.huaweicloud.com");
|
|
1316
|
+
}
|
|
1302
1317
|
var login_exports = {};
|
|
1303
1318
|
__export(login_exports, {
|
|
1304
1319
|
CODEARTS_LOGIN_BASE: () => CODEARTS_LOGIN_BASE,
|
|
@@ -1629,7 +1644,7 @@ var init_login = __esm({
|
|
|
1629
1644
|
init_oauth();
|
|
1630
1645
|
CODEARTS_LOGIN_BASE = "https://devcloud.cn-north-4.huaweicloud.com/doer/redirect";
|
|
1631
1646
|
HUAWEI_AUTH_BASE = "https://auth.huaweicloud.com/authui/login.html";
|
|
1632
|
-
CREDENTIAL_ENDPOINT = "https://snap-access.cn-north-4.myhuaweicloud.com/snap-manager/v1/login/ticket";
|
|
1647
|
+
CREDENTIAL_ENDPOINT = codeartsSiteHost("https://snap-access.cn-north-4.myhuaweicloud.com/snap-manager/v1/login/ticket");
|
|
1633
1648
|
PLUGIN_NAME = "snap_jetbrains";
|
|
1634
1649
|
PLUGIN_VERSION = "26.3.3";
|
|
1635
1650
|
CORS_HEADERS = {
|
|
@@ -1638,8 +1653,8 @@ var init_login = __esm({
|
|
|
1638
1653
|
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With",
|
|
1639
1654
|
"Access-Control-Max-Age": "86400"
|
|
1640
1655
|
};
|
|
1641
|
-
PORTAL_AUTHORIZE_BASE = "https://codearts.huaweicloud.com/portal/authorize";
|
|
1642
|
-
PORTAL_LOGIN_BASE = "https://codearts.huaweicloud.com/portal/login";
|
|
1656
|
+
PORTAL_AUTHORIZE_BASE = codeartsSiteHost("https://codearts.huaweicloud.com/portal/authorize");
|
|
1657
|
+
PORTAL_LOGIN_BASE = codeartsSiteHost("https://codearts.huaweicloud.com/portal/login");
|
|
1643
1658
|
LOGIN_PLUGIN_NAME = "snap_AIIDE";
|
|
1644
1659
|
LOGIN_PLUGIN_VERSION = "5.2.0";
|
|
1645
1660
|
OAUTH_THEME = "2";
|
|
@@ -30203,21 +30218,19 @@ var AccountPool = class {
|
|
|
30203
30218
|
/**
|
|
30204
30219
|
* [xdpool-local] 空表保护 —— issue #200。
|
|
30205
30220
|
*
|
|
30206
|
-
*
|
|
30207
|
-
*
|
|
30208
|
-
*
|
|
30209
|
-
*
|
|
30210
|
-
*
|
|
30211
|
-
* 拒绝时保留内存与磁盘上的旧表,并留下可查的日志;真要一次性清空(迁移、
|
|
30212
|
-
* 重置)可以设 `DSH_XDPOOL_ALLOW_EMPTY_ACCOUNTS=1`。
|
|
30221
|
+
* 升级/重装期间出现过「账号表被空快照覆盖、且没有 .bak」的报告:用户的账号
|
|
30222
|
+
* 在界面上全部消失。用空表覆盖一张非空表几乎总是故障(读失败、并发写、装包时
|
|
30223
|
+
* 的空状态),不是用户意图 —— 逐个删号走 removeAccount,那条路径显式允许清空。
|
|
30224
|
+
* 真要一次性重置可设 DSH_XDPOOL_ALLOW_EMPTY_ACCOUNTS=1。
|
|
30213
30225
|
*/
|
|
30214
30226
|
const empty = Array.isArray(accounts) && accounts.length === 0
|
|
30215
30227
|
const hadRows = Array.isArray(this.cache) && this.cache.length > 0
|
|
30216
30228
|
const forced = typeof process !== 'undefined' && process.env.DSH_XDPOOL_ALLOW_EMPTY_ACCOUNTS === '1'
|
|
30217
30229
|
if (empty && hadRows && options.allowEmpty !== true && !forced) {
|
|
30218
30230
|
this.ctx.logger?.warn?.(
|
|
30219
|
-
|
|
30220
|
-
+ '
|
|
30231
|
+
'[channel-pack] 拒绝用空账号表覆盖现有 ' + this.cache.length
|
|
30232
|
+
+ ' 个账号(疑似升级/重装时的空快照);逐个删除可正常清空,'
|
|
30233
|
+
+ '强制重置请设 DSH_XDPOOL_ALLOW_EMPTY_ACCOUNTS=1'
|
|
30221
30234
|
)
|
|
30222
30235
|
return
|
|
30223
30236
|
}
|
|
@@ -30685,7 +30698,7 @@ var AccountPool = class {
|
|
|
30685
30698
|
await this.ctx.credentials.unset(credentialRef(entry.credentialRef));
|
|
30686
30699
|
} catch {
|
|
30687
30700
|
}
|
|
30688
|
-
//
|
|
30701
|
+
// 显式删除:可以删到空,带上 allowEmpty。
|
|
30689
30702
|
await this.writeAccounts(this.readAccounts().filter((a) => a.id !== id), { allowEmpty: true });
|
|
30690
30703
|
}
|
|
30691
30704
|
/**
|
|
@@ -31455,8 +31468,8 @@ ${canonicalHash}`;
|
|
|
31455
31468
|
}
|
|
31456
31469
|
|
|
31457
31470
|
// vendor/channel-pack/src/models.ts
|
|
31458
|
-
var OPENGW_GATEWAY_CONFIG_URL = "https://opengw.developer.huaweicloud.com/api/v1/gateway/config";
|
|
31459
|
-
var SNAP_MODEL_BUILTIN_URL = "https://snap-access.cn-north-4.myhuaweicloud.com/v1/model/builtin";
|
|
31471
|
+
var OPENGW_GATEWAY_CONFIG_URL = codeartsSiteHost("https://opengw.developer.huaweicloud.com/api/v1/gateway/config");
|
|
31472
|
+
var SNAP_MODEL_BUILTIN_URL = codeartsSiteHost("https://snap-access.cn-north-4.myhuaweicloud.com/v1/model/builtin");
|
|
31460
31473
|
var CODEARTS_MODELS_CACHE_FILENAME = "codearts_models.json";
|
|
31461
31474
|
var CODEARTS_BENEFIT_CACHE_FILENAME = "codearts_benefit_models.json";
|
|
31462
31475
|
var CODEARTS_BENEFIT_FALLBACK = ["glm-5.3-flash", "deepseek-v4.1-flash"];
|
|
@@ -31465,12 +31478,16 @@ var MODEL_REFRESH_INTERVAL_MS = 2 * 36e5;
|
|
|
31465
31478
|
var memoryCache;
|
|
31466
31479
|
var benefitMemoryCache;
|
|
31467
31480
|
function normalizeModelId(id) {
|
|
31468
|
-
|
|
31469
|
-
|
|
31470
|
-
|
|
31471
|
-
|
|
31472
|
-
|
|
31473
|
-
|
|
31481
|
+
// Do NOT strip the trailing -NNNN build tag.
|
|
31482
|
+
//
|
|
31483
|
+
// The gateway publishes `deepseek-v4.1-flash-1017` and grants the account the
|
|
31484
|
+
// SAME id. Stripping "-1017" produced `deepseek-v4.1-flash`, which the gateway
|
|
31485
|
+
// rejects with TM.000010051 ("您当前无权调用该模型") — a message that reads like
|
|
31486
|
+
// a broken credential while the credential is perfectly valid. Measured against
|
|
31487
|
+
// the live endpoint: bare `deepseek-v4.1-flash` → TM.000010051,
|
|
31488
|
+
// `deepseek-v4.1-flash-1017` → HTTP 200. Every other builtin id (GLM-5.2,
|
|
31489
|
+
// glm-5.3, kimi-k3, speed, ...) carries no such suffix, so returning the raw id
|
|
31490
|
+
// is correct for the whole catalogue.
|
|
31474
31491
|
return id;
|
|
31475
31492
|
}
|
|
31476
31493
|
function parseModelInfo(m, seen) {
|
|
@@ -31482,7 +31499,23 @@ function parseModelInfo(m, seen) {
|
|
|
31482
31499
|
const name2 = typeof rawName === "string" && rawName.length > 0 ? normalizeModelId(rawName) : id;
|
|
31483
31500
|
if (seen.has(id)) return void 0;
|
|
31484
31501
|
seen.add(id);
|
|
31485
|
-
|
|
31502
|
+
// Keep the capacity the gateway actually publishes.
|
|
31503
|
+
//
|
|
31504
|
+
// The builtin catalogue already answers `context_window` and `max_tokens` per
|
|
31505
|
+
// model (deepseek-v4.1-flash-1017 → 1048576/65536, openpangu-2.1-pro →
|
|
31506
|
+
// 524288/65535, kimi-k3 → 1048576/65536, ...), but this function used to
|
|
31507
|
+
// discard them and the adapter fell back to a hand-maintained table listing
|
|
31508
|
+
// only 9 ids. Any model missing from that table resolved with no contextWindow
|
|
31509
|
+
// at all, and the host's compaction planner then refused the switch with
|
|
31510
|
+
// "no context capacity for codearts/<model>". Prefer the vendor number; the
|
|
31511
|
+
// static table stays as the offline fallback.
|
|
31512
|
+
const out = { id, name: name2 };
|
|
31513
|
+
const cw = Number(m["context_window"]);
|
|
31514
|
+
if (Number.isFinite(cw) && cw > 0) out.contextWindow = cw;
|
|
31515
|
+
const mt = Number(m["max_tokens"]);
|
|
31516
|
+
if (Number.isFinite(mt) && mt > 0) out.maxTokens = mt;
|
|
31517
|
+
if (m["supports_images"] === true) out.supportsImages = true;
|
|
31518
|
+
return out;
|
|
31486
31519
|
}
|
|
31487
31520
|
function extractJsonArray(text, path2) {
|
|
31488
31521
|
try {
|
|
@@ -31533,7 +31566,13 @@ async function fetchCodeArtsRemoteModels(credential, fetcher = fetch) {
|
|
|
31533
31566
|
const rawId = typeof entry["model_id"] === "string" ? entry["model_id"] : "";
|
|
31534
31567
|
const mi = parseModelInfo(entry, seen);
|
|
31535
31568
|
if (mi) {
|
|
31536
|
-
|
|
31569
|
+
// The original test was `normalizeModelId(rawId) === rawId`, i.e.
|
|
31570
|
+
// "this id carried no -NNNN build tag after normalisation". Now that
|
|
31571
|
+
// normalizeModelId is a pass-through, that test is always true and
|
|
31572
|
+
// every gateway model would be filed as a benefit model. Ask the
|
|
31573
|
+
// question the code actually means instead.
|
|
31574
|
+
const hasBuildTag = /-\d{4}$/u.test(rawId);
|
|
31575
|
+
if (rawId.length > 0 && !hasBuildTag) benefitIds.push(mi.id);
|
|
31537
31576
|
models.push(mi);
|
|
31538
31577
|
}
|
|
31539
31578
|
}
|
|
@@ -32811,23 +32850,19 @@ async function* recordThroughStream(openStream, meta) {
|
|
|
32811
32850
|
}
|
|
32812
32851
|
function registerAdapterIdempotent(llm, providers, adapter, warn) {
|
|
32813
32852
|
/**
|
|
32814
|
-
* [xdpool-local]
|
|
32853
|
+
* [xdpool-local] lane 让位 —— issue #201。
|
|
32815
32854
|
*
|
|
32816
|
-
*
|
|
32817
|
-
*
|
|
32818
|
-
*
|
|
32819
|
-
*
|
|
32820
|
-
* 插件在 mount 时按「自己池里有没有账号」决定要不要写
|
|
32821
|
-
* `DSH_XDPOOL_OWNS_POOL_LANES`:有账号就让位,没账号就删掉这个变量让 pack
|
|
32822
|
-
* 继续提供目录(否则那台机器上一个模型都看不到)。判断放在注册这一层,是因为
|
|
32823
|
-
* pack 的 pool-owned 清单只负责「不静音」,从来不是「不注册」。
|
|
32855
|
+
* buddy / workbuddy 两条 lane 有两条注册来源:本插件注册 xdpool / xdpool-global,
|
|
32856
|
+
* pack 注册 buddy / workbuddy。两边都注册时,选择器里 WorkBuddy 国内版/国际版
|
|
32857
|
+
* 各出现两次。插件在 mount 时按「自己池里有没有账号」写
|
|
32858
|
+
* DSH_XDPOOL_OWNS_POOL_LANES:有账号就让位,没账号删掉变量让 pack 继续提供目录。
|
|
32824
32859
|
*/
|
|
32825
32860
|
const owned = (typeof process === 'undefined' ? '' : process.env.DSH_XDPOOL_OWNS_POOL_LANES ?? '')
|
|
32826
32861
|
.split(',')
|
|
32827
32862
|
.map((id) => id.trim())
|
|
32828
32863
|
.filter((id) => id !== '')
|
|
32829
32864
|
if (owned.length > 0 && providers.length > 0 && providers.every((id) => owned.includes(id))) {
|
|
32830
|
-
warn?.(
|
|
32865
|
+
warn?.('[llm-register] ' + providers.join(', ') + ' 由 dsh-xdpool 自己服务,pack 跳过注册')
|
|
32831
32866
|
return void 0
|
|
32832
32867
|
}
|
|
32833
32868
|
let target = wrapAdapterWithTokenLedger(providers, adapter);
|
|
@@ -32850,7 +32885,7 @@ function registerAdapterIdempotent(llm, providers, adapter, warn) {
|
|
|
32850
32885
|
}
|
|
32851
32886
|
|
|
32852
32887
|
// vendor/channel-pack/src/llm-adapter.ts
|
|
32853
|
-
var CHAT_API_BASE = "https://snap-access.cn-north-4.myhuaweicloud.com/api/v2";
|
|
32888
|
+
var CHAT_API_BASE = codeartsSiteHost("https://snap-access.cn-north-4.myhuaweicloud.com/api/v2");
|
|
32854
32889
|
var PROVIDER = "codearts";
|
|
32855
32890
|
var BENEFIT_NOT_FOUND_CODE = "BENEFIT_NOT_FOUND";
|
|
32856
32891
|
var CODEARTS_BENEFIT_NOT_FOUND_ERROR_CODE = "InferHub.4004.200";
|
|
@@ -32911,20 +32946,76 @@ var IMAGE_MODELS = /* @__PURE__ */ new Set([
|
|
|
32911
32946
|
"deepseek-v4.1-flash",
|
|
32912
32947
|
"kimi-k2.6-vl"
|
|
32913
32948
|
]);
|
|
32914
|
-
/**
|
|
32915
|
-
|
|
32916
|
-
|
|
32949
|
+
/**
|
|
32950
|
+
* Window for one id.
|
|
32951
|
+
*
|
|
32952
|
+
* Order of truth:
|
|
32953
|
+
* 1. the value the gateway published for THIS id (`remote`),
|
|
32954
|
+
* 2. exact match in the static table,
|
|
32955
|
+
* 3. the base id's entry when this id carries a -NNNN build tag.
|
|
32956
|
+
*
|
|
32957
|
+
* The build tag is a release pointer, not a different model: it changes which
|
|
32958
|
+
* build answers, not how much it can hold. Without step 3 a tagged id resolved
|
|
32959
|
+
* with no window at all and the host refused to switch models.
|
|
32960
|
+
*/
|
|
32961
|
+
function contextWindowFor(model, remote) {
|
|
32962
|
+
const fromRemote = Number(remote);
|
|
32963
|
+
if (Number.isFinite(fromRemote) && fromRemote > 0) return fromRemote;
|
|
32964
|
+
var key = String(model).toLowerCase();
|
|
32965
|
+
var exact = CONTEXT_WINDOWS.get(key);
|
|
32966
|
+
if (exact !== void 0) return exact;
|
|
32967
|
+
var base = key.replace(/-\d{4}$/u, "");
|
|
32968
|
+
return base === key ? void 0 : CONTEXT_WINDOWS.get(base);
|
|
32917
32969
|
}
|
|
32918
32970
|
/** Input modalities for one id; text is the floor every model here meets. */
|
|
32919
|
-
function modalitiesFor(model) {
|
|
32920
|
-
|
|
32971
|
+
function modalitiesFor(model, remoteSupportsImages) {
|
|
32972
|
+
if (remoteSupportsImages === true) return ["text", "image"];
|
|
32973
|
+
var key = String(model).toLowerCase();
|
|
32974
|
+
if (IMAGE_MODELS.has(key)) return ["text", "image"];
|
|
32975
|
+
// same base-id fallback as contextWindowFor
|
|
32976
|
+
var base = key.replace(/-\d{4}$/u, "");
|
|
32977
|
+
return base !== key && IMAGE_MODELS.has(base) ? ["text", "image"] : ["text"];
|
|
32921
32978
|
}
|
|
32922
32979
|
function contentToText(content) {
|
|
32923
32980
|
if (typeof content === "string") return content;
|
|
32924
32981
|
if (!Array.isArray(content)) return "";
|
|
32925
32982
|
return content.filter((block) => typeof block === "object" && block !== null && block.type === "text").map((block) => String(block.text)).join("");
|
|
32926
32983
|
}
|
|
32927
|
-
|
|
32984
|
+
// [xdpool-local] issue #215: CodeArts 通道声明支持 image,但旧实现只序列化文本,
|
|
32985
|
+
// 图片块被静默丢弃。给本地序列化函数补可选的 imageUrls 参数(与同文件其它
|
|
32986
|
+
// openai-compat 适配器一致):不传时行为与原来完全相同。
|
|
32987
|
+
function codeArtsContentParts(content, imageUrls) {
|
|
32988
|
+
const parts = [];
|
|
32989
|
+
let hasImage = false;
|
|
32990
|
+
for (const raw of content) {
|
|
32991
|
+
if (typeof raw !== "object" || raw === null) continue;
|
|
32992
|
+
const block = raw;
|
|
32993
|
+
if (block.type === "text") {
|
|
32994
|
+
const text = String(block.text ?? "");
|
|
32995
|
+
if (text.length > 0) parts.push({ type: "text", text });
|
|
32996
|
+
continue;
|
|
32997
|
+
}
|
|
32998
|
+
if (block.type === "image") {
|
|
32999
|
+
hasImage = true;
|
|
33000
|
+
const url = block.attachment?.attachmentId === void 0 ? void 0 : imageUrls.get(String(block.attachment.attachmentId));
|
|
33001
|
+
// 绝不静默丢图:读不到字节时也显式告知模型这里有张图。
|
|
33002
|
+
parts.push(url === void 0 ? { type: "text", text: "[image unavailable]" } : { type: "image_url", image_url: { url } });
|
|
33003
|
+
continue;
|
|
33004
|
+
}
|
|
33005
|
+
if (block.type === "tool-result" && Array.isArray(block.content)) {
|
|
33006
|
+
const inner = codeArtsContentParts(block.content, imageUrls);
|
|
33007
|
+
if (inner !== void 0) {
|
|
33008
|
+
hasImage = true;
|
|
33009
|
+
parts.push(...inner);
|
|
33010
|
+
} else {
|
|
33011
|
+
const text = contentToText(block.content);
|
|
33012
|
+
if (text.length > 0) parts.push({ type: "text", text });
|
|
33013
|
+
}
|
|
33014
|
+
}
|
|
33015
|
+
}
|
|
33016
|
+
return hasImage && parts.length > 0 ? parts : void 0;
|
|
33017
|
+
}
|
|
33018
|
+
function serializeMessages(messages, imageUrls) {
|
|
32928
33019
|
const normalized = normalizeHarnessMessages(messages);
|
|
32929
33020
|
const wire = [];
|
|
32930
33021
|
const { keepCallIds, keepResultIds } = resolveToolPairing(normalized);
|
|
@@ -32959,13 +33050,28 @@ function serializeMessages(messages) {
|
|
|
32959
33050
|
const content = Array.isArray(message2.content) ? message2.content : [];
|
|
32960
33051
|
const toolResults = content.filter((block) => typeof block === "object" && block !== null && block.type === "tool-result");
|
|
32961
33052
|
const text = contentToText(message2.content);
|
|
32962
|
-
|
|
33053
|
+
// [xdpool-local] issue #215: imageUrls 存在时优先发多模态 parts;老的文本路径不变。
|
|
33054
|
+
const regular = content.filter((block) => !(typeof block === "object" && block !== null && block.type === "tool-result"));
|
|
33055
|
+
const parts = imageUrls === void 0 ? void 0 : codeArtsContentParts(regular, imageUrls);
|
|
33056
|
+
if (parts !== void 0) {
|
|
33057
|
+
wire.push({ role: "user", content: parts });
|
|
33058
|
+
} else if (text.length > 0 || toolResults.length === 0) {
|
|
33059
|
+
wire.push({ role: "user", content: text });
|
|
33060
|
+
}
|
|
32963
33061
|
for (const result of toolResults) {
|
|
32964
33062
|
if (!keepResultIds.has(String(result.toolCallId))) continue;
|
|
33063
|
+
let resultText = contentToText(result.content) || "(no output)";
|
|
33064
|
+
if (imageUrls !== void 0 && Array.isArray(result.content)) {
|
|
33065
|
+
const resultParts = codeArtsContentParts(result.content, imageUrls);
|
|
33066
|
+
if (resultParts !== void 0) {
|
|
33067
|
+
const joined = resultParts.filter((part) => part.type === "text").map((part) => String(part.text)).join("");
|
|
33068
|
+
if (joined.length > 0) resultText = joined;
|
|
33069
|
+
}
|
|
33070
|
+
}
|
|
32965
33071
|
wire.push({
|
|
32966
33072
|
role: "tool",
|
|
32967
33073
|
tool_call_id: String(result.toolCallId),
|
|
32968
|
-
content:
|
|
33074
|
+
content: resultText
|
|
32969
33075
|
});
|
|
32970
33076
|
}
|
|
32971
33077
|
}
|
|
@@ -32999,7 +33105,7 @@ function buildDsmlSystemPrompt(tools) {
|
|
|
32999
33105
|
toolJson
|
|
33000
33106
|
].join("\n");
|
|
33001
33107
|
}
|
|
33002
|
-
var QUEUE_STATUS_BASE = "https://snap-access.cn-north-4.myhuaweicloud.com/api/v1/queue/status";
|
|
33108
|
+
var QUEUE_STATUS_BASE = codeartsSiteHost("https://snap-access.cn-north-4.myhuaweicloud.com/api/v1/queue/status");
|
|
33003
33109
|
var QUEUE_RETRY_DELAY_MS = 1e4;
|
|
33004
33110
|
var QUEUE_MAX_ATTEMPTS2 = 180;
|
|
33005
33111
|
function resolveFirstTokenTimeoutMs() {
|
|
@@ -33430,12 +33536,12 @@ var CodeArtsAdapter = class extends LlmAdapter {
|
|
|
33430
33536
|
const disabled = this.options.accountPool?.disabledModelsFor(PROVIDER);
|
|
33431
33537
|
const listed = disabled === void 0 || disabled.size === 0 ? visible : visible.filter((m) => !disabled.has(m.id));
|
|
33432
33538
|
return listed.map((m) => {
|
|
33433
|
-
const contextWindow = contextWindowFor(m.id);
|
|
33539
|
+
const contextWindow = contextWindowFor(m.id, m.contextWindow);
|
|
33434
33540
|
return {
|
|
33435
33541
|
provider: PROVIDER,
|
|
33436
33542
|
id: m.id,
|
|
33437
33543
|
name: m.name,
|
|
33438
|
-
inputModalities: modalitiesFor(m.id),
|
|
33544
|
+
inputModalities: modalitiesFor(m.id, m.supportsImages),
|
|
33439
33545
|
maxTokens: CODEARTS_MAX_OUTPUT_TOKENS,
|
|
33440
33546
|
...contextWindow === void 0 ? {} : { contextWindow }
|
|
33441
33547
|
};
|
|
@@ -33445,15 +33551,15 @@ var CodeArtsAdapter = class extends LlmAdapter {
|
|
|
33445
33551
|
await this.ensureRemoteModels();
|
|
33446
33552
|
const remoteModel = this.remoteModels?.find((m) => m.id === model);
|
|
33447
33553
|
const name2 = remoteModel?.name ?? model;
|
|
33448
|
-
const contextWindow = contextWindowFor(model);
|
|
33554
|
+
const contextWindow = contextWindowFor(model, remoteModel?.contextWindow);
|
|
33449
33555
|
const resolved = {
|
|
33450
33556
|
provider,
|
|
33451
33557
|
id: model,
|
|
33452
33558
|
name: name2,
|
|
33453
|
-
inputModalities: modalitiesFor(model),
|
|
33559
|
+
inputModalities: modalitiesFor(model, remoteModel?.supportsImages),
|
|
33454
33560
|
// catalogFactsFor() forwards this as fact.maxTokens; without it the host
|
|
33455
33561
|
// has no way to learn the ceiling and passes its own catalog value through.
|
|
33456
|
-
defaultMaxTokens: CODEARTS_MAX_OUTPUT_TOKENS
|
|
33562
|
+
defaultMaxTokens: remoteModel?.maxTokens ?? CODEARTS_MAX_OUTPUT_TOKENS
|
|
33457
33563
|
};
|
|
33458
33564
|
if (contextWindow !== void 0) resolved.context = { contextWindow };
|
|
33459
33565
|
resolved.reasoning = {
|
|
@@ -33492,7 +33598,51 @@ var CodeArtsAdapter = class extends LlmAdapter {
|
|
|
33492
33598
|
}
|
|
33493
33599
|
if (currentAccountId) reportLedgerAccount(PROVIDER, currentAccountId);
|
|
33494
33600
|
}
|
|
33495
|
-
|
|
33601
|
+
// [xdpool-local] issue #215: 照搬 loomy/gemini 的图片收集逻辑。
|
|
33602
|
+
// 模型不支持图片 / readImage 缺失 / 字节读不到时都抛 LlmError,绝不静默丢图。
|
|
33603
|
+
const imageRefs = /* @__PURE__ */ new Map();
|
|
33604
|
+
for (const message2 of options.messages) {
|
|
33605
|
+
if (Array.isArray(message2.content)) collectImages3(message2.content, imageRefs);
|
|
33606
|
+
}
|
|
33607
|
+
let imageUrls;
|
|
33608
|
+
if (imageRefs.size > 0) {
|
|
33609
|
+
if (!modalitiesFor(options.model).includes("image")) {
|
|
33610
|
+
throw new LlmError2(
|
|
33611
|
+
`codearts: \u6A21\u578B "${options.model}" \u4E0D\u652F\u6301\u56FE\u7247\u8F93\u5165`, "UNSUPPORTED_CONTENT"
|
|
33612
|
+
);
|
|
33613
|
+
}
|
|
33614
|
+
if (this.options.readImage === void 0) {
|
|
33615
|
+
throw new LlmError2(
|
|
33616
|
+
"codearts: \u56FE\u7247\u8F93\u5165\u9700\u8981\u9644\u4EF6\u670D\u52A1\uFF08readImage \u672A\u63D0\u4F9B\uFF09",
|
|
33617
|
+
"UNSUPPORTED_CONTENT"
|
|
33618
|
+
); }
|
|
33619
|
+
imageUrls = /* @__PURE__ */ new Map();
|
|
33620
|
+
const readImage = this.options.readImage;
|
|
33621
|
+
for (const [id, ref] of imageRefs) {
|
|
33622
|
+
let image;
|
|
33623
|
+
try {
|
|
33624
|
+
const projected = await projectRequestImage(ref, {
|
|
33625
|
+
readImageRequest: this.options.readImageRequest,
|
|
33626
|
+
pixelBudget: this.options.imagePixelBudget,
|
|
33627
|
+
maxBytes: this.options.imageMaxBytes
|
|
33628
|
+
});
|
|
33629
|
+
image = projected ?? await readImage(ref);
|
|
33630
|
+
} catch (error) {
|
|
33631
|
+
throw new LlmError2(
|
|
33632
|
+
"codearts: \u56FE\u7247\u9644\u4EF6\u8BFB\u53D6\u5931\u8D25\uFF1B\u9644\u4EF6\u670D\u52A1\u53EF\u80FD\u672A\u5C31\u7EEA\uFF0C\u6216\u8BE5\u5BF9\u8C61\u5DF2\u4E0D\u5B58\u5728\u3002",
|
|
33633
|
+
"UNSUPPORTED_CONTENT",
|
|
33634
|
+
{ cause: error }
|
|
33635
|
+
);
|
|
33636
|
+
}
|
|
33637
|
+
if (image === void 0) {
|
|
33638
|
+
throw new LlmError2(
|
|
33639
|
+
"codearts: \u56FE\u7247\u9644\u4EF6\u8BFB\u53D6\u4E0D\u5230\u5185\u5BB9\uFF1B\u9644\u4EF6\u670D\u52A1\u53EF\u80FD\u672A\u5C31\u7EEA\u3002",
|
|
33640
|
+
"UNSUPPORTED_CONTENT"
|
|
33641
|
+
);
|
|
33642
|
+
} imageUrls.set(id, `data:${image.mediaType};base64,${Buffer.from(image.data).toString("base64")}`);
|
|
33643
|
+
}
|
|
33644
|
+
}
|
|
33645
|
+
const messages = serializeMessages(options.messages, imageUrls);
|
|
33496
33646
|
if (options.system !== void 0 && options.system.length > 0) {
|
|
33497
33647
|
messages.unshift({ role: "system", content: options.system });
|
|
33498
33648
|
}
|
|
@@ -43227,14 +43377,20 @@ var LoomyAdapter = class extends LlmAdapter7 {
|
|
|
43227
43377
|
...options.stop !== void 0 && options.stop.length > 0 ? { stop: options.stop } : {},
|
|
43228
43378
|
...effort !== void 0 ? { reasoning_effort: effort } : {},
|
|
43229
43379
|
...options.tools !== void 0 && options.tools.length > 0 ? {
|
|
43230
|
-
|
|
43231
|
-
|
|
43232
|
-
|
|
43233
|
-
|
|
43234
|
-
|
|
43235
|
-
|
|
43380
|
+
// DSH 内部形状是 {name,description,parameters};个别宿主直接递 OpenAI 形状
|
|
43381
|
+
// {type,function:{...}},那时 tool.description 是 undefined,.length 会抛
|
|
43382
|
+
// TypeError → 502(issue #234)。两种都认。
|
|
43383
|
+
tools: options.tools.map((tool) => {
|
|
43384
|
+
const fn = tool.function ?? tool
|
|
43385
|
+
return {
|
|
43386
|
+
type: "function",
|
|
43387
|
+
function: {
|
|
43388
|
+
name: fn.name,
|
|
43389
|
+
...fn.description?.length > 0 ? { description: fn.description } : {},
|
|
43390
|
+
...fn.parameters === void 0 ? {} : { parameters: fn.parameters }
|
|
43391
|
+
}
|
|
43236
43392
|
}
|
|
43237
|
-
})
|
|
43393
|
+
})
|
|
43238
43394
|
} : {}
|
|
43239
43395
|
});
|
|
43240
43396
|
const send = async (token) => {
|
|
@@ -43660,14 +43816,20 @@ var RaccoonAdapter = class extends LlmAdapter8 {
|
|
|
43660
43816
|
// ⚠️ tools 必须真的下发到请求体**顶层**:Qoder/TRAE 都因漏发而让模型
|
|
43661
43817
|
// 在正文里臆造 XML 工具调用,harness 认不出 → 任务终止。
|
|
43662
43818
|
...options.tools !== void 0 && options.tools.length > 0 ? {
|
|
43663
|
-
|
|
43664
|
-
|
|
43665
|
-
|
|
43666
|
-
|
|
43667
|
-
|
|
43668
|
-
|
|
43819
|
+
// DSH 内部形状是 {name,description,parameters};个别宿主直接递 OpenAI 形状
|
|
43820
|
+
// {type,function:{...}},那时 tool.description 是 undefined,.length 会抛
|
|
43821
|
+
// TypeError → 502(issue #234)。两种都认。
|
|
43822
|
+
tools: options.tools.map((tool) => {
|
|
43823
|
+
const fn = tool.function ?? tool
|
|
43824
|
+
return {
|
|
43825
|
+
type: "function",
|
|
43826
|
+
function: {
|
|
43827
|
+
name: fn.name,
|
|
43828
|
+
...fn.description?.length > 0 ? { description: fn.description } : {},
|
|
43829
|
+
...fn.parameters === void 0 ? {} : { parameters: fn.parameters }
|
|
43830
|
+
}
|
|
43669
43831
|
}
|
|
43670
|
-
})
|
|
43832
|
+
})
|
|
43671
43833
|
} : {},
|
|
43672
43834
|
// 思考档位(开 / 关)。⚠️ **必须在 `extra_body` 内** —— 实测放顶层会被忽略
|
|
43673
43835
|
//(连非法值都不报错)。不传档位时不发该字段,保持服务端默认(= 开)。
|
|
@@ -58185,7 +58347,7 @@ function roundCredits2(value) {
|
|
|
58185
58347
|
}
|
|
58186
58348
|
|
|
58187
58349
|
// vendor/channel-pack/src/codearts-credits.ts
|
|
58188
|
-
var CODEARTS_SNAP_ENGINE_URL = "https://snap-access.cn-north-4.myhuaweicloud.com";
|
|
58350
|
+
var CODEARTS_SNAP_ENGINE_URL = codeartsSiteHost("https://snap-access.cn-north-4.myhuaweicloud.com");
|
|
58189
58351
|
var CODEARTS_PACKAGE_INFO_PATH = "/snap-manager/v1/statistics/plugin";
|
|
58190
58352
|
var CODEARTS_OPS_DELIVERY_PATH = "/v1/ops/delivery";
|
|
58191
58353
|
var CODEARTS_OPS_CLAIM_PATH = "/v1/ops/claim";
|
|
@@ -58202,7 +58364,9 @@ var CREDIT_METRIC_LABELS = {
|
|
|
58202
58364
|
usageTotalPackageCredit: "\u603B\u79EF\u5206\u5305",
|
|
58203
58365
|
usageBasicPackageCredit: "\u57FA\u7840\u79EF\u5206\u5305",
|
|
58204
58366
|
usageOnDemandPackageCredit: "\u6309\u9700\u79EF\u5206\u5305",
|
|
58205
|
-
usageBonusPackageCredit: "\u8D60\u9001\u79EF\u5206\u5305"
|
|
58367
|
+
usageBonusPackageCredit: "\u8D60\u9001\u79EF\u5206\u5305",
|
|
58368
|
+
// \u56FD\u9645\u7AD9\uFF08issue #244\uFF09\uFF1Atoken \u5957\u9910\u53EA\u62A5\u4E00\u4E2A usage_token_num \u7A97\u53E3\u3002
|
|
58369
|
+
usageTokenNum: "Token \u5957\u9910"
|
|
58206
58370
|
};
|
|
58207
58371
|
var TOTAL_CREDIT_METRIC = "usageTotalPackageCredit";
|
|
58208
58372
|
var UNPARSABLE_RESPONSE_MESSAGE3 = "\u8BF7\u6C42\u5931\u8D25\u6216\u54CD\u5E94\u65E0\u6CD5\u89E3\u6790";
|
|
@@ -58320,6 +58484,23 @@ function parseCreditBalance(metrics) {
|
|
|
58320
58484
|
const used = readNumber8(record, "package_credit_used");
|
|
58321
58485
|
const remain = readNumber8(record, "package_credit_remain");
|
|
58322
58486
|
if (name2 === TOTAL_CREDIT_METRIC) totalRemain = remain;
|
|
58487
|
+
// 国际站 token 套餐(issue #244):字段名不同,只有套餐总量,无已用/剩余拆分。
|
|
58488
|
+
if (amount <= 0 && remain <= 0 && name2 === "usageTokenNum") {
|
|
58489
|
+
amount = readNumber8(record, "package_token_amount");
|
|
58490
|
+
if (amount > 0) packages.push({
|
|
58491
|
+
name: CREDIT_METRIC_LABELS.usageTokenNum,
|
|
58492
|
+
unit: "credit",
|
|
58493
|
+
remaining: amount,
|
|
58494
|
+
total: amount,
|
|
58495
|
+
used: 0,
|
|
58496
|
+
active: true,
|
|
58497
|
+
cycleStartTime: readString6(record, "start_date"),
|
|
58498
|
+
cycleEndTime: readString6(record, "end_date"),
|
|
58499
|
+
expiredTime: ""
|
|
58500
|
+
});
|
|
58501
|
+
sawAnyCreditMetric = true;
|
|
58502
|
+
continue;
|
|
58503
|
+
}
|
|
58323
58504
|
if (amount <= 0 && remain <= 0) continue;
|
|
58324
58505
|
packages.push({
|
|
58325
58506
|
name: label,
|
|
@@ -58404,6 +58585,11 @@ function findDailyCheckinActivity(activities) {
|
|
|
58404
58585
|
return activities.find((activity) => activity.type === CODEARTS_DAILY_LOGIN_TYPE);
|
|
58405
58586
|
}
|
|
58406
58587
|
async function claimCodeArtsDailyCheckin(credential, fetcher = fetch) {
|
|
58588
|
+
/* 国际站没有积分批次/每日签到(issue #244):ops 端点在那边是 404,
|
|
58589
|
+
与其报「活动列表查询失败」,不如直接如实答 inactive。 */
|
|
58590
|
+
if (process.env.DSH_XDPOOL_CODEARTS_INTL === "1") {
|
|
58591
|
+
return { kind: "inactive", message: "国际站无每日签到活动" };
|
|
58592
|
+
}
|
|
58407
58593
|
const infoResult = await fetchCodeArtsAccountInfoDetailed(credential, fetcher);
|
|
58408
58594
|
if (!infoResult.ok) {
|
|
58409
58595
|
return { kind: "failed", code: -1, message: `\u8D26\u6237\u4FE1\u606F\u67E5\u8BE2\u5931\u8D25\uFF1A${infoResult.message}` };
|
|
@@ -66873,10 +67059,13 @@ async function* consumeMinimaxSse(options) {
|
|
|
66873
67059
|
yield { type: "reasoning-delta", index, text: d.thinking };
|
|
66874
67060
|
} else if (d.type === "input_json_delta" && typeof d.partial_json === "string") {
|
|
66875
67061
|
if (state !== void 0) state.toolArgs += d.partial_json;
|
|
67062
|
+
// name 必须带上:网关拿它写 tool_call 记录,pi 重放时缺 name 的调用会被
|
|
67063
|
+
// 400 拒掉(issue #226)。其余 tool-call-delta 站点都发了,这里是唯一漏的。
|
|
66876
67064
|
yield {
|
|
66877
67065
|
type: "tool-call-delta",
|
|
66878
67066
|
index,
|
|
66879
67067
|
id: ToolCallId8(state?.toolId ?? ""),
|
|
67068
|
+
...state?.toolName.length > 0 ? { name: state.toolName } : {},
|
|
66880
67069
|
argumentsDelta: d.partial_json
|
|
66881
67070
|
};
|
|
66882
67071
|
}
|
|
@@ -69005,6 +69194,9 @@ function apply(ctx, config = {}) {
|
|
|
69005
69194
|
if (available2) await service.refreshAccountCredential(available2.entry.credentialRef, pool, available2.entry.id);
|
|
69006
69195
|
},
|
|
69007
69196
|
fetchRemoteModels: () => service.refreshModels(pool),
|
|
69197
|
+
// [xdpool-local] issue #215: 把附件服务桥接给 CodeArtsAdapter,否则图片块会被静默丢弃。
|
|
69198
|
+
readImage: makeReadImage(ctx),
|
|
69199
|
+
readImageRequest: makeReadImageRequest(ctx),
|
|
69008
69200
|
accountPool: pool
|
|
69009
69201
|
});
|
|
69010
69202
|
const resolveBuddyCredentialByRef = async (refName) => {
|