dshmarket 1.73.16 → 1.73.17

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/client/client.js CHANGED
@@ -360,7 +360,9 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
360
360
  installedEmpty: "尚未安装社区插件,可前往「发现」页浏览",
361
361
  marketGoneTitle: "插件市场已停止运行",
362
362
  marketGoneBody: "DSH 重新加载插件时把市场一起卸载了。重启 DSH 即可恢复;刚才的操作可能已经完成。",
363
- marketGoneRecord: "市场已从 DSH 卸载,这次操作没有结果。重启 DSH 后可在「已安装」里确认。",
363
+ marketGoneRecord: "市场被 DSH 卸载了,这次操作没有等到结果。市场恢复后,到「已安装」里确认。",
364
+ marketGoneReconnecting: "正在重新连接…",
365
+ marketGoneReconnect: "重新连接",
364
366
  loadFail: "插件目录加载失败,请稍后重试",
365
367
  loadRetry: "重试",
366
368
  installFail: "安装失败",
@@ -1152,7 +1154,9 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
1152
1154
  installedEmpty: "No community plugins yet — browse the Discover tab",
1153
1155
  marketGoneTitle: "The plugin market stopped running",
1154
1156
  marketGoneBody: "DSH unloaded the market while reloading plugins. Restart DSH to bring it back. The last operation may already have finished.",
1155
- marketGoneRecord: "The market was unloaded from DSH, so this operation has no result. After restarting, check Installed.",
1157
+ marketGoneRecord: "DSH unloaded the market, so this operation got no result. Once the market is back, check Installed.",
1158
+ marketGoneReconnecting: "Reconnecting…",
1159
+ marketGoneReconnect: "Reconnect",
1156
1160
  loadFail: "The plugin catalog failed to load. Try again later.",
1157
1161
  loadRetry: "Retry",
1158
1162
  installFail: "Install failed",
@@ -1944,7 +1948,9 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
1944
1948
  installedEmpty: "コミュニティプラグインはまだインストールされていません。「見つける」ページで探せます",
1945
1949
  marketGoneTitle: "プラグインマーケットが停止しました",
1946
1950
  marketGoneBody: "DSH がプラグインを再読み込みした際に、マーケットも一緒にアンロードされました。DSH を再起動すれば復旧します。直前の操作は完了している可能性があります。",
1947
- marketGoneRecord: "マーケットが DSH からアンロードされたため、この操作の結果はありません。再起動後、「インストール済み」で確認してください。",
1951
+ marketGoneRecord: "マーケットが DSH からアンロードされたため、この操作の結果は届きませんでした。マーケットが戻ったら、「インストール済み」で確認してください。",
1952
+ marketGoneReconnecting: "再接続しています…",
1953
+ marketGoneReconnect: "再接続",
1948
1954
  loadFail: "プラグインカタログの読み込みに失敗しました。しばらくしてから再試行してください",
1949
1955
  loadRetry: "再試行",
1950
1956
  installFail: "インストールに失敗しました",
@@ -7844,6 +7850,9 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
7844
7850
  const HOST_DEPENDENCY_PREVIEW_LIMIT = 5;
7845
7851
  /** After this long without a structured phase, the install line adds a note that waiting is normal (#1011). */
7846
7852
  const SLOW_INSTALL_SECONDS = 90;
7853
+ /** How long the page keeps asking for a market DSH unloaded, and how long one ask may take (#1151). */
7854
+ const RECONNECT_BUDGET_MS = 9e4;
7855
+ const RECONNECT_REQUEST_MS = 4e3;
7847
7856
  const IGNORED_UPDATES_SESSION_KEY = "dshm-updates-ignored";
7848
7857
  const UNAVAILABLE_HOST_COMPATIBILITY = {
7849
7858
  status: "unknown",
@@ -10106,6 +10115,8 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
10106
10115
  * exactly why it owes the user this sentence instead of a spinner.
10107
10116
  */
10108
10117
  const [marketGone, setMarketGone] = (0, react.useState)(false);
10118
+ const [reconnecting, setReconnecting] = (0, react.useState)(true);
10119
+ const [reconnectRound, setReconnectRound] = (0, react.useState)(0);
10109
10120
  const [installed, setInstalledState] = (0, react.useState)(cachedInstalled ?? {});
10110
10121
  const setInstalled = (0, react.useCallback)((value) => {
10111
10122
  cachedInstalled = value;
@@ -11186,6 +11197,66 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
11186
11197
  setLoadError(error instanceof Error ? error.message : String(error));
11187
11198
  });
11188
11199
  }, [noteMarketGone, t]);
