@chrysb/alphaclaw 0.8.7-beta.3 → 0.8.7

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 (29) hide show
  1. package/bin/alphaclaw.js +43 -174
  2. package/lib/public/css/tailwind.generated.css +1 -1
  3. package/lib/public/dist/app.bundle.js +2021 -2041
  4. package/lib/public/js/app.js +0 -3
  5. package/lib/public/js/components/gateway.js +3 -6
  6. package/lib/public/js/components/general/index.js +0 -2
  7. package/lib/public/js/components/onboarding/welcome-form-step.js +4 -29
  8. package/lib/public/js/components/routes/general-route.js +0 -2
  9. package/lib/public/js/components/routes/watchdog-route.js +0 -2
  10. package/lib/public/js/components/sidebar.js +7 -20
  11. package/lib/public/js/components/update-modal.js +1 -2
  12. package/lib/public/js/components/watchdog-tab/index.js +0 -2
  13. package/lib/public/js/components/welcome/index.js +0 -1
  14. package/lib/public/js/components/welcome/use-welcome.js +2 -52
  15. package/lib/public/js/hooks/use-app-shell-controller.js +9 -33
  16. package/lib/public/js/lib/api.js +0 -35
  17. package/lib/server/alphaclaw-version.js +128 -37
  18. package/lib/server/openclaw-version.js +130 -59
  19. package/lib/server/routes/system.js +1 -6
  20. package/lib/server/usage-tracker-config.js +3 -27
  21. package/package.json +2 -2
  22. package/patches/openclaw+2026.4.5.patch +13 -0
  23. package/lib/public/js/components/update-modal-helpers.js +0 -12
  24. package/lib/server/alphaclaw-runtime.js +0 -238
  25. package/lib/server/openclaw-runtime.js +0 -338
  26. package/lib/server/package-fingerprint.js +0 -202
  27. package/lib/server/pending-alphaclaw-update.js +0 -70
  28. package/lib/server/pending-openclaw-update.js +0 -71
  29. package/patches/openclaw+2026.4.1.patch +0 -13
