dsh-xdpool 3.0.7 → 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 -2361
- package/LICENSE +21 -21
- package/README.en.md +308 -308
- package/README.md +12 -1
- package/cordis.patch.yml +24 -24
- package/lib/bin.js +699 -32
- package/lib/client.js +1125 -135
- package/lib/index.d.ts +468 -7
- package/lib/index.js +5392 -478
- 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 +243 -45
|
@@ -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";
|
|
@@ -31453,8 +31468,8 @@ ${canonicalHash}`;
|
|
|
31453
31468
|
}
|
|
31454
31469
|
|
|
31455
31470
|
// vendor/channel-pack/src/models.ts
|
|
31456
|
-
var OPENGW_GATEWAY_CONFIG_URL = "https://opengw.developer.huaweicloud.com/api/v1/gateway/config";
|
|
31457
|
-
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");
|
|
31458
31473
|
var CODEARTS_MODELS_CACHE_FILENAME = "codearts_models.json";
|
|
31459
31474
|
var CODEARTS_BENEFIT_CACHE_FILENAME = "codearts_benefit_models.json";
|
|
31460
31475
|
var CODEARTS_BENEFIT_FALLBACK = ["glm-5.3-flash", "deepseek-v4.1-flash"];
|
|
@@ -31463,12 +31478,16 @@ var MODEL_REFRESH_INTERVAL_MS = 2 * 36e5;
|
|
|
31463
31478
|
var memoryCache;
|
|
31464
31479
|
var benefitMemoryCache;
|
|
31465
31480
|
function normalizeModelId(id) {
|
|
31466
|
-
|
|
31467
|
-
|
|
31468
|
-
|
|
31469
|
-
|
|
31470
|
-
|
|
31471
|
-
|
|
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.
|
|
31472
31491
|
return id;
|
|
31473
31492
|
}
|
|
31474
31493
|
function parseModelInfo(m, seen) {
|
|
@@ -31480,7 +31499,23 @@ function parseModelInfo(m, seen) {
|
|
|
31480
31499
|
const name2 = typeof rawName === "string" && rawName.length > 0 ? normalizeModelId(rawName) : id;
|
|
31481
31500
|
if (seen.has(id)) return void 0;
|
|
31482
31501
|
seen.add(id);
|
|
31483
|
-
|
|
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;
|
|
31484
31519
|
}
|
|
31485
31520
|
function extractJsonArray(text, path2) {
|
|
31486
31521
|
try {
|
|
@@ -31531,7 +31566,13 @@ async function fetchCodeArtsRemoteModels(credential, fetcher = fetch) {
|
|
|
31531
31566
|
const rawId = typeof entry["model_id"] === "string" ? entry["model_id"] : "";
|
|
31532
31567
|
const mi = parseModelInfo(entry, seen);
|
|
31533
31568
|
if (mi) {
|
|
31534
|
-
|
|
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);
|
|
31535
31576
|
models.push(mi);
|
|
31536
31577
|
}
|
|
31537
31578
|
}
|
|
@@ -32844,7 +32885,7 @@ function registerAdapterIdempotent(llm, providers, adapter, warn) {
|
|
|
32844
32885
|
}
|
|
32845
32886
|
|
|
32846
32887
|
// vendor/channel-pack/src/llm-adapter.ts
|
|
32847
|
-
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");
|
|
32848
32889
|
var PROVIDER = "codearts";
|
|
32849
32890
|
var BENEFIT_NOT_FOUND_CODE = "BENEFIT_NOT_FOUND";
|
|
32850
32891
|
var CODEARTS_BENEFIT_NOT_FOUND_ERROR_CODE = "InferHub.4004.200";
|
|
@@ -32905,20 +32946,76 @@ var IMAGE_MODELS = /* @__PURE__ */ new Set([
|
|
|
32905
32946
|
"deepseek-v4.1-flash",
|
|
32906
32947
|
"kimi-k2.6-vl"
|
|
32907
32948
|
]);
|
|
32908
|
-
/**
|
|
32909
|
-
|
|
32910
|
-
|
|
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);
|
|
32911
32969
|
}
|
|
32912
32970
|
/** Input modalities for one id; text is the floor every model here meets. */
|
|
32913
|
-
function modalitiesFor(model) {
|
|
32914
|
-
|
|
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"];
|
|
32915
32978
|
}
|
|
32916
32979
|
function contentToText(content) {
|
|
32917
32980
|
if (typeof content === "string") return content;
|
|
32918
32981
|
if (!Array.isArray(content)) return "";
|
|
32919
32982
|
return content.filter((block) => typeof block === "object" && block !== null && block.type === "text").map((block) => String(block.text)).join("");
|
|
32920
32983
|
}
|
|
32921
|
-
|
|
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) {
|
|
32922
33019
|
const normalized = normalizeHarnessMessages(messages);
|
|
32923
33020
|
const wire = [];
|
|
32924
33021
|
const { keepCallIds, keepResultIds } = resolveToolPairing(normalized);
|
|
@@ -32953,13 +33050,28 @@ function serializeMessages(messages) {
|
|
|
32953
33050
|
const content = Array.isArray(message2.content) ? message2.content : [];
|
|
32954
33051
|
const toolResults = content.filter((block) => typeof block === "object" && block !== null && block.type === "tool-result");
|
|
32955
33052
|
const text = contentToText(message2.content);
|
|
32956
|
-
|
|
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
|
+
}
|
|
32957
33061
|
for (const result of toolResults) {
|
|
32958
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
|
+
}
|
|
32959
33071
|
wire.push({
|
|
32960
33072
|
role: "tool",
|
|
32961
33073
|
tool_call_id: String(result.toolCallId),
|
|
32962
|
-
content:
|
|
33074
|
+
content: resultText
|
|
32963
33075
|
});
|
|
32964
33076
|
}
|
|
32965
33077
|
}
|
|
@@ -32993,7 +33105,7 @@ function buildDsmlSystemPrompt(tools) {
|
|
|
32993
33105
|
toolJson
|
|
32994
33106
|
].join("\n");
|
|
32995
33107
|
}
|
|
32996
|
-
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");
|
|
32997
33109
|
var QUEUE_RETRY_DELAY_MS = 1e4;
|
|
32998
33110
|
var QUEUE_MAX_ATTEMPTS2 = 180;
|
|
32999
33111
|
function resolveFirstTokenTimeoutMs() {
|
|
@@ -33424,12 +33536,12 @@ var CodeArtsAdapter = class extends LlmAdapter {
|
|
|
33424
33536
|
const disabled = this.options.accountPool?.disabledModelsFor(PROVIDER);
|
|
33425
33537
|
const listed = disabled === void 0 || disabled.size === 0 ? visible : visible.filter((m) => !disabled.has(m.id));
|
|
33426
33538
|
return listed.map((m) => {
|
|
33427
|
-
const contextWindow = contextWindowFor(m.id);
|
|
33539
|
+
const contextWindow = contextWindowFor(m.id, m.contextWindow);
|
|
33428
33540
|
return {
|
|
33429
33541
|
provider: PROVIDER,
|
|
33430
33542
|
id: m.id,
|
|
33431
33543
|
name: m.name,
|
|
33432
|
-
inputModalities: modalitiesFor(m.id),
|
|
33544
|
+
inputModalities: modalitiesFor(m.id, m.supportsImages),
|
|
33433
33545
|
maxTokens: CODEARTS_MAX_OUTPUT_TOKENS,
|
|
33434
33546
|
...contextWindow === void 0 ? {} : { contextWindow }
|
|
33435
33547
|
};
|
|
@@ -33439,15 +33551,15 @@ var CodeArtsAdapter = class extends LlmAdapter {
|
|
|
33439
33551
|
await this.ensureRemoteModels();
|
|
33440
33552
|
const remoteModel = this.remoteModels?.find((m) => m.id === model);
|
|
33441
33553
|
const name2 = remoteModel?.name ?? model;
|
|
33442
|
-
const contextWindow = contextWindowFor(model);
|
|
33554
|
+
const contextWindow = contextWindowFor(model, remoteModel?.contextWindow);
|
|
33443
33555
|
const resolved = {
|
|
33444
33556
|
provider,
|
|
33445
33557
|
id: model,
|
|
33446
33558
|
name: name2,
|
|
33447
|
-
inputModalities: modalitiesFor(model),
|
|
33559
|
+
inputModalities: modalitiesFor(model, remoteModel?.supportsImages),
|
|
33448
33560
|
// catalogFactsFor() forwards this as fact.maxTokens; without it the host
|
|
33449
33561
|
// has no way to learn the ceiling and passes its own catalog value through.
|
|
33450
|
-
defaultMaxTokens: CODEARTS_MAX_OUTPUT_TOKENS
|
|
33562
|
+
defaultMaxTokens: remoteModel?.maxTokens ?? CODEARTS_MAX_OUTPUT_TOKENS
|
|
33451
33563
|
};
|
|
33452
33564
|
if (contextWindow !== void 0) resolved.context = { contextWindow };
|
|
33453
33565
|
resolved.reasoning = {
|
|
@@ -33486,7 +33598,51 @@ var CodeArtsAdapter = class extends LlmAdapter {
|
|
|
33486
33598
|
}
|
|
33487
33599
|
if (currentAccountId) reportLedgerAccount(PROVIDER, currentAccountId);
|
|
33488
33600
|
}
|
|
33489
|
-
|
|
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);
|
|
33490
33646
|
if (options.system !== void 0 && options.system.length > 0) {
|
|
33491
33647
|
messages.unshift({ role: "system", content: options.system });
|
|
33492
33648
|
}
|
|
@@ -43221,14 +43377,20 @@ var LoomyAdapter = class extends LlmAdapter7 {
|
|
|
43221
43377
|
...options.stop !== void 0 && options.stop.length > 0 ? { stop: options.stop } : {},
|
|
43222
43378
|
...effort !== void 0 ? { reasoning_effort: effort } : {},
|
|
43223
43379
|
...options.tools !== void 0 && options.tools.length > 0 ? {
|
|
43224
|
-
|
|
43225
|
-
|
|
43226
|
-
|
|
43227
|
-
|
|
43228
|
-
|
|
43229
|
-
|
|
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
|
+
}
|
|
43230
43392
|
}
|
|
43231
|
-
})
|
|
43393
|
+
})
|
|
43232
43394
|
} : {}
|
|
43233
43395
|
});
|
|
43234
43396
|
const send = async (token) => {
|
|
@@ -43654,14 +43816,20 @@ var RaccoonAdapter = class extends LlmAdapter8 {
|
|
|
43654
43816
|
// ⚠️ tools 必须真的下发到请求体**顶层**:Qoder/TRAE 都因漏发而让模型
|
|
43655
43817
|
// 在正文里臆造 XML 工具调用,harness 认不出 → 任务终止。
|
|
43656
43818
|
...options.tools !== void 0 && options.tools.length > 0 ? {
|
|
43657
|
-
|
|
43658
|
-
|
|
43659
|
-
|
|
43660
|
-
|
|
43661
|
-
|
|
43662
|
-
|
|
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
|
+
}
|
|
43663
43831
|
}
|
|
43664
|
-
})
|
|
43832
|
+
})
|
|
43665
43833
|
} : {},
|
|
43666
43834
|
// 思考档位(开 / 关)。⚠️ **必须在 `extra_body` 内** —— 实测放顶层会被忽略
|
|
43667
43835
|
//(连非法值都不报错)。不传档位时不发该字段,保持服务端默认(= 开)。
|
|
@@ -58179,7 +58347,7 @@ function roundCredits2(value) {
|
|
|
58179
58347
|
}
|
|
58180
58348
|
|
|
58181
58349
|
// vendor/channel-pack/src/codearts-credits.ts
|
|
58182
|
-
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");
|
|
58183
58351
|
var CODEARTS_PACKAGE_INFO_PATH = "/snap-manager/v1/statistics/plugin";
|
|
58184
58352
|
var CODEARTS_OPS_DELIVERY_PATH = "/v1/ops/delivery";
|
|
58185
58353
|
var CODEARTS_OPS_CLAIM_PATH = "/v1/ops/claim";
|
|
@@ -58196,7 +58364,9 @@ var CREDIT_METRIC_LABELS = {
|
|
|
58196
58364
|
usageTotalPackageCredit: "\u603B\u79EF\u5206\u5305",
|
|
58197
58365
|
usageBasicPackageCredit: "\u57FA\u7840\u79EF\u5206\u5305",
|
|
58198
58366
|
usageOnDemandPackageCredit: "\u6309\u9700\u79EF\u5206\u5305",
|
|
58199
|
-
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"
|
|
58200
58370
|
};
|
|
58201
58371
|
var TOTAL_CREDIT_METRIC = "usageTotalPackageCredit";
|
|
58202
58372
|
var UNPARSABLE_RESPONSE_MESSAGE3 = "\u8BF7\u6C42\u5931\u8D25\u6216\u54CD\u5E94\u65E0\u6CD5\u89E3\u6790";
|
|
@@ -58314,6 +58484,23 @@ function parseCreditBalance(metrics) {
|
|
|
58314
58484
|
const used = readNumber8(record, "package_credit_used");
|
|
58315
58485
|
const remain = readNumber8(record, "package_credit_remain");
|
|
58316
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
|
+
}
|
|
58317
58504
|
if (amount <= 0 && remain <= 0) continue;
|
|
58318
58505
|
packages.push({
|
|
58319
58506
|
name: label,
|
|
@@ -58398,6 +58585,11 @@ function findDailyCheckinActivity(activities) {
|
|
|
58398
58585
|
return activities.find((activity) => activity.type === CODEARTS_DAILY_LOGIN_TYPE);
|
|
58399
58586
|
}
|
|
58400
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
|
+
}
|
|
58401
58593
|
const infoResult = await fetchCodeArtsAccountInfoDetailed(credential, fetcher);
|
|
58402
58594
|
if (!infoResult.ok) {
|
|
58403
58595
|
return { kind: "failed", code: -1, message: `\u8D26\u6237\u4FE1\u606F\u67E5\u8BE2\u5931\u8D25\uFF1A${infoResult.message}` };
|
|
@@ -66867,10 +67059,13 @@ async function* consumeMinimaxSse(options) {
|
|
|
66867
67059
|
yield { type: "reasoning-delta", index, text: d.thinking };
|
|
66868
67060
|
} else if (d.type === "input_json_delta" && typeof d.partial_json === "string") {
|
|
66869
67061
|
if (state !== void 0) state.toolArgs += d.partial_json;
|
|
67062
|
+
// name 必须带上:网关拿它写 tool_call 记录,pi 重放时缺 name 的调用会被
|
|
67063
|
+
// 400 拒掉(issue #226)。其余 tool-call-delta 站点都发了,这里是唯一漏的。
|
|
66870
67064
|
yield {
|
|
66871
67065
|
type: "tool-call-delta",
|
|
66872
67066
|
index,
|
|
66873
67067
|
id: ToolCallId8(state?.toolId ?? ""),
|
|
67068
|
+
...state?.toolName.length > 0 ? { name: state.toolName } : {},
|
|
66874
67069
|
argumentsDelta: d.partial_json
|
|
66875
67070
|
};
|
|
66876
67071
|
}
|
|
@@ -68999,6 +69194,9 @@ function apply(ctx, config = {}) {
|
|
|
68999
69194
|
if (available2) await service.refreshAccountCredential(available2.entry.credentialRef, pool, available2.entry.id);
|
|
69000
69195
|
},
|
|
69001
69196
|
fetchRemoteModels: () => service.refreshModels(pool),
|
|
69197
|
+
// [xdpool-local] issue #215: 把附件服务桥接给 CodeArtsAdapter,否则图片块会被静默丢弃。
|
|
69198
|
+
readImage: makeReadImage(ctx),
|
|
69199
|
+
readImageRequest: makeReadImageRequest(ctx),
|
|
69002
69200
|
accountPool: pool
|
|
69003
69201
|
});
|
|
69004
69202
|
const resolveBuddyCredentialByRef = async (refName) => {
|