dsh-xdpool 2.6.3 → 2.6.5

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 CHANGED
@@ -1,6 +1,52 @@
1
1
  # Changelog
2
2
  本项目的所有重要变更都会记录在此文件。
3
3
  版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
4
+ ## 2.6.5 — 安装不再被判失败,积分面板不再空白
5
+
6
+ > 五张 issue,三个独立根因。前两张是同一件事的两面:2.6.4 的 postinstall 会把**本来能用的安装**判成失败。
7
+
8
+ ### postinstall 不再让安装回滚(#134、#135)
9
+
10
+ 打包版宿主的依赖全在 `app.asar` 里,而 postinstall 跑在裸 Node 进程里——`fs.existsSync` **看不进 asar**,只有 Electron 打过补丁的 `fs` 才行。所以「这里没找到」经常只是「这个进程看不见」,而不是「不存在」。
11
+
12
+ 2.6.3 根本没有 postinstall,在 macOS 上照样能加载:宿主自己在运行时解析这些依赖。2.6.4 的脚本却把探测失败当成安装损坏并 `exit(1)`,于是插件管理器回滚了本来可用的升级。
13
+
14
+ 现在探测不到只输出说明、**正常退出**。只有真正创建链接失败才警告,而那也是警告不是失败。
15
+
16
+ 自检同时改用 **ESM 解析**:`@earendil-works/pi-ai` 是 ESM-only,`exports` 只有 `types` 和 `import`,没有 `require`、也没有 `./package.json` 子路径。`require.resolve` 对它必抛 `ERR_PACKAGE_PATH_NOT_EXPORTED`——包明明装着、能 import,却被判为缺失,这就是 2.6.4 在 Windows 上装不上的原因。
17
+
18
+ 宿主路径探测也补齐了:macOS 的 `/Applications/.../Contents/Resources`、Linux 的 `~/.local/share`,以及**从 `process.execPath` 反推**——报告者的宿主装在 F 盘,所有硬编码的 C 盘猜测都落空。
19
+
20
+ 顺带修好幂等性:`locate()` 现在先看磁盘上的 `node_modules/<name>`,所以已经建好的链接不会被误判为缺失、反复重建。
21
+
22
+ ### 积分面板点开不再空白(#133)
23
+
24
+ `failed || snapshot === undefined` 时整个组件 `return null`,把**触发按钮也一起摘掉**了。新建会话还没有快照,于是圆点先画出来(绿色,来自上一次渲染),随后组件卸载,屏幕上只剩一个空的浮层。
25
+
26
+ 现在圆点永远渲染,数据没到时在面板里说明「正在读取积分…」;读取失败则说失败。状态指示器必须对每一次点击都有回答——「还没加载」是回答,空盒子不是。
27
+
28
+ 未加载时的状态按灰色处理:未知余额不能显示成「你没问题」。
29
+
30
+ ### 空模型选择等于「全部」,不是「一个都不要」(#122)
31
+
32
+ DSH 0.2.2-rc.1 会在选择器首次使用前写入 `enabledModelIds: []`。原代码把空数组当成真实选择,过滤后得到 **0 个模型**,于是卡片上列着 16 个模型,每次请求却报 `has no configured model "<id>"`。
33
+
34
+ 现在空数组与 `undefined` 同等对待。两种状态事后无法区分,所以选了安全的那一侧:空选择等同于没选择,而「全部」一次点击就能改回来,「什么都没有」看起来像装坏了。
35
+
36
+ ### 路由链缺少字段不再让整页崩掉
37
+
38
+ 从磁盘读到的链路可能整个缺 `platforms`,或者某个分组的 `models` 缺失。三个字段原先都是无保护地展开,任何一处缺失都会让路由页崩在 `Cannot read properties of undefined (reading 'length')`——这个报错既不说是哪条链、也不说哪个字段。现在统一归一化。
39
+
40
+ ### 账号池与模型选择器用同一个名字(#119)
41
+
42
+ `buddy` 这条 lane 在插件里叫「WorkBuddy 国内版」,而 vendor 产品常量仍沿用上游旧名「CodeBuddy (腾讯)」,模型选择器的分组名因此和账号池卡片对不上。在呈现层覆盖,不改常量——那个常量还被 429 的报错文案引用着。
43
+
44
+ ## 2.6.4 — postinstall 真的会跑了
45
+
46
+ 2.6.3 的修复方向是对的,但 的改动在合并时丢了:`postinstall` 没挂上,`scripts/` 也没进 `files`。结果是 npm 上的 2.6.3 依然缺 peer 依赖,靠的是此前手动建的 junction。
47
+
48
+ 现在两者都补齐,并核对 `npm pack` 的内容确实包含 `scripts/link-host-peers.mjs`。
49
+
4
50
  ## 2.6.3 — 修掉 2.6.2 装上后插件起不来的问题
