wallet-agent-ai-radix 1.0.0
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/LICENSE +13 -0
- package/README.md +284 -0
- package/dist/agent.d.ts +2 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +158 -0
- package/dist/agent.js.map +1 -0
- package/dist/cli/derive.d.ts +5 -0
- package/dist/cli/derive.d.ts.map +1 -0
- package/dist/cli/derive.js +78 -0
- package/dist/cli/derive.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +32 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init.d.ts +2 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +171 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/recover.d.ts +2 -0
- package/dist/cli/recover.d.ts.map +1 -0
- package/dist/cli/recover.js +112 -0
- package/dist/cli/recover.js.map +1 -0
- package/dist/cli/unlock.d.ts +3 -0
- package/dist/cli/unlock.d.ts.map +1 -0
- package/dist/cli/unlock.js +70 -0
- package/dist/cli/unlock.js.map +1 -0
- package/dist/core/AGGRClient.d.ts +19 -0
- package/dist/core/AGGRClient.d.ts.map +1 -0
- package/dist/core/AGGRClient.js +103 -0
- package/dist/core/AGGRClient.js.map +1 -0
- package/dist/core/AgentWallet.d.ts +64 -0
- package/dist/core/AgentWallet.d.ts.map +1 -0
- package/dist/core/AgentWallet.js +658 -0
- package/dist/core/AgentWallet.js.map +1 -0
- package/dist/core/RadixClient.d.ts +15 -0
- package/dist/core/RadixClient.d.ts.map +1 -0
- package/dist/core/RadixClient.js +112 -0
- package/dist/core/RadixClient.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/keystore/Keystore.d.ts +17 -0
- package/dist/keystore/Keystore.d.ts.map +1 -0
- package/dist/keystore/Keystore.js +97 -0
- package/dist/keystore/Keystore.js.map +1 -0
- package/dist/tools/LangChainTools.d.ts +19 -0
- package/dist/tools/LangChainTools.d.ts.map +1 -0
- package/dist/tools/LangChainTools.js +613 -0
- package/dist/tools/LangChainTools.js.map +1 -0
- package/dist/types/index.d.ts +104 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTransferTool = createTransferTool;
|
|
4
|
+
exports.createSwapTool = createSwapTool;
|
|
5
|
+
exports.createConditionalOrderTool = createConditionalOrderTool;
|
|
6
|
+
exports.createBalanceTool = createBalanceTool;
|
|
7
|
+
exports.createOwnerApprovalTool = createOwnerApprovalTool;
|
|
8
|
+
exports.createGetConfigTool = createGetConfigTool;
|
|
9
|
+
exports.createAgentWalletTools = createAgentWalletTools;
|
|
10
|
+
exports.createGetWhitelistTool = createGetWhitelistTool;
|
|
11
|
+
exports.createCancelOrderTool = createCancelOrderTool;
|
|
12
|
+
exports.createListOrdersTool = createListOrdersTool;
|
|
13
|
+
exports.createGetQuoteTool = createGetQuoteTool;
|
|
14
|
+
// ─── Safety checks — called before any TX ────────────────────────────────────
|
|
15
|
+
// These prevent the agent from entering retry loops that drain funds via fees.
|
|
16
|
+
async function preflightChecks(wallet, amount, asset, to, recipientName) {
|
|
17
|
+
// 1. Get config and balance
|
|
18
|
+
const config = await wallet.getConfig();
|
|
19
|
+
const balance = await wallet.getBalance();
|
|
20
|
+
// 2. Frozen — hard stop
|
|
21
|
+
if (config.frozen) {
|
|
22
|
+
return {
|
|
23
|
+
error: JSON.stringify({
|
|
24
|
+
success: false,
|
|
25
|
+
error: "The PolicyVault is frozen by the owner. No operations allowed. STOP — do not retry. Notify the user.",
|
|
26
|
+
})
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
// 3. XRD balance check — need enough for fees
|
|
30
|
+
const MIN_XRD_FOR_FEES = 10;
|
|
31
|
+
const xrdBalance = balance.balances["XRD"] ?? 0;
|
|
32
|
+
const xrdNeeded = asset === "XRD" ? amount + MIN_XRD_FOR_FEES : MIN_XRD_FOR_FEES;
|
|
33
|
+
if (xrdBalance < xrdNeeded) {
|
|
34
|
+
return {
|
|
35
|
+
error: JSON.stringify({
|
|
36
|
+
success: false,
|
|
37
|
+
error: `Insufficient XRD for fees. Available: ${xrdBalance} XRD. Minimum required: ${xrdNeeded} XRD (${MIN_XRD_FOR_FEES} for fees${asset === "XRD" ? ` + ${amount} to transfer` : ""}). STOP — do not retry with smaller amounts. Notify the owner to deposit more XRD.`,
|
|
38
|
+
})
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// 4. Asset balance check
|
|
42
|
+
const assetBalance = balance.balances[asset] ?? 0;
|
|
43
|
+
if (assetBalance < amount) {
|
|
44
|
+
return {
|
|
45
|
+
error: JSON.stringify({
|
|
46
|
+
success: false,
|
|
47
|
+
error: `Insufficient ${asset} balance. Available: ${assetBalance} ${asset}. Requested: ${amount} ${asset}. STOP — do not retry with smaller amounts. Notify the owner to deposit more funds.`,
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// 5. Daily cap check
|
|
52
|
+
if (amount > config.dailyCap) {
|
|
53
|
+
return {
|
|
54
|
+
error: JSON.stringify({
|
|
55
|
+
success: false,
|
|
56
|
+
error: `Amount ${amount} ${asset} exceeds the daily cap of ${config.dailyCap}. STOP — this operation cannot be completed today. Do not split the transfer. Notify the user.`,
|
|
57
|
+
})
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// 6. Whitelist check — both name AND address must match
|
|
61
|
+
if (to && recipientName) {
|
|
62
|
+
const whitelist = await wallet.getWhitelist();
|
|
63
|
+
const whitelisted = whitelist.find((w) => w.address === to && w.name === recipientName);
|
|
64
|
+
if (!whitelisted) {
|
|
65
|
+
const addressExists = whitelist.find((w) => w.address === to);
|
|
66
|
+
const nameExists = whitelist.find((w) => w.name === recipientName);
|
|
67
|
+
let reason = "Address and name do not match any whitelisted entry.";
|
|
68
|
+
if (addressExists && !nameExists)
|
|
69
|
+
reason = `Address exists but name "${recipientName}" does not match. Expected name: "${addressExists.name}".`;
|
|
70
|
+
if (!addressExists && nameExists)
|
|
71
|
+
reason = `Name "${recipientName}" exists but address does not match.`;
|
|
72
|
+
if (!addressExists && !nameExists)
|
|
73
|
+
reason = `Neither address "${to}" nor name "${recipientName}" found in whitelist.`;
|
|
74
|
+
return {
|
|
75
|
+
error: JSON.stringify({
|
|
76
|
+
success: false,
|
|
77
|
+
error: `Whitelist validation failed. ${reason} STOP — do not retry. Verify both the address and name with the owner via the web dashboard.`,
|
|
78
|
+
})
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return { error: null, recipientName: whitelisted.name };
|
|
82
|
+
}
|
|
83
|
+
return { error: null };
|
|
84
|
+
}
|
|
85
|
+
function createTransferTool(wallet) {
|
|
86
|
+
return {
|
|
87
|
+
name: "wallet_transfer",
|
|
88
|
+
description: `Transfer tokens to an address on the Radix network.
|
|
89
|
+
Use this tool when you need to make a payment or send funds.
|
|
90
|
+
Available assets: XRD, HUSDC, HUSDT, HWBTC, HETH.
|
|
91
|
+
IMPORTANT: You must provide BOTH the recipient name AND address exactly as they appear in the whitelist.
|
|
92
|
+
Both must match — if either is wrong the transfer will be rejected.
|
|
93
|
+
Never split a transfer into multiple transactions.
|
|
94
|
+
If the amount exceeds the multisig threshold, owner approval will be requested automatically — do not retry.`,
|
|
95
|
+
parameters: {
|
|
96
|
+
type: "object",
|
|
97
|
+
properties: {
|
|
98
|
+
to: {
|
|
99
|
+
type: "string",
|
|
100
|
+
description: "Destination Radix address — must match the whitelisted address exactly",
|
|
101
|
+
},
|
|
102
|
+
recipientName: {
|
|
103
|
+
type: "string",
|
|
104
|
+
description: "Name of the recipient exactly as it appears in the whitelist — must match the address",
|
|
105
|
+
},
|
|
106
|
+
amount: {
|
|
107
|
+
type: "number",
|
|
108
|
+
description: "Amount to transfer — must be the full requested amount, never split",
|
|
109
|
+
},
|
|
110
|
+
asset: {
|
|
111
|
+
type: "string",
|
|
112
|
+
enum: ["XRD", "HUSDC", "HUSDT", "HWBTC", "HETH"],
|
|
113
|
+
description: "Asset to transfer",
|
|
114
|
+
},
|
|
115
|
+
reason: {
|
|
116
|
+
type: "string",
|
|
117
|
+
description: "Reason for the transfer — recorded in the audit log",
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
required: ["to", "recipientName", "amount", "asset", "reason"],
|
|
121
|
+
},
|
|
122
|
+
call: async (params) => {
|
|
123
|
+
const p = params;
|
|
124
|
+
try {
|
|
125
|
+
// ── Safety checks ──
|
|
126
|
+
const preflight = await preflightChecks(wallet, p.amount, p.asset, p.to, p.recipientName);
|
|
127
|
+
if (preflight.error)
|
|
128
|
+
return preflight.error;
|
|
129
|
+
const config = await wallet.getConfig();
|
|
130
|
+
// ── Multisig threshold — request owner approval, never split ──
|
|
131
|
+
if (p.amount > config.multisigThreshold) {
|
|
132
|
+
const result = await wallet.requestLargeTransfer({
|
|
133
|
+
to: p.to,
|
|
134
|
+
amount: p.amount,
|
|
135
|
+
asset: p.asset,
|
|
136
|
+
reason: p.reason,
|
|
137
|
+
});
|
|
138
|
+
wallet.waitForOwnerApproval({ to: result.to, amount: String(result.amount), asset: result.asset, reason: result.reason }, 30000);
|
|
139
|
+
return JSON.stringify({
|
|
140
|
+
success: true,
|
|
141
|
+
pending: true,
|
|
142
|
+
message: `Transfer of ${p.amount} ${p.asset} to ${preflight.recipientName} (${p.to}) requires owner approval. The request has been submitted successfully. The owner must go to the web dashboard and approve it. You will be notified when approved or rejected. STOP — do not retry or split.`,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
// ── Normal transfer ──
|
|
146
|
+
const result = await wallet.transfer(p);
|
|
147
|
+
if (result.txId === "pending_owner_approval") {
|
|
148
|
+
wallet.waitForOwnerApproval({ to: result.to, amount: String(result.amount), asset: result.asset, reason: result.reason }, 30000);
|
|
149
|
+
return JSON.stringify({
|
|
150
|
+
success: false,
|
|
151
|
+
pending: true,
|
|
152
|
+
message: `Large transfer detected. Owner approval required — check the web dashboard. STOP — do not split or retry this transfer.`,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return JSON.stringify({
|
|
156
|
+
success: true,
|
|
157
|
+
txId: result.txId,
|
|
158
|
+
message: `Transfer of ${result.amount} ${result.asset} to ${preflight.recipientName} (${result.to}) completed successfully. TxID: ${result.txId}`,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
return JSON.stringify({
|
|
163
|
+
success: false,
|
|
164
|
+
error: `Transfer failed: ${error}. STOP — do not retry, do not attempt alternatives, do not split. Report this error to the user and wait for instructions.`,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
// Transfer tool — agent uses this to send payments
|
|
171
|
+
// Swap tool — agent uses this to exchange tokens
|
|
172
|
+
function createSwapTool(wallet) {
|
|
173
|
+
return {
|
|
174
|
+
name: "wallet_swap",
|
|
175
|
+
description: `Swap one token for another through the Radix aggregator.
|
|
176
|
+
Use this tool when you need to exchange one asset for another.
|
|
177
|
+
Available assets: XRD, HUSDC, HUSDT, HWBTC, HETH.
|
|
178
|
+
IMPORTANT: Always use this tool directly for swaps — do not pre-filter based on max_per_transaction.
|
|
179
|
+
The tool handles all limit checks internally. Never retry a failed swap automatically.
|
|
180
|
+
IMPORTANT: Always check balance before swapping. Never retry a failed swap automatically.`,
|
|
181
|
+
parameters: {
|
|
182
|
+
type: "object",
|
|
183
|
+
properties: {
|
|
184
|
+
fromAsset: {
|
|
185
|
+
type: "string",
|
|
186
|
+
enum: ["XRD", "HUSDC", "HUSDT", "HWBTC", "HETH"],
|
|
187
|
+
description: "Source asset",
|
|
188
|
+
},
|
|
189
|
+
toAsset: {
|
|
190
|
+
type: "string",
|
|
191
|
+
enum: ["XRD", "HUSDC", "HUSDT", "HWBTC", "HETH"],
|
|
192
|
+
description: "Destination asset",
|
|
193
|
+
},
|
|
194
|
+
amount: {
|
|
195
|
+
type: "number",
|
|
196
|
+
description: "Amount to swap",
|
|
197
|
+
},
|
|
198
|
+
maxSlippage: {
|
|
199
|
+
type: "number",
|
|
200
|
+
description: "Maximum accepted slippage in percentage (e.g. 0.5)",
|
|
201
|
+
},
|
|
202
|
+
reason: {
|
|
203
|
+
type: "string",
|
|
204
|
+
description: "Reason for the swap — recorded in the audit log",
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
required: ["fromAsset", "toAsset", "amount", "maxSlippage", "reason"],
|
|
208
|
+
},
|
|
209
|
+
call: async (params) => {
|
|
210
|
+
const p = params;
|
|
211
|
+
try {
|
|
212
|
+
// ── Config check primero ──
|
|
213
|
+
const config = await wallet.getConfig();
|
|
214
|
+
// Max per transaction check
|
|
215
|
+
if (p.amount > config.maxPerTransaction) {
|
|
216
|
+
return JSON.stringify({
|
|
217
|
+
success: false,
|
|
218
|
+
error: `Swap of ${p.amount} ${p.fromAsset} exceeds the max per transaction limit of ${config.maxPerTransaction}. STOP — do not retry with smaller amounts. Ask the owner to increase the limit via the web dashboard.`,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
// Multisig threshold — swap grande no implementado aún
|
|
222
|
+
if (p.amount > config.multisigThreshold) {
|
|
223
|
+
return JSON.stringify({
|
|
224
|
+
success: false,
|
|
225
|
+
error: `Swap of ${p.amount} ${p.fromAsset} exceeds the multisig threshold of ${config.multisigThreshold}. Large swap approval requires subintents — not yet implemented. STOP — do not retry. Ask the owner to increase the multisig threshold or reduce the swap amount.`,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
// ── Safety checks ──
|
|
229
|
+
const preflight = await preflightChecks(wallet, p.amount, p.fromAsset);
|
|
230
|
+
if (preflight.error)
|
|
231
|
+
return preflight.error;
|
|
232
|
+
// ── Execute swap ──
|
|
233
|
+
const result = await wallet.swap(p);
|
|
234
|
+
return JSON.stringify({
|
|
235
|
+
success: true,
|
|
236
|
+
txId: result.txId,
|
|
237
|
+
message: `Swap of ${result.amountIn} ${result.fromAsset} for ${result.amountOut} ${result.toAsset} completed. Price: ${result.executedPrice}. TxID: ${result.txId}`,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
return JSON.stringify({
|
|
242
|
+
success: false,
|
|
243
|
+
error: `Swap failed: ${error}. STOP — do not retry, do not attempt alternatives. Report this error to the user and wait for instructions.`,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
// Conditional order tool — agent uses this for automated trading
|
|
250
|
+
function createConditionalOrderTool(wallet) {
|
|
251
|
+
return {
|
|
252
|
+
name: "wallet_conditional_order",
|
|
253
|
+
description: `Create a buy or sell order that executes automatically
|
|
254
|
+
when the price reaches a specified value.
|
|
255
|
+
Use this tool when the user wants to buy or sell at a specific price.
|
|
256
|
+
IMPORTANT: Never retry a failed order automatically.`,
|
|
257
|
+
parameters: {
|
|
258
|
+
type: "object",
|
|
259
|
+
properties: {
|
|
260
|
+
type: {
|
|
261
|
+
type: "string",
|
|
262
|
+
enum: ["buy", "sell"],
|
|
263
|
+
description: "Order type",
|
|
264
|
+
},
|
|
265
|
+
asset: {
|
|
266
|
+
type: "string",
|
|
267
|
+
enum: ["XRD", "HUSDC", "HUSDT", "HWBTC", "HETH"],
|
|
268
|
+
description: "Asset to buy or sell",
|
|
269
|
+
},
|
|
270
|
+
againstAsset: {
|
|
271
|
+
type: "string",
|
|
272
|
+
enum: ["XRD", "HUSDC", "HUSDT", "HWBTC", "HETH"],
|
|
273
|
+
description: "Asset to trade against",
|
|
274
|
+
},
|
|
275
|
+
amount: {
|
|
276
|
+
type: "number",
|
|
277
|
+
description: "Amount",
|
|
278
|
+
},
|
|
279
|
+
triggerPrice: {
|
|
280
|
+
type: "number",
|
|
281
|
+
description: "Price that triggers the order",
|
|
282
|
+
},
|
|
283
|
+
condition: {
|
|
284
|
+
type: "string",
|
|
285
|
+
enum: ["above", "below"],
|
|
286
|
+
description: "above = executes when price rises above trigger, below = when it drops below",
|
|
287
|
+
},
|
|
288
|
+
maxSlippage: {
|
|
289
|
+
type: "number",
|
|
290
|
+
description: "Maximum accepted slippage in percentage",
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
required: ["type", "asset", "againstAsset", "amount", "triggerPrice", "condition", "maxSlippage"],
|
|
294
|
+
},
|
|
295
|
+
call: async (params) => {
|
|
296
|
+
const p = params;
|
|
297
|
+
try {
|
|
298
|
+
// ── Safety checks ──
|
|
299
|
+
const preflight = await preflightChecks(wallet, p.amount, p.asset);
|
|
300
|
+
if (preflight.error)
|
|
301
|
+
return preflight.error;
|
|
302
|
+
const orderId = await wallet.createConditionalOrder(p);
|
|
303
|
+
return JSON.stringify({
|
|
304
|
+
success: true,
|
|
305
|
+
orderId,
|
|
306
|
+
message: `${p.type.toUpperCase()} order created. Will execute when ${p.asset} is ${p.condition} ${p.triggerPrice}. OrderID: ${orderId}`,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
catch (error) {
|
|
310
|
+
return JSON.stringify({
|
|
311
|
+
success: false,
|
|
312
|
+
error: `Order creation failed: ${error}. STOP — do not retry. Report this error to the user and wait for instructions.`,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
// Balance tool — agent checks available funds
|
|
319
|
+
function createBalanceTool(wallet) {
|
|
320
|
+
return {
|
|
321
|
+
name: "wallet_balance",
|
|
322
|
+
description: `Check the current PolicyVault balance.
|
|
323
|
+
Use this tool when you need to know how many funds are available
|
|
324
|
+
before making a transfer or swap.`,
|
|
325
|
+
parameters: {
|
|
326
|
+
type: "object",
|
|
327
|
+
properties: {},
|
|
328
|
+
required: [],
|
|
329
|
+
},
|
|
330
|
+
call: async () => {
|
|
331
|
+
try {
|
|
332
|
+
const result = await wallet.getBalance();
|
|
333
|
+
return JSON.stringify({
|
|
334
|
+
success: true,
|
|
335
|
+
balances: result.balances,
|
|
336
|
+
message: `Current balances: ${JSON.stringify(result.balances)}`,
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
catch (error) {
|
|
340
|
+
return JSON.stringify({
|
|
341
|
+
success: false,
|
|
342
|
+
error: `Error checking balance: ${error}`,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
// Owner approval tool — agent requests approval for large transfers
|
|
349
|
+
function createOwnerApprovalTool(wallet) {
|
|
350
|
+
return {
|
|
351
|
+
name: "wallet_request_owner_approval",
|
|
352
|
+
description: `Request owner approval for a transfer that exceeds the multisig threshold.
|
|
353
|
+
Use this tool when wallet_transfer fails because the amount is too large.
|
|
354
|
+
The owner will be notified and must approve the transaction from the web dashboard.
|
|
355
|
+
Do NOT use this without first trying wallet_transfer.
|
|
356
|
+
IMPORTANT: Never retry after requesting approval — wait for owner response.`,
|
|
357
|
+
parameters: {
|
|
358
|
+
type: "object",
|
|
359
|
+
properties: {
|
|
360
|
+
to: {
|
|
361
|
+
type: "string",
|
|
362
|
+
description: "Destination Radix address",
|
|
363
|
+
},
|
|
364
|
+
amount: {
|
|
365
|
+
type: "number",
|
|
366
|
+
description: "Amount to transfer",
|
|
367
|
+
},
|
|
368
|
+
asset: {
|
|
369
|
+
type: "string",
|
|
370
|
+
enum: ["XRD", "HUSDC", "HUSDT", "HWBTC", "HETH"],
|
|
371
|
+
description: "Asset to transfer",
|
|
372
|
+
},
|
|
373
|
+
reason: {
|
|
374
|
+
type: "string",
|
|
375
|
+
description: "Reason for the transfer",
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
required: ["to", "amount", "asset", "reason"],
|
|
379
|
+
},
|
|
380
|
+
call: async (params) => {
|
|
381
|
+
const p = params;
|
|
382
|
+
try {
|
|
383
|
+
const result = await wallet.requestLargeTransfer({
|
|
384
|
+
to: p.to,
|
|
385
|
+
amount: p.amount,
|
|
386
|
+
asset: p.asset,
|
|
387
|
+
reason: p.reason,
|
|
388
|
+
});
|
|
389
|
+
console.log(`[AgentWallet] Owner approval required for transfer of ${result.amount} ${result.asset} to ${result.to}. Reason: ${result.reason}`);
|
|
390
|
+
return JSON.stringify({
|
|
391
|
+
success: false,
|
|
392
|
+
pending: true,
|
|
393
|
+
message: `Large transfer requested. Amount: ${result.amount} ${result.asset} to ${result.to}. Owner approval required — please go to the web dashboard and approve the pending transaction. STOP — do not retry or attempt alternatives.`,
|
|
394
|
+
details: result,
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
catch (error) {
|
|
398
|
+
return JSON.stringify({
|
|
399
|
+
success: false,
|
|
400
|
+
error: `Error requesting large transfer: ${error}. STOP — do not retry.`,
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
// Config tool — agent checks vault configuration
|
|
407
|
+
function createGetConfigTool(wallet) {
|
|
408
|
+
return {
|
|
409
|
+
name: "wallet_get_config",
|
|
410
|
+
description: `Get the current PolicyVault configuration.
|
|
411
|
+
Use this tool to check spending limits before attempting a transfer.
|
|
412
|
+
Returns max per transaction, multisig threshold, daily cap and frozen status.
|
|
413
|
+
IMPORTANT: Always call this before any transfer or swap operation.
|
|
414
|
+
NOTE: max_per_transaction applies to transfers only. For swaps the relevant limit is multisig threshold.
|
|
415
|
+
NEVER refuse a swap based on max_per_transaction — always attempt the swap tool and let it handle the limits.`,
|
|
416
|
+
parameters: {
|
|
417
|
+
type: "object",
|
|
418
|
+
properties: {},
|
|
419
|
+
required: [],
|
|
420
|
+
},
|
|
421
|
+
call: async () => {
|
|
422
|
+
try {
|
|
423
|
+
const config = await wallet.getConfig();
|
|
424
|
+
return JSON.stringify({
|
|
425
|
+
success: true,
|
|
426
|
+
config,
|
|
427
|
+
message: `Max per transaction: ${config.maxPerTransaction}, Multisig threshold: ${config.multisigThreshold}, Daily cap: ${config.dailyCap}, Frozen: ${config.frozen}`,
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
catch (error) {
|
|
431
|
+
return JSON.stringify({
|
|
432
|
+
success: false,
|
|
433
|
+
error: `Error getting config: ${error}`,
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
// Export all tools together — agent adds them all at once
|
|
440
|
+
function createAgentWalletTools(wallet) {
|
|
441
|
+
return [
|
|
442
|
+
createGetConfigTool(wallet),
|
|
443
|
+
createBalanceTool(wallet),
|
|
444
|
+
createTransferTool(wallet),
|
|
445
|
+
createOwnerApprovalTool(wallet),
|
|
446
|
+
createSwapTool(wallet),
|
|
447
|
+
createConditionalOrderTool(wallet),
|
|
448
|
+
createCancelOrderTool(wallet),
|
|
449
|
+
createListOrdersTool(wallet),
|
|
450
|
+
createGetWhitelistTool(wallet),
|
|
451
|
+
createGetQuoteTool(wallet),
|
|
452
|
+
];
|
|
453
|
+
}
|
|
454
|
+
function createGetWhitelistTool(wallet) {
|
|
455
|
+
return {
|
|
456
|
+
name: "wallet_get_whitelist",
|
|
457
|
+
description: `Get the list of whitelisted addresses in the PolicyVault.
|
|
458
|
+
Use this tool when the user asks who they can send funds to,
|
|
459
|
+
or when you need to find the name and address of a recipient before transferring.
|
|
460
|
+
Always use this before a transfer if you don't know the exact name and address.`,
|
|
461
|
+
parameters: {
|
|
462
|
+
type: "object",
|
|
463
|
+
properties: {},
|
|
464
|
+
required: [],
|
|
465
|
+
},
|
|
466
|
+
call: async () => {
|
|
467
|
+
try {
|
|
468
|
+
const whitelist = await wallet.getWhitelist();
|
|
469
|
+
if (whitelist.length === 0) {
|
|
470
|
+
return JSON.stringify({
|
|
471
|
+
success: true,
|
|
472
|
+
whitelist: [],
|
|
473
|
+
message: "No addresses whitelisted yet. The owner must add addresses via the web dashboard.",
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
const list = whitelist.map((w) => `• ${w.name}: ${w.address}`).join("\n");
|
|
477
|
+
return JSON.stringify({
|
|
478
|
+
success: true,
|
|
479
|
+
whitelist,
|
|
480
|
+
message: `Whitelisted addresses:\n${list}`,
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
catch (error) {
|
|
484
|
+
return JSON.stringify({
|
|
485
|
+
success: false,
|
|
486
|
+
error: `Error getting whitelist: ${error}`,
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
function createCancelOrderTool(wallet) {
|
|
493
|
+
return {
|
|
494
|
+
name: "wallet_cancel_order",
|
|
495
|
+
description: `Cancel an active conditional order.
|
|
496
|
+
Use this tool when the user wants to cancel a pending order.
|
|
497
|
+
You need the orderId — use wallet_list_orders first if you don't have it.`,
|
|
498
|
+
parameters: {
|
|
499
|
+
type: "object",
|
|
500
|
+
properties: {
|
|
501
|
+
orderId: {
|
|
502
|
+
type: "string",
|
|
503
|
+
description: "The order ID to cancel",
|
|
504
|
+
},
|
|
505
|
+
},
|
|
506
|
+
required: ["orderId"],
|
|
507
|
+
},
|
|
508
|
+
call: async (params) => {
|
|
509
|
+
const p = params;
|
|
510
|
+
try {
|
|
511
|
+
const cancelled = wallet.cancelOrder(p.orderId);
|
|
512
|
+
if (!cancelled) {
|
|
513
|
+
return JSON.stringify({
|
|
514
|
+
success: false,
|
|
515
|
+
error: `Order ${p.orderId} not found. Use wallet_list_orders to see active orders.`,
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
return JSON.stringify({
|
|
519
|
+
success: true,
|
|
520
|
+
message: `Order ${p.orderId} cancelled successfully.`,
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
catch (error) {
|
|
524
|
+
return JSON.stringify({
|
|
525
|
+
success: false,
|
|
526
|
+
error: `Error cancelling order: ${error}. STOP — do not retry.`,
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
function createListOrdersTool(wallet) {
|
|
533
|
+
return {
|
|
534
|
+
name: "wallet_list_orders",
|
|
535
|
+
description: `List all active conditional orders.
|
|
536
|
+
Use this tool when the user asks what orders are pending,
|
|
537
|
+
or when you need an orderId to cancel a specific order.`,
|
|
538
|
+
parameters: {
|
|
539
|
+
type: "object",
|
|
540
|
+
properties: {},
|
|
541
|
+
required: [],
|
|
542
|
+
},
|
|
543
|
+
call: async () => {
|
|
544
|
+
try {
|
|
545
|
+
const orders = wallet.listActiveOrders();
|
|
546
|
+
if (orders.length === 0) {
|
|
547
|
+
return JSON.stringify({
|
|
548
|
+
success: true,
|
|
549
|
+
orders: [],
|
|
550
|
+
message: "No active orders.",
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
return JSON.stringify({
|
|
554
|
+
success: true,
|
|
555
|
+
orders,
|
|
556
|
+
message: `Active orders:\n${orders.map(o => `• ${o}`).join("\n")}`,
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
catch (error) {
|
|
560
|
+
return JSON.stringify({
|
|
561
|
+
success: false,
|
|
562
|
+
error: `Error listing orders: ${error}`,
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
function createGetQuoteTool(wallet) {
|
|
569
|
+
return {
|
|
570
|
+
name: "wallet_get_quote",
|
|
571
|
+
description: `Get the current swap quote/price for a token pair from the Radix aggregator.
|
|
572
|
+
Use this tool before creating a conditional order or swap to know the current market price.
|
|
573
|
+
Returns the current price and expected output amount.`,
|
|
574
|
+
parameters: {
|
|
575
|
+
type: "object",
|
|
576
|
+
properties: {
|
|
577
|
+
fromAsset: {
|
|
578
|
+
type: "string",
|
|
579
|
+
enum: ["XRD", "HUSDC", "HUSDT", "HWBTC", "HETH"],
|
|
580
|
+
description: "Source asset",
|
|
581
|
+
},
|
|
582
|
+
toAsset: {
|
|
583
|
+
type: "string",
|
|
584
|
+
enum: ["XRD", "HUSDC", "HUSDT", "HWBTC", "HETH"],
|
|
585
|
+
description: "Destination asset",
|
|
586
|
+
},
|
|
587
|
+
amount: {
|
|
588
|
+
type: "number",
|
|
589
|
+
description: "Amount to get quote for",
|
|
590
|
+
},
|
|
591
|
+
},
|
|
592
|
+
required: ["fromAsset", "toAsset", "amount"],
|
|
593
|
+
},
|
|
594
|
+
call: async (params) => {
|
|
595
|
+
const p = params;
|
|
596
|
+
try {
|
|
597
|
+
const quote = await wallet.getSwapQuote(p.fromAsset, p.toAsset, p.amount);
|
|
598
|
+
return JSON.stringify({
|
|
599
|
+
success: true,
|
|
600
|
+
quote,
|
|
601
|
+
message: `Quote: ${p.amount} ${p.fromAsset} → ${quote.outputTokens} ${p.toAsset}. Current price: ${quote.price} ${p.toAsset}/${p.fromAsset}.`,
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
catch (error) {
|
|
605
|
+
return JSON.stringify({
|
|
606
|
+
success: false,
|
|
607
|
+
error: `Error getting quote: ${error}`,
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
},
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
//# sourceMappingURL=LangChainTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LangChainTools.js","sourceRoot":"","sources":["../../src/tools/LangChainTools.ts"],"names":[],"mappings":";;AAwGA,gDA6FC;AAMD,wCA+EC;AAGD,gEAkEC;AAGD,8CA2BC;AAGD,0DAgEC;AAGD,kDA8BC;AAGD,wDAaC;AACD,wDAoCC;AACD,sDAsCC;AAED,oDAkCC;AACD,gDA2CC;AA/nBD,gFAAgF;AAChF,+EAA+E;AAE/E,KAAK,UAAU,eAAe,CAC5B,MAAmB,EACnB,MAAc,EACd,KAAa,E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