@chrysb/alphaclaw 0.8.7-beta.5 → 0.8.7-beta.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.
|
@@ -20,6 +20,7 @@ import { showToast } from "../components/toast.js";
|
|
|
20
20
|
|
|
21
21
|
export const useAppShellController = ({ location = "" } = {}) => {
|
|
22
22
|
const kInitialStatusPollDelayMs = 5000;
|
|
23
|
+
const kOpenclawUpdateRestartTimeoutMs = 5 * 60 * 1000;
|
|
23
24
|
const [onboarded, setOnboarded] = useState(null);
|
|
24
25
|
const [authEnabled, setAuthEnabled] = useState(false);
|
|
25
26
|
const [acVersion, setAcVersion] = useState(null);
|
|
@@ -249,7 +250,10 @@ export const useAppShellController = ({ location = "" } = {}) => {
|
|
|
249
250
|
const data = await updateOpenclaw();
|
|
250
251
|
if (data?.ok && data?.restarting) {
|
|
251
252
|
setOpenclawRestarting(true);
|
|
252
|
-
await waitForAlphaclawRestart(
|
|
253
|
+
await waitForAlphaclawRestart({
|
|
254
|
+
timeoutMs: kOpenclawUpdateRestartTimeoutMs,
|
|
255
|
+
timeoutErrorMessage: "OpenClaw update is taking longer than expected",
|
|
256
|
+
});
|
|
253
257
|
window.location.reload();
|
|
254
258
|
return { ...data, restartHandled: true };
|
|
255
259
|
}
|
package/lib/public/js/lib/api.js
CHANGED
|
@@ -536,6 +536,7 @@ export async function waitForAlphaclawRestart({
|
|
|
536
536
|
initialDelayMs = 1500,
|
|
537
537
|
intervalMs = 1000,
|
|
538
538
|
timeoutMs = 60000,
|
|
539
|
+
timeoutErrorMessage = "AlphaClaw restart is taking longer than expected",
|
|
539
540
|
} = {}) {
|
|
540
541
|
const deadline = Date.now() + Math.max(0, Number(timeoutMs) || 0);
|
|
541
542
|
await delay(initialDelayMs);
|
|
@@ -559,7 +560,7 @@ export async function waitForAlphaclawRestart({
|
|
|
559
560
|
await delay(intervalMs);
|
|
560
561
|
}
|
|
561
562
|
|
|
562
|
-
throw new Error("AlphaClaw restart is taking longer than expected");
|
|
563
|
+
throw new Error(String(timeoutErrorMessage || "AlphaClaw restart is taking longer than expected"));
|
|
563
564
|
}
|
|
564
565
|
|
|
565
566
|
export async function fetchSyncCron() {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
|
+
const os = require("os");
|
|
2
3
|
const path = require("path");
|
|
3
4
|
|
|
4
5
|
const { kRootDir } = require("./constants");
|
|
@@ -156,6 +157,84 @@ const applyManagedOpenclawPatch = ({
|
|
|
156
157
|
return true;
|
|
157
158
|
};
|
|
158
159
|
|
|
160
|
+
const kDisableBundledPluginPostinstallEnv =
|
|
161
|
+
"OPENCLAW_DISABLE_BUNDLED_PLUGIN_POSTINSTALL";
|
|
162
|
+
const kBundledPluginPostinstallFailureMarker =
|
|
163
|
+
"[postinstall] could not install bundled plugin deps:";
|
|
164
|
+
|
|
165
|
+
const runManagedOpenclawBundledPluginPostinstall = ({
|
|
166
|
+
execSyncImpl,
|
|
167
|
+
fsModule = fs,
|
|
168
|
+
logger = console,
|
|
169
|
+
runtimeDir,
|
|
170
|
+
} = {}) => {
|
|
171
|
+
const packageRoot = getManagedOpenclawPackageRoot({ runtimeDir });
|
|
172
|
+
const postinstallScriptPath = path.join(
|
|
173
|
+
packageRoot,
|
|
174
|
+
"scripts",
|
|
175
|
+
"postinstall-bundled-plugins.mjs",
|
|
176
|
+
);
|
|
177
|
+
if (!fsModule.existsSync(postinstallScriptPath)) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
const env = { ...process.env };
|
|
181
|
+
delete env[kDisableBundledPluginPostinstallEnv];
|
|
182
|
+
const logDir = fsModule.mkdtempSync(
|
|
183
|
+
path.join(os.tmpdir(), "openclaw-bundled-postinstall-"),
|
|
184
|
+
);
|
|
185
|
+
const logPath = path.join(logDir, "postinstall.log");
|
|
186
|
+
let commandError = null;
|
|
187
|
+
let output = "";
|
|
188
|
+
let stdoutFd;
|
|
189
|
+
let stderrFd;
|
|
190
|
+
try {
|
|
191
|
+
stdoutFd = fsModule.openSync(logPath, "a");
|
|
192
|
+
stderrFd = fsModule.openSync(logPath, "a");
|
|
193
|
+
try {
|
|
194
|
+
execSyncImpl(
|
|
195
|
+
`${shellQuote(process.execPath)} ${shellQuote(postinstallScriptPath)}`,
|
|
196
|
+
{
|
|
197
|
+
cwd: packageRoot,
|
|
198
|
+
env,
|
|
199
|
+
stdio: ["ignore", stdoutFd, stderrFd],
|
|
200
|
+
timeout: 180000,
|
|
201
|
+
},
|
|
202
|
+
);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
commandError = error;
|
|
205
|
+
}
|
|
206
|
+
} finally {
|
|
207
|
+
if (typeof stdoutFd === "number") {
|
|
208
|
+
try {
|
|
209
|
+
fsModule.closeSync(stdoutFd);
|
|
210
|
+
} catch {}
|
|
211
|
+
}
|
|
212
|
+
if (typeof stderrFd === "number") {
|
|
213
|
+
try {
|
|
214
|
+
fsModule.closeSync(stderrFd);
|
|
215
|
+
} catch {}
|
|
216
|
+
}
|
|
217
|
+
try {
|
|
218
|
+
output = String(fsModule.readFileSync(logPath, "utf8") || "").trim();
|
|
219
|
+
} catch {
|
|
220
|
+
output = "";
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
fsModule.rmSync(logDir, { recursive: true, force: true });
|
|
224
|
+
} catch {}
|
|
225
|
+
}
|
|
226
|
+
if (output) {
|
|
227
|
+
logger.log(output);
|
|
228
|
+
}
|
|
229
|
+
if (output.includes(kBundledPluginPostinstallFailureMarker)) {
|
|
230
|
+
throw new Error(output);
|
|
231
|
+
}
|
|
232
|
+
if (commandError) {
|
|
233
|
+
throw commandError;
|
|
234
|
+
}
|
|
235
|
+
return true;
|
|
236
|
+
};
|
|
237
|
+
|
|
159
238
|
const installManagedOpenclawRuntime = ({
|
|
160
239
|
execSyncImpl,
|
|
161
240
|
fsModule = fs,
|
|
@@ -190,6 +269,10 @@ const installManagedOpenclawRuntime = ({
|
|
|
190
269
|
`npm install ${shellQuote(installTarget)} --omit=dev --no-save --save=false --package-lock=false --prefer-online`,
|
|
191
270
|
{
|
|
192
271
|
cwd: runtimeDir,
|
|
272
|
+
env: {
|
|
273
|
+
...process.env,
|
|
274
|
+
[kDisableBundledPluginPostinstallEnv]: "1",
|
|
275
|
+
},
|
|
193
276
|
stdio: "inherit",
|
|
194
277
|
timeout: 180000,
|
|
195
278
|
},
|
|
@@ -197,6 +280,12 @@ const installManagedOpenclawRuntime = ({
|
|
|
197
280
|
} finally {
|
|
198
281
|
packedSource?.cleanup?.();
|
|
199
282
|
}
|
|
283
|
+
runManagedOpenclawBundledPluginPostinstall({
|
|
284
|
+
execSyncImpl,
|
|
285
|
+
fsModule,
|
|
286
|
+
logger,
|
|
287
|
+
runtimeDir,
|
|
288
|
+
});
|
|
200
289
|
const installedVersion = readManagedOpenclawRuntimeVersion({
|
|
201
290
|
fsModule,
|
|
202
291
|
runtimeDir,
|
|
@@ -334,5 +423,6 @@ module.exports = {
|
|
|
334
423
|
prependManagedOpenclawBinToPath,
|
|
335
424
|
readBundledOpenclawVersion,
|
|
336
425
|
readManagedOpenclawRuntimeVersion,
|
|
426
|
+
runManagedOpenclawBundledPluginPostinstall,
|
|
337
427
|
syncManagedOpenclawRuntimeWithBundled,
|
|
338
428
|
};
|