@linxin666/dsh-client-ui-plugin-manager 0.4.4 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,45 @@
1
+ /**
2
+ * One `document.body` MutationObserver per page, shared by every family
3
+ * plugin bundle.
4
+ *
5
+ * Family plugins that inject at the DOM level must notice when the shell
6
+ * re-renders around their injected node: the aggregate shell's column shims
7
+ * and any plugin surface still extending the shell from outside the official
8
+ * slot seats. Each consumer used to install its OWN `MutationObserver` on
9
+ * `document.body` with
10
+ * `{ childList: true, subtree: true }`, so a page carrying N family plugins
11
+ * paid N native observers and N callback invocations for EVERY mutation batch
12
+ * the app produced — chat token streaming alone produces many per second, and
13
+ * the count grows with the number of installed plugins.
14
+ *
15
+ * This module keeps exactly ONE body observer per page. The registry lives on
16
+ * `globalThis` under a `Symbol.for` key, so the per-package generated copies
17
+ * of this file (scripts/sync-shared.mjs) and separately bundled plugins all
18
+ * reach the same hub at runtime instead of one hub per module instance.
19
+ * Record subscribers receive the mutations accumulated since the last flush.
20
+ * Consumers that only re-check their DOM use subscribeBodyInvalidations:
21
+ * when all subscribers use that path, the hub retains no mutation records
22
+ * (or detached subtrees) while a background page's animation frames pause.
23
+ * Both paths run at most once per frame. The last subscriber disconnects the
24
+ * observer, cancels the pending frame and releases its records.
25
+ *
26
+ * Failure policy: without a DOM or `MutationObserver` the subscription is a
27
+ * no-op disposer (the same silence the per-consumer observers had), and when
28
+ * `requestAnimationFrame` is unavailable the flush runs synchronously so a
29
+ * subscriber is never silently dropped. A throwing subscriber cannot stop the
30
+ * others.
31
+ */
32
+ /**
33
+ * Subscribe to a coalesced DOM re-check without retaining mutation records.
34
+ * The marked wrapper also works with an older hub, which delivers records
35
+ * that it simply ignores until a page reload picks up the updated hub.
36
+ */
37
+ export declare function subscribeBodyInvalidations(subscriber: () => void): () => void;
38
+ /**
39
+ * Subscribe to body-level childList mutations.
40
+ * @param subscriber - called at most once per animation frame with the records
41
+ * collected since the previous flush; must be safe to run repeatedly.
42
+ * @returns the disposer removing this subscriber (and the observer when it was
43
+ * the last one).
44
+ */
45
+ export declare function subscribeBodyMutations(subscriber: (records: MutationRecord[]) => void): () => void;
@@ -24,6 +24,7 @@
24
24
  import type { Context as ClientContext } from '@deepseek-ai/cordis';
25
25
  import { type PluginUpdatePatchInjected } from './PluginUpdatePatch.tsx';
26
26
  import { type PluginManagerKey } from './locales.ts';
27
+ import { type RestartMode } from '../core/protocol.ts';
27
28
  import { type PluginManagerService } from '../core/service.ts';
