@okclaw-build/cli 1.0.0-beta.4 → 1.0.0-beta.40

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.
Files changed (65) hide show
  1. package/dist/commands/check.js +22 -6
  2. package/dist/commands/check.js.map +1 -1
  3. package/dist/commands/edit.d.ts +2 -7
  4. package/dist/commands/edit.js +28 -15
  5. package/dist/commands/edit.js.map +1 -1
  6. package/dist/commands/feed.d.ts +0 -9
  7. package/dist/commands/feed.js +80 -103
  8. package/dist/commands/feed.js.map +1 -1
  9. package/dist/commands/install.js +57 -9
  10. package/dist/commands/install.js.map +1 -1
  11. package/dist/commands/service.js +65 -12
  12. package/dist/commands/service.js.map +1 -1
  13. package/dist/commands/show.d.ts +13 -0
  14. package/dist/commands/show.js +70 -0
  15. package/dist/commands/show.js.map +1 -0
  16. package/dist/commands/skill.d.ts +1 -0
  17. package/dist/commands/skill.js +114 -0
  18. package/dist/commands/skill.js.map +1 -0
  19. package/dist/commands/uninstall.d.ts +1 -0
  20. package/dist/commands/uninstall.js +46 -0
  21. package/dist/commands/uninstall.js.map +1 -0
  22. package/dist/index.js +88 -5
  23. package/dist/index.js.map +1 -1
  24. package/dist/installers/base.d.ts +1 -0
  25. package/dist/installers/channel.d.ts +16 -1
  26. package/dist/installers/channel.js +139 -8
  27. package/dist/installers/channel.js.map +1 -1
  28. package/dist/installers/openclaw.d.ts +15 -0
  29. package/dist/installers/openclaw.js +171 -8
  30. package/dist/installers/openclaw.js.map +1 -1
  31. package/dist/installers/openviking-purge.d.ts +52 -0
  32. package/dist/installers/openviking-purge.js +380 -0
  33. package/dist/installers/openviking-purge.js.map +1 -0
  34. package/dist/installers/openviking.js +1 -2
  35. package/dist/installers/openviking.js.map +1 -1
  36. package/dist/installers/skill.d.ts +1 -0
  37. package/dist/installers/skill.js +11 -1
  38. package/dist/installers/skill.js.map +1 -1
  39. package/dist/output/mode.d.ts +11 -0
  40. package/dist/output/mode.js +27 -0
  41. package/dist/output/mode.js.map +1 -0
  42. package/dist/output/ndjson.d.ts +57 -0
  43. package/dist/output/ndjson.js +136 -0
  44. package/dist/output/ndjson.js.map +1 -0
  45. package/dist/utils/constants.d.ts +0 -2
  46. package/dist/utils/constants.js +1 -4
  47. package/dist/utils/constants.js.map +1 -1
  48. package/dist/utils/deps.d.ts +0 -5
  49. package/dist/utils/deps.js +1 -88
  50. package/dist/utils/deps.js.map +1 -1
  51. package/dist/utils/logger.d.ts +10 -0
  52. package/dist/utils/logger.js +31 -4
  53. package/dist/utils/logger.js.map +1 -1
  54. package/dist/utils/mirror.js +14 -0
  55. package/dist/utils/mirror.js.map +1 -1
  56. package/dist/utils/openclaw-config-cli.d.ts +19 -0
  57. package/dist/utils/openclaw-config-cli.js +81 -0
  58. package/dist/utils/openclaw-config-cli.js.map +1 -0
  59. package/dist/utils/openclaw-daemon.d.ts +23 -0
  60. package/dist/utils/openclaw-daemon.js +38 -0
  61. package/dist/utils/openclaw-daemon.js.map +1 -0
  62. package/dist/utils/shell.d.ts +12 -2
  63. package/dist/utils/shell.js +66 -3
  64. package/dist/utils/shell.js.map +1 -1
  65. package/package.json +3 -2
