Skip to content
Open
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
45 changes: 43 additions & 2 deletions agent-tee-phala/image/agent/elizaos/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import type { Plugin } from "@elizaos/core";
import { AgentRuntime, ModelProviderName, type Character, type Plugin } from "@elizaos/core";
import initSqlJs from "sql.js";
import { getWalletClient, getWalletProvider } from "./wallet";
import { SqlJsDatabaseAdapter } from "@elizaos/adapter-sqljs";

export default async function createElizaGoatPlugin(): Promise<Plugin> {
const openaiApiKey = process.env.OPENAI_API_KEY;
if (!openaiApiKey) {
throw new Error("Missing OPENAI_API_KEY environment variable");
}

async function createElizaGoatPlugin(): Promise<Plugin> {
const { walletClient, actions } = await getWalletClient();
return {
name: "[GOAT] Onchain Actions",
Expand All @@ -12,3 +19,37 @@ export default async function createElizaGoatPlugin(): Promise<Plugin> {
actions,
};
}

export default async function startElizaGoatPlugin() {
const plugins = await createElizaGoatPlugin();
const character: Character = {
name: "Rufus Agent",
adjectives: ["smart", "helpful", "friendly"],
lore: ["You are a helpful assistant that can help with a variety of tasks."],
bio: "You are a helpful assistant that can help with a variety of tasks.",
plugins: [plugins],
clients: [],
messageExamples: [],
modelProvider: ModelProviderName.OPENAI,
postExamples: [],
style: { all: [], chat: [], post: [] },
topics: [],
};

// Initialize the database
const SQL = await initSqlJs({
locateFile: (file) => `https://sql.js.org/dist/${file}`,
});
const db = new SQL.Database();

// Initialize the agent
const agent = new AgentRuntime({
character,
modelProvider: ModelProviderName.OPENAI,
token: openaiApiKey as string,
databaseAdapter: new SqlJsDatabaseAdapter(db),
cacheManager: undefined as any,
});
await agent.initialize();
console.log("Agent initialized...");
}
18 changes: 10 additions & 8 deletions agent-tee-phala/image/agent/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import startVercelAiAgent from "./vercel-ai";
import startElizaGoatPlugin from "./elizaos";

export default async function startAgent() {
console.log("Starting agent...");
await startVercelAiAgent();
console.log("Agent started");
}

startAgent();
(async function () {
try {
console.log("Starting agent...");
await startElizaGoatPlugin();
console.log("Agent started");
} catch (error) {
console.error("Error starting agent:", error);
}
})();
1 change: 1 addition & 0 deletions agent-tee-phala/image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@phala/dstack-sdk": "^0.1.10",
"@solana/web3.js": "^1.98.0",
"@types/express": "^5.0.0",
"@types/sql.js": "^1.4.9",
"ai": "^4.1.24",
"dotenv": "^16.4.5",
"express": "^4.21.2",
Expand Down
3 changes: 3 additions & 0 deletions agent-tee-phala/image/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.