Skip to content

Commit 542e098

Browse files
committed
Merge branch 'hfi' of https://github.com/odilitime/eliza into hfi
2 parents c51a81e + 4e2dff2 commit 542e098

37 files changed

+2512
-678
lines changed

.env.example

+3
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,9 @@ STORY_API_BASE_URL= # Story API base URL
399399
STORY_API_KEY= # Story API key
400400
PINATA_JWT= # Pinata JWT for uploading files to IPFS
401401

402+
# Cosmos
403+
COSMOS_RECOVERY_PHRASE= # 12 words recovery phrase (need to be in quotes, because of spaces)
404+
COSMOS_AVAILABLE_CHAINS= # mantrachaintestnet2,cosmos # Array of chains
402405
# Cronos zkEVM
403406
CRONOSZKEVM_ADDRESS=
404407
CRONOSZKEVM_PRIVATE_KEY=

agent/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@elizaos/plugin-binance": "workspace:*",
3838
"@elizaos/plugin-avail": "workspace:*",
3939
"@elizaos/plugin-bootstrap": "workspace:*",
40-
"@ai16z/plugin-cosmos": "workspace:*",
40+
"@elizaos/plugin-cosmos": "workspace:*",
4141
"@elizaos/plugin-intiface": "workspace:*",
4242
"@elizaos/plugin-coinbase": "workspace:*",
4343
"@elizaos/plugin-coinprice": "workspace:*",

agent/src/index.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { confluxPlugin } from "@elizaos/plugin-conflux";
5454
import { cronosZkEVMPlugin } from "@elizaos/plugin-cronoszkevm";
5555
import { echoChambersPlugin } from "@elizaos/plugin-echochambers";
5656
import { evmPlugin } from "@elizaos/plugin-evm";
57+
import { createCosmosPlugin } from "@elizaos/plugin-cosmos";
5758
import { flowPlugin } from "@elizaos/plugin-flow";
5859
import { fuelPlugin } from "@elizaos/plugin-fuel";
5960
import { genLayerPlugin } from "@elizaos/plugin-genlayer";
@@ -375,7 +376,7 @@ export function getTokenForProvider(
375376
}
376377
}
377378

