solana-agent-kit-torch-market 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -38
- package/dist/index.d.mts +186 -0
- package/dist/index.d.ts +186 -0
- package/dist/index.js +640 -0
- package/dist/index.mjs +595 -0
- package/package.json +4 -4
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
// src/tools/torch.ts
|
|
2
|
+
import { Transaction } from "@solana/web3.js";
|
|
3
|
+
import { signOrSendTX } from "solana-agent-kit";
|
|
4
|
+
var TORCH_API = "https://torch.market/api/v1";
|
|
5
|
+
async function torchListTokens(agent, status, sort, limit) {
|
|
6
|
+
const params = new URLSearchParams();
|
|
7
|
+
if (status) params.set("status", status);
|
|
8
|
+
if (sort) params.set("sort", sort);
|
|
9
|
+
if (limit) params.set("limit", limit.toString());
|
|
10
|
+
const res = await fetch(`${TORCH_API}/tokens?${params}`);
|
|
11
|
+
const json = await res.json();
|
|
12
|
+
if (!json.success) throw new Error(json.error?.message || "Failed to list tokens");
|
|
13
|
+
return json.data.tokens;
|
|
14
|
+
}
|
|
15
|
+
async function torchGetToken(agent, mint) {
|
|
16
|
+
const res = await fetch(`${TORCH_API}/tokens/${mint}`);
|
|
17
|
+
const json = await res.json();
|
|
18
|
+
if (!json.success) throw new Error(json.error?.message || "Token not found");
|
|
19
|
+
return json.data;
|
|
20
|
+
}
|
|
21
|
+
async function torchBuyToken(agent, mint, amountLamports, slippageBps = 100) {
|
|
22
|
+
const res = await fetch(`${TORCH_API}/transactions/buy`, {
|
|
23
|
+
method: "POST",
|
|
24
|
+
headers: { "Content-Type": "application/json" },
|
|
25
|
+
body: JSON.stringify({
|
|
26
|
+
mint,
|
|
27
|
+
buyer: agent.wallet.publicKey.toBase58(),
|
|
28
|
+
amount_sol: amountLamports,
|
|
29
|
+
slippage_bps: slippageBps
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
const json = await res.json();
|
|
33
|
+
if (!json.success) throw new Error(json.error?.message || "Failed to build buy transaction");
|
|
34
|
+
const tx = Transaction.from(Buffer.from(json.data.transaction, "base64"));
|
|
35
|
+
const { blockhash } = await agent.connection.getLatestBlockhash();
|
|
36
|
+
tx.recentBlockhash = blockhash;
|
|
37
|
+
return signOrSendTX(agent, tx);
|
|
38
|
+
}
|
|
39
|
+
async function torchSellToken(agent, mint, amountTokens, slippageBps = 100) {
|
|
40
|
+
const res = await fetch(`${TORCH_API}/transactions/sell`, {
|
|
41
|
+
method: "POST",
|
|
42
|
+
headers: { "Content-Type": "application/json" },
|
|
43
|
+
body: JSON.stringify({
|
|
44
|
+
mint,
|
|
45
|
+
seller: agent.wallet.publicKey.toBase58(),
|
|
46
|
+
amount_tokens: amountTokens,
|
|
47
|
+
slippage_bps: slippageBps
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
const json = await res.json();
|
|
51
|
+
if (!json.success) throw new Error(json.error?.message || "Failed to build sell transaction");
|
|
52
|
+
const tx = Transaction.from(Buffer.from(json.data.transaction, "base64"));
|
|
53
|
+
const { blockhash } = await agent.connection.getLatestBlockhash();
|
|
54
|
+
tx.recentBlockhash = blockhash;
|
|
55
|
+
return signOrSendTX(agent, tx);
|
|
56
|
+
}
|
|
57
|
+
async function torchVoteToken(agent, mint, vote) {
|
|
58
|
+
const res = await fetch(`${TORCH_API}/transactions/vote`, {
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: { "Content-Type": "application/json" },
|
|
61
|
+
body: JSON.stringify({
|
|
62
|
+
mint,
|
|
63
|
+
voter: agent.wallet.publicKey.toBase58(),
|
|
64
|
+
vote
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
const json = await res.json();
|
|
68
|
+
if (!json.success) throw new Error(json.error?.message || "Failed to build vote transaction");
|
|
69
|
+
const tx = Transaction.from(Buffer.from(json.data.transaction, "base64"));
|
|
70
|
+
const { blockhash } = await agent.connection.getLatestBlockhash();
|
|
71
|
+
tx.recentBlockhash = blockhash;
|
|
72
|
+
return signOrSendTX(agent, tx);
|
|
73
|
+
}
|
|
74
|
+
async function torchStarToken(agent, mint) {
|
|
75
|
+
const res = await fetch(`${TORCH_API}/transactions/star`, {
|
|
76
|
+
method: "POST",
|
|
77
|
+
headers: { "Content-Type": "application/json" },
|
|
78
|
+
body: JSON.stringify({
|
|
79
|
+
mint,
|
|
80
|
+
user: agent.wallet.publicKey.toBase58()
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
const json = await res.json();
|
|
84
|
+
if (!json.success) throw new Error(json.error?.message || "Failed to build star transaction");
|
|
85
|
+
const tx = Transaction.from(Buffer.from(json.data.transaction, "base64"));
|
|
86
|
+
const { blockhash } = await agent.connection.getLatestBlockhash();
|
|
87
|
+
tx.recentBlockhash = blockhash;
|
|
88
|
+
return signOrSendTX(agent, tx);
|
|
89
|
+
}
|
|
90
|
+
async function torchCreateToken(agent, name, symbol, metadataUri) {
|
|
91
|
+
const res = await fetch(`${TORCH_API}/transactions/create`, {
|
|
92
|
+
method: "POST",
|
|
93
|
+
headers: { "Content-Type": "application/json" },
|
|
94
|
+
body: JSON.stringify({
|
|
95
|
+
creator: agent.wallet.publicKey.toBase58(),
|
|
96
|
+
name,
|
|
97
|
+
symbol,
|
|
98
|
+
metadata_uri: metadataUri
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
const json = await res.json();
|
|
102
|
+
if (!json.success) throw new Error(json.error?.message || "Failed to build create transaction");
|
|
103
|
+
const tx = Transaction.from(Buffer.from(json.data.transaction, "base64"));
|
|
104
|
+
const { blockhash } = await agent.connection.getLatestBlockhash();
|
|
105
|
+
tx.recentBlockhash = blockhash;
|
|
106
|
+
const signature = await signOrSendTX(agent, tx);
|
|
107
|
+
return {
|
|
108
|
+
signature,
|
|
109
|
+
mint: json.data.mint
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
async function torchGetMessages(agent, mint, limit = 50) {
|
|
113
|
+
const params = new URLSearchParams();
|
|
114
|
+
if (limit) params.set("limit", limit.toString());
|
|
115
|
+
const res = await fetch(`${TORCH_API}/tokens/${mint}/messages?${params}`);
|
|
116
|
+
const json = await res.json();
|
|
117
|
+
if (!json.success) throw new Error(json.error?.message || "Failed to get messages");
|
|
118
|
+
return json.data.messages;
|
|
119
|
+
}
|
|
120
|
+
async function torchPostMessage(agent, mint, message) {
|
|
121
|
+
const res = await fetch(`${TORCH_API}/transactions/message`, {
|
|
122
|
+
method: "POST",
|
|
123
|
+
headers: { "Content-Type": "application/json" },
|
|
124
|
+
body: JSON.stringify({
|
|
125
|
+
mint,
|
|
126
|
+
sender: agent.wallet.publicKey.toBase58(),
|
|
127
|
+
message
|
|
128
|
+
})
|
|
129
|
+
});
|
|
130
|
+
const json = await res.json();
|
|
131
|
+
if (!json.success) throw new Error(json.error?.message || "Failed to build message transaction");
|
|
132
|
+
const tx = Transaction.from(Buffer.from(json.data.transaction, "base64"));
|
|
133
|
+
const { blockhash } = await agent.connection.getLatestBlockhash();
|
|
134
|
+
tx.recentBlockhash = blockhash;
|
|
135
|
+
return signOrSendTX(agent, tx);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// src/actions/torch.ts
|
|
139
|
+
import { z } from "zod";
|
|
140
|
+
var torchListTokensAction = {
|
|
141
|
+
name: "TORCH_LIST_TOKENS",
|
|
142
|
+
similes: [
|
|
143
|
+
"list torch tokens",
|
|
144
|
+
"browse torch market",
|
|
145
|
+
"find bonding curve tokens",
|
|
146
|
+
"show torch launchpad tokens",
|
|
147
|
+
"what tokens are on torch market"
|
|
148
|
+
],
|
|
149
|
+
description: "List tokens on Torch Market - a fair-launch platform with bonding curves and community treasuries. Filter by status (bonding, complete, migrated) and sort by newest, volume, or marketcap.",
|
|
150
|
+
examples: [
|
|
151
|
+
[
|
|
152
|
+
{
|
|
153
|
+
input: { status: "bonding", sort: "volume", limit: 10 },
|
|
154
|
+
output: {
|
|
155
|
+
status: "success",
|
|
156
|
+
tokens: [{ mint: "ABC...", name: "Example", symbol: "EX", progress_percent: 45 }],
|
|
157
|
+
count: 10
|
|
158
|
+
},
|
|
159
|
+
explanation: "List the top 10 bonding tokens by volume on Torch Market"
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
],
|
|
163
|
+
schema: z.object({
|
|
164
|
+
status: z.enum(["bonding", "complete", "migrated", "all"]).optional().describe("Filter by token status"),
|
|
165
|
+
sort: z.enum(["newest", "volume", "marketcap"]).optional().describe("Sort order"),
|
|
166
|
+
limit: z.number().positive().max(100).optional().describe("Number of tokens to return")
|
|
167
|
+
}),
|
|
168
|
+
handler: async (agent, input) => {
|
|
169
|
+
try {
|
|
170
|
+
const tokens = await torchListTokens(agent, input.status, input.sort, input.limit);
|
|
171
|
+
return {
|
|
172
|
+
status: "success",
|
|
173
|
+
tokens,
|
|
174
|
+
count: tokens.length,
|
|
175
|
+
message: `Found ${tokens.length} tokens on Torch Market`
|
|
176
|
+
};
|
|
177
|
+
} catch (error) {
|
|
178
|
+
return {
|
|
179
|
+
status: "error",
|
|
180
|
+
message: `Failed to list tokens: ${error.message}`
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
var torchGetTokenAction = {
|
|
186
|
+
name: "TORCH_GET_TOKEN",
|
|
187
|
+
similes: [
|
|
188
|
+
"get torch token info",
|
|
189
|
+
"torch token details",
|
|
190
|
+
"check torch token",
|
|
191
|
+
"lookup token on torch"
|
|
192
|
+
],
|
|
193
|
+
description: "Get detailed information about a specific token on Torch Market, including price, progress, treasury state, and vote counts.",
|
|
194
|
+
examples: [
|
|
195
|
+
[
|
|
196
|
+
{
|
|
197
|
+
input: { mint: "ABC123..." },
|
|
198
|
+
output: {
|
|
199
|
+
status: "success",
|
|
200
|
+
token: { name: "Example", symbol: "EX", progress_percent: 45, votes_burn: 100 }
|
|
201
|
+
},
|
|
202
|
+
explanation: "Get details for a specific Torch token"
|
|
203
|
+
}
|
|
204
|
+
]
|
|
205
|
+
],
|
|
206
|
+
schema: z.object({
|
|
207
|
+
mint: z.string().describe("Token mint address")
|
|
208
|
+
}),
|
|
209
|
+
handler: async (agent, input) => {
|
|
210
|
+
try {
|
|
211
|
+
const token = await torchGetToken(agent, input.mint);
|
|
212
|
+
return {
|
|
213
|
+
status: "success",
|
|
214
|
+
token,
|
|
215
|
+
message: `${token.name} (${token.symbol}) - ${token.progress_percent.toFixed(1)}% complete`
|
|
216
|
+
};
|
|
217
|
+
} catch (error) {
|
|
218
|
+
return {
|
|
219
|
+
status: "error",
|
|
220
|
+
message: `Failed to get token: ${error.message}`
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
var torchBuyTokenAction = {
|
|
226
|
+
name: "TORCH_BUY_TOKEN",
|
|
227
|
+
similes: [
|
|
228
|
+
"buy token on torch",
|
|
229
|
+
"purchase torch token",
|
|
230
|
+
"buy on torch market",
|
|
231
|
+
"invest in torch token"
|
|
232
|
+
],
|
|
233
|
+
description: "Buy tokens on Torch Market bonding curve. Specify amount in SOL. 10% of tokens go to community treasury, 90% to you. 1% protocol fee on buys.",
|
|
234
|
+
examples: [
|
|
235
|
+
[
|
|
236
|
+
{
|
|
237
|
+
input: { mint: "ABC123...", amountSol: 0.1 },
|
|
238
|
+
output: {
|
|
239
|
+
status: "success",
|
|
240
|
+
signature: "5xKp...",
|
|
241
|
+
message: "Bought tokens for 0.1 SOL"
|
|
242
|
+
},
|
|
243
|
+
explanation: "Buy tokens with 0.1 SOL on Torch Market"
|
|
244
|
+
}
|
|
245
|
+
]
|
|
246
|
+
],
|
|
247
|
+
schema: z.object({
|
|
248
|
+
mint: z.string().describe("Token mint address"),
|
|
249
|
+
amountSol: z.number().positive().describe("Amount of SOL to spend"),
|
|
250
|
+
slippagePercent: z.number().positive().max(50).optional().describe("Slippage tolerance as percentage (default 1%)")
|
|
251
|
+
}),
|
|
252
|
+
handler: async (agent, input) => {
|
|
253
|
+
try {
|
|
254
|
+
const lamports = Math.floor(input.amountSol * 1e9);
|
|
255
|
+
const bps = input.slippagePercent ? Math.floor(input.slippagePercent * 100) : 100;
|
|
256
|
+
const signature = await torchBuyToken(agent, input.mint, lamports, bps);
|
|
257
|
+
return {
|
|
258
|
+
status: "success",
|
|
259
|
+
signature,
|
|
260
|
+
message: `Bought tokens for ${input.amountSol} SOL`
|
|
261
|
+
};
|
|
262
|
+
} catch (error) {
|
|
263
|
+
return {
|
|
264
|
+
status: "error",
|
|
265
|
+
message: `Buy failed: ${error.message}`
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
var torchSellTokenAction = {
|
|
271
|
+
name: "TORCH_SELL_TOKEN",
|
|
272
|
+
similes: [
|
|
273
|
+
"sell token on torch",
|
|
274
|
+
"sell torch token",
|
|
275
|
+
"exit torch position"
|
|
276
|
+
],
|
|
277
|
+
description: "Sell tokens back to Torch Market bonding curve. No sell fees. Specify amount in tokens.",
|
|
278
|
+
examples: [
|
|
279
|
+
[
|
|
280
|
+
{
|
|
281
|
+
input: { mint: "ABC123...", amountTokens: 1e6 },
|
|
282
|
+
output: {
|
|
283
|
+
status: "success",
|
|
284
|
+
signature: "5xKp...",
|
|
285
|
+
message: "Sold 1M tokens"
|
|
286
|
+
},
|
|
287
|
+
explanation: "Sell 1M tokens back to the bonding curve"
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
],
|
|
291
|
+
schema: z.object({
|
|
292
|
+
mint: z.string().describe("Token mint address"),
|
|
293
|
+
amountTokens: z.number().positive().describe("Amount of tokens to sell"),
|
|
294
|
+
slippagePercent: z.number().positive().max(50).optional().describe("Slippage tolerance as percentage (default 1%)")
|
|
295
|
+
}),
|
|
296
|
+
handler: async (agent, input) => {
|
|
297
|
+
try {
|
|
298
|
+
const baseUnits = Math.floor(input.amountTokens * 1e6);
|
|
299
|
+
const bps = input.slippagePercent ? Math.floor(input.slippagePercent * 100) : 100;
|
|
300
|
+
const signature = await torchSellToken(agent, input.mint, baseUnits, bps);
|
|
301
|
+
return {
|
|
302
|
+
status: "success",
|
|
303
|
+
signature,
|
|
304
|
+
message: `Sold ${input.amountTokens.toLocaleString()} tokens`
|
|
305
|
+
};
|
|
306
|
+
} catch (error) {
|
|
307
|
+
return {
|
|
308
|
+
status: "error",
|
|
309
|
+
message: `Sell failed: ${error.message}`
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
var torchVoteTokenAction = {
|
|
315
|
+
name: "TORCH_VOTE_TOKEN",
|
|
316
|
+
similes: [
|
|
317
|
+
"vote on torch token",
|
|
318
|
+
"torch treasury vote",
|
|
319
|
+
"vote burn torch",
|
|
320
|
+
"vote return torch"
|
|
321
|
+
],
|
|
322
|
+
description: "Vote on treasury outcome for a graduated Torch token. After reaching 200 SOL, holders vote: 'burn' destroys treasury tokens (reducing supply), 'return' gives them to the creator. You must hold the token to vote.",
|
|
323
|
+
examples: [
|
|
324
|
+
[
|
|
325
|
+
{
|
|
326
|
+
input: { mint: "ABC123...", vote: "burn" },
|
|
327
|
+
output: {
|
|
328
|
+
status: "success",
|
|
329
|
+
signature: "5xKp...",
|
|
330
|
+
message: "Voted to burn treasury tokens"
|
|
331
|
+
},
|
|
332
|
+
explanation: "Vote to burn the community treasury tokens"
|
|
333
|
+
}
|
|
334
|
+
]
|
|
335
|
+
],
|
|
336
|
+
schema: z.object({
|
|
337
|
+
mint: z.string().describe("Token mint address"),
|
|
338
|
+
vote: z.enum(["burn", "return"]).describe("'burn' = destroy treasury tokens, 'return' = give to creator")
|
|
339
|
+
}),
|
|
340
|
+
handler: async (agent, input) => {
|
|
341
|
+
try {
|
|
342
|
+
const signature = await torchVoteToken(agent, input.mint, input.vote);
|
|
343
|
+
const desc = input.vote === "burn" ? "burn treasury tokens" : "return tokens to creator";
|
|
344
|
+
return {
|
|
345
|
+
status: "success",
|
|
346
|
+
signature,
|
|
347
|
+
vote: input.vote,
|
|
348
|
+
message: `Voted to ${desc}`
|
|
349
|
+
};
|
|
350
|
+
} catch (error) {
|
|
351
|
+
return {
|
|
352
|
+
status: "error",
|
|
353
|
+
message: `Vote failed: ${error.message}`
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
var torchStarTokenAction = {
|
|
359
|
+
name: "TORCH_STAR_TOKEN",
|
|
360
|
+
similes: [
|
|
361
|
+
"star torch token",
|
|
362
|
+
"support torch token",
|
|
363
|
+
"like token on torch"
|
|
364
|
+
],
|
|
365
|
+
description: "Star a token on Torch Market to show support (costs 0.05 SOL). When tokens reach the star threshold, creators receive rewards.",
|
|
366
|
+
examples: [
|
|
367
|
+
[
|
|
368
|
+
{
|
|
369
|
+
input: { mint: "ABC123..." },
|
|
370
|
+
output: {
|
|
371
|
+
status: "success",
|
|
372
|
+
signature: "5xKp...",
|
|
373
|
+
message: "Starred token for 0.05 SOL"
|
|
374
|
+
},
|
|
375
|
+
explanation: "Star a token to show support"
|
|
376
|
+
}
|
|
377
|
+
]
|
|
378
|
+
],
|
|
379
|
+
schema: z.object({
|
|
380
|
+
mint: z.string().describe("Token mint address to star")
|
|
381
|
+
}),
|
|
382
|
+
handler: async (agent, input) => {
|
|
383
|
+
try {
|
|
384
|
+
const signature = await torchStarToken(agent, input.mint);
|
|
385
|
+
return {
|
|
386
|
+
status: "success",
|
|
387
|
+
signature,
|
|
388
|
+
cost: 0.05,
|
|
389
|
+
message: "Starred token (cost: 0.05 SOL)"
|
|
390
|
+
};
|
|
391
|
+
} catch (error) {
|
|
392
|
+
return {
|
|
393
|
+
status: "error",
|
|
394
|
+
message: `Star failed: ${error.message}`
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
var torchCreateTokenAction = {
|
|
400
|
+
name: "TORCH_CREATE_TOKEN",
|
|
401
|
+
similes: [
|
|
402
|
+
"create token on torch",
|
|
403
|
+
"launch token on torch",
|
|
404
|
+
"create my own token",
|
|
405
|
+
"make a torch token",
|
|
406
|
+
"deploy token to torch market"
|
|
407
|
+
],
|
|
408
|
+
description: "Create a new token on Torch Market with automatic bonding curve, community treasury, and Raydium migration. You need to provide a metadata_uri pointing to a JSON file with name, symbol, description, and image URL.",
|
|
409
|
+
examples: [
|
|
410
|
+
[
|
|
411
|
+
{
|
|
412
|
+
input: {
|
|
413
|
+
name: "My Agent Token",
|
|
414
|
+
symbol: "MAT",
|
|
415
|
+
metadataUri: "https://arweave.net/abc123"
|
|
416
|
+
},
|
|
417
|
+
output: {
|
|
418
|
+
status: "success",
|
|
419
|
+
signature: "5xKp...",
|
|
420
|
+
mint: "NEW_MINT_ADDRESS",
|
|
421
|
+
message: "Created token My Agent Token ($MAT)"
|
|
422
|
+
},
|
|
423
|
+
explanation: "Create a new token with bonding curve"
|
|
424
|
+
}
|
|
425
|
+
]
|
|
426
|
+
],
|
|
427
|
+
schema: z.object({
|
|
428
|
+
name: z.string().max(32).describe("Token name (max 32 characters)"),
|
|
429
|
+
symbol: z.string().max(10).describe("Token symbol (max 10 characters)"),
|
|
430
|
+
metadataUri: z.string().url().describe("URI pointing to token metadata JSON with name, symbol, description, and image")
|
|
431
|
+
}),
|
|
432
|
+
handler: async (agent, input) => {
|
|
433
|
+
try {
|
|
434
|
+
const result = await torchCreateToken(
|
|
435
|
+
agent,
|
|
436
|
+
input.name,
|
|
437
|
+
input.symbol,
|
|
438
|
+
input.metadataUri
|
|
439
|
+
);
|
|
440
|
+
return {
|
|
441
|
+
status: "success",
|
|
442
|
+
signature: result.signature,
|
|
443
|
+
mint: result.mint,
|
|
444
|
+
message: `Created token ${input.name} ($${input.symbol})`
|
|
445
|
+
};
|
|
446
|
+
} catch (error) {
|
|
447
|
+
return {
|
|
448
|
+
status: "error",
|
|
449
|
+
message: `Create token failed: ${error.message}`
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
var torchGetMessagesAction = {
|
|
455
|
+
name: "TORCH_GET_MESSAGES",
|
|
456
|
+
similes: [
|
|
457
|
+
"get torch messages",
|
|
458
|
+
"read torch messages",
|
|
459
|
+
"see messages on torch",
|
|
460
|
+
"what are agents saying on torch",
|
|
461
|
+
"read token chat"
|
|
462
|
+
],
|
|
463
|
+
description: "Get messages from a token's page on Torch Market. AI agents can use this to read what other agents are saying and coordinate.",
|
|
464
|
+
examples: [
|
|
465
|
+
[
|
|
466
|
+
{
|
|
467
|
+
input: { mint: "ABC123...", limit: 20 },
|
|
468
|
+
output: {
|
|
469
|
+
status: "success",
|
|
470
|
+
messages: [{ memo: "Hello from an AI!", sender: "5xKp...", timestamp: 1234567890 }],
|
|
471
|
+
count: 1
|
|
472
|
+
},
|
|
473
|
+
explanation: "Read the last 20 messages on a token's page"
|
|
474
|
+
}
|
|
475
|
+
]
|
|
476
|
+
],
|
|
477
|
+
schema: z.object({
|
|
478
|
+
mint: z.string().describe("Token mint address"),
|
|
479
|
+
limit: z.number().positive().max(100).optional().describe("Number of messages to return (default 50, max 100)")
|
|
480
|
+
}),
|
|
481
|
+
handler: async (agent, input) => {
|
|
482
|
+
try {
|
|
483
|
+
const messages = await torchGetMessages(agent, input.mint, input.limit);
|
|
484
|
+
return {
|
|
485
|
+
status: "success",
|
|
486
|
+
messages,
|
|
487
|
+
count: messages.length,
|
|
488
|
+
message: `Found ${messages.length} messages`
|
|
489
|
+
};
|
|
490
|
+
} catch (error) {
|
|
491
|
+
return {
|
|
492
|
+
status: "error",
|
|
493
|
+
message: `Failed to get messages: ${error.message}`
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
var torchPostMessageAction = {
|
|
499
|
+
name: "TORCH_POST_MESSAGE",
|
|
500
|
+
similes: [
|
|
501
|
+
"post torch message",
|
|
502
|
+
"send torch message",
|
|
503
|
+
"say something on torch",
|
|
504
|
+
"communicate on torch",
|
|
505
|
+
"message other agents"
|
|
506
|
+
],
|
|
507
|
+
description: "Post a message on a token's page on Torch Market. AI agents can use this to communicate with each other. Messages are stored on-chain as SPL Memos and are permanent.",
|
|
508
|
+
examples: [
|
|
509
|
+
[
|
|
510
|
+
{
|
|
511
|
+
input: { mint: "ABC123...", message: "Hello from an AI agent!" },
|
|
512
|
+
output: {
|
|
513
|
+
status: "success",
|
|
514
|
+
signature: "5xKp...",
|
|
515
|
+
message: "Posted message"
|
|
516
|
+
},
|
|
517
|
+
explanation: "Post a message on a token's page"
|
|
518
|
+
}
|
|
519
|
+
]
|
|
520
|
+
],
|
|
521
|
+
schema: z.object({
|
|
522
|
+
mint: z.string().describe("Token mint address"),
|
|
523
|
+
message: z.string().max(500).describe("Message to post (max 500 characters)")
|
|
524
|
+
}),
|
|
525
|
+
handler: async (agent, input) => {
|
|
526
|
+
try {
|
|
527
|
+
const signature = await torchPostMessage(agent, input.mint, input.message);
|
|
528
|
+
return {
|
|
529
|
+
status: "success",
|
|
530
|
+
signature,
|
|
531
|
+
message: "Posted message"
|
|
532
|
+
};
|
|
533
|
+
} catch (error) {
|
|
534
|
+
return {
|
|
535
|
+
status: "error",
|
|
536
|
+
message: `Post message failed: ${error.message}`
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
// src/index.ts
|
|
543
|
+
var TorchMarketPlugin = {
|
|
544
|
+
name: "torch-market",
|
|
545
|
+
// Methods available on agent.methods
|
|
546
|
+
methods: {
|
|
547
|
+
torchListTokens,
|
|
548
|
+
torchGetToken,
|
|
549
|
+
torchBuyToken,
|
|
550
|
+
torchSellToken,
|
|
551
|
+
torchVoteToken,
|
|
552
|
+
torchStarToken,
|
|
553
|
+
torchCreateToken,
|
|
554
|
+
torchGetMessages,
|
|
555
|
+
torchPostMessage
|
|
556
|
+
},
|
|
557
|
+
// Actions for LangChain/AI agents
|
|
558
|
+
actions: [
|
|
559
|
+
torchListTokensAction,
|
|
560
|
+
torchGetTokenAction,
|
|
561
|
+
torchBuyTokenAction,
|
|
562
|
+
torchSellTokenAction,
|
|
563
|
+
torchVoteTokenAction,
|
|
564
|
+
torchStarTokenAction,
|
|
565
|
+
torchCreateTokenAction,
|
|
566
|
+
torchGetMessagesAction,
|
|
567
|
+
torchPostMessageAction
|
|
568
|
+
],
|
|
569
|
+
// Initialize (required by Plugin interface)
|
|
570
|
+
initialize: function() {
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
var index_default = TorchMarketPlugin;
|
|
574
|
+
export {
|
|
575
|
+
TorchMarketPlugin,
|
|
576
|
+
index_default as default,
|
|
577
|
+
torchBuyToken,
|
|
578
|
+
torchBuyTokenAction,
|
|
579
|
+
torchCreateToken,
|
|
580
|
+
torchCreateTokenAction,
|
|
581
|
+
torchGetMessages,
|
|
582
|
+
torchGetMessagesAction,
|
|
583
|
+
torchGetToken,
|
|
584
|
+
torchGetTokenAction,
|
|
585
|
+
torchListTokens,
|
|
586
|
+
torchListTokensAction,
|
|
587
|
+
torchPostMessage,
|
|
588
|
+
torchPostMessageAction,
|
|
589
|
+
torchSellToken,
|
|
590
|
+
torchSellTokenAction,
|
|
591
|
+
torchStarToken,
|
|
592
|
+
torchStarTokenAction,
|
|
593
|
+
torchVoteToken,
|
|
594
|
+
torchVoteTokenAction
|
|
595
|
+
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solana-agent-kit-torch-market",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Solana Agent Kit plugin for Torch Market - fair-launch token platform with community treasuries",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
10
11
|
"import": "./dist/index.mjs",
|
|
11
|
-
"require": "./dist/index.js"
|
|
12
|
-
"types": "./dist/index.d.ts"
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"repository": {
|
|
36
36
|
"type": "git",
|
|
37
|
-
"url": "https://github.com/
|
|
37
|
+
"url": "https://github.com/mrsirg97-rgb/solana-agent-kit"
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://torch.market",
|
|
40
40
|
"peerDependencies": {
|