fix: relax image tool agentDir guard
This commit is contained in:
@@ -703,7 +703,9 @@ describe("runEmbeddedPiAgent", () => {
|
|||||||
).resolves.toBeTruthy();
|
).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(
|
const agentDir = await fs.mkdtemp(
|
||||||
path.join(os.tmpdir(), "clawdbot-agent-"),
|
path.join(os.tmpdir(), "clawdbot-agent-"),
|
||||||
);
|
);
|
||||||
@@ -741,7 +743,9 @@ describe("runEmbeddedPiAgent", () => {
|
|||||||
if (firstAssistantIndex !== -1) {
|
if (firstAssistantIndex !== -1) {
|
||||||
expect(firstUserIndex).toBeLessThan(firstAssistantIndex);
|
expect(firstUserIndex).toBeLessThan(firstAssistantIndex);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
15_000,
|
||||||
|
);
|
||||||
|
|
||||||
it("persists the user message when prompt fails before assistant output", async () => {
|
it("persists the user message when prompt fails before assistant output", async () => {
|
||||||
const agentDir = await fs.mkdtemp(
|
const agentDir = await fs.mkdtemp(
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ describe("sandbox explain helpers", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const resolved = resolveSandboxConfigForAgent(cfg, "work");
|
const resolved = resolveSandboxConfigForAgent(cfg, "work");
|
||||||
expect(resolved.tools.allow).toEqual(["write"]);
|
expect(resolved.tools.allow).toEqual(["write", "image"]);
|
||||||
expect(resolved.tools.deny).toEqual(["browser"]);
|
expect(resolved.tools.deny).toEqual(["browser"]);
|
||||||
|
|
||||||
const policy = resolveSandboxToolPolicyForAgent(cfg, "work");
|
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.sources.allow.source).toBe("agent");
|
||||||
expect(policy.deny).toEqual(["browser"]);
|
expect(policy.deny).toEqual(["browser"]);
|
||||||
expect(policy.sources.deny.source).toBe("global");
|
expect(policy.sources.deny.source).toBe("global");
|
||||||
|
|||||||
@@ -299,9 +299,13 @@ export function createImageTool(options?: {
|
|||||||
agentDir?: string;
|
agentDir?: string;
|
||||||
sandboxRoot?: string;
|
sandboxRoot?: string;
|
||||||
}): AnyAgentTool | null {
|
}): AnyAgentTool | null {
|
||||||
const agentDir = options?.agentDir;
|
const agentDir = options?.agentDir?.trim();
|
||||||
if (!agentDir?.trim()) {
|
if (!agentDir) {
|
||||||
throw new Error("createImageTool requires agentDir when enabled");
|
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({
|
const imageModelConfig = resolveImageModelConfigForTool({
|
||||||
cfg: options?.config,
|
cfg: options?.config,
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ vi.mock("../commands/models.js", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("models cli", () => {
|
describe("models cli", () => {
|
||||||
it("registers github-copilot login command", async () => {
|
it(
|
||||||
|
"registers github-copilot login command",
|
||||||
|
async () => {
|
||||||
const { Command } = await import("commander");
|
const { Command } = await import("commander");
|
||||||
const { registerModelsCli } = await import("./models-cli.js");
|
const { registerModelsCli } = await import("./models-cli.js");
|
||||||
|
|
||||||
@@ -44,5 +46,7 @@ describe("models cli", () => {
|
|||||||
expect.objectContaining({ yes: true }),
|
expect.objectContaining({ yes: true }),
|
||||||
expect.any(Object),
|
expect.any(Object),
|
||||||
);
|
);
|
||||||
});
|
},
|
||||||
|
15_000,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user