@hmharness/cli 0.18.14 → 0.19.0
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/main.js +39 -11
- package/dist/tui.js +46 -0
- package/package.json +13 -10
package/dist/main.js
CHANGED
|
@@ -909,6 +909,21 @@ flags:
|
|
|
909
909
|
await tui(yes, rest.includes('--no-web'));
|
|
910
910
|
return;
|
|
911
911
|
}
|
|
912
|
+
if (cmd === 'cognitive') {
|
|
913
|
+
// Cognitive OS (blueprint 2026-09): read-only status one-pager. The
|
|
914
|
+
// subsystems are libraries first — they come alive when the agent loop
|
|
915
|
+
// and evolution pipeline adopt them; this command shows what exists.
|
|
916
|
+
await initHome();
|
|
917
|
+
const sub = rest.find((a) => !a.startsWith('-'));
|
|
918
|
+
if (sub !== 'status') {
|
|
919
|
+
stdout.write('用法: hmh cognitive status — 认知子系统状态(记忆五层/轨迹库/进化审计/环境注册表)\n');
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
const { cognitiveStatus, formatCognitiveStatus } = await import('@hmharness/cognitive');
|
|
923
|
+
const status = await cognitiveStatus(homeDir());
|
|
924
|
+
stdout.write(formatCognitiveStatus(status) + '\n');
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
912
927
|
if (cmd === 'web') {
|
|
913
928
|
await initHome();
|
|
914
929
|
const port = Number(rest.find((a) => a.startsWith('--port='))?.slice(7) ?? 7788);
|
|
@@ -929,29 +944,42 @@ flags:
|
|
|
929
944
|
const { patchConfig } = await import('@hmharness/kernel');
|
|
930
945
|
await patchConfig({ web: { exposure, token: webToken } });
|
|
931
946
|
}
|
|
932
|
-
if ((exposure === 'lan' || exposure === 'wan') && !webToken) {
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
947
|
+
if ((exposure === 'lan' || exposure === 'wan') && !webToken && !rest.includes('--token-gen')) {
|
|
948
|
+
// Pairing (QR one-time token) no longer needs a long-term key; the
|
|
949
|
+
// cfg token is just an extra always-valid link. Hint, don't block.
|
|
950
|
+
stdout.write(DIM('(提示:手机用网页里的 📱 二维码配对即可;如需长期固定链接可加 --token-gen)\n'));
|
|
936
951
|
}
|
|
937
952
|
if ((exposure === 'lan' || exposure === 'wan') && tokenArg) {
|
|
938
953
|
const { patchConfig } = await import('@hmharness/kernel');
|
|
939
954
|
await patchConfig({ web: { exposure, token: webToken } });
|
|
940
955
|
}
|
|
941
|
-
if (exposure !== 'loopback'
|
|
942
|
-
// print the ready
|
|
956
|
+
if (exposure !== 'loopback') {
|
|
957
|
+
// print the phone-ready access info once; the LAN IP shown must be the
|
|
958
|
+
// one a phone on the same WiFi can route to (virtual adapters like
|
|
959
|
+
// Tailscale/VMware excluded — see server.ts preferredLanAddress).
|
|
943
960
|
const osMod = await import('node:os');
|
|
944
|
-
const
|
|
961
|
+
const VIRTUAL = /vmware|virtual|hyper-?v|vethernet|wsl|tailscale|loopback|bluetooth|vbox|docker|tap-|pseudo/i;
|
|
962
|
+
const isRfc1918 = (a) => /^10\./.test(a) || /^192\.168\./.test(a) || /^172\.(1[6-9]|2\d|3[01])\./.test(a);
|
|
945
963
|
let lanIp = '';
|
|
946
|
-
|
|
964
|
+
let virtualFallback = '';
|
|
965
|
+
for (const [name, list] of Object.entries(osMod.networkInterfaces())) {
|
|
947
966
|
for (const n of list ?? []) {
|
|
948
|
-
if (n.family
|
|
967
|
+
if (n.family !== 'IPv4' || n.internal || !isRfc1918(n.address))
|
|
968
|
+
continue;
|
|
969
|
+
if (!VIRTUAL.test(name)) {
|
|
949
970
|
lanIp = lanIp || n.address;
|
|
950
971
|
}
|
|
972
|
+
else {
|
|
973
|
+
virtualFallback = virtualFallback || n.address;
|
|
974
|
+
}
|
|
951
975
|
}
|
|
952
976
|
}
|
|
953
|
-
|
|
954
|
-
stdout.write(YELLOW(
|
|
977
|
+
lanIp = lanIp || virtualFallback;
|
|
978
|
+
stdout.write(YELLOW('手机连接:打开 http://127.0.0.1:' + port + ' 点 📱 扫二维码(WiFi 直连免密码;互联网模式任何网络可用)\n'));
|
|
979
|
+
if (lanIp)
|
|
980
|
+
stdout.write(YELLOW(`WiFi 地址:http://${lanIp}:${port}(手机与电脑同一 WiFi)\n`));
|
|
981
|
+
if (exposure === 'wan')
|
|
982
|
+
stdout.write(YELLOW('互联网模式:启动后自动建立免费隧道(trycloudflare.com),无需公网 IP/端口转发\n'));
|
|
955
983
|
}
|
|
956
984
|
const t = await uiStrings();
|
|
957
985
|
const sub = rest.find((a) => !a.startsWith('-'));
|
package/dist/tui.js
CHANGED
|
@@ -120,6 +120,7 @@ export const COMMANDS = [
|
|
|
120
120
|
{ name: '/keymap', key: 'cmdKeymap' },
|
|
121
121
|
{ name: '/review', key: 'cmdReview' },
|
|
122
122
|
{ name: '/web', key: 'cmdWeb' },
|
|
123
|
+
{ name: '/remote', key: 'cmdRemote' },
|
|
123
124
|
{ name: '/exit', key: 'cmdExit' },
|
|
124
125
|
];
|
|
125
126
|
/** Commands whose name starts with the input (input must start with '/'). */
|
|
@@ -2441,6 +2442,51 @@ export async function tui(yes, noWeb = false, opts = {}) {
|
|
|
2441
2442
|
rt.addText(up ? t.tuiWebLinked(DEFAULT_WEB_PORT) : t.tuiWebHint, 'dim');
|
|
2442
2443
|
return;
|
|
2443
2444
|
}
|
|
2445
|
+
if (line === '/remote' || line === '/remote lan' || line === '/remote wan') {
|
|
2446
|
+
// 2026-09-28 DSH Desktop pattern: /remote shows a QR of a ONE-TIME
|
|
2447
|
+
// pairing link fetched from the running web server (/api/pair-info).
|
|
2448
|
+
// WiFi scan = connected (no password); internet mode goes through a
|
|
2449
|
+
// free tunnel and asks the phone for the 6-digit PIN shown here.
|
|
2450
|
+
rt.setBusy(true, '/remote');
|
|
2451
|
+
try {
|
|
2452
|
+
const mode = line === '/remote wan' ? 'wan' : 'lan';
|
|
2453
|
+
const { patchConfig } = await import('@hmharness/kernel');
|
|
2454
|
+
let webCfg = cfg.web ?? {};
|
|
2455
|
+
if (webCfg.exposure !== mode) {
|
|
2456
|
+
await patchConfig({ web: { exposure: mode, token: webCfg.token ?? '' } });
|
|
2457
|
+
}
|
|
2458
|
+
// ensure daemon is up on the exposure
|
|
2459
|
+
await ensureWebDaemon(DEFAULT_WEB_PORT);
|
|
2460
|
+
// ask the SERVER for the live pairing state (token rotates there)
|
|
2461
|
+
const info = await fetch(`http://127.0.0.1:${DEFAULT_WEB_PORT}/api/pair-info`).then((r) => r.json());
|
|
2462
|
+
const url = (mode === 'wan' ? info.tunnelPairingUrl : info.lanPairingUrl) || info.pairingUrl || '';
|
|
2463
|
+
if (!url)
|
|
2464
|
+
throw new Error('no pairing URL (is the web server on --exposure=lan?)');
|
|
2465
|
+
const QR = (await import('qrcode')).default;
|
|
2466
|
+
const art = await QR.toString(url, { type: 'terminal', small: true, margin: 1 });
|
|
2467
|
+
rt.addText('┌─────────────────────────────────┐', 'plain');
|
|
2468
|
+
rt.addText('│ 📱 连接手机(' + (mode === 'lan' ? 'WiFi 直连' : '互联网隧道') + ') │', 'plain');
|
|
2469
|
+
rt.addText('├─────────────────────────────────┤', 'plain');
|
|
2470
|
+
for (const l of art.split('\n'))
|
|
2471
|
+
rt.addText('│' + l.replace(/\x1b\[[0-9;]*m/g, '') + '│', 'plain');
|
|
2472
|
+
rt.addText('├─────────────────────────────────┤', 'plain');
|
|
2473
|
+
if (mode === 'wan') {
|
|
2474
|
+
rt.addText('│ 配对密码(6位): ' + (info.pin ?? '(服务器窗口查看)'), 'plain');
|
|
2475
|
+
}
|
|
2476
|
+
rt.addText('│ 链接: ' + url, 'plain');
|
|
2477
|
+
rt.addText('│ (二维码 5 分钟内有效, 过期自动刷新)', 'plain');
|
|
2478
|
+
rt.addText('└─────────────────────────────────┘', 'plain');
|
|
2479
|
+
rt.addText(DIM(mode === 'lan'
|
|
2480
|
+
? '手机与电脑连同一 WiFi,扫码即连(无需密码)。'
|
|
2481
|
+
: '任何网络可连:扫码后在手机输入上面的 6 位密码。网页里可切换线路。'), 'dim');
|
|
2482
|
+
}
|
|
2483
|
+
catch (err) {
|
|
2484
|
+
rt.addText(String(err), 'err');
|
|
2485
|
+
rt.addText(DIM('/remote 失败 - 先运行: hmh web start --exposure=lan'), 'dim');
|
|
2486
|
+
}
|
|
2487
|
+
rt.setBusy(false);
|
|
2488
|
+
return;
|
|
2489
|
+
}
|
|
2444
2490
|
if (line === '/resume' || line.startsWith('/resume ')) {
|
|
2445
2491
|
const arg = line.slice(8).trim();
|
|
2446
2492
|
// bare /resume opens the Codex-style full-frame picker (typeahead,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "hmharness command line: one-shot tasks, an interactive REPL, a fullscreen TUI, the web frontend, and direct tool invocation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -43,14 +43,17 @@
|
|
|
43
43
|
"build": "tsc -p tsconfig.build.json"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@hmharness/
|
|
47
|
-
"@hmharness/
|
|
48
|
-
"@hmharness/
|
|
49
|
-
"@hmharness/domain-
|
|
50
|
-
"@hmharness/
|
|
51
|
-
"@hmharness/
|
|
52
|
-
"@hmharness/
|
|
53
|
-
"@hmharness/
|
|
54
|
-
"@hmharness/
|
|
46
|
+
"@hmharness/agent": "0.19.0",
|
|
47
|
+
"@hmharness/cognitive": "0.19.0",
|
|
48
|
+
"@hmharness/domain-harmony": "0.19.0",
|
|
49
|
+
"@hmharness/domain-ops": "0.19.0",
|
|
50
|
+
"@hmharness/environments": "0.19.0",
|
|
51
|
+
"@hmharness/evaluation": "0.19.0",
|
|
52
|
+
"@hmharness/evolution": "0.19.0",
|
|
53
|
+
"@hmharness/kernel": "0.19.0",
|
|
54
|
+
"@hmharness/observability": "0.19.0",
|
|
55
|
+
"@hmharness/sandbox": "0.19.0",
|
|
56
|
+
"@hmharness/web": "0.19.0",
|
|
57
|
+
"qrcode": "^1.5.4"
|
|
55
58
|
}
|
|
56
59
|
}
|