@hmharness/cli 0.18.14 → 0.18.15
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 +24 -11
- package/dist/tui.js +46 -0
- package/package.json +11 -10
package/dist/main.js
CHANGED
|
@@ -929,29 +929,42 @@ flags:
|
|
|
929
929
|
const { patchConfig } = await import('@hmharness/kernel');
|
|
930
930
|
await patchConfig({ web: { exposure, token: webToken } });
|
|
931
931
|
}
|
|
932
|
-
if ((exposure === 'lan' || exposure === 'wan') && !webToken) {
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
932
|
+
if ((exposure === 'lan' || exposure === 'wan') && !webToken && !rest.includes('--token-gen')) {
|
|
933
|
+
// Pairing (QR one-time token) no longer needs a long-term key; the
|
|
934
|
+
// cfg token is just an extra always-valid link. Hint, don't block.
|
|
935
|
+
stdout.write(DIM('(提示:手机用网页里的 📱 二维码配对即可;如需长期固定链接可加 --token-gen)\n'));
|
|
936
936
|
}
|
|
937
937
|
if ((exposure === 'lan' || exposure === 'wan') && tokenArg) {
|
|
938
938
|
const { patchConfig } = await import('@hmharness/kernel');
|
|
939
939
|
await patchConfig({ web: { exposure, token: webToken } });
|
|
940
940
|
}
|
|
941
|
-
if (exposure !== 'loopback'
|
|
942
|
-
// print the ready
|
|
941
|
+
if (exposure !== 'loopback') {
|
|
942
|
+
// print the phone-ready access info once; the LAN IP shown must be the
|
|
943
|
+
// one a phone on the same WiFi can route to (virtual adapters like
|
|
944
|
+
// Tailscale/VMware excluded — see server.ts preferredLanAddress).
|
|
943
945
|
const osMod = await import('node:os');
|
|
944
|
-
const
|
|
946
|
+
const VIRTUAL = /vmware|virtual|hyper-?v|vethernet|wsl|tailscale|loopback|bluetooth|vbox|docker|tap-|pseudo/i;
|
|
947
|
+
const isRfc1918 = (a) => /^10\./.test(a) || /^192\.168\./.test(a) || /^172\.(1[6-9]|2\d|3[01])\./.test(a);
|
|
945
948
|
let lanIp = '';
|
|
946
|
-
|
|
949
|
+
let virtualFallback = '';
|
|
950
|
+
for (const [name, list] of Object.entries(osMod.networkInterfaces())) {
|
|
947
951
|
for (const n of list ?? []) {
|
|
948
|
-
if (n.family
|
|
952
|
+
if (n.family !== 'IPv4' || n.internal || !isRfc1918(n.address))
|
|
953
|
+
continue;
|
|
954
|
+
if (!VIRTUAL.test(name)) {
|
|
949
955
|
lanIp = lanIp || n.address;
|
|
950
956
|
}
|
|
957
|
+
else {
|
|
958
|
+
virtualFallback = virtualFallback || n.address;
|
|
959
|
+
}
|
|
951
960
|
}
|
|
952
961
|
}
|
|
953
|
-
|
|
954
|
-
stdout.write(YELLOW(
|
|
962
|
+
lanIp = lanIp || virtualFallback;
|
|
963
|
+
stdout.write(YELLOW('手机连接:打开 http://127.0.0.1:' + port + ' 点 📱 扫二维码(WiFi 直连免密码;互联网模式任何网络可用)\n'));
|
|
964
|
+
if (lanIp)
|
|
965
|
+
stdout.write(YELLOW(`WiFi 地址:http://${lanIp}:${port}(手机与电脑同一 WiFi)\n`));
|
|
966
|
+
if (exposure === 'wan')
|
|
967
|
+
stdout.write(YELLOW('互联网模式:启动后自动建立免费隧道(trycloudflare.com),无需公网 IP/端口转发\n'));
|
|
955
968
|
}
|
|
956
969
|
const t = await uiStrings();
|
|
957
970
|
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.18.
|
|
3
|
+
"version": "0.18.15",
|
|
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,15 @@
|
|
|
43
43
|
"build": "tsc -p tsconfig.build.json"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@hmharness/
|
|
47
|
-
"@hmharness/
|
|
48
|
-
"@hmharness/
|
|
49
|
-
"@hmharness/
|
|
50
|
-
"@hmharness/
|
|
51
|
-
"@hmharness/
|
|
52
|
-
"@hmharness/
|
|
53
|
-
"@hmharness/
|
|
54
|
-
"@hmharness/
|
|
46
|
+
"@hmharness/agent": "0.18.15",
|
|
47
|
+
"@hmharness/domain-harmony": "0.18.15",
|
|
48
|
+
"@hmharness/domain-ops": "0.18.15",
|
|
49
|
+
"@hmharness/evaluation": "0.18.15",
|
|
50
|
+
"@hmharness/evolution": "0.18.15",
|
|
51
|
+
"@hmharness/kernel": "0.18.15",
|
|
52
|
+
"@hmharness/observability": "0.18.15",
|
|
53
|
+
"@hmharness/sandbox": "0.18.15",
|
|
54
|
+
"@hmharness/web": "0.18.15",
|
|
55
|
+
"qrcode": "^1.5.4"
|
|
55
56
|
}
|
|
56
57
|
}
|