Skip to content

Commit f44f0dc

Browse files
feat: lint
1 parent f14e9e0 commit f44f0dc

21 files changed

+1235
-73
lines changed

agent/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"@ai16z/plugin-solana": "workspace:*",
2727
"@ai16z/plugin-starknet": "workspace:*",
2828
"@ai16z/plugin-coinbase": "workspace:*",
29+
"@ai16z/plugin-eternum": "workspace:*",
2930
"readline": "^1.3.0",
3031
"ws": "^8.18.0",
3132
"yargs": "17.7.2"

agent/src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import path from "path";
3434
import { fileURLToPath } from "url";
3535
import { character } from "./character.ts";
3636
import type { DirectClient } from "@ai16z/client-direct";
37+
import blobert from "./blobert.ts";
3738

3839
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
3940
const __dirname = path.dirname(__filename); // get the name of the directory
@@ -318,7 +319,7 @@ const startAgents = async () => {
318319

319320
let charactersArg = args.characters || args.character;
320321

321-
let characters = [character];
322+
let characters = [blobert];
322323

323324
if (charactersArg) {
324325
characters = await loadCharacters(charactersArg);

packages/core/src/runtime.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,10 @@ Text: ${attachment.text}
11661166
return { ...initialState, ...actionState } as State;
11671167
}
11681168

1169-
async updateRecentMessageState(state: State): Promise<State> {
1169+
async updateRecentMessageState(
1170+
state: State,
1171+
additionalKeys: { [key: string]: unknown } = {}
1172+
): Promise<State> {
11701173
const conversationLength = this.getConversationLength();
11711174
const recentMessagesData = await this.messageManager.getMemories({
11721175
roomId: state.roomId,
@@ -1227,6 +1230,7 @@ Text: ${attachment.text}
12271230
),
12281231
recentMessagesData,
12291232
attachments: formattedAttachments,
1233+
...additionalKeys,
12301234
} as State;
12311235
}
12321236
}

packages/core/src/types.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,10 @@ export interface IAgentRuntime {
10081008
additionalKeys?: { [key: string]: unknown }
10091009
): Promise<State>;
10101010

1011-
updateRecentMessageState(state: State): Promise<State>;
1011+
updateRecentMessageState(
1012+
state: State,
1013+
additionalKeys?: { [key: string]: unknown }
1014+
): Promise<State>;
10121015
}
10131016

