@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.
Files changed (176) hide show
  1. package/dist/cjs/init/index.d.ts +1 -0
  2. package/dist/cjs/{src → init}/init.d.ts +16 -16
  3. package/dist/cjs/standards-agent-kit.cjs +1 -1
  4. package/dist/cjs/standards-agent-kit.cjs.map +1 -1
  5. package/dist/{umd/src → cjs}/tools/AcceptConnectionRequestTool.d.ts +6 -6
  6. package/dist/cjs/{src/tools → tools}/CheckMessagesTool.d.ts +6 -6
  7. package/dist/{umd/src → cjs}/tools/ConnectionMonitorTool.d.ts +34 -34
  8. package/dist/{umd/src → cjs}/tools/FindRegistrationsTool.d.ts +4 -4
  9. package/dist/cjs/{src/tools → tools}/InitiateConnectionTool.d.ts +2 -2
  10. package/dist/{umd/src → cjs}/tools/ListConnectionsTool.d.ts +4 -4
  11. package/dist/{es/src → cjs}/tools/ListUnapprovedConnectionRequestsTool.d.ts +4 -4
  12. package/dist/{es/src → cjs}/tools/ManageConnectionRequestsTool.d.ts +4 -4
  13. package/dist/cjs/{src/tools → tools}/RegisterAgentTool.d.ts +76 -76
  14. package/dist/{es/src → cjs}/tools/RetrieveProfileTool.d.ts +4 -4
  15. package/dist/{es/src → cjs}/tools/SendMessageToConnectionTool.d.ts +6 -6
  16. package/dist/cjs/{src/tools → tools}/SendMessageTool.d.ts +6 -6
  17. package/dist/es/index.d.ts +5 -2
  18. package/dist/es/init/index.d.ts +1 -0
  19. package/dist/{umd/src → es/init}/init.d.ts +16 -16
  20. package/dist/es/standards-agent-kit.es.js +17 -17
  21. package/dist/es/standards-agent-kit.es10.js +65 -104
  22. package/dist/es/standards-agent-kit.es10.js.map +1 -1
  23. package/dist/es/standards-agent-kit.es11.js +371 -66
  24. package/dist/es/standards-agent-kit.es11.js.map +1 -1
  25. package/dist/es/standards-agent-kit.es12.js +153 -348
  26. package/dist/es/standards-agent-kit.es12.js.map +1 -1
  27. package/dist/es/standards-agent-kit.es13.js +105 -161
  28. package/dist/es/standards-agent-kit.es13.js.map +1 -1
  29. package/dist/es/standards-agent-kit.es14.js +48 -126
  30. package/dist/es/standards-agent-kit.es14.js.map +1 -1
  31. package/dist/es/standards-agent-kit.es15.js +108 -50
  32. package/dist/es/standards-agent-kit.es15.js.map +1 -1
  33. package/dist/es/standards-agent-kit.es16.js +239 -117
  34. package/dist/es/standards-agent-kit.es16.js.map +1 -1
  35. package/dist/es/standards-agent-kit.es17.js +120 -245
  36. package/dist/es/standards-agent-kit.es17.js.map +1 -1
  37. package/dist/es/standards-agent-kit.es2.js +321 -114
  38. package/dist/es/standards-agent-kit.es2.js.map +1 -1
  39. package/dist/es/standards-agent-kit.es23.js +15 -15
  40. package/dist/es/standards-agent-kit.es24.js +79 -22
  41. package/dist/es/standards-agent-kit.es24.js.map +1 -1
  42. package/dist/es/standards-agent-kit.es25.js +24 -3
  43. package/dist/es/standards-agent-kit.es25.js.map +1 -1
  44. package/dist/es/standards-agent-kit.es26.js +3 -81
  45. package/dist/es/standards-agent-kit.es26.js.map +1 -1
  46. package/dist/es/standards-agent-kit.es3.js +347 -284
  47. package/dist/es/standards-agent-kit.es3.js.map +1 -1
  48. package/dist/es/standards-agent-kit.es4.js +56 -366
  49. package/dist/es/standards-agent-kit.es4.js.map +1 -1
  50. package/dist/es/standards-agent-kit.es5.js +142 -58
  51. package/dist/es/standards-agent-kit.es5.js.map +1 -1
  52. package/dist/es/standards-agent-kit.es6.js +73 -143
  53. package/dist/es/standards-agent-kit.es6.js.map +1 -1
  54. package/dist/es/standards-agent-kit.es7.js +63 -63
  55. package/dist/es/standards-agent-kit.es7.js.map +1 -1
  56. package/dist/es/standards-agent-kit.es8.js +91 -77
  57. package/dist/es/standards-agent-kit.es8.js.map +1 -1
  58. package/dist/es/standards-agent-kit.es9.js +109 -90
  59. package/dist/es/standards-agent-kit.es9.js.map +1 -1
  60. package/dist/es/{src/tools → tools}/AcceptConnectionRequestTool.d.ts +6 -6
  61. package/dist/{umd/src → es}/tools/CheckMessagesTool.d.ts +6 -6
  62. package/dist/es/{src/tools → tools}/ConnectionMonitorTool.d.ts +34 -34
  63. package/dist/{cjs/src → es}/tools/FindRegistrationsTool.d.ts +4 -4
  64. package/dist/{umd/src → es}/tools/InitiateConnectionTool.d.ts +2 -2
  65. package/dist/{cjs/src → es}/tools/ListConnectionsTool.d.ts +4 -4
  66. package/dist/{cjs/src → es}/tools/ListUnapprovedConnectionRequestsTool.d.ts +4 -4
  67. package/dist/{umd/src → es}/tools/ManageConnectionRequestsTool.d.ts +4 -4
  68. package/dist/{umd/src → es}/tools/RegisterAgentTool.d.ts +76 -76
  69. package/dist/{cjs/src → es}/tools/RetrieveProfileTool.d.ts +4 -4
  70. package/dist/{umd/src → es}/tools/SendMessageToConnectionTool.d.ts +6 -6
  71. package/dist/{umd/src → es}/tools/SendMessageTool.d.ts +6 -6
  72. package/dist/umd/init/index.d.ts +1 -0
  73. package/dist/{es/src → umd/init}/init.d.ts +16 -16
  74. package/dist/umd/standards-agent-kit.umd.js +15 -14
  75. package/dist/umd/standards-agent-kit.umd.js.map +1 -1
  76. package/dist/{cjs/src → umd}/tools/AcceptConnectionRequestTool.d.ts +6 -6
  77. package/dist/{es/src → umd}/tools/CheckMessagesTool.d.ts +6 -6
  78. package/dist/{cjs/src → umd}/tools/ConnectionMonitorTool.d.ts +34 -34
  79. package/dist/{es/src → umd}/tools/FindRegistrationsTool.d.ts +4 -4
  80. package/dist/{es/src → umd}/tools/InitiateConnectionTool.d.ts +2 -2
  81. package/dist/{es/src → umd}/tools/ListConnectionsTool.d.ts +4 -4
  82. package/dist/umd/{src/tools → tools}/ListUnapprovedConnectionRequestsTool.d.ts +4 -4
  83. package/dist/{cjs/src → umd}/tools/ManageConnectionRequestsTool.d.ts +4 -4
  84. package/dist/{es/src → umd}/tools/RegisterAgentTool.d.ts +76 -76
  85. package/dist/umd/{src/tools → tools}/RetrieveProfileTool.d.ts +4 -4
  86. package/dist/{cjs/src → umd}/tools/SendMessageToConnectionTool.d.ts +6 -6
  87. package/dist/{es/src → umd}/tools/SendMessageTool.d.ts +6 -6
  88. package/package.json +2 -2
  89. package/src/hcs10/HCS10Client.ts +3 -7
  90. package/src/init/index.ts +1 -0
  91. package/src/{init.ts → init/init.ts} +22 -20
  92. package/src/tools/InitiateConnectionTool.ts +13 -13
  93. package/dist/umd/src/index.d.ts +0 -5
  94. /package/dist/cjs/{src/agents → agents}/index.d.ts +0 -0
  95. /package/dist/cjs/{src/hcs10 → hcs10}/HCS10Client.d.ts +0 -0
  96. /package/dist/cjs/{src/hcs10 → hcs10}/index.d.ts +0 -0
  97. /package/dist/cjs/{src/hcs10 → hcs10}/types.d.ts +0 -0
  98. /package/dist/cjs/{src/index.d.ts → index.d.ts} +0 -0
  99. /package/dist/cjs/{src/plugins → plugins}/BasePlugin.d.ts +0 -0
  100. /package/dist/cjs/{src/plugins → plugins}/GenericPlugin.d.ts +0 -0
  101. /package/dist/cjs/{src/plugins → plugins}/HCS10Plugin.d.ts +0 -0
  102. /package/dist/cjs/{src/plugins → plugins}/PluginInterface.d.ts +0 -0
  103. /package/dist/cjs/{src/plugins → plugins}/PluginLoader.d.ts +0 -0
  104. /package/dist/cjs/{src/plugins → plugins}/PluginRegistry.d.ts +0 -0
  105. /package/dist/cjs/{src/plugins → plugins}/defi/index.d.ts +0 -0
  106. /package/dist/cjs/{src/plugins → plugins}/hedera/HbarPricePlugin.d.ts +0 -0
  107. /package/dist/cjs/{src/plugins → plugins}/hedera/index.d.ts +0 -0
  108. /package/dist/cjs/{src/plugins → plugins}/index.d.ts +0 -0
  109. /package/dist/cjs/{src/plugins → plugins}/openconvai/OpenConvAIPlugin.d.ts +0 -0
  110. /package/dist/cjs/{src/plugins → plugins}/openconvai/index.d.ts +0 -0
  111. /package/dist/cjs/{src/plugins → plugins}/weather/index.d.ts +0 -0
  112. /package/dist/cjs/{src/state → state}/index.d.ts +0 -0
  113. /package/dist/cjs/{src/state → state}/open-convai-state.d.ts +0 -0
  114. /package/dist/cjs/{src/state → state}/state-types.d.ts +0 -0
  115. /package/dist/cjs/{src/tools → tools}/ConnectionTool.d.ts +0 -0
  116. /package/dist/cjs/{src/tools → tools}/index.d.ts +0 -0
  117. /package/dist/cjs/{src/utils → utils}/Encryption.d.ts +0 -0
  118. /package/dist/cjs/{src/utils → utils}/HederaClient.d.ts +0 -0
  119. /package/dist/cjs/{src/utils → utils}/connectionUtils.d.ts +0 -0
  120. /package/dist/cjs/{src/utils → utils}/ensure-agent-has-hbar.d.ts +0 -0
  121. /package/dist/cjs/{src/utils → utils}/state-tools.d.ts +0 -0
  122. /package/dist/es/{src/agents → agents}/index.d.ts +0 -0
  123. /package/dist/es/{src/hcs10 → hcs10}/HCS10Client.d.ts +0 -0
  124. /package/dist/es/{src/hcs10 → hcs10}/index.d.ts +0 -0
  125. /package/dist/es/{src/hcs10 → hcs10}/types.d.ts +0 -0
  126. /package/dist/es/{src/plugins → plugins}/BasePlugin.d.ts +0 -0
  127. /package/dist/es/{src/plugins → plugins}/GenericPlugin.d.ts +0 -0
  128. /package/dist/es/{src/plugins → plugins}/HCS10Plugin.d.ts +0 -0
  129. /package/dist/es/{src/plugins → plugins}/PluginInterface.d.ts +0 -0
  130. /package/dist/es/{src/plugins → plugins}/PluginLoader.d.ts +0 -0
  131. /package/dist/es/{src/plugins → plugins}/PluginRegistry.d.ts +0 -0
  132. /package/dist/es/{src/plugins → plugins}/defi/index.d.ts +0 -0
  133. /package/dist/es/{src/plugins → plugins}/hedera/HbarPricePlugin.d.ts +0 -0
  134. /package/dist/es/{src/plugins → plugins}/hedera/index.d.ts +0 -0
  135. /package/dist/es/{src/plugins → plugins}/index.d.ts +0 -0
  136. /package/dist/es/{src/plugins → plugins}/openconvai/OpenConvAIPlugin.d.ts +0 -0
  137. /package/dist/es/{src/plugins → plugins}/openconvai/index.d.ts +0 -0
  138. /package/dist/es/{src/plugins → plugins}/weather/index.d.ts +0 -0
  139. /package/dist/es/{src/state → state}/index.d.ts +0 -0
  140. /package/dist/es/{src/state → state}/open-convai-state.d.ts +0 -0
  141. /package/dist/es/{src/state → state}/state-types.d.ts +0 -0
  142. /package/dist/es/{src/tools → tools}/ConnectionTool.d.ts +0 -0
  143. /package/dist/es/{src/tools → tools}/index.d.ts +0 -0
  144. /package/dist/es/{src/utils → utils}/Encryption.d.ts +0 -0
  145. /package/dist/es/{src/utils → utils}/HederaClient.d.ts +0 -0
  146. /package/dist/es/{src/utils → utils}/connectionUtils.d.ts +0 -0
  147. /package/dist/es/{src/utils → utils}/ensure-agent-has-hbar.d.ts +0 -0
  148. /package/dist/es/{src/utils → utils}/state-tools.d.ts +0 -0
  149. /package/dist/umd/{src/agents → agents}/index.d.ts +0 -0
  150. /package/dist/umd/{src/hcs10 → hcs10}/HCS10Client.d.ts +0 -0
  151. /package/dist/umd/{src/hcs10 → hcs10}/index.d.ts +0 -0
  152. /package/dist/umd/{src/hcs10 → hcs10}/types.d.ts +0 -0
  153. /package/dist/{es/src → umd}/index.d.ts +0 -0
  154. /package/dist/umd/{src/plugins → plugins}/BasePlugin.d.ts +0 -0
  155. /package/dist/umd/{src/plugins → plugins}/GenericPlugin.d.ts +0 -0
  156. /package/dist/umd/{src/plugins → plugins}/HCS10Plugin.d.ts +0 -0
  157. /package/dist/umd/{src/plugins → plugins}/PluginInterface.d.ts +0 -0
  158. /package/dist/umd/{src/plugins → plugins}/PluginLoader.d.ts +0 -0
  159. /package/dist/umd/{src/plugins → plugins}/PluginRegistry.d.ts +0 -0
  160. /package/dist/umd/{src/plugins → plugins}/defi/index.d.ts +0 -0
  161. /package/dist/umd/{src/plugins → plugins}/hedera/HbarPricePlugin.d.ts +0 -0
  162. /package/dist/umd/{src/plugins → plugins}/hedera/index.d.ts +0 -0
  163. /package/dist/umd/{src/plugins → plugins}/index.d.ts +0 -0
  164. /package/dist/umd/{src/plugins → plugins}/openconvai/OpenConvAIPlugin.d.ts +0 -0
  165. /package/dist/umd/{src/plugins → plugins}/openconvai/index.d.ts +0 -0
  166. /package/dist/umd/{src/plugins → plugins}/weather/index.d.ts +0 -0
  167. /package/dist/umd/{src/state → state}/index.d.ts +0 -0
  168. /package/dist/umd/{src/state → state}/open-convai-state.d.ts +0 -0
  169. /package/dist/umd/{src/state → state}/state-types.d.ts +0 -0
  170. /package/dist/umd/{src/tools → tools}/ConnectionTool.d.ts +0 -0
  171. /package/dist/umd/{src/tools → tools}/index.d.ts +0 -0
  172. /package/dist/umd/{src/utils → utils}/Encryption.d.ts +0 -0
  173. /package/dist/umd/{src/utils → utils}/HederaClient.d.ts +0 -0
  174. /package/dist/umd/{src/utils → utils}/connectionUtils.d.ts +0 -0
  175. /package/dist/umd/{src/utils → utils}/ensure-agent-has-hbar.d.ts +0 -0
  176. /package/dist/umd/{src/utils → utils}/state-tools.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"standards-agent-kit.es3.js","sources":["../../src/hcs10/HCS10Client.ts"],"sourcesContent":["import { TransactionReceipt, PrivateKey } from '@hashgraph/sdk';\nimport {\n HCS10Client as StandardSDKClient,\n AgentBuilder,\n InboundTopicType as StandardInboundTopicType,\n AIAgentCapability as StandardAIAgentCapability,\n AgentRegistrationResult,\n WaitForConnectionConfirmationResponse,\n ProfileResponse as SDKProfileResponse,\n HCSMessage,\n LogLevel,\n Logger,\n FeeConfigBuilderInterface,\n SocialPlatform,\n} from '@hashgraphonline/standards-sdk';\nimport { AgentMetadata, AgentChannels } from './types';\nimport { encryptMessage } from '../utils/Encryption';\nimport { IStateManager } from '../state/state-types';\n\n// Keep type alias as they were removed accidentally\ntype StandardHandleConnectionRequest = InstanceType<\n typeof StandardSDKClient\n>['handleConnectionRequest'];\ntype HandleConnectionRequestResponse = Awaited<\n ReturnType<StandardHandleConnectionRequest>\n>;\nexport type StandardNetworkType = 'mainnet' | 'testnet';\n\nexport interface ClientValidationOptions {\n accountId: string;\n privateKey: string;\n network?: StandardNetworkType;\n stateManager?: IStateManager;\n}\n\nexport interface HCSMessageWithTimestamp extends HCSMessage {\n timestamp: number;\n data?: string;\n sequence_number: number;\n}\n\nexport interface ExtendedAgentMetadata extends AgentMetadata {\n pfpBuffer?: Buffer;\n pfpFileName?: string;\n feeConfig?: FeeConfigBuilderInterface;\n}\n\n/**\n * HCS10Client wraps the HCS-10 functionalities using the @hashgraphonline/standards-sdk.\n * - Creates and registers agents using the standard SDK flow.\n * - Manages agent communication channels (handled by standard SDK).\n * - Sends messages on Hedera topics (currently manual, potential for standard SDK integration).\n */\nexport class HCS10Client {\n public standardClient: StandardSDKClient;\n private useEncryption: boolean;\n public agentChannels?: AgentChannels;\n public guardedRegistryBaseUrl: string;\n public logger: Logger;\n\n constructor(\n operatorId: string,\n operatorPrivateKey: string,\n network: StandardNetworkType,\n options?: {\n useEncryption?: boolean;\n registryUrl?: string;\n logLevel?: LogLevel;\n }\n ) {\n this.standardClient = new StandardSDKClient({\n network: network,\n operatorId: operatorId,\n operatorPrivateKey: operatorPrivateKey,\n guardedRegistryBaseUrl: options?.registryUrl,\n logLevel: options?.logLevel,\n });\n this.guardedRegistryBaseUrl = options?.registryUrl || '';\n this.useEncryption = options?.useEncryption || false;\n const shouldSilence = process.env.DISABLE_LOGGING === 'true'; \n this.logger = new Logger({\n level: options?.logLevel || 'info',\n silent: shouldSilence,\n });\n }\n\n public getOperatorId(): string {\n const operator = this.standardClient.getClient().operatorAccountId;\n if (!operator) {\n throw new Error('Operator Account ID not configured in standard client.');\n }\n return operator.toString();\n }\n\n public getNetwork(): StandardNetworkType {\n return this.standardClient.getNetwork() as StandardNetworkType;\n }\n\n public async handleConnectionRequest(\n inboundTopicId: string,\n requestingAccountId: string,\n connectionRequestId: number,\n feeConfig?: FeeConfigBuilderInterface\n ): Promise<HandleConnectionRequestResponse> {\n try {\n const result = await this.standardClient.handleConnectionRequest(\n inboundTopicId,\n requestingAccountId,\n connectionRequestId,\n feeConfig\n );\n return result;\n } catch (error) {\n this.logger.error(\n `Error handling connection request #${connectionRequestId} for topic ${inboundTopicId}:`,\n error\n );\n throw new Error(\n `Failed to handle connection request: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n }\n\n /**\n * Retrieves the profile for a given account ID using the standard SDK.\n */\n public async getAgentProfile(accountId: string): Promise<SDKProfileResponse> {\n return this.standardClient.retrieveProfile(accountId);\n }\n\n /**\n * Exposes the standard SDK's submitConnectionRequest method.\n */\n public async submitConnectionRequest(\n inboundTopicId: string,\n memo: string\n ): Promise<TransactionReceipt> {\n return this.standardClient.submitConnectionRequest(\n inboundTopicId,\n memo\n ) as Promise<TransactionReceipt>;\n }\n\n /**\n * Exposes the standard SDK's waitForConnectionConfirmation method.\n */\n public async waitForConnectionConfirmation(\n outboundTopicId: string,\n connectionRequestId: number,\n maxAttempts = 60,\n delayMs = 2000\n ): Promise<WaitForConnectionConfirmationResponse> {\n return this.standardClient.waitForConnectionConfirmation(\n outboundTopicId,\n connectionRequestId,\n maxAttempts,\n delayMs\n );\n }\n\n /**\n * Creates and registers an agent using the standard SDK's HCS10Client.\n * This handles account creation, key generation, topic setup, and registration.\n *\n * When metadata includes fee configuration:\n * 1. The properties.feeConfig will be passed to the AgentBuilder\n * 2. The properties.inboundTopicType will be set to FEE_BASED\n * 3. The SDK's createAndRegisterAgent will apply the fees to the agent's inbound topic\n *\n * @param metadata - The agent's metadata, potentially including pfpBuffer, pfpFileName,\n * and fee configuration in properties.feeConfig\n * @returns The registration result from the standard SDK, containing accountId, keys, topics etc.\n */\n public async createAndRegisterAgent(\n metadata: ExtendedAgentMetadata\n ): Promise<AgentRegistrationResult> {\n const builder = new AgentBuilder()\n .setName(metadata.name)\n .setBio(metadata.description || '')\n .setCapabilities(\n metadata.capabilities\n ? metadata.capabilities\n : [StandardAIAgentCapability.TEXT_GENERATION]\n )\n .setType((metadata.type || 'autonomous') as 'autonomous' | 'manual')\n .setModel(metadata.model || 'agent-model-2024')\n .setNetwork(this.getNetwork())\n .setInboundTopicType(StandardInboundTopicType.PUBLIC);\n\n if (metadata?.feeConfig) {\n builder.setInboundTopicType(StandardInboundTopicType.FEE_BASED);\n builder.setFeeConfig(metadata.feeConfig);\n }\n\n if (metadata.pfpBuffer && metadata.pfpFileName) {\n if (metadata.pfpBuffer.byteLength === 0) {\n this.logger.warn(\n 'Provided PFP buffer is empty. Skipping profile picture.'\n );\n } else {\n this.logger.info(\n `Setting profile picture: ${metadata.pfpFileName} (${metadata.pfpBuffer.byteLength} bytes)`\n );\n builder.setProfilePicture(metadata.pfpBuffer, metadata.pfpFileName);\n }\n } else {\n this.logger.warn(\n 'Profile picture not provided in metadata. Agent creation might fail if required by the underlying SDK builder.'\n );\n }\n\n if (metadata.social) {\n Object.entries(metadata.social).forEach(([platform, handle]) => {\n builder.addSocial(platform as SocialPlatform, handle);\n });\n }\n\n if (metadata.properties) {\n Object.entries(metadata.properties).forEach(([key, value]) => {\n builder.addProperty(key, value);\n });\n }\n\n try {\n const hasFees = Boolean(metadata?.feeConfig);\n const result = await this.standardClient.createAndRegisterAgent(builder, {\n initialBalance: hasFees ? 50 : undefined,\n });\n if (\n result?.metadata?.inboundTopicId &&\n result?.metadata?.outboundTopicId\n ) {\n this.agentChannels = {\n inboundTopicId: result.metadata.inboundTopicId,\n outboundTopicId: result.metadata.outboundTopicId,\n };\n }\n return result;\n } catch (error) {\n this.logger.error('Error during agent creation/registration:', error);\n throw new Error(\n `Failed to create/register agent: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n }\n\n /**\n * Sends a structured HCS-10 message to the specified topic using the standard SDK client.\n * Handles potential inscription for large messages.\n *\n * @param topicId - The target topic ID (likely a connection topic).\n * @param operatorId - The operator ID string (e.g., \"inboundTopic@accountId\").\n * @param data - The actual message content/data.\n * @param memo - Optional memo for the message.\n * @param submitKey - Optional private key for topics requiring specific submit keys.\n * @returns A confirmation status string from the transaction receipt.\n */\n public async sendMessage(\n topicId: string,\n data: string,\n memo?: string,\n submitKey?: PrivateKey\n ): Promise<number | undefined> {\n if (this.useEncryption) {\n data = encryptMessage(data);\n }\n\n try {\n const messageResponse = await this.standardClient.sendMessage(\n topicId,\n data,\n memo,\n submitKey\n );\n return messageResponse.topicSequenceNumber?.toNumber();\n } catch (error) {\n this.logger.error(`Error sending message to topic ${topicId}:`, error);\n throw new Error(\n `Failed to send message: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n }\n\n /**\n * Retrieves messages from a topic using the standard SDK client.\n *\n * @param topicId - The topic ID to get messages from.\n * @returns Messages from the topic, mapped to the expected format.\n */\n public async getMessages(topicId: string): Promise<{\n messages: HCSMessageWithTimestamp[];\n }> {\n try {\n const result = await this.standardClient.getMessages(topicId);\n\n const mappedMessages = result.messages.map((sdkMessage) => {\n const timestamp = sdkMessage?.created?.getTime() || 0;\n\n return {\n ...sdkMessage,\n timestamp: timestamp,\n data: sdkMessage.data,\n sequence_number: sdkMessage.sequence_number,\n };\n });\n mappedMessages.sort(\n (a: { timestamp: number }, b: { timestamp: number }) =>\n a.timestamp - b.timestamp\n );\n return { messages: mappedMessages };\n } catch (error) {\n this.logger.error(`Error getting messages from topic ${topicId}:`, error);\n return { messages: [] };\n }\n }\n\n public async getMessageStream(topicId: string): Promise<{\n messages: HCSMessage[];\n }> {\n return this.standardClient.getMessageStream(topicId);\n }\n\n /**\n * Retrieves content from an inscribed message using the standard SDK client.\n * @param inscriptionIdOrData - The inscription ID (hcs://...) or potentially raw data string.\n * @returns The resolved message content.\n */\n public async getMessageContent(inscriptionIdOrData: string): Promise<string> {\n try {\n const content = await this.standardClient.getMessageContent(\n inscriptionIdOrData\n );\n return content as string;\n } catch (error) {\n this.logger.error(\n `Error retrieving message content for: ${inscriptionIdOrData}`,\n error\n );\n throw new Error(\n `Failed to retrieve message content: ${\n error instanceof Error ? error.message : String(error)\n }`\n );\n }\n }\n\n /**\n * Retrieves the inbound topic ID associated with the current operator.\n * This typically involves fetching the operator's own HCS-10 profile.\n * @returns A promise that resolves to the operator's inbound topic ID.\n * @throws {Error} If the operator ID cannot be determined or the profile/topic cannot be retrieved.\n */\n public async getInboundTopicId(): Promise<string> {\n try {\n const operatorId = this.getOperatorId();\n this.logger.info(\n `[HCS10Client] Retrieving profile for operator ${operatorId} to find inbound topic...`\n );\n const profileResponse = await this.getAgentProfile(operatorId);\n if (profileResponse.success && profileResponse.topicInfo?.inboundTopic) {\n this.logger.info(\n `[HCS10Client] Found inbound topic for operator ${operatorId}: ${profileResponse.topicInfo.inboundTopic}`\n );\n return profileResponse.topicInfo.inboundTopic;\n } else {\n throw new Error(\n `Could not retrieve inbound topic from profile for ${operatorId}. Profile success: ${profileResponse.success}, Error: ${profileResponse.error}`\n );\n }\n } catch (error) {\n this.logger.error(\n `[HCS10Client] Error fetching operator's inbound topic ID (${this.getOperatorId()}):`,\n error\n );\n const operatorId = this.getOperatorId();\n let detailedMessage = `Failed to get inbound topic ID for operator ${operatorId}.`;\n if (\n error instanceof Error &&\n error.message.includes('does not have a valid HCS-11 memo')\n ) {\n 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).`;\n } else if (error instanceof Error) {\n detailedMessage += ` Reason: ${error.message}`;\n } else {\n detailedMessage += ` Unexpected error: ${String(error)}`;\n }\n throw new Error(detailedMessage);\n }\n }\n\n /**\n * Retrieves the configured operator account ID and private key.\n * Required by tools needing to identify the current agent instance.\n */\n public getAccountAndSigner(): { accountId: string; signer: PrivateKey } {\n const result = this.standardClient.getAccountAndSigner();\n return {\n accountId: result.accountId,\n signer: result.signer as unknown as PrivateKey,\n };\n }\n\n /**\n * Retrieves the outbound topic ID for the current operator.\n * Fetches the operator's profile if necessary.\n * @returns The outbound topic ID string.\n * @throws If the outbound topic cannot be determined.\n */\n public async getOutboundTopicId(): Promise<string> {\n const operatorId = this.getOperatorId();\n const profile = await this.getAgentProfile(operatorId);\n if (profile.success && profile.topicInfo?.outboundTopic) {\n return profile.topicInfo.outboundTopic;\n } else {\n throw new Error(\n `Could not retrieve outbound topic from profile for ${operatorId}. Profile success: ${profile.success}, Error: ${profile.error}`\n );\n }\n }\n\n public setClient(accountId: string, privateKey: string): StandardSDKClient {\n this.standardClient = new StandardSDKClient({\n network: this.getNetwork(),\n operatorId: accountId,\n operatorPrivateKey: privateKey,\n guardedRegistryBaseUrl: this.guardedRegistryBaseUrl,\n });\n return this.standardClient;\n }\n\n /**\n * Validates that the operator account exists and has proper access for agent operations\n */\n private async validateOperator(\n options: ClientValidationOptions\n ): Promise<{\n isValid: boolean;\n operator?: { accountId: string };\n error?: string;\n }> {\n try {\n // Set up client with provided operator details\n this.setClient(options.accountId, options.privateKey);\n\n // Check if we can retrieve the operator ID\n const operatorId = this.getOperatorId();\n\n // If we got this far, basic validation passed\n return {\n isValid: true,\n operator: { accountId: operatorId },\n };\n } catch (error) {\n this.logger.error(`Validation error: ${error}`);\n return {\n isValid: false,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n }\n\n async initializeWithValidation(\n options: ClientValidationOptions\n ): Promise<{\n isValid: boolean;\n operator?: { accountId: string };\n error?: string;\n }> {\n const validationResult = await this.validateOperator(options);\n\n if (validationResult.isValid) {\n // If we have access to the state manager, initialize its connections manager\n if (options.stateManager) {\n options.stateManager.initializeConnectionsManager(this.standardClient);\n }\n }\n\n return validationResult;\n }\n}\n"],"names":["StandardSDKClient","StandardAIAgentCapability","StandardInboundTopicType"],"mappings":";;AAqDO,MAAM,YAAY;AAAA,EAOvB,YACE,YACA,oBACA,SACA,SAKA;AACK,SAAA,iBAAiB,IAAIA,cAAkB;AAAA,MAC1C;AAAA,MACA;AAAA,MACA;AAAA,MACA,wBAAwB,SAAS;AAAA,MACjC,UAAU,SAAS;AAAA,IAAA,CACpB;AACI,SAAA,yBAAyB,SAAS,eAAe;AACjD,SAAA,gBAAgB,SAAS,iBAAiB;AACzC,UAAA,gBAAgB,QAAQ,IAAI,oBAAoB;AACjD,SAAA,SAAS,IAAI,OAAO;AAAA,MACvB,OAAO,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OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,MAC9D;AAAA,IAAA;AAAA,EACF;AAAA,EAGF,MAAM,yBACJ,SAKC;AACD,UAAM,mBAAmB,MAAM,KAAK,iBAAiB,OAAO;AAE5D,QAAI,iBAAiB,SAAS;AAE5B,UAAI,QAAQ,cAAc;AAChB,gBAAA,aAAa,6BAA6B,KAAK,cAAc;AAAA,MAAA;AAAA,IACvE;AAGK,WAAA;AAAA,EAAA;AAEX;"}