11200
+ /**
11201
+ * Come back when the routes do (#1151).
11202
+ *
11203
+ * A 404 is how the page learns DSH unloaded the market, but DSH usually
11204
+ * mounts it again within seconds: it reloads plugins around an install or
11205
+ * an update, and the market is one of them. The page used to stay on "stopped"
11206
+ * for good, so the user restarted DSH — which also killed whatever the host
11207
+ * was still doing. Read-only on purpose: only `status` is asked, never a
11208
+ * request that changes anything, and nothing that was in flight is replayed.
11209
+ */
11210
+ (0, react.useEffect)(() => {
11211
+ if (!marketGone) return;
11212
+ setReconnecting(true);
11213
+ const startedAt = Date.now();
11214
+ let wait = 1e3;
11215
+ let timer;
11216
+ let inFlight;
11217
+ let stopped = false;
11218
+ const attempt = async () => {
11219
+ inFlight = new AbortController();
11220
+ const cutoff = setTimeout(() => inFlight?.abort(), RECONNECT_REQUEST_MS);
11221
+ try {
11222
+ const res = await fetch(api("/dsh-market/status"), {
11223
+ cache: "no-store",
11224
+ signal: inFlight.signal
11225
+ });
11226
+ const status = res.ok ? await res.json() : null;
11227
+ if (!stopped && status !== null && typeof status === "object" && typeof status.boot === "string") {
11228
+ setMarketGone(false);
11229
+ loadCatalog();
11230
+ refreshInstalled();
11231
+ return;
11232
+ }
11233
+ } catch {} finally {
11234
+ clearTimeout(cutoff);
11235
+ }
11236
+ if (stopped) return;
11237
+ if (Date.now() - startedAt >= RECONNECT_BUDGET_MS) {
11238
+ setReconnecting(false);
11239
+ return;
11240
+ }
11241
+ timer = setTimeout(() => {
11242
+ attempt();
11243
+ }, wait);
11244
+ wait = Math.min(wait * 2, 5e3);
11245
+ };
11246
+ timer = setTimeout(() => {
11247
+ attempt();
11248
+ }, wait);
11249
+ return () => {
11250
+ stopped = true;
11251
+ clearTimeout(timer);
11252
+ inFlight?.abort();
11253
+ };
11254
+ }, [
11255
+ marketGone,
11256
+ reconnectRound,
11257
+ loadCatalog,
11258
+ refreshInstalled
11259
+ ]);
11189
11260
  const loadHostCompatibility = (0, react.useCallback)(async (names) => {
11190
11261
  const unique = [...new Set(names)].filter((name) => {
11191
11262
  if (name === "" || hostCompatibilitySettled(name) || hostCompatibilityInFlight.has(name)) return false;
@@ -11626,36 +11697,20 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
11626
11697
  clearPinVars();
11627
11698
  };
11628
11699
  }, [surface, themesFullscreen]);
11629
- const { plugins: pluginsAll, hostHiddenCount } = (0, react.useMemo)(() => {
11630
- if (data === null) return {
11631
- plugins: [],
11632
- hostHiddenCount: 0
11633
- };
11700
+ const pluginsAll = (0, react.useMemo)(() => {
11701
+ if (data === null) return [];
11634
11702
  const query = {
11635
11703
  category: cat,
11636
11704
  query: q,
11637
11705
  lang,
11638
11706
  categories: data.categories,
11639
11707
  sort: `${sortField}-${sortDir}`,
11640
- sinceDays: timeRange === "all" ? void 0 : TIME_RANGE_DAYS[timeRange],
11641
- hostCompatibility
11708
+ sinceDays: timeRange === "all" ? void 0 : TIME_RANGE_DAYS[timeRange]
11642
11709
  };
11643
- const unfiltered = visiblePlugins(data.plugins, {
11710
+ return visiblePlugins(data.plugins, {
11644
11711
  ...query,
11645
11712
  compatibleWithHost: false
11646
11713
  });
11647
- if (!compatibleWithHost) return {
11648
- plugins: unfiltered,
11649
- hostHiddenCount: 0
11650
- };
11651
- const filtered = visiblePlugins(data.plugins, {
11652
- ...query,
11653
- compatibleWithHost: true
11654
- });
11655
- return {
11656
- plugins: filtered,
11657
- hostHiddenCount: unfiltered.length - filtered.length
11658
- };
11659
11714
  }, [
11660
11715
  data,
11661
11716
  q,
@@ -11663,21 +11718,35 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
11663
11718
  lang,
11664
11719
  sortField,
11665
11720
  sortDir,
11666
- timeRange,
11667
- hostCompatibility,
11668
- compatibleWithHost
11721
+ timeRange
11669
11722
  ]);
11670
11723
  const pluginBlocked = (plugin) => blockAliases(plugin, matchInstalledName(plugin, installed, repoIdentities, data?.plugins, repoHints)).some((name) => blockedNameSet.has(name));
11671
- const installedBlocked = (name) => {
11672
- if (blockedNameSet.has(name)) return true;
11673
- if (data === null) return false;
11674
- const spec = installed[name];
11675
- if (spec === void 0) return false;
11676
- const entry = catalogEntryForInstalled(data.plugins, name, String(spec), repoIdentities[name], repoHints[name]);
11677
- return entry !== void 0 && blockAliases(entry, name).some((alias) => blockedNameSet.has(alias));
11678
- };
11724
+ const installedBlocked = (0, react.useMemo)(() => {
11725
+ const compute = (name) => {
11726
+ if (blockedNameSet.has(name)) return true;
11727
+ if (data === null) return false;
11728
+ const spec = installed[name];
11729
+ if (spec === void 0) return false;
11730
+ const entry = catalogEntryForInstalled(data.plugins, name, String(spec), repoIdentities[name], repoHints[name]);
11731
+ return entry !== void 0 && blockAliases(entry, name).some((alias) => blockedNameSet.has(alias));
11732
+ };
11733
+ const cache = /* @__PURE__ */ new Map();
11734
+ return (name) => {
11735
+ const hit = cache.get(name);
11736
+ if (hit !== void 0) return hit;
11737
+ const value = compute(name);
11738
+ cache.set(name, value);
11739
+ return value;
11740
+ };
11741
+ }, [
11742
+ data,
11743
+ blockedNameSet,
11744
+ installed,
11745
+ repoIdentities,
11746
+ repoHints
11747
+ ]);
11679
11748
  const blockToggleName = (aliases) => aliases.find((name) => blockedNameSet.has(name)) ?? aliases[0];
11680
- const plugins = (0, react.useMemo)(() => pluginsAll.filter((plugin) => !pluginBlocked(plugin)), [
11749
+ const pluginsUnblocked = (0, react.useMemo)(() => pluginsAll.filter((plugin) => !pluginBlocked(plugin)), [
11681
11750
  pluginsAll,
11682
11751
  blockedNameSet,
11683
11752
  installed,
@@ -11685,6 +11754,27 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
11685
11754
  data,
11686
11755
  repoHints
11687
11756
  ]);
11757
+ const { plugins, hostHiddenCount } = (0, react.useMemo)(() => {
11758
+ if (!compatibleWithHost) return {
11759
+ plugins: pluginsUnblocked,
11760
+ hostHiddenCount: 0
11761
+ };
11762
+ const compatible = (plugin) => {
11763
+ const key = hostCompatibilityKey(plugin);
11764
+ return key === null || hostCompatibility[key]?.status !== "incompatible";
11765
+ };
11766
+ let hidden = 0;
11767
+ for (const plugin of pluginsAll) if (!compatible(plugin)) hidden += 1;
11768
+ return {
11769
+ plugins: pluginsUnblocked.filter(compatible),
11770
+ hostHiddenCount: hidden
11771
+ };
11772
+ }, [
11773
+ pluginsAll,
11774
+ pluginsUnblocked,
11775
+ compatibleWithHost,
11776
+ hostCompatibility
11777
+ ]);
11688
11778
  const recentlyAdded = (0, react.useMemo)(() => data === null || tab !== "discover" || q.trim() !== "" || cat !== "all" || timeRange !== "all" || sortField !== "downloads" || sortDir !== "desc" ? [] : visiblePlugins(data.plugins, {
11689
11779
  category: "all",
11690
11780
  query: "",
@@ -15300,10 +15390,22 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
15300
15390
  children: marketGone ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
15301
15391
  className: Market_module_css_default.empty,
15302
15392
  role: "alert",
15303
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: t("marketGoneTitle") }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
15304
- className: Market_module_css_default.spec,
15305
- children: t("marketGoneBody")
15306
- })]
15393
+ children: [
15394
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: t("marketGoneTitle") }) }),
15395
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
15396
+ className: Market_module_css_default.spec,
15397
+ children: t("marketGoneBody")
15398
+ }),
15399
+ reconnecting ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
15400
+ className: Market_module_css_default.spec,
15401
+ children: t("marketGoneReconnecting")
15402
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
15403
+ variant: "outline",
15404
+ size: "sm",
15405
+ onClick: () => setReconnectRound((round) => round + 1),
15406
+ children: t("marketGoneReconnect")
15407
+ }) })
15408
+ ]
15307
15409
  }) : tab === "backup" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
