heybash-xdpool 1.0.2 → 1.0.4

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,5 +1,18 @@
1
1
  # Heybash
2
2
 
3
+ ## 1.0.4 — WorkBuddy 模型去重与镜像同步
4
+
5
+ - 模型选择器统一使用 WorkBuddy 地区名称;同一区域的渠道模型与账号池模型重复时只显示一份,保留历史渠道调用。
6
+ - 正式发布后检查并同步国内 npm 镜像,降低团队成员看不到新版本的情况。
7
+
8
+ ## 1.0.3 — 路由上下文与模型显示修复
9
+
10
+ - 路由链按各渠道声明的实际上下文窗口计算安全下限;渠道未声明或数据无效时继续采用保守值,避免不必要的频繁压缩。
11
+ - 插件界面版本号在构建时读取包版本,避免更新后仍显示旧版本。
12
+ - 路由链展示最终上下文窗口,编辑成员时显示保存后的容量预览。
13
+ - 没有账号的地区不再显示无法使用的备用模型;账号状态改变后同步更新模型列表。
14
+ - 修复服务端与客户端开发时的类型检查错误。
15
+
3
16
  ## 1.0.2 — 路由与安装兼容修复
4
17
 
5
18
  - 安装时不再自动运行依赖链接脚本,避免 pnpm 严格脚本审批阻断插件安装或升级;脚本仍可在需要排查宿主依赖时手动运行。
package/README.en.md CHANGED
@@ -112,7 +112,7 @@ After editing source, rebuild and update the installed plugin, then fully quit a
112
112
 
113
113
  The package does not run a dependency-linking script during installation. DeepSeek Harness normally supplies the shared dependencies; if a particular environment cannot resolve them, run `node scripts/link-host-peers.mjs` manually from the installed package to troubleshoot.
114
114
 
115
- The account pools appear as **Heybash(国内版)** and **Heybash(国际版)**; the optional free-model group is **Heybash · 免费模型**.
115
+ The account pools appear as **WorkBuddy 国内版** and **WorkBuddy 国际版**; the optional free-model group is **Heybash · 免费模型**. Channel models already offered by the same regional pool are shown once; existing channel routes remain available to saved conversations.
116
116
 
117
117
  ## Upgrading from an older version
118
118
 
package/README.md CHANGED
@@ -115,7 +115,7 @@ dsh plugin --profile desktop add "file:/你的项目路径/dsh-xdpool-fork"
115
115
 
116
116
  安装包不自动执行依赖链接脚本。通常由 DeepSeek Harness 提供插件所需的共享依赖;如特殊环境出现依赖无法解析,可手动运行安装目录下的 `node scripts/link-host-peers.mjs` 进行排查。
117
117
 
118
- 模型选择器中的账号池分别显示为 **Heybash(国内版)**、**Heybash(国际版)**,免费模型分组显示为 **Heybash · 免费模型**。
118
+ 模型选择器中的账号池分别显示为 **WorkBuddy 国内版**、**WorkBuddy 国际版**,免费模型分组显示为 **Heybash · 免费模型**。同一区域中与账号池重复的渠道模型只展示一次,原有渠道标识仍可用于已有会话。
119
119
 
120
120
  ## 从旧版升级
121
121
 
package/lib/client.js CHANGED
@@ -9844,6 +9844,10 @@ window.__ModuleLoader__.load({
9844
9844
  }
9845
9845
  }));
9846
9846
  loadConnected().catch(() => {});
9847
+ if (channel.id === "buddy" || channel.id === "workbuddy") fetch(POOL_RESCAN_PATH, {
9848
+ method: "POST",
9849
+ credentials: "same-origin"
9850
+ }).catch(() => {});
9847
9851
  };
