Skip to content

Commit f040918

Browse files
authored
Merge branch 'develop' into fix/spelling
2 parents 48c7806 + 0f643c0 commit f040918

26 files changed

+3394
-2061
lines changed

.github/workflows/smoke-tests.yml

+5-12
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,17 @@ on:
1010
jobs:
1111
smoke-tests:
1212
runs-on: ubuntu-latest
13-
container:
14-
image: node:23-bullseye
1513
steps:
1614
- uses: actions/checkout@v4
1715

18-
- name: Cache pnpm
19-
uses: actions/cache@v4
16+
- uses: pnpm/action-setup@v3
2017
with:
21-
path: |
22-
~/.pnpm-store
23-
**/node_modules
24-
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
25-
restore-keys: ${{ runner.os }}-pnpm-
18+
version: 9.15.0
2619

27-
- name: Setup pnpm
28-
uses: pnpm/action-setup@v3
20+
- uses: actions/setup-node@v4
2921
with:
30-
version: 9.15.0
22+
node-version: "23.3.0"
23+
cache: "pnpm"
3124

3225
- name: Run smoke tests
3326
run: pnpm run smokeTests

agent/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"@elizaos/plugin-node": "workspace:*",
6464
"@elizaos/plugin-solana": "workspace:*",
6565
"@elizaos/plugin-injective": "workspace:*",
66-
"@elizaos/plugin-solana-agentkit": "workspace:*",
66+
"@elizaos/plugin-solana-agent-kit": "workspace:*",
6767
"@elizaos/plugin-squid-router": "workspace:*",
6868
"@elizaos/plugin-autonome": "workspace:*",
6969
"@elizaos/plugin-starknet": "workspace:*",

agent/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ import { openWeatherPlugin } from "@elizaos/plugin-open-weather";
8585
import { quaiPlugin } from "@elizaos/plugin-quai";
8686
import { sgxPlugin } from "@elizaos/plugin-sgx";
8787
import { solanaPlugin } from "@elizaos/plugin-solana";
88-
import { solanaAgentkitPlugin } from "@elizaos/plugin-solana-agentkit";
88+
import { solanaAgentkitPlugin } from "@elizaos/plugin-solana-agent-kit";
8989
import { squidRouterPlugin } from "@elizaos/plugin-squid-router";
9090
import { stargazePlugin } from "@elizaos/plugin-stargaze";
9191
import { storyPlugin } from "@elizaos/plugin-story";

packages/plugin-solana-agentkit/package.json packages/plugin-solana-agent-kit/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@elizaos/plugin-solana-agentkit",
2+
"name": "@elizaos/plugin-solana-agent-kit",
33
"version": "0.1.9-alpha.1",
44
"main": "dist/index.js",
55
"type": "module",

packages/plugin-solana-agentkit/src/actions/createToken.ts packages/plugin-solana-agent-kit/src/actions/createToken.ts