10141017
export interface IImageDescriptionService extends Service {

packages/plugin-eternum/.npmignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*
2+
3+
!dist/**
4+
!package.json
5+
!readme.md
6+
!tsup.config.ts

packages/plugin-eternum/package.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "@ai16z/plugin-eternum",
3+
"version": "0.1.4-alpha.3",
4+
"main": "dist/index.js",
5+
"type": "module",
6+
"types": "dist/index.d.ts",
7+
"dependencies": {
8+
"@ai16z/eliza": "0.1.4-alpha.3",
9+
"@ai16z/plugin-trustdb": "0.1.4-alpha.3",
10+
"@avnu/avnu-sdk": "^2.1.1",
11+
"@uniswap/sdk-core": "^6.0.0",
12+
"@unruggable_starknet/core": "^0.1.0",
13+
"langsmith": "^0.2.7",
14+
"openai": "^4.73.0",
15+
"starknet": "^6.17.0",
16+
"tsup": "^8.3.5",
17+
"vitest": "^2.1.4"
18+
},
19+
"scripts": {
20+
"build": "tsup --format esm --dts",
21+
"test": "vitest run",
22+
"test:watch": "vitest"
23+
},
24+
"peerDependencies": {
25+
"whatwg-url": "7.1.0"
26+
}
27+
}

packages/plugin-eternum/readme.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Eternum Plugin
2+
3+
## Overview
4+
5+
The idea here is that we provide the agent with context about the game:
6+
7+
1. Decide Task
8+
2. Decide Action
9+
3. Execute Action
10+
11+
### Runtime
12+
13+
Each of these steps could themselves be a few steps, this is very rough.
14+
15+
Look at [eternum/src/provider/index.ts](./eternum/src/provider/index.ts) for rough example of how the messages could
16+
work.
17+
18+
_Query 1:_
19+
20+
1. Look at goal, state of realm. So resource balances, buildings etc (this is fetched from a DB right?)
21+
2. Decide what information is needed for the context. (this is done by an LLM?) Create a graphql query for it, and fetch the information. Keep in
22+
context.
23+
3. Decide if you want to take an action or not. (we have a list of actions defined in the same way as eliza?)
24+
25+
- If not, return and ask question again in 1 minute
26+
- If yes, continue to Query 2
27+
28+
_Query 2:_
29+
30+
1. Pass context from Query 1 into another lookup to find how to take that action.
31+
2. consume the cache of available actions
32+
(wouldn't this be redundant if we have actions defined in the Eliza way?)
33+
34+
_Execute 3:_
35+
36+
1. Take an action or not.
37+
38+
if success -> save memory
39+
40+
Repeat
41+
42+
### TODO:
43+
44+
1. Create file will all available actions formatted calldata. Don't we already have that in the EternumProvider? Or do
45+
you mean Eliza actions?
46+
47+
- Add TypeDoc to all the Providers. In the example of the typedoc include formatted call data.
48+
- Write a script to extract only the typedoc information and save it to a file. This is what we will cache in the db. We
49+
need to be able to run this again so making a helper function is the key
50+
51+
2. Get all graphql models in a cache somehow. The entire generated files are too big. We need to compress the
52+
information of the available queries just enough that the model will still understand it.
53+
54+
3. Write Action that runs like the above. We just want everything encapsulated within that one ACTION for gameplay.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
export const GAME_DESCRIPTION = `
2+
Eternum is a browser-based game where you manage a realm and its resources.
3+
4+
To build a Realm you need the required resources. Which are:
5+
- 2500 Wood
6+
- 1800 Stone
7+
- 3000 Gold
8+
- 1200 Food
9+
- 500 Iron
10+
11+
To upgrade your Realm to Level 2 you need:
12+
- 5000 Wood
13+
- 3600 Stone
14+
- 6000 Gold
15+
- 2400 Food
16+
- 1000 Iron
17+
18+
To build a Military Academy you need:
19+
- 3000 Wood
20+
- 2500 Stone
21+
- 4000 Gold
22+
- 1500 Food
23+
- 800 Iron
24+
25+
To construct a Market you need:
26+
- 2000 Wood
27+
- 1500 Stone
28+
- 5000 Gold
29+
- 1000 Food
30+
- 300 Iron
31+
`;
32+
33+
export const WORLD_STATE = `You have:
34+
35+
Resources:
36+
- 3000 Wood
37+
- 1800 Stone
38+
- 3000 Gold
39+
- 1200 Food
40+
- 500 Iron
41+
42+
Standing Army:
43+
- 150 Swordsmen
44+
- 75 Archers
45+
- 25 Cavalry
46+
- 10 Siege Weapons
47+
- 5 War Elephants`;
48+
49+
export const AVAILABLE_QUERIES = `Available GraphQL Queries:
50+
51+
query GetResources {
52+
resources(playerId: "123") {
53+
wood
54+
stone
55+
gold
56+
food
57+
}
58+
}
59+
60+
query GetBaseMap {
61+
baseMap(playerId: "123") {
62+
tiles {
63+
x
64+
y
65+
type
66+
building {
67+
id
68+
type
69+
level
70+
}
71+
}
72+
}
73+
}
74+
75+
query GetMarketPrices {
76+
market {
77+
resources {
78+
name
79+
buyPrice
80+
sellPrice
81+
volume24h
82+
}
83+
}
84+
}`;
85+
export const AVAILABLE_ACTIONS = `Available Actions:
86+
87+
Create Realm:
88+
- Creates a new realm with the specified ID
89+
- Example calldata:
90+
{
91+
contractAddress: "realm",
92+
entrypoint: "create_realm",
93+
calldata: [
94+
realm_id,
95+
"0x1a3e37c77be7de91a9177c6b57956faa6da25607e567b10a25cf64fea5e533b"
96+
]
97+
}
98+
99+
Upgrade Realm:
100+
- Upgrades a realm to the next level
101+
- Example calldata:
102+
{
103+
contractAddress: "realm",
104+
entrypoint: "upgrade_realm",
105+
calldata: [
106+
realm_entity_id
107+
]
108+
}
109+
110+
Set Entity Name:
111+
- Sets the name for a specific entity
112+
- Example calldata:
113+
{
114+
contractAddress: "entity",
115+
entrypoint: "set_name",
116+
calldata: [
117+
entity_id,
118+
name
119+
]
120+
}`;

0 commit comments

Comments
 (0)