fix(openshell): cap command timeout config

This commit is contained in:
Peter Steinberger
2026-05-29 13:33:41 -04:00
parent 04de01f8cf
commit c36b2bf64e
3 changed files with 17 additions and 2 deletions

View File

@@ -56,7 +56,8 @@
},
"timeoutSeconds": {
"type": "number",
"minimum": 1
"minimum": 1,
"maximum": 2147000
}
}
},

View File

@@ -70,6 +70,14 @@ describe("openshell plugin config", () => {
).toThrow("mode must be one of mirror, remote");
});
it("rejects timeouts beyond Node's safe timer range", () => {
expect(() =>
resolveOpenShellPluginConfig({
timeoutSeconds: 2_147_001,
}),
).toThrow("timeoutSeconds must be a number <= 2147000");
});
it("keeps the runtime json schema in sync with the manifest config schema", () => {
const manifest = JSON.parse(
fsSync.readFileSync(new URL("../openclaw.plugin.json", import.meta.url), "utf8"),

View File

@@ -42,6 +42,7 @@ const DEFAULT_SOURCE = "openclaw";
const DEFAULT_REMOTE_WORKSPACE_DIR = "/sandbox";
const DEFAULT_REMOTE_AGENT_WORKSPACE_DIR = "/agent";
const DEFAULT_TIMEOUT_MS = 120_000;
const MAX_OPEN_SHELL_TIMEOUT_SECONDS = 2_147_000;
const OPEN_SHELL_MANAGED_REMOTE_ROOTS = [
DEFAULT_REMOTE_WORKSPACE_DIR,
DEFAULT_REMOTE_AGENT_WORKSPACE_DIR,
@@ -90,8 +91,13 @@ const OpenShellPluginConfigSchema = z.strictObject({
"remoteAgentWorkspaceDir must be a non-empty string",
).optional(),
timeoutSeconds: z
.number({ error: "timeoutSeconds must be a number >= 1" })
.number({
error: `timeoutSeconds must be a number between 1 and ${MAX_OPEN_SHELL_TIMEOUT_SECONDS}`,
})
.min(1, { error: "timeoutSeconds must be a number >= 1" })
.max(MAX_OPEN_SHELL_TIMEOUT_SECONDS, {
error: `timeoutSeconds must be a number <= ${MAX_OPEN_SHELL_TIMEOUT_SECONDS}`,
})
.optional(),
});