mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 13:21:25 +00:00
fix(update): harden global updates
This commit is contained in:
@@ -152,5 +152,14 @@ describe("gateway tool", () => {
|
||||
sessionKey: "agent:main:whatsapp:dm:+15555550123",
|
||||
}),
|
||||
);
|
||||
const updateCall = vi
|
||||
.mocked(callGatewayTool)
|
||||
.mock.calls.find((call) => call[0] === "update.run");
|
||||
expect(updateCall).toBeDefined();
|
||||
if (updateCall) {
|
||||
const [, opts, params] = updateCall;
|
||||
expect(opts).toMatchObject({ timeoutMs: 20 * 60_000 });
|
||||
expect(params).toMatchObject({ timeoutMs: 20 * 60_000 });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,6 +12,8 @@ import { stringEnum } from "../schema/typebox.js";
|
||||
import { type AnyAgentTool, jsonResult, readStringParam } from "./common.js";
|
||||
import { callGatewayTool } from "./gateway.js";
|
||||
|
||||
const DEFAULT_UPDATE_TIMEOUT_MS = 20 * 60_000;
|
||||
|
||||
function resolveBaseHashFromSnapshot(snapshot: unknown): string | undefined {
|
||||
if (!snapshot || typeof snapshot !== "object") {
|
||||
return undefined;
|
||||
@@ -233,11 +235,15 @@ export function createGatewayTool(opts?: {
|
||||
typeof params.restartDelayMs === "number" && Number.isFinite(params.restartDelayMs)
|
||||
? Math.floor(params.restartDelayMs)
|
||||
: undefined;
|
||||
const result = await callGatewayTool("update.run", gatewayOpts, {
|
||||
const updateGatewayOpts = {
|
||||
...gatewayOpts,
|
||||
timeoutMs: timeoutMs ?? DEFAULT_UPDATE_TIMEOUT_MS,
|
||||
};
|
||||
const result = await callGatewayTool("update.run", updateGatewayOpts, {
|
||||
sessionKey,
|
||||
note,
|
||||
restartDelayMs,
|
||||
timeoutMs,
|
||||
timeoutMs: timeoutMs ?? DEFAULT_UPDATE_TIMEOUT_MS,
|
||||
});
|
||||
return jsonResult({ ok: true, result });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user