dsh-wechat-remote 1.7.2 → 1.7.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.
- package/README.md +9 -3
- package/assets/release.json +35 -35
- package/bin/native-control.mjs +1 -1
- package/bin/release-selection.mjs +33 -0
- package/bin/setup.mjs +16 -16
- package/lib/install-control.js +1268 -1268
- package/lib/install-profile.js +210 -210
- package/lib/install-runtime.js +64 -64
- package/lib/package.json +1 -1
- package/lib/secure-file.js +76 -76
- package/lib/update-download.js +98 -98
- package/lib/update-policy.js +147 -147
- package/lib/update-worker.js +689 -679
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
# Agent远程管理助手 · DSH 插件安装器
|
|
1
|
+
# Agent远程管理助手 · DSH 插件安装器
|
|
2
|
+
|
|
3
|
+
当前安装器版本为 1.7.4,安装的正式插件仍为 1.7.2。已正常使用插件 1.7.2 的用户,无需因此重新安装。
|
|
2
4
|
|
|
3
5
|
首次安装和升级旧插件使用同一个命令:
|
|
4
6
|
|
|
@@ -8,10 +10,14 @@ npx -y dsh-wechat-remote@latest
|
|
|
8
10
|
|
|
9
11
|
需已安装 DSH,使用 Node.js 22.13 或更高版本。安装工具由包依赖自动提供,无需另装 pnpm 或 Git。
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
安装器安装正式插件,保留原配置、配对和会话,不会升级 DSH 本体。请先结束运行中的任务;安装完成后自动重启原 DSH 并尝试打开 WebUI。
|
|
14
|
+
|
|
15
|
+
DSH 的新版本、预览版本或未登记的主机架构不会仅因缺少验证记录而被拒绝安装。安装器仍检查必要运行能力、安装包完整性和已知不兼容问题,并保留失败恢复所需的备份;无法确认恢复结果时会提示保留数据。这不代表所有宿主组合均已通过功能验证。
|
|
12
16
|
|
|
13
17
|
支持已验证的 DSH `0.1.1-rc.2`、`0.1.2-rc.1`、`0.1.5-rc.1`,Windows / macOS Intel / Linux x64。普通 Node 启动、独立的 macOS launchd 和 Linux 用户级 systemd 服务可自动恢复;无法确认启动方式时不自动停止主机。
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
另已在 ARM64 Linux 电视盒子上验证 DSH `0.1.5-rc.1` 的首次安装、重复执行及重装。1.7.4 改善较慢主机启动时被误判为安装超时的问题;安装过程中请等待完成,勿重复执行命令。
|
|
20
|
+
|
|
21
|
+
旧插件 1.7.1 在 DSH 0.1.5 上无法一键更新时,可用本安装命令过渡一次。从插件 1.7.2 起,后续已验证的兼容更新不再受旧的 DSH 版本列表限制;不需要因此降低 DSH 版本或删除节点。
|
|
16
22
|
|
|
17
23
|
使用其他配置时附加 `--profile 配置名称`。安装损坏需要重装时附加 `--repair`;不会自动降级。
|
package/assets/release.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "1.7.2",
|
|
3
|
-
"catalog": {
|
|
4
|
-
"schemaVersion": 1,
|
|
5
|
-
"revision": "installer-1.7.2",
|
|
6
|
-
"issuedAt": 1789134534877,
|
|
7
|
-
"expiresAt": 1791553734877,
|
|
8
|
-
"releases": [
|
|
9
|
-
{
|
|
10
|
-
"version": "1.7.2",
|
|
11
|
-
"channel": "stable",
|
|
12
|
-
"dsh": [
|
|
13
|
-
"0.1.1-rc.2",
|
|
14
|
-
"0.1.2-rc.1",
|
|
15
|
-
"0.1.5-rc.1"
|
|
16
|
-
],
|
|
17
|
-
"platforms": [
|
|
18
|
-
"windows",
|
|
19
|
-
"macos",
|
|
20
|
-
"linux"
|
|
21
|
-
],
|
|
22
|
-
"architectures": [
|
|
23
|
-
"x64"
|
|
24
|
-
],
|
|
25
|
-
"asset": {
|
|
26
|
-
"url": "https://github.com/martinbear1/dsh-wechat-remote/releases/download/v1.7.2/harness-remote-dsh-wechat-remote-1.7.2.tgz",
|
|
27
|
-
"sha256": "0eb296a3a0c84f080148280f9b9419516a9dc640c9e13aa8cf014120aea591ee",
|
|
28
|
-
"bytes": 9539789
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
],
|
|
32
|
-
"blocked": [],
|
|
33
|
-
"retiredDsh": []
|
|
34
|
-
}
|
|
35
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"version": "1.7.2",
|
|
3
|
+
"catalog": {
|
|
4
|
+
"schemaVersion": 1,
|
|
5
|
+
"revision": "installer-1.7.2",
|
|
6
|
+
"issuedAt": 1789134534877,
|
|
7
|
+
"expiresAt": 1791553734877,
|
|
8
|
+
"releases": [
|
|
9
|
+
{
|
|
10
|
+
"version": "1.7.2",
|
|
11
|
+
"channel": "stable",
|
|
12
|
+
"dsh": [
|
|
13
|
+
"0.1.1-rc.2",
|
|
14
|
+
"0.1.2-rc.1",
|
|
15
|
+
"0.1.5-rc.1"
|
|
16
|
+
],
|
|
17
|
+
"platforms": [
|
|
18
|
+
"windows",
|
|
19
|
+
"macos",
|
|
20
|
+
"linux"
|
|
21
|
+
],
|
|
22
|
+
"architectures": [
|
|
23
|
+
"x64"
|
|
24
|
+
],
|
|
25
|
+
"asset": {
|
|
26
|
+
"url": "https://github.com/martinbear1/dsh-wechat-remote/releases/download/v1.7.2/harness-remote-dsh-wechat-remote-1.7.2.tgz",
|
|
27
|
+
"sha256": "0eb296a3a0c84f080148280f9b9419516a9dc640c9e13aa8cf014120aea591ee",
|
|
28
|
+
"bytes": 9539789
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"blocked": [],
|
|
33
|
+
"retiredDsh": []
|
|
34
|
+
}
|
|
35
|
+
}
|
package/bin/native-control.mjs
CHANGED
|
@@ -58,7 +58,7 @@ export async function waitForJson(filename, accept, timeout = 20000) {
|
|
|
58
58
|
* A listening WebUI is not proof that the asynchronous profile reload finished.
|
|
59
59
|
* Keep the same control entry/token while waiting; never restart a live host. */
|
|
60
60
|
export async function waitForInstallControl(filename, {
|
|
61
|
-
accept, ensureRunning, onWaiting = () => {}, timeoutMs =
|
|
61
|
+
accept, ensureRunning, onWaiting = () => {}, timeoutMs = 180000, initialWaitMs = 5000,
|
|
62
62
|
}) {
|
|
63
63
|
const deadline = Date.now() + timeoutMs
|
|
64
64
|
try { return await waitForJson(filename, accept, Math.min(initialWaitMs, timeoutMs)) }
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { validateCatalog, compareVersions, trustedReleaseAsset } from '../lib/update-policy.js'
|
|
2
|
+
|
|
3
|
+
/** Explicit CLI installation is not an automatic-update recommendation.
|
|
4
|
+
* Tested DSH/platform/architecture lists describe evidence, not admission.
|
|
5
|
+
* Keep trusted artifacts, explicit withdrawals and the no-downgrade floor.
|
|
6
|
+
*/
|
|
7
|
+
export function selectInstallTarget(pinned, remote, current, now = Date.now()) {
|
|
8
|
+
const local = validateCatalog(pinned.catalog)
|
|
9
|
+
const bundled = local.releases.find(r => r.version === pinned.version && r.channel === 'stable')
|
|
10
|
+
if (!bundled || !trustedReleaseAsset(bundled.asset, bundled.version)) {
|
|
11
|
+
throw new Error('安装包信息不完整,请重新获取官方安装器。')
|
|
12
|
+
}
|
|
13
|
+
let online
|
|
14
|
+
try {
|
|
15
|
+
const candidate = validateCatalog(remote)
|
|
16
|
+
if (candidate.issuedAt <= now + 300000 && candidate.expiresAt > now) online = candidate
|
|
17
|
+
} catch { /* The authenticated npm package remains usable without the catalog. */ }
|
|
18
|
+
|
|
19
|
+
// An installer never silently substitutes an older plugin than its own bundle.
|
|
20
|
+
// Keep the bundled bytes/hash for the same version even if remote metadata differs.
|
|
21
|
+
const candidates = [bundled, ...(online?.releases || []).filter(r => r.channel === 'stable'
|
|
22
|
+
&& compareVersions(r.version, bundled.version) > 0 && trustedReleaseAsset(r.asset, r.version))]
|
|
23
|
+
.sort((a, b) => compareVersions(b.version, a.version))
|
|
24
|
+
const rules = [...local.blocked, ...(online?.blocked || [])]
|
|
25
|
+
const blocked = release => rules.find(b => b.pluginVersion === release.version
|
|
26
|
+
&& (!b.dsh || b.dsh.includes(current.agentVersion))
|
|
27
|
+
&& (!b.platforms || b.platforms.includes(current.platform)))
|
|
28
|
+
const release = candidates.find(r => !blocked(r))
|
|
29
|
+
if (!release) {
|
|
30
|
+
throw new Error(`当前插件存在已知不兼容问题:${blocked(bundled).reason};未替换现有插件。`)
|
|
31
|
+
}
|
|
32
|
+
return release
|
|
33
|
+
}
|
package/bin/setup.mjs
CHANGED
|
@@ -8,7 +8,8 @@ import { randomBytes, createHash } from 'node:crypto'
|
|
|
8
8
|
import { fileURLToPath } from 'node:url'
|
|
9
9
|
import { attachControl, waitForJson, waitForInstallControl } from './native-control.mjs'
|
|
10
10
|
import { resolveInstallRuntime, verifyInstallRuntime } from '../lib/install-runtime.js'
|
|
11
|
-
import {
|
|
11
|
+
import { compareVersions } from '../lib/update-policy.js'
|
|
12
|
+
import { selectInstallTarget } from './release-selection.mjs'
|
|
12
13
|
import { boundedFetch, downloadRelease, auditArchive } from '../lib/update-download.js'
|
|
13
14
|
import { writePrivateJsonAtomic } from '../lib/secure-file.js'
|
|
14
15
|
import { control, validateJob, releaseOwnedUpdateLock } from '../lib/update-worker.js'
|
|
@@ -38,21 +39,16 @@ function portBusy(port) {
|
|
|
38
39
|
socket.setTimeout(500, () => end(false)); socket.once('connect', () => end(true)); socket.once('error', () => end(false))
|
|
39
40
|
})
|
|
40
41
|
}
|
|
41
|
-
async function selectRelease(host, assetsRoot = path.join(root, 'assets'), repair = false
|
|
42
|
+
export async function selectRelease(host, assetsRoot = path.join(root, 'assets'), repair = false,
|
|
43
|
+
fetchCatalog = () => boundedFetch('https://relay.xyxfood.xyz/v1/update-policy', 256 * 1024)) {
|
|
42
44
|
const current = { agentKind: 'dsh', agentVersion: host.dshVersion, pluginVersion: host.pluginVersion,
|
|
43
45
|
platform: { win32: 'windows', darwin: 'macos', linux: 'linux' }[host.platform], arch: host.arch }
|
|
44
46
|
const pinned = JSON.parse(fs.readFileSync(path.join(assetsRoot, 'release.json'), 'utf8'))
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
releases = [...releases, ...remote.releases].filter(r => !remote.blocked.some(b => b.pluginVersion === r.version && (!b.dsh || b.dsh.includes(current.agentVersion)) && (!b.platforms || b.platforms.includes(current.platform))))
|
|
51
|
-
}
|
|
52
|
-
} catch { /* Authenticated npm package retains its explicitly tested release. */ }
|
|
53
|
-
const release = releases.filter(r => r.channel === 'stable' && releaseMatches(r, current))
|
|
54
|
-
.sort((a, b) => compareVersions(b.version, a.version))[0]
|
|
55
|
-
if (!release) throw new Error('当前 DSH 版本或系统尚无已验证的插件版本;没有修改现有安装。')
|
|
47
|
+
let remote
|
|
48
|
+
try {
|
|
49
|
+
remote = JSON.parse((await fetchCatalog()).toString('utf8'))
|
|
50
|
+
} catch { /* Authenticated npm package retains its bundled release. */ }
|
|
51
|
+
const release = selectInstallTarget(pinned, remote, current)
|
|
56
52
|
if (host.pluginVersion !== '0.0.0' && (compareVersions(host.pluginVersion, release.version) > 0
|
|
57
53
|
|| (compareVersions(host.pluginVersion, release.version) === 0 && !repair))) return { release, archive: null }
|
|
58
54
|
let archive
|
|
@@ -77,10 +73,14 @@ export async function install({ profileName = 'web', cli = findDsh(), assetsRoot
|
|
|
77
73
|
// Initialize missing profiles through DSH itself, never synthesize a bundle list.
|
|
78
74
|
if (!fs.existsSync(path.join(profile, 'package.json'))) {
|
|
79
75
|
const log = fs.openSync(path.join(directory, 'startup.log'), 'a', 0o600)
|
|
80
|
-
launched = spawn(process.execPath, [cli, '--profile', profileName, '--no-open'], {
|
|
76
|
+
launched = spawn(process.execPath, [cli, '--profile', profileName, '--no-open'], {
|
|
81
77
|
cwd: process.cwd(), env: process.env, detached: true, windowsHide: true, stdio: ['ignore', log, log] })
|
|
82
78
|
fs.closeSync(log); launched.on('error', () => {}); launched.unref()
|
|
83
|
-
|
|
79
|
+
const initializedBy = Date.now() + 180000
|
|
80
|
+
while (!fs.existsSync(path.join(profile, 'package.json')) && Date.now() < initializedBy) {
|
|
81
|
+
if (launched.exitCode !== null || launched.signalCode !== null) break
|
|
82
|
+
await sleep(100)
|
|
83
|
+
}
|
|
84
84
|
if (!fs.existsSync(path.join(profile, 'package.json'))) throw new Error('DSH 未能初始化 profile;详情见本机安装记录。')
|
|
85
85
|
await sleep(2000)
|
|
86
86
|
}
|
|
@@ -97,7 +97,7 @@ export async function install({ profileName = 'web', cli = findDsh(), assetsRoot
|
|
|
97
97
|
ensureRunning: async () => {
|
|
98
98
|
if (launched || await portBusy(Number(process.env.DSH_PORT || 3080))) return
|
|
99
99
|
const log = fs.openSync(path.join(directory, 'startup.log'), 'a', 0o600)
|
|
100
|
-
launched = spawn(process.execPath, [cli, '--profile', profileName, '--no-open'], {
|
|
100
|
+
launched = spawn(process.execPath, [cli, '--profile', profileName, '--no-open'], {
|
|
101
101
|
cwd: process.cwd(), env: process.env, detached: true, windowsHide: true, stdio: ['ignore', log, log] })
|
|
102
102
|
fs.closeSync(log); launched.on('error', () => {}); launched.unref()
|
|
103
103
|
},
|