diff --git a/src/agents/clawdbot-tools.ts b/src/agents/clawdbot-tools.ts index e09be5c63..e0544e9a9 100644 --- a/src/agents/clawdbot-tools.ts +++ b/src/agents/clawdbot-tools.ts @@ -44,11 +44,13 @@ export function createClawdbotTools(options?: { /** Mutable ref to track if a reply was sent (for "first" mode). */ hasRepliedRef?: { value: boolean }; }): AnyAgentTool[] { - const imageTool = createImageTool({ - config: options?.config, - agentDir: options?.agentDir, - sandboxRoot: options?.sandboxRoot, - }); + const imageTool = options?.agentDir?.trim() + ? createImageTool({ + config: options?.config, + agentDir: options.agentDir, + sandboxRoot: options?.sandboxRoot, + }) + : null; const memorySearchTool = createMemorySearchTool({ config: options?.config, agentSessionKey: options?.agentSessionKey, diff --git a/src/agents/pi-embedded-runner.test.ts b/src/agents/pi-embedded-runner.test.ts index e6776c812..c1036f870 100644 --- a/src/agents/pi-embedded-runner.test.ts +++ b/src/agents/pi-embedded-runner.test.ts @@ -703,45 +703,49 @@ describe("runEmbeddedPiAgent", () => { ).resolves.toBeTruthy(); }); - it("persists the first user message before assistant output", async () => { - const agentDir = await fs.mkdtemp( - path.join(os.tmpdir(), "clawdbot-agent-"), - ); - const workspaceDir = await fs.mkdtemp( - path.join(os.tmpdir(), "clawdbot-workspace-"), - ); - const sessionFile = path.join(workspaceDir, "session.jsonl"); + it( + "persists the first user message before assistant output", + { timeout: 15_000 }, + async () => { + const agentDir = await fs.mkdtemp( + path.join(os.tmpdir(), "clawdbot-agent-"), + ); + const workspaceDir = await fs.mkdtemp( + path.join(os.tmpdir(), "clawdbot-workspace-"), + ); + const sessionFile = path.join(workspaceDir, "session.jsonl"); - const cfg = makeOpenAiConfig(["mock-1"]); - await ensureModels(cfg, agentDir); + const cfg = makeOpenAiConfig(["mock-1"]); + await ensureModels(cfg, agentDir); - await runEmbeddedPiAgent({ - sessionId: "session:test", - sessionKey: "agent:main:main", - sessionFile, - workspaceDir, - config: cfg, - prompt: "hello", - provider: "openai", - model: "mock-1", - timeoutMs: 5_000, - agentDir, - }); + await runEmbeddedPiAgent({ + sessionId: "session:test", + sessionKey: "agent:main:main", + sessionFile, + workspaceDir, + config: cfg, + prompt: "hello", + provider: "openai", + model: "mock-1", + timeoutMs: 5_000, + agentDir, + }); - const messages = await readSessionMessages(sessionFile); - const firstUserIndex = messages.findIndex( - (message) => - message?.role === "user" && - textFromContent(message.content) === "hello", - ); - const firstAssistantIndex = messages.findIndex( - (message) => message?.role === "assistant", - ); - expect(firstUserIndex).toBeGreaterThanOrEqual(0); - if (firstAssistantIndex !== -1) { - expect(firstUserIndex).toBeLessThan(firstAssistantIndex); - } - }, 15_000); + const messages = await readSessionMessages(sessionFile); + const firstUserIndex = messages.findIndex( + (message) => + message?.role === "user" && + textFromContent(message.content) === "hello", + ); + const firstAssistantIndex = messages.findIndex( + (message) => message?.role === "assistant", + ); + expect(firstUserIndex).toBeGreaterThanOrEqual(0); + if (firstAssistantIndex !== -1) { + expect(firstUserIndex).toBeLessThan(firstAssistantIndex); + } + }, + ); it("persists the user message when prompt fails before assistant output", async () => { const agentDir = await fs.mkdtemp( diff --git a/src/cli/models-cli.test.ts b/src/cli/models-cli.test.ts index 32614f31d..73f508913 100644 --- a/src/cli/models-cli.test.ts +++ b/src/cli/models-cli.test.ts @@ -14,35 +14,39 @@ vi.mock("../commands/models.js", async () => { }); describe("models cli", () => { - it("registers github-copilot login command", async () => { - const { Command } = await import("commander"); - const { registerModelsCli } = await import("./models-cli.js"); + it( + "registers github-copilot login command", + { timeout: 15_000 }, + async () => { + const { Command } = await import("commander"); + const { registerModelsCli } = await import("./models-cli.js"); - const program = new Command(); - registerModelsCli(program); + const program = new Command(); + registerModelsCli(program); - const models = program.commands.find((cmd) => cmd.name() === "models"); - expect(models).toBeTruthy(); + const models = program.commands.find((cmd) => cmd.name() === "models"); + expect(models).toBeTruthy(); - const auth = models?.commands.find((cmd) => cmd.name() === "auth"); - expect(auth).toBeTruthy(); + const auth = models?.commands.find((cmd) => cmd.name() === "auth"); + expect(auth).toBeTruthy(); - const login = auth?.commands.find( - (cmd) => cmd.name() === "login-github-copilot", - ); - expect(login).toBeTruthy(); + const login = auth?.commands.find( + (cmd) => cmd.name() === "login-github-copilot", + ); + expect(login).toBeTruthy(); - await program.parseAsync( - ["models", "auth", "login-github-copilot", "--yes"], - { - from: "user", - }, - ); + await program.parseAsync( + ["models", "auth", "login-github-copilot", "--yes"], + { + from: "user", + }, + ); - expect(githubCopilotLoginCommand).toHaveBeenCalledTimes(1); - expect(githubCopilotLoginCommand).toHaveBeenCalledWith( - expect.objectContaining({ yes: true }), - expect.any(Object), - ); - }, 15_000); + expect(githubCopilotLoginCommand).toHaveBeenCalledTimes(1); + expect(githubCopilotLoginCommand).toHaveBeenCalledWith( + expect.objectContaining({ yes: true }), + expect.any(Object), + ); + }, + ); }); diff --git a/src/commands/doctor.test.ts b/src/commands/doctor.test.ts index ad67cc85c..bafbe8481 100644 --- a/src/commands/doctor.test.ts +++ b/src/commands/doctor.test.ts @@ -325,7 +325,7 @@ vi.mock("./doctor-state-migrations.js", () => ({ describe("doctor", () => { it( "migrates routing.allowFrom to whatsapp.allowFrom", - { timeout: 15_000 }, + { timeout: 30_000 }, async () => { readConfigFileSnapshot.mockResolvedValue({ path: "/tmp/clawdbot.json",