1
+ {"version":3,"file":"standards-agent-kit.es3.js","sources":["../../src/tools/RegisterAgentTool.ts"],"sourcesContent":["import {\n AIAgentCapability,\n Logger,\n FeeConfigBuilder,\n} from '@hashgraphonline/standards-sdk';\nimport { ensureAgentHasEnoughHbar } from '../utils/ensure-agent-has-hbar';\nimport { HCS10Client, ExtendedAgentMetadata } from '../hcs10/HCS10Client';\nimport { StructuredTool } from '@langchain/core/tools';\nimport { z } from 'zod';\nimport { IStateManager } from '../state/state-types';\nimport { AgentPersistenceOptions } from '../state/state-types';\nimport fs from 'fs';\nimport path from 'path';\nimport axios from 'axios';\n\n/**\n * Interface for HCS10 registration result\n */\ninterface HCS10RegistrationResult {\n metadata?: {\n accountId?: string;\n inboundTopicId?: string;\n outboundTopicId?: string;\n profileTopicId?: string;\n privateKey?: string;\n capabilities?: number[];\n [key: string]: string | number | boolean | number[] | object | undefined;\n };\n}\n\n/**\n * Agent registration details returned when successful\n */\ninterface AgentRegistrationDetails {\n success: boolean;\n message: string;\n name: string;\n accountId: string;\n privateKey: string;\n inboundTopicId: string;\n outboundTopicId: string;\n profileTopicId: string;\n capabilities: number[];\n hasFees: boolean;\n hbarFee: number;\n tokenFee: { amount: number; tokenId: string } | null;\n profilePicture?: {\n source: string;\n topicId?: string;\n };\n}\n\n/**\n * Profile picture input types supported by the tool\n */\ntype ProfilePictureInput =\n | string\n | {\n url: string;\n filename: string;\n }\n | {\n path: string;\n filename?: string;\n };\n\n/**\n * RegisterAgentTool wraps the createAndRegisterAgent() function of HCS10Client.\n * It creates and registers an agent on Hedera using the HCS-10 standard SDK flow.\n * On success, returns a JSON string containing the new agent's details (including private key).\n */\nexport class RegisterAgentTool extends StructuredTool {\n name = 'register_agent';\n description =\n \"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.\";\n private client: HCS10Client;\n private stateManager?: IStateManager;\n\n schema = z.object({\n name: z.string().describe('The name of the agent to register'),\n description: z\n .string()\n .optional()\n .describe('Optional description of the agent'),\n type: z\n .enum(['autonomous', 'manual'])\n .optional()\n .describe('Optional agent type (default: autonomous)'),\n model: z\n .string()\n .optional()\n .describe('Optional model identifier for the agent'),\n capabilities: z\n .array(z.number())\n .optional()\n .describe(\n 'Optional array of AIAgentCapability enum values (0-18). If not provided, defaults to just TEXT_GENERATION (0)'\n ),\n profilePicture: z\n .union([\n z.string().describe('Path to a local image file or URL to an image'),\n z.object({\n url: z.string().describe('URL to an image file'),\n filename: z.string().describe('Filename to use for the image'),\n }),\n z.object({\n path: z.string().describe('Path to a local image file'),\n filename: z.string().optional().describe('Optional custom filename'),\n }),\n ])\n .optional()\n .describe(\n 'Optional profile picture for the agent (local file path or URL)'\n ),\n feeCollectorAccountId: z\n .string()\n .optional()\n .describe(\n \"The account ID to collect fees. If not specified, the new agent's account ID will be used. Required if any fee is specified.\"\n ),\n hbarFee: z\n .number()\n .optional()\n .describe(\n '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.'\n ),\n tokenFee: z\n .object({\n amount: z.number(),\n tokenId: z.string(),\n })\n .optional()\n .describe(\n '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.'\n ),\n hbarFees: z\n .array(\n z.object({\n amount: z.number(),\n collectorAccount: z.string().optional(),\n })\n )\n .optional()\n .describe(\n 'Optional: Array of HBAR fees with different collectors. If specified, inboundTopicType will be set to FEE_BASED.'\n ),\n tokenFees: z\n .array(\n z.object({\n amount: z.number(),\n tokenId: z.string(),\n collectorAccount: z.string().optional(),\n })\n )\n .optional()\n .describe(\n 'Optional: Array of token fees with different collectors. If specified, inboundTopicType will be set to FEE_BASED.'\n ),\n exemptAccountIds: z\n .array(z.string())\n .optional()\n .describe(\n 'Optional: Array of account IDs to exempt from ALL fees set for this agent.'\n ),\n setAsCurrent: z\n .boolean()\n .optional()\n .describe(\n 'Optional: Whether to set the newly registered agent as the current active agent in the state manager. Default: true'\n ),\n persistence: z\n .object({\n prefix: z.string().optional(),\n })\n .optional()\n .describe(\n '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.'\n ),\n });\n\n /**\n * Creates a new RegisterAgentTool instance\n * @param client - Instance of HCS10Client (already configured with operator/network)\n * @param stateManager - Optional state manager to store agent details\n */\n constructor(client: HCS10Client, stateManager?: IStateManager) {\n super();\n this.client = client;\n this.stateManager = stateManager;\n }\n\n /**\n * Loads a profile picture from a local file or URL and returns a buffer\n * @param profilePicture - Local file path or URL\n * @returns Object containing buffer and filename\n */\n private async loadProfilePicture(\n profilePicture: ProfilePictureInput\n ): Promise<{ buffer: Buffer; filename: string } | null> {\n const logger = Logger.getInstance({\n level: 'debug',\n });\n\n try {\n if (!profilePicture) {\n return null;\n }\n\n if (typeof profilePicture === 'string') {\n const isUrl =\n profilePicture.startsWith('http://') ||\n profilePicture.startsWith('https://');\n\n if (isUrl) {\n logger.info(`Loading profile picture from URL: ${profilePicture}`);\n const response = await axios.get(profilePicture, {\n responseType: 'arraybuffer',\n });\n const buffer = Buffer.from(response.data);\n\n const urlPathname = new URL(profilePicture).pathname;\n const filename = path.basename(urlPathname) || 'profile.png';\n\n return { buffer, filename };\n } else {\n if (!fs.existsSync(profilePicture)) {\n logger.warn(`Profile picture file not found: ${profilePicture}`);\n return null;\n }\n\n logger.info(`Loading profile picture from file: ${profilePicture}`);\n const buffer = fs.readFileSync(profilePicture);\n const filename = path.basename(profilePicture);\n\n return { buffer, filename };\n }\n }\n\n if ('url' in profilePicture) {\n logger.info(`Loading profile picture from URL: ${profilePicture.url}`);\n const response = await axios.get(profilePicture.url, {\n responseType: 'arraybuffer',\n });\n const buffer = Buffer.from(response.data);\n const filename = profilePicture.filename || 'profile.png';\n\n return { buffer, filename };\n }\n\n if ('path' in profilePicture) {\n if (!fs.existsSync(profilePicture.path)) {\n logger.warn(`Profile picture file not found: ${profilePicture.path}`);\n return null;\n }\n\n logger.info(\n `Loading profile picture from file: ${profilePicture.path}`\n );\n const buffer = fs.readFileSync(profilePicture.path);\n const filename =\n profilePicture.filename || path.basename(profilePicture.path);\n\n return { buffer, filename };\n }\n\n return null;\n } catch (error) {\n logger.error('Failed to load profile picture:', error);\n return null;\n }\n }\n\n /**\n * Calls createAndRegisterAgent() with the provided metadata.\n * Returns a JSON string with agent details on success, or an error string.\n */\n async _call(input: z.infer<typeof this.schema>): Promise<string> {\n const logger = Logger.getInstance({\n level: 'debug',\n });\n\n const metadata: ExtendedAgentMetadata = {\n name: input.name,\n description: input.description,\n type: input.type,\n model: input.model,\n capabilities: input.capabilities || [AIAgentCapability.TEXT_GENERATION],\n properties: {},\n };\n\n let profilePictureSource = '';\n if (input.profilePicture) {\n const profilePictureData = await this.loadProfilePicture(\n input.profilePicture\n );\n if (profilePictureData) {\n const { buffer, filename } = profilePictureData;\n metadata.pfpBuffer = buffer;\n metadata.pfpFileName = filename;\n\n if (typeof input.profilePicture === 'string') {\n profilePictureSource = input.profilePicture;\n } else if ('url' in input.profilePicture) {\n profilePictureSource = input.profilePicture.url;\n } else if ('path' in input.profilePicture) {\n profilePictureSource = input.profilePicture.path;\n }\n }\n }\n\n const hasHbarFee = input.hbarFee !== undefined && input.hbarFee > 0;\n const hasTokenFee = this.hasValidTokenFee(input.tokenFee);\n const hasHbarFees = input.hbarFees && input.hbarFees.length > 0;\n const hasTokenFees = input.tokenFees && input.tokenFees.length > 0;\n\n if (hasHbarFee || hasTokenFee || hasHbarFees || hasTokenFees) {\n const { accountId: operatorAccountId } =\n this.client.getAccountAndSigner();\n const collectorId = input.feeCollectorAccountId || operatorAccountId;\n\n if (!collectorId) {\n return 'Error: Fee collector account ID is required when specifying fees and could not be determined.';\n }\n\n const feeConfigBuilder = new FeeConfigBuilder({\n network: this.client.getNetwork(),\n logger,\n });\n\n try {\n const exemptAccountIds =\n input.exemptAccountIds?.filter(\n (id) => id !== collectorId && id.startsWith('0.0')\n ) || [];\n\n let updatedFeeConfig = feeConfigBuilder;\n\n if (hasHbarFee) {\n logger.info(\n `Adding HBAR fee: ${input.hbarFee} HBAR to be collected by ${collectorId}`\n );\n updatedFeeConfig = updatedFeeConfig.addHbarFee(\n input.hbarFee!,\n collectorId,\n exemptAccountIds\n );\n }\n\n if (hasHbarFees) {\n for (const fee of input.hbarFees!) {\n const feeCollector = fee.collectorAccount || collectorId;\n logger.info(\n `Adding HBAR fee: ${fee.amount} HBAR to be collected by ${feeCollector}`\n );\n updatedFeeConfig = updatedFeeConfig.addHbarFee(\n fee.amount,\n feeCollector,\n exemptAccountIds\n );\n }\n }\n\n if (hasTokenFee) {\n logger.info(\n `Adding token fee: ${input.tokenFee!.amount} of token ${\n input.tokenFee!.tokenId\n } to be collected by ${collectorId}`\n );\n updatedFeeConfig = await updatedFeeConfig.addTokenFee(\n input.tokenFee!.amount,\n input.tokenFee!.tokenId,\n collectorId,\n undefined,\n exemptAccountIds\n );\n }\n\n if (hasTokenFees) {\n for (const fee of input.tokenFees!) {\n const feeCollector = fee.collectorAccount || collectorId;\n logger.info(\n `Adding token fee: ${fee.amount} of token ${fee.tokenId} to be collected by ${feeCollector}`\n );\n updatedFeeConfig = await updatedFeeConfig.addTokenFee(\n fee.amount,\n fee.tokenId,\n feeCollector,\n undefined,\n exemptAccountIds\n );\n }\n }\n\n metadata.feeConfig = updatedFeeConfig;\n logger.info('FeeConfigBuilder created successfully');\n } catch (error) {\n return `Error: Failed to configure fees. Reason: ${\n error instanceof Error ? error.message : String(error)\n }`;\n }\n }\n\n try {\n logger.info('Registering agent with metadata');\n\n const result = (await this.client.createAndRegisterAgent(\n metadata\n )) as unknown as HCS10RegistrationResult;\n\n return this.processRegistrationResult(\n result,\n input,\n profilePictureSource\n );\n } catch (error) {\n return `Error: Failed to create/register agent \"${input.name}\". Reason: ${\n error instanceof Error ? error.message : String(error)\n }`;\n }\n }\n\n /**\n * Checks if the token fee configuration is valid\n */\n private hasValidTokenFee(tokenFee?: {\n amount: number;\n tokenId: string;\n }): boolean {\n return !!(\n tokenFee &&\n tokenFee.amount > 0 &&\n tokenFee.tokenId &&\n tokenFee.tokenId.trim() !== ''\n );\n }\n\n /**\n * Processes the registration result and returns formatted output\n */\n private async processRegistrationResult(\n result: HCS10RegistrationResult,\n input: z.infer<typeof this.schema>,\n profilePictureSource: string = ''\n ): Promise<string> {\n const newAgentAccountId = result?.metadata?.accountId || '';\n const inboundTopicId = result?.metadata?.inboundTopicId || '';\n const outboundTopicId = result?.metadata?.outboundTopicId || '';\n const profileTopicId = result?.metadata?.profileTopicId || '';\n const privateKey = result?.metadata?.privateKey || '';\n const pfpTopicId = result?.metadata?.pfpTopicId;\n\n this.validateRegistrationResult(\n newAgentAccountId,\n inboundTopicId,\n outboundTopicId,\n privateKey\n );\n\n if (\n this.stateManager &&\n privateKey &&\n newAgentAccountId &&\n inboundTopicId &&\n outboundTopicId &&\n (input.setAsCurrent === undefined || input.setAsCurrent)\n ) {\n const agent = {\n name: input.name,\n accountId: newAgentAccountId,\n inboundTopicId,\n outboundTopicId,\n profileTopicId,\n privateKey,\n pfpTopicId: pfpTopicId as string,\n };\n\n this.stateManager.setCurrentAgent(agent);\n\n if (this.stateManager.persistAgentData && input.persistence) {\n try {\n const persistenceOptions: AgentPersistenceOptions = {\n type: 'env-file',\n prefix: input.persistence.prefix,\n };\n\n await this.stateManager.persistAgentData(agent, persistenceOptions);\n } catch (error) {\n Logger.getInstance().warn('Failed to persist agent data', error);\n }\n }\n }\n\n await this.ensureAgentHasFunds(newAgentAccountId, input.name);\n\n const feeDescription = this.createFeeDescription(input);\n const feeMessage = feeDescription\n ? ` with ${feeDescription} fee on inbound topic`\n : '';\n\n const registrationDetails: AgentRegistrationDetails = {\n success: true,\n message: `Successfully registered agent '${input.name}'${feeMessage}.`,\n name: input.name,\n accountId: newAgentAccountId,\n privateKey: privateKey,\n inboundTopicId: inboundTopicId,\n outboundTopicId: outboundTopicId,\n profileTopicId: profileTopicId || 'N/A',\n capabilities: input.capabilities || [AIAgentCapability.TEXT_GENERATION],\n hasFees: !!(input.hbarFee || this.hasValidTokenFee(input.tokenFee)),\n hbarFee: input.hbarFee || 0,\n tokenFee: input.tokenFee || null,\n };\n\n if (pfpTopicId || profilePictureSource) {\n registrationDetails.profilePicture = {\n source: profilePictureSource,\n topicId: pfpTopicId as string,\n };\n }\n\n return JSON.stringify(registrationDetails);\n }\n\n /**\n * Ensures the agent has enough HBAR for operations\n */\n private async ensureAgentHasFunds(\n accountId: string,\n agentName: string\n ): Promise<void> {\n try {\n await ensureAgentHasEnoughHbar(\n Logger.getInstance({\n module: 'RegisterAgentTool',\n }),\n this.client.standardClient,\n accountId,\n agentName\n );\n } catch (error) {\n Logger.getInstance().error('Failed to auto fund agent', error);\n }\n }\n\n /**\n * Validates that all required fields are present in the registration result\n */\n private validateRegistrationResult(\n accountId?: string,\n inboundTopicId?: string,\n outboundTopicId?: string,\n privateKey?: string\n ): void {\n if (!accountId || !inboundTopicId || !outboundTopicId || !privateKey) {\n const missingFields = [\n !accountId && 'accountId',\n !inboundTopicId && 'inboundTopicId',\n !outboundTopicId && 'outboundTopicId',\n !privateKey && 'privateKey',\n ]\n .filter(Boolean)\n .join(', ');\n throw new Error(\n `Registration failed. The HCS client returned incomplete details (Missing: ${missingFields}).`\n );\n }\n }\n\n /**\n * Creates a description of the fees configured for the agent\n */\n private createFeeDescription(input: z.infer<typeof this.schema>): string {\n const hasHbarFee = input.hbarFee && input.hbarFee > 0;\n const hasTokenFee = this.hasValidTokenFee(input.tokenFee);\n if (!hasHbarFee && !hasTokenFee) {\n return '';\n }\n\n let description = '';\n if (hasHbarFee) {\n description += `${input.hbarFee} HBAR`;\n }\n if (hasTokenFee && input.tokenFee) {\n const tokenFeeText = `${input.tokenFee.amount} of token ${input.tokenFee.tokenId}`;\n description += description ? ` and ${tokenFeeText}` : tokenFeeText;\n }\n return description;\n }\n}\n"],"names":["path","fs"],"mappings":";;;;;;;AAuEO,MAAM,0BAA0B,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkHpD,YAAY,QAAqB,cAA8B;AACvD,UAAA;AAlHD,SAAA,OAAA;AAEL,SAAA,cAAA;AAIF,SAAA,SAAS,EAAE,OAAO;AAAA,MAChB,MAAM,EAAE,SAAS,SAAS,mCAAmC;AAAA,MAC7D,aAAa,EACV,OAAA,EACA,SAAS,EACT,SAAS,mCAAmC;AAAA,MAC/C,MAAM,EACH,KAAK,CAAC,cAAc,QAAQ,CAAC,EAC7B,SAAA,EACA,SAAS,2CAA2C;AAAA,MACvD,OAAO,EACJ,OAAA,EACA,SAAS,EACT,SAAS,yCAAyC;AAAA,MACrD,cAAc,EACX,MAAM,EAAE,QAAQ,EAChB,WACA;AAAA,QACC;AAAA,MACF;AAAA,MACF,gBAAgB,EACb,MAAM;AAAA,QACL,EAAE,OAAA,EAAS,SAAS,+CAA+C;AAAA,QACnE,EAAE,OAAO;AAAA,UACP,KAAK,EAAE,SAAS,SAAS,sBAAsB;AAAA,UAC/C,UAAU,EAAE,OAAO,EAAE,SAAS,+BAA+B;AAAA,QAAA,CAC9D;AAAA,QACD,EAAE,OAAO;AAAA,UACP,MAAM,EAAE,SAAS,SAAS,4BAA4B;AAAA,UACtD,UAAU,EAAE,OAAA,EAAS,SAAS,EAAE,SAAS,0BAA0B;AAAA,QACpE,CAAA;AAAA,MAAA,CACF,EACA,SAAA,E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AAA;AAAA;AAAA,EAMM,2BACN,WACA,gBACA,iBACA,YACM;AACN,QAAI,CAAC,aAAa,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,YAAY;AACpE,YAAM,gBAAgB;AAAA,QACpB,CAAC,aAAa;AAAA,QACd,CAAC,kBAAkB;AAAA,QACnB,CAAC,mBAAmB;AAAA,QACpB,CAAC,cAAc;AAAA,MAEd,EAAA,OAAO,OAAO,EACd,KAAK,IAAI;AACZ,YAAM,IAAI;AAAA,QACR,6EAA6E,aAAa;AAAA,MAC5F;AAAA,IAAA;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAMM,qBAAqB,OAA4C;AACvE,UAAM,aAAa,MAAM,WAAW,MAAM,UAAU;AACpD,UAAM,cAAc,KAAK,iBAAiB,MAAM,QAAQ;AACpD,QAAA,CAAC,cAAc,CAAC,aAAa;AACxB,aAAA;AAAA,IAAA;AAGT,QAAI,cAAc;AAClB,QAAI,YAAY;AACC,qBAAA,GAAG,MAAM,OAAO;AAAA,IAAA;AAE7B,QAAA,eAAe,MAAM,UAAU;AAC3B,YAAA,eAAe,GAAG,MAAM,SAAS,MAAM,aAAa,MAAM,SAAS,OAAO;AACjE,qBAAA,cAAc,QAAQ,YAAY,KAAK;AAAA,IAAA;AAEjD,WAAA;AAAA,EAAA;AAEX;"}
@@ -1,394 +1,84 @@
1
- import { Logger, AIAgentCapability, FeeConfigBuilder } from "@hashgraphonline/standards-sdk";
2
- import { ensureAgentHasEnoughHbar } from "./standards-agent-kit.es26.js";
3
1
  import { StructuredTool } from "@langchain/core/tools";
