@linxin666/dsh-client-ui-plugin-manager 0.4.1 → 0.4.3
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/README.i18n.yaml +2 -2
- package/README.md +17 -25
- package/README.zh.md +17 -25
- package/lib/client.js +171 -914
- package/lib/client.js.map +1 -1
- package/lib/index.js +423 -49
- package/lib/types/client/PluginUpdatePatch.d.ts +70 -0
- package/lib/types/client/index.d.ts +33 -21
- package/lib/types/client/locales.d.ts +19 -170
- package/lib/types/core/conflict.d.ts +13 -35
- package/lib/types/core/protocol.d.ts +0 -13
- package/lib/types/host/gateway.d.ts +111 -7
- package/lib/types/host/profile.d.ts +60 -5
- package/lib/types/mount-once.d.ts +38 -7
- package/package.json +15 -19
- package/lib/types/client/PluginManagerTab.d.ts +0 -32
- package/lib/types/core/repair.d.ts +0 -58
|
@@ -1,42 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plugin-manager browser half: contributes the
|
|
3
|
-
* the official Plugins
|
|
4
|
-
* provides the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
2
|
+
* Plugin-manager browser half: contributes the package's one remaining
|
|
3
|
+
* surface — the check-for-updates block on the official Plugins page — and
|
|
4
|
+
* provides the dual-channel face as the `'pluginManager'` cordis service for
|
|
5
|
+
* sibling client plugins.
|
|
6
|
+
*
|
|
7
|
+
* It is dual-channel: on runtimes with the official installer services
|
|
8
|
+
* (DSHCode, the 1.0.4 checkout web) every operation rides the official
|
|
9
|
+
* `/plugin-installer` and `/plugin-control` loopback RPC channels (the single
|
|
10
|
+
* writer); on the npm-published web runtime those channels do not exist, so the
|
|
11
|
+
* same face falls back to this package's own loopback HTTP gateway, which
|
|
12
|
+
* spawns the official CLI for writes. Neither the patch nor service consumers
|
|
13
|
+
* know which mode the face runs in.
|
|
14
|
+
*
|
|
15
|
+
* The package used to register its own "Plugin manager" tab into the official
|
|
16
|
+
* Plugins settings section (`settings.plugins.tab`). Installing, uninstalling
|
|
17
|
+
* and enabling moved to the official page long ago, and the tab's remaining
|
|
18
|
+
* half was UI no official page renders; the tab is gone and its one genuinely
|
|
19
|
+
* missing capability — comparing an installed plugin against its registry
|
|
20
|
+
* source, with the DSH-runtime compatibility gate — now renders inside the
|
|
21
|
+
* official page through the `plugins.detail.section` seat it declares.
|
|
12
22
|
* @module @linxin666/dsh-client-ui-plugin-manager/client
|
|
13
23
|
*/
|
|
14
24
|
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
15
|
-
import { type
|
|
25
|
+
import { type PluginUpdatePatchInjected } from './PluginUpdatePatch.tsx';
|
|
16
26
|
import { type PluginManagerKey } from './locales.ts';
|
|
17
27
|
import { type PluginManagerService } from '../core/service.ts';
|
|
18
28
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
19
29
|
interface LocaleNamespaceMap {
|
|
20
|
-
/** Copy for the
|
|
30
|
+
/** Copy for the check-for-updates patch. */
|
|
21
31
|
'settings.pluginManager': PluginManagerKey;
|
|
22
32
|
}
|
|
23
33
|
}
|
|
24
|
-
/** Services required by the
|
|
34
|
+
/** Services required by the patch registration and both channels. */
|
|
25
35
|
export declare const inject: string[];
|
|
26
36
|
/**
|
|
27
|
-
* The face the
|
|
28
|
-
*
|
|
37
|
+
* The face the update patch and the `'pluginManager'` cordis service share:
|
|
38
|
+
* the patch's wire surface plus the cross-plugin service contract. The gateway
|
|
39
|
+
* host still records install conflicts and boot failures; no client surface
|
|
40
|
+
* consumes either since the tab left, so neither is on this face.
|
|
29
41
|
*/
|
|
30
|
-
export type PluginManagerFace =
|
|
42
|
+
export type PluginManagerFace = PluginUpdatePatchInjected & PluginManagerService;
|
|
31
43
|
/**
|
|
32
44
|
* Build the dual-channel face once: official-channel and gateway-channel
|
|
33
|
-
* implementations, the mode detection that picks between them, the
|
|
34
|
-
*
|
|
35
|
-
*
|
|
45
|
+
* implementations, the mode detection that picks between them, and the
|
|
46
|
+
* change-notification listener set. The returned face is both the update
|
|
47
|
+
* patch's injected props and the value provided as the
|
|
36
48
|
* `'pluginManager'` cordis service.
|
|
37
|
-
* @param ctx - the client context (connection
|
|
49
|
+
* @param ctx - the client context (connection).
|
|
38
50
|
* @returns the shared face.
|
|
39
51
|
*/
|
|
40
52
|
export declare function createPluginManagerFace(ctx: ClientContext): PluginManagerFace;
|
|
41
|
-
/** Contribute the
|
|
53
|
+
/** Contribute the check-for-updates patch and provide the shared face. */
|
|
42
54
|
export declare function apply(ctx: ClientContext): void;
|
|
@@ -1,40 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Locale dictionaries for the plugin-manager
|
|
3
|
-
* key source; the en dictionary mirrors the exact key set.
|
|
2
|
+
* Locale dictionaries for the plugin-manager's official-page patch. The zh
|
|
3
|
+
* dictionary is the key source; the en dictionary mirrors the exact key set.
|
|
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.
|
|
7
|
+
* The former tab's keys (inventory, conflicts, repair seeds, safe mode,
|
|
8
|
+
* aggregate children) left with that tab.
|
|
4
9
|
* @module @linxin666/dsh-client-ui-plugin-manager/client
|
|
5
10
|
*/
|
|
6
11
|
/** Simplified Chinese copy (the key-set source of truth). */
|
|
7
12
|
declare const STATIC_ZH: {
|
|
8
|
-
|
|
9
|
-
manageElsewhere: string;
|
|
10
|
-
loading: string;
|
|
11
|
-
empty: string;
|
|
12
|
-
userPlugins: string;
|
|
13
|
-
products: string;
|
|
14
|
-
conflictTitle: string;
|
|
15
|
-
conflictDisabled: string;
|
|
16
|
-
conflictEnabled: string;
|
|
17
|
-
conflictChanged: string;
|
|
18
|
-
undoConflict: string;
|
|
19
|
-
conflictHint: string;
|
|
20
|
-
version: string;
|
|
21
|
-
latest: string;
|
|
22
|
-
update: string;
|
|
23
|
-
updating: string;
|
|
13
|
+
updateSection: string;
|
|
24
14
|
checkUpdates: string;
|
|
25
15
|
checking: string;
|
|
26
16
|
noUpdates: string;
|
|
17
|
+
update: string;
|
|
18
|
+
updating: string;
|
|
19
|
+
latest: string;
|
|
27
20
|
updateRequiresDsh: string;
|
|
28
21
|
updateBlockedDsh: string;
|
|
29
22
|
restartHint: string;
|
|
30
23
|
failed: string;
|
|
31
|
-
enabled: string;
|
|
32
|
-
disabled: string;
|
|
33
|
-
mixed: string;
|
|
34
|
-
unavailable: string;
|
|
35
|
-
uninstalled: string;
|
|
36
|
-
source: string;
|
|
37
|
-
applying: string;
|
|
38
24
|
fetching: string;
|
|
39
25
|
downloading: string;
|
|
40
26
|
downloadingPercent: string;
|
|
@@ -42,71 +28,19 @@ declare const STATIC_ZH: {
|
|
|
42
28
|
writing: string;
|
|
43
29
|
localOnlyTitle: string;
|
|
44
30
|
localOnlyBody: string;
|
|
45
|
-
failureBadge: string;
|
|
46
|
-
failureGroupTitle: string;
|
|
47
|
-
repair: string;
|
|
48
|
-
repairing: string;
|
|
49
|
-
copyError: string;
|
|
50
|
-
copied: string;
|
|
51
|
-
safeModeBanner: string;
|
|
52
|
-
exitSafeMode: string;
|
|
53
|
-
npmSource: string;
|
|
54
|
-
gitSource: string;
|
|
55
|
-
lockedRowHint: string;
|
|
56
|
-
childrenHint: string;
|
|
57
|
-
childrenSummary: string;
|
|
58
|
-
childrenShow: string;
|
|
59
|
-
childrenHide: string;
|
|
60
|
-
repairFailureTitle: string;
|
|
61
|
-
repairFailurePluginLabel: string;
|
|
62
|
-
repairFailureKindLabel: string;
|
|
63
|
-
repairFailureAtLabel: string;
|
|
64
|
-
repairFailureMessageLabel: string;
|
|
65
|
-
repairFailureStackLabel: string;
|
|
66
|
-
repairFailurePathLabel: string;
|
|
67
|
-
repairFailureAsk: string;
|
|
68
|
-
repairKindLoad: string;
|
|
69
|
-
repairKindHang: string;
|
|
70
|
-
repairKindLate: string;
|
|
71
|
-
repairConflictTitle: string;
|
|
72
|
-
repairConflictPluginLabel: string;
|
|
73
|
-
repairConflictChangeLabel: string;
|
|
74
|
-
repairConflictAsk: string;
|
|
75
|
-
repairStateEnabled: string;
|
|
76
|
-
repairStateDisabled: string;
|
|
77
|
-
repairStateUninstalled: string;
|
|
78
31
|
};
|
|
79
32
|
export declare const zh: {
|
|
80
|
-
|
|
81
|
-
manageElsewhere: string;
|
|
82
|
-
loading: string;
|
|
83
|
-
empty: string;
|
|
84
|
-
userPlugins: string;
|
|
85
|
-
products: string;
|
|
86
|
-
conflictTitle: string;
|
|
87
|
-
conflictDisabled: string;
|
|
88
|
-
conflictEnabled: string;
|
|
89
|
-
conflictChanged: string;
|
|
90
|
-
undoConflict: string;
|
|
91
|
-
conflictHint: string;
|
|
92
|
-
version: string;
|
|
93
|
-
latest: string;
|
|
94
|
-
update: string;
|
|
95
|
-
updating: string;
|
|
33
|
+
updateSection: string;
|
|
96
34
|
checkUpdates: string;
|
|
97
35
|
checking: string;
|
|
98
36
|
noUpdates: string;
|
|
37
|
+
update: string;
|
|
38
|
+
updating: string;
|
|
39
|
+
latest: string;
|
|
99
40
|
updateRequiresDsh: string;
|
|
100
41
|
updateBlockedDsh: string;
|
|
101
42
|
restartHint: string;
|
|
102
43
|
failed: string;
|
|
103
|
-
enabled: string;
|
|
104
|
-
disabled: string;
|
|
105
|
-
mixed: string;
|
|
106
|
-
unavailable: string;
|
|
107
|
-
uninstalled: string;
|
|
108
|
-
source: string;
|
|
109
|
-
applying: string;
|
|
110
44
|
fetching: string;
|
|
111
45
|
downloading: string;
|
|
112
46
|
downloadingPercent: string;
|
|
@@ -114,71 +48,19 @@ export declare const zh: {
|
|
|
114
48
|
writing: string;
|
|
115
49
|
localOnlyTitle: string;
|
|
116
50
|
localOnlyBody: string;
|
|
117
|
-
failureBadge: string;
|
|
118
|
-
failureGroupTitle: string;
|
|
119
|
-
repair: string;
|
|
120
|
-
repairing: string;
|
|
121
|
-
copyError: string;
|
|
122
|
-
copied: string;
|
|
123
|
-
safeModeBanner: string;
|
|
124
|
-
exitSafeMode: string;
|
|
125
|
-
npmSource: string;
|
|
126
|
-
gitSource: string;
|
|
127
|
-
lockedRowHint: string;
|
|
128
|
-
childrenHint: string;
|
|
129
|
-
childrenSummary: string;
|
|
130
|
-
childrenShow: string;
|
|
131
|
-
childrenHide: string;
|
|
132
|
-
repairFailureTitle: string;
|
|
133
|
-
repairFailurePluginLabel: string;
|
|
134
|
-
repairFailureKindLabel: string;
|
|
135
|
-
repairFailureAtLabel: string;
|
|
136
|
-
repairFailureMessageLabel: string;
|
|
137
|
-
repairFailureStackLabel: string;
|
|
138
|
-
repairFailurePathLabel: string;
|
|
139
|
-
repairFailureAsk: string;
|
|
140
|
-
repairKindLoad: string;
|
|
141
|
-
repairKindHang: string;
|
|
142
|
-
repairKindLate: string;
|
|
143
|
-
repairConflictTitle: string;
|
|
144
|
-
repairConflictPluginLabel: string;
|
|
145
|
-
repairConflictChangeLabel: string;
|
|
146
|
-
repairConflictAsk: string;
|
|
147
|
-
repairStateEnabled: string;
|
|
148
|
-
repairStateDisabled: string;
|
|
149
|
-
repairStateUninstalled: string;
|
|
150
51
|
};
|
|
151
52
|
export declare const en: {
|
|
152
|
-
|
|
153
|
-
manageElsewhere: string;
|
|
154
|
-
loading: string;
|
|
155
|
-
empty: string;
|
|
156
|
-
userPlugins: string;
|
|
157
|
-
products: string;
|
|
158
|
-
conflictTitle: string;
|
|
159
|
-
conflictDisabled: string;
|
|
160
|
-
conflictEnabled: string;
|
|
161
|
-
conflictChanged: string;
|
|
162
|
-
undoConflict: string;
|
|
163
|
-
conflictHint: string;
|
|
164
|
-
version: string;
|
|
165
|
-
latest: string;
|
|
166
|
-
update: string;
|
|
167
|
-
updating: string;
|
|
53
|
+
updateSection: string;
|
|
168
54
|
checkUpdates: string;
|
|
169
55
|
checking: string;
|
|
170
56
|
noUpdates: string;
|
|
57
|
+
update: string;
|
|
58
|
+
updating: string;
|
|
59
|
+
latest: string;
|
|
171
60
|
updateRequiresDsh: string;
|
|
172
61
|
updateBlockedDsh: string;
|
|
173
62
|
restartHint: string;
|
|
174
63
|
failed: string;
|
|
175
|
-
enabled: string;
|
|
176
|
-
disabled: string;
|
|
177
|
-
mixed: string;
|
|
178
|
-
unavailable: string;
|
|
179
|
-
uninstalled: string;
|
|
180
|
-
source: string;
|
|
181
|
-
applying: string;
|
|
182
64
|
fetching: string;
|
|
183
65
|
downloading: string;
|
|
184
66
|
downloadingPercent: string;
|
|
@@ -186,39 +68,6 @@ export declare const en: {
|
|
|
186
68
|
writing: string;
|
|
187
69
|
localOnlyTitle: string;
|
|
188
70
|
localOnlyBody: string;
|
|
189
|
-
failureBadge: string;
|
|
190
|
-
failureGroupTitle: string;
|
|
191
|
-
repair: string;
|
|
192
|
-
repairing: string;
|
|
193
|
-
copyError: string;
|
|
194
|
-
copied: string;
|
|
195
|
-
safeModeBanner: string;
|
|
196
|
-
exitSafeMode: string;
|
|
197
|
-
npmSource: string;
|
|
198
|
-
gitSource: string;
|
|
199
|
-
lockedRowHint: string;
|
|
200
|
-
childrenHint: string;
|
|
201
|
-
childrenSummary: string;
|
|
202
|
-
childrenShow: string;
|
|
203
|
-
childrenHide: string;
|
|
204
|
-
repairFailureTitle: string;
|
|
205
|
-
repairFailurePluginLabel: string;
|
|
206
|
-
repairFailureKindLabel: string;
|
|
207
|
-
repairFailureAtLabel: string;
|
|
208
|
-
repairFailureMessageLabel: string;
|
|
209
|
-
repairFailureStackLabel: string;
|
|
210
|
-
repairFailurePathLabel: string;
|
|
211
|
-
repairFailureAsk: string;
|
|
212
|
-
repairKindLoad: string;
|
|
213
|
-
repairKindHang: string;
|
|
214
|
-
repairKindLate: string;
|
|
215
|
-
repairConflictTitle: string;
|
|
216
|
-
repairConflictPluginLabel: string;
|
|
217
|
-
repairConflictChangeLabel: string;
|
|
218
|
-
repairConflictAsk: string;
|
|
219
|
-
repairStateEnabled: string;
|
|
220
|
-
repairStateDisabled: string;
|
|
221
|
-
repairStateUninstalled: string;
|
|
222
71
|
};
|
|
223
72
|
export type PluginManagerKey = keyof typeof STATIC_ZH;
|
|
224
73
|
export {};
|
|
@@ -1,43 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* rules at install time (disableControlsOnInstall: installing the
|
|
4
|
-
* family disables the built-in web-ui product rows so the two never
|
|
5
|
-
* double-mount)
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* attributable conflict notice.
|
|
2
|
+
* The install-conflict ledger row. The official host applies structural
|
|
3
|
+
* conflict rules at install time (disableControlsOnInstall: installing the
|
|
4
|
+
* dsh-web family disables the built-in web-ui product rows so the two never
|
|
5
|
+
* double-mount) and the gateway host records what the official CLI moved
|
|
6
|
+
* around an install, so a failure can be attributed to a concrete row rather
|
|
7
|
+
* than to an unknown install side effect.
|
|
9
8
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* shape is left to the boot-failure ring — the real start is the authoritative
|
|
14
|
-
* conflict detector.
|
|
9
|
+
* This is host-side bookkeeping. The panel that rendered these rows as
|
|
10
|
+
* reversible conflict notices lived in the removed "Plugin manager" tab, so
|
|
11
|
+
* only the row shape remains here.
|
|
15
12
|
* @module @linxin666/dsh-client-ui-plugin-manager/core
|
|
16
13
|
*/
|
|
17
|
-
import type {
|
|
18
|
-
/** One observed
|
|
14
|
+
import type { LayerState } from './patch-diff.ts';
|
|
15
|
+
/** One observed row membership change between two layer snapshots. */
|
|
19
16
|
export interface ControlChange {
|
|
20
17
|
id: string;
|
|
21
18
|
name: string;
|
|
22
|
-
from:
|
|
23
|
-
to:
|
|
19
|
+
from: LayerState;
|
|
20
|
+
to: LayerState;
|
|
24
21
|
}
|
|
25
|
-
/** Meaningful change kinds a conflict notice distinguishes. */
|
|
26
|
-
export type ControlChangeKind = 'rule-disabled' | 'rule-enabled' | 'state-change';
|
|
27
|
-
/**
|
|
28
|
-
* Diff two plugin-control snapshots by id. Only entries present in both
|
|
29
|
-
* snapshots with a changed state are reported; entries appearing or
|
|
30
|
-
* disappearing are ordinary install/uninstall outcomes, not conflicts.
|
|
31
|
-
* @param before - snapshot taken before the install.
|
|
32
|
-
* @param after - snapshot taken after the install.
|
|
33
|
-
* @returns one change per id whose state moved, in id order.
|
|
34
|
-
*/
|
|
35
|
-
export declare function diffControls(before: readonly PluginControlItem[], after: readonly PluginControlItem[]): ControlChange[];
|
|
36
|
-
/**
|
|
37
|
-
* Classify one control-state change for messaging. A change into `disabled`
|
|
38
|
-
* is the conflict rule's action (reversible by re-enabling); a change out of
|
|
39
|
-
* `disabled` is a manual undo; anything else is reported neutrally.
|
|
40
|
-
* @param change - one diff entry.
|
|
41
|
-
* @returns the message kind.
|
|
42
|
-
*/
|
|
43
|
-
export declare function classifyChange(change: ControlChange): ControlChangeKind;
|
|
@@ -85,13 +85,6 @@ export interface PluginFailuresSnapshot {
|
|
|
85
85
|
/** Whether the host is running in safe mode (user plugins skipped). */
|
|
86
86
|
safeMode: boolean;
|
|
87
87
|
}
|
|
88
|
-
/** One deployment-configured logical product switch. */
|
|
89
|
-
export interface PluginControlItem {
|
|
90
|
-
id: string;
|
|
91
|
-
name: string;
|
|
92
|
-
repository: string;
|
|
93
|
-
state: 'enabled' | 'disabled' | 'mixed' | 'unavailable' | 'uninstalled';
|
|
94
|
-
}
|
|
95
88
|
/**
|
|
96
89
|
* Validate and normalize a `list` / `uninstall` response value.
|
|
97
90
|
* @param value - decoded but untrusted response value.
|
|
@@ -104,12 +97,6 @@ export declare function parsePluginList(value: unknown): InstalledPluginItem[];
|
|
|
104
97
|
* @returns the typed installed-plugin row.
|
|
105
98
|
*/
|
|
106
99
|
export declare function parseInstalledPlugin(value: unknown): InstalledPluginItem;
|
|
107
|
-
/**
|
|
108
|
-
* Validate and normalize a plugin-control `list` / `set-enabled` response value.
|
|
109
|
-
* @param value - decoded but untrusted response value.
|
|
110
|
-
* @returns the typed control items.
|
|
111
|
-
*/
|
|
112
|
-
export declare function parsePluginControlSnapshot(value: unknown): PluginControlItem[];
|
|
113
100
|
/**
|
|
114
101
|
* Validate and normalize a `status` response value.
|
|
115
102
|
* @param value - decoded but untrusted response value.
|
|
@@ -49,23 +49,75 @@ export interface GatewayJob {
|
|
|
49
49
|
/** The binary search roots for the dsh CLI. */
|
|
50
50
|
export declare function findDshBinary(env?: NodeJS.ProcessEnv, platform?: string, exists?: (path: string) => boolean, hostEntryPath?: string | undefined): string | null;
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
52
|
+
* Read a file's leading bytes for the shebang probe. Every failure — a missing
|
|
53
|
+
* file, a directory, a permission error, an unreadable asar entry — reads as
|
|
54
|
+
* "no head", so the caller falls back to spawning the path directly.
|
|
55
|
+
* @param path - file to probe.
|
|
56
|
+
* @returns the leading text, or undefined.
|
|
57
|
+
*/
|
|
58
|
+
export declare function readFileHead(path: string): string | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Whether a resolved CLI path is a Node script: a `.js` module, or a file whose
|
|
61
|
+
* shebang names node. A Node script cannot be spawned as an executable on its
|
|
62
|
+
* own: the kernel hands the shebang to the interpreter it names, and
|
|
63
|
+
* `#!/usr/bin/env node` resolves node through PATH — which a GUI-launched host
|
|
64
|
+
* (the packaged Desktop app) does not carry, so the child dies before the CLI
|
|
65
|
+
* starts with `env: node: No such file or directory` (exit 127).
|
|
66
|
+
* @param path - the resolved CLI path.
|
|
67
|
+
* @param readHead - head probe (test seam).
|
|
68
|
+
* @returns true when the path needs a Node interpreter.
|
|
69
|
+
*/
|
|
70
|
+
export declare function isNodeScript(path: string, readHead?: (path: string) => string | undefined): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* The spawn command for the dsh CLI on this platform. A Node script (the
|
|
73
|
+
* npm/homebrew `dsh` shim, a `.bin` symlink, a packaged `lib/bin.js`) is run
|
|
74
|
+
* by an interpreter that exists regardless of PATH: a `node` sitting beside the
|
|
75
|
+
* CLI when the installation ships one (npm-global and homebrew layouts), else
|
|
76
|
+
* the host's own interpreter — `process.execPath`, which the ELECTRON_RUN_AS_NODE
|
|
77
|
+
* branch in {@link spawnDsh} covers for an Electron host. Windows additionally
|
|
78
|
+
* resolves the npm-generated shim into node plus bin.js and spawns them
|
|
79
|
+
* directly: going through cmd.exe splits unquoted paths with spaces
|
|
80
|
+
* (`'D:\Program' is not recognized`).
|
|
56
81
|
* @param binary - the dsh CLI path found by {@link findDshBinary}.
|
|
57
82
|
* @param platform - process platform (test seam).
|
|
58
83
|
* @param localNodeExists - existence probe (test seam).
|
|
59
84
|
* @param binJsExists - existence probe for the resolved bin script (test seam).
|
|
85
|
+
* @param readHead - shebang probe (test seam).
|
|
60
86
|
* @returns the executable and the argument prefix to run the dsh bin script.
|
|
61
87
|
*/
|
|
62
|
-
export declare function dshSpawnCommand(binary: string, platform?: string, localNodeExists?: (path: string) => boolean, binJsExists?: (path: string) => boolean): {
|
|
88
|
+
export declare function dshSpawnCommand(binary: string, platform?: string, localNodeExists?: (path: string) => boolean, binJsExists?: (path: string) => boolean, readHead?: (path: string) => string | undefined): {
|
|
63
89
|
command: string;
|
|
64
90
|
argsPrefix: string[];
|
|
65
91
|
};
|
|
66
92
|
/** Build the exact cmd.exe command line required to execute a trusted .cmd shim. */
|
|
67
93
|
export declare function windowsCmdShimArgs(binary: string, args: readonly string[]): string[];
|
|
68
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Prepend one directory to a child environment's PATH, collapsing every case
|
|
96
|
+
* variant of the key into one `PATH`. Windows exposes the variable as `Path`,
|
|
97
|
+
* and spreading `process.env` into a plain object preserves that spelling:
|
|
98
|
+
* assigning `env.PATH` beside it would leave two keys whose serialization
|
|
99
|
+
* drops the system directories (the desktop childEnv defect).
|
|
100
|
+
* @param env - the environment to copy.
|
|
101
|
+
* @param dir - directory to put first.
|
|
102
|
+
* @param platform - process platform (test seam).
|
|
103
|
+
* @returns a new environment with one normalized, prepended PATH.
|
|
104
|
+
*/
|
|
105
|
+
export declare function withPrependedPath(env: NodeJS.ProcessEnv, dir: string, platform?: string): NodeJS.ProcessEnv;
|
|
106
|
+
/**
|
|
107
|
+
* Spawn the dsh CLI with piped stdio and no shell parsing (see
|
|
108
|
+
* {@link dshSpawnCommand}).
|
|
109
|
+
*
|
|
110
|
+
* The CLI's own directory goes first on the child PATH: npm-global, homebrew and
|
|
111
|
+
* packaged layouts keep `node`, `pnpm` and `npx` beside the `dsh` shim, and a
|
|
112
|
+
* GUI-launched host carries none of them on its own PATH — the CLI forwards
|
|
113
|
+
* `dsh plugin` to pnpm, so without this the update would start and then fail on
|
|
114
|
+
* a missing pnpm instead. This mirrors the packaged Desktop launcher, which
|
|
115
|
+
* prepends its bundled runtime bin to the host it spawns.
|
|
116
|
+
* @param binary - the resolved dsh CLI path.
|
|
117
|
+
* @param args - arguments after the interpreter/script prefix.
|
|
118
|
+
* @param env - the host environment.
|
|
119
|
+
* @returns the spawned child process.
|
|
120
|
+
*/
|
|
69
121
|
export declare function spawnDsh(binary: string, args: string[], env: NodeJS.ProcessEnv): import("child_process").ChildProcessByStdio<null, import("stream").Readable, import("stream").Readable>;
|
|
70
122
|
/**
|
|
71
123
|
* Detect whether the official installer channels exist on this runtime by
|
|
@@ -80,6 +132,28 @@ export declare function spawnDsh(binary: string, args: string[], env: NodeJS.Pro
|
|
|
80
132
|
* @returns true when the dump names the official installer channels.
|
|
81
133
|
*/
|
|
82
134
|
export declare function detectOfficialChannels(binary: string, profileName: string, env?: NodeJS.ProcessEnv, spawnImpl?: typeof spawnDsh): Promise<boolean>;
|
|
135
|
+
/**
|
|
136
|
+
* The official in-process plugin manager (`@deepseek-ai/dsh-plugin-manager`),
|
|
137
|
+
* read from the host context as a contract observation — not an import, exactly
|
|
138
|
+
* like the profile facts and the installer wire shapes this package already
|
|
139
|
+
* mirrors. It is the same writer the official Plugins page drives, and on an
|
|
140
|
+
* application-owned profile it is the ONLY writer: `dsh plugin --profile desktop
|
|
141
|
+
* …` is refused before pnpm starts ("profile \"desktop\" is managed
|
|
142
|
+
* exclusively by the Electron application"), and the launcher hands that
|
|
143
|
+
* manager its bundled package-manager invocation through launcher facts.
|
|
144
|
+
*/
|
|
145
|
+
export interface NativePluginManager {
|
|
146
|
+
/**
|
|
147
|
+
* Install or update one package spec through the official manager.
|
|
148
|
+
* @param spec - package spec (e.g. `@scope/pkg@1.2.3`).
|
|
149
|
+
* @param options - activation choice and the request id the run is tracked under.
|
|
150
|
+
* @returns the manager's own diagnostics (the caller re-reads the profile).
|
|
151
|
+
*/
|
|
152
|
+
installBundle(spec: string, options?: {
|
|
153
|
+
enabled?: boolean;
|
|
154
|
+
requestId?: string;
|
|
155
|
+
}): Promise<unknown>;
|
|
156
|
+
}
|
|
83
157
|
/** The gateway: serializes CLI operations through one job table and one mutation queue. */
|
|
84
158
|
export declare class CliGateway {
|
|
85
159
|
private readonly facts;
|
|
@@ -99,6 +173,8 @@ export declare class CliGateway {
|
|
|
99
173
|
constructor(facts: ProfileFacts, env?: NodeJS.ProcessEnv, deps?: {
|
|
100
174
|
spawnImpl?: typeof spawnDsh;
|
|
101
175
|
findBinary?: (env: NodeJS.ProcessEnv) => string | null;
|
|
176
|
+
/** The official in-process manager, when the runtime publishes one. */
|
|
177
|
+
nativeManager?: () => NativePluginManager | undefined;
|
|
102
178
|
});
|
|
103
179
|
/**
|
|
104
180
|
* Run one profile mutation after every mutation already queued. The returned
|
|
@@ -114,6 +190,16 @@ export declare class CliGateway {
|
|
|
114
190
|
private retainFinished;
|
|
115
191
|
/** The dsh CLI path, through the test seam when present. */
|
|
116
192
|
private binary;
|
|
193
|
+
/**
|
|
194
|
+
* The official in-process manager to write through, or undefined when the CLI
|
|
195
|
+
* is the writer. Only an application-owned profile (a packaged Desktop launch)
|
|
196
|
+
* takes this path: there the CLI refuses the profile outright, while the
|
|
197
|
+
* official manager — which the launcher configures with its bundled
|
|
198
|
+
* package-manager invocation — owns the same files this gateway reads. On
|
|
199
|
+
* every other runtime the CLI stays the single writer, exactly as before.
|
|
200
|
+
* @returns the manager, or undefined when the CLI should run.
|
|
201
|
+
*/
|
|
202
|
+
private nativeManager;
|
|
117
203
|
/** Run one CLI command to completion and return the bounded output. */
|
|
118
204
|
private runCli;
|
|
119
205
|
/** Full package spec used when restoring a legacy dependency. */
|
|
@@ -128,10 +214,28 @@ export declare class CliGateway {
|
|
|
128
214
|
install(spec: string): {
|
|
129
215
|
jobId: string;
|
|
130
216
|
};
|
|
131
|
-
/**
|
|
217
|
+
/**
|
|
218
|
+
* Start an in-place npm update; the caller polls {@link status}. An
|
|
219
|
+
* application-owned profile runs it through the official in-process manager
|
|
220
|
+
* instead of the CLI (see {@link nativeManager}), and the job/status/polling
|
|
221
|
+
* contract the browser half drives is identical either way.
|
|
222
|
+
*/
|
|
132
223
|
update(id: string, version: string): {
|
|
133
224
|
jobId: string;
|
|
134
225
|
};
|
|
226
|
+
/** Start an in-place update through the official in-process manager. */
|
|
227
|
+
private enqueueNativeUpdate;
|
|
228
|
+
/**
|
|
229
|
+
* Run one update through the official in-process manager (an application-owned
|
|
230
|
+
* profile, where the CLI refuses to write). The manager resolves the registry,
|
|
231
|
+
* runs pnpm with the launcher's bundled toolchain and applies the bundle, then
|
|
232
|
+
* this reads the profile the same way the CLI path does: the dependency must
|
|
233
|
+
* still be there and the installed version must be the one the route resolved,
|
|
234
|
+
* so a green manager call that changed nothing is still reported as a failure.
|
|
235
|
+
* @param job - the update job being settled.
|
|
236
|
+
* @param native - the official manager.
|
|
237
|
+
*/
|
|
238
|
+
private runNativeUpdate;
|
|
135
239
|
/** Start a deterministic legacy aggregate migration. */
|
|
136
240
|
migrate(sourceId: string, targetId: string, targetVersion: string, targetSpec: string): {
|
|
137
241
|
jobId: string;
|
|
@@ -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
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
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). */
|