@@ -0,0 +1,136 @@
1
+ import { appendFileSync } from 'node:fs';
2
+ import { getNdjsonPath, getOpId, isNdjson } from './mode.js';
3
+ const defaultWriter = (line) => {
4
+ const path = getNdjsonPath();
5
+ if (path) {
6
+ appendFileSync(path, line);
7
+ }
8
+ else {
9
+ process.stdout.write(line);
10
+ }
11
+ };
12
+ /**
13
+ * 单 op 的事件发射器。在 text 模式下所有方法都是 no-op;ndjson 模式才写出。
14
+ *
15
+ * 约定:
16
+ * - seq 单调递增,同一 emitter 实例内唯一
17
+ * - end() 只能发一次,重复调用忽略
18
+ * - 非正常退出(exception/signal)由 registerExitHandlers 兜底补 end
19
+ */
20
+ export class NdjsonEmitter {
21
+ seq = 0;
22
+ op;
23
+ writer;
24
+ ended = false;
25
+ constructor(op, writer = defaultWriter) {
26
+ this.op = op;
27
+ this.writer = writer;
28
+ }
29
+ start(msg = '', fields) {
30
+ this.emit('start', 'info', { msg, fields });
31
+ }
32
+ stepStart(step, msg, fields) {
33
+ this.emit('step_start', 'info', { step, msg, fields });
34
+ }
35
+ progress(step, progress, msg, fields) {
36
+ const clamped = Number.isFinite(progress) ? Math.max(0, Math.min(1, progress)) : undefined;
37
+ this.emit('progress', 'info', { step, progress: clamped, msg, fields });
38
+ }
39
+ stepDone(step, msg, fields) {
40
+ this.emit('step_done', 'info', { step, msg, fields });
41
+ }
42
+ /**
43
+ * 通用日志事件。走独立 phase="log"(bug#7 修:之前借用 phase="progress" 会
44
+ * 污染"取 max(progress) 作为当前进度"的聚合逻辑)。用 level 区分严重度。
45
+ */
46
+ log(level, msg, fields) {
47
+ this.emit('log', level, { msg, fields });
48
+ }
49
+ /**
50
+ * 终态事件;必发。ok=false 时 fields 里加 errorCode(可选)。
51
+ * end 事件的 fields 可承载 op-specific 返回值(如 FILE_READ 的 content)。
52
+ */
53
+ end(ok, exitCode, code, fields) {
54
+ if (this.ended)
55
+ return;
56
+ this.ended = true;
57
+ const mergedFields = { ok, exitCode, ...(fields ?? {}) };
58
+ this.emit('end', ok ? 'info' : 'error', {
59
+ msg: ok ? 'success' : 'failed',
60
+ fields: mergedFields,
61
+ code,
62
+ });
63
+ }
64
+ hasEnded() {
65
+ return this.ended;
66
+ }
67
+ emit(phase, level, partial) {
68
+ if (!isNdjson())
69
+ return;
70
+ const opId = getOpId();
71
+ const userFields = { ...(partial.fields ?? {}) };
72
+ if (opId !== undefined && userFields.opId === undefined) {
73
+ userFields.opId = opId;
74
+ }
75
+ const event = {
76
+ ts: new Date().toISOString(),
77
+ seq: ++this.seq,
78
+ op: this.op,
79
+ phase,
80
+ level,
81
+ };
82
+ if (partial.step !== undefined)
83
+ event.step = partial.step;
84
+ if (partial.progress !== undefined)
85
+ event.progress = partial.progress;
86
+ if (partial.msg !== undefined && partial.msg !== '')
87
+ event.msg = partial.msg;
88
+ if (Object.keys(userFields).length > 0)
89
+ event.fields = userFields;
90
+ if (partial.code !== undefined)
91
+ event.code = partial.code;
92
+ this.writer(JSON.stringify(event) + '\n');
93
+ }
94
+ }
95
+ // bug#4 修:顶层 main().catch 里也要能拿到活 emitter 发 end 兜底。
96
+ // registerExitHandlers 时把 emitter 挂到 module 级,exposé getActiveEmitter 给 index.ts。
97
+ let activeEmitter = null;
98
+ export function getActiveEmitter() {
99
+ return activeEmitter;
100
+ }
101
+ export function clearActiveEmitter() {
102
+ activeEmitter = null;
103
+ }
104
+ /**
105
+ * 注册进程兜底,确保 ndjson 模式下 end 事件必发(plan P1 风险:忘 flush → os-api 卡死)。
106
+ * 只在 ndjson 模式生效。
107
+ */
108
+ export function registerExitHandlers(emitter) {
109
+ if (!isNdjson())
110
+ return;
111
+ activeEmitter = emitter;
112
+ const finalize = (exitCode, code) => {
113
+ if (!emitter.hasEnded()) {
114
+ emitter.end(false, exitCode, code);
115
+ }
116
+ };
117
+ process.on('uncaughtException', (err) => {
118
+ finalize(1, 'E_UNCAUGHT');
119
+ process.stderr.write(String(err?.stack ?? err) + '\n');
120
+ process.exit(1);
121
+ });
122
+ process.on('unhandledRejection', (reason) => {
123
+ finalize(1, 'E_UNHANDLED_REJECTION');
124
+ process.stderr.write(String(reason) + '\n');
125
+ process.exit(1);
126
+ });
127
+ process.on('SIGTERM', () => {
128
+ finalize(143, 'E_SIGTERM');
129
+ process.exit(143);
130
+ });
131
+ process.on('SIGINT', () => {
132
+ finalize(130, 'E_SIGINT');
133
+ process.exit(130);
134
+ });
135
+ }
136
+ //# sourceMappingURL=ndjson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ndjson.js","sourceRoot":"","sources":["../../src/output/ndjson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AA0B7D,MAAM,aAAa,GAAiB,CAA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MAJOR = 22;
12
12
  export declare const NODE_MIN_MINOR = 16;
