dsh-workbuddy-bridge 0.5.10 → 0.5.11

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/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { C as variantFor, D as WorkBuddyUpstreamClient, S as WORKBUDDY_VARIANTS, a as readHostHeartbeat, c as WORKBUDDY_BRIDGE_VERSION, et as resolveAppVersion, l as FALLBACK_WORKBUDDY_AI_MODELS, m as WorkBuddyCredentialStore, o as workbuddyHostHeartbeatPath, r as isHeartbeatProcessAlive, u as FALLBACK_WORKBUDDY_MODELS, x as CN_VARIANT } from "./heartbeat-DN0dHD6J.js";
2
+ import { C as variantFor, D as WorkBuddyUpstreamClient, S as WORKBUDDY_VARIANTS, a as readHostHeartbeat, c as WORKBUDDY_BRIDGE_VERSION, et as resolveAppVersion, l as FALLBACK_WORKBUDDY_AI_MODELS, m as WorkBuddyCredentialStore, o as workbuddyHostHeartbeatPath, r as isHeartbeatProcessAlive, u as FALLBACK_WORKBUDDY_MODELS, x as CN_VARIANT } from "./heartbeat-BE0IAXli.js";
3
3
  import { realpathSync } from "node:fs";
4
4
  import { fileURLToPath } from "node:url";
5
5
  //#region src/cli/bin.ts
@@ -6,7 +6,7 @@ import { withFileLock, writeFileAtomic } from "@deepseek-ai/dsh-atomic-write";
6
6
  import { resolveDshHome } from "@deepseek-ai/dsh-home-paths";
7
7
  import { createDecipheriv, createHash, randomBytes } from "node:crypto";
8
8
  import { execFile, execFileSync } from "node:child_process";
9
- import { accessSync, constants, realpathSync, statSync } from "node:fs";
9
+ import { accessSync, constants, readdirSync, realpathSync, statSync } from "node:fs";
10
10
  //#region src/protocol/app-version.ts
