@hmharness/cli 0.23.45 → 0.23.46

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.
@@ -0,0 +1,61 @@
1
+ 'use strict';
2
+ // board-defaults.cjs — config defaults for BOARD deployments.
3
+ //
4
+ // 2026-10-29 device incident: a restricted-network board inherited the
5
+ // internet tunnel's all-night retry storm because `web.tunnel` was simply
6
+ // ABSENT from its config (the server treats absent as "maybe on"). Board
7
+ // installs are overwhelmingly intranet — an absent web.tunnel is therefore
8
+ // written as `false` at install time. An EXPLICIT value (true or false) is
9
+ // the user's decision and is NEVER overwritten; the operation is idempotent.
10
+ //
11
+ // Pure functions only, zero deps. Shared by the twin installers
12
+ // (scripts/install-kaihongos.cjs and packages/cli/board/install-kaihongos.cjs);
13
+ // unit-tested from scripts/__tests__/board-defaults.test.cjs.
14
+
15
+ /** Pure: return the config with board defaults filled in WHERE (and only
16
+ * where) the key is absent. Returns the SAME object when nothing changes
17
+ * (explicit value), a NEW object otherwise — the input is never mutated. */
18
+ function withBoardDefaults(cfg) {
19
+ if (typeof cfg !== 'object' || cfg === null) return cfg;
20
+ const web = cfg.web;
21
+ if (typeof web === 'object' && web !== null && Object.prototype.hasOwnProperty.call(web, 'tunnel')) {
22
+ return cfg; // explicit true/false — the user's decision, never overwrite
23
+ }
24
+ const kept = typeof web === 'object' && web !== null ? web : {};
25
+ return Object.assign({}, cfg, { web: Object.assign({}, kept, { tunnel: false }) });
26
+ }
27
+
28
+ /** Apply withBoardDefaults() to the config file at `configPath`. Returns:
29
+ * - 'written' default injected (web.tunnel was absent)
30
+ * - 'explicit' web.tunnel already had a user value — kept as-is
31
+ * - 'missing' no config file yet — nothing to do (hmh init creates it)
32
+ * - 'corrupt' unparseable JSON — NEVER touched (a destroyed config is
33
+ * worse than a missing default)
34
+ * - 'write-error' the injection could not be persisted (read-only fs etc.) */
35
+ function ensureBoardDefaults(configPath) {
36
+ const fs = require('fs');
37
+ let raw;
38
+ try {
39
+ raw = fs.readFileSync(configPath, 'utf8');
40
+ } catch (_) {
41
+ return 'missing';
42
+ }
43
+ let cfg;
44
+ try {
45
+ cfg = JSON.parse(raw);
46
+ } catch (_) {
47
+ return 'corrupt';
48
+ }
49
+ if (typeof cfg !== 'object' || cfg === null) return 'corrupt';
50
+ const next = withBoardDefaults(cfg);
51
+ if (next === cfg) return 'explicit';
52
+ try {
53
+ // same format the kernel's patchConfig() writes — no gratuitous churn
54
+ fs.writeFileSync(configPath, JSON.stringify(next, null, 2) + '\n');
55
+ return 'written';
56
+ } catch (_) {
57
+ return 'write-error';
58
+ }
59
+ }
60
+
61
+ module.exports = { withBoardDefaults, ensureBoardDefaults };
@@ -23,6 +23,9 @@
23
23
  // the package set below is a FLOOR, extendHeal covers the rest — see
24
24
  // "why the heal layer exists" above installHealLayer()
25
25
  // 6. first run: `hmh init` if config.json is missing
26
+ // 7. config default: an ABSENT web.tunnel is written as false — boards are
27
+ // overwhelmingly intranet and must not inherit the internet tunnel's
28
+ // retry storm (2026-10-29 device incident); explicit values never touched
26
29
  //
27
30
  // Usage:
28
31
  // node install-kaihongos.cjs # install/upgrade to latest
@@ -34,6 +37,14 @@ const fs = require('fs');
34
37
  const path = require('path');
35
38
  const https = require('https');
36
39
  const { spawnSync } = require('child_process');
40
+ // board config defaults live in a shared module that ships in
41
+ // @hmharness/cli's board/ directory — resolve it whether this installer
42
+ // runs from scripts/ (repo) or packages/cli/board/ (npm package).
43
+ const { ensureBoardDefaults } = require(
44
+ fs.existsSync(path.join(__dirname, 'board-defaults.cjs'))
45
+ ? path.join(__dirname, 'board-defaults.cjs')
46
+ : path.join(__dirname, '..', 'packages', 'cli', 'board', 'board-defaults.cjs'),
47
+ );
37
48
 
38
49
  // ---------- board constants -------------------------------------------------
39
50
  let BOARD_HOME = '/data/local/home'; // KaihongOS board home
