@hashgraphonline/standards-agent-kit 0.2.1 → 0.2.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/builders/hcs10/hcs10-builder.d.ts +4 -0
- package/dist/cjs/builders/hcs2/hcs2-builder.d.ts +50 -0
- package/dist/cjs/builders/hcs2/index.d.ts +1 -0
- package/dist/cjs/builders/index.d.ts +2 -0
- package/dist/cjs/builders/inscriber/index.d.ts +1 -0
- package/dist/cjs/builders/inscriber/inscriber-builder.d.ts +46 -0
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/cjs/tools/hcs10/FindRegistrationsTool.d.ts +4 -4
- package/dist/cjs/tools/hcs10/RegisterAgentTool.d.ts +24 -8
- package/dist/cjs/tools/hcs10/index.d.ts +1 -0
- package/dist/cjs/tools/hcs10/natural-language-mapper.d.ts +19 -0
- package/dist/cjs/tools/hcs2/CreateRegistryTool.d.ts +48 -0
- package/dist/cjs/tools/hcs2/DeleteEntryTool.d.ts +41 -0
- package/dist/cjs/tools/hcs2/MigrateRegistryTool.d.ts +47 -0
- package/dist/cjs/tools/hcs2/QueryRegistryTool.d.ts +47 -0
- package/dist/cjs/tools/hcs2/RegisterEntryTool.d.ts +47 -0
- package/dist/cjs/tools/hcs2/UpdateEntryTool.d.ts +53 -0
- package/dist/cjs/tools/hcs2/base-hcs2-tools.d.ts +28 -0
- package/dist/cjs/tools/hcs2/hcs2-tool-params.d.ts +18 -0
- package/dist/cjs/tools/hcs2/index.d.ts +8 -0
- package/dist/cjs/tools/index.d.ts +2 -0
- package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +77 -0
- package/dist/cjs/tools/inscriber/InscribeFromFileTool.d.ts +65 -0
- package/dist/cjs/tools/inscriber/InscribeFromUrlTool.d.ts +65 -0
- package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +125 -0
- package/dist/cjs/tools/inscriber/RetrieveInscriptionTool.d.ts +35 -0
- package/dist/cjs/tools/inscriber/base-inscriber-tools.d.ts +28 -0
- package/dist/cjs/tools/inscriber/index.d.ts +7 -0
- package/dist/cjs/tools/inscriber/inscriber-tool-params.d.ts +18 -0
- package/dist/es/builders/hcs10/hcs10-builder.d.ts +4 -0
- package/dist/es/builders/hcs2/hcs2-builder.d.ts +50 -0
- package/dist/es/builders/hcs2/index.d.ts +1 -0
- package/dist/es/builders/index.d.ts +2 -0
- package/dist/es/builders/inscriber/index.d.ts +1 -0
- package/dist/es/builders/inscriber/inscriber-builder.d.ts +46 -0
- package/dist/es/index.d.ts +1 -1
- package/dist/es/standards-agent-kit.es.js +50 -16
- package/dist/es/standards-agent-kit.es.js.map +1 -1
- package/dist/es/standards-agent-kit.es10.js +17 -23
- package/dist/es/standards-agent-kit.es10.js.map +1 -1
- package/dist/es/standards-agent-kit.es11.js +36 -58
- package/dist/es/standards-agent-kit.es11.js.map +1 -1
- package/dist/es/standards-agent-kit.es12.js +43 -18
- package/dist/es/standards-agent-kit.es12.js.map +1 -1
- package/dist/es/standards-agent-kit.es13.js +53 -16
- package/dist/es/standards-agent-kit.es13.js.map +1 -1
- package/dist/es/standards-agent-kit.es14.js +18 -28
- package/dist/es/standards-agent-kit.es14.js.map +1 -1
- package/dist/es/standards-agent-kit.es15.js +26 -12
- package/dist/es/standards-agent-kit.es15.js.map +1 -1
- package/dist/es/standards-agent-kit.es16.js +37 -241
- package/dist/es/standards-agent-kit.es16.js.map +1 -1
- package/dist/es/standards-agent-kit.es17.js +16 -136
- package/dist/es/standards-agent-kit.es17.js.map +1 -1
- package/dist/es/standards-agent-kit.es18.js +154 -27
- package/dist/es/standards-agent-kit.es18.js.map +1 -1
- package/dist/es/standards-agent-kit.es19.js +26 -22
- package/dist/es/standards-agent-kit.es19.js.map +1 -1
- package/dist/es/standards-agent-kit.es2.js +27 -13
- package/dist/es/standards-agent-kit.es2.js.map +1 -1
- package/dist/es/standards-agent-kit.es20.js +42 -3
- package/dist/es/standards-agent-kit.es20.js.map +1 -1
- package/dist/es/standards-agent-kit.es21.js +48 -0
- package/dist/es/standards-agent-kit.es21.js.map +1 -0
- package/dist/es/standards-agent-kit.es22.js +51 -0
- package/dist/es/standards-agent-kit.es22.js.map +1 -0
- package/dist/es/standards-agent-kit.es23.js +45 -0
- package/dist/es/standards-agent-kit.es23.js.map +1 -0
- package/dist/es/standards-agent-kit.es24.js +48 -0
- package/dist/es/standards-agent-kit.es24.js.map +1 -0
- package/dist/es/standards-agent-kit.es25.js +45 -0
- package/dist/es/standards-agent-kit.es25.js.map +1 -0
- package/dist/es/standards-agent-kit.es26.js +32 -0
- package/dist/es/standards-agent-kit.es26.js.map +1 -0
- package/dist/es/standards-agent-kit.es27.js +71 -0
- package/dist/es/standards-agent-kit.es27.js.map +1 -0
- package/dist/es/standards-agent-kit.es28.js +71 -0
- package/dist/es/standards-agent-kit.es28.js.map +1 -0
- package/dist/es/standards-agent-kit.es29.js +79 -0
- package/dist/es/standards-agent-kit.es29.js.map +1 -0
- package/dist/es/standards-agent-kit.es3.js +59 -296
- package/dist/es/standards-agent-kit.es3.js.map +1 -1
- package/dist/es/standards-agent-kit.es30.js +90 -0
- package/dist/es/standards-agent-kit.es30.js.map +1 -0
- package/dist/es/standards-agent-kit.es31.js +45 -0
- package/dist/es/standards-agent-kit.es31.js.map +1 -0
- package/dist/es/standards-agent-kit.es32.js +249 -0
- package/dist/es/standards-agent-kit.es32.js.map +1 -0
- package/dist/es/standards-agent-kit.es33.js +141 -0
- package/dist/es/standards-agent-kit.es33.js.map +1 -0
- package/dist/es/standards-agent-kit.es34.js +33 -0
- package/dist/es/standards-agent-kit.es34.js.map +1 -0
- package/dist/es/standards-agent-kit.es35.js +28 -0
- package/dist/es/standards-agent-kit.es35.js.map +1 -0
- package/dist/es/standards-agent-kit.es36.js +7 -0
- package/dist/es/standards-agent-kit.es36.js.map +1 -0
- package/dist/es/standards-agent-kit.es4.js +44 -20
- package/dist/es/standards-agent-kit.es4.js.map +1 -1
- package/dist/es/standards-agent-kit.es5.js +312 -121
- package/dist/es/standards-agent-kit.es5.js.map +1 -1
- package/dist/es/standards-agent-kit.es6.js +24 -23
- package/dist/es/standards-agent-kit.es6.js.map +1 -1
- package/dist/es/standards-agent-kit.es7.js +220 -20
- package/dist/es/standards-agent-kit.es7.js.map +1 -1
- package/dist/es/standards-agent-kit.es8.js +20 -29
- package/dist/es/standards-agent-kit.es8.js.map +1 -1
- package/dist/es/standards-agent-kit.es9.js +26 -36
- package/dist/es/standards-agent-kit.es9.js.map +1 -1
- package/dist/es/tools/hcs10/FindRegistrationsTool.d.ts +4 -4
- package/dist/es/tools/hcs10/RegisterAgentTool.d.ts +24 -8
- package/dist/es/tools/hcs10/index.d.ts +1 -0
- package/dist/es/tools/hcs10/natural-language-mapper.d.ts +19 -0
- package/dist/es/tools/hcs2/CreateRegistryTool.d.ts +48 -0
- package/dist/es/tools/hcs2/DeleteEntryTool.d.ts +41 -0
- package/dist/es/tools/hcs2/MigrateRegistryTool.d.ts +47 -0
- package/dist/es/tools/hcs2/QueryRegistryTool.d.ts +47 -0
- package/dist/es/tools/hcs2/RegisterEntryTool.d.ts +47 -0
- package/dist/es/tools/hcs2/UpdateEntryTool.d.ts +53 -0
- package/dist/es/tools/hcs2/base-hcs2-tools.d.ts +28 -0
- package/dist/es/tools/hcs2/hcs2-tool-params.d.ts +18 -0
- package/dist/es/tools/hcs2/index.d.ts +8 -0
- package/dist/es/tools/index.d.ts +2 -0
- package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +77 -0
- package/dist/es/tools/inscriber/InscribeFromFileTool.d.ts +65 -0
- package/dist/es/tools/inscriber/InscribeFromUrlTool.d.ts +65 -0
- package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +125 -0
- package/dist/es/tools/inscriber/RetrieveInscriptionTool.d.ts +35 -0
- package/dist/es/tools/inscriber/base-inscriber-tools.d.ts +28 -0
- package/dist/es/tools/inscriber/index.d.ts +7 -0
- package/dist/es/tools/inscriber/inscriber-tool-params.d.ts +18 -0
- package/dist/umd/builders/hcs10/hcs10-builder.d.ts +4 -0
- package/dist/umd/builders/hcs2/hcs2-builder.d.ts +50 -0
- package/dist/umd/builders/hcs2/index.d.ts +1 -0
- package/dist/umd/builders/index.d.ts +2 -0
- package/dist/umd/builders/inscriber/index.d.ts +1 -0
- package/dist/umd/builders/inscriber/inscriber-builder.d.ts +46 -0
- package/dist/umd/index.d.ts +1 -1
- package/dist/umd/standards-agent-kit.umd.js +1 -1
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/dist/umd/tools/hcs10/FindRegistrationsTool.d.ts +4 -4
- package/dist/umd/tools/hcs10/RegisterAgentTool.d.ts +24 -8
- package/dist/umd/tools/hcs10/index.d.ts +1 -0
- package/dist/umd/tools/hcs10/natural-language-mapper.d.ts +19 -0
- package/dist/umd/tools/hcs2/CreateRegistryTool.d.ts +48 -0
- package/dist/umd/tools/hcs2/DeleteEntryTool.d.ts +41 -0
- package/dist/umd/tools/hcs2/MigrateRegistryTool.d.ts +47 -0
- package/dist/umd/tools/hcs2/QueryRegistryTool.d.ts +47 -0
- package/dist/umd/tools/hcs2/RegisterEntryTool.d.ts +47 -0
- package/dist/umd/tools/hcs2/UpdateEntryTool.d.ts +53 -0
- package/dist/umd/tools/hcs2/base-hcs2-tools.d.ts +28 -0
- package/dist/umd/tools/hcs2/hcs2-tool-params.d.ts +18 -0
- package/dist/umd/tools/hcs2/index.d.ts +8 -0
- package/dist/umd/tools/index.d.ts +2 -0
- package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +77 -0
- package/dist/umd/tools/inscriber/InscribeFromFileTool.d.ts +65 -0
- package/dist/umd/tools/inscriber/InscribeFromUrlTool.d.ts +65 -0
- package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +125 -0
- package/dist/umd/tools/inscriber/RetrieveInscriptionTool.d.ts +35 -0
- package/dist/umd/tools/inscriber/base-inscriber-tools.d.ts +28 -0
- package/dist/umd/tools/inscriber/index.d.ts +7 -0
- package/dist/umd/tools/inscriber/inscriber-tool-params.d.ts +18 -0
- package/package.json +32 -30
- package/src/builders/hcs10/hcs10-builder.ts +37 -16
- package/src/builders/hcs2/hcs2-builder.ts +148 -0
- package/src/builders/hcs2/index.ts +1 -0
- package/src/builders/index.ts +3 -1
- package/src/builders/inscriber/index.ts +1 -0
- package/src/builders/inscriber/inscriber-builder.ts +112 -0
- package/src/index.ts +1 -1
- package/src/tools/hcs10/FindRegistrationsTool.ts +19 -4
- package/src/tools/hcs10/RegisterAgentTool.ts +147 -9
- package/src/tools/hcs10/index.ts +2 -1
- package/src/tools/hcs10/natural-language-mapper.ts +194 -0
- package/src/tools/hcs2/CreateRegistryTool.ts +63 -0
- package/src/tools/hcs2/DeleteEntryTool.ts +58 -0
- package/src/tools/hcs2/MigrateRegistryTool.ts +64 -0
- package/src/tools/hcs2/QueryRegistryTool.ts +70 -0
- package/src/tools/hcs2/RegisterEntryTool.ts +63 -0
- package/src/tools/hcs2/UpdateEntryTool.ts +68 -0
- package/src/tools/hcs2/base-hcs2-tools.ts +65 -0
- package/src/tools/hcs2/hcs2-tool-params.ts +21 -0
- package/src/tools/hcs2/index.ts +8 -0
- package/src/tools/index.ts +3 -2
- package/src/tools/inscriber/InscribeFromBufferTool.ts +105 -0
- package/src/tools/inscriber/InscribeFromFileTool.ts +93 -0
- package/src/tools/inscriber/InscribeFromUrlTool.ts +93 -0
- package/src/tools/inscriber/InscribeHashinalTool.ts +117 -0
- package/src/tools/inscriber/RetrieveInscriptionTool.ts +59 -0
- package/src/tools/inscriber/base-inscriber-tools.ts +65 -0
- package/src/tools/inscriber/index.ts +7 -0
- package/src/tools/inscriber/inscriber-tool-params.ts +21 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es2.js","sources":["../../src/builders/hcs10/hcs10-builder.ts"],"sourcesContent":["import { BaseServiceBuilder } from 'hedera-agent-kit';\nimport type { HederaAgentKit } from 'hedera-agent-kit';\nimport { PrivateKey, TransactionReceipt } from '@hashgraph/sdk';\nimport { ActiveConnection, IStateManager } from '../../state/state-types';\nimport { ExecuteResult } from '../types';\nimport {\n FeeConfigBuilderInterface,\n FeeConfigBuilder,\n HCS10Client,\n AgentBuilder,\n InboundTopicType as StandardInboundTopicType,\n AIAgentCapability as StandardAIAgentCapability,\n AgentRegistrationResult,\n ProfileResponse as SDKProfileResponse,\n HCSMessage,\n LogLevel,\n Logger as SDKLogger,\n SocialPlatform,\n HandleConnectionRequestResponse,\n Connection,\n} from '@hashgraphonline/standards-sdk';\nimport fs from 'fs';\nimport path from 'path';\nimport axios from 'axios';\n\nconst NOT_INITIALIZED_ERROR = 'ConnectionsManager not initialized';\n\n/**\n * Internal agent data for registration\n */\ninterface AgentRegistrationData {\n name: string;\n bio?: string;\n alias?: string;\n type?: 'autonomous' | 'manual';\n model?: string;\n capabilities?: number[];\n creator?: string;\n socials?: Record<string, string>;\n properties?: Record<string, unknown>;\n pfpBuffer?: Buffer;\n pfpFileName?: string;\n existingProfilePictureTopicId?: string;\n feeConfig?: FeeConfigBuilderInterface;\n}\n\n/**\n * Message response with timestamp\n */\nexport interface HCSMessageWithTimestamp extends Omit<HCSMessage, 'op'> {\n timestamp: number;\n data?: string;\n sequence_number: number;\n op?: HCSMessage['op'] | string;\n operator_id?: string;\n created?: Date;\n m?: string;\n}\n\n/**\n * Network type for HCS-10\n */\nexport type StandardNetworkType = 'mainnet' | 'testnet';\n\n/**\n * Parameters for agent registration\n */\nexport interface RegisterAgentParams {\n name: string;\n bio?: string;\n alias?: string;\n type?: 'autonomous' | 'manual';\n model?: string;\n capabilities?: number[];\n creator?: string;\n socials?: Record<string, string>;\n properties?: Record<string, unknown>;\n profilePicture?:\n | string\n | {\n url?: string;\n path?: string;\n filename?: string;\n };\n existingProfilePictureTopicId?: string;\n initialBalance?: number;\n userAccountId?: string;\n hbarFee?: number;\n tokenFees?: Array<{\n amount: number;\n tokenId: string;\n }>;\n exemptAccountIds?: string[];\n}\n\n/**\n * Parameters for initiating a connection\n */\nexport interface InitiateConnectionParams {\n targetAccountId: string;\n disableMonitor?: boolean;\n memo?: string;\n}\n\n/**\n * Parameters for accepting a connection request\n */\nexport interface AcceptConnectionParams {\n requestKey: string;\n hbarFee?: number | undefined;\n exemptAccountIds?: string[] | undefined;\n}\n\n/**\n * Parameters for sending a message\n */\nexport interface SendMessageParams {\n topicId: string;\n message: string;\n disableMonitoring?: boolean;\n}\n\n/**\n * Parameters for sending a message to a connected account\n */\nexport interface SendMessageToConnectionParams {\n targetIdentifier: string;\n message: string;\n disableMonitoring?: boolean;\n}\n\n/**\n * HCS10Builder facilitates HCS-10 protocol operations for agent communication\n * This builder incorporates all HCS10Client functionality directly\n */\nexport class HCS10Builder extends BaseServiceBuilder {\n private standardClient: HCS10Client;\n private stateManager: IStateManager | undefined;\n private executeResult?: ExecuteResult & { rawResult?: unknown };\n private useEncryption: boolean;\n private guardedRegistryBaseUrl: string;\n private network: StandardNetworkType;\n private sdkLogger: SDKLogger;\n\n constructor(\n hederaKit: HederaAgentKit,\n stateManager?: IStateManager,\n options?: {\n useEncryption?: boolean;\n registryUrl?: string;\n logLevel?: LogLevel;\n }\n ) {\n super(hederaKit);\n this.stateManager = stateManager;\n this.useEncryption = options?.useEncryption || false;\n this.guardedRegistryBaseUrl = options?.registryUrl || '';\n\n const network = this.hederaKit.client.network;\n this.network = network.toString().includes('mainnet')\n ? 'mainnet'\n : 'testnet';\n\n const operatorId = this.hederaKit.signer.getAccountId().toString();\n const operatorPrivateKey = this.hederaKit.signer?.getOperatorPrivateKey()\n ? this.hederaKit.signer.getOperatorPrivateKey().toStringRaw()\n : '';\n\n this.sdkLogger = new SDKLogger({\n module: 'HCS10Builder',\n level: options?.logLevel || 'info',\n });\n\n this.standardClient = new HCS10Client({\n network: this.network,\n operatorId: operatorId,\n operatorPrivateKey: operatorPrivateKey,\n guardedRegistryBaseUrl: this.guardedRegistryBaseUrl,\n logLevel: options?.logLevel || 'info',\n });\n\n if (this.stateManager) {\n this.stateManager.initializeConnectionsManager(this.standardClient);\n }\n }\n\n /**\n * Get the operator account ID\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 /**\n * Get the network type\n */\n public getNetwork(): StandardNetworkType {\n return this.network;\n }\n\n /**\n * Get account and signer information\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 * Get the inbound topic ID for the current operator\n */\n public async getInboundTopicId(): Promise<string> {\n try {\n const operatorId = this.getOperatorId();\n this.logger.info(\n `[HCS10Builder] 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 `[HCS10Builder] 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 `[HCS10Builder] 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 * Get agent profile\n */\n public async getAgentProfile(accountId: string): Promise<SDKProfileResponse> {\n try {\n return await this.standardClient.retrieveProfile(accountId);\n } catch (error) {\n this.logger.error(\n `[HCS10Builder] Error retrieving agent profile for account ${accountId}:`,\n error\n );\n throw error;\n }\n }\n\n /**\n * Submit connection request\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 * Handle connection request\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\n if (\n result &&\n result.connectionTopicId &&\n typeof result.connectionTopicId === 'object' &&\n 'toString' in result.connectionTopicId\n ) {\n result.connectionTopicId = (\n result.connectionTopicId as { toString(): string }\n ).toString();\n }\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 * Send message to a topic\n */\n public async sendMessage(\n topicId: string,\n data: string,\n memo?: string\n ): Promise<{\n sequenceNumber: number | undefined;\n receipt: TransactionReceipt;\n transactionId: string | undefined;\n }> {\n if (topicId && typeof topicId === 'object' && 'toString' in topicId) {\n topicId = (topicId as unknown as { toString: () => string })?.toString();\n }\n\n if (!topicId || typeof topicId !== 'string') {\n throw new Error(\n `Invalid topic ID provided to sendMessage: ${JSON.stringify(topicId)}`\n );\n }\n\n try {\n const messageResponse = await this.standardClient.sendMessage(\n topicId,\n data,\n memo,\n undefined\n );\n return {\n sequenceNumber: messageResponse.topicSequenceNumber?.toNumber(),\n receipt: messageResponse as unknown as TransactionReceipt,\n transactionId:\n 'transactionId' in messageResponse\n ? (\n messageResponse as { transactionId?: { toString(): string } }\n ).transactionId?.toString()\n : undefined,\n };\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 * Get messages from a topic\n */\n public async getMessages(topicId: string): Promise<{\n messages: HCSMessageWithTimestamp[];\n }> {\n if (topicId && typeof topicId === 'object' && 'toString' in topicId) {\n topicId = (topicId as unknown as { toString: () => string })?.toString();\n }\n\n if (!topicId || typeof topicId !== 'string') {\n throw new Error(\n `Invalid topic ID provided to getMessages: ${JSON.stringify(topicId)}`\n );\n }\n\n try {\n const result = await this.standardClient.getMessages(topicId);\n\n const mappedMessages: HCSMessageWithTimestamp[] = 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 p: 'hcs-10' as const,\n } as HCSMessageWithTimestamp;\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 /**\n * Get message stream from a topic\n */\n public async getMessageStream(topicId: string): Promise<{\n messages: HCSMessage[];\n }> {\n if (topicId && typeof topicId === 'object' && 'toString' in topicId) {\n topicId = (topicId as unknown as { toString: () => string })?.toString();\n }\n\n if (!topicId || typeof topicId !== 'string') {\n throw new Error(\n `Invalid topic ID provided to getMessageStream: ${JSON.stringify(\n topicId\n )}`\n );\n }\n\n return this.standardClient.getMessageStream(topicId) as Promise<{ messages: HCSMessage[] }>;\n }\n\n /**\n * Get 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 * Get the standard client instance (for compatibility)\n */\n public getStandardClient(): HCS10Client {\n return this.standardClient;\n }\n\n /**\n * Load profile picture from URL or file path\n */\n private async loadProfilePicture(\n profilePicture: string | { url?: string; path?: string; filename?: string }\n ): Promise<{ buffer: Buffer; filename: string } | null> {\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 this.logger.info(\n `Loading profile picture from URL: ${profilePicture}`\n );\n const response = await axios.get(profilePicture, {\n responseType: 'arraybuffer',\n });\n const buffer = Buffer.from(response.data);\n const urlPathname = new URL(profilePicture).pathname;\n const filename = path.basename(urlPathname) || 'profile.png';\n return { buffer, filename };\n } else {\n if (!fs.existsSync(profilePicture)) {\n this.logger.warn(\n `Profile picture file not found: ${profilePicture}`\n );\n return null;\n }\n this.logger.info(\n `Loading profile picture from file: ${profilePicture}`\n );\n const buffer = fs.readFileSync(profilePicture);\n const filename = path.basename(profilePicture);\n return { buffer, filename };\n }\n } else if (profilePicture.url) {\n this.logger.info(\n `Loading profile picture from URL: ${profilePicture.url}`\n );\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 return { buffer, filename };\n } else if (profilePicture.path) {\n if (!fs.existsSync(profilePicture.path)) {\n this.logger.warn(\n `Profile picture file not found: ${profilePicture.path}`\n );\n return null;\n }\n this.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 return { buffer, filename };\n }\n\n return null;\n } catch (error) {\n this.logger.error('Failed to load profile picture:', error);\n return null;\n }\n }\n\n /**\n * Create and register an agent\n */\n private async createAndRegisterAgent(\n data: AgentRegistrationData\n ): Promise<AgentRegistrationResult> {\n const builder = new AgentBuilder()\n .setName(data.name)\n .setBio(data.bio || '')\n .setCapabilities(\n data.capabilities || [StandardAIAgentCapability.TEXT_GENERATION]\n )\n .setType(data.type || 'autonomous')\n .setModel(data.model || 'agent-model-2024')\n .setNetwork(this.getNetwork())\n .setInboundTopicType(StandardInboundTopicType.PUBLIC);\n\n if (data.alias) {\n builder.setAlias(data.alias);\n }\n\n if (data.creator) {\n builder.setCreator(data.creator);\n }\n\n if (data?.feeConfig) {\n builder.setInboundTopicType(StandardInboundTopicType.FEE_BASED);\n builder.setFeeConfig(data.feeConfig);\n }\n\n if (data.existingProfilePictureTopicId) {\n builder.setExistingProfilePicture(data.existingProfilePictureTopicId);\n } else if (data.pfpBuffer && data.pfpFileName) {\n if (data.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: ${data.pfpFileName} (${data.pfpBuffer.byteLength} bytes)`\n );\n builder.setProfilePicture(data.pfpBuffer, data.pfpFileName);\n }\n } else {\n this.logger.warn(\n 'Profile picture not provided. Agent creation might fail if required by the underlying SDK builder.'\n );\n }\n\n if (data.socials) {\n Object.entries(data.socials).forEach(([platform, handle]) => {\n builder.addSocial(platform as SocialPlatform, handle);\n });\n }\n\n if (data.properties) {\n Object.entries(data.properties).forEach(([key, value]) => {\n builder.addProperty(key, value);\n });\n }\n\n try {\n const hasFees = Boolean(data?.feeConfig);\n const result = await this.standardClient.createAndRegisterAgent(builder, {\n initialBalance: hasFees ? 50 : 10,\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 * Register a new HCS-10 agent\n * Note: This performs multiple transactions and requires directExecution mode\n */\n public async registerAgent(params: RegisterAgentParams): Promise<this> {\n this.clearNotes();\n\n if (this.hederaKit.operationalMode === 'returnBytes') {\n throw new Error(\n 'Agent registration requires multiple transactions and cannot be performed in returnBytes mode. ' +\n 'Please use autonomous mode.'\n );\n }\n\n try {\n let profilePictureData: { buffer: Buffer; filename: string } | null = null;\n if (params.profilePicture) {\n profilePictureData = await this.loadProfilePicture(\n params.profilePicture\n );\n }\n\n const registrationData: AgentRegistrationData = {\n name: params.name,\n ...(params.bio !== undefined && { bio: params.bio }),\n ...(params.alias !== undefined && { alias: params.alias }),\n ...(params.type !== undefined && { type: params.type }),\n ...(params.model !== undefined && { model: params.model }),\n ...(params.capabilities !== undefined && {\n capabilities: params.capabilities,\n }),\n ...(params.creator !== undefined && { creator: params.creator }),\n ...(params.socials !== undefined && { socials: params.socials }),\n ...(params.properties !== undefined && {\n properties: params.properties,\n }),\n ...(params.existingProfilePictureTopicId !== undefined && {\n existingProfilePictureTopicId: params.existingProfilePictureTopicId,\n }),\n ...(profilePictureData?.buffer !== undefined && {\n pfpBuffer: profilePictureData.buffer,\n }),\n ...(profilePictureData?.filename !== undefined && {\n pfpFileName: profilePictureData.filename,\n }),\n };\n\n if (params.hbarFee && params.hbarFee > 0) {\n const feeConfigBuilder = new FeeConfigBuilder({\n network: this.network,\n logger: this.sdkLogger,\n });\n\n const { accountId: collectorAccountId } = this.getAccountAndSigner();\n if (!collectorAccountId) {\n throw new Error('Could not determine account ID for fee collection.');\n }\n this.addNote(\n `Setting the operator account (${collectorAccountId}) as the fee collector since no specific collector was provided.`\n );\n\n const effectiveExemptIds =\n params.exemptAccountIds?.filter(\n (id: string) => id !== collectorAccountId && id.startsWith('0.0')\n ) || [];\n\n registrationData.feeConfig = feeConfigBuilder.addHbarFee(\n params.hbarFee,\n collectorAccountId,\n effectiveExemptIds\n );\n }\n\n const result = await this.createAndRegisterAgent(registrationData);\n\n this.executeResult = {\n success: true,\n transactionId: result.transactionId,\n receipt: undefined,\n scheduleId: undefined,\n rawResult: {\n ...result,\n name: params.name,\n accountId:\n result?.metadata?.accountId ||\n result.state?.agentMetadata?.accountId,\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n } catch (error) {\n this.logger.error('Failed to register agent:', error);\n throw error;\n }\n\n return this;\n }\n\n /**\n * Initiate a connection to another agent\n */\n public async initiateConnection(\n params: InitiateConnectionParams\n ): Promise<this> {\n this.clearNotes();\n\n try {\n const targetProfile = await this.getAgentProfile(params.targetAccountId);\n\n if (!targetProfile.success || !targetProfile.topicInfo?.inboundTopic) {\n throw new Error(\n `Could not retrieve inbound topic for target account ${params.targetAccountId}`\n );\n }\n\n const targetInboundTopicId = targetProfile.topicInfo.inboundTopic;\n let memo: string;\n if (params.memo !== undefined) {\n memo = params.memo;\n } else {\n memo = params.disableMonitor ? 'false' : 'true';\n this.addNote(\n `No custom memo was provided. Using default memo '${memo}' based on monitoring preference.`\n );\n }\n if (!params.disableMonitor) {\n this.addNote(\n `Monitoring will be enabled for this connection request as disableMonitor was not specified.`\n );\n }\n\n const result = await this.submitConnectionRequest(\n targetInboundTopicId,\n memo\n );\n\n this.executeResult = {\n success: true,\n transactionId:\n 'transactionId' in result\n ? (\n result as { transactionId?: { toString(): string } }\n ).transactionId?.toString()\n : undefined,\n receipt: result,\n scheduleId: undefined,\n rawResult: {\n targetAccountId: params.targetAccountId,\n targetInboundTopicId,\n connectionRequestSent: true,\n monitoringEnabled: !params.disableMonitor,\n ...result,\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n } catch (error) {\n this.logger.error('Failed to initiate connection:', error);\n throw error;\n }\n\n return this;\n }\n\n /**\n * Accept a connection request\n * Note: This performs multiple transactions and requires directExecution mode\n */\n public async acceptConnection(params: AcceptConnectionParams): Promise<this> {\n this.clearNotes();\n\n if (this.hederaKit.operationalMode === 'returnBytes') {\n throw new Error(\n 'Accepting connections requires multiple transactions and cannot be performed in returnBytes mode. ' +\n 'Please use autonomous mode.'\n );\n }\n\n try {\n const currentAgent = this.stateManager?.getCurrentAgent();\n if (!currentAgent) {\n throw new Error(\n 'Cannot accept connection request. No agent is currently active. Please register or select an agent first.'\n );\n }\n\n const connectionsManager = this.stateManager?.getConnectionsManager();\n if (!connectionsManager) {\n throw new Error(NOT_INITIALIZED_ERROR);\n }\n\n await connectionsManager.fetchConnectionData(currentAgent.accountId);\n\n const allRequests = [\n ...connectionsManager.getPendingRequests(),\n ...connectionsManager.getConnectionsNeedingConfirmation(),\n ];\n\n const request = allRequests.find(\n (r) =>\n r.uniqueRequestKey === params.requestKey ||\n r.connectionRequestId?.toString() === params.requestKey ||\n r.inboundRequestId?.toString() === params.requestKey\n );\n\n if (!request) {\n throw new Error(\n `Request with key ${params.requestKey} not found or no longer pending.`\n );\n }\n\n if (!request.needsConfirmation || !request.inboundRequestId) {\n throw new Error(\n `Request with key ${params.requestKey} is not an inbound request that can be accepted.`\n );\n }\n\n const targetAccountId = request.targetAccountId;\n const inboundRequestId = request.inboundRequestId;\n\n let feeConfig: FeeConfigBuilderInterface | undefined;\n\n if (params.hbarFee && params.hbarFee > 0) {\n const feeConfigBuilder = new FeeConfigBuilder({\n network: this.network,\n logger: this.sdkLogger,\n });\n\n const { accountId: collectorAccountId } = this.getAccountAndSigner();\n if (!collectorAccountId) {\n throw new Error('Could not determine account ID for fee collection.');\n }\n this.addNote(\n `Setting the operator account (${collectorAccountId}) as the fee collector since no specific collector was provided.`\n );\n\n const effectiveExemptIds =\n params.exemptAccountIds?.filter(\n (id: string) => id !== collectorAccountId && id.startsWith('0.0')\n ) || [];\n\n feeConfig = feeConfigBuilder.addHbarFee(\n params.hbarFee,\n collectorAccountId,\n effectiveExemptIds\n );\n }\n\n const inboundTopicId = await this.getInboundTopicId();\n const confirmationResult = await this.handleConnectionRequest(\n inboundTopicId,\n targetAccountId,\n inboundRequestId,\n feeConfig\n );\n\n let connectionTopicId = confirmationResult?.connectionTopicId;\n\n if (\n connectionTopicId &&\n typeof connectionTopicId === 'object' &&\n 'toString' in connectionTopicId\n ) {\n connectionTopicId = (\n connectionTopicId as unknown as { toString: () => string }\n )?.toString();\n }\n\n if (!connectionTopicId || typeof connectionTopicId !== 'string') {\n throw new Error(\n `Failed to create connection topic. Got: ${JSON.stringify(\n connectionTopicId\n )}`\n );\n }\n\n if (this.stateManager) {\n const targetAgentName =\n request.targetAgentName || `Agent ${targetAccountId}`;\n if (!request.targetAgentName) {\n this.addNote(\n `No agent name was provided in the connection request, using default name 'Agent ${targetAccountId}'.`\n );\n }\n\n let targetInboundTopicId = request.targetInboundTopicId || '';\n if (!targetInboundTopicId) {\n try {\n const targetProfile = await this.getAgentProfile(targetAccountId);\n if (\n targetProfile.success &&\n targetProfile.topicInfo?.inboundTopic\n ) {\n targetInboundTopicId = targetProfile.topicInfo.inboundTopic;\n }\n } catch (profileError) {\n this.logger.warn(\n `Could not fetch profile for ${targetAccountId}:`,\n profileError\n );\n }\n }\n\n const newConnection = {\n connectionId: `conn-${Date.now()}`,\n targetAccountId: targetAccountId,\n targetAgentName: targetAgentName,\n targetInboundTopicId: targetInboundTopicId,\n connectionTopicId: connectionTopicId,\n status: 'established' as const,\n created: new Date(),\n };\n this.stateManager.addActiveConnection(newConnection);\n\n connectionsManager.markConnectionRequestProcessed(\n request.targetInboundTopicId || '',\n inboundRequestId\n );\n }\n\n this.executeResult = {\n success: true,\n transactionId: undefined,\n receipt: undefined,\n scheduleId: undefined,\n rawResult: {\n targetAccountId,\n connectionTopicId,\n feeConfigured: !!params.hbarFee,\n hbarFee: params.hbarFee || 0,\n confirmationResult,\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n } catch (error) {\n this.logger.error('Failed to accept connection:', error);\n throw error;\n }\n\n return this;\n }\n\n /**\n * Send a message using HCS (for operations that need direct topic access)\n */\n public async sendHCS10Message(params: SendMessageParams): Promise<this> {\n this.clearNotes();\n\n try {\n const result = await this.sendMessage(params.topicId, params.message);\n\n this.executeResult = {\n success: true,\n transactionId: result.transactionId,\n receipt: result.receipt,\n scheduleId: undefined,\n rawResult: result,\n } as unknown as ExecuteResult & { rawResult?: unknown };\n\n this.addNote(`Message sent to topic ${params.topicId}.`);\n } catch (error) {\n this.logger.error('Failed to send message:', error);\n throw error;\n }\n\n return this;\n }\n\n /**\n * Send a message to a connected account with optional response monitoring\n */\n public async sendMessageToConnection(\n params: SendMessageToConnectionParams\n ): Promise<this> {\n this.clearNotes();\n\n if (!this.stateManager) {\n throw new Error(\n 'StateManager is required to send messages to connections'\n );\n }\n\n try {\n const currentAgent = this.stateManager.getCurrentAgent();\n if (!currentAgent) {\n throw new Error(\n 'Cannot send message. No agent is currently active. Please register or select an agent first.'\n );\n }\n\n let connection: ActiveConnection | undefined;\n\n if (params.targetIdentifier.includes('@')) {\n const parts = params.targetIdentifier.split('@');\n if (parts.length === 2) {\n const accountId = parts[1];\n connection = this.stateManager.getConnectionByIdentifier(accountId);\n\n if (!connection) {\n this.addNote(\n `Could not find connection using request key '${params.targetIdentifier}', extracted account ID '${accountId}'.`\n );\n }\n }\n }\n\n if (!connection) {\n connection = this.stateManager.getConnectionByIdentifier(\n params.targetIdentifier\n );\n }\n\n if (!connection) {\n const connections = this.stateManager.listConnections();\n const availableIds = connections.map(\n (c) => `${c.targetAccountId} (${c.connectionTopicId})`\n );\n throw new Error(\n `Connection not found for identifier: ${\n params.targetIdentifier\n }. Available connections: ${\n availableIds.join(', ') || 'none'\n }. Use 'list_connections' to see details.`\n );\n }\n\n let connectionTopicId = connection.connectionTopicId;\n if (\n connectionTopicId &&\n typeof connectionTopicId === 'object' &&\n 'toString' in connectionTopicId\n ) {\n connectionTopicId = (\n connectionTopicId as unknown as { toString: () => string }\n )?.toString();\n }\n\n if (!connectionTopicId || typeof connectionTopicId !== 'string') {\n throw new Error(\n `Invalid connection topic ID for ${\n connection.targetAccountId\n }: ${JSON.stringify(\n connectionTopicId\n )} (type: ${typeof connectionTopicId})`\n );\n }\n\n const targetAgentName = connection.targetAgentName;\n\n const operatorId = `${currentAgent.inboundTopicId}@${currentAgent.accountId}`;\n\n const messageResult = await this.sendMessage(\n connectionTopicId,\n params.message,\n `Agent message from ${currentAgent.name}`\n );\n\n if (!messageResult.sequenceNumber) {\n throw new Error('Failed to send message');\n }\n\n let reply: string | null = null;\n if (!params.disableMonitoring) {\n reply = await this.monitorResponses(\n connectionTopicId,\n operatorId,\n messageResult.sequenceNumber\n );\n } else {\n this.addNote(\n `Message sent successfully. Response monitoring was disabled.`\n );\n }\n\n this.executeResult = {\n success: true,\n transactionId: messageResult.transactionId,\n receipt: messageResult.receipt,\n scheduleId: undefined,\n rawResult: {\n targetAgentName,\n targetAccountId: connection.targetAccountId,\n connectionTopicId,\n sequenceNumber: messageResult.sequenceNumber,\n reply,\n monitoringEnabled: !params.disableMonitoring,\n message: params.message,\n messageResult,\n },\n };\n } catch (error) {\n this.logger.error('Failed to send message to connection:', error);\n throw error;\n }\n\n return this;\n }\n\n /**\n * Monitor responses on a topic after sending a message\n */\n private async monitorResponses(\n topicId: string,\n operatorId: string,\n sequenceNumber: number\n ): Promise<string | null> {\n const maxAttempts = 30;\n let attempts = 0;\n\n while (attempts < maxAttempts) {\n try {\n const messages = await this.getMessageStream(topicId);\n\n for (const message of messages.messages) {\n if (\n message.sequence_number < sequenceNumber ||\n message.operator_id === operatorId\n ) {\n continue;\n }\n const content = await this.getMessageContent(message.data || '');\n return content;\n }\n } catch (error) {\n this.logger.error(`Error monitoring responses: ${error}`);\n }\n await new Promise((resolve) => setTimeout(resolve, 4000));\n attempts++;\n }\n return null;\n }\n\n /**\n * Start passive monitoring for incoming connection requests\n * This method monitors continuously in the background\n */\n public async startPassiveConnectionMonitoring(): Promise<this> {\n this.clearNotes();\n\n if (!this.stateManager) {\n throw new Error('StateManager is required for passive monitoring');\n }\n\n const inboundTopicId = await this.getInboundTopicId();\n this.logger.info(\n `Starting passive connection monitoring on topic ${inboundTopicId}...`\n );\n\n this.executeResult = {\n success: true,\n transactionId: undefined,\n receipt: undefined,\n scheduleId: undefined,\n rawResult: {\n inboundTopicId,\n message: `Started monitoring inbound topic ${inboundTopicId} for connection requests in the background.`,\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n\n return this;\n }\n\n /**\n * Monitor for incoming connection requests\n */\n public async monitorConnections(params: {\n acceptAll?: boolean;\n targetAccountId?: string;\n monitorDurationSeconds?: number;\n hbarFees?: Array<{ amount: number; collectorAccount?: string }>;\n tokenFees?: Array<{\n amount: number;\n tokenId: string;\n collectorAccount?: string;\n }>;\n exemptAccountIds?: string[];\n defaultCollectorAccount?: string;\n }): Promise<this> {\n this.clearNotes();\n\n const {\n acceptAll = false,\n targetAccountId,\n monitorDurationSeconds = 120,\n hbarFees = [],\n tokenFees = [],\n exemptAccountIds = [],\n defaultCollectorAccount,\n } = params;\n\n if (!this.stateManager) {\n throw new Error('StateManager is required for connection monitoring');\n }\n\n const currentAgent = this.stateManager.getCurrentAgent();\n if (!currentAgent) {\n throw new Error(\n 'Cannot monitor for connections. No agent is currently active.'\n );\n }\n\n const inboundTopicId = await this.getInboundTopicId();\n const endTime = Date.now() + monitorDurationSeconds * 1000;\n const pollIntervalMs = 3000;\n let connectionRequestsFound = 0;\n let acceptedConnections = 0;\n const processedRequestIds = new Set<number>();\n\n while (Date.now() < endTime) {\n try {\n const messagesResult = await this.getMessages(inboundTopicId);\n const connectionRequests = messagesResult.messages.filter(\n (msg) =>\n msg.op === 'connection_request' &&\n typeof msg.sequence_number === 'number'\n );\n\n for (const request of connectionRequests) {\n const connectionRequestId = request.sequence_number;\n if (\n !connectionRequestId ||\n processedRequestIds.has(connectionRequestId)\n ) {\n continue;\n }\n\n const requestingAccountId = request.operator_id?.split('@')[1];\n if (!requestingAccountId) {\n continue;\n }\n\n connectionRequestsFound++;\n\n if (targetAccountId && requestingAccountId !== targetAccountId) {\n this.logger.info(\n `Skipping request from ${requestingAccountId} (not target account)`\n );\n continue;\n }\n\n if (acceptAll || targetAccountId === requestingAccountId) {\n this.logger.info(\n `Accepting connection request from ${requestingAccountId}`\n );\n\n let feeConfig;\n if (hbarFees.length > 0 || tokenFees.length > 0) {\n const builder = new FeeConfigBuilder({\n network: this.network,\n logger: this.sdkLogger,\n });\n\n for (const fee of hbarFees) {\n const collectorAccount =\n fee.collectorAccount ||\n defaultCollectorAccount ||\n this.getOperatorId();\n builder.addHbarFee(\n fee.amount,\n collectorAccount,\n exemptAccountIds\n );\n }\n\n for (const fee of tokenFees) {\n const collectorAccount =\n fee.collectorAccount ||\n defaultCollectorAccount ||\n this.getOperatorId();\n builder.addTokenFee(\n fee.amount,\n fee.tokenId,\n collectorAccount,\n undefined,\n exemptAccountIds\n );\n }\n\n feeConfig = builder;\n }\n\n await this.handleConnectionRequest(\n inboundTopicId,\n requestingAccountId,\n connectionRequestId,\n feeConfig\n );\n\n processedRequestIds.add(connectionRequestId);\n acceptedConnections++;\n }\n }\n } catch (error) {\n this.logger.error('Error during connection monitoring:', error);\n }\n\n await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));\n }\n\n this.executeResult = {\n success: true,\n transactionId: undefined,\n receipt: undefined,\n scheduleId: undefined,\n rawResult: {\n connectionRequestsFound,\n acceptedConnections,\n monitorDurationSeconds,\n processedRequestIds: Array.from(processedRequestIds),\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n\n this.addNote(\n `Monitoring completed. Found ${connectionRequestsFound} requests, accepted ${acceptedConnections}.`\n );\n\n return this;\n }\n\n /**\n * Manage connection requests (list, view, or reject)\n */\n public async manageConnectionRequests(params: {\n action: 'list' | 'view' | 'reject';\n requestKey?: string;\n }): Promise<this> {\n this.clearNotes();\n\n if (!this.stateManager) {\n throw new Error(\n 'StateManager is required for managing connection requests'\n );\n }\n\n const currentAgent = this.stateManager.getCurrentAgent();\n if (!currentAgent) {\n throw new Error(\n 'Cannot manage connection requests. No agent is currently active.'\n );\n }\n\n const connectionsManager = this.stateManager.getConnectionsManager();\n if (!connectionsManager) {\n throw new Error(NOT_INITIALIZED_ERROR);\n }\n\n try {\n const { accountId } = this.getAccountAndSigner();\n await connectionsManager.fetchConnectionData(accountId);\n\n const pendingRequests = connectionsManager.getPendingRequests();\n const needsConfirmation =\n connectionsManager.getConnectionsNeedingConfirmation();\n const allRequests = [...pendingRequests, ...needsConfirmation];\n\n switch (params.action) {\n case 'list':\n this.executeResult = {\n success: true,\n transactionId: undefined,\n receipt: undefined,\n scheduleId: undefined,\n rawResult: {\n requests: allRequests.map((request, index) => ({\n index: index + 1,\n type: request.needsConfirmation ? 'incoming' : 'outgoing',\n requestKey:\n request.uniqueRequestKey ||\n `${\n request.connectionRequestId ||\n request.inboundRequestId ||\n 'unknown'\n }`,\n targetAccountId: request.targetAccountId,\n targetAgentName:\n request.targetAgentName || `Agent ${request.targetAccountId}`,\n created: request.created.toISOString(),\n memo: request.memo,\n bio: request.profileInfo?.bio,\n })),\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n break;\n\n case 'view': {\n if (!params.requestKey) {\n throw new Error('Request key is required for viewing a request');\n }\n const viewRequest = allRequests.find(\n (r) =>\n r.uniqueRequestKey === params.requestKey ||\n r.connectionRequestId?.toString() === params.requestKey ||\n r.inboundRequestId?.toString() === params.requestKey\n );\n if (!viewRequest) {\n throw new Error(`Request with key ${params.requestKey} not found`);\n }\n this.executeResult = {\n success: true,\n transactionId: undefined,\n receipt: undefined,\n scheduleId: undefined,\n rawResult: {\n request: {\n type: viewRequest.needsConfirmation ? 'incoming' : 'outgoing',\n requestKey:\n viewRequest.uniqueRequestKey ||\n `${\n viewRequest.connectionRequestId ||\n viewRequest.inboundRequestId ||\n 'unknown'\n }`,\n targetAccountId: viewRequest.targetAccountId,\n targetAgentName:\n viewRequest.targetAgentName ||\n `Agent ${viewRequest.targetAccountId}`,\n created: viewRequest.created.toISOString(),\n memo: viewRequest.memo,\n profileInfo: viewRequest.profileInfo,\n },\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n break;\n }\n\n case 'reject': {\n if (!params.requestKey) {\n throw new Error('Request key is required for rejecting a request');\n }\n const rejectRequest = allRequests.find(\n (r) =>\n r.uniqueRequestKey === params.requestKey ||\n r.connectionRequestId?.toString() === params.requestKey ||\n r.inboundRequestId?.toString() === params.requestKey\n );\n if (!rejectRequest) {\n throw new Error(`Request with key ${params.requestKey} not found`);\n }\n if (rejectRequest.inboundRequestId) {\n connectionsManager.markConnectionRequestProcessed(\n rejectRequest.targetInboundTopicId || '',\n rejectRequest.inboundRequestId\n );\n } else if (rejectRequest.connectionRequestId) {\n connectionsManager.markConnectionRequestProcessed(\n rejectRequest.originTopicId || '',\n rejectRequest.connectionRequestId\n );\n }\n this.executeResult = {\n success: true,\n transactionId: undefined,\n receipt: undefined,\n scheduleId: undefined,\n rawResult: {\n rejectedRequest: {\n requestKey: params.requestKey,\n targetAccountId: rejectRequest.targetAccountId,\n targetAgentName:\n rejectRequest.targetAgentName ||\n `Agent ${rejectRequest.targetAccountId}`,\n },\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n break;\n }\n }\n } catch (error) {\n this.logger.error('Failed to manage connection requests:', error);\n throw error;\n }\n\n return this;\n }\n\n /**\n * List unapproved connection requests\n */\n public async listUnapprovedConnectionRequests(): Promise<this> {\n this.clearNotes();\n\n if (!this.stateManager) {\n throw new Error(\n 'StateManager is required for listing connection requests'\n );\n }\n\n const currentAgent = this.stateManager.getCurrentAgent();\n if (!currentAgent) {\n throw new Error(\n 'Cannot list connection requests. No agent is currently active.'\n );\n }\n\n try {\n const inboundTopicId = await this.getInboundTopicId();\n const messages = await this.getMessages(inboundTopicId);\n\n const unapprovedRequests = messages.messages\n .filter((msg): msg is HCSMessageWithTimestamp & { op: string } => msg.op === 'connection_request')\n .map((msg) => ({\n requestId: msg.sequence_number,\n fromAccountId: msg.operator_id?.split('@')[1] || 'unknown',\n timestamp: msg.timestamp || new Date(msg?.created || '').getTime(),\n memo: msg.m || '',\n data: msg.data,\n }))\n .filter((req): req is typeof req & { fromAccountId: string } => req.fromAccountId !== 'unknown');\n\n this.executeResult = {\n success: true,\n transactionId: undefined,\n receipt: undefined,\n scheduleId: undefined,\n rawResult: {\n requests: unapprovedRequests,\n count: unapprovedRequests.length,\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n\n if (unapprovedRequests.length === 0) {\n this.addNote('No unapproved connection requests found.');\n } else {\n this.addNote(\n `Found ${unapprovedRequests.length} unapproved connection request(s).`\n );\n }\n } catch (error) {\n this.logger.error(\n 'Failed to list unapproved connection requests:',\n error\n );\n throw error;\n }\n\n return this;\n }\n\n /**\n * List connections with enhanced details\n */\n public async listConnections(\n params: {\n includeDetails?: boolean;\n showPending?: boolean;\n } = {}\n ): Promise<this> {\n this.clearNotes();\n\n if (!this.stateManager) {\n throw new Error('StateManager is required to list connections');\n }\n\n const includeDetails = params.includeDetails ?? true;\n const showPending = params.showPending ?? true;\n\n try {\n const connections = await this.getEnhancedConnections();\n\n if (connections.length === 0) {\n this.executeResult = {\n success: true,\n rawResult: {\n connections: [],\n message: 'There are currently no active connections.',\n },\n } as ExecuteResult & { rawResult?: unknown };\n return this;\n }\n\n const activeConnections = connections.filter(\n (c): c is Connection => (c as Connection).status === 'established'\n );\n const pendingConnections = connections.filter(\n (c): c is Connection => (c as Connection).isPending\n );\n const needsConfirmation = connections.filter(\n (c): c is Connection => (c as Connection).needsConfirmation\n );\n\n let output = '';\n\n if (activeConnections.length > 0) {\n output += `🟢 Active Connections (${activeConnections.length}):\\n`;\n activeConnections.forEach((conn, index) => {\n output += this.formatConnection(conn, index, includeDetails);\n });\n output += '\\n';\n }\n\n if (showPending && needsConfirmation.length > 0) {\n output += `🟠 Connections Needing Confirmation (${needsConfirmation.length}):\\n`;\n needsConfirmation.forEach((conn, index) => {\n output += this.formatConnection(conn, index, includeDetails);\n });\n output += '\\n';\n }\n\n if (showPending && pendingConnections.length > 0) {\n output += `⚪ Pending Connection Requests (${pendingConnections.length}):\\n`;\n pendingConnections.forEach((conn, index) => {\n output += this.formatConnection(conn, index, includeDetails);\n });\n }\n\n this.executeResult = {\n success: true,\n rawResult: {\n connections,\n formattedOutput: output.trim(),\n activeCount: activeConnections.length,\n pendingCount: pendingConnections.length,\n needsConfirmationCount: needsConfirmation.length,\n },\n } as ExecuteResult & { rawResult?: unknown };\n } catch (error) {\n this.logger.error('Failed to list connections:', error);\n this.executeResult = {\n success: false,\n error: `Failed to list connections: ${\n error instanceof Error ? error.message : String(error)\n }`,\n } as ExecuteResult & { rawResult?: unknown };\n }\n\n return this;\n }\n\n private formatConnection(\n conn: unknown,\n index: number,\n includeDetails: boolean\n ): string {\n const connection = conn as {\n profileInfo?: { display_name?: string; bio?: string };\n targetAgentName?: string;\n targetAccountId?: string;\n isPending?: boolean;\n connectionTopicId?: string;\n status?: string;\n created?: Date;\n lastActivity?: Date;\n };\n\n let output = `${index + 1}. ${\n connection.profileInfo?.display_name ||\n connection.targetAgentName ||\n 'Unknown Agent'\n } (${connection.targetAccountId})\\n`;\n const displayTopicId = connection.isPending\n ? '(Pending Request)'\n : connection.connectionTopicId;\n output += ` Topic: ${displayTopicId}\\n`;\n const statusText = connection.status || 'unknown';\n output += ` Status: ${statusText}\\n`;\n\n if (includeDetails) {\n if (connection.profileInfo?.bio) {\n output += ` Bio: ${connection.profileInfo.bio.substring(0, 100)}${\n connection.profileInfo.bio.length > 100 ? '...' : ''\n }\\n`;\n }\n\n if (connection.created) {\n const createdLabel = connection.isPending\n ? 'Request sent'\n : 'Connection established';\n output += ` ${createdLabel}: ${connection.created.toLocaleString()}\\n`;\n }\n\n if (connection.lastActivity) {\n output += ` Last activity: ${connection.lastActivity.toLocaleString()}\\n`;\n }\n }\n\n return output;\n }\n\n private async getEnhancedConnections(): Promise<unknown[]> {\n try {\n const { accountId } = this.getAccountAndSigner();\n if (!accountId) {\n return this.stateManager!.listConnections();\n }\n\n const connectionManager = this.stateManager!.getConnectionsManager();\n if (!connectionManager) {\n this.logger.error(NOT_INITIALIZED_ERROR);\n return this.stateManager!.listConnections();\n }\n\n const connections = await connectionManager.fetchConnectionData(\n accountId\n );\n\n for (const connection of connections) {\n this.stateManager!.addActiveConnection(\n connection as unknown as ActiveConnection\n );\n }\n\n return connections;\n } catch (error) {\n this.logger.error('Failed to get enhanced connections:', error);\n return this.stateManager!.listConnections();\n }\n }\n\n /**\n * Check messages on a connection\n */\n public async checkMessages(params: {\n targetIdentifier: string;\n fetchLatest?: boolean;\n lastMessagesCount?: number;\n }): Promise<this> {\n this.clearNotes();\n\n if (!this.stateManager) {\n throw new Error('StateManager is required to check messages');\n }\n\n const connection = this.stateManager.getConnectionByIdentifier(\n params.targetIdentifier\n );\n\n if (!connection) {\n this.executeResult = {\n success: false,\n error: `Could not find an active connection matching identifier \"${params.targetIdentifier}\". Use 'list_connections' to see active connections.`,\n } as ExecuteResult & { rawResult?: unknown };\n return this;\n }\n\n const connectionTopicId = connection.connectionTopicId || '';\n\n if (!connectionTopicId || !connectionTopicId.match(/^\\d+\\.\\d+\\.\\d+$/)) {\n this.logger.error(\n `Invalid connection topic ID format: ${connectionTopicId}`\n );\n this.executeResult = {\n success: false,\n error: `Invalid connection topic ID format: ${connectionTopicId}. Expected format: 0.0.XXXXX`,\n } as ExecuteResult & { rawResult?: unknown };\n return this;\n }\n\n const targetAgentName = connection.targetAgentName;\n const lastProcessedTimestamp =\n this.stateManager.getLastTimestamp(connectionTopicId);\n\n this.logger.info(\n `Checking messages for connection with ${targetAgentName} (${connection.targetAccountId}) on topic ${connectionTopicId} (fetchLatest: ${params.fetchLatest}, lastCount: ${params.lastMessagesCount}, since: ${lastProcessedTimestamp})`\n );\n\n try {\n const result = await this.getMessages(connectionTopicId);\n const allMessages = result.messages;\n\n if (!allMessages || allMessages.length === 0) {\n this.executeResult = {\n success: true,\n rawResult: {\n messages: [],\n message: `No messages found on connection topic ${connectionTopicId}.`,\n },\n } as ExecuteResult & { rawResult?: unknown };\n return this;\n }\n\n let messagesToProcess: HCSMessageWithTimestamp[] = [];\n let latestTimestampNanos = lastProcessedTimestamp;\n const isFetchingLatest = params.fetchLatest === true;\n\n if (isFetchingLatest) {\n this.logger.info('Fetching latest messages regardless of timestamp.');\n const count = params.lastMessagesCount ?? 1;\n messagesToProcess = allMessages.slice(-count);\n } else {\n this.logger.info(\n `Filtering for messages newer than ${lastProcessedTimestamp}`\n );\n messagesToProcess = allMessages.filter(\n (msg: HCSMessageWithTimestamp) => {\n const msgTimestampNanos = msg.timestamp * 1_000_000;\n return msgTimestampNanos > lastProcessedTimestamp;\n }\n );\n\n if (messagesToProcess.length > 0) {\n latestTimestampNanos = messagesToProcess.reduce(\n (maxTs, msg) => Math.max(maxTs, msg.timestamp * 1_000_000),\n lastProcessedTimestamp\n );\n }\n }\n\n if (messagesToProcess.length === 0) {\n const message = isFetchingLatest\n ? `Could not retrieve the latest message(s). No messages found on topic ${connectionTopicId}.`\n : `No new messages found for connection with ${targetAgentName} since last check.`;\n\n this.executeResult = {\n success: true,\n rawResult: {\n messages: [],\n message,\n },\n } as ExecuteResult & { rawResult?: unknown };\n return this;\n }\n\n this.logger.info(`Processing ${messagesToProcess.length} message(s).`);\n\n let outputString = isFetchingLatest\n ? `Latest message(s) from ${targetAgentName}:\\n`\n : `New messages from ${targetAgentName}:\\n`;\n\n const processedMessages: Array<{\n timestamp: number;\n sequenceNumber: number;\n content: string | undefined;\n raw: HCSMessageWithTimestamp;\n }> = [];\n\n for (const msg of messagesToProcess) {\n let content = msg.data;\n try {\n if (typeof content === 'string' && content.startsWith('hcs://')) {\n this.logger.debug(`Resolving inscribed message: ${content}`);\n content = await this.getMessageContent(content);\n this.logger.debug(`Resolved content length: ${content?.length}`);\n }\n\n let displayContent = content;\n try {\n const parsed = JSON.parse(content || '{}');\n if (\n parsed.p === 'hcs-10' &&\n parsed.op === 'message' &&\n parsed.data\n ) {\n const senderOpId = parsed.operator_id || 'unknown_sender';\n displayContent = `[${senderOpId}]: ${parsed.data}`;\n } else {\n displayContent = content;\n }\n } catch {\n displayContent = content;\n }\n\n const messageDate = new Date(msg.timestamp);\n outputString += `\\n[${messageDate.toLocaleString()}] (Seq: ${\n msg.sequence_number\n })\\n${displayContent}\\n`;\n\n processedMessages.push({\n timestamp: msg.timestamp,\n sequenceNumber: msg.sequence_number,\n content: displayContent,\n raw: msg,\n });\n } catch (error) {\n const errorMsg = `Error processing message (Seq: ${\n msg.sequence_number\n }): ${error instanceof Error ? error.message : String(error)}`;\n this.logger.error(errorMsg);\n outputString += `\\n[Error processing message Seq: ${msg.sequence_number}]\\n`;\n }\n }\n\n if (!isFetchingLatest && latestTimestampNanos > lastProcessedTimestamp) {\n this.logger.debug(\n `Updating timestamp for topic ${connectionTopicId} to ${latestTimestampNanos}`\n );\n this.stateManager.updateTimestamp(\n connectionTopicId,\n latestTimestampNanos\n );\n }\n\n this.executeResult = {\n success: true,\n rawResult: {\n messages: processedMessages,\n formattedOutput: outputString.trim(),\n targetAgentName,\n connectionTopicId,\n },\n } as ExecuteResult & { rawResult?: unknown };\n } catch (error) {\n this.logger.error(\n `Failed to check messages for topic ${connectionTopicId}: ${error}`\n );\n this.executeResult = {\n success: false,\n error: `Error checking messages for ${targetAgentName}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n } as ExecuteResult & { rawResult?: unknown };\n }\n\n return this;\n }\n\n /**\n * Find registrations using the configured registry\n */\n public async findRegistrations(params: {\n accountId?: string;\n tags?: number[];\n }): Promise<this> {\n this.clearNotes();\n\n try {\n const options: {\n network: StandardNetworkType;\n accountId?: string;\n tags?: number[];\n } = {\n network: this.network,\n };\n\n if (params.accountId) {\n options.accountId = params.accountId;\n }\n\n if (params.tags && params.tags.length > 0) {\n options.tags = params.tags;\n }\n\n const result = await this.standardClient.findRegistrations(options);\n\n if (!result.success || result.error) {\n this.executeResult = {\n success: false,\n error: `Error finding registrations: ${\n result.error || 'Unknown error'\n }`,\n } as ExecuteResult & { rawResult?: unknown };\n return this;\n }\n\n if (!result.registrations || result.registrations.length === 0) {\n this.executeResult = {\n success: true,\n rawResult: {\n registrations: [],\n message: 'No registrations found matching the criteria.',\n },\n } as ExecuteResult & { rawResult?: unknown };\n return this;\n }\n\n const formattedRegistrations = result.registrations\n .map((reg: unknown): string => {\n const registration = reg as {\n agent?: { name?: string; capabilities?: string[] };\n accountId?: string;\n };\n const agentName = registration.agent?.name || 'Unknown Agent';\n const accountId = registration.accountId || 'Unknown Account';\n const capabilities =\n registration.agent?.capabilities?.join(', ') || 'None';\n\n return `Agent: ${agentName} (${accountId}), Capabilities: ${capabilities}`;\n })\n .join('\\\\n');\n\n this.executeResult = {\n success: true,\n rawResult: {\n registrations: result.registrations,\n formattedOutput: `Found ${result.registrations.length} registration(s):\\\\n${formattedRegistrations}`,\n },\n } as ExecuteResult & { rawResult?: unknown };\n } catch (error) {\n this.logger.error('Error during FindRegistrations execution:', error);\n this.executeResult = {\n success: false,\n error: `Failed to search registrations: ${\n error instanceof Error ? error.message : String(error)\n }`,\n } as ExecuteResult & { rawResult?: unknown };\n }\n\n return this;\n }\n\n /**\n * Retrieve detailed profile information for an agent\n */\n public async retrieveProfile(params: {\n accountId: string;\n disableCache?: boolean;\n }): Promise<this> {\n this.clearNotes();\n\n try {\n const profileResponse = await this.standardClient.retrieveProfile(\n params.accountId,\n params.disableCache || false\n );\n\n if (!profileResponse.success) {\n this.executeResult = {\n success: false,\n error: `Failed to retrieve profile: ${\n profileResponse.error || 'Unknown error'\n }`,\n } as ExecuteResult & { rawResult?: unknown };\n return this;\n }\n\n const profile = profileResponse.profile;\n const topicInfo = profileResponse.topicInfo;\n\n let profileDetails = `Profile for ${params.accountId}:\\n`;\n profileDetails += `Name: ${profile.name || 'Unknown'}\\n`;\n profileDetails += `Bio: ${profile.bio || 'No bio provided'}\\n`;\n profileDetails += `Type: ${profile.type || 'Unknown'}\\n`;\n profileDetails += `Model: ${profile.model || 'Unknown'}\\n`;\n\n if (profile.capabilities && profile.capabilities.length > 0) {\n profileDetails += `Capabilities: ${profile.capabilities.join(', ')}\\n`;\n } else {\n profileDetails += `Capabilities: None listed\\n`;\n }\n\n if (topicInfo) {\n profileDetails += `Inbound Topic: ${\n topicInfo.inboundTopic || 'Unknown'\n }\\n`;\n profileDetails += `Outbound Topic: ${\n topicInfo.outboundTopic || 'Unknown'\n }\\n`;\n profileDetails += `Profile Topic: ${\n topicInfo.profileTopicId || 'Unknown'\n }\\n`;\n }\n\n if (profile.social && Object.keys(profile.social).length > 0) {\n profileDetails += `Social: ${Object.entries(profile.social)\n .map(([platform, handle]: [string, unknown]): string => `${platform}: ${handle}`)\n .join(', ')}\\n`;\n }\n\n if (profile.properties && Object.keys(profile.properties).length > 0) {\n profileDetails += `Properties: ${JSON.stringify(profile.properties)}\\n`;\n }\n\n this.executeResult = {\n success: true,\n rawResult: {\n profileDetails,\n rawProfile: profileResponse,\n },\n } as ExecuteResult & { rawResult?: unknown };\n } catch (error) {\n this.logger.error(\n `Unexpected error retrieving profile for ${params.accountId}:`,\n error\n );\n this.executeResult = {\n success: false,\n error: `Unexpected error retrieving profile for ${params.accountId}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n } as ExecuteResult & { rawResult?: unknown };\n }\n\n return this;\n }\n\n /**\n * Override execute to return stored HCS10 operation results\n */\n public override async execute(): Promise<ExecuteResult> {\n if (this.executeResult) {\n return {\n success: this.executeResult.success,\n transactionId: this.executeResult.transactionId,\n receipt: this.executeResult.receipt,\n scheduleId: this.executeResult.scheduleId,\n error: this.executeResult.error,\n rawResult: this.executeResult.rawResult,\n notes: this.notes,\n } as ExecuteResult & { rawResult?: unknown; notes?: string[] };\n }\n\n return {\n success: false,\n error: 'No operation result available. Call a builder method first.',\n };\n }\n}\n"],"names":["SDKLogger","HCS10Client","StandardAIAgentCapability","StandardInboundTopicType"],"mappings":";;;;;AAyBA,MAAM,wBAAwB;AA8GvB,MAAM,qBAAqB,mBAAmB;AAAA,EASnD,YACE,WACA,cACA,SAKA;AACA,UAAM,SAAS;AACf,SAAK,eAAe;AACpB,SAAK,gBAAgB,SAAS,iBAAiB;AAC/C,SAAK,yBAAyB,SAAS,eAAe;AAEtD,UA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],"sourcesContent":["import { BaseServiceBuilder } from 'hedera-agent-kit';\nimport type { HederaAgentKit } from 'hedera-agent-kit';\nimport { PrivateKey, TransactionReceipt } from '@hashgraph/sdk';\nimport { ActiveConnection, IStateManager } from '../../state/state-types';\nimport { ExecuteResult } from '../types';\nimport {\n FeeConfigBuilderInterface,\n FeeConfigBuilder,\n HCS10Client,\n AgentBuilder,\n InboundTopicType as StandardInboundTopicType,\n AIAgentCapability as StandardAIAgentCapability,\n AgentRegistrationResult,\n ProfileResponse as SDKProfileResponse,\n HCSMessage,\n LogLevel,\n Logger as SDKLogger,\n SocialPlatform,\n HandleConnectionRequestResponse,\n Connection,\n} from '@hashgraphonline/standards-sdk';\nimport fs from 'fs';\nimport path from 'path';\nimport axios from 'axios';\n\nconst NOT_INITIALIZED_ERROR = 'ConnectionsManager not initialized';\n\n/**\n * Internal agent data for registration\n */\ninterface AgentRegistrationData {\n name: string;\n bio?: string;\n alias?: string;\n type?: 'autonomous' | 'manual';\n model?: string;\n capabilities?: number[];\n creator?: string;\n socials?: Record<string, string>;\n properties?: Record<string, unknown>;\n pfpBuffer?: Buffer;\n pfpFileName?: string;\n existingProfilePictureTopicId?: string;\n feeConfig?: FeeConfigBuilderInterface;\n}\n\n/**\n * Message response with timestamp\n */\nexport interface HCSMessageWithTimestamp extends Omit<HCSMessage, 'op'> {\n timestamp: number;\n data?: string;\n sequence_number: number;\n op?: HCSMessage['op'] | string;\n operator_id?: string;\n created?: Date;\n m?: string;\n}\n\n/**\n * Network type for HCS-10\n */\nexport type StandardNetworkType = 'mainnet' | 'testnet';\n\n/**\n * Parameters for agent registration\n */\nexport interface RegisterAgentParams {\n name: string;\n bio?: string;\n alias?: string;\n type?: 'autonomous' | 'manual';\n model?: string;\n capabilities?: number[];\n creator?: string;\n socials?: Record<string, string>;\n properties?: Record<string, unknown>;\n profilePicture?:\n | string\n | {\n url?: string;\n path?: string;\n filename?: string;\n };\n existingProfilePictureTopicId?: string;\n initialBalance?: number;\n userAccountId?: string;\n hbarFee?: number;\n tokenFees?: Array<{\n amount: number;\n tokenId: string;\n }>;\n exemptAccountIds?: string[];\n}\n\n/**\n * Parameters for initiating a connection\n */\nexport interface InitiateConnectionParams {\n targetAccountId: string;\n disableMonitor?: boolean;\n memo?: string;\n}\n\n/**\n * Parameters for accepting a connection request\n */\nexport interface AcceptConnectionParams {\n requestKey: string;\n hbarFee?: number | undefined;\n exemptAccountIds?: string[] | undefined;\n}\n\n/**\n * Parameters for sending a message\n */\nexport interface SendMessageParams {\n topicId: string;\n message: string;\n disableMonitoring?: boolean;\n}\n\n/**\n * Parameters for sending a message to a connected account\n */\nexport interface SendMessageToConnectionParams {\n targetIdentifier: string;\n message: string;\n disableMonitoring?: boolean;\n}\n\n/**\n * HCS10Builder facilitates HCS-10 protocol operations for agent communication\n * This builder incorporates all HCS10Client functionality directly\n */\nexport class HCS10Builder extends BaseServiceBuilder {\n private standardClient: HCS10Client;\n private stateManager: IStateManager | undefined;\n private executeResult?: ExecuteResult & { rawResult?: unknown };\n private useEncryption: boolean;\n private guardedRegistryBaseUrl: string;\n private network: StandardNetworkType;\n private sdkLogger: SDKLogger;\n\n constructor(\n hederaKit: HederaAgentKit,\n stateManager?: IStateManager,\n options?: {\n useEncryption?: boolean;\n registryUrl?: string;\n logLevel?: LogLevel;\n }\n ) {\n super(hederaKit);\n this.stateManager = stateManager;\n this.useEncryption = options?.useEncryption || false;\n this.guardedRegistryBaseUrl = options?.registryUrl || '';\n\n const network = this.hederaKit.client.network;\n this.network = network.toString().includes('mainnet')\n ? 'mainnet'\n : 'testnet';\n\n const operatorId = this.hederaKit.signer.getAccountId().toString();\n const operatorPrivateKey = this.hederaKit.signer?.getOperatorPrivateKey()\n ? this.hederaKit.signer.getOperatorPrivateKey().toStringRaw()\n : '';\n\n this.sdkLogger = new SDKLogger({\n module: 'HCS10Builder',\n level: options?.logLevel || 'info',\n });\n\n this.standardClient = new HCS10Client({\n network: this.network,\n operatorId: operatorId,\n operatorPrivateKey: operatorPrivateKey,\n guardedRegistryBaseUrl: this.guardedRegistryBaseUrl,\n logLevel: options?.logLevel || 'info',\n });\n\n if (this.stateManager) {\n this.stateManager.initializeConnectionsManager(this.standardClient);\n }\n }\n\n /**\n * Get the operator account ID\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 /**\n * Get the network type\n */\n public getNetwork(): StandardNetworkType {\n return this.network;\n }\n\n /**\n * Get state manager instance\n */\n public getStateManager(): IStateManager | undefined {\n return this.stateManager;\n }\n\n /**\n * Get account and signer information\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 * Get the inbound topic ID for the current operator\n */\n public async getInboundTopicId(): Promise<string> {\n try {\n const operatorId = this.getOperatorId();\n this.logger.info(\n `[HCS10Builder] 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 `[HCS10Builder] 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 `[HCS10Builder] 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 * Get agent profile\n */\n public async getAgentProfile(accountId: string): Promise<SDKProfileResponse> {\n try {\n return await this.standardClient.retrieveProfile(accountId);\n } catch (error) {\n this.logger.error(\n `[HCS10Builder] Error retrieving agent profile for account ${accountId}:`,\n error\n );\n throw error;\n }\n }\n\n /**\n * Submit connection request\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 * Handle connection request\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\n if (\n result &&\n result.connectionTopicId &&\n typeof result.connectionTopicId === 'object' &&\n 'toString' in result.connectionTopicId\n ) {\n result.connectionTopicId = (\n result.connectionTopicId as { toString(): string }\n ).toString();\n }\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 * Send message to a topic\n */\n public async sendMessage(\n topicId: string,\n data: string,\n memo?: string\n ): Promise<{\n sequenceNumber: number | undefined;\n receipt: TransactionReceipt;\n transactionId: string | undefined;\n }> {\n if (topicId && typeof topicId === 'object' && 'toString' in topicId) {\n topicId = (topicId as unknown as { toString: () => string })?.toString();\n }\n\n if (!topicId || typeof topicId !== 'string') {\n throw new Error(\n `Invalid topic ID provided to sendMessage: ${JSON.stringify(topicId)}`\n );\n }\n\n try {\n const messageResponse = await this.standardClient.sendMessage(\n topicId,\n data,\n memo,\n undefined\n );\n return {\n sequenceNumber: messageResponse.topicSequenceNumber?.toNumber(),\n receipt: messageResponse as unknown as TransactionReceipt,\n transactionId:\n 'transactionId' in messageResponse\n ? (\n messageResponse as { transactionId?: { toString(): string } }\n ).transactionId?.toString()\n : undefined,\n };\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 * Get messages from a topic\n */\n public async getMessages(topicId: string): Promise<{\n messages: HCSMessageWithTimestamp[];\n }> {\n if (topicId && typeof topicId === 'object' && 'toString' in topicId) {\n topicId = (topicId as unknown as { toString: () => string })?.toString();\n }\n\n if (!topicId || typeof topicId !== 'string') {\n throw new Error(\n `Invalid topic ID provided to getMessages: ${JSON.stringify(topicId)}`\n );\n }\n\n try {\n const result = await this.standardClient.getMessages(topicId);\n\n const mappedMessages: HCSMessageWithTimestamp[] = result.messages.map(\n (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 p: 'hcs-10' as const,\n } as HCSMessageWithTimestamp;\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 /**\n * Get message stream from a topic\n */\n public async getMessageStream(topicId: string): Promise<{\n messages: HCSMessage[];\n }> {\n if (topicId && typeof topicId === 'object' && 'toString' in topicId) {\n topicId = (topicId as unknown as { toString: () => string })?.toString();\n }\n\n if (!topicId || typeof topicId !== 'string') {\n throw new Error(\n `Invalid topic ID provided to getMessageStream: ${JSON.stringify(\n topicId\n )}`\n );\n }\n\n return this.standardClient.getMessageStream(topicId) as Promise<{\n messages: HCSMessage[];\n }>;\n }\n\n /**\n * Get 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 * Get the standard client instance (for compatibility)\n */\n public getStandardClient(): HCS10Client {\n return this.standardClient;\n }\n\n /**\n * Load profile picture from URL or file path\n */\n private async loadProfilePicture(\n profilePicture: string | { url?: string; path?: string; filename?: string }\n ): Promise<{ buffer: Buffer; filename: string } | null> {\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 this.logger.info(\n `Loading profile picture from URL: ${profilePicture}`\n );\n const response = await axios.get(profilePicture, {\n responseType: 'arraybuffer',\n });\n const buffer = Buffer.from(response.data);\n const urlPathname = new URL(profilePicture).pathname;\n const filename = path.basename(urlPathname) || 'profile.png';\n return { buffer, filename };\n } else {\n if (!fs.existsSync(profilePicture)) {\n this.logger.warn(\n `Profile picture file not found: ${profilePicture}`\n );\n return null;\n }\n this.logger.info(\n `Loading profile picture from file: ${profilePicture}`\n );\n const buffer = fs.readFileSync(profilePicture);\n const filename = path.basename(profilePicture);\n return { buffer, filename };\n }\n } else if (profilePicture.url) {\n this.logger.info(\n `Loading profile picture from URL: ${profilePicture.url}`\n );\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 return { buffer, filename };\n } else if (profilePicture.path) {\n if (!fs.existsSync(profilePicture.path)) {\n this.logger.warn(\n `Profile picture file not found: ${profilePicture.path}`\n );\n return null;\n }\n this.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 return { buffer, filename };\n }\n\n return null;\n } catch (error) {\n this.logger.error('Failed to load profile picture:', error);\n return null;\n }\n }\n\n /**\n * Create and register an agent\n */\n private async createAndRegisterAgent(\n data: AgentRegistrationData\n ): Promise<AgentRegistrationResult> {\n const builder = new AgentBuilder()\n .setName(data.name)\n .setBio(data.bio || '')\n .setCapabilities(\n data.capabilities || [StandardAIAgentCapability.TEXT_GENERATION]\n )\n .setType(data.type || 'autonomous')\n .setModel(data.model || 'agent-model-2024')\n .setNetwork(this.getNetwork())\n .setInboundTopicType(StandardInboundTopicType.PUBLIC);\n\n if (data.alias) {\n builder.setAlias(data.alias);\n }\n\n if (data.creator) {\n builder.setCreator(data.creator);\n }\n\n if (data?.feeConfig) {\n builder.setInboundTopicType(StandardInboundTopicType.FEE_BASED);\n builder.setFeeConfig(data.feeConfig);\n }\n\n if (data.existingProfilePictureTopicId) {\n builder.setExistingProfilePicture(data.existingProfilePictureTopicId);\n } else if (data.pfpBuffer && data.pfpFileName) {\n if (data.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: ${data.pfpFileName} (${data.pfpBuffer.byteLength} bytes)`\n );\n builder.setProfilePicture(data.pfpBuffer, data.pfpFileName);\n }\n } else {\n this.logger.warn(\n 'Profile picture not provided. Agent creation might fail if required by the underlying SDK builder.'\n );\n }\n\n if (data.socials) {\n Object.entries(data.socials).forEach(([platform, handle]) => {\n builder.addSocial(platform as SocialPlatform, handle);\n });\n }\n\n if (data.properties) {\n Object.entries(data.properties).forEach(([key, value]) => {\n builder.addProperty(key, value);\n });\n }\n\n try {\n const hasFees = Boolean(data?.feeConfig);\n const result = await this.standardClient.createAndRegisterAgent(builder, {\n initialBalance: hasFees ? 50 : 10,\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 * Register a new HCS-10 agent\n * Note: This performs multiple transactions and requires directExecution mode\n */\n public async registerAgent(params: RegisterAgentParams): Promise<this> {\n this.clearNotes();\n\n if (this.hederaKit.operationalMode === 'returnBytes') {\n throw new Error(\n 'Agent registration requires multiple transactions and cannot be performed in returnBytes mode. ' +\n 'Please use autonomous mode.'\n );\n }\n\n try {\n let profilePictureData: { buffer: Buffer; filename: string } | null =\n null;\n if (params.profilePicture) {\n profilePictureData = await this.loadProfilePicture(\n params.profilePicture\n );\n }\n\n const registrationData: AgentRegistrationData = {\n name: params.name,\n ...(params.bio !== undefined && { bio: params.bio }),\n ...(params.alias !== undefined && { alias: params.alias }),\n ...(params.type !== undefined && { type: params.type }),\n ...(params.model !== undefined && { model: params.model }),\n ...(params.capabilities !== undefined && {\n capabilities: params.capabilities,\n }),\n ...(params.creator !== undefined && { creator: params.creator }),\n ...(params.socials !== undefined && { socials: params.socials }),\n ...(params.properties !== undefined && {\n properties: params.properties,\n }),\n ...(params.existingProfilePictureTopicId !== undefined && {\n existingProfilePictureTopicId: params.existingProfilePictureTopicId,\n }),\n ...(profilePictureData?.buffer !== undefined && {\n pfpBuffer: profilePictureData.buffer,\n }),\n ...(profilePictureData?.filename !== undefined && {\n pfpFileName: profilePictureData.filename,\n }),\n };\n\n if (params.hbarFee && params.hbarFee > 0) {\n const feeConfigBuilder = new FeeConfigBuilder({\n network: this.network,\n logger: this.sdkLogger,\n });\n\n const { accountId: collectorAccountId } = this.getAccountAndSigner();\n if (!collectorAccountId) {\n throw new Error('Could not determine account ID for fee collection.');\n }\n this.addNote(\n `Setting the operator account (${collectorAccountId}) as the fee collector since no specific collector was provided.`\n );\n\n const effectiveExemptIds =\n params.exemptAccountIds?.filter(\n (id: string) => id !== collectorAccountId && id.startsWith('0.0')\n ) || [];\n\n registrationData.feeConfig = feeConfigBuilder.addHbarFee(\n params.hbarFee,\n collectorAccountId,\n effectiveExemptIds\n );\n }\n\n const result = await this.createAndRegisterAgent(registrationData);\n\n this.executeResult = {\n success: true,\n transactionId: result.transactionId,\n receipt: undefined,\n scheduleId: undefined,\n rawResult: {\n ...result,\n name: params.name,\n accountId:\n result?.metadata?.accountId ||\n result.state?.agentMetadata?.accountId,\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n } catch (error) {\n this.logger.error('Failed to register agent:', error);\n throw error;\n }\n\n return this;\n }\n\n /**\n * Initiate a connection to another agent\n */\n public async initiateConnection(\n params: InitiateConnectionParams\n ): Promise<this> {\n this.clearNotes();\n\n try {\n const targetProfile = await this.getAgentProfile(params.targetAccountId);\n\n if (!targetProfile.success || !targetProfile.topicInfo?.inboundTopic) {\n throw new Error(\n `Could not retrieve inbound topic for target account ${params.targetAccountId}`\n );\n }\n\n const targetInboundTopicId = targetProfile.topicInfo.inboundTopic;\n let memo: string;\n if (params.memo !== undefined) {\n memo = params.memo;\n } else {\n memo = params.disableMonitor ? 'false' : 'true';\n this.addNote(\n `No custom memo was provided. Using default memo '${memo}' based on monitoring preference.`\n );\n }\n if (!params.disableMonitor) {\n this.addNote(\n `Monitoring will be enabled for this connection request as disableMonitor was not specified.`\n );\n }\n\n const result = await this.submitConnectionRequest(\n targetInboundTopicId,\n memo\n );\n\n this.executeResult = {\n success: true,\n transactionId:\n 'transactionId' in result\n ? (\n result as { transactionId?: { toString(): string } }\n ).transactionId?.toString()\n : undefined,\n receipt: result,\n scheduleId: undefined,\n rawResult: {\n targetAccountId: params.targetAccountId,\n targetInboundTopicId,\n connectionRequestSent: true,\n monitoringEnabled: !params.disableMonitor,\n ...result,\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n } catch (error) {\n this.logger.error('Failed to initiate connection:', error);\n throw error;\n }\n\n return this;\n }\n\n /**\n * Accept a connection request\n * Note: This performs multiple transactions and requires directExecution mode\n */\n public async acceptConnection(params: AcceptConnectionParams): Promise<this> {\n this.clearNotes();\n\n if (this.hederaKit.operationalMode === 'returnBytes') {\n throw new Error(\n 'Accepting connections requires multiple transactions and cannot be performed in returnBytes mode. ' +\n 'Please use autonomous mode.'\n );\n }\n\n try {\n const currentAgent = this.stateManager?.getCurrentAgent();\n if (!currentAgent) {\n throw new Error(\n 'Cannot accept connection request. No agent is currently active. Please register or select an agent first.'\n );\n }\n\n const connectionsManager = this.stateManager?.getConnectionsManager();\n if (!connectionsManager) {\n throw new Error(NOT_INITIALIZED_ERROR);\n }\n\n await connectionsManager.fetchConnectionData(currentAgent.accountId);\n\n const allRequests = [\n ...connectionsManager.getPendingRequests(),\n ...connectionsManager.getConnectionsNeedingConfirmation(),\n ];\n\n const request = allRequests.find(\n (r) =>\n r.uniqueRequestKey === params.requestKey ||\n r.connectionRequestId?.toString() === params.requestKey ||\n r.inboundRequestId?.toString() === params.requestKey\n );\n\n if (!request) {\n throw new Error(\n `Request with key ${params.requestKey} not found or no longer pending.`\n );\n }\n\n if (!request.needsConfirmation || !request.inboundRequestId) {\n throw new Error(\n `Request with key ${params.requestKey} is not an inbound request that can be accepted.`\n );\n }\n\n const targetAccountId = request.targetAccountId;\n const inboundRequestId = request.inboundRequestId;\n\n let feeConfig: FeeConfigBuilderInterface | undefined;\n\n if (params.hbarFee && params.hbarFee > 0) {\n const feeConfigBuilder = new FeeConfigBuilder({\n network: this.network,\n logger: this.sdkLogger,\n });\n\n const { accountId: collectorAccountId } = this.getAccountAndSigner();\n if (!collectorAccountId) {\n throw new Error('Could not determine account ID for fee collection.');\n }\n this.addNote(\n `Setting the operator account (${collectorAccountId}) as the fee collector since no specific collector was provided.`\n );\n\n const effectiveExemptIds =\n params.exemptAccountIds?.filter(\n (id: string) => id !== collectorAccountId && id.startsWith('0.0')\n ) || [];\n\n feeConfig = feeConfigBuilder.addHbarFee(\n params.hbarFee,\n collectorAccountId,\n effectiveExemptIds\n );\n }\n\n const inboundTopicId = await this.getInboundTopicId();\n const confirmationResult = await this.handleConnectionRequest(\n inboundTopicId,\n targetAccountId,\n inboundRequestId,\n feeConfig\n );\n\n let connectionTopicId = confirmationResult?.connectionTopicId;\n\n if (\n connectionTopicId &&\n typeof connectionTopicId === 'object' &&\n 'toString' in connectionTopicId\n ) {\n connectionTopicId = (\n connectionTopicId as unknown as { toString: () => string }\n )?.toString();\n }\n\n if (!connectionTopicId || typeof connectionTopicId !== 'string') {\n throw new Error(\n `Failed to create connection topic. Got: ${JSON.stringify(\n connectionTopicId\n )}`\n );\n }\n\n if (this.stateManager) {\n const targetAgentName =\n request.targetAgentName || `Agent ${targetAccountId}`;\n if (!request.targetAgentName) {\n this.addNote(\n `No agent name was provided in the connection request, using default name 'Agent ${targetAccountId}'.`\n );\n }\n\n let targetInboundTopicId = request.targetInboundTopicId || '';\n if (!targetInboundTopicId) {\n try {\n const targetProfile = await this.getAgentProfile(targetAccountId);\n if (\n targetProfile.success &&\n targetProfile.topicInfo?.inboundTopic\n ) {\n targetInboundTopicId = targetProfile.topicInfo.inboundTopic;\n }\n } catch (profileError) {\n this.logger.warn(\n `Could not fetch profile for ${targetAccountId}:`,\n profileError\n );\n }\n }\n\n const newConnection = {\n connectionId: `conn-${Date.now()}`,\n targetAccountId: targetAccountId,\n targetAgentName: targetAgentName,\n targetInboundTopicId: targetInboundTopicId,\n connectionTopicId: connectionTopicId,\n status: 'established' as const,\n created: new Date(),\n };\n this.stateManager.addActiveConnection(newConnection);\n\n connectionsManager.markConnectionRequestProcessed(\n request.targetInboundTopicId || '',\n inboundRequestId\n );\n }\n\n this.executeResult = {\n success: true,\n transactionId: undefined,\n receipt: undefined,\n scheduleId: undefined,\n rawResult: {\n targetAccountId,\n connectionTopicId,\n feeConfigured: !!params.hbarFee,\n hbarFee: params.hbarFee || 0,\n confirmationResult,\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n } catch (error) {\n this.logger.error('Failed to accept connection:', error);\n throw error;\n }\n\n return this;\n }\n\n /**\n * Send a message using HCS (for operations that need direct topic access)\n */\n public async sendHCS10Message(params: SendMessageParams): Promise<this> {\n this.clearNotes();\n\n try {\n const result = await this.sendMessage(params.topicId, params.message);\n\n this.executeResult = {\n success: true,\n transactionId: result.transactionId,\n receipt: result.receipt,\n scheduleId: undefined,\n rawResult: result,\n } as unknown as ExecuteResult & { rawResult?: unknown };\n\n this.addNote(`Message sent to topic ${params.topicId}.`);\n } catch (error) {\n this.logger.error('Failed to send message:', error);\n throw error;\n }\n\n return this;\n }\n\n /**\n * Send a message to a connected account with optional response monitoring\n */\n public async sendMessageToConnection(\n params: SendMessageToConnectionParams\n ): Promise<this> {\n this.clearNotes();\n\n if (!this.stateManager) {\n throw new Error(\n 'StateManager is required to send messages to connections'\n );\n }\n\n try {\n const currentAgent = this.stateManager.getCurrentAgent();\n if (!currentAgent) {\n throw new Error(\n 'Cannot send message. No agent is currently active. Please register or select an agent first.'\n );\n }\n\n let connection: ActiveConnection | undefined;\n\n if (params.targetIdentifier.includes('@')) {\n const parts = params.targetIdentifier.split('@');\n if (parts.length === 2) {\n const accountId = parts[1];\n connection = this.stateManager.getConnectionByIdentifier(accountId);\n\n if (!connection) {\n this.addNote(\n `Could not find connection using request key '${params.targetIdentifier}', extracted account ID '${accountId}'.`\n );\n }\n }\n }\n\n if (!connection) {\n connection = this.stateManager.getConnectionByIdentifier(\n params.targetIdentifier\n );\n }\n\n if (!connection) {\n const connections = this.stateManager.listConnections();\n const availableIds = connections.map(\n (c) => `${c.targetAccountId} (${c.connectionTopicId})`\n );\n throw new Error(\n `Connection not found for identifier: ${\n params.targetIdentifier\n }. Available connections: ${\n availableIds.join(', ') || 'none'\n }. Use 'list_connections' to see details.`\n );\n }\n\n let connectionTopicId = connection.connectionTopicId;\n if (\n connectionTopicId &&\n typeof connectionTopicId === 'object' &&\n 'toString' in connectionTopicId\n ) {\n connectionTopicId = (\n connectionTopicId as unknown as { toString: () => string }\n )?.toString();\n }\n\n if (!connectionTopicId || typeof connectionTopicId !== 'string') {\n throw new Error(\n `Invalid connection topic ID for ${\n connection.targetAccountId\n }: ${JSON.stringify(\n connectionTopicId\n )} (type: ${typeof connectionTopicId})`\n );\n }\n\n const targetAgentName = connection.targetAgentName;\n\n const operatorId = `${currentAgent.inboundTopicId}@${currentAgent.accountId}`;\n\n const messageResult = await this.sendMessage(\n connectionTopicId,\n params.message,\n `Agent message from ${currentAgent.name}`\n );\n\n if (!messageResult.sequenceNumber) {\n throw new Error('Failed to send message');\n }\n\n let reply: string | null = null;\n if (!params.disableMonitoring) {\n reply = await this.monitorResponses(\n connectionTopicId,\n operatorId,\n messageResult.sequenceNumber\n );\n } else {\n this.addNote(\n `Message sent successfully. Response monitoring was disabled.`\n );\n }\n\n this.executeResult = {\n success: true,\n transactionId: messageResult.transactionId,\n receipt: messageResult.receipt,\n scheduleId: undefined,\n rawResult: {\n targetAgentName,\n targetAccountId: connection.targetAccountId,\n connectionTopicId,\n sequenceNumber: messageResult.sequenceNumber,\n reply,\n monitoringEnabled: !params.disableMonitoring,\n message: params.message,\n messageResult,\n },\n };\n } catch (error) {\n this.logger.error('Failed to send message to connection:', error);\n throw error;\n }\n\n return this;\n }\n\n /**\n * Monitor responses on a topic after sending a message\n */\n private async monitorResponses(\n topicId: string,\n operatorId: string,\n sequenceNumber: number\n ): Promise<string | null> {\n const maxAttempts = 30;\n let attempts = 0;\n\n while (attempts < maxAttempts) {\n try {\n const messages = await this.getMessageStream(topicId);\n\n for (const message of messages.messages) {\n if (\n message.sequence_number < sequenceNumber ||\n message.operator_id === operatorId\n ) {\n continue;\n }\n const content = await this.getMessageContent(message.data || '');\n return content;\n }\n } catch (error) {\n this.logger.error(`Error monitoring responses: ${error}`);\n }\n await new Promise((resolve) => setTimeout(resolve, 4000));\n attempts++;\n }\n return null;\n }\n\n /**\n * Start passive monitoring for incoming connection requests\n * This method monitors continuously in the background\n */\n public async startPassiveConnectionMonitoring(): Promise<this> {\n this.clearNotes();\n\n if (!this.stateManager) {\n throw new Error('StateManager is required for passive monitoring');\n }\n\n const inboundTopicId = await this.getInboundTopicId();\n this.logger.info(\n `Starting passive connection monitoring on topic ${inboundTopicId}...`\n );\n\n this.executeResult = {\n success: true,\n transactionId: undefined,\n receipt: undefined,\n scheduleId: undefined,\n rawResult: {\n inboundTopicId,\n message: `Started monitoring inbound topic ${inboundTopicId} for connection requests in the background.`,\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n\n return this;\n }\n\n /**\n * Monitor for incoming connection requests\n */\n public async monitorConnections(params: {\n acceptAll?: boolean;\n targetAccountId?: string;\n monitorDurationSeconds?: number;\n hbarFees?: Array<{ amount: number; collectorAccount?: string }>;\n tokenFees?: Array<{\n amount: number;\n tokenId: string;\n collectorAccount?: string;\n }>;\n exemptAccountIds?: string[];\n defaultCollectorAccount?: string;\n }): Promise<this> {\n this.clearNotes();\n\n const {\n acceptAll = false,\n targetAccountId,\n monitorDurationSeconds = 120,\n hbarFees = [],\n tokenFees = [],\n exemptAccountIds = [],\n defaultCollectorAccount,\n } = params;\n\n if (!this.stateManager) {\n throw new Error('StateManager is required for connection monitoring');\n }\n\n const currentAgent = this.stateManager.getCurrentAgent();\n if (!currentAgent) {\n throw new Error(\n 'Cannot monitor for connections. No agent is currently active.'\n );\n }\n\n const inboundTopicId = await this.getInboundTopicId();\n const endTime = Date.now() + monitorDurationSeconds * 1000;\n const pollIntervalMs = 3000;\n let connectionRequestsFound = 0;\n let acceptedConnections = 0;\n const processedRequestIds = new Set<number>();\n\n while (Date.now() < endTime) {\n try {\n const messagesResult = await this.getMessages(inboundTopicId);\n const connectionRequests = messagesResult.messages.filter(\n (msg) =>\n msg.op === 'connection_request' &&\n typeof msg.sequence_number === 'number'\n );\n\n for (const request of connectionRequests) {\n const connectionRequestId = request.sequence_number;\n if (\n !connectionRequestId ||\n processedRequestIds.has(connectionRequestId)\n ) {\n continue;\n }\n\n const requestingAccountId = request.operator_id?.split('@')[1];\n if (!requestingAccountId) {\n continue;\n }\n\n connectionRequestsFound++;\n\n if (targetAccountId && requestingAccountId !== targetAccountId) {\n this.logger.info(\n `Skipping request from ${requestingAccountId} (not target account)`\n );\n continue;\n }\n\n if (acceptAll || targetAccountId === requestingAccountId) {\n this.logger.info(\n `Accepting connection request from ${requestingAccountId}`\n );\n\n let feeConfig;\n if (hbarFees.length > 0 || tokenFees.length > 0) {\n const builder = new FeeConfigBuilder({\n network: this.network,\n logger: this.sdkLogger,\n });\n\n for (const fee of hbarFees) {\n const collectorAccount =\n fee.collectorAccount ||\n defaultCollectorAccount ||\n this.getOperatorId();\n builder.addHbarFee(\n fee.amount,\n collectorAccount,\n exemptAccountIds\n );\n }\n\n for (const fee of tokenFees) {\n const collectorAccount =\n fee.collectorAccount ||\n defaultCollectorAccount ||\n this.getOperatorId();\n builder.addTokenFee(\n fee.amount,\n fee.tokenId,\n collectorAccount,\n undefined,\n exemptAccountIds\n );\n }\n\n feeConfig = builder;\n }\n\n await this.handleConnectionRequest(\n inboundTopicId,\n requestingAccountId,\n connectionRequestId,\n feeConfig\n );\n\n processedRequestIds.add(connectionRequestId);\n acceptedConnections++;\n }\n }\n } catch (error) {\n this.logger.error('Error during connection monitoring:', error);\n }\n\n await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));\n }\n\n this.executeResult = {\n success: true,\n transactionId: undefined,\n receipt: undefined,\n scheduleId: undefined,\n rawResult: {\n connectionRequestsFound,\n acceptedConnections,\n monitorDurationSeconds,\n processedRequestIds: Array.from(processedRequestIds),\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n\n this.addNote(\n `Monitoring completed. Found ${connectionRequestsFound} requests, accepted ${acceptedConnections}.`\n );\n\n return this;\n }\n\n /**\n * Manage connection requests (list, view, or reject)\n */\n public async manageConnectionRequests(params: {\n action: 'list' | 'view' | 'reject';\n requestKey?: string;\n }): Promise<this> {\n this.clearNotes();\n\n if (!this.stateManager) {\n throw new Error(\n 'StateManager is required for managing connection requests'\n );\n }\n\n const currentAgent = this.stateManager.getCurrentAgent();\n if (!currentAgent) {\n throw new Error(\n 'Cannot manage connection requests. No agent is currently active.'\n );\n }\n\n const connectionsManager = this.stateManager.getConnectionsManager();\n if (!connectionsManager) {\n throw new Error(NOT_INITIALIZED_ERROR);\n }\n\n try {\n const { accountId } = this.getAccountAndSigner();\n await connectionsManager.fetchConnectionData(accountId);\n\n const pendingRequests = connectionsManager.getPendingRequests();\n const needsConfirmation =\n connectionsManager.getConnectionsNeedingConfirmation();\n const allRequests = [...pendingRequests, ...needsConfirmation];\n\n switch (params.action) {\n case 'list':\n this.executeResult = {\n success: true,\n transactionId: undefined,\n receipt: undefined,\n scheduleId: undefined,\n rawResult: {\n requests: allRequests.map((request, index) => ({\n index: index + 1,\n type: request.needsConfirmation ? 'incoming' : 'outgoing',\n requestKey:\n request.uniqueRequestKey ||\n `${\n request.connectionRequestId ||\n request.inboundRequestId ||\n 'unknown'\n }`,\n targetAccountId: request.targetAccountId,\n targetAgentName:\n request.targetAgentName || `Agent ${request.targetAccountId}`,\n created: request.created.toISOString(),\n memo: request.memo,\n bio: request.profileInfo?.bio,\n })),\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n break;\n\n case 'view': {\n if (!params.requestKey) {\n throw new Error('Request key is required for viewing a request');\n }\n const viewRequest = allRequests.find(\n (r) =>\n r.uniqueRequestKey === params.requestKey ||\n r.connectionRequestId?.toString() === params.requestKey ||\n r.inboundRequestId?.toString() === params.requestKey\n );\n if (!viewRequest) {\n throw new Error(`Request with key ${params.requestKey} not found`);\n }\n this.executeResult = {\n success: true,\n transactionId: undefined,\n receipt: undefined,\n scheduleId: undefined,\n rawResult: {\n request: {\n type: viewRequest.needsConfirmation ? 'incoming' : 'outgoing',\n requestKey:\n viewRequest.uniqueRequestKey ||\n `${\n viewRequest.connectionRequestId ||\n viewRequest.inboundRequestId ||\n 'unknown'\n }`,\n targetAccountId: viewRequest.targetAccountId,\n targetAgentName:\n viewRequest.targetAgentName ||\n `Agent ${viewRequest.targetAccountId}`,\n created: viewRequest.created.toISOString(),\n memo: viewRequest.memo,\n profileInfo: viewRequest.profileInfo,\n },\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n break;\n }\n\n case 'reject': {\n if (!params.requestKey) {\n throw new Error('Request key is required for rejecting a request');\n }\n const rejectRequest = allRequests.find(\n (r) =>\n r.uniqueRequestKey === params.requestKey ||\n r.connectionRequestId?.toString() === params.requestKey ||\n r.inboundRequestId?.toString() === params.requestKey\n );\n if (!rejectRequest) {\n throw new Error(`Request with key ${params.requestKey} not found`);\n }\n if (rejectRequest.inboundRequestId) {\n connectionsManager.markConnectionRequestProcessed(\n rejectRequest.targetInboundTopicId || '',\n rejectRequest.inboundRequestId\n );\n } else if (rejectRequest.connectionRequestId) {\n connectionsManager.markConnectionRequestProcessed(\n rejectRequest.originTopicId || '',\n rejectRequest.connectionRequestId\n );\n }\n this.executeResult = {\n success: true,\n transactionId: undefined,\n receipt: undefined,\n scheduleId: undefined,\n rawResult: {\n rejectedRequest: {\n requestKey: params.requestKey,\n targetAccountId: rejectRequest.targetAccountId,\n targetAgentName:\n rejectRequest.targetAgentName ||\n `Agent ${rejectRequest.targetAccountId}`,\n },\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n break;\n }\n }\n } catch (error) {\n this.logger.error('Failed to manage connection requests:', error);\n throw error;\n }\n\n return this;\n }\n\n /**\n * List unapproved connection requests\n */\n public async listUnapprovedConnectionRequests(): Promise<this> {\n this.clearNotes();\n\n if (!this.stateManager) {\n throw new Error(\n 'StateManager is required for listing connection requests'\n );\n }\n\n const currentAgent = this.stateManager.getCurrentAgent();\n if (!currentAgent) {\n throw new Error(\n 'Cannot list connection requests. No agent is currently active.'\n );\n }\n\n try {\n const inboundTopicId = await this.getInboundTopicId();\n const messages = await this.getMessages(inboundTopicId);\n\n const unapprovedRequests = messages.messages\n .filter(\n (msg): msg is HCSMessageWithTimestamp & { op: string } =>\n msg.op === 'connection_request'\n )\n .map((msg) => ({\n requestId: msg.sequence_number,\n fromAccountId: msg.operator_id?.split('@')[1] || 'unknown',\n timestamp: msg.timestamp || new Date(msg?.created || '').getTime(),\n memo: msg.m || '',\n data: msg.data,\n }))\n .filter(\n (req): req is typeof req & { fromAccountId: string } =>\n req.fromAccountId !== 'unknown'\n );\n\n this.executeResult = {\n success: true,\n transactionId: undefined,\n receipt: undefined,\n scheduleId: undefined,\n rawResult: {\n requests: unapprovedRequests,\n count: unapprovedRequests.length,\n },\n } as unknown as ExecuteResult & { rawResult?: unknown };\n\n if (unapprovedRequests.length === 0) {\n this.addNote('No unapproved connection requests found.');\n } else {\n this.addNote(\n `Found ${unapprovedRequests.length} unapproved connection request(s).`\n );\n }\n } catch (error) {\n this.logger.error(\n 'Failed to list unapproved connection requests:',\n error\n );\n throw error;\n }\n\n return this;\n }\n\n /**\n * List connections with enhanced details\n */\n public async listConnections(\n params: {\n includeDetails?: boolean;\n showPending?: boolean;\n } = {}\n ): Promise<this> {\n this.clearNotes();\n\n if (!this.stateManager) {\n throw new Error('StateManager is required to list connections');\n }\n\n const includeDetails = params.includeDetails ?? true;\n const showPending = params.showPending ?? true;\n\n try {\n const connections = await this.getEnhancedConnections();\n\n if (connections.length === 0) {\n this.executeResult = {\n success: true,\n rawResult: {\n connections: [],\n message: 'There are currently no active connections.',\n },\n } as ExecuteResult & { rawResult?: unknown };\n return this;\n }\n\n const activeConnections = connections.filter(\n (c): c is Connection => (c as Connection).status === 'established'\n );\n const pendingConnections = connections.filter(\n (c): c is Connection => (c as Connection).isPending\n );\n const needsConfirmation = connections.filter(\n (c): c is Connection => (c as Connection).needsConfirmation\n );\n\n let output = '';\n\n if (activeConnections.length > 0) {\n output += `🟢 Active Connections (${activeConnections.length}):\\n`;\n activeConnections.forEach((conn, index) => {\n output += this.formatConnection(conn, index, includeDetails);\n });\n output += '\\n';\n }\n\n if (showPending && needsConfirmation.length > 0) {\n output += `🟠 Connections Needing Confirmation (${needsConfirmation.length}):\\n`;\n needsConfirmation.forEach((conn, index) => {\n output += this.formatConnection(conn, index, includeDetails);\n });\n output += '\\n';\n }\n\n if (showPending && pendingConnections.length > 0) {\n output += `⚪ Pending Connection Requests (${pendingConnections.length}):\\n`;\n pendingConnections.forEach((conn, index) => {\n output += this.formatConnection(conn, index, includeDetails);\n });\n }\n\n this.executeResult = {\n success: true,\n rawResult: {\n connections,\n formattedOutput: output.trim(),\n activeCount: activeConnections.length,\n pendingCount: pendingConnections.length,\n needsConfirmationCount: needsConfirmation.length,\n },\n } as ExecuteResult & { rawResult?: unknown };\n } catch (error) {\n this.logger.error('Failed to list connections:', error);\n this.executeResult = {\n success: false,\n error: `Failed to list connections: ${\n error instanceof Error ? error.message : String(error)\n }`,\n } as ExecuteResult & { rawResult?: unknown };\n }\n\n return this;\n }\n\n private formatConnection(\n conn: unknown,\n index: number,\n includeDetails: boolean\n ): string {\n const connection = conn as {\n profileInfo?: { display_name?: string; bio?: string };\n targetAgentName?: string;\n targetAccountId?: string;\n isPending?: boolean;\n connectionTopicId?: string;\n status?: string;\n created?: Date;\n lastActivity?: Date;\n };\n\n let output = `${index + 1}. ${\n connection.profileInfo?.display_name ||\n connection.targetAgentName ||\n 'Unknown Agent'\n } (${connection.targetAccountId})\\n`;\n const displayTopicId = connection.isPending\n ? '(Pending Request)'\n : connection.connectionTopicId;\n output += ` Topic: ${displayTopicId}\\n`;\n const statusText = connection.status || 'unknown';\n output += ` Status: ${statusText}\\n`;\n\n if (includeDetails) {\n if (connection.profileInfo?.bio) {\n output += ` Bio: ${connection.profileInfo.bio.substring(0, 100)}${\n connection.profileInfo.bio.length > 100 ? '...' : ''\n }\\n`;\n }\n\n if (connection.created) {\n const createdLabel = connection.isPending\n ? 'Request sent'\n : 'Connection established';\n output += ` ${createdLabel}: ${connection.created.toLocaleString()}\\n`;\n }\n\n if (connection.lastActivity) {\n output += ` Last activity: ${connection.lastActivity.toLocaleString()}\\n`;\n }\n }\n\n return output;\n }\n\n private async getEnhancedConnections(): Promise<unknown[]> {\n try {\n const { accountId } = this.getAccountAndSigner();\n if (!accountId) {\n return this.stateManager!.listConnections();\n }\n\n const connectionManager = this.stateManager!.getConnectionsManager();\n if (!connectionManager) {\n this.logger.error(NOT_INITIALIZED_ERROR);\n return this.stateManager!.listConnections();\n }\n\n const connections = await connectionManager.fetchConnectionData(\n accountId\n );\n\n for (const connection of connections) {\n this.stateManager!.addActiveConnection(\n connection as unknown as ActiveConnection\n );\n }\n\n return connections;\n } catch (error) {\n this.logger.error('Failed to get enhanced connections:', error);\n return this.stateManager!.listConnections();\n }\n }\n\n /**\n * Check messages on a connection\n */\n public async checkMessages(params: {\n targetIdentifier: string;\n fetchLatest?: boolean;\n lastMessagesCount?: number;\n }): Promise<this> {\n this.clearNotes();\n\n if (!this.stateManager) {\n throw new Error('StateManager is required to check messages');\n }\n\n const connection = this.stateManager.getConnectionByIdentifier(\n params.targetIdentifier\n );\n\n if (!connection) {\n this.executeResult = {\n success: false,\n error: `Could not find an active connection matching identifier \"${params.targetIdentifier}\". Use 'list_connections' to see active connections.`,\n } as ExecuteResult & { rawResult?: unknown };\n return this;\n }\n\n const connectionTopicId = connection.connectionTopicId || '';\n\n if (!connectionTopicId || !connectionTopicId.match(/^\\d+\\.\\d+\\.\\d+$/)) {\n this.logger.error(\n `Invalid connection topic ID format: ${connectionTopicId}`\n );\n this.executeResult = {\n success: false,\n error: `Invalid connection topic ID format: ${connectionTopicId}. Expected format: 0.0.XXXXX`,\n } as ExecuteResult & { rawResult?: unknown };\n return this;\n }\n\n const targetAgentName = connection.targetAgentName;\n const lastProcessedTimestamp =\n this.stateManager.getLastTimestamp(connectionTopicId);\n\n this.logger.info(\n `Checking messages for connection with ${targetAgentName} (${connection.targetAccountId}) on topic ${connectionTopicId} (fetchLatest: ${params.fetchLatest}, lastCount: ${params.lastMessagesCount}, since: ${lastProcessedTimestamp})`\n );\n\n try {\n const result = await this.getMessages(connectionTopicId);\n const allMessages = result.messages;\n\n if (!allMessages || allMessages.length === 0) {\n this.executeResult = {\n success: true,\n rawResult: {\n messages: [],\n message: `No messages found on connection topic ${connectionTopicId}.`,\n },\n } as ExecuteResult & { rawResult?: unknown };\n return this;\n }\n\n let messagesToProcess: HCSMessageWithTimestamp[] = [];\n let latestTimestampNanos = lastProcessedTimestamp;\n const isFetchingLatest = params.fetchLatest === true;\n\n if (isFetchingLatest) {\n this.logger.info('Fetching latest messages regardless of timestamp.');\n const count = params.lastMessagesCount ?? 1;\n messagesToProcess = allMessages.slice(-count);\n } else {\n this.logger.info(\n `Filtering for messages newer than ${lastProcessedTimestamp}`\n );\n messagesToProcess = allMessages.filter(\n (msg: HCSMessageWithTimestamp) => {\n const msgTimestampNanos = msg.timestamp * 1_000_000;\n return msgTimestampNanos > lastProcessedTimestamp;\n }\n );\n\n if (messagesToProcess.length > 0) {\n latestTimestampNanos = messagesToProcess.reduce(\n (maxTs, msg) => Math.max(maxTs, msg.timestamp * 1_000_000),\n lastProcessedTimestamp\n );\n }\n }\n\n if (messagesToProcess.length === 0) {\n const message = isFetchingLatest\n ? `Could not retrieve the latest message(s). No messages found on topic ${connectionTopicId}.`\n : `No new messages found for connection with ${targetAgentName} since last check.`;\n\n this.executeResult = {\n success: true,\n rawResult: {\n messages: [],\n message,\n },\n } as ExecuteResult & { rawResult?: unknown };\n return this;\n }\n\n this.logger.info(`Processing ${messagesToProcess.length} message(s).`);\n\n let outputString = isFetchingLatest\n ? `Latest message(s) from ${targetAgentName}:\\n`\n : `New messages from ${targetAgentName}:\\n`;\n\n const processedMessages: Array<{\n timestamp: number;\n sequenceNumber: number;\n content: string | undefined;\n raw: HCSMessageWithTimestamp;\n }> = [];\n\n for (const msg of messagesToProcess) {\n let content = msg.data;\n try {\n if (typeof content === 'string' && content.startsWith('hcs://')) {\n this.logger.debug(`Resolving inscribed message: ${content}`);\n content = await this.getMessageContent(content);\n this.logger.debug(`Resolved content length: ${content?.length}`);\n }\n\n let displayContent = content;\n try {\n const parsed = JSON.parse(content || '{}');\n if (\n parsed.p === 'hcs-10' &&\n parsed.op === 'message' &&\n parsed.data\n ) {\n const senderOpId = parsed.operator_id || 'unknown_sender';\n displayContent = `[${senderOpId}]: ${parsed.data}`;\n } else {\n displayContent = content;\n }\n } catch {\n displayContent = content;\n }\n\n const messageDate = new Date(msg.timestamp);\n outputString += `\\n[${messageDate.toLocaleString()}] (Seq: ${\n msg.sequence_number\n })\\n${displayContent}\\n`;\n\n processedMessages.push({\n timestamp: msg.timestamp,\n sequenceNumber: msg.sequence_number,\n content: displayContent,\n raw: msg,\n });\n } catch (error) {\n const errorMsg = `Error processing message (Seq: ${\n msg.sequence_number\n }): ${error instanceof Error ? error.message : String(error)}`;\n this.logger.error(errorMsg);\n outputString += `\\n[Error processing message Seq: ${msg.sequence_number}]\\n`;\n }\n }\n\n if (!isFetchingLatest && latestTimestampNanos > lastProcessedTimestamp) {\n this.logger.debug(\n `Updating timestamp for topic ${connectionTopicId} to ${latestTimestampNanos}`\n );\n this.stateManager.updateTimestamp(\n connectionTopicId,\n latestTimestampNanos\n );\n }\n\n this.executeResult = {\n success: true,\n rawResult: {\n messages: processedMessages,\n formattedOutput: outputString.trim(),\n targetAgentName,\n connectionTopicId,\n },\n } as ExecuteResult & { rawResult?: unknown };\n } catch (error) {\n this.logger.error(\n `Failed to check messages for topic ${connectionTopicId}: ${error}`\n );\n this.executeResult = {\n success: false,\n error: `Error checking messages for ${targetAgentName}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n } as ExecuteResult & { rawResult?: unknown };\n }\n\n return this;\n }\n\n /**\n * Find registrations using the configured registry\n */\n public async findRegistrations(params: {\n accountId?: string;\n tags?: number[];\n }): Promise<this> {\n this.clearNotes();\n\n try {\n const options: {\n network: StandardNetworkType;\n accountId?: string;\n tags?: number[];\n } = {\n network: this.network,\n };\n\n if (params.accountId) {\n options.accountId = params.accountId;\n }\n\n if (params.tags && params.tags.length > 0) {\n options.tags = params.tags;\n }\n\n const result = await this.standardClient.findRegistrations(options);\n\n if (!result.success || result.error) {\n this.executeResult = {\n success: false,\n error: `Error finding registrations: ${\n result.error || 'Unknown error'\n }`,\n } as ExecuteResult & { rawResult?: unknown };\n return this;\n }\n\n if (!result.registrations || result.registrations.length === 0) {\n this.executeResult = {\n success: true,\n rawResult: {\n registrations: [],\n message: 'No registrations found matching the criteria.',\n },\n } as ExecuteResult & { rawResult?: unknown };\n return this;\n }\n\n const formattedRegistrations = result.registrations\n .map((reg: unknown): string => {\n const registration = reg as {\n agent?: { name?: string; capabilities?: string[] };\n accountId?: string;\n };\n const agentName = registration.agent?.name || 'Unknown Agent';\n const accountId = registration.accountId || 'Unknown Account';\n const capabilities =\n registration.agent?.capabilities?.join(', ') || 'None';\n\n return `Agent: ${agentName} (${accountId}), Capabilities: ${capabilities}`;\n })\n .join('\\\\n');\n\n this.executeResult = {\n success: true,\n rawResult: {\n registrations: result.registrations,\n formattedOutput: `Found ${result.registrations.length} registration(s):\\\\n${formattedRegistrations}`,\n },\n } as ExecuteResult & { rawResult?: unknown };\n } catch (error) {\n this.logger.error('Error during FindRegistrations execution:', error);\n this.executeResult = {\n success: false,\n error: `Failed to search registrations: ${\n error instanceof Error ? error.message : String(error)\n }`,\n } as ExecuteResult & { rawResult?: unknown };\n }\n\n return this;\n }\n\n /**\n * Retrieve detailed profile information for an agent\n */\n public async retrieveProfile(params: {\n accountId: string;\n disableCache?: boolean;\n }): Promise<this> {\n this.clearNotes();\n\n try {\n const profileResponse = await this.standardClient.retrieveProfile(\n params.accountId,\n params.disableCache || false\n );\n\n if (!profileResponse.success) {\n this.executeResult = {\n success: false,\n error: `Failed to retrieve profile: ${\n profileResponse.error || 'Unknown error'\n }`,\n } as ExecuteResult & { rawResult?: unknown };\n return this;\n }\n\n const profile = profileResponse.profile;\n const topicInfo = profileResponse.topicInfo;\n\n let profileDetails = `Profile for ${params.accountId}:\\n`;\n profileDetails += `Name: ${profile.name || 'Unknown'}\\n`;\n profileDetails += `Bio: ${profile.bio || 'No bio provided'}\\n`;\n profileDetails += `Type: ${profile.type || 'Unknown'}\\n`;\n profileDetails += `Model: ${profile.model || 'Unknown'}\\n`;\n\n if (profile.capabilities && profile.capabilities.length > 0) {\n profileDetails += `Capabilities: ${profile.capabilities.join(', ')}\\n`;\n } else {\n profileDetails += `Capabilities: None listed\\n`;\n }\n\n if (topicInfo) {\n profileDetails += `Inbound Topic: ${\n topicInfo.inboundTopic || 'Unknown'\n }\\n`;\n profileDetails += `Outbound Topic: ${\n topicInfo.outboundTopic || 'Unknown'\n }\\n`;\n profileDetails += `Profile Topic: ${\n topicInfo.profileTopicId || 'Unknown'\n }\\n`;\n }\n\n if (profile.social && Object.keys(profile.social).length > 0) {\n profileDetails += `Social: ${Object.entries(profile.social)\n .map(\n ([platform, handle]: [string, unknown]): string =>\n `${platform}: ${handle}`\n )\n .join(', ')}\\n`;\n }\n\n if (profile.properties && Object.keys(profile.properties).length > 0) {\n profileDetails += `Properties: ${JSON.stringify(profile.properties)}\\n`;\n }\n\n this.executeResult = {\n success: true,\n rawResult: {\n profileDetails,\n rawProfile: profileResponse,\n },\n } as ExecuteResult & { rawResult?: unknown };\n } catch (error) {\n this.logger.error(\n `Unexpected error retrieving profile for ${params.accountId}:`,\n error\n );\n this.executeResult = {\n success: false,\n error: `Unexpected error retrieving profile for ${params.accountId}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n } as ExecuteResult & { rawResult?: unknown };\n }\n\n return this;\n }\n\n /**\n * Override execute to return stored HCS10 operation results\n */\n public override async execute(): Promise<ExecuteResult> {\n if (this.executeResult) {\n return {\n success: this.executeResult.success,\n transactionId: this.executeResult.transactionId,\n receipt: this.executeResult.receipt,\n scheduleId: this.executeResult.scheduleId,\n error: this.executeResult.error,\n rawResult: this.executeResult.rawResult,\n notes: this.notes,\n } as ExecuteResult & { rawResult?: unknown; notes?: string[] };\n }\n\n return {\n success: false,\n error: 'No operation result available. Call a builder method first.',\n };\n }\n}\n"],"names":["SDKLogger","HCS10Client","StandardAIAgentCapability","StandardInboundTopicType"],"mappings":";;;;;AAyBA,MAAM,wBAAwB;AA8GvB,MAAM,qBAAqB,mBAAmB;AAAA,EASnD,YACE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AAA,QAC1B,WAAW,KAAK,cAAc;AAAA,QAC9B,OAAO,KAAK;AAAA,MAAA;AAAA,IAEhB;AAEA,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,IAAA;AAAA,EAEX;AACF;"}
|
|
@@ -1,7 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BaseHCS2QueryTool } from "./standards-agent-kit.es19.js";
|
|
3
|
+
import { HCS2RegistryType } from "@hashgraphonline/standards-sdk";
|
|
4
|
+
const createRegistrySchema = z.object({
|
|
5
|
+
registryType: z.nativeEnum(HCS2RegistryType).optional().describe("Registry type: 0 for indexed, 1 for non-indexed (default: 0)"),
|
|
6
|
+
ttl: z.number().int().positive().optional().describe("Time to live in seconds (default: 86400)"),
|
|
7
|
+
adminKey: z.union([z.string(), z.boolean()]).optional().describe("Admin key: public key string or true to use operator key"),
|
|
8
|
+
submitKey: z.union([z.string(), z.boolean()]).optional().describe("Submit key: public key string or true to use operator key")
|
|
9
|
+
});
|
|
10
|
+
class CreateRegistryTool extends BaseHCS2QueryTool {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.name = "createHCS2Registry";
|
|
14
|
+
this.description = "Create a new HCS-2 registry topic for storing decentralized data";
|
|
15
|
+
}
|
|
16
|
+
get specificInputSchema() {
|
|
17
|
+
return createRegistrySchema;
|
|
18
|
+
}
|
|
19
|
+
async executeQuery(params, _runManager) {
|
|
20
|
+
try {
|
|
21
|
+
const result = await this.hcs2Builder.createRegistry({
|
|
22
|
+
registryType: params.registryType,
|
|
23
|
+
ttl: params.ttl,
|
|
24
|
+
adminKey: params.adminKey,
|
|
25
|
+
submitKey: params.submitKey
|
|
26
|
+
});
|
|
27
|
+
if (!result.success) {
|
|
28
|
+
throw new Error(result.error || "Failed to create registry");
|
|
29
|
+
}
|
|
30
|
+
return `Successfully created HCS-2 registry!
|
|
31
|
+
|
|
32
|
+
Topic ID: ${result.topicId}
|
|
33
|
+
Registry Type: ${params.registryType === 1 ? "Non-Indexed" : "Indexed"}
|
|
34
|
+
TTL: ${params.ttl || 86400} seconds
|
|
35
|
+
|
|
36
|
+
You can now register entries to this registry using the topic ID.`;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
const errorMessage = error instanceof Error ? error.message : "Failed to create HCS-2 registry";
|
|
39
|
+
throw new Error(`Registry creation failed: ${errorMessage}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
3
42
|
}
|
|
4
43
|
export {
|
|
5
|
-
|
|
44
|
+
CreateRegistryTool
|
|
6
45
|
};
|
|
7
46
|
//# sourceMappingURL=standards-agent-kit.es20.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es20.js","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es20.js","sources":["../../src/tools/hcs2/CreateRegistryTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseHCS2QueryTool } from './base-hcs2-tools';\nimport { HCS2RegistryType } from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\n\n/**\n * Schema for creating an HCS-2 registry\n */\nconst createRegistrySchema = z.object({\n registryType: z\n .nativeEnum(HCS2RegistryType)\n .optional()\n .describe('Registry type: 0 for indexed, 1 for non-indexed (default: 0)'),\n ttl: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Time to live in seconds (default: 86400)'),\n adminKey: z\n .union([z.string(), z.boolean()])\n .optional()\n .describe('Admin key: public key string or true to use operator key'),\n submitKey: z\n .union([z.string(), z.boolean()])\n .optional()\n .describe('Submit key: public key string or true to use operator key'),\n});\n\n/**\n * Tool for creating HCS-2 registries\n */\nexport class CreateRegistryTool extends BaseHCS2QueryTool<typeof createRegistrySchema> {\n name = 'createHCS2Registry';\n description = 'Create a new HCS-2 registry topic for storing decentralized data';\n\n get specificInputSchema() {\n return createRegistrySchema;\n }\n\n protected async executeQuery(\n params: z.infer<typeof createRegistrySchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<unknown> {\n try {\n const result = await this.hcs2Builder.createRegistry({\n registryType: params.registryType,\n ttl: params.ttl,\n adminKey: params.adminKey,\n submitKey: params.submitKey,\n });\n\n if (!result.success) {\n throw new Error(result.error || 'Failed to create registry');\n }\n\n return `Successfully created HCS-2 registry!\\n\\nTopic ID: ${result.topicId}\\nRegistry Type: ${params.registryType === 1 ? 'Non-Indexed' : 'Indexed'}\\nTTL: ${params.ttl || 86400} seconds\\n\\nYou can now register entries to this registry using the topic ID.`;\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Failed to create HCS-2 registry';\n throw new Error(`Registry creation failed: ${errorMessage}`);\n }\n }\n}"],"names":[],"mappings":";;;AAQA,MAAM,uBAAuB,EAAE,OAAO;AAAA,EACpC,cAAc,EACX,WAAW,gBAAgB,EAC3B,SAAA,EACA,SAAS,8DAA8D;AAAA,EAC1E,KAAK,EACF,OAAA,EACA,IAAA,EACA,SAAA,EACA,SAAA,EACA,SAAS,0CAA0C;AAAA,EACtD,UAAU,EACP,MAAM,CAAC,EAAE,OAAA,GAAU,EAAE,QAAA,CAAS,CAAC,EAC/B,SAAA,EACA,SAAS,0DAA0D;AAAA,EACtE,WAAW,EACR,MAAM,CAAC,EAAE,OAAA,GAAU,EAAE,QAAA,CAAS,CAAC,EAC/B,SAAA,EACA,SAAS,2DAA2D;AACzE,CAAC;AAKM,MAAM,2BAA2B,kBAA+C;AAAA,EAAhF,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAA,OAAO;AACP,SAAA,cAAc;AAAA,EAAA;AAAA,EAEd,IAAI,sBAAsB;AACxB,WAAO;AAAA,EACT;AAAA,EAEA,MAAgB,aACd,QACA,aACkB;AAClB,QAAI;AACF,YAAM,SAAS,MAAM,KAAK,YAAY,eAAe;AAAA,QACnD,cAAc,OAAO;AAAA,QACrB,KAAK,OAAO;AAAA,QACZ,UAAU,OAAO;AAAA,QACjB,WAAW,OAAO;AAAA,MAAA,CACnB;AAED,UAAI,CAAC,OAAO,SAAS;AACnB,cAAM,IAAI,MAAM,OAAO,SAAS,2BAA2B;AAAA,MAC7D;AAEA,aAAO;AAAA;AAAA,YAAqD,OAAO,OAAO;AAAA,iBAAoB,OAAO,iBAAiB,IAAI,gBAAgB,SAAS;AAAA,OAAU,OAAO,OAAO,KAAK;AAAA;AAAA;AAAA,IAClL,SAAS,OAAO;AACd,YAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU;AAC9D,YAAM,IAAI,MAAM,6BAA6B,YAAY,EAAE;AAAA,IAC7D;AAAA,EACF;AACF;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BaseHCS2QueryTool } from "./standards-agent-kit.es19.js";
|
|
3
|
+
const registerEntrySchema = z.object({
|
|
4
|
+
registryTopicId: z.string().regex(/^\d+\.\d+\.\d+$/).describe("The HCS-2 registry topic ID (e.g., 0.0.123456)"),
|
|
5
|
+
targetTopicId: z.string().regex(/^\d+\.\d+\.\d+$/).describe("The target topic ID to register (e.g., 0.0.123456)"),
|
|
6
|
+
metadata: z.string().optional().describe("Optional metadata URI (HIP-412 format)"),
|
|
7
|
+
memo: z.string().max(500).optional().describe("Optional memo (max 500 characters)")
|
|
8
|
+
});
|
|
9
|
+
class RegisterEntryTool extends BaseHCS2QueryTool {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.name = "registerHCS2Entry";
|
|
13
|
+
this.description = "Register a new entry in an HCS-2 registry";
|
|
14
|
+
}
|
|
15
|
+
get specificInputSchema() {
|
|
16
|
+
return registerEntrySchema;
|
|
17
|
+
}
|
|
18
|
+
async executeQuery(params, _runManager) {
|
|
19
|
+
try {
|
|
20
|
+
const result = await this.hcs2Builder.registerEntry(
|
|
21
|
+
params.registryTopicId,
|
|
22
|
+
{
|
|
23
|
+
targetTopicId: params.targetTopicId,
|
|
24
|
+
metadata: params.metadata,
|
|
25
|
+
memo: params.memo
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
if (!result.success) {
|
|
29
|
+
throw new Error(result.error || "Failed to register entry");
|
|
30
|
+
}
|
|
31
|
+
return `Successfully registered entry in HCS-2 registry!
|
|
32
|
+
|
|
33
|
+
Registry Topic: ${params.registryTopicId}
|
|
34
|
+
Target Topic ID: ${params.targetTopicId}${params.metadata ? `
|
|
35
|
+
Metadata: ${params.metadata}` : ""}${params.memo ? `
|
|
36
|
+
Memo: ${params.memo}` : ""}
|
|
37
|
+
|
|
38
|
+
The entry has been added to the registry.`;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
const errorMessage = error instanceof Error ? error.message : "Failed to register entry";
|
|
41
|
+
throw new Error(`Entry registration failed: ${errorMessage}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
RegisterEntryTool
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=standards-agent-kit.es21.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es21.js","sources":["../../src/tools/hcs2/RegisterEntryTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseHCS2QueryTool } from './base-hcs2-tools';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\n\n/**\n * Schema for registering an entry in HCS-2\n */\nconst registerEntrySchema = z.object({\n registryTopicId: z\n .string()\n .regex(/^\\d+\\.\\d+\\.\\d+$/)\n .describe('The HCS-2 registry topic ID (e.g., 0.0.123456)'),\n targetTopicId: z\n .string()\n .regex(/^\\d+\\.\\d+\\.\\d+$/)\n .describe('The target topic ID to register (e.g., 0.0.123456)'),\n metadata: z\n .string()\n .optional()\n .describe('Optional metadata URI (HIP-412 format)'),\n memo: z\n .string()\n .max(500)\n .optional()\n .describe('Optional memo (max 500 characters)'),\n});\n\n/**\n * Tool for registering entries in HCS-2 registries\n */\nexport class RegisterEntryTool extends BaseHCS2QueryTool<typeof registerEntrySchema> {\n name = 'registerHCS2Entry';\n description = 'Register a new entry in an HCS-2 registry';\n\n get specificInputSchema() {\n return registerEntrySchema;\n }\n\n protected async executeQuery(\n params: z.infer<typeof registerEntrySchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<unknown> {\n try {\n const result = await this.hcs2Builder.registerEntry(\n params.registryTopicId,\n {\n targetTopicId: params.targetTopicId,\n metadata: params.metadata,\n memo: params.memo,\n }\n );\n\n if (!result.success) {\n throw new Error(result.error || 'Failed to register entry');\n }\n\n return `Successfully registered entry in HCS-2 registry!\\n\\nRegistry Topic: ${params.registryTopicId}\\nTarget Topic ID: ${params.targetTopicId}${params.metadata ? `\\nMetadata: ${params.metadata}` : ''}${params.memo ? `\\nMemo: ${params.memo}` : ''}\\n\\nThe entry has been added to the registry.`;\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Failed to register entry';\n throw new Error(`Entry registration failed: ${errorMessage}`);\n }\n }\n}"],"names":[],"mappings":";;AAOA,MAAM,sBAAsB,EAAE,OAAO;AAAA,EACnC,iBAAiB,EACd,OAAA,EACA,MAAM,iBAAiB,EACvB,SAAS,gDAAgD;AAAA,EAC5D,eAAe,EACZ,OAAA,EACA,MAAM,iBAAiB,EACvB,SAAS,oDAAoD;AAAA,EAChE,UAAU,EACP,OAAA,EACA,SAAA,EACA,SAAS,wCAAwC;AAAA,EACpD,MAAM,EACH,SACA,IAAI,GAAG,EACP,WACA,SAAS,oCAAoC;AAClD,CAAC;AAKM,MAAM,0BAA0B,kBAA8C;AAAA,EAA9E,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAA,OAAO;AACP,SAAA,cAAc;AAAA,EAAA;AAAA,EAEd,IAAI,sBAAsB;AACxB,WAAO;AAAA,EACT;AAAA,EAEA,MAAgB,aACd,QACA,aACkB;AAClB,QAAI;AACF,YAAM,SAAS,MAAM,KAAK,YAAY;AAAA,QACpC,OAAO;AAAA,QACP;AAAA,UACE,eAAe,OAAO;AAAA,UACtB,UAAU,OAAO;AAAA,UACjB,MAAM,OAAO;AAAA,QAAA;AAAA,MACf;AAGF,UAAI,CAAC,OAAO,SAAS;AACnB,cAAM,IAAI,MAAM,OAAO,SAAS,0BAA0B;AAAA,MAC5D;AAEA,aAAO;AAAA;AAAA,kBAAuE,OAAO,eAAe;AAAA,mBAAsB,OAAO,aAAa,GAAG,OAAO,WAAW;AAAA,YAAe,OAAO,QAAQ,KAAK,EAAE,GAAG,OAAO,OAAO;AAAA,QAAW,OAAO,IAAI,KAAK,EAAE;AAAA;AAAA;AAAA,IACxP,SAAS,OAAO;AACd,YAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU;AAC9D,YAAM,IAAI,MAAM,8BAA8B,YAAY,EAAE;AAAA,IAC9D;AAAA,EACF;AACF;"}
|