@hashgraphonline/standards-agent-kit 0.0.32 → 0.0.34
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/init/index.d.ts +1 -0
- package/dist/cjs/{src → init}/init.d.ts +16 -16
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/{umd/src → cjs}/tools/AcceptConnectionRequestTool.d.ts +6 -6
- package/dist/cjs/{src/tools → tools}/CheckMessagesTool.d.ts +6 -6
- package/dist/{umd/src → cjs}/tools/ConnectionMonitorTool.d.ts +34 -34
- package/dist/{umd/src → cjs}/tools/FindRegistrationsTool.d.ts +4 -4
- package/dist/cjs/{src/tools → tools}/InitiateConnectionTool.d.ts +2 -2
- package/dist/{umd/src → cjs}/tools/ListConnectionsTool.d.ts +4 -4
- package/dist/{es/src → cjs}/tools/ListUnapprovedConnectionRequestsTool.d.ts +4 -4
- package/dist/{es/src → cjs}/tools/ManageConnectionRequestsTool.d.ts +4 -4
- package/dist/cjs/{src/tools → tools}/RegisterAgentTool.d.ts +76 -76
- package/dist/{es/src → cjs}/tools/RetrieveProfileTool.d.ts +4 -4
- package/dist/{es/src → cjs}/tools/SendMessageToConnectionTool.d.ts +6 -6
- package/dist/cjs/{src/tools → tools}/SendMessageTool.d.ts +6 -6
- package/dist/es/index.d.ts +5 -2
- package/dist/es/init/index.d.ts +1 -0
- package/dist/{umd/src → es/init}/init.d.ts +16 -16
- package/dist/es/standards-agent-kit.es.js +17 -17
- package/dist/es/standards-agent-kit.es10.js +65 -104
- package/dist/es/standards-agent-kit.es10.js.map +1 -1
- package/dist/es/standards-agent-kit.es11.js +371 -66
- package/dist/es/standards-agent-kit.es11.js.map +1 -1
- package/dist/es/standards-agent-kit.es12.js +153 -348
- package/dist/es/standards-agent-kit.es12.js.map +1 -1
- package/dist/es/standards-agent-kit.es13.js +105 -161
- package/dist/es/standards-agent-kit.es13.js.map +1 -1
- package/dist/es/standards-agent-kit.es14.js +48 -126
- package/dist/es/standards-agent-kit.es14.js.map +1 -1
- package/dist/es/standards-agent-kit.es15.js +108 -50
- package/dist/es/standards-agent-kit.es15.js.map +1 -1
- package/dist/es/standards-agent-kit.es16.js +239 -117
- package/dist/es/standards-agent-kit.es16.js.map +1 -1
- package/dist/es/standards-agent-kit.es17.js +120 -245
- package/dist/es/standards-agent-kit.es17.js.map +1 -1
- package/dist/es/standards-agent-kit.es2.js +321 -114
- package/dist/es/standards-agent-kit.es2.js.map +1 -1
- package/dist/es/standards-agent-kit.es23.js +15 -15
- package/dist/es/standards-agent-kit.es24.js +79 -22
- package/dist/es/standards-agent-kit.es24.js.map +1 -1
- package/dist/es/standards-agent-kit.es25.js +24 -3
- package/dist/es/standards-agent-kit.es25.js.map +1 -1
- package/dist/es/standards-agent-kit.es26.js +3 -81
- package/dist/es/standards-agent-kit.es26.js.map +1 -1
- package/dist/es/standards-agent-kit.es3.js +347 -284
- package/dist/es/standards-agent-kit.es3.js.map +1 -1
- package/dist/es/standards-agent-kit.es4.js +56 -366
- package/dist/es/standards-agent-kit.es4.js.map +1 -1
- package/dist/es/standards-agent-kit.es5.js +142 -58
- package/dist/es/standards-agent-kit.es5.js.map +1 -1
- package/dist/es/standards-agent-kit.es6.js +73 -143
- package/dist/es/standards-agent-kit.es6.js.map +1 -1
- package/dist/es/standards-agent-kit.es7.js +63 -63
- package/dist/es/standards-agent-kit.es7.js.map +1 -1
- package/dist/es/standards-agent-kit.es8.js +91 -77
- package/dist/es/standards-agent-kit.es8.js.map +1 -1
- package/dist/es/standards-agent-kit.es9.js +109 -90
- package/dist/es/standards-agent-kit.es9.js.map +1 -1
- package/dist/es/{src/tools → tools}/AcceptConnectionRequestTool.d.ts +6 -6
- package/dist/{umd/src → es}/tools/CheckMessagesTool.d.ts +6 -6
- package/dist/es/{src/tools → tools}/ConnectionMonitorTool.d.ts +34 -34
- package/dist/{cjs/src → es}/tools/FindRegistrationsTool.d.ts +4 -4
- package/dist/{umd/src → es}/tools/InitiateConnectionTool.d.ts +2 -2
- package/dist/{cjs/src → es}/tools/ListConnectionsTool.d.ts +4 -4
- package/dist/{cjs/src → es}/tools/ListUnapprovedConnectionRequestsTool.d.ts +4 -4
- package/dist/{umd/src → es}/tools/ManageConnectionRequestsTool.d.ts +4 -4
- package/dist/{umd/src → es}/tools/RegisterAgentTool.d.ts +76 -76
- package/dist/{cjs/src → es}/tools/RetrieveProfileTool.d.ts +4 -4
- package/dist/{umd/src → es}/tools/SendMessageToConnectionTool.d.ts +6 -6
- package/dist/{umd/src → es}/tools/SendMessageTool.d.ts +6 -6
- package/dist/umd/init/index.d.ts +1 -0
- package/dist/{es/src → umd/init}/init.d.ts +16 -16
- package/dist/umd/standards-agent-kit.umd.js +15 -14
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/dist/{cjs/src → umd}/tools/AcceptConnectionRequestTool.d.ts +6 -6
- package/dist/{es/src → umd}/tools/CheckMessagesTool.d.ts +6 -6
- package/dist/{cjs/src → umd}/tools/ConnectionMonitorTool.d.ts +34 -34
- package/dist/{es/src → umd}/tools/FindRegistrationsTool.d.ts +4 -4
- package/dist/{es/src → umd}/tools/InitiateConnectionTool.d.ts +2 -2
- package/dist/{es/src → umd}/tools/ListConnectionsTool.d.ts +4 -4
- package/dist/umd/{src/tools → tools}/ListUnapprovedConnectionRequestsTool.d.ts +4 -4
- package/dist/{cjs/src → umd}/tools/ManageConnectionRequestsTool.d.ts +4 -4
- package/dist/{es/src → umd}/tools/RegisterAgentTool.d.ts +76 -76
- package/dist/umd/{src/tools → tools}/RetrieveProfileTool.d.ts +4 -4
- package/dist/{cjs/src → umd}/tools/SendMessageToConnectionTool.d.ts +6 -6
- package/dist/{es/src → umd}/tools/SendMessageTool.d.ts +6 -6
- package/package.json +2 -2
- package/src/hcs10/HCS10Client.ts +3 -7
- package/src/init/index.ts +1 -0
- package/src/{init.ts → init/init.ts} +22 -20
- package/src/tools/InitiateConnectionTool.ts +13 -13
- package/dist/umd/src/index.d.ts +0 -5
- /package/dist/cjs/{src/agents → agents}/index.d.ts +0 -0
- /package/dist/cjs/{src/hcs10 → hcs10}/HCS10Client.d.ts +0 -0
- /package/dist/cjs/{src/hcs10 → hcs10}/index.d.ts +0 -0
- /package/dist/cjs/{src/hcs10 → hcs10}/types.d.ts +0 -0
- /package/dist/cjs/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/cjs/{src/plugins → plugins}/BasePlugin.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/GenericPlugin.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/HCS10Plugin.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/PluginInterface.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/PluginLoader.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/PluginRegistry.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/defi/index.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/hedera/HbarPricePlugin.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/hedera/index.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/index.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/openconvai/OpenConvAIPlugin.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/openconvai/index.d.ts +0 -0
- /package/dist/cjs/{src/plugins → plugins}/weather/index.d.ts +0 -0
- /package/dist/cjs/{src/state → state}/index.d.ts +0 -0
- /package/dist/cjs/{src/state → state}/open-convai-state.d.ts +0 -0
- /package/dist/cjs/{src/state → state}/state-types.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/ConnectionTool.d.ts +0 -0
- /package/dist/cjs/{src/tools → tools}/index.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/Encryption.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/HederaClient.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/connectionUtils.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/ensure-agent-has-hbar.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/state-tools.d.ts +0 -0
- /package/dist/es/{src/agents → agents}/index.d.ts +0 -0
- /package/dist/es/{src/hcs10 → hcs10}/HCS10Client.d.ts +0 -0
- /package/dist/es/{src/hcs10 → hcs10}/index.d.ts +0 -0
- /package/dist/es/{src/hcs10 → hcs10}/types.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/BasePlugin.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/GenericPlugin.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/HCS10Plugin.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/PluginInterface.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/PluginLoader.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/PluginRegistry.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/defi/index.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/hedera/HbarPricePlugin.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/hedera/index.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/index.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/openconvai/OpenConvAIPlugin.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/openconvai/index.d.ts +0 -0
- /package/dist/es/{src/plugins → plugins}/weather/index.d.ts +0 -0
- /package/dist/es/{src/state → state}/index.d.ts +0 -0
- /package/dist/es/{src/state → state}/open-convai-state.d.ts +0 -0
- /package/dist/es/{src/state → state}/state-types.d.ts +0 -0
- /package/dist/es/{src/tools → tools}/ConnectionTool.d.ts +0 -0
- /package/dist/es/{src/tools → tools}/index.d.ts +0 -0
- /package/dist/es/{src/utils → utils}/Encryption.d.ts +0 -0
- /package/dist/es/{src/utils → utils}/HederaClient.d.ts +0 -0
- /package/dist/es/{src/utils → utils}/connectionUtils.d.ts +0 -0
- /package/dist/es/{src/utils → utils}/ensure-agent-has-hbar.d.ts +0 -0
- /package/dist/es/{src/utils → utils}/state-tools.d.ts +0 -0
- /package/dist/umd/{src/agents → agents}/index.d.ts +0 -0
- /package/dist/umd/{src/hcs10 → hcs10}/HCS10Client.d.ts +0 -0
- /package/dist/umd/{src/hcs10 → hcs10}/index.d.ts +0 -0
- /package/dist/umd/{src/hcs10 → hcs10}/types.d.ts +0 -0
- /package/dist/{es/src → umd}/index.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/BasePlugin.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/GenericPlugin.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/HCS10Plugin.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/PluginInterface.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/PluginLoader.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/PluginRegistry.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/defi/index.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/hedera/HbarPricePlugin.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/hedera/index.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/index.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/openconvai/OpenConvAIPlugin.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/openconvai/index.d.ts +0 -0
- /package/dist/umd/{src/plugins → plugins}/weather/index.d.ts +0 -0
- /package/dist/umd/{src/state → state}/index.d.ts +0 -0
- /package/dist/umd/{src/state → state}/open-convai-state.d.ts +0 -0
- /package/dist/umd/{src/state → state}/state-types.d.ts +0 -0
- /package/dist/umd/{src/tools → tools}/ConnectionTool.d.ts +0 -0
- /package/dist/umd/{src/tools → tools}/index.d.ts +0 -0
- /package/dist/umd/{src/utils → utils}/Encryption.d.ts +0 -0
- /package/dist/umd/{src/utils → utils}/HederaClient.d.ts +0 -0
- /package/dist/umd/{src/utils → utils}/connectionUtils.d.ts +0 -0
- /package/dist/umd/{src/utils → utils}/ensure-agent-has-hbar.d.ts +0 -0
- /package/dist/umd/{src/utils → utils}/state-tools.d.ts +0 -0
|
@@ -1,331 +1,394 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
guardedRegistryBaseUrl: options?.registryUrl,
|
|
10
|
-
logLevel: options?.logLevel
|
|
11
|
-
});
|
|
12
|
-
this.guardedRegistryBaseUrl = options?.registryUrl || "";
|
|
13
|
-
this.useEncryption = options?.useEncryption || false;
|
|
14
|
-
const shouldSilence = process.env.DISABLE_LOGGING === "true";
|
|
15
|
-
this.logger = new Logger({
|
|
16
|
-
level: options?.logLevel || "info",
|
|
17
|
-
silent: shouldSilence
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
getOperatorId() {
|
|
21
|
-
const operator = this.standardClient.getClient().operatorAccountId;
|
|
22
|
-
if (!operator) {
|
|
23
|
-
throw new Error("Operator Account ID not configured in standard client.");
|
|
24
|
-
}
|
|
25
|
-
return operator.toString();
|
|
26
|
-
}
|
|
27
|
-
getNetwork() {
|
|
28
|
-
return this.standardClient.getNetwork();
|
|
29
|
-
}
|
|
30
|
-
async handleConnectionRequest(inboundTopicId, requestingAccountId, connectionRequestId, feeConfig) {
|
|
31
|
-
try {
|
|
32
|
-
const result = await this.standardClient.handleConnectionRequest(
|
|
33
|
-
inboundTopicId,
|
|
34
|
-
requestingAccountId,
|
|
35
|
-
connectionRequestId,
|
|
36
|
-
feeConfig
|
|
37
|
-
);
|
|
38
|
-
return result;
|
|
39
|
-
} catch (error) {
|
|
40
|
-
this.logger.error(
|
|
41
|
-
`Error handling connection request #${connectionRequestId} for topic ${inboundTopicId}:`,
|
|
42
|
-
error
|
|
43
|
-
);
|
|
44
|
-
throw new Error(
|
|
45
|
-
`Failed to handle connection request: ${error instanceof Error ? error.message : String(error)}`
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Retrieves the profile for a given account ID using the standard SDK.
|
|
51
|
-
*/
|
|
52
|
-
async getAgentProfile(accountId) {
|
|
53
|
-
return this.standardClient.retrieveProfile(accountId);
|
|
54
|
-
}
|
|
1
|
+
import { Logger, AIAgentCapability, FeeConfigBuilder } from "@hashgraphonline/standards-sdk";
|
|
2
|
+
import { ensureAgentHasEnoughHbar } from "./standards-agent-kit.es24.js";
|
|
3
|
+
import { StructuredTool } from "@langchain/core/tools";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import fs__default from "fs";
|
|
6
|
+
import path__default from "path";
|
|
7
|
+
import axios from "axios";
|
|
8
|
+
class RegisterAgentTool extends StructuredTool {
|
|
55
9
|
/**
|
|
56
|
-
*
|
|
10
|
+
* Creates a new RegisterAgentTool instance
|
|
11
|
+
* @param client - Instance of HCS10Client (already configured with operator/network)
|
|
12
|
+
* @param stateManager - Optional state manager to store agent details
|
|
57
13
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
14
|
+
constructor(client, stateManager) {
|
|
15
|
+
super();
|
|
16
|
+
this.name = "register_agent";
|
|
17
|
+
this.description = "Creates and registers the AI agent on the Hedera network. Returns JSON string with agent details (accountId, privateKey, topics) on success. Optionally supports fee configuration for the agent's inbound topic using HBAR or specific tokens.";
|
|
18
|
+
this.schema = z.object({
|
|
19
|
+
name: z.string().describe("The name of the agent to register"),
|
|
20
|
+
description: z.string().optional().describe("Optional description of the agent"),
|
|
21
|
+
type: z.enum(["autonomous", "manual"]).optional().describe("Optional agent type (default: autonomous)"),
|
|
22
|
+
model: z.string().optional().describe("Optional model identifier for the agent"),
|
|
23
|
+
capabilities: z.array(z.number()).optional().describe(
|
|
24
|
+
"Optional array of AIAgentCapability enum values (0-18). If not provided, defaults to just TEXT_GENERATION (0)"
|
|
25
|
+
),
|
|
26
|
+
profilePicture: z.union([
|
|
27
|
+
z.string().describe("Path to a local image file or URL to an image"),
|
|
28
|
+
z.object({
|
|
29
|
+
url: z.string().describe("URL to an image file"),
|
|
30
|
+
filename: z.string().describe("Filename to use for the image")
|
|
31
|
+
}),
|
|
32
|
+
z.object({
|
|
33
|
+
path: z.string().describe("Path to a local image file"),
|
|
34
|
+
filename: z.string().optional().describe("Optional custom filename")
|
|
35
|
+
})
|
|
36
|
+
]).optional().describe(
|
|
37
|
+
"Optional profile picture for the agent (local file path or URL)"
|
|
38
|
+
),
|
|
39
|
+
feeCollectorAccountId: z.string().optional().describe(
|
|
40
|
+
"The account ID to collect fees. If not specified, the new agent's account ID will be used. Required if any fee is specified."
|
|
41
|
+
),
|
|
42
|
+
hbarFee: z.number().optional().describe(
|
|
43
|
+
"Optional: The fee amount in HBAR to charge per message on the inbound topic (e.g., 0.5). If specified, inboundTopicType will be set to FEE_BASED."
|
|
44
|
+
),
|
|
45
|
+
tokenFee: z.object({
|
|
46
|
+
amount: z.number(),
|
|
47
|
+
tokenId: z.string()
|
|
48
|
+
}).optional().describe(
|
|
49
|
+
'Optional: The fee amount and token ID to charge per message on the inbound topic (e.g., { amount: 10, tokenId: "0.0.12345" }). If specified, inboundTopicType will be set to FEE_BASED.'
|
|
50
|
+
),
|
|
51
|
+
hbarFees: z.array(
|
|
52
|
+
z.object({
|
|
53
|
+
amount: z.number(),
|
|
54
|
+
collectorAccount: z.string().optional()
|
|
55
|
+
})
|
|
56
|
+
).optional().describe(
|
|
57
|
+
"Optional: Array of HBAR fees with different collectors. If specified, inboundTopicType will be set to FEE_BASED."
|
|
58
|
+
),
|
|
59
|
+
tokenFees: z.array(
|
|
60
|
+
z.object({
|
|
61
|
+
amount: z.number(),
|
|
62
|
+
tokenId: z.string(),
|
|
63
|
+
collectorAccount: z.string().optional()
|
|
64
|
+
})
|
|
65
|
+
).optional().describe(
|
|
66
|
+
"Optional: Array of token fees with different collectors. If specified, inboundTopicType will be set to FEE_BASED."
|
|
67
|
+
),
|
|
68
|
+
exemptAccountIds: z.array(z.string()).optional().describe(
|
|
69
|
+
"Optional: Array of account IDs to exempt from ALL fees set for this agent."
|
|
70
|
+
),
|
|
71
|
+
setAsCurrent: z.boolean().optional().describe(
|
|
72
|
+
"Optional: Whether to set the newly registered agent as the current active agent in the state manager. Default: true"
|
|
73
|
+
),
|
|
74
|
+
persistence: z.object({
|
|
75
|
+
prefix: z.string().optional()
|
|
76
|
+
}).optional().describe(
|
|
77
|
+
"Optional: Configuration for persisting agent data to environment variables. The prefix will determine the environment variable names (e.g., PREFIX_ACCOUNT_ID). Defaults to TODD if not specified."
|
|
78
|
+
)
|
|
79
|
+
});
|
|
80
|
+
this.client = client;
|
|
81
|
+
this.stateManager = stateManager;
|
|
74
82
|
}
|
|
75
83
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* When metadata includes fee configuration:
|
|
80
|
-
* 1. The properties.feeConfig will be passed to the AgentBuilder
|
|
81
|
-
* 2. The properties.inboundTopicType will be set to FEE_BASED
|
|
82
|
-
* 3. The SDK's createAndRegisterAgent will apply the fees to the agent's inbound topic
|
|
83
|
-
*
|
|
84
|
-
* @param metadata - The agent's metadata, potentially including pfpBuffer, pfpFileName,
|
|
85
|
-
* and fee configuration in properties.feeConfig
|
|
86
|
-
* @returns The registration result from the standard SDK, containing accountId, keys, topics etc.
|
|
84
|
+
* Loads a profile picture from a local file or URL and returns a buffer
|
|
85
|
+
* @param profilePicture - Local file path or URL
|
|
86
|
+
* @returns Object containing buffer and filename
|
|
87
87
|
*/
|
|
88
|
-
async
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
)
|
|
92
|
-
if (metadata?.feeConfig) {
|
|
93
|
-
builder.setInboundTopicType(InboundTopicType.FEE_BASED);
|
|
94
|
-
builder.setFeeConfig(metadata.feeConfig);
|
|
95
|
-
}
|
|
96
|
-
if (metadata.pfpBuffer && metadata.pfpFileName) {
|
|
97
|
-
if (metadata.pfpBuffer.byteLength === 0) {
|
|
98
|
-
this.logger.warn(
|
|
99
|
-
"Provided PFP buffer is empty. Skipping profile picture."
|
|
100
|
-
);
|
|
101
|
-
} else {
|
|
102
|
-
this.logger.info(
|
|
103
|
-
`Setting profile picture: ${metadata.pfpFileName} (${metadata.pfpBuffer.byteLength} bytes)`
|
|
104
|
-
);
|
|
105
|
-
builder.setProfilePicture(metadata.pfpBuffer, metadata.pfpFileName);
|
|
106
|
-
}
|
|
107
|
-
} else {
|
|
108
|
-
this.logger.warn(
|
|
109
|
-
"Profile picture not provided in metadata. Agent creation might fail if required by the underlying SDK builder."
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
if (metadata.social) {
|
|
113
|
-
Object.entries(metadata.social).forEach(([platform, handle]) => {
|
|
114
|
-
builder.addSocial(platform, handle);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
if (metadata.properties) {
|
|
118
|
-
Object.entries(metadata.properties).forEach(([key, value]) => {
|
|
119
|
-
builder.addProperty(key, value);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
88
|
+
async loadProfilePicture(profilePicture) {
|
|
89
|
+
const logger = Logger.getInstance({
|
|
90
|
+
level: "debug"
|
|
91
|
+
});
|
|
122
92
|
try {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
93
|
+
if (!profilePicture) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
if (typeof profilePicture === "string") {
|
|
97
|
+
const isUrl = profilePicture.startsWith("http://") || profilePicture.startsWith("https://");
|
|
98
|
+
if (isUrl) {
|
|
99
|
+
logger.info(`Loading profile picture from URL: ${profilePicture}`);
|
|
100
|
+
const response = await axios.get(profilePicture, {
|
|
101
|
+
responseType: "arraybuffer"
|
|
102
|
+
});
|
|
103
|
+
const buffer = Buffer.from(response.data);
|
|
104
|
+
const urlPathname = new URL(profilePicture).pathname;
|
|
105
|
+
const filename = path__default.basename(urlPathname) || "profile.png";
|
|
106
|
+
return { buffer, filename };
|
|
107
|
+
} else {
|
|
108
|
+
if (!fs__default.existsSync(profilePicture)) {
|
|
109
|
+
logger.warn(`Profile picture file not found: ${profilePicture}`);
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
logger.info(`Loading profile picture from file: ${profilePicture}`);
|
|
113
|
+
const buffer = fs__default.readFileSync(profilePicture);
|
|
114
|
+
const filename = path__default.basename(profilePicture);
|
|
115
|
+
return { buffer, filename };
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if ("url" in profilePicture) {
|
|
119
|
+
logger.info(`Loading profile picture from URL: ${profilePicture.url}`);
|
|
120
|
+
const response = await axios.get(profilePicture.url, {
|
|
121
|
+
responseType: "arraybuffer"
|
|
122
|
+
});
|
|
123
|
+
const buffer = Buffer.from(response.data);
|
|
124
|
+
const filename = profilePicture.filename || "profile.png";
|
|
125
|
+
return { buffer, filename };
|
|
126
|
+
}
|
|
127
|
+
if ("path" in profilePicture) {
|
|
128
|
+
if (!fs__default.existsSync(profilePicture.path)) {
|
|
129
|
+
logger.warn(`Profile picture file not found: ${profilePicture.path}`);
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
logger.info(
|
|
133
|
+
`Loading profile picture from file: ${profilePicture.path}`
|
|
134
|
+
);
|
|
135
|
+
const buffer = fs__default.readFileSync(profilePicture.path);
|
|
136
|
+
const filename = profilePicture.filename || path__default.basename(profilePicture.path);
|
|
137
|
+
return { buffer, filename };
|
|
132
138
|
}
|
|
133
|
-
return
|
|
139
|
+
return null;
|
|
134
140
|
} catch (error) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
`Failed to create/register agent: ${error instanceof Error ? error.message : String(error)}`
|
|
138
|
-
);
|
|
141
|
+
logger.error("Failed to load profile picture:", error);
|
|
142
|
+
return null;
|
|
139
143
|
}
|
|
140
144
|
}
|
|
141
145
|
/**
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* @param topicId - The target topic ID (likely a connection topic).
|
|
146
|
-
* @param operatorId - The operator ID string (e.g., "inboundTopic@accountId").
|
|
147
|
-
* @param data - The actual message content/data.
|
|
148
|
-
* @param memo - Optional memo for the message.
|
|
149
|
-
* @param submitKey - Optional private key for topics requiring specific submit keys.
|
|
150
|
-
* @returns A confirmation status string from the transaction receipt.
|
|
146
|
+
* Calls createAndRegisterAgent() with the provided metadata.
|
|
147
|
+
* Returns a JSON string with agent details on success, or an error string.
|
|
151
148
|
*/
|
|
152
|
-
async
|
|
153
|
-
|
|
154
|
-
|
|
149
|
+
async _call(input) {
|
|
150
|
+
const logger = Logger.getInstance({
|
|
151
|
+
level: "debug"
|
|
152
|
+
});
|
|
153
|
+
const metadata = {
|
|
154
|
+
name: input.name,
|
|
155
|
+
description: input.description,
|
|
156
|
+
type: input.type,
|
|
157
|
+
model: input.model,
|
|
158
|
+
capabilities: input.capabilities || [AIAgentCapability.TEXT_GENERATION],
|
|
159
|
+
properties: {}
|
|
160
|
+
};
|
|
161
|
+
let profilePictureSource = "";
|
|
162
|
+
if (input.profilePicture) {
|
|
163
|
+
const profilePictureData = await this.loadProfilePicture(
|
|
164
|
+
input.profilePicture
|
|
165
|
+
);
|
|
166
|
+
if (profilePictureData) {
|
|
167
|
+
const { buffer, filename } = profilePictureData;
|
|
168
|
+
metadata.pfpBuffer = buffer;
|
|
169
|
+
metadata.pfpFileName = filename;
|
|
170
|
+
if (typeof input.profilePicture === "string") {
|
|
171
|
+
profilePictureSource = input.profilePicture;
|
|
172
|
+
} else if ("url" in input.profilePicture) {
|
|
173
|
+
profilePictureSource = input.profilePicture.url;
|
|
174
|
+
} else if ("path" in input.profilePicture) {
|
|
175
|
+
profilePictureSource = input.profilePicture.path;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const hasHbarFee = input.hbarFee !== void 0 && input.hbarFee > 0;
|
|
180
|
+
const hasTokenFee = this.hasValidTokenFee(input.tokenFee);
|
|
181
|
+
const hasHbarFees = input.hbarFees && input.hbarFees.length > 0;
|
|
182
|
+
const hasTokenFees = input.tokenFees && input.tokenFees.length > 0;
|
|
183
|
+
if (hasHbarFee || hasTokenFee || hasHbarFees || hasTokenFees) {
|
|
184
|
+
const { accountId: operatorAccountId } = this.client.getAccountAndSigner();
|
|
185
|
+
const collectorId = input.feeCollectorAccountId || operatorAccountId;
|
|
186
|
+
if (!collectorId) {
|
|
187
|
+
return "Error: Fee collector account ID is required when specifying fees and could not be determined.";
|
|
188
|
+
}
|
|
189
|
+
const feeConfigBuilder = new FeeConfigBuilder({
|
|
190
|
+
network: this.client.getNetwork(),
|
|
191
|
+
logger
|
|
192
|
+
});
|
|
193
|
+
try {
|
|
194
|
+
const exemptAccountIds = input.exemptAccountIds?.filter(
|
|
195
|
+
(id) => id !== collectorId && id.startsWith("0.0")
|
|
196
|
+
) || [];
|
|
197
|
+
let updatedFeeConfig = feeConfigBuilder;
|
|
198
|
+
if (hasHbarFee) {
|
|
199
|
+
logger.info(
|
|
200
|
+
`Adding HBAR fee: ${input.hbarFee} HBAR to be collected by ${collectorId}`
|
|
201
|
+
);
|
|
202
|
+
updatedFeeConfig = updatedFeeConfig.addHbarFee(
|
|
203
|
+
input.hbarFee,
|
|
204
|
+
collectorId,
|
|
205
|
+
exemptAccountIds
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
if (hasHbarFees) {
|
|
209
|
+
for (const fee of input.hbarFees) {
|
|
210
|
+
const feeCollector = fee.collectorAccount || collectorId;
|
|
211
|
+
logger.info(
|
|
212
|
+
`Adding HBAR fee: ${fee.amount} HBAR to be collected by ${feeCollector}`
|
|
213
|
+
);
|
|
214
|
+
updatedFeeConfig = updatedFeeConfig.addHbarFee(
|
|
215
|
+
fee.amount,
|
|
216
|
+
feeCollector,
|
|
217
|
+
exemptAccountIds
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (hasTokenFee) {
|
|
222
|
+
logger.info(
|
|
223
|
+
`Adding token fee: ${input.tokenFee.amount} of token ${input.tokenFee.tokenId} to be collected by ${collectorId}`
|
|
224
|
+
);
|
|
225
|
+
updatedFeeConfig = await updatedFeeConfig.addTokenFee(
|
|
226
|
+
input.tokenFee.amount,
|
|
227
|
+
input.tokenFee.tokenId,
|
|
228
|
+
collectorId,
|
|
229
|
+
void 0,
|
|
230
|
+
exemptAccountIds
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
if (hasTokenFees) {
|
|
234
|
+
for (const fee of input.tokenFees) {
|
|
235
|
+
const feeCollector = fee.collectorAccount || collectorId;
|
|
236
|
+
logger.info(
|
|
237
|
+
`Adding token fee: ${fee.amount} of token ${fee.tokenId} to be collected by ${feeCollector}`
|
|
238
|
+
);
|
|
239
|
+
updatedFeeConfig = await updatedFeeConfig.addTokenFee(
|
|
240
|
+
fee.amount,
|
|
241
|
+
fee.tokenId,
|
|
242
|
+
feeCollector,
|
|
243
|
+
void 0,
|
|
244
|
+
exemptAccountIds
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
metadata.feeConfig = updatedFeeConfig;
|
|
249
|
+
logger.info("FeeConfigBuilder created successfully");
|
|
250
|
+
} catch (error) {
|
|
251
|
+
return `Error: Failed to configure fees. Reason: ${error instanceof Error ? error.message : String(error)}`;
|
|
252
|
+
}
|
|
155
253
|
}
|
|
156
254
|
try {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
memo,
|
|
161
|
-
submitKey
|
|
255
|
+
logger.info("Registering agent with metadata");
|
|
256
|
+
const result = await this.client.createAndRegisterAgent(
|
|
257
|
+
metadata
|
|
162
258
|
);
|
|
163
|
-
return
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
`Failed to send message: ${error instanceof Error ? error.message : String(error)}`
|
|
259
|
+
return this.processRegistrationResult(
|
|
260
|
+
result,
|
|
261
|
+
input,
|
|
262
|
+
profilePictureSource
|
|
168
263
|
);
|
|
264
|
+
} catch (error) {
|
|
265
|
+
return `Error: Failed to create/register agent "${input.name}". Reason: ${error instanceof Error ? error.message : String(error)}`;
|
|
169
266
|
}
|
|
170
267
|
}
|
|
171
268
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
* @param topicId - The topic ID to get messages from.
|
|
175
|
-
* @returns Messages from the topic, mapped to the expected format.
|
|
269
|
+
* Checks if the token fee configuration is valid
|
|
176
270
|
*/
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const result = await this.standardClient.getMessages(topicId);
|
|
180
|
-
const mappedMessages = result.messages.map((sdkMessage) => {
|
|
181
|
-
const timestamp = sdkMessage?.created?.getTime() || 0;
|
|
182
|
-
return {
|
|
183
|
-
...sdkMessage,
|
|
184
|
-
timestamp,
|
|
185
|
-
data: sdkMessage.data,
|
|
186
|
-
sequence_number: sdkMessage.sequence_number
|
|
187
|
-
};
|
|
188
|
-
});
|
|
189
|
-
mappedMessages.sort(
|
|
190
|
-
(a, b) => a.timestamp - b.timestamp
|
|
191
|
-
);
|
|
192
|
-
return { messages: mappedMessages };
|
|
193
|
-
} catch (error) {
|
|
194
|
-
this.logger.error(`Error getting messages from topic ${topicId}:`, error);
|
|
195
|
-
return { messages: [] };
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
async getMessageStream(topicId) {
|
|
199
|
-
return this.standardClient.getMessageStream(topicId);
|
|
271
|
+
hasValidTokenFee(tokenFee) {
|
|
272
|
+
return !!(tokenFee && tokenFee.amount > 0 && tokenFee.tokenId && tokenFee.tokenId.trim() !== "");
|
|
200
273
|
}
|
|
201
274
|
/**
|
|
202
|
-
*
|
|
203
|
-
* @param inscriptionIdOrData - The inscription ID (hcs://...) or potentially raw data string.
|
|
204
|
-
* @returns The resolved message content.
|
|
275
|
+
* Processes the registration result and returns formatted output
|
|
205
276
|
*/
|
|
206
|
-
async
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
277
|
+
async processRegistrationResult(result, input, profilePictureSource = "") {
|
|
278
|
+
const newAgentAccountId = result?.metadata?.accountId || "";
|
|
279
|
+
const inboundTopicId = result?.metadata?.inboundTopicId || "";
|
|
280
|
+
const outboundTopicId = result?.metadata?.outboundTopicId || "";
|
|
281
|
+
const profileTopicId = result?.metadata?.profileTopicId || "";
|
|
282
|
+
const privateKey = result?.metadata?.privateKey || "";
|
|
283
|
+
const pfpTopicId = result?.metadata?.pfpTopicId;
|
|
284
|
+
this.validateRegistrationResult(
|
|
285
|
+
newAgentAccountId,
|
|
286
|
+
inboundTopicId,
|
|
287
|
+
outboundTopicId,
|
|
288
|
+
privateKey
|
|
289
|
+
);
|
|
290
|
+
if (this.stateManager && privateKey && newAgentAccountId && inboundTopicId && outboundTopicId && (input.setAsCurrent === void 0 || input.setAsCurrent)) {
|
|
291
|
+
const agent = {
|
|
292
|
+
name: input.name,
|
|
293
|
+
accountId: newAgentAccountId,
|
|
294
|
+
inboundTopicId,
|
|
295
|
+
outboundTopicId,
|
|
296
|
+
profileTopicId,
|
|
297
|
+
privateKey,
|
|
298
|
+
pfpTopicId
|
|
299
|
+
};
|
|
300
|
+
this.stateManager.setCurrentAgent(agent);
|
|
301
|
+
if (this.stateManager.persistAgentData && input.persistence) {
|
|
302
|
+
try {
|
|
303
|
+
const persistenceOptions = {
|
|
304
|
+
type: "env-file",
|
|
305
|
+
prefix: input.persistence.prefix
|
|
306
|
+
};
|
|
307
|
+
await this.stateManager.persistAgentData(agent, persistenceOptions);
|
|
308
|
+
} catch (error) {
|
|
309
|
+
Logger.getInstance().warn("Failed to persist agent data", error);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
await this.ensureAgentHasFunds(newAgentAccountId, input.name);
|
|
314
|
+
const feeDescription = this.createFeeDescription(input);
|
|
315
|
+
const feeMessage = feeDescription ? ` with ${feeDescription} fee on inbound topic` : "";
|
|
316
|
+
const registrationDetails = {
|
|
317
|
+
success: true,
|
|
318
|
+
message: `Successfully registered agent '${input.name}'${feeMessage}.`,
|
|
319
|
+
name: input.name,
|
|
320
|
+
accountId: newAgentAccountId,
|
|
321
|
+
privateKey,
|
|
322
|
+
inboundTopicId,
|
|
323
|
+
outboundTopicId,
|
|
324
|
+
profileTopicId: profileTopicId || "N/A",
|
|
325
|
+
capabilities: input.capabilities || [AIAgentCapability.TEXT_GENERATION],
|
|
326
|
+
hasFees: !!(input.hbarFee || this.hasValidTokenFee(input.tokenFee)),
|
|
327
|
+
hbarFee: input.hbarFee || 0,
|
|
328
|
+
tokenFee: input.tokenFee || null
|
|
329
|
+
};
|
|
330
|
+
if (pfpTopicId || profilePictureSource) {
|
|
331
|
+
registrationDetails.profilePicture = {
|
|
332
|
+
source: profilePictureSource,
|
|
333
|
+
topicId: pfpTopicId
|
|
334
|
+
};
|
|
220
335
|
}
|
|
336
|
+
return JSON.stringify(registrationDetails);
|
|
221
337
|
}
|
|
222
338
|
/**
|
|
223
|
-
*
|
|
224
|
-
* This typically involves fetching the operator's own HCS-10 profile.
|
|
225
|
-
* @returns A promise that resolves to the operator's inbound topic ID.
|
|
226
|
-
* @throws {Error} If the operator ID cannot be determined or the profile/topic cannot be retrieved.
|
|
339
|
+
* Ensures the agent has enough HBAR for operations
|
|
227
340
|
*/
|
|
228
|
-
async
|
|
341
|
+
async ensureAgentHasFunds(accountId, agentName) {
|
|
229
342
|
try {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
343
|
+
await ensureAgentHasEnoughHbar(
|
|
344
|
+
Logger.getInstance({
|
|
345
|
+
module: "RegisterAgentTool"
|
|
346
|
+
}),
|
|
347
|
+
this.client.standardClient,
|
|
348
|
+
accountId,
|
|
349
|
+
agentName
|
|
233
350
|
);
|
|
234
|
-
const profileResponse = await this.getAgentProfile(operatorId);
|
|
235
|
-
if (profileResponse.success && profileResponse.topicInfo?.inboundTopic) {
|
|
236
|
-
this.logger.info(
|
|
237
|
-
`[HCS10Client] Found inbound topic for operator ${operatorId}: ${profileResponse.topicInfo.inboundTopic}`
|
|
238
|
-
);
|
|
239
|
-
return profileResponse.topicInfo.inboundTopic;
|
|
240
|
-
} else {
|
|
241
|
-
throw new Error(
|
|
242
|
-
`Could not retrieve inbound topic from profile for ${operatorId}. Profile success: ${profileResponse.success}, Error: ${profileResponse.error}`
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
351
|
} catch (error) {
|
|
246
|
-
|
|
247
|
-
`[HCS10Client] Error fetching operator's inbound topic ID (${this.getOperatorId()}):`,
|
|
248
|
-
error
|
|
249
|
-
);
|
|
250
|
-
const operatorId = this.getOperatorId();
|
|
251
|
-
let detailedMessage = `Failed to get inbound topic ID for operator ${operatorId}.`;
|
|
252
|
-
if (error instanceof Error && error.message.includes("does not have a valid HCS-11 memo")) {
|
|
253
|
-
detailedMessage += ` The account profile may not exist or is invalid. Please ensure this operator account (${operatorId}) is registered as an HCS-10 agent. You might need to register it first (e.g., using the 'register_agent' tool or SDK function).`;
|
|
254
|
-
} else if (error instanceof Error) {
|
|
255
|
-
detailedMessage += ` Reason: ${error.message}`;
|
|
256
|
-
} else {
|
|
257
|
-
detailedMessage += ` Unexpected error: ${String(error)}`;
|
|
258
|
-
}
|
|
259
|
-
throw new Error(detailedMessage);
|
|
352
|
+
Logger.getInstance().error("Failed to auto fund agent", error);
|
|
260
353
|
}
|
|
261
354
|
}
|
|
262
355
|
/**
|
|
263
|
-
*
|
|
264
|
-
* Required by tools needing to identify the current agent instance.
|
|
265
|
-
*/
|
|
266
|
-
getAccountAndSigner() {
|
|
267
|
-
const result = this.standardClient.getAccountAndSigner();
|
|
268
|
-
return {
|
|
269
|
-
accountId: result.accountId,
|
|
270
|
-
signer: result.signer
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Retrieves the outbound topic ID for the current operator.
|
|
275
|
-
* Fetches the operator's profile if necessary.
|
|
276
|
-
* @returns The outbound topic ID string.
|
|
277
|
-
* @throws If the outbound topic cannot be determined.
|
|
356
|
+
* Validates that all required fields are present in the registration result
|
|
278
357
|
*/
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
358
|
+
validateRegistrationResult(accountId, inboundTopicId, outboundTopicId, privateKey) {
|
|
359
|
+
if (!accountId || !inboundTopicId || !outboundTopicId || !privateKey) {
|
|
360
|
+
const missingFields = [
|
|
361
|
+
!accountId && "accountId",
|
|
362
|
+
!inboundTopicId && "inboundTopicId",
|
|
363
|
+
!outboundTopicId && "outboundTopicId",
|
|
364
|
+
!privateKey && "privateKey"
|
|
365
|
+
].filter(Boolean).join(", ");
|
|
285
366
|
throw new Error(
|
|
286
|
-
`
|
|
367
|
+
`Registration failed. The HCS client returned incomplete details (Missing: ${missingFields}).`
|
|
287
368
|
);
|
|
288
369
|
}
|
|
289
370
|
}
|
|
290
|
-
setClient(accountId, privateKey) {
|
|
291
|
-
this.standardClient = new HCS10Client$1({
|
|
292
|
-
network: this.getNetwork(),
|
|
293
|
-
operatorId: accountId,
|
|
294
|
-
operatorPrivateKey: privateKey,
|
|
295
|
-
guardedRegistryBaseUrl: this.guardedRegistryBaseUrl
|
|
296
|
-
});
|
|
297
|
-
return this.standardClient;
|
|
298
|
-
}
|
|
299
371
|
/**
|
|
300
|
-
*
|
|
372
|
+
* Creates a description of the fees configured for the agent
|
|
301
373
|
*/
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
return
|
|
307
|
-
isValid: true,
|
|
308
|
-
operator: { accountId: operatorId }
|
|
309
|
-
};
|
|
310
|
-
} catch (error) {
|
|
311
|
-
this.logger.error(`Validation error: ${error}`);
|
|
312
|
-
return {
|
|
313
|
-
isValid: false,
|
|
314
|
-
error: error instanceof Error ? error.message : String(error)
|
|
315
|
-
};
|
|
374
|
+
createFeeDescription(input) {
|
|
375
|
+
const hasHbarFee = input.hbarFee && input.hbarFee > 0;
|
|
376
|
+
const hasTokenFee = this.hasValidTokenFee(input.tokenFee);
|
|
377
|
+
if (!hasHbarFee && !hasTokenFee) {
|
|
378
|
+
return "";
|
|
316
379
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
380
|
+
let description = "";
|
|
381
|
+
if (hasHbarFee) {
|
|
382
|
+
description += `${input.hbarFee} HBAR`;
|
|
383
|
+
}
|
|
384
|
+
if (hasTokenFee && input.tokenFee) {
|
|
385
|
+
const tokenFeeText = `${input.tokenFee.amount} of token ${input.tokenFee.tokenId}`;
|
|
386
|
+
description += description ? ` and ${tokenFeeText}` : tokenFeeText;
|
|
324
387
|
}
|
|
325
|
-
return
|
|
388
|
+
return description;
|
|
326
389
|
}
|
|
327
390
|
}
|
|
328
391
|
export {
|
|
329
|
-
|
|
392
|
+
RegisterAgentTool
|
|
330
393
|
};
|
|
331
394
|
//# sourceMappingURL=standards-agent-kit.es3.js.map
|