Skip to content

Commit e1b7c80

Browse files
autonome-aiwtfsayoodilitimecoderabbitai[bot]
authored
feat: support autonome platform (#2121)
* feat: support autonome platform * Update packages/plugin-autonome/src/actions/launchAgent.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix typo * Update packages/plugin-autonome/src/actions/launchAgent.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: Sayo <hi@sayo.wtf> Co-authored-by: Odilitime <janesmith@airmail.cc> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 4df0e5b commit e1b7c80

11 files changed

+290
-0
lines changed

.env.example

+4
Original file line numberDiff line numberDiff line change
@@ -476,3 +476,7 @@ TAVILY_API_KEY=
476476
# Verifiable Inference Configuration
477477
VERIFIABLE_INFERENCE_ENABLED=false # Set to false to disable verifiable inference
478478
VERIFIABLE_INFERENCE_PROVIDER=opacity # Options: opacity
479+
480+
# Autonome Configuration
481+
AUTONOME_JWT_TOKEN=
482+
AUTONOME_RPC=https://wizard-bff-rpc.alt.technology/v1/bff/aaa/apps

agent/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"@elizaos/plugin-node": "workspace:*",
5858
"@elizaos/plugin-solana": "workspace:*",
5959
"@elizaos/plugin-solana-agentkit": "workspace:*",
60+
"@elizaos/plugin-autonome": "workspace:*",
6061
"@elizaos/plugin-starknet": "workspace:*",
6162
"@elizaos/plugin-stargaze": "workspace:*",
6263
"@elizaos/plugin-giphy": "workspace:*",

agent/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import { obsidianPlugin } from "@elizaos/plugin-obsidian";
7171
import { sgxPlugin } from "@elizaos/plugin-sgx";
7272
import { solanaPlugin } from "@elizaos/plugin-solana";
7373
import { solanaAgentkitPlguin } from "@elizaos/plugin-solana-agentkit";
74+
import { autonomePlugin } from "@elizaos/plugin-autonome";
7475
import { storyPlugin } from "@elizaos/plugin-story";
7576
import { suiPlugin } from "@elizaos/plugin-sui";
7677
import { TEEMode, teePlugin } from "@elizaos/plugin-tee";
@@ -637,6 +638,7 @@ export async function createAgent(
637638
getSecret(character, "SOLANA_PRIVATE_KEY")
638639
? solanaAgentkitPlguin
639640
: null,
641+
getSecret(character, "AUTONOME_JWT_TOKEN") ? autonomePlugin : null,
640642
(getSecret(character, "NEAR_ADDRESS") ||
641643
getSecret(character, "NEAR_WALLET_PUBLIC_KEY")) &&
642644
getSecret(character, "NEAR_WALLET_SECRET_KEY")

packages/plugin-autonome/.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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import eslintGlobalConfig from "../../eslint.config.mjs";
2+
3+
export default [...eslintGlobalConfig];

packages/plugin-autonome/package.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "@elizaos/plugin-autonome",
3+
"version": "0.1.7-alpha.1",
4+
"main": "dist/index.js",
5+
"type": "module",
6+
"types": "dist/index.d.ts",
7+
"dependencies": {
8+
"@coral-xyz/anchor": "0.30.1",
9+
"@elizaos/core": "workspace:*",
10+
"@elizaos/plugin-tee": "workspace:*",
11+
"@elizaos/plugin-trustdb": "workspace:*",
12+
"axios": "^1.7.9"
13+
},
14+
"scripts": {
15+
"build": "tsup --format esm --dts",
16+
"dev": "tsup --format esm --dts --watch",
17+
"lint": "eslint --fix --cache .",
18+
"test": "vitest run"
19+
},
20+
"peerDependencies": {
21+
"form-data": "4.0.1",
22+
"whatwg-url": "7.1.0"
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
import axios from "axios";
2+
import {
3+
ActionExample,
4+
composeContext,
5+
Content,
6+
elizaLogger,
7+
generateObjectDeprecated,
8+
HandlerCallback,
9+
IAgentRuntime,
10+
Memory,
11+
ModelClass,
12+
State,
13+
type Action,
14+
} from "@elizaos/core";
15+
16+
export interface LaunchAgentContent extends Content {
17+
name: string;
18+
config: string;
19+
}
20+
21+
function isLaunchAgentContent(content: any): content is LaunchAgentContent {
22+
elizaLogger.log("Content for launchAgent", content);
23+
return typeof content.name === "string" && typeof content.config === "string";
24+
}
25+
26+
const launchTemplate = `Respond with a JSON markdown block containing only the extracted values. Use null for any values that cannot be determined.
27+
28+
Example response:
29+
\`\`\`json
30+
{
31+
"name": "xiaohuo",
32+
}
33+
\`\`\`
34+
35+
{{recentMessages}}
36+
37+
Given the recent messages, extract the following information about the requested agent launch:
38+
- Agent name
39+
- Character json config
40+
`;
41+
42+
export default {
43+
name: "LAUNCH_AGENT",
44+
similes: ["CREATE_AGENT", "DEPLOY_AGENT", "DEPLOY_ELIZA", "DEPLOY_BOT"],
45+
validate: async (runtime: IAgentRuntime, message: Memory) => {
46+
return true;
47+
},
48+
description: "Launch an Eliza agent",
49+
handler: async (
50+
runtime: IAgentRuntime,
51+
message: Memory,
52+
state: State,
53+
_options: { [key: string]: unknown },
54+
callback?: HandlerCallback
55+
): Promise<boolean> => {
56+
elizaLogger.log("Starting LAUNCH_AGENT handler...");
57+
// Initialize or update state
58+
if (!state) {
59+
state = (await runtime.composeState(message)) as State;
60+
} else {
61+
state = await runtime.updateRecentMessageState(state);
62+
}
63+
64+
// Compose launch context
65+
const launchContext = composeContext({
66+
state,
67+
template: launchTemplate,
68+
});
69+
70+
// Generate launch content
71+
const content = await generateObjectDeprecated({
72+
runtime,
73+
context: launchContext,
74+
modelClass: ModelClass.LARGE,
75+
});
76+
77+
// Validate launch content
78+
if (!isLaunchAgentContent(content)) {
79+
elizaLogger.error("Invalid launch content", content);
80+
if (callback) {
81+
callback({
82+
text: "Unable to process launch agent request. Invalid content provided.",
83+
content: { error: "Invalid launch agent content" },
84+
});
85+
}
86+
return false;
87+
}
88+
89+
const autonomeJwt = runtime.getSetting("AUTONOME_JWT_TOKEN");
90+
const autonomeRpc = runtime.getSetting("AUTONOME_RPC");
91+
92+
const requestBody = {
93+
name: content.name,
94+
config: content.config,
95+
creationMethod: 2,
96+
envList: {},
97+
templateId: "Eliza",
98+
99+
const sendPostRequest = async () => {
100+
try {
101+
const response = await axios.post(autonomeRpc, requestBody, {
102+
headers: {
103+
Authorization: `Bearer ${autonomeJwt}`,
104+
"Content-Type": "application/json",
105+
},
106+
});
107+
return response;
108+
} catch (error) {
109+
console.error("Error making RPC call:", error);
110+
}
111+
};
112+
113+
try {
114+
const resp = await sendPostRequest();
115+
if (resp && resp.data && resp.data.app && resp.data.app.id) {
116+
elizaLogger.log(
117+
"Launching successful, please find your agent on"
118+
);
119+
elizaLogger.log(
120+
"https://dev.autonome.fun/autonome/" +
121+
resp.data.app.id +
122+
"/details"
123+
);
124+
}
125+
if (callback) {
126+
callback({
127+
text: `Successfully launch agent ${content.name}`,
128+
content: {
129+
success: true,
130+
appId:
131+
"https://dev.autonome.fun/autonome/" +
132+
resp.data.app.id +
133+
"/details",
134+
},
135+
});
136+
}
137+
return true;
138+
} catch (error) {
139+
if (callback) {
140+
elizaLogger.error("Error during launching agent");
141+
elizaLogger.error(error);
142+
callback({
143+
text: `Error launching agent: ${error.message}`,
144+
content: { error: error.message },
145+
});
146+
}
147+
}
148+
},
149+
examples: [
150+
[
151+
{
152+
user: "{{user1}}",
153+
content: {
154+
text: "Launch an agent, name is xiaohuo",
155+
},
156+
},
157+
{
158+
user: "{{user2}}",
159+
content: {
160+
text: "I'll launch the agent now...",
161+
action: "LAUNCH_AGENT",
162+
},
163+
},
164+
{
165+
user: "{{user2}}",
166+
content: {
167+
text: "Successfully launch agent, id is ba2e8369-e256-4a0d-9f90-9c64e306dc9f",
168+
},
169+
},
170+
],
171+
] as ActionExample[][],
172+
} as Action;

packages/plugin-autonome/src/index.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Plugin } from "@elizaos/core";
2+
import launchAgent from "./actions/launchAgent";
3+
4+
export const autonomePlugin: Plugin = {
5+
name: "autonome",
6+
description: "Autonome Plugin for Eliza",
7+
actions: [launchAgent],
8+
evaluators: [],
9+
providers: [],
10+
};
11+
12+
export default autonomePlugin;
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../core/tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "dist",
5+
"rootDir": "src"
6+
},
7+
"include": [
8+
"src/**/*.ts"
9+
]
10+
}
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
"safe-buffer",
19+
"base-x",
20+
"bs58",
21+
"borsh",
22+
"@solana/buffer-layout",
23+
"stream",
24+
"buffer",
25+
"querystring",
26+
"amqplib",
27+
// Add other modules you want to externalize
28+
],
29+
});

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)