4
2
  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 {
3
+ import { Logger } from "@hashgraphonline/standards-sdk";
4
+ class SendMessageTool extends StructuredTool {
9
5
  /**
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
6
+ * @param client - Instance of HCS10Client.
13
7
  */
14
- constructor(client, stateManager) {
8
+ constructor(client) {
15
9
  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.";
10
+ this.name = "send_message";
11
+ this.description = "Sends a message to a specified Hedera topic using HCS-10 and monitors for responses.";
12
+ this.lastProcessedTimestamp = 0;
18
13
  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
- )
14
+ topicId: z.string().describe("The Hedera topic ID to send the message to"),
15
+ message: z.string().describe("The message content to send"),
16
+ disableMonitoring: z.boolean().optional().describe("Whether to disable monitoring for responses")
79
17
  });
80
18
  this.client = client;
81
- this.stateManager = stateManager;
19
+ this.logger = Logger.getInstance({ module: "SendMessageTool" });
82
20
  }
83
21
  /**
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
22
+ * Calls sendMessage() with the provided parameters.
87
23
  */
88
- async loadProfilePicture(profilePicture) {
89
- const logger = Logger.getInstance({
90
- level: "debug"
91
- });
24
+ async _call(input) {
92
25
  try {
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 };
26
+ const result = await this.client.sendMessage(
27
+ input.topicId,
28
+ input.message
29
+ );
30
+ if (!result) {
31
+ throw new Error("Failed to send message");
126
32
  }
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 };
33
+ this.logger.info(`Message sent with sequence number ${result}`);
34
+ if (!input.disableMonitoring) {
35
+ const response = await this.monitorResponses(input.topicId, result);
36
+ return `Successfully sent message to topic ${input.topicId}${response ? `
37
+ Response: ${response}` : ""}`;
38
+ } else {
39
+ return `Successfully sent message to topic ${input.topicId}`;
138
40
  }
139
- return null;
140
41
  } catch (error) {
141
- logger.error("Failed to load profile picture:", error);
142
- return null;
143
- }
144
- }
145
- /**
146
- * Calls createAndRegisterAgent() with the provided metadata.
147
- * Returns a JSON string with agent details on success, or an error string.
148
- */
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
42
+ throw new Error(
43
+ `Failed to send message: ${error instanceof Error ? error.message : String(error)}`
165
44
  );
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
45
  }
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
- });
46
+ }
47
+ async monitorResponses(topicId, sequenceNumber) {
48
+ const maxAttempts = 10;
49
+ let attempts = 0;
50
+ while (attempts < maxAttempts) {
193
51
  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
- );
52
+ const messages = await this.client.getMessageStream(topicId);
53
+ for (const message of messages.messages) {
54
+ if (message.created && message.created.getTime() > this.lastProcessedTimestamp) {
55
+ this.lastProcessedTimestamp = message.created.getTime();
56
+ const content = await this.client.getMessageContent(message.data || "");
57
+ let parsedContent;
58
+ try {
59
+ parsedContent = JSON.parse(content);
60
+ } catch (error) {
61
+ this.logger.error(`Error parsing message content: ${error}`);
62
+ continue;
63
+ }
64
+ if (message.sequence_number > sequenceNumber) {
65
+ if (parsedContent && typeof parsedContent.data === "string") {
66
+ return parsedContent.data;
67
+ }
68
+ return JSON.stringify(parsedContent);
69
+ }
246
70
  }
247
71
  }
248
- metadata.feeConfig = updatedFeeConfig;
249
- logger.info("FeeConfigBuilder created successfully");
250
72
  } catch (error) {
251
- return `Error: Failed to configure fees. Reason: ${error instanceof Error ? error.message : String(error)}`;
73
+ this.logger.error(`Error monitoring responses: ${error}`);
252
74
  }
