@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
|
@@ -1,118 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { IPlugin /*, PluginContext */ } from '../PluginInterface';
|
|
4
|
-
import axios from 'axios'; // Use axios instead of node-fetch
|
|
1
|
+
// Re-export the HBAR price tool from hedera-agent-kit
|
|
2
|
+
export { HederaGetHbarPriceTool as GetHbarPriceTool } from 'hedera-agent-kit';
|
|
5
3
|
|
|
6
|
-
|
|
4
|
+
import { BasePlugin, GenericPluginContext, HederaTool, HederaAgentKit } from 'hedera-agent-kit';
|
|
5
|
+
import { HederaGetHbarPriceTool } from 'hedera-agent-kit';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
|
-
* Defines the schema for the HBAR price API response.
|
|
10
|
-
*/
|
|
11
|
-
const ExchangeRateResponseSchema = z.object({
|
|
12
|
-
current_rate: z.object({
|
|
13
|
-
cent_equivalent: z.number(),
|
|
14
|
-
hbar_equivalent: z.number(),
|
|
15
|
-
expiration_time: z.number(),
|
|
16
|
-
}),
|
|
17
|
-
next_rate: z.object({
|
|
18
|
-
cent_equivalent: z.number(),
|
|
19
|
-
hbar_equivalent: z.number(),
|
|
20
|
-
expiration_time: z.number(),
|
|
21
|
-
}),
|
|
22
|
-
timestamp: z.string(),
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* A Langchain tool to get the current HBAR price in USD.
|
|
27
|
-
*/
|
|
28
|
-
// Export the class for testing purposes
|
|
29
|
-
export class GetHbarPriceTool extends StructuredTool {
|
|
30
|
-
name = 'getHbarPrice';
|
|
31
|
-
description = 'Retrieves the current price of HBAR in USD from the Hedera Mirror Node.';
|
|
32
|
-
schema = z.object({}); // No input required for this tool
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* DISCLAIMER: THIS TOOL USES THE EXCHANGE RATE ENDPOINT FROM THE MIRROR NODE, AND IT IS NOT GUARANTEED TO BE ACCURATE.
|
|
36
|
-
* USE AN ORACLE OR OTHER SOURCES FOR PRODUCTION USE WHERE PRICE IS IMPORTANT.
|
|
37
|
-
* Retrieves the current price of HBAR in USD from the Hedera Mirror Node.
|
|
38
|
-
* @returns A promise that resolves to a string containing the current HBAR price in USD.
|
|
39
|
-
*/
|
|
40
|
-
protected async _call(): Promise<string> {
|
|
41
|
-
try {
|
|
42
|
-
// Use axios.get instead of fetch
|
|
43
|
-
const response = await axios.get(`${HEDERA_MIRROR_NODE_API}/network/exchangerate`);
|
|
44
|
-
|
|
45
|
-
// Axios puts data directly in response.data
|
|
46
|
-
const data: unknown = response.data;
|
|
47
|
-
|
|
48
|
-
// Validate the response structure
|
|
49
|
-
const parsedData = ExchangeRateResponseSchema.safeParse(data);
|
|
50
|
-
if (!parsedData.success) {
|
|
51
|
-
console.error("Failed to parse exchange rate response:", parsedData.error);
|
|
52
|
-
throw new Error('Invalid API response format');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const { current_rate } = parsedData.data;
|
|
56
|
-
const priceUsd = current_rate.cent_equivalent / current_rate.hbar_equivalent / 100;
|
|
57
|
-
|
|
58
|
-
return `The current price of HBAR is $${priceUsd.toFixed(6)} USD.`;
|
|
59
|
-
} catch (error) {
|
|
60
|
-
console.error('Error fetching HBAR price:', error);
|
|
61
|
-
// Handle axios errors specifically if needed, otherwise generic handling
|
|
62
|
-
let errorMessage = 'An unknown error occurred';
|
|
63
|
-
if (axios.isAxiosError(error)) {
|
|
64
|
-
errorMessage = error.message;
|
|
65
|
-
if (error.response) {
|
|
66
|
-
errorMessage += ` (Status: ${error.response.status})`;
|
|
67
|
-
}
|
|
68
|
-
} else if (error instanceof Error) {
|
|
69
|
-
errorMessage = error.message;
|
|
70
|
-
}
|
|
71
|
-
return `Failed to retrieve HBAR price: ${errorMessage}`;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* DISCLAIMER: THIS PLUGIN USES THE EXCHANGE RATE ENDPOINT FROM THE MIRROR NODE, AND IT IS NOT GUARANTEED TO BE ACCURATE.
|
|
79
|
-
* USE AN ORACLE OR OTHER SOURCES FOR PRODUCTION USE WHERE PRICE IS IMPORTANT.
|
|
80
8
|
* Plugin to provide tools related to Hedera network information, like HBAR price.
|
|
9
|
+
* Uses the built-in HederaGetHbarPriceTool from hedera-agent-kit.
|
|
81
10
|
*/
|
|
82
|
-
export class HbarPricePlugin
|
|
11
|
+
export class HbarPricePlugin extends BasePlugin<GenericPluginContext> {
|
|
83
12
|
id = 'hedera-hbar-price';
|
|
84
13
|
name = 'Hedera HBAR Price Plugin';
|
|
85
14
|
description = 'Provides tools to interact with Hedera network data, specifically HBAR price.';
|
|
86
15
|
version = '1.0.0';
|
|
87
|
-
author = '
|
|
16
|
+
author = 'Hashgraph Online';
|
|
88
17
|
|
|
89
|
-
private tools:
|
|
18
|
+
private tools: HederaTool[] = [];
|
|
90
19
|
|
|
91
|
-
|
|
92
|
-
|
|
20
|
+
override async initialize(context: GenericPluginContext): Promise<void> {
|
|
21
|
+
await super.initialize(context);
|
|
22
|
+
this.initializeTools();
|
|
93
23
|
}
|
|
94
24
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
25
|
+
private initializeTools(): void {
|
|
26
|
+
this.tools = [
|
|
27
|
+
new HederaGetHbarPriceTool({
|
|
28
|
+
hederaKit: this.context.config.hederaKit as HederaAgentKit,
|
|
29
|
+
logger: this.context.logger
|
|
30
|
+
})
|
|
31
|
+
];
|
|
101
32
|
}
|
|
102
33
|
|
|
103
|
-
|
|
104
|
-
* Returns the tools provided by this plugin.
|
|
105
|
-
* @returns An array containing the GetHbarPriceTool.
|
|
106
|
-
*/
|
|
107
|
-
getTools(): StructuredTool[] {
|
|
34
|
+
getTools(): HederaTool[] {
|
|
108
35
|
return this.tools;
|
|
109
36
|
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Cleans up resources. Currently no cleanup needed.
|
|
113
|
-
*/
|
|
114
|
-
async cleanup(): Promise<void> {
|
|
115
|
-
// No cleanup necessary
|
|
116
|
-
return Promise.resolve();
|
|
117
|
-
}
|
|
118
37
|
}
|
package/src/plugins/index.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
export * from './PluginInterface';
|
|
2
2
|
export * from './PluginRegistry';
|
|
3
|
-
export * from './BasePlugin';
|
|
4
|
-
export * from './PluginLoader';
|
|
5
3
|
export * from './hedera/HbarPricePlugin';
|
|
6
|
-
export * from './GenericPlugin';
|
|
7
|
-
export * from './openconvai';
|
|
8
|
-
export * from './HCS10Plugin';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { StructuredTool } from '@langchain/core/tools';
|
|
1
|
+
import { BasePlugin, GenericPluginContext, BaseHederaQueryTool, HederaTool, HederaAgentKit } from 'hedera-agent-kit';
|
|
3
2
|
import { z } from 'zod';
|
|
4
3
|
import axios from 'axios';
|
|
5
4
|
|
|
@@ -22,26 +21,31 @@ interface ForecastDayData {
|
|
|
22
21
|
* an external web service (Weather API in this case).
|
|
23
22
|
*/
|
|
24
23
|
|
|
24
|
+
const GetCurrentWeatherSchema = z.object({
|
|
25
|
+
location: z.string().describe('The city and state, e.g. San Francisco, CA'),
|
|
26
|
+
unit: z
|
|
27
|
+
.enum(['celsius', 'fahrenheit'])
|
|
28
|
+
.optional()
|
|
29
|
+
.describe('The unit of temperature'),
|
|
30
|
+
});
|
|
31
|
+
|
|
25
32
|
/**
|
|
26
33
|
* Tool for getting current weather information
|
|
27
34
|
*/
|
|
28
|
-
class GetCurrentWeatherTool extends
|
|
35
|
+
class GetCurrentWeatherTool extends BaseHederaQueryTool<typeof GetCurrentWeatherSchema> {
|
|
29
36
|
name = 'get_current_weather';
|
|
30
37
|
description = 'Get the current weather for a location';
|
|
38
|
+
specificInputSchema = GetCurrentWeatherSchema;
|
|
39
|
+
namespace = 'weather';
|
|
31
40
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.enum(['celsius', 'fahrenheit'])
|
|
36
|
-
.optional()
|
|
37
|
-
.describe('The unit of temperature'),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
constructor(private apiKey?: string) {
|
|
41
|
-
super();
|
|
41
|
+
constructor(params: { hederaKit: HederaAgentKit; logger?: any; apiKey?: string }) {
|
|
42
|
+
super(params);
|
|
43
|
+
this.apiKey = params.apiKey;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
private apiKey?: string;
|
|
47
|
+
|
|
48
|
+
protected async executeQuery(input: z.infer<typeof GetCurrentWeatherSchema>): Promise<string> {
|
|
45
49
|
if (!this.apiKey) {
|
|
46
50
|
return 'Error: Weather API key not configured. Please set weatherApiKey in the plugin configuration.';
|
|
47
51
|
}
|
|
@@ -72,35 +76,37 @@ class GetCurrentWeatherTool extends StructuredTool {
|
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
78
|
|
|
79
|
+
const GetWeatherForecastSchema = z.object({
|
|
80
|
+
location: z.string().describe('The city and state, e.g. San Francisco, CA'),
|
|
81
|
+
days: z
|
|
82
|
+
.number()
|
|
83
|
+
.min(1)
|
|
84
|
+
.max(7)
|
|
85
|
+
.optional()
|
|
86
|
+
.describe('Number of days for the forecast (1-7, default: 3)'),
|
|
87
|
+
unit: z
|
|
88
|
+
.enum(['celsius', 'fahrenheit'])
|
|
89
|
+
.optional()
|
|
90
|
+
.describe('The unit of temperature'),
|
|
91
|
+
});
|
|
92
|
+
|
|
75
93
|
/**
|
|
76
94
|
* Tool for getting weather forecast
|
|
77
95
|
*/
|
|
78
|
-
class GetWeatherForecastTool extends
|
|
96
|
+
class GetWeatherForecastTool extends BaseHederaQueryTool<typeof GetWeatherForecastSchema> {
|
|
79
97
|
name = 'get_weather_forecast';
|
|
80
98
|
description = 'Get the weather forecast for a location';
|
|
99
|
+
specificInputSchema = GetWeatherForecastSchema;
|
|
100
|
+
namespace = 'weather';
|
|
81
101
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
.min(1)
|
|
87
|
-
.max(7)
|
|
88
|
-
.optional()
|
|
89
|
-
.describe('Number of days for the forecast (1-7, default: 3)'),
|
|
90
|
-
unit: z
|
|
91
|
-
.enum(['celsius', 'fahrenheit'])
|
|
92
|
-
.optional()
|
|
93
|
-
.describe('The unit of temperature'),
|
|
94
|
-
});
|
|
102
|
+
constructor(params: { hederaKit: HederaAgentKit; logger?: any; apiKey?: string }) {
|
|
103
|
+
super(params);
|
|
104
|
+
this.apiKey = params.apiKey;
|
|
105
|
+
}
|
|
95
106
|
|
|
96
107
|
private apiKey?: string;
|
|
97
108
|
|
|
98
|
-
|
|
99
|
-
super();
|
|
100
|
-
this.apiKey = apiKey;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async _call(input: z.infer<typeof this.schema>): Promise<string> {
|
|
109
|
+
protected async executeQuery(input: z.infer<typeof GetWeatherForecastSchema>): Promise<string> {
|
|
104
110
|
if (!this.apiKey) {
|
|
105
111
|
return 'Error: Weather API key not configured. Please set weatherApiKey in the plugin configuration.';
|
|
106
112
|
}
|
|
@@ -148,16 +154,17 @@ class GetWeatherForecastTool extends StructuredTool {
|
|
|
148
154
|
|
|
149
155
|
/**
|
|
150
156
|
* Weather API Plugin for the Standards Agent Kit
|
|
157
|
+
* Uses BaseHederaQueryTool for consistent tool architecture
|
|
151
158
|
*/
|
|
152
|
-
export default class WeatherPlugin extends
|
|
159
|
+
export default class WeatherPlugin extends BasePlugin<GenericPluginContext> {
|
|
153
160
|
id = 'weather-api';
|
|
154
161
|
name = 'Weather API Plugin';
|
|
155
162
|
description = 'Provides tools to access weather data';
|
|
156
163
|
version = '1.0.0';
|
|
157
164
|
author = 'Hashgraph Online';
|
|
158
|
-
namespace = 'weather';
|
|
159
165
|
|
|
160
166
|
private apiKey?: string;
|
|
167
|
+
private tools: HederaTool[] = [];
|
|
161
168
|
|
|
162
169
|
override async initialize(context: GenericPluginContext): Promise<void> {
|
|
163
170
|
await super.initialize(context);
|
|
@@ -168,12 +175,21 @@ export default class WeatherPlugin extends GenericPlugin {
|
|
|
168
175
|
'Weather API key not provided. Weather tools will not function correctly.'
|
|
169
176
|
);
|
|
170
177
|
}
|
|
178
|
+
|
|
179
|
+
this.initializeTools();
|
|
171
180
|
}
|
|
172
181
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
182
|
+
private initializeTools(): void {
|
|
183
|
+
const hederaKit = this.context.config.hederaKit as HederaAgentKit;
|
|
184
|
+
const logger = this.context.logger;
|
|
185
|
+
|
|
186
|
+
this.tools = [
|
|
187
|
+
new GetCurrentWeatherTool({ hederaKit, logger, apiKey: this.apiKey }),
|
|
188
|
+
new GetWeatherForecastTool({ hederaKit, logger, apiKey: this.apiKey }),
|
|
177
189
|
];
|
|
178
190
|
}
|
|
191
|
+
|
|
192
|
+
override getTools(): HederaTool[] {
|
|
193
|
+
return this.tools;
|
|
194
|
+
}
|
|
179
195
|
}
|
package/src/state/state-types.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HCS10BaseClient,
|
|
3
|
-
ConnectionsManager,
|
|
4
3
|
AIAgentProfile,
|
|
5
|
-
Connection,
|
|
6
4
|
IConnectionsManager,
|
|
7
5
|
} from '@hashgraphonline/standards-sdk';
|
|
8
6
|
|
|
@@ -106,7 +104,7 @@ export interface IStateManager {
|
|
|
106
104
|
/**
|
|
107
105
|
* Sets the current active agent, clearing any previous connections.
|
|
108
106
|
*/
|
|
109
|
-
setCurrentAgent(
|
|
107
|
+
setCurrentAgent(_agent: RegisteredAgent | null): void;
|
|
110
108
|
|
|
111
109
|
/**
|
|
112
110
|
* Gets the current active agent.
|
|
@@ -117,13 +115,13 @@ export interface IStateManager {
|
|
|
117
115
|
* Adds a new active connection to the state.
|
|
118
116
|
* Will not add duplicates based on connectionTopicId.
|
|
119
117
|
*/
|
|
120
|
-
addActiveConnection(
|
|
118
|
+
addActiveConnection(_connection: ActiveConnection): void;
|
|
121
119
|
|
|
122
120
|
/**
|
|
123
121
|
* Updates an existing connection or adds it if not found.
|
|
124
122
|
* Preserves existing properties when updating.
|
|
125
123
|
*/
|
|
126
|
-
updateOrAddConnection(
|
|
124
|
+
updateOrAddConnection(_connection: ActiveConnection): void;
|
|
127
125
|
|
|
128
126
|
/**
|
|
129
127
|
* Lists all active connections for the current agent.
|
|
@@ -136,25 +134,25 @@ export interface IStateManager {
|
|
|
136
134
|
* - A target account ID
|
|
137
135
|
* - A connection topic ID
|
|
138
136
|
*/
|
|
139
|
-
getConnectionByIdentifier(
|
|
137
|
+
getConnectionByIdentifier(_identifier: string): ActiveConnection | undefined;
|
|
140
138
|
|
|
141
139
|
/**
|
|
142
140
|
* Gets the last processed message timestamp for a connection.
|
|
143
141
|
*/
|
|
144
|
-
getLastTimestamp(
|
|
142
|
+
getLastTimestamp(_connectionTopicId: string): number;
|
|
145
143
|
|
|
146
144
|
/**
|
|
147
145
|
* Updates the last processed message timestamp for a connection.
|
|
148
146
|
*/
|
|
149
|
-
updateTimestamp(
|
|
147
|
+
updateTimestamp(_connectionTopicId: string, _timestampNanos: number): void;
|
|
150
148
|
|
|
151
149
|
/**
|
|
152
150
|
* Persists agent data to storage
|
|
153
151
|
* Implementation may vary depending on the state manager
|
|
154
152
|
*/
|
|
155
153
|
persistAgentData?(
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
_agent: RegisteredAgent,
|
|
155
|
+
_options?: AgentPersistenceOptions
|
|
158
156
|
): Promise<void>;
|
|
159
157
|
|
|
160
158
|
/**
|
|
@@ -162,7 +160,7 @@ export interface IStateManager {
|
|
|
162
160
|
* @param baseClient - The HCS10BaseClient instance to use
|
|
163
161
|
* @returns The initialized ConnectionsManager
|
|
164
162
|
*/
|
|
165
|
-
initializeConnectionsManager(
|
|
163
|
+
initializeConnectionsManager(_baseClient: HCS10BaseClient): IConnectionsManager;
|
|
166
164
|
|
|
167
165
|
/**
|
|
168
166
|
* Gets the ConnectionsManager instance
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseHCS10TransactionTool } from './base-hcs10-tools';
|
|
3
|
+
import { HCS10Builder } from '../../builders/hcs10/hcs10-builder';
|
|
4
|
+
import { HCS10TransactionToolParams } from './hcs10-tool-params';
|
|
5
|
+
import { BaseServiceBuilder } from 'hedera-agent-kit';
|
|
6
|
+
|
|
7
|
+
const AcceptConnectionRequestZodSchema = z.object({
|
|
8
|
+
requestKey: z
|
|
9
|
+
.string()
|
|
10
|
+
.describe(
|
|
11
|
+
'The unique request key of the specific request to accept. Use the "manage_connection_requests" tool with action="list" first to get valid keys.'
|
|
12
|
+
),
|
|
13
|
+
hbarFee: z
|
|
14
|
+
.number()
|
|
15
|
+
.optional()
|
|
16
|
+
.describe(
|
|
17
|
+
'Optional HBAR fee amount to charge the connecting agent per message on the new connection topic.'
|
|
18
|
+
),
|
|
19
|
+
exemptAccountIds: z
|
|
20
|
+
.array(z.string())
|
|
21
|
+
.optional()
|
|
22
|
+
.describe(
|
|
23
|
+
'Optional list of account IDs to exempt from any configured fees on the new connection topic.'
|
|
24
|
+
),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Tool for accepting incoming HCS-10 connection requests
|
|
29
|
+
*/
|
|
30
|
+
export class AcceptConnectionRequestTool extends BaseHCS10TransactionTool<
|
|
31
|
+
typeof AcceptConnectionRequestZodSchema
|
|
32
|
+
> {
|
|
33
|
+
name = 'accept_connection_request';
|
|
34
|
+
description =
|
|
35
|
+
'Accepts a pending HCS-10 connection request from another agent. Use list_unapproved_connection_requests to see pending requests.';
|
|
36
|
+
specificInputSchema = AcceptConnectionRequestZodSchema;
|
|
37
|
+
|
|
38
|
+
constructor(params: HCS10TransactionToolParams) {
|
|
39
|
+
super(params);
|
|
40
|
+
this.neverScheduleThisTool = true;
|
|
41
|
+
this.requiresMultipleTransactions = true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
protected async callBuilderMethod(
|
|
45
|
+
builder: BaseServiceBuilder,
|
|
46
|
+
specificArgs: z.infer<typeof AcceptConnectionRequestZodSchema>
|
|
47
|
+
): Promise<void> {
|
|
48
|
+
const hcs10Builder = builder as HCS10Builder;
|
|
49
|
+
|
|
50
|
+
await hcs10Builder.acceptConnection({
|
|
51
|
+
requestKey: specificArgs.requestKey,
|
|
52
|
+
hbarFee: specificArgs.hbarFee,
|
|
53
|
+
exemptAccountIds: specificArgs.exemptAccountIds,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseHCS10QueryTool } from './base-hcs10-tools';
|
|
3
|
+
import { HCS10QueryToolParams } from './hcs10-tool-params';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A tool to check for new messages on an active HCS-10 connection topic,
|
|
7
|
+
* or optionally fetch the latest messages regardless of timestamp.
|
|
8
|
+
*/
|
|
9
|
+
const CheckMessagesZodSchema = z.object({
|
|
10
|
+
targetIdentifier: z
|
|
11
|
+
.string()
|
|
12
|
+
.describe(
|
|
13
|
+
"The account ID (e.g., 0.0.12345) of the target agent OR the connection number (e.g., '1', '2') from the 'list_connections' tool to check messages for."
|
|
14
|
+
),
|
|
15
|
+
fetchLatest: z
|
|
16
|
+
.boolean()
|
|
17
|
+
.optional()
|
|
18
|
+
.default(false)
|
|
19
|
+
.describe(
|
|
20
|
+
'Set to true to fetch the latest messages even if they have been seen before, ignoring the last checked timestamp. Defaults to false (fetching only new messages).'
|
|
21
|
+
),
|
|
22
|
+
lastMessagesCount: z
|
|
23
|
+
.number()
|
|
24
|
+
.int()
|
|
25
|
+
.positive()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe(
|
|
28
|
+
'When fetchLatest is true, specifies how many of the most recent messages to retrieve. Defaults to 1.'
|
|
29
|
+
),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export class CheckMessagesTool extends BaseHCS10QueryTool<
|
|
33
|
+
typeof CheckMessagesZodSchema
|
|
34
|
+
> {
|
|
35
|
+
name = 'check_messages';
|
|
36
|
+
description = `Checks for and retrieves messages from an active connection.
|
|
37
|
+
Identify the target agent using their account ID (e.g., 0.0.12345) or the connection number shown in 'list_connections'.
|
|
38
|
+
By default, it only retrieves messages newer than the last check.
|
|
39
|
+
Use 'fetchLatest: true' to get the most recent messages regardless of when they arrived.
|
|
40
|
+
Use 'lastMessagesCount' to specify how many latest messages to retrieve (default 1 when fetchLatest is true).`;
|
|
41
|
+
specificInputSchema = CheckMessagesZodSchema;
|
|
42
|
+
constructor(params: HCS10QueryToolParams) {
|
|
43
|
+
super(params);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
protected async executeQuery({
|
|
47
|
+
targetIdentifier,
|
|
48
|
+
fetchLatest,
|
|
49
|
+
lastMessagesCount,
|
|
50
|
+
}: z.infer<typeof CheckMessagesZodSchema>): Promise<unknown> {
|
|
51
|
+
const hcs10Builder = this.hcs10Builder;
|
|
52
|
+
await hcs10Builder.checkMessages({
|
|
53
|
+
targetIdentifier,
|
|
54
|
+
fetchLatest,
|
|
55
|
+
lastMessagesCount: lastMessagesCount || 1,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const result = await hcs10Builder.execute();
|
|
59
|
+
|
|
60
|
+
if (result.success && 'rawResult' in result && result.rawResult) {
|
|
61
|
+
const raw = result.rawResult as {
|
|
62
|
+
formattedOutput?: string;
|
|
63
|
+
message?: string;
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
success: true,
|
|
67
|
+
data: raw.formattedOutput || raw.message || 'Messages checked',
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseHCS10TransactionTool } from './base-hcs10-tools';
|
|
3
|
+
import { HCS10Builder } from '../../builders/hcs10/hcs10-builder';
|
|
4
|
+
import { HCS10TransactionToolParams } from './hcs10-tool-params';
|
|
5
|
+
import { BaseServiceBuilder } from 'hedera-agent-kit';
|
|
6
|
+
|
|
7
|
+
const ConnectionMonitorZodSchema = z.object({
|
|
8
|
+
acceptAll: z
|
|
9
|
+
.boolean()
|
|
10
|
+
.optional()
|
|
11
|
+
.describe(
|
|
12
|
+
'Whether to automatically accept all incoming connection requests. Default is false.'
|
|
13
|
+
),
|
|
14
|
+
targetAccountId: z
|
|
15
|
+
.string()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe(
|
|
18
|
+
'If provided, only accept connection requests from this specific account ID.'
|
|
19
|
+
),
|
|
20
|
+
hbarFees: z
|
|
21
|
+
.array(
|
|
22
|
+
z.object({
|
|
23
|
+
amount: z.number(),
|
|
24
|
+
collectorAccount: z.string().optional(),
|
|
25
|
+
})
|
|
26
|
+
)
|
|
27
|
+
.optional()
|
|
28
|
+
.describe(
|
|
29
|
+
'Array of HBAR fee amounts to charge per message (with optional collector accounts).'
|
|
30
|
+
),
|
|
31
|
+
tokenFees: z
|
|
32
|
+
.array(
|
|
33
|
+
z.object({
|
|
34
|
+
amount: z.number(),
|
|
35
|
+
tokenId: z.string(),
|
|
36
|
+
collectorAccount: z.string().optional(),
|
|
37
|
+
})
|
|
38
|
+
)
|
|
39
|
+
.optional()
|
|
40
|
+
.describe(
|
|
41
|
+
'Array of token fee amounts and IDs to charge per message (with optional collector accounts).'
|
|
42
|
+
),
|
|
43
|
+
exemptAccountIds: z
|
|
44
|
+
.array(z.string())
|
|
45
|
+
.optional()
|
|
46
|
+
.describe(
|
|
47
|
+
'Array of account IDs to exempt from ALL fees set in this request.'
|
|
48
|
+
),
|
|
49
|
+
monitorDurationSeconds: z
|
|
50
|
+
.number()
|
|
51
|
+
.optional()
|
|
52
|
+
.describe(
|
|
53
|
+
'How long to monitor for incoming requests in seconds. Default is 120.'
|
|
54
|
+
),
|
|
55
|
+
defaultCollectorAccount: z
|
|
56
|
+
.string()
|
|
57
|
+
.optional()
|
|
58
|
+
.describe(
|
|
59
|
+
'Default account to collect fees if not specified at the fee level. Defaults to the agent account.'
|
|
60
|
+
),
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A tool for monitoring incoming connection requests and accepting them with optional fee settings.
|
|
65
|
+
*/
|
|
66
|
+
export class ConnectionMonitorTool extends BaseHCS10TransactionTool<
|
|
67
|
+
typeof ConnectionMonitorZodSchema
|
|
68
|
+
> {
|
|
69
|
+
name = 'monitor_connections';
|
|
70
|
+
description =
|
|
71
|
+
'Monitors for incoming connection requests and accepts them with optional fee settings. Use this to watch for connection requests and accept them, optionally setting HBAR or token fees on the connection. Note: When acceptAll=true, this tool requires multiple transactions and cannot be used in returnBytes mode.';
|
|
72
|
+
specificInputSchema = ConnectionMonitorZodSchema;
|
|
73
|
+
constructor(params: HCS10TransactionToolParams) {
|
|
74
|
+
super(params);
|
|
75
|
+
this.neverScheduleThisTool = true;
|
|
76
|
+
this.requiresMultipleTransactions = true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
protected async callBuilderMethod(
|
|
80
|
+
builder: BaseServiceBuilder,
|
|
81
|
+
specificArgs: z.infer<typeof ConnectionMonitorZodSchema>
|
|
82
|
+
): Promise<void> {
|
|
83
|
+
const hcs10Builder = builder as HCS10Builder;
|
|
84
|
+
await hcs10Builder.monitorConnections({
|
|
85
|
+
...(specificArgs.acceptAll !== undefined && {
|
|
86
|
+
acceptAll: specificArgs.acceptAll,
|
|
87
|
+
}),
|
|
88
|
+
...(specificArgs.targetAccountId !== undefined && {
|
|
89
|
+
targetAccountId: specificArgs.targetAccountId,
|
|
90
|
+
}),
|
|
91
|
+
...(specificArgs.monitorDurationSeconds !== undefined && {
|
|
92
|
+
monitorDurationSeconds: specificArgs.monitorDurationSeconds,
|
|
93
|
+
}),
|
|
94
|
+
hbarFees: (specificArgs.hbarFees || []) as Array<{
|
|
95
|
+
amount: number;
|
|
96
|
+
collectorAccount?: string;
|
|
97
|
+
}>,
|
|
98
|
+
tokenFees: (specificArgs.tokenFees || []) as Array<{
|
|
99
|
+
amount: number;
|
|
100
|
+
tokenId: string;
|
|
101
|
+
collectorAccount?: string;
|
|
102
|
+
}>,
|
|
103
|
+
...(specificArgs.exemptAccountIds !== undefined && {
|
|
104
|
+
exemptAccountIds: specificArgs.exemptAccountIds,
|
|
105
|
+
}),
|
|
106
|
+
...(specificArgs.defaultCollectorAccount !== undefined && {
|
|
107
|
+
defaultCollectorAccount: specificArgs.defaultCollectorAccount,
|
|
108
|
+
}),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AIAgentCapability } from '@hashgraphonline/standards-sdk';
|
|
3
|
+
import { BaseHCS10QueryTool } from './base-hcs10-tools';
|
|
4
|
+
import { HCS10QueryToolParams } from './hcs10-tool-params';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A tool to search for registered HCS-10 agents using the configured registry.
|
|
8
|
+
*/
|
|
9
|
+
const FindRegistrationsZodSchema = z.object({
|
|
10
|
+
accountId: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe(
|
|
14
|
+
'Optional: Filter registrations by a specific Hedera account ID (e.g., 0.0.12345).'
|
|
15
|
+
),
|
|
16
|
+
tags: z
|
|
17
|
+
.array(z.nativeEnum(AIAgentCapability))
|
|
18
|
+
.optional()
|
|
19
|
+
.describe(
|
|
20
|
+
'Optional: Filter registrations by a list of tags (API filter only).'
|
|
21
|
+
),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export class FindRegistrationsTool extends BaseHCS10QueryTool<
|
|
25
|
+
typeof FindRegistrationsZodSchema
|
|
26
|
+
> {
|
|
27
|
+
name = 'find_registrations';
|
|
28
|
+
description =
|
|
29
|
+
'Searches the configured agent registry for HCS-10 agents. You can filter by account ID or tags. Returns basic registration info.';
|
|
30
|
+
specificInputSchema = FindRegistrationsZodSchema;
|
|
31
|
+
constructor(params: HCS10QueryToolParams) {
|
|
32
|
+
super(params);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
protected async executeQuery({
|
|
36
|
+
accountId,
|
|
37
|
+
tags,
|
|
38
|
+
}: z.infer<typeof FindRegistrationsZodSchema>): Promise<unknown> {
|
|
39
|
+
const hcs10Builder = this.hcs10Builder;
|
|
40
|
+
const params: { accountId?: string; tags?: number[] } = {};
|
|
41
|
+
if (accountId) {
|
|
42
|
+
params.accountId = accountId;
|
|
43
|
+
}
|
|
44
|
+
if (tags) {
|
|
45
|
+
params.tags = tags;
|
|
46
|
+
}
|
|
47
|
+
await hcs10Builder.findRegistrations(params);
|
|
48
|
+
|
|
49
|
+
const result = await hcs10Builder.execute();
|
|
50
|
+
|
|
51
|
+
if (result.success && 'rawResult' in result && result.rawResult) {
|
|
52
|
+
const raw = result.rawResult as {
|
|
53
|
+
formattedOutput?: string;
|
|
54
|
+
message?: string;
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
success: true,
|
|
58
|
+
data: raw.formattedOutput || raw.message || 'Registrations searched',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
}
|