dsh-wechat-remote 1.7.2 → 1.7.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.md CHANGED
@@ -1,4 +1,6 @@
1
- # Agent远程管理助手 · DSH 插件安装器
1
+ # Agent远程管理助手 · DSH 插件安装器
2
+
3
+ 当前安装器版本为 1.7.3,安装的正式插件仍为 1.7.2。已正常使用插件 1.7.2 的用户,无需因此重新安装。
2
4
 
3
5
  首次安装和升级旧插件使用同一个命令:
4
6
 
@@ -8,10 +10,12 @@ npx -y dsh-wechat-remote@latest
8
10
 
9
11
  需已安装 DSH,使用 Node.js 22.13 或更高版本。安装工具由包依赖自动提供,无需另装 pnpm 或 Git。
10
12
 
11
- 安装器仅选择适配当前 DSH 和主机的正式插件,保留原配置、配对和会话,不会升级 DSH 本体。请先结束运行中的任务;安装完成后自动重启原 DSH 并尝试打开 WebUI。
12
-
13
- 支持已验证的 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 服务可自动恢复;无法确认启动方式时不自动停止主机。
13
+ 安装器安装正式插件,保留原配置、配对和会话,不会升级 DSH 本体。请先结束运行中的任务;安装完成后自动重启原 DSH 并尝试打开 WebUI。
14
14
 
15
- 旧插件 1.7.1 在 DSH 0.1.5 上无法一键更新时,可用本安装命令过渡一次。从插件 1.7.2 起,后续已验证的兼容更新不再受旧的 DSH 版本列表限制;不需要因此降低 DSH 版本或删除节点。
15
+ DSH 的新版本、预览版本或未登记的主机架构不会仅因缺少验证记录而被拒绝安装。安装器仍检查必要运行能力、安装包完整性和已知不兼容问题,安装失败会回退;这不代表所有宿主组合均已通过功能验证。
16
+
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 服务可自动恢复;无法确认启动方式时不自动停止主机。
18
+
19
+ 旧插件 1.7.1 在 DSH 0.1.5 上无法一键更新时,可用本安装命令过渡一次。从插件 1.7.2 起,后续已验证的兼容更新不再受旧的 DSH 版本列表限制;不需要因此降低 DSH 版本或删除节点。
16
20
 
17
21
  使用其他配置时附加 `--profile 配置名称`。安装损坏需要重装时附加 `--repair`;不会自动降级。
@@ -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
+ }
@@ -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 { validateCatalog, releaseMatches, compareVersions } from '../lib/update-policy.js'
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
- const catalog = validateCatalog(pinned.catalog)
46
- let releases = catalog.releases
47
- try {
48
- const remote = validateCatalog(JSON.parse((await boundedFetch('https://relay.xyxfood.xyz/v1/update-policy', 256 * 1024)).toString('utf8')))
49
- if (remote.issuedAt <= Date.now() + 300000 && remote.expiresAt > Date.now()) {
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,7 +73,7 @@ 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
  for (let i = 0; i < 100 && !fs.existsSync(path.join(profile, 'package.json')); i++) await sleep(100)
@@ -97,7 +93,7 @@ export async function install({ profileName = 'web', cli = findDsh(), assetsRoot
97
93
  ensureRunning: async () => {
98
94
  if (launched || await portBusy(Number(process.env.DSH_PORT || 3080))) return
99
95
  const log = fs.openSync(path.join(directory, 'startup.log'), 'a', 0o600)
100
- launched = spawn(process.execPath, [cli, '--profile', profileName, '--no-open'], {
96
+ launched = spawn(process.execPath, [cli, '--profile', profileName, '--no-open'], {
101
97
  cwd: process.cwd(), env: process.env, detached: true, windowsHide: true, stdio: ['ignore', log, log] })
102
98
  fs.closeSync(log); launched.on('error', () => {}); launched.unref()
103
99
  },