UNPKG

@hashgraphonline/standards-agent-kit

Version:

A modular SDK for building on-chain autonomous agents using Hashgraph Online Standards, including HCS-10 for agent discovery and communication.

1 lines 315 kB
{"version":3,"file":"standards-agent-kit.cjs","sources":["../../src/tools/hcs10/base-hcs10-tools.ts","../../src/tools/hcs10/natural-language-mapper.ts","../../src/tools/hcs10/RegisterAgentTool.ts","../../src/tools/hcs10/SendMessageToConnectionTool.ts","../../src/tools/hcs10/InitiateConnectionTool.ts","../../src/tools/hcs10/ListConnectionsTool.ts","../../src/tools/hcs10/CheckMessagesTool.ts","../../src/tools/hcs10/FindRegistrationsTool.ts","../../src/tools/hcs10/ConnectionMonitorTool.ts","../../src/tools/hcs10/ManageConnectionRequestsTool.ts","../../src/tools/hcs10/AcceptConnectionRequestTool.ts","../../src/tools/hcs10/RetrieveProfileTool.ts","../../src/tools/hcs10/ListUnapprovedConnectionRequestsTool.ts","../../src/tools/hcs2/base-hcs2-tools.ts","../../src/tools/hcs2/CreateRegistryTool.ts","../../src/tools/hcs2/RegisterEntryTool.ts","../../src/tools/hcs2/UpdateEntryTool.ts","../../src/tools/hcs2/DeleteEntryTool.ts","../../src/tools/hcs2/MigrateRegistryTool.ts","../../src/tools/hcs2/QueryRegistryTool.ts","../../src/tools/hcs6/base-hcs6-tools.ts","../../src/tools/hcs6/CreateDynamicRegistryTool.ts","../../src/tools/hcs6/RegisterDynamicHashinalTool.ts","../../src/tools/hcs6/UpdateDynamicHashinalTool.ts","../../src/tools/hcs6/QueryDynamicRegistryTool.ts","../../src/tools/inscriber/base-inscriber-tools.ts","../../src/tools/inscriber/InscribeFromUrlTool.ts","../../src/tools/inscriber/InscribeFromFileTool.ts","../../src/tools/inscriber/InscribeFromBufferTool.ts","../../src/tools/inscriber/InscribeHashinalTool.ts","../../src/tools/inscriber/RetrieveInscriptionTool.ts","../../src/utils/state-tools.ts","../../src/state/open-convai-state.ts","../../src/builders/hcs10/hcs10-builder.ts","../../src/plugins/hedera/HbarPricePlugin.ts","../../src/builders/hcs2/hcs2-builder.ts","../../src/builders/hcs6/hcs6-builder.ts","../../src/builders/inscriber/inscriber-builder.ts","../../src/hcs10/HCS10Client.ts","../../src/init/init.ts"],"sourcesContent":["import {\n BaseHederaTransactionTool,\n BaseHederaQueryTool,\n BaseServiceBuilder,\n} from 'hedera-agent-kit';\nimport { HCS10Builder } from '../../builders/hcs10/hcs10-builder';\nimport {\n HCS10TransactionToolParams,\n HCS10QueryToolParams,\n} from './hcs10-tool-params';\nimport { z } from 'zod';\n\n/**\n * Base class for HCS10 transaction tools\n */\nexport abstract class BaseHCS10TransactionTool<\n T extends z.ZodObject<\n z.ZodRawShape,\n z.UnknownKeysParam,\n z.ZodTypeAny\n > = z.ZodObject<z.ZodRawShape>\n> extends BaseHederaTransactionTool<T> {\n protected hcs10Builder: HCS10Builder;\n namespace = 'hcs10' as const;\n\n constructor(params: HCS10TransactionToolParams) {\n super(params);\n this.hcs10Builder = params.hcs10Builder;\n }\n\n /**\n * Override to return the HCS10Builder\n */\n protected getServiceBuilder(): BaseServiceBuilder {\n return this.hcs10Builder;\n }\n}\n\n/**\n * Base class for HCS10 query tools\n */\nexport abstract class BaseHCS10QueryTool<\n T extends z.ZodObject<\n z.ZodRawShape,\n z.UnknownKeysParam,\n z.ZodTypeAny\n > = z.ZodObject<z.ZodRawShape>\n> extends BaseHederaQueryTool<T> {\n protected hcs10Builder: HCS10Builder;\n namespace = 'hcs10' as const;\n\n constructor(params: HCS10QueryToolParams) {\n super(params);\n this.hcs10Builder = params.hcs10Builder;\n }\n\n /**\n * Override to return the HCS10Builder\n */\n protected getServiceBuilder(): BaseServiceBuilder {\n return this.hcs10Builder;\n }\n}\n","import { AIAgentCapability } from '@hashgraphonline/standards-sdk';\n\n/**\n * Maps natural language terms to AIAgentCapability enum values\n */\nexport class NaturalLanguageMapper {\n private static readonly CAPABILITY_MAPPINGS: Record<string, AIAgentCapability[]> = {\n // Common terms\n 'ai': [AIAgentCapability.TEXT_GENERATION],\n 'artificial intelligence': [AIAgentCapability.TEXT_GENERATION],\n 'chat': [AIAgentCapability.TEXT_GENERATION],\n 'conversation': [AIAgentCapability.TEXT_GENERATION],\n 'text': [AIAgentCapability.TEXT_GENERATION],\n 'text generation': [AIAgentCapability.TEXT_GENERATION],\n \n // Image\n 'image': [AIAgentCapability.IMAGE_GENERATION],\n 'picture': [AIAgentCapability.IMAGE_GENERATION],\n 'visual': [AIAgentCapability.IMAGE_GENERATION],\n 'photo': [AIAgentCapability.IMAGE_GENERATION],\n \n // Audio\n 'audio': [AIAgentCapability.AUDIO_GENERATION],\n 'sound': [AIAgentCapability.AUDIO_GENERATION],\n 'voice': [AIAgentCapability.AUDIO_GENERATION],\n 'speech': [AIAgentCapability.AUDIO_GENERATION],\n \n // Video\n 'video': [AIAgentCapability.VIDEO_GENERATION],\n 'movie': [AIAgentCapability.VIDEO_GENERATION],\n 'animation': [AIAgentCapability.VIDEO_GENERATION],\n \n // Code\n 'code': [AIAgentCapability.CODE_GENERATION],\n 'programming': [AIAgentCapability.CODE_GENERATION],\n 'development': [AIAgentCapability.CODE_GENERATION],\n 'coding': [AIAgentCapability.CODE_GENERATION],\n \n // Translation\n 'translate': [AIAgentCapability.LANGUAGE_TRANSLATION],\n 'translation': [AIAgentCapability.LANGUAGE_TRANSLATION],\n 'language': [AIAgentCapability.LANGUAGE_TRANSLATION],\n \n // Summarization\n 'summarize': [AIAgentCapability.SUMMARIZATION_EXTRACTION],\n 'summary': [AIAgentCapability.SUMMARIZATION_EXTRACTION],\n 'extract': [AIAgentCapability.SUMMARIZATION_EXTRACTION],\n 'extraction': [AIAgentCapability.SUMMARIZATION_EXTRACTION],\n \n // Knowledge\n 'knowledge': [AIAgentCapability.KNOWLEDGE_RETRIEVAL],\n 'search': [AIAgentCapability.KNOWLEDGE_RETRIEVAL],\n 'retrieve': [AIAgentCapability.KNOWLEDGE_RETRIEVAL],\n 'lookup': [AIAgentCapability.KNOWLEDGE_RETRIEVAL],\n \n // Data\n 'data': [AIAgentCapability.DATA_INTEGRATION],\n 'data processing': [AIAgentCapability.DATA_INTEGRATION],\n 'data integration': [AIAgentCapability.DATA_INTEGRATION],\n 'etl': [AIAgentCapability.DATA_INTEGRATION],\n \n // Market\n 'market': [AIAgentCapability.MARKET_INTELLIGENCE],\n 'trading': [AIAgentCapability.MARKET_INTELLIGENCE],\n 'finance': [AIAgentCapability.MARKET_INTELLIGENCE],\n 'financial': [AIAgentCapability.MARKET_INTELLIGENCE],\n \n // Analytics\n 'analytics': [AIAgentCapability.TRANSACTION_ANALYTICS],\n 'analysis': [AIAgentCapability.TRANSACTION_ANALYTICS],\n 'analyze': [AIAgentCapability.TRANSACTION_ANALYTICS],\n 'transactions': [AIAgentCapability.TRANSACTION_ANALYTICS],\n \n // Smart Contract\n 'audit': [AIAgentCapability.SMART_CONTRACT_AUDIT],\n 'contract': [AIAgentCapability.SMART_CONTRACT_AUDIT],\n 'smart contract': [AIAgentCapability.SMART_CONTRACT_AUDIT],\n \n // Governance\n 'governance': [AIAgentCapability.GOVERNANCE_FACILITATION],\n 'voting': [AIAgentCapability.GOVERNANCE_FACILITATION],\n 'dao': [AIAgentCapability.GOVERNANCE_FACILITATION],\n \n // Security\n 'security': [AIAgentCapability.SECURITY_MONITORING],\n 'monitoring': [AIAgentCapability.SECURITY_MONITORING],\n 'threat': [AIAgentCapability.SECURITY_MONITORING],\n \n // Compliance\n 'compliance': [AIAgentCapability.COMPLIANCE_ANALYSIS],\n 'regulatory': [AIAgentCapability.COMPLIANCE_ANALYSIS],\n 'regulation': [AIAgentCapability.COMPLIANCE_ANALYSIS],\n \n // Fraud\n 'fraud': [AIAgentCapability.FRAUD_DETECTION],\n 'detection': [AIAgentCapability.FRAUD_DETECTION],\n 'anomaly': [AIAgentCapability.FRAUD_DETECTION],\n \n // Multi-agent\n 'coordination': [AIAgentCapability.MULTI_AGENT_COORDINATION],\n 'multi-agent': [AIAgentCapability.MULTI_AGENT_COORDINATION],\n 'orchestration': [AIAgentCapability.MULTI_AGENT_COORDINATION],\n \n // API\n 'api': [AIAgentCapability.API_INTEGRATION],\n 'integration': [AIAgentCapability.API_INTEGRATION],\n 'webhook': [AIAgentCapability.API_INTEGRATION],\n \n // Workflow\n 'workflow': [AIAgentCapability.WORKFLOW_AUTOMATION],\n 'automation': [AIAgentCapability.WORKFLOW_AUTOMATION],\n 'process': [AIAgentCapability.WORKFLOW_AUTOMATION],\n };\n\n /**\n * Parse natural language text and extract capability values\n */\n static parseCapabilities(text: string): AIAgentCapability[] {\n if (!text) return [AIAgentCapability.TEXT_GENERATION];\n \n const normalizedText = text.toLowerCase();\n const capabilities = new Set<AIAgentCapability>();\n \n // Check for exact matches first\n for (const [term, caps] of Object.entries(this.CAPABILITY_MAPPINGS)) {\n if (normalizedText.includes(term)) {\n caps.forEach(cap => capabilities.add(cap));\n }\n }\n \n // Default to TEXT_GENERATION if no capabilities found\n if (capabilities.size === 0) {\n capabilities.add(AIAgentCapability.TEXT_GENERATION);\n }\n \n return Array.from(capabilities);\n }\n\n /**\n * Parse tags/capabilities from various input formats\n */\n static parseTagsOrCapabilities(input: any): AIAgentCapability[] {\n // If already an array of numbers, return as is\n if (Array.isArray(input) && input.every(item => typeof item === 'number')) {\n return input;\n }\n \n // If array of strings, parse each\n if (Array.isArray(input) && input.every(item => typeof item === 'string')) {\n const capabilities = new Set<AIAgentCapability>();\n input.forEach(term => {\n this.parseCapabilities(term).forEach(cap => capabilities.add(cap));\n });\n return Array.from(capabilities);\n }\n \n // If single string, parse it\n if (typeof input === 'string') {\n return this.parseCapabilities(input);\n }\n \n // Default\n return [AIAgentCapability.TEXT_GENERATION];\n }\n\n /**\n * Convert capability enum to human-readable name\n */\n static getCapabilityName(capability: AIAgentCapability): string {\n const names: Record<AIAgentCapability, string> = {\n [AIAgentCapability.TEXT_GENERATION]: 'Text Generation',\n [AIAgentCapability.IMAGE_GENERATION]: 'Image Generation',\n [AIAgentCapability.AUDIO_GENERATION]: 'Audio Generation',\n [AIAgentCapability.VIDEO_GENERATION]: 'Video Generation',\n [AIAgentCapability.CODE_GENERATION]: 'Code Generation',\n [AIAgentCapability.LANGUAGE_TRANSLATION]: 'Language Translation',\n [AIAgentCapability.SUMMARIZATION_EXTRACTION]: 'Summarization & Extraction',\n [AIAgentCapability.KNOWLEDGE_RETRIEVAL]: 'Knowledge Retrieval',\n [AIAgentCapability.DATA_INTEGRATION]: 'Data Integration',\n [AIAgentCapability.MARKET_INTELLIGENCE]: 'Market Intelligence',\n [AIAgentCapability.TRANSACTION_ANALYTICS]: 'Transaction Analytics',\n [AIAgentCapability.SMART_CONTRACT_AUDIT]: 'Smart Contract Audit',\n [AIAgentCapability.GOVERNANCE_FACILITATION]: 'Governance Facilitation',\n [AIAgentCapability.SECURITY_MONITORING]: 'Security Monitoring',\n [AIAgentCapability.COMPLIANCE_ANALYSIS]: 'Compliance Analysis',\n [AIAgentCapability.FRAUD_DETECTION]: 'Fraud Detection',\n [AIAgentCapability.MULTI_AGENT_COORDINATION]: 'Multi-Agent Coordination',\n [AIAgentCapability.API_INTEGRATION]: 'API Integration',\n [AIAgentCapability.WORKFLOW_AUTOMATION]: 'Workflow Automation',\n };\n \n return names[capability] || 'Unknown Capability';\n }\n}","import { AIAgentCapability } from '@hashgraphonline/standards-sdk';\nimport { z } from 'zod';\nimport { BaseServiceBuilder } from 'hedera-agent-kit';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\nimport {\n HCS10Builder,\n RegisterAgentParams,\n} from '../../builders/hcs10/hcs10-builder';\nimport { BaseHCS10TransactionTool } from './base-hcs10-tools';\nimport { HCS10TransactionToolParams } from './hcs10-tool-params';\nimport { RegisteredAgent } from '../../state/state-types';\nimport { NaturalLanguageMapper } from './natural-language-mapper';\n\nconst RegisterAgentZodSchema = z.object({\n name: z\n .string()\n .min(1)\n .max(50)\n .describe('A unique name for the agent (1-50 characters)'),\n description: z\n .string()\n .max(500)\n .optional()\n .describe('Optional bio description for the agent (max 500 characters)'),\n alias: z\n .string()\n .optional()\n .transform((val) => {\n if (!val || val.toLowerCase().includes('random')) {\n const timestamp = Date.now().toString(36);\n const randomChars = Math.random().toString(36);\n return `bot${timestamp}${randomChars}`;\n }\n return val;\n })\n .describe(\n 'Optional custom username/alias for the agent. Use \"random\" to generate a unique alias'\n ),\n type: z\n .enum(['autonomous', 'manual'])\n .optional()\n .describe('Agent type (default: autonomous)'),\n model: z\n .string()\n .optional()\n .describe('AI model identifier (default: agent-model-2024)'),\n capabilities: z\n .union([\n z.array(z.nativeEnum(AIAgentCapability)),\n z.array(z.string()),\n z.string(),\n ])\n .optional()\n .transform((val) => {\n if (!val) return undefined;\n if (typeof val === 'string') {\n return NaturalLanguageMapper.parseCapabilities(val);\n }\n if (Array.isArray(val) && val.length > 0 && typeof val[0] === 'string') {\n return NaturalLanguageMapper.parseTagsOrCapabilities(val);\n }\n return val as AIAgentCapability[];\n })\n .describe('Agent capabilities - can be capability names (e.g. \"ai\", \"data processing\"), capability enum values, or array of either. Common values: \"ai\"/\"text\" (TEXT_GENERATION), \"data\" (DATA_INTEGRATION), \"analytics\" (TRANSACTION_ANALYTICS)'),\n tags: z\n .union([\n z.array(z.string()),\n z.string(),\n ])\n .optional()\n .transform((val) => {\n if (!val) return undefined;\n if (typeof val === 'string') {\n return NaturalLanguageMapper.parseCapabilities(val);\n }\n return NaturalLanguageMapper.parseTagsOrCapabilities(val);\n })\n .describe('Tags for the agent (alternative to capabilities) - e.g. \"ai\", \"data\", \"analytics\". Will be converted to appropriate capabilities.'),\n creator: z.string().optional().describe('Creator attribution for the agent'),\n socials: z\n .record(\n z.enum([\n 'twitter',\n 'github',\n 'discord',\n 'telegram',\n 'linkedin',\n 'youtube',\n 'website',\n 'x',\n ] as const),\n z.string()\n )\n .optional()\n .describe(\n 'Social media links (e.g., {\"twitter\": \"@handle\", \"discord\": \"username\"})'\n ),\n properties: z\n .record(z.unknown())\n .optional()\n .describe('Custom metadata properties for the agent'),\n profilePicture: z\n .union([\n z.string().describe('URL or local file path to profile picture'),\n z.object({\n url: z.string().optional(),\n path: z.string().optional(),\n filename: z.string().optional(),\n }),\n ])\n .optional()\n .describe(\n 'Optional profile picture as URL, file path, or object with url/path/filename'\n ),\n existingProfilePictureTopicId: z\n .string()\n .optional()\n .describe(\n 'Topic ID of an existing profile picture to reuse (e.g., 0.0.12345)'\n ),\n initialBalance: z\n .number()\n .positive()\n .optional()\n .describe(\n 'Optional initial HBAR balance for the new agent account (will create new account if provided)'\n ),\n userAccountId: z\n .string()\n .optional()\n .describe(\n 'Optional account ID (e.g., 0.0.12345) to use as the agent account instead of creating a new one'\n ),\n hbarFee: z\n .number()\n .positive()\n .optional()\n .describe(\n 'Optional HBAR fee amount to charge per message on the inbound topic'\n ),\n tokenFees: z\n .array(\n z.object({\n amount: z.number().positive(),\n tokenId: z.string(),\n })\n )\n .optional()\n .describe('Optional token fees to charge per message'),\n exemptAccountIds: z\n .array(z.string())\n .optional()\n .describe('Optional account IDs to exempt from fees'),\n setAsCurrent: z\n .boolean()\n .optional()\n .describe('Whether to set as current agent (default: true)'),\n persistence: z\n .object({\n prefix: z.string().optional(),\n })\n .optional()\n .describe('Optional persistence configuration'),\n});\n\nexport class RegisterAgentTool extends BaseHCS10TransactionTool<\n typeof RegisterAgentZodSchema\n> {\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. Supports natural language for capabilities/tags like \"ai\", \"data processing\", \"analytics\". Note: This tool requires multiple transactions and cannot be used in returnBytes mode. If alias is set to \"random\" or contains \"random\", a unique alias will be generated.';\n specificInputSchema = RegisterAgentZodSchema;\n private specificArgs: z.infer<typeof RegisterAgentZodSchema> | undefined;\n\n constructor(params: HCS10TransactionToolParams) {\n super(params);\n this.neverScheduleThisTool = true;\n this.requiresMultipleTransactions = true;\n }\n\n protected async callBuilderMethod(\n builder: BaseServiceBuilder,\n specificArgs: z.infer<typeof RegisterAgentZodSchema>\n ): Promise<void> {\n const hcs10Builder = builder as HCS10Builder;\n this.specificArgs = specificArgs;\n const params: RegisterAgentParams = {\n name: specificArgs.name,\n };\n\n if (specificArgs.description !== undefined) {\n params.bio = specificArgs.description;\n }\n if (specificArgs.alias !== undefined) {\n params.alias = specificArgs.alias;\n } else {\n const randomSuffix = Date.now().toString(36);\n params.alias = `${specificArgs.name}${randomSuffix}`;\n }\n if (specificArgs.type !== undefined) {\n params.type = specificArgs.type;\n }\n if (specificArgs.model !== undefined) {\n params.model = specificArgs.model;\n }\n // Handle both capabilities and tags (tags takes precedence if both provided)\n if (specificArgs.tags !== undefined) {\n params.capabilities = specificArgs.tags as AIAgentCapability[];\n } else if (specificArgs.capabilities !== undefined) {\n params.capabilities = specificArgs.capabilities as AIAgentCapability[];\n }\n if (specificArgs.creator !== undefined) {\n params.creator = specificArgs.creator;\n }\n if (specificArgs.socials !== undefined) {\n params.socials = specificArgs.socials;\n }\n if (specificArgs.properties !== undefined) {\n params.properties = specificArgs.properties;\n }\n if (specificArgs.profilePicture !== undefined) {\n if (typeof specificArgs.profilePicture === 'string') {\n params.profilePicture = specificArgs.profilePicture;\n } else {\n const profilePicObj: {\n url?: string;\n path?: string;\n filename?: string;\n } = {};\n if (specificArgs.profilePicture.url !== undefined) {\n profilePicObj.url = specificArgs.profilePicture.url;\n }\n if (specificArgs.profilePicture.path !== undefined) {\n profilePicObj.path = specificArgs.profilePicture.path;\n }\n if (specificArgs.profilePicture.filename !== undefined) {\n profilePicObj.filename = specificArgs.profilePicture.filename;\n }\n params.profilePicture = profilePicObj;\n }\n }\n if (specificArgs.existingProfilePictureTopicId !== undefined) {\n params.existingProfilePictureTopicId =\n specificArgs.existingProfilePictureTopicId;\n }\n if (specificArgs.userAccountId !== undefined) {\n params.userAccountId = specificArgs.userAccountId;\n }\n if (specificArgs.hbarFee !== undefined) {\n params.hbarFee = specificArgs.hbarFee;\n }\n if (specificArgs.tokenFees !== undefined) {\n params.tokenFees = specificArgs.tokenFees;\n }\n if (specificArgs.exemptAccountIds !== undefined) {\n params.exemptAccountIds = specificArgs.exemptAccountIds;\n }\n if (specificArgs.initialBalance !== undefined) {\n params.initialBalance = specificArgs.initialBalance;\n }\n\n await hcs10Builder.registerAgent(params);\n }\n\n /**\n * Override _call to intercept the result and save agent to state if needed\n */\n protected override async _call(\n args: z.infer<ReturnType<this['schema']>>,\n runManager?: CallbackManagerForToolRun\n ): Promise<string> {\n const result = await super._call(args, runManager);\n\n const shouldSetAsCurrent = this.specificArgs?.setAsCurrent !== false;\n\n if (this.specificArgs && shouldSetAsCurrent) {\n try {\n const parsed = JSON.parse(result);\n if (parsed.rawResult) {\n this._handleRegistrationResult(parsed.rawResult);\n } else if (parsed.state || parsed.accountId || parsed.metadata) {\n this._handleRegistrationResult(parsed);\n }\n } catch (e) {}\n }\n\n return result;\n }\n\n /**\n * Extract agent data from registration result and save to state\n */\n private _handleRegistrationResult(rawResult: any): void {\n let accountId = rawResult.accountId || rawResult.metadata?.accountId;\n\n if (!accountId && rawResult.state?.createdResources) {\n const accountResource = rawResult.state.createdResources.find(\n (r: string) => r.startsWith('account:')\n );\n if (accountResource) {\n accountId = accountResource.split(':')[1];\n }\n }\n\n const inboundTopicId =\n rawResult.inboundTopicId ||\n rawResult.metadata?.inboundTopicId ||\n rawResult.state?.inboundTopicId;\n\n const outboundTopicId =\n rawResult.outboundTopicId ||\n rawResult.metadata?.outboundTopicId ||\n rawResult.state?.outboundTopicId;\n\n const profileTopicId =\n rawResult.profileTopicId ||\n rawResult.metadata?.profileTopicId ||\n rawResult.state?.profileTopicId;\n\n const privateKey = rawResult.privateKey || rawResult.metadata?.privateKey;\n\n if (accountId && inboundTopicId && outboundTopicId && this.specificArgs) {\n const registeredAgent: RegisteredAgent = {\n name: this.specificArgs.name,\n accountId,\n inboundTopicId,\n outboundTopicId,\n profileTopicId,\n privateKey,\n };\n\n const hcs10Builder = this.getServiceBuilder() as HCS10Builder;\n const stateManager = hcs10Builder.getStateManager();\n if (stateManager) {\n stateManager.setCurrentAgent(registeredAgent);\n\n if (stateManager.persistAgentData) {\n const prefix =\n this.specificArgs.persistence?.prefix ||\n this.specificArgs.name.toUpperCase().replace(/[^A-Z0-9]/g, '_');\n stateManager\n .persistAgentData(registeredAgent, {\n type: 'env-file',\n prefix: prefix,\n })\n .catch(() => {});\n }\n }\n }\n }\n}\n","import { z } from 'zod';\nimport { BaseHCS10TransactionTool } from './base-hcs10-tools';\nimport { HCS10Builder } from '../../builders/hcs10/hcs10-builder';\nimport { HCS10TransactionToolParams } from './hcs10-tool-params';\nimport { BaseServiceBuilder } from 'hedera-agent-kit';\n\nconst SendMessageToConnectionZodSchema = z.object({\n targetIdentifier: z\n .string()\n .optional()\n .describe(\n \"The request key (e.g., 'req-1:0.0.6155171@0.0.6154875'), account ID (e.g., 0.0.12345) of the target agent, OR the connection number (e.g., '1', '2') from the 'list_connections' tool. Request key is most deterministic.\"\n ),\n connectionId: z\n .string()\n .optional()\n .describe(\n \"The connection number (e.g., '1', '2') from the 'list_connections' tool.\"\n ),\n agentId: z\n .string()\n .optional()\n .describe('The account ID (e.g., 0.0.12345) of the target agent.'),\n message: z.string().describe('The text message content to send.'),\n disableMonitoring: z.boolean().optional().default(false),\n});\n\n/**\n * A tool to send a message to an agent over an established HCS-10 connection.\n */\nexport class SendMessageToConnectionTool extends BaseHCS10TransactionTool<\n typeof SendMessageToConnectionZodSchema\n> {\n name = 'send_message_to_connection';\n description =\n \"Use this to send a message to an agent you already have an active connection with. Provide the target agent's account ID (e.g., 0.0.12345) and your message. If no active connection exists, this will fail - use initiate_connection instead to create a new connection first.\";\n specificInputSchema = SendMessageToConnectionZodSchema;\n constructor(params: HCS10TransactionToolParams) {\n super(params);\n this.requiresMultipleTransactions = true;\n this.neverScheduleThisTool = true;\n }\n\n protected async callBuilderMethod(\n builder: BaseServiceBuilder,\n specificArgs: z.infer<typeof SendMessageToConnectionZodSchema>\n ): Promise<void> {\n const hcs10Builder = builder as HCS10Builder;\n\n const targetIdentifier =\n specificArgs.targetIdentifier ||\n specificArgs.agentId ||\n specificArgs.connectionId;\n\n if (!targetIdentifier) {\n throw new Error(\n 'Either targetIdentifier, connectionId, or agentId must be provided'\n );\n }\n\n const stateManager = hcs10Builder.getStateManager();\n if (stateManager) {\n const connectionsManager = stateManager.getConnectionsManager();\n if (connectionsManager) {\n try {\n const currentAgent = stateManager.getCurrentAgent();\n if (currentAgent && currentAgent.accountId) {\n await connectionsManager.fetchConnectionData(\n currentAgent.accountId\n );\n }\n } catch (error) {\n console.debug('Could not refresh connections:', error);\n }\n }\n\n if (targetIdentifier.match(/^\\d+$/)) {\n const connections = stateManager.listConnections();\n const connectionIndex = parseInt(targetIdentifier) - 1; // Connection numbers are 1-based\n\n const establishedConnections = connections.filter(\n (conn) =>\n conn.status === 'established' &&\n !conn.isPending &&\n !conn.needsConfirmation\n );\n\n if (\n connectionIndex >= 0 &&\n connectionIndex < establishedConnections.length\n ) {\n const selectedConnection = establishedConnections[connectionIndex];\n if (selectedConnection && selectedConnection.connectionTopicId) {\n await hcs10Builder.sendMessageToConnection({\n targetIdentifier: selectedConnection.connectionTopicId,\n message: specificArgs.message,\n disableMonitoring: specificArgs.disableMonitoring,\n });\n return;\n }\n }\n }\n\n if (targetIdentifier.match(/^\\d+\\.\\d+\\.\\d+$/)) {\n const connections = stateManager.listConnections();\n const establishedConnection = connections.find(\n (conn) =>\n (conn.targetAccountId === targetIdentifier ||\n conn.targetAccountId === `0.0.${targetIdentifier}`) &&\n conn.status === 'established' &&\n !conn.isPending &&\n !conn.needsConfirmation\n );\n\n if (establishedConnection && establishedConnection.connectionTopicId) {\n await hcs10Builder.sendMessageToConnection({\n targetIdentifier: establishedConnection.connectionTopicId,\n message: specificArgs.message,\n disableMonitoring: specificArgs.disableMonitoring,\n });\n return;\n }\n }\n }\n\n await hcs10Builder.sendMessageToConnection({\n targetIdentifier: targetIdentifier,\n message: specificArgs.message,\n disableMonitoring: specificArgs.disableMonitoring,\n });\n }\n}\n","import { z } from 'zod';\nimport { BaseHCS10TransactionTool } from './base-hcs10-tools';\nimport { HCS10Builder } from '../../builders/hcs10/hcs10-builder';\nimport { HCS10TransactionToolParams } from './hcs10-tool-params';\nimport { BaseServiceBuilder } from 'hedera-agent-kit';\n\nconst InitiateConnectionZodSchema = z.object({\n targetAccountId: z\n .string()\n .describe(\n 'The Hedera account ID (e.g., 0.0.12345) of the agent you want to connect with.'\n ),\n disableMonitor: z\n .boolean()\n .optional()\n .describe(\n 'If true, does not wait for connection confirmation. Returns immediately after sending the request.'\n ),\n memo: z\n .string()\n .optional()\n .describe(\n 'Optional memo to include with the connection request (e.g., \"Hello from Alice\"). If not provided, defaults to \"true\" or \"false\" based on monitoring preference.'\n ),\n});\n\n/**\n * A tool to actively START a NEW HCS-10 connection TO a target agent.\n * Requires the target agent's account ID.\n * It retrieves their profile, sends a connection request, and optionally waits for confirmation.\n * Use this tool ONLY to actively INITIATE an OUTGOING connection.\n */\nexport class InitiateConnectionTool extends BaseHCS10TransactionTool<\n typeof InitiateConnectionZodSchema\n> {\n name = 'initiate_connection';\n description =\n 'ONLY use this to START a BRAND NEW connection to an agent you have NEVER connected to before. If you already have an active connection to this agent, use send_message_to_connection instead. This creates a new connection request and waits for acceptance.';\n specificInputSchema = InitiateConnectionZodSchema;\n constructor(params: HCS10TransactionToolParams) {\n super(params);\n this.neverScheduleThisTool = true;\n this.requiresMultipleTransactions = true;\n }\n\n protected async callBuilderMethod(\n builder: BaseServiceBuilder,\n specificArgs: z.infer<typeof InitiateConnectionZodSchema>\n ): Promise<void> {\n const hcs10Builder = builder as HCS10Builder;\n const params: {\n targetAccountId: string;\n disableMonitor?: boolean;\n memo?: string;\n } = {\n targetAccountId: specificArgs.targetAccountId,\n };\n if (specificArgs.disableMonitor !== undefined) {\n params.disableMonitor = specificArgs.disableMonitor;\n }\n if (specificArgs.memo !== undefined) {\n params.memo = specificArgs.memo;\n }\n await hcs10Builder.initiateConnection(params);\n }\n}","import { z } from 'zod';\nimport { BaseHCS10QueryTool } from './base-hcs10-tools';\nimport { HCS10QueryToolParams } from './hcs10-tool-params';\n\n/**\n * A tool to list currently active HCS-10 connections stored in the state manager.\n * Enhanced to show more details similar to moonscape's implementation.\n */\nconst ListConnectionsZodSchema = z.object({\n includeDetails: z\n .boolean()\n .optional()\n .describe(\n 'Whether to include detailed information about each connection'\n ),\n showPending: z\n .boolean()\n .optional()\n .describe('Whether to include pending connection requests'),\n});\n\nexport class ListConnectionsTool extends BaseHCS10QueryTool<\n typeof ListConnectionsZodSchema\n> {\n name = 'list_connections';\n description =\n 'Lists all active HCS-10 connections. Use this FIRST before sending messages to check if you already have an active connection to a target agent. Shows connection details and agent information for each active connection.';\n specificInputSchema = ListConnectionsZodSchema;\n constructor(params: HCS10QueryToolParams) {\n super(params);\n }\n\n protected async executeQuery(\n args: z.infer<typeof ListConnectionsZodSchema>\n ): Promise<unknown> {\n const hcs10Builder = this.hcs10Builder;\n const params: { includeDetails?: boolean; showPending?: boolean } = {};\n if (args.includeDetails !== undefined) {\n params.includeDetails = args.includeDetails;\n }\n if (args.showPending !== undefined) {\n params.showPending = args.showPending;\n }\n await hcs10Builder.listConnections(params);\n\n const result = await hcs10Builder.execute();\n\n if (result.success && 'rawResult' in result && result.rawResult) {\n const raw = result.rawResult as { formattedOutput?: string; message?: string };\n return {\n success: true,\n data: raw.formattedOutput || raw.message || 'Connections listed'\n };\n }\n\n return result;\n }\n}","import { z } from 'zod';\nimport { BaseHCS10QueryTool } from './base-hcs10-tools';\nimport { HCS10QueryToolParams } from './hcs10-tool-params';\n\n/**\n * A tool to check for new messages on an active HCS-10 connection topic,\n * or optionally fetch the latest messages regardless of timestamp.\n */\nconst CheckMessagesZodSchema = z.object({\n targetIdentifier: z\n .string()\n .describe(\n \"The account ID (e.g., 0.0.12345) of the target agent OR the connection number (e.g., '1', '2') from the 'list_connections' tool to check messages for.\"\n ),\n fetchLatest: z\n .boolean()\n .optional()\n .default(false)\n .describe(\n 'Set to true to fetch the latest messages even if they have been seen before, ignoring the last checked timestamp. Defaults to false (fetching only new messages).'\n ),\n lastMessagesCount: z\n .number()\n .int()\n .positive()\n .optional()\n .describe(\n 'When fetchLatest is true, specifies how many of the most recent messages to retrieve. Defaults to 1.'\n ),\n});\n\nexport class CheckMessagesTool extends BaseHCS10QueryTool<\n typeof CheckMessagesZodSchema\n> {\n name = 'check_messages';\n description = `Checks for and retrieves messages from an active connection.\nIdentify the target agent using their account ID (e.g., 0.0.12345) or the connection number shown in 'list_connections'.\nBy default, it only retrieves messages newer than the last check.\nUse 'fetchLatest: true' to get the most recent messages regardless of when they arrived.\nUse 'lastMessagesCount' to specify how many latest messages to retrieve (default 1 when fetchLatest is true).`;\n specificInputSchema = CheckMessagesZodSchema;\n constructor(params: HCS10QueryToolParams) {\n super(params);\n }\n\n protected async executeQuery({\n targetIdentifier,\n fetchLatest,\n lastMessagesCount,\n }: z.infer<typeof CheckMessagesZodSchema>): Promise<unknown> {\n const hcs10Builder = this.hcs10Builder;\n await hcs10Builder.checkMessages({\n targetIdentifier,\n fetchLatest,\n lastMessagesCount: lastMessagesCount || 1,\n });\n\n const result = await hcs10Builder.execute();\n\n if (result.success && 'rawResult' in result && result.rawResult) {\n const raw = result.rawResult as {\n formattedOutput?: string;\n message?: string;\n };\n return {\n success: true,\n data: raw.formattedOutput || raw.message || 'Messages checked',\n };\n }\n\n return result;\n }\n}","import { z } from 'zod';\nimport { AIAgentCapability } from '@hashgraphonline/standards-sdk';\nimport { BaseHCS10QueryTool } from './base-hcs10-tools';\nimport { HCS10QueryToolParams } from './hcs10-tool-params';\nimport { NaturalLanguageMapper } from './natural-language-mapper';\n\n/**\n * A tool to search for registered HCS-10 agents using the configured registry.\n */\nconst FindRegistrationsZodSchema = z.object({\n accountId: z\n .string()\n .optional()\n .describe(\n 'Optional: Filter registrations by a specific Hedera account ID (e.g., 0.0.12345).'\n ),\n tags: z\n .union([\n z.array(z.nativeEnum(AIAgentCapability)),\n z.array(z.string()),\n z.string(),\n ])\n .optional()\n .transform((val) => {\n if (!val) return undefined;\n if (typeof val === 'string') {\n return NaturalLanguageMapper.parseCapabilities(val);\n }\n if (Array.isArray(val) && val.length > 0 && typeof val[0] === 'string') {\n return NaturalLanguageMapper.parseTagsOrCapabilities(val);\n }\n return val as AIAgentCapability[];\n })\n .describe(\n 'Optional: Filter by capabilities/tags like \"ai\", \"data\", \"analytics\". Can be natural language terms or capability numbers.'\n ),\n});\n\nexport class FindRegistrationsTool extends BaseHCS10QueryTool<\n typeof FindRegistrationsZodSchema\n> {\n name = 'find_registrations';\n description =\n 'Searches the configured agent registry for HCS-10 agents. You can filter by account ID or tags/capabilities using natural language like \"ai\", \"data processing\", \"analytics\". Returns basic registration info.';\n specificInputSchema = FindRegistrationsZodSchema;\n constructor(params: HCS10QueryToolParams) {\n super(params);\n }\n\n protected async executeQuery({\n accountId,\n tags,\n }: z.infer<typeof FindRegistrationsZodSchema>): Promise<unknown> {\n const hcs10Builder = this.hcs10Builder;\n const params: { accountId?: string; tags?: number[] } = {};\n if (accountId) {\n params.accountId = accountId;\n }\n if (tags) {\n params.tags = tags as number[];\n }\n await hcs10Builder.findRegistrations(params);\n\n const result = await hcs10Builder.execute();\n\n if (result.success && 'rawResult' in result && result.rawResult) {\n const raw = result.rawResult as {\n formattedOutput?: string;\n message?: string;\n };\n return {\n success: true,\n data: raw.formattedOutput || raw.message || 'Registrations searched',\n };\n }\n\n return result;\n }\n}","import { z } from 'zod';\nimport { BaseHCS10TransactionTool } from './base-hcs10-tools';\nimport { HCS10Builder } from '../../builders/hcs10/hcs10-builder';\nimport { HCS10TransactionToolParams } from './hcs10-tool-params';\nimport { BaseServiceBuilder } from 'hedera-agent-kit';\n\nconst ConnectionMonitorZodSchema = z.object({\n acceptAll: z\n .boolean()\n .optional()\n .describe(\n 'Whether to automatically accept all incoming connection requests. Default is false.'\n ),\n targetAccountId: z\n .string()\n .optional()\n .describe(\n 'If provided, only accept connection requests from this specific account ID.'\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 'Array of HBAR fee amounts to charge per message (with optional collector accounts).'\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 'Array of token fee amounts and IDs to charge per message (with optional collector accounts).'\n ),\n exemptAccountIds: z\n .array(z.string())\n .optional()\n .describe(\n 'Array of account IDs to exempt from ALL fees set in this request.'\n ),\n monitorDurationSeconds: z\n .number()\n .optional()\n .describe(\n 'How long to monitor for incoming requests in seconds. Default is 120.'\n ),\n defaultCollectorAccount: z\n .string()\n .optional()\n .describe(\n 'Default account to collect fees if not specified at the fee level. Defaults to the agent account.'\n ),\n});\n\n/**\n * A tool for monitoring incoming connection requests and accepting them with optional fee settings.\n */\nexport class ConnectionMonitorTool extends BaseHCS10TransactionTool<\n typeof ConnectionMonitorZodSchema\n> {\n name = 'monitor_connections';\n description =\n 'Monitors for incoming connection requests and accepts them with optional fee settings. Use this to watch for connection requests and accept them, optionally setting HBAR or token fees on the connection. Note: When acceptAll=true, this tool requires multiple transactions and cannot be used in returnBytes mode.';\n specificInputSchema = ConnectionMonitorZodSchema;\n constructor(params: HCS10TransactionToolParams) {\n super(params);\n this.neverScheduleThisTool = true;\n this.requiresMultipleTransactions = true;\n }\n\n protected async callBuilderMethod(\n builder: BaseServiceBuilder,\n specificArgs: z.infer<typeof ConnectionMonitorZodSchema>\n ): Promise<void> {\n const hcs10Builder = builder as HCS10Builder;\n await hcs10Builder.monitorConnections({\n ...(specificArgs.acceptAll !== undefined && {\n acceptAll: specificArgs.acceptAll,\n }),\n ...(specificArgs.targetAccountId !== undefined && {\n targetAccountId: specificArgs.targetAccountId,\n }),\n ...(specificArgs.monitorDurationSeconds !== undefined && {\n monitorDurationSeconds: specificArgs.monitorDurationSeconds,\n }),\n hbarFees: (specificArgs.hbarFees || []) as Array<{\n amount: number;\n collectorAccount?: string;\n }>,\n tokenFees: (specificArgs.tokenFees || []) as Array<{\n amount: number;\n tokenId: string;\n collectorAccount?: string;\n }>,\n ...(specificArgs.exemptAccountIds !== undefined && {\n exemptAccountIds: specificArgs.exemptAccountIds,\n }),\n ...(specificArgs.defaultCollectorAccount !== undefined && {\n defaultCollectorAccount: specificArgs.defaultCollectorAccount,\n }),\n });\n }\n}\n","import { z } from 'zod';\nimport { BaseHCS10QueryTool } from './base-hcs10-tools';\nimport { HCS10QueryToolParams } from './hcs10-tool-params';\n\nconst ManageConnectionRequestsZodSchema = z.object({\n action: z\n .enum(['list', 'view', 'reject'])\n .describe(\n 'The action to perform: list all requests, view details of a specific request, or reject a request'\n ),\n requestKey: z\n .string()\n .optional()\n .describe(\n 'The unique request key to view or reject (required for view and reject actions)'\n ),\n});\n\n/**\n * A tool for managing incoming connection requests in a LangChain-compatible way.\n * This tool allows an agent to list, view details of, and reject incoming connection requests.\n */\nexport class ManageConnectionRequestsTool extends BaseHCS10QueryTool<\n typeof ManageConnectionRequestsZodSchema\n> {\n name = 'manage_connection_requests';\n description =\n 'Manage incoming connection requests. List pending requests, view details about requesting agents, and reject connection requests. Use the separate \"accept_connection_request\" tool to accept.';\n specificInputSchema = ManageConnectionRequestsZodSchema;\n constructor(params: HCS10QueryToolParams) {\n super(params);\n }\n\n protected async executeQuery({\n action,\n requestKey,\n }: z.infer<typeof ManageConnectionRequestsZodSchema>): Promise<unknown> {\n const hcs10Builder = this.hcs10Builder;\n const params: { action: 'list' | 'view' | 'reject'; requestKey?: string } =\n { action };\n if (requestKey !== undefined) {\n params.requestKey = requestKey;\n }\n await hcs10Builder.manageConnectionRequests(params);\n const result = await hcs10Builder.execute();\n return 'rawResult' in result ? result.rawResult : result;\n }\n}\n","import { z } from 'zod';\nimport { BaseHCS10TransactionTool } from './base-hcs10-tools';\nimport { HCS10Builder } from '../../builders/hcs10/hcs10-builder';\nimport { HCS10TransactionToolParams } from './hcs10-tool-params';\nimport { BaseServiceBuilder } from 'hedera-agent-kit';\n\nconst AcceptConnectionRequestZodSchema = z.object({\n requestKey: z\n .string()\n .describe(\n 'The unique request key of the specific request to accept. Use the \"manage_connection_requests\" tool with action=\"list\" first to get valid keys.'\n ),\n hbarFee: z\n .number()\n .optional()\n .describe(\n 'Optional HBAR fee amount to charge the connecting agent per message on the new connection topic.'\n ),\n exemptAccountIds: z\n .array(z.string())\n .optional()\n .describe(\n 'Optional list of account IDs to exempt from any configured fees on the new connection topic.'\n ),\n});\n\n/**\n * Tool for accepting incoming HCS-10 connection requests\n */\nexport class AcceptConnectionRequestTool extends BaseHCS10TransactionTool<\n typeof AcceptConnectionRequestZodSchema\n> {\n name = 'accept_connection_request';\n description =\n 'Accepts a pending HCS-10 connection request from another agent. Use list_unapproved_connection_requests to see pending requests.';\n specificInputSchema = AcceptConnectionRequestZodSchema;\n\n constructor(params: HCS10TransactionToolParams) {\n super(params);\n this.neverScheduleThisTool = true;\n this.requiresMultipleTransactions = true;\n }\n\n protected async callBuilderMethod(\n builder: BaseServiceBuilder,\n specificArgs: z.infer<typeof AcceptConnectionRequestZodSchema>\n ): Promise<void> {\n const hcs10Builder = builder as HCS10Builder;\n\n await hcs10Builder.acceptConnection({\n requestKey: specificArgs.requestKey,\n hbarFee: specificArgs.hbarFee,\n exemptAccountIds: specificArgs.exemptAccountIds,\n });\n }\n}","import { z } from 'zod';\nimport { BaseHCS10QueryTool } from './base-hcs10-tools';\nimport { HCS10QueryToolParams } from './hcs10-tool-params';\nconst RetrieveProfileZodSchema = z.object({\n accountId: z\n .string()\n .describe(\n 'The Hedera account ID of the agent whose profile you want to retrieve (e.g., 0.0.12345).'\n ),\n disableCache: z\n .boolean()\n .optional()\n .describe(\n 'Optional: Force refresh from the network instead of using cache.'\n ),\n});\n\n/**\n * Tool to retrieve detailed profile information for a specific HCS-10 agent\n */\nexport class RetrieveProfileTool extends BaseHCS10QueryTool<\n typeof RetrieveProfileZodSchema\n> {\n name = 'retrieve_profile';\n description =\n 'Gets the detailed profile information for a specific HCS-10 agent by their account ID. Returns name, bio, capabilities, topics, and other metadata.';\n specificInputSchema = RetrieveProfileZodSchema;\n constructor(params: HCS10QueryToolParams) {\n super(params);\n }\n\n protected async executeQuery({\n accountId,\n disableCache,\n }: z.infer<typeof RetrieveProfileZodSchema>): Promise<unknown> {\n const hcs10Builder = this.hcs10Builder;\n const params: { accountId: string; disableCache?: boolean } = {\n accountId,\n };\n if (disableCache !== undefined) {\n params.disableCache = disableCache;\n }\n await hcs10Builder.retrieveProfile(params);\n\n const result = await hcs10Builder.execute();\n\n if (result.success && 'rawResult' in result && result.rawResult) {\n const raw = result.rawResult as {\n profileDetails?: string;\n rawProfile?: unknown;\n };\n return {\n success: true,\n data: raw.profileDetails || 'Profile retrieved',\n rawProfile: raw.rawProfile,\n };\n }\n\n return result;\n }\n}","import { z } from 'zod';\nimport { BaseHCS10QueryTool } from './base-hcs10-tools';\nimport { HCS10QueryToolParams } from './hcs10-tool-params';\nconst ListUnapprovedConnectionRequestsZodSchema = z.object({});\n\n/**\n * Lists all connection requests that are not fully established\n */\nexport class ListUnapprovedConnectionRequestsTool extends BaseHCS10QueryTool<\n typeof ListUnapprovedConnectionRequestsZodSchema\n> {\n name = 'list_unapproved_connection_requests';\n description =\n 'Lists all connection requests that are not fully established, including incoming requests needing approval and outgoing requests waiting for confirmation.';\n specificInputSchema = ListUnapprovedConnectionRequestsZodSchema;\n constructor(params: HCS10QueryToolParams) {\n super(params);\n }\n\n protected async executeQuery(): Promise<unknown> {\n const hcs10Builder = this.hcs10Builder;\n await hcs10Builder.listUnapprovedConnectionRequests();\n const result = await hcs10Builder.execute();\n return 'rawResult' in result ? result.rawResult : result;\n }\n}","import {\n BaseHederaTransactionTool,\n BaseHederaQueryTool,\n BaseServiceBuilder,\n} from 'hedera-agent-kit';\nimport { HCS2Builder } from '../../builders/hcs2/hcs2-builder';\nimport {\n HCS2TransactionToolParams,\n HCS2QueryToolParams,\n} from './hcs2-tool-params';\nimport { z } from 'zod';\n\n/**\n * Base class for HCS2 transaction tools\n */\nexport abstract class BaseHCS2TransactionTool<\n T extends z.ZodObject<\n z.ZodRawShape,\n z.UnknownKeysParam,\n z.ZodTypeAny\n > = z.ZodObject<z.ZodRawShape>\n> extends BaseHederaTransactionTool<T> {\n protected hcs2Builder: HCS2Builder;\n namespace = 'hcs2' as const;\n\n constructor(params: HCS2TransactionToolParams) {\n super(params);\n this.hcs2Builder = params.hcs2Builder;\n }\n\n /**\n * Override to return the HCS2Builder\n */\n protected getServiceBuilder(): BaseServiceBuilder {\n return this.hcs2Builder;\n }\n}\n\n/**\n * Base class for HCS2 query tools\n */\nexport abstract class BaseHCS2QueryTool<\n T extends z.ZodObject<\n z.ZodRawShape,\n z.UnknownKeysParam,\n z.ZodTypeAny\n > = z.ZodObject<z.ZodRawShape>\n> extends BaseHederaQueryTool<T> {\n protected hcs2Builder: HCS2Builder;\n namespace = 'hcs2' as const;\n\n constructor(params: HCS2QueryToolParams) {\n super(params);\n this.hcs2Builder = params.hcs2Builder;\n }\n\n /**\n * Override to return the HCS2Builder\n */\n protected getServiceBuilder(): BaseServiceBuilder {\n return this.hcs2Builder;\n }\n}","import { z } from 'zod';\nimport { BaseHCS2QueryTool } from './base-hcs2-tools';\nimport { HCS2RegistryType } from '@hashgraphonline/standards-sdk';\nimport { Callbac