13
13
  export declare const NODE_INSTALL_VERSION = "22.16.0";
14
- export declare const PYTHON_MIN_MAJOR = 3;
15
- export declare const PYTHON_MIN_MINOR = 11;
16
14
  export declare const NPM_REGISTRY = "https://registry.npmmirror.com";
17
15
  export declare const PIP_INDEX_URL = "https://pypi.tuna.tsinghua.edu.cn/simple";
18
16
  export declare const PIP_TRUSTED_HOST = "pypi.tuna.tsinghua.edu.cn";
@@ -9,13 +9,10 @@ export const OPENVIKING_HOME = '/root/.openviking';
9
9
  export const OPENVIKING_CONF = `${OPENVIKING_HOME}/ov.conf`;
10
10
  export const OPENVIKING_ENV = `${OPENCLAW_HOME}/openviking.env`;
11
11
  export const OPENVIKING_PORT = 1933;
12
- // Version requirements — slightly above official minimums
13
- // Official: Node >= 22.14, Python >= 3.10
12
+ // Version requirements — slightly above official minimum (Node >= 22.14)
14
13
  export const NODE_MIN_MAJOR = 22;
15
14
  export const NODE_MIN_MINOR = 16;
16
15
  export const NODE_INSTALL_VERSION = '22.16.0';
17
- export const PYTHON_MIN_MAJOR = 3;
18
- export const PYTHON_MIN_MINOR = 11;
19
16
  // China mirrors
20
17
  export const NPM_REGISTRY = 'https://registry.npmmirror.com';
21
18
  export const PIP_INDEX_URL = 'https://pypi.tuna.tsinghua.edu.cn/simple';
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC;AAC1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,WAAW,SAAS,CAAC;AACzD,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,WAAW,SAAS,CAAC;AACzD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,WAAW,MAAM,CAAC;AAEnD,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAC/C,MAAM,CA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AAC;AAC5D,MAAM,CAAC,MAAM,WAAW,GAAG,oCAAoC,CAAC;AAEhE,wEAAwE;AACxE,MAAM,CAAC,MAAM,WAAW,GAAG,6BAA6B,CAAC;AACzD,MAAM,CAAC,MAAM,eAAe,GAAG,uBAAuB,CAAC;AACvD,MAAM,CAAC,MAAM,qBAAqB,GAAG,0BAA0B,CAAC;AAEhE,gDAAgD;AAChD,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;AAC1F,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC9C,mBAAmB,EAAE,WAAW,EAAE,oBAAoB;IACtD,mBAAmB,EAAE,eAAe,EAAE,iBAAiB;IACvD,8BAA8B,EAAE,sBAAsB;IACtD,eAAe;CAChB,CAAC;AAEF,8BAA8B;AAC9B,MAAM,CAAC,MAAM,oBAAoB,GAA2B;IAC1D,QAAQ,EAAE,iBAAiB;IAC3B,MAAM,EAAE,iCAAiC;IACzC,iDAAiD;IACjD,mEAAmE;CACpE,CAAC;AAEF,yEAAyE;AACzE,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC"}
@@ -3,11 +3,6 @@
3
3
  * Installs nvm first if not present, then installs Node.js through nvm.
4
4
  */
5
5
  export declare function ensureNodeVersion(): Promise<void>;
6
- /**
7
- * Ensure Python >= PYTHON_MIN_MAJOR.PYTHON_MIN_MINOR is installed.
8
- * Auto-installs via system package manager if missing or too old.
9
- */
10
- export declare function ensurePython(): Promise<void>;
11
6
  /**
12
7
  * Ensure a command exists on PATH.
13
8
  */
@@ -1,6 +1,6 @@
1
1
  import { shell, shellCapture, commandExists } from './shell.js';
2
2
  import { info, warn } from './logger.js';
