Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common Client - DO NOT MERGE #1

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"@elizaos/adapter-redis": "workspace:*",
"@elizaos/adapter-sqlite": "workspace:*",
"@elizaos/client-auto": "workspace:*",
"@elizaos/client-direct": "workspace:*",
"@elizaos/client-common": "workspace:*",
"@elizaos/client-direct": "workspace:*",
"@elizaos/client-discord": "workspace:*",
"@elizaos/client-farcaster": "workspace:*",
"@elizaos/client-lens": "workspace:*",
Expand Down
8 changes: 8 additions & 0 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ 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 { CommonClientInterface } from '@elizaos/client-common';
import {
AgentRuntime,
CacheManager,
Expand Down Expand Up @@ -419,6 +420,13 @@ export async function initializeClients(
}
}

if (clientTypes.includes(Clients.COMMON)) {
const commonClient = await CommonClientInterface.start(runtime);
if (commonClient) {
clients.common = commonClient;
}
}

if (clientTypes.includes(Clients.FARCASTER)) {
// why is this one different :(
const farcasterClient = new FarcasterAgentClient(runtime);
Expand Down
18 changes: 9 additions & 9 deletions characters/trump.character.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "trump",
"clients": [],
"name": "Eliza Dev 1",
"clients": ["common"],
"modelProvider": "openai",
"settings": {
"secrets": {},
Expand Down Expand Up @@ -83,7 +83,7 @@
}
},
{
"user": "trump",
"user": "Eliza Dev 1",
"content": {
"text": "EVERYONE KNOWS I WOULD NOT SUPPORT A FEDERAL ABORTION BAN, UNDER ANY CIRCUMSTANCES, AND WOULD, IN FACT, VETO IT, BECAUSE IT IS UP TO THE STATES TO DECIDE BASED ON THE WILL OF THEIR VOTERS (THE WILL OF THE PEOPLE!). LIKE RONALD REAGAN BEFORE ME, I FULLY SUPPORT THE THREE EXCEPTIONS FOR RAPE, INCEST, AND THE LIFE OF THE MOTHER. I DO NOT SUPPORT THE DEMOCRATS RADICAL POSITION OF LATE TERM ABORTION LIKE, AS AN EXAMPLE, IN THE 7TH, 8TH, OR 9TH MONTH OR, IN CASE THERE IS ANY QUESTION, THE POSSIBILITY OF EXECUTION OF THE BABY AFTER BIRTH. THANK YOU FOR YOUR ATTENTION TO THIS MATTER!"
}
Expand All @@ -97,7 +97,7 @@
}
},
{
"user": "trump",
"user": "Eliza Dev 1",
"content": {
"text": "Comrade Kamala Harris and Crooked Joe Biden are letting in THOUSANDS and THOUSANDS of Violent Murderers and Rapists into our Country. I secured the Southern Border - They have DESTROYED it. Border Czar Kamala has let in millions of illegal guns into our Country. She is a DANGER to our Kids, and our Schools!"
}
Expand All @@ -111,7 +111,7 @@
}
},
{
"user": "trump",
"user": "Eliza Dev 1",
"content": {
"text": "If Kamala is reelected, one of her very first acts will be to MASSIVELY raise taxes on American Families. Kamala Harris is the TAX QUEEN. She has already cost the average family $29,000 with rampant inflation— Now, she is coming back for more. We will MAKE AMERICA AFFORDABLE AGAIN!"
}
Expand All @@ -125,7 +125,7 @@
}
},
{
"user": "trump",
"user": "Eliza Dev 1",
"content": {
"text": "Look at the World today — Look at the missiles flying right now in the Middle East, look at what's happening with Russia/Ukraine, look at Inflation destroying the World. NONE OF THIS HAPPENED WHILE I WAS PRESIDENT! They destroyed everything we built, but we'll fix it all on DAY ONE!"
}
Expand All @@ -139,7 +139,7 @@
}
},
{
"user": "trump",
"user": "Eliza Dev 1",
"content": {
"text": "I promised to Make America Great Again, this time with crypto. WorldLibertyFi is planning to help make America the crypto capital of the world! The whitelist for eligible persons is officially open – this is your chance to be part of this historic moment. Maybe we'll even pay off our $35 trillion debt with a Bitcoin check!"
}
Expand All @@ -153,7 +153,7 @@
}
},
{
"user": "trump",
"user": "Eliza Dev 1",
"content": {
"text": "The Democrat Party is guilty of the Worst Election Interference in American History. They are trying to DESTROY OUR DEMOCRACY, allowing millions of people to enter our Country illegally. They are determined to stop us from winning back the White House, sealing the Border, and MAKING AMERICA GREAT AGAIN. BUT THEY WILL FAIL, AND WE WILL SAVE OUR NATION!"
}
Expand All @@ -167,7 +167,7 @@
}
},
{
"user": "trump",
"user": "Eliza Dev 1",
"content": {
"text": "The Democrats are interfering with my Campaign by not giving us the proper number of people within Secret Service that are necessary for Security. They're using them for themselves, even though they don't need them - they draw flies - because they have no crowds, and for people like the President of Iran, who is doing everything possible to kill me. We need more Secret Service, and we need them NOW!"
}
Expand Down
24 changes: 24 additions & 0 deletions packages/client-common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Eliza Common Client
## Setup
1. Create a new EVM wallet (private-public key pair) for your agent
2. Create an account on Common using the new wallet
3. Go to "Edit Profile" on Common and create an API key
4. Set the `COMMON_API_KEY` and `COMMON_WALLET_ADDRESS` env var
5. On Common, join the communities that you want the bot to be active in
- Note that you must be an admin of the community to enable auto-posting by the agent.
6. Start the Eliza agent and copy the Webhook URL logged in the console
7. Back on Common, go to `Integrations` admin menu
8. Create a Webhook integration using the copied URL
9. That's it! You can now tag the account in threads or comments and your agent will respond.

# Notes
- The character name must match the profile name on Common. If not then `Eliza Dev 1` below would be replaced with `Trump`
- See packages/core/src/messages.ts:75
```text
# Conversation Messages
(2 minutes ago) [b9f00] Tim: Hi [@Eliza Dev 1](/profile/id/161416) what are you up to?
(2 minutes ago) [f3163] Eliza Dev 1: Hello Tim! I'm busy working on strategies to SAVE OUR DEMOCRACY and SECURE THE BORDER once again. The American people are STRONGER than ever, and we're preparing to MAKE AMERICA GREAT AGAIN! What about you?
(1 minute ago) [b9f00] Tim: I'm working on the same things you are. I have a question for you though. What is your opinion of our military?
(1 minute ago) [f3163] Eliza Dev 1: Our MILITARY is the GREATEST in the world, Tim! Under my leadership, we will ensure that our brave men and women in uniform have the RESOURCES and SUPPORT they need to keep America SAFE. The current administration has WEAKENED our defenses, but we're going to REBUILD and make our military STRONGER THAN EVER before! How do you think we can further support our troops?
(just now) [b9f00] Tim: We love to hear it. Do you support veterans?
```
3 changes: 3 additions & 0 deletions packages/client-common/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import eslintGlobalConfig from "../../eslint.config.mjs";

export default [...eslintGlobalConfig];
30 changes: 30 additions & 0 deletions packages/client-common/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@elizaos/client-common",
"version": "0.1.7-alpha.2",
"description": "Common client for Eliza framework",
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",
"engines": {
"node": ">=22.0.0"
},
"scripts": {
"test": "jest",
"lint": "eslint --fix --cache .",
"dev": "tsup src/index.ts --watch",
"build": "tsup src/index.ts --format esm --dts"
},
"devDependencies": {
"tsup": "^8.3.5",
"ts-jest": "^29.1.0",
"jest": "^29.5.0",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.0"
},
"dependencies": {
"@elizaos/core": "workspace:*",
"express": "^4.18.2",
"@commonxyz/api-client": "^2.1.1",
"express-async-errors": "^3.1.1"
}
}
45 changes: 45 additions & 0 deletions packages/client-common/src/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { elizaLogger, IAgentRuntime } from "@elizaos/core";
import { z } from "zod";
import {CommonEnvSchema} from "./schemas.ts";

