@hashgraphonline/standards-sdk 0.0.124 → 0.0.125
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/hcs-10/sdk.d.ts.map +1 -1
- package/dist/cjs/{index-ByrQ9sMv.cjs → index-6LoriFtz.cjs} +2 -2
- package/dist/cjs/index-6LoriFtz.cjs.map +1 -0
- package/dist/cjs/{index-CHar8dVv-C3O0C2Vj.cjs → index-CHar8dVv-DHlTexOJ.cjs} +2 -2
- package/dist/cjs/{index-CHar8dVv-C3O0C2Vj.cjs.map → index-CHar8dVv-DHlTexOJ.cjs.map} +1 -1
- package/dist/cjs/standards-sdk.cjs +1 -1
- package/dist/es/hcs-10/sdk.d.ts.map +1 -1
- package/dist/es/standards-sdk.es20.js +6 -6
- package/dist/es/standards-sdk.es27.js +501 -2
- package/dist/es/standards-sdk.es27.js.map +1 -1
- package/dist/es/standards-sdk.es28.js +64 -456
- package/dist/es/standards-sdk.es28.js.map +1 -1
- package/dist/es/standards-sdk.es29.js +36 -79
- package/dist/es/standards-sdk.es29.js.map +1 -1
- package/dist/es/standards-sdk.es30.js +222 -32
- package/dist/es/standards-sdk.es30.js.map +1 -1
- package/dist/es/standards-sdk.es31.js +100 -183
- package/dist/es/standards-sdk.es31.js.map +1 -1
- package/dist/es/standards-sdk.es32.js +5 -167
- package/dist/es/standards-sdk.es32.js.map +1 -1
- package/dist/es/standards-sdk.es33.js +2 -11
- package/dist/es/standards-sdk.es33.js.map +1 -1
- package/dist/es/standards-sdk.es7.js +10 -9
- package/dist/es/standards-sdk.es7.js.map +1 -1
- package/dist/es/standards-sdk.es9.js +1 -1
- package/dist/umd/hcs-10/sdk.d.ts.map +1 -1
- package/dist/umd/standards-sdk.umd.js +1 -1
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/package.json +2 -1
- package/dist/cjs/index-ByrQ9sMv.cjs.map +0 -1
|
@@ -75,7 +75,7 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
75
75
|
}
|
|
76
76
|
const PK = this.keyType === "ecdsa" ? PrivateKey.fromStringECDSA(this.operatorPrivateKey) : PrivateKey.fromStringED25519(this.operatorPrivateKey);
|
|
77
77
|
this.logger.debug(
|
|
78
|
-
`Setting operator: ${this.
|
|
78
|
+
`Setting operator: ${this.operatorAccountId} with key type: ${this.keyType}`
|
|
79
79
|
);
|
|
80
80
|
this.client.setOperator(this.operatorAccountId, PK);
|
|
81
81
|
return {
|
|
@@ -883,15 +883,15 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
883
883
|
details: { state, account }
|
|
884
884
|
});
|
|
885
885
|
}
|
|
886
|
-
const keyType =
|
|
887
|
-
const privateKey = keyType === "ed25519" ? PrivateKey.fromStringED25519(account.privateKey) : PrivateKey.fromStringECDSA(account.privateKey);
|
|
886
|
+
const keyType = detectKeyTypeFromString(account.privateKey);
|
|
887
|
+
const privateKey = keyType.detectedType === "ed25519" ? PrivateKey.fromStringED25519(account.privateKey) : PrivateKey.fromStringECDSA(account.privateKey);
|
|
888
888
|
const publicKey = privateKey.publicKey.toString();
|
|
889
889
|
agentClient = new HCS10Client({
|
|
890
890
|
network: config.network,
|
|
891
891
|
operatorId: account.accountId,
|
|
892
892
|
operatorPrivateKey: account.privateKey,
|
|
893
893
|
operatorPublicKey: publicKey,
|
|
894
|
-
keyType: keyType
|
|
894
|
+
keyType: keyType.detectedType,
|
|
895
895
|
logLevel: "info",
|
|
896
896
|
guardedRegistryBaseUrl: baseUrl
|
|
897
897
|
});
|
|
@@ -1658,8 +1658,9 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
1658
1658
|
details: { state, account }
|
|
1659
1659
|
});
|
|
1660
1660
|
}
|
|
1661
|
-
const keyType =
|
|
1662
|
-
|
|
1661
|
+
const keyType = detectKeyTypeFromString(account.privateKey);
|
|
1662
|
+
builder.setExistingAccount(account.accountId, account.privateKey);
|
|
1663
|
+
const privateKey = keyType.detectedType === "ed25519" ? PrivateKey.fromStringED25519(account.privateKey) : PrivateKey.fromStringECDSA(account.privateKey);
|
|
1663
1664
|
const publicKey = privateKey.publicKey.toString();
|
|
1664
1665
|
serverClient = new HCS10Client({
|
|
1665
1666
|
network: config.network,
|
|
@@ -1753,15 +1754,15 @@ class HCS10Client extends HCS10BaseClient {
|
|
|
1753
1754
|
"Cannot resume registration without account information"
|
|
1754
1755
|
);
|
|
1755
1756
|
}
|
|
1756
|
-
const keyType =
|
|
1757
|
-
const privateKey = keyType === "ed25519" ? PrivateKey.fromStringED25519(account.privateKey) : PrivateKey.fromStringECDSA(account.privateKey);
|
|
1757
|
+
const keyType = detectKeyTypeFromString(account.privateKey);
|
|
1758
|
+
const privateKey = keyType.detectedType === "ed25519" ? PrivateKey.fromStringED25519(account.privateKey) : PrivateKey.fromStringECDSA(account.privateKey);
|
|
1758
1759
|
const publicKey = privateKey.publicKey.toString();
|
|
1759
1760
|
serverClient = new HCS10Client({
|
|
1760
1761
|
network: config.network,
|
|
1761
1762
|
operatorId: account.accountId,
|
|
1762
1763
|
operatorPrivateKey: account.privateKey,
|
|
1763
1764
|
operatorPublicKey: publicKey,
|
|
1764
|
-
keyType: keyType
|
|
1765
|
+
keyType: keyType.detectedType,
|
|
1765
1766
|
logLevel: "info",
|
|
1766
1767
|
guardedRegistryBaseUrl: baseUrl
|
|
1767
1768
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es7.js","sources":["../../src/hcs-10/sdk.ts"],"sourcesContent":["import {\n Client,\n AccountCreateTransaction,\n PrivateKey,\n Hbar,\n KeyList,\n TopicCreateTransaction,\n TopicMessageSubmitTransaction,\n TopicId,\n Transaction,\n TransactionResponse,\n TransactionReceipt,\n PublicKey,\n AccountId,\n CustomFixedFee,\n TokenId,\n ScheduleCreateTransaction,\n Timestamp,\n} from '@hashgraph/sdk';\nimport {\n PayloadSizeError,\n AccountCreationError,\n TopicCreationError,\n ConnectionConfirmationError,\n} from './errors';\nimport {\n InscriptionSDK,\n RetrievedInscriptionResult,\n} from '@kiloscribe/inscription-sdk';\nimport { Logger, LogLevel, detectKeyTypeFromString } from '../utils';\nimport { HCS10BaseClient } from './base-client';\nimport * as mime from 'mime-types';\nimport {\n HCSClientConfig,\n CreateAccountResponse,\n CreateAgentResponse,\n CreateMCPServerResponse,\n StoreHCS11ProfileResponse,\n AgentRegistrationResult,\n HandleConnectionRequestResponse,\n WaitForConnectionConfirmationResponse,\n GetAccountAndSignerResponse,\n AgentCreationState,\n RegistrationProgressCallback,\n InscribePfpResponse,\n MCPServerCreationState,\n} from './types';\nimport { MirrorNodeConfig } from '../services';\nimport {\n HCS11Client,\n AgentMetadata as HCS11AgentMetadata,\n SocialLink,\n SocialPlatform,\n InboundTopicType,\n AgentMetadata,\n MCPServerBuilder,\n} from '../hcs-11';\nimport { FeeConfigBuilderInterface, TopicFeeConfig } from '../fees';\nimport { accountIdsToExemptKeys } from '../utils/topic-fee-utils';\nimport { Hcs10MemoType } from './base-client';\nimport { AgentBuilder } from '../hcs-11/agent-builder';\nimport { inscribe } from '../inscribe/inscriber';\nimport { TokenFeeConfig } from '../fees/types';\nimport { addSeconds } from 'date-fns';\n\nexport class HCS10Client extends HCS10BaseClient {\n private client: Client;\n private operatorPrivateKey: string;\n private operatorAccountId: string;\n declare protected network: string;\n declare protected logger: Logger;\n protected guardedRegistryBaseUrl: string;\n private hcs11Client: HCS11Client;\n private keyType: 'ed25519' | 'ecdsa';\n\n constructor(config: HCSClientConfig) {\n super({\n network: config.network,\n logLevel: config.logLevel,\n prettyPrint: config.prettyPrint,\n feeAmount: config.feeAmount,\n mirrorNode: config.mirrorNode,\n silent: config.silent,\n keyType: config.keyType,\n });\n this.client =\n config.network === 'mainnet' ? Client.forMainnet() : Client.forTestnet();\n this.operatorPrivateKey = config.operatorPrivateKey;\n\n this.operatorAccountId = config.operatorId;\n if (config.keyType) {\n this.keyType = config.keyType;\n const PK =\n this.keyType === 'ecdsa'\n ? PrivateKey.fromStringECDSA(this.operatorPrivateKey)\n : PrivateKey.fromStringED25519(this.operatorPrivateKey);\n this.client.setOperator(config.operatorId, PK);\n } else {\n try {\n const keyDetection = detectKeyTypeFromString(this.operatorPrivateKey);\n this.client.setOperator(config.operatorId, keyDetection.privateKey);\n this.keyType = keyDetection.detectedType;\n } catch (error) {\n this.logger.warn(\n 'Failed to detect key type from private key format, will query mirror node',\n );\n this.keyType = 'ed25519';\n }\n\n this.initializeOperator();\n }\n\n this.network = config.network;\n this.logger = Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS-SDK',\n silent: config.silent,\n });\n this.guardedRegistryBaseUrl =\n config.guardedRegistryBaseUrl || 'https://moonscape.tech';\n\n this.hcs11Client = new HCS11Client({\n network: config.network,\n auth: {\n operatorId: config.operatorId,\n privateKey: config.operatorPrivateKey,\n },\n logLevel: config.logLevel,\n silent: config.silent,\n keyType: config.keyType,\n });\n }\n\n public async initializeOperator(): Promise<{\n accountId: string;\n privateKey: string;\n keyType: 'ed25519' | 'ecdsa';\n client: Client;\n }> {\n const account = await this.requestAccount(this.operatorAccountId);\n const keyType = account?.key?._type;\n\n if (keyType.includes('ECDSA')) {\n this.keyType = 'ecdsa';\n } else if (keyType.includes('ED25519')) {\n this.keyType = 'ed25519';\n } else {\n this.keyType = 'ed25519';\n }\n\n const PK =\n this.keyType === 'ecdsa'\n ? PrivateKey.fromStringECDSA(this.operatorPrivateKey)\n : PrivateKey.fromStringED25519(this.operatorPrivateKey);\n\n this.logger.debug(\n `Setting operator: ${this.operatorId} with key type: ${this.keyType}`,\n );\n\n this.client.setOperator(this.operatorAccountId, PK);\n\n return {\n accountId: this.operatorAccountId,\n privateKey: this.operatorPrivateKey,\n keyType: this.keyType,\n client: this.client,\n };\n }\n\n public getClient() {\n return this.client;\n }\n\n /**\n * Creates a new Hedera account\n * @param initialBalance Optional initial balance in HBAR (default: 50)\n * @returns Object with account ID and private key\n */\n async createAccount(\n initialBalance: number = 50,\n ): Promise<CreateAccountResponse> {\n if (!this.keyType) {\n await this.initializeOperator();\n }\n\n this.logger.info(\n `Creating new account with ${initialBalance} HBAR initial balance`,\n );\n const newKey = PrivateKey.generateED25519();\n\n const accountTransaction = new AccountCreateTransaction()\n .setKeyWithoutAlias(newKey.publicKey)\n .setInitialBalance(new Hbar(initialBalance));\n\n this.logger.debug('Executing account creation transaction');\n const accountResponse = await accountTransaction.execute(this.client);\n const accountReceipt = await accountResponse.getReceipt(this.client);\n const newAccountId = accountReceipt.accountId;\n\n if (!newAccountId) {\n this.logger.error('Account creation failed: accountId is null');\n throw new AccountCreationError(\n 'Failed to create account: accountId is null',\n );\n }\n\n this.logger.info(\n `Account created successfully: ${newAccountId.toString()}`,\n );\n return {\n accountId: newAccountId.toString(),\n privateKey: newKey.toString(),\n };\n }\n\n /**\n * Creates an inbound topic for an agent\n * @param accountId The account ID associated with the inbound topic\n * @param topicType Type of inbound topic (public, controlled, or fee-based)\n * @param ttl Optional Time-To-Live for the topic memo, defaults to 60\n * @param feeConfigBuilder Optional fee configuration builder for fee-based topics\n * @returns The topic ID of the created inbound topic\n */\n async createInboundTopic(\n accountId: string,\n topicType: InboundTopicType,\n ttl: number = 60,\n feeConfigBuilder?: FeeConfigBuilderInterface,\n ): Promise<string> {\n if (!this.keyType) {\n await this.initializeOperator();\n }\n\n const memo = this._generateHcs10Memo(Hcs10MemoType.INBOUND, {\n accountId,\n ttl,\n });\n\n let submitKey: boolean | PublicKey | KeyList | undefined;\n let finalFeeConfig: TopicFeeConfig | undefined;\n\n switch (topicType) {\n case InboundTopicType.PUBLIC:\n submitKey = false;\n break;\n case InboundTopicType.CONTROLLED:\n submitKey = true;\n break;\n case InboundTopicType.FEE_BASED:\n submitKey = false;\n if (!feeConfigBuilder) {\n throw new Error(\n 'Fee configuration builder is required for fee-based topics',\n );\n }\n\n const internalFees = (feeConfigBuilder as any)\n .customFees as TokenFeeConfig[];\n internalFees.forEach(fee => {\n if (!fee.feeCollectorAccountId) {\n this.logger.debug(\n `Defaulting fee collector for token ${\n fee.feeTokenId || 'HBAR'\n } to agent ${accountId}`,\n );\n fee.feeCollectorAccountId = accountId;\n }\n });\n\n finalFeeConfig = feeConfigBuilder.build();\n break;\n default:\n throw new Error(`Unsupported inbound topic type: ${topicType}`);\n }\n\n return this.createTopic(memo, true, submitKey, finalFeeConfig);\n }\n\n /**\n * Creates a new agent with inbound and outbound topics\n * @param builder The agent builder object\n * @param ttl Optional Time-To-Live for the topic memos, defaults to 60\n * @param existingState Optional existing state to resume from\n * @returns Object with topic IDs\n */\n async createAgent(\n builder: AgentBuilder,\n ttl: number = 60,\n existingState?: Partial<AgentCreationState>,\n progressCallback?: RegistrationProgressCallback,\n ): Promise<CreateAgentResponse> {\n if (!this.keyType) {\n await this.initializeOperator();\n }\n\n const config = builder.build();\n const accountId = this.client.operatorAccountId?.toString();\n if (!accountId) {\n throw new Error('Failed to retrieve operator account ID');\n }\n\n const result = await this._createEntityTopics(\n ttl,\n {\n outboundTopicId: existingState?.outboundTopicId || '',\n inboundTopicId: existingState?.inboundTopicId || '',\n pfpTopicId:\n existingState?.pfpTopicId || config.existingPfpTopicId || '',\n profileTopicId: existingState?.profileTopicId || '',\n },\n accountId,\n config.inboundTopicType,\n config.feeConfig,\n config.pfpBuffer,\n config.pfpFileName,\n progressCallback,\n );\n\n if (!result.profileTopicId) {\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Creating agent profile',\n progressPercent: 60,\n details: {\n outboundTopicId: result.outboundTopicId,\n inboundTopicId: result.inboundTopicId,\n pfpTopicId: result.pfpTopicId,\n state: {\n currentStage: 'profile',\n completedPercentage: 60,\n },\n },\n });\n }\n\n const profileResult = await this.storeHCS11Profile(\n config.name,\n config.bio,\n result.inboundTopicId,\n result.outboundTopicId,\n config.capabilities,\n config.metadata,\n config.pfpBuffer && config.pfpBuffer.length > 0 && !result.pfpTopicId\n ? config.pfpBuffer\n : undefined,\n config.pfpFileName,\n result.pfpTopicId,\n );\n result.profileTopicId = profileResult.profileTopicId;\n this.logger.info(\n `Profile stored with topic ID: ${result.profileTopicId}`,\n );\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Agent profile created',\n progressPercent: 70,\n details: {\n outboundTopicId: result.outboundTopicId,\n inboundTopicId: result.inboundTopicId,\n pfpTopicId: result.pfpTopicId,\n profileTopicId: result.profileTopicId,\n state: {\n currentStage: 'profile',\n completedPercentage: 70,\n },\n },\n });\n }\n } else {\n this.logger.info(\n `Using existing profile topic ID: ${result.profileTopicId}`,\n );\n }\n\n return result;\n }\n\n /**\n * Inscribes a profile picture to Hedera\n * @param buffer Profile picture buffer\n * @param fileName Filename\n * @returns Response with topic ID and transaction ID\n */\n async inscribePfp(\n buffer: Buffer,\n fileName: string,\n ): Promise<InscribePfpResponse> {\n try {\n this.logger.info('Inscribing profile picture using HCS-11 client');\n\n const imageResult = await this.hcs11Client.inscribeImage(\n buffer,\n fileName,\n );\n\n if (!imageResult.success) {\n this.logger.error(\n `Failed to inscribe profile picture: ${imageResult.error}`,\n );\n throw new Error(\n imageResult?.error || 'Failed to inscribe profile picture',\n );\n }\n\n this.logger.info(\n `Successfully inscribed profile picture with topic ID: ${imageResult.imageTopicId}`,\n );\n return {\n pfpTopicId: imageResult.imageTopicId,\n transactionId: imageResult.transactionId,\n success: true,\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error inscribing profile picture: ${error.message}`;\n this.logger.error(logMessage);\n return {\n pfpTopicId: '',\n transactionId: '',\n success: false,\n error: error.message,\n };\n }\n }\n\n /**\n * Stores an HCS-11 profile for an agent\n * @param agentName Agent name\n * @param agentBio Agent description\n * @param inboundTopicId Inbound topic ID\n * @param outboundTopicId Outbound topic ID\n * @param capabilities Agent capability tags\n * @param metadata Additional metadata\n * @param pfpBuffer Optional profile picture buffer\n * @param pfpFileName Optional profile picture filename\n * @returns Response with topic IDs and transaction ID\n */\n async storeHCS11Profile(\n agentName: string,\n agentBio: string,\n inboundTopicId: string,\n outboundTopicId: string,\n capabilities: number[] = [],\n metadata: AgentMetadata,\n pfpBuffer?: Buffer,\n pfpFileName?: string,\n existingPfpTopicId?: string,\n ): Promise<StoreHCS11ProfileResponse> {\n try {\n let pfpTopicId = existingPfpTopicId || '';\n\n if (!pfpTopicId && pfpBuffer && pfpFileName) {\n this.logger.info('Inscribing profile picture for HCS-11 profile');\n const pfpResult = await this.inscribePfp(pfpBuffer, pfpFileName);\n if (!pfpResult.success) {\n this.logger.warn(\n `Failed to inscribe profile picture: ${pfpResult.error}, proceeding without pfp`,\n );\n } else {\n pfpTopicId = pfpResult.pfpTopicId;\n }\n } else if (existingPfpTopicId) {\n this.logger.info(\n `Using existing profile picture with topic ID: ${existingPfpTopicId} for HCS-11 profile`,\n );\n pfpTopicId = existingPfpTopicId;\n }\n\n const agentType = this.hcs11Client.getAgentTypeFromMetadata({\n type: metadata.type || 'autonomous',\n } as HCS11AgentMetadata);\n\n const formattedSocials: SocialLink[] | undefined = metadata.socials\n ? (Object.entries(metadata.socials)\n .filter(([_, handle]) => handle)\n .map(([platform, handle]) => ({\n platform: platform as SocialPlatform,\n handle: handle as string,\n })) as SocialLink[])\n : undefined;\n\n const profile = this.hcs11Client.createAIAgentProfile(\n agentName,\n agentType,\n capabilities,\n metadata.model || 'unknown',\n {\n alias: agentName.toLowerCase().replace(/\\s+/g, '_'),\n bio: agentBio,\n profileImage: pfpTopicId ? `hcs://1/${pfpTopicId}` : undefined,\n socials: formattedSocials,\n properties: metadata.properties,\n inboundTopicId,\n outboundTopicId,\n creator: metadata.creator,\n },\n );\n\n const profileResult = await this.hcs11Client.createAndInscribeProfile(\n profile,\n true,\n );\n\n if (!profileResult.success) {\n this.logger.error(`Failed to inscribe profile: ${profileResult.error}`);\n throw new Error(profileResult.error || 'Failed to inscribe profile');\n }\n\n this.logger.info(\n `Profile inscribed with topic ID: ${profileResult.profileTopicId}, transaction ID: ${profileResult.transactionId}`,\n );\n\n return {\n profileTopicId: profileResult.profileTopicId,\n pfpTopicId,\n transactionId: profileResult.transactionId,\n success: true,\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error storing HCS-11 profile: ${error.message}`;\n this.logger.error(logMessage);\n return {\n profileTopicId: '',\n pfpTopicId: '',\n transactionId: '',\n success: false,\n error: error.message,\n };\n }\n }\n\n private async setupFees(\n transaction: TopicCreateTransaction,\n feeConfig: TopicFeeConfig,\n additionalExemptAccounts: string[] = [],\n ): Promise<TopicCreateTransaction> {\n let modifiedTransaction = transaction;\n if (!this.client.operatorPublicKey) {\n return modifiedTransaction;\n }\n\n if (!feeConfig.customFees || feeConfig.customFees.length === 0) {\n this.logger.warn('No custom fees provided in fee config for setupFees');\n return modifiedTransaction;\n }\n\n if (feeConfig.customFees.length > 10) {\n this.logger.warn(\n 'More than 10 custom fees provided, only the first 10 will be used',\n );\n feeConfig.customFees = feeConfig.customFees.slice(0, 10);\n }\n\n const customFees = feeConfig.customFees\n .map(fee => {\n if (!fee.feeCollectorAccountId) {\n this.logger.error(\n 'Internal Error: Fee collector ID missing in setupFees',\n );\n return null;\n }\n if (fee.type === 'FIXED_FEE') {\n const customFee = new CustomFixedFee()\n .setAmount(Number(fee.feeAmount.amount))\n .setFeeCollectorAccountId(\n AccountId.fromString(fee.feeCollectorAccountId),\n );\n\n if (fee.feeTokenId) {\n customFee.setDenominatingTokenId(\n TokenId.fromString(fee.feeTokenId),\n );\n }\n\n return customFee;\n }\n return null;\n })\n .filter(Boolean) as CustomFixedFee[];\n\n if (customFees.length === 0) {\n this.logger.warn('No valid custom fees to apply in setupFees');\n return modifiedTransaction;\n }\n\n const exemptAccountIds = [\n ...(feeConfig.exemptAccounts || []),\n ...additionalExemptAccounts,\n ];\n\n if (exemptAccountIds.length > 0) {\n modifiedTransaction = await this.setupExemptKeys(\n transaction,\n exemptAccountIds,\n );\n }\n\n return modifiedTransaction\n .setFeeScheduleKey(this.client.operatorPublicKey)\n .setCustomFees(customFees);\n }\n\n private async setupExemptKeys(\n transaction: TopicCreateTransaction,\n exemptAccountIds: string[],\n ): Promise<TopicCreateTransaction> {\n let modifiedTransaction = transaction;\n const uniqueExemptAccountIds = Array.from(new Set(exemptAccountIds));\n const filteredExemptAccounts = uniqueExemptAccountIds.filter(\n account => account !== this.client.operatorAccountId?.toString(),\n );\n\n let exemptKeys: PublicKey[] = [];\n if (filteredExemptAccounts.length > 0) {\n try {\n exemptKeys = await accountIdsToExemptKeys(\n filteredExemptAccounts,\n this.network,\n this.logger,\n );\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error getting exempt keys: ${error.message}, continuing without exempt keys`;\n this.logger.warn(logMessage);\n }\n }\n\n if (exemptKeys.length > 0) {\n modifiedTransaction = modifiedTransaction.setFeeExemptKeys(exemptKeys);\n }\n\n return modifiedTransaction;\n }\n\n /**\n * Handles a connection request from another account\n * @param inboundTopicId Inbound topic ID of your agent\n * @param requestingAccountId Requesting account ID\n * @param connectionRequestId Connection request ID\n * @param connectionFeeConfig Optional fee configuration for the connection topic\n * @param ttl Optional ttl parameter with default\n * @returns Response with connection details\n */\n async handleConnectionRequest(\n inboundTopicId: string,\n requestingAccountId: string,\n connectionRequestId: number,\n connectionFeeConfig?: FeeConfigBuilderInterface,\n ttl: number = 60,\n ): Promise<HandleConnectionRequestResponse> {\n const memo = this._generateHcs10Memo(Hcs10MemoType.CONNECTION, {\n ttl,\n inboundTopicId,\n connectionId: connectionRequestId,\n });\n this.logger.info(\n `Handling connection request ${connectionRequestId} from ${requestingAccountId}`,\n );\n\n const accountId = this.getClient().operatorAccountId?.toString();\n if (!accountId) {\n throw new Error('Failed to retrieve operator account ID');\n }\n\n let requesterKey = await this.mirrorNode.getPublicKey(requestingAccountId);\n const accountKey = await this.mirrorNode.getPublicKey(accountId);\n\n if (!accountKey) {\n throw new Error('Failed to retrieve public key');\n }\n\n const thresholdKey = new KeyList([accountKey, requesterKey], 1);\n\n let connectionTopicId: string;\n\n try {\n if (connectionFeeConfig) {\n const feeConfig = connectionFeeConfig.build();\n const modifiedFeeConfig = {\n ...feeConfig,\n exemptAccounts: [...(feeConfig.exemptAccounts || [])],\n };\n\n connectionTopicId = await this.createTopic(\n memo,\n thresholdKey,\n thresholdKey,\n modifiedFeeConfig,\n );\n } else {\n connectionTopicId = await this.createTopic(\n memo,\n thresholdKey,\n thresholdKey,\n );\n }\n\n this.logger.info(`Created new connection topic ID: ${connectionTopicId}`);\n } catch (error) {\n const logMessage = `Failed to create connection topic: ${error}`;\n this.logger.error(logMessage);\n throw new TopicCreationError(logMessage);\n }\n\n const operatorId = `${inboundTopicId}@${accountId}`;\n\n const confirmedConnectionSequenceNumber = await this.confirmConnection(\n inboundTopicId,\n connectionTopicId,\n requestingAccountId,\n connectionRequestId,\n 'Connection accepted. Looking forward to collaborating!',\n );\n\n const accountTopics = await this.retrieveCommunicationTopics(accountId);\n\n const requestingAccountTopics =\n await this.retrieveCommunicationTopics(requestingAccountId);\n\n const requestingAccountOperatorId = `${requestingAccountTopics.inboundTopic}@${requestingAccountId}`;\n\n await this.recordOutboundConnectionConfirmation({\n outboundTopicId: accountTopics.outboundTopic,\n requestorOutboundTopicId: requestingAccountTopics.outboundTopic,\n connectionRequestId: connectionRequestId,\n confirmedRequestId: confirmedConnectionSequenceNumber,\n connectionTopicId,\n operatorId: requestingAccountOperatorId,\n memo: `Connection established with ${requestingAccountId}`,\n });\n\n return {\n connectionTopicId,\n confirmedConnectionSequenceNumber,\n operatorId,\n };\n }\n\n /**\n * Confirms a connection request from another account\n * @param inboundTopicId Inbound topic ID\n * @param connectionTopicId Connection topic ID\n * @param connectedAccountId Connected account ID\n * @param connectionId Connection ID\n * @param memo Memo for the connection request\n * @param submitKey Optional submit key\n * @returns Sequence number of the confirmed connection\n */\n async confirmConnection(\n inboundTopicId: string,\n connectionTopicId: string,\n connectedAccountId: string,\n connectionId: number,\n memo: string,\n submitKey?: PrivateKey,\n ): Promise<number> {\n const operatorId = await this.getOperatorId();\n this.logger.info(`Confirming connection with ID ${connectionId}`);\n const payload = {\n p: 'hcs-10',\n op: 'connection_created',\n connection_topic_id: connectionTopicId,\n connected_account_id: connectedAccountId,\n operator_id: operatorId,\n connection_id: connectionId,\n m: memo,\n };\n\n const submissionCheck = await this.canSubmitToTopic(\n inboundTopicId,\n this.client.operatorAccountId?.toString() || '',\n );\n\n const result = await this.submitPayload(\n inboundTopicId,\n payload,\n submitKey,\n submissionCheck.requiresFee,\n );\n\n const sequenceNumber = result.topicSequenceNumber?.toNumber();\n\n if (!sequenceNumber) {\n throw new ConnectionConfirmationError(\n 'Failed to confirm connection: sequence number is null',\n );\n }\n\n return sequenceNumber;\n }\n\n async sendMessage(\n connectionTopicId: string,\n data: string,\n memo?: string,\n submitKey?: PrivateKey,\n options?: {\n progressCallback?: RegistrationProgressCallback;\n waitMaxAttempts?: number;\n waitIntervalMs?: number;\n },\n ): Promise<TransactionReceipt> {\n const submissionCheck = await this.canSubmitToTopic(\n connectionTopicId,\n this.client.operatorAccountId?.toString() || '',\n );\n\n const operatorId = await this.getOperatorId();\n\n const payload = {\n p: 'hcs-10',\n op: 'message',\n operator_id: operatorId,\n data,\n m: memo,\n };\n\n const payloadString = JSON.stringify(payload);\n const isLargePayload = Buffer.from(payloadString).length > 1000;\n\n if (isLargePayload) {\n this.logger.info(\n 'Message payload exceeds 1000 bytes, storing via inscription',\n );\n try {\n const contentBuffer = Buffer.from(data);\n const fileName = `message-${Date.now()}.json`;\n const inscriptionResult = await this.inscribeFile(\n contentBuffer,\n fileName,\n {\n progressCallback: options?.progressCallback,\n waitMaxAttempts: options?.waitMaxAttempts,\n waitIntervalMs: options?.waitIntervalMs,\n },\n );\n\n if (inscriptionResult?.topic_id) {\n payload.data = `hcs://1/${inscriptionResult.topic_id}`;\n this.logger.info(\n `Large message inscribed with topic ID: ${inscriptionResult.topic_id}`,\n );\n } else {\n throw new Error('Failed to inscribe large message content');\n }\n } catch (error: any) {\n const logMessage = `Error inscribing large message: ${error.message}`;\n this.logger.error(logMessage);\n throw new Error(logMessage);\n }\n }\n\n this.logger.info('Submitting message to connection topic', payload);\n return await this.submitPayload(\n connectionTopicId,\n payload,\n submitKey,\n submissionCheck.requiresFee,\n );\n }\n\n async createTopic(\n memo: string,\n adminKey?: boolean | PublicKey | KeyList,\n submitKey?: boolean | PublicKey | KeyList,\n feeConfig?: TopicFeeConfig,\n ): Promise<string> {\n this.logger.info('Creating topic');\n const transaction = new TopicCreateTransaction().setTopicMemo(memo);\n\n if (adminKey) {\n if (\n typeof adminKey === 'boolean' &&\n adminKey &&\n this.client.operatorPublicKey\n ) {\n transaction.setAdminKey(this.client.operatorPublicKey);\n transaction.setAutoRenewAccountId(this.client.operatorAccountId!);\n } else if (adminKey instanceof PublicKey || adminKey instanceof KeyList) {\n transaction.setAdminKey(adminKey);\n if (this.client.operatorAccountId) {\n transaction.setAutoRenewAccountId(this.client.operatorAccountId);\n }\n }\n }\n\n if (submitKey) {\n if (\n typeof submitKey === 'boolean' &&\n submitKey &&\n this.client.operatorPublicKey\n ) {\n transaction.setSubmitKey(this.client.operatorPublicKey);\n } else if (\n submitKey instanceof PublicKey ||\n submitKey instanceof KeyList\n ) {\n transaction.setSubmitKey(submitKey);\n }\n }\n\n if (feeConfig) {\n await this.setupFees(transaction, feeConfig);\n }\n\n this.logger.debug('Executing topic creation transaction');\n const txResponse = await transaction.execute(this.client);\n const receipt = await txResponse.getReceipt(this.client);\n\n if (!receipt.topicId) {\n this.logger.error('Failed to create topic: topicId is null');\n throw new Error('Failed to create topic: topicId is null');\n }\n\n const topicId = receipt.topicId.toString();\n return topicId;\n }\n\n public async submitPayload(\n topicId: string,\n payload: object | string,\n submitKey?: PrivateKey,\n requiresFee: boolean = false,\n ): Promise<TransactionReceipt> {\n const message =\n typeof payload === 'string' ? payload : JSON.stringify(payload);\n\n const payloadSizeInBytes = Buffer.byteLength(message, 'utf8');\n if (payloadSizeInBytes > 1000) {\n throw new PayloadSizeError(\n 'Payload size exceeds 1000 bytes limit',\n payloadSizeInBytes,\n );\n }\n\n const transaction = new TopicMessageSubmitTransaction()\n .setTopicId(TopicId.fromString(topicId))\n .setMessage(message);\n\n if (requiresFee) {\n this.logger.info(\n 'Topic requires fee payment, setting max transaction fee',\n );\n transaction.setMaxTransactionFee(new Hbar(this.feeAmount));\n }\n\n let transactionResponse: TransactionResponse;\n if (submitKey) {\n const frozenTransaction = transaction.freezeWith(this.client);\n const signedTransaction = await frozenTransaction.sign(submitKey);\n transactionResponse = await signedTransaction.execute(this.client);\n } else {\n transactionResponse = await transaction.execute(this.client);\n }\n\n const receipt = await transactionResponse.getReceipt(this.client);\n if (!receipt) {\n this.logger.error('Failed to submit message: receipt is null');\n throw new Error('Failed to submit message: receipt is null');\n }\n this.logger.info('Message submitted successfully');\n return receipt;\n }\n\n async inscribeFile(\n buffer: Buffer,\n fileName: string,\n options?: {\n progressCallback?: RegistrationProgressCallback;\n waitMaxAttempts?: number;\n waitIntervalMs?: number;\n },\n ): Promise<RetrievedInscriptionResult> {\n this.logger.info('Inscribing file');\n if (!this.client.operatorAccountId) {\n this.logger.error('Operator account ID is not set');\n throw new Error('Operator account ID is not set');\n }\n\n if (!this.operatorPrivateKey) {\n this.logger.error('Operator private key is not set');\n throw new Error('Operator private key is not set');\n }\n\n const mimeType = mime.lookup(fileName) || 'application/octet-stream';\n\n const sdk = await InscriptionSDK.createWithAuth({\n type: 'server',\n accountId: this.client.operatorAccountId.toString(),\n privateKey: this.operatorPrivateKey.toString(),\n network: this.network as 'testnet' | 'mainnet',\n });\n\n const inscriptionOptions = {\n mode: 'file' as const,\n waitForConfirmation: true,\n waitMaxAttempts: options?.waitMaxAttempts || 30,\n waitIntervalMs: options?.waitIntervalMs || 4000,\n progressCallback: options?.progressCallback,\n logging: {\n level: this.logger.getLevel ? this.logger.getLevel() : 'info',\n },\n };\n\n const response = await inscribe(\n {\n type: 'buffer',\n buffer,\n fileName,\n mimeType,\n },\n {\n accountId: this.client.operatorAccountId.toString(),\n privateKey: this.operatorPrivateKey.toString(),\n network: this.network as 'testnet' | 'mainnet',\n },\n inscriptionOptions,\n sdk,\n );\n\n if (!response.confirmed || !response.inscription) {\n throw new Error('Inscription was not confirmed');\n }\n\n return response.inscription;\n }\n\n /**\n * Waits for confirmation of a connection request\n * @param inboundTopicId Inbound topic ID\n * @param connectionRequestId Connection request ID\n * @param maxAttempts Maximum number of attempts\n * @param delayMs Delay between attempts in milliseconds\n * @returns Connection confirmation details\n */\n async waitForConnectionConfirmation(\n inboundTopicId: string,\n connectionRequestId: number,\n maxAttempts = 60,\n delayMs = 2000,\n recordConfirmation = true,\n ): Promise<WaitForConnectionConfirmationResponse> {\n this.logger.info(\n `Waiting for connection confirmation on inbound topic ${inboundTopicId} for request ID ${connectionRequestId}`,\n );\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n this.logger.info(\n `Attempt ${attempt + 1}/${maxAttempts} to find connection confirmation`,\n );\n const messages = await this.mirrorNode.getTopicMessages(inboundTopicId);\n\n const connectionCreatedMessages = messages.filter(\n m => m.op === 'connection_created',\n );\n\n this.logger.info(\n `Found ${connectionCreatedMessages.length} connection_created messages`,\n );\n\n if (connectionCreatedMessages.length > 0) {\n for (const message of connectionCreatedMessages) {\n if (Number(message.connection_id) === Number(connectionRequestId)) {\n const confirmationResult = {\n connectionTopicId: message.connection_topic_id,\n sequence_number: Number(message.sequence_number),\n confirmedBy: message.operator_id,\n memo: message.m,\n };\n\n const confirmedByAccountId = this.extractAccountFromOperatorId(\n confirmationResult.confirmedBy,\n );\n\n const account = this.getAccountAndSigner();\n const confirmedByConnectionTopics =\n await this.retrieveCommunicationTopics(confirmedByAccountId);\n\n const agentConnectionTopics =\n await this.retrieveCommunicationTopics(account.accountId);\n\n this.logger.info(\n 'Connection confirmation found',\n confirmationResult,\n );\n\n if (recordConfirmation) {\n /**\n * Record's the confirmation of the connection request from the\n * confirmedBy account to the agent account.\n */\n await this.recordOutboundConnectionConfirmation({\n requestorOutboundTopicId:\n confirmedByConnectionTopics.outboundTopic,\n outboundTopicId: agentConnectionTopics.outboundTopic,\n connectionRequestId,\n confirmedRequestId: confirmationResult.sequence_number,\n connectionTopicId: confirmationResult.connectionTopicId,\n operatorId: confirmationResult.confirmedBy,\n memo: confirmationResult.memo || 'Connection confirmed',\n });\n }\n\n return confirmationResult;\n }\n }\n }\n\n if (attempt < maxAttempts - 1) {\n this.logger.info(\n `No matching confirmation found, waiting ${delayMs}ms before retrying...`,\n );\n await new Promise(resolve => setTimeout(resolve, delayMs));\n }\n }\n\n throw new Error(\n `Connection confirmation not found after ${maxAttempts} attempts for request ID ${connectionRequestId}`,\n );\n }\n\n getAccountAndSigner(): GetAccountAndSignerResponse {\n const PK =\n this.keyType === 'ecdsa'\n ? PrivateKey.fromStringECDSA(this.operatorPrivateKey)\n : PrivateKey.fromStringED25519(this.operatorPrivateKey);\n\n return {\n accountId: this.client.operatorAccountId!.toString()!,\n signer: PK,\n };\n }\n\n /**\n * Creates and registers an agent with a Guarded registry.\n *\n * This function performs the following steps:\n * 1. Creates a new account if no existing account is provided.\n * 2. Initializes an HCS10 client with the new account.\n * 3. Creates an agent on the client.\n * 4. Registers the agent with the Hashgraph Online Guarded Registry.\n *\n * @param builder The agent builder object\n * @param options Optional configuration including progress callback and state management\n * @returns Agent registration result\n */\n async createAndRegisterAgent(\n builder: AgentBuilder,\n options?: {\n baseUrl?: string;\n progressCallback?: RegistrationProgressCallback;\n existingState?: AgentCreationState;\n initialBalance?: number;\n },\n ): Promise<AgentRegistrationResult> {\n try {\n const config = builder.build();\n const progressCallback = options?.progressCallback;\n const baseUrl = options?.baseUrl || this.guardedRegistryBaseUrl;\n\n let state =\n options?.existingState ||\n ({\n currentStage: 'init',\n completedPercentage: 0,\n createdResources: [],\n } as AgentCreationState);\n\n state.agentMetadata = config.metadata;\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Starting agent creation process',\n progressPercent: 0,\n details: { state },\n });\n }\n\n let account = config.existingAccount;\n let agentClient: HCS10Client;\n\n if (\n !state.inboundTopicId ||\n !state.outboundTopicId ||\n !state.profileTopicId\n ) {\n if (!account) {\n if (\n state.createdResources &&\n state.createdResources.some(r => r.startsWith('account:'))\n ) {\n const accountResource = state.createdResources.find(r =>\n r.startsWith('account:'),\n );\n const existingAccountId = accountResource?.split(':')[1];\n\n if (existingAccountId && config.existingAccount) {\n account = config.existingAccount;\n this.logger.info(\n `Resuming with existing account: ${existingAccountId}`,\n );\n } else {\n account = await this.createAccount(options?.initialBalance);\n state.createdResources = state.createdResources || [];\n state.createdResources.push(`account:${account.accountId}`);\n }\n } else {\n account = await this.createAccount(options?.initialBalance);\n state.createdResources = state.createdResources || [];\n state.createdResources.push(`account:${account.accountId}`);\n }\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Created account or using existing account',\n progressPercent: 20,\n details: { state, account },\n });\n }\n\n const keyType =\n this.keyType || detectKeyTypeFromString(account.privateKey);\n\n const privateKey =\n keyType === 'ed25519'\n ? PrivateKey.fromStringED25519(account.privateKey)\n : PrivateKey.fromStringECDSA(account.privateKey);\n\n const publicKey = privateKey.publicKey.toString();\n\n agentClient = new HCS10Client({\n network: config.network,\n operatorId: account.accountId,\n operatorPrivateKey: account.privateKey,\n operatorPublicKey: publicKey,\n keyType: keyType === 'ed25519' ? 'ed25519' : 'ecdsa',\n logLevel: 'info' as LogLevel,\n guardedRegistryBaseUrl: baseUrl,\n });\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Initialized agent client',\n progressPercent: 25,\n details: { state },\n });\n }\n\n let outboundTopicId = state.outboundTopicId;\n let inboundTopicId = state.inboundTopicId;\n let pfpTopicId = state.pfpTopicId;\n let profileTopicId = state.profileTopicId;\n\n if (!outboundTopicId || !inboundTopicId || !profileTopicId) {\n if (pfpTopicId) {\n builder.setExistingProfilePicture(pfpTopicId);\n }\n\n const createResult = await agentClient.createAgent(\n builder,\n 60,\n state,\n data => {\n if (progressCallback) {\n progressCallback({\n stage: data.stage,\n message: data.message,\n progressPercent: data.progressPercent || 0,\n details: {\n ...data.details,\n state: {\n ...state,\n ...data.details?.state,\n },\n },\n });\n }\n },\n );\n\n outboundTopicId = createResult.outboundTopicId;\n inboundTopicId = createResult.inboundTopicId;\n pfpTopicId = createResult.pfpTopicId;\n profileTopicId = createResult.profileTopicId;\n\n state.outboundTopicId = outboundTopicId;\n state.inboundTopicId = inboundTopicId;\n state.pfpTopicId = pfpTopicId;\n state.profileTopicId = profileTopicId;\n\n if (!state.createdResources) {\n state.createdResources = [];\n }\n\n if (\n pfpTopicId &&\n !state.createdResources.includes(`pfp:${pfpTopicId}`)\n ) {\n state.createdResources.push(`pfp:${pfpTopicId}`);\n }\n if (!state.createdResources.includes(`inbound:${inboundTopicId}`)) {\n state.createdResources.push(`inbound:${inboundTopicId}`);\n }\n if (!state.createdResources.includes(`outbound:${outboundTopicId}`)) {\n state.createdResources.push(`outbound:${outboundTopicId}`);\n }\n if (!state.createdResources.includes(`profile:${profileTopicId}`)) {\n state.createdResources.push(`profile:${profileTopicId}`);\n }\n }\n\n state.currentStage = 'profile';\n state.completedPercentage = 60;\n\n if (progressCallback) {\n progressCallback({\n stage: 'submitting',\n message: 'Created agent with topics and profile',\n progressPercent: 60,\n details: {\n state,\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n },\n });\n }\n } else {\n account = account || config.existingAccount;\n if (!account) {\n throw new Error(\n 'Cannot resume registration without account information',\n );\n }\n\n agentClient = new HCS10Client({\n network: config.network,\n operatorId: account.accountId,\n operatorPrivateKey: account.privateKey,\n operatorPublicKey: PrivateKey.fromString(\n account.privateKey,\n ).publicKey.toString(),\n logLevel: 'info' as LogLevel,\n guardedRegistryBaseUrl: baseUrl,\n });\n\n this.logger.info('Resuming registration with existing state', {\n inboundTopicId: state.inboundTopicId,\n outboundTopicId: state.outboundTopicId,\n profileTopicId: state.profileTopicId,\n pfpTopicId: state.pfpTopicId,\n });\n }\n\n const operatorId = `${state.inboundTopicId}@${account.accountId}`;\n\n if (\n state.currentStage !== 'complete' ||\n !state.createdResources?.includes(\n `registration:${state.inboundTopicId}`,\n )\n ) {\n const registrationResult =\n await agentClient.registerAgentWithGuardedRegistry(\n account.accountId,\n config.network,\n {\n progressCallback: data => {\n const adjustedPercent = 60 + (data.progressPercent || 0) * 0.4;\n if (progressCallback) {\n progressCallback({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: {\n ...data.details,\n outboundTopicId: state.outboundTopicId,\n inboundTopicId: state.inboundTopicId,\n pfpTopicId: state.pfpTopicId,\n profileTopicId: state.profileTopicId,\n operatorId,\n state: data.details?.state || state,\n },\n });\n }\n },\n existingState: state,\n },\n );\n\n if (!registrationResult.success) {\n return {\n ...registrationResult,\n state,\n };\n }\n\n state = registrationResult.state || state;\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'completed',\n message: 'Agent creation and registration complete',\n progressPercent: 100,\n details: {\n outboundTopicId: state.outboundTopicId,\n inboundTopicId: state.inboundTopicId,\n pfpTopicId: state.pfpTopicId,\n profileTopicId: state.profileTopicId,\n operatorId,\n state,\n },\n });\n }\n\n return {\n success: true,\n state,\n metadata: {\n accountId: account.accountId,\n privateKey: account.privateKey,\n operatorId,\n inboundTopicId: state.inboundTopicId!,\n outboundTopicId: state.outboundTopicId!,\n profileTopicId: state.profileTopicId!,\n pfpTopicId: state.pfpTopicId!,\n },\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to create and register agent: ${error.message}`;\n this.logger.error(logMessage);\n return {\n error: error.message,\n success: false,\n state:\n options?.existingState ||\n ({\n currentStage: 'init',\n completedPercentage: 0,\n error: error.message,\n } as AgentCreationState),\n };\n }\n }\n\n /**\n * Registers an agent with the guarded registry\n * @param accountId Account ID to register\n * @param inboundTopicId Inbound topic ID for the agent\n * @param network Network type ('mainnet' or 'testnet')\n * @param options Optional configuration including progress callback and confirmation settings\n * @returns Registration result\n */\n async registerAgentWithGuardedRegistry(\n accountId: string,\n network: string = this.network,\n options?: {\n progressCallback?: RegistrationProgressCallback;\n maxAttempts?: number;\n delayMs?: number;\n existingState?: AgentCreationState;\n },\n ): Promise<AgentRegistrationResult> {\n try {\n this.logger.info('Registering agent with guarded registry');\n\n const maxAttempts = options?.maxAttempts ?? 60;\n const delayMs = options?.delayMs ?? 2000;\n const progressCallback = options?.progressCallback;\n let state =\n options?.existingState ||\n ({\n currentStage: 'registration',\n completedPercentage: 0,\n createdResources: [],\n } as AgentCreationState);\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Preparing agent registration',\n progressPercent: 10,\n details: {\n state,\n },\n });\n }\n\n const registrationResult = await this.executeRegistration(\n accountId,\n network,\n this.guardedRegistryBaseUrl,\n this.logger,\n );\n\n if (!registrationResult.success) {\n return {\n ...registrationResult,\n state,\n };\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'submitting',\n message: 'Submitting registration to registry',\n progressPercent: 30,\n details: {\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n if (registrationResult.transaction) {\n const transaction = Transaction.fromBytes(\n Buffer.from(registrationResult.transaction, 'base64'),\n );\n\n this.logger.info(`Processing registration transaction`);\n await transaction.execute(this.client);\n this.logger.info(`Successfully processed registration transaction`);\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'confirming',\n message: 'Confirming registration transaction',\n progressPercent: 60,\n details: {\n accountId,\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n const confirmed = await this.waitForRegistrationConfirmation(\n registrationResult.transactionId!,\n network,\n this.guardedRegistryBaseUrl,\n maxAttempts,\n delayMs,\n this.logger,\n );\n\n state.currentStage = 'complete';\n state.completedPercentage = 100;\n if (!state.createdResources) {\n state.createdResources = [];\n }\n if (registrationResult.transactionId) {\n state.createdResources.push(\n `registration:${registrationResult.transactionId}`,\n );\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'completed',\n message: 'Agent registration complete',\n progressPercent: 100,\n details: {\n confirmed,\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n return {\n ...registrationResult,\n confirmed,\n state,\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to register agent: ${error.message}`;\n this.logger.error(logMessage);\n return {\n error: error.message,\n success: false,\n };\n }\n }\n\n /**\n * Registers an agent with the guarded registry. Should be called by a registry.\n * @param registryTopicId - The topic ID of the guarded registry.\n * @param accountId - The account ID of the agent\n * @param inboundTopicId - The topic ID of the inbound topic\n * @param memo - The memo of the agent\n * @param submitKey - The submit key of the agent\n */\n async registerAgent(\n registryTopicId: string,\n accountId: string,\n inboundTopicId: string,\n memo: string,\n submitKey?: PrivateKey,\n ): Promise<void> {\n this.logger.info('Registering agent');\n const payload = {\n p: 'hcs-10',\n op: 'register',\n account_id: accountId,\n inbound_topic_id: inboundTopicId,\n m: memo,\n };\n\n await this.submitPayload(registryTopicId, payload, submitKey);\n }\n\n async getInboundTopicType(topicId: string): Promise<InboundTopicType> {\n try {\n const topicInfo = await this.mirrorNode.getTopicInfo(topicId);\n\n if (!topicInfo) {\n throw new Error('Topic does not exist');\n }\n\n const hasSubmitKey = topicInfo.submit_key && topicInfo.submit_key.key;\n\n if (!hasSubmitKey) {\n return InboundTopicType.PUBLIC;\n }\n\n const hasFeeScheduleKey =\n topicInfo.fee_schedule_key && topicInfo.fee_schedule_key.key;\n\n if (hasFeeScheduleKey && topicInfo.custom_fees) {\n const customFees = topicInfo.custom_fees;\n\n if (\n customFees &&\n customFees.fixed_fees &&\n customFees.fixed_fees.length > 0\n ) {\n this.logger.info(\n `Topic ${topicId} is fee-based with ${customFees.fixed_fees.length} custom fees`,\n );\n return InboundTopicType.FEE_BASED;\n }\n }\n\n return InboundTopicType.CONTROLLED;\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error determining topic type: ${error.message}`;\n this.logger.error(logMessage);\n throw new Error(logMessage);\n }\n }\n\n getNetwork(): string {\n return this.network;\n }\n\n getLogger(): Logger {\n return this.logger;\n }\n\n /**\n * Public method to get the operator account ID configured for this client instance.\n * @returns The operator account ID string, or null if not set.\n */\n getOperatorAccountId(): string | null {\n return this.client.operatorAccountId?.toString() ?? null;\n }\n\n /**\n * Creates a scheduled transaction from a transaction object\n * @param transaction The transaction to schedule\n * @param memo Optional memo to include with the scheduled transaction\n * @param expirationTime Optional expiration time in seconds from now\n * @returns Object with schedule ID and transaction ID\n */\n private async createScheduledTransaction(\n transaction: Transaction,\n memo?: string,\n expirationTime?: number,\n schedulePayerAccountId?: string,\n ): Promise<{\n scheduleId: string;\n transactionId: string;\n }> {\n this.logger.info('Creating scheduled transaction');\n\n const scheduleTransaction = new ScheduleCreateTransaction()\n .setScheduledTransaction(transaction)\n .setPayerAccountId(\n schedulePayerAccountId\n ? AccountId.fromString(schedulePayerAccountId)\n : this.client.operatorAccountId,\n );\n\n if (memo) {\n scheduleTransaction.setScheduleMemo(memo);\n }\n\n if (expirationTime) {\n const expirationDate = addSeconds(new Date(), expirationTime);\n const timestamp = Timestamp.fromDate(expirationDate);\n scheduleTransaction.setExpirationTime(timestamp);\n }\n\n this.logger.debug('Executing schedule create transaction');\n const scheduleResponse = await scheduleTransaction.execute(this.client);\n const scheduleReceipt = await scheduleResponse.getReceipt(this.client);\n\n if (!scheduleReceipt.scheduleId) {\n this.logger.error(\n 'Failed to create scheduled transaction: scheduleId is null',\n );\n throw new Error(\n 'Failed to create scheduled transaction: scheduleId is null',\n );\n }\n\n const scheduleId = scheduleReceipt.scheduleId.toString();\n const transactionId = scheduleResponse.transactionId.toString();\n\n this.logger.info(\n `Scheduled transaction created successfully: ${scheduleId}`,\n );\n\n return {\n scheduleId,\n transactionId,\n };\n }\n\n /**\n * Sends a transaction operation on a connection topic\n * @param connectionTopicId Connection topic ID\n * @param scheduleId Schedule ID of the scheduled transaction\n * @param data Human-readable description of the transaction, can also be a JSON string or HRL\n * @param submitKey Optional submit key\n * @param options Optional parameters including memo (timestamp is no longer used here)\n * @returns Transaction receipt\n */\n private async sendTransactionOperation(\n connectionTopicId: string,\n scheduleId: string,\n data: string,\n submitKey?: PrivateKey,\n options?: {\n memo?: string;\n },\n ): Promise<TransactionReceipt> {\n const submissionCheck = await this.canSubmitToTopic(\n connectionTopicId,\n this.client.operatorAccountId?.toString() || '',\n );\n\n const operatorId = await this.getOperatorId();\n\n const payload = {\n p: 'hcs-10',\n op: 'transaction',\n operator_id: operatorId,\n schedule_id: scheduleId,\n data,\n m: options?.memo,\n };\n\n this.logger.info(\n 'Submitting transaction operation to connection topic',\n payload,\n );\n return await this.submitPayload(\n connectionTopicId,\n payload,\n submitKey,\n submissionCheck.requiresFee,\n );\n }\n\n /**\n * Creates and sends a transaction operation in one call\n * @param connectionTopicId Connection topic ID for sending the transaction operation\n * @param transaction The transaction to schedule\n * @param data Human-readable description of the transaction, can also be a JSON string or HRL\n * @param options Optional parameters for schedule creation and operation memo\n * @returns Object with schedule details (including scheduleId and its transactionId) and HCS-10 operation receipt\n */\n async sendTransaction(\n connectionTopicId: string,\n transaction: Transaction,\n data: string,\n options?: {\n scheduleMemo?: string;\n expirationTime?: number;\n submitKey?: PrivateKey;\n operationMemo?: string;\n schedulePayerAccountId?: string;\n },\n ): Promise<{\n scheduleId: string;\n transactionId: string;\n receipt: TransactionReceipt;\n }> {\n this.logger.info(\n 'Creating scheduled transaction and sending transaction operation',\n );\n\n const { scheduleId, transactionId } = await this.createScheduledTransaction(\n transaction,\n options?.scheduleMemo,\n options?.expirationTime,\n options?.schedulePayerAccountId,\n );\n\n const receipt = await this.sendTransactionOperation(\n connectionTopicId,\n scheduleId,\n data,\n options?.submitKey,\n {\n memo: options?.operationMemo,\n },\n );\n\n return {\n scheduleId,\n transactionId,\n receipt,\n };\n }\n\n /**\n * Creates a new MCP server with inbound and outbound topics.\n *\n * This method creates communication topics and profiles required for an MCP server,\n * registers the profile with the server's account, and handles profile picture\n * inscriptions if provided.\n *\n * @param builder The MCP server builder object\n * @param ttl Optional Time-To-Live for the topic memos, defaults to 60\n * @param existingState Optional existing state to resume from\n * @returns Object with topic IDs\n */\n async createMCPServer(\n builder: MCPServerBuilder,\n ttl: number = 60,\n existingState?: Partial<MCPServerCreationState>,\n progressCallback?: RegistrationProgressCallback,\n ): Promise<CreateMCPServerResponse> {\n if (!this.keyType) {\n await this.initializeOperator();\n }\n\n const config = builder.build();\n const accountId = this.client.operatorAccountId?.toString();\n if (!accountId) {\n throw new Error('Failed to retrieve operator account ID');\n }\n\n const result = await this._createEntityTopics(\n ttl,\n {\n outboundTopicId: existingState?.outboundTopicId || '',\n inboundTopicId: existingState?.inboundTopicId || '',\n pfpTopicId:\n existingState?.pfpTopicId || config.existingPfpTopicId || '',\n profileTopicId: existingState?.profileTopicId || '',\n },\n accountId,\n InboundTopicType.PUBLIC,\n undefined,\n config.pfpBuffer,\n config.pfpFileName,\n progressCallback,\n );\n\n if (!result.profileTopicId) {\n this.logger.info('Creating and storing HCS-11 MCP server profile');\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Creating MCP server profile',\n progressPercent: 60,\n details: {\n outboundTopicId: result.outboundTopicId,\n inboundTopicId: result.inboundTopicId,\n pfpTopicId: result.pfpTopicId,\n state: {\n currentStage: 'profile',\n completedPercentage: 60,\n },\n },\n });\n }\n\n await this.hcs11Client.initializeOperator();\n const profile = this.hcs11Client.createMCPServerProfile(\n config.name,\n config.mcpServer,\n {\n alias: config.alias,\n bio: config.bio,\n socials: config.socials || [],\n inboundTopicId: result.inboundTopicId,\n outboundTopicId: result.outboundTopicId,\n profileImage: result.pfpTopicId\n ? `hcs://1/${result.pfpTopicId}`\n : undefined,\n },\n );\n\n const profileResult = await this.hcs11Client.inscribeProfile(profile);\n\n if (!profileResult.success) {\n this.logger.error(\n `Failed to inscribe MCP server profile: ${profileResult.error}`,\n );\n throw new Error(\n profileResult.error || 'Failed to inscribe MCP server profile',\n );\n }\n\n result.profileTopicId = profileResult.profileTopicId;\n this.logger.info(\n `MCP server profile stored with topic ID: ${result.profileTopicId}`,\n );\n\n const memoResult = await this.hcs11Client.updateAccountMemoWithProfile(\n accountId,\n result.profileTopicId,\n );\n\n if (!memoResult.success) {\n this.logger.warn(\n `Failed to update account memo: ${memoResult.error}, but continuing with MCP server creation`,\n );\n } else {\n this.logger.info(`Updated account memo with profile reference`);\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'MCP server profile created',\n progressPercent: 70,\n details: {\n outboundTopicId: result.outboundTopicId,\n inboundTopicId: result.inboundTopicId,\n pfpTopicId: result.pfpTopicId,\n profileTopicId: result.profileTopicId,\n state: {\n currentStage: 'profile',\n completedPercentage: 70,\n },\n },\n });\n }\n } else {\n this.logger.info(\n `Using existing profile topic ID: ${result.profileTopicId}`,\n );\n }\n\n return result;\n }\n\n /**\n * Creates the base topic structure for an entity (agent or MCP server).\n *\n * @param ttl Time-To-Live for topic memos\n * @param existingTopics Object containing any existing topic IDs to reuse\n * @param accountId The account ID associated with the entity\n * @param inboundTopicType Type of inbound topic\n * @param feeConfig Optional fee configuration for fee-based topics\n * @param pfpBuffer Optional profile picture buffer\n * @param pfpFileName Optional profile picture filename\n * @param progressCallback Optional callback for reporting progress\n * @returns Object with created topic IDs\n */\n private async _createEntityTopics(\n ttl: number,\n existingTopics: {\n outboundTopicId: string;\n inboundTopicId: string;\n pfpTopicId: string;\n profileTopicId: string;\n },\n accountId: string,\n inboundTopicType: InboundTopicType,\n feeConfig?: FeeConfigBuilderInterface,\n pfpBuffer?: Buffer,\n pfpFileName?: string,\n progressCallback?: RegistrationProgressCallback,\n ): Promise<CreateAgentResponse> {\n let { outboundTopicId, inboundTopicId, pfpTopicId, profileTopicId } =\n existingTopics;\n\n if (!outboundTopicId) {\n const outboundMemo = this._generateHcs10Memo(Hcs10MemoType.OUTBOUND, {\n ttl,\n });\n outboundTopicId = await this.createTopic(outboundMemo, true, true);\n this.logger.info(`Created new outbound topic ID: ${outboundTopicId}`);\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Created outbound topic',\n progressPercent: 30,\n details: {\n outboundTopicId,\n state: {\n currentStage: 'topics',\n completedPercentage: 30,\n },\n },\n });\n }\n } else {\n this.logger.info(`Using existing outbound topic ID: ${outboundTopicId}`);\n }\n\n if (!inboundTopicId) {\n inboundTopicId = await this.createInboundTopic(\n accountId,\n inboundTopicType,\n ttl,\n inboundTopicType === InboundTopicType.FEE_BASED ? feeConfig : undefined,\n );\n this.logger.info(`Created new inbound topic ID: ${inboundTopicId}`);\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Created inbound topic',\n progressPercent: 40,\n details: {\n outboundTopicId,\n inboundTopicId,\n state: {\n currentStage: 'topics',\n completedPercentage: 40,\n },\n },\n });\n }\n } else {\n this.logger.info(`Using existing inbound topic ID: ${inboundTopicId}`);\n }\n\n if (!pfpTopicId && pfpBuffer && pfpBuffer.length > 0 && pfpFileName) {\n this.logger.info('Inscribing new profile picture');\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Inscribing profile picture',\n progressPercent: 50,\n details: {\n outboundTopicId,\n inboundTopicId,\n state: {\n currentStage: 'pfp',\n completedPercentage: 50,\n },\n },\n });\n }\n\n const pfpResult = await this.inscribePfp(pfpBuffer, pfpFileName);\n pfpTopicId = pfpResult.pfpTopicId;\n this.logger.info(\n `Profile picture inscribed with topic ID: ${pfpTopicId}`,\n );\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Profile picture inscribed',\n progressPercent: 55,\n details: {\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n state: {\n currentStage: 'pfp',\n completedPercentage: 55,\n },\n },\n });\n }\n } else if (pfpTopicId) {\n this.logger.info(\n `Using existing profile picture with topic ID: ${pfpTopicId}`,\n );\n }\n\n return {\n inboundTopicId,\n outboundTopicId,\n pfpTopicId,\n profileTopicId,\n };\n }\n\n /**\n * Creates and registers an MCP server with a Guarded registry.\n *\n * This function creates a new account if needed, initializes an HCS10 client,\n * creates an MCP server with inbound and outbound topics, and registers\n * it with the Hashgraph Online Guarded Registry.\n *\n * @param builder The MCP server builder object with configuration\n * @param options Optional settings for registration process\n * @returns Registration result with success status and metadata\n */\n async createAndRegisterMCPServer(\n builder: MCPServerBuilder,\n options?: {\n baseUrl?: string;\n progressCallback?: RegistrationProgressCallback;\n existingState?: MCPServerCreationState;\n initialBalance?: number;\n },\n ): Promise<AgentRegistrationResult> {\n try {\n const config = builder.build();\n const progressCallback = options?.progressCallback;\n const baseUrl = options?.baseUrl || this.guardedRegistryBaseUrl;\n\n let state =\n options?.existingState ||\n ({\n currentStage: 'init',\n completedPercentage: 0,\n createdResources: [],\n } as MCPServerCreationState);\n\n state.serverMetadata = {\n name: config.name,\n description: config.mcpServer.description,\n services: config.mcpServer.services,\n };\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Starting MCP server creation process',\n progressPercent: 0,\n details: { state },\n });\n }\n\n let account = config.existingAccount;\n let serverClient: HCS10Client;\n\n if (\n !state.inboundTopicId ||\n !state.outboundTopicId ||\n !state.profileTopicId\n ) {\n if (!account) {\n if (\n state.createdResources &&\n state.createdResources.some(r => r.startsWith('account:'))\n ) {\n const accountResource = state.createdResources.find(r =>\n r.startsWith('account:'),\n );\n const existingAccountId = accountResource?.split(':')[1];\n\n if (existingAccountId && config.existingAccount) {\n account = config.existingAccount;\n this.logger.info(\n `Resuming with existing account: ${existingAccountId}`,\n );\n } else {\n account = await this.createAccount(options?.initialBalance);\n state.createdResources = state.createdResources || [];\n state.createdResources.push(`account:${account.accountId}`);\n }\n } else {\n account = await this.createAccount(options?.initialBalance);\n state.createdResources = state.createdResources || [];\n state.createdResources.push(`account:${account.accountId}`);\n }\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Created account or using existing account',\n progressPercent: 20,\n details: { state, account },\n });\n }\n const keyType =\n this.keyType || detectKeyTypeFromString(account.privateKey);\n\n const privateKey =\n keyType === 'ed25519'\n ? PrivateKey.fromStringED25519(account.privateKey)\n : PrivateKey.fromStringECDSA(account.privateKey);\n\n const publicKey = privateKey.publicKey.toString();\n\n serverClient = new HCS10Client({\n network: config.network,\n operatorId: account.accountId,\n operatorPrivateKey: account.privateKey,\n operatorPublicKey: publicKey,\n logLevel: 'info' as LogLevel,\n guardedRegistryBaseUrl: baseUrl,\n });\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Initialized MCP server client',\n progressPercent: 25,\n details: { state },\n });\n }\n\n let outboundTopicId = state.outboundTopicId;\n let inboundTopicId = state.inboundTopicId;\n let pfpTopicId = state.pfpTopicId;\n let profileTopicId = state.profileTopicId;\n\n if (!outboundTopicId || !inboundTopicId || !profileTopicId) {\n if (pfpTopicId) {\n builder.setExistingProfilePicture(pfpTopicId);\n }\n\n const createResult = await serverClient.createMCPServer(\n builder,\n 60,\n state,\n data => {\n if (progressCallback) {\n progressCallback({\n stage: data.stage,\n message: data.message,\n progressPercent: data.progressPercent || 0,\n details: {\n ...data.details,\n state: {\n ...state,\n ...data.details?.state,\n },\n },\n });\n }\n },\n );\n\n outboundTopicId = createResult.outboundTopicId;\n inboundTopicId = createResult.inboundTopicId;\n pfpTopicId = createResult.pfpTopicId;\n profileTopicId = createResult.profileTopicId;\n\n state.outboundTopicId = outboundTopicId;\n state.inboundTopicId = inboundTopicId;\n state.pfpTopicId = pfpTopicId;\n state.profileTopicId = profileTopicId;\n\n if (!state.createdResources) {\n state.createdResources = [];\n }\n\n if (\n pfpTopicId &&\n !state.createdResources.includes(`pfp:${pfpTopicId}`)\n ) {\n state.createdResources.push(`pfp:${pfpTopicId}`);\n }\n if (!state.createdResources.includes(`inbound:${inboundTopicId}`)) {\n state.createdResources.push(`inbound:${inboundTopicId}`);\n }\n if (!state.createdResources.includes(`outbound:${outboundTopicId}`)) {\n state.createdResources.push(`outbound:${outboundTopicId}`);\n }\n if (!state.createdResources.includes(`profile:${profileTopicId}`)) {\n state.createdResources.push(`profile:${profileTopicId}`);\n }\n }\n\n state.currentStage = 'profile';\n state.completedPercentage = 60;\n\n if (progressCallback) {\n progressCallback({\n stage: 'submitting',\n message: 'Created MCP server with topics and profile',\n progressPercent: 60,\n details: {\n state,\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n },\n });\n }\n } else {\n account = account || config.existingAccount;\n if (!account) {\n throw new Error(\n 'Cannot resume registration without account information',\n );\n }\n\n const keyType =\n this.keyType || detectKeyTypeFromString(account.privateKey);\n\n const privateKey =\n keyType === 'ed25519'\n ? PrivateKey.fromStringED25519(account.privateKey)\n : PrivateKey.fromStringECDSA(account.privateKey);\n\n const publicKey = privateKey.publicKey.toString();\n\n serverClient = new HCS10Client({\n network: config.network,\n operatorId: account.accountId,\n operatorPrivateKey: account.privateKey,\n operatorPublicKey: publicKey,\n keyType: keyType === 'ed25519' ? 'ed25519' : 'ecdsa',\n logLevel: 'info' as LogLevel,\n guardedRegistryBaseUrl: baseUrl,\n });\n\n this.logger.info('Resuming registration with existing state', {\n inboundTopicId: state.inboundTopicId,\n outboundTopicId: state.outboundTopicId,\n profileTopicId: state.profileTopicId,\n pfpTopicId: state.pfpTopicId,\n });\n }\n\n const operatorId = `${state.inboundTopicId}@${account.accountId}`;\n\n if (\n state.currentStage !== 'complete' ||\n !state.createdResources?.includes(\n `registration:${state.inboundTopicId}`,\n )\n ) {\n const registrationResult =\n await serverClient.registerAgentWithGuardedRegistry(\n account.accountId,\n config.network,\n {\n progressCallback: data => {\n const adjustedPercent = 60 + (data.progressPercent || 0) * 0.4;\n if (progressCallback) {\n progressCallback({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: {\n ...data.details,\n outboundTopicId: state.outboundTopicId,\n inboundTopicId: state.inboundTopicId,\n pfpTopicId: state.pfpTopicId,\n profileTopicId: state.profileTopicId,\n operatorId,\n state: data.details?.state || state,\n },\n });\n }\n },\n existingState: state,\n },\n );\n\n if (!registrationResult.success) {\n return {\n ...registrationResult,\n state,\n };\n }\n\n state = registrationResult.state || state;\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'completed',\n message: 'MCP server creation and registration complete',\n progressPercent: 100,\n details: {\n outboundTopicId: state.outboundTopicId,\n inboundTopicId: state.inboundTopicId,\n pfpTopicId: state.pfpTopicId,\n profileTopicId: state.profileTopicId,\n operatorId,\n state,\n },\n });\n }\n\n return {\n success: true,\n state,\n metadata: {\n accountId: account.accountId,\n privateKey: account.privateKey,\n operatorId,\n inboundTopicId: state.inboundTopicId!,\n outboundTopicId: state.outboundTopicId!,\n profileTopicId: state.profileTopicId!,\n pfpTopicId: state.pfpTopicId!,\n },\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to create and register MCP server: ${error.message}`;\n this.logger.error(logMessage);\n return {\n error: error.message,\n success: false,\n state:\n options?.existingState ||\n ({\n currentStage: 'init',\n completedPercentage: 0,\n error: error.message,\n } as MCPServerCreationState),\n };\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAiEO,MAAM,oBAAoB,gBAAgB;AAAA,EAU/C,YAAY,QAAyB;AAC7B,UAAA;AAAA,MACJ,SAAS,OAAO;AAAA,MAChB,UAAU,OAAO;AAAA,MACjB,aAAa,OAAO;AAAA,MACpB,WAAW,OAAO;AAAA,MAClB,YAAY,OAAO;AAAA,MACnB,QAAQ,OAAO;AAAA,MACf,SAAS,OAAO;AAAA,IAAA,CACjB;AACI,SAAA,SACH,OAAO,YAAY,YAAY,OAAO,WAAW,IAAI,OAAO,WAAW;AACzE,SAAK,qBAAqB,OAAO;AAEjC,SAAK,oBAAoB,OAAO;AAChC,QAAI,OAAO,SAAS;AAClB,WAAK,UAAU,OAAO;AACtB,YAAM,KACJ,KAAK,YAAY,UACb,WAAW,gBAAgB,KAAK,kBAAkB,IAClD,WAAW,kBAAkB,KAAK,kBAAkB;AAC1D,WAAK,OAAO,YAAY,OAAO,YAAY,EAAE;AAAA,IAAA,OACxC;AACD,UAAA;AACI,cAAA,eAAe,wBAAwB,KAAK,kBAAkB;AACpE,aAAK,OAAO,YAAY,OAAO,YAAY,aAAa,UAAU;AAClE,aAAK,UAAU,aAAa;AAAA,eACrB,OAAO;AACd,aAAK,OAA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MAAA;AAGI,aAAA;AAAA,QACL,SAAS;AAAA,QACT;AAAA,QACA,UAAU;AAAA,UACR,WAAW,QAAQ;AAAA,UACnB,YAAY,QAAQ;AAAA,UACpB;AAAA,UACA,gBAAgB,MAAM;AAAA,UACtB,iBAAiB,MAAM;AAAA,UACvB,gBAAgB,MAAM;AAAA,UACtB,YAAY,MAAM;AAAA,QAAA;AAAA,MAEtB;AAAA,aACO,GAAQ;AACf,YAAM,QAAQ;AACR,YAAA,aAAa,6CAA6C,MAAM,OAAO;AACxE,WAAA,OAAO,MAAM,UAAU;AACrB,aAAA;AAAA,QACL,OAAO,MAAM;AAAA,QACb,SAAS;AAAA,QACT,OACE,SAAS,iBACR;AAAA,UACC,cAAc;AAAA,UACd,qBAAqB;AAAA,UACrB,OAAO,MAAM;AAAA,QAAA;AAAA,MAEnB;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es7.js","sources":["../../src/hcs-10/sdk.ts"],"sourcesContent":["import {\n Client,\n AccountCreateTransaction,\n PrivateKey,\n Hbar,\n KeyList,\n TopicCreateTransaction,\n TopicMessageSubmitTransaction,\n TopicId,\n Transaction,\n TransactionResponse,\n TransactionReceipt,\n PublicKey,\n AccountId,\n CustomFixedFee,\n TokenId,\n ScheduleCreateTransaction,\n Timestamp,\n} from '@hashgraph/sdk';\nimport {\n PayloadSizeError,\n AccountCreationError,\n TopicCreationError,\n ConnectionConfirmationError,\n} from './errors';\nimport {\n InscriptionSDK,\n RetrievedInscriptionResult,\n} from '@kiloscribe/inscription-sdk';\nimport { Logger, LogLevel, detectKeyTypeFromString } from '../utils';\nimport { HCS10BaseClient } from './base-client';\nimport * as mime from 'mime-types';\nimport {\n HCSClientConfig,\n CreateAccountResponse,\n CreateAgentResponse,\n CreateMCPServerResponse,\n StoreHCS11ProfileResponse,\n AgentRegistrationResult,\n HandleConnectionRequestResponse,\n WaitForConnectionConfirmationResponse,\n GetAccountAndSignerResponse,\n AgentCreationState,\n RegistrationProgressCallback,\n InscribePfpResponse,\n MCPServerCreationState,\n} from './types';\nimport { MirrorNodeConfig } from '../services';\nimport {\n HCS11Client,\n AgentMetadata as HCS11AgentMetadata,\n SocialLink,\n SocialPlatform,\n InboundTopicType,\n AgentMetadata,\n MCPServerBuilder,\n} from '../hcs-11';\nimport { FeeConfigBuilderInterface, TopicFeeConfig } from '../fees';\nimport { accountIdsToExemptKeys } from '../utils/topic-fee-utils';\nimport { Hcs10MemoType } from './base-client';\nimport { AgentBuilder } from '../hcs-11/agent-builder';\nimport { inscribe } from '../inscribe/inscriber';\nimport { TokenFeeConfig } from '../fees/types';\nimport { addSeconds } from 'date-fns';\n\nexport class HCS10Client extends HCS10BaseClient {\n private client: Client;\n private operatorPrivateKey: string;\n private operatorAccountId: string;\n declare protected network: string;\n declare protected logger: Logger;\n protected guardedRegistryBaseUrl: string;\n private hcs11Client: HCS11Client;\n private keyType: 'ed25519' | 'ecdsa';\n\n constructor(config: HCSClientConfig) {\n super({\n network: config.network,\n logLevel: config.logLevel,\n prettyPrint: config.prettyPrint,\n feeAmount: config.feeAmount,\n mirrorNode: config.mirrorNode,\n silent: config.silent,\n keyType: config.keyType,\n });\n this.client =\n config.network === 'mainnet' ? Client.forMainnet() : Client.forTestnet();\n this.operatorPrivateKey = config.operatorPrivateKey;\n\n this.operatorAccountId = config.operatorId;\n if (config.keyType) {\n this.keyType = config.keyType;\n const PK =\n this.keyType === 'ecdsa'\n ? PrivateKey.fromStringECDSA(this.operatorPrivateKey)\n : PrivateKey.fromStringED25519(this.operatorPrivateKey);\n this.client.setOperator(config.operatorId, PK);\n } else {\n try {\n const keyDetection = detectKeyTypeFromString(this.operatorPrivateKey);\n this.client.setOperator(config.operatorId, keyDetection.privateKey);\n this.keyType = keyDetection.detectedType;\n } catch (error) {\n this.logger.warn(\n 'Failed to detect key type from private key format, will query mirror node',\n );\n this.keyType = 'ed25519';\n }\n\n this.initializeOperator();\n }\n\n this.network = config.network;\n this.logger = Logger.getInstance({\n level: config.logLevel || 'info',\n module: 'HCS-SDK',\n silent: config.silent,\n });\n this.guardedRegistryBaseUrl =\n config.guardedRegistryBaseUrl || 'https://moonscape.tech';\n\n this.hcs11Client = new HCS11Client({\n network: config.network,\n auth: {\n operatorId: config.operatorId,\n privateKey: config.operatorPrivateKey,\n },\n logLevel: config.logLevel,\n silent: config.silent,\n keyType: config.keyType,\n });\n }\n\n public async initializeOperator(): Promise<{\n accountId: string;\n privateKey: string;\n keyType: 'ed25519' | 'ecdsa';\n client: Client;\n }> {\n const account = await this.requestAccount(this.operatorAccountId);\n const keyType = account?.key?._type;\n\n if (keyType.includes('ECDSA')) {\n this.keyType = 'ecdsa';\n } else if (keyType.includes('ED25519')) {\n this.keyType = 'ed25519';\n } else {\n this.keyType = 'ed25519';\n }\n\n const PK =\n this.keyType === 'ecdsa'\n ? PrivateKey.fromStringECDSA(this.operatorPrivateKey)\n : PrivateKey.fromStringED25519(this.operatorPrivateKey);\n\n this.logger.debug(\n `Setting operator: ${this.operatorAccountId} with key type: ${this.keyType}`,\n );\n\n this.client.setOperator(this.operatorAccountId, PK);\n\n return {\n accountId: this.operatorAccountId,\n privateKey: this.operatorPrivateKey,\n keyType: this.keyType,\n client: this.client,\n };\n }\n\n public getClient() {\n return this.client;\n }\n\n /**\n * Creates a new Hedera account\n * @param initialBalance Optional initial balance in HBAR (default: 50)\n * @returns Object with account ID and private key\n */\n async createAccount(\n initialBalance: number = 50,\n ): Promise<CreateAccountResponse> {\n if (!this.keyType) {\n await this.initializeOperator();\n }\n\n this.logger.info(\n `Creating new account with ${initialBalance} HBAR initial balance`,\n );\n const newKey = PrivateKey.generateED25519();\n\n const accountTransaction = new AccountCreateTransaction()\n .setKeyWithoutAlias(newKey.publicKey)\n .setInitialBalance(new Hbar(initialBalance));\n\n this.logger.debug('Executing account creation transaction');\n const accountResponse = await accountTransaction.execute(this.client);\n const accountReceipt = await accountResponse.getReceipt(this.client);\n const newAccountId = accountReceipt.accountId;\n\n if (!newAccountId) {\n this.logger.error('Account creation failed: accountId is null');\n throw new AccountCreationError(\n 'Failed to create account: accountId is null',\n );\n }\n\n this.logger.info(\n `Account created successfully: ${newAccountId.toString()}`,\n );\n return {\n accountId: newAccountId.toString(),\n privateKey: newKey.toString(),\n };\n }\n\n /**\n * Creates an inbound topic for an agent\n * @param accountId The account ID associated with the inbound topic\n * @param topicType Type of inbound topic (public, controlled, or fee-based)\n * @param ttl Optional Time-To-Live for the topic memo, defaults to 60\n * @param feeConfigBuilder Optional fee configuration builder for fee-based topics\n * @returns The topic ID of the created inbound topic\n */\n async createInboundTopic(\n accountId: string,\n topicType: InboundTopicType,\n ttl: number = 60,\n feeConfigBuilder?: FeeConfigBuilderInterface,\n ): Promise<string> {\n if (!this.keyType) {\n await this.initializeOperator();\n }\n\n const memo = this._generateHcs10Memo(Hcs10MemoType.INBOUND, {\n accountId,\n ttl,\n });\n\n let submitKey: boolean | PublicKey | KeyList | undefined;\n let finalFeeConfig: TopicFeeConfig | undefined;\n\n switch (topicType) {\n case InboundTopicType.PUBLIC:\n submitKey = false;\n break;\n case InboundTopicType.CONTROLLED:\n submitKey = true;\n break;\n case InboundTopicType.FEE_BASED:\n submitKey = false;\n if (!feeConfigBuilder) {\n throw new Error(\n 'Fee configuration builder is required for fee-based topics',\n );\n }\n\n const internalFees = (feeConfigBuilder as any)\n .customFees as TokenFeeConfig[];\n internalFees.forEach(fee => {\n if (!fee.feeCollectorAccountId) {\n this.logger.debug(\n `Defaulting fee collector for token ${\n fee.feeTokenId || 'HBAR'\n } to agent ${accountId}`,\n );\n fee.feeCollectorAccountId = accountId;\n }\n });\n\n finalFeeConfig = feeConfigBuilder.build();\n break;\n default:\n throw new Error(`Unsupported inbound topic type: ${topicType}`);\n }\n\n return this.createTopic(memo, true, submitKey, finalFeeConfig);\n }\n\n /**\n * Creates a new agent with inbound and outbound topics\n * @param builder The agent builder object\n * @param ttl Optional Time-To-Live for the topic memos, defaults to 60\n * @param existingState Optional existing state to resume from\n * @returns Object with topic IDs\n */\n async createAgent(\n builder: AgentBuilder,\n ttl: number = 60,\n existingState?: Partial<AgentCreationState>,\n progressCallback?: RegistrationProgressCallback,\n ): Promise<CreateAgentResponse> {\n if (!this.keyType) {\n await this.initializeOperator();\n }\n\n const config = builder.build();\n const accountId = this.client.operatorAccountId?.toString();\n if (!accountId) {\n throw new Error('Failed to retrieve operator account ID');\n }\n\n const result = await this._createEntityTopics(\n ttl,\n {\n outboundTopicId: existingState?.outboundTopicId || '',\n inboundTopicId: existingState?.inboundTopicId || '',\n pfpTopicId:\n existingState?.pfpTopicId || config.existingPfpTopicId || '',\n profileTopicId: existingState?.profileTopicId || '',\n },\n accountId,\n config.inboundTopicType,\n config.feeConfig,\n config.pfpBuffer,\n config.pfpFileName,\n progressCallback,\n );\n\n if (!result.profileTopicId) {\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Creating agent profile',\n progressPercent: 60,\n details: {\n outboundTopicId: result.outboundTopicId,\n inboundTopicId: result.inboundTopicId,\n pfpTopicId: result.pfpTopicId,\n state: {\n currentStage: 'profile',\n completedPercentage: 60,\n },\n },\n });\n }\n\n const profileResult = await this.storeHCS11Profile(\n config.name,\n config.bio,\n result.inboundTopicId,\n result.outboundTopicId,\n config.capabilities,\n config.metadata,\n config.pfpBuffer && config.pfpBuffer.length > 0 && !result.pfpTopicId\n ? config.pfpBuffer\n : undefined,\n config.pfpFileName,\n result.pfpTopicId,\n );\n result.profileTopicId = profileResult.profileTopicId;\n this.logger.info(\n `Profile stored with topic ID: ${result.profileTopicId}`,\n );\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Agent profile created',\n progressPercent: 70,\n details: {\n outboundTopicId: result.outboundTopicId,\n inboundTopicId: result.inboundTopicId,\n pfpTopicId: result.pfpTopicId,\n profileTopicId: result.profileTopicId,\n state: {\n currentStage: 'profile',\n completedPercentage: 70,\n },\n },\n });\n }\n } else {\n this.logger.info(\n `Using existing profile topic ID: ${result.profileTopicId}`,\n );\n }\n\n return result;\n }\n\n /**\n * Inscribes a profile picture to Hedera\n * @param buffer Profile picture buffer\n * @param fileName Filename\n * @returns Response with topic ID and transaction ID\n */\n async inscribePfp(\n buffer: Buffer,\n fileName: string,\n ): Promise<InscribePfpResponse> {\n try {\n this.logger.info('Inscribing profile picture using HCS-11 client');\n\n const imageResult = await this.hcs11Client.inscribeImage(\n buffer,\n fileName,\n );\n\n if (!imageResult.success) {\n this.logger.error(\n `Failed to inscribe profile picture: ${imageResult.error}`,\n );\n throw new Error(\n imageResult?.error || 'Failed to inscribe profile picture',\n );\n }\n\n this.logger.info(\n `Successfully inscribed profile picture with topic ID: ${imageResult.imageTopicId}`,\n );\n return {\n pfpTopicId: imageResult.imageTopicId,\n transactionId: imageResult.transactionId,\n success: true,\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error inscribing profile picture: ${error.message}`;\n this.logger.error(logMessage);\n return {\n pfpTopicId: '',\n transactionId: '',\n success: false,\n error: error.message,\n };\n }\n }\n\n /**\n * Stores an HCS-11 profile for an agent\n * @param agentName Agent name\n * @param agentBio Agent description\n * @param inboundTopicId Inbound topic ID\n * @param outboundTopicId Outbound topic ID\n * @param capabilities Agent capability tags\n * @param metadata Additional metadata\n * @param pfpBuffer Optional profile picture buffer\n * @param pfpFileName Optional profile picture filename\n * @returns Response with topic IDs and transaction ID\n */\n async storeHCS11Profile(\n agentName: string,\n agentBio: string,\n inboundTopicId: string,\n outboundTopicId: string,\n capabilities: number[] = [],\n metadata: AgentMetadata,\n pfpBuffer?: Buffer,\n pfpFileName?: string,\n existingPfpTopicId?: string,\n ): Promise<StoreHCS11ProfileResponse> {\n try {\n let pfpTopicId = existingPfpTopicId || '';\n\n if (!pfpTopicId && pfpBuffer && pfpFileName) {\n this.logger.info('Inscribing profile picture for HCS-11 profile');\n const pfpResult = await this.inscribePfp(pfpBuffer, pfpFileName);\n if (!pfpResult.success) {\n this.logger.warn(\n `Failed to inscribe profile picture: ${pfpResult.error}, proceeding without pfp`,\n );\n } else {\n pfpTopicId = pfpResult.pfpTopicId;\n }\n } else if (existingPfpTopicId) {\n this.logger.info(\n `Using existing profile picture with topic ID: ${existingPfpTopicId} for HCS-11 profile`,\n );\n pfpTopicId = existingPfpTopicId;\n }\n\n const agentType = this.hcs11Client.getAgentTypeFromMetadata({\n type: metadata.type || 'autonomous',\n } as HCS11AgentMetadata);\n\n const formattedSocials: SocialLink[] | undefined = metadata.socials\n ? (Object.entries(metadata.socials)\n .filter(([_, handle]) => handle)\n .map(([platform, handle]) => ({\n platform: platform as SocialPlatform,\n handle: handle as string,\n })) as SocialLink[])\n : undefined;\n\n const profile = this.hcs11Client.createAIAgentProfile(\n agentName,\n agentType,\n capabilities,\n metadata.model || 'unknown',\n {\n alias: agentName.toLowerCase().replace(/\\s+/g, '_'),\n bio: agentBio,\n profileImage: pfpTopicId ? `hcs://1/${pfpTopicId}` : undefined,\n socials: formattedSocials,\n properties: metadata.properties,\n inboundTopicId,\n outboundTopicId,\n creator: metadata.creator,\n },\n );\n\n const profileResult = await this.hcs11Client.createAndInscribeProfile(\n profile,\n true,\n );\n\n if (!profileResult.success) {\n this.logger.error(`Failed to inscribe profile: ${profileResult.error}`);\n throw new Error(profileResult.error || 'Failed to inscribe profile');\n }\n\n this.logger.info(\n `Profile inscribed with topic ID: ${profileResult.profileTopicId}, transaction ID: ${profileResult.transactionId}`,\n );\n\n return {\n profileTopicId: profileResult.profileTopicId,\n pfpTopicId,\n transactionId: profileResult.transactionId,\n success: true,\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error storing HCS-11 profile: ${error.message}`;\n this.logger.error(logMessage);\n return {\n profileTopicId: '',\n pfpTopicId: '',\n transactionId: '',\n success: false,\n error: error.message,\n };\n }\n }\n\n private async setupFees(\n transaction: TopicCreateTransaction,\n feeConfig: TopicFeeConfig,\n additionalExemptAccounts: string[] = [],\n ): Promise<TopicCreateTransaction> {\n let modifiedTransaction = transaction;\n if (!this.client.operatorPublicKey) {\n return modifiedTransaction;\n }\n\n if (!feeConfig.customFees || feeConfig.customFees.length === 0) {\n this.logger.warn('No custom fees provided in fee config for setupFees');\n return modifiedTransaction;\n }\n\n if (feeConfig.customFees.length > 10) {\n this.logger.warn(\n 'More than 10 custom fees provided, only the first 10 will be used',\n );\n feeConfig.customFees = feeConfig.customFees.slice(0, 10);\n }\n\n const customFees = feeConfig.customFees\n .map(fee => {\n if (!fee.feeCollectorAccountId) {\n this.logger.error(\n 'Internal Error: Fee collector ID missing in setupFees',\n );\n return null;\n }\n if (fee.type === 'FIXED_FEE') {\n const customFee = new CustomFixedFee()\n .setAmount(Number(fee.feeAmount.amount))\n .setFeeCollectorAccountId(\n AccountId.fromString(fee.feeCollectorAccountId),\n );\n\n if (fee.feeTokenId) {\n customFee.setDenominatingTokenId(\n TokenId.fromString(fee.feeTokenId),\n );\n }\n\n return customFee;\n }\n return null;\n })\n .filter(Boolean) as CustomFixedFee[];\n\n if (customFees.length === 0) {\n this.logger.warn('No valid custom fees to apply in setupFees');\n return modifiedTransaction;\n }\n\n const exemptAccountIds = [\n ...(feeConfig.exemptAccounts || []),\n ...additionalExemptAccounts,\n ];\n\n if (exemptAccountIds.length > 0) {\n modifiedTransaction = await this.setupExemptKeys(\n transaction,\n exemptAccountIds,\n );\n }\n\n return modifiedTransaction\n .setFeeScheduleKey(this.client.operatorPublicKey)\n .setCustomFees(customFees);\n }\n\n private async setupExemptKeys(\n transaction: TopicCreateTransaction,\n exemptAccountIds: string[],\n ): Promise<TopicCreateTransaction> {\n let modifiedTransaction = transaction;\n const uniqueExemptAccountIds = Array.from(new Set(exemptAccountIds));\n const filteredExemptAccounts = uniqueExemptAccountIds.filter(\n account => account !== this.client.operatorAccountId?.toString(),\n );\n\n let exemptKeys: PublicKey[] = [];\n if (filteredExemptAccounts.length > 0) {\n try {\n exemptKeys = await accountIdsToExemptKeys(\n filteredExemptAccounts,\n this.network,\n this.logger,\n );\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error getting exempt keys: ${error.message}, continuing without exempt keys`;\n this.logger.warn(logMessage);\n }\n }\n\n if (exemptKeys.length > 0) {\n modifiedTransaction = modifiedTransaction.setFeeExemptKeys(exemptKeys);\n }\n\n return modifiedTransaction;\n }\n\n /**\n * Handles a connection request from another account\n * @param inboundTopicId Inbound topic ID of your agent\n * @param requestingAccountId Requesting account ID\n * @param connectionRequestId Connection request ID\n * @param connectionFeeConfig Optional fee configuration for the connection topic\n * @param ttl Optional ttl parameter with default\n * @returns Response with connection details\n */\n async handleConnectionRequest(\n inboundTopicId: string,\n requestingAccountId: string,\n connectionRequestId: number,\n connectionFeeConfig?: FeeConfigBuilderInterface,\n ttl: number = 60,\n ): Promise<HandleConnectionRequestResponse> {\n const memo = this._generateHcs10Memo(Hcs10MemoType.CONNECTION, {\n ttl,\n inboundTopicId,\n connectionId: connectionRequestId,\n });\n this.logger.info(\n `Handling connection request ${connectionRequestId} from ${requestingAccountId}`,\n );\n\n const accountId = this.getClient().operatorAccountId?.toString();\n if (!accountId) {\n throw new Error('Failed to retrieve operator account ID');\n }\n\n let requesterKey = await this.mirrorNode.getPublicKey(requestingAccountId);\n const accountKey = await this.mirrorNode.getPublicKey(accountId);\n\n if (!accountKey) {\n throw new Error('Failed to retrieve public key');\n }\n\n const thresholdKey = new KeyList([accountKey, requesterKey], 1);\n\n let connectionTopicId: string;\n\n try {\n if (connectionFeeConfig) {\n const feeConfig = connectionFeeConfig.build();\n const modifiedFeeConfig = {\n ...feeConfig,\n exemptAccounts: [...(feeConfig.exemptAccounts || [])],\n };\n\n connectionTopicId = await this.createTopic(\n memo,\n thresholdKey,\n thresholdKey,\n modifiedFeeConfig,\n );\n } else {\n connectionTopicId = await this.createTopic(\n memo,\n thresholdKey,\n thresholdKey,\n );\n }\n\n this.logger.info(`Created new connection topic ID: ${connectionTopicId}`);\n } catch (error) {\n const logMessage = `Failed to create connection topic: ${error}`;\n this.logger.error(logMessage);\n throw new TopicCreationError(logMessage);\n }\n\n const operatorId = `${inboundTopicId}@${accountId}`;\n\n const confirmedConnectionSequenceNumber = await this.confirmConnection(\n inboundTopicId,\n connectionTopicId,\n requestingAccountId,\n connectionRequestId,\n 'Connection accepted. Looking forward to collaborating!',\n );\n\n const accountTopics = await this.retrieveCommunicationTopics(accountId);\n\n const requestingAccountTopics =\n await this.retrieveCommunicationTopics(requestingAccountId);\n\n const requestingAccountOperatorId = `${requestingAccountTopics.inboundTopic}@${requestingAccountId}`;\n\n await this.recordOutboundConnectionConfirmation({\n outboundTopicId: accountTopics.outboundTopic,\n requestorOutboundTopicId: requestingAccountTopics.outboundTopic,\n connectionRequestId: connectionRequestId,\n confirmedRequestId: confirmedConnectionSequenceNumber,\n connectionTopicId,\n operatorId: requestingAccountOperatorId,\n memo: `Connection established with ${requestingAccountId}`,\n });\n\n return {\n connectionTopicId,\n confirmedConnectionSequenceNumber,\n operatorId,\n };\n }\n\n /**\n * Confirms a connection request from another account\n * @param inboundTopicId Inbound topic ID\n * @param connectionTopicId Connection topic ID\n * @param connectedAccountId Connected account ID\n * @param connectionId Connection ID\n * @param memo Memo for the connection request\n * @param submitKey Optional submit key\n * @returns Sequence number of the confirmed connection\n */\n async confirmConnection(\n inboundTopicId: string,\n connectionTopicId: string,\n connectedAccountId: string,\n connectionId: number,\n memo: string,\n submitKey?: PrivateKey,\n ): Promise<number> {\n const operatorId = await this.getOperatorId();\n this.logger.info(`Confirming connection with ID ${connectionId}`);\n const payload = {\n p: 'hcs-10',\n op: 'connection_created',\n connection_topic_id: connectionTopicId,\n connected_account_id: connectedAccountId,\n operator_id: operatorId,\n connection_id: connectionId,\n m: memo,\n };\n\n const submissionCheck = await this.canSubmitToTopic(\n inboundTopicId,\n this.client.operatorAccountId?.toString() || '',\n );\n\n const result = await this.submitPayload(\n inboundTopicId,\n payload,\n submitKey,\n submissionCheck.requiresFee,\n );\n\n const sequenceNumber = result.topicSequenceNumber?.toNumber();\n\n if (!sequenceNumber) {\n throw new ConnectionConfirmationError(\n 'Failed to confirm connection: sequence number is null',\n );\n }\n\n return sequenceNumber;\n }\n\n async sendMessage(\n connectionTopicId: string,\n data: string,\n memo?: string,\n submitKey?: PrivateKey,\n options?: {\n progressCallback?: RegistrationProgressCallback;\n waitMaxAttempts?: number;\n waitIntervalMs?: number;\n },\n ): Promise<TransactionReceipt> {\n const submissionCheck = await this.canSubmitToTopic(\n connectionTopicId,\n this.client.operatorAccountId?.toString() || '',\n );\n\n const operatorId = await this.getOperatorId();\n\n const payload = {\n p: 'hcs-10',\n op: 'message',\n operator_id: operatorId,\n data,\n m: memo,\n };\n\n const payloadString = JSON.stringify(payload);\n const isLargePayload = Buffer.from(payloadString).length > 1000;\n\n if (isLargePayload) {\n this.logger.info(\n 'Message payload exceeds 1000 bytes, storing via inscription',\n );\n try {\n const contentBuffer = Buffer.from(data);\n const fileName = `message-${Date.now()}.json`;\n const inscriptionResult = await this.inscribeFile(\n contentBuffer,\n fileName,\n {\n progressCallback: options?.progressCallback,\n waitMaxAttempts: options?.waitMaxAttempts,\n waitIntervalMs: options?.waitIntervalMs,\n },\n );\n\n if (inscriptionResult?.topic_id) {\n payload.data = `hcs://1/${inscriptionResult.topic_id}`;\n this.logger.info(\n `Large message inscribed with topic ID: ${inscriptionResult.topic_id}`,\n );\n } else {\n throw new Error('Failed to inscribe large message content');\n }\n } catch (error: any) {\n const logMessage = `Error inscribing large message: ${error.message}`;\n this.logger.error(logMessage);\n throw new Error(logMessage);\n }\n }\n\n this.logger.info('Submitting message to connection topic', payload);\n return await this.submitPayload(\n connectionTopicId,\n payload,\n submitKey,\n submissionCheck.requiresFee,\n );\n }\n\n async createTopic(\n memo: string,\n adminKey?: boolean | PublicKey | KeyList,\n submitKey?: boolean | PublicKey | KeyList,\n feeConfig?: TopicFeeConfig,\n ): Promise<string> {\n this.logger.info('Creating topic');\n const transaction = new TopicCreateTransaction().setTopicMemo(memo);\n\n if (adminKey) {\n if (\n typeof adminKey === 'boolean' &&\n adminKey &&\n this.client.operatorPublicKey\n ) {\n transaction.setAdminKey(this.client.operatorPublicKey);\n transaction.setAutoRenewAccountId(this.client.operatorAccountId!);\n } else if (adminKey instanceof PublicKey || adminKey instanceof KeyList) {\n transaction.setAdminKey(adminKey);\n if (this.client.operatorAccountId) {\n transaction.setAutoRenewAccountId(this.client.operatorAccountId);\n }\n }\n }\n\n if (submitKey) {\n if (\n typeof submitKey === 'boolean' &&\n submitKey &&\n this.client.operatorPublicKey\n ) {\n transaction.setSubmitKey(this.client.operatorPublicKey);\n } else if (\n submitKey instanceof PublicKey ||\n submitKey instanceof KeyList\n ) {\n transaction.setSubmitKey(submitKey);\n }\n }\n\n if (feeConfig) {\n await this.setupFees(transaction, feeConfig);\n }\n\n this.logger.debug('Executing topic creation transaction');\n const txResponse = await transaction.execute(this.client);\n const receipt = await txResponse.getReceipt(this.client);\n\n if (!receipt.topicId) {\n this.logger.error('Failed to create topic: topicId is null');\n throw new Error('Failed to create topic: topicId is null');\n }\n\n const topicId = receipt.topicId.toString();\n return topicId;\n }\n\n public async submitPayload(\n topicId: string,\n payload: object | string,\n submitKey?: PrivateKey,\n requiresFee: boolean = false,\n ): Promise<TransactionReceipt> {\n const message =\n typeof payload === 'string' ? payload : JSON.stringify(payload);\n\n const payloadSizeInBytes = Buffer.byteLength(message, 'utf8');\n if (payloadSizeInBytes > 1000) {\n throw new PayloadSizeError(\n 'Payload size exceeds 1000 bytes limit',\n payloadSizeInBytes,\n );\n }\n\n const transaction = new TopicMessageSubmitTransaction()\n .setTopicId(TopicId.fromString(topicId))\n .setMessage(message);\n\n if (requiresFee) {\n this.logger.info(\n 'Topic requires fee payment, setting max transaction fee',\n );\n transaction.setMaxTransactionFee(new Hbar(this.feeAmount));\n }\n\n let transactionResponse: TransactionResponse;\n if (submitKey) {\n const frozenTransaction = transaction.freezeWith(this.client);\n const signedTransaction = await frozenTransaction.sign(submitKey);\n transactionResponse = await signedTransaction.execute(this.client);\n } else {\n transactionResponse = await transaction.execute(this.client);\n }\n\n const receipt = await transactionResponse.getReceipt(this.client);\n if (!receipt) {\n this.logger.error('Failed to submit message: receipt is null');\n throw new Error('Failed to submit message: receipt is null');\n }\n this.logger.info('Message submitted successfully');\n return receipt;\n }\n\n async inscribeFile(\n buffer: Buffer,\n fileName: string,\n options?: {\n progressCallback?: RegistrationProgressCallback;\n waitMaxAttempts?: number;\n waitIntervalMs?: number;\n },\n ): Promise<RetrievedInscriptionResult> {\n this.logger.info('Inscribing file');\n if (!this.client.operatorAccountId) {\n this.logger.error('Operator account ID is not set');\n throw new Error('Operator account ID is not set');\n }\n\n if (!this.operatorPrivateKey) {\n this.logger.error('Operator private key is not set');\n throw new Error('Operator private key is not set');\n }\n\n const mimeType = mime.lookup(fileName) || 'application/octet-stream';\n\n const sdk = await InscriptionSDK.createWithAuth({\n type: 'server',\n accountId: this.client.operatorAccountId.toString(),\n privateKey: this.operatorPrivateKey.toString(),\n network: this.network as 'testnet' | 'mainnet',\n });\n\n const inscriptionOptions = {\n mode: 'file' as const,\n waitForConfirmation: true,\n waitMaxAttempts: options?.waitMaxAttempts || 30,\n waitIntervalMs: options?.waitIntervalMs || 4000,\n progressCallback: options?.progressCallback,\n logging: {\n level: this.logger.getLevel ? this.logger.getLevel() : 'info',\n },\n };\n\n const response = await inscribe(\n {\n type: 'buffer',\n buffer,\n fileName,\n mimeType,\n },\n {\n accountId: this.client.operatorAccountId.toString(),\n privateKey: this.operatorPrivateKey.toString(),\n network: this.network as 'testnet' | 'mainnet',\n },\n inscriptionOptions,\n sdk,\n );\n\n if (!response.confirmed || !response.inscription) {\n throw new Error('Inscription was not confirmed');\n }\n\n return response.inscription;\n }\n\n /**\n * Waits for confirmation of a connection request\n * @param inboundTopicId Inbound topic ID\n * @param connectionRequestId Connection request ID\n * @param maxAttempts Maximum number of attempts\n * @param delayMs Delay between attempts in milliseconds\n * @returns Connection confirmation details\n */\n async waitForConnectionConfirmation(\n inboundTopicId: string,\n connectionRequestId: number,\n maxAttempts = 60,\n delayMs = 2000,\n recordConfirmation = true,\n ): Promise<WaitForConnectionConfirmationResponse> {\n this.logger.info(\n `Waiting for connection confirmation on inbound topic ${inboundTopicId} for request ID ${connectionRequestId}`,\n );\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n this.logger.info(\n `Attempt ${attempt + 1}/${maxAttempts} to find connection confirmation`,\n );\n const messages = await this.mirrorNode.getTopicMessages(inboundTopicId);\n\n const connectionCreatedMessages = messages.filter(\n m => m.op === 'connection_created',\n );\n\n this.logger.info(\n `Found ${connectionCreatedMessages.length} connection_created messages`,\n );\n\n if (connectionCreatedMessages.length > 0) {\n for (const message of connectionCreatedMessages) {\n if (Number(message.connection_id) === Number(connectionRequestId)) {\n const confirmationResult = {\n connectionTopicId: message.connection_topic_id,\n sequence_number: Number(message.sequence_number),\n confirmedBy: message.operator_id,\n memo: message.m,\n };\n\n const confirmedByAccountId = this.extractAccountFromOperatorId(\n confirmationResult.confirmedBy,\n );\n\n const account = this.getAccountAndSigner();\n const confirmedByConnectionTopics =\n await this.retrieveCommunicationTopics(confirmedByAccountId);\n\n const agentConnectionTopics =\n await this.retrieveCommunicationTopics(account.accountId);\n\n this.logger.info(\n 'Connection confirmation found',\n confirmationResult,\n );\n\n if (recordConfirmation) {\n /**\n * Record's the confirmation of the connection request from the\n * confirmedBy account to the agent account.\n */\n await this.recordOutboundConnectionConfirmation({\n requestorOutboundTopicId:\n confirmedByConnectionTopics.outboundTopic,\n outboundTopicId: agentConnectionTopics.outboundTopic,\n connectionRequestId,\n confirmedRequestId: confirmationResult.sequence_number,\n connectionTopicId: confirmationResult.connectionTopicId,\n operatorId: confirmationResult.confirmedBy,\n memo: confirmationResult.memo || 'Connection confirmed',\n });\n }\n\n return confirmationResult;\n }\n }\n }\n\n if (attempt < maxAttempts - 1) {\n this.logger.info(\n `No matching confirmation found, waiting ${delayMs}ms before retrying...`,\n );\n await new Promise(resolve => setTimeout(resolve, delayMs));\n }\n }\n\n throw new Error(\n `Connection confirmation not found after ${maxAttempts} attempts for request ID ${connectionRequestId}`,\n );\n }\n\n getAccountAndSigner(): GetAccountAndSignerResponse {\n const PK =\n this.keyType === 'ecdsa'\n ? PrivateKey.fromStringECDSA(this.operatorPrivateKey)\n : PrivateKey.fromStringED25519(this.operatorPrivateKey);\n\n return {\n accountId: this.client.operatorAccountId!.toString()!,\n signer: PK,\n };\n }\n\n /**\n * Creates and registers an agent with a Guarded registry.\n *\n * This function performs the following steps:\n * 1. Creates a new account if no existing account is provided.\n * 2. Initializes an HCS10 client with the new account.\n * 3. Creates an agent on the client.\n * 4. Registers the agent with the Hashgraph Online Guarded Registry.\n *\n * @param builder The agent builder object\n * @param options Optional configuration including progress callback and state management\n * @returns Agent registration result\n */\n async createAndRegisterAgent(\n builder: AgentBuilder,\n options?: {\n baseUrl?: string;\n progressCallback?: RegistrationProgressCallback;\n existingState?: AgentCreationState;\n initialBalance?: number;\n },\n ): Promise<AgentRegistrationResult> {\n try {\n const config = builder.build();\n const progressCallback = options?.progressCallback;\n const baseUrl = options?.baseUrl || this.guardedRegistryBaseUrl;\n\n let state =\n options?.existingState ||\n ({\n currentStage: 'init',\n completedPercentage: 0,\n createdResources: [],\n } as AgentCreationState);\n\n state.agentMetadata = config.metadata;\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Starting agent creation process',\n progressPercent: 0,\n details: { state },\n });\n }\n\n let account = config.existingAccount;\n let agentClient: HCS10Client;\n\n if (\n !state.inboundTopicId ||\n !state.outboundTopicId ||\n !state.profileTopicId\n ) {\n if (!account) {\n if (\n state.createdResources &&\n state.createdResources.some(r => r.startsWith('account:'))\n ) {\n const accountResource = state.createdResources.find(r =>\n r.startsWith('account:'),\n );\n const existingAccountId = accountResource?.split(':')[1];\n\n if (existingAccountId && config.existingAccount) {\n account = config.existingAccount;\n this.logger.info(\n `Resuming with existing account: ${existingAccountId}`,\n );\n } else {\n account = await this.createAccount(options?.initialBalance);\n state.createdResources = state.createdResources || [];\n state.createdResources.push(`account:${account.accountId}`);\n }\n } else {\n account = await this.createAccount(options?.initialBalance);\n state.createdResources = state.createdResources || [];\n state.createdResources.push(`account:${account.accountId}`);\n }\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Created account or using existing account',\n progressPercent: 20,\n details: { state, account },\n });\n }\n\n const keyType = detectKeyTypeFromString(account.privateKey);\n\n const privateKey =\n keyType.detectedType === 'ed25519'\n ? PrivateKey.fromStringED25519(account.privateKey)\n : PrivateKey.fromStringECDSA(account.privateKey);\n\n const publicKey = privateKey.publicKey.toString();\n\n agentClient = new HCS10Client({\n network: config.network,\n operatorId: account.accountId,\n operatorPrivateKey: account.privateKey,\n operatorPublicKey: publicKey,\n keyType: keyType.detectedType as 'ed25519' | 'ecdsa',\n logLevel: 'info' as LogLevel,\n guardedRegistryBaseUrl: baseUrl,\n });\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Initialized agent client',\n progressPercent: 25,\n details: { state },\n });\n }\n\n let outboundTopicId = state.outboundTopicId;\n let inboundTopicId = state.inboundTopicId;\n let pfpTopicId = state.pfpTopicId;\n let profileTopicId = state.profileTopicId;\n\n if (!outboundTopicId || !inboundTopicId || !profileTopicId) {\n if (pfpTopicId) {\n builder.setExistingProfilePicture(pfpTopicId);\n }\n\n const createResult = await agentClient.createAgent(\n builder,\n 60,\n state,\n data => {\n if (progressCallback) {\n progressCallback({\n stage: data.stage,\n message: data.message,\n progressPercent: data.progressPercent || 0,\n details: {\n ...data.details,\n state: {\n ...state,\n ...data.details?.state,\n },\n },\n });\n }\n },\n );\n\n outboundTopicId = createResult.outboundTopicId;\n inboundTopicId = createResult.inboundTopicId;\n pfpTopicId = createResult.pfpTopicId;\n profileTopicId = createResult.profileTopicId;\n\n state.outboundTopicId = outboundTopicId;\n state.inboundTopicId = inboundTopicId;\n state.pfpTopicId = pfpTopicId;\n state.profileTopicId = profileTopicId;\n\n if (!state.createdResources) {\n state.createdResources = [];\n }\n\n if (\n pfpTopicId &&\n !state.createdResources.includes(`pfp:${pfpTopicId}`)\n ) {\n state.createdResources.push(`pfp:${pfpTopicId}`);\n }\n if (!state.createdResources.includes(`inbound:${inboundTopicId}`)) {\n state.createdResources.push(`inbound:${inboundTopicId}`);\n }\n if (!state.createdResources.includes(`outbound:${outboundTopicId}`)) {\n state.createdResources.push(`outbound:${outboundTopicId}`);\n }\n if (!state.createdResources.includes(`profile:${profileTopicId}`)) {\n state.createdResources.push(`profile:${profileTopicId}`);\n }\n }\n\n state.currentStage = 'profile';\n state.completedPercentage = 60;\n\n if (progressCallback) {\n progressCallback({\n stage: 'submitting',\n message: 'Created agent with topics and profile',\n progressPercent: 60,\n details: {\n state,\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n },\n });\n }\n } else {\n account = account || config.existingAccount;\n if (!account) {\n throw new Error(\n 'Cannot resume registration without account information',\n );\n }\n\n agentClient = new HCS10Client({\n network: config.network,\n operatorId: account.accountId,\n operatorPrivateKey: account.privateKey,\n operatorPublicKey: PrivateKey.fromString(\n account.privateKey,\n ).publicKey.toString(),\n logLevel: 'info' as LogLevel,\n guardedRegistryBaseUrl: baseUrl,\n });\n\n this.logger.info('Resuming registration with existing state', {\n inboundTopicId: state.inboundTopicId,\n outboundTopicId: state.outboundTopicId,\n profileTopicId: state.profileTopicId,\n pfpTopicId: state.pfpTopicId,\n });\n }\n\n const operatorId = `${state.inboundTopicId}@${account.accountId}`;\n\n if (\n state.currentStage !== 'complete' ||\n !state.createdResources?.includes(\n `registration:${state.inboundTopicId}`,\n )\n ) {\n const registrationResult =\n await agentClient.registerAgentWithGuardedRegistry(\n account.accountId,\n config.network,\n {\n progressCallback: data => {\n const adjustedPercent = 60 + (data.progressPercent || 0) * 0.4;\n if (progressCallback) {\n progressCallback({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: {\n ...data.details,\n outboundTopicId: state.outboundTopicId,\n inboundTopicId: state.inboundTopicId,\n pfpTopicId: state.pfpTopicId,\n profileTopicId: state.profileTopicId,\n operatorId,\n state: data.details?.state || state,\n },\n });\n }\n },\n existingState: state,\n },\n );\n\n if (!registrationResult.success) {\n return {\n ...registrationResult,\n state,\n };\n }\n\n state = registrationResult.state || state;\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'completed',\n message: 'Agent creation and registration complete',\n progressPercent: 100,\n details: {\n outboundTopicId: state.outboundTopicId,\n inboundTopicId: state.inboundTopicId,\n pfpTopicId: state.pfpTopicId,\n profileTopicId: state.profileTopicId,\n operatorId,\n state,\n },\n });\n }\n\n return {\n success: true,\n state,\n metadata: {\n accountId: account.accountId,\n privateKey: account.privateKey,\n operatorId,\n inboundTopicId: state.inboundTopicId!,\n outboundTopicId: state.outboundTopicId!,\n profileTopicId: state.profileTopicId!,\n pfpTopicId: state.pfpTopicId!,\n },\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to create and register agent: ${error.message}`;\n this.logger.error(logMessage);\n return {\n error: error.message,\n success: false,\n state:\n options?.existingState ||\n ({\n currentStage: 'init',\n completedPercentage: 0,\n error: error.message,\n } as AgentCreationState),\n };\n }\n }\n\n /**\n * Registers an agent with the guarded registry\n * @param accountId Account ID to register\n * @param inboundTopicId Inbound topic ID for the agent\n * @param network Network type ('mainnet' or 'testnet')\n * @param options Optional configuration including progress callback and confirmation settings\n * @returns Registration result\n */\n async registerAgentWithGuardedRegistry(\n accountId: string,\n network: string = this.network,\n options?: {\n progressCallback?: RegistrationProgressCallback;\n maxAttempts?: number;\n delayMs?: number;\n existingState?: AgentCreationState;\n },\n ): Promise<AgentRegistrationResult> {\n try {\n this.logger.info('Registering agent with guarded registry');\n\n const maxAttempts = options?.maxAttempts ?? 60;\n const delayMs = options?.delayMs ?? 2000;\n const progressCallback = options?.progressCallback;\n let state =\n options?.existingState ||\n ({\n currentStage: 'registration',\n completedPercentage: 0,\n createdResources: [],\n } as AgentCreationState);\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Preparing agent registration',\n progressPercent: 10,\n details: {\n state,\n },\n });\n }\n\n const registrationResult = await this.executeRegistration(\n accountId,\n network,\n this.guardedRegistryBaseUrl,\n this.logger,\n );\n\n if (!registrationResult.success) {\n return {\n ...registrationResult,\n state,\n };\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'submitting',\n message: 'Submitting registration to registry',\n progressPercent: 30,\n details: {\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n if (registrationResult.transaction) {\n const transaction = Transaction.fromBytes(\n Buffer.from(registrationResult.transaction, 'base64'),\n );\n\n this.logger.info(`Processing registration transaction`);\n await transaction.execute(this.client);\n this.logger.info(`Successfully processed registration transaction`);\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'confirming',\n message: 'Confirming registration transaction',\n progressPercent: 60,\n details: {\n accountId,\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n const confirmed = await this.waitForRegistrationConfirmation(\n registrationResult.transactionId!,\n network,\n this.guardedRegistryBaseUrl,\n maxAttempts,\n delayMs,\n this.logger,\n );\n\n state.currentStage = 'complete';\n state.completedPercentage = 100;\n if (!state.createdResources) {\n state.createdResources = [];\n }\n if (registrationResult.transactionId) {\n state.createdResources.push(\n `registration:${registrationResult.transactionId}`,\n );\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'completed',\n message: 'Agent registration complete',\n progressPercent: 100,\n details: {\n confirmed,\n transactionId: registrationResult.transactionId,\n state,\n },\n });\n }\n\n return {\n ...registrationResult,\n confirmed,\n state,\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to register agent: ${error.message}`;\n this.logger.error(logMessage);\n return {\n error: error.message,\n success: false,\n };\n }\n }\n\n /**\n * Registers an agent with the guarded registry. Should be called by a registry.\n * @param registryTopicId - The topic ID of the guarded registry.\n * @param accountId - The account ID of the agent\n * @param inboundTopicId - The topic ID of the inbound topic\n * @param memo - The memo of the agent\n * @param submitKey - The submit key of the agent\n */\n async registerAgent(\n registryTopicId: string,\n accountId: string,\n inboundTopicId: string,\n memo: string,\n submitKey?: PrivateKey,\n ): Promise<void> {\n this.logger.info('Registering agent');\n const payload = {\n p: 'hcs-10',\n op: 'register',\n account_id: accountId,\n inbound_topic_id: inboundTopicId,\n m: memo,\n };\n\n await this.submitPayload(registryTopicId, payload, submitKey);\n }\n\n async getInboundTopicType(topicId: string): Promise<InboundTopicType> {\n try {\n const topicInfo = await this.mirrorNode.getTopicInfo(topicId);\n\n if (!topicInfo) {\n throw new Error('Topic does not exist');\n }\n\n const hasSubmitKey = topicInfo.submit_key && topicInfo.submit_key.key;\n\n if (!hasSubmitKey) {\n return InboundTopicType.PUBLIC;\n }\n\n const hasFeeScheduleKey =\n topicInfo.fee_schedule_key && topicInfo.fee_schedule_key.key;\n\n if (hasFeeScheduleKey && topicInfo.custom_fees) {\n const customFees = topicInfo.custom_fees;\n\n if (\n customFees &&\n customFees.fixed_fees &&\n customFees.fixed_fees.length > 0\n ) {\n this.logger.info(\n `Topic ${topicId} is fee-based with ${customFees.fixed_fees.length} custom fees`,\n );\n return InboundTopicType.FEE_BASED;\n }\n }\n\n return InboundTopicType.CONTROLLED;\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Error determining topic type: ${error.message}`;\n this.logger.error(logMessage);\n throw new Error(logMessage);\n }\n }\n\n getNetwork(): string {\n return this.network;\n }\n\n getLogger(): Logger {\n return this.logger;\n }\n\n /**\n * Public method to get the operator account ID configured for this client instance.\n * @returns The operator account ID string, or null if not set.\n */\n getOperatorAccountId(): string | null {\n return this.client.operatorAccountId?.toString() ?? null;\n }\n\n /**\n * Creates a scheduled transaction from a transaction object\n * @param transaction The transaction to schedule\n * @param memo Optional memo to include with the scheduled transaction\n * @param expirationTime Optional expiration time in seconds from now\n * @returns Object with schedule ID and transaction ID\n */\n private async createScheduledTransaction(\n transaction: Transaction,\n memo?: string,\n expirationTime?: number,\n schedulePayerAccountId?: string,\n ): Promise<{\n scheduleId: string;\n transactionId: string;\n }> {\n this.logger.info('Creating scheduled transaction');\n\n const scheduleTransaction = new ScheduleCreateTransaction()\n .setScheduledTransaction(transaction)\n .setPayerAccountId(\n schedulePayerAccountId\n ? AccountId.fromString(schedulePayerAccountId)\n : this.client.operatorAccountId,\n );\n\n if (memo) {\n scheduleTransaction.setScheduleMemo(memo);\n }\n\n if (expirationTime) {\n const expirationDate = addSeconds(new Date(), expirationTime);\n const timestamp = Timestamp.fromDate(expirationDate);\n scheduleTransaction.setExpirationTime(timestamp);\n }\n\n this.logger.debug('Executing schedule create transaction');\n const scheduleResponse = await scheduleTransaction.execute(this.client);\n const scheduleReceipt = await scheduleResponse.getReceipt(this.client);\n\n if (!scheduleReceipt.scheduleId) {\n this.logger.error(\n 'Failed to create scheduled transaction: scheduleId is null',\n );\n throw new Error(\n 'Failed to create scheduled transaction: scheduleId is null',\n );\n }\n\n const scheduleId = scheduleReceipt.scheduleId.toString();\n const transactionId = scheduleResponse.transactionId.toString();\n\n this.logger.info(\n `Scheduled transaction created successfully: ${scheduleId}`,\n );\n\n return {\n scheduleId,\n transactionId,\n };\n }\n\n /**\n * Sends a transaction operation on a connection topic\n * @param connectionTopicId Connection topic ID\n * @param scheduleId Schedule ID of the scheduled transaction\n * @param data Human-readable description of the transaction, can also be a JSON string or HRL\n * @param submitKey Optional submit key\n * @param options Optional parameters including memo (timestamp is no longer used here)\n * @returns Transaction receipt\n */\n private async sendTransactionOperation(\n connectionTopicId: string,\n scheduleId: string,\n data: string,\n submitKey?: PrivateKey,\n options?: {\n memo?: string;\n },\n ): Promise<TransactionReceipt> {\n const submissionCheck = await this.canSubmitToTopic(\n connectionTopicId,\n this.client.operatorAccountId?.toString() || '',\n );\n\n const operatorId = await this.getOperatorId();\n\n const payload = {\n p: 'hcs-10',\n op: 'transaction',\n operator_id: operatorId,\n schedule_id: scheduleId,\n data,\n m: options?.memo,\n };\n\n this.logger.info(\n 'Submitting transaction operation to connection topic',\n payload,\n );\n return await this.submitPayload(\n connectionTopicId,\n payload,\n submitKey,\n submissionCheck.requiresFee,\n );\n }\n\n /**\n * Creates and sends a transaction operation in one call\n * @param connectionTopicId Connection topic ID for sending the transaction operation\n * @param transaction The transaction to schedule\n * @param data Human-readable description of the transaction, can also be a JSON string or HRL\n * @param options Optional parameters for schedule creation and operation memo\n * @returns Object with schedule details (including scheduleId and its transactionId) and HCS-10 operation receipt\n */\n async sendTransaction(\n connectionTopicId: string,\n transaction: Transaction,\n data: string,\n options?: {\n scheduleMemo?: string;\n expirationTime?: number;\n submitKey?: PrivateKey;\n operationMemo?: string;\n schedulePayerAccountId?: string;\n },\n ): Promise<{\n scheduleId: string;\n transactionId: string;\n receipt: TransactionReceipt;\n }> {\n this.logger.info(\n 'Creating scheduled transaction and sending transaction operation',\n );\n\n const { scheduleId, transactionId } = await this.createScheduledTransaction(\n transaction,\n options?.scheduleMemo,\n options?.expirationTime,\n options?.schedulePayerAccountId,\n );\n\n const receipt = await this.sendTransactionOperation(\n connectionTopicId,\n scheduleId,\n data,\n options?.submitKey,\n {\n memo: options?.operationMemo,\n },\n );\n\n return {\n scheduleId,\n transactionId,\n receipt,\n };\n }\n\n /**\n * Creates a new MCP server with inbound and outbound topics.\n *\n * This method creates communication topics and profiles required for an MCP server,\n * registers the profile with the server's account, and handles profile picture\n * inscriptions if provided.\n *\n * @param builder The MCP server builder object\n * @param ttl Optional Time-To-Live for the topic memos, defaults to 60\n * @param existingState Optional existing state to resume from\n * @returns Object with topic IDs\n */\n async createMCPServer(\n builder: MCPServerBuilder,\n ttl: number = 60,\n existingState?: Partial<MCPServerCreationState>,\n progressCallback?: RegistrationProgressCallback,\n ): Promise<CreateMCPServerResponse> {\n if (!this.keyType) {\n await this.initializeOperator();\n }\n\n const config = builder.build();\n const accountId = this.client.operatorAccountId?.toString();\n if (!accountId) {\n throw new Error('Failed to retrieve operator account ID');\n }\n\n const result = await this._createEntityTopics(\n ttl,\n {\n outboundTopicId: existingState?.outboundTopicId || '',\n inboundTopicId: existingState?.inboundTopicId || '',\n pfpTopicId:\n existingState?.pfpTopicId || config.existingPfpTopicId || '',\n profileTopicId: existingState?.profileTopicId || '',\n },\n accountId,\n InboundTopicType.PUBLIC,\n undefined,\n config.pfpBuffer,\n config.pfpFileName,\n progressCallback,\n );\n\n if (!result.profileTopicId) {\n this.logger.info('Creating and storing HCS-11 MCP server profile');\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Creating MCP server profile',\n progressPercent: 60,\n details: {\n outboundTopicId: result.outboundTopicId,\n inboundTopicId: result.inboundTopicId,\n pfpTopicId: result.pfpTopicId,\n state: {\n currentStage: 'profile',\n completedPercentage: 60,\n },\n },\n });\n }\n\n await this.hcs11Client.initializeOperator();\n const profile = this.hcs11Client.createMCPServerProfile(\n config.name,\n config.mcpServer,\n {\n alias: config.alias,\n bio: config.bio,\n socials: config.socials || [],\n inboundTopicId: result.inboundTopicId,\n outboundTopicId: result.outboundTopicId,\n profileImage: result.pfpTopicId\n ? `hcs://1/${result.pfpTopicId}`\n : undefined,\n },\n );\n\n const profileResult = await this.hcs11Client.inscribeProfile(profile);\n\n if (!profileResult.success) {\n this.logger.error(\n `Failed to inscribe MCP server profile: ${profileResult.error}`,\n );\n throw new Error(\n profileResult.error || 'Failed to inscribe MCP server profile',\n );\n }\n\n result.profileTopicId = profileResult.profileTopicId;\n this.logger.info(\n `MCP server profile stored with topic ID: ${result.profileTopicId}`,\n );\n\n const memoResult = await this.hcs11Client.updateAccountMemoWithProfile(\n accountId,\n result.profileTopicId,\n );\n\n if (!memoResult.success) {\n this.logger.warn(\n `Failed to update account memo: ${memoResult.error}, but continuing with MCP server creation`,\n );\n } else {\n this.logger.info(`Updated account memo with profile reference`);\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'MCP server profile created',\n progressPercent: 70,\n details: {\n outboundTopicId: result.outboundTopicId,\n inboundTopicId: result.inboundTopicId,\n pfpTopicId: result.pfpTopicId,\n profileTopicId: result.profileTopicId,\n state: {\n currentStage: 'profile',\n completedPercentage: 70,\n },\n },\n });\n }\n } else {\n this.logger.info(\n `Using existing profile topic ID: ${result.profileTopicId}`,\n );\n }\n\n return result;\n }\n\n /**\n * Creates the base topic structure for an entity (agent or MCP server).\n *\n * @param ttl Time-To-Live for topic memos\n * @param existingTopics Object containing any existing topic IDs to reuse\n * @param accountId The account ID associated with the entity\n * @param inboundTopicType Type of inbound topic\n * @param feeConfig Optional fee configuration for fee-based topics\n * @param pfpBuffer Optional profile picture buffer\n * @param pfpFileName Optional profile picture filename\n * @param progressCallback Optional callback for reporting progress\n * @returns Object with created topic IDs\n */\n private async _createEntityTopics(\n ttl: number,\n existingTopics: {\n outboundTopicId: string;\n inboundTopicId: string;\n pfpTopicId: string;\n profileTopicId: string;\n },\n accountId: string,\n inboundTopicType: InboundTopicType,\n feeConfig?: FeeConfigBuilderInterface,\n pfpBuffer?: Buffer,\n pfpFileName?: string,\n progressCallback?: RegistrationProgressCallback,\n ): Promise<CreateAgentResponse> {\n let { outboundTopicId, inboundTopicId, pfpTopicId, profileTopicId } =\n existingTopics;\n\n if (!outboundTopicId) {\n const outboundMemo = this._generateHcs10Memo(Hcs10MemoType.OUTBOUND, {\n ttl,\n });\n outboundTopicId = await this.createTopic(outboundMemo, true, true);\n this.logger.info(`Created new outbound topic ID: ${outboundTopicId}`);\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Created outbound topic',\n progressPercent: 30,\n details: {\n outboundTopicId,\n state: {\n currentStage: 'topics',\n completedPercentage: 30,\n },\n },\n });\n }\n } else {\n this.logger.info(`Using existing outbound topic ID: ${outboundTopicId}`);\n }\n\n if (!inboundTopicId) {\n inboundTopicId = await this.createInboundTopic(\n accountId,\n inboundTopicType,\n ttl,\n inboundTopicType === InboundTopicType.FEE_BASED ? feeConfig : undefined,\n );\n this.logger.info(`Created new inbound topic ID: ${inboundTopicId}`);\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Created inbound topic',\n progressPercent: 40,\n details: {\n outboundTopicId,\n inboundTopicId,\n state: {\n currentStage: 'topics',\n completedPercentage: 40,\n },\n },\n });\n }\n } else {\n this.logger.info(`Using existing inbound topic ID: ${inboundTopicId}`);\n }\n\n if (!pfpTopicId && pfpBuffer && pfpBuffer.length > 0 && pfpFileName) {\n this.logger.info('Inscribing new profile picture');\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Inscribing profile picture',\n progressPercent: 50,\n details: {\n outboundTopicId,\n inboundTopicId,\n state: {\n currentStage: 'pfp',\n completedPercentage: 50,\n },\n },\n });\n }\n\n const pfpResult = await this.inscribePfp(pfpBuffer, pfpFileName);\n pfpTopicId = pfpResult.pfpTopicId;\n this.logger.info(\n `Profile picture inscribed with topic ID: ${pfpTopicId}`,\n );\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Profile picture inscribed',\n progressPercent: 55,\n details: {\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n state: {\n currentStage: 'pfp',\n completedPercentage: 55,\n },\n },\n });\n }\n } else if (pfpTopicId) {\n this.logger.info(\n `Using existing profile picture with topic ID: ${pfpTopicId}`,\n );\n }\n\n return {\n inboundTopicId,\n outboundTopicId,\n pfpTopicId,\n profileTopicId,\n };\n }\n\n /**\n * Creates and registers an MCP server with a Guarded registry.\n *\n * This function creates a new account if needed, initializes an HCS10 client,\n * creates an MCP server with inbound and outbound topics, and registers\n * it with the Hashgraph Online Guarded Registry.\n *\n * @param builder The MCP server builder object with configuration\n * @param options Optional settings for registration process\n * @returns Registration result with success status and metadata\n */\n async createAndRegisterMCPServer(\n builder: MCPServerBuilder,\n options?: {\n baseUrl?: string;\n progressCallback?: RegistrationProgressCallback;\n existingState?: MCPServerCreationState;\n initialBalance?: number;\n },\n ): Promise<AgentRegistrationResult> {\n try {\n const config = builder.build();\n const progressCallback = options?.progressCallback;\n const baseUrl = options?.baseUrl || this.guardedRegistryBaseUrl;\n\n let state =\n options?.existingState ||\n ({\n currentStage: 'init',\n completedPercentage: 0,\n createdResources: [],\n } as MCPServerCreationState);\n\n state.serverMetadata = {\n name: config.name,\n description: config.mcpServer.description,\n services: config.mcpServer.services,\n };\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Starting MCP server creation process',\n progressPercent: 0,\n details: { state },\n });\n }\n\n let account = config.existingAccount;\n let serverClient: HCS10Client;\n\n if (\n !state.inboundTopicId ||\n !state.outboundTopicId ||\n !state.profileTopicId\n ) {\n if (!account) {\n if (\n state.createdResources &&\n state.createdResources.some(r => r.startsWith('account:'))\n ) {\n const accountResource = state.createdResources.find(r =>\n r.startsWith('account:'),\n );\n const existingAccountId = accountResource?.split(':')[1];\n\n if (existingAccountId && config.existingAccount) {\n account = config.existingAccount;\n this.logger.info(\n `Resuming with existing account: ${existingAccountId}`,\n );\n } else {\n account = await this.createAccount(options?.initialBalance);\n state.createdResources = state.createdResources || [];\n state.createdResources.push(`account:${account.accountId}`);\n }\n } else {\n account = await this.createAccount(options?.initialBalance);\n state.createdResources = state.createdResources || [];\n state.createdResources.push(`account:${account.accountId}`);\n }\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Created account or using existing account',\n progressPercent: 20,\n details: { state, account },\n });\n }\n const keyType = detectKeyTypeFromString(account.privateKey);\n\n builder.setExistingAccount(account.accountId, account.privateKey);\n\n const privateKey =\n keyType.detectedType === 'ed25519'\n ? PrivateKey.fromStringED25519(account.privateKey)\n : PrivateKey.fromStringECDSA(account.privateKey);\n\n const publicKey = privateKey.publicKey.toString();\n\n serverClient = new HCS10Client({\n network: config.network,\n operatorId: account.accountId,\n operatorPrivateKey: account.privateKey,\n operatorPublicKey: publicKey,\n logLevel: 'info' as LogLevel,\n guardedRegistryBaseUrl: baseUrl,\n });\n\n if (progressCallback) {\n progressCallback({\n stage: 'preparing',\n message: 'Initialized MCP server client',\n progressPercent: 25,\n details: { state },\n });\n }\n\n let outboundTopicId = state.outboundTopicId;\n let inboundTopicId = state.inboundTopicId;\n let pfpTopicId = state.pfpTopicId;\n let profileTopicId = state.profileTopicId;\n\n if (!outboundTopicId || !inboundTopicId || !profileTopicId) {\n if (pfpTopicId) {\n builder.setExistingProfilePicture(pfpTopicId);\n }\n\n const createResult = await serverClient.createMCPServer(\n builder,\n 60,\n state,\n data => {\n if (progressCallback) {\n progressCallback({\n stage: data.stage,\n message: data.message,\n progressPercent: data.progressPercent || 0,\n details: {\n ...data.details,\n state: {\n ...state,\n ...data.details?.state,\n },\n },\n });\n }\n },\n );\n\n outboundTopicId = createResult.outboundTopicId;\n inboundTopicId = createResult.inboundTopicId;\n pfpTopicId = createResult.pfpTopicId;\n profileTopicId = createResult.profileTopicId;\n\n state.outboundTopicId = outboundTopicId;\n state.inboundTopicId = inboundTopicId;\n state.pfpTopicId = pfpTopicId;\n state.profileTopicId = profileTopicId;\n\n if (!state.createdResources) {\n state.createdResources = [];\n }\n\n if (\n pfpTopicId &&\n !state.createdResources.includes(`pfp:${pfpTopicId}`)\n ) {\n state.createdResources.push(`pfp:${pfpTopicId}`);\n }\n if (!state.createdResources.includes(`inbound:${inboundTopicId}`)) {\n state.createdResources.push(`inbound:${inboundTopicId}`);\n }\n if (!state.createdResources.includes(`outbound:${outboundTopicId}`)) {\n state.createdResources.push(`outbound:${outboundTopicId}`);\n }\n if (!state.createdResources.includes(`profile:${profileTopicId}`)) {\n state.createdResources.push(`profile:${profileTopicId}`);\n }\n }\n\n state.currentStage = 'profile';\n state.completedPercentage = 60;\n\n if (progressCallback) {\n progressCallback({\n stage: 'submitting',\n message: 'Created MCP server with topics and profile',\n progressPercent: 60,\n details: {\n state,\n outboundTopicId,\n inboundTopicId,\n pfpTopicId,\n profileTopicId,\n },\n });\n }\n } else {\n account = account || config.existingAccount;\n if (!account) {\n throw new Error(\n 'Cannot resume registration without account information',\n );\n }\n\n const keyType = detectKeyTypeFromString(account.privateKey);\n\n const privateKey =\n keyType.detectedType === 'ed25519'\n ? PrivateKey.fromStringED25519(account.privateKey)\n : PrivateKey.fromStringECDSA(account.privateKey);\n\n const publicKey = privateKey.publicKey.toString();\n\n serverClient = new HCS10Client({\n network: config.network,\n operatorId: account.accountId,\n operatorPrivateKey: account.privateKey,\n operatorPublicKey: publicKey,\n keyType: keyType.detectedType as 'ed25519' | 'ecdsa',\n logLevel: 'info' as LogLevel,\n guardedRegistryBaseUrl: baseUrl,\n });\n\n this.logger.info('Resuming registration with existing state', {\n inboundTopicId: state.inboundTopicId,\n outboundTopicId: state.outboundTopicId,\n profileTopicId: state.profileTopicId,\n pfpTopicId: state.pfpTopicId,\n });\n }\n\n const operatorId = `${state.inboundTopicId}@${account.accountId}`;\n\n if (\n state.currentStage !== 'complete' ||\n !state.createdResources?.includes(\n `registration:${state.inboundTopicId}`,\n )\n ) {\n const registrationResult =\n await serverClient.registerAgentWithGuardedRegistry(\n account.accountId,\n config.network,\n {\n progressCallback: data => {\n const adjustedPercent = 60 + (data.progressPercent || 0) * 0.4;\n if (progressCallback) {\n progressCallback({\n stage: data.stage,\n message: data.message,\n progressPercent: adjustedPercent,\n details: {\n ...data.details,\n outboundTopicId: state.outboundTopicId,\n inboundTopicId: state.inboundTopicId,\n pfpTopicId: state.pfpTopicId,\n profileTopicId: state.profileTopicId,\n operatorId,\n state: data.details?.state || state,\n },\n });\n }\n },\n existingState: state,\n },\n );\n\n if (!registrationResult.success) {\n return {\n ...registrationResult,\n state,\n };\n }\n\n state = registrationResult.state || state;\n }\n\n if (progressCallback) {\n progressCallback({\n stage: 'completed',\n message: 'MCP server creation and registration complete',\n progressPercent: 100,\n details: {\n outboundTopicId: state.outboundTopicId,\n inboundTopicId: state.inboundTopicId,\n pfpTopicId: state.pfpTopicId,\n profileTopicId: state.profileTopicId,\n operatorId,\n state,\n },\n });\n }\n\n return {\n success: true,\n state,\n metadata: {\n accountId: account.accountId,\n privateKey: account.privateKey,\n operatorId,\n inboundTopicId: state.inboundTopicId!,\n outboundTopicId: state.outboundTopicId!,\n profileTopicId: state.profileTopicId!,\n pfpTopicId: state.pfpTopicId!,\n },\n };\n } catch (e: any) {\n const error = e as Error;\n const logMessage = `Failed to create and register MCP server: ${error.message}`;\n this.logger.error(logMessage);\n return {\n error: error.message,\n success: false,\n state:\n options?.existingState ||\n ({\n currentStage: 'init',\n completedPercentage: 0,\n error: error.message,\n } as MCPServerCreationState),\n };\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAiEO,MAAM,oBAAoB,gBAAgB;AAAA,EAU/C,YAAY,QAAyB;AAC7B,UAAA;AAAA,MACJ,SAAS,OAAO;AAAA,MAChB,UAAU,OAAO;AAAA,MACjB,aAAa,OAAO;AAAA,MACpB,WAAW,OAAO;AAAA,MAClB,YAAY,OAAO;AAAA,MACnB,QAAQ,OAAO;AAAA,MACf,SAAS,OAAO;AAAA,IAAA,CACjB;AACI,SAAA,SACH,OAAO,YAAY,YAAY,OAAO,WAAW,IAAI,OAAO,WAAW;AACzE,SAAK,qBAAqB,OAAO;AAEjC,SAAK,oBAAoB,OAAO;AAChC,QAAI,OAAO,SAAS;AAClB,WAAK,UAAU,OAAO;AACtB,YAAM,KACJ,KAAK,YAAY,UACb,WAAW,gBAAgB,KAAK,kBAAkB,IAClD,WAAW,kBAAkB,KAAK,kBAAkB;AAC1D,WAAK,OAAO,YAAY,OAAO,YAAY,EAAE;AAAA,IAAA,OACxC;AACD,UAAA;AACI,cAAA,eAAe,wBAAwB,KAAK,kBAAkB;AACpE,aAAK,OAAO,YAAY,OAAO,YAAY,aAAa,UAAU;AAClE,aAAK,UAAU,aAAa;AAAA,eACrB,OAAO;AACd,aAAK,OAAO;AAAA,UACV;AAAA,QACF;AACA,aAAK,UAAU;AAAA,MAAA;AAGjB,WAAK,mBAAmB;AAAA,IAAA;AAG1B,SAAK,UAAU,OAAO;AACjB,SAAA,SAAS,OAAO,YAAY;AAAA,MAC/B,OAAO,OAAO,YAAY;AAAA,MAC1B,QAAQ;AAAA,MACR,QAAQ,OAAO;AAAA,IAAA,CAChB;AACI,SAAA,yBACH,OAAO,0BAA0B;AAE9B,SAAA,cA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