3
- import { NODE_MIN_MAJOR, NODE_MIN_MINOR, NODE_INSTALL_VERSION, NODE_MIRROR, PYTHON_MIN_MAJOR, PYTHON_MIN_MINOR, } from './constants.js';
3
+ import { NODE_MIN_MAJOR, NODE_MIN_MINOR, NODE_INSTALL_VERSION, NODE_MIRROR, } from './constants.js';
4
4
  /**
5
5
  * Ensure Node.js >= NODE_MIN_MAJOR.NODE_MIN_MINOR is installed via nvm.
6
6
  * Installs nvm first if not present, then installs Node.js through nvm.
@@ -55,79 +55,6 @@ async function installNodejs() {
55
55
  throw new Error('Node.js installation failed: node command not found');
56
56
  info(`Node.js ${verify.stdout.trim()} installed via nvm ✓`);
57
57
  }
58
- /**
59
- * Ensure Python >= PYTHON_MIN_MAJOR.PYTHON_MIN_MINOR is installed.
60
- * Auto-installs via system package manager if missing or too old.
61
- */
62
- export async function ensurePython() {
63
- const required = `${PYTHON_MIN_MAJOR}.${PYTHON_MIN_MINOR}`;
64
- const result = await shellCapture('python3 --version');
65
- if (result.code === 0) {
66
- const match = result.stdout.match(/(\d+)\.(\d+)\.?(\d+)?/);
67
- if (match) {
68
- const version = `${match[1]}.${match[2]}`;
69
- if (versionGe(version, required)) {
70
- info(`Python ${result.stdout.trim()} >= ${required} ✓`);
71
- await ensurePip();
72
- return;
73
- }
74
- warn(`Python ${version} < ${required}, upgrading...`);
75
- }
76
- }
77
- else {
78
- info('Python3 not found, installing...');
79
- }
80
- await installPython();
81
- await ensurePip();
82
- }
83
- async function installPython() {
84
- const required = `${PYTHON_MIN_MAJOR}.${PYTHON_MIN_MINOR}`;
85
- info(`Installing Python >= ${required}...`);
86
- if (await commandExists('apt-get')) {
87
- // Try deadsnakes PPA for newer Python on older Ubuntu
88
- await shell('apt-get update -qq').catch(() => { });
89
- await shell('apt-get install -y -qq python3 python3-pip python3-venv python3-dev').catch(async () => {
90
- info('Trying deadsnakes PPA...');
91
- await shell('apt-get install -y -qq software-properties-common').catch(() => { });
92
- await shell('add-apt-repository -y ppa:deadsnakes/ppa').catch(() => { });
93
- await shell('apt-get update -qq');
94
- await shell('apt-get install -y -qq python3 python3-pip python3-venv python3-dev');
95
- });
96
- }
97
- else if (await commandExists('dnf')) {
98
- await shell('dnf install -y python3 python3-pip python3-devel');
99
- }
100
- else if (await commandExists('yum')) {
101
- await shell('yum install -y python3 python3-pip python3-devel');
102
- }
103
- else {
104
- throw new Error(`Cannot install Python: no supported package manager. Install Python >= ${required} manually.`);
105
- }
106
- // Verify
107
- const verify = await shellCapture('python3 --version');
108
- if (verify.code !== 0)
109
- throw new Error('Python installation failed');
110
- const match = verify.stdout.match(/(\d+)\.(\d+)/);
111
- if (match && !versionGe(`${match[1]}.${match[2]}`, required)) {
112
- throw new Error(`Installed Python ${match[1]}.${match[2]} still below ${required}. Install manually.`);
113
- }
114
- info(`Python ${verify.stdout.trim()} installed ✓`);
115
- }
116
- /**
117
- * Ensure pip is available.
118
- */
119
- async function ensurePip() {
120
- const result = await shellCapture('python3 -m pip --version');
121
- if (result.code === 0)
122
- return;
123
- info('pip not found, installing...');
124
- await shell('curl -fsSL https://bootstrap.pypa.io/get-pip.py | python3').catch(async () => {
125
- await installSystemPackages(['python3-pip']);
126
- });
127
- const verify = await shellCapture('python3 -m pip --version');
128
- if (verify.code !== 0)
129
- throw new Error('Failed to install pip');
130
- }
131
58
  /**
132
59
  * Ensure a command exists on PATH.
133
60
  */
@@ -147,20 +74,6 @@ export async function checkDiskSpace(requiredMb) {
147
74
  }
148
75
  }
149
76
  // ---- helpers ----