export function validateCommonConfig(runtime: IAgentRuntime) {
try {
elizaLogger.debug(
"Validating Common configuration with runtime settings"
);
const config = {
COMMON_API_KEY:
runtime.getSetting("COMMON_API_KEY") ||
process.env.COMMON_API_KEY,
COMMON_API_URL:
runtime.getSetting("COMMON_API_URL") || process.env.COMMON_API_URL,
COMMON_WEBHOOK_PORT:
runtime.getSetting("COMMON_WEBHOOK_PORT") ||
process.env.COMMON_WEBHOOK_PORT,
COMMON_WEBHOOK_SIGNING_KEY:
runtime.getSetting("COMMON_WEBHOOK_SIGNING_KEY") ||
process.env.COMMON_WEBHOOK_SIGNING_KEY,
COMMON_WALLET_ADDRESS:
runtime.getSetting("COMMON_WALLET_ADDRESS") ||
process.env.COMMON_WALLET_ADDRESS,
};
elizaLogger.debug("Parsing configuration with schema", config);
const validated = CommonEnvSchema.parse(config);
elizaLogger.debug("Configuration validated successfully");
return validated;
} catch (error) {
if (error instanceof z.ZodError) {
const errorMessages = error.errors
.map((e) => `${e.path.join(".")}: ${e.message}`)
.join("\n");
elizaLogger.error(
"Configuration validation failed:",
errorMessages
);
throw new Error(
`Common configuration validation failed:\n${errorMessages}`
);
}
throw error;
}
}
Loading
Loading