+2-11
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import {
1111
State,
1212
type Action,
1313
} from "@elizaos/core";
14-
15-
import { SolanaAgentKit } from "solana-agent-kit";
16-
14+
import { getSAK } from "../client";
1715
export interface CreateTokenContent extends Content {
1816
name: string;
1917
uri: string;
@@ -103,14 +101,7 @@ export default {
103101
}
104102

105103
elizaLogger.log("Init solana agent kit...");
106-
const solanaPrivatekey = runtime.getSetting("SOLANA_PRIVATE_KEY");
107-
const rpc = runtime.getSetting("SOLANA_RPC_URL");
108-
const openAIKey = runtime.getSetting("OPENAI_API_KEY");
109-
const solanaAgentKit = new SolanaAgentKit(
110-
solanaPrivatekey,
111-
rpc,
112-
openAIKey
113-
);
104+
const solanaAgentKit = await getSAK(runtime);
114105
try {
115106
const deployedAddress = await solanaAgentKit.deployToken(
116107
content.name,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
2+
import { elizaLogger, } from "@elizaos/core";
3+
import {
4+
ActionExample,
5+
Content,
6+
HandlerCallback,
7+
IAgentRuntime,
8+
Memory,
9+
ModelClass,
10+
State,
11+
type Action,
12+
} from "@elizaos/core";
13+
import { composeContext } from "@elizaos/core";
14+
import { generateObjectDeprecated } from "@elizaos/core";
15+
import { ACTIONS } from "solana-agent-kit";
16+
import { getSAK } from "../client";
17+
18+
const GET_TOKEN_INFO_ACTION = ACTIONS.GET_TOKEN_DATA_ACTION;
19+
20+
export interface GetTokenInfoContent extends Content {
21+
tokenAddress: string;
22+
}
23+
24+
function isGetTokenInfoContent(
25+
runtime: IAgentRuntime,
26+
content: any
27+
): content is GetTokenInfoContent {
28+
elizaLogger.log("Content for transfer", content);
29+
return (
30+
typeof content.tokenAddress === "string"
31+
);
32+
}
33+
34+
const getTokenInfoTemplate = `Respond with a JSON markdown block containing only the extracted values. Use null for any values that cannot be determined.
35+
36+
Example response:
37+
\`\`\`json
38+
{
39+
"tokenAddress": "SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa",
40+
}
41+
\`\`\`
42+
43+
{{recentMessages}}
44+
45+
Given the recent messages, extract the following information about the requested token:
46+
- Token contract address
47+
48+
Respond with a JSON markdown block containing only the extracted values.`;
49+
50+
export default {
51+
name: GET_TOKEN_INFO_ACTION.name,
52+
similes: GET_TOKEN_INFO_ACTION.similes,
53+
validate: async (runtime: IAgentRuntime, message: Memory) => {
54+
elizaLogger.log("Validating get token info from user:", message.userId);
55+
56+
return false;
57+
},
58+
description: GET_TOKEN_INFO_ACTION.description,
59+
handler: async (
60+
runtime: IAgentRuntime,
61+
message: Memory,
62+
state: State,
63+
_options: { [key: string]: unknown },
64+
callback?: HandlerCallback
65+
): Promise<boolean> => {
66+
elizaLogger.log("Starting GET_TOKEN_INFO handler...");
67+
const sak = await getSAK(runtime);
68+
69+
// Initialize or update state
70+
if (!state) {
71+
state = (await runtime.composeState(message)) as State;
72+
} else {
73+
state = await runtime.updateRecentMessageState(state);
74+
}
75+
76+
// Compose get token info context
77+
const getTokenInfoContext = composeContext({
78+
state,
79+
template: getTokenInfoTemplate,
80+
});
81+
82+
// Generate get token info content
83+
const content = await generateObjectDeprecated({
84+
runtime,
85+
context: getTokenInfoContext,
86+
modelClass: ModelClass.LARGE,
87+
});
88+
89+
// Validate get token info content
90+
if (!isGetTokenInfoContent(runtime, content)) {
91+
elizaLogger.error("Invalid content for GET_TOKEN_INFO action.");
92+
if (callback) {
93+
callback({
94+
text: "Unable to process get token info request. Invalid content provided.",
95+
content: { error: "Invalid get token info content" },
96+
});
97+
}
98+
return false;
99+
}
100+
101+
try {
102+
103+
const tokenData = await sak.getTokenDataByAddress(content.tokenAddress)
104+
105+
console.log("Token data:", tokenData);
106+
107+
if (callback) {
108+
callback({
109+
text: `Successfully retrieved token data for ${content.tokenAddress}`,
110+
content: {
111+
success: true,
112+
tokenData: tokenData,
113+
},
114+
});
115+
}
116+
117+
return true;
118+
} catch (error) {
119+
elizaLogger.error("Error during get token info:", error);
120+
if (callback) {
121+
callback({
122+
text: `Error getting token info: ${error.message}`,
123+
content: { error: error.message },
124+
});
125+
}
126+
return false;
127+
}
128+
},
129+
130+
examples: [
131+
[
132+
{
133+
user: "{{user1}}",
134+
content: {
135+
text: "Get token info for SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa",
136+
},
137+
},
138+
{
139+
user: "{{user2}}",
140+
content: {
141+
text: "Get token info for SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa",
142+
action: "GET_TOKEN_INFO",
143+
},
144+
},
145+
{
146+
user: "{{user2}}",
147+
content: {
148+
text: "Successfully retrieved token info for SENDdRQtYMWaQrBroBrJ2Q53fgVuq95CV9UPGEvpCxa",
149+
},
150+
},
151+
],
152+
] as ActionExample[][],
153+
} as Action;

0 commit comments

Comments
 (0)