mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 16:14:58 +00:00
secrets: default exec no-output timeout to timeoutMs
This commit is contained in:
committed by
Peter Steinberger
parent
0b5d8e5b47
commit
be578b43d3
@@ -178,6 +178,44 @@ describe("secret ref resolver", () => {
|
|||||||
expect(value).toBe("value:openai/api-key");
|
expect(value).toBe("value:openai/api-key");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("uses timeoutMs as the default no-output timeout for exec providers", async () => {
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-secrets-resolve-exec-delay-"));
|
||||||
|
cleanupRoots.push(root);
|
||||||
|
const scriptPath = path.join(root, "resolver-delay.mjs");
|
||||||
|
await writeSecureFile(
|
||||||
|
scriptPath,
|
||||||
|
[
|
||||||
|
"#!/usr/bin/env node",
|
||||||
|
"setTimeout(() => {",
|
||||||
|
" process.stdout.write(JSON.stringify({ protocolVersion: 1, values: { delayed: 'ok' } }));",
|
||||||
|
"}, 2200);",
|
||||||
|
].join("\n"),
|
||||||
|
0o700,
|
||||||
|
);
|
||||||
|
|
||||||
|
const value = await resolveSecretRefString(
|
||||||
|
{ source: "exec", provider: "execmain", id: "delayed" },
|
||||||
|
{
|
||||||
|
config: {
|
||||||
|
secrets: {
|
||||||
|
providers: {
|
||||||
|
execmain: {
|
||||||
|
source: "exec",
|
||||||
|
command: scriptPath,
|
||||||
|
passEnv: ["PATH"],
|
||||||
|
timeoutMs: 5000,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
expect(value).toBe("ok");
|
||||||
|
});
|
||||||
|
|
||||||
it("supports non-JSON single-value exec output when jsonOnly is false", async () => {
|
it("supports non-JSON single-value exec output when jsonOnly is false", async () => {
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ const DEFAULT_MAX_BATCH_BYTES = 256 * 1024;
|
|||||||
const DEFAULT_FILE_MAX_BYTES = 1024 * 1024;
|
const DEFAULT_FILE_MAX_BYTES = 1024 * 1024;
|
||||||
const DEFAULT_FILE_TIMEOUT_MS = 5_000;
|
const DEFAULT_FILE_TIMEOUT_MS = 5_000;
|
||||||
const DEFAULT_EXEC_TIMEOUT_MS = 5_000;
|
const DEFAULT_EXEC_TIMEOUT_MS = 5_000;
|
||||||
const DEFAULT_EXEC_NO_OUTPUT_TIMEOUT_MS = 2_000;
|
|
||||||
const DEFAULT_EXEC_MAX_OUTPUT_BYTES = 1024 * 1024;
|
const DEFAULT_EXEC_MAX_OUTPUT_BYTES = 1024 * 1024;
|
||||||
const WINDOWS_ABS_PATH_PATTERN = /^[A-Za-z]:[\\/]/;
|
const WINDOWS_ABS_PATH_PATTERN = /^[A-Za-z]:[\\/]/;
|
||||||
const WINDOWS_UNC_PATH_PATTERN = /^\\\\[^\\]+\\[^\\]+/;
|
const WINDOWS_UNC_PATH_PATTERN = /^\\\\[^\\]+\\[^\\]+/;
|
||||||
@@ -539,7 +538,7 @@ async function resolveExecRefs(params: {
|
|||||||
const timeoutMs = normalizePositiveInt(params.providerConfig.timeoutMs, DEFAULT_EXEC_TIMEOUT_MS);
|
const timeoutMs = normalizePositiveInt(params.providerConfig.timeoutMs, DEFAULT_EXEC_TIMEOUT_MS);
|
||||||
const noOutputTimeoutMs = normalizePositiveInt(
|
const noOutputTimeoutMs = normalizePositiveInt(
|
||||||
params.providerConfig.noOutputTimeoutMs,
|
params.providerConfig.noOutputTimeoutMs,
|
||||||
DEFAULT_EXEC_NO_OUTPUT_TIMEOUT_MS,
|
timeoutMs,
|
||||||
);
|
);
|
||||||
const maxOutputBytes = normalizePositiveInt(
|
const maxOutputBytes = normalizePositiveInt(
|
||||||
params.providerConfig.maxOutputBytes,
|
params.providerConfig.maxOutputBytes,
|
||||||
|
|||||||
Reference in New Issue
Block a user