diff --git a/extensions/agentmail/src/tools.ts b/extensions/agentmail/src/tools.ts index ca4252c52..15b9f99d6 100644 --- a/extensions/agentmail/src/tools.ts +++ b/extensions/agentmail/src/tools.ts @@ -1,13 +1,18 @@ import type { ChannelAgentTool } from "clawdbot/plugin-sdk"; import { AgentMailToolkit } from "agentmail-toolkit/clawdbot"; -import { getAgentMailClient } from "./client.js"; +import { getResolvedCredentials } from "./client.js"; +import { AgentMailClient } from "agentmail"; /** * Returns all AgentMail agent tools. + * Returns empty array if AgentMail is not configured (no token). */ export function createAgentMailTools(): ChannelAgentTool[] { - const client = getAgentMailClient(); + const { apiKey } = getResolvedCredentials(); + if (!apiKey) return []; + + const client = new AgentMailClient({ apiKey }); const toolkit = new AgentMailToolkit(client); return toolkit.getTools(); }