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

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,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. */
@@ -30,6 +31,10 @@ export interface GatewayRouteDeps {
30
31
  dshVersion?: () => Promise<string | undefined>;
31
32
  /** Official-channel detection seam (test seam); defaults to the boot dump probe. */
32
33
  officialChannels?: () => Promise<boolean>;
34
+ /** Launch-fact seam for the restart route (test seam); defaults to this process. */
35
+ restartFacts?: () => RestartFacts;
36
+ /** Restart effect seam (test seam); defaults to the detached helper plus a real exit. */
37
+ restartRuntime?: RestartRuntime;
33
38
  }
34
39
  /** The published `/latest` manifest: version plus the compat metadata fields. */
35
40
  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.5",
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",