@chrysb/alphaclaw 0.8.7-beta.6 → 0.8.7-beta.8
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");
|
|
@@ -178,24 +179,59 @@ const runManagedOpenclawBundledPluginPostinstall = ({
|
|
|
178
179
|
}
|
|
179
180
|
const env = { ...process.env };
|
|
180
181
|
delete env[kDisableBundledPluginPostinstallEnv];
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
+
}
|
|
193
226
|
if (output) {
|
|
194
227
|
logger.log(output);
|
|
195
228
|
}
|
|
196
229
|
if (output.includes(kBundledPluginPostinstallFailureMarker)) {
|
|
197
230
|
throw new Error(output);
|
|
198
231
|
}
|
|
232
|
+
if (commandError) {
|
|
233
|
+
throw commandError;
|
|
234
|
+
}
|
|
199
235
|
return true;
|
|
200
236
|
};
|
|
201
237
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { execFileSync } = require("child_process");
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const path = require("path");
|
|
4
4
|
const {
|
|
@@ -7,6 +7,7 @@ const {
|
|
|
7
7
|
kRootDir,
|
|
8
8
|
} = require("./constants");
|
|
9
9
|
const { normalizeOpenclawVersion } = require("./helpers");
|
|
10
|
+
const { getManagedOpenclawBinPath } = require("./openclaw-runtime");
|
|
10
11
|
const { parseJsonObjectFromNoisyOutput } = require("./utils/json");
|
|
11
12
|
|
|
12
13
|
const createOpenclawVersionService = ({
|
|
@@ -25,6 +26,11 @@ const createOpenclawVersionService = ({
|
|
|
25
26
|
const buildOpenclawInstallSpec = (version = "latest") =>
|
|
26
27
|
`openclaw@${String(version || "").trim() || "latest"}`;
|
|
27
28
|
|
|
29
|
+
const getOpenclawCommandPath = () => {
|
|
30
|
+
const managedBinPath = getManagedOpenclawBinPath();
|
|
31
|
+
return fs.existsSync(managedBinPath) ? managedBinPath : "openclaw";
|
|
32
|
+
};
|
|
33
|
+
|
|
28
34
|
const readOpenclawVersion = () => {
|
|
29
35
|
const now = Date.now();
|
|
30
36
|
if (
|
|
@@ -34,9 +40,9 @@ const createOpenclawVersionService = ({
|
|
|
34
40
|
return kOpenclawVersionCache.value;
|
|
35
41
|
}
|
|
36
42
|
try {
|
|
37
|
-
const raw =
|
|
43
|
+
const raw = execFileSync(getOpenclawCommandPath(), ["--version"], {
|
|
38
44
|
env: gatewayEnv(),
|
|
39
|
-
timeout:
|
|
45
|
+
timeout: 10000,
|
|
40
46
|
encoding: "utf8",
|
|
41
47
|
}).trim();
|
|
42
48
|
const version = normalizeOpenclawVersion(raw);
|
|
@@ -60,11 +66,16 @@ const createOpenclawVersionService = ({
|
|
|
60
66
|
};
|
|
61
67
|
}
|
|
62
68
|
try {
|
|
63
|
-
const raw =
|
|
69
|
+
const raw = execFileSync(
|
|
70
|
+
getOpenclawCommandPath(),
|
|
71
|
+
["update", "status", "--json"],
|
|
72
|
+
{
|
|
64
73
|
env: gatewayEnv(),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
timeout: 30000,
|
|
75
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
76
|
+
encoding: "utf8",
|
|
77
|
+
},
|
|
78
|
+
).trim();
|
|
68
79
|
const parsed = parseJsonObjectFromNoisyOutput(raw);
|
|
69
80
|
if (!parsed) {
|
|
70
81
|
throw new Error("openclaw update status returned invalid JSON payload");
|