Skip to content

Commit 9fb49b5

Browse files
committed
add auto lock
1 parent ada9486 commit 9fb49b5

File tree

7 files changed

+155
-30
lines changed

7 files changed

+155
-30
lines changed

packages/agent/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@ai16z/adapter-postgres": "workspace:*",
1717
"@ai16z/adapter-sqlite": "workspace:*",
1818
"@ai16z/client-direct": "workspace:*",
19+
"@ai16z/client-auto": "workspace:*",
1920
"@ai16z/client-discord": "workspace:*",
2021
"@ai16z/client-telegram": "workspace:*",
2122
"@ai16z/client-twitter": "workspace:*",

packages/agent/src/index.ts

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { PostgresDatabaseAdapter } from "@ai16z/adapter-postgres/src/index.ts";
22
import { SqliteDatabaseAdapter } from "@ai16z/adapter-sqlite/src/index.ts";
33
import { DirectClientInterface } from "@ai16z/client-direct/src/index.ts";
44
import { DiscordClientInterface } from "@ai16z/client-discord/src/index.ts";
5+
import { AutoClientInterface } from "@ai16z/client-auto/src/index.ts";
56
import { TelegramClientInterface } from "@ai16z/client-telegram/src/index.ts";
67
import { TwitterClientInterface } from "@ai16z/client-twitter/src/index.ts";
78
import { defaultCharacter } from "@ai16z/eliza/src/defaultCharacter.ts";
@@ -174,6 +175,11 @@ export async function initializeClients(
174175
const clientTypes =
175176
character.clients?.map((str) => str.toLowerCase()) || [];
176177

178+
if (clientTypes.includes("auto")) {
179+
const autoClient = await AutoClientInterface.start(runtime);
180+
if (autoClient) clients.push(autoClient);
181+
}
182+
177183
if (clientTypes.includes("discord")) {
178184
clients.push(await DiscordClientInterface.start(runtime));
179185
}

packages/client-auto/package.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "@ai16z/client-auto",
3+
"version": "0.0.1",
4+
"main": "dist/index.js",
5+
"type": "module",
6+
"types": "dist/index.d.ts",
7+
"dependencies": {
8+
"@ai16z/eliza": "workspace:*",
9+
"@ai16z/plugin-image-generation": "workspace:*",
10+
"@types/body-parser": "1.19.5",
11+
"@types/cors": "2.8.17",
12+
"@types/express": "5.0.0",
13+
"body-parser": "1.20.3",
14+
"cors": "2.8.5",
15+
"multer": "1.4.5-lts.1"
16+
},
17+
"devDependencies": {
18+
"tsup": "^8.3.5"
19+
},
20+
"scripts": {
21+
"build": "tsup --format esm --dts",
22+
"dev": "tsup --watch"
23+
},
24+
"peerDependencies": {
25+
"whatwg-url": "7.1.0"
26+
}
27+
}

packages/client-auto/src/index.ts

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import {
2+
Client,
3+
IAgentRuntime
4+
} from "@ai16z/eliza/src/types.ts";
5+
6+
7+
export class AutoClient {
8+
interval: NodeJS.Timeout;
9+
runtime: IAgentRuntime;
10+
11+
constructor(runtime: IAgentRuntime) {
12+
this.runtime = runtime;
13+
// start a loop that runs every x seconds
14+
this.interval = setInterval(() => {
15+
this.makeTrades();
16+
}, 60 * 60 * 1000); // 1 hour in milliseconds
17+
18+
}
19+
20+
makeTrades() {
21+
console.log("Running auto loop");
22+
23+
// malibu todos
24+
// get high trust recommendations
25+
26+
// get information for all tokens which were recommended
27+
// get any additional information we might need
28+
// make sure we're looking at the right tokens and data
29+
30+
// shaw -- TODOs
31+
// compose thesis context
32+
// write a thesis which trades and why
33+
34+
// compose trade context
35+
// geratate trades with LLM
36+
// parse trades from LLM
37+
// post thesis to twitter
38+
39+
// malibu todos
40+
// execute trades
41+
}
42+
}
43+
44+
export const AutoClientInterface: Client = {
45+
start: async (runtime: IAgentRuntime) => {
46+
const client = new AutoClient(runtime);
47+
return client;
48+
},
49+
stop: async (runtime: IAgentRuntime) => {
50+
console.warn("Direct client does not support stopping yet");
51+
},
52+
};
53+
54+
export default AutoClientInterface;

packages/client-auto/tsconfig.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "dist",
5+
"rootDir": "./src"
6+
},
7+
"include": ["src"]
8+
}

packages/client-auto/tsup.config.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { defineConfig } from "tsup";
2+
3+
export default defineConfig({
4+
entry: ["src/index.ts"],
5+
outDir: "dist",
6+
sourcemap: true,
7+
clean: true,
8+
format: ["esm"], // Ensure you're targeting CommonJS
9+
external: [
10+
"dotenv", // Externalize dotenv to prevent bundling
11+
"fs", // Externalize fs to use Node.js built-in module
12+
"path", // Externalize other built-ins if necessary
13+
"@reflink/reflink",
14+
"@node-llama-cpp",
15+
"https",
16+
"http",
17+
"agentkeepalive",
18+
// Add other modules you want to externalize
19+
],
20+
});

pnpm-lock.yaml

+39-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)