@hashgraphonline/standards-sdk 0.0.113 → 0.0.114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/cjs/hcs-10/base-client.d.ts +2 -0
  2. package/dist/cjs/hcs-10/base-client.d.ts.map +1 -1
  3. package/dist/cjs/hcs-10/browser.d.ts +2 -0
  4. package/dist/cjs/hcs-10/browser.d.ts.map +1 -1
  5. package/dist/cjs/hcs-10/connections-manager.d.ts +1 -0
  6. package/dist/cjs/hcs-10/connections-manager.d.ts.map +1 -1
  7. package/dist/cjs/hcs-10/errors.d.ts.map +1 -1
  8. package/dist/cjs/hcs-10/registrations.d.ts.map +1 -1
  9. package/dist/cjs/hcs-10/sdk.d.ts.map +1 -1
  10. package/dist/cjs/hcs-10/types.d.ts +2 -0
  11. package/dist/cjs/hcs-10/types.d.ts.map +1 -1
  12. package/dist/cjs/hcs-11/client.d.ts.map +1 -1
  13. package/dist/cjs/hcs-11/types.d.ts +1 -0
  14. package/dist/cjs/hcs-11/types.d.ts.map +1 -1
  15. package/dist/cjs/hcs-3/src/index.d.ts.map +1 -1
  16. package/dist/cjs/hcs-7/evm-bridge.d.ts.map +1 -1
  17. package/dist/cjs/hcs-7/redis-cache.d.ts.map +1 -1
  18. package/dist/cjs/hcs-7/wasm-bridge.d.ts.map +1 -1
  19. package/dist/cjs/index-C8CnOC88.cjs +11 -0
  20. package/dist/cjs/index-C8CnOC88.cjs.map +1 -0
  21. package/dist/cjs/{index-CHar8dVv-SclbHQNq.cjs → index-CHar8dVv-CO7x6bkg.cjs} +2 -2
  22. package/dist/cjs/{index-CHar8dVv-SclbHQNq.cjs.map → index-CHar8dVv-CO7x6bkg.cjs.map} +1 -1
  23. package/dist/cjs/services/mirror-node.d.ts +1 -1
  24. package/dist/cjs/services/mirror-node.d.ts.map +1 -1
  25. package/dist/cjs/standards-sdk.cjs +1 -1
  26. package/dist/cjs/utils/logger.d.ts +1 -1
  27. package/dist/cjs/utils/logger.d.ts.map +1 -1
  28. package/dist/cjs/utils/parsers/hts-parser.d.ts.map +1 -1
  29. package/dist/cjs/utils/parsers/scs-parser.d.ts.map +1 -1
  30. package/dist/cjs/utils/progress-reporter.d.ts.map +1 -1
  31. package/dist/cjs/utils/sleep.d.ts.map +1 -1
  32. package/dist/cjs/utils/transaction-parser-types.d.ts.map +1 -1
  33. package/dist/es/hcs-10/base-client.d.ts +2 -0
  34. package/dist/es/hcs-10/base-client.d.ts.map +1 -1
  35. package/dist/es/hcs-10/browser.d.ts +2 -0
  36. package/dist/es/hcs-10/browser.d.ts.map +1 -1
  37. package/dist/es/hcs-10/connections-manager.d.ts +1 -0
  38. package/dist/es/hcs-10/connections-manager.d.ts.map +1 -1
  39. package/dist/es/hcs-10/errors.d.ts.map +1 -1
  40. package/dist/es/hcs-10/registrations.d.ts.map +1 -1
  41. package/dist/es/hcs-10/sdk.d.ts.map +1 -1
  42. package/dist/es/hcs-10/types.d.ts +2 -0
  43. package/dist/es/hcs-10/types.d.ts.map +1 -1
  44. package/dist/es/hcs-11/client.d.ts.map +1 -1
  45. package/dist/es/hcs-11/types.d.ts +1 -0
  46. package/dist/es/hcs-11/types.d.ts.map +1 -1
  47. package/dist/es/hcs-3/src/index.d.ts.map +1 -1
  48. package/dist/es/hcs-7/evm-bridge.d.ts.map +1 -1
  49. package/dist/es/hcs-7/redis-cache.d.ts.map +1 -1
  50. package/dist/es/hcs-7/wasm-bridge.d.ts.map +1 -1
  51. package/dist/es/services/mirror-node.d.ts +1 -1
  52. package/dist/es/services/mirror-node.d.ts.map +1 -1
  53. package/dist/es/standards-sdk.es10.js +7 -16
  54. package/dist/es/standards-sdk.es10.js.map +1 -1
  55. package/dist/es/standards-sdk.es12.js.map +1 -1
  56. package/dist/es/standards-sdk.es13.js +5 -4
  57. package/dist/es/standards-sdk.es13.js.map +1 -1
  58. package/dist/es/standards-sdk.es14.js.map +1 -1
  59. package/dist/es/standards-sdk.es15.js +13 -3
  60. package/dist/es/standards-sdk.es15.js.map +1 -1
  61. package/dist/es/standards-sdk.es16.js.map +1 -1
  62. package/dist/es/standards-sdk.es17.js.map +1 -1
  63. package/dist/es/standards-sdk.es18.js.map +1 -1
  64. package/dist/es/standards-sdk.es19.js.map +1 -1
  65. package/dist/es/standards-sdk.es2.js +5 -1
  66. package/dist/es/standards-sdk.es2.js.map +1 -1
  67. package/dist/es/standards-sdk.es20.js.map +1 -1
  68. package/dist/es/standards-sdk.es21.js +9 -27
  69. package/dist/es/standards-sdk.es21.js.map +1 -1
  70. package/dist/es/standards-sdk.es22.js.map +1 -1
  71. package/dist/es/standards-sdk.es23.js.map +1 -1
  72. package/dist/es/standards-sdk.es25.js.map +1 -1
  73. package/dist/es/standards-sdk.es26.js.map +1 -1
  74. package/dist/es/standards-sdk.es27.js.map +1 -1
  75. package/dist/es/standards-sdk.es28.js.map +1 -1
  76. package/dist/es/standards-sdk.es29.js.map +1 -1
  77. package/dist/es/standards-sdk.es3.js +17 -9
  78. package/dist/es/standards-sdk.es3.js.map +1 -1
  79. package/dist/es/standards-sdk.es30.js.map +1 -1
  80. package/dist/es/standards-sdk.es31.js.map +1 -1
  81. package/dist/es/standards-sdk.es33.js.map +1 -1
  82. package/dist/es/standards-sdk.es4.js +4 -1
  83. package/dist/es/standards-sdk.es4.js.map +1 -1
  84. package/dist/es/standards-sdk.es5.js +4 -7
  85. package/dist/es/standards-sdk.es5.js.map +1 -1
  86. package/dist/es/standards-sdk.es6.js.map +1 -1
  87. package/dist/es/standards-sdk.es7.js +7 -6
  88. package/dist/es/standards-sdk.es7.js.map +1 -1
  89. package/dist/es/standards-sdk.es8.js +8 -9
  90. package/dist/es/standards-sdk.es8.js.map +1 -1
  91. package/dist/es/standards-sdk.es9.js +1 -3
  92. package/dist/es/standards-sdk.es9.js.map +1 -1
  93. package/dist/es/utils/logger.d.ts +1 -1
  94. package/dist/es/utils/logger.d.ts.map +1 -1
  95. package/dist/es/utils/parsers/hts-parser.d.ts.map +1 -1
  96. package/dist/es/utils/parsers/scs-parser.d.ts.map +1 -1
  97. package/dist/es/utils/progress-reporter.d.ts.map +1 -1
  98. package/dist/es/utils/sleep.d.ts.map +1 -1
  99. package/dist/es/utils/transaction-parser-types.d.ts.map +1 -1
  100. package/dist/umd/hcs-10/base-client.d.ts +2 -0
  101. package/dist/umd/hcs-10/base-client.d.ts.map +1 -1
  102. package/dist/umd/hcs-10/browser.d.ts +2 -0
  103. package/dist/umd/hcs-10/browser.d.ts.map +1 -1
  104. package/dist/umd/hcs-10/connections-manager.d.ts +1 -0
  105. package/dist/umd/hcs-10/connections-manager.d.ts.map +1 -1
  106. package/dist/umd/hcs-10/errors.d.ts.map +1 -1
  107. package/dist/umd/hcs-10/registrations.d.ts.map +1 -1
  108. package/dist/umd/hcs-10/sdk.d.ts.map +1 -1
  109. package/dist/umd/hcs-10/types.d.ts +2 -0
  110. package/dist/umd/hcs-10/types.d.ts.map +1 -1
  111. package/dist/umd/hcs-11/client.d.ts.map +1 -1
  112. package/dist/umd/hcs-11/types.d.ts +1 -0
  113. package/dist/umd/hcs-11/types.d.ts.map +1 -1
  114. package/dist/umd/hcs-3/src/index.d.ts.map +1 -1
  115. package/dist/umd/hcs-7/evm-bridge.d.ts.map +1 -1
  116. package/dist/umd/hcs-7/redis-cache.d.ts.map +1 -1
  117. package/dist/umd/hcs-7/wasm-bridge.d.ts.map +1 -1
  118. package/dist/umd/services/mirror-node.d.ts +1 -1
  119. package/dist/umd/services/mirror-node.d.ts.map +1 -1
  120. package/dist/umd/standards-sdk.umd.js +6 -6
  121. package/dist/umd/standards-sdk.umd.js.map +1 -1
  122. package/dist/umd/utils/logger.d.ts +1 -1
  123. package/dist/umd/utils/logger.d.ts.map +1 -1
  124. package/dist/umd/utils/parsers/hts-parser.d.ts.map +1 -1
  125. package/dist/umd/utils/parsers/scs-parser.d.ts.map +1 -1
  126. package/dist/umd/utils/progress-reporter.d.ts.map +1 -1
  127. package/dist/umd/utils/sleep.d.ts.map +1 -1
  128. package/dist/umd/utils/transaction-parser-types.d.ts.map +1 -1
  129. package/package.json +7 -2
  130. package/dist/cjs/index-CcE0yY9g.cjs +0 -11
  131. package/dist/cjs/index-CcE0yY9g.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"standards-sdk.es10.js","sources":["../../src/hcs-10/connections-manager.ts"],"sourcesContent":["import { Logger, LoggerOptions } from '../utils/logger';\nimport { HCSMessage, HCS10BaseClient } from './base-client';\nimport { AIAgentProfile } from '../hcs-11';\nimport { TransactMessage } from './types';\n\n/**\n * Represents a connection request between agents\n */\nexport interface ConnectionRequest {\n id: number;\n requesterId: string;\n requesterTopicId: string;\n targetAccountId: string;\n targetTopicId: string;\n operatorId: string;\n sequenceNumber: number;\n created: Date;\n memo?: string;\n status: 'pending' | 'confirmed' | 'rejected';\n}\n\n/**\n * Represents an active connection between agents\n */\nexport interface Connection {\n connectionTopicId: string;\n targetAccountId: string;\n targetAgentName?: string;\n targetInboundTopicId?: string;\n targetOutboundTopicId?: string;\n status: 'pending' | 'established' | 'needs_confirmation' | 'closed';\n isPending: boolean;\n needsConfirmation: boolean;\n memo?: string;\n created: Date;\n lastActivity?: Date;\n profileInfo?: AIAgentProfile;\n connectionRequestId?: number;\n confirmedRequestId?: number;\n requesterOutboundTopicId?: string;\n inboundRequestId?: number;\n closedReason?: string;\n closeMethod?: string;\n uniqueRequestKey?: string;\n originTopicId?: string;\n processed: boolean;\n}\n\n/**\n * Options for the connections manager\n */\nexport interface ConnectionsManagerOptions {\n logLevel?: 'debug' | 'info' | 'warn' | 'error';\n filterPendingAccountIds?: string[];\n baseClient: HCS10BaseClient;\n}\n\n/**\n * Defines the interface for a connections manager that handles HCS-10 connections\n * This interface represents the public API of ConnectionsManager\n */\nexport interface IConnectionsManager {\n /**\n * Fetches and processes connection data using the configured client\n * @param accountId - The account ID to fetch connection data for\n * @returns A promise that resolves to an array of Connection objects\n */\n fetchConnectionData(accountId: string): Promise<Connection[]>;\n\n /**\n * Process outbound messages to track connection requests and confirmations\n * @param messages - The messages to process\n * @param accountId - The account ID that sent the messages\n * @returns Array of connections after processing\n */\n processOutboundMessages(\n messages: HCSMessage[],\n accountId: string\n ): Connection[];\n\n /**\n * Process inbound messages to track connection requests and confirmations\n * @param messages - The messages to process\n * @returns Array of connections after processing\n */\n processInboundMessages(messages: HCSMessage[]): Connection[];\n\n /**\n * Process connection topic messages to update last activity time\n * @param connectionTopicId - The topic ID of the connection\n * @param messages - The messages to process\n * @returns The updated connection or undefined if not found\n */\n processConnectionMessages(\n connectionTopicId: string,\n messages: HCSMessage[]\n ): Connection | undefined;\n\n /**\n * Adds or updates profile information for a connection\n * @param accountId - The account ID to add profile info for\n * @param profile - The profile information\n */\n addProfileInfo(accountId: string, profile: AIAgentProfile): void;\n\n /**\n * Gets all connections\n * @returns Array of all connections that should be visible\n */\n getAllConnections(): Connection[];\n\n /**\n * Gets all pending connection requests\n * @returns Array of pending connection requests\n */\n getPendingRequests(): Connection[];\n\n /**\n * Gets all active (established) connections\n * @returns Array of active connections\n */\n getActiveConnections(): Connection[];\n\n /**\n * Gets all connections needing confirmation\n * @returns Array of connections needing confirmation\n */\n getConnectionsNeedingConfirmation(): Connection[];\n\n /**\n * Gets a connection by its topic ID\n * @param connectionTopicId - The topic ID to look up\n * @returns The connection with the given topic ID, or undefined if not found\n */\n getConnectionByTopicId(connectionTopicId: string): Connection | undefined;\n\n /**\n * Gets a connection by account ID\n * @param accountId - The account ID to look up\n * @returns The connection with the given account ID, or undefined if not found\n */\n getConnectionByAccountId(accountId: string): Connection | undefined;\n\n /**\n * Gets all connections for a specific account ID\n * @param accountId - The account ID to look up\n * @returns Array of connections for the given account ID\n */\n getConnectionsByAccountId(accountId: string): Connection[];\n\n /**\n * Updates or adds a connection\n * @param connection - The connection to update or add\n */\n updateOrAddConnection(connection: Connection): void;\n\n /**\n * Clears all tracked connections and requests\n */\n clearAll(): void;\n\n /**\n * Checks if a given connection request has been processed already\n * This uses a combination of topic ID and request ID to uniquely identify requests\n *\n * @param inboundTopicId - The inbound topic ID where the request was received\n * @param requestId - The sequence number (request ID)\n * @returns True if this specific request has been processed, false otherwise\n */\n isConnectionRequestProcessed(\n inboundTopicId: string,\n requestId: number\n ): boolean;\n\n /**\n * Marks a specific connection request as processed\n *\n * @param inboundTopicId - The inbound topic ID where the request was received\n * @param requestId - The sequence number (request ID)\n * @returns True if a matching connection was found and marked, false otherwise\n */\n markConnectionRequestProcessed(\n inboundTopicId: string,\n requestId: number\n ): boolean;\n\n /**\n * Gets pending transactions from a specific connection\n * @param connectionTopicId - The connection topic ID to check for transactions\n * @param limit - Optional limit for the number of transactions to return\n * @returns Array of pending transaction messages sorted by timestamp (newest first)\n */\n getPendingTransactions(\n connectionTopicId: string,\n limit?: number\n ): Promise<TransactMessage[]>;\n\n /**\n * Gets the status of a scheduled transaction\n * @param scheduleId - The schedule ID to check\n * @returns Status of the scheduled transaction\n */\n getScheduledTransactionStatus(scheduleId: string): Promise<{\n executed: boolean;\n executedTimestamp?: string;\n deleted: boolean;\n expirationTime?: string;\n }>;\n\n /**\n * Gets the timestamp of the last message sent by the specified operator on the connection topic\n * @param connectionTopicId - The topic ID to check\n * @param operatorAccountId - The account ID of the operator\n * @returns The timestamp of the last message or undefined if no messages found\n */\n getLastOperatorActivity(\n connectionTopicId: string,\n operatorAccountId: string\n ): Promise<Date | undefined>;\n}\n\n/**\n * ConnectionsManager provides a unified way to track and manage HCS-10 connections\n * across different applications. It works with both frontend and backend implementations.\n */\nexport class ConnectionsManager implements IConnectionsManager {\n private logger: Logger;\n private connections: Map<string, Connection> = new Map();\n private pendingRequests: Map<string, ConnectionRequest> = new Map();\n private profileCache: Map<string, AIAgentProfile> = new Map();\n private filterPendingAccountIds: Set<string> = new Set();\n private baseClient: HCS10BaseClient;\n\n /**\n * Creates a new ConnectionsManager instance\n */\n constructor(options: ConnectionsManagerOptions) {\n const loggerOptions: LoggerOptions = {\n module: 'ConnectionsManager',\n level: options?.logLevel || 'info',\n prettyPrint: true,\n };\n this.logger = new Logger(loggerOptions);\n\n if (options?.filterPendingAccountIds) {\n this.filterPendingAccountIds = new Set(options.filterPendingAccountIds);\n }\n\n if (!options.baseClient) {\n throw new Error('ConnectionsManager requires a baseClient to operate');\n }\n\n this.baseClient = options.baseClient;\n }\n\n /**\n * Fetches and processes connection data using the configured client\n * @param accountId - The account ID to fetch connection data for\n * @returns A promise that resolves to an array of Connection objects\n */\n async fetchConnectionData(accountId: string): Promise<Connection[]> {\n try {\n const topicInfo = await this.baseClient.retrieveCommunicationTopics(\n accountId\n );\n\n const isValidTopicId = (topicId: string): boolean => {\n return Boolean(topicId) && !topicId.includes(':');\n };\n\n if (\n !isValidTopicId(topicInfo.inboundTopic) ||\n !isValidTopicId(topicInfo.outboundTopic)\n ) {\n this.logger.warn(\n 'Invalid topic IDs detected in retrieved communication topics'\n );\n return this.getAllConnections();\n }\n\n const [outboundMessagesResult, inboundMessagesResult] = await Promise.all(\n [\n this.baseClient.getMessages(topicInfo.outboundTopic),\n this.baseClient.getMessages(topicInfo.inboundTopic),\n ]\n );\n\n this.processOutboundMessages(\n outboundMessagesResult.messages || [],\n accountId\n );\n this.processInboundMessages(inboundMessagesResult.messages || []);\n\n const pendingCount = Array.from(this.connections.values()).filter(\n (conn) => conn.status === 'pending' || conn.isPending\n ).length;\n this.logger.debug(\n `Processed ${\n outboundMessagesResult.messages?.length || 0\n } outbound and ${\n inboundMessagesResult.messages?.length || 0\n } inbound messages. Found ${pendingCount} pending connections.`\n );\n\n await this.checkTargetInboundTopicsForConfirmations();\n await this.checkOutboundRequestsForConfirmations();\n await this.fetchProfilesForConnections();\n await this.fetchConnectionActivity();\n\n return this.getAllConnections();\n } catch (error) {\n this.logger.error('Error fetching connection data:', error);\n return this.getAllConnections();\n }\n }\n\n /**\n * Checks target agent inbound topics to find confirmations for pending requests\n * that might not be visible in our local messages\n */\n private async checkTargetInboundTopicsForConfirmations(): Promise<void> {\n const pendingConnections = Array.from(this.connections.values()).filter(\n (conn) =>\n (conn.isPending || conn.status === 'pending') &&\n conn.targetInboundTopicId\n );\n\n if (pendingConnections.length === 0) {\n return;\n }\n\n const pendingRequestsByTarget = new Map<string, Connection[]>();\n\n pendingConnections.forEach((conn) => {\n if (conn.targetInboundTopicId) {\n const requests =\n pendingRequestsByTarget.get(conn.targetInboundTopicId) || [];\n requests.push(conn);\n pendingRequestsByTarget.set(conn.targetInboundTopicId, requests);\n }\n });\n\n const MAX_FETCH_ATTEMPTS = 2;\n const FETCH_DELAY_MS = 500;\n\n for (const [\n targetInboundTopicId,\n requests,\n ] of pendingRequestsByTarget.entries()) {\n for (let attempt = 1; attempt <= MAX_FETCH_ATTEMPTS; attempt++) {\n try {\n const targetMessagesResult = await this.baseClient.getMessages(\n targetInboundTopicId\n );\n const targetMessages = targetMessagesResult.messages || [];\n\n let confirmedAny = false;\n\n for (const conn of requests) {\n const requestId = conn.connectionRequestId;\n if (!requestId) {\n continue;\n }\n\n const confirmationMsg = targetMessages.find((msg) => {\n if (msg.op !== 'connection_created' || !msg.connection_topic_id) {\n return false;\n }\n\n if (msg.connection_id !== requestId) {\n return false;\n }\n\n if (conn.uniqueRequestKey) {\n const keyParts = conn.uniqueRequestKey.split(':');\n if (keyParts.length > 1) {\n const operatorIdPart = keyParts[1];\n\n if (msg.operator_id && msg.operator_id === operatorIdPart) {\n return true;\n }\n\n if (msg.connected_account_id === conn.targetAccountId) {\n return true;\n }\n }\n }\n\n return true;\n });\n\n if (confirmationMsg?.connection_topic_id) {\n confirmedAny = true;\n\n const connectionTopicId = confirmationMsg.connection_topic_id;\n\n let pendingKey = conn.uniqueRequestKey;\n\n const newConnection: Connection = {\n connectionTopicId,\n targetAccountId: conn.targetAccountId,\n targetAgentName: conn.targetAgentName,\n targetInboundTopicId: conn.targetInboundTopicId,\n status: 'established',\n isPending: false,\n needsConfirmation: false,\n created: new Date(confirmationMsg.created || conn.created),\n profileInfo: conn.profileInfo,\n connectionRequestId: requestId,\n uniqueRequestKey: conn.uniqueRequestKey,\n originTopicId: conn.originTopicId,\n processed: conn.processed,\n memo: conn.memo,\n };\n\n this.connections.set(connectionTopicId, newConnection);\n\n if (pendingKey) {\n this.connections.delete(pendingKey);\n }\n\n this.logger.debug(\n `Confirmed connection in target inbound topic: ${connectionTopicId}`\n );\n }\n }\n\n if (confirmedAny || attempt === MAX_FETCH_ATTEMPTS) {\n break;\n }\n\n await new Promise((resolve) => setTimeout(resolve, FETCH_DELAY_MS));\n } catch (error) {\n this.logger.debug(\n `Error fetching target inbound topic ${targetInboundTopicId}:`,\n error\n );\n if (attempt === MAX_FETCH_ATTEMPTS) {\n break;\n }\n await new Promise((resolve) => setTimeout(resolve, FETCH_DELAY_MS));\n }\n }\n }\n }\n\n /**\n * Checks target agents' inbound topics for confirmations of our outbound connection requests\n * This complements checkTargetInboundTopicsForConfirmations by looking for confirmations\n * that might have been sent to the target agent's inbound topic rather than our own\n */\n private async checkOutboundRequestsForConfirmations(): Promise<void> {\n const allConnections = Array.from(this.connections.values());\n this.logger.info(`Total connections in map: ${allConnections.length}`);\n\n const pendingByStatus = allConnections.filter(\n (conn) => conn.status === 'pending'\n );\n this.logger.info(\n `Connections with status='pending': ${pendingByStatus.length}`\n );\n\n const pendingConnections = allConnections.filter(\n (conn) => conn.status === 'pending'\n );\n\n if (!Boolean(pendingConnections?.length)) {\n this.logger.info('No pending connections found');\n return;\n }\n\n for (const conn of pendingConnections) {\n this.logger.debug(\n `Processing pending connection: ${conn.connectionTopicId}`\n );\n\n if (!conn.targetAccountId) {\n this.logger.debug(\n `Skipping connection ${conn.connectionTopicId} - no targetAccountId`\n );\n continue;\n }\n\n let targetInboundTopicId = conn.targetInboundTopicId;\n if (!targetInboundTopicId) {\n try {\n const profileResponse = await this.baseClient.retrieveProfile(\n conn.targetAccountId\n );\n if (profileResponse?.profile?.inboundTopicId) {\n targetInboundTopicId = profileResponse.profile.inboundTopicId;\n this.connections.set(conn.connectionTopicId, {\n ...conn,\n targetInboundTopicId,\n });\n this.logger.debug(\n `Updated connection ${conn.connectionTopicId} with inbound topic ID: ${targetInboundTopicId}`\n );\n } else {\n this.logger.debug(\n `Couldn't get inbound topic ID for account ${conn.targetAccountId}`\n );\n continue;\n }\n } catch (error) {\n this.logger.debug(\n `Error fetching profile for ${conn.targetAccountId}: ${error}`\n );\n continue;\n }\n }\n\n if (!targetInboundTopicId || targetInboundTopicId.includes(':')) {\n this.logger.debug(\n `Skipping invalid inbound topic format: ${targetInboundTopicId}`\n );\n continue;\n }\n\n const requestId = conn.connectionRequestId || conn.inboundRequestId;\n if (!requestId) {\n this.logger.debug(\n `Skipping connection ${conn.connectionTopicId} - no request ID`\n );\n continue;\n }\n\n try {\n this.logger.debug(\n `Checking for confirmations on topic ${targetInboundTopicId} for request ID ${requestId}`\n );\n const targetMessagesResult = await this.baseClient.getMessages(\n targetInboundTopicId\n );\n const targetMessages = targetMessagesResult.messages || [];\n\n const confirmationMsg = targetMessages.find(\n (msg) =>\n msg.op === 'connection_created' &&\n msg.connection_id === requestId &&\n msg.connection_topic_id\n );\n\n if (confirmationMsg?.connection_topic_id) {\n const connectionTopicId = confirmationMsg.connection_topic_id;\n this.logger.info(\n `Found confirmation for request #${requestId} to ${conn.targetAccountId} on their inbound topic`\n );\n\n this.connections.set(conn.connectionTopicId, {\n ...conn,\n connectionTopicId,\n status: 'established',\n isPending: false,\n needsConfirmation: false,\n created: new Date(confirmationMsg.created || conn.created),\n lastActivity: new Date(confirmationMsg.created || conn.created),\n });\n } else {\n this.logger.debug(\n `No confirmation found for request ID ${requestId} on topic ${targetInboundTopicId}`\n );\n }\n } catch (error) {\n this.logger.warn(\n `Error checking for confirmations on target inbound topic for ${conn.targetAccountId}: ${error}`\n );\n }\n }\n }\n\n /**\n * Fetches profiles for all connected accounts\n * @param accountId - The account ID making the request\n */\n private async fetchProfilesForConnections(): Promise<void> {\n const targetAccountIds = new Set<string>();\n\n for (const connection of this.connections.values()) {\n if (\n connection.targetAccountId &&\n !this.profileCache.has(connection.targetAccountId)\n ) {\n targetAccountIds.add(connection.targetAccountId);\n }\n }\n\n const accountIdPromises = Array.from(targetAccountIds).map(\n async (targetId) => {\n try {\n const profileResponse = await this.baseClient.retrieveProfile(\n targetId\n );\n if (profileResponse.success && profileResponse.profile) {\n this.addProfileInfo(targetId, profileResponse.profile);\n\n this.updatePendingConnectionsWithProfileInfo(\n targetId,\n profileResponse.profile\n );\n }\n } catch (error) {\n this.logger.debug(`Failed to fetch profile for ${targetId}:`, error);\n }\n }\n );\n\n await Promise.allSettled(accountIdPromises);\n }\n\n /**\n * Updates pending connections with inbound topic IDs from profile info\n * @param accountId - The account ID to update connections for\n * @param profile - The profile containing the inbound topic ID\n */\n private updatePendingConnectionsWithProfileInfo(\n accountId: string,\n profile: AIAgentProfile\n ): void {\n const pendingConnections = Array.from(this.connections.values()).filter(\n (conn) =>\n conn.targetAccountId === accountId &&\n (conn.isPending || conn.needsConfirmation) &&\n !conn.targetInboundTopicId\n );\n\n if (pendingConnections.length > 0 && profile.inboundTopicId) {\n for (const conn of pendingConnections) {\n const updatedConn = {\n ...conn,\n targetInboundTopicId: profile.inboundTopicId,\n };\n this.connections.set(conn.connectionTopicId, updatedConn);\n }\n }\n }\n\n /**\n * Fetches activity from active connection topics\n * Updates the lastActivity timestamp for each connection based on latest messages\n * @returns Promise that resolves when all activity has been fetched\n */\n private async fetchConnectionActivity(): Promise<void> {\n const activeConnections = this.getActiveConnections();\n\n const validConnections = activeConnections.filter((connection) => {\n const topicId = connection.connectionTopicId;\n\n if (!topicId || topicId.includes(':') || !topicId.match(/^0\\.0\\.\\d+$/)) {\n this.logger.debug(\n `Skipping activity fetch for invalid topic ID format: ${topicId}`\n );\n return false;\n }\n return true;\n });\n\n const activityPromises = validConnections.map(async (connection) => {\n try {\n const topicId = connection.connectionTopicId;\n const messagesResult = await this.baseClient.getMessages(topicId);\n\n if (messagesResult?.messages?.length > 0) {\n this.processConnectionMessages(topicId, messagesResult.messages);\n }\n } catch (error) {\n this.logger.debug(\n `Failed to fetch activity for ${connection.connectionTopicId}:`,\n error\n );\n }\n });\n\n await Promise.allSettled(activityPromises);\n }\n\n /**\n * Checks if an account should be filtered, taking into account existing established connections\n * @param accountId - The account ID to check\n * @returns True if the account should be filtered, false otherwise\n */\n private shouldFilterAccount(accountId: string): boolean {\n if (!this.filterPendingAccountIds.has(accountId)) {\n return false;\n }\n\n if (this.hasEstablishedConnectionWithAccount(accountId)) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Process outbound messages to track connection requests and confirmations\n * @param messages - The messages to process\n * @param accountId - The account ID that sent the messages\n * @returns Array of connections after processing\n */\n processOutboundMessages(\n messages: HCSMessage[],\n accountId: string\n ): Connection[] {\n if (!Boolean(messages?.length)) {\n return Array.from(this.connections.values());\n }\n\n const requestMessages = messages.filter(\n (msg) => msg.op === 'connection_request' && msg.connection_request_id\n );\n\n for (const msg of requestMessages) {\n const requestId = msg.connection_request_id!;\n const operatorId = msg.operator_id || '';\n const targetAccountId =\n this.baseClient.extractAccountFromOperatorId(operatorId);\n const targetInboundTopicId =\n this.baseClient.extractTopicFromOperatorId(operatorId);\n\n if (this.shouldFilterAccount(targetAccountId)) {\n this.logger.debug(\n `Filtering out outbound request to account: ${targetAccountId}`\n );\n continue;\n }\n\n const isAlreadyConfirmed = Array.from(this.connections.values()).some(\n (conn) =>\n conn.connectionRequestId === requestId &&\n !conn.isPending &&\n conn.targetAccountId === targetAccountId\n );\n\n const pendingKey = `req-${requestId}:${operatorId}`;\n\n if (!isAlreadyConfirmed && !this.pendingRequests.has(pendingKey)) {\n const pendingRequest = {\n id: requestId,\n requesterId: accountId,\n requesterTopicId: msg.outbound_topic_id || '',\n targetAccountId,\n targetTopicId: targetInboundTopicId,\n operatorId,\n sequenceNumber: msg.sequence_number,\n created: msg.created || new Date(),\n memo: msg.m,\n status: 'pending' as 'pending' | 'confirmed' | 'rejected',\n };\n\n this.pendingRequests.set(pendingKey, pendingRequest);\n\n if (!this.connections.has(pendingKey)) {\n const pendingConnection = {\n connectionTopicId: pendingKey,\n targetAccountId,\n targetInboundTopicId,\n status: 'pending' as\n | 'pending'\n | 'established'\n | 'needs_confirmation'\n | 'closed',\n isPending: true,\n needsConfirmation: false,\n created: msg.created || new Date(),\n connectionRequestId: requestId,\n uniqueRequestKey: pendingKey,\n originTopicId: msg.outbound_topic_id || '',\n processed: false,\n memo: msg.m,\n };\n\n this.connections.set(pendingKey, pendingConnection);\n }\n }\n }\n\n const confirmationMessages = messages.filter(\n (msg) =>\n msg.op === 'connection_created' &&\n msg.connection_topic_id &&\n msg.connection_request_id\n );\n\n for (const msg of confirmationMessages) {\n const requestId = msg.connection_request_id!;\n const connectionTopicId = msg.connection_topic_id!;\n const targetAccountId = this.baseClient.extractAccountFromOperatorId(\n msg.operator_id || ''\n );\n\n if (this.shouldFilterAccount(targetAccountId)) {\n this.logger.debug(\n `Filtering out outbound confirmation to account: ${targetAccountId}`\n );\n continue;\n }\n\n const pendingKey = `req-${requestId}:${msg.operator_id}`;\n\n const pendingRequest = this.pendingRequests.get(pendingKey);\n if (pendingRequest) {\n pendingRequest.status = 'confirmed';\n }\n\n if (this.connections.has(pendingKey)) {\n this.connections.delete(pendingKey);\n }\n\n if (!this.connections.has(connectionTopicId)) {\n this.connections.set(connectionTopicId, {\n connectionTopicId,\n targetAccountId,\n status: 'established',\n isPending: false,\n needsConfirmation: false,\n created: msg.created || new Date(),\n connectionRequestId: requestId,\n confirmedRequestId: msg.confirmed_request_id,\n requesterOutboundTopicId: msg.outbound_topic_id,\n uniqueRequestKey: pendingKey,\n originTopicId: msg.outbound_topic_id || '',\n processed: false,\n memo: msg.m,\n });\n } else {\n const conn = this.connections.get(connectionTopicId)!;\n this.connections.set(connectionTopicId, {\n ...conn,\n status: 'established',\n isPending: false,\n needsConfirmation: false,\n connectionRequestId: requestId,\n confirmedRequestId: msg.confirmed_request_id,\n requesterOutboundTopicId: msg.outbound_topic_id,\n uniqueRequestKey: pendingKey,\n originTopicId: msg.outbound_topic_id || '',\n processed: false,\n memo: msg.m,\n });\n }\n }\n\n const closedMessages = messages.filter(\n (msg) =>\n (msg.op as string) === 'connection_closed' ||\n (msg.op === 'close_connection' && msg.connection_topic_id)\n );\n\n for (const msg of closedMessages) {\n const connectionTopicId = msg.connection_topic_id!;\n\n if (this.connections.has(connectionTopicId)) {\n const conn = this.connections.get(connectionTopicId)!;\n if (\n this.shouldFilterAccount(conn.targetAccountId) &&\n conn.status !== 'established'\n ) {\n continue;\n }\n\n const uniqueKey =\n msg.connection_request_id && msg.operator_id\n ? `req-${msg.connection_request_id}:${msg.operator_id}`\n : undefined;\n\n this.connections.set(connectionTopicId, {\n ...conn,\n status: 'closed',\n isPending: false,\n needsConfirmation: false,\n lastActivity: msg.created || new Date(),\n closedReason: msg.reason,\n closeMethod: msg.close_method,\n uniqueRequestKey: uniqueKey,\n originTopicId: conn.originTopicId,\n processed: false,\n memo: msg.m,\n });\n }\n }\n\n return Array.from(this.connections.values()).filter(\n (conn) =>\n conn.status === 'established' ||\n conn.status === 'closed' ||\n !this.filterPendingAccountIds.has(conn.targetAccountId)\n );\n }\n\n /**\n * Process inbound messages to track connection requests and confirmations\n * @param messages - The messages to process\n * @returns Array of connections after processing\n */\n processInboundMessages(messages: HCSMessage[]): Connection[] {\n if (!Boolean(messages?.length)) {\n return Array.from(this.connections.values());\n }\n\n const requestMessages = messages.filter(\n (msg) => msg.op === 'connection_request' && msg.sequence_number\n );\n\n const confirmationMessages = messages.filter(\n (msg) =>\n msg.op === 'connection_created' &&\n msg.connection_topic_id &&\n msg.connection_id\n );\n\n for (const msg of requestMessages) {\n const sequenceNumber = msg.sequence_number;\n const operatorId = msg.operator_id || '';\n const requestorAccountId =\n this.baseClient.extractAccountFromOperatorId(operatorId);\n const requestorTopicId =\n this.baseClient.extractTopicFromOperatorId(operatorId);\n\n if (this.shouldFilterAccount(requestorAccountId)) {\n this.logger.debug(\n `Filtering out request from account: ${requestorAccountId}`\n );\n continue;\n }\n\n const needsConfirmKey = `inb-${sequenceNumber}:${operatorId}`;\n\n const hasCreated = confirmationMessages.some(\n (m) => m.connection_id === sequenceNumber\n );\n\n if (hasCreated) {\n this.logger.debug(\n `Skipping request from ${requestorAccountId} as it has already been confirmed`\n );\n continue;\n }\n\n if (!this.connections.has(needsConfirmKey)) {\n this.connections.set(needsConfirmKey, {\n connectionTopicId: needsConfirmKey,\n targetAccountId: requestorAccountId,\n targetInboundTopicId: requestorTopicId,\n status: 'needs_confirmation',\n isPending: false,\n needsConfirmation: true,\n created: msg.created || new Date(),\n inboundRequestId: sequenceNumber,\n uniqueRequestKey: needsConfirmKey,\n originTopicId: requestorTopicId,\n processed: false,\n memo: msg.m,\n });\n }\n }\n\n for (const msg of confirmationMessages) {\n const sequenceNumber = msg.connection_id!;\n const connectionTopicId = msg.connection_topic_id!;\n const connectedAccountId = msg.connected_account_id || '';\n const operatorId = msg.operator_id || '';\n\n if (this.shouldFilterAccount(connectedAccountId)) {\n this.logger.debug(\n `Filtering out confirmation for account: ${connectedAccountId}`\n );\n continue;\n }\n\n const needsConfirmKey = `inb-${sequenceNumber}:${operatorId}`;\n\n if (this.connections.has(needsConfirmKey)) {\n this.connections.delete(needsConfirmKey);\n }\n\n if (!this.connections.has(connectionTopicId)) {\n this.connections.set(connectionTopicId, {\n connectionTopicId,\n targetAccountId: connectedAccountId,\n status: 'established',\n isPending: false,\n needsConfirmation: false,\n created: msg.created || new Date(),\n inboundRequestId: sequenceNumber,\n uniqueRequestKey: needsConfirmKey,\n originTopicId: msg.connection_topic_id,\n processed: false,\n memo: msg.m,\n });\n } else {\n const conn = this.connections.get(connectionTopicId)!;\n this.connections.set(connectionTopicId, {\n ...conn,\n status: 'established',\n isPending: false,\n needsConfirmation: false,\n inboundRequestId: sequenceNumber,\n uniqueRequestKey: needsConfirmKey,\n originTopicId: msg.connection_topic_id,\n processed: false,\n memo: msg.m,\n });\n }\n }\n\n return Array.from(this.connections.values()).filter(\n (conn) =>\n conn.status === 'established' ||\n conn.status === 'closed' ||\n !this.filterPendingAccountIds.has(conn.targetAccountId)\n );\n }\n\n /**\n * Process connection topic messages to update last activity time\n * @param connectionTopicId - The topic ID of the connection\n * @param messages - The messages to process\n * @returns The updated connection or undefined if not found\n */\n processConnectionMessages(\n connectionTopicId: string,\n messages: HCSMessage[]\n ): Connection | undefined {\n if (\n !messages ||\n messages.length === 0 ||\n !this.connections.has(connectionTopicId)\n ) {\n return this.connections.get(connectionTopicId);\n }\n\n const latestMessage = messages\n .filter((m) => m.created)\n .sort((a, b) => {\n const dateA = a.created ? new Date(a.created).getTime() : 0;\n const dateB = b.created ? new Date(b.created).getTime() : 0;\n return dateB - dateA;\n })[0];\n\n if (latestMessage?.created) {\n const conn = this.connections.get(connectionTopicId)!;\n this.connections.set(connectionTopicId, {\n ...conn,\n lastActivity: latestMessage.created,\n });\n }\n\n const closeMessage = messages.find((msg) => msg.op === 'close_connection');\n if (closeMessage) {\n const conn = this.connections.get(connectionTopicId)!;\n this.connections.set(connectionTopicId, {\n ...conn,\n status: 'closed',\n lastActivity: closeMessage.created || new Date(),\n closedReason: closeMessage.reason,\n closeMethod: 'explicit',\n });\n }\n\n return this.connections.get(connectionTopicId);\n }\n\n /**\n * Adds or updates profile information for a connection\n * @param accountId - The account ID to add profile info for\n * @param profile - The profile information\n */\n addProfileInfo(accountId: string, profile: AIAgentProfile): void {\n this.profileCache.set(accountId, profile);\n\n const matchingConnections = Array.from(this.connections.values()).filter(\n (conn) => conn.targetAccountId === accountId\n );\n\n for (const conn of matchingConnections) {\n this.connections.set(conn.connectionTopicId, {\n ...conn,\n profileInfo: profile,\n targetAgentName: profile.display_name,\n targetInboundTopicId: profile.inboundTopicId,\n targetOutboundTopicId: profile.outboundTopicId,\n });\n }\n }\n\n /**\n * Gets all connections\n * @returns Array of all connections that should be visible\n */\n getAllConnections(): Connection[] {\n const connections = Array.from(this.connections.values()).filter(\n (conn) =>\n conn.status === 'established' ||\n conn.status === 'closed' ||\n !this.filterPendingAccountIds.has(conn.targetAccountId)\n );\n return connections;\n }\n\n /**\n * Gets all pending connection requests\n * @returns Array of pending connection requests\n */\n getPendingRequests(): Connection[] {\n const pendingConnections = Array.from(this.connections.values()).filter(\n (conn) => {\n return (\n conn.isPending &&\n !this.filterPendingAccountIds.has(conn.targetAccountId)\n );\n }\n );\n\n return pendingConnections;\n }\n\n /**\n * Helper method to check if there's an established connection with an account\n * @param accountId - The account ID to check\n * @returns True if there's an established connection, false otherwise\n */\n private hasEstablishedConnectionWithAccount(accountId: string): boolean {\n return Array.from(this.connections.values()).some(\n (conn) =>\n conn.targetAccountId === accountId && conn.status === 'established'\n );\n }\n\n /**\n * Gets all active (established) connections\n * @returns Array of active connections\n */\n getActiveConnections(): Connection[] {\n return Array.from(this.connections.values()).filter(\n (conn) => conn.status === 'established'\n );\n }\n\n /**\n * Gets all connections needing confirmation\n * @returns Array of connections needing confirmation\n */\n getConnectionsNeedingConfirmation(): Connection[] {\n return Array.from(this.connections.values()).filter(\n (conn) =>\n conn.needsConfirmation &&\n !this.filterPendingAccountIds.has(conn.targetAccountId)\n );\n }\n\n /**\n * Gets a connection by its topic ID\n * @param connectionTopicId - The topic ID to look up\n * @returns The connection with the given topic ID, or undefined if not found\n */\n getConnectionByTopicId(connectionTopicId: string): Connection | undefined {\n return this.connections.get(connectionTopicId);\n }\n\n /**\n * Gets a connection by account ID\n * @param accountId - The account ID to look up\n * @returns The connection with the given account ID, or undefined if not found\n */\n getConnectionByAccountId(accountId: string): Connection | undefined {\n return Array.from(this.connections.values()).find(\n (conn) =>\n conn.targetAccountId === accountId && conn.status === 'established'\n );\n }\n\n /**\n * Gets all connections for a specific account ID\n * @param accountId - The account ID to look up\n * @returns Array of connections for the given account ID\n */\n getConnectionsByAccountId(accountId: string): Connection[] {\n return Array.from(this.connections.values()).filter(\n (conn) => conn.targetAccountId === accountId\n );\n }\n\n /**\n * Updates or adds a connection\n * @param connection - The connection to update or add\n */\n updateOrAddConnection(connection: Connection): void {\n this.connections.set(connection.connectionTopicId, connection);\n }\n\n /**\n * Clears all tracked connections and requests\n */\n clearAll(): void {\n this.connections.clear();\n this.pendingRequests.clear();\n }\n\n /**\n * Checks if a given connection request has been processed already\n * This uses a combination of topic ID and request ID to uniquely identify requests\n *\n * @param inboundTopicId - The inbound topic ID where the request was received\n * @param requestId - The sequence number (request ID)\n * @returns True if this specific request has been processed, false otherwise\n */\n isConnectionRequestProcessed(\n inboundTopicId: string,\n requestId: number\n ): boolean {\n for (const conn of this.connections.values()) {\n if (\n conn.originTopicId === inboundTopicId &&\n conn.inboundRequestId === requestId &&\n conn.processed\n ) {\n return true;\n }\n\n if (\n conn.originTopicId === inboundTopicId &&\n conn.connectionRequestId === requestId &&\n conn.processed\n ) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Marks a specific connection request as processed\n *\n * @param inboundTopicId - The inbound topic ID where the request was received\n * @param requestId - The sequence number (request ID)\n * @returns True if a matching connection was found and marked, false otherwise\n */\n markConnectionRequestProcessed(\n inboundTopicId: string,\n requestId: number\n ): boolean {\n let found = false;\n\n for (const [key, conn] of this.connections.entries()) {\n if (\n conn.originTopicId === inboundTopicId &&\n conn.inboundRequestId === requestId\n ) {\n this.connections.set(key, {\n ...conn,\n processed: true,\n });\n found = true;\n this.logger.debug(\n `Marked inbound connection request #${requestId} on topic ${inboundTopicId} as processed`\n );\n }\n\n if (\n conn.originTopicId === inboundTopicId &&\n conn.connectionRequestId === requestId\n ) {\n this.connections.set(key, {\n ...conn,\n processed: true,\n });\n found = true;\n this.logger.debug(\n `Marked outbound connection request #${requestId} on topic ${inboundTopicId} as processed`\n );\n }\n }\n\n return found;\n }\n\n /**\n * Gets pending transactions from a specific connection\n * @param connectionTopicId - The connection topic ID to check for transactions\n * @param limit - Optional limit for the number of transactions to return\n * @returns Array of pending transaction messages sorted by timestamp (newest first)\n */\n async getPendingTransactions(\n connectionTopicId: string,\n limit?: number\n ): Promise<TransactMessage[]> {\n try {\n const transactMessages = await this.baseClient.getTransactionRequests(\n connectionTopicId,\n limit\n );\n\n const pendingTransactions: TransactMessage[] = [];\n\n for (const transaction of transactMessages) {\n try {\n const status =\n await this.baseClient.mirrorNode.getScheduledTransactionStatus(\n transaction.schedule_id\n );\n\n if (!status.executed && !status.deleted) {\n pendingTransactions.push(transaction);\n }\n } catch (error) {\n this.logger.error(`Error checking transaction status: ${error}`);\n pendingTransactions.push(transaction);\n }\n }\n\n return pendingTransactions;\n } catch (error) {\n this.logger.error(`Error getting pending transactions: ${error}`);\n return [];\n }\n }\n\n /**\n * Gets the status of a scheduled transaction\n * @param scheduleId - The schedule ID to check\n * @returns Status of the scheduled transaction\n */\n async getScheduledTransactionStatus(scheduleId: string): Promise<{\n executed: boolean;\n executedTimestamp?: string;\n deleted: boolean;\n expirationTime?: string;\n }> {\n return this.baseClient.mirrorNode.getScheduledTransactionStatus(scheduleId);\n }\n\n /**\n * Gets the timestamp of the last message sent by the specified operator on the connection topic\n * @param connectionTopicId - The topic ID to check\n * @param operatorAccountId - The account ID of the operator\n * @returns The timestamp of the last message or undefined if no messages found\n */\n async getLastOperatorActivity(\n connectionTopicId: string,\n operatorAccountId: string\n ): Promise<Date | undefined> {\n try {\n const { messages } = await this.baseClient.getMessageStream(\n connectionTopicId\n );\n\n const operatorMessages = messages.filter(\n (msg) =>\n msg.operator_id &&\n msg.operator_id.includes(operatorAccountId) &&\n msg.created\n );\n\n if (operatorMessages.length === 0) {\n return undefined;\n }\n\n operatorMessages.sort(\n (a, b) => b.created!.getTime() - a.created!.getTime()\n );\n\n return operatorMessages[0].created;\n } catch (error) {\n this.logger.error(`Error getting last operator activity: ${error}`);\n return undefined;\n }\n }\n}\n"],"names":[],"mappings":";AAiOO,MAAM,mBAAkD;AAAA;AAAA;AAAA;AAAA,EAW7D,YAAY,SAAoC;AATxC,SAAA,kCAA2C,IAAI;AAC/C,SAAA,sCAAsD,IAAI;AAC1D,SAAA,mCAAgD,IAAI;AACpD,SAAA,8CAA2C,IAAI;AAOrD,UAAM,gBAA+B;AAAA,MACn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AAAA,MACF;AAEA,YAAM,mBAAmB,SAAS;AAAA,QAChC,CAAC,QACC,IAAI,eACJ,IAAI,YAAY,SAAS,iBAAiB,KAC1C,IAAI;AAAA,MACR;AAEI,UAAA,iBAAiB,WAAW,GAAG;AAC1B,eAAA;AAAA,MAAA;AAGQ,uBAAA;AAAA,QACf,CAAC,GAAG,MAAM,EAAE,QAAS,YAAY,EAAE,QAAS,QAAQ;AAAA,MACtD;AAEO,aAAA,iBAAiB,CAAC,EAAE;AAAA,aACpB,OAAO;AACd,WAAK,OAAO,MAAM,yCAAyC,KAAK,EAAE;AAC3D,aAAA;AAAA,IAAA;AAAA,EACT;AAEJ;"}
