fix: relax image tool agentDir guard

This commit is contained in:
Peter Steinberger
2026-01-12 18:12:51 +00:00
parent 9526f9861a
commit 2ed95634fe
4 changed files with 21 additions and 9 deletions

View File

@@ -703,7 +703,9 @@ describe("runEmbeddedPiAgent", () => {
).resolves.toBeTruthy();
});
it("persists the first user message before assistant output", async () => {
it(
"persists the first user message before assistant output",
async () => {
const agentDir = await fs.mkdtemp(
path.join(os.tmpdir(), "clawdbot-agent-"),
);
@@ -741,7 +743,9 @@ describe("runEmbeddedPiAgent", () => {
if (firstAssistantIndex !== -1) {
expect(firstUserIndex).toBeLessThan(firstAssistantIndex);
}
});
},
15_000,
);
it("persists the user message when prompt fails before assistant output", async () => {
const agentDir = await fs.mkdtemp(

View File

@@ -25,11 +25,11 @@ describe("sandbox explain helpers", () => {
};
const resolved = resolveSandboxConfigForAgent(cfg, "work");
expect(resolved.tools.allow).toEqual(["write"]);
expect(resolved.tools.allow).toEqual(["write", "image"]);
expect(resolved.tools.deny).toEqual(["browser"]);
const policy = resolveSandboxToolPolicyForAgent(cfg, "work");
expect(policy.allow).toEqual(["write"]);
expect(policy.allow).toEqual(["write", "image"]);
expect(policy.sources.allow.source).toBe("agent");
expect(policy.deny).toEqual(["browser"]);
expect(policy.sources.deny.source).toBe("global");

View File

@@ -299,9 +299,13 @@ export function createImageTool(options?: {
agentDir?: string;
sandboxRoot?: string;
}): AnyAgentTool | null {
const agentDir = options?.agentDir;
if (!agentDir?.trim()) {
throw new Error("createImageTool requires agentDir when enabled");
const agentDir = options?.agentDir?.trim();
if (!agentDir) {
const explicit = coerceImageModelConfig(options?.config);
if (explicit.primary?.trim() || (explicit.fallbacks?.length ?? 0) > 0) {
throw new Error("createImageTool requires agentDir when enabled");
}
return null;
}
const imageModelConfig = resolveImageModelConfigForTool({
cfg: options?.config,

View File

@@ -14,7 +14,9 @@ vi.mock("../commands/models.js", async () => {
});
describe("models cli", () => {
it("registers github-copilot login command", async () => {
it(
"registers github-copilot login command",
async () => {
const { Command } = await import("commander");
const { registerModelsCli } = await import("./models-cli.js");
@@ -44,5 +46,7 @@ describe("models cli", () => {
expect.objectContaining({ yes: true }),
expect.any(Object),
);
});
},
15_000,
);
});