@chrysb/alphaclaw 0.8.8 → 0.8.9

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 (30) 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 +2089 -2109
  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 -37
  16. package/lib/public/js/lib/api.js +0 -36
  17. package/lib/server/alphaclaw-version.js +128 -37
  18. package/lib/server/gateway.js +14 -32
  19. package/lib/server/init/register-server-routes.js +1 -7
  20. package/lib/server/openclaw-version.js +136 -76
  21. package/lib/server/routes/pages.js +1 -9
  22. package/lib/server/routes/system.js +1 -6
  23. package/lib/server/usage-tracker-config.js +3 -27
  24. package/package.json +1 -1
  25. package/lib/public/js/components/update-modal-helpers.js +0 -12
  26. package/lib/server/alphaclaw-runtime.js +0 -294
  27. package/lib/server/openclaw-runtime.js +0 -428
  28. package/lib/server/package-fingerprint.js +0 -274
  29. package/lib/server/pending-alphaclaw-update.js +0 -85
  30. package/lib/server/pending-openclaw-update.js +0 -86
@@ -1,12 +0,0 @@
1
- export const createUpdateModalSubmitHandler = ({
2
- onClose = () => {},
3
- onUpdate = async () => ({ ok: false }),
4
- }) => {
5
- return async () => {
6
- const result = await onUpdate();
7
- if (result?.ok) {
8
- onClose();
9
- }
10
- return result;
11
- };
12
- };
@@ -1,294 +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
- seedRuntimeFromBundledInstall,
11
- } = require("./package-fingerprint");
12
-
13
- const getManagedAlphaclawRuntimeDir = ({ rootDir = kRootDir } = {}) =>
14
- path.join(rootDir, ".alphaclaw-runtime");
15
-
16
- const getBundledAlphaclawPackageRoot = () => path.resolve(__dirname, "..", "..");
17
-
18
- const getManagedAlphaclawPackageRoot = ({ runtimeDir } = {}) =>
19
- path.join(
20
- runtimeDir || getManagedAlphaclawRuntimeDir(),
21
- "node_modules",
22
- "@chrysb",
23
- "alphaclaw",
24
- );
25
-
26
- const getManagedAlphaclawCliPath = ({ runtimeDir } = {}) =>
27
- path.join(
28
- getManagedAlphaclawPackageRoot({ runtimeDir }),
29
- "bin",
30
- "alphaclaw.js",
31
- );
32
-
33
- const getManagedAlphaclawPackageJsonPath = ({ runtimeDir } = {}) =>
34
- path.join(
35
- getManagedAlphaclawPackageRoot({ runtimeDir }),
36
- "package.json",
37
- );
38
-
39
- const ensureManagedAlphaclawRuntimeProject = ({
40
- fsModule = fs,
41
- runtimeDir,
42
- } = {}) => {
43
- const resolvedRuntimeDir = runtimeDir || getManagedAlphaclawRuntimeDir();
44
- const packageJsonPath = path.join(resolvedRuntimeDir, "package.json");
45
- fsModule.mkdirSync(resolvedRuntimeDir, { recursive: true });
46
- if (!fsModule.existsSync(packageJsonPath)) {
47
- fsModule.writeFileSync(
48
- packageJsonPath,
49
- JSON.stringify(
50
- {
51
- name: "alphaclaw-runtime",
52
- private: true,
53
- },
54
- null,
55
- 2,
56
- ),
57
- );
58
- }
59
- return {
60
- runtimeDir: resolvedRuntimeDir,
61
- packageJsonPath,
62
- };
63
- };
64
-
65
- const readManagedAlphaclawRuntimeVersion = ({
66
- fsModule = fs,
67
- runtimeDir,
68
- } = {}) => {
69
- try {
70
- const pkg = JSON.parse(
71
- fsModule.readFileSync(
72
- getManagedAlphaclawPackageJsonPath({ runtimeDir }),
73
- "utf8",
74
- ),
75
- );
76
- return String(pkg?.version || "").trim() || null;
77
- } catch {
78
- return null;
79
- }
80
- };
81
-
82
- const readBundledAlphaclawVersion = ({
83
- fsModule = fs,
84
- packageJsonPath = path.resolve(__dirname, "..", "..", "package.json"),
85
- } = {}) => {
86
- try {
87
- const pkg = JSON.parse(fsModule.readFileSync(packageJsonPath, "utf8"));
88
- return String(pkg?.version || "").trim() || null;
89
- } catch {
90
- return null;
91
- }
92
- };
93
-
94
- const shellQuote = (value) =>
95
- `'${String(value || "").replace(/'/g, `'\"'\"'`)}'`;
96
-
97
- const installManagedAlphaclawRuntime = ({
98
- execSyncImpl,
99
- fsModule = fs,
100
- runtimeDir,
101
- spec,
102
- sourcePath,
103
- } = {}) => {
104
- const normalizedSourcePath = String(sourcePath || "").trim();
105
- const normalizedSpec = normalizedSourcePath
106
- ? normalizedSourcePath
107
- : String(spec || "").trim() || "@chrysb/alphaclaw@latest";
108
- ensureManagedAlphaclawRuntimeProject({
109
- fsModule,
110
- runtimeDir,
111
- });
112
- let packedSource = null;
113
- try {
114
- const installTarget = normalizedSourcePath
115
- ? (() => {
116
- packedSource = packLocalPackageForInstall({
117
- execSyncImpl,
118
- fsModule,
119
- packageRoot: normalizedSourcePath,
120
- tempDirPrefix: "alphaclaw-runtime-pack-",
121
- });
122
- return packedSource.tarballPath;
123
- })()
124
- : normalizedSpec;
125
- execSyncImpl(
126
- `npm install ${shellQuote(installTarget)} --omit=dev --no-save --save=false --package-lock=false --prefer-online`,
127
- {
128
- cwd: runtimeDir,
129
- stdio: "inherit",
130
- timeout: 180000,
131
- },
132
- );
133
- } finally {
134
- packedSource?.cleanup?.();
135
- }
136
- return {
137
- spec: normalizedSpec,
138
- version: readManagedAlphaclawRuntimeVersion({
139
- fsModule,
140
- runtimeDir,
141
- }),
142
- };
143
- };
144
-
145
- const seedManagedAlphaclawRuntimeFromBundledInstall = ({
146
- fsModule = fs,
147
- logger = console,
148
- runtimeDir,
149
- packageRoot,
150
- } = {}) => {
151
- const seedResult = seedRuntimeFromBundledInstall({
152
- fsModule,
153
- packageRoot,
154
- runtimeDir,
155
- runtimePackageJson: {
156
- name: "alphaclaw-runtime",
157
- private: true,
158
- },
159
- });
160
- if (!seedResult.seeded) {
161
- return {
162
- seeded: false,
163
- version: null,
164
- };
165
- }
166
- logger.log("[alphaclaw] Seeded managed AlphaClaw runtime from bundled node_modules");
167
- return {
168
- seeded: true,
169
- version: readManagedAlphaclawRuntimeVersion({
170
- fsModule,
171
- runtimeDir,
172
- }),
173
- };
174
- };
175
-
176
- const syncManagedAlphaclawRuntimeWithBundled = ({
177
- execSyncImpl,
178
- fsModule = fs,
179
- logger = console,
180
- runtimeDir,
181
- packageRoot = getBundledAlphaclawPackageRoot(),
182
- packageJsonPath,
183
- } = {}) => {
184
- const bundledVersion = readBundledAlphaclawVersion({
185
- fsModule,
186
- packageJsonPath: packageJsonPath || path.join(packageRoot, "package.json"),
187
- });
188
- if (!bundledVersion) {
189
- return {
190
- checked: false,
191
- synced: false,
192
- bundledVersion: null,
193
- runtimeVersion: readManagedAlphaclawRuntimeVersion({
194
- fsModule,
195
- runtimeDir,
196
- }),
197
- };
198
- }
199
-
200
- const runtimeVersion = readManagedAlphaclawRuntimeVersion({
201
- fsModule,
202
- runtimeDir,
203
- });
204
- const runtimePackageRoot = getManagedAlphaclawPackageRoot({ runtimeDir });
205
- const runtimePackageRootIsSymlink = isPackageRootSymlink({
206
- fsModule,
207
- packageRoot: runtimePackageRoot,
208
- });
209
- const bundledFingerprint = computePackageFingerprint({
210
- fsModule,
211
- packageRoot,
212
- packageJsonPath: packageJsonPath || path.join(packageRoot, "package.json"),
213
- });
214
- const runtimeFingerprint = computePackageFingerprint({
215
- fsModule,
216
- packageRoot: runtimePackageRoot,
217
- packageJsonPath: getManagedAlphaclawPackageJsonPath({ runtimeDir }),
218
- });
219
- if (runtimeVersion && compareVersionParts(runtimeVersion, bundledVersion) >= 0) {
220
- if (
221
- compareVersionParts(runtimeVersion, bundledVersion) > 0 ||
222
- (!runtimePackageRootIsSymlink &&
223
- (!bundledFingerprint || runtimeFingerprint === bundledFingerprint))
224
- ) {
225
- return {
226
- checked: true,
227
- synced: false,
228
- bundledVersion,
229
- runtimeVersion,
230
- };
231
- }
232
- logger.log(
233
- runtimePackageRootIsSymlink
234
- ? `[alphaclaw] Managed AlphaClaw runtime ${runtimeVersion} is symlinked to the bundled package; refreshing runtime...`
235
- : `[alphaclaw] Managed AlphaClaw runtime ${runtimeVersion} differs from bundled ${bundledVersion}; refreshing runtime...`,
236
- );
237
- } else {
238
- logger.log(
239
- runtimeVersion
240
- ? `[alphaclaw] Managed AlphaClaw runtime ${runtimeVersion} is older than bundled ${bundledVersion}; syncing runtime...`
241
- : `[alphaclaw] Managed AlphaClaw runtime missing; seeding bundled AlphaClaw ${bundledVersion}...`,
242
- );
243
- }
244
-
245
- if (!runtimeVersion) {
246
- try {
247
- const seedResult = seedManagedAlphaclawRuntimeFromBundledInstall({
248
- fsModule,
249
- logger,
250
- runtimeDir,
251
- packageRoot,
252
- });
253
- if (seedResult.seeded) {
254
- return {
255
- checked: true,
256
- synced: true,
257
- bundledVersion,
258
- runtimeVersion: seedResult.version || bundledVersion,
259
- };
260
- }
261
- } catch (error) {
262
- logger.log(
263
- `[alphaclaw] Could not seed managed AlphaClaw runtime from bundled node_modules: ${error.message}`,
264
- );
265
- }
266
- }
267
-
268
- const installResult = installManagedAlphaclawRuntime({
269
- execSyncImpl,
270
- fsModule,
271
- runtimeDir,
272
- sourcePath: packageRoot,
273
- });
274
- return {
275
- checked: true,
276
- synced: true,
277
- bundledVersion,
278
- runtimeVersion: installResult.version || bundledVersion,
279
- };
280
- };
281
-
282
- module.exports = {
283
- ensureManagedAlphaclawRuntimeProject,
284
- getBundledAlphaclawPackageRoot,
285
- getManagedAlphaclawCliPath,
286
- getManagedAlphaclawPackageJsonPath,
287
- getManagedAlphaclawPackageRoot,
288
- getManagedAlphaclawRuntimeDir,
289
- installManagedAlphaclawRuntime,
290
- readBundledAlphaclawVersion,
291
- readManagedAlphaclawRuntimeVersion,
292
- seedManagedAlphaclawRuntimeFromBundledInstall,
293
- syncManagedAlphaclawRuntimeWithBundled,
294
- };