@hcu-lab.me/mcp-device 1.0.5 → 1.0.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.
- package/dist/config-manager.js +55 -18
- package/dist/device/device-state.d.ts +2 -0
- package/dist/device/device-state.js +3 -1
- package/dist/device/device.js +63 -4
- package/dist/device/execution-engine.d.ts +1 -0
- package/dist/device/execution-engine.js +7 -1
- package/dist/device/gateway-channel.d.ts +13 -1
- package/dist/device/gateway-channel.js +91 -20
- package/dist/device/gateway-identity.d.ts +1 -0
- package/dist/device/gateway-identity.js +4 -0
- package/dist/device/linux-service.d.ts +2 -0
- package/dist/device/linux-service.js +2 -2
- package/dist/device/runtime-owner.d.ts +1 -0
- package/dist/device/runtime-owner.js +4 -4
- package/dist/device/self-update.d.ts +107 -12
- package/dist/device/self-update.js +660 -62
- package/dist/device/update-helper.cjs +343 -0
- package/dist/handlers/filesystem-handlers.js +3 -0
- package/dist/index.js +7 -3
- package/dist/npm-scripts/remote.d.ts +5 -0
- package/dist/npm-scripts/remote.js +50 -1
- package/dist/server.js +76 -70
- package/dist/terminal-manager.js +40 -0
- package/dist/utils/capture.js +1 -1
- package/dist/utils/files/factory.js +20 -0
- package/dist/utils/files/text.d.ts +1 -0
- package/dist/utils/files/text.js +78 -34
- package/dist/utils/trackTools.js +23 -2
- package/dist/utils/usageTracker.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
|
@@ -1,20 +1,115 @@
|
|
|
1
1
|
import { spawn as spawnCallback } from 'child_process';
|
|
2
|
+
import { type DeviceStatePaths } from './device-state.js';
|
|
2
3
|
export declare const MCP_DEVICE_PACKAGE = "@hcu-lab.me/mcp-device";
|
|
4
|
+
export type DeviceUpdateManagerKind = 'windows-task' | 'windows-run' | 'windows-manual' | 'systemd' | 'pm2';
|
|
5
|
+
export type DeviceUpdatePhase = 'prepared' | 'helper_started' | 'handoff_ready' | 'quiescing' | 'installing' | 'installed_waiting_reconnect' | 'rollback' | 'failed';
|
|
6
|
+
export interface DeviceUpdateState {
|
|
7
|
+
schema: number;
|
|
8
|
+
requestId: string;
|
|
9
|
+
fromVersion: string;
|
|
10
|
+
targetVersion: string;
|
|
11
|
+
state: DeviceUpdatePhase;
|
|
12
|
+
startedAt: number;
|
|
13
|
+
updatedAt?: number;
|
|
14
|
+
completedAt: number | null;
|
|
15
|
+
errorCode: string | null;
|
|
16
|
+
message: string | null;
|
|
17
|
+
deviceId: string;
|
|
18
|
+
managerKind: DeviceUpdateManagerKind;
|
|
19
|
+
parentPid: number;
|
|
20
|
+
childPid: number | null;
|
|
21
|
+
packageRoot: string;
|
|
22
|
+
globalPrefix: string;
|
|
23
|
+
nodePath: string;
|
|
24
|
+
npmCliPath: string;
|
|
25
|
+
targetTarball: string;
|
|
26
|
+
cacheDir: string;
|
|
27
|
+
rollbackSnapshot: string;
|
|
28
|
+
rollbackPath: string;
|
|
29
|
+
helperPath: string;
|
|
30
|
+
handoffPath: string;
|
|
31
|
+
runtimeOwnerControlPath: string;
|
|
32
|
+
windowsRunnerPath?: string;
|
|
33
|
+
windowsTaskName?: string;
|
|
34
|
+
windowsUpdateTaskName?: string;
|
|
35
|
+
powershellPath?: string;
|
|
36
|
+
schtasksPath?: string;
|
|
37
|
+
systemctlPath?: string;
|
|
38
|
+
systemdRunPath?: string;
|
|
39
|
+
systemdUnit?: string;
|
|
40
|
+
systemdUpdateUnit?: string;
|
|
41
|
+
pm2Path?: string;
|
|
42
|
+
pm2Name?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface PreparedDeviceUpdate {
|
|
45
|
+
state: DeviceUpdateState;
|
|
46
|
+
statePath: string;
|
|
47
|
+
helperRunnerPath?: string;
|
|
48
|
+
}
|
|
49
|
+
type ExecFileFn = (file: string, args: string[]) => Promise<{
|
|
50
|
+
stdout?: string;
|
|
51
|
+
stderr?: string;
|
|
52
|
+
}>;
|
|
53
|
+
export interface DeviceUpdateManagerOverride {
|
|
54
|
+
managerKind: DeviceUpdateManagerKind;
|
|
55
|
+
windowsRunnerPath?: string;
|
|
56
|
+
windowsTaskName?: string;
|
|
57
|
+
powershellPath?: string;
|
|
58
|
+
schtasksPath?: string;
|
|
59
|
+
systemctlPath?: string;
|
|
60
|
+
systemdRunPath?: string;
|
|
61
|
+
systemdUnit?: string;
|
|
62
|
+
pm2Path?: string;
|
|
63
|
+
pm2Name?: string;
|
|
64
|
+
}
|
|
3
65
|
export declare function normalizeUpdateVersion(value: string): string;
|
|
4
|
-
export declare function
|
|
66
|
+
export declare function readDeviceUpdateState(paths?: DeviceStatePaths): Promise<DeviceUpdateState | null>;
|
|
67
|
+
export declare function assertDeviceStartupAllowedDuringUpdate(currentVersion?: string, paths?: DeviceStatePaths): Promise<void>;
|
|
68
|
+
export declare function resolveNpmCliPath(options?: {
|
|
5
69
|
platform?: NodeJS.Platform | string;
|
|
6
|
-
execFile?:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}>;
|
|
10
|
-
npmPath?: string;
|
|
70
|
+
execFile?: ExecFileFn;
|
|
71
|
+
nodePath?: string;
|
|
72
|
+
npmExecPath?: string;
|
|
11
73
|
}): Promise<string>;
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
74
|
+
export declare function findCurrentPackageRoot(entrypoint?: string): Promise<string>;
|
|
75
|
+
export declare function prepareDevicePackageUpdate(options: {
|
|
76
|
+
targetVersion: string;
|
|
77
|
+
requestId: string;
|
|
14
78
|
deviceId: string;
|
|
15
|
-
|
|
79
|
+
childPid?: number | null;
|
|
80
|
+
fromVersion?: string;
|
|
16
81
|
argv?: string[];
|
|
17
|
-
|
|
82
|
+
platform?: NodeJS.Platform | string;
|
|
83
|
+
execFile?: ExecFileFn;
|
|
84
|
+
paths?: DeviceStatePaths;
|
|
85
|
+
entrypoint?: string;
|
|
86
|
+
nodePath?: string;
|
|
87
|
+
packageRoot?: string;
|
|
88
|
+
npmCliPath?: string;
|
|
89
|
+
globalPrefix?: string;
|
|
90
|
+
globalRoot?: string;
|
|
91
|
+
managerOverride?: DeviceUpdateManagerOverride;
|
|
92
|
+
helperSourcePath?: string;
|
|
93
|
+
}): Promise<PreparedDeviceUpdate>;
|
|
94
|
+
export declare function launchDeviceUpdateHelper(prepared: PreparedDeviceUpdate, options?: {
|
|
95
|
+
execFile?: ExecFileFn;
|
|
18
96
|
spawn?: typeof spawnCallback;
|
|
19
|
-
|
|
20
|
-
|
|
97
|
+
platform?: NodeJS.Platform | string;
|
|
98
|
+
paths?: DeviceStatePaths;
|
|
99
|
+
}): Promise<void>;
|
|
100
|
+
export declare function signalDeviceUpdateHandoff(handoff?: {
|
|
101
|
+
childPid?: number | null;
|
|
102
|
+
}, paths?: DeviceStatePaths): Promise<void>;
|
|
103
|
+
export declare function markPreparedUpdateFailed(code: string, message: string, paths?: DeviceStatePaths): Promise<void>;
|
|
104
|
+
export type UpdateReconciliation = {
|
|
105
|
+
action: 'none';
|
|
106
|
+
} | {
|
|
107
|
+
action: 'success';
|
|
108
|
+
state: DeviceUpdateState;
|
|
109
|
+
} | {
|
|
110
|
+
action: 'report-failed';
|
|
111
|
+
state: DeviceUpdateState;
|
|
112
|
+
};
|
|
113
|
+
export declare function reconcileDeviceUpdateAfterStart(currentVersion?: string, paths?: DeviceStatePaths): Promise<UpdateReconciliation>;
|
|
114
|
+
export declare function retireDeviceUpdateState(state: DeviceUpdateState, paths?: DeviceStatePaths): Promise<void>;
|
|
115
|
+
export {};
|