Skip to content

Commit 34d64ad

Browse files
committed
Merge branch 'feat/genlayer-plugin' of https://github.com/yeagerai/eliza into HEAD
2 parents b808c24 + b5ba91c commit 34d64ad

File tree

34 files changed

+3606
-2936
lines changed

34 files changed

+3606
-2936
lines changed

.env.example

+2
Original file line numberDiff line numberDiff line change
@@ -373,3 +373,5 @@ FUEL_WALLET_PRIVATE_KEY=
373373
# Tokenizer Settings
374374
TOKENIZER_MODEL= # Specify the tokenizer model to be used.
375375
TOKENIZER_TYPE= # Options: tiktoken (for OpenAI models) or auto (AutoTokenizer from Hugging Face for non-OpenAI models). Default: tiktoken.
376+
# GenLayer
377+
GENLAYER_PRIVATE_KEY=0x0000000000000000000000000000000000000000000000000000000000000000 # Private key of the GenLayer account to use for the agent

CHANGELOG.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312
- chore: bump version to v0.1.7-alpha.1 [\#1361](https://github.com/elizaOS/eliza/pull/1361) ([shakkernerd](https://github.com/shakkernerd))
313313
- chore: New version 0.1.7 alpha.1 [\#1360](https://github.com/elizaOS/eliza/pull/1360) ([shakkernerd](https://github.com/shakkernerd))
314314
- chore: develop -\> main, change elizaos/eliza to elizaos/core [\#1359](https://github.com/elizaOS/eliza/pull/1359) ([lalalune](https://github.com/lalalune))
315-
- feat: change @elizaos/eliza to @elizaos/core [\#1357](https://github.com/elizaOS/eliza/pull/1357) ([lalalune](https://github.com/lalalune))
315+
- feat: change @elizaos/core to @elizaos/core [\#1357](https://github.com/elizaOS/eliza/pull/1357) ([lalalune](https://github.com/lalalune))
316316
- chore: Merge Develop into Main [\#1356](https://github.com/elizaOS/eliza/pull/1356) ([lalalune](https://github.com/lalalune))
317317
- chore: revert discord url [\#1355](https://github.com/elizaOS/eliza/pull/1355) ([madjin](https://github.com/madjin))
318318
- Update DOCUMENTATION links to point to https://elizaOS.github.io/eliza/ [\#1353](https://github.com/elizaOS/eliza/pull/1353) ([imwylin](https://github.com/imwylin))
@@ -502,7 +502,7 @@
502502
- Agent Responds Twice to prompts [\#726](https://github.com/elizaOS/eliza/issues/726)
503503
- Twitter Client Breaks out of the box [\#673](https://github.com/elizaOS/eliza/issues/673)
504504
- Twitter client only works for one agent when running multiple agents simultaneously [\#656](https://github.com/elizaOS/eliza/issues/656)
505-
- Cannot find module '@ai16z/eliza' or its corresponding type declarations. [\#601](https://github.com/elizaOS/eliza/issues/601)
505+
- Cannot find module '@elizaos/core' or its corresponding type declarations. [\#601](https://github.com/elizaOS/eliza/issues/601)
506506
- create-eliza-app package doesn't install or exist [\#553](https://github.com/elizaOS/eliza/issues/553)
507507
- Non node.js environments have issues building \(workers for instance\) [\#507](https://github.com/elizaOS/eliza/issues/507)
508508
- Error: Property 'clients' does not exist on type 'Plugin' in src/index.ts during pnpm start [\#423](https://github.com/elizaOS/eliza/issues/423)
@@ -1259,7 +1259,7 @@
12591259
- feat: Add Heurist API Integration as New Model Provider [\#335](https://github.com/elizaOS/eliza/pull/335) ([tsubasakong](https://github.com/tsubasakong))
12601260
- Docs: additional Quickstart clarification and improvements [\#334](https://github.com/elizaOS/eliza/pull/334) ([odilitime](https://github.com/odilitime))
12611261
- Docs: README.md improvements: clarify testing, add additional docker information [\#333](https://github.com/elizaOS/eliza/pull/333) ([odilitime](https://github.com/odilitime))
1262-
- fix: Build error for packages requiring @ai16z/eliza [\#331](https://github.com/elizaOS/eliza/pull/331) ([shakkernerd](https://github.com/shakkernerd))
1262+
- fix: Build error for packages requiring @elizaos/core [\#331](https://github.com/elizaOS/eliza/pull/331) ([shakkernerd](https://github.com/shakkernerd))
12631263
- claude vertex configs added to generation.ts \(was missing\) [\#330](https://github.com/elizaOS/eliza/pull/330) ([denizekiz](https://github.com/denizekiz))
12641264
- README\_KOR.md Korean version edited by a Korean [\#329](https://github.com/elizaOS/eliza/pull/329) ([zo-eth](https://github.com/zo-eth))
12651265
- Save Trade on creation to the backend [\#328](https://github.com/elizaOS/eliza/pull/328) ([MarcoMandar](https://github.com/MarcoMandar))

agent/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"@elizaos/plugin-fuel": "workspace:*",
6262
"@elizaos/plugin-avalanche": "workspace:*",
6363
"@elizaos/plugin-web-search": "workspace:*",
64+
"@elizaos/plugin-genlayer": "workspace:*",
6465
"readline": "1.3.0",
6566
"ws": "8.18.0",
6667
"yargs": "17.7.2"

agent/src/index.ts

+17-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { PostgresDatabaseAdapter } from "@elizaos/adapter-postgres";
2+
import { RedisClient } from "@elizaos/adapter-redis";
23
import { SqliteDatabaseAdapter } from "@elizaos/adapter-sqlite";
34
import { AutoClientInterface } from "@elizaos/client-auto";
45
import { DiscordClientInterface } from "@elizaos/client-discord";
@@ -10,31 +11,33 @@ import { TwitterClientInterface } from "@elizaos/client-twitter";
1011
import {
1112
AgentRuntime,
1213
CacheManager,
14+
CacheStore,
1315
Character,
16+
Client,
1417
Clients,
1518
DbCacheAdapter,
1619
defaultCharacter,
1720
elizaLogger,
1821
FsCacheAdapter,
1922
IAgentRuntime,
23+
ICacheManager,
2024
IDatabaseAdapter,
2125
IDatabaseCacheAdapter,
2226
ModelProviderName,
2327
settings,
2428
stringToUuid,
25-
validateCharacterConfig,
26-
CacheStore,
27-
Client,
28-
ICacheManager,
29-
parseBooleanFromText,
29+
validateCharacterConfig
3030
} from "@elizaos/core";
31-
import { RedisClient } from "@elizaos/adapter-redis";
3231
import { zgPlugin } from "@elizaos/plugin-0g";
3332
import { bootstrapPlugin } from "@elizaos/plugin-bootstrap";
3433
import createGoatPlugin from "@elizaos/plugin-goat";
3534
// import { intifacePlugin } from "@elizaos/plugin-intiface";
35+
import { genLayerPlugin } from "@elizaos/plugin-genlayer";
3636
import { DirectClient } from "@elizaos/client-direct";
37+
import { ThreeDGenerationPlugin } from "@elizaos/plugin-3d-generation";
38+
import { abstractPlugin } from "@elizaos/plugin-abstract";
3739
import { aptosPlugin } from "@elizaos/plugin-aptos";
40+
import { avalanchePlugin } from "@elizaos/plugin-avalanche";
3841
import {
3942
advancedTradePlugin,
4043
coinbaseCommercePlugin,
@@ -44,32 +47,29 @@ import {
4447
webhookPlugin,
4548
} from "@elizaos/plugin-coinbase";
4649
import { confluxPlugin } from "@elizaos/plugin-conflux";
50+
import { cronosZkEVMPlugin } from "@elizaos/plugin-cronoszkevm";
51+
import { echoChamberPlugin } from "@elizaos/plugin-echochambers";
4752
import { evmPlugin } from "@elizaos/plugin-evm";
48-
import { storyPlugin } from "@elizaos/plugin-story";
4953
import { flowPlugin } from "@elizaos/plugin-flow";
5054
import { fuelPlugin } from "@elizaos/plugin-fuel";
5155
import { imageGenerationPlugin } from "@elizaos/plugin-image-generation";
52-
import { ThreeDGenerationPlugin } from "@elizaos/plugin-3d-generation";
5356
import { multiversxPlugin } from "@elizaos/plugin-multiversx";
5457
import { nearPlugin } from "@elizaos/plugin-near";
5558
import { nftGenerationPlugin } from "@elizaos/plugin-nft-generation";
5659
import { createNodePlugin } from "@elizaos/plugin-node";
5760
import { solanaPlugin } from "@elizaos/plugin-solana";
61+
import { storyPlugin } from "@elizaos/plugin-story";
5862
import { suiPlugin } from "@elizaos/plugin-sui";
5963
import { TEEMode, teePlugin } from "@elizaos/plugin-tee";
6064
import { tonPlugin } from "@elizaos/plugin-ton";
61-
import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";
62-
import { cronosZkEVMPlugin } from "@elizaos/plugin-cronoszkevm";
63-
import { abstractPlugin } from "@elizaos/plugin-abstract";
64-
import { avalanchePlugin } from "@elizaos/plugin-avalanche";
6565
import { webSearchPlugin } from "@elizaos/plugin-web-search";
66-
import { echoChamberPlugin } from "@elizaos/plugin-echochambers";
66+
import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";
6767
import Database from "better-sqlite3";
6868
import fs from "fs";
69+
import net from "net";
6970
import path from "path";
7071
import { fileURLToPath } from "url";
7172
import yargs from "yargs";
72-
import net from "net";
7373

7474
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
7575
const __dirname = path.dirname(__filename); // get the name of the directory
@@ -609,6 +609,9 @@ export async function createAgent(
609609
getSecret(character, "ECHOCHAMBERS_API_KEY")
610610
? echoChamberPlugin
611611
: null,
612+
getSecret(character, "GENLAYER_PRIVATE_KEY")
613+
? genLayerPlugin
614+
: null,
612615
].filter(Boolean),
613616
providers: [],
614617
actions: [],

docs/community/Discord/development/coders/chat_2024-12-05.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# 💻-coders 2024-12-05
22

33
## Summary
4+
45
The discussion focused on creating custom plugins, running them from .json files to TS configs. Lambert successfully ran his methods using 'plugins: []' without modifying agent/src/index.ts but with custom clients calling the plugin. Ayvaras mentioned memory consumption issues needing optimization.
56

67
## FAQ
8+
79
- Is there a ts equivalent for running a character from a json file? How to import and use custom plugins in agent/src/index.ts? (asked by [DL])
810
- How did you solve the memory consumption issue with your uncensored model? (asked by [nylon, nylon])
911
- What's the difference between Solana plugin and Goat one? How to login with cookies in browser, then copy into .env file following specific syntax mentioned somewhere on README? (asked by [SotoAlt | WAWE])
@@ -16,20 +18,22 @@ The discussion focused on creating custom plugins, running them from .json files
1618
- Why am I getting an error when trying to generate a new tweet? What should be in the .env file for it to work correctly? (asked by @Manasvi)
1719

1820
## Who Helped Who
21+
1922
- [DL] helped [dl] with Create a custom plugin for characters and import it into the ts file. by providing Odilitime explained how to set up character object in agent/src/index.ts.
2023
- [coinwitch (ai16z intern)] helped [SotoAlt | WAWE] with Troubleshooting Eliza Agent by providing coinwitch helped with getting the agent working in eliza-starter project.
2124
- @sototal helped @ayvaras with Resolving server IP change issue by providing SotoAlt | WAWE suggested using cookies for login and enabling 2FA as a solution.
2225
- 'Try without' and 'nah my agent doesn't have any', suggesting Ayvaras to test the software feature with cookies disabled. helped [Ayvaras (02:39, 02:41)] with 'Investigate why setting VPN doesn't work' by providing [lambert (02:38, 02:40)]
2326
- @lambert, @Tharakesh helped @Ayvaras with Troubleshooting cookie usage in the application by providing Ayvaras asked for help with cookies and database deletion
2427
- @lambert helped @Manasvi with Troubleshooting error in Eliza project. by providing Provided guidance on checking Twitter API credentials and ensuring correct setup.
2528
- frenchplace helped problem with loading content into memory via API or commands with loading sources for agent's knowledge by providing Robotic Dreams provided a solution on how to specify plugins in character file and set required fields.
26-
- @DL helped @cleverson1 with Resolving Twitter integration issue with @ai16z/plugin-image-generation. by providing DL (@ai16z) provided guidance on using image plugin without specifying plugins field and ensuring correct AI API keys are used.
29+
- @DL helped @cleverson1 with Resolving Twitter integration issue with @elizaos/plugin-image-generation. by providing DL (@ai16z) provided guidance on using image plugin without specifying plugins field and ensuring correct AI API keys are used.
2730
- [Bunchu] helped [Cleverson1] with Adding web search plugin by providing @bunchu helped @cleverson1 by providing steps to add a plugin and resolve image posting issue.
2831
- kungfumode helped Agent Issue Resolution Successful. with Tweet formatting by providing Ayvaras provided a PR to fix the issue of agents posting multi-line tweets.
2932

3033
## Action Items
3134

3235
### Technical Tasks
36+
3337
- Create a custom plugin for character files (mentioned by [DL, lambert])
3438
- Create a TG token bot (mentioned by [SotoAlt | WAWE])
3539
- Watch Agent Dev School videos for learning (mentioned by @coinwitch)
@@ -45,12 +49,14 @@ The discussion focused on creating custom plugins, running them from .json files
4549
- Fix tweet formatting issue by applying PR #856 (mentioned by Ayvaras)
4650

4751
### Documentation Needs
52+
4853
- Optimize memory consumption of the uncensored model. (mentioned by Ayvaras)
4954
- Fix the issue with `Cannot GET /` error in eliza-starter project. (mentioned by [coinwitch (ai16z intern)])
5055
- Ensure the .env file contains correct Twitter account details. (mentioned by Ayvaras)
5156
- Use pnpm run build for Twitter agent and terminal runtime agent, investigate if possible. (mentioned by Konstantine)
5257
- Create a GitHub issue to address image plugin documentation (mentioned by @coinwitch (ai16z intern))
53-
- Add @ai16z/plugin-web-search to dependencies in package.json and import it into index.ts. (mentioned by [Bunchu])
58+
- Add @elizaos/plugin-web-search to dependencies in package.json and import it into index.ts. (mentioned by [Bunchu])
5459

5560
### Feature Requests
56-
- Resolve server IP change issue by using cookies or enabling two-factor authentication (2FA) (mentioned by @SotoAlt | WAWE)
61+
62+
- Resolve server IP change issue by using cookies or enabling two-factor authentication (2FA) (mentioned by @SotoAlt | WAWE)

packages/plugin-aptos/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"dependencies": {
2222
"@elizaos/core": "workspace:*",
2323
"@aptos-labs/ts-sdk": "^1.26.0",
24-
"bignumber": "1.1.0",
2524
"bignumber.js": "9.1.2",
2625
"node-cache": "5.1.2",
2726
"tsup": "8.3.5",

packages/plugin-cronoszkevm/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
],
2121
"dependencies": {
2222
"@elizaos/core": "workspace:*",
23-
"@elizaos/plugin-trustdb": "workspace:*",
2423
"tsup": "^8.3.5",
2524
"web3": "^4.15.0",
2625
"web3-plugin-zksync": "^1.0.8"

packages/plugin-cronoszkevm/src/enviroment.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IAgentRuntime } from "@elizaos/eliza";
1+
import { IAgentRuntime } from "@elizaos/core";
22
import { z } from "zod";
33

44
export const CronosZkEVMEnvSchema = z.object({

packages/plugin-genlayer/package.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "@elizaos/plugin-genlayer",
3+
"version": "0.1.0",
4+
"main": "dist/index.js",
5+
"type": "module",
6+
"types": "dist/index.d.ts",
7+
"scripts": {
8+
"build": "tsup --format esm --dts",
9+
"dev": "tsup --format esm --dts --watch",
10+
"lint": "eslint . --fix",
11+
"test": "vitest run"
12+
},
13+
"dependencies": {
14+
"genlayer-js": "0.4.7",
15+
"@elizaos/core": "workspace:*",
16+
"tsup": "8.3.5"
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
import {
2+
Action,
3+
HandlerCallback,
4+
IAgentRuntime,
5+
Memory,
6+
State,
7+
elizaLogger,
8+
} from "@elizaos/core";
9+
import fs from "fs";
10+
import { DeployContractParams } from "../types";
11+
import { ClientProvider } from "../providers/client";
12+
import { getParamsWithLLM } from "../utils/llm";
13+
14+
const deployContractTemplate = `
15+
# Task: Determine the contract code file path and constructor arguments for deploying a contract.
16+
17+
# Instructions: The user is requesting to deploy a contract to the GenLayer protocol.
18+
19+
<latest user message>
20+
{{userMessage}}
21+
</latest user message>
22+
23+
<data from recent messages>
24+
{{recentMessagesData}}
25+
</data from recent messages>
26+
27+
# Your response must be formatted as a JSON block with this structure:
28+
\`\`\`json
29+
{
30+
"code_file": "<Contract Code File Path>",
31+
"args": [<Constructor Args>],
32+
"leaderOnly": <true/false>
33+
}
34+
\`\`\`
35+
`;
36+
37+
export const deployContractAction: Action = {
38+
name: "DEPLOY_CONTRACT",
39+
similes: ["DEPLOY_CONTRACT"],
40+
description: "Deploy a contract to the GenLayer protocol",
41+
validate: async (runtime: IAgentRuntime) => {
42+
const privateKey = runtime.getSetting("GENLAYER_PRIVATE_KEY");
43+
return typeof privateKey === "string" && privateKey.startsWith("0x");
44+
},
45+
handler: async (
46+
runtime: IAgentRuntime,
47+
message: Memory,
48+
state: State,
49+
_options: any,
50+
callback: HandlerCallback
51+
) => {
52+
elizaLogger.info("Starting deploy contract action");
53+
elizaLogger.debug("User message:", message.content.text);
54+
55+
const clientProvider = new ClientProvider(runtime);
56+
const options = await getParamsWithLLM<DeployContractParams>(
57+
runtime,
58+
message,
59+
deployContractTemplate,
60+
state
61+
);
62+
63+
if (!options) {
64+
elizaLogger.error("Failed to parse deploy contract parameters");
65+
throw new Error("Failed to parse deploy contract parameters");
66+
}
67+
68+
elizaLogger.debug("Parsed parameters:", options);
69+
elizaLogger.info(
70+
"Deploying contract with code length:",
71+
options.code_file.length
72+
);
73+
74+
const code = await fs.readFileSync(options.code_file, "utf8");
75+
76+
const result = await clientProvider.client.deployContract({
77+
code: code,
78+
args: options.args,
79+
leaderOnly: options.leaderOnly,
80+
});
81+
82+
elizaLogger.success(
83+
`Successfully sent contract for deployment. Transaction hash: ${result}`
84+
);
85+
await callback(
86+
{
87+
text: `Successfully sent contract for deployment. Transaction hash: ${result}`,
88+
},
89+
[]
90+
);
91+
},
92+
examples: [
93+
[
94+
{
95+
user: "{{user1}}",
96+
content: {
97+
text: "Deploy a new contract from /home/az/yeagerai/genlayer-studio/examples/contracts/wizard_of_coin.py with the argument 'true'",
98+
},
99+
},
100+
{
101+
user: "{{agentName}}",
102+
content: {
103+
text: "Deploying contract...",
104+
action: "DEPLOY_CONTRACT",
105+
},
106+
},
107+
],
108+
[
109+
{
110+
user: "{{user1}}",
111+
content: {
112+
text: "Please help me deploy a contract",
113+
},
114+
},
115+
{
116+
user: "{{agentName}}",
117+
content: {
118+
text: "Sure! I'll help you deploy a contract. Please provide the code file path and constructor arguments.",
119+
action: "CONTINUE",
120+
},
121+
},
122+
{
123+
user: "{{user1}}",
124+
content: {
125+
text: "The code file is /home/az/yeagerai/genlayer-studio/examples/contracts/wizard_of_coin.py",
126+
},
127+
},
128+
{
129+
user: "{{agentName}}",
130+
content: {
131+
text: "Understood, I'll help you deploy the contract from /home/az/yeagerai/genlayer-studio/examples/contracts/wizard_of_coin.py. Now, please provide the constructor arguments.",
132+
action: "CONTINUE",
133+
},
134+
},
135+
{
136+
user: "{{user1}}",
137+
content: {
138+
text: "The constructor argument is 'true'",
139+
},
140+
},
141+
{
142+
user: "{{agentName}}",
143+
content: {
144+
text: "Perfect, I'll help you deploy the contract from /home/az/yeagerai/genlayer-studio/examples/contracts/wizard_of_coin.py with the argument 'true'.",
145+
action: "DEPLOY_CONTRACT",
146+
},
147+
},
148+
],
149+
],
150+
};

0 commit comments

Comments
 (0)