11
11
  /**
12
12
  * The international desktop app's version, used as the `/v3/config` UA.
@@ -2124,6 +2124,56 @@ const WINDOWS_LOCAL_PROGRAM_SUFFIX = {
2124
2124
  ]
2125
2125
  };
2126
2126
  /**
2127
+ * The directory a staged Windows install keeps its per-version runtimes in.
2128
+ *
2129
+ * WorkBuddy 5.12 replaced the single-binary layout with a staged one: the
2130
+ * documented path now holds a small activation launcher, and each installed
2131
+ * version's runtime lives under `<root>\versions\<version>\` (verified against
2132
+ * CN 5.12.1, where `<root>\WorkBuddy.exe` is 544 KB and the runtime beside it
2133
+ * is 195 MB). The launcher only prints activation lines and never runs `-e`,
2134
+ * so the key helper must spawn the staged runtime instead.
2135
+ */
2136
+ const WINDOWS_STAGED_DIRECTORY = "versions";
2137
+ /** The runtime filename inside a staged version directory, keyed by product. */
2138
+ const WINDOWS_STAGED_APP_FILENAME = {
2139
+ cn: "WorkBuddy-app.exe",
2140
+ ai: "WorkBuddyAI-app.exe"
2141
+ };
2142
+ /**
2143
+ * The newest usable runtime of a staged Windows install, or `undefined`.
2144
+ *
2145
+ * Version directory names are compared numerically so `5.12.10` outranks
2146
+ * `5.12.9`; an unparsable name is skipped rather than guessed at. Choosing the
2147
+ * newest matters because an upgrade leaves the previous version directory
2148
+ * behind, and an older runtime may predate the staged layout entirely.
2149
+ */
2150
+ function stagedWindowsRuntime(root, product) {
2151
+ const stagedRoot = join(root, WINDOWS_STAGED_DIRECTORY);
2152
+ let names;
2153
+ try {
2154
+ names = readdirSync(stagedRoot);
2155
+ } catch {
2156
+ return;
2157
+ }
2158
+ const ranked = names.map((name) => ({
2159
+ name,
2160
+ segments: name.split(".").map((part) => Number.parseInt(part, 10))
2161
+ })).filter(({ segments }) => segments.length > 0 && segments.every((segment) => Number.isFinite(segment))).sort((left, right) => compareVersionSegments(right.segments, left.segments));
2162
+ for (const { name } of ranked) {
2163
+ const candidate = join(stagedRoot, name, WINDOWS_STAGED_APP_FILENAME[product]);
2164
+ if (isExecutable(candidate)) return candidate;
2165
+ }
2166
+ }
2167
+ /** Compare dotted version segments numerically, padding the shorter side with 0. */
2168
+ function compareVersionSegments(left, right) {
2169
+ const length = Math.max(left.length, right.length);
2170
+ for (let index = 0; index < length; index += 1) {
2171
+ const difference = (left[index] ?? 0) - (right[index] ?? 0);
2172
+ if (difference !== 0) return difference;
2173
+ }
2174
+ return 0;
2175
+ }
2176
+ /**
2127
2177
  * The Electron binary one discovery strategy expects at its default location, or
2128
2178
  * `undefined` where that strategy has no verified layout on this platform.
2129
2179
  *
@@ -2699,7 +2749,7 @@ function workBuddyDiscoveryTools() {
2699
2749
  return this.explicitPath;
2700
2750
  }
2701
2751
  if (this.discovery === "none") throw new WorkBuddyElectronPathError("electron-binary-unavailable", `no WorkBuddy Electron binary is configured for this platform; set ${WORKBUDDY_ELECTRON_BIN_ENV} to the app's Electron binary`);
2702
- if (this.defaultPath !== void 0 && isExecutable(this.defaultPath)) return this.defaultPath;
2752
+ if (this.defaultPath !== void 0 && isExecutable(this.defaultPath)) return (this.discovery === "windows-workbuddy" ? stagedWindowsRuntime(dirname(this.defaultPath), this.product) : void 0) ?? this.defaultPath;
2703
2753
  if (this.discoveredPath !== void 0) {
2704
2754
  if (isExecutable(this.discoveredPath)) return this.discoveredPath;
2705
2755
  this.discoveredPath = void 0;
@@ -2807,7 +2857,7 @@ function workBuddyDiscoveryTools() {
2807
2857
  }
2808
2858
  const seen = /* @__PURE__ */ new Map();
