Config: newline-join sandbox setupCommand arrays (#31953)

This commit is contained in:
Mark L
2026-03-03 02:11:32 +08:00
committed by GitHub
parent 8b27582509
commit 9b8e642475
4 changed files with 26 additions and 2 deletions

View File

@@ -7,6 +7,26 @@ import {
import { validateConfigObject } from "./config.js";
describe("sandbox docker config", () => {
it("joins setupCommand arrays with newlines", () => {
const res = validateConfigObject({
agents: {
defaults: {
sandbox: {
docker: {
setupCommand: ["apt-get update", "apt-get install -y curl"],
},
},
},
},
});
expect(res.ok).toBe(true);
if (res.ok) {
expect(res.config.agents?.defaults?.sandbox?.docker?.setupCommand).toBe(
"apt-get update\napt-get install -y curl",
);
}
});
it("accepts safe binds array in sandbox.docker config", () => {
const res = validateConfigObject({
agents: {

View File

@@ -17,7 +17,7 @@ export type SandboxDockerSettings = {
capDrop?: string[];
/** Extra environment variables for sandbox exec. */
env?: Record<string, string>;
/** Optional setup command run once after container creation. */
/** Optional setup command run once after container creation (array entries are joined by newline). */
setupCommand?: string;
/** Limit container PIDs (0 = Docker default). */
pidsLimit?: number;

View File

@@ -102,7 +102,10 @@ export const SandboxDockerSchema = z
user: z.string().optional(),
capDrop: z.array(z.string()).optional(),
env: z.record(z.string(), z.string()).optional(),
setupCommand: z.string().optional(),
setupCommand: z
.union([z.string(), z.array(z.string())])
.transform((value) => (Array.isArray(value) ? value.join("\n") : value))
.optional(),
pidsLimit: z.number().int().positive().optional(),
memory: z.union([z.string(), z.number()]).optional(),
memorySwap: z.union([z.string(), z.number()]).optional(),