Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 33 additions & 16 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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)) {
Expand All @@ -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));
Expand Down
8 changes: 4 additions & 4 deletions characters/chatdkg.character.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 4 additions & 2 deletions packages/client-direct/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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<any>;

res.json({
Expand Down
4 changes: 2 additions & 2 deletions packages/client-twitter/src/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
29 changes: 13 additions & 16 deletions packages/core/src/parsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`;
Expand Down
Loading