378-
async function initializeDatabase(dataDir: string) {
379+
function initializeDatabase(dataDir: string) {
379380
if (process.env.POSTGRES_URL) {
380381
elizaLogger.info("Initializing PostgreSQL connection...");
381382
const db = new PostgresDatabaseAdapter({
@@ -587,6 +588,9 @@ export async function createAgent(
587588
getSecret(character, "WALLET_PUBLIC_KEY")?.startsWith("0x"))
588589
? evmPlugin
589590
: null,
591+
getSecret(character, "COSMOS_RECOVERY_PHRASE") &&
592+
getSecret(character, "COSMOS_AVAILABLE_CHAINS") &&
593+
createCosmosPlugin(),
590594
(getSecret(character, "SOLANA_PUBLIC_KEY") ||
591595
(getSecret(character, "WALLET_PUBLIC_KEY") &&
592596
!getSecret(character, "WALLET_PUBLIC_KEY")?.startsWith(
@@ -769,9 +773,11 @@ async function startAgent(
769773
fs.mkdirSync(dataDir, { recursive: true });
770774
}
771775

772-
db = (await initializeDatabase(dataDir)) as IDatabaseAdapter &
776+
db = initializeDatabase(dataDir) as IDatabaseAdapter &
773777
IDatabaseCacheAdapter;
774778

779+
await db.init();
780+
775781
const cache = initializeCache(
776782
process.env.CACHE_STORE ?? CacheStore.DATABASE,
777783
character,

characters/cosmosHelper.character.json

+10-26
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
"clients": [],
44
"modelProvider": "groq",
55
"settings": {
6-
"secrets": {},
76
"voice": {
87
"model": "en_US-male-medium"
98
},
109
"chains": {
1110
"cosmos": ["axelar", "carbon", "mantrachaintestnet2"]
1211
}
1312
},
14-
"plugins": ["@ai16z/plugin-cosmos","@ai16z/plugin-bootstrap"],
13+
"plugins": [],
1514
"bio": [
1615
"Expert in Cosmos ecosystem.",
1716
"Knowledgeable in CosmWasm and Stargate.",
@@ -24,37 +23,22 @@
2423
"Supports projects and interactions within the Cosmos ecosystem."
2524
],
2625
"knowledge": [
27-
"knows EXACT cost to families under Kamala ($29,000)",
28-
"understands REAL border numbers (worse than reported)",
29-
"saw what really happened in Minneapolis 2020",
30-
"remembers who begged for help (and when)",
31-
"knows why Iran's president targeting us",
32-
"understands Secret Service allocation (and why they do it)",
33-
"knows REAL rally numbers (they hide them)",
34-
"saw the TRUTH about China Virus response",
35-
"understands states' rights better than anyone",
36-
"knows why they're letting in illegal guns",
37-
"remembers when America was AFFORDABLE",
38-
"understands the REAL election interference",
39-
"knows why they're scared of WorldLibertyFi",
40-
"saw what they did to women's sports",
41-
"understands the REAL Middle East situation",
42-
"knows why missiles flying everywhere now",
43-
"remembers perfect peace under Trump presidency",
44-
"understands Democrat election strategy (letting in MILLIONS)",
45-
"knows Kamala's REAL tax plans (coming for everything)",
46-
"saw what they did to Minneapolis (and other cities)"
26+
"Knows how Cosmos blockchain works",
27+
"Knows what actions should he call for token transfer, swapping or bridging",
28+
"Knows that users might want to do specific actions multiple times and should help them by doing it again.",
29+
"Should always ask for confirmation before calling an COSMOS_TRANSFER, COSMOS_BRIDGE, COSMOS_SWAP actions.",
30+
"Should call actions COSMOS_TRANSFER, COSMOS_BRIDGE, COSMOS_SWAP only after previous confirmation."
4731
],
4832
"messageExamples": [
4933
[
5034
{
5135
"user": "{{user1}}",
52-
"content": { "text": "Can you explain the Cosmos Hub?" }
36+
"content": { "text": "Show my balances of my wallet on {{mantrachaintestnet2}}" }
5337
},
5438
{
5539
"user": "CosmosHelper",
5640
"content": {
57-
"text": "The Cosmos Hub is the central blockchain in the Cosmos ecosystem, facilitating interoperability between connected blockchains."
41+
"text": "Your balances on chain {{mantrachaintestnet2}} are: \n - 13456.124 OM\n - 1222 ONDO\n 0.122122 USDY"
5842
}
5943
}
6044
],
@@ -97,12 +81,12 @@
9781
[
9882
{
9983
"user": "{{user1}}",
100-
"content": { "text": "What are validators?" }
84+
"content": { "text": "Make transfer 0.0001 OM to mantra13248w8dtnn07sxc3gq4l3ts4rvfyat6fks0ecj on mantrachaintestnet2" }
10185
},
10286
{
10387
"user": "CosmosHelper",
10488
"content": {
105-
"text": "Validators are responsible for securing the network by validating transactions and producing new blocks. They earn rewards through staking."
89+
"text": "Sure, your transfer i being processed."
10690
}
10791
}
10892
]

packages/client-twitter/src/interactions.ts

+51-41
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ Thread of Tweets You Are Replying To:
9090
export class TwitterInteractionClient {
9191
client: ClientBase;
9292
runtime: IAgentRuntime;
93+
private isDryRun: boolean;
9394
constructor(client: ClientBase, runtime: IAgentRuntime) {
9495
this.client = client;
9596
this.runtime = runtime;
97+
this.isDryRun = this.client.twitterConfig.TWITTER_DRY_RUN;
9698
}
9799

98100
async start() {
@@ -430,54 +432,62 @@ export class TwitterInteractionClient {
430432
response.text = removeQuotes(response.text);
431433

432434
if (response.text) {
433-
try {
434-
const callback: HandlerCallback = async (response: Content) => {
435-
const memories = await sendTweet(
436-
this.client,
437-
response,
438-
message.roomId,
439-
this.client.twitterConfig.TWITTER_USERNAME,
440-
tweet.id
441-
);
442-
return memories;
443-
};
435+
if (this.isDryRun) {
436+
elizaLogger.info(
437+
`Dry run: Selected Post: ${tweet.id} - ${tweet.username}: ${tweet.text}\nAgent's Output:\n${response.text}`
438+
);
439+
} else {
440+
try {
441+
const callback: HandlerCallback = async (
442+
response: Content
443+
) => {
444+
const memories = await sendTweet(
445+
this.client,
446+
response,
447+
message.roomId,
448+
this.client.twitterConfig.TWITTER_USERNAME,
449+
tweet.id
450+
);
451+
return memories;
452+
};
444453

445-
const responseMessages = await callback(response);
454+
const responseMessages = await callback(response);
446455

447-
state = (await this.runtime.updateRecentMessageState(
448-
state
449-
)) as State;
456+
state = (await this.runtime.updateRecentMessageState(
457+
state
458+
)) as State;
450459

451-
for (const responseMessage of responseMessages) {
452-
if (
453-
responseMessage ===
454-
responseMessages[responseMessages.length - 1]
455-
) {
456-
responseMessage.content.action = response.action;
457-
} else {
458-
responseMessage.content.action = "CONTINUE";
460+
for (const responseMessage of responseMessages) {
461+
if (
462+
responseMessage ===
463+
responseMessages[responseMessages.length - 1]
464+
) {
465+
responseMessage.content.action = response.action;
466+
} else {
467+
responseMessage.content.action = "CONTINUE";
468+
}
469+
await this.runtime.messageManager.createMemory(
470+
responseMessage
471+
);
459472
}
460-
await this.runtime.messageManager.createMemory(
461-
responseMessage
462-
);
463-
}
464473

465-
await this.runtime.processActions(
466-
message,
467-
responseMessages,
468-
state,
469-
callback
470-
);
474+
await this.runtime.processActions(
475+
message,
476+
responseMessages,
477+
state,
478+
callback
479+
);
471480

472-
const responseInfo = `Context:\n\n${context}\n\nSelected Post: ${tweet.id} - ${tweet.username}: ${tweet.text}\nAgent's Output:\n${response.text}`;
481+
const responseInfo = `Context:\n\n${context}\n\nSelected Post: ${tweet.id} - ${tweet.username}: ${tweet.text}\nAgent's Output:\n${response.text}`;
473482

474-
await this.runtime.cacheManager.set(
475-
`twitter/tweet_generation_${tweet.id}.txt`,
476-
responseInfo
477-
);
478-
await wait();
479-
} catch (error) {
480-
elizaLogger.error(`Error sending response tweet: ${error}`);
483+
await this.runtime.cacheManager.set(
484+
`twitter/tweet_generation_${tweet.id}.txt`,
485+
responseInfo
486+
);
487+
await wait();
488+
} catch (error) {
489+
elizaLogger.error(`Error sending response tweet: ${error}`);
490+
}
481491
}
482492
}
483493
}

0 commit comments

Comments
 (0)