@@ -67,11 +78,11 @@ let PACKAGES = ['cli', 'web', 'agent', 'kernel', 'sandbox', 'evolution',
67
78
  // the offline path tried <name>-undefined.tgz → 404 → INSTALL FAILED (directly
68
79
  // contradicting the promise above; evidence: cli 0.23.42 declares 14 deps).
69
80
  const FALLBACK_PINS = {
70
- cli: '0.23.45', web: '0.23.45', agent: '0.23.45', kernel: '0.23.45',
71
- sandbox: '0.23.45', evolution: '0.23.45', 'domain-ops': '0.23.45',
72
- evaluation: '0.23.45', observability: '0.23.45', 'domain-harmony': '0.23.45',
73
- cognitive: '0.23.45', environments: '0.23.45', lsp: '0.23.45',
74
- browser: '0.23.45', extension: '0.23.45',
81
+ cli: '0.23.46', web: '0.23.46', agent: '0.23.46', kernel: '0.23.46',
82
+ sandbox: '0.23.46', evolution: '0.23.46', 'domain-ops': '0.23.46',
83
+ evaluation: '0.23.46', observability: '0.23.46', 'domain-harmony': '0.23.46',
84
+ cognitive: '0.23.46', environments: '0.23.46', lsp: '0.23.46',
85
+ browser: '0.23.46', extension: '0.23.46',
75
86
  };
76
87
 
77
88
  // ---------- helpers ---------------------------------------------------------
@@ -354,6 +365,14 @@ function installHealLayer() {
354
365
  log((r.stdout || r.stderr || '').trim().split('\n').slice(-3).join('\n'));
355
366
  }
356
367
 
368
+ // board default (2026-10-29 device incident): an ABSENT web.tunnel must
369
+ // not inherit the internet tunnel's all-night retry storm. Injects
370
+ // web.tunnel=false only where the key is missing; explicit user values
371
+ // are never overwritten. Idempotent — safe to run on every install.
372
+ const dflt = ensureBoardDefaults(path.join(HMH_HOME, 'config.json'));
373
+ if (dflt === 'written') log('config: web.tunnel=false 默认已写入(板级多为内网部署;需互联网隧道请显式设为 true)');
374
+ else if (dflt === 'corrupt' || dflt === 'write-error') log('warn: config.json ' + dflt + ' — web.tunnel 默认值未注入');
375
+
357
376
  console.log('\nnext steps:');
358
377
  console.log(' 1. put your provider keys in ' + path.join(HMH_HOME, 'config.json'));
359
378
  console.log(' (presets for 38 vendors: docs/PROVIDERS.md)');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/cli",
3
- "version": "0.23.45",
3
+ "version": "0.23.46",
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",
@@ -45,20 +45,20 @@
45
45
  "build": "tsc -p tsconfig.build.json"
46
46
  },
47
47
  "dependencies": {
48
- "@hmharness/agent": "0.23.45",
49
- "@hmharness/browser": "0.23.45",
50
- "@hmharness/cognitive": "0.23.45",
51
- "@hmharness/domain-harmony": "0.23.45",
52
- "@hmharness/domain-ops": "0.23.45",
53
- "@hmharness/environments": "0.23.45",
54
- "@hmharness/evaluation": "0.23.45",
55
- "@hmharness/evolution": "0.23.45",
56
- "@hmharness/extension": "0.23.45",
57
- "@hmharness/kernel": "0.23.45",
58
- "@hmharness/observability": "0.23.45",
59
- "@hmharness/sandbox": "0.23.45",
60
- "@hmharness/web": "0.23.45",
48
+ "@hmharness/agent": "0.23.46",
49
+ "@hmharness/browser": "0.23.46",
50
+ "@hmharness/cognitive": "0.23.46",
51
+ "@hmharness/domain-harmony": "0.23.46",
52
+ "@hmharness/domain-ops": "0.23.46",
53
+ "@hmharness/environments": "0.23.46",
54
+ "@hmharness/evaluation": "0.23.46",
55
+ "@hmharness/evolution": "0.23.46",
56
+ "@hmharness/extension": "0.23.46",
57
+ "@hmharness/kernel": "0.23.46",
58
+ "@hmharness/observability": "0.23.46",
59
+ "@hmharness/sandbox": "0.23.46",
60
+ "@hmharness/web": "0.23.46",
61
61
  "qrcode": "^1.5.4",
62
- "@hmharness/lsp": "0.23.45"
62
+ "@hmharness/lsp": "0.23.46"
63
63
  }
64
64
  }
@@ -1,5 +1,10 @@
1
1
  {
2
2
  "notes": [
3
+ {
4
+ "v": "0.23.46",
5
+ "date": "2026-10-29",
6
+ "note": "隧道重试风暴根治(指数退避+放弃)+板级默认 web.tunnel=false;1042 测试"
7
+ },
3
8
  {
4
9
  "v": "0.23.45",
5
10
  "date": "2026-10-29",