@linxin666/dsh-client-ui-plugin-manager 0.4.2 → 0.4.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.
@@ -6,6 +6,11 @@
6
6
  * CLI changed (the conflict ledger). The npm web runtime has no installer
7
7
  * service, so this gateway is its write path; on runtimes with official
8
8
  * channels the browser half never calls it.
9
+ *
10
+ * One exception: an application-owned profile (a packaged Desktop launch)
11
+ * cannot be written by the CLI at all — the official launcher refuses it — so
12
+ * installs, updates and removals there run through the official in-process
13
+ * plugin manager instead (see {@link NativePluginManager}).
9
14
  * @module @linxin666/dsh-client-ui-plugin-manager/host
10
15
  */
11
16
  import type { InstalledPluginItem } from '../core/protocol.ts';
@@ -49,23 +54,75 @@ export interface GatewayJob {
49
54
  /** The binary search roots for the dsh CLI. */
50
55
  export declare function findDshBinary(env?: NodeJS.ProcessEnv, platform?: string, exists?: (path: string) => boolean, hostEntryPath?: string | undefined): string | null;
51
56
  /**
52
- * The spawn command for the dsh CLI on this platform. Windows runs the
53
- * npm-generated dsh.cmd wrapper by resolving its node binary and bin.js script
54
- * and spawning them directly: going through cmd.exe splits unquoted paths with
55
- * spaces (`'D:\Program' is not recognized`).
57
+ * Read a file's leading bytes for the shebang probe. Every failure — a missing
58
+ * file, a directory, a permission error, an unreadable asar entry — reads as
59
+ * "no head", so the caller falls back to spawning the path directly.
60
+ * @param path - file to probe.
61
+ * @returns the leading text, or undefined.
62
+ */
63
+ export declare function readFileHead(path: string): string | undefined;
64
+ /**
65
+ * Whether a resolved CLI path is a Node script: a `.js` module, or a file whose
66
+ * shebang names node. A Node script cannot be spawned as an executable on its
67
+ * own: the kernel hands the shebang to the interpreter it names, and
68
+ * `#!/usr/bin/env node` resolves node through PATH — which a GUI-launched host
69
+ * (the packaged Desktop app) does not carry, so the child dies before the CLI
70
+ * starts with `env: node: No such file or directory` (exit 127).
71
+ * @param path - the resolved CLI path.
72
+ * @param readHead - head probe (test seam).
73
+ * @returns true when the path needs a Node interpreter.
74
+ */
75
+ export declare function isNodeScript(path: string, readHead?: (path: string) => string | undefined): boolean;
76
+ /**
77
+ * The spawn command for the dsh CLI on this platform. A Node script (the
78
+ * npm/homebrew `dsh` shim, a `.bin` symlink, a packaged `lib/bin.js`) is run
79
+ * by an interpreter that exists regardless of PATH: a `node` sitting beside the
80
+ * CLI when the installation ships one (npm-global and homebrew layouts), else
81
+ * the host's own interpreter — `process.execPath`, which the ELECTRON_RUN_AS_NODE
82
+ * branch in {@link spawnDsh} covers for an Electron host. Windows additionally
83
+ * resolves the npm-generated shim into node plus bin.js and spawns them
84
+ * directly: going through cmd.exe splits unquoted paths with spaces
85
+ * (`'D:\Program' is not recognized`).
56
86
  * @param binary - the dsh CLI path found by {@link findDshBinary}.
57
87
  * @param platform - process platform (test seam).
58
88
  * @param localNodeExists - existence probe (test seam).
59
89
  * @param binJsExists - existence probe for the resolved bin script (test seam).
90
+ * @param readHead - shebang probe (test seam).
60
91
  * @returns the executable and the argument prefix to run the dsh bin script.
61
92
  */
62
- export declare function dshSpawnCommand(binary: string, platform?: string, localNodeExists?: (path: string) => boolean, binJsExists?: (path: string) => boolean): {
93
+ export declare function dshSpawnCommand(binary: string, platform?: string, localNodeExists?: (path: string) => boolean, binJsExists?: (path: string) => boolean, readHead?: (path: string) => string | undefined): {
63
94
  command: string;
64
95
  argsPrefix: string[];
65
96
  };
66
97
  /** Build the exact cmd.exe command line required to execute a trusted .cmd shim. */
67
98
  export declare function windowsCmdShimArgs(binary: string, args: readonly string[]): string[];
68
- /** Spawn the dsh CLI with piped stdio and no shell parsing (see {@link dshSpawnCommand}). */
99
+ /**
100
+ * Prepend one directory to a child environment's PATH, collapsing every case
101
+ * variant of the key into one `PATH`. Windows exposes the variable as `Path`,
102
+ * and spreading `process.env` into a plain object preserves that spelling:
103
+ * assigning `env.PATH` beside it would leave two keys whose serialization
104
+ * drops the system directories (the desktop childEnv defect).
105
+ * @param env - the environment to copy.
106
+ * @param dir - directory to put first.
107
+ * @param platform - process platform (test seam).
108
+ * @returns a new environment with one normalized, prepended PATH.
109
+ */
110
+ export declare function withPrependedPath(env: NodeJS.ProcessEnv, dir: string, platform?: string): NodeJS.ProcessEnv;
111
+ /**
112
+ * Spawn the dsh CLI with piped stdio and no shell parsing (see
113
+ * {@link dshSpawnCommand}).
114
+ *
115
+ * The CLI's own directory goes first on the child PATH: npm-global, homebrew and
116
+ * packaged layouts keep `node`, `pnpm` and `npx` beside the `dsh` shim, and a
117
+ * GUI-launched host carries none of them on its own PATH — the CLI forwards
118
+ * `dsh plugin` to pnpm, so without this the update would start and then fail on
119
+ * a missing pnpm instead. This mirrors the packaged Desktop launcher, which
120
+ * prepends its bundled runtime bin to the host it spawns.
121
+ * @param binary - the resolved dsh CLI path.
122
+ * @param args - arguments after the interpreter/script prefix.
123
+ * @param env - the host environment.
124
+ * @returns the spawned child process.
125
+ */
69
126
  export declare function spawnDsh(binary: string, args: string[], env: NodeJS.ProcessEnv): import("child_process").ChildProcessByStdio<null, import("stream").Readable, import("stream").Readable>;
70
127
  /**
71
128
  * Detect whether the official installer channels exist on this runtime by
@@ -80,6 +137,74 @@ export declare function spawnDsh(binary: string, args: string[], env: NodeJS.Pro
80
137
  * @returns true when the dump names the official installer channels.
81
138
  */
82
139
  export declare function detectOfficialChannels(binary: string, profileName: string, env?: NodeJS.ProcessEnv, spawnImpl?: typeof spawnDsh): Promise<boolean>;
140
+ /**
141
+ * The official in-process plugin manager (`@deepseek-ai/dsh-plugin-manager`),
142
+ * read from the host context as a contract observation — not an import, exactly
143
+ * like the profile facts and the installer wire shapes this package already
144
+ * mirrors. It is the same writer the official Plugins page drives, and on an
145
+ * application-owned profile it is the ONLY writer: `dsh plugin --profile desktop
146
+ * …` is refused before pnpm starts ("profile \"desktop\" is managed
147
+ * exclusively by the Electron application"), and the launcher hands that
148
+ * manager its bundled package-manager invocation through launcher facts.
149
+ */
150
+ export interface NativePluginManager {
151
+ /**
152
+ * Install or update one package spec through the official manager.
153
+ * @param spec - package spec (e.g. `@scope/pkg@1.2.3`).
154
+ * @param options - activation choice and the request id the run is tracked under.
155
+ * @returns the manager's own verdict ({@link NativeManagerOutcome}); the caller
156
+ * re-reads the profile as well, but must read this first — a refusal resolves.
157
+ */
158
+ installBundle(spec: string, options?: {
159
+ enabled?: boolean;
160
+ requestId?: string;
161
+ }): Promise<unknown>;
162
+ /**
163
+ * Remove one profile-owned bundle through the official manager.
164
+ * @param name - installed dependency (bundle) name.
165
+ * @returns the manager's own verdict ({@link NativeManagerOutcome}); the caller
166
+ * re-reads the profile as well, but must read this first — a refusal resolves.
167
+ */
168
+ removeBundle(name: string): Promise<unknown>;
169
+ }
170
+ /**
171
+ * The verdict the official in-process manager returns for one mutation. Its
172
+ * internal `change()` wrapper never rejects a failed operation: it folds the
173
+ * failure into this resolved value (`application: 'failed'` plus `error`), so a
174
+ * resolved promise is not proof the profile moved. Reading only whether the
175
+ * call threw reported a refused pnpm run as "the manager succeeded but nothing
176
+ * changed" and hid the real reason (2026-09-29: `dsh-better-sidebar` update
177
+ * blocked by `ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION`). Contract observation,
178
+ * shape mirrored from `@deepseek-ai/dsh-plugin-manager`.
179
+ */
180
+ export interface NativeManagerOutcome {
181
+ /** `applied` or `restart-required` on success, `cancelled`, or `failed`. */
182
+ application?: string;
183
+ /** Whether the profile files differ from before the run. */
184
+ changed?: boolean;
185
+ /** Present when `application` is `failed`. */
186
+ error?: {
187
+ /** The manager's own failure code (`operation-error`, `incompatible-version`, …). */
188
+ code?: string;
189
+ /** Raw failure text for `operation-error` (the pnpm output tail). */
190
+ diagnostic?: string;
191
+ /** Packages an `incompatible-version` refusal names. */
192
+ incompatible?: readonly {
193
+ name?: string;
194
+ version?: string;
195
+ runtimeVersion?: string;
196
+ }[];
197
+ };
198
+ }
199
+ /**
200
+ * The official manager's own failure text for one run, or undefined when its
201
+ * verdict is not a failure. The manager resolves a failed run instead of
202
+ * rejecting it, so this is the only place its refusal can be read — the profile
203
+ * re-read afterwards can only say that nothing moved, never why.
204
+ * @param outcome - the resolved value of `installBundle` / `removeBundle`.
205
+ * @returns the failure text to report, or undefined for a run that did not fail.
206
+ */
207
+ export declare function nativeManagerFailure(outcome: unknown): string | undefined;
83
208
  /** The gateway: serializes CLI operations through one job table and one mutation queue. */
84
209
  export declare class CliGateway {
85
210
  private readonly facts;
@@ -99,6 +224,8 @@ export declare class CliGateway {
99
224
  constructor(facts: ProfileFacts, env?: NodeJS.ProcessEnv, deps?: {
100
225
  spawnImpl?: typeof spawnDsh;
101
226
  findBinary?: (env: NodeJS.ProcessEnv) => string | null;
227
+ /** The official in-process manager, when the runtime publishes one. */
228
+ nativeManager?: () => NativePluginManager | undefined;
102
229
  });
103
230
  /**
104
231
  * Run one profile mutation after every mutation already queued. The returned
@@ -114,6 +241,24 @@ export declare class CliGateway {
114
241
  private retainFinished;
115
242
  /** The dsh CLI path, through the test seam when present. */
116
243
  private binary;
244
+ /**
245
+ * The official in-process manager to write through, or undefined when the CLI
246
+ * is the writer. Only an application-owned profile (a packaged Desktop launch)
247
+ * takes this path: there the CLI refuses the profile outright, while the
248
+ * official manager — which the launcher configures with its bundled
249
+ * package-manager invocation — owns the same files this gateway reads. On
250
+ * every other runtime the CLI stays the single writer, exactly as before.
251
+ * @returns the manager, or undefined when the CLI should run.
252
+ */
253
+ private nativeManager;
254
+ /**
255
+ * Whether this gateway will write through the official in-process manager
256
+ * instead of the CLI (an application-owned profile, see
257
+ * {@link nativeManager}). The HTTP layer reads it so its CLI-availability
258
+ * guard never rejects a job the CLI is not going to run.
259
+ * @returns true when the native writer serves installs, updates and removals.
260
+ */
261
+ usesNativeWriter(): boolean;
117
262
  /** Run one CLI command to completion and return the bounded output. */
118
263
  private runCli;
119
264
  /** Full package spec used when restoring a legacy dependency. */
@@ -124,22 +269,85 @@ export declare class CliGateway {
124
269
  private rollbackMigration;
125
270
  /** Spawn the CLI, through the test seam when present. */
126
271
  private spawnCli;
127
- /** Start an install; the caller polls {@link status}. */
272
+ /**
273
+ * Start an install; the caller polls {@link status}. An application-owned
274
+ * profile runs it through the official in-process manager instead of the CLI
275
+ * (see {@link nativeManager}), exactly like {@link update}; the job table,
276
+ * polling contract and profile verification are identical either way.
277
+ */
128
278
  install(spec: string): {
129
279
  jobId: string;
130
280
  };
131
- /** Start an in-place npm update; the caller polls {@link status}. */
281
+ /**
282
+ * Start an in-place npm update; the caller polls {@link status}. An
283
+ * application-owned profile runs it through the official in-process manager
284
+ * instead of the CLI (see {@link nativeManager}), and the job/status/polling
285
+ * contract the browser half drives is identical either way.
286
+ */
132
287
  update(id: string, version: string): {
133
288
  jobId: string;
134
289
  };
290
+ /** Start an install through the official in-process manager. */
291
+ private enqueueNativeInstall;
292
+ /**
293
+ * Run one install through the official in-process manager (an
294
+ * application-owned profile, where the CLI refuses to write). The manager
295
+ * resolves the registry, runs pnpm with the launcher's bundled toolchain and
296
+ * applies the bundle, then this reads the profile the same way the CLI path
297
+ * does: the install is only `done` once the profile carries a dependency it
298
+ * did not carry before, so a green manager call that added nothing is still
299
+ * reported as a failure. Its resolved verdict is read first
300
+ * ({@link nativeManagerFailure}): the manager folds a refused run into that
301
+ * value instead of rejecting, and only the verdict names the reason. The
302
+ * CLI-specific guards are deliberately absent — the official manager
303
+ * validates and applies the bundle itself, exactly as it does for the
304
+ * official Plugins page.
305
+ * @param job - the install job being settled.
306
+ * @param native - the official manager.
307
+ */
308
+ private runNativeInstall;
309
+ /** Start an in-place update through the official in-process manager. */
310
+ private enqueueNativeUpdate;
311
+ /**
312
+ * Run one update through the official in-process manager (an application-owned
313
+ * profile, where the CLI refuses to write). The manager resolves the registry,
314
+ * runs pnpm with the launcher's bundled toolchain and applies the bundle, then
315
+ * this reads the profile the same way the CLI path does: the dependency must
316
+ * still be there and the installed version must be the one the route resolved,
317
+ * so a green manager call that changed nothing is still reported as a failure.
318
+ * Its resolved verdict is read first ({@link nativeManagerFailure}): a refused
319
+ * run (pnpm exited non-zero, an incompatible version, a cancellation) resolves
320
+ * with `application: 'failed'`, and only that verdict carries the reason — the
321
+ * profile re-read can only show that the version did not move.
322
+ * @param job - the update job being settled.
323
+ * @param native - the official manager.
324
+ */
325
+ private runNativeUpdate;
135
326
  /** Start a deterministic legacy aggregate migration. */
136
327
  migrate(sourceId: string, targetId: string, targetVersion: string, targetSpec: string): {
137
328
  jobId: string;
138
329
  };
139
- /** Start a removal; the caller polls {@link status}. */
330
+ /**
331
+ * Start a removal; the caller polls {@link status}. An application-owned
332
+ * profile removes through the official in-process manager, the same writer
333
+ * the install and update paths use there (the CLI refuses that profile).
334
+ */
140
335
  remove(id: string): {
141
336
  jobId: string;
142
337
  };
338
+ /** Start a removal through the official in-process manager. */
339
+ private enqueueNativeRemove;
340
+ /**
341
+ * Run one removal through the official in-process manager (an
342
+ * application-owned profile, where the CLI refuses to write). The removal is
343
+ * only `done` once a dependency the profile carried before is gone, exactly
344
+ * the verification the CLI path performs. Its resolved verdict is read first
345
+ * ({@link nativeManagerFailure}): a refused removal resolves with
346
+ * `application: 'failed'` rather than rejecting.
347
+ * @param job - the removal job being settled.
348
+ * @param native - the official manager.
349
+ */
350
+ private runNativeRemove;
143
351
  /**
144
352
  * Read one job's current state (a shallow copy). Finished jobs beyond the
145
353
  * ring cap are evicted and read as not-found, the same as an id that never
@@ -6,6 +6,23 @@
6
6
  * write goes through the official CLI or the patch-row editor.
7
7
  * @module @linxin666/dsh-client-ui-plugin-manager/host
8
8
  */
9
+ /**
10
+ * The launched-profile slice the official runtime publishes on the host
11
+ * context as `profileContext` (`{ name, dir, patchPath, installAnchor, ... }`).
12
+ * It is a contract observation, not an import: the gateway needs the same
13
+ * three facts the runtime already resolved, and rebuilding them from
14
+ * `--profile` / `DSH_HOME` cannot name the profile on a launcher that passes
15
+ * neither. This package still treats the value as foreign input: the name is
16
+ * traversal-checked, the directory must be an absolute traversal-free path,
17
+ * and the patch path is accepted only when it is the profile's own patch file
18
+ * — it is a WRITE target, so a foreign path there would redirect the
19
+ * gateway's row writes outside the profile it mounts.
20
+ */
21
+ export interface LaunchedProfile {
22
+ name?: unknown;
23
+ dir?: unknown;
24
+ patchPath?: unknown;
25
+ }
9
26
  /** Resolved locations of one profile's writable surface. */
10
27
  export interface ProfileFacts {
11
28
  /** Profile name (the directory under $DSH_HOME/profiles). */
@@ -27,15 +44,53 @@ export declare function stripBom(text: string): string;
27
44
  /** Read the packaged desktop app's persisted active profile, when present. */
28
45
  export declare function desktopSelectedProfile(env?: NodeJS.ProcessEnv): string | undefined;
29
46
  /**
30
- * Resolve the boot profile name from the host argv: an explicit `--profile`
31
- * flag wins, then the DSH_PROFILE environment override, then the `web`
32
- * subcommand alias. The launcher hands the app its own args verbatim, so the
33
- * web app's argv is the reliable source on every CLI-launched host.
47
+ * Whether the host argv names the packaged Desktop launcher, whose entry
48
+ * script is `@deepseek-ai/dsh-desktop-host`. The Desktop client boots the
49
+ * `desktop` profile through `runProfile()` WITHOUT a `--profile` flag and
50
+ * without exporting DSH_PROFILE, so argv is the only launcher fact left and
51
+ * the desktop channel probe must stay on for that shape (the packaged host
52
+ * registers the official installer services programmatically, which the CLI
53
+ * boot dump cannot see).
54
+ * @param argv - process argv.
55
+ */
56
+ export declare function isPackagedDesktopArgv(argv: readonly string[]): boolean;
57
+ /**
58
+ * The profile directory a packaged Desktop launch carries in its OWN argv.
59
+ * Electron under ELECTRON_RUN_AS_NODE (and node alike) strips exec switches
60
+ * from `process.argv`, so the desktop host launches as
61
+ * `[execPath, dsh-desktop-host/lib/index.js, <dsh>, <profileDir>, ...]` and
62
+ * hands the profile directory to its own `loadProfileDirectory` as that
63
+ * positional argument. This is a launcher fact independent of the
64
+ * `profileContext` service, so a runtime that publishes no service can
65
+ * still be named correctly; a published service stays authoritative above it.
66
+ * @param argv - process argv.
67
+ * @returns the absolute profile directory, or undefined when argv names none.
68
+ */
69
+ export declare function desktopProfileDirFromArgv(argv: readonly string[]): string | undefined;
70
+ /**
71
+ * Resolve the boot profile from the launcher facts: an explicit `--profile`
72
+ * flag wins, then the profile the official runtime published on the host
73
+ * context, then the profile directory a packaged launch carries in its own
74
+ * argv, then the DSH_PROFILE environment override, then the `web` subcommand
75
+ * alias, then the packaged Desktop app's persisted selection.
76
+ *
77
+ * Why the launched facts outrank DSH_PROFILE: in this runtime the variable is
78
+ * an OUTPUT, not a boot selector. `runProfile()` is the single launch path for
79
+ * CLI and Desktop alike and provides `profileContext` in both, and
80
+ * `@deepseek-ai/dsh-shell-env` DERIVES `DSH_PROFILE` from `profileContext.name`
81
+ * for the shell children it spawns; no runtime module reads it to choose a
82
+ * profile. Whenever both exist they therefore describe the same profile, and
83
+ * the service carries the more precise facts (the exact directory and patch
84
+ * file). A hand-set or stale value disagreeing with the running host is the
85
+ * one case where the order matters, and following it would mount the gateway -
86
+ * and write its rows - into a profile this host never reads.
34
87
  * @param argv - process argv (test seam).
35
88
  * @param env - process environment (test seam).
89
+ * @param launched - the profile facts the Host published, when available.
90
+ * @param desktopLauncher - whether argv names the packaged Desktop launcher.
36
91
  * @returns the resolved profile facts.
37
92
  */
38
- export declare function resolveProfile(argv?: readonly string[], env?: NodeJS.ProcessEnv): ProfileFacts;
93
+ export declare function resolveProfile(argv?: readonly string[], env?: NodeJS.ProcessEnv, launched?: LaunchedProfile, desktopLauncher?: boolean): ProfileFacts;
39
94
  /** The profile package.json surface the gateway reads. */
40
95
  export interface ProfileManifest {
41
96
  /** dsh.profile.bundles entries (may be absent). */
@@ -17,7 +17,11 @@ export declare const GATEWAY_PREFIX = "/api/plugin-manager";
17
17
  export interface GatewayRouteDeps {
18
18
  facts: ProfileFacts;
19
19
  gateway: CliGateway;
20
- /** Resolve the dsh binary presence (the CLI is the write path). */
20
+ /**
21
+ * Resolve the dsh binary presence. Only the CLI-backed writer needs it: an
22
+ * application-owned profile writes through the official in-process manager
23
+ * (`gateway.usesNativeWriter()`), so its routes must not demand a binary.
24
+ */
21
25
  cliAvailable: () => boolean;
22
26
  /** Registry fetch seam for update checks (test seam); the default reads the
23
27
  * `/<name>/latest` manifest including the `dsh` / `engines` metadata. */
@@ -4,19 +4,50 @@
4
4
  * the loader accepts a standalone install of the same package side by side;
5
5
  * without this guard the second instance would still re-register the same
6
6
  * webserver routes, tools, settings namespaces, and system-prompt sections
7
- * and fail the boot. mountOnce makes the second host apply a no-op for the
8
- * lifetime of the first instance (the browser half is already deduped by
9
- * package name in the client module host).
7
+ * and fail the boot. mountOnce makes a mount of an already-mounted package a
8
+ * no-op for as long as the first instance lives (the browser half is already
9
+ * deduped by package name in the client module host).
10
+ *
11
+ * A no-op is only safe while the holder is ALIVE. The holder can be disposed
12
+ * long after the refused mount ran its course: the Host reloads a profile by
13
+ * creating the new loader entries before the old ones are torn down (a
14
+ * plugin-manager enable/disable/install write, a settings-driven row reload,
15
+ * HMR), so the new aggregate shell entry mounts its family plugin while the
16
+ * previous entry still owns the name. Dropping that refused mount lost the
17
+ * plugin for good - the previous entry then disposed its own mount, releasing
18
+ * the name with nobody left to take it, and the family row stayed listed as
19
+ * active while its host routes 404ed (the task-board panel showed
20
+ * "board.hostError.notMounted", no degraded record appeared, and only a Host
21
+ * restart recovered it).
22
+ *
23
+ * The refused mount is therefore QUEUED, not dropped, and replayed the moment
24
+ * the holder releases the name - if the waiting fiber is still alive then. The
25
+ * single-instance guarantee is unchanged: exactly one mount is live per
26
+ * package name, and the replay re-enters the guard so a later mount still
27
+ * dedupes against it.
10
28
  *
11
29
  * The registry rides a global symbol so two module instances of the same
12
- * package (npm copy vs repository link) still share one verdict. cordis
13
- * `ctx.effect` runs its callback immediately and treats the callback's
30
+ * package (npm copy vs repository link) still share one verdict. That symbol
31
+ * is a CROSS-REPOSITORY contract, not this file's private state: the four
32
+ * satellite packages (dsh-skins / dsh-pet / dsh-presets /
33
+ * dsh-community-plugins) are separate repositories carrying their own copy of
34
+ * this guard, rebuilt on their own schedule, so the value under `MOUNTED`
35
+ * must keep the shape every published copy reads (a `Set` of package names
36
+ * with `has`/`add`/`delete`). The wait queues this guard added therefore live
37
+ * under their own additive key, and the registry reads back a `Set` even when
38
+ * some other build left a different value there. Changing `MOUNTED`'s shape
39
+ * in place broke that contract once: a satellite's legacy copy created a
40
+ * `Set`, the family's new copy read it as a `Map`, and every family row
41
+ * mounted after it failed with "claims.get is not a function".
42
+ *
43
+ * cordis `ctx.effect` runs its callback immediately and treats the callback's
14
44
  * return value as the fiber disposer, so the unmarker is returned, not run.
15
45
  */
16
46
  /**
17
47
  * Wrap a cordis plugin apply so the package runs at most once per process.
18
- * The first mount registers normally and unmarks when its fiber disposes;
19
- * any later mount of the same package name is a no-op.
48
+ * The first mount registers normally and releases the name when its fiber
49
+ * disposes; a mount refused while that name is held waits for the release and
50
+ * then runs, unless its own fiber disposes first.
20
51
  * @param packageName - npm package identity shared by every install source.
21
52
  * @param fn - the original plugin apply.
22
53
  * @returns an apply of the same shape.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-client-ui-plugin-manager",
3
- "description": "Plugin manager tab for the dsh web GUI Plugins settings section: installs plugins from npm or git through the official host channels, lists installed plugins with next-start enablement switches, surfaces install-time conflict actions with undo, and hands failures off to repair conversations.",
4
- "version": "0.4.2",
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",
5
5
  "icon": "icon.svg",
6
6
  "type": "module",
7
7
  "main": "lib/index.js",
@@ -20,39 +20,35 @@
20
20
  },
21
21
  "dsh": {
22
22
  "engines": {
23
- "dsh": ">=0.1.7-rc.2"
23
+ "dsh": ">=0.2.0-rc.1"
24
24
  },
25
25
  "bundle": {
26
26
  "patch": "./cordis.patch.yml"
27
27
  },
28
28
  "client": {
29
29
  "inject": [
30
- "@deepseek-ai/dsh-api-session-controller",
31
- "@deepseek-ai/dsh-api-workspace-controller",
32
30
  "@deepseek-ai/dsh-client-connection",
33
- "@deepseek-ai/dsh-client-ui-renderer",
34
- "@deepseek-ai/dsh-client-ui-settings",
35
- "@deepseek-ai/dsh-client-ui-workspace"
31
+ "@deepseek-ai/dsh-client-ui-renderer"
36
32
  ],
37
33
  "platform": "web"
38
34
  }
39
35
  },
40
36
  "peerDependencies": {
41
- "@deepseek-ai/dsh": ">=0.1.7-rc.2",
37
+ "@deepseek-ai/dsh": ">=0.2.0-rc.1",
42
38
  "react": "^18.2.0"
43
39
  },
44
40
  "devDependencies": {
45
41
  "@deepseek-ai/cordis": "^4.0.4",
46
- "@deepseek-ai/dsh-api-session-controller": "^0.1.7-rc.2",
47
- "@deepseek-ai/dsh-api-workspace-controller": "^0.1.7-rc.2",
48
- "@deepseek-ai/dsh-client-connection": "^0.1.7-rc.2",
49
- "@deepseek-ai/dsh-client-locale": "^0.1.7-rc.2",
50
- "@deepseek-ai/dsh-client-ui-primitives": "^0.1.7-rc.2",
51
- "@deepseek-ai/dsh-client-ui-renderer": "^0.1.7-rc.2",
52
- "@deepseek-ai/dsh-client-ui-settings": "^0.1.7-rc.2",
53
- "@deepseek-ai/dsh-client-ui-slots": "^0.1.7-rc.2",
54
- "@deepseek-ai/dsh-client-ui-workspace": "^0.1.7-rc.2",
55
- "@deepseek-ai/dsh-host-webserver": "^0.1.7-rc.2",
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",
56
52
  "@testing-library/react": "^16.1.0",
57
53
  "@types/node": "^22.20.0",
58
54
  "@types/react": "~18.3.1",
@@ -1,32 +0,0 @@
1
- import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
2
- import { type ControlChange } from '../core/conflict.ts';
3
- import type { InstallProgressItem, InstalledPluginItem, PluginControlItem, PluginFailuresSnapshot, PluginUpdateItem } from '../core/protocol.ts';
4
- /** Registration-side wire face used by the tab. */
5
- export interface PluginManagerTabInjected {
6
- /** Whether this browser has loopback authority to use the host routes. */
7
- isLoopback: boolean;
8
- /** Read the installed snapshot (the tab renders it read-only). */
9
- list: () => Promise<InstalledPluginItem[]>;
10
- /** Re-install one plugin from its recorded source. */
11
- update: (id: string) => Promise<InstalledPluginItem>;
12
- /** Compare installed versions against their sources. */
13
- checkUpdates: () => Promise<PluginUpdateItem[]>;
14
- /** Read the current install/update progress. */
15
- status: () => Promise<InstallProgressItem>;
16
- /** Read the recorded boot failures, plugin root, and safe-mode state. */
17
- failures: () => Promise<PluginFailuresSnapshot>;
18
- /** Persist the safe-mode marker (web: applied at the next manual restart). */
19
- setSafeMode: (enabled: boolean) => Promise<void>;
20
- /** Start a repair conversation over the plugin install root. */
21
- repairPlugin: (pluginRoot: string, message: string) => Promise<void>;
22
- /** Read the deployment-configured built-in product switches. */
23
- controlsList: () => Promise<PluginControlItem[]>;
24
- /** Persist one product's next-start enablement. */
25
- controlsSetEnabled: (pluginId: string, enabled: boolean) => Promise<PluginControlItem[]>;
26
- /** Conflicts the gateway host computed around the last install (gateway mode only). */
27
- lastInstallConflicts?: () => readonly ControlChange[];
28
- }
29
- /** Full component props assembled by the Settings slot renderer. */
30
- export type PluginManagerTabProps = PropsRuntime<'settings.plugins.tab'> & PropsLocale<'settings.pluginManager'> & InjectFace<PluginManagerTabInjected>;
31
- /** The plugin-manager settings tab. */
32
- export declare function PluginManagerTab(props: PluginManagerTabProps): import("react").JSX.Element;
@@ -1,58 +0,0 @@
1
- /**
2
- * Repair-conversation seed text. The failure surfaces this package still owns
3
- * hand off to the agent through the same shape: a recorded boot failure (the
4
- * failure-ring row) and an install-conflict change. The seeded message must be
5
- * self-contained — the repair session's workspace is the plugin install root,
6
- * so the agent's file tools reach the plugin code without leaving the
7
- * workspace boundary.
8
- *
9
- * Secret discipline: the seed carries only the spec, the host's truncated
10
- * failure message/stack, and paths. Callers must never append credentials,
11
- * tokens, or environment contents; the failure ring is the host's bounded,
12
- * pruned record and nothing else is added.
13
- * @module @linxin666/dsh-client-ui-plugin-manager/core
14
- */
15
- import type { PluginFailureItem } from './protocol.ts';
16
- import type { LayerState } from './patch-diff.ts';
17
- /** Localized fragments the builders assemble. */
18
- export interface RepairCopy {
19
- failureTitle: string;
20
- failurePluginLabel: string;
21
- failureKindLabel: string;
22
- failureAtLabel: string;
23
- failureMessageLabel: string;
24
- failureStackLabel: string;
25
- failurePathLabel: string;
26
- failureAsk: string;
27
- conflictTitle: string;
28
- conflictPluginLabel: string;
29
- conflictChangeLabel: string;
30
- conflictAsk: string;
31
- /** Localized names of the failure kinds. */
32
- kindNames: Record<PluginFailureItem['kind'], string>;
33
- /** Localized names of the layer states a conflict change traverses. */
34
- stateNames: Record<LayerState, string>;
35
- }
36
- /** Default copy (zh): the package's zh dictionary keys map onto these strings. */
37
- export declare const DEFAULT_REPAIR_COPY: RepairCopy;
38
- /**
39
- * Seed text for one boot-failure ring row: the failure record, so the agent
40
- * can attribute and fix it in place.
41
- * @param failure - the recorded failure row.
42
- * @param copy - localized fragments.
43
- * @returns the repair prompt text.
44
- */
45
- export declare function failureRepairMessage(failure: PluginFailureItem, copy?: RepairCopy): string;
46
- /**
47
- * Seed text for one install-conflict notice: the entry and its state change,
48
- * so the agent can attribute the conflict and resolve the double mount.
49
- * @param change - the conflict change (id, display name, from/to states).
50
- * @param copy - localized fragments.
51
- * @returns the repair prompt text.
52
- */
53
- export declare function conflictRepairMessage(change: {
54
- id: string;
55
- name: string;
56
- from: LayerState;
57
- to: LayerState;
58
- }, copy?: RepairCopy): string;