fix(update): harden global updates

This commit is contained in:
Peter Steinberger
2026-02-02 04:44:35 -08:00
parent 6b0d6e2540
commit 57d008a33d
7 changed files with 122 additions and 3 deletions

View File

@@ -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 });
}
});
});

View File

@@ -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 });
}