28
29
  declare module '@deepseek-ai/dsh-client-ui-slots' {
29
30
  interface LocaleNamespaceMap {
@@ -39,7 +40,23 @@ export declare const inject: string[];
39
40
  * host still records install conflicts and boot failures; no client surface
40
41
  * consumes either since the tab left, so neither is on this face.
41
42
  */
42
- export type PluginManagerFace = PluginUpdatePatchInjected & PluginManagerService;
43
+ export type PluginManagerFace = PluginUpdatePatchInjected & PluginManagerService & {
44
+ /**
45
+ * Restart DSH so an applied plugin update is loaded. Always rides this
46
+ * package's own loopback route: neither official channel
47
+ * (`/plugin-installer`, `/plugin-control`) has a restart method, and the
48
+ * route answers how the restart was carried out (in-place relaunch, or a
49
+ * packaged Desktop shell that owns the process tree). See host/restart.ts.
50
+ */
51
+ restart: () => Promise<RestartMode>;
52
+ /**
53
+ * Read how a restart would be carried out without triggering it (the same
54
+ * route's plan read). The toolbar words its confirmation from this, so a
55
+ * packaged Desktop host can say what its system dialog will do instead of
56
+ * surprising the user with it.
57
+ */
58
+ restartPlan: () => Promise<RestartMode>;
59
+ };
43
60
  /**
44
61
  * Build the dual-channel face once: official-channel and gateway-channel
45
62
  * implementations, the mode detection that picks between them, and the
@@ -2,8 +2,9 @@
2
2
  * Locale dictionaries for the plugin-manager's official-page patch. The zh
3
3
  * dictionary is the key source; the en dictionary mirrors the exact key set.
4
4
  *
5
- * The key set covers only what this package still renders: the
6
- * check-for-updates block on a bundle's page in the official Plugins panel.
5
+ * The key set covers only what this package renders: the check-for-updates
6
+ * block on a bundle's page in the official Plugins panel, and the list-level
7
+ * update toolbar mounted beside that panel's "Installed" heading.
7
8
  * The former tab's keys (inventory, conflicts, repair seeds, safe mode,
8
9
  * aggregate children) left with that tab.
9
10
  * @module @linxin666/dsh-client-ui-plugin-manager/client
@@ -19,7 +20,25 @@ declare const STATIC_ZH: {
19
20
  latest: string;
20
21
  updateRequiresDsh: string;
21
22
  updateBlockedDsh: string;
23
+ updateUnverifiedDsh: string;
22
24
  restartHint: string;
25
+ updatesAvailable: string;
26
+ updateAll: string;
27
+ updatingAll: string;
28
+ updateAllDone: string;
29
+ updatesPanelTitle: string;
30
+ thirdPartyOnly: string;
31
+ restartNow: string;
32
+ restarting: string;
33
+ restartConfirm: string;
34
+ restartPlanRelaunch: string;
35
+ restartPlanShell: string;
36
+ restartPlanManual: string;
37
+ restartShellWarning: string;
38
+ restartDesktopHint: string;
39
+ restartRelaunchHint: string;
40
+ restartManualHint: string;
41
+ cancel: string;
23
42
  failed: string;
24
43
  fetching: string;
25
44
  downloading: string;
@@ -39,7 +58,25 @@ export declare const zh: {
39
58
  latest: string;
40
59
  updateRequiresDsh: string;
41
60
  updateBlockedDsh: string;
61
+ updateUnverifiedDsh: string;
42
62
  restartHint: string;
63
+ updatesAvailable: string;
64
+ updateAll: string;
65
+ updatingAll: string;
66
+ updateAllDone: string;
67
+ updatesPanelTitle: string;
68
+ thirdPartyOnly: string;
69
+ restartNow: string;
70
+ restarting: string;
71
+ restartConfirm: string;
72
+ restartPlanRelaunch: string;
73
+ restartPlanShell: string;
74
+ restartPlanManual: string;
75
+ restartShellWarning: string;
76
+ restartDesktopHint: string;
77
+ restartRelaunchHint: string;
78
+ restartManualHint: string;
79
+ cancel: string;
43
80
  failed: string;
44
81
  fetching: string;
45
82
  downloading: string;
@@ -59,7 +96,25 @@ export declare const en: {
59
96
  latest: string;
60
97
  updateRequiresDsh: string;
61
98
  updateBlockedDsh: string;
99
+ updateUnverifiedDsh: string;
62
100
  restartHint: string;
101
+ updatesAvailable: string;
102
+ updateAll: string;
103
+ updatingAll: string;
104
+ updateAllDone: string;
105
+ updatesPanelTitle: string;
106
+ thirdPartyOnly: string;
107
+ restartNow: string;
108
+ restarting: string;
109
+ restartConfirm: string;
110
+ restartPlanRelaunch: string;
111
+ restartPlanShell: string;
112
+ restartPlanManual: string;
113
+ restartShellWarning: string;
114
+ restartDesktopHint: string;
115
+ restartRelaunchHint: string;
116
+ restartManualHint: string;
117
+ cancel: string;
63
118
  failed: string;
64
119
  fetching: string;
65
120
  downloading: string;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Mounting the update toolbar beside the official Plugins page's "Installed"
3
+ * heading.
4
+ *
5
+ * The page renders that heading itself — `<section data-plugin-group="bundles">
6
+ * <div class="groupHead"><h3>Installed</h3><span>7</span></div>…` — and declares
7
+ * no seat next to it: its extension points are `plugins.detail.*` (per page),
8
+ * `plugins.bundle.config` / `plugins.row.config` / `plugins.item` (configuration
9
+ * entries) and `plugins.bundle.activation`. A list-level action therefore has
10
+ * to be inserted into the page's own chrome, the same way the sidebar foot card
11
+ * is inserted above the Settings row.
12
+ *
13
+ * The container is a plain element carrying its own React root, so it can never
14
+ * disturb the page's reconciliation, and it re-seats itself through the
15
+ * page-wide body-mutation hub: a re-render that relocates or drops the heading
16
+ * is followed on the next frame, and a panel switch that unmounts the list
17
+ * simply detaches the container until the list returns.
18
+ * @module @linxin666/dsh-client-ui-plugin-manager/client
19
+ */
20
+ import { type PluginListToolbarProps } from './PluginListToolbar.tsx';
21
+ /** Stable attribute identifying the injected container (mount idempotency). */
22
+ export declare const TOOLBAR_MOUNT_SELECTOR = "[data-dsh-plugin-manager-toolbar]";
23
+ /** Toolbar props without the translate function, which is rebuilt per render. */
24
+ export type PluginListToolbarMountInput = Omit<PluginListToolbarProps, 't'> & {
25
+ /** Translate in the namespace, read on every render so a language switch lands. */
26
+ t: PluginListToolbarProps['t'];
27
+ };
28
+ /** The mount's inputs. */
29
+ export interface PluginToolbarMountOptions {
30
+ /** Build the toolbar props; called on mount and on every locale change. */
31
+ props: () => PluginListToolbarMountInput;
32
+ /** Locale change subscription (ctx.locale.subscribe); re-renders the toolbar. */
33
+ subscribe?: (listener: () => void) => () => void;
34
+ }
35
+ /**
36
+ * The official page's "Installed" group heading, when it is mounted. Class
37
+ * names are CSS-module hashes in the official bundle, so the seat is found
38
+ * through the page's own data attributes plus DOM position.
39
+ * @returns the heading element to append into, or undefined off the list view.
40
+ */
41
+ export declare function toolbarSeat(): HTMLElement | undefined;
42
+ /**
43
+ * Mount the toolbar into the Installed heading.
44
+ * @param options - props factory and the optional locale subscription.
45
+ * @returns disposer removing the container, its observers and its React root.
46
+ */
47
+ export declare function mountPluginListToolbar(options: PluginToolbarMountOptions): () => void;
@@ -43,6 +43,13 @@ export interface InstalledPluginItem {
43
43
  */
44
44
  children?: InstalledPluginChild[];
45
45
  }
46
+ /**
47
+ * How the host carried out (or refused) a restart request:
48
+ * `relaunch` — this host re-executes itself in place; `shell` — the packaged
49
+ * Desktop shell owns the process tree and runs its own restart; `manual` —
50
+ * neither is safe here, the user restarts DSH themselves.
51
+ */
52
+ export type RestartMode = 'relaunch' | 'shell' | 'manual';
46
53
  /** Point-in-time install/update progress reported by the host. */
47
54
  export interface InstallProgressItem {
48
55
  kind: 'idle' | 'install' | 'update';
@@ -66,6 +73,12 @@ export interface PluginUpdateItem {
66
73
  requiresDsh?: string;
67
74
  /** Whether the running DSH host satisfies requiresDsh; absent when unknown. */
68
75
  compatible?: boolean;
76
+ /**
77
+ * The running DSH version the verdict was made from, when the host could read
78
+ * it. Its absence is what separates "this host is too old" from "this host
79
+ * could not be asked" — different problems, with different copy (issue #1819).
80
+ */
81
+ hostVersion?: string;
69
82
  }
70
83
  /** One recorded plugin boot failure served by the host. */
71
84
  export interface PluginFailureItem {
@@ -109,6 +122,12 @@ export declare function parseInstallStatus(value: unknown): InstallProgressItem;
109
122
  * @returns typed update rows.
110
123
  */
111
124
  export declare function parseUpdateList(value: unknown): PluginUpdateItem[];
125
+ /**
126
+ * Validate and normalize a `restart` response value.
127
+ * @param value - decoded but untrusted response value.
128
+ * @returns the mode the host actually used.
129
+ */
130
+ export declare function parseRestartMode(value: unknown): RestartMode;
112
131
  /**
113
132
  * Validate and normalize a `failures` response value.
114
133
  * @param value - decoded but untrusted response value.
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Which update rows the list-level toolbar may act on. Pure, shared by the
3
+ * browser half (the toolbar) and its tests: the host answers with every
4
+ * installed package whose registry source serves a newer release, and the
5
+ * policy of what may be updated in bulk lives here rather than in the host,
6
+ * so the same rows stay available to the per-page update block.
7
+ *
8
+ * Two filters:
9
+ *
10
+ * - **Third-party only.** A package published under the `@deepseek-ai/` scope
11
+ * ships with DSH itself: its version is chosen by the running installation,
12
+ * the official page says an upgrade arrives by upgrading DSH, and a
13
+ * plugin-initiated `pnpm add` of such a package can pull a release the runtime was
14
+ * never tested against. The bulk action therefore never touches it.
15
+ * - **Compatibility gate.** An update whose manifest declares a DSH minimum the
16
+ * running host does not satisfy is listed (the user may still upgrade DSH)
17
+ * but cannot be applied: the host would refuse it with 412 anyway.
18
+ * @module @linxin666/dsh-client-ui-plugin-manager/core
19
+ */
20
+ import type { PluginUpdateItem } from './protocol.ts';
21
+ /** The npm scope DSH's own packages are published under. */
22
+ export declare const OFFICIAL_SCOPE = "@deepseek-ai/";
23
+ /** Whether a package id is a third-party plugin rather than a DSH-shipped one. */
24
+ export declare function isThirdPartyPlugin(id: string): boolean;
25
+ /** The third-party update rows, in host order. */
26
+ export declare function thirdPartyUpdates(items: readonly PluginUpdateItem[]): PluginUpdateItem[];
27
+ /** Whether the running DSH host satisfies the row's declared minimum. */
28
+ export declare function isUpdateApplicable(item: PluginUpdateItem): boolean;
29
+ /** The third-party rows this runtime can actually apply. */
30
+ export declare function applicableUpdates(items: readonly PluginUpdateItem[]): PluginUpdateItem[];
@@ -55,7 +55,9 @@ export declare function meetsMinimumDsh(host: string, minimum: string): boolean
55
55
  export declare function displayMinimumVersion(minimum: string): string;
56
56
  /**
57
57
  * Read the declared DSH minimum from a published registry manifest:
58
- * `dsh.engines.dsh` first, top-level `engines.dsh` as the fallback.
58
+ * `dsh.engines.dsh` first, top-level `engines.dsh` next, and
59
+ * `peerDependencies["@deepseek-ai/dsh"]` last, which is where a package that
60
+ * only declares the host as a peer still gets gated at boot.
59
61
  * Defensive against malformed or untrusted metadata: anything that is not a
60
62
  * non-empty string reads as absent.
61
63
  * @param manifest - the decoded registry version manifest.
@@ -64,4 +66,5 @@ export declare function displayMinimumVersion(minimum: string): string;
64
66
  export declare function dshRequirementOf(manifest: {
65
67
  dsh?: unknown;
66
68
  engines?: unknown;
69
+ peerDependencies?: unknown;
67
70
  }): string | undefined;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Run one piece of work outside the caller's async context.
3
+ *
4
+ * A Host mutation that runs inside `hmr.runExclusive` marks the running async
5
+ * context with an AsyncLocalStorage store. Side effects on that path that write
6
+ * a file the HMR config watcher refreshes from - `cordis.patch.yml` above all -
7
+ * must not run under that mark, or the watcher's refresh re-enters the
8
+ * exclusive transaction and is refused with "HMR transactions cannot be nested"
9
+ * (#1751, #1754, #1816).
10
+ *
11
+ * Deferring is NOT enough, and the earlier belt that this one replaces was
12
+ * built on a disproven premise: Node propagates an AsyncLocalStorage store into
13
+ * `setImmediate`, into `node:timers`, into promise continuations, and into any
14
+ * AsyncResource scoped to the current async id. Measured on Node 24:
15
+ *
16
+ * ```
17
+ * als.run(true, () => setImmediate(() => als.getStore())) // -> true
18
+ * ```
19
+ *
20
+ * What DOES start clean is an AsyncResource whose `triggerAsyncId` is not the
21
+ * transaction. A resource created once at module scope - that is, before any
22
+ * transaction existed - carries no store, and everything it schedules inherits
23
+ * that emptiness rather than the caller's mark:
24
+ *
25
+ * ```
26
+ * const detached = new AsyncResource('...') // module scope
27
+ * als.run(true, () => detached.runInAsyncScope(() => setImmediate(() => als.getStore())))
28
+ * // -> undefined
29
+ * ```
30
+ *
31
+ * @module dsh-web-shared/host/detached-work
32
+ */
33
+ /**
34
+ * Run `work` outside the caller's AsyncLocalStorage context.
35
+ *
36
+ * The call itself is synchronous - this schedules, it does not defer. Work that
37
+ * must not block the caller should schedule its own `setImmediate` inside
38
+ * `work`, which then also starts clean because it inherits this resource's
39
+ * empty context rather than the caller's.
40
+ *
41
+ * @param work - the side effect to detach from the caller's async context.
42
+ * @returns whatever `work` returns.
43
+ */
44
+ export declare function runDetached<T>(work: () => T): T;
@@ -52,7 +52,7 @@ export interface GatewayJob {
52
52
  error?: string;
53
53
  }
54
54
  /** The binary search roots for the dsh CLI. */
55
- export declare function findDshBinary(env?: NodeJS.ProcessEnv, platform?: string, exists?: (path: string) => boolean, hostEntryPath?: string | undefined): string | null;
55
+ export declare function findDshBinary(env?: NodeJS.ProcessEnv, platform?: string, exists?: (path: string) => boolean, hostEntryPath?: string | undefined, resourcesPath?: string | undefined): string | null;
56
56
  /**
57
57
  * Read a file's leading bytes for the shebang probe. Every failure — a missing
58
58
  * file, a directory, a permission error, an unreadable asar entry — reads as
@@ -22,6 +22,14 @@ export interface LaunchedProfile {
22
22
  name?: unknown;
23
23
  dir?: unknown;
24
24
  patchPath?: unknown;
25
+ /**
26
+ * Absolute path of the running installation's own `@deepseek-ai/dsh`
27
+ * package.json — the launcher's install anchor. Its `version` IS the version
28
+ * of the DSH this process booted, so it answers the compatibility question
29
+ * without spawning anything; on a packaged Desktop install it is the only
30
+ * source that does, because no `dsh` reaches that host's PATH (issue #1819).
31
+ */
32
+ installAnchor?: unknown;
25
33
  }
26
34
  /** Resolved locations of one profile's writable surface. */
27
35
  export interface ProfileFacts {
@@ -43,6 +51,26 @@ export interface ProfileFacts {
43
51
  export declare function stripBom(text: string): string;
44
52
  /** Read the packaged desktop app's persisted active profile, when present. */
45
53
  export declare function desktopSelectedProfile(env?: NodeJS.ProcessEnv): string | undefined;
54
+ /**
55
+ * The running installation's own `@deepseek-ai/dsh` package.json, as the
56
+ * launcher published it on `profileContext`, or undefined when the host
57
+ * publishes none (or publishes something unusable). This is a READ-ONLY
58
+ * fact — unlike the profile directory and the patch path it is never a write
59
+ * target — but it still arrives from outside this package, so it must be an
60
+ * absolute, traversal-free path before anything reads a version out of it.
61
+ * @param launched - the profile facts the Host published, when available.
62
+ * @returns the validated anchor path, or undefined.
63
+ */
64
+ export declare function launchedInstallAnchor(launched: LaunchedProfile | undefined): string | undefined;
65
+ /**
66
+ * Read the `version` field of one package manifest, tolerating every failure:
67
+ * a missing file, an unreadable one (a stripped asar entry), malformed JSON, or
68
+ * a non-string version all read as "no version". Callers fall back to their next
69
+ * source rather than reporting a version nobody declared.
70
+ * @param manifestPath - absolute path of a package.json.
71
+ * @returns the declared version, or undefined.
72
+ */
73
+ export declare function readManifestVersion(manifestPath: string): string | undefined;
46
74
  /**
47
75
  * Whether the host argv names the packaged Desktop launcher, whose entry
48
76
  * script is `@deepseek-ai/dsh-desktop-host`. The Desktop client boots the
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Restart planning and execution for the plugin-manager gateway.
3
+ *
4
+ * The plugin page's restart action exists to make an applied plugin update
5
+ * effective, which means the DSH host process must come back with the new
6
+ * packages loaded. How that is achieved depends entirely on who launched this
7
+ * process, and the host can only tell that from its own facts:
8
+ *
9
+ * - A packaged Desktop launch (the Electron shell's child process, see
10
+ * isPackagedDesktopArgv / ELECTRON_RUN_AS_NODE) cannot be relaunched by a
11
+ * plugin: Electron owns the process tree, and anything this process spawns
12
+ * would fight the shell for the same port while Electron reports the host as
13
+ * crashed. The plugin therefore stops the host and lets the shell run the
14
+ * restart it already owns (app.relaunch(), the same recovery action the
15
+ * Desktop app offers after installing a downloaded update). Mode 'shell'.
16
+ * - A host this plugin can prove is a terminal launch (an interactive stdio
17
+ * pair, no Electron in the environment) is restarted in place: a detached
18
+ * helper waits for this process to exit and re-executes the same command
19
+ * line, so the port is free before the replacement binds it. Mode 'relaunch'.
20
+ * - Everything else — a supervisor-managed launch with piped stdio, a shell
21
+ * this plugin cannot identify — is left alone: the route answers 'manual'
22
+ * and this process keeps running rather than dying with no replacement.
23
+ * Mode 'manual'.
24
+ *
25
+ * The decision is pure ({@link planRestart}) so the modes are testable without
26
+ * spawning anything; {@link performRestart} is the effectful half.
27
+ * @module @linxin666/dsh-client-ui-plugin-manager/host
28
+ */
29
+ /** How a restart request is carried out. */
30
+ export type RestartMode = 'shell' | 'relaunch' | 'manual';
31
+ /** The command line a relaunch re-executes. */
32
+ export interface RelaunchCommand {
33
+ /** Absolute path of the executable (Node, or the Electron binary in Node mode). */
34
+ execPath: string;
35
+ /** argv after the script path: what `node <argv[0]> <argv[1..]>` ran. */
36
+ argv: string[];
37
+ /** Working directory the replacement starts in. */
38
+ cwd: string;
39
+ /** Environment the replacement and its plugin subprocesses inherit. */
40
+ env: NodeJS.ProcessEnv;
41
+ }
42
+ /** One restart verdict. */
43
+ export interface RestartPlan {
44
+ mode: RestartMode;
45
+ /** Present exactly when mode is 'relaunch'. */
46
+ command?: RelaunchCommand;
47
+ }
48
+ /** The process facts the verdict is derived from. */
49
+ export interface RestartFacts {
50
+ /** Whether the running profile was inferred from the packaged Desktop launcher. */
51
+ desktop?: boolean;
52
+ env: NodeJS.ProcessEnv;
53
+ execPath: string;
54
+ argv: readonly string[];
55
+ execArgv?: readonly string[];
56
+ cwd: string;
57
+ /** Whether stdio is a terminal (a launch a human can see and stop). */
58
+ interactive: boolean;
59
+ }
60
+ /** Grace period between answering the restart request and leaving the process. */
61
+ export declare const RESTART_EXIT_DELAY_MS = 400;
62
+ /** How long the helper waits for this process to disappear before giving up on the wait. */
63
+ export declare const RESTART_WAIT_MS = 30000;
64
+ /**
65
+ * Decide how a restart request is carried out.
66
+ * @param facts - the running process's launch facts.
67
+ * @returns the planned mode, with the relaunch command when one is used.
68
+ */
69
+ export declare function planRestart(facts: RestartFacts): RestartPlan;
70
+ /** Absolute path of the relaunch journal this plugin appends to. */
71
+ export declare function restartLogPath(home?: string): string;
72
+ /**
73
+ * Start the detached relaunch helper.
74
+ * @param command - the command line the replacement runs.
75
+ * @param logPath - journal the helper (and the replacement's output) appends to.
76
+ * @returns true when a helper process was actually created.
77
+ */
78
+ export declare function startRelaunchHelper(command: RelaunchCommand, logPath?: string): boolean;
79
+ /** Effect seams for {@link performRestart} (tests replace them). */
80
+ export interface RestartRuntime {
81
+ /** Start the relaunch helper; false means no replacement was created. */
82
+ startHelper?: (command: RelaunchCommand) => boolean;
83
+ /** Leave this process. */
84
+ exit?: () => void;
85
+ /** Schedule the exit (delay seam). */
86
+ schedule?: (run: () => void, delayMs: number) => void;
87
+ }
88
+ /**
89
+ * Carry out one restart plan.
90
+ * @param plan - the verdict from {@link planRestart}.
91
+ * @param runtime - effect seams; the defaults spawn the helper and exit.
92
+ * @returns the mode actually used: 'relaunch' degrades to 'manual' when the
93
+ * helper could not be started, so a process that cannot be replaced stays up.
94
+ */
95
+ export declare function performRestart(plan: RestartPlan, runtime?: RestartRuntime): RestartMode;
@@ -11,6 +11,7 @@ import type { WebRoute } from '@deepseek-ai/dsh-host-webserver';
11
11
  import { type CliGateway } from './gateway.ts';
12
12
  import { type ProfileFacts } from './profile.ts';
13
13
  import { buildPluginRow } from './state.ts';
14
+ import { type RestartFacts, type RestartRuntime } from './restart.ts';
14
15
  /** Route prefix the browser half mirrors. */
15
16
  export declare const GATEWAY_PREFIX = "/api/plugin-manager";
16
17
  /** Dependencies every route shares. */
@@ -26,10 +27,24 @@ export interface GatewayRouteDeps {
26
27
  /** Registry fetch seam for update checks (test seam); the default reads the
27
28
  * `/<name>/latest` manifest including the `dsh` / `engines` metadata. */
28
29
  fetchManifest?: (name: string) => Promise<RegistryVersionManifest | undefined>;
29
- /** Running DSH host version seam (test seam); the default probes `dsh --version`. */
30
+ /**
31
+ * Running DSH host version seam (test seam). The default reads the version of
32
+ * the running installation in process, then falls back to `dsh --version`.
33
+ */
30
34
  dshVersion?: () => Promise<string | undefined>;
35
+ /**
36
+ * The running installation's own `@deepseek-ai/dsh` package.json, when the
37
+ * launcher published one. It is the primary version source: the file belongs
38
+ * to the runtime this process booted, so reading it needs no subprocess and no
39
+ * PATH — which a packaged Desktop host does not have (issue #1819).
40
+ */
41
+ installAnchor?: string;
31
42
  /** Official-channel detection seam (test seam); defaults to the boot dump probe. */
32
43
  officialChannels?: () => Promise<boolean>;
44
+ /** Launch-fact seam for the restart route (test seam); defaults to this process. */
45
+ restartFacts?: () => RestartFacts;
46
+ /** Restart effect seam (test seam); defaults to the detached helper plus a real exit. */
47
+ restartRuntime?: RestartRuntime;
33
48
  }
34
49
  /** The published `/latest` manifest: version plus the compat metadata fields. */
35
50
  export interface RegistryVersionManifest {
@@ -13,7 +13,9 @@ import { type ProfileFacts } from './profile.ts';
13
13
  * itself (the UI performing the write), the family settings surface the tab
14
14
  * injects into, and the aggregate compat face (disabling it unmounts the
15
15
  * whole folded client bundle while host rows keep running — a half-dead
16
- * page). Covers both the standalone and the aggregate row ids.
16
+ * page). Covers both the standalone and the aggregate row ids. The standalone
17
+ * id is this package's own `cordis.patch.yml` insert id, never the official
18
+ * `ui-plugin-manager` row the DSH web-app bundle already claims.
17
19
  */
18
20
  export declare const LOCKED_ENTRY_IDS: ReadonlySet<string>;
19
21
  /** The listing result: plugin rows plus the raw layer snapshot for diffs. */
@@ -12,8 +12,13 @@
12
12
  * @module @linxin666/dsh-client-ui-plugin-manager
13
13
  */
14
14
  import type { Context } from '@deepseek-ai/cordis';
15
- /** Stable cordis plugin name (matches cordis.patch.yml insert id). */
16
- export declare const name = "ui-plugin-manager";
15
+ /**
16
+ * Stable cordis plugin name (matches this package's own cordis.patch.yml
17
+ * insert id). It must not repeat an id another bundle already claims: the
18
+ * loader keeps one entry per id, so a shared id would also give two host
19
+ * halves one cordis plugin name.
20
+ */
21
+ export declare const name = "ui-plugin-manager-update-check";
17
22
  /** Services the gateway needs — the web server seam. */
18
23
  export declare const inject: string[];
19
24
  /** Apply the host half (once per process). */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-client-ui-plugin-manager",
3
3
  "description": "Update checking for the dsh web GUI's official Plugins page: compares installed plugins against the version their registry source serves, gates the update on the DSH runtime minimum the release declares, and drives the update through the official installer channel or this package's loopback CLI gateway.",
4
- "version": "0.4.4",
4
+ "version": "0.4.6",
5
5
  "icon": "icon.svg",
6
6
  "type": "module",
7
7
  "main": "lib/index.js",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dsh": {
22
22
  "engines": {
23
- "dsh": ">=0.2.0-rc.1"
23
+ "dsh": ">=0.2.0-rc.2"
24
24
  },
25
25
  "bundle": {
26
26
  "patch": "./cordis.patch.yml"
@@ -34,21 +34,21 @@
34
34
  }
35
35
  },
36
36
  "peerDependencies": {
37
- "@deepseek-ai/dsh": ">=0.2.0-rc.1",
37
+ "@deepseek-ai/dsh": ">=0.2.0-rc.2",
38
38
  "react": "^18.2.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@deepseek-ai/cordis": "^4.0.4",
42
- "@deepseek-ai/dsh-api-session-controller": "^0.2.0-rc.1",
43
- "@deepseek-ai/dsh-api-workspace-controller": "^0.2.0-rc.1",
44
- "@deepseek-ai/dsh-client-connection": "^0.2.0-rc.1",
45
- "@deepseek-ai/dsh-client-locale": "^0.2.0-rc.1",
46
- "@deepseek-ai/dsh-client-ui-primitives": "^0.2.0-rc.1",
47
- "@deepseek-ai/dsh-client-ui-renderer": "^0.2.0-rc.1",
48
- "@deepseek-ai/dsh-client-ui-settings": "^0.2.0-rc.1",
49
- "@deepseek-ai/dsh-client-ui-slots": "^0.2.0-rc.1",
50
- "@deepseek-ai/dsh-client-ui-workspace": "^0.2.0-rc.1",
51
- "@deepseek-ai/dsh-host-webserver": "^0.2.0-rc.1",
42
+ "@deepseek-ai/dsh-api-session-controller": "^0.2.0-rc.2",
43
+ "@deepseek-ai/dsh-api-workspace-controller": "^0.2.0-rc.2",
44
+ "@deepseek-ai/dsh-client-connection": "^0.2.0-rc.2",
45
+ "@deepseek-ai/dsh-client-locale": "^0.2.0-rc.2",
46
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.2.0-rc.2",
47
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.2.0-rc.2",
48
+ "@deepseek-ai/dsh-client-ui-settings": "^0.2.0-rc.2",
49
+ "@deepseek-ai/dsh-client-ui-slots": "^0.2.0-rc.2",
50
+ "@deepseek-ai/dsh-client-ui-workspace": "^0.2.0-rc.2",
51
+ "@deepseek-ai/dsh-host-webserver": "^0.2.0-rc.2",
52
52
  "@testing-library/react": "^16.1.0",
53
53
  "@types/node": "^22.20.0",
54
54
  "@types/react": "~18.3.1",
@@ -61,7 +61,10 @@
61
61
  "vitest": "^4.1.1"
62
62
  },
63
63
  "files": [
64
- "lib",
64
+ "lib/**/*.js",
65
+ "lib/**/*.js.map",
66
+ "lib/**/*.d.ts",
67
+ "lib/**/*.d.ts.map",
65
68
  "cordis.patch.yml",
66
69
  "README.md",
67
70
  "README.zh.md",
@@ -73,7 +76,7 @@
73
76
  "yaml": "^2.8.2"
74
77
  },
75
78
  "scripts": {
76
- "build": "tsc -p tsconfig.build.json && tsdown",
79
+ "build": "tsc -b tsconfig.build.json && tsdown",
77
80
  "watch": "tsdown --watch",
78
81
  "test": "vitest run",
79
82
  "typecheck": "tsc --noEmit"