9848
9852
  timers.current.set(channel.id, window.setInterval(() => {
9849
9853
  tick();
@@ -10110,8 +10114,7 @@ window.__ModuleLoader__.load({
10110
10114
  *
10111
10115
  * Split out of {@link ./PoolCard} for the same reason as the aggregate page: it
10112
10116
  * reads its own document (`POOL_COMBOS_PATH`) and must not ride the pool card's
10113
- * 30-second poll, because a routing document only changes when this page writes
10114
- * it.
10117
+ * 30-second poll. Opening the page or saving chains reads its own document.
10115
10118
  *
10116
10119
  * Two deliberate honesty choices, both about not lying to the user:
10117
10120
  *
@@ -10217,6 +10220,11 @@ window.__ModuleLoader__.load({
10217
10220
  if (value >= 1e3) return `${Math.round(value / 100) / 10}K`;
10218
10221
  return String(value);
10219
10222
  }
10223
+ /** Match the server's minimum over members it can currently resolve. */
10224
+ function draftContextWindow(models, candidates) {
10225
+ const windows = models.map((id) => candidates.get(id)?.contextWindow).filter((value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0);
10226
+ return windows.length === 0 ? void 0 : Math.min(...windows);
10227
+ }
10220
10228
  function RoutingPage({ t }) {
10221
10229
  const [status, setStatus] = (0, react.useState)(void 0);
10222
10230
  const [error, setError] = (0, react.useState)(void 0);
@@ -10380,6 +10388,10 @@ window.__ModuleLoader__.load({
10380
10388
  children: [drafts.map((draft) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChainRow, {
10381
10389
  draft,
10382
10390
  editable: draft.key === editing,
10391
+ preview: draft.key === editing || (() => {
10392
+ const saved = combos.find((combo) => combo.id === draft.id);
10393
+ return saved === void 0 || JSON.stringify(draft.flat) !== JSON.stringify(draftOf(saved).flat);
10394
+ })(),
10383
10395
  candidateById,
10384
10396
  t,
10385
10397
  onEdit: () => {
@@ -10413,7 +10425,7 @@ window.__ModuleLoader__.load({
10413
10425
  * the roster lost instead of quietly presenting a shorter chain than the user
10414
10426
  * typed.
10415
10427
  */
10416
- function ChainRow({ draft, editable, candidateById, t, onEdit, onDelete }) {
10428
+ function ChainRow({ draft, editable, preview, candidateById, t, onEdit, onDelete }) {
10417
10429
  /**
10418
10430
  * Members the roster cannot serve right now, computed from the FLATTENED draft.
10419
10431
  *
@@ -10423,6 +10435,8 @@ window.__ModuleLoader__.load({
10423
10435
  */
10424
10436
  const flat = draft.flat;
10425
10437
  const missing = flat.filter((model) => candidateById.has(model) === false);
10438
+ const window = draftContextWindow(flat, candidateById);
10439
+ const windowText = window === void 0 ? "—" : compact(window);
10426
10440
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10427
10441
  className: "dsm-xdpool-rt-row",
10428
10442
  "data-off": draft.enabled ? "false" : "true",
@@ -10445,15 +10459,24 @@ window.__ModuleLoader__.load({
10445
10459
  }),
10446
10460
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
10447
10461
  className: "dsm-xdpool-pills",
10448
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10449
- className: "dsm-xdpool-pill",
10450
- "data-tone": "off",
10451
- children: t?.("route.platformCount", { count: draft.platforms.length }) ?? `${draft.platforms.length} platform(s)`
10452
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10453
- className: "dsm-xdpool-pill",
10454
- "data-tone": "off",
10455
- children: t?.("route.memberCount", { count: flat.length }) ?? `${flat.length} model(s)`
10456
- })]
10462
+ children: [
10463
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10464
+ className: "dsm-xdpool-pill",
10465
+ "data-tone": "off",
10466
+ children: t?.("route.platformCount", { count: draft.platforms.length }) ?? `${draft.platforms.length} platform(s)`
10467
+ }),
10468
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10469
+ className: "dsm-xdpool-pill",
10470
+ "data-tone": "off",
10471
+ children: t?.("route.memberCount", { count: flat.length }) ?? `${flat.length} model(s)`
10472
+ }),
10473
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10474
+ className: "dsm-xdpool-pill",
10475
+ "data-tone": "off",
10476
+ title: t?.("route.contextHint") ?? "Smallest context window among currently available members.",
10477
+ children: preview ? t?.("route.contextPreview", { tokens: windowText }) ?? `Context preview ${windowText} (save to apply)` : t?.("route.contextWindow", { tokens: windowText }) ?? `Context ${windowText}`
10478
+ })
10479
+ ]
10457
10480
  }),
10458
10481
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
10459
10482
  className: "dsm-xdpool-pageactions",
@@ -13270,20 +13293,8 @@ window.__ModuleLoader__.load({
13270
13293
  });
13271
13294
  }
13272
13295
  // src/version.ts
13273
- /**
13274
- * The plugin's own version, hand-maintained for the browser bundle.
13275
- *
13276
- * The card ships as `lib/client.js`, served to the host dialog as a browser
13277
- * script: `package.json` is neither reachable nor guaranteed to be the file
13278
- * the running build came from. A manifest lying next to the code is worse than
13279
- * a number a test keeps honest.
13280
- *
13281
- * `tests/version-sync.test.ts` fails when this drifts from `package.json`, so
13282
- * the release checklist cannot ship a card that calls itself the wrong version.
13283
- *
13284
- * @module dsh-xdpool/version
13285
- */
13286
- const POOL_VERSION = "1.0.0";
13296
+ /** Version embedded in the browser bundle at build time from the package manifest. */
13297
+ const POOL_VERSION = "1.0.4";
13287
13298
  // src/client/PoolCard.tsx
13288
13299
  /**
13289
13300
  * Heybash card contributed to DSH Plugin configuration.
@@ -16742,6 +16753,9 @@ window.__ModuleLoader__.load({
16742
16753
  "route.usable": "ready",
16743
16754
  "route.unusable": "needs a key",
16744
16755
  "route.memberCount": "{count} member(s)",
16756
+ "route.contextWindow": "Context {tokens}",
16757
+ "route.contextPreview": "Context preview {tokens} (save to apply)",
16758
+ "route.contextHint": "The smallest context window among currently available members.",
16745
16759
  "route.capacity": "{tokens} tokens",
16746
16760
  "route.images": "images",
16747
16761
  "route.missing": "Not available right now: {models}",
@@ -17327,6 +17341,9 @@ window.__ModuleLoader__.load({
17327
17341
  "route.usable": "可用",
17328
17342
  "route.unusable": "缺 key",
17329
17343
  "route.memberCount": "{count} 个成员",
17344
+ "route.contextWindow": "上下文 {tokens}",
17345
+ "route.contextPreview": "上下文预览 {tokens}(保存后生效)",
17346
+ "route.contextHint": "按当前可用成员中最小的上下文窗口计算。",
17330
17347
  "route.capacity": "{tokens} tokens",
17331
17348
  "route.images": "看图",
17332
17349
  "route.missing": "这些成员暂时不在册:{models}",
package/lib/index.d.ts CHANGED
@@ -2736,6 +2736,7 @@ interface HostModelRow {
2736
2736
  channel: string;
2737
2737
  modelId: string;
2738
2738
  name: string;
2739
+ contextWindow?: number;
2739
2740
  supportsImages?: boolean;
2740
2741
  supportedEfforts?: readonly string[];
2741
2742
  }
@@ -3105,6 +3106,7 @@ interface ChannelLaneRow {
3105
3106
  channel: string;
3106
3107
  modelId: string;
3107
3108
  name: string;
3109
+ contextWindow?: number;
3108
3110
  supportsImages?: boolean;
3109
3111
  supportedEfforts?: readonly string[];
3110
3112
  }
@@ -3336,6 +3338,8 @@ interface WorkBuddyAdapterOptions {
3336
3338
  ctx: Context$1;
3337
3339
  providerId?: string;
3338
3340
  displayName?: string;
3341
+ /** Whether this region currently has any account; absent for non-pool adapters. */
3342
+ hasAccount?: (() => boolean) | undefined;
3339
3343
  /**
3340
3344
  * The rows this provider serves, when it is a LATER lane rather than a pool.
3341
3345
  *
@@ -4147,6 +4151,8 @@ export declare function writePreferredId(accountId: string | undefined, path?: s
4147
4151
  /** Constructor dependencies — a narrow slice of the pool runtime. */
4148
4152
  interface PoolStatusRouteOptions {
4149
4153
  pool: WorkBuddyAccountPool;
4154
+ /** Re-announce models after a rescan changes region availability. */
4155
+ onPoolChanged?: () => void;
4150
4156
  /** One catalog per region; the card reads the one for its active tab. */
4151
4157
  catalogs: Readonly<Record<PoolRegion, WorkBuddyCatalog>>;
4152
4158
  client: WorkBuddyUpstreamClient;
package/lib/index.js CHANGED
@@ -11181,7 +11181,7 @@ function resolveComboMember(modelId, sources) {
11181
11181
  host: true,
11182
11182
  channel: hostRow.channel,
11183
11183
  name: hostRow.name,
11184
- contextWindow: COMBO_DEFAULT_CONTEXT_WINDOW,
11184
+ contextWindow: Number.isSafeInteger(hostRow.contextWindow) && hostRow.contextWindow > 0 ? hostRow.contextWindow : COMBO_DEFAULT_CONTEXT_WINDOW,
11185
11185
  maxOutputTokens: COMBO_DEFAULT_MAX_OUTPUT,
11186
11186
  supportsImages: hostRow.supportsImages === true,
11187
11187
  ...hostRow.supportedEfforts === void 0 ? {} : { supportedEfforts: hostRow.supportedEfforts }
@@ -13232,14 +13232,14 @@ const POOL_PROVIDER_BY_REGION = {
13232
13232
  /**
13233
13233
  * Display name each region registers under, so the picker can group them.
13234
13234
  *
13235
- * The regional suffix distinguishes the two Heybash account pools.
13235
+ * The regional suffix distinguishes the two WorkBuddy account pools.
13236
13236
  *
13237
13237
  * Display name only. The provider ids above are what the host matches on when it
13238
13238
  * persists a selection, so renaming a group must never touch them.
13239
13239
  */
13240
13240
  const POOL_NAME_BY_REGION = {
13241
- cn: "Heybash(国内版)",
13242
- global: "Heybash(国际版)"
13241
+ cn: "WorkBuddy 国内版",
13242
+ global: "WorkBuddy 国际版"
13243
13243
  };
13244
13244
  /** Provider idle ceiling while one stream read is outstanding. */
13245
13245
  const WORKBUDDY_STREAM_IDLE_TIMEOUT_MS = 3e5;
@@ -13279,6 +13279,10 @@ const NO_COST = {
13279
13279
  cacheRead: 0,
13280
13280
  cacheWrite: 0
13281
13281
  };
13282
+ /** Keep catalog and preferences intact while hiding a region with no accounts. */
13283
+ function visiblePoolModels(catalog, hasAccount) {
13284
+ return hasAccount ? catalog.visible() : [];
13285
+ }
13282
13286
  function modelInput(info) {
13283
13287
  return info.supportsImages ? ["text", "image"] : ["text"];
13284
13288
  }
@@ -13448,7 +13452,7 @@ function createWorkBuddyAdapter(options) {
13448
13452
  const baseUrl = `${shim.baseUrl()}/v1`;
13449
13453
  if (extraRows !== void 0) return (extraRows() ?? []).map((row) => toExtraLaneModel(row, baseUrl, providerId));
13450
13454
  if (aggregateCatalog) return [...catalog.providerRows().map((row) => toAggregateModel(row, baseUrl, providerId)), ...catalog.comboRows().map((row) => toComboModel(row, baseUrl, providerId))];
13451
- return catalog.visible().map((info) => toPiModel(info, baseUrl, providerId));
13455
+ return visiblePoolModels(catalog, options.hasAccount?.() !== false).map((info) => toPiModel(info, baseUrl, providerId));
13452
13456
  };
13453
13457
  /**
13454
13458
  * Build a fresh provider object whose `models` array is the catalog as it
@@ -18184,7 +18188,9 @@ function registerPoolStatusRoute(ctx, deps) {
18184
18188
  if (req.method !== "POST") return json(res, 405, { error: "method not allowed" });
18185
18189
  if (!loopbackOrigin(req)) return json(res, 403, { error: "origin-not-trusted" });
18186
18190
  try {
18187
- json(res, 200, { accounts: (await deps.pool.scan()).length });
18191
+ const accounts = await deps.pool.scan();
18192
+ deps.onPoolChanged?.();
18193
+ json(res, 200, { accounts: accounts.length });
18188
18194
  } catch (error) {
18189
18195
  json(res, 500, { error: safeMessage(error) });
18190
18196
  }
@@ -19432,7 +19438,7 @@ const LISTING_TTL_MS = 6e4;
19432
19438
  * would pull the pack mount into this module.
19433
19439
  */
19434
19440
  function createChannelLane(options) {
19435
- const { llm, providers, toId, attachments, logger } = options;
19441
+ const { llm, providers, toId, attachments, onRows, logger } = options;
19436
19442
  const cache = /* @__PURE__ */ new Map();
19437
19443
  const inflight = /* @__PURE__ */ new Map();
19438
19444
  const fetchRows = (channel) => {
@@ -19443,8 +19449,11 @@ function createChannelLane(options) {
19443
19449
  const tracked = llm.listModels(channel).then((models) => Promise.all(models.map(async (model) => {
19444
19450
  let supportedEfforts;
19445
19451
  let supportsImages;
19452
+ let contextWindow;
19446
19453
  if (llm.resolveModelInfo !== void 0) try {
19447
19454
  const info = await llm.resolveModelInfo(channel, model.id);
19455
+ const declaredWindow = info.context?.contextWindow;
19456
+ if (Number.isSafeInteger(declaredWindow) && declaredWindow > 0) contextWindow = declaredWindow;
19448
19457
  if (Array.isArray(info.inputModalities)) supportsImages = info.inputModalities.includes("image");
19449
19458
  supportedEfforts = [...new Set((info.reasoning?.efforts ?? []).map((effort) => effort.id === "on" ? "high" : effort.id))];
19450
19459
  } catch {}
@@ -19453,6 +19462,7 @@ function createChannelLane(options) {
19453
19462
  channel,
19454
19463
  modelId: model.id,
19455
19464
  name: model.name ?? model.id,
19465
+ ...contextWindow === void 0 ? {} : { contextWindow },
19456
19466
  ...supportsImages === void 0 ? {} : { supportsImages },
19457
19467
  ...supportedEfforts === void 0 ? {} : { supportedEfforts }
19458
19468
  };
@@ -19471,7 +19481,11 @@ function createChannelLane(options) {
19471
19481
  return tracked;
19472
19482
  };
19473
19483
  return {
19474
- rows: async () => (await Promise.all(providers().map(fetchRows))).flat(),
19484
+ rows: async () => {
19485
+ const rows = (await Promise.all(providers().map(fetchRows))).flat();
19486
+ await onRows?.(rows);
19487
+ return rows;
19488
+ },
19475
19489
  resolve: (id) => {
19476
19490
  const separator = id.indexOf(":");
19477
19491
  if (separator <= 0 || separator === id.length - 1) return void 0;
@@ -20457,6 +20471,11 @@ function createWorkBuddyShim(options) {
20457
20471
  aggregate: aggregate === void 0 ? [] : aggregate.catalog.providerRows(),
20458
20472
  host: channels === void 0 ? [] : await channels.rows()
20459
20473
  };
20474
+ const refreshed = aggregate?.catalog.findCombo(row.id);
20475
+ if (refreshed !== void 0 && refreshed.contextWindow < row.contextWindow) {
20476
+ writeOpenAIError(res, 400, "context_length_exceeded", `chain ${row.id}: model context window changed from ${row.contextWindow} to ${refreshed.contextWindow}; retry with the refreshed context limit`);
20477
+ return;
20478
+ }
20460
20479
  let members = comboChain(row).map((modelId) => resolveComboMember(modelId, sources)).filter((member) => member !== void 0);
20461
20480
  const body = JSON.parse(raw);
20462
20481
  if (Array.isArray(body.messages) && body.messages.some((message) => Array.isArray(message.content) && message.content.some((part) => typeof part === "object" && part !== null && [
@@ -22474,7 +22493,7 @@ function combosStatusOf(store, catalog, poolRows, hostRows = []) {
22474
22493
  name: row.name,
22475
22494
  owner: row.channel,
22476
22495
  usable: true,
22477
- contextWindow: COMBO_DEFAULT_CONTEXT_WINDOW,
22496
+ contextWindow: Number.isSafeInteger(row.contextWindow) && row.contextWindow > 0 ? row.contextWindow : COMBO_DEFAULT_CONTEXT_WINDOW,
22478
22497
  supportsImages: row.supportsImages === true,
22479
22498
  siblings: []
22480
22499
  }))
@@ -22982,6 +23001,7 @@ function apply(ctx, config = {}) {
22982
23001
  if (storedLedger !== void 0) core.scheduler.applyEarningsLedger(storedLedger);
22983
23002
  const usageRecorder = new UsageRecorder();
22984
23003
  let hostRosterCache = [];
23004
+ let appliedHostRoster = "[]";
22985
23005
  const aggregateCatalog = new AggregateCatalog(() => readAggregateSettingsSync(), () => core.catalogs.cn.current(), () => hostRosterCache);
22986
23006
  aggregateCatalog.refresh();
22987
23007
  ctx.on("llm/stream", (options, next) => recoverCompactionStream(options, next, {
@@ -23018,6 +23038,17 @@ function apply(ctx, config = {}) {
23018
23038
  */
23019
23039
  const channelLane = createChannelLane({
23020
23040
  llm: ctx.llm,
23041
+ onRows: async (rows) => {
23042
+ const snapshot = JSON.stringify(rows);
23043
+ if (snapshot === appliedHostRoster) return;
23044
+ hostRosterCache = rows;
23045
+ try {
23046
+ await aggregateCatalog.refresh();
23047
+ if (hostRosterCache === rows) appliedHostRoster = snapshot;
23048
+ } catch (error) {
23049
+ ctx.logger?.warn?.("heybash-xdpool: could not refresh channel capabilities:", error);
23050
+ }
23051
+ },
23021
23052
  providers: () => REGISTERED_CHANNELS.map((channel) => channel.id).filter((id) => channelListableAsRows(id, POOL_OWNED_CHANNELS)),
23022
23053
  toId: (channel, modelId) => `${channel}:${modelId}`,
23023
23054
  attachments: () => ctx.get("attachments"),
@@ -23048,14 +23079,7 @@ function apply(ctx, config = {}) {
23048
23079
  */
23049
23080
  const hostRoster = async () => {
23050
23081
  try {
23051
- hostRosterCache = (await channelLane.rows()).map((row) => ({
23052
- id: row.id,
23053
- channel: row.channel,
23054
- modelId: row.modelId,
23055
- name: row.name,
23056
- ...row.supportsImages === void 0 ? {} : { supportsImages: row.supportsImages },
23057
- ...row.supportedEfforts === void 0 ? {} : { supportedEfforts: row.supportedEfforts }
23058
- }));
23082
+ await channelLane.rows();
23059
23083
  } catch (error) {
23060
23084
  ctx.logger?.warn?.("heybash-xdpool: could not list login-channel models:", error);
23061
23085
  }
@@ -23198,6 +23222,7 @@ function apply(ctx, config = {}) {
23198
23222
  };
23199
23223
  ctx.inject(["webServer"], (webCtx) => registerPoolStatusRoute(webCtx, {
23200
23224
  pool: core.pool,
23225
+ onPoolChanged: () => invalidateCatalog(),
23201
23226
  catalogs: core.catalogs,
23202
23227
  client: core.client,
23203
23228
  usage: () => usageRecorder.summary(),
@@ -23231,6 +23256,7 @@ function apply(ctx, config = {}) {
23231
23256
  } else await unignoreAccount(accountId, ignoredPath);
23232
23257
  refreshIgnored();
23233
23258
  if (!ignored) await core.pool.scan();
23259
+ invalidateCatalog();
23234
23260
  },
23235
23261
  ignoredAccounts: () => ignoredAccounts,
23236
23262
  setPreferredAccount: async (accountId) => {
@@ -23475,7 +23501,11 @@ function apply(ctx, config = {}) {
23475
23501
  }) };
23476
23502
  }).finally(() => {
23477
23503
  if (stopped) return;
23478
- adoptChannelPackAccounts(scoped, core.pool, ctx.logger);
23504
+ adoptChannelPackAccounts(scoped, core.pool, ctx.logger).then(() => {
23505
+ if (!stopped) invalidateCatalog();
23506
+ }).catch((error) => {
23507
+ ctx.logger.warn("heybash-xdpool: account adoption failed", error);
23508
+ });
23479
23509
  });
23480
23510
  });
23481
23511
  Promise.all([shims.cn.ready, shims.global.ready]).then(async () => {
@@ -23488,14 +23518,16 @@ function apply(ctx, config = {}) {
23488
23518
  shim: shims.cn,
23489
23519
  catalog: core.catalogs.cn,
23490
23520
  providerId: POOL_PROVIDER_BY_REGION.cn,
23491
- displayName: POOL_NAME_BY_REGION.cn
23521
+ displayName: POOL_NAME_BY_REGION.cn,
23522
+ hasAccount: () => core.pool.list("cn").length > 0
23492
23523
  }),
23493
23524
  global: createWorkBuddyAdapter({
23494
23525
  ctx,
23495
23526
  shim: shims.global,
23496
23527
  catalog: core.catalogs.global,
23497
23528
  providerId: POOL_PROVIDER_BY_REGION.global,
23498
- displayName: POOL_NAME_BY_REGION.global
23529
+ displayName: POOL_NAME_BY_REGION.global,
23530
+ hasAccount: () => core.pool.list("global").length > 0
23499
23531
  }),
23500
23532
  aggregate: createWorkBuddyAdapter({
23501
23533
  ctx,
@@ -23624,7 +23656,7 @@ function apply(ctx, config = {}) {
23624
23656
  }));
23625
23657
  if (request.provider !== "xdpool" && request.provider !== "xdpool-global") return [];
23626
23658
  const region = request.provider === "xdpool-global" ? "global" : "cn";
23627
- return core.catalogs[region].visible().map((model) => ({
23659
+ return visiblePoolModels(core.catalogs[region], core.pool.list(region).length > 0).map((model) => ({
23628
23660
  id: model.id,
23629
23661
  name: model.name,
23630
23662
  contextWindow: model.contextWindow,
@@ -23665,6 +23697,7 @@ function apply(ctx, config = {}) {
23665
23697
  if (stopped) return;
23666
23698
  core.pool.scan().then((accounts) => {
23667
23699
  ctx.logger.info?.(`heybash-xdpool: ${accounts.length} WorkBuddy account(s) in rotation`);
23700
+ invalidateCatalog();
23668
23701
  }, (error) => {
23669
23702
  ctx.logger.warn("heybash-xdpool: account discovery failed", error);
23670
23703
  });
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.2",
5
+ "version": "1.0.4",
6
6
  "license": "MIT",
7
7
  "author": "Heybash",
8
8
  "contributors": [
@@ -55,11 +55,13 @@
55
55
  "README.en.md",
56
56
  "CHANGELOG.md",
57
57
  "LICENSE",
58
- "scripts"
58
+ "scripts",
59
+ "tools/sync-npmmirror.mjs"
59
60
  ],
60
61
  "scripts": {
61
62
  "build": "tsdown",
62
63
  "prepublishOnly": "tsdown",
64
+ "postpublish": "node tools/sync-npmmirror.mjs --published",
63
65
  "test": "vitest run",
64
66
  "typecheck": "tsc -p tsconfig.json --noEmit",
65
67
  "typecheck:client": "tsc -p tsconfig.client.json --noEmit"
@@ -81,6 +83,7 @@
81
83
  },
82
84
  "devDependencies": {
83
85
  "@deepseek-ai/cordis": "4.0.2",
86
+ "@deepseek-ai/dsh-attachment": "0.2.1-rc.4",
84
87
  "@deepseek-ai/dsh-client-locale": "0.2.1-rc.4",
85
88
  "@deepseek-ai/dsh-client-runtime": "0.1.1-rc.2",
86
89
  "@deepseek-ai/dsh-client-ui-primitives": "0.2.1-rc.4",
@@ -93,7 +96,7 @@
93
96
  "@deepseek-ai/dsh-llm-pi-ai": "0.2.1-rc.4",
94
97
  "@deepseek-ai/dsh-settings": "0.2.1-rc.4",
95
98
  "@deepseek-ai/schemastery": "3.18.2",
96
- "@earendil-works/pi-ai": "0.85.1",
99
+ "@earendil-works/pi-ai": "1.5.0",
97
100
  "@types/node": "^26.4.1",
98
101
  "@types/react": "~18.3.31",
99
102
  "@types/react-dom": "~18.3.0",
@@ -105,9 +108,9 @@
105
108
  },
106
109
  "peerDependencies": {
107
110
  "@deepseek-ai/cordis": "^4.0.1-rc.1",
111
+ "@deepseek-ai/dsh-credentials": ">=0.1.1-rc.1 <0.3.0",
108
112
  "@deepseek-ai/dsh-llm": ">=0.1.1-rc.1 <0.3.0",
109
113
  "@deepseek-ai/dsh-llm-pi-ai": ">=0.1.1-rc.1 <0.3.0",
110
- "@deepseek-ai/dsh-credentials": ">=0.1.1-rc.1 <0.3.0",
111
114
  "@deepseek-ai/dsh-settings": ">=0.1.1-rc.1 <0.3.0",
112
115
  "@deepseek-ai/schemastery": "^3.18.1",
113
116
  "@earendil-works/pi-ai": ">=0.82.1"
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env node
2
+ /** Synchronize the public package after npm has made the requested version available. */
3
+ import { pathToFileURL } from 'node:url'
4
+ import { createHash } from 'node:crypto'
5
+
6
+ const NAME = 'heybash-xdpool'
7
+ const NPM = `https://registry.npmjs.org/${NAME}`
8
+ const MIRROR = `https://registry.npmmirror.com/${NAME}`
9
+ const SYNC = `https://registry.npmmirror.com/-/package/${NAME}/syncs`
10
+ const VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u
11
+ const TASK_ID = /^[0-9A-Za-z_-]+$/u
12
+ const MAX_TARBALL_BYTES = 64 * 1024 * 1024
13
+ const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms))
14
+
15
+ async function request(fetchImpl, url, init = {}) {
16
+ const response = await fetchImpl(url, {
17
+ ...init,
18
+ signal: AbortSignal.timeout(15_000),
19
+ })
20
+ if (!response.ok) throw new Error(`${init.method ?? 'GET'} ${new URL(url).hostname}: HTTP ${response.status}`)
21
+ return response
22
+ }
23
+
24
+ async function retry(label, action, { attempts, intervalMs, sleep, log }) {
25
+ let lastError
26
+ for (let i = 0; i < attempts; i++) {
27
+ try { return await action() } catch (error) {
28
+ lastError = error
29
+ log(`${label} (${i + 1}/${attempts}): ${error instanceof Error ? error.message : String(error)}`)
30
+ if (error?.terminal === true) throw error
31
+ if (i + 1 < attempts) await sleep(intervalMs)
32
+ }
33
+ }
34
+ throw new Error(`${label} failed after ${attempts} attempts: ${lastError instanceof Error ? lastError.message : String(lastError)}`)
35
+ }
36
+
37
+ /**
38
+ * Poll the real public registry endpoints without credentials. A matching
39
+ * version, checksum, latest tag and reachable tarball are all required before
40
+ * reporting success. `version` absent means the current official latest.
41
+ */
42
+ export async function syncMirror({
43
+ version, fetchImpl = fetch, sleep = delay, log = console.log,
44
+ attempts = 24, intervalMs = 10_000, syncAttempts = 3,
45
+ } = {}) {
46
+ if (version !== undefined && !VERSION.test(version)) throw new Error('Invalid target version')
47
+ const options = { attempts, intervalMs, sleep, log }
48
+ const read = async (url) => (await request(fetchImpl, url)).json()
49
+ const official = await retry('Waiting for npm', async () => {
50
+ const data = await read(NPM)
51
+ const target = version ?? data['dist-tags']?.latest
52
+ if (typeof target !== 'string' || !VERSION.test(target)) throw new Error('npm has no valid target version')
53
+ const checksum = data.versions?.[target]?.dist?.shasum
54
+ if (typeof checksum !== 'string' || !/^[a-f0-9]{40}$/u.test(checksum)) throw new Error(`npm ${target} is not yet available with a checksum`)
55
+ return { target, checksum, latest: data['dist-tags']?.latest }
56
+ }, options)
57
+ log(`npm target ${official.target}; latest ${official.latest}`)
58
+
59
+ const verify = async (download = false) => {
60
+ const mirror = await read(MIRROR)
61
+ if (mirror.versions?.[official.target]?.dist?.shasum !== official.checksum) throw new Error(`mirror ${official.target} is missing or has a different checksum`)
62
+ if (official.latest === official.target && mirror['dist-tags']?.latest !== official.target) throw new Error(`mirror latest is not ${official.target}`)
63
+ const tarball = mirror.versions[official.target].dist.tarball
64
+ const expected = `https://registry.npmmirror.com/${NAME}/-/${NAME}-${official.target}.tgz`
65
+ if (tarball !== expected) throw new Error('mirror returned an unexpected tarball URL')
66
+ const artifact = await request(fetchImpl, tarball, { method: download ? 'GET' : 'HEAD' })
67
+ if (download) {
68
+ if (artifact.body === null) throw new Error('mirror tarball has no body')
69
+ const digest = createHash('sha1')
70
+ let bytes = 0
71
+ for await (const chunk of artifact.body) {
72
+ bytes += chunk.length
73
+ if (bytes > MAX_TARBALL_BYTES) throw new Error('mirror tarball exceeds size limit')
74
+ digest.update(chunk)
75
+ }
76
+ if (digest.digest('hex') !== official.checksum) throw new Error('mirror tarball checksum does not match npm')
77
+ }
78
+ return official.target
79
+ }
80
+
81
+ try {
82
+ const target = await verify()
83
+ log(`Mirror already serves ${target} with the correct checksum`)
84
+ return { version: target, synced: false }
85
+ } catch (error) {
86
+ log(`Mirror needs synchronization: ${error instanceof Error ? error.message : String(error)}`)
87
+ }
88
+
89
+ let lastError
90
+ for (let attempt = 0; attempt < syncAttempts; attempt++) {
91
+ try {
92
+ const task = await (await request(fetchImpl, SYNC, {
93
+ method: 'PUT', headers: { 'content-type': 'application/json' },
94
+ body: JSON.stringify({ skipDependencies: true }),
95
+ })).json()
96
+ if (task.ok !== true || typeof task.id !== 'string' || !TASK_ID.test(task.id)) throw new Error('mirror did not return a valid sync task')
97
+ log(`Mirror synchronization task ${task.id}`)
98
+ await retry('Waiting for mirror synchronization', async () => {
99
+ const status = await read(`${SYNC}/${task.id}`)
100
+ if (status.state === 'success') return
101
+ if (status.state === 'failed' || status.state === 'fail') {
102
+ throw Object.assign(new Error(`sync task ${status.state}`), { terminal: true })
103
+ }
104
+ throw new Error(`sync task ${String(status.state)}`)
105
+ }, options)
106
+ const target = await retry('Waiting for mirror availability', () => verify(true), options)
107
+ log(`Mirror serves ${target} with the correct checksum`)
108
+ return { version: target, synced: true }
109
+ } catch (error) {
110
+ lastError = error
111
+ log(`Mirror synchronization attempt ${attempt + 1}/${syncAttempts} failed: ${error instanceof Error ? error.message : String(error)}`)
112
+ if (attempt + 1 < syncAttempts) await sleep(intervalMs)
113
+ }
114
+ }
115
+ throw new Error(`Mirror synchronization failed: ${lastError instanceof Error ? lastError.message : String(lastError)}`)
116
+ }
117
+
118
+ if (process.argv[1] !== undefined && import.meta.url === pathToFileURL(process.argv[1]).href) {
119
+ const args = process.argv.slice(2)
120
+ const published = args.length === 1 && args[0] === '--published'
121
+ const publishedVersion = published ? process.env.npm_package_version : undefined
122
+ if ((published && (publishedVersion === undefined || !VERSION.test(publishedVersion)))
123
+ || (!published && args.length !== 0 && (args.length !== 2 || args[0] !== '--version'))) {
124
+ console.error('Usage: node tools/sync-npmmirror.mjs [--version X.Y.Z | --published (npm lifecycle only)]')
125
+ process.exitCode = 2
126
+ } else {
127
+ syncMirror(published ? { version: publishedVersion } : args.length === 2 ? { version: args[1] } : {}).catch(error => {
128
+ console.error(error instanceof Error ? error.message : String(error))
129
+ process.exitCode = 1
130
+ })
131
+ }
132
+ }
@@ -1,4 +1,5 @@
1
- // Generated by scripts/build-channel-pack.mjs — do not edit.
1
+ // Generated by scripts/build-channel-pack.mjs — local compatibility patches are marked below.
2
+ import { withoutPoolDuplicates } from './pool-model-dedupe.js';
2
3
  // Source: vendor/channel-pack/src (the absorbed free-channel pack; see NOTICE.md).
3
4
  import { createRequire as __ofmCreateRequire } from 'node:module'
4
5
  const require = __ofmCreateRequire(import.meta.url)
@@ -36226,6 +36227,12 @@ function positiveMaxTokens(value) {
36226
36227
  function registerBuddyLlm(ctx, options) {
36227
36228
  const product = options.product ?? CODEBUDDY;
36228
36229
  const adapter = new BuddyAdapter(options);
36230
+ // [patch:workbuddy-picker-dedupe] Keep the historical provider callable while
36231
+ // hiding entries already listed by this region's WorkBuddy pool in the picker.
36232
+ const listChannelModels = adapter.listModels.bind(adapter);
36233
+ adapter.listModels = async (provider) => withoutPoolDuplicates(
36234
+ await listChannelModels(provider), product.id, (poolProvider) => ctx.llm.listModels(poolProvider)
36235
+ );
36229
36236
  registerAdapterIdempotent(ctx.llm, [product.id], adapter);
36230
36237
  return adapter;
36231
36238
  }
@@ -0,0 +1,16 @@
1
+ /** Hide only model IDs also offered by the corresponding WorkBuddy pool.
2
+ * The channel adapter itself stays registered so previously saved routes work.
3
+ * If the pool is unavailable, keep the original channel catalog intact.
4
+ */
5
+ export async function withoutPoolDuplicates(rows, provider, listModels) {
6
+ const poolProvider = provider === 'buddy' ? 'xdpool'
7
+ : provider === 'workbuddy' ? 'xdpool-global' : undefined
8
+ if (poolProvider === undefined) return rows
9
+ try {
10
+ const poolRows = await listModels(poolProvider)
11
+ const ids = new Set(poolRows.map(row => row.id))
12
+ return rows.filter(row => !ids.has(row.id))
13
+ } catch {
14
+ return rows
15
+ }
16
+ }