75
+ attempts++;
76
+ await new Promise((resolve) => setTimeout(resolve, 1e3));
253
77
  }
254
- try {
255
- logger.info("Registering agent with metadata");
256
- const result = await this.client.createAndRegisterAgent(
257
- metadata
258
- );
259
- return this.processRegistrationResult(
260
- result,
261
- input,
262
- profilePictureSource
263
- );
264
- } catch (error) {
265
- return `Error: Failed to create/register agent "${input.name}". Reason: ${error instanceof Error ? error.message : String(error)}`;
266
- }
267
- }
268
- /**
269
- * Checks if the token fee configuration is valid
270
- */
271
- hasValidTokenFee(tokenFee) {
272
- return !!(tokenFee && tokenFee.amount > 0 && tokenFee.tokenId && tokenFee.tokenId.trim() !== "");
273
- }
274
- /**
275
- * Processes the registration result and returns formatted output
276
- */
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
- };
335
- }
336
- return JSON.stringify(registrationDetails);
337
- }
338
- /**
339
- * Ensures the agent has enough HBAR for operations
340
- */
341
- async ensureAgentHasFunds(accountId, agentName) {
342
- try {
343
- await ensureAgentHasEnoughHbar(
344
- Logger.getInstance({
345
- module: "RegisterAgentTool"
346
- }),
347
- this.client.standardClient,
348
- accountId,
349
- agentName
350
- );
351
- } catch (error) {
352
- Logger.getInstance().error("Failed to auto fund agent", error);
353
- }
354
- }
355
- /**
356
- * Validates that all required fields are present in the registration result
357
- */
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(", ");
366
- throw new Error(
367
- `Registration failed. The HCS client returned incomplete details (Missing: ${missingFields}).`
368
- );
369
- }
370
- }
371
- /**
372
- * Creates a description of the fees configured for the agent
373
- */
374
- createFeeDescription(input) {
375
- const hasHbarFee = input.hbarFee && input.hbarFee > 0;
376
- const hasTokenFee = this.hasValidTokenFee(input.tokenFee);
377
- if (!hasHbarFee && !hasTokenFee) {
378
- return "";
379
- }
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;
387
- }
388
- return description;
78
+ return null;
389
79
  }
390
80
  }
391
81
  export {
392
- RegisterAgentTool
82
+ SendMessageTool
393
83
  };
394
84
  //# sourceMappingURL=standards-agent-kit.es4.js.map