@hashgraphonline/standards-agent-kit 0.0.37 → 0.2.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/dist/cjs/builders/hcs10/hcs10-builder.d.ts +262 -0
- package/dist/cjs/builders/index.d.ts +2 -0
- package/dist/cjs/builders/types.d.ts +10 -0
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/init/init.d.ts +21 -22
- package/dist/cjs/plugins/PluginInterface.d.ts +4 -80
- package/dist/cjs/plugins/PluginRegistry.d.ts +1 -47
- package/dist/cjs/plugins/defi/index.d.ts +7 -4
- package/dist/cjs/plugins/hedera/HbarPricePlugin.d.ts +7 -35
- package/dist/cjs/plugins/index.d.ts +0 -5
- package/dist/cjs/plugins/weather/index.d.ts +6 -5
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/cjs/state/state-types.d.ts +8 -8
- package/dist/cjs/tools/hcs10/AcceptConnectionRequestTool.d.ts +40 -0
- package/dist/cjs/tools/hcs10/CheckMessagesTool.d.ts +40 -0
- package/dist/cjs/tools/hcs10/ConnectionMonitorTool.d.ts +134 -0
- package/dist/cjs/tools/hcs10/FindRegistrationsTool.d.ts +34 -0
- package/dist/cjs/tools/hcs10/InitiateConnectionTool.d.ts +43 -0
- package/dist/cjs/tools/hcs10/ListConnectionsTool.d.ts +34 -0
- package/dist/cjs/tools/hcs10/ListUnapprovedConnectionRequestsTool.d.ts +15 -0
- package/dist/cjs/tools/hcs10/ManageConnectionRequestsTool.d.ts +34 -0
- package/dist/cjs/tools/hcs10/RegisterAgentTool.d.ts +218 -0
- package/dist/cjs/tools/hcs10/RetrieveProfileTool.d.ts +33 -0
- package/dist/cjs/tools/hcs10/SendMessageToConnectionTool.d.ts +40 -0
- package/dist/cjs/tools/hcs10/base-hcs10-tools.d.ts +28 -0
- package/dist/cjs/tools/hcs10/hcs10-tool-params.d.ts +18 -0
- package/dist/cjs/tools/hcs10/index.d.ts +13 -0
- package/dist/cjs/tools/index.d.ts +1 -13
- package/dist/es/builders/hcs10/hcs10-builder.d.ts +262 -0
- package/dist/es/builders/index.d.ts +2 -0
- package/dist/es/builders/types.d.ts +10 -0
- package/dist/es/index.d.ts +3 -1
- package/dist/es/init/init.d.ts +21 -22
- package/dist/es/plugins/PluginInterface.d.ts +4 -80
- package/dist/es/plugins/PluginRegistry.d.ts +1 -47
- package/dist/es/plugins/defi/index.d.ts +7 -4
- package/dist/es/plugins/hedera/HbarPricePlugin.d.ts +7 -35
- package/dist/es/plugins/index.d.ts +0 -5
- package/dist/es/plugins/weather/index.d.ts +6 -5
- package/dist/es/standards-agent-kit.es.js +10 -18
- package/dist/es/standards-agent-kit.es.js.map +1 -1
- package/dist/es/standards-agent-kit.es10.js +29 -76
- package/dist/es/standards-agent-kit.es10.js.map +1 -1
- package/dist/es/standards-agent-kit.es11.js +61 -384
- package/dist/es/standards-agent-kit.es11.js.map +1 -1
- package/dist/es/standards-agent-kit.es12.js +22 -190
- package/dist/es/standards-agent-kit.es12.js.map +1 -1
- package/dist/es/standards-agent-kit.es13.js +26 -138
- package/dist/es/standards-agent-kit.es13.js.map +1 -1
- package/dist/es/standards-agent-kit.es14.js +35 -59
- package/dist/es/standards-agent-kit.es14.js.map +1 -1
- package/dist/es/standards-agent-kit.es15.js +11 -117
- package/dist/es/standards-agent-kit.es15.js.map +1 -1
- package/dist/es/standards-agent-kit.es16.js +1 -1
- package/dist/es/standards-agent-kit.es16.js.map +1 -1
- package/dist/es/standards-agent-kit.es17.js +63 -46
- package/dist/es/standards-agent-kit.es17.js.map +1 -1
- package/dist/es/standards-agent-kit.es18.js +25 -74
- package/dist/es/standards-agent-kit.es18.js.map +1 -1
- package/dist/es/standards-agent-kit.es19.js +22 -13
- package/dist/es/standards-agent-kit.es19.js.map +1 -1
- package/dist/es/standards-agent-kit.es2.js +1381 -188
- package/dist/es/standards-agent-kit.es2.js.map +1 -1
- package/dist/es/standards-agent-kit.es20.js +3 -67
- package/dist/es/standards-agent-kit.es20.js.map +1 -1
- package/dist/es/standards-agent-kit.es3.js +285 -347
- package/dist/es/standards-agent-kit.es3.js.map +1 -1
- package/dist/es/standards-agent-kit.es4.js +22 -74
- package/dist/es/standards-agent-kit.es4.js.map +1 -1
- package/dist/es/standards-agent-kit.es5.js +127 -154
- package/dist/es/standards-agent-kit.es5.js.map +1 -1
- package/dist/es/standards-agent-kit.es6.js +21 -88
- package/dist/es/standards-agent-kit.es6.js.map +1 -1
- package/dist/es/standards-agent-kit.es7.js +28 -86
- package/dist/es/standards-agent-kit.es7.js.map +1 -1
- package/dist/es/standards-agent-kit.es8.js +27 -100
- package/dist/es/standards-agent-kit.es8.js.map +1 -1
- package/dist/es/standards-agent-kit.es9.js +35 -117
- package/dist/es/standards-agent-kit.es9.js.map +1 -1
- package/dist/es/state/state-types.d.ts +8 -8
- package/dist/es/tools/hcs10/AcceptConnectionRequestTool.d.ts +40 -0
- package/dist/es/tools/hcs10/CheckMessagesTool.d.ts +40 -0
- package/dist/es/tools/hcs10/ConnectionMonitorTool.d.ts +134 -0
- package/dist/es/tools/hcs10/FindRegistrationsTool.d.ts +34 -0
- package/dist/es/tools/hcs10/InitiateConnectionTool.d.ts +43 -0
- package/dist/es/tools/hcs10/ListConnectionsTool.d.ts +34 -0
- package/dist/es/tools/hcs10/ListUnapprovedConnectionRequestsTool.d.ts +15 -0
- package/dist/es/tools/hcs10/ManageConnectionRequestsTool.d.ts +34 -0
- package/dist/es/tools/hcs10/RegisterAgentTool.d.ts +218 -0
- package/dist/es/tools/hcs10/RetrieveProfileTool.d.ts +33 -0
- package/dist/es/tools/hcs10/SendMessageToConnectionTool.d.ts +40 -0
- package/dist/es/tools/hcs10/base-hcs10-tools.d.ts +28 -0
- package/dist/es/tools/hcs10/hcs10-tool-params.d.ts +18 -0
- package/dist/es/tools/hcs10/index.d.ts +13 -0
- package/dist/es/tools/index.d.ts +1 -13
- package/dist/umd/builders/hcs10/hcs10-builder.d.ts +262 -0
- package/dist/umd/builders/index.d.ts +2 -0
- package/dist/umd/builders/types.d.ts +10 -0
- package/dist/umd/index.d.ts +3 -1
- package/dist/umd/init/init.d.ts +21 -22
- package/dist/umd/plugins/PluginInterface.d.ts +4 -80
- package/dist/umd/plugins/PluginRegistry.d.ts +1 -47
- package/dist/umd/plugins/defi/index.d.ts +7 -4
- package/dist/umd/plugins/hedera/HbarPricePlugin.d.ts +7 -35
- package/dist/umd/plugins/index.d.ts +0 -5
- package/dist/umd/plugins/weather/index.d.ts +6 -5
- package/dist/umd/standards-agent-kit.umd.js +1 -164
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/dist/umd/state/state-types.d.ts +8 -8
- package/dist/umd/tools/hcs10/AcceptConnectionRequestTool.d.ts +40 -0
- package/dist/umd/tools/hcs10/CheckMessagesTool.d.ts +40 -0
- package/dist/umd/tools/hcs10/ConnectionMonitorTool.d.ts +134 -0
- package/dist/umd/tools/hcs10/FindRegistrationsTool.d.ts +34 -0
- package/dist/umd/tools/hcs10/InitiateConnectionTool.d.ts +43 -0
- package/dist/umd/tools/hcs10/ListConnectionsTool.d.ts +34 -0
- package/dist/umd/tools/hcs10/ListUnapprovedConnectionRequestsTool.d.ts +15 -0
- package/dist/umd/tools/hcs10/ManageConnectionRequestsTool.d.ts +34 -0
- package/dist/umd/tools/hcs10/RegisterAgentTool.d.ts +218 -0
- package/dist/umd/tools/hcs10/RetrieveProfileTool.d.ts +33 -0
- package/dist/umd/tools/hcs10/SendMessageToConnectionTool.d.ts +40 -0
- package/dist/umd/tools/hcs10/base-hcs10-tools.d.ts +28 -0
- package/dist/umd/tools/hcs10/hcs10-tool-params.d.ts +18 -0
- package/dist/umd/tools/hcs10/index.d.ts +13 -0
- package/dist/umd/tools/index.d.ts +1 -13
- package/package.json +41 -41
- package/src/builders/hcs10/hcs10-builder.ts +2108 -0
- package/src/builders/index.ts +2 -0
- package/src/builders/types.ts +11 -0
- package/src/hcs10/HCS10Client.ts +3 -2
- package/src/index.ts +4 -2
- package/src/init/init.ts +85 -63
- package/src/plugins/PluginInterface.ts +15 -94
- package/src/plugins/PluginRegistry.ts +2 -98
- package/src/plugins/defi/index.ts +31 -118
- package/src/plugins/hedera/HbarPricePlugin.ts +19 -100
- package/src/plugins/index.ts +0 -5
- package/src/plugins/weather/index.ts +56 -40
- package/src/state/state-types.ts +9 -11
- package/src/tools/hcs10/AcceptConnectionRequestTool.ts +56 -0
- package/src/tools/hcs10/CheckMessagesTool.ts +73 -0
- package/src/tools/hcs10/ConnectionMonitorTool.ts +111 -0
- package/src/tools/hcs10/FindRegistrationsTool.ts +64 -0
- package/src/tools/hcs10/InitiateConnectionTool.ts +66 -0
- package/src/tools/hcs10/ListConnectionsTool.ts +58 -0
- package/src/tools/hcs10/ListUnapprovedConnectionRequestsTool.ts +26 -0
- package/src/tools/hcs10/ManageConnectionRequestsTool.ts +48 -0
- package/src/tools/hcs10/RegisterAgentTool.ts +213 -0
- package/src/tools/hcs10/RetrieveProfileTool.ts +61 -0
- package/src/tools/hcs10/SendMessageToConnectionTool.ts +45 -0
- package/src/tools/hcs10/base-hcs10-tools.ts +65 -0
- package/src/tools/hcs10/hcs10-tool-params.ts +21 -0
- package/src/tools/hcs10/index.ts +13 -0
- package/src/tools/index.ts +2 -13
- package/src/utils/HederaClient.ts +2 -2
- package/src/utils/ensure-agent-has-hbar.ts +3 -4
- package/dist/cjs/agents/index.d.ts +0 -0
- package/dist/cjs/plugins/BasePlugin.d.ts +0 -28
- package/dist/cjs/plugins/GenericPlugin.d.ts +0 -17
- package/dist/cjs/plugins/HCS10Plugin.d.ts +0 -13
- package/dist/cjs/plugins/PluginLoader.d.ts +0 -38
- package/dist/cjs/plugins/openconvai/OpenConvAIPlugin.d.ts +0 -23
- package/dist/cjs/plugins/openconvai/index.d.ts +0 -1
- package/dist/cjs/tools/AcceptConnectionRequestTool.d.ts +0 -33
- package/dist/cjs/tools/CheckMessagesTool.d.ts +0 -34
- package/dist/cjs/tools/ConnectionMonitorTool.d.ts +0 -100
- package/dist/cjs/tools/ConnectionTool.d.ts +0 -40
- package/dist/cjs/tools/FindRegistrationsTool.d.ts +0 -28
- package/dist/cjs/tools/InitiateConnectionTool.d.ts +0 -30
- package/dist/cjs/tools/ListConnectionsTool.d.ts +0 -33
- package/dist/cjs/tools/ListUnapprovedConnectionRequestsTool.d.ts +0 -41
- package/dist/cjs/tools/ManageConnectionRequestsTool.d.ts +0 -38
- package/dist/cjs/tools/RegisterAgentTool.d.ts +0 -188
- package/dist/cjs/tools/RetrieveProfileTool.d.ts +0 -34
- package/dist/cjs/tools/SendMessageToConnectionTool.d.ts +0 -34
- package/dist/cjs/tools/SendMessageTool.d.ts +0 -40
- package/dist/es/agents/index.d.ts +0 -0
- package/dist/es/plugins/BasePlugin.d.ts +0 -28
- package/dist/es/plugins/GenericPlugin.d.ts +0 -17
- package/dist/es/plugins/HCS10Plugin.d.ts +0 -13
- package/dist/es/plugins/PluginLoader.d.ts +0 -38
- package/dist/es/plugins/openconvai/OpenConvAIPlugin.d.ts +0 -23
- package/dist/es/plugins/openconvai/index.d.ts +0 -1
- package/dist/es/standards-agent-kit.es21.js +0 -92
- package/dist/es/standards-agent-kit.es21.js.map +0 -1
- package/dist/es/standards-agent-kit.es22.js +0 -7
- package/dist/es/standards-agent-kit.es22.js.map +0 -1
- package/dist/es/standards-agent-kit.es23.js +0 -106
- package/dist/es/standards-agent-kit.es23.js.map +0 -1
- package/dist/es/standards-agent-kit.es24.js +0 -7
- package/dist/es/standards-agent-kit.es24.js.map +0 -1
- package/dist/es/standards-agent-kit.es25.js +0 -7
- package/dist/es/standards-agent-kit.es25.js.map +0 -1
- package/dist/es/standards-agent-kit.es26.js +0 -85
- package/dist/es/standards-agent-kit.es26.js.map +0 -1
- package/dist/es/standards-agent-kit.es27.js +0 -28
- package/dist/es/standards-agent-kit.es27.js.map +0 -1
- package/dist/es/tools/AcceptConnectionRequestTool.d.ts +0 -33
- package/dist/es/tools/CheckMessagesTool.d.ts +0 -34
- package/dist/es/tools/ConnectionMonitorTool.d.ts +0 -100
- package/dist/es/tools/ConnectionTool.d.ts +0 -40
- package/dist/es/tools/FindRegistrationsTool.d.ts +0 -28
- package/dist/es/tools/InitiateConnectionTool.d.ts +0 -30
- package/dist/es/tools/ListConnectionsTool.d.ts +0 -33
- package/dist/es/tools/ListUnapprovedConnectionRequestsTool.d.ts +0 -41
- package/dist/es/tools/ManageConnectionRequestsTool.d.ts +0 -38
- package/dist/es/tools/RegisterAgentTool.d.ts +0 -188
- package/dist/es/tools/RetrieveProfileTool.d.ts +0 -34
- package/dist/es/tools/SendMessageToConnectionTool.d.ts +0 -34
- package/dist/es/tools/SendMessageTool.d.ts +0 -40
- package/dist/umd/agents/index.d.ts +0 -0
- package/dist/umd/plugins/BasePlugin.d.ts +0 -28
- package/dist/umd/plugins/GenericPlugin.d.ts +0 -17
- package/dist/umd/plugins/HCS10Plugin.d.ts +0 -13
- package/dist/umd/plugins/PluginLoader.d.ts +0 -38
- package/dist/umd/plugins/openconvai/OpenConvAIPlugin.d.ts +0 -23
- package/dist/umd/plugins/openconvai/index.d.ts +0 -1
- package/dist/umd/tools/AcceptConnectionRequestTool.d.ts +0 -33
- package/dist/umd/tools/CheckMessagesTool.d.ts +0 -34
- package/dist/umd/tools/ConnectionMonitorTool.d.ts +0 -100
- package/dist/umd/tools/ConnectionTool.d.ts +0 -40
- package/dist/umd/tools/FindRegistrationsTool.d.ts +0 -28
- package/dist/umd/tools/InitiateConnectionTool.d.ts +0 -30
- package/dist/umd/tools/ListConnectionsTool.d.ts +0 -33
- package/dist/umd/tools/ListUnapprovedConnectionRequestsTool.d.ts +0 -41
- package/dist/umd/tools/ManageConnectionRequestsTool.d.ts +0 -38
- package/dist/umd/tools/RegisterAgentTool.d.ts +0 -188
- package/dist/umd/tools/RetrieveProfileTool.d.ts +0 -34
- package/dist/umd/tools/SendMessageToConnectionTool.d.ts +0 -34
- package/dist/umd/tools/SendMessageTool.d.ts +0 -40
- package/src/agents/index.ts +0 -1
- package/src/plugins/BasePlugin.ts +0 -37
- package/src/plugins/GenericPlugin.ts +0 -19
- package/src/plugins/HCS10Plugin.ts +0 -14
- package/src/plugins/PluginLoader.ts +0 -121
- package/src/plugins/README.md +0 -113
- package/src/plugins/openconvai/OpenConvAIPlugin.ts +0 -124
- package/src/plugins/openconvai/index.ts +0 -1
- package/src/tools/AcceptConnectionRequestTool.ts +0 -196
- package/src/tools/CheckMessagesTool.ts +0 -194
- package/src/tools/ConnectionMonitorTool.ts +0 -550
- package/src/tools/ConnectionTool.ts +0 -231
- package/src/tools/FindRegistrationsTool.ts +0 -114
- package/src/tools/InitiateConnectionTool.ts +0 -137
- package/src/tools/ListConnectionsTool.ts +0 -158
- package/src/tools/ListUnapprovedConnectionRequestsTool.ts +0 -173
- package/src/tools/ManageConnectionRequestsTool.ts +0 -275
- package/src/tools/RegisterAgentTool.ts +0 -590
- package/src/tools/RetrieveProfileTool.ts +0 -94
- package/src/tools/SendMessageToConnectionTool.ts +0 -142
- package/src/tools/SendMessageTool.ts +0 -116
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TransactionReceipt } from '@hashgraph/sdk';
|
|
2
|
+
|
|
3
|
+
export interface ExecuteResult {
|
|
4
|
+
success: boolean;
|
|
5
|
+
receipt?: TransactionReceipt;
|
|
6
|
+
scheduleId?: string;
|
|
7
|
+
error?: string;
|
|
8
|
+
transactionId?: string | undefined;
|
|
9
|
+
rawResult?: unknown;
|
|
10
|
+
notes?: string[];
|
|
11
|
+
}
|
package/src/hcs10/HCS10Client.ts
CHANGED
|
@@ -313,7 +313,7 @@ export class HCS10Client {
|
|
|
313
313
|
(a: { timestamp: number }, b: { timestamp: number }) =>
|
|
314
314
|
a.timestamp - b.timestamp
|
|
315
315
|
);
|
|
316
|
-
return { messages: mappedMessages };
|
|
316
|
+
return { messages: mappedMessages as HCSMessageWithTimestamp[] };
|
|
317
317
|
} catch (error) {
|
|
318
318
|
this.logger.error(`Error getting messages from topic ${topicId}:`, error);
|
|
319
319
|
return { messages: [] };
|
|
@@ -323,7 +323,8 @@ export class HCS10Client {
|
|
|
323
323
|
public async getMessageStream(topicId: string): Promise<{
|
|
324
324
|
messages: HCSMessage[];
|
|
325
325
|
}> {
|
|
326
|
-
|
|
326
|
+
const result = this.standardClient.getMessageStream(topicId);
|
|
327
|
+
return result as Promise<{ messages: HCSMessage[] }>;
|
|
327
328
|
}
|
|
328
329
|
|
|
329
330
|
/**
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export * from './hcs10';
|
|
2
1
|
export * from './tools';
|
|
3
2
|
export * from './state';
|
|
4
3
|
export * from './init';
|
|
5
|
-
export * from './plugins';
|
|
4
|
+
export * from './plugins';
|
|
5
|
+
export { HCS10Builder } from './builders';
|
|
6
|
+
export type { ExecuteResult } from './builders';
|
|
7
|
+
export { HCS10Client } from './hcs10';
|
package/src/init/init.ts
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { HederaAgentKit, ServerSigner } from 'hedera-agent-kit';
|
|
2
|
+
import { HCS10Builder } from '../builders/hcs10/hcs10-builder';
|
|
3
|
+
import { RegisterAgentTool } from '../tools/hcs10/RegisterAgentTool';
|
|
4
|
+
import { FindRegistrationsTool } from '../tools/hcs10/FindRegistrationsTool';
|
|
5
|
+
import { InitiateConnectionTool } from '../tools/hcs10/InitiateConnectionTool';
|
|
6
|
+
import { ListConnectionsTool } from '../tools/hcs10/ListConnectionsTool';
|
|
7
|
+
import { SendMessageToConnectionTool } from '../tools/hcs10/SendMessageToConnectionTool';
|
|
8
|
+
import { CheckMessagesTool } from '../tools/hcs10/CheckMessagesTool';
|
|
9
|
+
import { ConnectionMonitorTool } from '../tools/hcs10/ConnectionMonitorTool';
|
|
10
|
+
import { ManageConnectionRequestsTool } from '../tools/hcs10/ManageConnectionRequestsTool';
|
|
11
|
+
import { AcceptConnectionRequestTool } from '../tools/hcs10/AcceptConnectionRequestTool';
|
|
12
|
+
import { RetrieveProfileTool } from '../tools/hcs10/RetrieveProfileTool';
|
|
13
|
+
import { ListUnapprovedConnectionRequestsTool } from '../tools/hcs10/ListUnapprovedConnectionRequestsTool';
|
|
5
14
|
import { IStateManager } from '../state/state-types';
|
|
6
15
|
import { OpenConvaiState } from '../state/open-convai-state';
|
|
7
|
-
import { FindRegistrationsTool } from '../tools/FindRegistrationsTool';
|
|
8
|
-
import { InitiateConnectionTool } from '../tools/InitiateConnectionTool';
|
|
9
|
-
import { ListConnectionsTool } from '../tools/ListConnectionsTool';
|
|
10
|
-
import { SendMessageToConnectionTool } from '../tools/SendMessageToConnectionTool';
|
|
11
|
-
import { CheckMessagesTool } from '../tools/CheckMessagesTool';
|
|
12
|
-
import { ConnectionMonitorTool } from '../tools/ConnectionMonitorTool';
|
|
13
|
-
import { ManageConnectionRequestsTool } from '../tools/ManageConnectionRequestsTool';
|
|
14
|
-
import { AcceptConnectionRequestTool } from '../tools/AcceptConnectionRequestTool';
|
|
15
|
-
import { RetrieveProfileTool } from '../tools/RetrieveProfileTool';
|
|
16
|
-
import { ListUnapprovedConnectionRequestsTool } from '../tools/ListUnapprovedConnectionRequestsTool';
|
|
17
16
|
import { Logger } from '@hashgraphonline/standards-sdk';
|
|
18
17
|
import { ENV_FILE_PATH } from '../utils/state-tools';
|
|
19
18
|
|
|
20
19
|
export interface HCS10ClientConfig {
|
|
21
20
|
operatorId?: string;
|
|
22
21
|
operatorKey?: string;
|
|
23
|
-
network?:
|
|
22
|
+
network?: 'mainnet' | 'testnet';
|
|
24
23
|
useEncryption?: boolean;
|
|
25
24
|
registryUrl?: string;
|
|
26
25
|
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
@@ -44,8 +43,6 @@ export interface HCS10Tools {
|
|
|
44
43
|
listConnectionsTool: ListConnectionsTool;
|
|
45
44
|
sendMessageToConnectionTool: SendMessageToConnectionTool;
|
|
46
45
|
checkMessagesTool: CheckMessagesTool;
|
|
47
|
-
sendMessageTool: SendMessageTool;
|
|
48
|
-
connectionTool: ConnectionTool;
|
|
49
46
|
connectionMonitorTool: ConnectionMonitorTool;
|
|
50
47
|
manageConnectionRequestsTool: ManageConnectionRequestsTool;
|
|
51
48
|
acceptConnectionRequestTool: AcceptConnectionRequestTool;
|
|
@@ -56,16 +53,18 @@ export interface HCS10Tools {
|
|
|
56
53
|
* Initializes the HCS10 client and returns pre-registered LangChain tools.
|
|
57
54
|
*
|
|
58
55
|
* @param options - Initialization options
|
|
59
|
-
* @returns Object containing
|
|
56
|
+
* @returns Object containing hederaKit, hcs10Builder and requested tools
|
|
60
57
|
*/
|
|
61
|
-
export const initializeStandardsAgentKit = (
|
|
58
|
+
export const initializeStandardsAgentKit = async (
|
|
62
59
|
options?: HCS10InitializationOptions
|
|
63
|
-
): {
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
): Promise<{
|
|
61
|
+
hederaKit: HederaAgentKit;
|
|
62
|
+
hcs10Builder: HCS10Builder;
|
|
63
|
+
monitoringHederaKit?: HederaAgentKit;
|
|
64
|
+
monitoringHcs10Builder?: HCS10Builder;
|
|
66
65
|
tools: Partial<HCS10Tools>;
|
|
67
66
|
stateManager: IStateManager;
|
|
68
|
-
} => {
|
|
67
|
+
}> => {
|
|
69
68
|
const config = options?.clientConfig || {};
|
|
70
69
|
|
|
71
70
|
const operatorId = config.operatorId || process.env.HEDERA_OPERATOR_ID;
|
|
@@ -74,7 +73,7 @@ export const initializeStandardsAgentKit = (
|
|
|
74
73
|
|
|
75
74
|
const networkEnv = config.network || process.env.HEDERA_NETWORK || 'testnet';
|
|
76
75
|
|
|
77
|
-
let network:
|
|
76
|
+
let network: 'mainnet' | 'testnet';
|
|
78
77
|
if (networkEnv === 'mainnet') {
|
|
79
78
|
network = 'mainnet';
|
|
80
79
|
} else if (networkEnv === 'testnet') {
|
|
@@ -106,82 +105,105 @@ export const initializeStandardsAgentKit = (
|
|
|
106
105
|
});
|
|
107
106
|
logger.info('State manager initialized');
|
|
108
107
|
|
|
109
|
-
|
|
108
|
+
// Create HederaAgentKit
|
|
109
|
+
const signer = new ServerSigner(operatorId, operatorPrivateKey, network);
|
|
110
|
+
const hederaKit = new HederaAgentKit(signer);
|
|
111
|
+
await hederaKit.initialize();
|
|
112
|
+
logger.info(`HederaAgentKit initialized for ${operatorId} on ${network}`);
|
|
113
|
+
|
|
114
|
+
// Create HCS10Builder
|
|
115
|
+
const hcs10Builder = new HCS10Builder(hederaKit, stateManager, {
|
|
110
116
|
useEncryption: config.useEncryption,
|
|
111
117
|
registryUrl: config.registryUrl,
|
|
118
|
+
logLevel: config.logLevel,
|
|
112
119
|
});
|
|
113
|
-
logger.info(`HCS10Client initialized for ${operatorId} on ${network}`);
|
|
114
120
|
|
|
115
|
-
let
|
|
121
|
+
let monitoringHederaKit: HederaAgentKit | undefined;
|
|
122
|
+
let monitoringHcs10Builder: HCS10Builder | undefined;
|
|
123
|
+
|
|
116
124
|
if (options?.monitoringClient) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
);
|
|
125
|
+
const monitoringSigner = new ServerSigner(operatorId, operatorPrivateKey, network);
|
|
126
|
+
monitoringHederaKit = new HederaAgentKit(monitoringSigner);
|
|
127
|
+
await monitoringHederaKit.initialize();
|
|
128
|
+
monitoringHcs10Builder = new HCS10Builder(monitoringHederaKit, stateManager, {
|
|
129
|
+
useEncryption: config.useEncryption,
|
|
130
|
+
registryUrl: config.registryUrl,
|
|
131
|
+
logLevel: 'error',
|
|
132
|
+
});
|
|
127
133
|
logger.info('Monitoring client initialized');
|
|
128
134
|
}
|
|
129
135
|
|
|
130
136
|
const tools: Partial<HCS10Tools> = {};
|
|
131
137
|
|
|
132
|
-
|
|
133
|
-
tools.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
// Always create RegisterAgentTool
|
|
139
|
+
tools.registerAgentTool = new RegisterAgentTool({
|
|
140
|
+
hederaKit,
|
|
141
|
+
hcs10Builder,
|
|
142
|
+
logger: undefined,
|
|
137
143
|
});
|
|
138
144
|
|
|
139
145
|
if (options?.createAllTools) {
|
|
140
146
|
tools.findRegistrationsTool = new FindRegistrationsTool({
|
|
141
|
-
|
|
147
|
+
hederaKit,
|
|
148
|
+
hcs10Builder,
|
|
149
|
+
logger: undefined,
|
|
150
|
+
});
|
|
151
|
+
tools.retrieveProfileTool = new RetrieveProfileTool({
|
|
152
|
+
hederaKit,
|
|
153
|
+
hcs10Builder,
|
|
154
|
+
logger: undefined,
|
|
142
155
|
});
|
|
143
|
-
tools.retrieveProfileTool = new RetrieveProfileTool(hcs10Client);
|
|
144
156
|
tools.initiateConnectionTool = new InitiateConnectionTool({
|
|
145
|
-
|
|
146
|
-
|
|
157
|
+
hederaKit,
|
|
158
|
+
hcs10Builder,
|
|
159
|
+
logger: undefined,
|
|
147
160
|
});
|
|
148
161
|
tools.listConnectionsTool = new ListConnectionsTool({
|
|
149
|
-
|
|
150
|
-
|
|
162
|
+
hederaKit,
|
|
163
|
+
hcs10Builder,
|
|
164
|
+
logger: undefined,
|
|
151
165
|
});
|
|
152
166
|
tools.sendMessageToConnectionTool = new SendMessageToConnectionTool({
|
|
153
|
-
|
|
154
|
-
|
|
167
|
+
hederaKit,
|
|
168
|
+
hcs10Builder,
|
|
169
|
+
logger: undefined,
|
|
155
170
|
});
|
|
156
171
|
tools.checkMessagesTool = new CheckMessagesTool({
|
|
157
|
-
|
|
158
|
-
|
|
172
|
+
hederaKit,
|
|
173
|
+
hcs10Builder,
|
|
174
|
+
logger: undefined,
|
|
159
175
|
});
|
|
160
176
|
tools.connectionMonitorTool = new ConnectionMonitorTool({
|
|
161
|
-
|
|
162
|
-
|
|
177
|
+
hederaKit: monitoringHederaKit || hederaKit,
|
|
178
|
+
hcs10Builder: monitoringHcs10Builder || hcs10Builder,
|
|
179
|
+
logger: undefined,
|
|
163
180
|
});
|
|
164
181
|
tools.manageConnectionRequestsTool = new ManageConnectionRequestsTool({
|
|
165
|
-
|
|
166
|
-
|
|
182
|
+
hederaKit,
|
|
183
|
+
hcs10Builder,
|
|
184
|
+
logger: undefined,
|
|
167
185
|
});
|
|
168
186
|
tools.acceptConnectionRequestTool = new AcceptConnectionRequestTool({
|
|
169
|
-
|
|
170
|
-
|
|
187
|
+
hederaKit,
|
|
188
|
+
hcs10Builder,
|
|
189
|
+
logger: undefined,
|
|
171
190
|
});
|
|
172
191
|
tools.listUnapprovedConnectionRequestsTool =
|
|
173
192
|
new ListUnapprovedConnectionRequestsTool({
|
|
174
|
-
|
|
175
|
-
|
|
193
|
+
hederaKit,
|
|
194
|
+
hcs10Builder,
|
|
195
|
+
logger: undefined,
|
|
176
196
|
});
|
|
177
197
|
|
|
178
198
|
logger.info('All tools initialized');
|
|
179
199
|
}
|
|
180
200
|
|
|
181
201
|
return {
|
|
182
|
-
|
|
183
|
-
|
|
202
|
+
hederaKit,
|
|
203
|
+
hcs10Builder,
|
|
204
|
+
monitoringHederaKit,
|
|
205
|
+
monitoringHcs10Builder,
|
|
184
206
|
tools,
|
|
185
207
|
stateManager,
|
|
186
208
|
};
|
|
187
|
-
};
|
|
209
|
+
};
|
|
@@ -1,56 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
// Re-export plugin interfaces from hedera-agent-kit for consistency
|
|
2
|
+
export { BasePlugin } from 'hedera-agent-kit';
|
|
3
|
+
export type {
|
|
4
|
+
IPlugin,
|
|
5
|
+
BasePluginContext,
|
|
6
|
+
GenericPluginContext,
|
|
7
|
+
PluginContext,
|
|
8
|
+
IPluginClient,
|
|
9
|
+
IPluginStateManager,
|
|
10
|
+
HederaTool,
|
|
11
|
+
} from 'hedera-agent-kit';
|
|
12
|
+
|
|
13
|
+
// Extended context for HCS10-specific functionality
|
|
2
14
|
import { HCS10Client } from '../hcs10/HCS10Client';
|
|
3
15
|
import { IStateManager } from '../state/state-types';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Basic client interface required by plugins
|
|
8
|
-
*/
|
|
9
|
-
export interface IPluginClient {
|
|
10
|
-
getNetwork(): string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Basic state manager interface required by plugins
|
|
15
|
-
*/
|
|
16
|
-
export interface IPluginStateManager {
|
|
17
|
-
getCurrentAgent?(): unknown;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Base context provided to all plugins during initialization
|
|
22
|
-
*/
|
|
23
|
-
export interface BasePluginContext {
|
|
24
|
-
/**
|
|
25
|
-
* Logger instance
|
|
26
|
-
*/
|
|
27
|
-
logger: Logger;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Configuration options
|
|
31
|
-
*/
|
|
32
|
-
config: Record<string, unknown>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Context provided to platform-agnostic plugins during initialization
|
|
37
|
-
*/
|
|
38
|
-
export interface GenericPluginContext extends BasePluginContext {
|
|
39
|
-
/**
|
|
40
|
-
* Generic client interface
|
|
41
|
-
*/
|
|
42
|
-
client: IPluginClient;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Optional generic state manager
|
|
46
|
-
*/
|
|
47
|
-
stateManager?: IPluginStateManager;
|
|
48
|
-
}
|
|
16
|
+
import { BasePluginContext } from 'hedera-agent-kit';
|
|
49
17
|
|
|
50
18
|
/**
|
|
51
19
|
* Context provided to HCS10-specific plugins during initialization
|
|
52
20
|
*/
|
|
53
|
-
export interface
|
|
21
|
+
export interface HCS10PluginContext extends BasePluginContext {
|
|
54
22
|
/**
|
|
55
23
|
* The HCS10Client instance
|
|
56
24
|
*/
|
|
@@ -61,50 +29,3 @@ export interface PluginContext extends BasePluginContext {
|
|
|
61
29
|
*/
|
|
62
30
|
stateManager?: IStateManager;
|
|
63
31
|
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Standard interface that all plugins must implement
|
|
67
|
-
*/
|
|
68
|
-
export interface IPlugin<T extends BasePluginContext = BasePluginContext> {
|
|
69
|
-
/**
|
|
70
|
-
* Unique identifier for the plugin
|
|
71
|
-
*/
|
|
72
|
-
id: string;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Human-readable name of the plugin
|
|
76
|
-
*/
|
|
77
|
-
name: string;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Description of what the plugin does
|
|
81
|
-
*/
|
|
82
|
-
description: string;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Version of the plugin
|
|
86
|
-
*/
|
|
87
|
-
version: string;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Author of the plugin
|
|
91
|
-
*/
|
|
92
|
-
author: string;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Initialize the plugin with the provided context
|
|
96
|
-
* @param context The context containing shared resources
|
|
97
|
-
*/
|
|
98
|
-
initialize(context: T): Promise<void>;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Get the tools provided by this plugin
|
|
102
|
-
* @returns Array of tools provided by this plugin
|
|
103
|
-
*/
|
|
104
|
-
getTools(): StructuredTool[];
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Clean up resources when the plugin is unloaded
|
|
108
|
-
*/
|
|
109
|
-
cleanup?(): Promise<void>;
|
|
110
|
-
}
|
|
@@ -1,98 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { Logger } from '@hashgraphonline/standards-sdk';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Registry for managing plugins in the Standards Agent Kit
|
|
7
|
-
*/
|
|
8
|
-
export class PluginRegistry {
|
|
9
|
-
private plugins: Map<string, IPlugin> = new Map();
|
|
10
|
-
private context: PluginContext;
|
|
11
|
-
private logger: Logger;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Creates a new PluginRegistry instance
|
|
15
|
-
* @param context The context to provide to plugins during initialization
|
|
16
|
-
*/
|
|
17
|
-
constructor(context: PluginContext) {
|
|
18
|
-
this.context = context;
|
|
19
|
-
this.logger = context.logger;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Register a plugin with the registry
|
|
24
|
-
* @param plugin The plugin to register
|
|
25
|
-
* @throws Error if a plugin with the same ID is already registered
|
|
26
|
-
*/
|
|
27
|
-
async registerPlugin(plugin: IPlugin): Promise<void> {
|
|
28
|
-
if (this.plugins.has(plugin.id)) {
|
|
29
|
-
throw new Error(`Plugin with ID ${plugin.id} is already registered`);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
await plugin.initialize(this.context);
|
|
33
|
-
this.plugins.set(plugin.id, plugin);
|
|
34
|
-
this.logger.info(`Plugin registered: ${plugin.name} (${plugin.id}) v${plugin.version}`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Get a plugin by ID
|
|
39
|
-
* @param id The ID of the plugin to retrieve
|
|
40
|
-
* @returns The plugin, or undefined if not found
|
|
41
|
-
*/
|
|
42
|
-
getPlugin(id: string): IPlugin | undefined {
|
|
43
|
-
return this.plugins.get(id);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Get all registered plugins
|
|
48
|
-
* @returns Array of all registered plugins
|
|
49
|
-
*/
|
|
50
|
-
getAllPlugins(): IPlugin[] {
|
|
51
|
-
return Array.from(this.plugins.values());
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Get all tools from all registered plugins
|
|
56
|
-
* @returns Array of all tools provided by registered plugins
|
|
57
|
-
*/
|
|
58
|
-
getAllTools(): StructuredTool[] {
|
|
59
|
-
return this.getAllPlugins().flatMap(plugin => plugin.getTools());
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Unregister a plugin
|
|
64
|
-
* @param id The ID of the plugin to unregister
|
|
65
|
-
* @returns true if the plugin was unregistered, false if it wasn't found
|
|
66
|
-
*/
|
|
67
|
-
async unregisterPlugin(id: string): Promise<boolean> {
|
|
68
|
-
const plugin = this.plugins.get(id);
|
|
69
|
-
if (!plugin) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (plugin.cleanup) {
|
|
74
|
-
try {
|
|
75
|
-
await plugin.cleanup();
|
|
76
|
-
} catch (error) {
|
|
77
|
-
this.logger.error(`Error during plugin cleanup: ${error}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const result = this.plugins.delete(id);
|
|
82
|
-
if (result) {
|
|
83
|
-
this.logger.info(`Plugin unregistered: ${plugin.name} (${plugin.id})`);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Unregister all plugins
|
|
91
|
-
*/
|
|
92
|
-
async unregisterAllPlugins(): Promise<void> {
|
|
93
|
-
const pluginIds = Array.from(this.plugins.keys());
|
|
94
|
-
for (const id of pluginIds) {
|
|
95
|
-
await this.unregisterPlugin(id);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
1
|
+
// Re-export PluginRegistry from hedera-agent-kit
|
|
2
|
+
export { PluginRegistry } from 'hedera-agent-kit';
|
|
@@ -1,129 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Tool for getting token price information using CoinGecko
|
|
9
|
-
*/
|
|
10
|
-
class GetTokenPriceTool extends StructuredTool {
|
|
11
|
-
name = 'get_token_price';
|
|
12
|
-
description = 'Get the current price of a token on Hedera';
|
|
13
|
-
|
|
14
|
-
schema = z.object({
|
|
15
|
-
tokenId: z.string().describe('The Hedera token ID (e.g., 0.0.12345)'),
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
constructor(private client: HCS10Client) {
|
|
19
|
-
super();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async _call(input: z.infer<typeof this.schema>): Promise<string> {
|
|
23
|
-
try {
|
|
24
|
-
// In a real implementation, this would map Hedera token IDs to CoinGecko IDs
|
|
25
|
-
// This is a simplified mock implementation
|
|
26
|
-
const mockCoinGeckoIds: Record<string, string> = {
|
|
27
|
-
'0.0.1234': 'hbar',
|
|
28
|
-
'0.0.5678': 'ethereum',
|
|
29
|
-
'0.0.9012': 'bitcoin',
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const coinGeckoId = mockCoinGeckoIds[input.tokenId] || 'hbar';
|
|
33
|
-
|
|
34
|
-
// Use CoinGecko's public API (no API key required)
|
|
35
|
-
const response = await axios.get(`https://api.coingecko.com/api/v3/simple/price?ids=${coinGeckoId}&vs_currencies=usd`);
|
|
36
|
-
|
|
37
|
-
const price = response.data[coinGeckoId]?.usd || 0;
|
|
38
|
-
|
|
39
|
-
return `Current price of token ${input.tokenId}: $${price.toFixed(4)} USD`;
|
|
40
|
-
} catch (error) {
|
|
41
|
-
return `Error fetching token price: ${error instanceof Error ? error.message : String(error)}`;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Tool for swapping tokens
|
|
48
|
-
*/
|
|
49
|
-
class SwapTokensTool extends StructuredTool {
|
|
50
|
-
name = 'swap_tokens';
|
|
51
|
-
description = 'Swap one token for another on Hedera';
|
|
52
|
-
|
|
53
|
-
schema = z.object({
|
|
54
|
-
fromTokenId: z.string().describe('The ID of the token to swap from (e.g., 0.0.12345)'),
|
|
55
|
-
toTokenId: z.string().describe('The ID of the token to swap to (e.g., 0.0.67890)'),
|
|
56
|
-
amount: z.number().positive().describe('The amount of the source token to swap'),
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
constructor(private client: HCS10Client) {
|
|
60
|
-
super();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async _call(input: z.infer<typeof this.schema>): Promise<string> {
|
|
64
|
-
try {
|
|
65
|
-
// In a real implementation, this would interact with a DEX contract
|
|
66
|
-
// This is a simplified mock implementation
|
|
67
|
-
const { accountId } = this.client.getAccountAndSigner();
|
|
68
|
-
|
|
69
|
-
// Mock exchange rate
|
|
70
|
-
const exchangeRate = Math.random() * 2;
|
|
71
|
-
const receivedAmount = input.amount * exchangeRate;
|
|
72
|
-
|
|
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
|
-
} catch (error) {
|
|
75
|
-
return `Error performing token swap: ${error instanceof Error ? error.message : String(error)}`;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Tool for checking token balance
|
|
82
|
-
*/
|
|
83
|
-
class CheckTokenBalanceTool extends StructuredTool {
|
|
84
|
-
name = 'check_token_balance';
|
|
85
|
-
description = 'Check the balance of a token for an account on Hedera';
|
|
86
|
-
|
|
87
|
-
schema = z.object({
|
|
88
|
-
tokenId: z.string().describe('The Hedera token ID (e.g., 0.0.12345)'),
|
|
89
|
-
accountId: z.string().optional().describe('The account ID to check (defaults to the operator account)'),
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
constructor(private client: HCS10Client) {
|
|
93
|
-
super();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async _call(input: z.infer<typeof this.schema>): Promise<string> {
|
|
97
|
-
try {
|
|
98
|
-
const { accountId: operatorId } = this.client.getAccountAndSigner();
|
|
99
|
-
const accountToCheck = input.accountId || operatorId;
|
|
100
|
-
|
|
101
|
-
// In a real implementation, this would query the account's token balance
|
|
102
|
-
// This is a simplified mock implementation
|
|
103
|
-
const mockBalance = Math.floor(Math.random() * 10000);
|
|
104
|
-
|
|
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
|
-
} catch (error) {
|
|
107
|
-
return `Error checking token balance: ${error instanceof Error ? error.message : String(error)}`;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
1
|
+
import { BasePlugin, GenericPluginContext, HederaTool, HederaAgentKit } from 'hedera-agent-kit';
|
|
2
|
+
import {
|
|
3
|
+
HederaGetTokenInfoTool,
|
|
4
|
+
HederaTransferTokensTool,
|
|
5
|
+
HederaGetAccountTokensTool,
|
|
6
|
+
HederaAssociateTokensTool
|
|
7
|
+
} from 'hedera-agent-kit';
|
|
111
8
|
|
|
112
9
|
/**
|
|
113
10
|
* DeFi Integration Plugin for the Standards Agent Kit
|
|
11
|
+
* Uses built-in Hedera token tools from hedera-agent-kit
|
|
114
12
|
*/
|
|
115
|
-
export default class DeFiPlugin extends
|
|
13
|
+
export default class DeFiPlugin extends BasePlugin<GenericPluginContext> {
|
|
116
14
|
id = 'defi-integration';
|
|
117
15
|
name = 'DeFi Integration Plugin';
|
|
118
|
-
description = 'Provides tools to interact with DeFi protocols on Hedera';
|
|
16
|
+
description = 'Provides tools to interact with DeFi protocols on Hedera using built-in Hedera tools';
|
|
119
17
|
version = '1.0.0';
|
|
120
18
|
author = 'Hashgraph Online';
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
19
|
+
|
|
20
|
+
private tools: HederaTool[] = [];
|
|
21
|
+
|
|
22
|
+
override async initialize(context: GenericPluginContext): Promise<void> {
|
|
23
|
+
await super.initialize(context);
|
|
24
|
+
this.initializeTools();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private initializeTools(): void {
|
|
28
|
+
const hederaKit = this.context.config.hederaKit as HederaAgentKit;
|
|
29
|
+
const logger = this.context.logger;
|
|
30
|
+
|
|
31
|
+
this.tools = [
|
|
32
|
+
new HederaGetTokenInfoTool({ hederaKit, logger }),
|
|
33
|
+
new HederaTransferTokensTool({ hederaKit, logger }),
|
|
34
|
+
new HederaGetAccountTokensTool({ hederaKit, logger }),
|
|
35
|
+
new HederaAssociateTokensTool({ hederaKit, logger })
|
|
127
36
|
];
|
|
128
37
|
}
|
|
38
|
+
|
|
39
|
+
getTools(): HederaTool[] {
|
|
40
|
+
return this.tools;
|
|
41
|
+
}
|
|
129
42
|
}
|