Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bino-dev' into bino
Browse files Browse the repository at this point in the history
  • Loading branch information
nicky-ru committed Jan 9, 2025
2 parents 45e7abe + b9fefee commit 43b9a81
Show file tree
Hide file tree
Showing 468 changed files with 121 additions and 65,593 deletions.
27 changes: 0 additions & 27 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,15 @@
"@elizaos/client-auto": "workspace:*",
"@elizaos/client-direct": "workspace:*",
"@elizaos/client-discord": "workspace:*",
"@elizaos/client-farcaster": "workspace:*",
"@elizaos/client-lens": "workspace:*",
"@elizaos/client-telegram": "workspace:*",
"@elizaos/client-twitter": "workspace:*",
"@elizaos/client-slack": "workspace:*",
"@elizaos/core": "workspace:*",
"@elizaos/plugin-0g": "workspace:*",
"@elizaos/plugin-abstract": "workspace:*",
"@elizaos/plugin-aptos": "workspace:*",
"@elizaos/plugin-bootstrap": "workspace:*",
"@elizaos/plugin-intiface": "workspace:*",
"@elizaos/plugin-coinbase": "workspace:*",
"@elizaos/plugin-conflux": "workspace:*",
"@elizaos/plugin-evm": "workspace:*",
"@elizaos/plugin-echochambers": "workspace:*",
"@elizaos/plugin-flow": "workspace:*",
"@elizaos/plugin-gitbook": "workspace:*",
"@elizaos/plugin-story": "workspace:*",
"@elizaos/plugin-goat": "workspace:*",
"@elizaos/plugin-icp": "workspace:*",
"@elizaos/plugin-image-generation": "workspace:*",
"@elizaos/plugin-nft-generation": "workspace:*",
"@elizaos/plugin-node": "workspace:*",
"@elizaos/plugin-solana": "workspace:*",
"@elizaos/plugin-starknet": "workspace:*",
"@elizaos/plugin-ton": "workspace:*",
"@elizaos/plugin-sui": "workspace:*",
"@elizaos/plugin-tee": "workspace:*",
"@elizaos/plugin-multiversx": "workspace:*",
"@elizaos/plugin-near": "workspace:*",
"@elizaos/plugin-zksync-era": "workspace:*",
"@elizaos/plugin-twitter": "workspace:*",
"@elizaos/plugin-cronoszkevm": "workspace:*",
"@elizaos/plugin-3d-generation": "workspace:*",
"@elizaos/plugin-fuel": "workspace:*",
"@elizaos/plugin-avalanche": "workspace:*",
"@elizaos/plugin-web-search": "workspace:*",
"@elizaos/plugin-depin": "workspace:*",
"readline": "1.3.0",
Expand Down
95 changes: 2 additions & 93 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { PostgresDatabaseAdapter } from "@elizaos/adapter-postgres";
import { SqliteDatabaseAdapter } from "@elizaos/adapter-sqlite";
import { AutoClientInterface } from "@elizaos/client-auto";
import { DiscordClientInterface } from "@elizaos/client-discord";
import { SlackClientInterface } from "@elizaos/client-slack";
import { TelegramClientInterface } from "@elizaos/client-telegram";
import { TwitterClientInterface } from "@elizaos/client-twitter";
import {
Expand All @@ -23,31 +22,15 @@ import {
CacheStore,
Client,
ICacheManager,
parseBooleanFromText,
} from "@elizaos/core";
import { RedisClient } from "@elizaos/adapter-redis";
import { bootstrapPlugin } from "@elizaos/plugin-bootstrap";
import { DirectClient } from "@elizaos/client-direct";
import { evmPlugin } from "@elizaos/plugin-evm";
import { storyPlugin } from "@elizaos/plugin-story";
import { flowPlugin } from "@elizaos/plugin-flow";
import { fuelPlugin } from "@elizaos/plugin-fuel";
import { imageGenerationPlugin } from "@elizaos/plugin-image-generation";
import { ThreeDGenerationPlugin } from "@elizaos/plugin-3d-generation";
import { multiversxPlugin } from "@elizaos/plugin-multiversx";
import { nearPlugin } from "@elizaos/plugin-near";
import { nftGenerationPlugin } from "@elizaos/plugin-nft-generation";
import { createNodePlugin } from "@elizaos/plugin-node";
import { solanaPlugin } from "@elizaos/plugin-solana";
import { suiPlugin } from "@elizaos/plugin-sui";
import { TEEMode, teePlugin } from "@elizaos/plugin-tee";
import { tonPlugin } from "@elizaos/plugin-ton";
import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";
import { cronosZkEVMPlugin } from "@elizaos/plugin-cronoszkevm";
import { abstractPlugin } from "@elizaos/plugin-abstract";
import { avalanchePlugin } from "@elizaos/plugin-avalanche";
import { webSearchPlugin } from "@elizaos/plugin-web-search";
import { echoChamberPlugin } from "@elizaos/plugin-echochambers";
import Database from "better-sqlite3";
import fs from "fs";
import path from "path";
Expand Down Expand Up @@ -345,8 +328,7 @@ function initializeDatabase(dataDir: string) {
elizaLogger.info("Initializing PostgreSQL connection...");
const db = new PostgresDatabaseAdapter({
connectionString: process.env.POSTGRES_URL,
parseInputs: true,
max: 50
max: 15,
});

// Test the connection
Expand Down Expand Up @@ -404,25 +386,10 @@ export async function initializeClients(
}
}

if (clientTypes.includes(Clients.FARCASTER)) {
// why is this one different :(
const farcasterClient = new FarcasterAgentClient(runtime);
if (farcasterClient) {
farcasterClient.start();
clients.farcaster = farcasterClient;
}
}

elizaLogger.log("client keys", Object.keys(clients));

// TODO: Add Slack client to the list
// Initialize clients as an object

if (clientTypes.includes("slack")) {
const slackClient = await SlackClientInterface.start(runtime);
if (slackClient) clients.slack = slackClient; // Use object property instead of push
}

function determineClientType(client: Client): string {
// Check if client has a direct type identifier
if ("type" in client) {
Expand Down Expand Up @@ -488,14 +455,6 @@ export async function createAgent(
throw new Error("Invalid TEE configuration");
}

let goatPlugin: any | undefined;

if (getSecret(character, "EVM_PRIVATE_KEY")) {
goatPlugin = await createGoatPlugin((secret) =>
getSecret(character, secret)
);
}

return new AgentRuntime({
databaseAdapter: db,
token,
Expand All @@ -507,16 +466,6 @@ export async function createAgent(
bootstrapPlugin,
nodePlugin,
getSecret(character, "TAVILY_API_KEY") ? webSearchPlugin : null,
getSecret(character, "SOLANA_PUBLIC_KEY") ||
(getSecret(character, "WALLET_PUBLIC_KEY") &&
!getSecret(character, "WALLET_PUBLIC_KEY")?.startsWith("0x"))
? solanaPlugin
: null,
(getSecret(character, "NEAR_ADDRESS") ||
getSecret(character, "NEAR_WALLET_PUBLIC_KEY")) &&
getSecret(character, "NEAR_WALLET_SECRET_KEY")
? nearPlugin
: null,
getSecret(character, "EVM_PUBLIC_KEY") ||
(getSecret(character, "WALLET_PUBLIC_KEY") &&
getSecret(character, "WALLET_PUBLIC_KEY")?.startsWith("0x"))
Expand All @@ -529,49 +478,9 @@ export async function createAgent(
getSecret(character, "LIVEPEER_GATEWAY_URL")
? imageGenerationPlugin
: null,
getSecret(character, "FAL_API_KEY") ? ThreeDGenerationPlugin : null,
...(getSecret(character, "COINBASE_API_KEY") &&
getSecret(character, "COINBASE_PRIVATE_KEY")
? [
coinbaseMassPaymentsPlugin,
tradePlugin,
tokenContractPlugin,
advancedTradePlugin,
]
: []),
...(teeMode !== TEEMode.OFF && walletSecretSalt
? [teePlugin, solanaPlugin]
? [teePlugin]
: []),
getSecret(character, "COINBASE_API_KEY") &&
getSecret(character, "COINBASE_PRIVATE_KEY") &&
getSecret(character, "COINBASE_NOTIFICATION_URI")
? webhookPlugin
: null,
goatPlugin,
getSecret(character, "ABSTRACT_PRIVATE_KEY")
? abstractPlugin
: null,
getSecret(character, "FLOW_ADDRESS") &&
getSecret(character, "FLOW_PRIVATE_KEY")
? flowPlugin
: null,
getSecret(character, "APTOS_PRIVATE_KEY") ? aptosPlugin : null,
getSecret(character, "MVX_PRIVATE_KEY") ? multiversxPlugin : null,
getSecret(character, "ZKSYNC_PRIVATE_KEY") ? zksyncEraPlugin : null,
getSecret(character, "CRONOSZKEVM_PRIVATE_KEY")
? cronosZkEVMPlugin
: null,
getSecret(character, "TON_PRIVATE_KEY") ? tonPlugin : null,
getSecret(character, "SUI_PRIVATE_KEY") ? suiPlugin : null,
getSecret(character, "STORY_PRIVATE_KEY") ? storyPlugin : null,
getSecret(character, "FUEL_PRIVATE_KEY") ? fuelPlugin : null,
getSecret(character, "AVALANCHE_PRIVATE_KEY")
? avalanchePlugin
: null,
getSecret(character, "ECHOCHAMBERS_API_URL") &&
getSecret(character, "ECHOCHAMBERS_API_KEY")
? echoChamberPlugin
: null,
].filter(Boolean),
providers: [],
actions: [],
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
"node": "23.3.0"
},
"dependencies": {
"@0glabs/0g-ts-sdk": "0.2.1",
"@coinbase/coinbase-sdk": "0.10.0",
"@deepgram/sdk": "^3.9.0",
"@vitest/eslint-plugin": "1.0.1",
"amqplib": "0.10.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-postgres/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { v4 } from "uuid";

// Import the entire module as default
import pg from "pg";
import pg, { PoolConfig } from "pg";
type Pool = pg.Pool;

import {
Expand Down Expand Up @@ -43,7 +43,7 @@ export class PostgresDatabaseAdapter
private readonly jitterMax: number = 1000; // 1 second
private readonly connectionTimeout: number = 5000; // 5 seconds

constructor(connectionConfig: any) {
constructor(connectionConfig: PoolConfig) {
super({
//circuitbreaker stuff
failureThreshold: 5,
Expand Down
73 changes: 48 additions & 25 deletions packages/client-discord/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,14 +390,14 @@ export class MessageManager {
});

// simulate discord typing while generating a response
const stopTyping = this.simulateTyping(message)
const stopTyping = this.simulateTyping(message);

const responseContent = await this._generateResponse(
memory,
state,
context
).finally(() => {
stopTyping()
stopTyping();
});

responseContent.text = responseContent.text?.trim();
Expand All @@ -408,7 +408,6 @@ export class MessageManager {
if (!responseContent.text) {
return;
}

const callback: HandlerCallback = async (
content: Content,
files: any[]
Expand Down Expand Up @@ -466,7 +465,24 @@ export class MessageManager {
}
};

const responseMessages = await callback(responseContent);
let responseMessages: Memory[] = [];
if (responseContent.generatePreActionResponse) {
responseMessages = await callback(responseContent);
} else {
// If we're not generating a pre-action response, create a single memory
const memory: Memory = {
id: stringToUuid(
message.id + "-response-" + this.runtime.agentId
),
userId: this.runtime.agentId,
agentId: this.runtime.agentId,
content: responseContent,
roomId,
embedding: getEmbeddingZeroVector(),
createdAt: Date.now(),
};
responseMessages = [memory];
}

state = await this.runtime.updateRecentMessageState(state);

Expand Down Expand Up @@ -513,6 +529,10 @@ export class MessageManager {
}

private _isMessageForMe(message: DiscordMessage): boolean {
if (message.channel.type === ChannelType.DM) {
return true;
}

const isMentioned = message.mentions.users?.has(
this.client.user?.id as string
);
Expand All @@ -532,25 +552,28 @@ export class MessageManager {
return false;
}

return (
isMentioned ||
(!this.runtime.character.clientConfig?.discord
?.shouldRespondOnlyToMentions &&
(message.content
.toLowerCase()
.includes(
this.client.user?.username.toLowerCase() as string
) ||
message.content
.toLowerCase()
.includes(
this.client.user?.tag.toLowerCase() as string
) ||
(nickname &&
message.content
.toLowerCase()
.includes(nickname.toLowerCase()))))
);
if (isMentioned) {
return true;
}

if (
this.runtime.character.clientConfig?.discord
?.shouldRespondOnlyToMentions
) {
return false;
}

const hasUsername = message.content
.toLowerCase()
.includes(this.client.user?.username.toLowerCase() as string);
const hasTag = message.content
.toLowerCase()
.includes(this.client.user?.tag.toLowerCase() as string);
const hasNickname =
nickname &&
message.content.toLowerCase().includes(nickname.toLowerCase());

return hasUsername || hasTag || hasNickname;
}

async processMessageMedia(
Expand Down Expand Up @@ -1332,7 +1355,7 @@ export class MessageManager {
typingLoop();

return function stopTyping() {
typing = false
}
typing = false;
};
}
}
32 changes: 0 additions & 32 deletions packages/client-farcaster/package.json

This file was deleted.

Loading

0 comments on commit 43b9a81

Please sign in to comment.