150
- async function installSystemPackages(packages) {
151
- if (await commandExists('apt-get')) {
152
- await shell(`apt-get update -qq && apt-get install -y -qq ${packages.join(' ')}`);
153
- }
154
- else if (await commandExists('dnf')) {
155
- await shell(`dnf install -y ${packages.join(' ')}`);
156
- }
157
- else if (await commandExists('yum')) {
158
- await shell(`yum install -y ${packages.join(' ')}`);
159
- }
160
- else {
161
- throw new Error(`Cannot install packages: no supported package manager`);
162
- }
163
- }
164
77
  function versionGe(a, b) {
165
78
  const pa = a.split('.').map(Number);
166
79
  const pb = b.split('.').map(Number);
@@ -1 +1 @@
1
- {"version":3,"file":"deps.js","sourceRoot":"","sources":["../../src/utils/deps.ts"],"names":[],"mappings":"AAAA,OA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,CAAC;IACpG,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC9C,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,SAAS,GAAG,UAAU,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,4BAA4B,SAAS,iBAAiB,UAAU,aAAa,CAAC,CAAC;IACjG,CAAC;AACH,CAAC;AAED,oBAAoB;AAEpB,SAAS,SAAS,CAAC,CAAS,EAAE,CAAS;IACrC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACxD,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACtB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,EAAE,GAAG,EAAE;YAAE,OAAO,IAAI,CAAC;QACzB,IAAI,EAAE,GAAG,EAAE;YAAE,OAAO,KAAK,CAAC;IAC5B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,3 +1,13 @@
1
+ /**
2
+ * 人类可读 log。
3
+ *
4
+ * ndjson 模式下:所有业务级 log(info / warn / success / error)静默。
5
+ * - info/warn/success 本就无关紧要,静默避免污染 stdout 结构化流
6
+ * - error 也静默(bug#5 修):业务错误必须通过 emitter.end(false, code, { error: msg }) 承载,
7
+ * 与 design 契约对齐(stderr 仅给真正的崩溃栈,由 registerExitHandlers 的 uncaughtException 打印)
8
+ *
9
+ * 调用方注意:ndjson 模式下调 error(msg) 不会让用户看见消息,务必把 msg 塞进 emitter.end 的 fields。
10
+ */
1
11
  export declare function info(msg: string): void;
2
12
  export declare function warn(msg: string): void;
3
13
  export declare function error(msg: string): void;
@@ -1,5 +1,32 @@
1
- export function info(msg) { console.log(`[okclaw] ${msg}`); }
2
- export function warn(msg) { console.log(`[okclaw] WARN: ${msg}`); }
3
- export function error(msg) { console.error(`[okclaw] ERROR: ${msg}`); }
4
- export function success(msg) { console.log(`[okclaw] ✓ ${msg}`); }
1
+ import { isNdjson } from '../output/mode.js';
2
+ /**
3
+ * 人类可读 log。
4
+ *
5
+ * ndjson 模式下:所有业务级 log(info / warn / success / error)静默。
6
+ * - info/warn/success 本就无关紧要,静默避免污染 stdout 结构化流
7
+ * - error 也静默(bug#5 修):业务错误必须通过 emitter.end(false, code, { error: msg }) 承载,
8
+ * 与 design 契约对齐(stderr 仅给真正的崩溃栈,由 registerExitHandlers 的 uncaughtException 打印)
9
+ *
10
+ * 调用方注意:ndjson 模式下调 error(msg) 不会让用户看见消息,务必把 msg 塞进 emitter.end 的 fields。
11
+ */
12
+ export function info(msg) {
13
+ if (isNdjson())
14
+ return;
15
+ console.log(`[okclaw] ${msg}`);
16
+ }
17
+ export function warn(msg) {
18
+ if (isNdjson())
19
+ return;
20
+ console.log(`[okclaw] WARN: ${msg}`);
21
+ }
22
+ export function error(msg) {
23
+ if (isNdjson())
24
+ return;
25
+ console.error(`[okclaw] ERROR: ${msg}`);
26
+ }
27
+ export function success(msg) {
28
+ if (isNdjson())
29
+ return;
30
+ console.log(`[okclaw] ✓ ${msg}`);
31
+ }
5
32
  //# sourceMappingURL=logger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,IAAI,CAAC,GAAW,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AACrE,MAAM,UAAU,IAAI,CAAC,GAAW,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AAC3E,MAAM,UAAU,KAAK,CAAC,GAAW,IAAI,OAAO,CAAC,KAAK,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/E,MAAM,UAAU,OAAO,CAAC,GAAW,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C;;;;;;;;;GASG;AAEH,MAAM,UAAU,IAAI,CAAC,GAAW;IAC9B,IAAI,QAAQ,EAAE;QAAE,OAAO;IACvB,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,EAAE,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,GAAW;IAC9B,IAAI,QAAQ,EAAE;QAAE,OAAO;IACvB,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,EAAE,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,GAAW;IAC/B,IAAI,QAAQ,EAAE;QAAE,OAAO;IACvB,OAAO,CAAC,KAAK,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,IAAI,QAAQ,EAAE;QAAE,OAAO;IACvB,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,EAAE,CAAC,CAAC;AACnC,CAAC"}
@@ -4,6 +4,20 @@ import { NPM_REGISTRY, PIP_INDEX_URL, PIP_TRUSTED_HOST } from './constants.js';
4
4
  export async function configureMirrors() {
5
5
  info('Configuring China mirrors...');
6
6
  await shell(`npm config set registry ${NPM_REGISTRY}`).catch(() => { });
7
+ // 第三方插件(如 @soimy/dingtalk)的 devDependencies 偶发会因为上游版本漂移
8
+ // 出现 peer dep 冲突(实例:oxlint@1.63.0 要求 oxlint-tsgolint>=0.22.1,但插件
9
+ // 钉死 ^0.18.0),npm 10 默认严格 peer 解析会报 ERESOLVE 直接挂掉
10
+ // openclaw plugins install 内部的 npm install。openclaw 没暴露 install flag 给我们传,
11
+ // 设成全局 npm config 是唯一能影响它的方式。lint/format devDep 的版本拉新对运行时
12
+ // 无影响,让 npm 用旧 peer 解析逻辑通过即可。
13
+ await shell(`npm config set legacy-peer-deps true`).catch(() => { });
14
+ // 部分 npm 包(如 openclaw 依赖的 libsignal-node)用 git+ssh://git@github.com/...
15
+ // 引用 GitHub 仓库。云主机 root 账户默认没有 GitHub SSH key 会拉取失败。
16
+ // 这里把 ssh://git@github.com/ 和 git@github.com: 都重写成 https://github.com/(匿名可读)。
17
+ // 注意: 同一个 URL name 下要写多个 insteadOf 必须用 --add,否则第二次 set 会覆盖第一次。
18
+ await shell(`git config --global --unset-all url."https://github.com/".insteadOf 2>/dev/null || true`).catch(() => { });
19
+ await shell(`git config --global --add url."https://github.com/".insteadOf ssh://git@github.com/`).catch(() => { });
20
+ await shell(`git config --global --add url."https://github.com/".insteadOf git@github.com:`).catch(() => { });
7
21
  // Use /root/.pip — not ~/
8
22
  await shell(`mkdir -p /root/.pip && cat > /root/.pip/pip.conf << 'EOF'
9
23
  [global]
@@ -1 +1 @@
1
- {"version":3,"file":"mirror.js","sourceRoot":"","sources":["../../src/utils/mirror.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE/E,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC,8BAA8B,CAAC,CAAC;IAErC,M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AAC;IAElB,0BAA0B;IAC1B,MAAM,KAAK,CAAC;;cAEA,aAAa;iBACV,gBAAgB;IAC7B,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAEpB,IAAI,CAAC,qBAAqB,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,19 @@
1
+ export declare class OpenclawConfigCliError extends Error {
2
+ readonly cmd: string;
3
+ readonly exitCode: number;
4
+ readonly stdout: string;
5
+ readonly stderr: string;
6
+ constructor(cmd: string, exitCode: number, stdout: string, stderr: string);
7
+ }
8
+ export interface CliRunner {
9
+ run(args: string[]): {
10
+ exitCode: number;
11
+ stdout: string;
12
+ stderr: string;
13
+ };
14
+ }
15
+ export declare const defaultCliRunner: CliRunner;
16
+ export declare function configGet(path: string, runner?: CliRunner): unknown | undefined;
17
+ export declare function configSet(path: string, valueJson: string, runner?: CliRunner): void;
18
+ export declare function configUnset(path: string, runner?: CliRunner): void;
19
+ export declare function configValidate(runner?: CliRunner): boolean;
@@ -0,0 +1,81 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ export class OpenclawConfigCliError extends Error {
3
+ cmd;
4
+ exitCode;
5
+ stdout;
6
+ stderr;
7
+ constructor(cmd, exitCode, stdout, stderr) {
8
+ super(`openclaw ${cmd} failed (exit ${exitCode}): ${stderr || stdout}`);
9
+ this.cmd = cmd;
10
+ this.exitCode = exitCode;
11
+ this.stdout = stdout;
12
+ this.stderr = stderr;
13
+ }
14
+ }
15
+ function stringifyOutput(value) {
16
+ if (typeof value === 'string')
17
+ return value;
18
+ if (Buffer.isBuffer(value))
19
+ return value.toString('utf8');
20
+ return '';
21
+ }
22
+ export const defaultCliRunner = {
23
+ run(args) {
24
+ try {
25
+ const stdout = execFileSync('openclaw', args, {
26
+ encoding: 'utf8',
27
+ stdio: ['ignore', 'pipe', 'pipe'],
28
+ });
29
+ return { exitCode: 0, stdout, stderr: '' };
30
+ }
31
+ catch (err) {
32
+ const error = err;
33
+ return {
34
+ exitCode: typeof error.status === 'number' ? error.status : 127,
35
+ stdout: stringifyOutput(error.stdout),
36
+ stderr: stringifyOutput(error.stderr || error.message),
37
+ };
38
+ }
39
+ },
40
+ };
41
+ function runOrThrow(args, runner = defaultCliRunner) {
42
+ const result = runner.run(args);
43
+ if (result.exitCode !== 0) {
44
+ throw new OpenclawConfigCliError(args.join(' '), result.exitCode, result.stdout, result.stderr);
45
+ }
46
+ return result;
47
+ }
48
+ function isNotFoundOutput(output) {
49
+ return /Config\s+path\s+not\s+found/i.test(output);
50
+ }
51
+ export function configGet(path, runner = defaultCliRunner) {
52
+ const args = ['config', 'get', path];
53
+ const result = runner.run(args);
54
+ if (result.exitCode !== 0) {
55
+ if (isNotFoundOutput(`${result.stderr}\n${result.stdout}`))
56
+ return undefined;
57
+ throw new OpenclawConfigCliError(args.join(' '), result.exitCode, result.stdout, result.stderr);
58
+ }
59
+ const stdout = result.stdout.trim();
60
+ if (!stdout)
61
+ return undefined;
62
+ try {
63
+ return JSON.parse(stdout);
64
+ }
65
+ catch {
66
+ // openclaw config get prints scalar string values as raw text without JSON
67
+ // quoting (e.g. `openviking` rather than `"openviking"`). number / bool / null
68
+ // are valid JSON literals so they parse above; only unquoted strings reach here.
69
+ return stdout;
70
+ }
71
+ }
72
+ export function configSet(path, valueJson, runner = defaultCliRunner) {
73
+ runOrThrow(['config', 'set', path, valueJson, '--strict-json'], runner);
74
+ }
75
+ export function configUnset(path, runner = defaultCliRunner) {
76
+ runOrThrow(['config', 'unset', path], runner);
77
+ }
78
+ export function configValidate(runner = defaultCliRunner) {
79
+ return runner.run(['config', 'validate']).exitCode === 0;
80
+ }
81
+ //# sourceMappingURL=openclaw-config-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openclaw-config-cli.js","sourceRoot":"","sources":["../../src/utils/openclaw-config-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,OAAO,sBAA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CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,2EAA2E;QAC3E,+EAA+E;QAC/E,iFAAiF;QACjF,OAAO,MAAM,CAAC;IAChB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,SAAiB,EAAE,SAAoB,gBAAgB;IAC7F,UAAU,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,CAAC,EAAE,MAAM,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,SAAoB,gBAAgB;IAC5E,UAAU,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,SAAoB,gBAAgB;IACjE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Best-effort stop of the openclaw gateway daemon so cli operations have
3
+ * exclusive write access to openclaw.json + extensions/.
4
+ *
5
+ * Why this is needed: the daemon has a config file watcher that writes its
6
+ * own metadata back into openclaw.json on every config change. Concurrent
7
+ * writes during cli's cleanup / `openclaw plugins install` / `openclaw config
8
+ * set` race with that watcher and produce:
9
+ * - ENOTEMPTY: rmdir '.../node_modules/.cache/jiti' (jiti cache write race)
10
+ * - ConfigMutationConflictError: config changed since last load (hash check
11
+ * in openclaw plugins install commit / openclaw config set atomic write)
12
+ *
13
+ * Tries every supervisor we know of, each tolerated if absent. Order matters:
14
+ * ask the supervisor (openclaw cli / systemd) first so it doesn't auto-restart
15
+ * on us, then pkill -9 as the last resort.
16
+ *
17
+ * Bootstrap orchestrator (commands/install.ts) is responsible for restarting
18
+ * the daemon after the full component install pipeline finishes.
19
+ *
20
+ * @param context A short label for logs, e.g. "dingtalk install" or
21
+ * "openclaw deployment defaults".
22
+ */
23
+ export declare function stopDaemonForExclusiveAccess(context: string): Promise<void>;
@@ -0,0 +1,38 @@
1
+ import { shell } from './shell.js';
2
+ import { info } from './logger.js';
3
+ /**
4
+ * Best-effort stop of the openclaw gateway daemon so cli operations have
5
+ * exclusive write access to openclaw.json + extensions/.
6
+ *
7
+ * Why this is needed: the daemon has a config file watcher that writes its
8
+ * own metadata back into openclaw.json on every config change. Concurrent
9
+ * writes during cli's cleanup / `openclaw plugins install` / `openclaw config
10
+ * set` race with that watcher and produce:
11
+ * - ENOTEMPTY: rmdir '.../node_modules/.cache/jiti' (jiti cache write race)
12
+ * - ConfigMutationConflictError: config changed since last load (hash check
13
+ * in openclaw plugins install commit / openclaw config set atomic write)
14
+ *
15
+ * Tries every supervisor we know of, each tolerated if absent. Order matters:
16
+ * ask the supervisor (openclaw cli / systemd) first so it doesn't auto-restart
17
+ * on us, then pkill -9 as the last resort.
18
+ *
19
+ * Bootstrap orchestrator (commands/install.ts) is responsible for restarting
20
+ * the daemon after the full component install pipeline finishes.
21
+ *
22
+ * @param context A short label for logs, e.g. "dingtalk install" or
23
+ * "openclaw deployment defaults".
24
+ */
25
+ export async function stopDaemonForExclusiveAccess(context) {
26
+ info(`Stopping openclaw gateway for exclusive access during ${context}...`);
27
+ await shell(`openclaw gateway stop 2>/dev/null || true`).catch(() => { });
28
+ await shell(`systemctl --user stop openclaw 2>/dev/null || true`).catch(() => { });
29
+ await shell(`systemctl stop openclaw 2>/dev/null || true`).catch(() => { });
30
+ // Match `pkill -f 'openclaw-gateway'` exactly the same way as
31
+ // OpenclawInstaller.uninstall — narrow enough that we don't kill the cli
32
+ // process running this code, broad enough to catch the gateway daemon.
33
+ await shell(`pkill -9 -f 'openclaw-gateway' 2>/dev/null || true`).catch(() => { });
34
+ // 1.5s is enough for systemd's default RestartSec (100ms) to fire if it
35
+ // would, and short enough not to drag deploy time noticeably.
36
+ await new Promise((resolve) => setTimeout(resolve, 1500));
37
+ }
38
+ //# sourceMappingURL=openclaw-daemon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openclaw-daemon.js","sourceRoot":"","sources":["../../src/utils/openclaw-daemon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,OAAe;IAChE,IAAI,CAAC,yDAAyD,OAAO,KAAK,CAAC,CAAC;IAC5E,MAAM,KAAK,CAAC,2CAA2C,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACzE,MAAM,KAAK,CAAC,oDAAoD,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAClF,MAAM,KAAK,CAAC,6CAA6C,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC3E,8DAA8D;IAC9D,yEAAyE;IACzE,uEAAuE;IACvE,MAAM,KAAK,CAAC,oDAAoD,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAClF,wEAAwE;IACxE,8DAA8D;IAC9D,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;AAC5D,CAAC"}
@@ -8,8 +8,18 @@ export interface ShellResult {
8
8
  */
9
9
  export declare function ensureRoot(): void;
10
10
  /**
11
- * Run a shell command with inherited stdio (visible output).
12
- * Automatically sources nvm so node/npm/openclaw are available.
11
+ * Run a shell command and wait for exit.
12
+ *
13
+ * text 模式:stdio:inherit,子进程输出直通父进程 TTY(本地交互体验不变)。
14
+ *
15
+ * ndjson 模式:捕获 stdout/stderr 并按行合成 phase="log" 事件(stdout→level=info,
16
+ * stderr→level=warn),通过 {@link getActiveEmitter} 拿到当前 op 的 emitter 发出。
17
+ * 这样像 `npm install` 这种几分钟才回一行 ndjson 的长操作,其实时进度也能通过
18
+ * 事件流推给 os-api / 前端,用户不会看到 UI 卡死 10 分钟。
19
+ *
20
+ * 透传是"尽力而为":emitter 缺失(理论上只有本地脚本直接 import shell() 且没走
21
+ * 正常 command 入口才会发生)时静默吞,不影响命令本身执行。
22
+ *
13
23
  * Throws on non-zero exit.
14
24
  */
15
25
  export declare function shell(cmd: string): Promise<void>;