heybash-xdpool 1.0.8 → 1.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": "heybash-xdpool",
3
3
  "displayName": "Heybash",
4
4
  "description": "Heybash model pool for DeepSeek Harness: account rotation, provider aggregation, routing chains, usage insights and a local OpenAI-compatible gateway.",
5
- "version": "1.0.8",
5
+ "version": "1.0.9",
6
6
  "license": "MIT",
7
7
  "author": "Heybash",
8
8
  "contributors": [
@@ -37794,6 +37794,22 @@ function buildQoderInferPayload(ask, requestId = crypto.randomUUID()) {
37794
37794
  };
37795
37795
  }
37796
37796
  var gluePromise = null;
37797
+ // Qoder's WASM has a limited heap; preserve system, tools, and the entire latest turn.
37798
+ const QODER_PAYLOAD_BYTE_BUDGET = 700 * 1024;
37799
+ function fitQoderPayload(payload) {
37800
+ const measure = (value) => Buffer.byteLength(JSON.stringify(value), "utf8");
37801
+ if (measure(payload) <= QODER_PAYLOAD_BYTE_BUDGET) return payload;
37802
+ const out = { ...payload, messages: Array.isArray(payload.messages) ? [...payload.messages] : [] };
37803
+ while (measure(out) > QODER_PAYLOAD_BYTE_BUDGET) {
37804
+ const firstUser = out.messages.findIndex((message) => message?.role === "user");
37805
+ const nextUser = firstUser < 0 ? -1 : out.messages.findIndex((message, index) => index > firstUser && message?.role === "user");
37806
+ if (firstUser < 0 || nextUser < 0) {
37807
+ throw new LlmError5("Qoder 请求过大;请压缩上下文或缩短当前请求后重试", "CONTEXT_WINDOW_EXCEEDED", { status: 400 });
37808
+ }
37809
+ out.messages.splice(firstUser, nextUser - firstUser);
37810
+ }
37811
+ return out;
37812
+ }
37797
37813
  async function getGlue() {
37798
37814
  gluePromise ??= createGlue();
37799
37815
  return gluePromise;
@@ -38013,7 +38029,7 @@ var QoderEncryptedInfer = class _QoderEncryptedInfer {
38013
38029
  const result = g.callPointer((stack) => {
38014
38030
  const host = g.writeString(this.host);
38015
38031
  const hostLen = g.lastLength();
38016
- const body = g.writeString(JSON.stringify(payload));
38032
+ const body = g.writeString(JSON.stringify(fitQoderPayload(payload)));
38017
38033
  const bodyLen = g.lastLength();
38018
38034
  const key = g.writeString(ask.modelKey);
38019
38035
  const keyLen = g.lastLength();
@@ -46814,6 +46830,17 @@ var TraeAuth = class _TraeAuth extends Service5 {
46814
46830
  if (pool) {
46815
46831
  const available2 = await pool.getAvailableAccount(this.product.id, "").catch(() => void 0);
46816
46832
  if (available2) credential = available2.credential;
46833
+ // Model discovery can use an enabled account that is temporarily cooling.
46834
+ if (credential === void 0) {
46835
+ for (const entry of pool.listAccountsByProvider(this.product.id)) {
46836
+ if (entry.enabled === false || !entry.credentialRef) continue;
46837
+ try {
46838
+ const stored = await this.ctx.credentials.resolve(credentialRef6(entry.credentialRef));
46839
+ const parsed = stored ? parseCredential5(stored.value) : void 0;
46840
+ if (parsed?.access_token) { credential = parsed; break; }
46841
+ } catch { /* try the next account */ }
46842
+ }
46843
+ }
46817
46844
  }
46818
46845
  if (credential === void 0) {
46819
46846
  const resolved = await this.ctx.credentials.resolve(credentialRef6(this.credentialRefName));