diff --git a/agent/src/index.ts b/agent/src/index.ts index ca94768aab867..63bac8153e520 100644 --- a/agent/src/index.ts +++ b/agent/src/index.ts @@ -4,13 +4,14 @@ import { RedisClient } from "@elizaos/adapter-redis"; import { SqliteDatabaseAdapter } from "@elizaos/adapter-sqlite"; import { SupabaseDatabaseAdapter } from "@elizaos/adapter-supabase"; import { AutoClientInterface } from "@elizaos/client-auto"; -import { DiscordClientInterface } from "@elizaos/client-discord"; -import { InstagramClientInterface } from "@elizaos/client-instagram"; -import { LensAgentClient } from "@elizaos/client-lens"; -import { SlackClientInterface } from "@elizaos/client-slack"; +// Discord and other unused clients moved to dynamic imports to avoid startup crashes +// import { DiscordClientInterface } from "@elizaos/client-discord"; +// import { InstagramClientInterface } from "@elizaos/client-instagram"; +// import { LensAgentClient } from "@elizaos/client-lens"; +// import { SlackClientInterface } from "@elizaos/client-slack"; import { TelegramClientInterface } from "@elizaos/client-telegram"; import { TwitterClientInterface } from "@elizaos/client-twitter"; -import { FarcasterClientInterface } from "@elizaos/client-farcaster"; +// import { FarcasterClientInterface } from "@elizaos/client-farcaster"; import { DirectClient } from "@elizaos/client-direct"; // import { agentKitPlugin } from "@elizaos/plugin-agentkit"; // import { ReclaimAdapter } from "@elizaos/plugin-reclaim"; @@ -736,8 +737,13 @@ export async function initializeClients( } if (clientTypes.includes(Clients.DISCORD)) { - const discordClient = await DiscordClientInterface.start(runtime); - if (discordClient) clients.discord = discordClient; + try { + const { DiscordClientInterface } = await import("@elizaos/client-discord"); + const discordClient = await DiscordClientInterface.start(runtime); + if (discordClient) clients.discord = discordClient; + } catch (error) { + elizaLogger.error("Failed to load Discord client:", error.message); + } } if (clientTypes.includes(Clients.TELEGRAM)) { @@ -753,22 +759,33 @@ export async function initializeClients( } if (clientTypes.includes(Clients.INSTAGRAM)) { - const instagramClient = await InstagramClientInterface.start(runtime); - if (instagramClient) { - clients.instagram = instagramClient; + try { + const { InstagramClientInterface } = await import("@elizaos/client-instagram"); + const instagramClient = await InstagramClientInterface.start(runtime); + if (instagramClient) clients.instagram = instagramClient; + } catch (error) { + elizaLogger.error("Failed to load Instagram client:", error.message); } } if (clientTypes.includes(Clients.FARCASTER)) { - const farcasterClient = await FarcasterClientInterface.start(runtime); - if (farcasterClient) { - clients.farcaster = farcasterClient; + try { + const { FarcasterClientInterface } = await import("@elizaos/client-farcaster"); + const farcasterClient = await FarcasterClientInterface.start(runtime); + if (farcasterClient) clients.farcaster = farcasterClient; + } catch (error) { + elizaLogger.error("Failed to load Farcaster client:", error.message); } } if (clientTypes.includes("lens")) { - const lensClient = new LensAgentClient(runtime); - lensClient.start(); - clients.lens = lensClient; + try { + const { LensAgentClient } = await import("@elizaos/client-lens"); + const lensClient = new LensAgentClient(runtime); + lensClient.start(); + clients.lens = lensClient; + } catch (error) { + elizaLogger.error("Failed to load Lens client:", error.message); + } } elizaLogger.log("client keys", Object.keys(clients)); diff --git a/characters/chatdkg.character.json b/characters/chatdkg.character.json index 76f3b372ea0bb..9af4baa508356 100644 --- a/characters/chatdkg.character.json +++ b/characters/chatdkg.character.json @@ -1,13 +1,13 @@ { "name": "ChatDKG", - "clients": ["twitter"], + "clients": ["telegram"], "modelProvider": "anthropic", "settings": { "secrets": { "ANTHROPIC_API_KEY": "", - "SMALL_ANTHROPIC_MODEL": "claude-3-5-haiku-20241022", - "MEDIUM_ANTHROPIC_MODEL": "claude-3-5-sonnet-20240620", - "LARGE_ANTHROPIC_MODEL": "claude-3-5-sonnet-20241022" + "SMALL_ANTHROPIC_MODEL": "claude-haiku-4-5-20251001", + "MEDIUM_ANTHROPIC_MODEL": "claude-sonnet-4-6", + "LARGE_ANTHROPIC_MODEL": "claude-sonnet-4-6" }, "voice": { "model": "en_US-male-medium" diff --git a/packages/client-direct/src/api.ts b/packages/client-direct/src/api.ts index 28e465759e49e..ac3b09c903fde 100644 --- a/packages/client-direct/src/api.ts +++ b/packages/client-direct/src/api.ts @@ -15,7 +15,8 @@ import { } from "@elizaos/core"; import type { TeeLogQuery, TeeLogService } from "@elizaos/plugin-tee-log"; -import { REST, Routes } from "discord.js"; +// discord.js import moved to dynamic to avoid crash when discord dependencies have issues +// import { REST, Routes } from "discord.js"; import type { DirectClient } from "."; import { validateUuid } from "@elizaos/core"; @@ -226,9 +227,10 @@ export function createApiRouter( } const API_TOKEN = runtime.getSetting("DISCORD_API_TOKEN") as string; - const rest = new REST({ version: "10" }).setToken(API_TOKEN); try { + const { REST, Routes } = await import("discord.js"); + const rest = new REST({ version: "10" }).setToken(API_TOKEN); const guilds = (await rest.get(Routes.userGuilds())) as Array; res.json({ diff --git a/packages/client-twitter/src/interactions.ts b/packages/client-twitter/src/interactions.ts index 98be2dddd86f3..18dd406317152 100644 --- a/packages/client-twitter/src/interactions.ts +++ b/packages/client-twitter/src/interactions.ts @@ -62,9 +62,9 @@ Here is the descriptions of images in the Current post. ` + messageCompletionFooter; export const twitterShouldRespondTemplate = (targetUsersStr: string) => - `# INSTRUCTIONS: Determine if {{agentName}} (@{{twitterUserName}}) should respond to the message and participate in the conversation. Do not comment. Just respond with "true" or "false". + `# INSTRUCTIONS: Determine if {{agentName}} (@{{twitterUserName}}) should respond to the message and participate in the conversation. Do not comment. Just respond with [RESPOND], [IGNORE], or [STOP]. -Response options are RESPOND, IGNORE and STOP. +Response options are [RESPOND], [IGNORE] and [STOP]. PRIORITY RULE: ALWAYS RESPOND to these users regardless of topic or message content: ${targetUsersStr}. Topic relevance should be ignored for these users. diff --git a/packages/core/src/parsing.ts b/packages/core/src/parsing.ts index 0d9b5defe5596..01281592cc8af 100644 --- a/packages/core/src/parsing.ts +++ b/packages/core/src/parsing.ts @@ -14,22 +14,19 @@ Your response must include one of the options.`; export const parseShouldRespondFromText = ( text: string ): "RESPOND" | "IGNORE" | "STOP" | null => { - const match = text - .split("\n")[0] - .trim() - .replace("[", "") - .toUpperCase() - .replace("]", "") - .match(/^(RESPOND|IGNORE|STOP)$/i); - return match - ? (match[0].toUpperCase() as "RESPOND" | "IGNORE" | "STOP") - : text.includes("RESPOND") - ? "RESPOND" - : text.includes("IGNORE") - ? "IGNORE" - : text.includes("STOP") - ? "STOP" - : null; + const firstLine = text.split("\n")[0].trim(); + const cleaned = firstLine.replace("[", "").toUpperCase().replace("]", ""); + const match = cleaned.match(/^(RESPOND|IGNORE|STOP)$/i); + if (match) { + return match[0].toUpperCase() as "RESPOND" | "IGNORE" | "STOP"; + } + if (text.includes("RESPOND")) return "RESPOND"; + if (text.includes("IGNORE")) return "IGNORE"; + if (text.includes("STOP")) return "STOP"; + const lower = firstLine.toLowerCase(); + if (lower === "true" || lower === "yes") return "RESPOND"; + if (lower === "false" || lower === "no") return "IGNORE"; + return null; }; export const booleanFooter = `Respond with only a YES or a NO.`;