2809
2859
  for (const root of roots) {
2810
- const electronPath = join(root, WINDOWS_ELECTRON_FILENAME[this.product]);
2860
+ const electronPath = stagedWindowsRuntime(root, this.product) ?? join(root, WINDOWS_ELECTRON_FILENAME[this.product]);
2811
2861
  if (!isExecutable(electronPath)) continue;
2812
2862
  let identity;
2813
2863
  try {
@@ -4259,7 +4309,7 @@ var WorkBuddyCatalog = class {
4259
4309
  };
4260
4310
  //#endregion
4261
4311
  //#region src/version.ts
4262
- const WORKBUDDY_BRIDGE_VERSION = "0.5.10";
4312
+ const WORKBUDDY_BRIDGE_VERSION = "0.5.11";
4263
4313
  //#endregion
4264
4314
  //#region src/web/heartbeat.ts
4265
4315
  /**
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as readBundleVersion, A as isPlanLimitBody, B as randomSentinel, C as variantFor, D as WorkBuddyUpstreamClient, F as prepareChatRequest, G as chatUserAgent, H as upstreamDisplayMessage, I as prepareInternationalChatBody, J as resolveChatIdentity, K as fallbackChatIdentity, L as regionOf, M as normalizeCredits, N as parseModelCatalog, O as cacheConversationId, P as prepareChatBody, Q as installedAppVersion, R as PROBE_EFFORT_CANDIDATES, S as WORKBUDDY_VARIANTS, U as CN_APP_VERSION_FILENAME, V as classifyUpstreamError, W as FALLBACK_CN_APP_VERSION, X as WORKBUDDY_APP_VERSION_FILENAME, Y as validCliVersion, Z as appUserAgent, _ as desktopAuthCandidatesFor, a as readHostHeartbeat, b as AI_VARIANT, c as WORKBUDDY_BRIDGE_VERSION, d as WorkBuddyCatalog, et as resolveAppVersion, f as WORKBUDDY_AUTH_FILENAME, g as defaultDesktopAuthPath, h as defaultDesktopAuthCandidates, i as processStartTimeMs, j as modelWithCurrentPromotion, k as isChannelGateBody, l as FALLBACK_WORKBUDDY_AI_MODELS, m as WorkBuddyCredentialStore, n as clearHostHeartbeat, o as workbuddyHostHeartbeatPath, p as WORKBUDDY_AUTH_FILE_ENV, q as readCliVersion, r as isHeartbeatProcessAlive, s as writeHostHeartbeat, t as WORKBUDDY_HOST_HEARTBEAT_FILENAME, tt as validAppVersion, u as FALLBACK_WORKBUDDY_MODELS, v as parseWorkBuddyAuth, w as WORKBUDDY_CREDIT_PATH, x as CN_VARIANT, y as workbuddyOwnAuthPath, z as probeModel } from "./heartbeat-DN0dHD6J.js";
1
+ import { $ as readBundleVersion, A as isPlanLimitBody, B as randomSentinel, C as variantFor, D as WorkBuddyUpstreamClient, F as prepareChatRequest, G as chatUserAgent, H as upstreamDisplayMessage, I as prepareInternationalChatBody, J as resolveChatIdentity, K as fallbackChatIdentity, L as regionOf, M as normalizeCredits, N as parseModelCatalog, O as cacheConversationId, P as prepareChatBody, Q as installedAppVersion, R as PROBE_EFFORT_CANDIDATES, S as WORKBUDDY_VARIANTS, U as CN_APP_VERSION_FILENAME, V as classifyUpstreamError, W as FALLBACK_CN_APP_VERSION, X as WORKBUDDY_APP_VERSION_FILENAME, Y as validCliVersion, Z as appUserAgent, _ as desktopAuthCandidatesFor, a as readHostHeartbeat, b as AI_VARIANT, c as WORKBUDDY_BRIDGE_VERSION, d as WorkBuddyCatalog, et as resolveAppVersion, f as WORKBUDDY_AUTH_FILENAME, g as defaultDesktopAuthPath, h as defaultDesktopAuthCandidates, i as processStartTimeMs, j as modelWithCurrentPromotion, k as isChannelGateBody, l as FALLBACK_WORKBUDDY_AI_MODELS, m as WorkBuddyCredentialStore, n as clearHostHeartbeat, o as workbuddyHostHeartbeatPath, p as WORKBUDDY_AUTH_FILE_ENV, q as readCliVersion, r as isHeartbeatProcessAlive, s as writeHostHeartbeat, t as WORKBUDDY_HOST_HEARTBEAT_FILENAME, tt as validAppVersion, u as FALLBACK_WORKBUDDY_MODELS, v as parseWorkBuddyAuth, w as WORKBUDDY_CREDIT_PATH, x as CN_VARIANT, y as workbuddyOwnAuthPath, z as probeModel } from "./heartbeat-BE0IAXli.js";
2
2
  import z from "@deepseek-ai/schemastery";
3
3
  import { dirname, join, resolve } from "node:path";
4
4
  import { resolveDshHome } from "@deepseek-ai/dsh-home-paths";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "dsh-workbuddy-bridge",
3
3
  "displayName": "DSH WorkBuddy Bridge",
4
4
  "description": "将 WorkBuddy 桌面 App 包含的模型自动接入 DeepSeek Harness — bring WorkBuddy desktop app models into DeepSeek Harness with zero configuration.",
5
- "version": "0.5.10",
5
+ "version": "0.5.11",
6
6
  "author": "zlZayn",
7
7
  "keywords": [
8
8
  "dsh",