dsh-xdpool 3.0.7 → 3.0.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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "dsh-xdpool",
3
3
  "displayName": "DSH XD Pool",
4
4
  "description": "One DSH model pool for every free quota you have: merge all locally signed-in WorkBuddy accounts with auto-failover, sign in to 22 vendors by QR/web, aggregate 77 external vendors' keys, plus a usage dashboard, model routing, a local OpenAI-compatible gateway and a points-automation suite.",
5
- "version": "3.0.7",
5
+ "version": "3.0.9",
6
6
  "license": "MIT",
7
7
  "author": "XDTrees",
8
8
  "homepage": "https://github.com/XDTrees/dsh-xdpool#readme",
@@ -70,7 +70,6 @@
70
70
  "inject": [
71
71
  "@deepseek-ai/dsh-client-ui-settings",
72
72
  "@deepseek-ai/dsh-client-ui-slots",
73
- "@deepseek-ai/dsh-client-ui-settings-plugins",
74
73
  "@deepseek-ai/dsh-client-ui-primitives",
75
74
  "@deepseek-ai/dsh-client-locale"
76
75
  ],
@@ -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
- if (id.length > 5) {
31467
- const suffix = id.slice(-5);
31468
- if (suffix.startsWith("-") && /^\d{4}$/.test(suffix.slice(1))) {
31469
- return id.slice(0, -5);
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
- return { id, name: name2 };
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 (typeof m["supports_images"] === "boolean") out.supportsImages = m["supports_images"];
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
- if (rawId.length > 0 && normalizeModelId(rawId) === rawId) benefitIds.push(mi.id);
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,43 @@ var IMAGE_MODELS = /* @__PURE__ */ new Set([
32905
32946
  "deepseek-v4.1-flash",
32906
32947
  "kimi-k2.6-vl"
32907
32948
  ]);
32908
- /** Window for one id, or undefined when this channel publishes none. */
32909
- function contextWindowFor(model) {
32910
- return CONTEXT_WINDOWS.get(String(model).toLowerCase());
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
- return IMAGE_MODELS.has(String(model).toLowerCase()) ? ["text", "image"] : ["text"];
32971
+ function modalitiesFor(model, remoteSupportsImages) {
32972
+ if (remoteSupportsImages === false) return ["text"];
32973
+ if (remoteSupportsImages === true) return ["text", "image"];
32974
+ var key = String(model).toLowerCase();
32975
+ if (IMAGE_MODELS.has(key)) return ["text", "image"];
32976
+ // same base-id fallback as contextWindowFor
32977
+ var base = key.replace(/-\d{4}$/u, "");
32978
+ return base !== key && IMAGE_MODELS.has(base) ? ["text", "image"] : ["text"];
32915
32979
  }
32916
32980
  function contentToText(content) {
32917
32981
  if (typeof content === "string") return content;
32918
32982
  if (!Array.isArray(content)) return "";
32919
32983
  return content.filter((block) => typeof block === "object" && block !== null && block.type === "text").map((block) => String(block.text)).join("");
32920
32984
  }
32921
- function serializeMessages(messages) {
32985
+ async function serializeMessages(messages, readImage) {
32922
32986
  const normalized = normalizeHarnessMessages(messages);
32923
32987
  const wire = [];
32924
32988
  const { keepCallIds, keepResultIds } = resolveToolPairing(normalized);
@@ -32953,13 +33017,38 @@ function serializeMessages(messages) {
32953
33017
  const content = Array.isArray(message2.content) ? message2.content : [];
32954
33018
  const toolResults = content.filter((block) => typeof block === "object" && block !== null && block.type === "tool-result");
32955
33019
  const text = contentToText(message2.content);
32956
- if (text.length > 0 || toolResults.length === 0) wire.push({ role: "user", content: text });
33020
+ const images = content.filter((block) => block?.type === "image");
33021
+ if (images.length > 0) {
33022
+ if (typeof readImage !== "function") throw new Error("codearts: image attachment bridge is unavailable");
33023
+ const parts = [];
33024
+ let imageBytes = 0;
33025
+ for (const block of content) {
33026
+ if (block.type === "text") parts.push({ type: "text", text: String(block.text) });
33027
+ if (block.type !== "image") continue;
33028
+ const image = await readImage(block.attachment);
33029
+ if (!image?.data?.length || !/^image\/(png|jpeg|webp|gif)$/.test(image.mediaType)) {
33030
+ throw new Error("codearts: invalid image attachment");
33031
+ }
33032
+ imageBytes += image.data.length;
33033
+ if (imageBytes > 20971520) throw new Error("codearts: image attachment budget exceeded");
33034
+ parts.push({ type: "image_url", image_url: { url: `data:${image.mediaType};base64,${Buffer.from(image.data).toString("base64")}` } });
33035
+ }
33036
+ wire.push({ role: "user", content: parts });
33037
+ } else if (text.length > 0 || toolResults.length === 0) wire.push({ role: "user", content: text });
32957
33038
  for (const result of toolResults) {
32958
33039
  if (!keepResultIds.has(String(result.toolCallId))) continue;
33040
+ let resultText = contentToText(result.content) || "(no output)";
33041
+ if (imageUrls !== void 0 && Array.isArray(result.content)) {
33042
+ const resultParts = codeArtsContentParts(result.content, imageUrls);
33043
+ if (resultParts !== void 0) {
33044
+ const joined = resultParts.filter((part) => part.type === "text").map((part) => String(part.text)).join("");
33045
+ if (joined.length > 0) resultText = joined;
33046
+ }
33047
+ }
32959
33048
  wire.push({
32960
33049
  role: "tool",
32961
33050
  tool_call_id: String(result.toolCallId),
32962
- content: contentToText(result.content) || "(no output)"
33051
+ content: resultText
32963
33052
  });
32964
33053
  }
32965
33054
  }
@@ -32993,7 +33082,7 @@ function buildDsmlSystemPrompt(tools) {
32993
33082
  toolJson
32994
33083
  ].join("\n");
32995
33084
  }
32996
- var QUEUE_STATUS_BASE = "https://snap-access.cn-north-4.myhuaweicloud.com/api/v1/queue/status";
33085
+ var QUEUE_STATUS_BASE = codeartsSiteHost("https://snap-access.cn-north-4.myhuaweicloud.com/api/v1/queue/status");
32997
33086
  var QUEUE_RETRY_DELAY_MS = 1e4;
32998
33087
  var QUEUE_MAX_ATTEMPTS2 = 180;
32999
33088
  function resolveFirstTokenTimeoutMs() {
@@ -33415,7 +33504,7 @@ var CodeArtsAdapter = class extends LlmAdapter {
33415
33504
  */
33416
33505
  listAllModels() {
33417
33506
  const source = this.remoteModels ?? DEFAULT_MODELS.map((id) => ({ id, name: id }));
33418
- return source.filter((m) => !/-VL-/i.test(m.id) && !/-VL$/i.test(m.id)).map((m) => ({ id: m.id, name: m.name }));
33507
+ return source.filter((m) => !/-VL-/i.test(m.id) && !/-VL$/i.test(m.id)).map((m) => ({ ...m }));
33419
33508
  }
33420
33509
  async listModels(_provider) {
33421
33510
  if (!await providerCatalogVisible(this.options.accountPool, PROVIDER)) return [];
@@ -33424,13 +33513,13 @@ var CodeArtsAdapter = class extends LlmAdapter {
33424
33513
  const disabled = this.options.accountPool?.disabledModelsFor(PROVIDER);
33425
33514
  const listed = disabled === void 0 || disabled.size === 0 ? visible : visible.filter((m) => !disabled.has(m.id));
33426
33515
  return listed.map((m) => {
33427
- const contextWindow = contextWindowFor(m.id);
33516
+ const contextWindow = contextWindowFor(m.id, m.contextWindow);
33428
33517
  return {
33429
33518
  provider: PROVIDER,
33430
33519
  id: m.id,
33431
33520
  name: m.name,
33432
- inputModalities: modalitiesFor(m.id),
33433
- maxTokens: CODEARTS_MAX_OUTPUT_TOKENS,
33521
+ inputModalities: modalitiesFor(m.id, m.supportsImages),
33522
+ maxTokens: Math.min(m.maxTokens ?? CODEARTS_MAX_OUTPUT_TOKENS, CODEARTS_MAX_OUTPUT_TOKENS),
33434
33523
  ...contextWindow === void 0 ? {} : { contextWindow }
33435
33524
  };
33436
33525
  });
@@ -33439,15 +33528,15 @@ var CodeArtsAdapter = class extends LlmAdapter {
33439
33528
  await this.ensureRemoteModels();
33440
33529
  const remoteModel = this.remoteModels?.find((m) => m.id === model);
33441
33530
  const name2 = remoteModel?.name ?? model;
33442
- const contextWindow = contextWindowFor(model);
33531
+ const contextWindow = contextWindowFor(model, remoteModel?.contextWindow);
33443
33532
  const resolved = {
33444
33533
  provider,
33445
33534
  id: model,
33446
33535
  name: name2,
33447
- inputModalities: modalitiesFor(model),
33536
+ inputModalities: modalitiesFor(model, remoteModel?.supportsImages),
33448
33537
  // catalogFactsFor() forwards this as fact.maxTokens; without it the host
33449
33538
  // has no way to learn the ceiling and passes its own catalog value through.
33450
- defaultMaxTokens: CODEARTS_MAX_OUTPUT_TOKENS
33539
+ defaultMaxTokens: Math.min(remoteModel?.maxTokens ?? CODEARTS_MAX_OUTPUT_TOKENS, CODEARTS_MAX_OUTPUT_TOKENS)
33451
33540
  };
33452
33541
  if (contextWindow !== void 0) resolved.context = { contextWindow };
33453
33542
  resolved.reasoning = {
@@ -33486,7 +33575,7 @@ var CodeArtsAdapter = class extends LlmAdapter {
33486
33575
  }
33487
33576
  if (currentAccountId) reportLedgerAccount(PROVIDER, currentAccountId);
33488
33577
  }
33489
- const messages = serializeMessages(options.messages);
33578
+ const messages = await serializeMessages(options.messages, this.options.readImage);
33490
33579
  if (options.system !== void 0 && options.system.length > 0) {
33491
33580
  messages.unshift({ role: "system", content: options.system });
33492
33581
  }
@@ -33534,7 +33623,7 @@ var CodeArtsAdapter = class extends LlmAdapter {
33534
33623
  // 因此这是上限而不只是默认值:调用方传来的更大值(宿主模型目录里别的
33535
33624
  // provider 带 384000)会被原样发出并触发 INVALID_REQUEST,必须收回;
33536
33625
  // 调用方主动设的较小值保留。
33537
- max_tokens: Math.min(options.maxTokens ?? CODEARTS_MAX_OUTPUT_TOKENS, CODEARTS_MAX_OUTPUT_TOKENS),
33626
+ max_tokens: Math.min(options.maxTokens ?? CODEARTS_MAX_OUTPUT_TOKENS, CODEARTS_MAX_OUTPUT_TOKENS, this.remoteModels?.find((m) => m.id === options.model)?.maxTokens ?? CODEARTS_MAX_OUTPUT_TOKENS),
33538
33627
  ...wireTools !== void 0 && wireTools.length > 0 ? { tools: wireTools } : {}
33539
33628
  });
33540
33629
  const url = `${CHAT_API_BASE}/chat/completions`;
@@ -43221,14 +43310,20 @@ var LoomyAdapter = class extends LlmAdapter7 {
43221
43310
  ...options.stop !== void 0 && options.stop.length > 0 ? { stop: options.stop } : {},
43222
43311
  ...effort !== void 0 ? { reasoning_effort: effort } : {},
43223
43312
  ...options.tools !== void 0 && options.tools.length > 0 ? {
43224
- tools: options.tools.map((tool) => ({
43225
- type: "function",
43226
- function: {
43227
- name: tool.name,
43228
- ...tool.description.length > 0 ? { description: tool.description } : {},
43229
- ...tool.parameters === void 0 ? {} : { parameters: tool.parameters }
43313
+ // DSH 内部形状是 {name,description,parameters};个别宿主直接递 OpenAI 形状
43314
+ // {type,function:{...}},那时 tool.description 是 undefined,.length 会抛
43315
+ // TypeError → 502(issue #234)。两种都认。
43316
+ tools: options.tools.map((tool) => {
43317
+ const fn = tool.function ?? tool
43318
+ return {
43319
+ type: "function",
43320
+ function: {
43321
+ name: fn.name,
43322
+ ...fn.description?.length > 0 ? { description: fn.description } : {},
43323
+ ...fn.parameters === void 0 ? {} : { parameters: fn.parameters }
43324
+ }
43230
43325
  }
43231
- }))
43326
+ })
43232
43327
  } : {}
43233
43328
  });
43234
43329
  const send = async (token) => {
@@ -43654,14 +43749,20 @@ var RaccoonAdapter = class extends LlmAdapter8 {
43654
43749
  // ⚠️ tools 必须真的下发到请求体**顶层**:Qoder/TRAE 都因漏发而让模型
43655
43750
  // 在正文里臆造 XML 工具调用,harness 认不出 → 任务终止。
43656
43751
  ...options.tools !== void 0 && options.tools.length > 0 ? {
43657
- tools: options.tools.map((tool) => ({
43658
- type: "function",
43659
- function: {
43660
- name: tool.name,
43661
- ...tool.description.length > 0 ? { description: tool.description } : {},
43662
- ...tool.parameters === void 0 ? {} : { parameters: tool.parameters }
43752
+ // DSH 内部形状是 {name,description,parameters};个别宿主直接递 OpenAI 形状
43753
+ // {type,function:{...}},那时 tool.description 是 undefined,.length 会抛
43754
+ // TypeError → 502(issue #234)。两种都认。
43755
+ tools: options.tools.map((tool) => {
43756
+ const fn = tool.function ?? tool
43757
+ return {
43758
+ type: "function",
43759
+ function: {
43760
+ name: fn.name,
43761
+ ...fn.description?.length > 0 ? { description: fn.description } : {},
43762
+ ...fn.parameters === void 0 ? {} : { parameters: fn.parameters }
43763
+ }
43663
43764
  }
43664
- }))
43765
+ })
43665
43766
  } : {},
43666
43767
  // 思考档位(开 / 关)。⚠️ **必须在 `extra_body` 内** —— 实测放顶层会被忽略
43667
43768
  //(连非法值都不报错)。不传档位时不发该字段,保持服务端默认(= 开)。
@@ -58179,7 +58280,7 @@ function roundCredits2(value) {
58179
58280
  }
58180
58281
 
58181
58282
  // vendor/channel-pack/src/codearts-credits.ts
58182
- var CODEARTS_SNAP_ENGINE_URL = "https://snap-access.cn-north-4.myhuaweicloud.com";
58283
+ var CODEARTS_SNAP_ENGINE_URL = codeartsSiteHost("https://snap-access.cn-north-4.myhuaweicloud.com");
58183
58284
  var CODEARTS_PACKAGE_INFO_PATH = "/snap-manager/v1/statistics/plugin";
58184
58285
  var CODEARTS_OPS_DELIVERY_PATH = "/v1/ops/delivery";
58185
58286
  var CODEARTS_OPS_CLAIM_PATH = "/v1/ops/claim";
@@ -58196,7 +58297,9 @@ var CREDIT_METRIC_LABELS = {
58196
58297
  usageTotalPackageCredit: "\u603B\u79EF\u5206\u5305",
58197
58298
  usageBasicPackageCredit: "\u57FA\u7840\u79EF\u5206\u5305",
58198
58299
  usageOnDemandPackageCredit: "\u6309\u9700\u79EF\u5206\u5305",
58199
- usageBonusPackageCredit: "\u8D60\u9001\u79EF\u5206\u5305"
58300
+ usageBonusPackageCredit: "\u8D60\u9001\u79EF\u5206\u5305",
58301
+ // \u56FD\u9645\u7AD9\uFF08issue #244\uFF09\uFF1Atoken \u5957\u9910\u53EA\u62A5\u4E00\u4E2A usage_token_num \u7A97\u53E3\u3002
58302
+ usageTokenNum: "Token \u5957\u9910"
58200
58303
  };
58201
58304
  var TOTAL_CREDIT_METRIC = "usageTotalPackageCredit";
58202
58305
  var UNPARSABLE_RESPONSE_MESSAGE3 = "\u8BF7\u6C42\u5931\u8D25\u6216\u54CD\u5E94\u65E0\u6CD5\u89E3\u6790";
@@ -58314,6 +58417,23 @@ function parseCreditBalance(metrics) {
58314
58417
  const used = readNumber8(record, "package_credit_used");
58315
58418
  const remain = readNumber8(record, "package_credit_remain");
58316
58419
  if (name2 === TOTAL_CREDIT_METRIC) totalRemain = remain;
58420
+ // 国际站 token 套餐(issue #244):字段名不同,只有套餐总量,无已用/剩余拆分。
58421
+ if (amount <= 0 && remain <= 0 && name2 === "usageTokenNum") {
58422
+ amount = readNumber8(record, "package_token_amount");
58423
+ if (amount > 0) packages.push({
58424
+ name: CREDIT_METRIC_LABELS.usageTokenNum,
58425
+ unit: "credit",
58426
+ remaining: amount,
58427
+ total: amount,
58428
+ used: 0,
58429
+ active: true,
58430
+ cycleStartTime: readString6(record, "start_date"),
58431
+ cycleEndTime: readString6(record, "end_date"),
58432
+ expiredTime: ""
58433
+ });
58434
+ sawAnyCreditMetric = true;
58435
+ continue;
58436
+ }
58317
58437
  if (amount <= 0 && remain <= 0) continue;
58318
58438
  packages.push({
58319
58439
  name: label,
@@ -58398,6 +58518,11 @@ function findDailyCheckinActivity(activities) {
58398
58518
  return activities.find((activity) => activity.type === CODEARTS_DAILY_LOGIN_TYPE);
58399
58519
  }
58400
58520
  async function claimCodeArtsDailyCheckin(credential, fetcher = fetch) {
58521
+ /* 国际站没有积分批次/每日签到(issue #244):ops 端点在那边是 404,
58522
+ 与其报「活动列表查询失败」,不如直接如实答 inactive。 */
58523
+ if (process.env.DSH_XDPOOL_CODEARTS_INTL === "1") {
58524
+ return { kind: "inactive", message: "国际站无每日签到活动" };
58525
+ }
58401
58526
  const infoResult = await fetchCodeArtsAccountInfoDetailed(credential, fetcher);
58402
58527
  if (!infoResult.ok) {
58403
58528
  return { kind: "failed", code: -1, message: `\u8D26\u6237\u4FE1\u606F\u67E5\u8BE2\u5931\u8D25\uFF1A${infoResult.message}` };
@@ -66867,10 +66992,13 @@ async function* consumeMinimaxSse(options) {
66867
66992
  yield { type: "reasoning-delta", index, text: d.thinking };
66868
66993
  } else if (d.type === "input_json_delta" && typeof d.partial_json === "string") {
66869
66994
  if (state !== void 0) state.toolArgs += d.partial_json;
66995
+ // name 必须带上:网关拿它写 tool_call 记录,pi 重放时缺 name 的调用会被
66996
+ // 400 拒掉(issue #226)。其余 tool-call-delta 站点都发了,这里是唯一漏的。
66870
66997
  yield {
66871
66998
  type: "tool-call-delta",
66872
66999
  index,
66873
67000
  id: ToolCallId8(state?.toolId ?? ""),
67001
+ ...state?.toolName.length > 0 ? { name: state.toolName } : {},
66874
67002
  argumentsDelta: d.partial_json
66875
67003
  };
66876
67004
  }
@@ -68698,7 +68826,10 @@ var OPENCODE_CATALOG_TIMEOUT_MS = 8e3;
68698
68826
  var name = "codearts-auth";
68699
68827
  var inject = ["credentials", "commands", "llm"];
68700
68828
  var Config = Schema2.object({
68701
- providers: Schema2.dict(Schema2.any()).default({}).volatile()
68829
+ providers: (() => {
68830
+ const schema = Schema2.dict(Schema2.any()).default({});
68831
+ return typeof schema.volatile === "function" ? schema.volatile() : schema;
68832
+ })()
68702
68833
  });
68703
68834
  function registerProviderSettings(ctx, ...namespaces) {
68704
68835
  const settings = settingsOf(ctx);
@@ -68986,6 +69117,7 @@ function apply(ctx, config = {}) {
68986
69117
  ctx.logger.warn(`[channel-pack] \u6E05\u7406 WorkBuddy \u65E7\u7248\u8D26\u53F7\u5931\u8D25\uFF1A${String(error)}`);
68987
69118
  });
68988
69119
  const codearts = registerCodeArtsLlm(ctx, {
69120
+ readImage: makeReadImage(ctx),
68989
69121
  credentialRef: credentialRef16(CODEARTS_CREDENTIAL_REF),
68990
69122
  resolveCredential: async () => {
68991
69123
  const available2 = await pool.getAvailableAccount("codearts", "");
@@ -68999,6 +69131,9 @@ function apply(ctx, config = {}) {
68999
69131
  if (available2) await service.refreshAccountCredential(available2.entry.credentialRef, pool, available2.entry.id);
69000
69132
  },
69001
69133
  fetchRemoteModels: () => service.refreshModels(pool),
69134
+ // [xdpool-local] issue #215: 把附件服务桥接给 CodeArtsAdapter,否则图片块会被静默丢弃。
69135
+ readImage: makeReadImage(ctx),
69136
+ readImageRequest: makeReadImageRequest(ctx),
69002
69137
  accountPool: pool
69003
69138
  });
69004
69139
  const resolveBuddyCredentialByRef = async (refName) => {