15308
15410
  className: Market_module_css_default.backupGrid,
15309
15411
  children: [
@@ -15670,7 +15772,7 @@ window.__ModuleLoader__.load({ id: "dshmarket", factory: (require) => {
15670
15772
  })]
15671
15773
  })),
15672
15774
  plugins.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EmptyResults, {
15673
- blocked: pluginsAll.length > 0,
15775
+ blocked: pluginsAll.length > hostHiddenCount,
15674
15776
  t,
15675
15777
  onClear: data.plugins.length > 0 && (q !== "" || cat !== "all" || timeRange !== "all" || compatibleWithHost) ? () => {
15676
15778
  setQ("");
@@ -13,6 +13,7 @@ import { dirname } from 'node:path';
13
13
  import { compareSemver, isSemver, satisfiesRange } from './check.js';
14
14
  import { classifyPeer, crossesImplicitCeiling } from './compatibility.js';
15
15
  import { marketFetch } from './net.js';
16
+ import { isStableReleaseVersion } from './release-candidates.js';
16
17
  import { activeRegion, githubRoutesFor, rememberGithubRoute, throughProxy } from './regions.js';
17
18
  import { parseSourceUrl } from './sources.js';
18
19
  const CACHE_SCHEMA = 'dsh-market/discovery-compatibility-cache/v1';
@@ -446,10 +447,14 @@ export class DiscoveryManifestIndex {
446
447
  * installed one, which is what an update needs: suggesting a downgrade is not
447
448
  * an update.
448
449
  *
450
+ * `stableOnly` drops prereleases. The official Desktop refuses to move a
451
+ * stable install onto a prerelease by itself (#991), so offering one there is
452
+ * an enabled button that can only answer 409 (#1161).
453
+ *
449
454
  * @returns the version, or null when the packument cannot be read or nothing
450
455
  * in the history declares itself compatible.
451
456
  */
452
- export async function findCompatibleVersion(npmName, hostVersion, hostPackages, registry, fetcher = marketFetch, minimumVersionExclusive = null) {
457
+ export async function findCompatibleVersion(npmName, hostVersion, hostPackages, registry, fetcher = marketFetch, minimumVersionExclusive = null, stableOnly = false) {
453
458
  let doc;
454
459
  try {
455
460
  const res = await fetcher(`${registry}/${encodeURIComponent(npmName)}`, { signal: AbortSignal.timeout(15_000), headers: { accept: 'application/json', 'user-agent': 'dsh-market' } });
@@ -465,6 +470,7 @@ export async function findCompatibleVersion(npmName, hostVersion, hostPackages,
465
470
  return null;
466
471
  const candidates = Object.keys(versions)
467
472
  .filter(version => isSemver(version)
473
+ && (!stableOnly || isStableReleaseVersion(version))
468
474
  && (minimumVersionExclusive === null || compareSemver(version, minimumVersionExclusive) > 0))
469
475
  .sort((left, right) => compareSemver(right, left));
470
476
  for (const version of candidates) {
package/lib/dsh-cli.js CHANGED
@@ -479,7 +479,11 @@ export function dshArgv() {
479
479
  // The official bundled CLI inherits the launcher's cwd. Its entry can
480
480
  // live inside app.asar: Electron can read it, but the OS cannot chdir there.
481
481
  // Do not probe that directory through Electron's virtual filesystem.
482
- return { file: nodeExecutable(), args: [...process.execArgv, abs], cwd: desktopCli ? undefined : dirname(abs), viaShell: false };
482
+ // An entry inside an .asar archive carries the same hazard as the desktop
483
+ // CLI above: Electron's fs shim resolves the directory, the OS cannot chdir
484
+ // there, and CreateProcess fails with ENOENT naming an unrelated executable.
485
+ const entryInAsar = /[\\/][^\\/]+\.asar[\\/]/i.test(abs);
486
+ return { file: nodeExecutable(), args: [...process.execArgv, abs], cwd: desktopCli || entryInAsar ? undefined : dirname(abs), viaShell: false };
483
487
  }
484
488
  // Bare `dsh` is a .cmd shim on Windows that only a shell can start (#13).
485
489
  return { file: 'dsh', args: [], cwd: undefined, viaShell: winCmdShim };
package/lib/index.js CHANGED
@@ -118,15 +118,18 @@ function hostPackageManagerOf(context) {
118
118
  function agentsLookupOf(ctx) {
119
119
  return () => ctx.get('agents');
120
120
  }
121
+ /** What an all-interfaces listener reports as its bind host; it names no machine. */
122
+ const WILDCARD_BIND_HOSTS = new Set(['0.0.0.0', '::', '[::]']);
121
123
  /**
122
124
  * The deployment's declared authorities, read from the host (#729).
123
125
  *
124
- * DSH's own /api fence accepts loopback OR an authority the operator declared
125
- * (`dsh web --trusted-host <name>`, plus the LAN literals the CLI derives when
126
- * bound to 0.0.0.0). The market's routes are `exact` registrations on the bare
127
- * webServer, and exact matches win over that fence's prefix, so they never
128
- * pass through it — and a loopback-only rule of its own made every mutating
129
- * route 403 on any deployment reached by a name.
126
+ * DSH's own /api fence accepts loopback, the listener's bind IP literal, or an
127
+ * authority the operator declared (`dsh web --trusted-host <name>`). The
128
+ * market's routes are `exact` registrations on the bare webServer, and exact
129
+ * matches win over that fence's prefix, so they never pass through it — and a
130
+ * loopback-only rule of its own made every mutating route 403 on any deployment
131
+ * reached by a name. The source below therefore mirrors the host's fence: the
132
+ * declared `trustedHosts` plus the listener's own bind host from `webServer`.
130
133
  *
131
134
  * The `connection` service is optional: a host without it leaves the fence
132
135
  * exactly as it was, which is the behaviour every release so far has had.
@@ -153,9 +156,29 @@ export function useTrustedHosts(ctx) {
153
156
  warned = true;
154
157
  console.warn('dsh-market: the host connection service is not available; the origin fence accepts loopback only');
155
158
  }
156
- return Array.isArray(connection?.trustedHosts)
159
+ const hosts = Array.isArray(connection?.trustedHosts)
157
160
  ? connection.trustedHosts.filter((entry) => typeof entry === 'string')
158
161
  : [];
162
+ // The host's own fence accepts the listener's bind IP independently of the
163
+ // declared trustedHosts list, so a deployment reached through its own bind
164
+ // address passed /api yet still 403s here. Mirror that acceptance as a
165
+ // port-less entry, with the same normalization the host applies (the zone
166
+ // id is an interface selector, not address text; a bare IPv6 literal needs
167
+ // brackets to survive the canonical-form parse). The webserver config
168
+ // already rejects anything that is not a concrete, non-wildcard IP literal
169
+ // at load, so the value is safe to trust.
170
+ const bindHost = ctx.get('webServer')?.host;
171
+ // Older hosts bind the all-interfaces literal itself, which no browser
172
+ // sends as a Host and which names no machine in particular: not an
173
+ // authority to trust. Newer ones refuse to load with it.
174
+ if (typeof bindHost === 'string' && bindHost !== '' && !WILDCARD_BIND_HOSTS.has(bindHost)) {
175
+ const zoneAt = bindHost.indexOf('%');
176
+ const address = zoneAt === -1 ? bindHost : bindHost.slice(0, zoneAt);
177
+ const entry = address.includes(':') && !address.startsWith('[') ? `[${address}]` : address;
178
+ if (!hosts.includes(entry))
179
+ hosts.push(entry);
180
+ }
181
+ return hosts;
159
182
  });
160
183
  // The same service carries the host's request gate (#603): its fence plus
161
184
  // its browser login, the check its own API runs. Read per request for the
package/lib/install.js CHANGED
@@ -1048,7 +1048,7 @@ export function parsePrepareNotAllowed(stdout, stderr) {
1048
1048
  // … git-hosted package \"pkg@1.0.0\" needs to execute build scripts …
1049
1049
  // Unescape before matching, or the ndjson path — the ONLY path in
1050
1050
  // production — silently returns null and the approve banner never shows.
1051
- const text = `${stdout}\n${stderr}`.replace(/\\"/g, '"');
1051
+ const text = unwrapPnpmErrors(`${stdout}\n${stderr}`.replace(/\\"/g, '"'));
1052
1052
  const m = /git-hosted package "([^"]+)" needs to execute build scripts/.exec(text);
1053
1053
  if (m === null)
1054
1054
  return null;
@@ -1057,6 +1057,42 @@ export function parsePrepareNotAllowed(stdout, stderr) {
1057
1057
  const at = raw.lastIndexOf('@');
1058
1058
  return at > 0 ? raw.slice(0, at) : raw;
1059
1059
  }
1060
+ /**
1061
+ * Undo the line wrapping of pnpm 12's boxed error text (#1156).
1062
+ *
1063
+ * pnpm 12 prints a failure as
1064
+ *
1065
+ * Error: ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED
1066
+ *
1067
+ * × adding a new package
1068
+ * ╰─▶ The git-hosted package "x@1.0.0" needs to execute build
1069
+ * scripts but is not in the "allowBuilds" allowlist.
1070
+ * help: …
1071
+ *
1072
+ * and wraps it at about 80 columns — through the middle of a sentence, and
1073
+ * through the middle of a package key at a `/` or `-`. Every sentence this
1074
+ * file matches then has a line break where its single space was, so the
1075
+ * refusal was classified correctly and still yielded no package name, no
1076
+ * key, and therefore no approve-and-retry button. Continuation lines are
1077
+ * indented deeper than the line they continue; join them back, without a
1078
+ * space when the break fell inside a token.
1079
+ *
1080
+ * Output that never wraps this way (pnpm 10/11, ndjson) has no such lines
1081
+ * and comes back unchanged.
1082
+ */
1083
+ export function unwrapPnpmErrors(text) {
1084
+ const out = [];
1085
+ for (const line of text.replace(/\r\n/g, '\n').split('\n')) {
1086
+ const previous = out[out.length - 1];
1087
+ if (previous !== undefined && /^ {2,}\S/.test(previous) && /^ {4,}\S/.test(line)) {
1088
+ out[out.length - 1] = previous + (/[^\s][/-]$/.test(previous) ? '' : ' ') + line.trim();
1089
+ }
1090
+ else {
1091
+ out.push(line);
1092
+ }
1093
+ }
1094
+ return out.join('\n');
1095
+ }
1060
1096
  /**
1061
1097
  * The allowBuilds key pnpm itself printed for a prepare refusal, when it
1062
1098
  * printed one (#698).
@@ -1077,8 +1113,8 @@ export function parsePrepareNotAllowed(stdout, stderr) {
1077
1113
  */
1078
1114
  export function parsePrepareKey(stdout, stderr) {
1079
1115
  // ndjson carries this inside a JSON string: quotes and newlines escaped.
1080
- const text = `${stdout}\n${stderr}`.replace(/\\"/g, '"').replace(/\\n/g, '\n');
1081
- const m = /For example:\s*\n\s*allowBuilds:\s*\n[ \t]+("?)([^\s"]+)\1:\s*true/.exec(text);
1116
+ const text = unwrapPnpmErrors(`${stdout}\n${stderr}`.replace(/\\"/g, '"').replace(/\\n/g, '\n'));
1117
+ const m = /For example:\s*allowBuilds:\s*("?)([^\s"]+)\1:\s*true/.exec(text);
1082
1118
  return m === null ? null : m[2];
1083
1119
  }
1084
1120
  /**
@@ -1118,7 +1154,7 @@ export function allowBuildKeyFromIgnoredBuild(depPath) {
1118
1154
  * path can contain, so the surrounding JSON is not swallowed.
1119
1155
  */
1120
1156
  export function parseIgnoredBuildEntries(stdout, stderr) {
1121
- const m = /Ignored build scripts:?\s*([^\n]+)/i.exec(`${stdout}\n${stderr}`);
1157
+ const m = /Ignored build scripts:?\s*([^\n]+)/i.exec(unwrapPnpmErrors(`${stdout}\n${stderr}`));
1122
1158
  if (m === null)
1123
1159
  return [];
1124
1160
  const found = [];
@@ -241,7 +241,8 @@ async function updateMarketInPlace(spec, name, options, context) {
241
241
  const args = ['add', spec];
242
242
  if (typeof options.registry === 'string' && options.registry !== '')
243
243
  args.push(`--registry=${options.registry}`);
244
- const run = await runHostPnpm(invocation, directory, args);
244
+ context.onOwnChild?.(true);
245
+ const run = await runHostPnpm(invocation, directory, args).finally(() => context.onOwnChild?.(false));
245
246
  const output = `${run.stdout}\n${run.stderr}`.trim();
246
247
  if (run.cancelled) {
247
248
  return { application: 'cancelled', packageResult: { exitCode: run.exitCode, output } };
@@ -384,6 +385,29 @@ async function installOrReinstall(manager, spec, options, context) {
384
385
  throw error;
385
386
  }
386
387
  }
388
+ /**
389
+ * The operation the desktop manager is running, visible to every instance of
390
+ * this runtime in the process (#1151).
391
+ *
392
+ * The host reloads the market while an operation the market started is still
393
+ * inside the manager, so the instance that began it is disposed and a new one
394
+ * is built around it. The new one has no `active` of its own and would call
395
+ * the manager idle: it would start a second operation into the first, and its
396
+ * start-up repair would take the removal in progress for an interrupted one.
397
+ * The slot lives on `globalThis` because a reload may evaluate this module
398
+ * again, which a module-level variable would not survive.
399
+ */
400
+ const OPERATION_SLOT = Symbol.for('dshmarket.officialDesktop.operation');
401
+ function runningOperation() {
402
+ return globalThis[OPERATION_SLOT];
403
+ }
404
+ function setRunningOperation(operation) {
405
+ const slot = globalThis;
406
+ if (operation === undefined)
407
+ delete slot[OPERATION_SLOT];
408
+ else
409
+ slot[OPERATION_SLOT] = operation;
410
+ }
387
411
  /** Resolve the profile directory without making an invalid name a construction failure. */
388
412
  function safeProfileDirectory(profile, explicit) {
389
413
  if (explicit !== undefined)
@@ -415,13 +439,22 @@ _profileDirectory,
415
439
  packageManager) {
416
440
  let disposed = false;
417
441
  let repairing = false;
442
+ // True only while the self-update overlay runs its own pnpm child: the one
443
+ // operation this instance, and nobody else, has to stop and wait for.
444
+ let ownsChild = false;
418
445
  let active;
419
446
  const directory = safeProfileDirectory(profileName, _profileDirectory);
420
447
  const journal = directory === undefined ? undefined : PendingUpdateJournal.forProfile(directory);
421
448
  const updateContext = directory === undefined || journal === undefined
422
449
  ? undefined
423
- : { profile: profileName, profileDirectory: directory, journal, packageManager };
424
- const busy = () => active !== undefined || repairing;
450
+ : {
451
+ profile: profileName,
452
+ profileDirectory: directory,
453
+ journal,
454
+ packageManager,
455
+ onOwnChild: running => { ownsChild = running; },
456
+ };
457
+ const busy = () => active !== undefined || repairing || runningOperation() !== undefined;
425
458
  const runPlugin = (profile, argv) => {
426
459
  if (disposed)
427
460
  return Promise.resolve(failure('official desktop plugin runtime is disposed', 127));
@@ -429,7 +462,7 @@ packageManager) {
429
462
  return Promise.resolve(failure('refusing to change a different profile', 127));
430
463
  // A repair uses the same manager; overlapping the two would race the
431
464
  // profile's write lock and the route's single-operation rule.
432
- if (active !== undefined || repairing)
465
+ if (busy())
433
466
  return Promise.resolve({ ...failure('another plugin operation is running', 127), busy: true });
434
467
  const manager = managerLookup();
435
468
  if (manager === undefined
@@ -509,6 +542,8 @@ packageManager) {
509
542
  }
510
543
  const current = { requestId, cancelled: false, done: Promise.resolve(failure('not started')) };
511
544
  active = current;
545
+ const flight = { done: current.done };
546
+ setRunningOperation(flight);
512
547
  current.done = operation.then((result) => {
513
548
  // `overridden` is a change the manager KEPT (`changed: true`) whose live
514
549
  // state differs because another layer — a user patch — overrides it.
@@ -560,11 +595,21 @@ packageManager) {
560
595
  progress.cancelling = false;
561
596
  if (active === current)
562
597
  active = undefined;
598
+ if (runningOperation() === flight)
599
+ setRunningOperation(undefined);
563
600
  });
601
+ flight.done = current.done;
564
602
  return current.done;
565
603
  };
566
604
  const repairPendingUpdates = async () => {
567
605
  const empty = { reinstalled: [], finished: [], failed: [], abandoned: [] };
606
+ // An operation a previous instance started is still inside the manager:
607
+ // its journal record is in progress, not interrupted. Let it settle first
608
+ // — it finishes its own record on success, and a failure leaves the
609
+ // record for exactly this repair. The operation is bounded by its own
610
+ // deadline, so this wait is too.
611
+ if (active === undefined)
612
+ await runningOperation()?.done.catch(() => { });
568
613
  if (disposed || repairing || active !== undefined)
569
614
  return empty;
570
615
  const manager = managerLookup();
@@ -607,13 +652,26 @@ packageManager) {
607
652
  acceptsMarketPnpmFlags: false,
608
653
  dispose: async () => {
609
654
  disposed = true;
610
- if (active?.requestId !== undefined) {
655
+ const running = active;
656
+ // An operation inside the host's manager is the host's to finish (#1151).
657
+ // The host reloads the market in the middle of the operation the market
658
+ // started — and its reconciliation waits for this very disposer — so
659
+ // waiting here for the operation, which waits for the reconciliation,
660
+ // is a cycle: the market was already unmounted, the request never
661
+ // answered, the profile lock stayed held. Cancelling would also abort
662
+ // the update the user asked for halfway. Let it run; the next instance
663
+ // sees it through `runningOperation`.
664
+ if (running !== undefined && !ownsChild) {
665
+ void running.done.catch(() => { });
666
+ return;
667
+ }
668
+ if (running?.requestId !== undefined) {
611
669
  const manager = managerLookup();
612
670
  if (manager !== undefined)
613
- void manager.cancelInstall(active.requestId).catch(() => { });
671
+ void manager.cancelInstall(running.requestId).catch(() => { });
614
672
  }
615
673
  cancelHostChild();
616
- await active?.done;
674
+ await running?.done;
617
675
  },
618
676
  };
619
677
  }
package/lib/routes.js CHANGED
@@ -721,6 +721,38 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
721
721
  return;
722
722
  logEvent('warn', 'toggle', `${name}: kept off by this market's own record, while ${homePatchPath} enables it — that layer is not the one the market writes, so the market will not follow it. Move the row into this profile's cordis.patch.yml to make it stick (#519)`);
723
723
  }
724
+ /**
725
+ * Replay one switched-off package at boot, carrier-safe.
726
+ *
727
+ * The disable list only names a package, while a CARRIER bundle's patch
728
+ * also rewires foreign rows: it disables stock rows or gives them an
729
+ * `inject:` for a service the bundle's own gate entry provides. Disabling
730
+ * every matching entry would stop that gate too (the gate entry's name is
731
+ * `<pkg>/<row>`, so it matches the package), and the foreign rows would
732
+ * wait forever for a service that no longer exists — every preset pending.
733
+ *
734
+ * While such a bundle still sits in dsh.profile.bundles (an interrupted or
735
+ * older toggle can leave the list and the stack out of sync), reconcile it
736
+ * the same way the live toggle route does: remove the whole bundle so its
737
+ * entire patch stops applying on the next composition. Ordinary packages
738
+ * keep the best-effort entry disable they always had.
739
+ *
740
+ * The bundle removal edits the manifest for the NEXT composition; the
741
+ * current process already loaded the bundle, which is the same restart
742
+ * contract a live carrier toggle already has.
743
+ */
744
+ async function replayDisabledPackage(name) {
745
+ const carrierRows = carrierRowIds(activeProfileDir, name);
746
+ if (carrierRows.length > 0
747
+ && declaresBundle(activeProfileDir, name)
748
+ && readProfileBundles(activeProfileDir).includes(name)) {
749
+ removeProfileBundle(activeProfileDir, name);
750
+ logEvent('info', 'boot', `${name}: carrier removed from dsh.profile.bundles during boot replay (carrier rows: ${carrierRows.join(', ')}) — restart to finish; its gate is not disabled`);
751
+ return;
752
+ }
753
+ if (await themes.setEntryDisabled(name, true))
754
+ logEvent('info', 'boot', `plugin kept off: ${name}`);
755
+ }
724
756
  // Client-only packages (dsh.client without dsh.bundle) are invisible to the
725
757
  // bundle layer in every boot; the market shim-mounts them so their client
726
758
  // bundles are actually served.
@@ -735,8 +767,7 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
735
767
  if (followOutsideEnable(name))
736
768
  continue;
737
769
  noteHomeLayerConflict(name);
738
- if (await themes.setEntryDisabled(name, true))
739
- logEvent('info', 'boot', `plugin kept off: ${name}`);
770
+ await replayDisabledPackage(name);
740
771
  }
741
772
  });
742
773
  // Self-healing guard: dsh's own patch overlay can re-update entries during
@@ -745,8 +776,15 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
745
776
  host.on?.('internal/plugin', (payload) => {
746
777
  const fiber = payload;
747
778
  const name = fiber.entry?.options?.name;
748
- if (name !== undefined && disabled.has(name) && !followOutsideEnable(name))
749
- void themes.setEntryDisabled(name, true);
779
+ if (name === undefined || !disabled.has(name) || followOutsideEnable(name))
780
+ return;
781
+ // A carrier is reconciled by removing its bundle for the next
782
+ // composition, not by disabling its entries. Pushing a matching entry
783
+ // back down here would stop the gate foreign rows inject and re-strand
784
+ // them in the running process; let the restart finish the switch.
785
+ if (carrierRowIds(activeProfileDir, name).length > 0 && declaresBundle(activeProfileDir, name))
786
+ return;
787
+ void themes.setEntryDisabled(name, true);
750
788
  });
751
789
  let installing = false;
752
790
  let restarting = false;
@@ -3164,7 +3202,12 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
3164
3202
  sendJson(response, 200, { compatibleVersion: null, reason: 'installed-version-unknown' });
3165
3203
  return;
3166
3204
  }
3167
- const compatibleVersion = await findCompatibleVersion(npmName, host.version, corePackageNames(host.directory ?? null), routesFor(region).npmRegistry, undefined, currentVersion);
3205
+ // The update route's own rule (#991): the Desktop moves a stable npm
3206
+ // install only to a stable release, so a prerelease found here would
3207
+ // be an enabled button that answers 409 (#1161).
3208
+ const stableOnly = upgradeOnly && config.desktopHost === true && !SELF_NAMES.has(npmName)
3209
+ && isStableReleaseVersion(currentVersion);
3210
+ const compatibleVersion = await findCompatibleVersion(npmName, host.version, corePackageNames(host.directory ?? null), routesFor(region).npmRegistry, undefined, currentVersion, stableOnly);
3168
3211
  // A compatible version is only advice until the release-age gate
3169
3212
  // agrees: the dialog says "update to X", and clicking that used to
3170
3213
  // dead-end on a 409 the log never mentioned. Answer both questions
@@ -138,8 +138,12 @@ export declare class DiscoveryManifestIndex {
138
138
  * installed one, which is what an update needs: suggesting a downgrade is not
139
139
  * an update.
140
140
  *
141
+ * `stableOnly` drops prereleases. The official Desktop refuses to move a
142
+ * stable install onto a prerelease by itself (#991), so offering one there is
143
+ * an enabled button that can only answer 409 (#1161).
144
+ *
141
145
  * @returns the version, or null when the packument cannot be read or nothing
142
146
  * in the history declares itself compatible.
143
147
  */
144
- export declare function findCompatibleVersion(npmName: string, hostVersion: string, hostPackages: ReadonlySet<string>, registry: string, fetcher?: FetchLike, minimumVersionExclusive?: string | null): Promise<string | null>;
148
+ export declare function findCompatibleVersion(npmName: string, hostVersion: string, hostPackages: ReadonlySet<string>, registry: string, fetcher?: FetchLike, minimumVersionExclusive?: string | null, stableOnly?: boolean): Promise<string | null>;
145
149
  export {};
@@ -18,12 +18,13 @@ export declare function describeProfileContext(value: unknown): string;
18
18
  /**
19
19
  * The deployment's declared authorities, read from the host (#729).
20
20
  *
21
- * DSH's own /api fence accepts loopback OR an authority the operator declared
22
- * (`dsh web --trusted-host <name>`, plus the LAN literals the CLI derives when
23
- * bound to 0.0.0.0). The market's routes are `exact` registrations on the bare
24
- * webServer, and exact matches win over that fence's prefix, so they never
25
- * pass through it — and a loopback-only rule of its own made every mutating
26
- * route 403 on any deployment reached by a name.
21
+ * DSH's own /api fence accepts loopback, the listener's bind IP literal, or an
22
+ * authority the operator declared (`dsh web --trusted-host <name>`). The
23
+ * market's routes are `exact` registrations on the bare webServer, and exact
24
+ * matches win over that fence's prefix, so they never pass through it — and a
25
+ * loopback-only rule of its own made every mutating route 403 on any deployment
26
+ * reached by a name. The source below therefore mirrors the host's fence: the
27
+ * declared `trustedHosts` plus the listener's own bind host from `webServer`.
27
28
  *
28
29
  * The `connection` service is optional: a host without it leaves the fence
29
30
  * exactly as it was, which is the behaviour every release so far has had.
@@ -402,6 +402,30 @@ export declare function isStaleUpdate(check: {
402
402
  * node_modules yet (the fetcher rejects before materialization, #68).
403
403
  */
404
404
  export declare function parsePrepareNotAllowed(stdout: string, stderr: string): string | null;
405
+ /**
406
+ * Undo the line wrapping of pnpm 12's boxed error text (#1156).
407
+ *
408
+ * pnpm 12 prints a failure as
409
+ *
410
+ * Error: ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED
411
+ *
412
+ * × adding a new package
413
+ * ╰─▶ The git-hosted package "x@1.0.0" needs to execute build
414
+ * scripts but is not in the "allowBuilds" allowlist.
415
+ * help: …
416
+ *
417
+ * and wraps it at about 80 columns — through the middle of a sentence, and
418
+ * through the middle of a package key at a `/` or `-`. Every sentence this
419
+ * file matches then has a line break where its single space was, so the
420
+ * refusal was classified correctly and still yielded no package name, no
421
+ * key, and therefore no approve-and-retry button. Continuation lines are
422
+ * indented deeper than the line they continue; join them back, without a
423
+ * space when the break fell inside a token.
424
+ *
425
+ * Output that never wraps this way (pnpm 10/11, ndjson) has no such lines
426
+ * and comes back unchanged.
427
+ */
428
+ export declare function unwrapPnpmErrors(text: string): string;
405
429
  /**
406
430
  * The allowBuilds key pnpm itself printed for a prepare refusal, when it
407
431
  * printed one (#698).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dshmarket",
3
3
  "description": "Visual plugin market inside DeepSeek Harness — browse, search, and one-click install community plugins. · DSH 可视化插件市场:逛一逛,点一下,装好。",
4
- "version": "1.73.16",
4
+ "version": "1.73.17",
5
5
  "icon": "assets/logo.svg",
6
6
  "type": "module",
7
7
  "main": "lib/index.js",