5
51
 
6
52
  > 2.6.2 从 npm 安装后,插件导入失败(`Cannot find package '@earendil-works/pi-ai'`),
package/lib/bin.js CHANGED
@@ -5011,7 +5011,21 @@ var WorkBuddyCatalog = class {
5011
5011
  */
5012
5012
  visible() {
5013
5013
  const enabled = this.selection.enabledModelIds;
5014
- const allow = enabled === void 0 ? void 0 : new Set(enabled);
5014
+ /**
5015
+ * An EMPTY list means "nothing has been chosen yet", not "serve nothing".
5016
+ *
5017
+ * `undefined` was already treated as "all enabled", but `[]` fell through to an empty
5018
+ * allow-set and filtered out every model. A host that writes the legacy key with a
5019
+ * default `[]` — DSH 0.2.2-rc.1 does exactly that before the picker has ever been
5020
+ * used — therefore made this catalog publish ZERO models, and the picker and every
5021
+ * "test" call reported `has no configured model "<id>"` for models that were plainly
5022
+ * listed on the card (issue #122).
5023
+ *
5024
+ * The two states cannot be distinguished by intent afterwards, so the safe reading is
5025
+ * chosen: an empty selection is indistinguishable from no selection, and "everything"
5026
+ * is recoverable in one click whereas "nothing" looks like a broken install.
5027
+ */
5028
+ const allow = enabled === void 0 || enabled.length === 0 ? void 0 : new Set(enabled);
5015
5029
  const images = this.selection.imageModelIds;
5016
5030
  const imageSet = images === void 0 ? void 0 : new Set(images);
5017
5031
  const budgets = this.selection.contextBudgets;
package/lib/client.js CHANGED
@@ -10340,12 +10340,22 @@ window.__ModuleLoader__.load({
10340
10340
  * can serve right now. Dropping them would make a save silently delete members
10341
10341
  * the user never asked to remove — the "保存了没法用" class of data loss.
10342
10342
  */
10343
- const platforms = combo.platforms.map((group) => ({
10344
- owner: group.owner,
10345
- models: [...group.models]
10343
+ /**
10344
+ * A chain read from disk may be missing `platforms` entirely — an older shape, a
10345
+ * hand-edited file, or a partial write — and either level can be absent:
10346
+ * `platforms` itself, or one group's `models` array inside it.
10347
+ *
10348
+ * Both used to be spread unguarded, so a chain in either state crashed the whole
10349
+ * routing page with `Cannot read properties of undefined (reading 'length')` — a
10350
+ * message that names neither the chain nor the field, leaving nothing to act on.
10351
+ * Normalising here means every reader below can treat the shape as total.
10352
+ */
10353
+ const platforms = (Array.isArray(combo.platforms) ? combo.platforms : []).filter((group) => group !== null && typeof group === "object").map((group) => ({
10354
+ owner: typeof group.owner === "string" ? group.owner : "workbuddy",
10355
+ models: Array.isArray(group.models) ? [...group.models].filter((model) => typeof model === "string") : []
10346
10356
  }));
10347
- const known = new Set(combo.models);
10348
- for (const modelId of combo.missing) {
10357
+ const known = new Set(Array.isArray(combo.models) ? combo.models : []);
10358
+ for (const modelId of Array.isArray(combo.missing) ? combo.missing : []) {
10349
10359
  if (known.has(modelId)) continue;
10350
10360
  const slash = modelId.indexOf("/");
10351
10361
  const owner = slash === -1 ? "workbuddy" : modelId.slice(0, slash);
@@ -10362,7 +10372,7 @@ window.__ModuleLoader__.load({
10362
10372
  id: combo.id,
10363
10373
  name: combo.name,
10364
10374
  platforms,
10365
- flat: [...combo.models, ...combo.missing.filter((id) => !combo.models.includes(id))],
10375
+ flat: [...Array.isArray(combo.models) ? combo.models : [], ...(Array.isArray(combo.missing) ? combo.missing : []).filter((id) => !(Array.isArray(combo.models) ? combo.models : []).includes(id))],
10366
10376
  strategy: combo.strategy,
10367
10377
  stickyLimit: combo.stickyLimit,
10368
10378
  enabled: combo.enabled
@@ -13460,7 +13470,7 @@ window.__ModuleLoader__.load({
13460
13470
  *
13461
13471
  * @module dsh-xdpool/version
13462
13472
  */
13463
- const POOL_VERSION = "2.6.3";
13473
+ const POOL_VERSION = "2.6.5";
13464
13474
  //#endregion
13465
13475
  //#region src/client/PoolCard.tsx
13466
13476
  /**
@@ -16413,7 +16423,23 @@ window.__ModuleLoader__.load({
16413
16423
  document.removeEventListener("keydown", onKey);
16414
16424
  };
16415
16425
  }, [open]);
16416
- if (failed || snapshot === void 0) return null;
16426
+ /**
16427
+ * The dot itself is never withheld.
16428
+ *
16429
+ * `failed || snapshot === undefined` used to `return null` for the WHOLE component, which
16430
+ * removed the trigger as well as the panel. The reported symptom was "clicking the green
16431
+ * credit icon opens a blank page": a newly created session has no snapshot yet, so the dot
16432
+ * briefly existed (green, from an earlier paint) and then the component unmounted, leaving
16433
+ * an empty popover shell on screen.
16434
+ *
16435
+ * Rendering the dot unconditionally and explaining the absence INSIDE the panel is the
16436
+ * only version where a click always produces an answer — which is the entire job of a
16437
+ * status indicator.
16438
+ *
16439
+ * `snapshot === undefined` before the first successful load reads as grey: an unknown
16440
+ * balance must not be presented as "you are fine".
16441
+ */
16442
+ const ready = snapshot !== void 0 && !failed;
16417
16443
  /**
16418
16444
  * Green when the serving channel still has credits, grey when it does not.
16419
16445
  *
@@ -16421,7 +16447,7 @@ window.__ModuleLoader__.load({
16421
16447
  * reserved floor, so a non-zero total is genuinely spendable. A channel that could not
16422
16448
  * be read is grey — the dot must not claim "you are fine" on missing data.
16423
16449
  */
16424
- const alive = snapshot.channel !== void 0 && snapshot.channel.total > 0;
16450
+ const alive = ready && snapshot.channel !== void 0 && snapshot.channel.total > 0;
16425
16451
  const label = alive ? t?.("dot.alive") ?? "还有积分" : t?.("dot.empty") ?? "没有积分了";
16426
16452
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
16427
16453
  className: "dsm-xdpool-dotwrap",
@@ -16435,7 +16461,7 @@ window.__ModuleLoader__.load({
16435
16461
  "data-state": alive ? "alive" : "empty",
16436
16462
  "aria-label": label,
16437
16463
  "aria-expanded": open,
16438
- title: `${label} · ${snapshot.channel === void 0 ? "—" : grouped(snapshot.channel.total)}`,
16464
+ title: `${label} · ${snapshot?.channel === void 0 ? "—" : grouped(snapshot.channel.total)}`,
16439
16465
  onClick: () => {
16440
16466
  setOpen((current) => !current);
16441
16467
  },
@@ -16453,7 +16479,10 @@ window.__ModuleLoader__.load({
16453
16479
  top: `${String(pos.top)}px`,
16454
16480
  left: `${String(pos.left)}px`
16455
16481
  },
16456
- children: [
16482
+ children: [!ready ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
16483
+ className: "dsm-xdpool-dotpanel-empty",
16484
+ children: failed ? t?.("dot.loadFailed") ?? "积分数据读取失败" : t?.("dot.loading") ?? "正在读取积分…"
16485
+ }) : null, !ready ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
16457
16486
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
16458
16487
  className: "dsm-xdpool-dotpanel-head",
16459
16488
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -16508,7 +16537,7 @@ window.__ModuleLoader__.load({
16508
16537
  }, channel.id);
16509
16538
  })
16510
16539
  }) : null
16511
- ]
16540
+ ] })]
16512
16541
  })
16513
16542
  ]
16514
16543
  });
@@ -17055,6 +17084,8 @@ window.__ModuleLoader__.load({
17055
17084
  "dot.spentToday": "Used today",
17056
17085
  "dot.model": "Model",
17057
17086
  "dot.channelUnknown": "No channel connected",
17087
+ "dot.loading": "Reading credits…",
17088
+ "dot.loadFailed": "Could not read the credit data",
17058
17089
  "dot.remaining": "Remaining",
17059
17090
  "dot.barLabel": "Share of the period budget used",
17060
17091
  "gw.keyHint": "This key survives a DSH restart. Rotating it drops every device that still holds the old one. This is not the per-process secret of the pool itself — a client that learned that one would stop working the next time DSH restarts.",
@@ -17649,6 +17680,8 @@ window.__ModuleLoader__.load({
17649
17680
  "dot.spentToday": "今日已用",
17650
17681
  "dot.model": "模型",
17651
17682
  "dot.channelUnknown": "未连接渠道",
17683
+ "dot.loading": "正在读取积分…",
17684
+ "dot.loadFailed": "积分数据读取失败",
17652
17685
  "dot.remaining": "剩余积分",
17653
17686
  "dot.barLabel": "本期已用占比",
17654
17687
  "gw.keyHint": "这把密钥在 DSH 重启后仍然有效。轮换会让所有还在用旧密钥的设备立刻断线。这里给的也不是账号池自己每进程生成的秘密 —— 客户端要是拿到它,DSH 下次一重启就全废了。",
package/lib/index.js CHANGED
@@ -5196,7 +5196,21 @@ var WorkBuddyCatalog = class {
5196
5196
  */
5197
5197
  visible() {
5198
5198
  const enabled = this.selection.enabledModelIds;
5199
- const allow = enabled === void 0 ? void 0 : new Set(enabled);
5199
+ /**
5200
+ * An EMPTY list means "nothing has been chosen yet", not "serve nothing".
5201
+ *
5202
+ * `undefined` was already treated as "all enabled", but `[]` fell through to an empty
5203
+ * allow-set and filtered out every model. A host that writes the legacy key with a
5204
+ * default `[]` — DSH 0.2.2-rc.1 does exactly that before the picker has ever been
5205
+ * used — therefore made this catalog publish ZERO models, and the picker and every
5206
+ * "test" call reported `has no configured model "<id>"` for models that were plainly
5207
+ * listed on the card (issue #122).
5208
+ *
5209
+ * The two states cannot be distinguished by intent afterwards, so the safe reading is
5210
+ * chosen: an empty selection is indistinguishable from no selection, and "everything"
5211
+ * is recoverable in one click whereas "nothing" looks like a broken install.
5212
+ */
5213
+ const allow = enabled === void 0 || enabled.length === 0 ? void 0 : new Set(enabled);
5200
5214
  const images = this.selection.imageModelIds;
5201
5215
  const imageSet = images === void 0 ? void 0 : new Set(images);
5202
5216
  const budgets = this.selection.contextBudgets;
@@ -22696,7 +22710,17 @@ function apply(ctx, config = {}) {
22696
22710
  ...contextBudgets === void 0 ? {} : { contextBudgets }
22697
22711
  };
22698
22712
  const fallbackSelection = (region) => {
22699
- return legacySelection.enabledModelIds === void 0 && legacySelection.imageModelIds === void 0 && legacySelection.contextBudgets === void 0 ? core.catalogs[region].currentSelection() : legacySelection;
22713
+ /**
22714
+ * An empty ARRAY counts as absent here too.
22715
+ *
22716
+ * The legacy keys may be present but empty: a host that initialises
22717
+ * `enabledModelIds: []` before the picker is first used (DSH 0.2.2-rc.1 does) makes
22718
+ * "the key exists" a very different statement from "the user chose models". Reading
22719
+ * `[]` as a real selection narrowed the catalog to zero models — the `has no
22720
+ * configured model "<id>"` report in issue #122.
22721
+ */
22722
+ const list = legacySelection.enabledModelIds;
22723
+ return (list === void 0 || list.length === 0) && legacySelection.imageModelIds === void 0 && legacySelection.contextBudgets === void 0 ? core.catalogs[region].currentSelection() : legacySelection;
22700
22724
  };
22701
22725
  core.catalogs.cn.applySelection(modelSelectionCn ?? fallbackSelection("cn"));
22702
22726
  core.catalogs.global.applySelection(modelSelectionGlobal ?? fallbackSelection("global"));
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 13 vendors by QR/web, aggregate 76 vendors' free tiers, plus a usage dashboard, model routing, a local OpenAI-compatible gateway and a points-automation suite.",
5
- "version": "2.6.3",
5
+ "version": "2.6.5",
6
6
  "license": "MIT",
7
7
  "author": "XDTrees",
8
8
  "homepage": "https://github.com/XDTrees/dsh-xdpool#readme",
@@ -51,14 +51,16 @@
51
51
  "README.md",
52
52
  "README.en.md",
53
53
  "CHANGELOG.md",
54
- "LICENSE"
54
+ "LICENSE",
55
+ "scripts"
55
56
  ],
56
57
  "scripts": {
57
58
  "build": "tsdown",
58
59
  "prepublishOnly": "tsdown",
59
60
  "test": "vitest run",
60
61
  "typecheck": "tsc -p tsconfig.json --noEmit",
61
- "typecheck:client": "tsc -p tsconfig.client.json --noEmit"
62
+ "typecheck:client": "tsc -p tsconfig.client.json --noEmit",
63
+ "postinstall": "node scripts/link-host-peers.mjs"
62
64
  },
63
65
  "dsh": {
64
66
  "bundle": {
@@ -131,4 +133,4 @@
131
133
  "optional": true
132
134
  }
133
135
  }
134
- }
136
+ }
@@ -0,0 +1,261 @@
1
+ /**
2
+ * Link the host-provided peer dependencies into this package's node_modules.
3
+ *
4
+ * WHY THIS EXISTS
5
+ *
6
+ * Seven of this plugin's dependencies are `peerDependencies`: the host supplies them, not
7
+ * npm. A manual copy of the package into `node_modules/dsh-xdpool` resolved them by walking
8
+ * up into the host's tree, so nothing was ever missing. Installing normally breaks that
9
+ * walk, and a top-level import failure prevents `apply()` from ever running — so EVERY web
10
+ * route is unregistered and the card renders empty while blaming the gateway.
11
+ *
12
+ * WHAT IT MAY NOT DO: FAIL THE INSTALL
13
+ *
14
+ * The script links what it can find and then stops. It does not exit non-zero when the
15
+ * host cannot be located, for a reason that two bug reports made concrete:
16
+ *
17
+ * - A PACKAGED host keeps its dependencies inside `app.asar`, and `fs.existsSync` in a
18
+ * plain Node process cannot see inside an asar archive — only Electron's patched `fs`
19
+ * can. So "not found" from here often means "invisible to this process", not "absent".
20
+ * - The host resolves these peers itself at runtime. 2.6.3 shipped with no postinstall at
21
+ * all and loaded fine on macOS for exactly that reason.
22
+ *
23
+ * The previous version treated a failed probe as proof of a broken install and exited 1,
24
+ * which made the plugin manager roll back a working upgrade. That is the worst outcome
25
+ * available: the user loses the new version to protect against a problem they did not have.
26
+ *
27
+ * So the contract is now: link when the host is reachable, otherwise say what was not
28
+ * found and finish successfully. Only an actual failure to CREATE a link is reported, and
29
+ * even then as a warning — the plugin may still load through the host's own resolution.
30
+ *
31
+ * HOW RESOLUTION IS CHECKED
32
+ *
33
+ * With ESM, not CJS. `@earendil-works/pi-ai` is ESM-only: its `exports` map has `types` and
34
+ * `import` but no `require` and no `./package.json` subpath. A `require.resolve()` of it
35
+ * throws ERR_PACKAGE_PATH_NOT_EXPORTED even when the package is installed and importable,
36
+ * which is precisely the false negative the reporter hit. `import.meta.resolve` asks the
37
+ * question the plugin will actually ask.
38
+ *
39
+ * @module dsh-xdpool/scripts/link-host-peers
40
+ */
41
+ import { existsSync, mkdirSync, readFileSync, rmSync, symlinkSync } from 'node:fs'
42
+ import { dirname, join, resolve } from 'node:path'
43
+ import { fileURLToPath, pathToFileURL } from 'node:url'
44
+
45
+ const HERE = dirname(fileURLToPath(import.meta.url))
46
+ const PACKAGE_ROOT = resolve(HERE, '..')
47
+ const ENTRY_URL = pathToFileURL(join(PACKAGE_ROOT, 'lib', 'index.js')).href
48
+
49
+ /** The peer dependencies this plugin imports at runtime. */
50
+ function peerNames() {
51
+ const manifest = JSON.parse(readFileSync(join(PACKAGE_ROOT, 'package.json'), 'utf8'))
52
+ return Object.keys(manifest.peerDependencies ?? {})
53
+ }
54
+
55
+ /**
56
+ * Can the plugin resolve `name` from its own entry point?
57
+ *
58
+ * `import.meta.resolve` answers with ESM conditions, which is what the plugin uses. It
59
+ * never throws for a missing package in current Node — it returns a URL that may not
60
+ * exist — so the answer is checked for existence as well.
61
+ *
62
+ * A `data:` or `node:` result is not a real package file and is treated as unresolved.
63
+ */
64
+ function resolvesFromEntry(name) {
65
+ try {
66
+ const url = import.meta.resolve(name, ENTRY_URL)
67
+ if (typeof url !== 'string' || url === '') return undefined
68
+ if (url.startsWith('node:') || url.startsWith('data:')) return undefined
69
+ return fileURLToPath(url)
70
+ } catch {
71
+ return undefined
72
+ }
73
+ }
74
+
75
+ /**
76
+ * The package directory for `name`, whether or not it can be imported right now.
77
+ *
78
+ * The physical check comes FIRST because it is the only one that works for an ESM-only
79
+ * package whose `exports` map omits `./package.json`: `require.resolve(`${name}/package.json`)`
80
+ * throws ERR_PACKAGE_PATH_NOT_EXPORTED for `pi-ai` even with the package sitting on disk.
81
+ * That false negative used to send an already-linked peer back into the missing list, so a
82
+ * second `postinstall` run re-linked what it had just built.
83
+ */
84
+ function locate(name) {
85
+ // 1. On disk under this package's own node_modules — a junction we made earlier counts.
86
+ const physical = join(PACKAGE_ROOT, 'node_modules', name)
87
+ if (existsSync(join(physical, 'package.json'))) return physical
88
+ // 2. Whatever ESM resolves from the entry, which is the real question.
89
+ const resolved = resolvesFromEntry(name)
90
+ if (resolved !== undefined) {
91
+ // Walk up to the package root: the first directory named like the package.
92
+ const wanted = name.startsWith('@') ? name.split('/')[1] : name
93
+ let dir = dirname(resolved)
94
+ while (dir !== dirname(dir)) {
95
+ if (dir.endsWith(`/${wanted}`) || dir.endsWith(`\\${wanted}`)) return dir
96
+ dir = dirname(dir)
97
+ }
98
+ return dirname(resolved)
99
+ }
100
+ return undefined
101
+ }
102
+
103
+ /**
104
+ * Candidate host module roots.
105
+ *
106
+ * The host SPLITS its tree — `cordis` and the `@deepseek-ai/*` runtime in one place,
107
+ * `pi-ai` in another — so several roots are tried rather than one.
108
+ *
109
+ * `DSH_HOST_ROOT` is honoured when set, but note it is NOT injected by the host: two
110
+ * reporters verified that the plugin manager does not pass it. It exists for an operator
111
+ * who wants to point at a specific tree by hand.
112
+ *
113
+ * On a packaged install most of this is unverifiable from a plain Node process, because the
114
+ * dependencies live inside `app.asar` and `existsSync` cannot see in. That is expected and
115
+ * is why a miss is not an error.
116
+ */
117
+ function hostRoots() {
118
+ const roots = []
119
+ const env = process.env['DSH_HOST_ROOT']
120
+ if (typeof env === 'string' && env !== '') roots.push(env)
121
+ // When the host loads the plugin from inside its own tree.
122
+ roots.push(resolve(PACKAGE_ROOT, '..'))
123
+ roots.push(resolve(PACKAGE_ROOT, '..', '..', '..'))
124
+ /**
125
+ * Derived from the running executable, which is the only signal that survives a
126
+ * non-default install drive — the reporter's harness sat on `F:` while every hard-coded
127
+ * guess pointed at `C:`. `process.execPath` is the Node or Electron binary doing the
128
+ * install, which for the bundled runtime lives inside the harness directory.
129
+ */
130
+ for (const up of [1, 2, 3, 4, 5]) {
131
+ const segments = [process.execPath]
132
+ for (let i = 0; i < up; i += 1) segments.push('..')
133
+ const base = resolve(...segments)
134
+ for (const app of ['app', join('app', 'dsh')]) {
135
+ roots.push(join(base, 'resources', app, 'node_modules'))
136
+ }
137
+ roots.push(join(base, 'node_modules'))
138
+ }
139
+ for (const base of HARNESS_BASES) {
140
+ if (typeof base !== 'string' || base === '') continue
141
+ for (const app of ['app', join('app', 'dsh')]) {
142
+ roots.push(join(base, 'resources', app, 'node_modules'))
143
+ }
144
+ }
145
+ return [...new Set(roots)]
146
+ }
147
+
148
+ /**
149
+ * Where a DSH install commonly sits, per platform.
150
+ *
151
+ * Every entry is a guess and a miss is silent, which is what makes listing several
152
+ * acceptable. `HARNESS_BASES` used to be Windows-only — the macOS reporter's whole
153
+ * `LOCALAPPDATA`/`PROGRAMFILES` loop simply never ran.
154
+ */
155
+ const HARNESS_BASES = [
156
+ process.env['DSH_HARNESS_ROOT'],
157
+ // macOS: /Applications/DeepSeek Harness.app/Contents/Resources
158
+ '/Applications/DeepSeek Harness.app/Contents/Resources',
159
+ join(process.env['HOME'] ?? '', 'Applications', 'DeepSeek Harness.app', 'Contents', 'Resources'),
160
+ // Linux
161
+ join(process.env['HOME'] ?? '', '.local', 'share', 'deepseek-harness'),
162
+ '/opt/DeepSeek Harness',
163
+ // Windows
164
+ typeof process.env['LOCALAPPDATA'] === 'string' ? join(process.env['LOCALAPPDATA'], 'Programs', 'DeepSeek Harness') : undefined,
165
+ typeof process.env['LOCALAPPDATA'] === 'string' ? join(process.env['LOCALAPPDATA'], 'DeepSeek Harness') : undefined,
166
+ typeof process.env['ProgramW6432'] === 'string' ? process.env['ProgramW6432'] : undefined,
167
+ typeof process.env['PROGRAMFILES'] === 'string' ? process.env['PROGRAMFILES'] : undefined,
168
+ ]
169
+
170
+ /** Whether this is a source checkout rather than an installed package. */
171
+ const IS_SOURCE_CHECKOUT = existsSync(join(PACKAGE_ROOT, 'src'))
172
+
173
+ const linked = []
174
+ const alreadyResolved = []
175
+ const notFound = []
176
+ const failed = []
177
+
178
+ for (const name of peerNames()) {
179
+ // Already resolvable: leave it alone. Someone who installed a peer deliberately keeps
180
+ // control, and re-linking would overwrite that choice. This check is also what makes the
181
+ // script idempotent — a second run must not rebuild links it made the first time.
182
+ if (locate(name) !== undefined) { alreadyResolved.push(name); continue }
183
+ let target
184
+ for (const root of hostRoots()) {
185
+ const candidate = join(root, name)
186
+ // `existsSync` cannot see inside `app.asar`; on a packaged host this simply misses and
187
+ // the peer is reported as not found, which is no longer fatal.
188
+ if (existsSync(join(candidate, 'package.json'))) { target = candidate; break }
189
+ }
190
+ if (target === undefined) { notFound.push(name); continue }
191
+ const dest = join(PACKAGE_ROOT, 'node_modules', name)
192
+ try {
193
+ mkdirSync(dirname(dest), { recursive: true })
194
+ // A previous run may have left a link (or a partial one); replacing it is correct
195
+ // because the resolve check above already skipped anything that works.
196
+ if (existsSync(dest)) rmSync(dest, { recursive: true, force: true })
197
+ // Junction on Windows because creating a real symlink needs elevation there; a
198
+ // junction needs none and behaves the same for directory reads.
199
+ symlinkSync(target, dest, process.platform === 'win32' ? 'junction' : 'dir')
200
+ linked.push(`${name} → ${target}`)
201
+ } catch (error) {
202
+ failed.push(`${name} (${error instanceof Error ? error.message : String(error)})`)
203
+ }
204
+ }
205
+
206
+ if (linked.length > 0) {
207
+ process.stdout.write(`dsh-xdpool: linked ${String(linked.length)} host dependency(ies)\n`)
208
+ for (const line of linked) process.stdout.write(` ${line}\n`)
209
+ }
210
+ if (alreadyResolved.length > 0 && linked.length === 0) {
211
+ process.stdout.write(`dsh-xdpool: all ${String(alreadyResolved.length)} peer dependencies already resolve\n`)
212
+ }
213
+
214
+ /**
215
+ * Report, and deliberately do not fail.
216
+ *
217
+ * A packaged host hides these inside `app.asar` (invisible to a bare Node process) and
218
+ * resolves them itself at runtime — 2.6.3 shipped with no postinstall and loaded fine. So
219
+ * "not found from here" is not evidence of a broken install, and exiting non-zero on it
220
+ * rolled back working upgrades for macOS and Windows users alike.
221
+ */
222
+ if (notFound.length > 0) {
223
+ process.stdout.write(
224
+ `dsh-xdpool: ${String(notFound.length)} peer dependency(ies) not visible from this process:\n`
225
+ + notFound.map(name => ` ${name}\n`).join('')
226
+ + (IS_SOURCE_CHECKOUT
227
+ ? 'Expected in a source checkout: build and test resolve them from devDependencies.\n'
228
+ : 'This is normal for a packaged host, which keeps them inside app.asar and resolves\n'
229
+ + 'them itself at runtime. Set DSH_HOST_ROOT to a directory containing node_modules\n'
230
+ + 'only if the plugin later fails to load.\n'),
231
+ )
232
+ }
233
+ if (failed.length > 0) {
234
+ // A link that could not be CREATED is a real problem, but still not fatal: the host may
235
+ // resolve the peer without our help. Worth a warning, not a rollback.
236
+ process.stdout.write(
237
+ `dsh-xdpool: could not link ${String(failed.length)} dependency(ies):\n`
238
+ + failed.map(name => ` ${name}\n`).join(''),
239
+ )
240
+ }
241
+
242
+ /**
243
+ * Final self-check, phrased as the plugin would phrase it.
244
+ *
245
+ * Uses ESM resolution rather than CJS: `pi-ai` is ESM-only with no `require` condition and
246
+ * no `./package.json` subpath, so a `require.resolve` of it throws
247
+ * ERR_PACKAGE_PATH_NOT_EXPORTED while the package sits there fully importable. That false
248
+ * negative is what made 2.6.4 uninstallable on Windows.
249
+ *
250
+ * An unresolved peer is reported and the script still exits 0, for the asar reason above.
251
+ */
252
+ const unresolved = peerNames().filter(name => locate(name) === undefined)
253
+ if (unresolved.length === 0) {
254
+ process.stdout.write('dsh-xdpool: all peer dependencies resolve; the build should load\n')
255
+ } else {
256
+ process.stdout.write(
257
+ `dsh-xdpool: ${String(unresolved.length)} peer dependency(ies) do not resolve here: `
258
+ + `${unresolved.join(', ')}\n`
259
+ + ' Not treated as an install failure — see the note above.\n',
260
+ )
261
+ }
@@ -36894,7 +36894,19 @@ var LobsteraiAdapter = class extends LlmAdapter3 {
36894
36894
  */
36895
36895
  providerInfo(provider) {
36896
36896
  const id = typeof provider === "string" && provider.length > 0 ? provider : this.product.id;
36897
- return { id, name: this.product.displayName };
36897
+ // [xdpool-local] Present this lane under the name the rest of the plugin uses.
36898
+ //
36899
+ // `channels.ts` (REGISTERED_CHANNELS), `region-card.tsx` and
36900
+ // `ChannelPoolSection.tsx` all call this lane 「WorkBuddy 国内版」, while the
36901
+ // vendor product constant still carries the upstream name "CodeBuddy (腾讯)".
36902
+ // One lane rendered under two names in one product is issue #119: the pool card
36903
+ // and the model picker disagreed about which product the user had signed in to.
36904
+ //
36905
+ // Overridden at the PRESENTATION layer rather than in the constant, because
36906
+ // `throwIfAllAccountsRateLimited` also reads `product.displayName` for its error
36907
+ // text; changing the constant would silently rewrite those messages too.
36908
+ const name = id === "buddy" ? "WorkBuddy 国内版" : this.product.displayName;
36909
+ return { id, name };
36898
36910
  }
36899
36911
  /**
36900
36912
  * 懒加载远端模型目录(仅拉取一次)。