@hashgraphonline/standards-agent-kit 0.0.37 → 0.0.38
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/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/cjs/tools/AcceptConnectionRequestTool.d.ts +6 -6
- package/dist/cjs/tools/CheckMessagesTool.d.ts +6 -6
- package/dist/cjs/tools/ConnectionMonitorTool.d.ts +34 -34
- package/dist/cjs/tools/FindRegistrationsTool.d.ts +4 -4
- package/dist/cjs/tools/InitiateConnectionTool.d.ts +2 -2
- package/dist/cjs/tools/ListConnectionsTool.d.ts +4 -4
- package/dist/cjs/tools/ListUnapprovedConnectionRequestsTool.d.ts +4 -4
- package/dist/cjs/tools/ManageConnectionRequestsTool.d.ts +4 -4
- package/dist/cjs/tools/RegisterAgentTool.d.ts +76 -76
- package/dist/cjs/tools/RetrieveProfileTool.d.ts +4 -4
- package/dist/cjs/tools/SendMessageToConnectionTool.d.ts +6 -6
- package/dist/cjs/tools/SendMessageTool.d.ts +6 -6
- package/dist/es/standards-agent-kit.es14.js.map +1 -1
- package/dist/es/standards-agent-kit.es18.js.map +1 -1
- package/dist/es/standards-agent-kit.es7.js.map +1 -1
- package/dist/es/standards-agent-kit.es9.js.map +1 -1
- package/dist/es/tools/AcceptConnectionRequestTool.d.ts +6 -6
- package/dist/es/tools/CheckMessagesTool.d.ts +6 -6
- package/dist/es/tools/ConnectionMonitorTool.d.ts +34 -34
- package/dist/es/tools/FindRegistrationsTool.d.ts +4 -4
- package/dist/es/tools/InitiateConnectionTool.d.ts +2 -2
- package/dist/es/tools/ListConnectionsTool.d.ts +4 -4
- package/dist/es/tools/ListUnapprovedConnectionRequestsTool.d.ts +4 -4
- package/dist/es/tools/ManageConnectionRequestsTool.d.ts +4 -4
- package/dist/es/tools/RegisterAgentTool.d.ts +76 -76
- package/dist/es/tools/RetrieveProfileTool.d.ts +4 -4
- package/dist/es/tools/SendMessageToConnectionTool.d.ts +6 -6
- package/dist/es/tools/SendMessageTool.d.ts +6 -6
- package/dist/umd/standards-agent-kit.umd.js +49 -19
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/dist/umd/tools/AcceptConnectionRequestTool.d.ts +6 -6
- package/dist/umd/tools/CheckMessagesTool.d.ts +6 -6
- package/dist/umd/tools/ConnectionMonitorTool.d.ts +34 -34
- package/dist/umd/tools/FindRegistrationsTool.d.ts +4 -4
- package/dist/umd/tools/InitiateConnectionTool.d.ts +2 -2
- package/dist/umd/tools/ListConnectionsTool.d.ts +4 -4
- package/dist/umd/tools/ListUnapprovedConnectionRequestsTool.d.ts +4 -4
- package/dist/umd/tools/ManageConnectionRequestsTool.d.ts +4 -4
- package/dist/umd/tools/RegisterAgentTool.d.ts +76 -76
- package/dist/umd/tools/RetrieveProfileTool.d.ts +4 -4
- package/dist/umd/tools/SendMessageToConnectionTool.d.ts +6 -6
- package/dist/umd/tools/SendMessageTool.d.ts +6 -6
- package/package.json +3 -6
- package/src/agents/index.ts +1 -1
- package/src/plugins/PluginRegistry.ts +11 -11
- package/src/plugins/defi/index.ts +18 -18
- package/src/tools/CheckMessagesTool.ts +1 -1
- package/src/tools/InitiateConnectionTool.ts +1 -1
- package/src/tools/RetrieveProfileTool.ts +1 -1
|
@@ -10,15 +10,15 @@ import { HCS10Client } from '../../../src/hcs10/HCS10Client';
|
|
|
10
10
|
class GetTokenPriceTool extends StructuredTool {
|
|
11
11
|
name = 'get_token_price';
|
|
12
12
|
description = 'Get the current price of a token on Hedera';
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
schema = z.object({
|
|
15
15
|
tokenId: z.string().describe('The Hedera token ID (e.g., 0.0.12345)'),
|
|
16
16
|
});
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
constructor(private client: HCS10Client) {
|
|
19
19
|
super();
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
async _call(input: z.infer<typeof this.schema>): Promise<string> {
|
|
23
23
|
try {
|
|
24
24
|
// In a real implementation, this would map Hedera token IDs to CoinGecko IDs
|
|
@@ -28,14 +28,14 @@ class GetTokenPriceTool extends StructuredTool {
|
|
|
28
28
|
'0.0.5678': 'ethereum',
|
|
29
29
|
'0.0.9012': 'bitcoin',
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
const coinGeckoId = mockCoinGeckoIds[input.tokenId] || 'hbar';
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
// Use CoinGecko's public API (no API key required)
|
|
35
35
|
const response = await axios.get(`https://api.coingecko.com/api/v3/simple/price?ids=${coinGeckoId}&vs_currencies=usd`);
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
const price = response.data[coinGeckoId]?.usd || 0;
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
return `Current price of token ${input.tokenId}: $${price.toFixed(4)} USD`;
|
|
40
40
|
} catch (error) {
|
|
41
41
|
return `Error fetching token price: ${error instanceof Error ? error.message : String(error)}`;
|
|
@@ -49,27 +49,27 @@ class GetTokenPriceTool extends StructuredTool {
|
|
|
49
49
|
class SwapTokensTool extends StructuredTool {
|
|
50
50
|
name = 'swap_tokens';
|
|
51
51
|
description = 'Swap one token for another on Hedera';
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
schema = z.object({
|
|
54
54
|
fromTokenId: z.string().describe('The ID of the token to swap from (e.g., 0.0.12345)'),
|
|
55
55
|
toTokenId: z.string().describe('The ID of the token to swap to (e.g., 0.0.67890)'),
|
|
56
56
|
amount: z.number().positive().describe('The amount of the source token to swap'),
|
|
57
57
|
});
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
constructor(private client: HCS10Client) {
|
|
60
60
|
super();
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
async _call(input: z.infer<typeof this.schema>): Promise<string> {
|
|
64
64
|
try {
|
|
65
65
|
// In a real implementation, this would interact with a DEX contract
|
|
66
66
|
// This is a simplified mock implementation
|
|
67
67
|
const { accountId } = this.client.getAccountAndSigner();
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
// Mock exchange rate
|
|
70
70
|
const exchangeRate = Math.random() * 2;
|
|
71
71
|
const receivedAmount = input.amount * exchangeRate;
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
return `Simulated swap of ${input.amount} tokens (${input.fromTokenId}) for ${receivedAmount.toFixed(4)} tokens (${input.toTokenId}).\n\nNote: This is a mock implementation. In a real implementation, this would execute the swap through a DEX on Hedera.`;
|
|
74
74
|
} catch (error) {
|
|
75
75
|
return `Error performing token swap: ${error instanceof Error ? error.message : String(error)}`;
|
|
@@ -83,25 +83,25 @@ class SwapTokensTool extends StructuredTool {
|
|
|
83
83
|
class CheckTokenBalanceTool extends StructuredTool {
|
|
84
84
|
name = 'check_token_balance';
|
|
85
85
|
description = 'Check the balance of a token for an account on Hedera';
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
schema = z.object({
|
|
88
88
|
tokenId: z.string().describe('The Hedera token ID (e.g., 0.0.12345)'),
|
|
89
89
|
accountId: z.string().optional().describe('The account ID to check (defaults to the operator account)'),
|
|
90
90
|
});
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
constructor(private client: HCS10Client) {
|
|
93
93
|
super();
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
async _call(input: z.infer<typeof this.schema>): Promise<string> {
|
|
97
97
|
try {
|
|
98
98
|
const { accountId: operatorId } = this.client.getAccountAndSigner();
|
|
99
99
|
const accountToCheck = input.accountId || operatorId;
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
// In a real implementation, this would query the account's token balance
|
|
102
102
|
// This is a simplified mock implementation
|
|
103
103
|
const mockBalance = Math.floor(Math.random() * 10000);
|
|
104
|
-
|
|
104
|
+
|
|
105
105
|
return `Token balance for account ${accountToCheck}:\n${mockBalance} tokens of ${input.tokenId}\n\nNote: This is a mock implementation. In a real implementation, this would query the actual token balance from the Hedera network.`;
|
|
106
106
|
} catch (error) {
|
|
107
107
|
return `Error checking token balance: ${error instanceof Error ? error.message : String(error)}`;
|
|
@@ -118,7 +118,7 @@ export default class DeFiPlugin extends HCS10Plugin {
|
|
|
118
118
|
description = 'Provides tools to interact with DeFi protocols on Hedera';
|
|
119
119
|
version = '1.0.0';
|
|
120
120
|
author = 'Hashgraph Online';
|
|
121
|
-
|
|
121
|
+
|
|
122
122
|
getTools(): StructuredTool[] {
|
|
123
123
|
return [
|
|
124
124
|
new GetTokenPriceTool(this.context.client),
|
|
@@ -100,7 +100,7 @@ Use 'lastMessagesCount' to specify how many latest messages to retrieve (default
|
|
|
100
100
|
const msgTimestampNanos = msg.timestamp * 1_000_000;
|
|
101
101
|
return msgTimestampNanos > lastProcessedTimestamp;
|
|
102
102
|
});
|
|
103
|
-
|
|
103
|
+
|
|
104
104
|
if (messagesToProcess.length > 0) {
|
|
105
105
|
latestTimestampNanos = messagesToProcess.reduce(
|
|
106
106
|
(maxTs, msg) => Math.max(maxTs, msg.timestamp * 1_000_000),
|
|
@@ -74,7 +74,7 @@ export class InitiateConnectionTool extends StructuredTool {
|
|
|
74
74
|
if (!sequenceNumberLong) {
|
|
75
75
|
throw new Error('Connection request sequence number not found.');
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
let connectionRequestId: number;
|
|
79
79
|
try {
|
|
80
80
|
connectionRequestId = sequenceNumberLong.toNumber();
|
|
@@ -74,7 +74,7 @@ export class RetrieveProfileTool extends StructuredTool {
|
|
|
74
74
|
`Successfully retrieved profile for ${targetAccountId}.`
|
|
75
75
|
);
|
|
76
76
|
|
|
77
|
-
return JSON.stringify(result.profile, null, 2);
|
|
77
|
+
return JSON.stringify(result.profile, null, 2);
|
|
78
78
|
} else {
|
|
79
79
|
const errorMessage = `Error retrieving profile for ${targetAccountId}: ${
|
|
80
80
|
result.error || 'Profile not found or invalid.'
|