@hmharness/cli 0.23.25 → 0.23.26
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/board/install-kaihongos.cjs +263 -263
- package/dist/evolution-daemon.js +35 -35
- package/dist/web-daemon.js +47 -5
- package/package.json +64 -64
- package/release-notes.json +69 -64
|
@@ -1,264 +1,264 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// install-kaihongos.cjs — one-command board installer for @hmharness/cli on
|
|
3
|
-
// TWIN COPY: scripts/install-kaihongos.cjs (repo installs) and
|
|
4
|
-
// packages/cli/board/install-kaihongos.cjs (ships in the npm package - the
|
|
5
|
-
// board auto-update channel runs THIS one, settled design T28). Keep both
|
|
6
|
-
// in sync when bumping FALLBACK_PINS.
|
|
7
|
-
// KaihongOS / OpenHarmony 5.0 boards (no npm, no Python, read-only rootfs).
|
|
8
|
-
//
|
|
9
|
-
// What it does (idempotent, re-run any time):
|
|
10
|
-
// 1. locates a usable Node >= 22 (the running one, or known board paths)
|
|
11
|
-
// 2. resolves the @hmharness/* version set from registry.npmjs.org
|
|
12
|
-
// (offline fallback: known-good pins below)
|
|
13
|
-
// 3. downloads the 10 first-party tarballs and unpacks them under
|
|
14
|
-
// <BOARD_HOME>/.local/hmharness/node_modules (staged, verified, swapped)
|
|
15
|
-
// 4. writes a hardened launcher and installs it into THREE locations:
|
|
16
|
-
// <BOARD_HOME>/.local/bin/hmh (user path, always writable)
|
|
17
|
-
// /usr/local/bin/hmh (default PATH on classic shells)
|
|
18
|
-
// /system/bin/hmh (read-only rootfs, remount dance;
|
|
19
|
-
// ALSO visible inside isolated
|
|
20
|
-
// tmpfs mount-namespace terminals
|
|
21
|
-
// where /bin -> /system/bin)
|
|
22
|
-
// 5. first run: `hmh init` if config.json is missing
|
|
23
|
-
//
|
|
24
|
-
// Usage:
|
|
25
|
-
// node install-kaihongos.cjs # install/upgrade to latest
|
|
26
|
-
// node install-kaihongos.cjs --bin-only # only (re)write launchers
|
|
27
|
-
// node install-kaihongos.cjs --home=/x # non-default board home
|
|
28
|
-
//
|
|
29
|
-
// Only Node core modules are used; tar extraction uses busybox tar.
|
|
30
|
-
const fs = require('fs');
|
|
31
|
-
const path = require('path');
|
|
32
|
-
const https = require('https');
|
|
33
|
-
const { spawnSync } = require('child_process');
|
|
34
|
-
|
|
35
|
-
// ---------- board constants -------------------------------------------------
|
|
36
|
-
let BOARD_HOME = '/data/local/home'; // KaihongOS board home
|
|
37
|
-
let BIN_ONLY = false;
|
|
38
|
-
|
|
39
|
-
for (const a of process.argv.slice(2)) {
|
|
40
|
-
if (a.startsWith('--home=')) BOARD_HOME = a.slice(7);
|
|
41
|
-
else if (a === '--bin-only') BIN_ONLY = true;
|
|
42
|
-
else { console.error('unknown arg:', a); process.exit(2); }
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const ROOT = path.join(BOARD_HOME, '.local', 'hmharness');
|
|
46
|
-
const NM = path.join(ROOT, 'node_modules');
|
|
47
|
-
const HMH_HOME = path.join(BOARD_HOME, '.hmharness');
|
|
48
|
-
const REG = 'https://registry.npmjs.org';
|
|
49
|
-
const PACKAGES = ['cli', 'web', 'agent', 'kernel', 'sandbox', 'evolution',
|
|
50
|
-
'domain-ops', 'evaluation', 'observability', 'domain-harmony'];
|
|
51
|
-
|
|
52
|
-
// Known-good pin set (offline fallback when the registry is unreachable).
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// install-kaihongos.cjs — one-command board installer for @hmharness/cli on
|
|
3
|
+
// TWIN COPY: scripts/install-kaihongos.cjs (repo installs) and
|
|
4
|
+
// packages/cli/board/install-kaihongos.cjs (ships in the npm package - the
|
|
5
|
+
// board auto-update channel runs THIS one, settled design T28). Keep both
|
|
6
|
+
// in sync when bumping FALLBACK_PINS.
|
|
7
|
+
// KaihongOS / OpenHarmony 5.0 boards (no npm, no Python, read-only rootfs).
|
|
8
|
+
//
|
|
9
|
+
// What it does (idempotent, re-run any time):
|
|
10
|
+
// 1. locates a usable Node >= 22 (the running one, or known board paths)
|
|
11
|
+
// 2. resolves the @hmharness/* version set from registry.npmjs.org
|
|
12
|
+
// (offline fallback: known-good pins below)
|
|
13
|
+
// 3. downloads the 10 first-party tarballs and unpacks them under
|
|
14
|
+
// <BOARD_HOME>/.local/hmharness/node_modules (staged, verified, swapped)
|
|
15
|
+
// 4. writes a hardened launcher and installs it into THREE locations:
|
|
16
|
+
// <BOARD_HOME>/.local/bin/hmh (user path, always writable)
|
|
17
|
+
// /usr/local/bin/hmh (default PATH on classic shells)
|
|
18
|
+
// /system/bin/hmh (read-only rootfs, remount dance;
|
|
19
|
+
// ALSO visible inside isolated
|
|
20
|
+
// tmpfs mount-namespace terminals
|
|
21
|
+
// where /bin -> /system/bin)
|
|
22
|
+
// 5. first run: `hmh init` if config.json is missing
|
|
23
|
+
//
|
|
24
|
+
// Usage:
|
|
25
|
+
// node install-kaihongos.cjs # install/upgrade to latest
|
|
26
|
+
// node install-kaihongos.cjs --bin-only # only (re)write launchers
|
|
27
|
+
// node install-kaihongos.cjs --home=/x # non-default board home
|
|
28
|
+
//
|
|
29
|
+
// Only Node core modules are used; tar extraction uses busybox tar.
|
|
30
|
+
const fs = require('fs');
|
|
31
|
+
const path = require('path');
|
|
32
|
+
const https = require('https');
|
|
33
|
+
const { spawnSync } = require('child_process');
|
|
34
|
+
|
|
35
|
+
// ---------- board constants -------------------------------------------------
|
|
36
|
+
let BOARD_HOME = '/data/local/home'; // KaihongOS board home
|
|
37
|
+
let BIN_ONLY = false;
|
|
38
|
+
|
|
39
|
+
for (const a of process.argv.slice(2)) {
|
|
40
|
+
if (a.startsWith('--home=')) BOARD_HOME = a.slice(7);
|
|
41
|
+
else if (a === '--bin-only') BIN_ONLY = true;
|
|
42
|
+
else { console.error('unknown arg:', a); process.exit(2); }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const ROOT = path.join(BOARD_HOME, '.local', 'hmharness');
|
|
46
|
+
const NM = path.join(ROOT, 'node_modules');
|
|
47
|
+
const HMH_HOME = path.join(BOARD_HOME, '.hmharness');
|
|
48
|
+
const REG = 'https://registry.npmjs.org';
|
|
49
|
+
const PACKAGES = ['cli', 'web', 'agent', 'kernel', 'sandbox', 'evolution',
|
|
50
|
+
'domain-ops', 'evaluation', 'observability', 'domain-harmony'];
|
|
51
|
+
|
|
52
|
+
// Known-good pin set (offline fallback when the registry is unreachable).
|
|
53
53
|
const FALLBACK_PINS = {
|
|
54
|
-
cli: '0.23.
|
|
55
|
-
sandbox: '0.23.
|
|
56
|
-
evaluation: '0.23.
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// ---------- helpers ---------------------------------------------------------
|
|
60
|
-
function log(msg) { console.log(msg); }
|
|
61
|
-
|
|
62
|
-
function httpsJSON(url, timeoutMs) {
|
|
63
|
-
return new Promise((resolve, reject) => {
|
|
64
|
-
const req = https.request(new URL(url), { headers: { 'User-Agent': 'hmh-kaihongos-installer' }, timeout: timeoutMs || 20000 }, (res) => {
|
|
65
|
-
if (res.statusCode !== 200) { res.resume(); reject(new Error(url + ' -> ' + res.statusCode)); return; }
|
|
66
|
-
const chunks = [];
|
|
67
|
-
res.on('data', (c) => chunks.push(c));
|
|
68
|
-
res.on('end', () => { try { resolve(JSON.parse(Buffer.concat(chunks).toString('utf8'))); } catch (e) { reject(e); } });
|
|
69
|
-
});
|
|
70
|
-
req.on('timeout', () => { req.destroy(new Error('timeout')); });
|
|
71
|
-
req.on('error', reject);
|
|
72
|
-
req.end();
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function download(url, file) {
|
|
77
|
-
return new Promise((resolve, reject) => {
|
|
78
|
-
let attempt = 0;
|
|
79
|
-
function go() {
|
|
80
|
-
attempt++;
|
|
81
|
-
const req = https.request(new URL(url), { headers: { 'User-Agent': 'hmh-kaihongos-installer' }, timeout: 30000 }, (res) => {
|
|
82
|
-
if (res.statusCode !== 200) { res.resume(); reject(new Error(url + ' -> ' + res.statusCode)); return; }
|
|
83
|
-
const out = fs.createWriteStream(file);
|
|
84
|
-
res.pipe(out);
|
|
85
|
-
out.on('finish', () => out.close(resolve));
|
|
86
|
-
out.on('error', reject);
|
|
87
|
-
});
|
|
88
|
-
req.on('timeout', () => { req.destroy(); retry(); });
|
|
89
|
-
req.on('error', (e) => {
|
|
90
|
-
if (attempt < 10 && /EAI_AGAIN|ENOTFOUND|ECONNRESET|ETIMEDOUT/.test(e.code || '')) setTimeout(retry, 1500 * attempt);
|
|
91
|
-
else reject(e);
|
|
92
|
-
});
|
|
93
|
-
req.end();
|
|
94
|
-
}
|
|
95
|
-
function retry() { if (attempt < 10) go(); else reject(new Error('retries exhausted: ' + url)); }
|
|
96
|
-
go();
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function extract(tgz, dest) {
|
|
101
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
102
|
-
// busybox tar is present on KaihongOS / OpenHarmony boards and understands
|
|
103
|
-
// --strip-components. (GNU/toybox tar also fine if busybox is missing.)
|
|
104
|
-
const cmds = [
|
|
105
|
-
['busybox', ['tar', '-xzf', tgz, '-C', dest, '--strip-components=1']],
|
|
106
|
-
['tar', ['-xzf', tgz, '-C', dest, '--strip-components=1']],
|
|
107
|
-
];
|
|
108
|
-
for (const [bin, args] of cmds) {
|
|
109
|
-
const r = spawnSync(bin, args, { encoding: 'utf8' });
|
|
110
|
-
if (r.status === 0) return;
|
|
111
|
-
if (r.error && r.error.code !== 'ENOENT') log(' warn: ' + bin + ' tar: ' + (r.stderr || r.error.message).slice(0, 120));
|
|
112
|
-
}
|
|
113
|
-
throw new Error('no usable tar (tried busybox tar, tar)');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async function resolveVersions() {
|
|
117
|
-
log('resolving latest @hmharness/cli from registry ...');
|
|
118
|
-
const meta = await httpsJSON(REG + '/@hmharness/cli');
|
|
119
|
-
const cliLatest = meta['dist-tags'].latest;
|
|
120
|
-
const deps = (meta.versions[cliLatest].dependencies) || {};
|
|
121
|
-
const pins = { cli: cliLatest };
|
|
122
|
-
for (const n of PACKAGES.slice(1)) {
|
|
123
|
-
const want = deps['@hmharness/' + n];
|
|
124
|
-
if (want && want !== '*') { pins[n] = want.replace(/[^0-9.]/g, ''); continue; }
|
|
125
|
-
const m = await httpsJSON(REG + '/@hmharness/' + n);
|
|
126
|
-
pins[n] = m['dist-tags'].latest;
|
|
127
|
-
}
|
|
128
|
-
return pins;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// ---------- node discovery --------------------------------------------------
|
|
132
|
-
function findNode() {
|
|
133
|
-
const cands = [process.execPath,
|
|
134
|
-
path.join(BOARD_HOME, 'dsh-pack/node/bin/node'),
|
|
135
|
-
path.join(BOARD_HOME, '.ohos/node/bin/node'),
|
|
136
|
-
'/usr/local/bin/node', '/usr/bin/node', '/system/bin/node'];
|
|
137
|
-
for (const c of cands) {
|
|
138
|
-
try {
|
|
139
|
-
fs.accessSync(c, fs.constants.X_OK);
|
|
140
|
-
const v = spawnSync(c, ['--version'], { encoding: 'utf8' });
|
|
141
|
-
if (v.status === 0) { const maj = parseInt((v.stdout || '').replace('v', ''), 10); if (maj >= 22) return c; }
|
|
142
|
-
} catch (_) { /* next */ }
|
|
143
|
-
}
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// ---------- launcher --------------------------------------------------------
|
|
148
|
-
function launcherSource(nodeBin) {
|
|
149
|
-
return [
|
|
150
|
-
'#!/system/bin/sh',
|
|
151
|
-
'# hmh launcher — KaihongOS board install (generated by install-kaihongos.cjs)',
|
|
152
|
-
'# Board layout is fixed under ' + BOARD_HOME + ', independent of caller HOME/PATH.',
|
|
153
|
-
'HROOT="' + ROOT + '"',
|
|
154
|
-
'HNODE="' + nodeBin + '"',
|
|
155
|
-
'[ -x "$HNODE" ] || for c in node ' + BOARD_HOME + '/dsh-pack/node/bin/node ' + BOARD_HOME + '/.ohos/node/bin/node; do',
|
|
156
|
-
' [ -x "$c" ] && HNODE="$c" && break',
|
|
157
|
-
'done',
|
|
158
|
-
'# optional board-wide secrets file (edit or remove — keys normally live in config.json)',
|
|
159
|
-
'[ -f ' + BOARD_HOME + '/.config/apikeys.env ] && . ' + BOARD_HOME + '/.config/apikeys.env',
|
|
160
|
-
'# board shells run with HOME=/ — force a real writable HOME and a stable state dir',
|
|
161
|
-
'[ -z "${HMH_HOME:-}" ] && export HMH_HOME="' + HMH_HOME + '"',
|
|
162
|
-
'export HOME="' + BOARD_HOME + '"',
|
|
163
|
-
'export NODE_ALLOW_JIT="${NODE_ALLOW_JIT:-1}"',
|
|
164
|
-
'# drop --jitless inherited from sandbox profiles; board root shell can JIT',
|
|
165
|
-
'NODE_OPTIONS="$(echo "${NODE_OPTIONS:-}" | sed \'s|--jitless||g; s/ */ /g\')"',
|
|
166
|
-
'NODE_OPTIONS="$(echo "$NODE_OPTIONS" | sed \'s/^ *//;s/ *$//\')"',
|
|
167
|
-
'[ -n "$NODE_OPTIONS" ] && export NODE_OPTIONS',
|
|
168
|
-
'# optional DevEco-layout toolchain shims (hvigorw / ohpm)',
|
|
169
|
-
'[ -z "${HM_DEVECO_HOME:-}" ] && [ -d ' + BOARD_HOME + '/.local/hm-devtools ] && export HM_DEVECO_HOME="' + BOARD_HOME + '/.local/hm-devtools"',
|
|
170
|
-
'exec "$HNODE" "$HROOT/node_modules/@hmharness/cli/dist/main.js" "$@"',
|
|
171
|
-
'',
|
|
172
|
-
].join('\n');
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function writeLauncher(nodeBin) {
|
|
176
|
-
const src = launcherSource(nodeBin);
|
|
177
|
-
const userBin = path.join(BOARD_HOME, '.local', 'bin');
|
|
178
|
-
fs.mkdirSync(userBin, { recursive: true });
|
|
179
|
-
fs.writeFileSync(path.join(userBin, 'hmh'), src);
|
|
180
|
-
fs.chmodSync(path.join(userBin, 'hmh'), 0o755);
|
|
181
|
-
log('launcher: ' + path.join(userBin, 'hmh'));
|
|
182
|
-
|
|
183
|
-
// System locations live on the read-only rootfs — remount rw, copy, restore ro.
|
|
184
|
-
// /system/bin matters most: isolated tmpfs-namespace terminals (ttyd web
|
|
185
|
-
// terminals, containers) see no /usr at all, but /bin -> /system/bin + /data.
|
|
186
|
-
for (const sysBin of ['/usr/local/bin', '/system/bin']) {
|
|
187
|
-
try { fs.mkdirSync(sysBin, { recursive: true }); } catch (_) { /* exists */ }
|
|
188
|
-
const target = path.join(sysBin, 'hmh');
|
|
189
|
-
const rw = spawnSync('mount', ['-o', 'remount,rw', '/'], { encoding: 'utf8' });
|
|
190
|
-
try {
|
|
191
|
-
fs.writeFileSync(target, src);
|
|
192
|
-
fs.chmodSync(target, 0o755);
|
|
193
|
-
log('launcher: ' + target + (rw.status === 0 ? ' (rootfs remounted rw then ro)' : ''));
|
|
194
|
-
} catch (e) {
|
|
195
|
-
log('warn: could not write ' + target + ': ' + e.message);
|
|
196
|
-
} finally {
|
|
197
|
-
if (rw.status === 0) spawnSync('mount', ['-o', 'remount,ro', '/'], { encoding: 'utf8' });
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// ---------- main ------------------------------------------------------------
|
|
203
|
-
(async () => {
|
|
204
|
-
log('board home: ' + BOARD_HOME);
|
|
205
|
-
const nodeBin = findNode();
|
|
206
|
-
if (!nodeBin) { console.error('FATAL: no Node >= 22 found (looked at PATH, dsh-pack, .ohos). hmh needs Node >= 22.'); process.exit(1); }
|
|
207
|
-
log('node: ' + nodeBin + ' (' + (spawnSync(nodeBin, ['--version'], { encoding: 'utf8' }).stdout || '').trim() + ')');
|
|
208
|
-
|
|
209
|
-
if (!BIN_ONLY) {
|
|
210
|
-
let pins;
|
|
211
|
-
try { pins = await resolveVersions(); }
|
|
212
|
-
catch (e) {
|
|
213
|
-
log('warn: registry unreachable (' + e.message.slice(0, 80) + ') — falling back to known-good pins');
|
|
214
|
-
pins = Object.assign({}, FALLBACK_PINS);
|
|
215
|
-
}
|
|
216
|
-
for (const n of PACKAGES) log(' @hmharness/' + n + '@' + pins[n]);
|
|
217
|
-
|
|
218
|
-
const STAGE = NM + '.new';
|
|
219
|
-
fs.rmSync(STAGE, { recursive: true, force: true });
|
|
220
|
-
fs.mkdirSync(path.join(STAGE, '@hmharness'), { recursive: true });
|
|
221
|
-
for (const name of PACKAGES) {
|
|
222
|
-
const ver = pins[name];
|
|
223
|
-
const tgz = path.join(ROOT, '.stage.tgz');
|
|
224
|
-
process.stdout.write('download ' + name + '@' + ver + ' ... ');
|
|
225
|
-
await download(REG + '/@hmharness/' + name + '/-/' + name + '-' + ver + '.tgz', tgz);
|
|
226
|
-
const dest = path.join(STAGE, '@hmharness', name);
|
|
227
|
-
extract(tgz, dest);
|
|
228
|
-
const pkg = JSON.parse(fs.readFileSync(path.join(dest, 'package.json'), 'utf8'));
|
|
229
|
-
if (pkg.version !== ver) throw new Error(name + ': unpacked ' + pkg.version + ' != ' + ver);
|
|
230
|
-
log('ok');
|
|
231
|
-
}
|
|
232
|
-
fs.rmSync(path.join(ROOT, '.stage.tgz'), { force: true });
|
|
233
|
-
|
|
234
|
-
// syntax-check the staged CLI entrypoint before swapping anything
|
|
235
|
-
const main = path.join(STAGE, '@hmharness', 'cli', 'dist', 'main.js');
|
|
236
|
-
const chk = spawnSync(nodeBin, ['--check', main], { encoding: 'utf8' });
|
|
237
|
-
if (chk.status !== 0) throw new Error('staged main.js failed --check: ' + (chk.stderr || '').slice(0, 200));
|
|
238
|
-
log('staged CLI entrypoint OK');
|
|
239
|
-
|
|
240
|
-
const BAK = NM + '.bak';
|
|
241
|
-
fs.rmSync(BAK, { recursive: true, force: true });
|
|
242
|
-
if (fs.existsSync(NM)) fs.renameSync(NM, BAK);
|
|
243
|
-
fs.renameSync(STAGE, NM);
|
|
244
|
-
log('installed @hmharness/cli@' + pins.cli + ' (previous tree kept at ' + BAK + ')');
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
writeLauncher(nodeBin);
|
|
248
|
-
|
|
249
|
-
// first run: create the state skeleton + blank config (never overwrite)
|
|
250
|
-
if (!fs.existsSync(path.join(HMH_HOME, 'config.json'))) {
|
|
251
|
-
log('first run: creating config skeleton at ' + HMH_HOME);
|
|
252
|
-
const r = spawnSync(nodeBin, [path.join(NM, '@hmharness', 'cli', 'dist', 'main.js'), 'init'], {
|
|
253
|
-
encoding: 'utf8', env: Object.assign({}, process.env, { HMH_HOME, HOME: BOARD_HOME }),
|
|
254
|
-
});
|
|
255
|
-
log((r.stdout || r.stderr || '').trim().split('\n').slice(-3).join('\n'));
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
console.log('\nnext steps:');
|
|
259
|
-
console.log(' 1. put your provider keys in ' + path.join(HMH_HOME, 'config.json'));
|
|
260
|
-
console.log(' (presets for 38 vendors: docs/PROVIDERS.md)');
|
|
261
|
-
console.log(' 2. hmh check # verify toolchain');
|
|
262
|
-
console.log(' 3. hmh tui # or: hmh web start → http://127.0.0.1:7788');
|
|
263
|
-
console.log('pitfalls & details: docs/KAIHONGOS.md');
|
|
264
|
-
})().catch((e) => { console.error('INSTALL FAILED:', e.message); process.exit(1); });
|
|
54
|
+
cli: '0.23.26', web: '0.23.26', agent: '0.23.26', kernel: '0.23.26',
|
|
55
|
+
sandbox: '0.23.26', evolution: '0.23.26', 'domain-ops': '0.23.26',
|
|
56
|
+
evaluation: '0.23.26', observability: '0.23.26', 'domain-harmony': '0.23.26',
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// ---------- helpers ---------------------------------------------------------
|
|
60
|
+
function log(msg) { console.log(msg); }
|
|
61
|
+
|
|
62
|
+
function httpsJSON(url, timeoutMs) {
|
|
63
|
+
return new Promise((resolve, reject) => {
|
|
64
|
+
const req = https.request(new URL(url), { headers: { 'User-Agent': 'hmh-kaihongos-installer' }, timeout: timeoutMs || 20000 }, (res) => {
|
|
65
|
+
if (res.statusCode !== 200) { res.resume(); reject(new Error(url + ' -> ' + res.statusCode)); return; }
|
|
66
|
+
const chunks = [];
|
|
67
|
+
res.on('data', (c) => chunks.push(c));
|
|
68
|
+
res.on('end', () => { try { resolve(JSON.parse(Buffer.concat(chunks).toString('utf8'))); } catch (e) { reject(e); } });
|
|
69
|
+
});
|
|
70
|
+
req.on('timeout', () => { req.destroy(new Error('timeout')); });
|
|
71
|
+
req.on('error', reject);
|
|
72
|
+
req.end();
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function download(url, file) {
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
78
|
+
let attempt = 0;
|
|
79
|
+
function go() {
|
|
80
|
+
attempt++;
|
|
81
|
+
const req = https.request(new URL(url), { headers: { 'User-Agent': 'hmh-kaihongos-installer' }, timeout: 30000 }, (res) => {
|
|
82
|
+
if (res.statusCode !== 200) { res.resume(); reject(new Error(url + ' -> ' + res.statusCode)); return; }
|
|
83
|
+
const out = fs.createWriteStream(file);
|
|
84
|
+
res.pipe(out);
|
|
85
|
+
out.on('finish', () => out.close(resolve));
|
|
86
|
+
out.on('error', reject);
|
|
87
|
+
});
|
|
88
|
+
req.on('timeout', () => { req.destroy(); retry(); });
|
|
89
|
+
req.on('error', (e) => {
|
|
90
|
+
if (attempt < 10 && /EAI_AGAIN|ENOTFOUND|ECONNRESET|ETIMEDOUT/.test(e.code || '')) setTimeout(retry, 1500 * attempt);
|
|
91
|
+
else reject(e);
|
|
92
|
+
});
|
|
93
|
+
req.end();
|
|
94
|
+
}
|
|
95
|
+
function retry() { if (attempt < 10) go(); else reject(new Error('retries exhausted: ' + url)); }
|
|
96
|
+
go();
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function extract(tgz, dest) {
|
|
101
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
102
|
+
// busybox tar is present on KaihongOS / OpenHarmony boards and understands
|
|
103
|
+
// --strip-components. (GNU/toybox tar also fine if busybox is missing.)
|
|
104
|
+
const cmds = [
|
|
105
|
+
['busybox', ['tar', '-xzf', tgz, '-C', dest, '--strip-components=1']],
|
|
106
|
+
['tar', ['-xzf', tgz, '-C', dest, '--strip-components=1']],
|
|
107
|
+
];
|
|
108
|
+
for (const [bin, args] of cmds) {
|
|
109
|
+
const r = spawnSync(bin, args, { encoding: 'utf8' });
|
|
110
|
+
if (r.status === 0) return;
|
|
111
|
+
if (r.error && r.error.code !== 'ENOENT') log(' warn: ' + bin + ' tar: ' + (r.stderr || r.error.message).slice(0, 120));
|
|
112
|
+
}
|
|
113
|
+
throw new Error('no usable tar (tried busybox tar, tar)');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function resolveVersions() {
|
|
117
|
+
log('resolving latest @hmharness/cli from registry ...');
|
|
118
|
+
const meta = await httpsJSON(REG + '/@hmharness/cli');
|
|
119
|
+
const cliLatest = meta['dist-tags'].latest;
|
|
120
|
+
const deps = (meta.versions[cliLatest].dependencies) || {};
|
|
121
|
+
const pins = { cli: cliLatest };
|
|
122
|
+
for (const n of PACKAGES.slice(1)) {
|
|
123
|
+
const want = deps['@hmharness/' + n];
|
|
124
|
+
if (want && want !== '*') { pins[n] = want.replace(/[^0-9.]/g, ''); continue; }
|
|
125
|
+
const m = await httpsJSON(REG + '/@hmharness/' + n);
|
|
126
|
+
pins[n] = m['dist-tags'].latest;
|
|
127
|
+
}
|
|
128
|
+
return pins;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// ---------- node discovery --------------------------------------------------
|
|
132
|
+
function findNode() {
|
|
133
|
+
const cands = [process.execPath,
|
|
134
|
+
path.join(BOARD_HOME, 'dsh-pack/node/bin/node'),
|
|
135
|
+
path.join(BOARD_HOME, '.ohos/node/bin/node'),
|
|
136
|
+
'/usr/local/bin/node', '/usr/bin/node', '/system/bin/node'];
|
|
137
|
+
for (const c of cands) {
|
|
138
|
+
try {
|
|
139
|
+
fs.accessSync(c, fs.constants.X_OK);
|
|
140
|
+
const v = spawnSync(c, ['--version'], { encoding: 'utf8' });
|
|
141
|
+
if (v.status === 0) { const maj = parseInt((v.stdout || '').replace('v', ''), 10); if (maj >= 22) return c; }
|
|
142
|
+
} catch (_) { /* next */ }
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ---------- launcher --------------------------------------------------------
|
|
148
|
+
function launcherSource(nodeBin) {
|
|
149
|
+
return [
|
|
150
|
+
'#!/system/bin/sh',
|
|
151
|
+
'# hmh launcher — KaihongOS board install (generated by install-kaihongos.cjs)',
|
|
152
|
+
'# Board layout is fixed under ' + BOARD_HOME + ', independent of caller HOME/PATH.',
|
|
153
|
+
'HROOT="' + ROOT + '"',
|
|
154
|
+
'HNODE="' + nodeBin + '"',
|
|
155
|
+
'[ -x "$HNODE" ] || for c in node ' + BOARD_HOME + '/dsh-pack/node/bin/node ' + BOARD_HOME + '/.ohos/node/bin/node; do',
|
|
156
|
+
' [ -x "$c" ] && HNODE="$c" && break',
|
|
157
|
+
'done',
|
|
158
|
+
'# optional board-wide secrets file (edit or remove — keys normally live in config.json)',
|
|
159
|
+
'[ -f ' + BOARD_HOME + '/.config/apikeys.env ] && . ' + BOARD_HOME + '/.config/apikeys.env',
|
|
160
|
+
'# board shells run with HOME=/ — force a real writable HOME and a stable state dir',
|
|
161
|
+
'[ -z "${HMH_HOME:-}" ] && export HMH_HOME="' + HMH_HOME + '"',
|
|
162
|
+
'export HOME="' + BOARD_HOME + '"',
|
|
163
|
+
'export NODE_ALLOW_JIT="${NODE_ALLOW_JIT:-1}"',
|
|
164
|
+
'# drop --jitless inherited from sandbox profiles; board root shell can JIT',
|
|
165
|
+
'NODE_OPTIONS="$(echo "${NODE_OPTIONS:-}" | sed \'s|--jitless||g; s/ */ /g\')"',
|
|
166
|
+
'NODE_OPTIONS="$(echo "$NODE_OPTIONS" | sed \'s/^ *//;s/ *$//\')"',
|
|
167
|
+
'[ -n "$NODE_OPTIONS" ] && export NODE_OPTIONS',
|
|
168
|
+
'# optional DevEco-layout toolchain shims (hvigorw / ohpm)',
|
|
169
|
+
'[ -z "${HM_DEVECO_HOME:-}" ] && [ -d ' + BOARD_HOME + '/.local/hm-devtools ] && export HM_DEVECO_HOME="' + BOARD_HOME + '/.local/hm-devtools"',
|
|
170
|
+
'exec "$HNODE" "$HROOT/node_modules/@hmharness/cli/dist/main.js" "$@"',
|
|
171
|
+
'',
|
|
172
|
+
].join('\n');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function writeLauncher(nodeBin) {
|
|
176
|
+
const src = launcherSource(nodeBin);
|
|
177
|
+
const userBin = path.join(BOARD_HOME, '.local', 'bin');
|
|
178
|
+
fs.mkdirSync(userBin, { recursive: true });
|
|
179
|
+
fs.writeFileSync(path.join(userBin, 'hmh'), src);
|
|
180
|
+
fs.chmodSync(path.join(userBin, 'hmh'), 0o755);
|
|
181
|
+
log('launcher: ' + path.join(userBin, 'hmh'));
|
|
182
|
+
|
|
183
|
+
// System locations live on the read-only rootfs — remount rw, copy, restore ro.
|
|
184
|
+
// /system/bin matters most: isolated tmpfs-namespace terminals (ttyd web
|
|
185
|
+
// terminals, containers) see no /usr at all, but /bin -> /system/bin + /data.
|
|
186
|
+
for (const sysBin of ['/usr/local/bin', '/system/bin']) {
|
|
187
|
+
try { fs.mkdirSync(sysBin, { recursive: true }); } catch (_) { /* exists */ }
|
|
188
|
+
const target = path.join(sysBin, 'hmh');
|
|
189
|
+
const rw = spawnSync('mount', ['-o', 'remount,rw', '/'], { encoding: 'utf8' });
|
|
190
|
+
try {
|
|
191
|
+
fs.writeFileSync(target, src);
|
|
192
|
+
fs.chmodSync(target, 0o755);
|
|
193
|
+
log('launcher: ' + target + (rw.status === 0 ? ' (rootfs remounted rw then ro)' : ''));
|
|
194
|
+
} catch (e) {
|
|
195
|
+
log('warn: could not write ' + target + ': ' + e.message);
|
|
196
|
+
} finally {
|
|
197
|
+
if (rw.status === 0) spawnSync('mount', ['-o', 'remount,ro', '/'], { encoding: 'utf8' });
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// ---------- main ------------------------------------------------------------
|
|
203
|
+
(async () => {
|
|
204
|
+
log('board home: ' + BOARD_HOME);
|
|
205
|
+
const nodeBin = findNode();
|
|
206
|
+
if (!nodeBin) { console.error('FATAL: no Node >= 22 found (looked at PATH, dsh-pack, .ohos). hmh needs Node >= 22.'); process.exit(1); }
|
|
207
|
+
log('node: ' + nodeBin + ' (' + (spawnSync(nodeBin, ['--version'], { encoding: 'utf8' }).stdout || '').trim() + ')');
|
|
208
|
+
|
|
209
|
+
if (!BIN_ONLY) {
|
|
210
|
+
let pins;
|
|
211
|
+
try { pins = await resolveVersions(); }
|
|
212
|
+
catch (e) {
|
|
213
|
+
log('warn: registry unreachable (' + e.message.slice(0, 80) + ') — falling back to known-good pins');
|
|
214
|
+
pins = Object.assign({}, FALLBACK_PINS);
|
|
215
|
+
}
|
|
216
|
+
for (const n of PACKAGES) log(' @hmharness/' + n + '@' + pins[n]);
|
|
217
|
+
|
|
218
|
+
const STAGE = NM + '.new';
|
|
219
|
+
fs.rmSync(STAGE, { recursive: true, force: true });
|
|
220
|
+
fs.mkdirSync(path.join(STAGE, '@hmharness'), { recursive: true });
|
|
221
|
+
for (const name of PACKAGES) {
|
|
222
|
+
const ver = pins[name];
|
|
223
|
+
const tgz = path.join(ROOT, '.stage.tgz');
|
|
224
|
+
process.stdout.write('download ' + name + '@' + ver + ' ... ');
|
|
225
|
+
await download(REG + '/@hmharness/' + name + '/-/' + name + '-' + ver + '.tgz', tgz);
|
|
226
|
+
const dest = path.join(STAGE, '@hmharness', name);
|
|
227
|
+
extract(tgz, dest);
|
|
228
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(dest, 'package.json'), 'utf8'));
|
|
229
|
+
if (pkg.version !== ver) throw new Error(name + ': unpacked ' + pkg.version + ' != ' + ver);
|
|
230
|
+
log('ok');
|
|
231
|
+
}
|
|
232
|
+
fs.rmSync(path.join(ROOT, '.stage.tgz'), { force: true });
|
|
233
|
+
|
|
234
|
+
// syntax-check the staged CLI entrypoint before swapping anything
|
|
235
|
+
const main = path.join(STAGE, '@hmharness', 'cli', 'dist', 'main.js');
|
|
236
|
+
const chk = spawnSync(nodeBin, ['--check', main], { encoding: 'utf8' });
|
|
237
|
+
if (chk.status !== 0) throw new Error('staged main.js failed --check: ' + (chk.stderr || '').slice(0, 200));
|
|
238
|
+
log('staged CLI entrypoint OK');
|
|
239
|
+
|
|
240
|
+
const BAK = NM + '.bak';
|
|
241
|
+
fs.rmSync(BAK, { recursive: true, force: true });
|
|
242
|
+
if (fs.existsSync(NM)) fs.renameSync(NM, BAK);
|
|
243
|
+
fs.renameSync(STAGE, NM);
|
|
244
|
+
log('installed @hmharness/cli@' + pins.cli + ' (previous tree kept at ' + BAK + ')');
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
writeLauncher(nodeBin);
|
|
248
|
+
|
|
249
|
+
// first run: create the state skeleton + blank config (never overwrite)
|
|
250
|
+
if (!fs.existsSync(path.join(HMH_HOME, 'config.json'))) {
|
|
251
|
+
log('first run: creating config skeleton at ' + HMH_HOME);
|
|
252
|
+
const r = spawnSync(nodeBin, [path.join(NM, '@hmharness', 'cli', 'dist', 'main.js'), 'init'], {
|
|
253
|
+
encoding: 'utf8', env: Object.assign({}, process.env, { HMH_HOME, HOME: BOARD_HOME }),
|
|
254
|
+
});
|
|
255
|
+
log((r.stdout || r.stderr || '').trim().split('\n').slice(-3).join('\n'));
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
console.log('\nnext steps:');
|
|
259
|
+
console.log(' 1. put your provider keys in ' + path.join(HMH_HOME, 'config.json'));
|
|
260
|
+
console.log(' (presets for 38 vendors: docs/PROVIDERS.md)');
|
|
261
|
+
console.log(' 2. hmh check # verify toolchain');
|
|
262
|
+
console.log(' 3. hmh tui # or: hmh web start → http://127.0.0.1:7788');
|
|
263
|
+
console.log('pitfalls & details: docs/KAIHONGOS.md');
|
|
264
|
+
})().catch((e) => { console.error('INSTALL FAILED:', e.message); process.exit(1); });
|
package/dist/evolution-daemon.js
CHANGED
|
@@ -48,41 +48,41 @@ function daemonPid(home) {
|
|
|
48
48
|
* latent bug in the old runner). */
|
|
49
49
|
export function daemonRunnerSource(pidFile, entryAbs) {
|
|
50
50
|
const entryJson = JSON.stringify(entryAbs);
|
|
51
|
-
return `
|
|
52
|
-
const { execFile } = require('node:child_process');
|
|
53
|
-
const { writeFileSync, unlinkSync } = require('node:fs');
|
|
54
|
-
const { join } = require('node:path');
|
|
55
|
-
const home = process.env.HMH_HOME || join(require('node:os').homedir(), '.hmharness');
|
|
56
|
-
const hmhBin = process.execPath;
|
|
57
|
-
const hmhEntry = ${entryJson};
|
|
58
|
-
const HOURS = Number(process.env.HMH_EVOLVE_EVERY_HOURS || 6);
|
|
59
|
-
function stamp() { return new Date().toISOString(); }
|
|
60
|
-
function runHmh(args, timeoutMs) {
|
|
61
|
-
return new Promise((resolve) => {
|
|
62
|
-
execFile(hmhBin, [hmhEntry, ...args], { timeout: timeoutMs, windowsHide: true }, (err, stdout, stderr) => {
|
|
63
|
-
resolve({ err, out: String(stdout || '') + String(stderr || '') });
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
async function cycle() {
|
|
68
|
-
try {
|
|
69
|
-
const evo = await runHmh(['evolve'], 600000);
|
|
70
|
-
console.log(stamp(), 'evolve cycle done', evo.err ? ('err ' + String(evo.err).slice(0, 120)) : '');
|
|
71
|
-
} catch (e) { console.error(stamp(), 'evolve error:', String(e).slice(0, 200)); }
|
|
72
|
-
// finetune gate after every evolve cycle - the command itself decides
|
|
73
|
-
// (labels threshold, no running job, cooldown, kill-switch) so an
|
|
74
|
-
// unattended run is always safe and cheap when nothing is due
|
|
75
|
-
try {
|
|
76
|
-
const ft = await runHmh(['auto-finetune', '--submit'], 900000);
|
|
77
|
-
const interesting = ft.out.split('\\n').filter((l) => l.includes('\\u2713') || l.includes('\\u5fae\\u8c03') || l.includes('ERR')).slice(0, 3);
|
|
78
|
-
console.log(stamp(), 'finetune gate:', interesting.join(' | ') || 'not due');
|
|
79
|
-
} catch (e) { console.error(stamp(), 'finetune error:', String(e).slice(0, 200)); }
|
|
80
|
-
}
|
|
81
|
-
writeFileSync(join(home, '${pidFile}'), String(process.pid));
|
|
82
|
-
setTimeout(cycle, 30000);
|
|
83
|
-
setInterval(cycle, HOURS * 3600000);
|
|
84
|
-
process.on('SIGTERM', () => { try { unlinkSync(join(home, '${pidFile}')); } catch {} process.exit(0); });
|
|
85
|
-
process.on('SIGINT', () => { try { unlinkSync(join(home, '${pidFile}')); } catch {} process.exit(0); });
|
|
51
|
+
return `
|
|
52
|
+
const { execFile } = require('node:child_process');
|
|
53
|
+
const { writeFileSync, unlinkSync } = require('node:fs');
|
|
54
|
+
const { join } = require('node:path');
|
|
55
|
+
const home = process.env.HMH_HOME || join(require('node:os').homedir(), '.hmharness');
|
|
56
|
+
const hmhBin = process.execPath;
|
|
57
|
+
const hmhEntry = ${entryJson};
|
|
58
|
+
const HOURS = Number(process.env.HMH_EVOLVE_EVERY_HOURS || 6);
|
|
59
|
+
function stamp() { return new Date().toISOString(); }
|
|
60
|
+
function runHmh(args, timeoutMs) {
|
|
61
|
+
return new Promise((resolve) => {
|
|
62
|
+
execFile(hmhBin, [hmhEntry, ...args], { timeout: timeoutMs, windowsHide: true }, (err, stdout, stderr) => {
|
|
63
|
+
resolve({ err, out: String(stdout || '') + String(stderr || '') });
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async function cycle() {
|
|
68
|
+
try {
|
|
69
|
+
const evo = await runHmh(['evolve'], 600000);
|
|
70
|
+
console.log(stamp(), 'evolve cycle done', evo.err ? ('err ' + String(evo.err).slice(0, 120)) : '');
|
|
71
|
+
} catch (e) { console.error(stamp(), 'evolve error:', String(e).slice(0, 200)); }
|
|
72
|
+
// finetune gate after every evolve cycle - the command itself decides
|
|
73
|
+
// (labels threshold, no running job, cooldown, kill-switch) so an
|
|
74
|
+
// unattended run is always safe and cheap when nothing is due
|
|
75
|
+
try {
|
|
76
|
+
const ft = await runHmh(['auto-finetune', '--submit'], 900000);
|
|
77
|
+
const interesting = ft.out.split('\\n').filter((l) => l.includes('\\u2713') || l.includes('\\u5fae\\u8c03') || l.includes('ERR')).slice(0, 3);
|
|
78
|
+
console.log(stamp(), 'finetune gate:', interesting.join(' | ') || 'not due');
|
|
79
|
+
} catch (e) { console.error(stamp(), 'finetune error:', String(e).slice(0, 200)); }
|
|
80
|
+
}
|
|
81
|
+
writeFileSync(join(home, '${pidFile}'), String(process.pid));
|
|
82
|
+
setTimeout(cycle, 30000);
|
|
83
|
+
setInterval(cycle, HOURS * 3600000);
|
|
84
|
+
process.on('SIGTERM', () => { try { unlinkSync(join(home, '${pidFile}')); } catch {} process.exit(0); });
|
|
85
|
+
process.on('SIGINT', () => { try { unlinkSync(join(home, '${pidFile}')); } catch {} process.exit(0); });
|
|
86
86
|
`;
|
|
87
87
|
}
|
|
88
88
|
/**
|
package/dist/web-daemon.js
CHANGED
|
@@ -68,6 +68,33 @@ function portOwnerPid(port) {
|
|
|
68
68
|
catch { /* netstat unavailable - give up quietly */ }
|
|
69
69
|
return 0;
|
|
70
70
|
}
|
|
71
|
+
/** Is the pid a WEB daemon of ours (`main.js web --port=`)? Port eviction may
|
|
72
|
+
* ONLY target self-family processes: other hmh surfaces (extension serve,
|
|
73
|
+
* mcp-serve, dev-tree servers) legitimately occupy adjacent ports, and the
|
|
74
|
+
* old blind taskkill kept murdering them on every version-aware restart
|
|
75
|
+
* (the "并行活动又抢了端口" port war). */
|
|
76
|
+
function isSelfWebDaemon(pid) {
|
|
77
|
+
if (!pid || process.platform !== 'win32')
|
|
78
|
+
return process.platform !== 'win32';
|
|
79
|
+
try {
|
|
80
|
+
const out = execSync(`powershell -NoProfile -Command "(Get-CimInstance Win32_Process -Filter 'ProcessId=${pid}').CommandLine"`, { encoding: 'utf8', timeout: 8000 });
|
|
81
|
+
const cmd = out.trim();
|
|
82
|
+
return cmd.includes(' web ') || /main\.js(\.ts)?\s+web\b/.test(cmd) || /\bweb\b\s*--port=/.test(cmd);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** Describe a foreign occupier for the warning line (best effort). */
|
|
89
|
+
function foreignOwnerDesc(pid) {
|
|
90
|
+
try {
|
|
91
|
+
const out = execSync(`powershell -NoProfile -Command "(Get-CimInstance Win32_Process -Filter 'ProcessId=${pid}').CommandLine"`, { encoding: 'utf8', timeout: 8000 });
|
|
92
|
+
return out.trim().slice(0, 120);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return 'pid ' + pid;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
71
98
|
/** Wait (bounded) until nothing answers on the port — used after evicting a
|
|
72
99
|
* stale listener so the respawn does not die on EADDRINUSE. */
|
|
73
100
|
export async function waitPortFree(port, maxMs = 4000) {
|
|
@@ -97,14 +124,21 @@ export function stopWebDaemon(port = DEFAULT_WEB_PORT) {
|
|
|
97
124
|
unlinkSync(join(homeDir(), 'web.pid'));
|
|
98
125
|
}
|
|
99
126
|
catch { /* absent */ }
|
|
100
|
-
// stale pid file but the port is still held
|
|
127
|
+
// stale pid file but the port is still held: evict ONLY if the holder is
|
|
128
|
+
// one of OUR web daemons - a foreign hmh surface (extension serve,
|
|
129
|
+
// dev-tree server) owns its port legitimately and must not be murdered
|
|
101
130
|
const owner = portOwnerPid(port);
|
|
102
131
|
if (owner && owner !== pid) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
132
|
+
if (isSelfWebDaemon(owner)) {
|
|
133
|
+
try {
|
|
134
|
+
spawn('taskkill', ['/PID', String(owner), '/T', '/F'], { windowsHide: true });
|
|
135
|
+
killed = true;
|
|
136
|
+
}
|
|
137
|
+
catch { /* best effort */ }
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
console.error(`[web] port ${port} is held by a NON-web process - not evicting: ${foreignOwnerDesc(owner)}`);
|
|
106
141
|
}
|
|
107
|
-
catch { /* best effort */ }
|
|
108
142
|
}
|
|
109
143
|
return killed;
|
|
110
144
|
}
|
|
@@ -185,6 +219,14 @@ export async function ensureWebDaemon(port = DEFAULT_WEB_PORT, entry = process.a
|
|
|
185
219
|
// for the port to free so the respawn cannot die on EADDRINUSE
|
|
186
220
|
stopWebDaemon(port);
|
|
187
221
|
await waitPortFree(port);
|
|
222
|
+
// a foreign surface still holding the port (stop refused to murder it):
|
|
223
|
+
// do NOT crash-loop a doomed respawn - say so and stay down
|
|
224
|
+
const holder = portOwnerPid(port);
|
|
225
|
+
if (holder && !isSelfWebDaemon(holder)) {
|
|
226
|
+
console.error(`[web] port ${port} is held by another process - not evicting: ${foreignOwnerDesc(holder)}`);
|
|
227
|
+
console.error(`[web] stop it, or start the web UI elsewhere: hmh web --port=<port>`);
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
188
230
|
}
|
|
189
231
|
spawnWebDaemon(port, entry);
|
|
190
232
|
for (let i = 0; i < 12; i++) {
|
package/package.json
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@hmharness/cli",
|
|
3
|
-
"version": "0.23.
|
|
4
|
-
"description": "hmharness command line: one-shot tasks, an interactive REPL, a fullscreen TUI, the web frontend, and direct tool invocation.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/main.js",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./dist/main.d.ts",
|
|
10
|
-
"default": "./dist/main.js"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"types": "dist/main.d.ts",
|
|
14
|
-
"bin": {
|
|
15
|
-
"hmh": "dist/main.js"
|
|
16
|
-
},
|
|
17
|
-
"files": [
|
|
18
|
-
"dist",
|
|
19
|
-
"board",
|
|
20
|
-
"release-notes.json"
|
|
21
|
-
],
|
|
22
|
-
"engines": {
|
|
23
|
-
"node": ">=22"
|
|
24
|
-
},
|
|
25
|
-
"keywords": [
|
|
26
|
-
"harmonyos",
|
|
27
|
-
"openharmony",
|
|
28
|
-
"ohos",
|
|
29
|
-
"agent",
|
|
30
|
-
"ai",
|
|
31
|
-
"cli",
|
|
32
|
-
"coding-agent",
|
|
33
|
-
"arkts",
|
|
34
|
-
"self-evolving",
|
|
35
|
-
"mcp"
|
|
36
|
-
],
|
|
37
|
-
"repository": {
|
|
38
|
-
"type": "git",
|
|
39
|
-
"url": "git+https://github.com/swsgbl/hmharness.git"
|
|
40
|
-
},
|
|
41
|
-
"homepage": "https://swsgbl.github.io/hmharness/",
|
|
42
|
-
"bugs": "https://github.com/swsgbl/hmharness/issues",
|
|
43
|
-
"license": "MIT",
|
|
44
|
-
"scripts": {
|
|
45
|
-
"build": "tsc -p tsconfig.build.json"
|
|
46
|
-
},
|
|
47
|
-
"dependencies": {
|
|
48
|
-
"@hmharness/agent": "0.23.
|
|
49
|
-
"@hmharness/browser": "0.23.
|
|
50
|
-
"@hmharness/cognitive": "0.23.
|
|
51
|
-
"@hmharness/domain-harmony": "0.23.
|
|
52
|
-
"@hmharness/domain-ops": "0.23.
|
|
53
|
-
"@hmharness/environments": "0.23.
|
|
54
|
-
"@hmharness/evaluation": "0.23.
|
|
55
|
-
"@hmharness/evolution": "0.23.
|
|
56
|
-
"@hmharness/extension": "0.23.
|
|
57
|
-
"@hmharness/kernel": "0.23.
|
|
58
|
-
"@hmharness/observability": "0.23.
|
|
59
|
-
"@hmharness/sandbox": "0.23.
|
|
60
|
-
"@hmharness/web": "0.23.
|
|
61
|
-
"qrcode": "^1.5.4",
|
|
62
|
-
"@hmharness/lsp": "0.23.
|
|
63
|
-
}
|
|
64
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@hmharness/cli",
|
|
3
|
+
"version": "0.23.26",
|
|
4
|
+
"description": "hmharness command line: one-shot tasks, an interactive REPL, a fullscreen TUI, the web frontend, and direct tool invocation.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/main.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/main.d.ts",
|
|
10
|
+
"default": "./dist/main.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"types": "dist/main.d.ts",
|
|
14
|
+
"bin": {
|
|
15
|
+
"hmh": "dist/main.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"board",
|
|
20
|
+
"release-notes.json"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=22"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"harmonyos",
|
|
27
|
+
"openharmony",
|
|
28
|
+
"ohos",
|
|
29
|
+
"agent",
|
|
30
|
+
"ai",
|
|
31
|
+
"cli",
|
|
32
|
+
"coding-agent",
|
|
33
|
+
"arkts",
|
|
34
|
+
"self-evolving",
|
|
35
|
+
"mcp"
|
|
36
|
+
],
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/swsgbl/hmharness.git"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://swsgbl.github.io/hmharness/",
|
|
42
|
+
"bugs": "https://github.com/swsgbl/hmharness/issues",
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc -p tsconfig.build.json"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@hmharness/agent": "0.23.26",
|
|
49
|
+
"@hmharness/browser": "0.23.26",
|
|
50
|
+
"@hmharness/cognitive": "0.23.26",
|
|
51
|
+
"@hmharness/domain-harmony": "0.23.26",
|
|
52
|
+
"@hmharness/domain-ops": "0.23.26",
|
|
53
|
+
"@hmharness/environments": "0.23.26",
|
|
54
|
+
"@hmharness/evaluation": "0.23.26",
|
|
55
|
+
"@hmharness/evolution": "0.23.26",
|
|
56
|
+
"@hmharness/extension": "0.23.26",
|
|
57
|
+
"@hmharness/kernel": "0.23.26",
|
|
58
|
+
"@hmharness/observability": "0.23.26",
|
|
59
|
+
"@hmharness/sandbox": "0.23.26",
|
|
60
|
+
"@hmharness/web": "0.23.26",
|
|
61
|
+
"qrcode": "^1.5.4",
|
|
62
|
+
"@hmharness/lsp": "0.23.26"
|
|
63
|
+
}
|
|
64
|
+
}
|
package/release-notes.json
CHANGED
|
@@ -1,64 +1,69 @@
|
|
|
1
|
-
{
|
|
2
|
-
"notes": [
|
|
3
|
-
{
|
|
4
|
-
"v": "0.23.
|
|
5
|
-
"date": "2026-10-06",
|
|
6
|
-
"note": "
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"v": "0.23.
|
|
10
|
-
"date": "2026-10-
|
|
11
|
-
"note": "
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"v": "0.23.
|
|
15
|
-
"date": "2026-10-
|
|
16
|
-
"note": "
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"v": "0.23.
|
|
20
|
-
"date": "2026-10-04",
|
|
21
|
-
"note": "
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"v": "0.23.
|
|
25
|
-
"date": "2026-10-04",
|
|
26
|
-
"note": "
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"v": "0.23.
|
|
30
|
-
"date": "2026-10-04",
|
|
31
|
-
"note": "
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"v": "0.23.
|
|
35
|
-
"date": "2026-10-04",
|
|
36
|
-
"note": "
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"v": "0.23.
|
|
40
|
-
"date": "2026-10-04",
|
|
41
|
-
"note": "
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"v": "0.23.
|
|
45
|
-
"date": "2026-10-04",
|
|
46
|
-
"note": "
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
"v": "0.23.
|
|
50
|
-
"date": "2026-10-
|
|
51
|
-
"note": "
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"v": "0.23.
|
|
55
|
-
"date": "2026-10-03",
|
|
56
|
-
"note": "
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"v": "0.23.
|
|
60
|
-
"date": "2026-10-
|
|
61
|
-
"note": "
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
1
|
+
{
|
|
2
|
+
"notes": [
|
|
3
|
+
{
|
|
4
|
+
"v": "0.23.26",
|
|
5
|
+
"date": "2026-10-06",
|
|
6
|
+
"note": "会话独立运行(对标 dsh 3080):多会话真并行——每会话独立子进程/队列/审批/中断,输入区跟随当前会话;端口收复只驱逐自家族守护(extension serve 等不再被误杀);侧栏各会话显示运行状态点"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"v": "0.23.25",
|
|
10
|
+
"date": "2026-10-06",
|
|
11
|
+
"note": "浏览器扩展对话面板:侧栏直接和助手对话(你的 provider 当大脑,page_read/page_act 工具环当面执行留审计),桥守护 install 完即自动拉起;零配对装载即连;Code World Model 三传感器族生产接线(LSP 符号/诊断 + 浏览器观察 + 构建判定)"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"v": "0.23.24",
|
|
15
|
+
"date": "2026-10-05",
|
|
16
|
+
"note": "七浏览器真装验证:Chrome/Edge/Brave/Opera/夸克/Firefox/BrowserOS 两连跑全绿;Firefox 走 Marionette 临时装载 + 演示页同源配对;MV3 主机权限边界如实上报,只读命令可重放"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"v": "0.23.23",
|
|
20
|
+
"date": "2026-10-04",
|
|
21
|
+
"note": "更新体验:后台更新时 TUI 内轻提示(开始/完成),升级后首次启动显示一行更新简报——无弹窗但不再失联"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"v": "0.23.22",
|
|
25
|
+
"date": "2026-10-04",
|
|
26
|
+
"note": "审计研究基建池全量:COG-MEA 长任务循环、版本化评测任务集(数据集指纹+种子+留出)、沙箱红队加固、WM-2 观测因果挖掘、Code World Model"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"v": "0.23.21",
|
|
30
|
+
"date": "2026-10-04",
|
|
31
|
+
"note": "BrowserOS AI 浏览器包(第 15 包)+ ACP 服务器(BrowserOS 助手面板可直接驱动 hmh)+ flaky 根因修复"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"v": "0.23.20",
|
|
35
|
+
"date": "2026-10-04",
|
|
36
|
+
"note": "认知消融三臂阶梯仪器(ablate --task --ladder3,支持 --difficulty=hard)"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"v": "0.23.19",
|
|
40
|
+
"date": "2026-10-04",
|
|
41
|
+
"note": "能力 OS 首片:LSP 源信任 + sha256 钉扎(DevEco 本地 clangd 自动发现并钉扎,PATH 源一次性信任)"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"v": "0.23.18",
|
|
45
|
+
"date": "2026-10-04",
|
|
46
|
+
"note": "群体循环远程吸收:absorb --from=<url>(协议墙+大小上限+免内容校验)"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"v": "0.23.17",
|
|
50
|
+
"date": "2026-10-04",
|
|
51
|
+
"note": "12 周计划收官特性:DevEco 本地 LSP 服务器发现(官方 clangd 全链路)"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"v": "0.23.16",
|
|
55
|
+
"date": "2026-10-03",
|
|
56
|
+
"note": "发布链三防线(private 包/依赖覆盖预检/板级兜底钉随版);@hmharness/lsp 首发修复全新安装;KaihongOS 板级自动更新通道生效"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"v": "0.23.15",
|
|
60
|
+
"date": "2026-10-03",
|
|
61
|
+
"note": "热修:补上 0.23.14 缺失的 lsp 依赖发布;发布预检加入依赖覆盖与 private 检查"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"v": "0.23.14",
|
|
65
|
+
"date": "2026-10-02",
|
|
66
|
+
"note": "无垫片更新链(更新弹窗根因修复,node 直跑 npm-cli.js);KaihongOS 板端随包安装器;长会话队列断路器与崩溃断点召回"
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|