1
+ {"version":3,"file":"standards-sdk.es10.js","sources":["../../src/hcs-10/connections-manager.ts"],"sourcesContent":["import { Logger, LoggerOptions } from '../utils/logger';\nimport { HCSMessage, HCS10BaseClient } from './base-client';\nimport { AIAgentProfile } from '../hcs-11';\nimport { TransactMessage } from './types';\n\n/**\n * Represents a connection request between agents\n */\nexport interface ConnectionRequest {\n id: number;\n requesterId: string;\n requesterTopicId: string;\n targetAccountId: string;\n targetTopicId: string;\n operatorId: string;\n sequenceNumber: number;\n created: Date;\n memo?: string;\n status: 'pending' | 'confirmed' | 'rejected';\n}\n\n/**\n * Represents an active connection between agents\n */\nexport interface Connection {\n connectionTopicId: string;\n targetAccountId: string;\n targetAgentName?: string;\n targetInboundTopicId?: string;\n targetOutboundTopicId?: string;\n status: 'pending' | 'established' | 'needs_confirmation' | 'closed';\n isPending: boolean;\n needsConfirmation: boolean;\n memo?: string;\n created: Date;\n lastActivity?: Date;\n profileInfo?: AIAgentProfile;\n connectionRequestId?: number;\n confirmedRequestId?: number;\n requesterOutboundTopicId?: string;\n inboundRequestId?: number;\n closedReason?: string;\n closeMethod?: string;\n uniqueRequestKey?: string;\n originTopicId?: string;\n processed: boolean;\n}\n\n/**\n * Options for the connections manager\n */\nexport interface ConnectionsManagerOptions {\n logLevel?: 'debug' | 'info' | 'warn' | 'error';\n filterPendingAccountIds?: string[];\n baseClient: HCS10BaseClient;\n silent?: boolean;\n}\n\n/**\n * Defines the interface for a connections manager that handles HCS-10 connections\n * This interface represents the public API of ConnectionsManager\n */\nexport interface IConnectionsManager {\n /**\n * Fetches and processes connection data using the configured client\n * @param accountId - The account ID to fetch connection data for\n * @returns A promise that resolves to an array of Connection objects\n */\n fetchConnectionData(accountId: string): Promise<Connection[]>;\n\n /**\n * Process outbound messages to track connection requests and confirmations\n * @param messages - The messages to process\n * @param accountId - The account ID that sent the messages\n * @returns Array of connections after processing\n */\n processOutboundMessages(\n messages: HCSMessage[],\n accountId: string,\n ): Connection[];\n\n /**\n * Process inbound messages to track connection requests and confirmations\n * @param messages - The messages to process\n * @returns Array of connections after processing\n */\n processInboundMessages(messages: HCSMessage[]): Connection[];\n\n /**\n * Process connection topic messages to update last activity time\n * @param connectionTopicId - The topic ID of the connection\n * @param messages - The messages to process\n * @returns The updated connection or undefined if not found\n */\n processConnectionMessages(\n connectionTopicId: string,\n messages: HCSMessage[],\n ): Connection | undefined;\n\n /**\n * Adds or updates profile information for a connection\n * @param accountId - The account ID to add profile info for\n * @param profile - The profile information\n */\n addProfileInfo(accountId: string, profile: AIAgentProfile): void;\n\n /**\n * Gets all connections\n * @returns Array of all connections that should be visible\n */\n getAllConnections(): Connection[];\n\n /**\n * Gets all pending connection requests\n * @returns Array of pending connection requests\n */\n getPendingRequests(): Connection[];\n\n /**\n * Gets all active (established) connections\n * @returns Array of active connections\n */\n getActiveConnections(): Connection[];\n\n /**\n * Gets all connections needing confirmation\n * @returns Array of connections needing confirmation\n */\n getConnectionsNeedingConfirmation(): Connection[];\n\n /**\n * Gets a connection by its topic ID\n * @param connectionTopicId - The topic ID to look up\n * @returns The connection with the given topic ID, or undefined if not found\n */\n getConnectionByTopicId(connectionTopicId: string): Connection | undefined;\n\n /**\n * Gets a connection by account ID\n * @param accountId - The account ID to look up\n * @returns The connection with the given account ID, or undefined if not found\n */\n getConnectionByAccountId(accountId: string): Connection | undefined;\n\n /**\n * Gets all connections for a specific account ID\n * @param accountId - The account ID to look up\n * @returns Array of connections for the given account ID\n */\n getConnectionsByAccountId(accountId: string): Connection[];\n\n /**\n * Updates or adds a connection\n * @param connection - The connection to update or add\n */\n updateOrAddConnection(connection: Connection): void;\n\n /**\n * Clears all tracked connections and requests\n */\n clearAll(): void;\n\n /**\n * Checks if a given connection request has been processed already\n * This uses a combination of topic ID and request ID to uniquely identify requests\n *\n * @param inboundTopicId - The inbound topic ID where the request was received\n * @param requestId - The sequence number (request ID)\n * @returns True if this specific request has been processed, false otherwise\n */\n isConnectionRequestProcessed(\n inboundTopicId: string,\n requestId: number,\n ): boolean;\n\n /**\n * Marks a specific connection request as processed\n *\n * @param inboundTopicId - The inbound topic ID where the request was received\n * @param requestId - The sequence number (request ID)\n * @returns True if a matching connection was found and marked, false otherwise\n */\n markConnectionRequestProcessed(\n inboundTopicId: string,\n requestId: number,\n ): boolean;\n\n /**\n * Gets pending transactions from a specific connection\n * @param connectionTopicId - The connection topic ID to check for transactions\n * @param limit - Optional limit for the number of transactions to return\n * @returns Array of pending transaction messages sorted by timestamp (newest first)\n */\n getPendingTransactions(\n connectionTopicId: string,\n limit?: number,\n ): Promise<TransactMessage[]>;\n\n /**\n * Gets the status of a scheduled transaction\n * @param scheduleId - The schedule ID to check\n * @returns Status of the scheduled transaction\n */\n getScheduledTransactionStatus(scheduleId: string): Promise<{\n executed: boolean;\n executedTimestamp?: string;\n deleted: boolean;\n expirationTime?: string;\n }>;\n\n /**\n * Gets the timestamp of the last message sent by the specified operator on the connection topic\n * @param connectionTopicId - The topic ID to check\n * @param operatorAccountId - The account ID of the operator\n * @returns The timestamp of the last message or undefined if no messages found\n */\n getLastOperatorActivity(\n connectionTopicId: string,\n operatorAccountId: string,\n ): Promise<Date | undefined>;\n}\n\n/**\n * ConnectionsManager provides a unified way to track and manage HCS-10 connections\n * across different applications. It works with both frontend and backend implementations.\n */\nexport class ConnectionsManager implements IConnectionsManager {\n private logger: Logger;\n private connections: Map<string, Connection> = new Map();\n private pendingRequests: Map<string, ConnectionRequest> = new Map();\n private profileCache: Map<string, AIAgentProfile> = new Map();\n private filterPendingAccountIds: Set<string> = new Set();\n private baseClient: HCS10BaseClient;\n\n /**\n * Creates a new ConnectionsManager instance\n */\n constructor(options: ConnectionsManagerOptions) {\n const loggerOptions: LoggerOptions = {\n module: 'ConnectionsManager',\n level: options?.logLevel || 'info',\n prettyPrint: true,\n silent: options?.silent,\n };\n this.logger = new Logger(loggerOptions);\n\n if (options?.filterPendingAccountIds) {\n this.filterPendingAccountIds = new Set(options.filterPendingAccountIds);\n }\n\n if (!options.baseClient) {\n throw new Error('ConnectionsManager requires a baseClient to operate');\n }\n\n this.baseClient = options.baseClient;\n }\n\n /**\n * Fetches and processes connection data using the configured client\n * @param accountId - The account ID to fetch connection data for\n * @returns A promise that resolves to an array of Connection objects\n */\n async fetchConnectionData(accountId: string): Promise<Connection[]> {\n try {\n const topicInfo =\n await this.baseClient.retrieveCommunicationTopics(accountId);\n\n const isValidTopicId = (topicId: string): boolean => {\n return Boolean(topicId) && !topicId.includes(':');\n };\n\n if (\n !isValidTopicId(topicInfo.inboundTopic) ||\n !isValidTopicId(topicInfo.outboundTopic)\n ) {\n this.logger.warn(\n 'Invalid topic IDs detected in retrieved communication topics',\n );\n return this.getAllConnections();\n }\n\n const [outboundMessagesResult, inboundMessagesResult] = await Promise.all(\n [\n this.baseClient.getMessages(topicInfo.outboundTopic),\n this.baseClient.getMessages(topicInfo.inboundTopic),\n ],\n );\n\n this.processOutboundMessages(\n outboundMessagesResult.messages || [],\n accountId,\n );\n this.processInboundMessages(inboundMessagesResult.messages || []);\n\n const pendingCount = Array.from(this.connections.values()).filter(\n conn => conn.status === 'pending' || conn.isPending,\n ).length;\n this.logger.debug(\n `Processed ${\n outboundMessagesResult.messages?.length || 0\n } outbound and ${\n inboundMessagesResult.messages?.length || 0\n } inbound messages. Found ${pendingCount} pending connections.`,\n );\n\n await this.checkTargetInboundTopicsForConfirmations();\n await this.checkOutboundRequestsForConfirmations();\n await this.fetchProfilesForConnections();\n await this.fetchConnectionActivity();\n\n return this.getAllConnections();\n } catch (error) {\n this.logger.error('Error fetching connection data:', error);\n return this.getAllConnections();\n }\n }\n\n /**\n * Checks target agent inbound topics to find confirmations for pending requests\n * that might not be visible in our local messages\n */\n private async checkTargetInboundTopicsForConfirmations(): Promise<void> {\n const pendingConnections = Array.from(this.connections.values()).filter(\n conn =>\n (conn.isPending || conn.status === 'pending') &&\n conn.targetInboundTopicId,\n );\n\n if (pendingConnections.length === 0) {\n return;\n }\n\n const pendingRequestsByTarget = new Map<string, Connection[]>();\n\n pendingConnections.forEach(conn => {\n if (conn.targetInboundTopicId) {\n const requests =\n pendingRequestsByTarget.get(conn.targetInboundTopicId) || [];\n requests.push(conn);\n pendingRequestsByTarget.set(conn.targetInboundTopicId, requests);\n }\n });\n\n const MAX_FETCH_ATTEMPTS = 2;\n const FETCH_DELAY_MS = 500;\n\n for (const [\n targetInboundTopicId,\n requests,\n ] of pendingRequestsByTarget.entries()) {\n for (let attempt = 1; attempt <= MAX_FETCH_ATTEMPTS; attempt++) {\n try {\n const targetMessagesResult =\n await this.baseClient.getMessages(targetInboundTopicId);\n const targetMessages = targetMessagesResult.messages || [];\n\n let confirmedAny = false;\n\n for (const conn of requests) {\n const requestId = conn.connectionRequestId;\n if (!requestId) {\n continue;\n }\n\n const confirmationMsg = targetMessages.find(msg => {\n if (msg.op !== 'connection_created' || !msg.connection_topic_id) {\n return false;\n }\n\n if (msg.connection_id !== requestId) {\n return false;\n }\n\n if (conn.uniqueRequestKey) {\n const keyParts = conn.uniqueRequestKey.split(':');\n if (keyParts.length > 1) {\n const operatorIdPart = keyParts[1];\n\n if (msg.operator_id && msg.operator_id === operatorIdPart) {\n return true;\n }\n\n if (msg.connected_account_id === conn.targetAccountId) {\n return true;\n }\n }\n }\n\n return true;\n });\n\n if (confirmationMsg?.connection_topic_id) {\n confirmedAny = true;\n\n const connectionTopicId = confirmationMsg.connection_topic_id;\n\n let pendingKey = conn.uniqueRequestKey;\n\n const newConnection: Connection = {\n connectionTopicId,\n targetAccountId: conn.targetAccountId,\n targetAgentName: conn.targetAgentName,\n targetInboundTopicId: conn.targetInboundTopicId,\n status: 'established',\n isPending: false,\n needsConfirmation: false,\n created: new Date(confirmationMsg.created || conn.created),\n profileInfo: conn.profileInfo,\n connectionRequestId: requestId,\n uniqueRequestKey: conn.uniqueRequestKey,\n originTopicId: conn.originTopicId,\n processed: conn.processed,\n memo: conn.memo,\n };\n\n this.connections.set(connectionTopicId, newConnection);\n\n if (pendingKey) {\n this.connections.delete(pendingKey);\n }\n\n this.logger.debug(\n `Confirmed connection in target inbound topic: ${connectionTopicId}`,\n );\n }\n }\n\n if (confirmedAny || attempt === MAX_FETCH_ATTEMPTS) {\n break;\n }\n\n await new Promise(resolve => setTimeout(resolve, FETCH_DELAY_MS));\n } catch (error) {\n this.logger.debug(\n `Error fetching target inbound topic ${targetInboundTopicId}:`,\n error,\n );\n if (attempt === MAX_FETCH_ATTEMPTS) {\n break;\n }\n await new Promise(resolve => setTimeout(resolve, FETCH_DELAY_MS));\n }\n }\n }\n }\n\n /**\n * Checks target agents' inbound topics for confirmations of our outbound connection requests\n * This complements checkTargetInboundTopicsForConfirmations by looking for confirmations\n * that might have been sent to the target agent's inbound topic rather than our own\n */\n private async checkOutboundRequestsForConfirmations(): Promise<void> {\n const allConnections = Array.from(this.connections.values());\n this.logger.info(`Total connections in map: ${allConnections.length}`);\n\n const pendingByStatus = allConnections.filter(\n conn => conn.status === 'pending',\n );\n this.logger.info(\n `Connections with status='pending': ${pendingByStatus.length}`,\n );\n\n const pendingConnections = allConnections.filter(\n conn => conn.status === 'pending',\n );\n\n if (!Boolean(pendingConnections?.length)) {\n this.logger.info('No pending connections found');\n return;\n }\n\n for (const conn of pendingConnections) {\n this.logger.debug(\n `Processing pending connection: ${conn.connectionTopicId}`,\n );\n\n if (!conn.targetAccountId) {\n this.logger.debug(\n `Skipping connection ${conn.connectionTopicId} - no targetAccountId`,\n );\n continue;\n }\n\n let targetInboundTopicId = conn.targetInboundTopicId;\n if (!targetInboundTopicId) {\n try {\n const profileResponse = await this.baseClient.retrieveProfile(\n conn.targetAccountId,\n );\n if (profileResponse?.profile?.inboundTopicId) {\n targetInboundTopicId = profileResponse.profile.inboundTopicId;\n this.connections.set(conn.connectionTopicId, {\n ...conn,\n targetInboundTopicId,\n });\n this.logger.debug(\n `Updated connection ${conn.connectionTopicId} with inbound topic ID: ${targetInboundTopicId}`,\n );\n } else {\n this.logger.debug(\n `Couldn't get inbound topic ID for account ${conn.targetAccountId}`,\n );\n continue;\n }\n } catch (error) {\n this.logger.debug(\n `Error fetching profile for ${conn.targetAccountId}: ${error}`,\n );\n continue;\n }\n }\n\n if (!targetInboundTopicId || targetInboundTopicId.includes(':')) {\n this.logger.debug(\n `Skipping invalid inbound topic format: ${targetInboundTopicId}`,\n );\n continue;\n }\n\n const requestId = conn.connectionRequestId || conn.inboundRequestId;\n if (!requestId) {\n this.logger.debug(\n `Skipping connection ${conn.connectionTopicId} - no request ID`,\n );\n continue;\n }\n\n try {\n this.logger.debug(\n `Checking for confirmations on topic ${targetInboundTopicId} for request ID ${requestId}`,\n );\n const targetMessagesResult =\n await this.baseClient.getMessages(targetInboundTopicId);\n const targetMessages = targetMessagesResult.messages || [];\n\n const confirmationMsg = targetMessages.find(\n msg =>\n msg.op === 'connection_created' &&\n msg.connection_id === requestId &&\n msg.connection_topic_id,\n );\n\n if (confirmationMsg?.connection_topic_id) {\n const connectionTopicId = confirmationMsg.connection_topic_id;\n this.logger.info(\n `Found confirmation for request #${requestId} to ${conn.targetAccountId} on their inbound topic`,\n );\n\n this.connections.set(conn.connectionTopicId, {\n ...conn,\n connectionTopicId,\n status: 'established',\n isPending: false,\n needsConfirmation: false,\n created: new Date(confirmationMsg.created || conn.created),\n lastActivity: new Date(confirmationMsg.created || conn.created),\n });\n } else {\n this.logger.debug(\n `No confirmation found for request ID ${requestId} on topic ${targetInboundTopicId}`,\n );\n }\n } catch (error) {\n this.logger.warn(\n `Error checking for confirmations on target inbound topic for ${conn.targetAccountId}: ${error}`,\n );\n }\n }\n }\n\n /**\n * Fetches profiles for all connected accounts\n * @param accountId - The account ID making the request\n */\n private async fetchProfilesForConnections(): Promise<void> {\n const targetAccountIds = new Set<string>();\n\n for (const connection of this.connections.values()) {\n if (\n connection.targetAccountId &&\n !this.profileCache.has(connection.targetAccountId)\n ) {\n targetAccountIds.add(connection.targetAccountId);\n }\n }\n\n const accountIdPromises = Array.from(targetAccountIds).map(\n async targetId => {\n try {\n const profileResponse =\n await this.baseClient.retrieveProfile(targetId);\n if (profileResponse.success && profileResponse.profile) {\n this.addProfileInfo(targetId, profileResponse.profile);\n\n this.updatePendingConnectionsWithProfileInfo(\n targetId,\n profileResponse.profile,\n );\n }\n } catch (error) {\n this.logger.debug(`Failed to fetch profile for ${targetId}:`, error);\n }\n },\n );\n\n await Promise.allSettled(accountIdPromises);\n }\n\n /**\n * Updates pending connections with inbound topic IDs from profile info\n * @param accountId - The account ID to update connections for\n * @param profile - The profile containing the inbound topic ID\n */\n private updatePendingConnectionsWithProfileInfo(\n accountId: string,\n profile: AIAgentProfile,\n ): void {\n const pendingConnections = Array.from(this.connections.values()).filter(\n conn =>\n conn.targetAccountId === accountId &&\n (conn.isPending || conn.needsConfirmation) &&\n !conn.targetInboundTopicId,\n );\n\n if (pendingConnections.length > 0 && profile.inboundTopicId) {\n for (const conn of pendingConnections) {\n const updatedConn = {\n ...conn,\n targetInboundTopicId: profile.inboundTopicId,\n };\n this.connections.set(conn.connectionTopicId, updatedConn);\n }\n }\n }\n\n /**\n * Fetches activity from active connection topics\n * Updates the lastActivity timestamp for each connection based on latest messages\n * @returns Promise that resolves when all activity has been fetched\n */\n private async fetchConnectionActivity(): Promise<void> {\n const activeConnections = this.getActiveConnections();\n\n const validConnections = activeConnections.filter(connection => {\n const topicId = connection.connectionTopicId;\n\n if (!topicId || topicId.includes(':') || !topicId.match(/^0\\.0\\.\\d+$/)) {\n this.logger.debug(\n `Skipping activity fetch for invalid topic ID format: ${topicId}`,\n );\n return false;\n }\n return true;\n });\n\n const activityPromises = validConnections.map(async connection => {\n try {\n const topicId = connection.connectionTopicId;\n const messagesResult = await this.baseClient.getMessages(topicId);\n\n if (messagesResult?.messages?.length > 0) {\n this.processConnectionMessages(topicId, messagesResult.messages);\n }\n } catch (error) {\n this.logger.debug(\n `Failed to fetch activity for ${connection.connectionTopicId}:`,\n error,\n );\n }\n });\n\n await Promise.allSettled(activityPromises);\n }\n\n /**\n * Checks if an account should be filtered, taking into account existing established connections\n * @param accountId - The account ID to check\n * @returns True if the account should be filtered, false otherwise\n */\n private shouldFilterAccount(accountId: string): boolean {\n if (!this.filterPendingAccountIds.has(accountId)) {\n return false;\n }\n\n if (this.hasEstablishedConnectionWithAccount(accountId)) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Process outbound messages to track connection requests and confirmations\n * @param messages - The messages to process\n * @param accountId - The account ID that sent the messages\n * @returns Array of connections after processing\n */\n processOutboundMessages(\n messages: HCSMessage[],\n accountId: string,\n ): Connection[] {\n if (!Boolean(messages?.length)) {\n return Array.from(this.connections.values());\n }\n\n const requestMessages = messages.filter(\n msg => msg.op === 'connection_request' && msg.connection_request_id,\n );\n\n for (const msg of requestMessages) {\n const requestId = msg.connection_request_id!;\n const operatorId = msg.operator_id || '';\n const targetAccountId =\n this.baseClient.extractAccountFromOperatorId(operatorId);\n const targetInboundTopicId =\n this.baseClient.extractTopicFromOperatorId(operatorId);\n\n if (this.shouldFilterAccount(targetAccountId)) {\n this.logger.debug(\n `Filtering out outbound request to account: ${targetAccountId}`,\n );\n continue;\n }\n\n const isAlreadyConfirmed = Array.from(this.connections.values()).some(\n conn =>\n conn.connectionRequestId === requestId &&\n !conn.isPending &&\n conn.targetAccountId === targetAccountId,\n );\n\n const pendingKey = `req-${requestId}:${operatorId}`;\n\n if (!isAlreadyConfirmed && !this.pendingRequests.has(pendingKey)) {\n const pendingRequest = {\n id: requestId,\n requesterId: accountId,\n requesterTopicId: msg.outbound_topic_id || '',\n targetAccountId,\n targetTopicId: targetInboundTopicId,\n operatorId,\n sequenceNumber: msg.sequence_number,\n created: msg.created || new Date(),\n memo: msg.m,\n status: 'pending' as 'pending' | 'confirmed' | 'rejected',\n };\n\n this.pendingRequests.set(pendingKey, pendingRequest);\n\n if (!this.connections.has(pendingKey)) {\n const pendingConnection = {\n connectionTopicId: pendingKey,\n targetAccountId,\n targetInboundTopicId,\n status: 'pending' as\n | 'pending'\n | 'established'\n | 'needs_confirmation'\n | 'closed',\n isPending: true,\n needsConfirmation: false,\n created: msg.created || new Date(),\n connectionRequestId: requestId,\n uniqueRequestKey: pendingKey,\n originTopicId: msg.outbound_topic_id || '',\n processed: false,\n memo: msg.m,\n };\n\n this.connections.set(pendingKey, pendingConnection);\n }\n }\n }\n\n const confirmationMessages = messages.filter(\n msg =>\n msg.op === 'connection_created' &&\n msg.connection_topic_id &&\n msg.connection_request_id,\n );\n\n for (const msg of confirmationMessages) {\n const requestId = msg.connection_request_id!;\n const connectionTopicId = msg.connection_topic_id!;\n const targetAccountId = this.baseClient.extractAccountFromOperatorId(\n msg.operator_id || '',\n );\n\n if (this.shouldFilterAccount(targetAccountId)) {\n this.logger.debug(\n `Filtering out outbound confirmation to account: ${targetAccountId}`,\n );\n continue;\n }\n\n const pendingKey = `req-${requestId}:${msg.operator_id}`;\n\n const pendingRequest = this.pendingRequests.get(pendingKey);\n if (pendingRequest) {\n pendingRequest.status = 'confirmed';\n }\n\n if (this.connections.has(pendingKey)) {\n this.connections.delete(pendingKey);\n }\n\n if (!this.connections.has(connectionTopicId)) {\n this.connections.set(connectionTopicId, {\n connectionTopicId,\n targetAccountId,\n status: 'established',\n isPending: false,\n needsConfirmation: false,\n created: msg.created || new Date(),\n connectionRequestId: requestId,\n confirmedRequestId: msg.confirmed_request_id,\n requesterOutboundTopicId: msg.outbound_topic_id,\n uniqueRequestKey: pendingKey,\n originTopicId: msg.outbound_topic_id || '',\n processed: false,\n memo: msg.m,\n });\n } else {\n const conn = this.connections.get(connectionTopicId)!;\n this.connections.set(connectionTopicId, {\n ...conn,\n status: 'established',\n isPending: false,\n needsConfirmation: false,\n connectionRequestId: requestId,\n confirmedRequestId: msg.confirmed_request_id,\n requesterOutboundTopicId: msg.outbound_topic_id,\n uniqueRequestKey: pendingKey,\n originTopicId: msg.outbound_topic_id || '',\n processed: false,\n memo: msg.m,\n });\n }\n }\n\n const closedMessages = messages.filter(\n msg =>\n (msg.op as string) === 'connection_closed' ||\n (msg.op === 'close_connection' && msg.connection_topic_id),\n );\n\n for (const msg of closedMessages) {\n const connectionTopicId = msg.connection_topic_id!;\n\n if (this.connections.has(connectionTopicId)) {\n const conn = this.connections.get(connectionTopicId)!;\n if (\n this.shouldFilterAccount(conn.targetAccountId) &&\n conn.status !== 'established'\n ) {\n continue;\n }\n\n const uniqueKey =\n msg.connection_request_id && msg.operator_id\n ? `req-${msg.connection_request_id}:${msg.operator_id}`\n : undefined;\n\n this.connections.set(connectionTopicId, {\n ...conn,\n status: 'closed',\n isPending: false,\n needsConfirmation: false,\n lastActivity: msg.created || new Date(),\n closedReason: msg.reason,\n closeMethod: msg.close_method,\n uniqueRequestKey: uniqueKey,\n originTopicId: conn.originTopicId,\n processed: false,\n memo: msg.m,\n });\n }\n }\n\n return Array.from(this.connections.values()).filter(\n conn =>\n conn.status === 'established' ||\n conn.status === 'closed' ||\n !this.filterPendingAccountIds.has(conn.targetAccountId),\n );\n }\n\n /**\n * Process inbound messages to track connection requests and confirmations\n * @param messages - The messages to process\n * @returns Array of connections after processing\n */\n processInboundMessages(messages: HCSMessage[]): Connection[] {\n if (!Boolean(messages?.length)) {\n return Array.from(this.connections.values());\n }\n\n const requestMessages = messages.filter(\n msg => msg.op === 'connection_request' && msg.sequence_number,\n );\n\n const confirmationMessages = messages.filter(\n msg =>\n msg.op === 'connection_created' &&\n msg.connection_topic_id &&\n msg.connection_id,\n );\n\n for (const msg of requestMessages) {\n const sequenceNumber = msg.sequence_number;\n const operatorId = msg.operator_id || '';\n const requestorAccountId =\n this.baseClient.extractAccountFromOperatorId(operatorId);\n const requestorTopicId =\n this.baseClient.extractTopicFromOperatorId(operatorId);\n\n if (this.shouldFilterAccount(requestorAccountId)) {\n this.logger.debug(\n `Filtering out request from account: ${requestorAccountId}`,\n );\n continue;\n }\n\n const needsConfirmKey = `inb-${sequenceNumber}:${operatorId}`;\n\n const hasCreated = confirmationMessages.some(\n m => m.connection_id === sequenceNumber,\n );\n\n if (hasCreated) {\n this.logger.debug(\n `Skipping request from ${requestorAccountId} as it has already been confirmed`,\n );\n continue;\n }\n\n if (!this.connections.has(needsConfirmKey)) {\n this.connections.set(needsConfirmKey, {\n connectionTopicId: needsConfirmKey,\n targetAccountId: requestorAccountId,\n targetInboundTopicId: requestorTopicId,\n status: 'needs_confirmation',\n isPending: false,\n needsConfirmation: true,\n created: msg.created || new Date(),\n inboundRequestId: sequenceNumber,\n uniqueRequestKey: needsConfirmKey,\n originTopicId: requestorTopicId,\n processed: false,\n memo: msg.m,\n });\n }\n }\n\n for (const msg of confirmationMessages) {\n const sequenceNumber = msg.connection_id!;\n const connectionTopicId = msg.connection_topic_id!;\n const connectedAccountId = msg.connected_account_id || '';\n const operatorId = msg.operator_id || '';\n\n if (this.shouldFilterAccount(connectedAccountId)) {\n this.logger.debug(\n `Filtering out confirmation for account: ${connectedAccountId}`,\n );\n continue;\n }\n\n const needsConfirmKey = `inb-${sequenceNumber}:${operatorId}`;\n\n if (this.connections.has(needsConfirmKey)) {\n this.connections.delete(needsConfirmKey);\n }\n\n if (!this.connections.has(connectionTopicId)) {\n this.connections.set(connectionTopicId, {\n connectionTopicId,\n targetAccountId: connectedAccountId,\n status: 'established',\n isPending: false,\n needsConfirmation: false,\n created: msg.created || new Date(),\n inboundRequestId: sequenceNumber,\n uniqueRequestKey: needsConfirmKey,\n originTopicId: msg.connection_topic_id,\n processed: false,\n memo: msg.m,\n });\n } else {\n const conn = this.connections.get(connectionTopicId)!;\n this.connections.set(connectionTopicId, {\n ...conn,\n status: 'established',\n isPending: false,\n needsConfirmation: false,\n inboundRequestId: sequenceNumber,\n uniqueRequestKey: needsConfirmKey,\n originTopicId: msg.connection_topic_id,\n processed: false,\n memo: msg.m,\n });\n }\n }\n\n return Array.from(this.connections.values()).filter(\n conn =>\n conn.status === 'established' ||\n conn.status === 'closed' ||\n !this.filterPendingAccountIds.has(conn.targetAccountId),\n );\n }\n\n /**\n * Process connection topic messages to update last activity time\n * @param connectionTopicId - The topic ID of the connection\n * @param messages - The messages to process\n * @returns The updated connection or undefined if not found\n */\n processConnectionMessages(\n connectionTopicId: string,\n messages: HCSMessage[],\n ): Connection | undefined {\n if (\n !messages ||\n messages.length === 0 ||\n !this.connections.has(connectionTopicId)\n ) {\n return this.connections.get(connectionTopicId);\n }\n\n const latestMessage = messages\n .filter(m => m.created)\n .sort((a, b) => {\n const dateA = a.created ? new Date(a.created).getTime() : 0;\n const dateB = b.created ? new Date(b.created).getTime() : 0;\n return dateB - dateA;\n })[0];\n\n if (latestMessage?.created) {\n const conn = this.connections.get(connectionTopicId)!;\n this.connections.set(connectionTopicId, {\n ...conn,\n lastActivity: latestMessage.created,\n });\n }\n\n const closeMessage = messages.find(msg => msg.op === 'close_connection');\n if (closeMessage) {\n const conn = this.connections.get(connectionTopicId)!;\n this.connections.set(connectionTopicId, {\n ...conn,\n status: 'closed',\n lastActivity: closeMessage.created || new Date(),\n closedReason: closeMessage.reason,\n closeMethod: 'explicit',\n });\n }\n\n return this.connections.get(connectionTopicId);\n }\n\n /**\n * Adds or updates profile information for a connection\n * @param accountId - The account ID to add profile info for\n * @param profile - The profile information\n */\n addProfileInfo(accountId: string, profile: AIAgentProfile): void {\n this.profileCache.set(accountId, profile);\n\n const matchingConnections = Array.from(this.connections.values()).filter(\n conn => conn.targetAccountId === accountId,\n );\n\n for (const conn of matchingConnections) {\n this.connections.set(conn.connectionTopicId, {\n ...conn,\n profileInfo: profile,\n targetAgentName: profile.display_name,\n targetInboundTopicId: profile.inboundTopicId,\n targetOutboundTopicId: profile.outboundTopicId,\n });\n }\n }\n\n /**\n * Gets all connections\n * @returns Array of all connections that should be visible\n */\n getAllConnections(): Connection[] {\n const connections = Array.from(this.connections.values()).filter(\n conn =>\n conn.status === 'established' ||\n conn.status === 'closed' ||\n !this.filterPendingAccountIds.has(conn.targetAccountId),\n );\n return connections;\n }\n\n /**\n * Gets all pending connection requests\n * @returns Array of pending connection requests\n */\n getPendingRequests(): Connection[] {\n const pendingConnections = Array.from(this.connections.values()).filter(\n conn => {\n return (\n conn.isPending &&\n !this.filterPendingAccountIds.has(conn.targetAccountId)\n );\n },\n );\n\n return pendingConnections;\n }\n\n /**\n * Helper method to check if there's an established connection with an account\n * @param accountId - The account ID to check\n * @returns True if there's an established connection, false otherwise\n */\n private hasEstablishedConnectionWithAccount(accountId: string): boolean {\n return Array.from(this.connections.values()).some(\n conn =>\n conn.targetAccountId === accountId && conn.status === 'established',\n );\n }\n\n /**\n * Gets all active (established) connections\n * @returns Array of active connections\n */\n getActiveConnections(): Connection[] {\n return Array.from(this.connections.values()).filter(\n conn => conn.status === 'established',\n );\n }\n\n /**\n * Gets all connections needing confirmation\n * @returns Array of connections needing confirmation\n */\n getConnectionsNeedingConfirmation(): Connection[] {\n return Array.from(this.connections.values()).filter(\n conn =>\n conn.needsConfirmation &&\n !this.filterPendingAccountIds.has(conn.targetAccountId),\n );\n }\n\n /**\n * Gets a connection by its topic ID\n * @param connectionTopicId - The topic ID to look up\n * @returns The connection with the given topic ID, or undefined if not found\n */\n getConnectionByTopicId(connectionTopicId: string): Connection | undefined {\n return this.connections.get(connectionTopicId);\n }\n\n /**\n * Gets a connection by account ID\n * @param accountId - The account ID to look up\n * @returns The connection with the given account ID, or undefined if not found\n */\n getConnectionByAccountId(accountId: string): Connection | undefined {\n return Array.from(this.connections.values()).find(\n conn =>\n conn.targetAccountId === accountId && conn.status === 'established',\n );\n }\n\n /**\n * Gets all connections for a specific account ID\n * @param accountId - The account ID to look up\n * @returns Array of connections for the given account ID\n */\n getConnectionsByAccountId(accountId: string): Connection[] {\n return Array.from(this.connections.values()).filter(\n conn => conn.targetAccountId === accountId,\n );\n }\n\n /**\n * Updates or adds a connection\n * @param connection - The connection to update or add\n */\n updateOrAddConnection(connection: Connection): void {\n this.connections.set(connection.connectionTopicId, connection);\n }\n\n /**\n * Clears all tracked connections and requests\n */\n clearAll(): void {\n this.connections.clear();\n this.pendingRequests.clear();\n }\n\n /**\n * Checks if a given connection request has been processed already\n * This uses a combination of topic ID and request ID to uniquely identify requests\n *\n * @param inboundTopicId - The inbound topic ID where the request was received\n * @param requestId - The sequence number (request ID)\n * @returns True if this specific request has been processed, false otherwise\n */\n isConnectionRequestProcessed(\n inboundTopicId: string,\n requestId: number,\n ): boolean {\n for (const conn of this.connections.values()) {\n if (\n conn.originTopicId === inboundTopicId &&\n conn.inboundRequestId === requestId &&\n conn.processed\n ) {\n return true;\n }\n\n if (\n conn.originTopicId === inboundTopicId &&\n conn.connectionRequestId === requestId &&\n conn.processed\n ) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Marks a specific connection request as processed\n *\n * @param inboundTopicId - The inbound topic ID where the request was received\n * @param requestId - The sequence number (request ID)\n * @returns True if a matching connection was found and marked, false otherwise\n */\n markConnectionRequestProcessed(\n inboundTopicId: string,\n requestId: number,\n ): boolean {\n let found = false;\n\n for (const [key, conn] of this.connections.entries()) {\n if (\n conn.originTopicId === inboundTopicId &&\n conn.inboundRequestId === requestId\n ) {\n this.connections.set(key, {\n ...conn,\n processed: true,\n });\n found = true;\n this.logger.debug(\n `Marked inbound connection request #${requestId} on topic ${inboundTopicId} as processed`,\n );\n }\n\n if (\n conn.originTopicId === inboundTopicId &&\n conn.connectionRequestId === requestId\n ) {\n this.connections.set(key, {\n ...conn,\n processed: true,\n });\n found = true;\n this.logger.debug(\n `Marked outbound connection request #${requestId} on topic ${inboundTopicId} as processed`,\n );\n }\n }\n\n return found;\n }\n\n /**\n * Gets pending transactions from a specific connection\n * @param connectionTopicId - The connection topic ID to check for transactions\n * @param limit - Optional limit for the number of transactions to return\n * @returns Array of pending transaction messages sorted by timestamp (newest first)\n */\n async getPendingTransactions(\n connectionTopicId: string,\n limit?: number,\n ): Promise<TransactMessage[]> {\n try {\n const transactMessages = await this.baseClient.getTransactionRequests(\n connectionTopicId,\n limit,\n );\n\n const pendingTransactions: TransactMessage[] = [];\n\n for (const transaction of transactMessages) {\n try {\n const status =\n await this.baseClient.mirrorNode.getScheduledTransactionStatus(\n transaction.schedule_id,\n );\n\n if (!status.executed && !status.deleted) {\n pendingTransactions.push(transaction);\n }\n } catch (error) {\n this.logger.error(`Error checking transaction status: ${error}`);\n pendingTransactions.push(transaction);\n }\n }\n\n return pendingTransactions;\n } catch (error) {\n this.logger.error(`Error getting pending transactions: ${error}`);\n return [];\n }\n }\n\n /**\n * Gets the status of a scheduled transaction\n * @param scheduleId - The schedule ID to check\n * @returns Status of the scheduled transaction\n */\n async getScheduledTransactionStatus(scheduleId: string): Promise<{\n executed: boolean;\n executedTimestamp?: string;\n deleted: boolean;\n expirationTime?: string;\n }> {\n return this.baseClient.mirrorNode.getScheduledTransactionStatus(scheduleId);\n }\n\n /**\n * Gets the timestamp of the last message sent by the specified operator on the connection topic\n * @param connectionTopicId - The topic ID to check\n * @param operatorAccountId - The account ID of the operator\n * @returns The timestamp of the last message or undefined if no messages found\n */\n async getLastOperatorActivity(\n connectionTopicId: string,\n operatorAccountId: string,\n ): Promise<Date | undefined> {\n try {\n const { messages } =\n await this.baseClient.getMessageStream(connectionTopicId);\n\n const operatorMessages = messages.filter(\n msg =>\n msg.operator_id &&\n msg.operator_id.includes(operatorAccountId) &&\n msg.created,\n );\n\n if (operatorMessages.length === 0) {\n return undefined;\n }\n\n operatorMessages.sort(\n (a, b) => b.created!.getTime() - a.created!.getTime(),\n );\n\n return operatorMessages[0].created;\n } catch (error) {\n this.logger.error(`Error get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AQF,MAAM,8BAA8B,YAKjC;AACD,WAAO,KAAK,WAAW,WAAW,8BAA8B,UAAU;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS5E,MAAM,wBACJ,mBACA,mBAC2B;AACvB,QAAA;AACF,YAAM,EAAE,SAAS,IACf,MAAM,KAAK,WAAW,iBAAiB,iBAAiB;AAE1D,YAAM,mBAAmB,SAAS;AAAA,QAChC,CAAA,QACE,IAAI,eACJ,IAAI,YAAY,SAAS,iBAAiB,KAC1C,IAAI;AAAA,MACR;AAEI,UAAA,iBAAiB,WAAW,GAAG;AAC1B,eAAA;AAAA,MAAA;AAGQ,uBAAA;AAAA,QACf,CAAC,GAAG,MAAM,EAAE,QAAS,YAAY,EAAE,QAAS,QAAQ;AAAA,MACtD;AAEO,aAAA,iBAAiB,CAAC,EAAE;AAAA,aACpB,OAAO;AACd,WAAK,OAAO,MAAM,yCAAyC,KAAK,EAAE;AAC3D,aAAA;AAAA,IAAA;AAAA,EACT;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"standards-sdk.es12.js","sources":["../../src/hcs-11/person-builder.ts"],"sourcesContent":["import { HCS11Profile, SocialLink, SocialPlatform } from './types';\nimport { Logger } from '../utils/logger';\n\nexport class PersonBuilder {\n private config: Partial<\n HCS11Profile & { pfpBuffer?: Buffer; pfpFileName?: string }\n > = {\n version: '1.0',\n type: 0,\n };\n private logger: Logger;\n\n constructor() {\n this.logger = Logger.getInstance({\n module: 'PersonBuilder',\n });\n }\n\n setName(name: string): this {\n this.config.display_name = name;\n return this;\n }\n\n setAlias(alias: string): this {\n this.config.alias = alias;\n return this;\n }\n\n setBio(bio: string): this {\n this.config.bio = bio;\n return this;\n }\n\n /**\n * @deprecated Use setBio instead\n */\n setDescription(description: string): this {\n return this.setBio(description);\n }\n\n addSocial(platform: SocialPlatform, handle: string): this {\n if (!this.config.socials) {\n this.config.socials = [];\n }\n const existingSocial = this.config.socials.find(\n (s: SocialLink) => s.platform === platform\n );\n if (!existingSocial) {\n this.config.socials.push({ platform, handle });\n } else {\n existingSocial.handle = handle;\n }\n return this;\n }\n\n setProfileImage(profileImage: string): this {\n this.config.profileImage = profileImage;\n return this;\n }\n\n setProfilePicture(pfpBuffer: Buffer, pfpFileName: string): this {\n this.config.pfpBuffer = pfpBuffer;\n this.config.pfpFileName = pfpFileName;\n return this;\n }\n\n setExistingProfilePicture(pfpTopicId: string): this {\n this.config.profileImage = `hcs://1/${pfpTopicId}`;\n return this;\n }\n\n addProperty(key: string, value: any): this {\n if (!this.config.properties) {\n this.config.properties = {};\n }\n this.config.properties[key] = value;\n return this;\n }\n\n setInboundTopicId(topicId: string): this {\n this.config.inboundTopicId = topicId;\n return this;\n }\n\n setOutboundTopicId(topicId: string): this {\n this.config.outboundTopicId = topicId;\n return this;\n }\n\n getProfilePicture(): { pfpBuffer?: Buffer; pfpFileName?: string } {\n return {\n pfpBuffer: this.config.pfpBuffer,\n pfpFileName: this.config.pfpFileName,\n };\n }\n\n build(): HCS11Profile & { pfpBuffer?: Buffer; pfpFileName?: string } {\n if (!this.config.display_name) {\n throw new Error('Display name is required for the profile');\n }\n\n if (!this.config.bio) {\n this.logger.warn('No bio provided for person profile');\n }\n\n if (!this.config.pfpBuffer && !this.config.profileImage) {\n this.logger.warn('No profile picture provided or referenced');\n }\n\n return {\n version: this.config.version!,\n type: 0,\n display_name: this.config.display_name,\n alias: this.config.alias,\n bio: this.config.bio,\n socials: this.config.socials,\n profileImage: this.config.profileImage,\n properties: this.config.properties,\n inboundTopicId: this.config.inboundTopicId,\n outboundTopicId: this.config.outboundTopicId,\n pfpBuffer: this.config.pfpBuffer,\n pfpFileName: this.config.pfpFileName,\n };\n }\n}\n"],"names":[],"mappings":";AAGO,MAAM,cAAc;AAAA,EASzB,cAAc;AARd,SAAQ,SAEJ;AAAA,MACF,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAIO,SAAA,SAAS,OAAO,YAAY;AAAA,MAC/B,QAAQ;AA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AuB;AACxC,SAAK,OAAO,kBAAkB;AACvB,WAAA;AAAA,EAAA;AAAA,EAGT,oBAAkE;AACzD,WAAA;AAAA,MACL,WAAW,KAAK,OAAO;AAAA,MACvB,aAAa,KAAK,OAAO;AAAA,IAC3B;AAAA,EAAA;AAAA,EAGF,QAAqE;AAC/D,QAAA,CAAC,KAAK,OAAO,cAAc;AACvB,YAAA,IAAI,MAAM,0CAA0C;AAAA,IAAA;AAGxD,QAAA,CAAC,KAAK,OAAO,KAAK;AACf,WAAA,OAAO,KAAK,oCAAoC;AAAA,IAAA;AAGvD,QAAI,CAAC,KAAK,OAAO,aAAa,CAAC,KAAK,OAAO,cAAc;AAClD,WAAA,OAAO,KAAK,2CAA2C;AAAA,IAAA;AAGvD,WAAA;AAAA,MACL,SAAS,KAAK,OAAO;AAAA,MACrB,MAAM;AAAA,MACN,cAAc,KAAK,OAAO;AAAA,MAC1B,OAAO,KAAK,OAAO;AAAA,MACnB,KAAK,KAAK,OAAO;AAAA,MACjB,SAAS,KAAK,OAAO;AAAA,MACrB,cAAc,KAAK,OAAO;AAAA,MAC1B,YAAY,KAAK,OAAO;AAAA,MACxB,gBAAgB,KAAK,OAAO;AAAA,MAC5B,iBAAiB,KAAK,OAAO;AAAA,MAC7B,WAAW,KAAK,OAAO;AAAA,MACvB,aAAa,KAAK,OAAO;AAAA,IAC3B;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"standards-sdk.es12.js","sources":["../../src/hcs-11/person-builder.ts"],"sourcesContent":["import { HCS11Profile, SocialLink, SocialPlatform } from './types';\nimport { Logger } from '../utils/logger';\n\nexport class PersonBuilder {\n private config: Partial<\n HCS11Profile & { pfpBuffer?: Buffer; pfpFileName?: string }\n > = {\n version: '1.0',\n type: 0,\n };\n private logger: Logger;\n\n constructor() {\n this.logger = Logger.getInstance({\n module: 'PersonBuilder',\n });\n }\n\n setName(name: string): this {\n this.config.display_name = name;\n return this;\n }\n\n setAlias(alias: string): this {\n this.config.alias = alias;\n return this;\n }\n\n setBio(bio: string): this {\n this.config.bio = bio;\n return this;\n }\n\n /**\n * @deprecated Use setBio instead\n */\n setDescription(description: string): this {\n return this.setBio(description);\n }\n\n addSocial(platform: SocialPlatform, handle: string): this {\n if (!this.config.socials) {\n this.config.socials = [];\n }\n const existingSocial = this.config.socials.find(\n (s: SocialLink) => s.platform === platform,\n );\n if (!existingSocial) {\n this.config.socials.push({ platform, handle });\n } else {\n existingSocial.handle = handle;\n }\n return this;\n }\n\n setProfileImage(profileImage: string): this {\n this.config.profileImage = profileImage;\n return this;\n }\n\n setProfilePicture(pfpBuffer: Buffer, pfpFileName: string): this {\n this.config.pfpBuffer = pfpBuffer;\n this.config.pfpFileName = pfpFileName;\n return this;\n }\n\n setExistingProfilePicture(pfpTopicId: string): this {\n this.config.profileImage = `hcs://1/${pfpTopicId}`;\n return this;\n }\n\n addProperty(key: string, value: any): this {\n if (!this.config.properties) {\n this.config.properties = {};\n }\n this.config.properties[key] = value;\n return this;\n }\n\n setInboundTopicId(topicId: string): this {\n this.config.inboundTopicId = topicId;\n return this;\n }\n\n setOutboundTopicId(topicId: string): this {\n this.config.outboundTopicId = topicId;\n return this;\n }\n\n getProfilePicture(): { pfpBuffer?: Buffer; pfpFileName?: string } {\n return {\n pfpBuffer: this.config.pfpBuffer,\n pfpFileName: this.config.pfpFileName,\n };\n }\n\n build(): HCS11Profile & { pfpBuffer?: Buffer; pfpFileName?: string } {\n if (!this.config.display_name) {\n throw new Error('Display name is required for the profile');\n }\n\n if (!this.config.bio) {\n this.logger.warn('No bio provided for person profile');\n }\n\n if (!this.config.pfpBuffer && !this.config.profileImage) {\n this.logger.warn('No profile picture provided or referenced');\n }\n\n return {\n version: this.config.version!,\n type: 0,\n display_name: this.config.display_name,\n alias: this.config.alias,\n bio: this.config.bio,\n socials: this.config.socials,\n profileImage: this.config.profileImage,\n properties: this.config.properties,\n inboundTopicId: this.config.inboundTopicId,\n outboundTopicId: this.config.outboundTopicId,\n pfpBuffer: this.config.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AAO,YAAY;AACtB,WAAA,OAAO,aAAa,CAAC;AAAA,IAAA;AAEvB,SAAA,OAAO,WAAW,GAAG,IAAI;AACvB,WAAA;AAAA,EAAA;AAAA,EAGT,kBAAkB,SAAuB;AACvC,SAAK,OAAO,iBAAiB;AACtB,WAAA;AAAA,EAAA;AAAA,EAGT,mBAAmB,SAAuB;AACxC,SAAK,OAAO,kBAAkB;AACvB,WAAA;AAAA,EAAA;AAAA,EAGT,oBAAkE;AACzD,WAAA;AAAA,MACL,WAAW,KAAK,OAAO;AAAA,MACvB,aAAa,KAAK,OAAO;AAAA,IAC3B;AAAA,EAAA;AAAA,EAGF,QAAqE;AAC/D,QAAA,CAAC,KAAK,OAAO,cAAc;AACvB,YAAA,IAAI,MAAM,0CAA0C;AAAA,IAAA;AAGxD,QAAA,CAAC,KAAK,OAAO,KAAK;AACf,WAAA,OAAO,KAAK,oCAAoC;AAAA,IAAA;AAGvD,QAAI,CAAC,KAAK,OAAO,aAAa,CAAC,KAAK,OAAO,cAAc;AAClD,WAAA,OAAO,KAAK,2CAA2C;AAAA,IAAA;AAGvD,WAAA;AAAA,MACL,SAAS,KAAK,OAAO;AAAA,MACrB,MAAM;AAAA,MACN,cAAc,KAAK,OAAO;AAAA,MAC1B,OAAO,KAAK,OAAO;AAAA,MACnB,KAAK,KAAK,OAAO;AAAA,MACjB,SAAS,KAAK,OAAO;AAAA,MACrB,cAAc,KAAK,OAAO;AAAA,MAC1B,YAAY,KAAK,OAAO;AAAA,MACxB,gBAAgB,KAAK,OAAO;AAAA,MAC5B,iBAAiB,KAAK,OAAO;AAAA,MAC7B,WAAW,KAAK,OAAO;AAAA,MACvB,aAAa,KAAK,OAAO;AAAA,IAC3B;AAAA,EAAA;AAEJ;"}
@@ -46,6 +46,11 @@ class HCS11Client {
46
46
  this.client = config.network === "mainnet" ? Client.forMainnet() : Client.forTestnet();
47
47
  this.auth = config.auth;
48
48
  this.network = config.network;
49
+ this.logger = Logger.getInstance({
50
+ level: config.logLevel || "info",
51
+ module: "HCS-11",
52
+ silent: config.silent
53
+ });
49
54
  this.mirrorNode = new HederaMirrorNode(
50
55
  this.network,
51
56
  this.logger
@@ -54,10 +59,6 @@ class HCS11Client {
54
59
  const privateKey = PrivateKey.fromString(this.auth.privateKey);
55
60
  this.client.setOperator(this.auth.operatorId, privateKey);
56
61
  }
57
- this.logger = Logger.getInstance({
58
- level: config.logLevel || "info",
59
- module: "HCS-11"
60
- });
61
62
  }
62
63
  getClient() {
63
64
  return this.client;
@@ -1 +1 @@
1
- {"version":3,"file":"standards-sdk.es13.js","sources":["../../src/hcs-11/client.ts"],"sourcesContent":["import {\n AccountId,\n AccountUpdateTransaction,\n Client,\n PrivateKey,\n Status,\n Transaction,\n} from '@hashgraph/sdk';\nimport {\n inscribe,\n inscribeWithSigner,\n InscriptionInput,\n InscriptionOptions,\n} from '../inscribe';\nimport { Logger } from '../utils/logger';\nimport * as mime from 'mime-types';\nimport { z, ZodIssue } from 'zod';\nimport type { DAppSigner } from '@hashgraph/hedera-wallet-connect';\nimport { ProgressReporter } from '../utils/progress-reporter';\nimport { HederaMirrorNode } from '../services';\nimport { TopicInfo } from '../services/types';\nimport {\n ProfileType,\n AIAgentType,\n AIAgentCapability,\n SocialLink,\n PersonalProfile,\n AIAgentProfile,\n HCS11Profile,\n HCS11Auth,\n HCS11ClientConfig,\n TransactionResult,\n InscribeProfileResponse,\n InscribeImageResponse,\n AgentMetadata,\n InscribeImageOptions,\n InscribeProfileOptions,\n capabilityNameToCapabilityMap,\n} from './types';\n\nconst SocialLinkSchema = z.object({\n platform: z.string().min(1),\n handle: z.string().min(1),\n});\n\nconst AIAgentDetailsSchema = z.object({\n type: z.nativeEnum(AIAgentType),\n capabilities: z.array(z.nativeEnum(AIAgentCapability)).min(1),\n model: z.string().min(1),\n creator: z.string().optional(),\n});\n\nconst BaseProfileSchema = z.object({\n version: z.string().min(1),\n type: z.nativeEnum(ProfileType),\n display_name: z.string().min(1),\n alias: z.string().optional(),\n bio: z.string().optional(),\n socials: z.array(SocialLinkSchema).optional(),\n profileImage: z.string().optional(),\n properties: z.record(z.any()).optional(),\n inboundTopicId: z.string().optional(),\n outboundTopicId: z.string().optional(),\n});\n\nconst PersonalProfileSchema = BaseProfileSchema.extend({\n type: z.literal(ProfileType.PERSONAL),\n language: z.string().optional(),\n timezone: z.string().optional(),\n});\n\nconst AIAgentProfileSchema = BaseProfileSchema.extend({\n type: z.literal(ProfileType.AI_AGENT),\n aiAgent: AIAgentDetailsSchema,\n});\n\nconst HCS11ProfileSchema = z.union([\n PersonalProfileSchema,\n AIAgentProfileSchema,\n]);\n\nexport class HCS11Client {\n private client: Client;\n private auth: HCS11Auth;\n private network: string;\n private logger: Logger;\n private mirrorNode: HederaMirrorNode;\n\n constructor(config: HCS11ClientConfig) {\n this.client =\n config.network === 'mainnet' ? Client.forMainnet() : Client.forTestnet();\n this.auth = config.auth;\n this.network = config.network;\n this.mirrorNode = new HederaMirrorNode(\n this.network as 'mainnet' | 'testnet',\n this.logger\n );\n\n if (this.auth.privateKey) {\n const privateKey = PrivateKey.fromString(this.auth.privateKey);\n this.client.setOperator(this.auth.operatorId, privateKey);\n }\n\n this.logger = Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS-11',\n });\n }\n\n public getClient(): Client {\n return this.client;\n }\n\n public getOperatorId(): string {\n return this.auth.operatorId;\n }\n\n public createPersonalProfile(\n displayName: string,\n options?: {\n alias?: string;\n bio?: string;\n socials?: SocialLink[];\n profileImage?: string;\n language?: string;\n timezone?: string;\n properties?: Record<string, any>;\n inboundTopicId?: string;\n outboundTopicId?: string;\n }\n ): PersonalProfile {\n return {\n version: '1.0',\n type: ProfileType.PERSONAL,\n display_name: displayName,\n alias: options?.alias,\n bio: options?.bio,\n socials: options?.socials,\n profileImage: options?.profileImage,\n properties: options?.properties,\n inboundTopicId: options?.inboundTopicId,\n outboundTopicId: options?.outboundTopicId,\n };\n }\n\n public createAIAgentProfile(\n displayName: string,\n agentType: AIAgentType,\n capabilities: AIAgentCapability[],\n model: string,\n options?: {\n alias?: string;\n bio?: string;\n socials?: SocialLink[];\n profileImage?: string;\n properties?: Record<string, any>;\n inboundTopicId?: string;\n outboundTopicId?: string;\n creator?: string;\n }\n ): AIAgentProfile {\n const validation = this.validateProfile({\n version: '1.0',\n type: ProfileType.AI_AGENT,\n display_name: displayName,\n alias: options?.alias,\n bio: options?.bio,\n socials: options?.socials,\n profileImage: options?.profileImage,\n properties: options?.properties,\n inboundTopicId: options?.inboundTopicId,\n outboundTopicId: options?.outboundTopicId,\n aiAgent: {\n type: agentType,\n capabilities,\n model,\n creator: options?.creator,\n },\n });\n\n if (!validation.valid) {\n throw new Error(\n `Invalid AI Agent Profile: ${validation.errors.join(', ')}`\n );\n }\n\n return {\n version: '1.0',\n type: ProfileType.AI_AGENT,\n display_name: displayName,\n alias: options?.alias,\n bio: options?.bio,\n socials: options?.socials,\n profileImage: options?.profileImage,\n properties: options?.properties,\n inboundTopicId: options?.inboundTopicId,\n outboundTopicId: options?.outboundTopicId,\n aiAgent: {\n type: agentType,\n capabilities,\n model,\n creator: options?.creator,\n },\n };\n }\n\n public validateProfile(profile: unknown): {\n valid: boolean;\n errors: string[];\n } {\n const result = HCS11ProfileSchema.safeParse(profile);\n\n if (result.success) {\n return { valid: true, errors: [] };\n }\n\n const formattedErrors = result.error.errors.map((err: ZodIssue) => {\n const path = err.path.join('.');\n let message = err.message;\n\n if (err.code === 'invalid_type') {\n message = `Expected ${err.expected}, got ${err.received}`;\n } else if (err.code === 'invalid_enum_value') {\n const validOptions = (err as any).options?.join(', ');\n message = `Invalid value. Valid options are: ${validOptions}`;\n } else if (err.code === 'too_small' && err.type === 'string') {\n message = 'Cannot be empty';\n }\n\n return `${path}: ${message}`;\n });\n\n return { valid: false, errors: formattedErrors };\n }\n\n public profileToJSONString(profile: HCS11Profile): string {\n return JSON.stringify(profile);\n }\n\n public parseProfileFromString(profileStr: string): HCS11Profile | null {\n try {\n const parsedProfile = JSON.parse(profileStr);\n const validation = this.validateProfile(parsedProfile);\n if (!validation.valid) {\n this.logger.error('Invalid profile format:', validation.errors);\n return null;\n }\n return parsedProfile as HCS11Profile;\n } catch (error) {\n this.logger.error('Error parsing profile:');\n return null;\n }\n }\n\n public setProfileForAccountMemo(\n topicId: string,\n topicStandard: 1 | 2 | 7 = 1\n ): string {\n return `hcs-11:hcs://${topicStandard}/${topicId}`;\n }\n\n private async executeTransaction<T>(\n transaction: Transaction\n ): Promise<TransactionResult<T>> {\n try {\n if (this.auth.privateKey) {\n const signedTx = await transaction.signWithOperator(this.client);\n const response = await signedTx.execute(this.client);\n const receipt = await response.getReceipt(this.client);\n\n if (receipt.status.toString() !== Status.Success.toString()) {\n return {\n success: false,\n error: `Transaction failed: ${receipt.status.toString()}`,\n };\n }\n\n return {\n success: true,\n result: receipt as T,\n };\n }\n\n if (!this.auth.signer) {\n throw new Error('No valid authentication method provided');\n }\n\n const signer = this.auth.signer;\n const frozenTransaction = await transaction.freezeWithSigner(signer);\n const response = await frozenTransaction.executeWithSigner(signer);\n const receipt = await response.getReceiptWithSigner(signer);\n\n if (receipt.status.toString() !== Status.Success.toString()) {\n return {\n success: false,\n error: `Transaction failed: ${receipt.status.toString()}: ${Status.Success.toString()}`,\n };\n }\n\n return {\n success: true,\n result: receipt as T,\n };\n } catch (error) {\n return {\n success: false,\n error:\n error instanceof Error\n ? error.message\n : 'Unknown error during transaction execution',\n };\n }\n }\n\n public async inscribeImage(\n buffer: Buffer,\n fileName: string,\n options?: InscribeImageOptions\n ): Promise<InscribeImageResponse> {\n try {\n const progressCallback = options?.progressCallback;\n const progressReporter = new ProgressReporter({\n module: 'HCS11-Image',\n logger: this.logger,\n callback: progressCallback as any,\n });\n\n progressReporter.preparing('Preparing to inscribe image', 0);\n\n const mimeType = mime.lookup(fileName) || 'application/octet-stream';\n\n const waitForConfirmation = options?.waitForConfirmation ?? true;\n\n let inscriptionResponse;\n if (this.auth.signer) {\n if ('accountId' in this.auth.signer) {\n progressReporter.preparing('Using signer for inscription', 10);\n\n inscriptionResponse = await inscribeWithSigner(\n {\n type: 'buffer',\n buffer,\n fileName,\n mimeType,\n },\n this.auth.signer as DAppSigner,\n {\n network: this.network as 'mainnet' | 'testnet',\n waitForConfirmation,\n waitMaxAttempts: 150,\n waitIntervalMs: 4000,\n logging: {\n level: 'debug',\n },\n progressCallback: (data: any) => {\n const adjustedPercent = 10 + (data.progressPercent || 0) * 0.8;\n progressReporter.report({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: data.details,\n });\n },\n }\n );\n } else {\n progressReporter.failed(\n 'Signer must be a DAppSigner for inscription'\n );\n throw new Error('Signer must be a DAppSigner for inscription');\n }\n } else {\n if (!this.auth.privateKey) {\n progressReporter.failed('Private key is required for inscription');\n this.logger.error('Private key is required for inscription');\n throw new Error('Private key is required for inscription');\n }\n\n progressReporter.preparing('Using private key for inscription', 10);\n\n inscriptionResponse = await inscribe(\n {\n type: 'buffer',\n buffer,\n fileName,\n mimeType,\n },\n {\n accountId: this.auth.operatorId,\n privateKey: this.auth.privateKey,\n network: this.network as 'mainnet' | 'testnet',\n },\n {\n waitForConfirmation,\n waitMaxAttempts: 150,\n waitIntervalMs: 2000,\n logging: {\n level: 'debug',\n },\n progressCallback: (data: any) => {\n const adjustedPercent = 10 + (data.progressPercent || 0) * 0.8;\n progressReporter.report({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: data.details,\n });\n },\n }\n );\n }\n\n if (inscriptionResponse.confirmed) {\n progressReporter.completed('Image inscription completed', {\n topic_id: inscriptionResponse.inscription.topic_id,\n });\n return {\n imageTopicId: inscriptionResponse.inscription.topic_id || '',\n transactionId: inscriptionResponse.result.jobId,\n success: true,\n };\n } else {\n progressReporter.verifying('Waiting for inscription confirmation', 50, {\n jobId: inscriptionResponse.result.jobId,\n });\n return {\n imageTopicId: '',\n transactionId: inscriptionResponse.result.jobId,\n success: false,\n error: 'Inscription not confirmed',\n };\n }\n } catch (error: any) {\n this.logger.error('Error inscribing image:', error);\n return {\n imageTopicId: '',\n transactionId: '',\n success: false,\n error: error.message || 'Error inscribing image',\n };\n }\n }\n\n public async inscribeProfile(\n profile: HCS11Profile,\n options?: InscribeProfileOptions\n ): Promise<InscribeProfileResponse> {\n this.logger.info('Inscribing HCS-11 profile');\n\n const progressCallback = options?.progressCallback;\n const progressReporter = new ProgressReporter({\n module: 'HCS11-Profile',\n logger: this.logger,\n callback: progressCallback as any,\n });\n\n progressReporter.preparing('Validating profile data', 5);\n\n const validation = this.validateProfile(profile);\n if (!validation.valid) {\n progressReporter.failed(\n `Invalid profile: ${validation.errors.join(', ')}`\n );\n return {\n profileTopicId: '',\n transactionId: '',\n success: false,\n error: `Invalid profile: ${validation.errors.join(', ')}`,\n };\n }\n\n progressReporter.preparing('Formatting profile for inscription', 15);\n\n const profileJson = this.profileToJSONString(profile);\n const fileName = `profile-${profile.display_name\n .toLowerCase()\n .replace(/\\s+/g, '-')}.json`;\n\n try {\n const contentBuffer = Buffer.from(profileJson, 'utf-8');\n const contentType = 'application/json';\n\n progressReporter.preparing('Preparing profile for inscription', 20);\n\n const input: InscriptionInput = {\n type: 'buffer',\n buffer: contentBuffer,\n fileName,\n mimeType: contentType,\n };\n\n const inscriptionOptions: InscriptionOptions = {\n waitForConfirmation: true,\n mode: 'file',\n network: this.network as 'mainnet' | 'testnet',\n waitMaxAttempts: 100,\n waitIntervalMs: 2000,\n progressCallback: (data: any) => {\n const adjustedPercent =\n 20 + Number(data?.progressPercent || 0) * 0.75;\n progressReporter?.report({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: data.details,\n });\n },\n };\n\n progressReporter.submitting('Submitting profile to Hedera network', 30);\n\n const inscriptionResponse = this.auth.privateKey\n ? await inscribe(\n input,\n {\n accountId: this.auth.operatorId,\n privateKey: this.auth.privateKey,\n network: this.network as 'mainnet' | 'testnet',\n },\n inscriptionOptions\n )\n : await inscribeWithSigner(\n input,\n this.auth.signer as DAppSigner,\n inscriptionOptions\n );\n\n if (\n !inscriptionResponse.confirmed ||\n !inscriptionResponse.inscription.topic_id\n ) {\n progressReporter.failed('Failed to inscribe profile content');\n return {\n profileTopicId: '',\n transactionId: '',\n success: false,\n error: 'Failed to inscribe profile content',\n };\n }\n\n const topicId = inscriptionResponse.inscription.topic_id;\n\n progressReporter.completed('Profile inscription completed', {\n topicId,\n transactionId: inscriptionResponse.result.transactionId,\n });\n\n return {\n profileTopicId: topicId,\n transactionId: inscriptionResponse.result.transactionId,\n success: true,\n };\n } catch (error: any) {\n progressReporter.failed(\n `Error inscribing profile: ${error.message || 'Unknown error'}`\n );\n return {\n profileTopicId: '',\n transactionId: '',\n success: false,\n error: error.message || 'Unknown error during inscription',\n };\n }\n }\n\n public async updateAccountMemoWithProfile(\n accountId: string | AccountId,\n profileTopicId: string\n ): Promise<TransactionResult> {\n try {\n this.logger.info(\n `Updating account memo for ${accountId} with profile ${profileTopicId}`\n );\n const memo = this.setProfileForAccountMemo(profileTopicId);\n\n const transaction = new AccountUpdateTransaction()\n .setAccountMemo(memo)\n .setAccountId(accountId);\n\n return this.executeTransaction(transaction);\n } catch (error) {\n this.logger.error(\n `Error updating account memo: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n );\n return {\n success: false,\n error:\n error instanceof Error\n ? error.message\n : 'Unknown error updating account memo',\n };\n }\n }\n\n /**\n * Creates and inscribes a profile.\n *\n * @param profile - The profile to create and inscribe.\n * @param updateAccountMemo - Whether to update the account memo with the profile.\n * @param options - Optional configuration options.\n * @returns A promise that resolves to the inscription result.\n */\n public async createAndInscribeProfile(\n profile: HCS11Profile,\n updateAccountMemo = true,\n options?: InscribeProfileOptions\n ): Promise<InscribeProfileResponse> {\n const progressCallback = options?.progressCallback;\n const progressReporter = new ProgressReporter({\n module: 'HCS11-ProfileCreation',\n logger: this.logger,\n callback: progressCallback as any,\n });\n\n progressReporter.preparing('Starting profile creation process', 0);\n\n const inscriptionProgress = progressReporter.createSubProgress({\n minPercent: 0,\n maxPercent: 80,\n logPrefix: 'Inscription',\n });\n\n const inscriptionResult = await this.inscribeProfile(profile, {\n ...options,\n progressCallback: (data: any) => {\n inscriptionProgress.report({\n stage: data.stage,\n message: data.message,\n progressPercent: data.progressPercent,\n details: data.details,\n });\n },\n });\n\n if (!inscriptionResult?.success) {\n progressReporter.failed('Profile inscription failed', {\n error: inscriptionResult?.error,\n });\n return inscriptionResult;\n }\n\n progressReporter.confirming('Profile inscribed, updating account memo', 85);\n\n if (updateAccountMemo) {\n const memoResult = await this.updateAccountMemoWithProfile(\n this.auth.operatorId,\n inscriptionResult.profileTopicId\n );\n\n if (!memoResult.success) {\n progressReporter.failed('Failed to update account memo', {\n error: memoResult?.error,\n });\n return {\n ...inscriptionResult,\n success: false,\n error: memoResult?.error,\n };\n }\n }\n\n progressReporter.completed('Profile creation completed successfully', {\n profileTopicId: inscriptionResult.profileTopicId,\n transactionId: inscriptionResult.transactionId,\n });\n\n return inscriptionResult;\n }\n\n /**\n * Gets the capabilities from the capability names.\n *\n * @param capabilityNames - The capability names to get the capabilities for.\n * @returns The capabilities.\n */\n public async getCapabilitiesFromTags(\n capabilityNames: string[]\n ): Promise<number[]> {\n const capabilities: number[] = [];\n\n if (capabilityNames.length === 0) {\n return [AIAgentCapability.TEXT_GENERATION];\n }\n\n for (const capabilityName of capabilityNames) {\n const capability =\n capabilityNameToCapabilityMap[capabilityName.toLowerCase()];\n if (capability !== undefined && !capabilities.includes(capability)) {\n capabilities.push(capability);\n }\n }\n\n if (capabilities.length === 0) {\n capabilities.push(AIAgentCapability.TEXT_GENERATION);\n }\n\n return capabilities;\n }\n\n /**\n * Gets the agent type from the metadata.\n *\n * @param metadata - The metadata of the agent.\n * @returns The agent type.\n */\n public getAgentTypeFromMetadata(metadata: AgentMetadata): AIAgentType {\n if (metadata.type === 'autonomous') {\n return AIAgentType.AUTONOMOUS;\n } else {\n return AIAgentType.MANUAL;\n }\n }\n\n /**\n * Fetches a profile from the account memo.\n *\n * @param accountId - The account ID of the agent to fetch the profile for.\n * @param network - The network to use for the fetch.\n * @returns A promise that resolves to the profile.\n */\n public async fetchProfileByAccountId(\n accountId: string | AccountId,\n network?: string\n ): Promise<{\n success: boolean;\n profile?: HCS11Profile;\n error?: string;\n topicInfo?: TopicInfo;\n }> {\n try {\n this.logger.info(\n `Fetching profile for account ${accountId.toString()} on ${\n this.network\n }`\n );\n\n const memo = await this.mirrorNode.getAccountMemo(accountId.toString());\n\n this.logger.info(`Got account memo: ${memo}`);\n\n if (!memo?.startsWith('hcs-11:')) {\n return {\n success: false,\n error: `Account ${accountId.toString()} does not have a valid HCS-11 memo`,\n };\n }\n\n this.logger.info(`Found HCS-11 memo: ${memo}`);\n\n const protocolReference = memo.substring(7);\n\n if (protocolReference?.startsWith('hcs://')) {\n const hcsFormat = protocolReference.match(/hcs:\\/\\/(\\d+)\\/(.+)/);\n\n if (!hcsFormat) {\n return {\n success: false,\n error: `Invalid HCS protocol reference format: ${protocolReference}`,\n };\n }\n\n const [_, protocolId, profileTopicId] = hcsFormat;\n const networkParam = network || this.network || 'mainnet';\n\n this.logger.info(\n `Retrieving profile from Kiloscribe CDN: ${profileTopicId}`\n );\n const cdnUrl = `https://kiloscribe.com/api/inscription-cdn/${profileTopicId}?network=${networkParam}`;\n\n try {\n const response = await fetch(cdnUrl);\n\n if (!response.ok) {\n return {\n success: false,\n error: `Failed to fetch profile from Kiloscribe CDN: ${response.statusText}`,\n };\n }\n\n const profileData = await response.json();\n\n if (!profileData) {\n return {\n success: false,\n error: `No profile data found for topic ${profileTopicId}`,\n };\n }\n\n return {\n success: true,\n profile: profileData,\n topicInfo: {\n inboundTopic: profileData.inboundTopicId,\n outboundTopic: profileData.outboundTopicId,\n profileTopicId,\n },\n };\n } catch (cdnError: any) {\n this.logger.error(\n `Error retrieving from Kiloscribe CDN: ${cdnError.message}`\n );\n return {\n success: false,\n error: `Error retrieving from Kiloscribe CDN: ${cdnError.message}`,\n };\n }\n } else if (protocolReference.startsWith('ipfs://')) {\n this.logger.warn('IPFS protocol references are not fully supported');\n const response = await fetch(\n `https://ipfs.io/ipfs/${protocolReference.replace('ipfs://', '')}`\n );\n const profileData = await response.json();\n return {\n success: true,\n profile: profileData,\n topicInfo: {\n inboundTopic: profileData.inboundTopicId,\n outboundTopic: profileData.outboundTopicId,\n profileTopicId: profileData.profileTopicId,\n },\n };\n } else if (protocolReference.startsWith('ar://')) {\n const arTxId = protocolReference.replace('ar://', '');\n const response = await fetch(`https://arweave.net/${arTxId}`);\n\n if (!response.ok) {\n return {\n success: false,\n error: `Failed to fetch profile from Arweave ${arTxId}: ${response.statusText}`,\n };\n }\n\n const profileData = await response.json();\n\n return {\n success: true,\n profile: profileData,\n topicInfo: {\n inboundTopic: profileData.inboundTopicId,\n outboundTopic: profileData.outboundTopicId,\n profileTopicId: profileData.profileTopicId,\n },\n };\n } else {\n return {\n success: false,\n error: `Invalid protocol reference format: ${protocolReference}`,\n };\n }\n } catch (error: any) {\n this.logger.error(`Error fetching profile: ${error.message}`);\n return {\n success: false,\n error: `Error fetching profile: ${error.message}`,\n };\n }\n }\n}\n"],"names":["response","receipt"],"mappings":";;;;;;;;AAwCA,MAAM,mBAAmB,EAAE,OAAO;AAAA,EAChC,UAAU,EAAE,SAAS,IAAI,CAAC;AAAA,EAC1B,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC;AAC1B,CAAC;AAED,MAAM,uBAAuB,EAAE,OAAO;AAAA,EACpC,MAAM,EAAE,WAAW,WAAW;AAAA,EAC9B,cAAc,EAAE,MAAM,EAAE,WAAW,iBAAiB,CAAC,EAAE,IAAI,CAAC;AAAA,EAC5D,OAAO,EAAE,SAAS,IAAI,CAAC;AAAA,EACvB,SAAS,EAAE,OAAO,EAAE,SAAS;AAC/B,CAAC;AAED,MAAM,oBAAoB,EAAE,OAAO;AAAA,EACjC,SAAS,EAAE,SAAS,IAAI,CAAC;AAAA,EACzB,MAAM,EAAE,WAAW,WAAW;AAAA,EAC9B,cAAc,EAAE,S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W,MAAM,MAAM,uBAAuB,MAAM,EAAE;AAExD,YAAA,CAAC,SAAS,IAAI;AACT,iBAAA;AAAA,YACL,SAAS;AAAA,YACT,OAAO,wCAAwC,MAAM,KAAK,SAAS,UAAU;AAAA,UAC/E;AAAA,QAAA;AAGI,cAAA,cAAc,MAAM,SAAS,KAAK;AAEjC,eAAA;AAAA,UACL,SAAS;AAAA,UACT,SAAS;AAAA,UACT,WAAW;AAAA,YACT,cAAc,YAAY;AAAA,YAC1B,eAAe,YAAY;AAAA,YAC3B,gBAAgB,YAAY;AAAA,UAAA;AAAA,QAEhC;AAAA,MAAA,OACK;AACE,eAAA;AAAA,UACL,SAAS;AAAA,UACT,OAAO,sCAAsC,iBAAiB;AAAA,QAChE;AAAA,MAAA;AAAA,aAEK,OAAY;AACnB,WAAK,OAAO,MAAM,2BAA2B,MAAM,OAAO,EAAE;AACrD,aAAA;AAAA,QACL,SAAS;AAAA,QACT,OAAO,2BAA2B,MAAM,OAAO;AAAA,MACjD;AAAA,IAAA;AAAA,EACF;AAEJ;"}
1
+ {"version":3,"file":"standards-sdk.es13.js","sources":["../../src/hcs-11/client.ts"],"sourcesContent":["import {\n AccountId,\n AccountUpdateTransaction,\n Client,\n PrivateKey,\n Status,\n Transaction,\n} from '@hashgraph/sdk';\nimport {\n inscribe,\n inscribeWithSigner,\n InscriptionInput,\n InscriptionOptions,\n} from '../inscribe';\nimport { Logger } from '../utils/logger';\nimport * as mime from 'mime-types';\nimport { z, ZodIssue } from 'zod';\nimport type { DAppSigner } from '@hashgraph/hedera-wallet-connect';\nimport { ProgressReporter } from '../utils/progress-reporter';\nimport { HederaMirrorNode } from '../services';\nimport { TopicInfo } from '../services/types';\nimport {\n ProfileType,\n AIAgentType,\n AIAgentCapability,\n SocialLink,\n PersonalProfile,\n AIAgentProfile,\n HCS11Profile,\n HCS11Auth,\n HCS11ClientConfig,\n TransactionResult,\n InscribeProfileResponse,\n InscribeImageResponse,\n AgentMetadata,\n InscribeImageOptions,\n InscribeProfileOptions,\n capabilityNameToCapabilityMap,\n} from './types';\n\nconst SocialLinkSchema = z.object({\n platform: z.string().min(1),\n handle: z.string().min(1),\n});\n\nconst AIAgentDetailsSchema = z.object({\n type: z.nativeEnum(AIAgentType),\n capabilities: z.array(z.nativeEnum(AIAgentCapability)).min(1),\n model: z.string().min(1),\n creator: z.string().optional(),\n});\n\nconst BaseProfileSchema = z.object({\n version: z.string().min(1),\n type: z.nativeEnum(ProfileType),\n display_name: z.string().min(1),\n alias: z.string().optional(),\n bio: z.string().optional(),\n socials: z.array(SocialLinkSchema).optional(),\n profileImage: z.string().optional(),\n properties: z.record(z.any()).optional(),\n inboundTopicId: z.string().optional(),\n outboundTopicId: z.string().optional(),\n});\n\nconst PersonalProfileSchema = BaseProfileSchema.extend({\n type: z.literal(ProfileType.PERSONAL),\n language: z.string().optional(),\n timezone: z.string().optional(),\n});\n\nconst AIAgentProfileSchema = BaseProfileSchema.extend({\n type: z.literal(ProfileType.AI_AGENT),\n aiAgent: AIAgentDetailsSchema,\n});\n\nconst HCS11ProfileSchema = z.union([\n PersonalProfileSchema,\n AIAgentProfileSchema,\n]);\n\nexport class HCS11Client {\n private client: Client;\n private auth: HCS11Auth;\n private network: string;\n private logger: Logger;\n private mirrorNode: HederaMirrorNode;\n\n constructor(config: HCS11ClientConfig) {\n this.client =\n config.network === 'mainnet' ? Client.forMainnet() : Client.forTestnet();\n this.auth = config.auth;\n this.network = config.network;\n \n this.logger = Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS-11',\n silent: config.silent,\n });\n \n this.mirrorNode = new HederaMirrorNode(\n this.network as 'mainnet' | 'testnet',\n this.logger,\n );\n\n if (this.auth.privateKey) {\n const privateKey = PrivateKey.fromString(this.auth.privateKey);\n this.client.setOperator(this.auth.operatorId, privateKey);\n }\n }\n\n public getClient(): Client {\n return this.client;\n }\n\n public getOperatorId(): string {\n return this.auth.operatorId;\n }\n\n public createPersonalProfile(\n displayName: string,\n options?: {\n alias?: string;\n bio?: string;\n socials?: SocialLink[];\n profileImage?: string;\n language?: string;\n timezone?: string;\n properties?: Record<string, any>;\n inboundTopicId?: string;\n outboundTopicId?: string;\n },\n ): PersonalProfile {\n return {\n version: '1.0',\n type: ProfileType.PERSONAL,\n display_name: displayName,\n alias: options?.alias,\n bio: options?.bio,\n socials: options?.socials,\n profileImage: options?.profileImage,\n properties: options?.properties,\n inboundTopicId: options?.inboundTopicId,\n outboundTopicId: options?.outboundTopicId,\n };\n }\n\n public createAIAgentProfile(\n displayName: string,\n agentType: AIAgentType,\n capabilities: AIAgentCapability[],\n model: string,\n options?: {\n alias?: string;\n bio?: string;\n socials?: SocialLink[];\n profileImage?: string;\n properties?: Record<string, any>;\n inboundTopicId?: string;\n outboundTopicId?: string;\n creator?: string;\n },\n ): AIAgentProfile {\n const validation = this.validateProfile({\n version: '1.0',\n type: ProfileType.AI_AGENT,\n display_name: displayName,\n alias: options?.alias,\n bio: options?.bio,\n socials: options?.socials,\n profileImage: options?.profileImage,\n properties: options?.properties,\n inboundTopicId: options?.inboundTopicId,\n outboundTopicId: options?.outboundTopicId,\n aiAgent: {\n type: agentType,\n capabilities,\n model,\n creator: options?.creator,\n },\n });\n\n if (!validation.valid) {\n throw new Error(\n `Invalid AI Agent Profile: ${validation.errors.join(', ')}`,\n );\n }\n\n return {\n version: '1.0',\n type: ProfileType.AI_AGENT,\n display_name: displayName,\n alias: options?.alias,\n bio: options?.bio,\n socials: options?.socials,\n profileImage: options?.profileImage,\n properties: options?.properties,\n inboundTopicId: options?.inboundTopicId,\n outboundTopicId: options?.outboundTopicId,\n aiAgent: {\n type: agentType,\n capabilities,\n model,\n creator: options?.creator,\n },\n };\n }\n\n public validateProfile(profile: unknown): {\n valid: boolean;\n errors: string[];\n } {\n const result = HCS11ProfileSchema.safeParse(profile);\n\n if (result.success) {\n return { valid: true, errors: [] };\n }\n\n const formattedErrors = result.error.errors.map((err: ZodIssue) => {\n const path = err.path.join('.');\n let message = err.message;\n\n if (err.code === 'invalid_type') {\n message = `Expected ${err.expected}, got ${err.received}`;\n } else if (err.code === 'invalid_enum_value') {\n const validOptions = (err as any).options?.join(', ');\n message = `Invalid value. Valid options are: ${validOptions}`;\n } else if (err.code === 'too_small' && err.type === 'string') {\n message = 'Cannot be empty';\n }\n\n return `${path}: ${message}`;\n });\n\n return { valid: false, errors: formattedErrors };\n }\n\n public profileToJSONString(profile: HCS11Profile): string {\n return JSON.stringify(profile);\n }\n\n public parseProfileFromString(profileStr: string): HCS11Profile | null {\n try {\n const parsedProfile = JSON.parse(profileStr);\n const validation = this.validateProfile(parsedProfile);\n if (!validation.valid) {\n this.logger.error('Invalid profile format:', validation.errors);\n return null;\n }\n return parsedProfile as HCS11Profile;\n } catch (error) {\n this.logger.error('Error parsing profile:');\n return null;\n }\n }\n\n public setProfileForAccountMemo(\n topicId: string,\n topicStandard: 1 | 2 | 7 = 1,\n ): string {\n return `hcs-11:hcs://${topicStandard}/${topicId}`;\n }\n\n private async executeTransaction<T>(\n transaction: Transaction,\n ): Promise<TransactionResult<T>> {\n try {\n if (this.auth.privateKey) {\n const signedTx = await transaction.signWithOperator(this.client);\n const response = await signedTx.execute(this.client);\n const receipt = await response.getReceipt(this.client);\n\n if (receipt.status.toString() !== Status.Success.toString()) {\n return {\n success: false,\n error: `Transaction failed: ${receipt.status.toString()}`,\n };\n }\n\n return {\n success: true,\n result: receipt as T,\n };\n }\n\n if (!this.auth.signer) {\n throw new Error('No valid authentication method provided');\n }\n\n const signer = this.auth.signer;\n const frozenTransaction = await transaction.freezeWithSigner(signer);\n const response = await frozenTransaction.executeWithSigner(signer);\n const receipt = await response.getReceiptWithSigner(signer);\n\n if (receipt.status.toString() !== Status.Success.toString()) {\n return {\n success: false,\n error: `Transaction failed: ${receipt.status.toString()}: ${Status.Success.toString()}`,\n };\n }\n\n return {\n success: true,\n result: receipt as T,\n };\n } catch (error) {\n return {\n success: false,\n error:\n error instanceof Error\n ? error.message\n : 'Unknown error during transaction execution',\n };\n }\n }\n\n public async inscribeImage(\n buffer: Buffer,\n fileName: string,\n options?: InscribeImageOptions,\n ): Promise<InscribeImageResponse> {\n try {\n const progressCallback = options?.progressCallback;\n const progressReporter = new ProgressReporter({\n module: 'HCS11-Image',\n logger: this.logger,\n callback: progressCallback as any,\n });\n\n progressReporter.preparing('Preparing to inscribe image', 0);\n\n const mimeType = mime.lookup(fileName) || 'application/octet-stream';\n\n const waitForConfirmation = options?.waitForConfirmation ?? true;\n\n let inscriptionResponse;\n if (this.auth.signer) {\n if ('accountId' in this.auth.signer) {\n progressReporter.preparing('Using signer for inscription', 10);\n\n inscriptionResponse = await inscribeWithSigner(\n {\n type: 'buffer',\n buffer,\n fileName,\n mimeType,\n },\n this.auth.signer as DAppSigner,\n {\n network: this.network as 'mainnet' | 'testnet',\n waitForConfirmation,\n waitMaxAttempts: 150,\n waitIntervalMs: 4000,\n logging: {\n level: 'debug',\n },\n progressCallback: (data: any) => {\n const adjustedPercent = 10 + (data.progressPercent || 0) * 0.8;\n progressReporter.report({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: data.details,\n });\n },\n },\n );\n } else {\n progressReporter.failed(\n 'Signer must be a DAppSigner for inscription',\n );\n throw new Error('Signer must be a DAppSigner for inscription');\n }\n } else {\n if (!this.auth.privateKey) {\n progressReporter.failed('Private key is required for inscription');\n this.logger.error('Private key is required for inscription');\n throw new Error('Private key is required for inscription');\n }\n\n progressReporter.preparing('Using private key for inscription', 10);\n\n inscriptionResponse = await inscribe(\n {\n type: 'buffer',\n buffer,\n fileName,\n mimeType,\n },\n {\n accountId: this.auth.operatorId,\n privateKey: this.auth.privateKey,\n network: this.network as 'mainnet' | 'testnet',\n },\n {\n waitForConfirmation,\n waitMaxAttempts: 150,\n waitIntervalMs: 2000,\n logging: {\n level: 'debug',\n },\n progressCallback: (data: any) => {\n const adjustedPercent = 10 + (data.progressPercent || 0) * 0.8;\n progressReporter.report({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: data.details,\n });\n },\n },\n );\n }\n\n if (inscriptionResponse.confirmed) {\n progressReporter.completed('Image inscription completed', {\n topic_id: inscriptionResponse.inscription.topic_id,\n });\n return {\n imageTopicId: inscriptionResponse.inscription.topic_id || '',\n transactionId: inscriptionResponse.result.jobId,\n success: true,\n };\n } else {\n progressReporter.verifying('Waiting for inscription confirmation', 50, {\n jobId: inscriptionResponse.result.jobId,\n });\n return {\n imageTopicId: '',\n transactionId: inscriptionResponse.result.jobId,\n success: false,\n error: 'Inscription not confirmed',\n };\n }\n } catch (error: any) {\n this.logger.error('Error inscribing image:', error);\n return {\n imageTopicId: '',\n transactionId: '',\n success: false,\n error: error.message || 'Error inscribing image',\n };\n }\n }\n\n public async inscribeProfile(\n profile: HCS11Profile,\n options?: InscribeProfileOptions,\n ): Promise<InscribeProfileResponse> {\n this.logger.info('Inscribing HCS-11 profile');\n\n const progressCallback = options?.progressCallback;\n const progressReporter = new ProgressReporter({\n module: 'HCS11-Profile',\n logger: this.logger,\n callback: progressCallback as any,\n });\n\n progressReporter.preparing('Validating profile data', 5);\n\n const validation = this.validateProfile(profile);\n if (!validation.valid) {\n progressReporter.failed(\n `Invalid profile: ${validation.errors.join(', ')}`,\n );\n return {\n profileTopicId: '',\n transactionId: '',\n success: false,\n error: `Invalid profile: ${validation.errors.join(', ')}`,\n };\n }\n\n progressReporter.preparing('Formatting profile for inscription', 15);\n\n const profileJson = this.profileToJSONString(profile);\n const fileName = `profile-${profile.display_name\n .toLowerCase()\n .replace(/\\s+/g, '-')}.json`;\n\n try {\n const contentBuffer = Buffer.from(profileJson, 'utf-8');\n const contentType = 'application/json';\n\n progressReporter.preparing('Preparing profile for inscription', 20);\n\n const input: InscriptionInput = {\n type: 'buffer',\n buffer: contentBuffer,\n fileName,\n mimeType: contentType,\n };\n\n const inscriptionOptions: InscriptionOptions = {\n waitForConfirmation: true,\n mode: 'file',\n network: this.network as 'mainnet' | 'testnet',\n waitMaxAttempts: 100,\n waitIntervalMs: 2000,\n progressCallback: (data: any) => {\n const adjustedPercent =\n 20 + Number(data?.progressPercent || 0) * 0.75;\n progressReporter?.report({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: data.details,\n });\n },\n };\n\n progressReporter.submitting('Submitting profile to Hedera network', 30);\n\n const inscriptionResponse = this.auth.privateKey\n ? await inscribe(\n input,\n {\n accountId: this.auth.operatorId,\n privateKey: this.auth.privateKey,\n network: this.network as 'mainnet' | 'testnet',\n },\n inscriptionOptions,\n )\n : await inscribeWithSigner(\n input,\n this.auth.signer as DAppSigner,\n inscriptionOptions,\n );\n\n if (\n !inscriptionResponse.confirmed ||\n !inscriptionResponse.inscription.topic_id\n ) {\n progressReporter.failed('Failed to inscribe profile content');\n return {\n profileTopicId: '',\n transactionId: '',\n success: false,\n error: 'Failed to inscribe profile content',\n };\n }\n\n const topicId = inscriptionResponse.inscription.topic_id;\n\n progressReporter.completed('Profile inscription completed', {\n topicId,\n transactionId: inscriptionResponse.result.transactionId,\n });\n\n return {\n profileTopicId: topicId,\n transactionId: inscriptionResponse.result.transactionId,\n success: true,\n };\n } catch (error: any) {\n progressReporter.failed(\n `Error inscribing profile: ${error.message || 'Unknown error'}`,\n );\n return {\n profileTopicId: '',\n transactionId: '',\n success: false,\n error: error.message || 'Unknown error during inscription',\n };\n }\n }\n\n public async updateAccountMemoWithProfile(\n accountId: string | AccountId,\n profileTopicId: string,\n ): Promise<TransactionResult> {\n try {\n this.logger.info(\n `Updating account memo for ${accountId} with profile ${profileTopicId}`,\n );\n const memo = this.setProfileForAccountMemo(profileTopicId);\n\n const transaction = new AccountUpdateTransaction()\n .setAccountMemo(memo)\n .setAccountId(accountId);\n\n return this.executeTransaction(transaction);\n } catch (error) {\n this.logger.error(\n `Error updating account memo: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n );\n return {\n success: false,\n error:\n error instanceof Error\n ? error.message\n : 'Unknown error updating account memo',\n };\n }\n }\n\n /**\n * Creates and inscribes a profile.\n *\n * @param profile - The profile to create and inscribe.\n * @param updateAccountMemo - Whether to update the account memo with the profile.\n * @param options - Optional configuration options.\n * @returns A promise that resolves to the inscription result.\n */\n public async createAndInscribeProfile(\n profile: HCS11Profile,\n updateAccountMemo = true,\n options?: InscribeProfileOptions,\n ): Promise<InscribeProfileResponse> {\n const progressCallback = options?.progressCallback;\n const progressReporter = new ProgressReporter({\n module: 'HCS11-ProfileCreation',\n logger: this.logger,\n callback: progressCallback as any,\n });\n\n progressReporter.preparing('Starting profile creation process', 0);\n\n const inscriptionProgress = progressReporter.createSubProgress({\n minPercent: 0,\n maxPercent: 80,\n logPrefix: 'Inscription',\n });\n\n const inscriptionResult = await this.inscribeProfile(profile, {\n ...options,\n progressCallback: (data: any) => {\n inscriptionProgress.report({\n stage: data.stage,\n message: data.message,\n progressPercent: data.progressPercent,\n details: data.details,\n });\n },\n });\n\n if (!inscriptionResult?.success) {\n progressReporter.failed('Profile inscription failed', {\n error: inscriptionResult?.error,\n });\n return inscriptionResult;\n }\n\n progressReporter.confirming('Profile inscribed, updating account memo', 85);\n\n if (updateAccountMemo) {\n const memoResult = await this.updateAccountMemoWithProfile(\n this.auth.operatorId,\n inscriptionResult.profileTopicId,\n );\n\n if (!memoResult.success) {\n progressReporter.failed('Failed to update account memo', {\n error: memoResult?.error,\n });\n return {\n ...inscriptionResult,\n success: false,\n error: memoResult?.error,\n };\n }\n }\n\n progressReporter.completed('Profile creation completed successfully', {\n profileTopicId: inscriptionResult.profileTopicId,\n transactionId: inscriptionResult.transactionId,\n });\n\n return inscriptionResult;\n }\n\n /**\n * Gets the capabilities from the capability names.\n *\n * @param capabilityNames - The capability names to get the capabilities for.\n * @returns The capabilities.\n */\n public async getCapabilitiesFromTags(\n capabilityNames: string[],\n ): Promise<number[]> {\n const capabilities: number[] = [];\n\n if (capabilityNames.length === 0) {\n return [AIAgentCapability.TEXT_GENERATION];\n }\n\n for (const capabilityName of capabilityNames) {\n const capability =\n capabilityNameToCapabilityMap[capabilityName.toLowerCase()];\n if (capability !== undefined && !capabilities.includes(capability)) {\n capabilities.push(capability);\n }\n }\n\n if (capabilities.length === 0) {\n capabilities.push(AIAgentCapability.TEXT_GENERATION);\n }\n\n return capabilities;\n }\n\n /**\n * Gets the agent type from the metadata.\n *\n * @param metadata - The metadata of the agent.\n * @returns The agent type.\n */\n public getAgentTypeFromMetadata(metadata: AgentMetadata): AIAgentType {\n if (metadata.type === 'autonomous') {\n return AIAgentType.AUTONOMOUS;\n } else {\n return AIAgentType.MANUAL;\n }\n }\n\n /**\n * Fetches a profile from the account memo.\n *\n * @param accountId - The account ID of the agent to fetch the profile for.\n * @param network - The network to use for the fetch.\n * @returns A promise that resolves to the profile.\n */\n public async fetchProfileByAccountId(\n accountId: string | AccountId,\n network?: string,\n ): Promise<{\n success: boolean;\n profile?: HCS11Profile;\n error?: string;\n topicInfo?: TopicInfo;\n }> {\n try {\n this.logger.info(\n `Fetching profile for account ${accountId.toString()} on ${\n this.network\n }`,\n );\n\n const memo = await this.mirrorNode.getAccountMemo(accountId.toString());\n\n this.logger.info(`Got account memo: ${memo}`);\n\n if (!memo?.startsWith('hcs-11:')) {\n return {\n success: false,\n error: `Account ${accountId.toString()} does not have a valid HCS-11 memo`,\n };\n }\n\n this.logger.info(`Found HCS-11 memo: ${memo}`);\n\n const protocolReference = memo.substring(7);\n\n if (protocolReference?.startsWith('hcs://')) {\n const hcsFormat = protocolReference.match(/hcs:\\/\\/(\\d+)\\/(.+)/);\n\n if (!hcsFormat) {\n return {\n success: false,\n error: `Invalid HCS protocol reference format: ${protocolReference}`,\n };\n }\n\n const [_, protocolId, profileTopicId] = hcsFormat;\n const networkParam = network || this.network || 'mainnet';\n\n this.logger.info(\n `Retrieving profile from Kiloscribe CDN: ${profileTopicId}`,\n );\n const cdnUrl = `https://kiloscribe.com/api/inscription-cdn/${profileTopicId}?network=${networkParam}`;\n\n try {\n const response = await fetch(cdnUrl);\n\n if (!response.ok) {\n return {\n success: false,\n error: `Failed to fetch profile from Kiloscribe CDN: ${response.statusText}`,\n };\n }\n\n const profileData = await response.json();\n\n if (!profileData) {\n return {\n success: false,\n error: `No profile data found for topic ${profileTopicId}`,\n };\n }\n\n return {\n success: true,\n profile: profileData,\n topicInfo: {\n inboundTopic: profileData.inboundTopicId,\n outboundTopic: profileData.outboundTopicId,\n profileTopicId,\n },\n };\n } catch (cdnError: any) {\n this.logger.error(\n `Error retrieving from Kiloscribe CDN: ${cdnError.message}`,\n );\n return {\n success: false,\n error: `Error retrieving from Kiloscribe CDN: ${cdnError.message}`,\n };\n }\n } else if (protocolReference.startsWith('ipfs://')) {\n this.logger.warn('IPFS protocol references are not fully supported');\n const response = await fetch(\n `https://ipfs.io/ipfs/${protocolReference.replace('ipfs://', '')}`,\n );\n const profileData = await response.json();\n return {\n success: true,\n profile: profileData,\n topicInfo: {\n inboundTopic: profileData.inboundTopicId,\n outboundTopic: profileData.outboundTopicId,\n profileTopicId: profileData.profileTopicId,\n },\n };\n } else if (protocolReference.startsWith('ar://')) {\n const arTxId = protocolReference.replace('ar://', '');\n const response = await fetch(`https://arweave.net/${arTxId}`);\n\n if (!response.ok) {\n return {\n success: false,\n error: `Failed to fetch profile from Arweave ${arTxId}: ${response.statusText}`,\n };\n }\n\n const profileData = await response.json();\n\n return {\n success: true,\n profile: profileData,\n topicInfo: {\n inboundTopic: profileData.inboundTopicId,\n outboundTopic: profileData.outboundTopicId,\n profileTopicId: profileData.profileTopicId,\n },\n };\n } else {\n return {\n success: false,\n error: `Invalid protocol reference format: ${protocolReference}`,\n };\n }\n } catch (error: any) {\n this.logger.error(`Error fetching profile: ${error.message}`);\n return {\n success: false,\n error: `Error fetching profile: ${error.message}`,\n };\n }\n }\n}\n"],"names":["response","receipt"],"mappings":";;;;;;;;AAwCA,MAAM,mBAAmB,EAAE,OAAO;AAAA,EAChC,UAAU,EAAE,SAAS,IAAI,CAAC;AAAA,EAC1B,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC;AAC1B,CAAC;AAED,MAAM,uB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E,cAAM,WAAW,MAAM;AAAA,UACrB,wBAAwB,kBAAkB,QAAQ,WAAW,EAAE,CAAC;AAAA,QAClE;AACM,cAAA,cAAc,MAAM,SAAS,KAAK;AACjC,eAAA;AAAA,UACL,SAAS;AAAA,UACT,SAAS;AAAA,UACT,WAAW;AAAA,YACT,cAAc,YAAY;AAAA,YAC1B,eAAe,YAAY;AAAA,YAC3B,gBAAgB,YAAY;AAAA,UAAA;AAAA,QAEhC;AAAA,MACS,WAAA,kBAAkB,WAAW,OAAO,GAAG;AAChD,cAAM,SAAS,kBAAkB,QAAQ,SAAS,EAAE;AACpD,cAAM,WAAW,MAAM,MAAM,uBAAuB,MAAM,EAAE;AAExD,YAAA,CAAC,SAAS,IAAI;AACT,iBAAA;AAAA,YACL,SAAS;AAAA,YACT,OAAO,wCAAwC,MAAM,KAAK,SAAS,UAAU;AAAA,UAC/E;AAAA,QAAA;AAGI,cAAA,cAAc,MAAM,SAAS,KAAK;AAEjC,eAAA;AAAA,UACL,SAAS;AAAA,UACT,SAAS;AAAA,UACT,WAAW;AAAA,YACT,cAAc,YAAY;AAAA,YAC1B,eAAe,YAAY;AAAA,YAC3B,gBAAgB,YAAY;AAAA,UAAA;AAAA,QAEhC;AAAA,MAAA,OACK;AACE,eAAA;AAAA,UACL,SAAS;AAAA,UACT,OAAO,sCAAsC,iBAAiB;AAAA,QAChE;AAAA,MAAA;AAAA,aAEK,OAAY;AACnB,WAAK,OAAO,MAAM,2BAA2B,MAAM,OAAO,EAAE;AACrD,aAAA;AAAA,QACL,SAAS;AAAA,QACT,OAAO,2BAA2B,MAAM,OAAO;AAAA,MACjD;AAAA,IAAA;AAAA,EACF;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"standards-sdk.es14.js","sources":["../../src/hcs-11/types.ts"],"sourcesContent":["import type { Signer } from '@hashgraph/sdk';\nimport type { DAppSigner } from '@hashgraph/hedera-wallet-connect';\nimport { RegistrationProgressCallback } from '../hcs-10/types';\nimport { LogLevel } from '../utils/logger';\nimport { FeeConfigBuilderInterface } from '../fees';\nimport { NetworkType } from '../utils/types';\n\nexport enum ProfileType {\n PERSONAL = 0,\n AI_AGENT = 1,\n}\n\nexport enum AIAgentType {\n MANUAL = 0,\n AUTONOMOUS = 1,\n}\n\nexport enum EndpointType {\n REST = 0,\n WEBSOCKET = 1,\n GRPC = 2,\n}\n\nexport enum AIAgentCapability {\n TEXT_GENERATION = 0,\n IMAGE_GENERATION = 1,\n AUDIO_GENERATION = 2,\n VIDEO_GENERATION = 3,\n CODE_GENERATION = 4,\n LANGUAGE_TRANSLATION = 5,\n SUMMARIZATION_EXTRACTION = 6,\n KNOWLEDGE_RETRIEVAL = 7,\n DATA_INTEGRATION = 8,\n MARKET_INTELLIGENCE = 9,\n TRANSACTION_ANALYTICS = 10,\n SMART_CONTRACT_AUDIT = 11,\n GOVERNANCE_FACILITATION = 12,\n SECURITY_MONITORING = 13,\n COMPLIANCE_ANALYSIS = 14,\n FRAUD_DETECTION = 15,\n MULTI_AGENT_COORDINATION = 16,\n API_INTEGRATION = 17,\n WORKFLOW_AUTOMATION = 18,\n}\n\nexport type SocialPlatform =\n | 'twitter'\n | 'github'\n | 'discord'\n | 'telegram'\n | 'linkedin'\n | 'youtube'\n | 'website'\n | 'x';\n\nexport interface SocialLink {\n platform: SocialPlatform;\n handle: string;\n}\n\nexport interface AIAgentDetails {\n type: AIAgentType;\n capabilities: AIAgentCapability[];\n model: string;\n creator?: string;\n}\n\nexport interface BaseProfile {\n version: string;\n type: ProfileType;\n display_name: string;\n alias?: string;\n bio?: string;\n socials?: SocialLink[];\n profileImage?: string;\n properties?: Record<string, any>;\n inboundTopicId?: string;\n outboundTopicId?: string;\n}\n\nexport interface PersonalProfile extends BaseProfile {\n type: ProfileType.PERSONAL;\n}\n\nexport interface AIAgentProfile extends BaseProfile {\n type: ProfileType.AI_AGENT;\n aiAgent: AIAgentDetails;\n}\n\nexport type HCS11Profile = PersonalProfile | AIAgentProfile;\n\nexport enum InboundTopicType {\n PUBLIC = 'PUBLIC',\n CONTROLLED = 'CONTROLLED',\n FEE_BASED = 'FEE_BASED',\n}\n\nexport interface HCS11Auth {\n operatorId: string;\n privateKey?: string;\n signer?: DAppSigner | Signer;\n}\n\nexport interface HCS11ClientConfig {\n network: NetworkType;\n auth: HCS11Auth;\n logLevel?: LogLevel;\n}\n\nexport interface TransactionResult<T = unknown> {\n success: boolean;\n error?: string;\n result?: T;\n}\n\nexport interface InscribeProfileResponse {\n profileTopicId: string;\n transactionId: string;\n success: boolean;\n error?: string;\n inboundTopicId?: string;\n outboundTopicId?: string;\n}\n\nexport interface InscribeImageResponse {\n imageTopicId: string;\n transactionId: string;\n success: boolean;\n error?: string;\n}\n\nexport interface AgentMetadata {\n type: 'autonomous' | 'manual';\n model?: string;\n socials?: { [key in SocialPlatform]?: string };\n creator?: string;\n properties?: Record<string, any>;\n}\n\nexport interface ProgressOptions {\n progressCallback?: RegistrationProgressCallback;\n}\n\nexport interface InscribeImageOptions extends ProgressOptions {\n waitForConfirmation?: boolean;\n}\n\nexport interface InscribeProfileOptions extends ProgressOptions {\n waitForConfirmation?: boolean;\n}\n\nexport interface AgentConfiguration {\n name: string;\n alias: string;\n bio: string;\n capabilities: number[];\n metadata: AgentMetadata;\n pfpBuffer?: Buffer;\n pfpFileName?: string;\n network: NetworkType;\n inboundTopicType: InboundTopicType;\n feeConfig?: FeeConfigBuilderInterface;\n connectionFeeConfig?: FeeConfigBuilderInterface;\n existingAccount?: {\n accountId: string;\n privateKey: string;\n };\n existingPfpTopicId?: string;\n}\n\nexport interface PersonConfig extends BaseProfile {\n type: ProfileType.PERSONAL;\n pfpBuffer?: Buffer;\n pfpFileName?: string;\n}\n\nexport const SUPPORTED_SOCIAL_PLATFORMS: SocialPlatform[] = [\n 'twitter',\n 'github',\n 'discord',\n 'telegram',\n 'linkedin',\n 'youtube',\n 'website',\n 'x',\n];\n\nexport const capabilityNameToCapabilityMap: Record<string, AIAgentCapability> =\n {\n text_generation: AIAgentCapability.TEXT_GENERATION,\n image_generation: AIAgentCapability.IMAGE_GENERATION,\n audio_generation: AIAgentCapability.AUDIO_GENERATION,\n video_generation: AIAgentCapability.VIDEO_GENERATION,\n code_generation: AIAgentCapability.CODE_GENERATION,\n language_translation: AIAgentCapability.LANGUAGE_TRANSLATION,\n summarization: AIAgentCapability.SUMMARIZATION_EXTRACTION,\n extraction: AIAgentCapability.SUMMARIZATION_EXTRACTION,\n knowledge_retrieval: AIAgentCapability.KNOWLEDGE_RETRIEVAL,\n data_integration: AIAgentCapability.DATA_INTEGRATION,\n data_visualization: AIAgentCapability.DATA_INTEGRATION,\n market_intelligence: AIAgentCapability.MARKET_INTELLIGENCE,\n transaction_analytics: AIAgentCapability.TRANSACTION_ANALYTICS,\n smart_contract_audit: AIAgentCapability.SMART_CONTRACT_AUDIT,\n governance: AIAgentCapability.GOVERNANCE_FACILITATION,\n security_monitoring: AIAgentCapability.SECURITY_MONITORING,\n compliance_analysis: AIAgentCapability.COMPLIANCE_ANALYSIS,\n fraud_detection: AIAgentCapability.FRAUD_DETECTION,\n multi_agent: AIAgentCapability.MULTI_AGENT_COORDINATION,\n api_integration: AIAgentCapability.API_INTEGRATION,\n workflow_automation: AIAgentCapability.WORKFLOW_AUTOMATION,\n };\n\nexport interface AgentMetadata {\n type: 'autonomous' | 'manual';\n model?: string;\n socials?: {\n twitter?: string;\n discord?: string;\n github?: string;\n website?: string;\n x?: string;\n linkedin?: string;\n youtube?: string;\n telegram?: string;\n };\n creator?: string;\n properties?: Record<string, any>;\n}\n"],"names":["ProfileType","AIAgentType","EndpointType","AIAgentCapability","InboundTopicType"],"mappings":"AAOY,IAAA,gCAAAA,iBAAL;AACLA,eAAAA,aAAA,cAAW,CAAX,IAAA;AACAA,eAAAA,aAAA,cAAW,CAAX,IAAA;AAFUA,SAAAA;AAAA,GAAA,eAAA,CAAA,CAAA;AAKA,IAAA,gCAAAC,iBAAL;AACLA,eAAAA,aAAA,YAAS,CAAT,IAAA;AACAA,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YAAa,IAAA;AACbA,oBAAA,WAAY,IAAA;AAHFA,SAAAA;AAAA,GAAA,oBAAA,CAAA,CAAA;AAqFL,MAAM,6BAA+C;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,gCACX;AAAA,EACE,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,qBAAqB;AAAA,EACrB,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,uBAAuB;AAAA,EACvB,sBAAsB;AAAA,EACtB,YAAY;AAAA,EACZ,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,qBAAqB;AAAA;AACvB;"}
1
+ {"version":3,"file":"standards-sdk.es14.js","sources":["../../src/hcs-11/types.ts"],"sourcesContent":["import type { Signer } from '@hashgraph/sdk';\nimport type { DAppSigner } from '@hashgraph/hedera-wallet-connect';\nimport { RegistrationProgressCallback } from '../hcs-10/types';\nimport { LogLevel } from '../utils/logger';\nimport { FeeConfigBuilderInterface } from '../fees';\nimport { NetworkType } from '../utils/types';\n\nexport enum ProfileType {\n PERSONAL = 0,\n AI_AGENT = 1,\n}\n\nexport enum AIAgentType {\n MANUAL = 0,\n AUTONOMOUS = 1,\n}\n\nexport enum EndpointType {\n REST = 0,\n WEBSOCKET = 1,\n GRPC = 2,\n}\n\nexport enum AIAgentCapability {\n TEXT_GENERATION = 0,\n IMAGE_GENERATION = 1,\n AUDIO_GENERATION = 2,\n VIDEO_GENERATION = 3,\n CODE_GENERATION = 4,\n LANGUAGE_TRANSLATION = 5,\n SUMMARIZATION_EXTRACTION = 6,\n KNOWLEDGE_RETRIEVAL = 7,\n DATA_INTEGRATION = 8,\n MARKET_INTELLIGENCE = 9,\n TRANSACTION_ANALYTICS = 10,\n SMART_CONTRACT_AUDIT = 11,\n GOVERNANCE_FACILITATION = 12,\n SECURITY_MONITORING = 13,\n COMPLIANCE_ANALYSIS = 14,\n FRAUD_DETECTION = 15,\n MULTI_AGENT_COORDINATION = 16,\n API_INTEGRATION = 17,\n WORKFLOW_AUTOMATION = 18,\n}\n\nexport type SocialPlatform =\n | 'twitter'\n | 'github'\n | 'discord'\n | 'telegram'\n | 'linkedin'\n | 'youtube'\n | 'website'\n | 'x';\n\nexport interface SocialLink {\n platform: SocialPlatform;\n handle: string;\n}\n\nexport interface AIAgentDetails {\n type: AIAgentType;\n capabilities: AIAgentCapability[];\n model: string;\n creator?: string;\n}\n\nexport interface BaseProfile {\n version: string;\n type: ProfileType;\n display_name: string;\n alias?: string;\n bio?: string;\n socials?: SocialLink[];\n profileImage?: string;\n properties?: Record<string, any>;\n inboundTopicId?: string;\n outboundTopicId?: string;\n}\n\nexport interface PersonalProfile extends BaseProfile {\n type: ProfileType.PERSONAL;\n}\n\nexport interface AIAgentProfile extends BaseProfile {\n type: ProfileType.AI_AGENT;\n aiAgent: AIAgentDetails;\n}\n\nexport type HCS11Profile = PersonalProfile | AIAgentProfile;\n\nexport enum InboundTopicType {\n PUBLIC = 'PUBLIC',\n CONTROLLED = 'CONTROLLED',\n FEE_BASED = 'FEE_BASED',\n}\n\nexport interface HCS11Auth {\n operatorId: string;\n privateKey?: string;\n signer?: DAppSigner | Signer;\n}\n\nexport interface HCS11ClientConfig {\n network: NetworkType;\n auth: HCS11Auth;\n logLevel?: LogLevel;\n silent?: boolean;\n}\n\nexport interface TransactionResult<T = unknown> {\n success: boolean;\n error?: string;\n result?: T;\n}\n\nexport interface InscribeProfileResponse {\n profileTopicId: string;\n transactionId: string;\n success: boolean;\n error?: string;\n inboundTopicId?: string;\n outboundTopicId?: string;\n}\n\nexport interface InscribeImageResponse {\n imageTopicId: string;\n transactionId: string;\n success: boolean;\n error?: string;\n}\n\nexport interface AgentMetadata {\n type: 'autonomous' | 'manual';\n model?: string;\n socials?: { [key in SocialPlatform]?: string };\n creator?: string;\n properties?: Record<string, any>;\n}\n\nexport interface ProgressOptions {\n progressCallback?: RegistrationProgressCallback;\n}\n\nexport interface InscribeImageOptions extends ProgressOptions {\n waitForConfirmation?: boolean;\n}\n\nexport interface InscribeProfileOptions extends ProgressOptions {\n waitForConfirmation?: boolean;\n}\n\nexport interface AgentConfiguration {\n name: string;\n alias: string;\n bio: string;\n capabilities: number[];\n metadata: AgentMetadata;\n pfpBuffer?: Buffer;\n pfpFileName?: string;\n network: NetworkType;\n inboundTopicType: InboundTopicType;\n feeConfig?: FeeConfigBuilderInterface;\n connectionFeeConfig?: FeeConfigBuilderInterface;\n existingAccount?: {\n accountId: string;\n privateKey: string;\n };\n existingPfpTopicId?: string;\n}\n\nexport interface PersonConfig extends BaseProfile {\n type: ProfileType.PERSONAL;\n pfpBuffer?: Buffer;\n pfpFileName?: string;\n}\n\nexport const SUPPORTED_SOCIAL_PLATFORMS: SocialPlatform[] = [\n 'twitter',\n 'github',\n 'discord',\n 'telegram',\n 'linkedin',\n 'youtube',\n 'website',\n 'x',\n];\n\nexport const capabilityNameToCapabilityMap: Record<string, AIAgentCapability> =\n {\n text_generation: AIAgentCapability.TEXT_GENERATION,\n image_generation: AIAgentCapability.IMAGE_GENERATION,\n audio_generation: AIAgentCapability.AUDIO_GENERATION,\n video_generation: AIAgentCapability.VIDEO_GENERATION,\n code_generation: AIAgentCapability.CODE_GENERATION,\n language_translation: AIAgentCapability.LANGUAGE_TRANSLATION,\n summarization: AIAgentCapability.SUMMARIZATION_EXTRACTION,\n extraction: AIAgentCapability.SUMMARIZATION_EXTRACTION,\n knowledge_retrieval: AIAgentCapability.KNOWLEDGE_RETRIEVAL,\n data_integration: AIAgentCapability.DATA_INTEGRATION,\n data_visualization: AIAgentCapability.DATA_INTEGRATION,\n market_intelligence: AIAgentCapability.MARKET_INTELLIGENCE,\n transaction_analytics: AIAgentCapability.TRANSACTION_ANALYTICS,\n smart_contract_audit: AIAgentCapability.SMART_CONTRACT_AUDIT,\n governance: AIAgentCapability.GOVERNANCE_FACILITATION,\n security_monitoring: AIAgentCapability.SECURITY_MONITORING,\n compliance_analysis: AIAgentCapability.COMPLIANCE_ANALYSIS,\n fraud_detection: AIAgentCapability.FRAUD_DETECTION,\n multi_agent: AIAgentCapability.MULTI_AGENT_COORDINATION,\n api_integration: AIAgentCapability.API_INTEGRATION,\n workflow_automation: AIAgentCapability.WORKFLOW_AUTOMATION,\n };\n\nexport interface AgentMetadata {\n type: 'autonomous' | 'manual';\n model?: string;\n socials?: {\n twitter?: string;\n discord?: string;\n github?: string;\n website?: string;\n x?: string;\n linkedin?: string;\n youtube?: string;\n telegram?: string;\n };\n creator?: string;\n properties?: Record<string, any>;\n}\n"],"names":["ProfileType","AIAgentType","EndpointType","AIAgentCapability","InboundTopicType"],"mappings":"AAOY,IAAA,gCAAAA,iBAAL;AACLA,eAAAA,aAAA,cAAW,CAAX,IAAA;AACAA,eAAAA,aAAA,cAAW,CAAX,IAAA;AAFUA,SAAAA;AAAA,GAAA,eAAA,CAAA,CAAA;AAKA,IAAA,gCAAAC,iBAAL;AACLA,eAAAA,aAAA,YAAS,CAAT,IAAA;AACAA,eAAAA,aAAA,gBAAa,CAAb,IAAA;AAFUA,SAAAA;AAAA,GAAA,eAAA,CAAA,CAAA;AAKA,IAAA,iCAAAC,kBAAL;AACLA,gBAAAA,cAAA,UAAO,CAAP,IAAA;AACAA,gBAAAA,cAAA,eAAY,CAAZ,IAAA;AACAA,gBAAAA,cAAA,UAAO,CAAP,IAAA;AAHUA,SAAAA;AAAA,GAAA,gBAAA,CAAA,CAAA;AAMA,IAAA,sCAAAC,uBAAL;AACLA,qBAAAA,mBAAA,qBAAkB,CAAlB,IAAA;AACAA,qBAAAA,mBAAA,sBAAmB,CAAnB,IAAA;AACAA,qBAAAA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