@lynn123411/dsh-chat-translate 1.2.4 → 1.2.6

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/lib/index.js CHANGED
@@ -786,7 +786,7 @@ defineMethod("transform", [
786
786
  "preserve"
787
787
  ], ({ inner }, isInner) => inner.toString(isInner));
788
788
 
789
- // node_modules/.pnpm/@deepseek-ai+dsh-home-paths@0.1.3-alpha.2_@deepseek-ai+cordis@4.0.2/node_modules/@deepseek-ai/dsh-home-paths/lib/index.js
789
+ // node_modules/.pnpm/@deepseek-ai+dsh-home-paths@0.1.5-rc.1_@deepseek-ai+cordis@4.0.2/node_modules/@deepseek-ai/dsh-home-paths/lib/index.js
790
790
  import { homedir } from "node:os";
791
791
  import { basename, dirname, join, resolve as resolve2 } from "node:path";
792
792
  var DSH_HOME_DIR_NAME = ".dsh";
@@ -842,21 +842,6 @@ var ConfigManager = class {
842
842
  config.baseUrl.trim() && config.model.trim() && this.credentials.getApiKey()
843
843
  );
844
844
  }
845
- getMaskedConfig() {
846
- const config = this.getConfig();
847
- return {
848
- enabled: config.enabled,
849
- concurrency: config.concurrency,
850
- timeoutMs: config.timeoutMs,
851
- aiTimeoutMs: config.aiTimeoutMs,
852
- aiEnabled: config.aiEnabled,
853
- bingEnabled: config.bingEnabled,
854
- baseUrl: config.baseUrl,
855
- model: config.model,
856
- targetLang: config.targetLang || "zh-Hans",
857
- aiConfigured: this.isAiConfigured()
858
- };
859
- }
860
845
  onConfigChange(listener) {
861
846
  return this.scope.watch(listener);
862
847
  }
@@ -864,6 +849,11 @@ var ConfigManager = class {
864
849
  * Merge a partial update into the settings namespace. Values are sanitized
865
850
  * here (bounds, trimming) so the schema's own constraints act as a second
866
851
  * line of defence rather than the only one.
852
+ *
853
+ * @internal Test-only. No production path calls this: the host writes the
854
+ * settings namespace from the browser through the DSH settings service, and
855
+ * this facade is only driven by `scripts/test-*.mjs` (regression suite).
856
+ * Kept (with this marker) so those tests keep exercising the sanitizer.
867
857
  */
868
858
  async updateConfig(partial) {
869
859
  await this.scope.update(sanitizePatch({ ...partial }));
@@ -975,7 +965,13 @@ var CredentialsReader = class {
975
965
  getApiKey() {
976
966
  return this.cachedKey;
977
967
  }
978
- /** Status-only view for the settings UI (plaintext never crosses the wire). */
968
+ /**
969
+ * Status-only view of the ref (plaintext never crosses the wire).
970
+ *
971
+ * @internal Test-only. The settings UI reads key status through the
972
+ * `credentials` Remote API with its own client-side shape, so nothing in
973
+ * `src/` calls this host-side method; only `scripts/test-*.mjs` do.
974
+ */
979
975
  async describe() {
980
976
  try {
981
977
  const info = await this.service.describe(TRANSLATE_API_KEY_REF);
@@ -1123,6 +1119,32 @@ var LruDiskCache = class {
1123
1119
  }
1124
1120
  };
1125
1121
 
1122
+ // src/describe-error.ts
1123
+ function describeError(err) {
1124
+ if (err === null || err === void 0) return String(err);
1125
+ const parts = [];
1126
+ const push2 = (s) => {
1127
+ const t = String(s || "").trim();
1128
+ if (t && !parts.includes(t)) parts.push(t);
1129
+ };
1130
+ const head = err.message || String(err);
1131
+ push2(head);
1132
+ const headCode = err.code;
1133
+ if (headCode && !head.includes(headCode)) push2("[" + headCode + "]");
1134
+ let cause = err.cause;
1135
+ for (let depth = 0; cause && depth < 4; depth++) {
1136
+ const label = cause.message || String(cause);
1137
+ push2(cause.code && !label.includes(cause.code) ? label + " [" + cause.code + "]" : label);
1138
+ if (Array.isArray(cause.errors)) {
1139
+ for (const sub of cause.errors.slice(0, 3)) {
1140
+ if (sub) push2(sub.code || sub.message || String(sub));
1141
+ }
1142
+ }
1143
+ cause = cause.cause;
1144
+ }
1145
+ return parts.join(" \u2190 ");
1146
+ }
1147
+
1126
1148
  // src/server/adapters/bing.ts
1127
1149
  var TRANSLATOR_URL = "https://cn.bing.com/translator";
1128
1150
  var TRANSLATE_URL = "https://cn.bing.com/ttranslatev3?isVertical=1&&IG={IG}&IID=translator.5025.1";
@@ -1487,7 +1509,7 @@ var TranslationDispatcher = class {
1487
1509
  } catch (err) {
1488
1510
  this.recordFailure(chId);
1489
1511
  console.warn(
1490
- `[dsh-chat-translate] channel ${chId} failed: ${err?.message || String(err)} | text: ${text.slice(0, 60)}`
1512
+ `[dsh-chat-translate] channel ${chId} failed: ${describeError(err)} | text: ${text.slice(0, 60)}`
1491
1513
  );
1492
1514
  }
1493
1515
  }
@@ -1531,7 +1553,7 @@ var TranslationDispatcher = class {
1531
1553
  }
1532
1554
  return { ok: false, latencyMs, error: "Empty translation returned" };
1533
1555
  } catch (err) {
1534
- return { ok: false, latencyMs: Date.now() - start, error: err?.message || String(err) };
1556
+ return { ok: false, latencyMs: Date.now() - start, error: describeError(err) };
1535
1557
  }
1536
1558
  }
1537
1559
  enqueueTask(task) {
@@ -1697,7 +1719,7 @@ function createHttpHandler(configManager, dispatcher) {
1697
1719
  sendJson(res, 404, { ok: false, error: "Endpoint not found" });
1698
1720
  } catch (err) {
1699
1721
  const status = err?.message?.includes("exceeded maximum allowed size") ? 413 : 500;
1700
- sendJson(res, status, { ok: false, error: err?.message || String(err) });
1722
+ sendJson(res, status, { ok: false, error: describeError(err) });
1701
1723
  }
1702
1724
  };
1703
1725
  }