@@ -1,238 +0,0 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
-
4
- const { kRootDir } = require("./constants");
5
- const { compareVersionParts } = require("./helpers");
6
- const {
7
- computePackageFingerprint,
8
- isPackageRootSymlink,
9
- packLocalPackageForInstall,
10
- } = require("./package-fingerprint");
11
-
12
- const getManagedAlphaclawRuntimeDir = ({ rootDir = kRootDir } = {}) =>
13
- path.join(rootDir, ".alphaclaw-runtime");
14
-
15
- const getBundledAlphaclawPackageRoot = () => path.resolve(__dirname, "..", "..");
16
-
17
- const getManagedAlphaclawPackageRoot = ({ runtimeDir } = {}) =>
18
- path.join(
19
- runtimeDir || getManagedAlphaclawRuntimeDir(),
20
- "node_modules",
21
- "@chrysb",
22
- "alphaclaw",
23
- );
24
-
25
- const getManagedAlphaclawCliPath = ({ runtimeDir } = {}) =>
26
- path.join(
27
- getManagedAlphaclawPackageRoot({ runtimeDir }),
28
- "bin",
29
- "alphaclaw.js",
30
- );
31
-
32
- const getManagedAlphaclawPackageJsonPath = ({ runtimeDir } = {}) =>
33
- path.join(
34
- getManagedAlphaclawPackageRoot({ runtimeDir }),
35
- "package.json",
36
- );
37
-
38
- const ensureManagedAlphaclawRuntimeProject = ({
39
- fsModule = fs,
40
- runtimeDir,
41
- } = {}) => {
42
- const resolvedRuntimeDir = runtimeDir || getManagedAlphaclawRuntimeDir();
43
- const packageJsonPath = path.join(resolvedRuntimeDir, "package.json");
44
- fsModule.mkdirSync(resolvedRuntimeDir, { recursive: true });
45
- if (!fsModule.existsSync(packageJsonPath)) {
46
- fsModule.writeFileSync(
47
- packageJsonPath,
48
- JSON.stringify(
49
- {
50
- name: "alphaclaw-runtime",
51
- private: true,
52
- },
53
- null,
54
- 2,
55
- ),
56
- );
57
- }
58
- return {
59
- runtimeDir: resolvedRuntimeDir,
60
- packageJsonPath,
61
- };
62
- };
63
-
64
- const readManagedAlphaclawRuntimeVersion = ({
65
- fsModule = fs,
66
- runtimeDir,
67
- } = {}) => {
68
- try {
69
- const pkg = JSON.parse(
70
- fsModule.readFileSync(
71
- getManagedAlphaclawPackageJsonPath({ runtimeDir }),
72
- "utf8",
73
- ),
74
- );
75
- return String(pkg?.version || "").trim() || null;
76
- } catch {
77
- return null;
78
- }
79
- };
80
-
81
- const readBundledAlphaclawVersion = ({
82
- fsModule = fs,
83
- packageJsonPath = path.resolve(__dirname, "..", "..", "package.json"),
84
- } = {}) => {
85
- try {
86
- const pkg = JSON.parse(fsModule.readFileSync(packageJsonPath, "utf8"));
87
- return String(pkg?.version || "").trim() || null;
88
- } catch {
89
- return null;
90
- }
91
- };
92
-
93
- const shellQuote = (value) =>
94
- `'${String(value || "").replace(/'/g, `'\"'\"'`)}'`;
95
-
96
- const installManagedAlphaclawRuntime = ({
97
- execSyncImpl,
98
- fsModule = fs,
99
- runtimeDir,
100
- spec,
101
- sourcePath,
102
- } = {}) => {
103
- const normalizedSourcePath = String(sourcePath || "").trim();
104
- const normalizedSpec = normalizedSourcePath
105
- ? normalizedSourcePath
106
- : String(spec || "").trim() || "@chrysb/alphaclaw@latest";
107
- ensureManagedAlphaclawRuntimeProject({
108
- fsModule,
109
- runtimeDir,
110
- });
111
- let packedSource = null;
112
- try {
113
- const installTarget = normalizedSourcePath
114
- ? (() => {
115
- packedSource = packLocalPackageForInstall({
116
- execSyncImpl,
117
- fsModule,
118
- packageRoot: normalizedSourcePath,
119
- tempDirPrefix: "alphaclaw-runtime-pack-",
120
- });
121
- return packedSource.tarballPath;
122
- })()
123
- : normalizedSpec;
124
- execSyncImpl(
125
- `npm install ${shellQuote(installTarget)} --omit=dev --no-save --save=false --package-lock=false --prefer-online`,
126
- {
127
- cwd: runtimeDir,
128
- stdio: "inherit",
129
- timeout: 180000,
130
- },
131
- );
132
- } finally {
133
- packedSource?.cleanup?.();
134
- }
135
- return {
136
- spec: normalizedSpec,
137
- version: readManagedAlphaclawRuntimeVersion({
138
- fsModule,
139
- runtimeDir,
140
- }),
141
- };
142
- };
143
-
144
- const syncManagedAlphaclawRuntimeWithBundled = ({
145
- execSyncImpl,
146
- fsModule = fs,
147
- logger = console,
148
- runtimeDir,
149
- packageRoot = getBundledAlphaclawPackageRoot(),
150
- packageJsonPath,
151
- } = {}) => {
152
- const bundledVersion = readBundledAlphaclawVersion({
153
- fsModule,
154
- packageJsonPath: packageJsonPath || path.join(packageRoot, "package.json"),
155
- });
156
- if (!bundledVersion) {
157
- return {
158
- checked: false,
159
- synced: false,
160
- bundledVersion: null,
161
- runtimeVersion: readManagedAlphaclawRuntimeVersion({
162
- fsModule,
163
- runtimeDir,
164
- }),
165
- };
166
- }
167
-
168
- const runtimeVersion = readManagedAlphaclawRuntimeVersion({
169
- fsModule,
170
- runtimeDir,
171
- });
172
- const runtimePackageRoot = getManagedAlphaclawPackageRoot({ runtimeDir });
173
- const runtimePackageRootIsSymlink = isPackageRootSymlink({
174
- fsModule,
175
- packageRoot: runtimePackageRoot,
176
- });
177
- const bundledFingerprint = computePackageFingerprint({
178
- fsModule,
179
- packageRoot,
180
- packageJsonPath: packageJsonPath || path.join(packageRoot, "package.json"),
181
- });
182
- const runtimeFingerprint = computePackageFingerprint({
183
- fsModule,
184
- packageRoot: runtimePackageRoot,
185
- packageJsonPath: getManagedAlphaclawPackageJsonPath({ runtimeDir }),
186
- });
187
- if (runtimeVersion && compareVersionParts(runtimeVersion, bundledVersion) >= 0) {
188
- if (
189
- compareVersionParts(runtimeVersion, bundledVersion) > 0 ||
190
- (!runtimePackageRootIsSymlink &&
191
- (!bundledFingerprint || runtimeFingerprint === bundledFingerprint))
192
- ) {
193
- return {
194
- checked: true,
195
- synced: false,
196
- bundledVersion,
197
- runtimeVersion,
198
- };
199
- }
200
- logger.log(
201
- runtimePackageRootIsSymlink
202
- ? `[alphaclaw] Managed AlphaClaw runtime ${runtimeVersion} is symlinked to the bundled package; refreshing runtime...`
203
- : `[alphaclaw] Managed AlphaClaw runtime ${runtimeVersion} differs from bundled ${bundledVersion}; refreshing runtime...`,
204
- );
205
- } else {
206
- logger.log(
207
- runtimeVersion
208
- ? `[alphaclaw] Managed AlphaClaw runtime ${runtimeVersion} is older than bundled ${bundledVersion}; syncing runtime...`
209
- : `[alphaclaw] Managed AlphaClaw runtime missing; seeding bundled AlphaClaw ${bundledVersion}...`,
210
- );
211
- }
212
-
213
- const installResult = installManagedAlphaclawRuntime({
214
- execSyncImpl,
215
- fsModule,
216
- runtimeDir,
217
- sourcePath: packageRoot,
218
- });
219
- return {
220
- checked: true,
221
- synced: true,
222
- bundledVersion,
223
- runtimeVersion: installResult.version || bundledVersion,
224
- };
225
- };
226
-
227
- module.exports = {
228
- ensureManagedAlphaclawRuntimeProject,
229
- getBundledAlphaclawPackageRoot,
230
- getManagedAlphaclawCliPath,
231
- getManagedAlphaclawPackageJsonPath,
232
- getManagedAlphaclawPackageRoot,
233
- getManagedAlphaclawRuntimeDir,
234
- installManagedAlphaclawRuntime,
235
- readBundledAlphaclawVersion,
236
- readManagedAlphaclawRuntimeVersion,
237
- syncManagedAlphaclawRuntimeWithBundled,
238
- };
@@ -1,338 +0,0 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
-
4
- const { kRootDir } = require("./constants");
5
- const {
6
- compareVersionParts,
7
- normalizeOpenclawVersion,
8
- } = require("./helpers");
9
- const {
10
- computePackageFingerprint,
11
- isPackageRootSymlink,
12
- packLocalPackageForInstall,
13
- resolvePackageRootFromEntryPath,
14
- } = require("./package-fingerprint");
15
-
16
- const getManagedOpenclawRuntimeDir = ({ rootDir = kRootDir } = {}) =>
17
- path.join(rootDir, ".openclaw-runtime");
18
-
19
- const getBundledOpenclawPackageRoot = ({
20
- fsModule = fs,
21
- resolveImpl = require.resolve,
22
- } = {}) =>
23
- resolvePackageRootFromEntryPath({
24
- fsModule,
25
- entryPath: resolveImpl("openclaw"),
26
- });
27
-
28
- const getManagedOpenclawPackageRoot = ({ runtimeDir } = {}) =>
29
- path.join(
30
- runtimeDir || getManagedOpenclawRuntimeDir(),
31
- "node_modules",
32
- "openclaw",
33
- );
34
-
35
- const getManagedOpenclawBinDir = ({ runtimeDir } = {}) =>
36
- path.join(
37
- runtimeDir || getManagedOpenclawRuntimeDir(),
38
- "node_modules",
39
- ".bin",
40
- );
41
-
42
- const getManagedOpenclawBinPath = ({ runtimeDir } = {}) =>
43
- path.join(getManagedOpenclawBinDir({ runtimeDir }), "openclaw");
44
-
45
- const getManagedOpenclawPackageJsonPath = ({ runtimeDir } = {}) =>
46
- path.join(
47
- getManagedOpenclawPackageRoot({ runtimeDir }),
48
- "package.json",
49
- );
50
-
51
- const ensureManagedOpenclawRuntimeProject = ({
52
- fsModule = fs,
53
- runtimeDir,
54
- } = {}) => {
55
- const resolvedRuntimeDir = runtimeDir || getManagedOpenclawRuntimeDir();
56
- const packageJsonPath = path.join(resolvedRuntimeDir, "package.json");
57
- fsModule.mkdirSync(resolvedRuntimeDir, { recursive: true });
58
- if (!fsModule.existsSync(packageJsonPath)) {
59
- fsModule.writeFileSync(
60
- packageJsonPath,
61
- JSON.stringify(
62
- {
63
- name: "alphaclaw-openclaw-runtime",
64
- private: true,
65
- },
66
- null,
67
- 2,
68
- ),
69
- );
70
- }
71
- return {
72
- runtimeDir: resolvedRuntimeDir,
73
- packageJsonPath,
74
- };
75
- };
76
-
77
- const readManagedOpenclawRuntimeVersion = ({
78
- fsModule = fs,
79
- runtimeDir,
80
- } = {}) => {
81
- try {
82
- const pkg = JSON.parse(
83
- fsModule.readFileSync(
84
- getManagedOpenclawPackageJsonPath({ runtimeDir }),
85
- "utf8",
86
- ),
87
- );
88
- return normalizeOpenclawVersion(pkg?.version || "");
89
- } catch {
90
- return null;
91
- }
92
- };
93
-
94
- const readBundledOpenclawVersion = ({
95
- fsModule = fs,
96
- resolveImpl = require.resolve,
97
- } = {}) => {
98
- try {
99
- const packageRoot = getBundledOpenclawPackageRoot({
100
- fsModule,
101
- resolveImpl,
102
- });
103
- if (!packageRoot) return null;
104
- const pkg = JSON.parse(
105
- fsModule.readFileSync(path.join(packageRoot, "package.json"), "utf8"),
106
- );
107
- return normalizeOpenclawVersion(pkg?.version || "");
108
- } catch {
109
- return null;
110
- }
111
- };
112
-
113
- const shellQuote = (value) =>
114
- `'${String(value || "").replace(/'/g, `'\"'\"'`)}'`;
115
-
116
- const applyManagedOpenclawPatch = ({
117
- execSyncImpl,
118
- fsModule = fs,
119
- logger = console,
120
- runtimeDir,
121
- version,
122
- alphaclawRoot = path.resolve(__dirname, "..", ".."),
123
- } = {}) => {
124
- const normalizedVersion = normalizeOpenclawVersion(version);
125
- if (!normalizedVersion) return false;
126
- const patchesDir = path.join(alphaclawRoot, "patches");
127
- const patchFileName = `openclaw+${normalizedVersion}.patch`;
128
- const patchFilePath = path.join(patchesDir, patchFileName);
129
- if (!fsModule.existsSync(patchFilePath)) {
130
- return false;
131
- }
132
-
133
- const runtimePatchDirName = ".alphaclaw-patches";
134
- const runtimePatchDirPath = path.join(runtimeDir, runtimePatchDirName);
135
- try {
136
- if (fsModule.existsSync(runtimePatchDirPath)) {
137
- fsModule.rmSync(runtimePatchDirPath, { recursive: true, force: true });
138
- }
139
- } catch {}
140
- fsModule.symlinkSync(patchesDir, runtimePatchDirPath);
141
-
142
- const patchPackageMain = require.resolve("patch-package/dist/index.js", {
143
- paths: [alphaclawRoot],
144
- });
145
- logger.log(
146
- `[alphaclaw] Applying bundled OpenClaw patch for ${normalizedVersion}...`,
147
- );
148
- execSyncImpl(
149
- `${shellQuote(process.execPath)} ${shellQuote(patchPackageMain)} --patch-dir ${shellQuote(runtimePatchDirName)}`,
150
- {
151
- cwd: runtimeDir,
152
- stdio: "inherit",
153
- timeout: 120000,
154
- },
155
- );
156
- return true;
157
- };
158
-
159
- const installManagedOpenclawRuntime = ({
160
- execSyncImpl,
161
- fsModule = fs,
162
- logger = console,
163
- runtimeDir,
164
- spec,
165
- sourcePath,
166
- alphaclawRoot,
167
- } = {}) => {
168
- const normalizedSourcePath = String(sourcePath || "").trim();
169
- const normalizedSpec = normalizedSourcePath
170
- ? normalizedSourcePath
171
- : String(spec || "").trim() || "openclaw@latest";
172
- ensureManagedOpenclawRuntimeProject({
173
- fsModule,
174
- runtimeDir,
175
- });
176
- let packedSource = null;
177
- try {
178
- const installTarget = normalizedSourcePath
179
- ? (() => {
180
- packedSource = packLocalPackageForInstall({
181
- execSyncImpl,
182
- fsModule,
183
- packageRoot: normalizedSourcePath,
184
- tempDirPrefix: "openclaw-runtime-pack-",
185
- });
186
- return packedSource.tarballPath;
187
- })()
188
- : normalizedSpec;
189
- execSyncImpl(
190
- `npm install ${shellQuote(installTarget)} --omit=dev --no-save --save=false --package-lock=false --prefer-online`,
191
- {
192
- cwd: runtimeDir,
193
- stdio: "inherit",
194
- timeout: 180000,
195
- },
196
- );
197
- } finally {
198
- packedSource?.cleanup?.();
199
- }
200
- const installedVersion = readManagedOpenclawRuntimeVersion({
201
- fsModule,
202
- runtimeDir,
203
- });
204
- applyManagedOpenclawPatch({
205
- execSyncImpl,
206
- fsModule,
207
- logger,
208
- runtimeDir,
209
- version: installedVersion,
210
- alphaclawRoot,
211
- });
212
- return {
213
- spec: normalizedSpec,
214
- version: installedVersion,
215
- };
216
- };
217
-
218
- const syncManagedOpenclawRuntimeWithBundled = ({
219
- execSyncImpl,
220
- fsModule = fs,
221
- logger = console,
222
- runtimeDir,
223
- resolveImpl,
224
- alphaclawRoot,
225
- } = {}) => {
226
- const bundledPackageRoot = getBundledOpenclawPackageRoot({
227
- fsModule,
228
- resolveImpl,
229
- });
230
- const bundledVersion = readBundledOpenclawVersion({
231
- fsModule,
232
- resolveImpl,
233
- });
234
- if (!bundledVersion) {
235
- return {
236
- checked: false,
237
- synced: false,
238
- bundledVersion: null,
239
- runtimeVersion: readManagedOpenclawRuntimeVersion({ fsModule, runtimeDir }),
240
- };
241
- }
242
-
243
- const runtimeVersion = readManagedOpenclawRuntimeVersion({
244
- fsModule,
245
- runtimeDir,
246
- });
247
- const runtimePackageRoot = getManagedOpenclawPackageRoot({ runtimeDir });
248
- const runtimePackageRootIsSymlink = isPackageRootSymlink({
249
- fsModule,
250
- packageRoot: runtimePackageRoot,
251
- });
252
- const bundledFingerprint = computePackageFingerprint({
253
- fsModule,
254
- packageRoot: bundledPackageRoot,
255
- });
256
- const runtimeFingerprint = computePackageFingerprint({
257
- fsModule,
258
- packageRoot: runtimePackageRoot,
259
- packageJsonPath: getManagedOpenclawPackageJsonPath({ runtimeDir }),
260
- });
261
- if (runtimeVersion && compareVersionParts(runtimeVersion, bundledVersion) >= 0) {
262
- if (
263
- compareVersionParts(runtimeVersion, bundledVersion) > 0 ||
264
- (!runtimePackageRootIsSymlink &&
265
- (!bundledFingerprint || runtimeFingerprint === bundledFingerprint))
266
- ) {
267
- return {
268
- checked: true,
269
- synced: false,
270
- bundledVersion,
271
- runtimeVersion,
272
- };
273
- }
274
- logger.log(
275
- runtimePackageRootIsSymlink
276
- ? `[alphaclaw] Managed OpenClaw runtime ${runtimeVersion} is symlinked to the bundled package; refreshing runtime...`
277
- : `[alphaclaw] Managed OpenClaw runtime ${runtimeVersion} differs from bundled ${bundledVersion}; refreshing runtime...`,
278
- );
279
- } else {
280
- logger.log(
281
- runtimeVersion
282
- ? `[alphaclaw] Managed OpenClaw runtime ${runtimeVersion} is older than bundled ${bundledVersion}; syncing runtime...`
283
- : `[alphaclaw] Managed OpenClaw runtime missing; seeding bundled OpenClaw ${bundledVersion}...`,
284
- );
285
- }
286
-
287
- const installResult = installManagedOpenclawRuntime({
288
- execSyncImpl,
289
- fsModule,
290
- logger,
291
- runtimeDir,
292
- sourcePath: bundledPackageRoot,
293
- alphaclawRoot,
294
- });
295
- return {
296
- checked: true,
297
- synced: true,
298
- bundledVersion,
299
- runtimeVersion: installResult.version || bundledVersion,
300
- };
301
- };
302
-
303
- const prependManagedOpenclawBinToPath = ({
304
- env = process.env,
305
- fsModule = fs,
306
- logger = console,
307
- runtimeDir,
308
- } = {}) => {
309
- const resolvedRuntimeDir = runtimeDir || getManagedOpenclawRuntimeDir();
310
- const binDir = getManagedOpenclawBinDir({ runtimeDir: resolvedRuntimeDir });
311
- const binPath = getManagedOpenclawBinPath({ runtimeDir: resolvedRuntimeDir });
312
- if (!fsModule.existsSync(binPath)) {
313
- return false;
314
- }
315
- const currentEntries = String(env.PATH || "")
316
- .split(path.delimiter)
317
- .filter(Boolean);
318
- const nextEntries = [binDir, ...currentEntries.filter((entry) => entry !== binDir)];
319
- env.PATH = nextEntries.join(path.delimiter);
320
- logger.log(`[alphaclaw] Using managed OpenClaw runtime from ${resolvedRuntimeDir}`);
321
- return true;
322
- };
323
-
324
- module.exports = {
325
- applyManagedOpenclawPatch,
326
- ensureManagedOpenclawRuntimeProject,
327
- getBundledOpenclawPackageRoot,
328
- getManagedOpenclawBinDir,
329
- getManagedOpenclawBinPath,
330
- getManagedOpenclawPackageRoot,
331
- getManagedOpenclawPackageJsonPath,
332
- getManagedOpenclawRuntimeDir,
333
- installManagedOpenclawRuntime,
334
- prependManagedOpenclawBinToPath,
335
- readBundledOpenclawVersion,
336
- readManagedOpenclawRuntimeVersion,
337
- syncManagedOpenclawRuntimeWithBundled,
338
- };