@hashgraph/hedera-agent-kit 3.8.2-rc.1
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/LICENCE +190 -0
- package/README.md +310 -0
- package/dist/cjs/elizaos/index.d.ts +354 -0
- package/dist/cjs/elizaos/index.js +48415 -0
- package/dist/cjs/elizaos/index.js.map +1 -0
- package/dist/cjs/index.d.ts +1775 -0
- package/dist/cjs/index.js +5719 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/elizaos/index.d.mts +354 -0
- package/dist/esm/elizaos/index.mjs +4999 -0
- package/dist/esm/elizaos/index.mjs.map +1 -0
- package/dist/esm/index.d.mts +1775 -0
- package/dist/esm/index.mjs +5652 -0
- package/dist/esm/index.mjs.map +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/shared/parameter-schemas/token.zod.ts","../../../src/shared/parameter-schemas/common.zod.ts","../../../src/shared/parameter-schemas/account.zod.ts","../../../src/shared/parameter-schemas/consensus.zod.ts","../../../src/shared/hedera-utils/hedera-parameter-normaliser.ts","../../../src/shared/hedera-utils/decimals-utils.ts","../../../src/shared/utils/account-resolver.ts","../../../src/shared/hedera-utils/mirrornode/types.ts","../../../src/shared/hedera-utils/mirrornode/hedera-mirrornode-service-default-impl.ts","../../../src/shared/hedera-utils/mirrornode/hedera-mirrornode-utils.ts","../../../src/shared/parameter-schemas/evm.zod.ts","../../../src/shared/parameter-schemas/transaction.zod.ts","../../../src/plugins/core-token-plugin/tools/fungible-token/airdrop-fungible-token.ts","../../../src/shared/strategies/tx-mode-strategy.ts","../../../src/shared/hedera-utils/hedera-builder.ts","../../../src/shared/utils/default-tool-output-parsing.ts","../../../src/shared/constants/contracts.ts","../../../src/shared/utils/prompt-generator.ts","../../../src/plugins/core-token-plugin/tools/fungible-token/transfer-fungible-token-with-allowance.ts","../../../src/plugins/core-token-plugin/tools/fungible-token/create-fungible-token.ts","../../../src/plugins/core-token-plugin/tools/fungible-token/mint-fungible-token.ts","../../../src/plugins/core-token-plugin/tools/non-fungible-token/create-non-fungible-token.ts","../../../src/plugins/core-token-plugin/tools/non-fungible-token/mint-non-fungible-token.ts","../../../src/plugins/core-token-plugin/tools/non-fungible-token/approve-non-fungible-token-allowance.ts","../../../src/plugins/core-token-plugin/tools/non-fungible-token/delete-non-fungible-token-allowance.ts","../../../src/plugins/core-token-plugin/tools/update-token.ts","../../../src/plugins/core-token-plugin/tools/dissociate-token.ts","../../../src/plugins/core-token-plugin/tools/associate-token.ts","../../../src/plugins/core-token-plugin/tools/non-fungible-token/transfer-non-fungible-token-with-allowance.ts","../../../src/plugins/core-token-plugin/tools/non-fungible-token/transfer-non-fungible-token.ts","../../../src/plugins/core-token-plugin/index.ts","../../../src/plugins/core-account-plugin/tools/account/transfer-hbar.ts","../../../src/plugins/core-account-plugin/tools/account/transfer-hbar-with-allowance.ts","../../../src/plugins/core-account-plugin/tools/account/approve-hbar-allowance.ts","../../../src/plugins/core-account-plugin/tools/account/create-account.ts","../../../src/plugins/core-account-plugin/tools/account/delete-account.ts","../../../src/plugins/core-account-plugin/tools/account/update-account.ts","../../../src/plugins/core-account-plugin/tools/account/sign-schedule-transaction.ts","../../../src/plugins/core-account-plugin/tools/account/schedule-delete.ts","../../../src/plugins/core-account-plugin/tools/account/delete-hbar-allowance.ts","../../../src/plugins/core-token-plugin/tools/fungible-token/approve-token-allowance.ts","../../../src/plugins/core-token-plugin/tools/fungible-token/delete-token-allowance.ts","../../../src/plugins/core-account-plugin/index.ts","../../../src/plugins/core-consensus-plugin/tools/consensus/create-topic.ts","../../../src/plugins/core-consensus-plugin/tools/consensus/delete-topic.ts","../../../src/plugins/core-consensus-plugin/tools/consensus/submit-topic-message.ts","../../../src/plugins/core-consensus-plugin/tools/consensus/update-topic.ts","../../../src/plugins/core-consensus-plugin/index.ts","../../../src/shared/hedera-utils/hbar-conversion-utils.ts","../../../src/plugins/core-queries-plugin/tools/queries/get-account-query.ts","../../../src/shared/parameter-schemas/core-misc.zod.ts","../../../src/plugins/core-misc-query-plugin/tools/queries/get-exchange-rate-query.ts","../../../src/plugins/core-misc-query-plugin/index.ts","../../../src/plugins/core-evm-plugin/tools/erc20/create-erc20.ts","../../../src/plugins/core-evm-plugin/tools/erc20/transfer-erc20.ts","../../../src/plugins/core-evm-plugin/tools/erc721/transfer-erc721.ts","../../../src/plugins/core-evm-plugin/tools/erc721/mint-erc721.ts","../../../src/plugins/core-evm-plugin/tools/erc721/create-erc721.ts","../../../src/plugins/core-evm-plugin/index.ts","../../../src/plugins/core-account-query-plugin/tools/queries/get-hbar-balance-query.ts","../../../src/plugins/core-account-query-plugin/tools/queries/get-account-query.ts","../../../src/plugins/core-account-query-plugin/tools/queries/get-account-token-balances-query.ts","../../../src/plugins/core-account-query-plugin/index.ts","../../../src/plugins/core-token-query-plugin/tools/queries/get-token-info-query.ts","../../../src/plugins/core-token-query-plugin/tools/queries/get-pending-airdrop-query.ts","../../../src/plugins/core-token-query-plugin/index.ts","../../../src/plugins/core-consensus-query-plugin/tools/queries/get-topic-messages-query.ts","../../../src/plugins/core-consensus-query-plugin/tools/queries/get-topic-info-query.ts","../../../src/plugins/core-consensus-query-plugin/index.ts","../../../src/plugins/core-evm-query-plugin/tools/queries/get-contract-info-query.ts","../../../src/plugins/core-evm-query-plugin/index.ts","../../../src/plugins/core-transactions-query-plugin/tools/queries/get-transaction-record-query.ts","../../../src/plugins/core-transactions-query-plugin/index.ts","../../../src/shared/plugin.ts","../../../src/shared/tool-discovery.ts","../../../src/elizaos/tool.ts","../../../src/elizaos/utils/extraction.ts","../../../src/elizaos/utils/parser.ts","../../../src/elizaos/toolkit.ts"],"sourcesContent":["import { Context } from '@/shared/configuration';\nimport { z } from 'zod';\nimport {\n AccountId,\n NftId,\n PublicKey,\n TokenId,\n TokenNftAllowance,\n TokenSupplyType,\n TokenType,\n} from '@hashgraph/sdk';\nimport { TokenTransferMinimalParams } from '@/shared/hedera-utils/types';\nimport {\n optionalScheduledTransactionParams,\n optionalScheduledTransactionParamsNormalised,\n} from '@/shared/parameter-schemas/common.zod';\n\nexport const createFungibleTokenParameters = (_context: Context = {}) =>\n optionalScheduledTransactionParams(_context).extend({\n tokenName: z.string().describe('The name of the token.'),\n tokenSymbol: z.string().describe('The symbol of the token.'),\n initialSupply: z\n .number()\n .int()\n .optional()\n .default(0)\n .describe(\n 'The initial supply of the token. Given in display units, the tool will handle parsing',\n ),\n supplyType: z\n .enum(['finite', 'infinite'])\n .optional()\n .default('finite')\n .describe('Supply type of the token.'),\n maxSupply: z\n .number()\n .int()\n .optional()\n .describe(\n 'The maximum supply of the token. Given in display units, the tool will handle parsing',\n ),\n decimals: z.number().int().optional().default(0).describe('The number of decimals.'),\n treasuryAccountId: z.string().optional().describe('The treasury account of the token.'),\n isSupplyKey: z\n .boolean()\n .optional()\n .describe('Determines if the token supply key should be set.'),\n });\n\nexport const createFungibleTokenParametersNormalised = (_context: Context = {}) =>\n optionalScheduledTransactionParamsNormalised(_context).merge(\n createFungibleTokenParameters(_context)\n .omit({ schedulingParams: true })\n .extend({\n treasuryAccountId: z.string().describe('The treasury account of the token.'),\n autoRenewAccountId: z\n .string()\n .optional()\n .describe(\n 'The auto renew account for the token. If not provided, defaults to the operator account.',\n ),\n supplyKey: z\n .custom<PublicKey>()\n .optional()\n .describe('The supply key. If not provided, defaults to the operator’s public key.'),\n supplyType: z.custom<TokenSupplyType>().describe('Supply type of the token.'),\n adminKey: z.custom<PublicKey>().optional().describe('The admin key for the token.'),\n kycKey: z.custom<PublicKey>().optional().describe('The KYC key for the token.'),\n freezeKey: z.custom<PublicKey>().optional().describe('The freeze key for the token.'),\n wipeKey: z.custom<PublicKey>().optional().describe('The wipe key for the token.'),\n pauseKey: z.custom<PublicKey>().optional().describe('The pause key for the token.'),\n metadataKey: z.custom<PublicKey>().optional().describe('The metadata key for the token.'),\n tokenMemo: z.string().optional().describe('The memo for the token.'),\n tokenType: z.custom<TokenType>().optional().describe('The type of the token.'),\n }),\n );\n\nexport const createNonFungibleTokenParameters = (_context: Context = {}) =>\n optionalScheduledTransactionParams(_context).extend({\n tokenName: z.string().describe('The name of the token.'),\n tokenSymbol: z.string().describe('The symbol of the token.'),\n maxSupply: z.number().int().optional().describe('The maximum supply of the token.'),\n treasuryAccountId: z.string().optional().describe('The treasury account of the token.'),\n supplyType: z.enum(['finite', 'infinite']).optional().describe('Supply type of the token.'),\n isSupplyKey: z\n .boolean()\n .optional()\n .describe('Determines if the token supply key should be set.'),\n });\n\nexport const createNonFungibleTokenParametersNormalised = (_context: Context = {}) =>\n createNonFungibleTokenParameters(_context)\n .omit({ schedulingParams: true }) // remove unnormalized scheduling params\n .merge(optionalScheduledTransactionParamsNormalised(_context)) // add normalized ones\n .extend({\n autoRenewAccountId: z\n .string()\n .describe(\n 'The auto renew account for the token. If not provided, defaults to the operator account.',\n ),\n supplyKey: z\n .custom<PublicKey>()\n .describe('The supply key. If not provided, defaults to the operator’s public key.'),\n supplyType: z.custom<TokenSupplyType>().describe('Supply type of the token.'),\n maxSupply: z.number().int().optional().describe('The maximum supply of the token.'),\n tokenType: z\n .custom<TokenType>()\n .default(TokenType.NonFungibleUnique)\n .describe('Token type of the token - must be non-fungible unique for NFT.'),\n adminKey: z.custom<PublicKey>().optional().describe('The admin key for the token.'),\n kycKey: z.custom<PublicKey>().optional().describe('The KYC key for the token.'),\n freezeKey: z.custom<PublicKey>().optional().describe('The freeze key for the token.'),\n wipeKey: z.custom<PublicKey>().optional().describe('The wipe key for the token.'),\n pauseKey: z.custom<PublicKey>().optional().describe('The pause key for the token.'),\n tokenMemo: z.string().optional().describe('The memo for the token.'),\n });\n\nconst AirdropRecipientSchema = z.object({\n accountId: z.string().describe('Recipient account ID (e.g., \"0.0.xxxx\"). (Required)'),\n amount: z\n .union([z.number(), z.string()])\n .describe('Amount in display units, the tool will handle parsing. (Required)'),\n});\n\nexport const airdropFungibleTokenParameters = (_context: Context = {}) =>\n z.object({\n tokenId: z.string().describe('The id of the token.'),\n sourceAccountId: z.string().optional().describe('The account to airdrop the token from.'),\n recipients: z\n .array(AirdropRecipientSchema)\n .min(1)\n .describe('Array of recipient objects, each with accountId and amount.'),\n });\n\nexport const airdropFungibleTokenParametersNormalised = () =>\n z.object({\n tokenTransfers: z\n .custom<TokenTransferMinimalParams[]>()\n .describe('Array of TokenTransfer objects constructed from the original recipients.'),\n });\n\nexport const mintFungibleTokenParameters = (_context: Context = {}) =>\n optionalScheduledTransactionParams(_context).extend({\n tokenId: z.string().describe('The id of the token.'),\n amount: z\n .number()\n .describe(\n 'The amount of tokens to mint. Given in display units, the tool will handle parsing',\n ),\n });\n\nexport const mintFungibleTokenParametersNormalised = (_context: Context = {}) =>\n mintFungibleTokenParameters(_context)\n .omit({ schedulingParams: true })\n .merge(optionalScheduledTransactionParamsNormalised(_context));\n\nexport const mintNonFungibleTokenParameters = (_context: Context = {}) =>\n optionalScheduledTransactionParams(_context).extend({\n tokenId: z.string().describe('The id of the NFT class.'),\n uris: z.array(z.string().max(100)).max(10).describe('An array of URIs hosting NFT metadata.'),\n });\n\nexport const mintNonFungibleTokenParametersNormalised = (_context: Context = {}) =>\n optionalScheduledTransactionParamsNormalised(_context).extend({\n tokenId: z.string().describe('The id of the NFT class.'),\n metadata: z\n .instanceof(Uint8Array<ArrayBufferLike>)\n .array()\n .optional(),\n });\n\nexport const deleteTokenParameters = (_context: Context = {}) =>\n z.object({\n tokenId: z.string().describe('The ID of the token to delete.'),\n });\n\nexport const deleteTokenParametersNormalised = (_context: Context = {}) =>\n deleteTokenParameters(_context).extend({});\n\nexport const tokenInfoQueryParameters = (_context: Context = {}) =>\n z.object({\n tokenId: z.string().optional().describe('The token ID to query.'),\n });\n\nexport const updateTokenParameters = (_context: Context = {}) =>\n z.object({\n tokenId: z.string().describe('The ID of the token to update (e.g., 0.0.12345).'),\n tokenDesc: z\n .string()\n .optional()\n .describe('Optional description of the token update operation.'),\n tokenName: z\n .string()\n .max(100)\n .optional()\n .describe('New name for the token. Up to 100 characters.'),\n tokenSymbol: z\n .string()\n .max(100)\n .optional()\n .describe('New symbol for the token. Up to 100 characters.'),\n treasuryAccountId: z\n .string()\n .optional()\n .describe('New treasury account for the token (Hedera account ID).'),\n adminKey: z\n .union([z.boolean(), z.string()])\n .optional()\n .describe(\n 'New admin key. Pass boolean `true` to use the operator/user key, or provide a Hedera-compatible public key string. Required for most property updates.',\n ),\n kycKey: z\n .union([z.boolean(), z.string()])\n .optional()\n .describe(\n 'New KYC key. Pass boolean `true` to use the operator/user key, or provide a public key string.',\n ),\n freezeKey: z\n .union([z.boolean(), z.string()])\n .optional()\n .describe(\n 'New freeze key. Pass boolean `true` to use the operator/user key, or provide a public key string.',\n ),\n wipeKey: z\n .union([z.boolean(), z.string()])\n .optional()\n .describe(\n 'New wipe key. Pass boolean `true` to use the operator/user key, or provide a public key string.',\n ),\n supplyKey: z\n .union([z.boolean(), z.string()])\n .optional()\n .describe(\n 'New supply key. Pass boolean `true` to use the operator/user key, or provide a public key string.',\n ),\n feeScheduleKey: z\n .union([z.boolean(), z.string()])\n .optional()\n .describe(\n 'New fee schedule key. Pass boolean `true` to use the operator/user key, or provide a public key string.',\n ),\n pauseKey: z\n .union([z.boolean(), z.string()])\n .optional()\n .describe(\n 'New pause key. Pass boolean `true` to use the operator/user key, or provide a public key string.',\n ),\n metadataKey: z\n .union([z.boolean(), z.string()])\n .optional()\n .describe(\n 'New metadata key. Pass boolean `true` to use the operator/user key, or provide a public key string.',\n ),\n metadata: z\n .string()\n .optional()\n .describe('New metadata for the token, in bytes (as base64 or hex).'),\n tokenMemo: z\n .string()\n .max(100)\n .optional()\n .describe('Short public memo for the token, up to 100 characters.'),\n autoRenewAccountId: z\n .string()\n .optional()\n .describe('Account to automatically pay for token renewal (Hedera account ID).'),\n });\n\nexport const updateTokenParametersNormalised = (_context: Context = {}) =>\n z.object({\n tokenId: z.instanceof(TokenId),\n\n // Strings\n tokenName: z.string().optional(),\n tokenSymbol: z.string().optional(),\n tokenMemo: z.string().optional(),\n metadata: z.instanceof(Uint8Array<ArrayBufferLike>).optional(),\n\n // IDs\n treasuryAccountId: z.union([z.string(), z.instanceof(AccountId)]).optional(),\n autoRenewAccountId: z.union([z.string(), z.instanceof(AccountId)]).optional(),\n\n // Keys\n adminKey: z.instanceof(PublicKey).optional(),\n supplyKey: z.instanceof(PublicKey).optional(),\n wipeKey: z.instanceof(PublicKey).optional(),\n freezeKey: z.instanceof(PublicKey).optional(),\n kycKey: z.instanceof(PublicKey).optional(),\n feeScheduleKey: z.instanceof(PublicKey).optional(),\n pauseKey: z.instanceof(PublicKey).optional(),\n metadataKey: z.instanceof(PublicKey).optional(),\n });\n\n// Associate Token\nexport const associateTokenParameters = (_context: Context = {}) =>\n z.object({\n // If not passed, will be injected from context in normalisation\n accountId: z\n .string()\n .optional()\n .describe(\n 'Account ID to associate tokens with (e.g., 0.0.xxxxx). If not provided, operator account ID will be used',\n ),\n // One or more token IDs to associate\n tokenIds: z.array(z.string()).min(1).describe('Array of token IDs to associate'),\n });\n\nexport const associateTokenParametersNormalised = (_context: Context = {}) =>\n z.object({\n accountId: z.string().describe('Resolved account ID to associate tokens with'),\n tokenIds: z.array(z.string()).min(1).describe('Array of token IDs to associate'),\n });\n\nexport const pendingAirdropQueryParameters = (_context: Context = {}) =>\n z.object({\n accountId: z.string().optional().describe('The account ID to query.'),\n });\n\nexport const dissociateTokenParameters = (_context: Context = {}) =>\n z.object({\n tokenIds: z\n .array(z.string())\n .min(1)\n .describe('The list of Hedera token IDs (strings) to dissociate. Must provide at least one.'),\n accountId: z\n .string()\n .optional()\n .describe(\n 'The account ID from which to dissociate the tokens. Defaults to operator account.',\n ),\n transactionMemo: z.string().optional().describe('Optional memo for the transaction.'),\n });\n\nexport const dissociateTokenParametersNormalised = (_context: Context = {}) =>\n dissociateTokenParameters(_context).extend({\n tokenIds: z.array(z.instanceof(TokenId)),\n accountId: z.instanceof(AccountId),\n });\n\nexport const approveNftAllowanceParameters = (_context: Context = {}) =>\n z.object({\n ownerAccountId: z\n .string()\n .optional()\n .describe('Owner account ID (defaults to operator account ID if omitted)'),\n spenderAccountId: z.string().describe('Spender account ID'),\n tokenId: z.string().describe('The NFT token ID'),\n allSerials: z\n .boolean()\n .optional()\n .describe(\n 'If true, approve allowance for all current and future serials of the NFT collection. If true, do not provide serialNumbers.',\n ),\n serialNumbers: z\n .array(z.number().int().nonnegative())\n .optional()\n .describe('Array of NFT serial numbers to approve. Required if allSerials is not true.'),\n transactionMemo: z.string().optional().describe('Memo to include with the transaction'),\n });\n\nexport const approveNftAllowanceParametersNormalised = (_context: Context = {}) =>\n z.object({\n nftApprovals: z.array(z.instanceof(TokenNftAllowance)).optional(),\n transactionMemo: z.string().optional(),\n });\n\n// Delete NFT Allowance\nexport const deleteNftAllowanceParameters = (_context: Context = {}) =>\n z.object({\n ownerAccountId: z\n .string()\n .optional()\n .describe('Owner account ID (defaults to operator account ID if omitted)'),\n tokenId: z.string().describe('The NFT token ID'),\n serialNumbers: z\n .array(z.number().int().min(1))\n .min(1)\n .describe('Array of NFT serial numbers to remove allowance for.'),\n transactionMemo: z.string().optional().describe('Memo to include with the transaction'),\n });\n\nexport const deleteNftAllowanceParametersNormalised = (_context: Context = {}) =>\n z.object({\n nftWipes: z.array(z.instanceof(NftId)).min(1),\n ownerAccountId: z.instanceof(AccountId),\n transactionMemo: z.string().optional(),\n });\n\nexport const transferNonFungibleTokenWithAllowanceParameters = (_context: Context) =>\n z.object({\n sourceAccountId: z.string().describe('Account ID of the token owner (the allowance granter)'),\n tokenId: z.string().describe('The NFT token ID (e.g. \"0.0.12345\")'),\n recipients: z\n .array(\n z.object({\n recipientId: z.string().describe('Account ID of the recipient (Required)'),\n serialNumber: z.number().int().min(1).describe('Serial number of the NFT to transfer (Required)'),\n }),\n )\n .min(1)\n .describe('Array of recipient and NFT serial number pairs to transfer'),\n transactionMemo: z\n .string()\n .optional()\n .describe('Optional memo to include with the transaction'),\n });\n\nexport const transferNonFungibleTokenWithAllowanceParametersNormalised = (_context: Context) =>\n z.object({\n sourceAccountId: z.instanceof(AccountId),\n transactionMemo: z.string().optional(),\n transfers: z.array(\n z.object({\n nftId: z.instanceof(NftId),\n receiver: z.instanceof(AccountId),\n }),\n ),\n });\n\nexport const transferNonFungibleTokenParameters = (_context: Context) =>\n optionalScheduledTransactionParams(_context)\n .extend({\n tokenId: z.string().describe('The NFT token ID (e.g. \"0.0.12345\")'),\n recipients: z\n .array(\n z.object({\n recipientId: z.string().describe('Account ID of the recipient (Required)'),\n serialNumber: z.number().int().min(1).describe('Serial number of the NFT to transfer (Required)'),\n }),\n )\n .min(1)\n .describe('Array of recipient and NFT serial number pairs to transfer'),\n transactionMemo: z\n .string()\n .optional()\n .describe('Optional memo to include with the transaction'),\n });\n\nexport const transferNonFungibleTokenParametersNormalised = (_context: Context) =>\n optionalScheduledTransactionParamsNormalised(_context).extend({\n senderAccountId: z.instanceof(AccountId),\n transactionMemo: z.string().optional(),\n transfers: z.array(\n z.object({\n nftId: z.instanceof(NftId),\n receiver: z.instanceof(AccountId),\n }),\n ),\n });\n\nexport const transferFungibleTokenWithAllowanceParameters = (context: Context = {}) =>\n optionalScheduledTransactionParams(context).extend({\n tokenId: z.string().describe('Token ID to transfer'),\n sourceAccountId: z.string().describe('Account ID of the token owner (the allowance granter)'),\n transfers: z\n .array(\n z.object({\n accountId: z.string().describe('Recipient account ID (Required)'),\n amount: z\n .number()\n .nonnegative()\n .describe('Amount of tokens to transfer in display unit. (Required)'),\n }),\n )\n .min(1)\n .describe('Array of recipient transfers'),\n transactionMemo: z.string().optional().describe('Memo for the transaction'),\n });\n\nexport const transferFungibleTokenWithAllowanceParametersNormalised = (context: Context = {}) =>\n optionalScheduledTransactionParamsNormalised(context).extend({\n tokenId: z.string(),\n tokenTransfers: z.custom<TokenTransferMinimalParams[]>(),\n approvedTransfer: z.object({\n ownerAccountId: z.string(),\n amount: z.number(),\n }),\n transactionMemo: z.string().optional(),\n });\n","import { Context } from '@/shared';\nimport { z } from 'zod';\nimport { AccountId, PublicKey, Timestamp } from '@hashgraph/sdk';\n\nexport const optionalScheduledTransactionParams = (_context: Context = {}) =>\n z.object({\n schedulingParams: z\n .object({\n isScheduled: z\n .boolean()\n .optional()\n .default(false)\n .describe(\n 'If true, the transaction will be created as a scheduled transaction. If false or omitted, all other scheduling parameters will be ignored.',\n ),\n adminKey: z\n .union([z.boolean(), z.string()])\n .optional()\n .default(false)\n .describe(\n 'Admin key that can delete or modify the scheduled transaction before execution. If true, the operator key will be used. If false or omitted, no admin key is set. If a string is passed, it will be used as the admin key.',\n ),\n payerAccountId: z\n .string()\n .optional()\n .describe(\n 'Account that will pay the transaction fee when the scheduled transaction executes. Defaults to the ${AccountResolver.getDefaultAccountDescription(context)}.',\n ),\n expirationTime: z\n .string()\n .optional()\n .describe(\n 'Time when the scheduled transaction will expire if not fully signed (ISO 8601 format).',\n ),\n waitForExpiry: z\n .boolean()\n .optional()\n .default(false)\n .describe(\n 'Determines when the scheduled transaction executes:\\n' +\n '- `false` (default): execute as soon as all required signatures are collected.\\n' +\n '- `true`: execute at the scheduled expiration time, regardless of signatures.\\n' +\n 'Requires `expirationTime` to be set if true; otherwise an error is thrown.\\n' +\n 'Set to true only if the user explicitly requests execution at expiration.',\n ),\n })\n .optional()\n .describe(\n 'Optional scheduling parameters. Used to control whether the transaction should be scheduled, provide metadata, control payer/admin keys, and manage execution/expiration behavior.',\n ),\n });\n\nexport const optionalScheduledTransactionParamsNormalised = (_context: Context) =>\n z.object({\n schedulingParams: z\n .object({\n isScheduled: z.boolean(),\n adminKey: z.instanceof(PublicKey).optional(),\n payerAccountID: z.instanceof(AccountId).optional(),\n expirationTime: z.instanceof(Timestamp).optional(),\n waitForExpiry: z.boolean().optional(),\n })\n .optional(),\n });\n","import { Context } from '@/shared/configuration';\nimport { z } from 'zod';\nimport { AccountId, Hbar, Key, HbarAllowance, TokenAllowance } from '@hashgraph/sdk';\nimport BigNumber from 'bignumber.js';\nimport Long from 'long';\nimport {\n optionalScheduledTransactionParams,\n optionalScheduledTransactionParamsNormalised,\n} from '@/shared/parameter-schemas/common.zod';\n\nexport const transferHbarParameters = (context: Context = {}) =>\n optionalScheduledTransactionParams(context).extend({\n transfers: z\n .array(\n z.object({\n accountId: z.string().describe('Recipient account ID (Required)'),\n amount: z.number().describe('Amount of HBAR to transfer (Required)'),\n }),\n )\n .describe(\n 'Array of HBAR transfers to RECIPIENTS. Do NOT include the sender/source account in this array.',\n )\n .min(1),\n sourceAccountId: z\n .string()\n .optional()\n .describe(\n 'Account ID of the sender/owner — the balance will be deducted from this account. Use this INSTEAD of adding a negative transfer.',\n ),\n transactionMemo: z.string().optional().describe('Memo to include with the transaction'),\n });\n\nexport const transferHbarParametersNormalised = (context: Context = {}) =>\n optionalScheduledTransactionParamsNormalised(context).extend({\n hbarTransfers: z.array(\n z.object({\n accountId: z.union([z.string(), z.instanceof(AccountId)]),\n amount: z.union([\n z.number(),\n z.string(),\n z.instanceof(Hbar),\n z.instanceof(Long),\n z.instanceof(BigNumber),\n ]),\n }),\n ),\n transactionMemo: z.string().optional(),\n });\n\nexport const createAccountParameters = (_context: Context = {}) =>\n optionalScheduledTransactionParams(_context).extend({\n publicKey: z\n .string()\n .optional()\n .describe('Account public key. If not provided, the operator’s public key will be used.'),\n accountMemo: z.string().optional().describe('Optional memo for the account.'),\n initialBalance: z\n .number()\n .optional()\n .default(0)\n .describe('Initial HBAR balance to fund the account (defaults to 0).'),\n maxAutomaticTokenAssociations: z\n .number()\n .optional()\n .default(-1)\n .describe('Max automatic token associations (-1 for unlimited).'),\n });\n\nexport const createAccountParametersNormalised = (_context: Context = {}) =>\n optionalScheduledTransactionParamsNormalised(_context).extend({\n accountMemo: z.string().optional(),\n initialBalance: z.union([z.string(), z.number()]).optional(),\n key: z.instanceof(Key).optional(),\n maxAutomaticTokenAssociations: z.union([z.number(), z.instanceof(Long)]).optional(),\n });\n\nexport const deleteAccountParameters = (_context: Context = {}) =>\n z.object({\n accountId: z.string().describe('The account ID to delete.'),\n transferAccountId: z\n .string()\n .optional()\n .describe(\n 'The ID of the account to transfer the remaining funds to. If not provided, the operator account ID will be used.',\n ),\n });\n\nexport const deleteAccountParametersNormalised = (_context: Context = {}) =>\n z.object({\n accountId: z.instanceof(AccountId),\n transferAccountId: z.instanceof(AccountId),\n });\n\nexport const updateAccountParameters = (_context: Context = {}) =>\n optionalScheduledTransactionParams(_context).extend({\n // If not passed, will be injected from context in normalization\n accountId: z\n .string()\n .optional()\n .describe(\n 'Account ID to update (e.g., 0.0.xxxxx). If not provided, operator account ID will be used',\n ),\n\n maxAutomaticTokenAssociations: z\n .number()\n .int()\n .optional()\n .describe('Max automatic token associations, positive, zero or -1 if unlimited'),\n stakedAccountId: z.string().optional().describe('Staked account ID'),\n accountMemo: z.string().optional().describe('Account memo'),\n declineStakingReward: z.boolean().optional().describe('Decline staking rewards'),\n });\n\nexport const updateAccountParametersNormalised = (_context: Context = {}) =>\n optionalScheduledTransactionParamsNormalised(_context).extend({\n accountId: z.instanceof(AccountId),\n maxAutomaticTokenAssociations: z.union([z.number(), z.instanceof(Long)]).optional(),\n stakedAccountId: z.union([z.string(), z.instanceof(AccountId)]).optional(),\n accountMemo: z.string().optional(),\n declineStakingReward: z.boolean().optional(),\n });\n\nexport const accountQueryParameters = (_context: Context = {}) =>\n z.object({\n accountId: z.string().describe('The account ID to query.'),\n });\n\nexport const accountBalanceQueryParameters = (_context: Context = {}) =>\n z.object({\n accountId: z.string().optional().describe('The account ID to query.'),\n });\n\nexport const accountBalanceQueryParametersNormalised = (_context: Context = {}) =>\n z.object({\n accountId: z.string().describe('The account ID to query.'),\n });\n\nexport const accountTokenBalancesQueryParameters = (_context: Context = {}) =>\n z.object({\n accountId: z\n .string()\n .optional()\n .describe('The account ID to query. If not provided, this accountId will be used.'),\n tokenId: z.string().optional().describe('The token ID to query.'),\n });\n\nexport const accountTokenBalancesQueryParametersNormalised = (_context: Context = {}) =>\n z.object({\n accountId: z.string(),\n tokenId: z.string().optional(),\n });\n\nexport const signScheduleTransactionParameters = (_context: Context = {}) =>\n z.object({\n scheduleId: z.string().describe('The ID of the scheduled transaction to sign'),\n });\n\nexport const scheduleDeleteTransactionParameters = (_context: Context = {}) =>\n z.object({\n scheduleId: z.string().describe('The ID of the scheduled transaction to delete'),\n });\n\nexport const approveHbarAllowanceParameters = (_context: Context = {}) =>\n z.object({\n ownerAccountId: z\n .string()\n .optional()\n .describe('Owner account ID (defaults to operator account ID if omitted)'),\n spenderAccountId: z.string().describe('Spender account ID'),\n amount: z\n .number()\n .describe('Amount of HBAR to approve as allowance (can be decimal, not negative)'),\n transactionMemo: z.string().optional().describe('Memo to include with the transaction'),\n });\n\nexport const approveHbarAllowanceParametersNormalised = (_context: Context = {}) =>\n z.object({\n hbarApprovals: z.array(z.instanceof(HbarAllowance)).optional(),\n transactionMemo: z.string().optional(),\n });\n\nexport const approveTokenAllowanceParameters = (_context: Context = {}) =>\n z.object({\n ownerAccountId: z\n .string()\n .optional()\n .describe('Owner account ID (defaults to operator account ID if omitted)'),\n spenderAccountId: z.string().describe('Spender account ID'),\n tokenApprovals: z\n .array(\n z.object({\n tokenId: z.string().describe('Token ID (Required)'),\n amount: z\n .number()\n .nonnegative()\n .describe(\n 'Amount of tokens to approve (must be positive, can be float or int) Given in display units, the tool will handle parsing. (Required)',\n ),\n }),\n )\n .min(1)\n .describe('List of token allowances to approve'),\n transactionMemo: z.string().optional().describe('Memo to include with the transaction'),\n });\n\nexport const approveTokenAllowanceParametersNormalised = (_context: Context = {}) =>\n z.object({\n tokenApprovals: z.array(z.instanceof(TokenAllowance)).optional(),\n transactionMemo: z.string().optional(),\n });\n\nexport const transferHbarWithAllowanceParameters = transferHbarParameters;\n\nexport const transferHbarWithAllowanceParametersNormalised = (_context: Context = {}) =>\n z.object({\n hbarTransfers: z.array(\n z.object({\n accountId: z.union([z.string(), z.instanceof(AccountId)]),\n amount: z.union([\n z.number(),\n z.string(),\n z.instanceof(Hbar),\n z.instanceof(Long),\n z.instanceof(BigNumber),\n ]),\n }),\n ),\n hbarApprovedTransfer: z.object({\n ownerAccountId: z.instanceof(AccountId),\n amount: z.instanceof(Hbar),\n }),\n transactionMemo: z.string().optional(),\n });\n\nexport const deleteHbarAllowanceParameters = (_context: Context = {}) =>\n z.object({\n ownerAccountId: z\n .string()\n .optional()\n .describe('Owner account ID (defaults to operator account ID if omitted)'),\n spenderAccountId: z.string().describe('Spender account ID'),\n transactionMemo: z.string().optional().describe('Memo to include with the transaction'),\n });\n\nexport const deleteTokenAllowanceParameters = (_context: Context = {}) =>\n z.object({\n ownerAccountId: z.string().optional(),\n spenderAccountId: z.string(),\n tokenIds: z.array(z.string()), // list of token IDs whose allowances we’re deleting\n transactionMemo: z.string().optional(),\n });\n","import { z } from 'zod';\nimport { Context } from '@/shared/configuration';\nimport { AccountId, PublicKey, TopicId } from '@hashgraph/sdk';\nimport {\n optionalScheduledTransactionParams,\n optionalScheduledTransactionParamsNormalised,\n} from '@/shared/parameter-schemas/common.zod';\n\nexport const getTopicInfoParameters = (_context: Context = {}) => {\n return z.object({\n topicId: z.string().describe('The topic ID to query.'),\n });\n};\n\nexport const createTopicParameters = (_context: Context = {}) => {\n return z.object({\n isSubmitKey: z\n .boolean()\n .optional()\n .default(false)\n .describe('Whether to set a submit key for the topic (optional)'),\n topicMemo: z.string().optional().describe('Memo for the topic (optional)'),\n transactionMemo: z\n .string()\n .optional()\n .describe('An optional memo to include on the submitted transaction (optional).'),\n });\n};\n\nexport const createTopicParametersNormalised = (_context: Context = {}) =>\n createTopicParameters(_context).extend({\n autoRenewAccountId: z\n .string()\n .describe(\n 'The auto renew account for the topic. If not provided, defaults to the operator account.',\n ),\n submitKey: z.custom<PublicKey>().optional().describe('The submit key of topic'),\n adminKey: z.custom<PublicKey>().optional().describe('The admin key of topic'),\n });\n\nexport const submitTopicMessageParameters = (_context: Context = {}) =>\n optionalScheduledTransactionParams(_context).extend({\n topicId: z.string().describe('The ID of the topic to submit the message to'),\n message: z.string().describe('The message to submit to the topic'),\n transactionMemo: z\n .string()\n .optional()\n .describe('An optional memo to include on the submitted transaction (optional).'),\n });\n\nexport const submitTopicMessageParametersNormalised = (_context: Context = {}) =>\n submitTopicMessageParameters(_context)\n .omit({ schedulingParams: true })\n .merge(optionalScheduledTransactionParamsNormalised(_context));\n\nexport const deleteTopicParameters = (_context: Context = {}) =>\n z.object({\n topicId: z.string().describe('The ID of the topic to delete.'),\n });\n\nexport const deleteTopicParametersNormalised = (_context: Context = {}) =>\n deleteTopicParameters(_context).extend({});\n\nexport const topicMessagesQueryParameters = (_context: Context = {}) =>\n z.object({\n topicId: z.string().describe('The topic ID to query.'),\n startTime: z\n .string()\n .datetime()\n .optional()\n .describe(\n 'The start time to query. If set, the messages will be returned after this timestamp.',\n ),\n endTime: z\n .string()\n .datetime()\n .optional()\n .describe(\n 'The end time to query. If set, the messages will be returned before this timestamp.',\n ),\n limit: z\n .number()\n .optional()\n .describe('The limit of messages to query. If set, the number of messages to return.'),\n });\n\nexport const updateTopicParameters = (_context: Context = {}) =>\n z.object({\n topicId: z.string().describe('The ID of the topic to update (e.g., 0.0.12345).'),\n topicMemo: z.string().optional().describe('Optional new memo for the topic.'),\n adminKey: z\n .union([z.boolean(), z.string()])\n .optional()\n .describe(\n 'New admin key. Pass boolean `true` to use the operator/user key, or provide a Hedera-compatible public key string.',\n ),\n submitKey: z\n .union([z.boolean(), z.string()])\n .optional()\n .describe(\n 'New submit key. Pass boolean `true` to use the operator/user key, or provide a Hedera-compatible public key string.',\n ),\n autoRenewAccountId: z\n .string()\n .optional()\n .describe('Account to automatically pay for topic renewal (Hedera account ID).'),\n autoRenewPeriod: z.number().optional().describe('Auto renew period in seconds.'),\n expirationTime: z\n .union([z.string(), z.instanceof(Date)])\n .optional()\n .describe('New expiration time for the topic (ISO string or Date).'),\n });\n\nexport const updateTopicParametersNormalised = (_context: Context = {}) =>\n z.object({\n topicId: z.instanceof(TopicId),\n topicMemo: z.string().optional(),\n adminKey: z.instanceof(PublicKey).optional(),\n submitKey: z.instanceof(PublicKey).optional(),\n autoRenewAccountId: z.union([z.string(), z.instanceof(AccountId)]).optional(),\n autoRenewPeriod: z.number().optional(),\n expirationTime: z.instanceof(Date).optional(),\n });\n","// optional to use methods in here\n\nimport {\n airdropFungibleTokenParameters,\n airdropFungibleTokenParametersNormalised,\n approveNftAllowanceParameters,\n approveNftAllowanceParametersNormalised,\n associateTokenParameters,\n associateTokenParametersNormalised,\n createFungibleTokenParameters,\n createFungibleTokenParametersNormalised,\n createNonFungibleTokenParameters,\n createNonFungibleTokenParametersNormalised,\n deleteNftAllowanceParameters,\n deleteNftAllowanceParametersNormalised,\n dissociateTokenParameters,\n dissociateTokenParametersNormalised,\n mintFungibleTokenParameters,\n mintFungibleTokenParametersNormalised,\n mintNonFungibleTokenParameters,\n mintNonFungibleTokenParametersNormalised,\n transferNonFungibleTokenWithAllowanceParameters,\n transferNonFungibleTokenWithAllowanceParametersNormalised,\n transferNonFungibleTokenParameters,\n transferNonFungibleTokenParametersNormalised,\n transferFungibleTokenWithAllowanceParameters,\n transferFungibleTokenWithAllowanceParametersNormalised,\n updateTokenParameters,\n updateTokenParametersNormalised,\n} from '@/shared/parameter-schemas/token.zod';\nimport {\n accountBalanceQueryParameters,\n accountTokenBalancesQueryParameters,\n approveHbarAllowanceParameters,\n approveHbarAllowanceParametersNormalised,\n createAccountParameters,\n createAccountParametersNormalised,\n deleteAccountParameters,\n deleteAccountParametersNormalised,\n transferHbarParameters,\n updateAccountParameters,\n updateAccountParametersNormalised,\n deleteHbarAllowanceParameters,\n approveTokenAllowanceParameters,\n approveTokenAllowanceParametersNormalised,\n transferHbarWithAllowanceParameters,\n transferHbarWithAllowanceParametersNormalised,\n deleteTokenAllowanceParameters,\n transferHbarParametersNormalised,\n accountBalanceQueryParametersNormalised,\n accountTokenBalancesQueryParametersNormalised,\n} from '@/shared/parameter-schemas/account.zod';\nimport {\n createTopicParameters,\n createTopicParametersNormalised,\n deleteTopicParameters,\n deleteTopicParametersNormalised,\n submitTopicMessageParameters,\n submitTopicMessageParametersNormalised,\n updateTopicParameters,\n updateTopicParametersNormalised,\n} from '@/shared/parameter-schemas/consensus.zod';\n\nimport {\n AccountId,\n Client,\n Hbar,\n Long,\n PublicKey,\n TokenId,\n TokenNftAllowance,\n TokenSupplyType,\n TokenType,\n TopicId,\n HbarAllowance,\n TokenAllowance,\n Timestamp,\n NftId,\n} from '@hashgraph/sdk';\nimport { Context } from '@/shared/configuration';\nimport z from 'zod';\nimport { IHederaMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-service.interface';\nimport { toBaseUnit } from '@/shared/hedera-utils/decimals-utils';\nimport { TokenTransferMinimalParams, TransferHbarInput } from '@/shared/hedera-utils/types';\nimport { AccountResolver } from '@/shared/utils/account-resolver';\nimport { ethers } from 'ethers';\nimport {\n createERC20Parameters,\n createERC721Parameters,\n evmContractCallParamsNormalised,\n mintERC721Parameters,\n transferERC20Parameters,\n transferERC721Parameters,\n} from '@/shared/parameter-schemas/evm.zod';\nimport {\n normalisedTransactionRecordQueryParameters,\n transactionRecordQueryParameters,\n} from '@/shared/parameter-schemas/transaction.zod';\nimport {\n optionalScheduledTransactionParams,\n optionalScheduledTransactionParamsNormalised,\n} from '@/shared/parameter-schemas/common.zod';\n\nexport default class HederaParameterNormaliser {\n static parseParamsWithSchema(\n params: any,\n schema: any,\n context: Context = {},\n ): z.infer<ReturnType<typeof schema>> {\n let parsedParams: z.infer<ReturnType<typeof schema>>;\n try {\n parsedParams = schema(context).parse(params);\n } catch (e) {\n if (e instanceof z.ZodError) {\n const issues = this.formatZodIssues(e);\n throw new Error(`Invalid parameters: ${issues}`);\n }\n throw e;\n }\n return parsedParams;\n }\n\n private static formatZodIssues(error: z.ZodError): string {\n return error.errors.map(err => `Field \"${err.path.join('.')}\" - ${err.message}`).join('; ');\n }\n\n static async normaliseCreateFungibleTokenParams(\n params: z.infer<ReturnType<typeof createFungibleTokenParameters>>,\n context: Context,\n client: Client,\n mirrorNode: IHederaMirrornodeService,\n ): Promise<z.infer<ReturnType<typeof createFungibleTokenParametersNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof createFungibleTokenParameters>> =\n this.parseParamsWithSchema(params, createFungibleTokenParameters, context);\n\n const defaultAccountId = AccountResolver.getDefaultAccount(context, client);\n const treasuryAccountId = parsedParams.treasuryAccountId ?? defaultAccountId;\n if (!treasuryAccountId) throw new Error('Must include treasury account ID');\n\n const initialSupply = toBaseUnit(\n parsedParams.initialSupply ?? 0,\n parsedParams.decimals,\n ).toNumber();\n\n const isFinite = (parsedParams.supplyType ?? 'infinite') === 'finite';\n const supplyType = isFinite ? TokenSupplyType.Finite : TokenSupplyType.Infinite;\n\n const maxSupply = isFinite\n ? toBaseUnit(parsedParams.maxSupply ?? 1_000_000, parsedParams.decimals).toNumber() // default finite max supply\n : undefined;\n\n if (maxSupply !== undefined && initialSupply > maxSupply) {\n throw new Error(`Initial supply (${initialSupply}) cannot exceed max supply (${maxSupply})`);\n }\n\n const publicKey =\n (await mirrorNode.getAccount(defaultAccountId).then(r => r.accountPublicKey)) ??\n client.operatorPublicKey?.toStringDer();\n\n // Normalize scheduling parameters (if present and isScheduled = true)\n const schedulingParams = parsedParams?.schedulingParams?.isScheduled\n ? (await this.normaliseScheduledTransactionParams(parsedParams, context, client))\n .schedulingParams\n : { isScheduled: false };\n\n return {\n ...parsedParams,\n schedulingParams,\n supplyType,\n treasuryAccountId,\n maxSupply,\n initialSupply,\n autoRenewAccountId: defaultAccountId,\n supplyKey: parsedParams.isSupplyKey === true ? PublicKey.fromString(publicKey) : undefined,\n };\n }\n\n static async normaliseCreateNonFungibleTokenParams(\n params: z.infer<ReturnType<typeof createNonFungibleTokenParameters>>,\n context: Context,\n client: Client,\n mirrorNode: IHederaMirrornodeService,\n ): Promise<z.infer<ReturnType<typeof createNonFungibleTokenParametersNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof createNonFungibleTokenParameters>> =\n this.parseParamsWithSchema(params, createNonFungibleTokenParameters, context);\n\n const defaultAccountId = AccountResolver.getDefaultAccount(context, client);\n const treasuryAccountId = parsedParams.treasuryAccountId ?? defaultAccountId;\n if (!treasuryAccountId) throw new Error('Must include treasury account ID');\n\n const publicKey =\n (await mirrorNode.getAccount(defaultAccountId).then(r => r.accountPublicKey)) ??\n client.operatorPublicKey?.toStringDer();\n\n if (!publicKey) throw new Error('Could not determine public key for supply key');\n\n // Determine supply type based on user input\n const hasMaxSupply = parsedParams.maxSupply !== undefined;\n const userSupplyType = parsedParams.supplyType;\n\n let isFinite: boolean;\n if (hasMaxSupply) {\n // User provided maxSupply, so it must be finite\n isFinite = true;\n } else isFinite = userSupplyType !== 'infinite';\n\n const supplyType = isFinite ? TokenSupplyType.Finite : TokenSupplyType.Infinite;\n const maxSupply = isFinite ? (parsedParams.maxSupply ?? 100) : undefined;\n\n // Normalize scheduling parameters (if present and isScheduled = true)\n const schedulingParams = parsedParams?.schedulingParams?.isScheduled\n ? (await this.normaliseScheduledTransactionParams(parsedParams, context, client))\n .schedulingParams\n : { isScheduled: false };\n\n return {\n ...parsedParams,\n schedulingParams,\n treasuryAccountId,\n maxSupply,\n supplyKey: PublicKey.fromString(publicKey), // the supply key is mandatory in the case of NFT\n supplyType,\n autoRenewAccountId: defaultAccountId,\n tokenType: TokenType.NonFungibleUnique,\n };\n }\n\n static async normaliseTransferHbar(\n params: z.infer<ReturnType<typeof transferHbarParameters>>,\n context: Context,\n client: Client,\n ): Promise<z.infer<ReturnType<typeof transferHbarParametersNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof transferHbarParameters>> =\n this.parseParamsWithSchema(params, transferHbarParameters, context);\n\n const sourceAccountId = AccountResolver.resolveAccount(\n parsedParams.sourceAccountId,\n context,\n client,\n );\n\n const hbarTransfers: TransferHbarInput[] = [];\n let totalTinybars = Long.ZERO;\n\n for (const transfer of parsedParams.transfers) {\n const amount = new Hbar(transfer.amount);\n\n if (amount.isNegative() || amount.toTinybars().equals(Long.ZERO)) {\n throw new Error(`Invalid transfer amount: ${transfer.amount}`);\n }\n\n totalTinybars = totalTinybars.add(amount.toTinybars());\n\n hbarTransfers.push({\n accountId: transfer.accountId,\n amount,\n });\n }\n\n hbarTransfers.push({\n accountId: sourceAccountId,\n amount: Hbar.fromTinybars(totalTinybars.negate()),\n });\n\n // Normalize scheduling parameters (if present and isScheduled = true)\n const schedulingParams = parsedParams?.schedulingParams?.isScheduled\n ? (await this.normaliseScheduledTransactionParams(parsedParams, context, client))\n .schedulingParams\n : { isScheduled: false };\n\n return {\n hbarTransfers,\n schedulingParams,\n transactionMemo: parsedParams.transactionMemo,\n };\n }\n\n static normaliseTransferHbarWithAllowance(\n params: z.infer<ReturnType<typeof transferHbarWithAllowanceParameters>>,\n context: Context,\n _client: Client,\n ): z.infer<ReturnType<typeof transferHbarWithAllowanceParametersNormalised>> {\n const parsed = this.parseParamsWithSchema(params, transferHbarWithAllowanceParameters, context);\n\n const hbarTransfers: TransferHbarInput[] = [];\n let totalTinybars = Long.ZERO;\n\n for (const transfer of parsed.transfers) {\n const amount = new Hbar(transfer.amount);\n if (amount.isNegative() || amount.toTinybars().equals(Long.ZERO)) {\n throw new Error(`Invalid transfer amount: ${transfer.amount}`);\n }\n\n totalTinybars = totalTinybars.add(amount.toTinybars());\n\n hbarTransfers.push({\n accountId: transfer.accountId,\n amount,\n });\n }\n\n return {\n hbarTransfers,\n hbarApprovedTransfer: {\n ownerAccountId: parsed.sourceAccountId,\n amount: Hbar.fromTinybars(totalTinybars).negated(),\n },\n transactionMemo: parsed.transactionMemo,\n };\n }\n\n static normaliseApproveHbarAllowance(\n params: z.infer<ReturnType<typeof approveHbarAllowanceParameters>>,\n context: Context,\n client: Client,\n ): z.infer<ReturnType<typeof approveHbarAllowanceParametersNormalised>> {\n const parsedParams: z.infer<ReturnType<typeof approveHbarAllowanceParameters>> =\n this.parseParamsWithSchema(params, approveHbarAllowanceParameters, context);\n\n const ownerAccountId = AccountResolver.resolveAccount(\n parsedParams.ownerAccountId,\n context,\n client,\n );\n\n const spenderAccountId = parsedParams.spenderAccountId;\n\n const amount = new Hbar(parsedParams.amount);\n if (amount.isNegative()) {\n throw new Error(`Invalid allowance amount: ${parsedParams.amount}`);\n }\n\n return {\n hbarApprovals: [\n new HbarAllowance({\n ownerAccountId: AccountId.fromString(ownerAccountId),\n spenderAccountId: AccountId.fromString(spenderAccountId),\n amount,\n }),\n ],\n transactionMemo: parsedParams.transactionMemo,\n } as z.infer<ReturnType<typeof approveHbarAllowanceParametersNormalised>>;\n }\n\n /**\n * Normalizes parameters for deleting an HBAR allowance.\n *\n * This function sets the allowance `amount` to **0**, which is the Hedera\n * convention for revoking an existing allowance. It validates and resolves\n * the provided parameters, then returns an object compatible with\n * `approveHbarAllowanceParametersNormalised`.\n * @param params\n * @param context\n * @param client\n */\n static normaliseDeleteHbarAllowance(\n params: z.infer<ReturnType<typeof deleteHbarAllowanceParameters>>,\n context: Context,\n client: Client,\n ): z.infer<ReturnType<typeof approveHbarAllowanceParametersNormalised>> {\n const parsedParams = this.parseParamsWithSchema(params, deleteHbarAllowanceParameters, context);\n\n // Build approve params with amount = 0 (Hedera convention for revoke)\n const approveParams: z.infer<ReturnType<typeof approveHbarAllowanceParameters>> = {\n ownerAccountId: parsedParams.ownerAccountId,\n spenderAccountId: parsedParams.spenderAccountId,\n amount: 0,\n transactionMemo: parsedParams.transactionMemo,\n };\n\n // Delegate to the approval normalizer\n return this.normaliseApproveHbarAllowance(approveParams, context, client);\n }\n\n static normaliseApproveNftAllowance(\n params: z.infer<ReturnType<typeof approveNftAllowanceParameters>>,\n context: Context,\n client: Client,\n ): z.infer<ReturnType<typeof approveNftAllowanceParametersNormalised>> {\n const parsedParams: z.infer<ReturnType<typeof approveNftAllowanceParameters>> =\n this.parseParamsWithSchema(params, approveNftAllowanceParameters, context);\n\n const ownerAccountId = AccountResolver.resolveAccount(\n parsedParams.ownerAccountId,\n context,\n client,\n );\n\n const spenderAccountId = parsedParams.spenderAccountId;\n const tokenId = TokenId.fromString(parsedParams.tokenId);\n\n const approveAll = !!parsedParams.allSerials;\n const serials = parsedParams.serialNumbers ?? [];\n\n // Validate mutual exclusivity and required inputs\n if (approveAll && serials.length > 0) {\n throw new Error(\n 'When approving for all serials (allSerials=true), serialNumbers must not be provided.',\n );\n }\n if (!approveAll && serials.length === 0) {\n throw new Error('serialNumbers must contain at least one serial');\n }\n\n // Compute values for unified return\n const allSerialsValue: boolean | null = approveAll ? true : null;\n const serialNumbersValue: Long[] | null = approveAll\n ? null\n : serials.map(serialNumber => Long.fromNumber(serialNumber));\n\n return {\n nftApprovals: [\n new TokenNftAllowance({\n allSerials: allSerialsValue,\n delegatingSpender: null,\n ownerAccountId: AccountId.fromString(ownerAccountId),\n spenderAccountId: AccountId.fromString(spenderAccountId),\n tokenId,\n serialNumbers: serialNumbersValue,\n }),\n ],\n transactionMemo: parsedParams.transactionMemo,\n } as z.infer<ReturnType<typeof approveNftAllowanceParametersNormalised>>;\n }\n\n static normaliseDeleteNftAllowance(\n params: z.infer<ReturnType<typeof deleteNftAllowanceParameters>>,\n context: Context,\n client: Client,\n ): z.infer<ReturnType<typeof deleteNftAllowanceParametersNormalised>> {\n const parsedParams: z.infer<ReturnType<typeof deleteNftAllowanceParameters>> =\n this.parseParamsWithSchema(params, deleteNftAllowanceParameters, context);\n\n const ownerAccountId = AccountResolver.resolveAccount(\n parsedParams.ownerAccountId,\n context,\n client,\n );\n\n const tokenId = TokenId.fromString(parsedParams.tokenId);\n\n if (!parsedParams.serialNumbers || parsedParams.serialNumbers.length === 0) {\n throw new Error('serial_numbers must be provided');\n }\n\n // Convert serial numbers to NftId array\n const nftWipes = parsedParams.serialNumbers.map(serial => new NftId(tokenId, serial));\n\n return {\n nftWipes,\n ownerAccountId: AccountId.fromString(ownerAccountId),\n transactionMemo: parsedParams.transactionMemo,\n };\n }\n\n static normaliseTransferNonFungibleTokenWithAllowance(\n params: z.infer<ReturnType<typeof transferNonFungibleTokenWithAllowanceParameters>>,\n context: Context,\n ): z.infer<ReturnType<typeof transferNonFungibleTokenWithAllowanceParametersNormalised>> {\n // Validate input using schema\n const parsedParams: z.infer<\n ReturnType<typeof transferNonFungibleTokenWithAllowanceParameters>\n > = this.parseParamsWithSchema(\n params,\n transferNonFungibleTokenWithAllowanceParameters,\n context,\n );\n\n // Convert tokenId to SDK TokenId\n const tokenId = TokenId.fromString(parsedParams.tokenId);\n\n // Map recipients to normalized NFT transfers\n const seenSerials = new Set<number>();\n for (const { serialNumber } of parsedParams.recipients) {\n if (seenSerials.has(serialNumber)) {\n throw new Error(`Duplicate serial number: ${serialNumber}`);\n }\n seenSerials.add(serialNumber);\n }\n\n const transfers = parsedParams.recipients.map(recipient => ({\n nftId: new NftId(tokenId, Number(recipient.serialNumber)),\n receiver: AccountId.fromString(recipient.recipientId),\n }));\n\n return {\n sourceAccountId: AccountId.fromString(parsedParams.sourceAccountId),\n transactionMemo: parsedParams.transactionMemo,\n transfers,\n };\n }\n\n static async normaliseTransferNonFungibleToken(\n params: z.infer<ReturnType<typeof transferNonFungibleTokenParameters>>,\n context: Context,\n client: Client,\n ): Promise<z.infer<ReturnType<typeof transferNonFungibleTokenParametersNormalised>>> {\n // Validate input using schema\n const parsedParams: z.infer<ReturnType<typeof transferNonFungibleTokenParameters>> =\n this.parseParamsWithSchema(params, transferNonFungibleTokenParameters, context);\n\n // Resolve sender account (defaults to operator)\n const senderAccountId = AccountResolver.getDefaultAccount(context, client);\n if (!senderAccountId) {\n throw new Error('Could not determine sender account ID');\n }\n\n // Convert tokenId to SDK TokenId\n const tokenId = TokenId.fromString(parsedParams.tokenId);\n\n // Validate no duplicate serial numbers\n const seenSerials = new Set<number>();\n for (const { serialNumber } of parsedParams.recipients) {\n if (seenSerials.has(serialNumber)) {\n throw new Error(`Duplicate serial number: ${serialNumber}`);\n }\n seenSerials.add(serialNumber);\n }\n\n // Map recipients to normalized NFT transfers\n const transfers = parsedParams.recipients.map(recipient => ({\n nftId: new NftId(tokenId, Number(recipient.serialNumber)),\n receiver: AccountId.fromString(recipient.recipientId),\n }));\n\n // Normalize scheduling parameters (if present and isScheduled = true)\n const schedulingParams = parsedParams?.schedulingParams?.isScheduled\n ? (await this.normaliseScheduledTransactionParams(parsedParams, context, client))\n .schedulingParams\n : { isScheduled: false };\n\n return {\n senderAccountId: AccountId.fromString(senderAccountId),\n transactionMemo: parsedParams.transactionMemo,\n transfers,\n schedulingParams,\n };\n }\n\n static async normaliseApproveTokenAllowance(\n params: z.infer<ReturnType<typeof approveTokenAllowanceParameters>>,\n context: Context,\n client: Client,\n mirrorNode: IHederaMirrornodeService,\n ): Promise<z.infer<ReturnType<typeof approveTokenAllowanceParametersNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof approveTokenAllowanceParameters>> =\n this.parseParamsWithSchema(params, approveTokenAllowanceParameters, context);\n\n const ownerAccountId = AccountResolver.resolveAccount(\n parsedParams.ownerAccountId,\n context,\n client,\n );\n\n const spenderAccountId = parsedParams.spenderAccountId;\n\n const tokenAllowancesPromises = parsedParams.tokenApprovals.map(async tokenAllowance => {\n const tokenInfo = await mirrorNode.getTokenInfo(tokenAllowance.tokenId);\n const decimals = Number(tokenInfo.decimals);\n\n // Fallback to 0 if decimals are missing or NaN\n const safeDecimals = Number.isFinite(decimals) ? decimals : 0;\n\n const baseAmount = toBaseUnit(tokenAllowance.amount, safeDecimals).toNumber();\n\n return new TokenAllowance({\n ownerAccountId: AccountId.fromString(ownerAccountId),\n spenderAccountId: AccountId.fromString(spenderAccountId),\n tokenId: TokenId.fromString(tokenAllowance.tokenId),\n amount: Long.fromNumber(baseAmount),\n });\n });\n\n return {\n transactionMemo: parsedParams.transactionMemo,\n tokenApprovals: await Promise.all(tokenAllowancesPromises),\n } as z.infer<ReturnType<typeof approveTokenAllowanceParametersNormalised>>;\n }\n\n /**\n * Normalizes parameters for deleting a Fungible Token allowance.\n *\n * This function sets the allowance `amount` to **0**, which is the Hedera\n * convention for revoking an existing allowance. It validates and resolves\n * the provided parameters, then returns an object compatible with\n * `approveTokenAllowanceParametersNormalised`.\n * @param params\n * @param context\n * @param client\n * @param mirrorNode\n */\n static async normaliseDeleteTokenAllowance(\n params: z.infer<ReturnType<typeof deleteTokenAllowanceParameters>>,\n context: Context,\n client: Client,\n mirrorNode: IHederaMirrornodeService,\n ): Promise<z.infer<ReturnType<typeof approveTokenAllowanceParametersNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof deleteTokenAllowanceParameters>> =\n this.parseParamsWithSchema(params, deleteTokenAllowanceParameters, context);\n\n // Build approve params with amount = 0 (Hedera convention for revoke)\n const approveParams: z.infer<ReturnType<typeof approveTokenAllowanceParameters>> = {\n ownerAccountId: parsedParams.ownerAccountId,\n spenderAccountId: parsedParams.spenderAccountId,\n tokenApprovals: parsedParams.tokenIds.map(tokenId => ({ tokenId: tokenId, amount: 0 })),\n transactionMemo: parsedParams.transactionMemo,\n };\n // Delegate to the approval normalizer\n return this.normaliseApproveTokenAllowance(approveParams, context, client, mirrorNode);\n }\n\n static async normaliseTransferFungibleTokenWithAllowance(\n params: z.infer<ReturnType<typeof transferFungibleTokenWithAllowanceParameters>>,\n context: Context,\n client: Client,\n mirrodnode: IHederaMirrornodeService,\n ): Promise<z.infer<ReturnType<typeof transferFungibleTokenWithAllowanceParametersNormalised>>> {\n const parsedParams = this.parseParamsWithSchema(\n params,\n transferFungibleTokenWithAllowanceParameters,\n context,\n );\n const tokenInfo = await mirrodnode.getTokenInfo(parsedParams.tokenId);\n const tokenDecimals = tokenInfo.decimals;\n\n const tokenTransfers: TokenTransferMinimalParams[] = [];\n let totalAmount = 0;\n\n for (const transfer of parsedParams.transfers) {\n totalAmount += transfer.amount;\n tokenTransfers.push({\n accountId: transfer.accountId,\n amount: toBaseUnit(transfer.amount, Number(tokenDecimals)).toNumber(),\n tokenId: parsedParams.tokenId,\n });\n }\n\n // Normalize scheduling parameters (if present and isScheduled = true)\n const schedulingParams = parsedParams?.schedulingParams?.isScheduled\n ? (await this.normaliseScheduledTransactionParams(parsedParams, context, client))\n .schedulingParams\n : { isScheduled: false };\n\n return {\n schedulingParams,\n tokenId: parsedParams.tokenId,\n tokenTransfers,\n approvedTransfer: {\n ownerAccountId: parsedParams.sourceAccountId,\n amount: toBaseUnit(-totalAmount, Number(tokenDecimals)).toNumber(),\n },\n transactionMemo: parsedParams.transactionMemo,\n };\n }\n\n static async normaliseAirdropFungibleTokenParams(\n params: z.infer<ReturnType<typeof airdropFungibleTokenParameters>>,\n context: Context,\n client: Client,\n mirrorNode: IHederaMirrornodeService,\n ): Promise<z.infer<ReturnType<typeof airdropFungibleTokenParametersNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof airdropFungibleTokenParameters>> =\n this.parseParamsWithSchema(params, airdropFungibleTokenParameters, context);\n\n const sourceAccountId = AccountResolver.resolveAccount(\n parsedParams.sourceAccountId,\n context,\n client,\n );\n\n const tokenInfo = await mirrorNode.getTokenInfo(parsedParams.tokenId);\n const tokenDecimals = parseInt(tokenInfo.decimals, 10);\n\n if (isNaN(tokenDecimals)) {\n throw new Error(`Invalid token decimals for token ${parsedParams.tokenId}`);\n }\n\n const tokenTransfers: TokenTransferMinimalParams[] = [];\n let totalAmount = Long.ZERO;\n\n for (const recipient of parsedParams.recipients) {\n const amountRaw = Number(recipient.amount);\n\n if (amountRaw <= 0) {\n throw new Error(`Invalid recipient amount: ${recipient.amount}`);\n }\n\n const amount = Long.fromString(toBaseUnit(amountRaw, tokenDecimals).toNumber().toString());\n\n totalAmount = totalAmount.add(amount);\n\n tokenTransfers.push({\n tokenId: parsedParams.tokenId,\n accountId: recipient.accountId,\n amount,\n });\n }\n\n // Sender negative total\n tokenTransfers.push({\n tokenId: parsedParams.tokenId,\n accountId: sourceAccountId,\n amount: totalAmount.negate(),\n });\n\n return {\n tokenTransfers,\n };\n }\n\n static normaliseAssociateTokenParams(\n params: z.infer<ReturnType<typeof associateTokenParameters>>,\n context: Context,\n client: Client,\n ): z.infer<ReturnType<typeof associateTokenParametersNormalised>> {\n const parsedParams: z.infer<ReturnType<typeof associateTokenParameters>> =\n this.parseParamsWithSchema(params, associateTokenParameters, context);\n\n const accountId = AccountResolver.resolveAccount(parsedParams.accountId, context, client);\n return {\n accountId,\n tokenIds: parsedParams.tokenIds,\n };\n }\n\n static async normaliseDissociateTokenParams(\n params: z.infer<ReturnType<typeof dissociateTokenParameters>>,\n context: Context,\n client: Client,\n ): Promise<z.infer<ReturnType<typeof dissociateTokenParametersNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof dissociateTokenParameters>> =\n this.parseParamsWithSchema(params, dissociateTokenParameters, context);\n\n if (parsedParams.accountId === undefined) {\n parsedParams.accountId = AccountResolver.getDefaultAccount(context, client);\n\n if (!parsedParams.accountId) {\n throw new Error('Could not determine default account ID');\n }\n }\n\n return {\n ...parsedParams,\n accountId: AccountId.fromString(parsedParams.accountId),\n tokenIds: parsedParams.tokenIds.map(id => TokenId.fromString(id)),\n };\n }\n\n static async normaliseCreateTopicParams(\n params: z.infer<ReturnType<typeof createTopicParameters>>,\n context: Context,\n client: Client,\n mirrorNode: IHederaMirrornodeService,\n ): Promise<z.infer<ReturnType<typeof createTopicParametersNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof createTopicParameters>> =\n this.parseParamsWithSchema(params, createTopicParameters, context);\n\n const defaultAccountId = AccountResolver.getDefaultAccount(context, client);\n if (!defaultAccountId) throw new Error('Could not determine default account ID');\n\n const normalised: z.infer<ReturnType<typeof createTopicParametersNormalised>> = {\n ...parsedParams,\n autoRenewAccountId: defaultAccountId,\n };\n\n if (parsedParams.isSubmitKey) {\n const publicKey =\n (await mirrorNode.getAccount(defaultAccountId).then(r => r.accountPublicKey)) ??\n client.operatorPublicKey?.toStringDer();\n if (!publicKey) {\n throw new Error('Could not determine public key for submit key');\n }\n normalised.submitKey = PublicKey.fromString(publicKey);\n }\n\n return normalised;\n }\n\n static normaliseDeleteTopic(\n params: z.infer<ReturnType<typeof deleteTopicParameters>>,\n context: Context,\n _client: Client,\n _mirrorNode: IHederaMirrornodeService,\n ): z.infer<ReturnType<typeof deleteTopicParametersNormalised>> {\n // First, validate against the basic schema\n const parsedParams: z.infer<ReturnType<typeof deleteTopicParameters>> =\n this.parseParamsWithSchema(params, deleteTopicParameters, context);\n\n // Then, validate against the normalized schema delete topic schema\n return this.parseParamsWithSchema(parsedParams, deleteTopicParametersNormalised, context);\n }\n\n static normaliseUpdateTopic = async (\n params: z.infer<ReturnType<typeof updateTopicParameters>>,\n context: Context,\n client: Client,\n ): Promise<z.infer<ReturnType<typeof updateTopicParametersNormalised>>> => {\n const parsedParams: z.infer<ReturnType<typeof updateTopicParameters>> =\n this.parseParamsWithSchema(params, updateTopicParameters, context);\n\n const topicId = TopicId.fromString(parsedParams.topicId);\n const userPublicKey = await AccountResolver.getDefaultPublicKey(context, client);\n\n const normalised: z.infer<ReturnType<typeof updateTopicParametersNormalised>> = {\n topicId,\n } as any;\n\n // Keys\n const maybeKeys: Record<string, string | boolean | undefined> = {\n adminKey: parsedParams.adminKey,\n submitKey: parsedParams.submitKey,\n };\n\n for (const [field, rawVal] of Object.entries(maybeKeys)) {\n const resolved = this.resolveKey(rawVal, userPublicKey);\n if (resolved) {\n (normalised as any)[field] = resolved;\n }\n }\n\n // Other optional props\n if (parsedParams.topicMemo) normalised.topicMemo = parsedParams.topicMemo;\n if (parsedParams.autoRenewAccountId)\n normalised.autoRenewAccountId = parsedParams.autoRenewAccountId;\n if (parsedParams.autoRenewPeriod) normalised.autoRenewPeriod = parsedParams.autoRenewPeriod;\n if (parsedParams.expirationTime) {\n normalised.expirationTime =\n parsedParams.expirationTime instanceof Date\n ? parsedParams.expirationTime\n : new Date(parsedParams.expirationTime);\n }\n\n return normalised;\n };\n\n static normaliseSubmitTopicMessage = async (\n params: z.infer<ReturnType<typeof submitTopicMessageParameters>>,\n context: Context,\n client: Client,\n ): Promise<z.infer<ReturnType<typeof submitTopicMessageParametersNormalised>>> => {\n const parsedParams: z.infer<ReturnType<typeof submitTopicMessageParameters>> =\n this.parseParamsWithSchema(params, submitTopicMessageParameters, context);\n\n // Normalize scheduling parameters (if present and isScheduled = true)\n const schedulingParams = parsedParams?.schedulingParams?.isScheduled\n ? (await this.normaliseScheduledTransactionParams(parsedParams, context, client))\n .schedulingParams\n : { isScheduled: false };\n\n return {\n ...parsedParams,\n schedulingParams,\n };\n };\n\n static async normaliseCreateAccount(\n params: z.infer<ReturnType<typeof createAccountParameters>>,\n context: Context,\n client: Client,\n mirrorNode: IHederaMirrornodeService,\n ): Promise<z.infer<ReturnType<typeof createAccountParametersNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof createAccountParameters>> =\n this.parseParamsWithSchema(params, createAccountParameters, context);\n\n // Try resolving the publicKey in priority order\n let publicKey = parsedParams.publicKey ?? client.operatorPublicKey?.toStringDer();\n\n if (!publicKey) {\n const defaultAccountId = AccountResolver.getDefaultAccount(context, client);\n if (defaultAccountId) {\n const account = await mirrorNode.getAccount(defaultAccountId);\n publicKey = account?.accountPublicKey;\n }\n }\n\n if (!publicKey) {\n throw new Error(\n 'Unable to resolve public key: no param, mirror node, or client operator key available.',\n );\n }\n\n // Normalize scheduling parameters (if present and isScheduled = true)\n const schedulingParams = parsedParams.schedulingParams?.isScheduled\n ? (await this.normaliseScheduledTransactionParams(parsedParams, context, client))\n .schedulingParams\n : { isScheduled: false };\n\n return {\n ...parsedParams,\n schedulingParams,\n key: PublicKey.fromString(publicKey),\n };\n }\n\n static normaliseHbarBalanceParams(\n params: z.infer<ReturnType<typeof accountBalanceQueryParameters>>,\n context: Context,\n client: Client,\n ): z.infer<ReturnType<typeof accountBalanceQueryParametersNormalised>> {\n const parsedParams: z.infer<ReturnType<typeof accountBalanceQueryParameters>> =\n this.parseParamsWithSchema(params, accountBalanceQueryParameters, context);\n\n const accountId = AccountResolver.resolveAccount(parsedParams.accountId, context, client);\n return {\n accountId,\n };\n }\n\n static normaliseAccountTokenBalancesParams(\n params: z.infer<ReturnType<typeof accountTokenBalancesQueryParameters>>,\n context: Context,\n client: Client,\n ): z.infer<ReturnType<typeof accountTokenBalancesQueryParametersNormalised>> {\n const parsedParams: z.infer<ReturnType<typeof accountTokenBalancesQueryParameters>> =\n this.parseParamsWithSchema(params, accountTokenBalancesQueryParameters, context);\n\n const accountId = AccountResolver.resolveAccount(parsedParams.accountId, context, client);\n return {\n ...parsedParams,\n accountId,\n };\n }\n\n static async normaliseCreateERC20Params(\n params: z.infer<ReturnType<typeof createERC20Parameters>>,\n factoryContractId: string,\n factoryContractAbi: string[],\n factoryContractFunctionName: string,\n context: Context,\n client: Client,\n ): Promise<z.infer<ReturnType<typeof evmContractCallParamsNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof createERC20Parameters>> =\n this.parseParamsWithSchema(params, createERC20Parameters, context);\n\n // Create an interface for encoding\n const iface = new ethers.Interface(factoryContractAbi);\n\n // Encode the function call\n const encodedData = iface.encodeFunctionData(factoryContractFunctionName, [\n parsedParams.tokenName,\n parsedParams.tokenSymbol,\n parsedParams.decimals,\n parsedParams.initialSupply,\n ]);\n\n const functionParameters = ethers.getBytes(encodedData);\n\n // Normalize scheduling parameters (if present and isScheduled = true)\n const schedulingParams = parsedParams?.schedulingParams?.isScheduled\n ? (await this.normaliseScheduledTransactionParams(parsedParams, context, client))\n .schedulingParams\n : { isScheduled: false };\n\n return {\n ...parsedParams,\n contractId: factoryContractId,\n functionParameters,\n gas: 3000000, //TODO: make this configurable\n schedulingParams,\n };\n }\n\n static async normaliseCreateERC721Params(\n params: z.infer<ReturnType<typeof createERC721Parameters>>,\n factoryContractId: string,\n factoryContractAbi: string[],\n factoryContractFunctionName: string,\n context: Context,\n client: Client,\n ): Promise<z.infer<ReturnType<typeof evmContractCallParamsNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof createERC721Parameters>> =\n this.parseParamsWithSchema(params, createERC721Parameters, context);\n\n // Create an interface for encoding\n const iface = new ethers.Interface(factoryContractAbi);\n\n // Encode the function call\n const encodedData = iface.encodeFunctionData(factoryContractFunctionName, [\n parsedParams.tokenName,\n parsedParams.tokenSymbol,\n parsedParams.baseURI,\n ]);\n\n const functionParameters = ethers.getBytes(encodedData);\n\n // Normalize scheduling parameters (if present and isScheduled = true)\n const schedulingParams = parsedParams?.schedulingParams?.isScheduled\n ? (await this.normaliseScheduledTransactionParams(parsedParams, context, client))\n .schedulingParams\n : { isScheduled: false };\n\n return {\n ...parsedParams,\n contractId: factoryContractId,\n functionParameters,\n gas: 3000000, //TODO: make this configurable\n schedulingParams,\n };\n }\n\n static async normaliseMintFungibleTokenParams(\n params: z.infer<ReturnType<typeof mintFungibleTokenParameters>>,\n context: Context,\n client: Client,\n mirrorNode: IHederaMirrornodeService,\n ): Promise<z.infer<ReturnType<typeof mintFungibleTokenParametersNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof mintFungibleTokenParameters>> =\n this.parseParamsWithSchema(params, mintFungibleTokenParameters, context);\n\n const tokenInfo = await mirrorNode.getTokenInfo(parsedParams.tokenId);\n const decimals = Number(tokenInfo.decimals);\n\n // Fallback to 0 if decimals are missing or NaN\n const safeDecimals = Number.isFinite(decimals) ? decimals : 0;\n\n const baseAmount = toBaseUnit(parsedParams.amount, safeDecimals).toNumber();\n\n // Normalize scheduling parameters (if present and isScheduled = true)\n const schedulingParams = parsedParams?.schedulingParams?.isScheduled\n ? (await this.normaliseScheduledTransactionParams(parsedParams, context, client))\n .schedulingParams\n : { isScheduled: false };\n\n return {\n schedulingParams,\n tokenId: parsedParams.tokenId,\n amount: baseAmount,\n };\n }\n\n static async normaliseMintNonFungibleTokenParams(\n params: z.infer<ReturnType<typeof mintNonFungibleTokenParameters>>,\n context: Context,\n client: Client,\n ): Promise<z.infer<ReturnType<typeof mintNonFungibleTokenParametersNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof mintNonFungibleTokenParameters>> =\n this.parseParamsWithSchema(params, mintNonFungibleTokenParameters, context);\n\n const encoder = new TextEncoder();\n const metadata = parsedParams.uris.map(uri => encoder.encode(uri));\n\n // Normalize scheduling parameters (if present and isScheduled = true)\n const schedulingParams = parsedParams?.schedulingParams?.isScheduled\n ? (await this.normaliseScheduledTransactionParams(parsedParams, context, client))\n .schedulingParams\n : { isScheduled: false };\n\n return {\n ...parsedParams,\n schedulingParams,\n metadata: metadata,\n };\n }\n\n static async normaliseTransferERC20Params(\n params: z.infer<ReturnType<typeof transferERC20Parameters>>,\n factoryContractAbi: string[],\n factoryContractFunctionName: string,\n context: Context,\n mirrorNode: IHederaMirrornodeService,\n client: Client,\n ): Promise<z.infer<ReturnType<typeof evmContractCallParamsNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof transferERC20Parameters>> =\n this.parseParamsWithSchema(params, transferERC20Parameters, context);\n\n const recipientAddress = await AccountResolver.getHederaEVMAddress(\n parsedParams.recipientAddress,\n mirrorNode,\n );\n const contractId = await HederaParameterNormaliser.getHederaAccountId(\n parsedParams.contractId,\n mirrorNode,\n );\n const iface = new ethers.Interface(factoryContractAbi);\n const encodedData = iface.encodeFunctionData(factoryContractFunctionName, [\n recipientAddress,\n parsedParams.amount,\n ]);\n\n const functionParameters = ethers.getBytes(encodedData);\n\n // Normalize scheduling parameters (if present and isScheduled = true)\n const schedulingParams = parsedParams?.schedulingParams?.isScheduled\n ? (await this.normaliseScheduledTransactionParams(parsedParams, context, client))\n .schedulingParams\n : { isScheduled: false };\n\n return {\n contractId,\n functionParameters,\n gas: 100_000,\n schedulingParams,\n };\n }\n\n static async normaliseTransferERC721Params(\n params: z.infer<ReturnType<typeof transferERC721Parameters>>,\n factoryContractAbi: string[],\n factoryContractFunctionName: string,\n context: Context,\n mirrorNode: IHederaMirrornodeService,\n client: Client,\n ): Promise<z.infer<ReturnType<typeof evmContractCallParamsNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof transferERC721Parameters>> =\n this.parseParamsWithSchema(params, transferERC721Parameters, context);\n\n // Resolve fromAddress using AccountResolver pattern, similar to transfer-hbar\n const resolvedFromAddress = AccountResolver.resolveAccount(\n parsedParams.fromAddress,\n context,\n client,\n );\n const fromAddress = await AccountResolver.getHederaEVMAddress(resolvedFromAddress, mirrorNode);\n const toAddress = await AccountResolver.getHederaEVMAddress(parsedParams.toAddress, mirrorNode);\n const contractId = await HederaParameterNormaliser.getHederaAccountId(\n parsedParams.contractId,\n mirrorNode,\n );\n const iface = new ethers.Interface(factoryContractAbi);\n const encodedData = iface.encodeFunctionData(factoryContractFunctionName, [\n fromAddress,\n toAddress,\n parsedParams.tokenId,\n ]);\n\n const functionParameters = ethers.getBytes(encodedData);\n\n // Normalize scheduling parameters (if present and isScheduled = true)\n const schedulingParams = parsedParams?.schedulingParams?.isScheduled\n ? (await this.normaliseScheduledTransactionParams(parsedParams, context, client))\n .schedulingParams\n : { isScheduled: false };\n\n return {\n contractId,\n functionParameters,\n gas: 100_000,\n schedulingParams,\n };\n }\n\n static async normaliseMintERC721Params(\n params: z.infer<ReturnType<typeof mintERC721Parameters>>,\n factoryContractAbi: string[],\n factoryContractFunctionName: string,\n context: Context,\n mirrorNode: IHederaMirrornodeService,\n client: Client,\n ): Promise<z.infer<ReturnType<typeof evmContractCallParamsNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof mintERC721Parameters>> =\n this.parseParamsWithSchema(params, mintERC721Parameters, context);\n\n const resolvedToAddress = AccountResolver.resolveAccount(\n parsedParams.toAddress,\n context,\n client,\n );\n const toAddress = await AccountResolver.getHederaEVMAddress(resolvedToAddress, mirrorNode);\n const contractId = await HederaParameterNormaliser.getHederaAccountId(\n parsedParams.contractId,\n mirrorNode,\n );\n const iface = new ethers.Interface(factoryContractAbi);\n const encodedData = iface.encodeFunctionData(factoryContractFunctionName, [toAddress]);\n const functionParameters = ethers.getBytes(encodedData);\n\n // Normalize scheduling parameters (if present and isScheduled = true)\n const schedulingParams = parsedParams?.schedulingParams?.isScheduled\n ? (await this.normaliseScheduledTransactionParams(parsedParams, context, client))\n .schedulingParams\n : { isScheduled: false };\n\n return {\n contractId,\n functionParameters,\n gas: 100_000,\n schedulingParams,\n };\n }\n\n static normaliseDeleteAccount(\n params: z.infer<ReturnType<typeof deleteAccountParameters>>,\n context: Context,\n client: Client,\n ): z.infer<ReturnType<typeof deleteAccountParametersNormalised>> {\n const parsedParams: z.infer<ReturnType<typeof deleteAccountParameters>> =\n this.parseParamsWithSchema(params, deleteAccountParameters, context);\n\n if (!AccountResolver.isHederaAddress(parsedParams.accountId)) {\n throw new Error('Account ID must be a Hedera address');\n }\n\n // if no transfer account ID is provided, use the operator account ID\n const transferAccountId =\n parsedParams.transferAccountId ?? AccountResolver.getDefaultAccount(context, client);\n if (!transferAccountId) {\n throw new Error('Could not determine transfer account ID');\n }\n\n return {\n accountId: AccountId.fromString(parsedParams.accountId),\n transferAccountId: AccountId.fromString(transferAccountId),\n };\n }\n\n static async normaliseUpdateAccount(\n params: z.infer<ReturnType<typeof updateAccountParameters>>,\n context: Context,\n client: Client,\n ): Promise<z.infer<ReturnType<typeof updateAccountParametersNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof updateAccountParameters>> =\n this.parseParamsWithSchema(params, updateAccountParameters, context);\n\n const accountId = AccountId.fromString(\n AccountResolver.resolveAccount(parsedParams.accountId, context, client),\n );\n\n const normalised: z.infer<ReturnType<typeof updateAccountParametersNormalised>> = {\n accountId,\n } as any;\n\n if (parsedParams.maxAutomaticTokenAssociations !== undefined) {\n normalised.maxAutomaticTokenAssociations = parsedParams.maxAutomaticTokenAssociations;\n }\n if (parsedParams.stakedAccountId !== undefined) {\n normalised.stakedAccountId = parsedParams.stakedAccountId;\n }\n if (parsedParams.accountMemo !== undefined) {\n normalised.accountMemo = parsedParams.accountMemo;\n }\n if (parsedParams.declineStakingReward !== undefined) {\n normalised.declineStakingReward = parsedParams.declineStakingReward;\n }\n\n // Normalize scheduling parameters (if present and isScheduled = true)\n const schedulingParams = parsedParams?.schedulingParams?.isScheduled\n ? (await this.normaliseScheduledTransactionParams(parsedParams, context, client))\n .schedulingParams\n : { isScheduled: false };\n\n return {\n ...normalised,\n schedulingParams,\n };\n }\n\n static normaliseGetTransactionRecordParams(\n params: z.infer<ReturnType<typeof transactionRecordQueryParameters>>,\n context: Context,\n ): z.infer<ReturnType<typeof normalisedTransactionRecordQueryParameters>> {\n const parsedParams: z.infer<ReturnType<typeof transactionRecordQueryParameters>> =\n this.parseParamsWithSchema(params, transactionRecordQueryParameters, context);\n\n const normalised: z.infer<ReturnType<typeof normalisedTransactionRecordQueryParameters>> = {\n nonce: parsedParams.nonce,\n } as any;\n\n if (!parsedParams.transactionId) {\n throw new Error('transactionId is required');\n }\n\n const mirrorNodeStyleRegex = /^\\d+\\.\\d+\\.\\d+-\\d+-\\d+$/;\n const sdkStyleRegex = /^(\\d+\\.\\d+\\.\\d+)@(\\d+)\\.(\\d+)$/;\n\n if (mirrorNodeStyleRegex.test(parsedParams.transactionId)) {\n // Already in mirror-node style, use as-is\n normalised.transactionId = parsedParams.transactionId;\n } else {\n const match = parsedParams.transactionId.match(sdkStyleRegex);\n if (!match) {\n throw new Error(`Invalid transactionId format: ${parsedParams.transactionId}`);\n }\n\n const [, accountId, seconds, nanos] = match;\n normalised.transactionId = `${accountId}-${seconds}-${nanos}`;\n }\n\n return normalised;\n }\n\n static async getHederaAccountId(\n address: string,\n mirrorNode: IHederaMirrornodeService,\n ): Promise<string> {\n if (AccountResolver.isHederaAddress(address)) {\n return address;\n }\n const account = await mirrorNode.getAccount(address);\n return account.accountId;\n }\n\n static async normaliseUpdateToken(\n params: z.infer<ReturnType<typeof updateTokenParameters>>,\n context: Context,\n client: Client,\n ): Promise<z.infer<ReturnType<typeof updateTokenParametersNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof updateTokenParameters>> =\n this.parseParamsWithSchema(params, updateTokenParameters, context);\n\n const tokenId = TokenId.fromString(parsedParams.tokenId);\n const userPublicKey = await AccountResolver.getDefaultPublicKey(context, client);\n\n const normalised: z.infer<ReturnType<typeof updateTokenParametersNormalised>> = {\n tokenId,\n };\n\n // Keys\n const maybeKeys: Record<string, string | boolean | undefined> = {\n adminKey: parsedParams.adminKey,\n supplyKey: parsedParams.supplyKey,\n wipeKey: parsedParams.wipeKey,\n freezeKey: parsedParams.freezeKey,\n kycKey: parsedParams.kycKey,\n feeScheduleKey: parsedParams.feeScheduleKey,\n pauseKey: parsedParams.pauseKey,\n metadataKey: parsedParams.metadataKey,\n };\n\n for (const [field, rawVal] of Object.entries(maybeKeys)) {\n const resolved = this.resolveKey(rawVal, userPublicKey);\n if (resolved) {\n (normalised as any)[field] = resolved;\n }\n }\n\n // Other optional props\n if (parsedParams.tokenName) {\n normalised.tokenName = parsedParams.tokenName;\n }\n if (parsedParams.tokenSymbol) {\n normalised.tokenSymbol = parsedParams.tokenSymbol;\n }\n if (parsedParams.treasuryAccountId) {\n normalised.treasuryAccountId = parsedParams.treasuryAccountId;\n }\n if (parsedParams.tokenMemo) {\n normalised.tokenMemo = parsedParams.tokenMemo;\n }\n if (parsedParams.metadata) {\n normalised.metadata = new TextEncoder().encode(parsedParams.metadata);\n }\n if (parsedParams.autoRenewAccountId) {\n normalised.autoRenewAccountId = parsedParams.autoRenewAccountId;\n }\n\n return normalised;\n }\n\n static async normaliseScheduledTransactionParams(\n params: z.infer<ReturnType<typeof optionalScheduledTransactionParams>>,\n context: Context,\n client: Client,\n ): Promise<z.infer<ReturnType<typeof optionalScheduledTransactionParamsNormalised>>> {\n const parsedParams: z.infer<ReturnType<typeof optionalScheduledTransactionParams>> =\n HederaParameterNormaliser.parseParamsWithSchema(\n params,\n optionalScheduledTransactionParams,\n context,\n );\n\n const scheduling = parsedParams.schedulingParams;\n\n const userPublicKey = await AccountResolver.getDefaultPublicKey(context, client);\n\n // Resolve adminKey\n const adminKey = HederaParameterNormaliser.resolveKey(scheduling?.adminKey, userPublicKey);\n\n // Resolve payerAccountID\n const payerAccountID = scheduling?.payerAccountId\n ? AccountId.fromString(scheduling?.payerAccountId)\n : undefined;\n\n // Resolve expirationTime\n const expirationTime = scheduling?.expirationTime\n ? Timestamp.fromDate(scheduling?.expirationTime)\n : undefined;\n\n return {\n schedulingParams: {\n isScheduled: scheduling?.isScheduled ?? false,\n adminKey,\n payerAccountID,\n expirationTime,\n waitForExpiry: scheduling?.waitForExpiry ?? false,\n },\n };\n }\n\n /**\n * Resolves a raw key value to a Hedera PublicKey instance.\n *\n * This method handles multiple input formats:\n * - `undefined`: Returns undefined\n * - `string`: Attempts to parse as ED25519, ECDSA, or generic PublicKey format\n * - ED25519: Hex-encoded (64 chars) or DER-encoded string\n * - ECDSA: Hex-encoded (66 chars with prefix) or DER-encoded string\n * - `true`: Returns the provided userKey\n * - `false`: Returns undefined\n *\n * @param rawValue - The raw key value from user input (string, boolean, or undefined)\n * @param userKey - The fallback PublicKey to use when rawValue is `true`\n * @returns The resolved PublicKey or undefined\n *\n * @example\n * // String input - ED25519 hex\n * resolveKey(\"302a300506032b6570032100...\", userKey)\n *\n * @example\n * // Boolean input - use userKey\n * resolveKey(true, userKey) // returns userKey\n *\n * @example\n * // Undefined input\n * resolveKey(undefined, userKey) // returns undefined\n */\n private static resolveKey(\n rawValue: string | boolean | undefined,\n userKey: PublicKey,\n ): PublicKey | undefined {\n if (rawValue === undefined) {\n return undefined;\n }\n\n if (typeof rawValue === 'string') {\n const lower = rawValue.toLowerCase();\n if (lower === 'true') return userKey;\n if (lower === 'false') return undefined;\n\n // Attempt to parse string as ED25519 key first\n try {\n return PublicKey.fromStringED25519(rawValue);\n } catch {\n // Ignore and try next format\n }\n\n // Attempt to parse string as ECDSA key\n try {\n return PublicKey.fromStringECDSA(rawValue);\n } catch {\n // Ignore and try next format\n }\n\n // Final attempt: generic PublicKey parser (handles DER format)\n try {\n return PublicKey.fromString(rawValue);\n } catch {\n // All parsing attempts failed\n throw new Error(\n `Failed to parse public key from string: ${rawValue.substring(0, 20)}...`,\n );\n }\n }\n\n // Handle boolean: true returns userKey, false returns undefined\n return rawValue ? userKey : undefined;\n }\n}\n","import BigNumber from 'bignumber.js';\n\n/**\n * Converts a token amount to base units (the smallest denomination).\n * Example: toBaseUnit(1.5, 8) => BigNumber(150000000)\n *\n * @param amount - The human-readable token amount (number or BigNumber).\n * @param decimals - The number of decimals the token uses.\n * @returns The amount in base units as BigNumber.\n */\nexport function toBaseUnit(amount: number | BigNumber, decimals: number): BigNumber {\n const amountBN = new BigNumber(amount);\n const multiplier = new BigNumber(10).pow(decimals);\n return amountBN.multipliedBy(multiplier).integerValue(BigNumber.ROUND_FLOOR);\n}\n\n/**\n * Converts a base unit amount to a human-readable value.\n * Example: toDisplayUnit(150000000, 8) => BigNumber(1.5)\n *\n * @param baseAmount - The amount in base units (number or BigNumber).\n * @param decimals - The number of decimals the token uses.\n * @returns The human-readable token amount as BigNumber.\n */\nexport function toDisplayUnit(baseAmount: number | BigNumber, decimals: number): BigNumber {\n const baseAmountBN = new BigNumber(baseAmount);\n const divisor = new BigNumber(10).pow(decimals);\n return baseAmountBN.dividedBy(divisor);\n}\n","import { Client, PublicKey } from '@hashgraph/sdk';\nimport { Context, AgentMode } from '@/shared/configuration';\nimport { IHederaMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-service.interface';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\n\nexport class AccountResolver {\n /**\n * Gets the default account based on the agent mode and context.\n * In RETURN_BYTES mode, prefers context.accountId (user's account).\n * In AUTONOMOUS mode or when no context account, uses an operator account.\n */\n static getDefaultAccount(context: Context, client: Client): string {\n // Prefer context.accountId (user's account) if it is set\n if (context.accountId) {\n return context.accountId;\n }\n\n // Use operator account if context.accountId is not set\n const operatorAccount = client.operatorAccountId?.toString();\n if (!operatorAccount) {\n throw new Error('No account available: neither context.accountId nor operator account');\n }\n\n return operatorAccount;\n }\n\n static async getDefaultPublicKey(context: Context, client: Client): Promise<PublicKey> {\n if (context.mode === AgentMode.AUTONOMOUS) {\n return client.operatorPublicKey!;\n }\n\n const defaultAccount = this.getDefaultAccount(context, client);\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n\n const defaultAccountDetails = await mirrornodeService.getAccount(defaultAccount);\n\n if (!defaultAccountDetails?.accountPublicKey) {\n throw new Error('No public key available for the default account');\n }\n\n return PublicKey.fromString(defaultAccountDetails.accountPublicKey);\n }\n\n /**\n * Resolves an account ID, using the provided account or falling back to the default.\n */\n static resolveAccount(\n providedAccount: string | undefined,\n context: Context,\n client: Client,\n ): string {\n return providedAccount || this.getDefaultAccount(context, client);\n }\n\n /**\n * Gets a description of which account will be used as default for prompts.\n */\n static getDefaultAccountDescription(context: Context): string {\n if (context.mode === AgentMode.RETURN_BYTES && context.accountId) {\n return `user account (${context.accountId})`;\n }\n return 'operator account';\n }\n\n static isHederaAddress(address: string): boolean {\n return address.startsWith('0.') || address.startsWith('0.0.');\n }\n\n static async getHederaEVMAddress(\n address: string,\n mirrorNode: IHederaMirrornodeService,\n ): Promise<string> {\n if (!AccountResolver.isHederaAddress(address)) {\n return address;\n }\n const account = await mirrorNode.getAccount(address);\n return account.evmAddress;\n }\n}\n","import { LedgerId } from '@hashgraph/sdk';\nimport BigNumber from 'bignumber.js';\n\nexport const LedgerIdToBaseUrl: Map<string, string> = new Map([\n [LedgerId.MAINNET.toString(), 'https://mainnet-public.mirrornode.hedera.com/api/v1'],\n [LedgerId.TESTNET.toString(), 'https://testnet.mirrornode.hedera.com/api/v1'],\n]);\n\nexport type AccountTokenBalancesQueryParams = {\n accountId: string;\n tokenId?: string;\n};\n\nexport type TopicMessagesQueryParams = {\n topicId: string;\n lowerTimestamp: string;\n upperTimestamp: string;\n limit: number;\n};\n\nexport type TopicMessage = {\n topicId: string;\n message: string;\n consensus_timestamp: string;\n};\n\nexport type TopicMessagesResponse = {\n topicId: string;\n messages: TopicMessage[];\n};\n\n// Mirrors Hedera Mirror Node /topics/{topicId} response shape (fields optional to be resilient)\nexport type TopicInfo = {\n topic_id?: string;\n memo?: string | null;\n admin_key?: {\n _type?: string;\n key?: string;\n } | null;\n submit_key?: {\n _type?: string;\n key?: string;\n } | null;\n auto_renew_account?: string | null;\n auto_renew_period?: number | null;\n created_timestamp?: string | null;\n deleted?: boolean;\n sequence_number?: number | null;\n running_hash?: string | null;\n running_hash_version?: number | null;\n};\n\nexport type TokenBalance = {\n automatic_association: boolean;\n created_timestamp: string;\n token_id: string;\n freeze_status: string;\n kyc_status: string;\n balance: number;\n decimals: number;\n symbol: string;\n};\n\nexport type TokenBalancesResponse = {\n tokens: TokenBalance[];\n};\n\nexport type NftBalance = {\n account_id: string;\n created_timestamp: string;\n delegating_spender: string | null;\n deleted: boolean;\n metadata: string;\n modified_timestamp: string;\n serial_number: number;\n spender: string | null;\n token_id: string;\n};\n\nexport type NftBalanceResponse = {\n nfts: NftBalance[];\n links: {\n next: string | null;\n };\n};\n\nexport type AccountResponse = {\n accountId: string;\n accountPublicKey: string;\n balance: AccountBalanceResponse;\n evmAddress: string;\n};\n\nexport type AccountAPIResponse = {\n account: string;\n key: {\n key: string;\n _type: KeyEncryptionType;\n };\n balance: AccountBalanceResponse;\n evm_address: string;\n};\n\nexport type AccountBalanceResponse = {\n balance: BigNumber;\n timestamp: string;\n tokens: TokenBalance[];\n};\n\nexport type TopicMessagesAPIResponse = {\n messages: TopicMessage[];\n links: {\n next: string | null;\n };\n};\n\nexport type KeyEncryptionType = 'ED25519' | 'ECDSA_SECP256K1';\n\n/**\n * This type matches responses from Hedera Mirror Node API\n */\nexport type TokenInfo = {\n // Basic Token Identity\n token_id?: string;\n name: string;\n symbol: string;\n type?: string;\n memo?: string;\n\n // Supply Information\n decimals: string;\n initial_supply?: string;\n total_supply?: string;\n max_supply?: string;\n supply_type?: string;\n\n // Account & Treasury\n treasury_account_id?: string;\n auto_renew_account?: string;\n auto_renew_period?: number;\n\n // Status & State\n deleted: boolean;\n freeze_default?: boolean;\n pause_status?: string;\n\n // Timestamps\n created_timestamp?: string;\n modified_timestamp?: string;\n expiry_timestamp?: number;\n\n // Keys\n admin_key?: {\n _type: string;\n key: string;\n } | null;\n supply_key?: {\n _type: string;\n key: string;\n } | null;\n kyc_key?: {\n _type: string;\n key: string;\n } | null;\n freeze_key?: {\n _type: string;\n key: string;\n } | null;\n wipe_key?: {\n _type: string;\n key: string;\n } | null;\n pause_key?: {\n _type: string;\n key: string;\n } | null;\n fee_schedule_key?: {\n _type: string;\n key: string;\n } | null;\n metadata_key?: {\n _type: string;\n key: string;\n } | null;\n\n // Metadata & Custom Features\n metadata?: string;\n custom_fees?: {\n created_timestamp: string;\n fixed_fees: any[];\n fractional_fees: any[];\n };\n};\n\nexport type TransferData = {\n account: string;\n amount: number;\n is_approval: boolean;\n};\n\nexport type TransactionData = {\n batch_key: string | null;\n bytes: string | null;\n charged_tx_fee: number;\n consensus_timestamp: string;\n entity_id: string;\n max_fee: string;\n max_custom_fees: any[];\n memo_base64: string;\n name: string;\n nft_transfers: any[];\n node: string;\n nonce: number;\n parent_consensus_timestamp: string | null;\n result: string;\n scheduled: boolean;\n staking_reward_transfers: any[];\n token_transfers: any[];\n transaction_hash: string;\n transaction_id: string;\n transfers: TransferData[];\n valid_duration_seconds: string;\n valid_start_timestamp: string;\n};\n\nexport type TransactionDetailsResponse = {\n transactions: TransactionData[];\n};\n\nexport interface ContractInfo {\n admin_key?: {\n description?: string;\n _type?: string;\n example?: string;\n key?: string;\n } | null;\n\n auto_renew_account?: string | null;\n auto_renew_period?: number | null;\n contract_id?: string | null;\n created_timestamp?: string | null;\n deleted?: boolean;\n evm_address?: string;\n expiration_timestamp?: string | null;\n file_id?: string | null;\n max_automatic_token_associations?: number | null;\n memo?: string;\n nonce?: number | null;\n obtainer_id?: string | null;\n permanent_removal?: boolean | null;\n proxy_account_id?: string | null;\n\n timestamp?: {\n description?: string;\n from: string;\n to?: string | null;\n };\n}\n\nexport type ExchangeRate = {\n hbar_equivalent: number;\n cent_equivalent: number;\n expiration_time: number;\n};\n\nexport type ExchangeRateResponse = {\n current_rate: ExchangeRate;\n next_rate: ExchangeRate;\n timestamp: string;\n};\n\nexport interface TokenAirdropsResponse {\n airdrops: TokenAirdrop[];\n links: Links;\n}\n\nexport interface TokenAirdrop {\n amount: number;\n receiver_id: string | null;\n sender_id: string | null;\n serial_number: number | null;\n timestamp: TimestampRange;\n token_id: string | null;\n}\n\nexport interface TimestampRange {\n from: string;\n to: string | null;\n}\n\nexport interface Links {\n next: string | null;\n}\n\nexport interface TokenAllowanceResponse {\n allowances: TokenAllowance[];\n links: {\n next: string | null;\n };\n}\n\nexport interface TokenAllowance {\n amount: number;\n amount_granted: number;\n owner: string; // e.g. \"0.0.6941870\"\n spender: string; // e.g. \"0.0.6941872\"\n timestamp: {\n from: string; // Hedera consensus timestamp, e.g. \"1759488103.097757000\"\n to: string | null;\n };\n token_id: string; // e.g. \"0.0.6941871\"\n}\n\nexport interface ScheduledTransactionDetailsResponse {\n admin_key?: {\n _type?: string;\n key?: string;\n } | null;\n deleted: boolean;\n consensus_timestamp: string;\n creator_account_id: string;\n executed_timestamp: string | null;\n expiration_time: string | null;\n memo: string;\n payer_account_id: string;\n schedule_id: string;\n signatures: Array<{\n consensus_timestamp: string;\n public_key_prefix: string;\n signature: string;\n type: string;\n }>;\n transaction_body: string;\n wait_for_expiry: boolean;\n}\n","import { LedgerId } from '@hashgraph/sdk';\nimport { IHederaMirrornodeService } from './hedera-mirrornode-service.interface';\nimport {\n AccountAPIResponse,\n AccountResponse,\n LedgerIdToBaseUrl,\n TokenBalancesResponse,\n TokenInfo,\n TopicInfo,\n TopicMessage,\n TopicMessagesAPIResponse,\n TopicMessagesQueryParams,\n TopicMessagesResponse,\n TransactionDetailsResponse,\n ContractInfo,\n TokenAirdropsResponse,\n ExchangeRateResponse,\n TokenAllowanceResponse,\n NftBalanceResponse,\n ScheduledTransactionDetailsResponse,\n} from './types';\nimport BigNumber from 'bignumber.js';\n\nexport class HederaMirrornodeServiceDefaultImpl implements IHederaMirrornodeService {\n private readonly baseUrl: string;\n\n constructor(private readonly ledgerId: LedgerId) {\n if (!LedgerIdToBaseUrl.has(ledgerId.toString())) {\n throw new Error(`Network type ${ledgerId} not supported`);\n }\n this.baseUrl = LedgerIdToBaseUrl.get(ledgerId.toString())!;\n }\n\n async getAccount(accountId: string): Promise<AccountResponse> {\n const url = `${this.baseUrl}/accounts/${accountId}`;\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(\n `Failed to fetch account ${accountId}: ${response.status} ${response.statusText}`,\n );\n }\n\n const data: AccountAPIResponse = await response.json();\n\n // Check if the response is empty (no account found)\n if (!data.account) {\n throw new Error(`Account ${accountId} not found`);\n }\n\n return {\n accountId: data.account,\n accountPublicKey: data?.key?.key,\n balance: data.balance,\n evmAddress: data.evm_address,\n };\n }\n\n async getAccountHbarBalance(accountId: string): Promise<BigNumber> {\n let account;\n try {\n account = await this.getAccount(accountId);\n } catch (error) {\n throw Error(`Failed to fetch hbar balance for ${accountId}: ${error}`);\n }\n return new BigNumber(account.balance.balance);\n }\n\n async getAccountTokenBalances(\n accountId: string,\n tokenId?: string,\n ): Promise<TokenBalancesResponse> {\n const tokenIdParam = tokenId ? `&token.id=${tokenId}` : '';\n const url = `${this.baseUrl}/accounts/${accountId}/tokens?${tokenIdParam}`;\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(\n `Failed to fetch balance for account ${accountId}: ${response.status} ${response.statusText}`,\n );\n }\n\n const res = await response.json();\n\n // Fetch and attach symbols in parallel\n await Promise.all(\n res.tokens.map(async (balance: any) => {\n try {\n const tokenInfo = await this.getTokenInfo(balance.token_id);\n balance.symbol = tokenInfo.symbol;\n } catch (err) {\n console.warn(`Failed to fetch token info for ${balance.token_id}:`, err);\n balance.symbol = 'UNKNOWN';\n }\n }),\n );\n\n return res;\n }\n\n async getTopicMessages(queryParams: TopicMessagesQueryParams): Promise<TopicMessagesResponse> {\n const lowerThreshold = queryParams.lowerTimestamp\n ? `×tamp=gte:${queryParams.lowerTimestamp}`\n : '';\n const upperThreshold = queryParams.upperTimestamp\n ? `×tamp=lte:${queryParams.upperTimestamp}`\n : '';\n const baseParams = `&order=desc&limit=100`;\n let url: string | null =\n `${this.baseUrl}/topics/${queryParams.topicId}/messages?${lowerThreshold}${upperThreshold}${baseParams}`;\n const arrayOfMessages: TopicMessage[] = [];\n let fetchedMessages = 0;\n try {\n while (url) {\n // Results are paginated\n\n fetchedMessages += 1;\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(\n `Failed to get topic messages for ${queryParams.topicId}: ${response.status} ${response.statusText}`,\n );\n }\n\n const data: TopicMessagesAPIResponse = await response.json();\n\n arrayOfMessages.push(...data.messages);\n if (fetchedMessages >= 100) {\n break;\n }\n\n // Update URL for pagination.\n // This endpoint does not return a full path to the next page, it has to be built first\n url = data.links.next ? this.baseUrl + data.links.next : null;\n }\n } catch (error) {\n console.error(`Failed to fetch topic messages for ${queryParams.topicId}. Error:`, error);\n throw error;\n }\n return {\n topicId: queryParams.topicId,\n messages: arrayOfMessages.slice(0, queryParams.limit),\n };\n }\n\n async getTokenInfo(tokenId: string): Promise<TokenInfo> {\n const url = `${this.baseUrl}/tokens/${tokenId}`;\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(\n `Failed to get token info for a token ${tokenId}: ${response.status} ${response.statusText}`,\n );\n }\n\n return await response.json();\n }\n\n async getTopicInfo(topicId: string): Promise<TopicInfo> {\n const url = `${this.baseUrl}/topics/${topicId}`;\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(\n `Failed to get topic info for ${topicId}: ${response.status} ${response.statusText}`,\n );\n }\n\n return await response.json();\n }\n\n async getTransactionRecord(\n transactionId: string,\n nonce?: number,\n ): Promise<TransactionDetailsResponse> {\n let url = `${this.baseUrl}/transactions/${transactionId}`;\n if (nonce !== undefined) {\n url += `?nonce=${nonce}`;\n }\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(\n `Failed to get transaction record for ${transactionId}: ${response.status} ${response.statusText}`,\n );\n }\n\n return await response.json();\n }\n\n async getContractInfo(contractId: string): Promise<ContractInfo> {\n const url = `${this.baseUrl}/contracts/${contractId}`;\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(\n `Failed to get contract info for ${contractId}: ${response.status} ${response.statusText}`,\n );\n }\n\n return await response.json();\n }\n\n async getPendingAirdrops(accountId: string): Promise<TokenAirdropsResponse> {\n const url = `${this.baseUrl}/accounts/${accountId}/airdrops/pending`;\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(\n `Failed to fetch pending airdrops for an account ${accountId}: ${response.status} ${response.statusText}`,\n );\n }\n\n return await response.json();\n }\n\n async getOutstandingAirdrops(accountId: string): Promise<TokenAirdropsResponse> {\n const url = `${this.baseUrl}/accounts/${accountId}/airdrops/outstanding`;\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(\n `Failed to fetch outstanding airdrops for an account ${accountId}: ${response.status} ${response.statusText}`,\n );\n }\n\n return await response.json();\n }\n\n async getExchangeRate(timestamp?: string): Promise<ExchangeRateResponse> {\n const timestampParam = timestamp ? `?timestamp=${encodeURIComponent(timestamp)}` : '';\n const url = `${this.baseUrl}/network/exchangerate${timestampParam}`;\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}. Message: ${response.statusText}`);\n }\n return await response.json();\n }\n\n async getTokenAllowances(\n ownerAccountId: string,\n spenderAccountId: string,\n ): Promise<TokenAllowanceResponse> {\n const url = `${this.baseUrl}/accounts/${ownerAccountId}/allowances/tokens?spender.id=${spenderAccountId}`;\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}. Message: ${response.statusText}`);\n }\n return await response.json();\n }\n\n async getAccountNfts(ownerAccountId: string): Promise<NftBalanceResponse> {\n const url = `${this.baseUrl}/accounts/${ownerAccountId}/nfts`;\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}. Message: ${response.statusText}`);\n }\n return await response.json();\n }\n\n async getScheduledTransactionDetails(\n scheduleId: string,\n ): Promise<ScheduledTransactionDetailsResponse> {\n const url = `${this.baseUrl}/schedules/${scheduleId}`;\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}. Message: ${response.statusText}`);\n }\n return await response.json();\n }\n\n getBaseUrl(): string {\n return this.baseUrl;\n }\n}\n","import { LedgerId } from '@hashgraph/sdk';\nimport { HederaMirrornodeServiceDefaultImpl } from './hedera-mirrornode-service-default-impl';\nimport { IHederaMirrornodeService } from './hedera-mirrornode-service.interface';\n\nexport const getMirrornodeService = (\n mirrornodeService: IHederaMirrornodeService | undefined,\n ledgerId: LedgerId,\n) => {\n if (mirrornodeService) {\n return mirrornodeService;\n }\n return new HederaMirrornodeServiceDefaultImpl(ledgerId);\n};\n","import { Context } from '@/shared/configuration';\nimport { z } from 'zod';\nimport {\n optionalScheduledTransactionParams,\n optionalScheduledTransactionParamsNormalised,\n} from '@/shared/parameter-schemas/common.zod';\n\nexport const contractExecuteTransactionParametersNormalised = (context: Context = {}) =>\n optionalScheduledTransactionParamsNormalised(context)\n .extend({\n contractId: z.string().describe('The ID of the contract to execute.'),\n functionParameters: z\n .instanceof(Uint8Array<ArrayBufferLike>)\n .describe('The parameters of the function to execute.'),\n gas: z.number().int().describe('The gas limit for the contract call.'),\n })\n .extend({\n payableAmount: z\n .number()\n .optional()\n .describe('The amount of HBAR to pay for the transaction.'),\n });\nexport const transferERC20Parameters = (context: Context = {}) =>\n optionalScheduledTransactionParams(context).extend({\n contractId: z.string().describe('The id of the ERC20 contract.'),\n recipientAddress: z.string().describe('Address to which the tokens will be transferred.'),\n amount: z.number().describe('The amount of tokens to transfer.'),\n });\n\nexport const createERC721Parameters = (context: Context = {}) =>\n optionalScheduledTransactionParams(context).extend({\n tokenName: z.string().describe('The name of the token.'),\n tokenSymbol: z.string().describe('The symbol of the token.'),\n baseURI: z.string().default('').describe('The base URI for token metadata.'),\n });\n\nexport const createERC20Parameters = (context: Context = {}) =>\n optionalScheduledTransactionParams(context).extend({\n tokenName: z.string().describe('The name of the token.'),\n tokenSymbol: z.string().describe('The symbol of the token.'),\n decimals: z\n .number()\n .int()\n .min(0)\n .optional()\n .default(18)\n .describe('The number of decimals the token supports.'),\n initialSupply: z\n .number()\n .int()\n .min(0)\n .optional()\n .default(0)\n .describe('The initial supply of the token.'),\n });\n\nexport const transferERC721Parameters = (context: Context = {}) =>\n optionalScheduledTransactionParams(context).extend({\n contractId: z.string().describe('The id of the ERC721 contract.'),\n fromAddress: z\n .string()\n .optional()\n .describe('Address from which the token will be transferred.'),\n toAddress: z.string().describe('Address to which the token will be transferred.'),\n tokenId: z.number().describe('The ID of the token to transfer.'),\n });\n\nexport const mintERC721Parameters = (context: Context = {}) =>\n optionalScheduledTransactionParams(context).extend({\n contractId: z.string().describe('The id of the ERC721 contract.'),\n toAddress: z.string().optional().describe('Address to which the token will be minted.'),\n });\n\nexport const evmContractCallParamsNormalised = (context: Context) =>\n optionalScheduledTransactionParamsNormalised(context).extend({\n contractId: z.string(),\n functionParameters: z.instanceof(Uint8Array<ArrayBufferLike>),\n gas: z.number().int(),\n });\n\nexport const contractInfoQueryParameters = (_context: Context = {}) =>\n z.object({\n contractId: z.string().describe('The token ID to query.'),\n });\n","import { Context } from '@/shared';\nimport { z } from 'zod';\n\nexport const transactionRecordQueryParameters = (_context: Context = {}) => {\n return z.object({\n transactionId: z\n .string()\n .describe(\n 'The transaction ID to fetch details for. Should be in format \\\\\"shard.realm.num-sss-nnn\\\\\" format where sss are seconds and nnn are nanoseconds',\n ),\n nonce: z\n .number()\n .nonnegative()\n .optional()\n .describe('Optional nonnegative nonce value for the transaction'),\n });\n};\n\nexport const normalisedTransactionRecordQueryParameters = (_context: Context = {}) =>\n transactionRecordQueryParameters(_context).extend({});\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport { airdropFungibleTokenParameters } from '@/shared/parameter-schemas/token.zod';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst airdropFungibleTokenPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const sourceAccountDesc = PromptGenerator.getAccountParameterDescription(\n 'sourceAccountId',\n context,\n );\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will airdrop a HTS fungible token on Hedera.\n\nParameters:\n- tokenId (str, required): The id of the token\n- ${sourceAccountDesc}\n- recipients (array, required): A list of recipient objects (can contian a single recipient), each containing:\n - accountId (string, required): The recipient's account ID (e.g., \"0.0.1234\")\n - amount (number or string, required): The amount of tokens to send to that recipient (in display units)\n- transactionMemo (str, optional): Optional memo for the transaction - not required for the tool call.\n${usageInstructions}\n\nIf the user specifies multiple recipients in a single request, include them all in **one tool call** as a list of recipients.\nUser might want to airdrop to a single recipient.\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `Token successfully airdropped with transaction id ${response.transactionId.toString()}`;\n};\n\nconst airdropFungibleToken = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof airdropFungibleTokenParameters>>,\n) => {\n try {\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const normalisedParams = await HederaParameterNormaliser.normaliseAirdropFungibleTokenParams(\n params,\n context,\n client,\n mirrornodeService,\n );\n const tx = HederaBuilder.airdropFungibleToken(normalisedParams);\n const result = await handleTransaction(tx, client, context, postProcess);\n return result;\n } catch (error) {\n const desc = 'Failed to airdrop fungible token';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[airdrop_fungible_token_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const AIRDROP_FUNGIBLE_TOKEN_TOOL = 'airdrop_fungible_token_tool';\n\nconst tool = (context: Context): Tool => ({\n method: AIRDROP_FUNGIBLE_TOKEN_TOOL,\n name: 'Airdrop Fungible Token',\n description: airdropFungibleTokenPrompt(context),\n parameters: airdropFungibleTokenParameters(context),\n execute: airdropFungibleToken,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import {\n AccountId,\n Client,\n ScheduleId,\n TokenId,\n TopicId,\n Transaction,\n TransactionId,\n} from '@hashgraph/sdk';\nimport { AgentMode, Context } from '@/shared/configuration';\n\ninterface TxModeStrategy {\n handle<T extends Transaction>(\n tx: T,\n client: Client,\n context: Context,\n postProcess?: (response: RawTransactionResponse) => unknown,\n ): Promise<unknown>;\n}\n\nexport interface RawTransactionResponse {\n status: string;\n accountId: AccountId | null;\n tokenId: TokenId | null;\n transactionId: string;\n topicId: TopicId | null;\n scheduleId: ScheduleId | null;\n}\n\nexport interface ExecuteStrategyResult {\n raw: RawTransactionResponse;\n humanMessage: string;\n}\n\nexport class ExecuteStrategy implements TxModeStrategy {\n defaultPostProcess(response: RawTransactionResponse): string {\n return JSON.stringify(response, null, 2);\n }\n\n async handle(\n tx: Transaction,\n client: Client,\n _context: Context,\n postProcess: (response: RawTransactionResponse) => string = this.defaultPostProcess,\n ) {\n const submit = await tx.execute(client);\n const receipt = await submit.getReceipt(client);\n const rawTransactionResponse: RawTransactionResponse = {\n status: receipt.status.toString(),\n accountId: receipt.accountId,\n tokenId: receipt.tokenId,\n transactionId: tx.transactionId?.toString() ?? '',\n topicId: receipt.topicId,\n scheduleId: receipt.scheduleId,\n };\n return {\n raw: rawTransactionResponse,\n humanMessage: postProcess(rawTransactionResponse),\n };\n }\n}\n\nclass ReturnBytesStrategy implements TxModeStrategy {\n async handle(tx: Transaction, client: Client, context: Context) {\n if (!context.accountId) throw new Error('…');\n const id = TransactionId.generate(context.accountId);\n tx.setTransactionId(id).freezeWith(client);\n return { bytes: tx.toBytes() };\n }\n}\n\nconst getStrategyFromContext = (context: Context) => {\n if (context.mode === AgentMode.RETURN_BYTES) {\n return new ReturnBytesStrategy();\n }\n return new ExecuteStrategy();\n};\n\nexport const handleTransaction = async (\n tx: Transaction,\n client: Client,\n context: Context,\n postProcess?: (response: RawTransactionResponse) => string,\n) => {\n const strategy = getStrategyFromContext(context);\n return await strategy.handle(tx, client, context, postProcess);\n};\n","import {\n AccountAllowanceApproveTransaction,\n AccountAllowanceDeleteTransaction,\n AccountCreateTransaction,\n AccountDeleteTransaction,\n AccountId,\n AccountUpdateTransaction,\n ContractExecuteTransaction,\n Hbar,\n HbarUnit,\n ScheduleCreateTransaction,\n ScheduleDeleteTransaction,\n ScheduleSignTransaction,\n TokenAirdropTransaction,\n TokenAssociateTransaction,\n TokenCreateTransaction,\n TokenDeleteTransaction,\n TokenDissociateTransaction,\n TokenId,\n TokenMintTransaction,\n TokenUpdateTransaction,\n TopicCreateTransaction,\n TopicDeleteTransaction,\n TopicMessageSubmitTransaction,\n TopicUpdateTransaction,\n Transaction,\n TransferTransaction,\n} from '@hashgraph/sdk';\nimport {\n airdropFungibleTokenParametersNormalised,\n approveNftAllowanceParametersNormalised,\n associateTokenParametersNormalised,\n createFungibleTokenParametersNormalised,\n createNonFungibleTokenParametersNormalised,\n deleteNftAllowanceParametersNormalised,\n deleteTokenParametersNormalised,\n dissociateTokenParametersNormalised,\n mintFungibleTokenParametersNormalised,\n mintNonFungibleTokenParametersNormalised,\n updateTokenParametersNormalised,\n transferFungibleTokenWithAllowanceParametersNormalised,\n transferNonFungibleTokenWithAllowanceParametersNormalised,\n transferNonFungibleTokenParametersNormalised,\n} from '@/shared/parameter-schemas/token.zod';\nimport z from 'zod';\nimport {\n approveHbarAllowanceParametersNormalised,\n approveTokenAllowanceParametersNormalised,\n createAccountParametersNormalised,\n deleteAccountParametersNormalised,\n scheduleDeleteTransactionParameters,\n signScheduleTransactionParameters,\n transferHbarParametersNormalised,\n transferHbarWithAllowanceParametersNormalised,\n updateAccountParametersNormalised,\n} from '@/shared/parameter-schemas/account.zod';\nimport {\n createTopicParametersNormalised,\n deleteTopicParametersNormalised,\n submitTopicMessageParametersNormalised,\n updateTopicParametersNormalised,\n} from '@/shared/parameter-schemas/consensus.zod';\nimport { contractExecuteTransactionParametersNormalised } from '@/shared/parameter-schemas/evm.zod';\nimport { optionalScheduledTransactionParamsNormalised } from '@/shared/parameter-schemas/common.zod';\n\nexport default class HederaBuilder {\n static createFungibleToken(\n params: z.infer<ReturnType<typeof createFungibleTokenParametersNormalised>>,\n ) {\n const tx = new TokenCreateTransaction(params);\n return HederaBuilder.maybeWrapInSchedule(tx, params.schedulingParams);\n }\n\n static createNonFungibleToken(\n params: z.infer<ReturnType<typeof createNonFungibleTokenParametersNormalised>>,\n ) {\n const tx = new TokenCreateTransaction(params);\n return HederaBuilder.maybeWrapInSchedule(tx, params.schedulingParams);\n }\n\n static transferHbar(params: z.infer<ReturnType<typeof transferHbarParametersNormalised>>) {\n const tx = new TransferTransaction(params as any);\n return HederaBuilder.maybeWrapInSchedule(tx, params.schedulingParams);\n }\n\n static transferNonFungibleTokenWithAllowance(\n params: z.infer<ReturnType<typeof transferNonFungibleTokenWithAllowanceParametersNormalised>>,\n ) {\n const tx = new TransferTransaction();\n\n for (const transfer of params.transfers) {\n tx.addApprovedNftTransfer(transfer.nftId, params.sourceAccountId, transfer.receiver);\n }\n\n if (params.transactionMemo) {\n tx.setTransactionMemo(params.transactionMemo);\n }\n\n return tx;\n }\n\n static transferNonFungibleToken(\n params: z.infer<ReturnType<typeof transferNonFungibleTokenParametersNormalised>>,\n ) {\n const tx = new TransferTransaction();\n\n for (const transfer of params.transfers) {\n tx.addNftTransfer(transfer.nftId, params.senderAccountId, transfer.receiver);\n }\n\n if (params.transactionMemo) {\n tx.setTransactionMemo(params.transactionMemo);\n }\n\n return HederaBuilder.maybeWrapInSchedule(tx, params.schedulingParams);\n }\n\n static transferHbarWithAllowance(\n params: z.infer<ReturnType<typeof transferHbarWithAllowanceParametersNormalised>>,\n ) {\n // transfers are passed through the constructor\n const tx = new TransferTransaction(params as any);\n\n // Add approved transfer (allowance-based) - approved transfer passing through a constructor is not supported\n tx.addApprovedHbarTransfer(\n params.hbarApprovedTransfer.ownerAccountId,\n params.hbarApprovedTransfer.amount,\n );\n\n if (params.transactionMemo) {\n tx.setTransactionMemo(params.transactionMemo);\n }\n\n return tx;\n }\n\n static airdropFungibleToken(\n params: z.infer<ReturnType<typeof airdropFungibleTokenParametersNormalised>>,\n ) {\n return new TokenAirdropTransaction(params as any);\n }\n\n static transferFungibleTokenWithAllowance(\n params: z.infer<ReturnType<typeof transferFungibleTokenWithAllowanceParametersNormalised>>,\n ) {\n const tx = new TransferTransaction();\n\n // Add approved (allowance-based) owner transfer - constructor does not support setting approved transfers\n tx.addApprovedTokenTransfer(\n params.tokenId,\n params.approvedTransfer.ownerAccountId,\n params.approvedTransfer.amount,\n );\n\n // adding token transfers manually - passing through constructor results in a TRANSFERS_NOT_ZERO_SUM_FOR_TOKEN error\n for (const t of params.tokenTransfers) {\n tx.addTokenTransfer(t.tokenId, t.accountId, t.amount);\n }\n\n // Add approved (allowance-based) owner transfer - constructor does not support setting approved transfers\n if (params.transactionMemo) {\n tx.setTransactionMemo(params.transactionMemo);\n }\n\n return HederaBuilder.maybeWrapInSchedule(tx, params.schedulingParams);\n }\n\n static updateToken(params: z.infer<ReturnType<typeof updateTokenParametersNormalised>>) {\n return new TokenUpdateTransaction(params);\n }\n\n static createTopic(params: z.infer<ReturnType<typeof createTopicParametersNormalised>>) {\n const { transactionMemo, ...rest } = params as any;\n const tx = new TopicCreateTransaction(rest);\n if (transactionMemo) tx.setTransactionMemo(transactionMemo);\n return tx;\n }\n\n static submitTopicMessage(\n params: z.infer<ReturnType<typeof submitTopicMessageParametersNormalised>>,\n ) {\n const { transactionMemo, ...rest } = params as any;\n const tx = new TopicMessageSubmitTransaction(rest);\n if (transactionMemo) tx.setTransactionMemo(transactionMemo);\n return HederaBuilder.maybeWrapInSchedule(tx, params.schedulingParams);\n }\n\n static updateTopic(params: z.infer<ReturnType<typeof updateTopicParametersNormalised>>) {\n return new TopicUpdateTransaction(params);\n }\n\n static executeTransaction(\n params: z.infer<ReturnType<typeof contractExecuteTransactionParametersNormalised>>,\n ) {\n const tx = new ContractExecuteTransaction(params);\n if (params.payableAmount) {\n tx.setPayableAmount(Hbar.from(params.payableAmount, HbarUnit.Tinybar));\n }\n\n return HederaBuilder.maybeWrapInSchedule(tx, params.schedulingParams);\n }\n\n static mintFungibleToken(\n params: z.infer<ReturnType<typeof mintFungibleTokenParametersNormalised>>,\n ) {\n const tx = new TokenMintTransaction(params);\n return HederaBuilder.maybeWrapInSchedule(tx, params.schedulingParams);\n }\n\n static mintNonFungibleToken(\n params: z.infer<ReturnType<typeof mintNonFungibleTokenParametersNormalised>>,\n ) {\n const tx = new TokenMintTransaction(params);\n return HederaBuilder.maybeWrapInSchedule(tx, params.schedulingParams);\n }\n\n static dissociateToken(params: z.infer<ReturnType<typeof dissociateTokenParametersNormalised>>) {\n return new TokenDissociateTransaction(params);\n }\n\n static createAccount(params: z.infer<ReturnType<typeof createAccountParametersNormalised>>) {\n const tx = new AccountCreateTransaction(params);\n return HederaBuilder.maybeWrapInSchedule(tx, params.schedulingParams);\n }\n\n static deleteAccount(params: z.infer<ReturnType<typeof deleteAccountParametersNormalised>>) {\n return new AccountDeleteTransaction(params);\n }\n\n static updateAccount(params: z.infer<ReturnType<typeof updateAccountParametersNormalised>>) {\n const tx = new AccountUpdateTransaction(params);\n return HederaBuilder.maybeWrapInSchedule(tx, params.schedulingParams);\n }\n\n static deleteToken(params: z.infer<ReturnType<typeof deleteTokenParametersNormalised>>) {\n return new TokenDeleteTransaction(params);\n }\n\n static deleteTopic(params: z.infer<ReturnType<typeof deleteTopicParametersNormalised>>) {\n return new TopicDeleteTransaction(params);\n }\n\n static signScheduleTransaction(\n params: z.infer<ReturnType<typeof signScheduleTransactionParameters>>,\n ) {\n return new ScheduleSignTransaction(params);\n }\n\n static deleteScheduleTransaction(\n params: z.infer<ReturnType<typeof scheduleDeleteTransactionParameters>>,\n ) {\n return new ScheduleDeleteTransaction(params as any);\n }\n\n static associateToken(params: z.infer<ReturnType<typeof associateTokenParametersNormalised>>) {\n return new TokenAssociateTransaction({\n accountId: AccountId.fromString(params.accountId),\n tokenIds: params.tokenIds.map(t => TokenId.fromString(t)),\n });\n }\n\n private static buildAccountAllowanceApproveTx(\n params: z.infer<\n ReturnType<\n | typeof approveHbarAllowanceParametersNormalised\n | typeof approveNftAllowanceParametersNormalised\n >\n >,\n ) {\n const tx = new AccountAllowanceApproveTransaction(params as any);\n if ((params as any).transactionMemo) {\n tx.setTransactionMemo((params as any).transactionMemo);\n }\n return tx;\n }\n\n static approveHbarAllowance(\n params: z.infer<ReturnType<typeof approveHbarAllowanceParametersNormalised>>,\n ) {\n return this.buildAccountAllowanceApproveTx(params);\n }\n\n static approveNftAllowance(\n params: z.infer<ReturnType<typeof approveNftAllowanceParametersNormalised>>,\n ) {\n return this.buildAccountAllowanceApproveTx(params);\n }\n\n static deleteNftAllowance(\n params: z.infer<ReturnType<typeof deleteNftAllowanceParametersNormalised>>,\n ) {\n const tx = new AccountAllowanceDeleteTransaction();\n\n for (const nftId of params.nftWipes) {\n tx.deleteAllTokenNftAllowances(nftId, params.ownerAccountId);\n }\n\n if (params.transactionMemo) {\n tx.setTransactionMemo(params.transactionMemo);\n }\n\n return tx;\n }\n\n static approveTokenAllowance(\n params: z.infer<ReturnType<typeof approveTokenAllowanceParametersNormalised>>,\n ) {\n const tx = new AccountAllowanceApproveTransaction(params);\n if (params.transactionMemo) {\n tx.setTransactionMemo(params.transactionMemo);\n }\n return tx;\n }\n\n static maybeWrapInSchedule(\n tx: Transaction,\n schedulingParams?: z.infer<\n ReturnType<typeof optionalScheduledTransactionParamsNormalised>\n >['schedulingParams'],\n ): Transaction {\n if (schedulingParams?.isScheduled) {\n return new ScheduleCreateTransaction(schedulingParams)\n .setScheduledTransaction(tx)\n .setWaitForExpiry(schedulingParams.waitForExpiry || false) // passing through constructor is failing\n .setExpirationTime(schedulingParams.expirationTime || null); // passing through constructor is failing\n }\n return tx;\n }\n}\n","/**\n * Parse a transaction tool's JSON output into a normalized shape.\n *\n * Accepts a stringified JSON `rawOutput` produced by a transaction tool and\n * returns a consistent `{ raw: any, humanMessage: string }` object.\n *\n * Behavior:\n * - If `rawOutput` is not valid JSON, returns a `raw` object with\n * `{ status: 'PARSE_ERROR', error, originalOutput }` and a generic error\n * `humanMessage`.\n * - If the parsed object has a top-level `bytes` field (RETURN_BYTES mode),\n * the parsed object is returned as `raw` and a default human-friendly message\n * is provided.\n * - If the parsed object contains both `raw` and `humanMessage` (EXECUTE_TRANSACTION\n * mode), any additional top-level fields are merged into the returned `raw`\n * object so extra tool information is preserved.\n * - For any other shape, returns a `PARSE_ERROR` indicating an unexpected format.\n *\n * @param rawOutput - JSON string output from a transaction tool\n * @returns An object containing the untyped `raw` tool data and a `humanMessage`\n */\nexport const transactionToolOutputParser = (\n rawOutput: string,\n): { raw: any; humanMessage: string } => {\n let parsedObject;\n try {\n parsedObject = JSON.parse(rawOutput);\n } catch (error) {\n console.error(`[transactionToolOutputParser] Failed to parse JSON:`, rawOutput, error);\n return {\n raw: { status: 'PARSE_ERROR', error: error, originalOutput: rawOutput },\n humanMessage: 'Error: Failed to parse tool output. The output was malformed.',\n };\n }\n\n // Case 1: Handle RETURN_BYTES mode output\n if (parsedObject && parsedObject.bytes) {\n return {\n raw: parsedObject, // The 'raw' data *is* the object with the bytes\n humanMessage: 'Transaction bytes are ready for signing.', // The parser can add a helpful default message\n };\n }\n\n // Case 2: Handle EXECUTE_TRANSACTION mode output\n if (\n parsedObject &&\n typeof parsedObject.raw !== 'undefined' &&\n typeof parsedObject.humanMessage !== 'undefined'\n ) {\n const { raw, humanMessage, ...otherFields } = parsedObject;\n\n // This ensures any extra data from the tool is not lost\n // It will be merged into the 'raw' object returned\n const mergedRaw = { ...raw, ...otherFields };\n\n return {\n raw: mergedRaw,\n humanMessage: humanMessage,\n };\n }\n\n // Fallback for anything else\n console.error(`[transactionToolOutputParser] Parsed object has unknown shape:`, parsedObject);\n return {\n raw: { status: 'PARSE_ERROR', originalOutput: rawOutput, parsedObject },\n humanMessage: 'Error: Parsed tool output had an unexpected format.',\n };\n};\n\n/**\n * A temporary, generic output parser for **all query tools**.\n * * This function provides a basic, untyped parsing mechanism for the\n * stringified JSON output from any query tool. It extracts the common\n * `{ raw: any, humanMessage: string }` structure.\n * * @remarks\n * This is a temporary, \"one-size-fits-all\" solution.\n * The long-term goal is to replace this with **specific, strongly-typed\n * output parsers for each individual query tool**. This will allow\n * for better compile-time type-checking and more robust handling of\n * each tool's unique `raw` data structure (e.g., `AccountResponse`,\n * `TokenInfoResponse`, etc.).\n *\n * @param rawOutput The stringified JSON content from a query tool's ToolMessage.\n * @returns A JavaScript object with 'raw' and 'humanMessage' keys.\n */\nexport const untypedQueryOutputParser = (rawOutput: string): { raw: any; humanMessage: string } => {\n let parsedObject;\n try {\n parsedObject = JSON.parse(rawOutput);\n } catch (error) {\n console.error(`untypedQueryOutputParser failed to parse JSON:`, error);\n return {\n raw: { status: 'PARSE_ERROR', error: error, originalOutput: rawOutput },\n humanMessage: 'Error: Failed to parse tool output. The output was malformed.',\n };\n }\n\n // Basic check to ensure the common structure is present\n if (\n !parsedObject ||\n typeof parsedObject.raw === 'undefined' ||\n typeof parsedObject.humanMessage === 'undefined'\n ) {\n console.error(\n `untypedQueryOutputParser: Parsed object missing 'raw' or 'humanMessage' key:`,\n parsedObject,\n );\n return {\n raw: {\n status: 'PARSE_ERROR',\n error: \"Parsed object missing 'raw' or 'humanMessage'\",\n originalOutput: rawOutput,\n },\n humanMessage: 'Error: Tool output had an unexpected format.',\n };\n }\n\n return {\n // The 'raw' data is the untyped JSON object from the tool.\n // This generic parser just passes it through. A future, tool-specific\n // parser would validate and cast this 'raw' object into a specific type.\n raw: parsedObject.raw,\n humanMessage: parsedObject.humanMessage,\n };\n};\n","import { LedgerId } from '@hashgraph/sdk';\n\nconst TESTNET_ERC20_FACTORY_ADDRESS = '0.0.6471814';\nconst TESTNET_ERC721_FACTORY_ADDRESS = '0.0.6510666'; // TODO: Update with actual deployed address\n\n// ERC20 Factory contract addresses for different networks\nexport const ERC20_FACTORY_ADDRESSES: Map<string, string> = new Map([\n [LedgerId.TESTNET.toString(), TESTNET_ERC20_FACTORY_ADDRESS], // Current testnet address\n]);\n\n// ERC721 Factory contract addresses for different networks\nexport const ERC721_FACTORY_ADDRESSES: Map<string, string> = new Map([\n [LedgerId.TESTNET.toString(), TESTNET_ERC721_FACTORY_ADDRESS], // Current testnet address\n]);\n\n// ERC20 Factory contract ABI\nexport const ERC20_FACTORY_ABI = [\n 'function deployToken(string memory name_, string memory symbol_, uint8 decimals_, uint256 initialSupply_) external returns (address)',\n];\n\n// ERC721 Factory contract ABI\nexport const ERC721_FACTORY_ABI = [\n 'function deployToken(string memory name_, string memory symbol_, string memory baseURI_) external returns (address)',\n];\n\nexport const ERC20_TRANSFER_FUNCTION_NAME = 'transfer';\nexport const ERC20_TRANSFER_FUNCTION_ABI = [\n 'function transfer(address to, uint256 amount) external returns (bool)',\n];\n\nexport const ERC721_TRANSFER_FUNCTION_NAME = 'transferFrom';\nexport const ERC721_TRANSFER_FUNCTION_ABI = [\n 'function transferFrom(address from, address to, uint256 tokenId) external returns (bool)',\n];\n\nexport const ERC721_MINT_FUNCTION_NAME = 'safeMint';\nexport const ERC721_MINT_FUNCTION_ABI = ['function safeMint(address to) external returns (bool)'];\n\n/**\n * Get the ERC20 factory contract address for the specified network\n * @param ledgerId - The Hedera network ledger ID\n * @returns The factory contract address for the network\n * @throws Error if the network is not supported\n */\nexport function getERC20FactoryAddress(ledgerId: LedgerId): string {\n const address = ERC20_FACTORY_ADDRESSES.get(ledgerId.toString());\n if (!address) {\n throw new Error(`Network type ${ledgerId} not supported for ERC20 factory`);\n }\n return address;\n}\n\n/**\n * Get the ERC721 factory contract address for the specified network\n * @param ledgerId - The Hedera network ledger ID\n * @returns The factory contract address for the network\n * @throws Error if the network is not supported\n */\nexport function getERC721FactoryAddress(ledgerId: LedgerId): string {\n const address = ERC721_FACTORY_ADDRESSES.get(ledgerId.toString());\n if (!address) {\n throw new Error(`Network type ${ledgerId} not supported for ERC721 factory`);\n }\n return address;\n}\n","import { Context, AgentMode } from '@/shared/configuration';\nimport { AccountResolver } from '@/shared';\n\nexport class PromptGenerator {\n /**\n * Generates a consistent context snippet for tool prompts.\n */\n static getContextSnippet(context: Context): string {\n const lines = ['Context:'];\n\n if (context.mode === AgentMode.RETURN_BYTES) {\n lines.push(`- Mode: Return Bytes (preparing transactions for user signing)`);\n if (context.accountId) {\n lines.push(`- User Account: ${context.accountId} (default for transaction parameters)`);\n lines.push(`- When no account is specified, ${context.accountId} will be used`);\n } else {\n lines.push(`- User Account: Not specified`);\n lines.push(`- When no account is specified, the operator account will be used`);\n }\n } else if (context.mode === AgentMode.AUTONOMOUS) {\n lines.push(`- Mode: Autonomous (agent executes transactions directly)`);\n if (context.accountId) {\n lines.push(`- User Account: ${context.accountId}`);\n }\n lines.push(`- When no account is specified, the operator account will be used`);\n } else {\n lines.push(`- Mode: ${context.mode || 'Not specified'}`);\n if (context.accountId) {\n lines.push(`- User Account: ${context.accountId}`);\n }\n lines.push(`- Default account will be determined at execution time`);\n }\n\n return lines.join('\\n');\n }\n\n static getAnyAddressParameterDescription(\n paramName: string,\n context: Context,\n isRequired: boolean = false,\n ): string {\n if (isRequired) {\n return `${paramName} (str, required): The account address. This can be the EVM address or the Hedera account id`;\n }\n\n return `${paramName} (str, optional): The Hedera account ID or EVM address. If not provided, defaults to the ${AccountResolver.getDefaultAccountDescription(context)}`;\n }\n\n /**\n * Generates a consistent description for optional account parameters.\n */\n static getAccountParameterDescription(\n paramName: string,\n context: Context,\n isRequired: boolean = false,\n ): string {\n if (isRequired) {\n return `${paramName} (str, required): The Hedera account ID`;\n }\n\n const defaultAccountDesc = AccountResolver.getDefaultAccountDescription(context);\n return `${paramName} (str, optional): The Hedera account ID. If not provided, defaults to the ${defaultAccountDesc}`;\n }\n\n /**\n * Generates consistent parameter usage instructions.\n */\n static getParameterUsageInstructions(): string {\n return `\nImportant:\n- Do not request or ask for parameters that are optional and were not provided by the user. Tool can be called without any parameters if all are optional.\n- Only include optional parameters if explicitly provided by the user\n- Do not generate placeholder values for optional fields\n- Leave optional parameters undefined if not specified by the user\n- If a required parameter is not specified by the user, DO NOT guess or generate placeholder values. You must stop and ask the user for the missing required information.\n- Important: If the user mentions multiple recipients or amounts and tool accepts an array, combine all recipients, tokens or similar assets into a single array and make exactly one call to that tool. Do not split the action into multiple tool calls if it's possible to do so.\n`;\n }\n\n static getScheduledTransactionParamsDescription(context: Context): string {\n return `schedulingParams (object, optional): Parameters for scheduling this transaction instead of executing immediately. \n\n**Fields that apply to the *schedule entity*, not the inner transaction:**\n\n- **isScheduled** (boolean, optional, default false): \n If true, the transaction will be created as a scheduled transaction. \n If false or omitted, all other scheduling parameters will be ignored.\n\n- **adminKey** (boolean|string, optional, default false): \n Admin key that can delete or modify the scheduled transaction before execution. \n - If true, the operator key will be used. \n - If false or omitted, no admin key is set. \n - If a string is passed, it will be used as the admin key.\n\n- **payerAccountId** (string, optional): \n Account that will pay the transaction fee when the scheduled transaction executes. \n Defaults to the ${AccountResolver.getDefaultAccountDescription(context)}.\n\n- **expirationTime** (string, optional, ISO 8601): \n Time when the scheduled transaction will expire if not fully signed.\n \n- **waitForExpiry** (boolean, optional, default \\`false\\`): \n Determines when the scheduled transaction executes: \n - \\`false\\` (default): execute as soon as all required signatures are collected. \n - \\`true\\`: execute at the scheduled expiration time, even if all signatures are already collected. \n Requires \\`expirationTime\\` to be set if \\`true\\`. Set to \\`true\\` only when the user explicitly requests execution at expiration.\n\n**Notes**\n- Setting any scheduling parameter implies delayed execution through the Hedera schedule service.\n- The network executes the scheduled transaction automatically once all required signatures are collected.\n`;\n }\n}\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { transferFungibleTokenWithAllowanceParameters } from '@/shared/parameter-schemas/token.zod';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst transferFungibleTokenWithAllowancePrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will transfer a HTS fungible token using an existing **token allowance**.\n\nParameters:\n- tokenId (string, required): The token ID to transfer (e.g. \"0.0.12345\")\n- sourceAccountId (string, required): Account ID of the token owner (the allowance granter)\n- transfers (array of objects, required): List of token transfers. Each object should contain:\n - accountId (string, required): Recipient account ID\n - amount (number, required): Amount of tokens to transfer in display unit\n- transactionMemo (string, optional): Optional memo for the transaction\n${PromptGenerator.getScheduledTransactionParamsDescription(context)}\n\n${usageInstructions}\n\nExample: Spend allowance from account 0.0.1002 to send 25 fungible tokens with id 0.0.33333 to 0.0.2002\nExample 2: Use allowance from 0.0.1002 to send 50 TKN (FT token id: '0.0.33333') to 0.0.2002 and 75 TKN to 0.0.3003\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n if (response.scheduleId) {\n return `Scheduled allowance transfer created successfully.\nTransaction ID: ${response.transactionId}\nSchedule ID: ${response.scheduleId.toString()}`;\n }\n return `Fungible tokens successfully transferred with allowance.\nTransaction ID: ${response.transactionId}`;\n};\n\nconst transferFungibleTokenWithAllowance = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof transferFungibleTokenWithAllowanceParameters>>,\n) => {\n try {\n const mirrornode = getMirrornodeService(context.mirrornodeService, client.ledgerId!);\n const normalisedParams =\n await HederaParameterNormaliser.normaliseTransferFungibleTokenWithAllowance(\n params,\n context,\n client,\n mirrornode,\n );\n\n const tx = HederaBuilder.transferFungibleTokenWithAllowance(normalisedParams);\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to transfer fungible token with allowance';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[transfer_fungible_token_with_allowance_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const TRANSFER_FUNGIBLE_TOKEN_WITH_ALLOWANCE_TOOL =\n 'transfer_fungible_token_with_allowance_tool';\n\nconst tool = (context: Context): Tool => ({\n method: TRANSFER_FUNGIBLE_TOKEN_WITH_ALLOWANCE_TOOL,\n name: 'Transfer Fungible Token with Allowance',\n description: transferFungibleTokenWithAllowancePrompt(context),\n parameters: transferFungibleTokenWithAllowanceParameters(context),\n execute: transferFungibleTokenWithAllowance,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport { createFungibleTokenParameters } from '@/shared/parameter-schemas/token.zod';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst createFungibleTokenPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const treasuryAccountDesc = PromptGenerator.getAccountParameterDescription(\n 'treasuryAccountId',\n context,\n );\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool creates a HTS fungible token on Hedera.\n\nParameters:\n- tokenName (str, required): The name of the token\n- tokenSymbol (str, optional): The symbol of the token\n- initialSupply (int, optional): The initial supply of the token, defaults to 0. Given in display units, the tool will handle parsing\n- supplyType (str, optional): The supply type of the token. Can be \"finite\" or \"infinite\". Defaults to \"finite\"\n- maxSupply (int, optional): The maximum supply of the token. Only applicable if supplyType is \"finite\". Defaults to 1,000,000 if not specified. Given in display units, the tool will handle parsing\n- decimals (int, optional): The number of decimals the token supports. Defaults to 0\n- ${treasuryAccountDesc}\n- isSupplyKey (boolean, optional): If user wants to set supply key set to true, otherwise false\n${PromptGenerator.getScheduledTransactionParamsDescription(context)}\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n if (response.scheduleId) {\n return `Scheduled transaction created successfully.\nTransaction ID: ${response.transactionId}\nSchedule ID: ${response.scheduleId.toString()}`;\n }\n const tokenIdStr = response.tokenId ? response.tokenId.toString() : 'unknown';\n return `Token created successfully.\nTransaction ID: ${response.transactionId}\nToken ID: ${tokenIdStr}`;\n};\n\nconst createFungibleToken = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof createFungibleTokenParameters>>,\n) => {\n try {\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const normalisedParams = await HederaParameterNormaliser.normaliseCreateFungibleTokenParams(\n params,\n context,\n client,\n mirrornodeService,\n );\n const tx = HederaBuilder.createFungibleToken(normalisedParams);\n\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to create fungible token';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[create_fungible_token_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const CREATE_FUNGIBLE_TOKEN_TOOL = 'create_fungible_token_tool';\n\nconst tool = (context: Context): Tool => ({\n method: CREATE_FUNGIBLE_TOKEN_TOOL,\n name: 'Create Fungible Token',\n description: createFungibleTokenPrompt(context),\n parameters: createFungibleTokenParameters(context),\n execute: createFungibleToken,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport { mintFungibleTokenParameters } from '@/shared/parameter-schemas/token.zod';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst mintFungibleTokenPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will mint a given amount (supply) of an existing HTS fungible token on Hedera.\n\nParameters:\n- tokenId (str, required): The id of the token\n- amount (number, required): The amount to be minted. Given in display units, the tool will handle parsing\n${usageInstructions}\n\nExample: \"Mint 1 of 0.0.6458037\" means minting the amount of 1 of the token with id 0.0.6458037.\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n if (response.scheduleId) {\n return `Scheduled mint transaction created successfully.\nTransaction ID: ${response.transactionId.toString()}\nSchedule ID: ${response.scheduleId.toString()}`;\n }\n return `Tokens successfully minted.\nTransaction ID: ${response.transactionId.toString()}`;\n};\n\nconst mintFungibleToken = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof mintFungibleTokenParameters>>,\n) => {\n try {\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const normalisedParams = await HederaParameterNormaliser.normaliseMintFungibleTokenParams(\n params,\n context,\n client,\n mirrornodeService,\n );\n const tx = HederaBuilder.mintFungibleToken(normalisedParams);\n\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to mint fungible token';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[mint_fungible_token_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const MINT_FUNGIBLE_TOKEN_TOOL = 'mint_fungible_token_tool';\n\nconst tool = (context: Context): Tool => ({\n method: MINT_FUNGIBLE_TOKEN_TOOL,\n name: 'Mint Fungible Token',\n description: mintFungibleTokenPrompt(context),\n parameters: mintFungibleTokenParameters(context),\n execute: mintFungibleToken,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport { createNonFungibleTokenParameters } from '@/shared/parameter-schemas/token.zod';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst createNonFungibleTokenPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const treasuryAccountDesc = PromptGenerator.getAccountParameterDescription(\n 'treasuryAccountId',\n context,\n );\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool creates a HTS non-fungible token (NFT) on Hedera.\n\nParameters:\n- tokenName (str, required): Name of the token\n- tokenSymbol (str, required): Symbol of the token\n- supplyType (str, optional): The supply type of the token. Can be \"finite\" or \"infinite\". Defaults to \"finite\"\n- maxSupply (int, optional): Maximum NFT supply. Only applicable if supplyType is \"finite\". Defaults to 100 if not specified\n- isSupplyKey (boolean, optional): If user wants to set supply key set to true, otherwise false\n- ${treasuryAccountDesc}\n${PromptGenerator.getScheduledTransactionParamsDescription(context)}\n\nFor tool call only tokenName and tokenSymbol are optional and if not provided, the tool will use the default values.\n\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n if (response.scheduleId) {\n return `Scheduled transaction created successfully.\nTransaction ID: ${response.transactionId.toString()}\nSchedule ID: ${response.scheduleId.toString()}`;\n }\n const tokenIdStr = response.tokenId ? response.tokenId.toString() : 'unknown';\n return `Token created successfully.\nTransaction ID: ${response.transactionId.toString()}\nToken ID: ${tokenIdStr}`;\n};\n\nconst createNonFungibleToken = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof createNonFungibleTokenParameters>>,\n) => {\n try {\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const normalisedParams = await HederaParameterNormaliser.normaliseCreateNonFungibleTokenParams(\n params,\n context,\n client,\n mirrornodeService,\n );\n const tx = HederaBuilder.createNonFungibleToken(normalisedParams);\n\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to create non-fungible token';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[create_non_fungible_token_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const CREATE_NON_FUNGIBLE_TOKEN_TOOL = 'create_non_fungible_token_tool';\n\nconst tool = (context: Context): Tool => ({\n method: CREATE_NON_FUNGIBLE_TOKEN_TOOL,\n name: 'Create Non-Fungible Token',\n description: createNonFungibleTokenPrompt(context),\n parameters: createNonFungibleTokenParameters(context),\n execute: createNonFungibleToken,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport { mintNonFungibleTokenParameters } from '@/shared/parameter-schemas/token.zod';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst mintNonFungibleTokenPrompt = (_context: Context = {}) => {\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n\nThis tool will mint HTS NFTs with its unique metadata for the class of NFTs (non-fungible tokens) defined by the tokenId on Hedera.\n\nParameters:\n- tokenId (str, required): The id of the token\n- uris (array, required): An array of strings (URIs) of maximum size 10 hosting the NFT metadata\n${usageInstructions}\n\nExample: \"Mint 0.0.6465503 with metadata: ipfs://bafyreiao6ajgsfji6qsgbqwdtjdu5gmul7tv2v3pd6kjgcw5o65b2ogst4/metadata.json\" means minting an NFT with the given metadata URI for the class of NFTs defined by the token with id 0.0.6465503.\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n if (response.scheduleId) {\n return `Scheduled mint transaction created successfully.\nTransaction ID: ${response.transactionId.toString()}\nSchedule ID: ${response.scheduleId.toString()}`;\n }\n const tokenIdStr = response.tokenId ? response.tokenId.toString() : 'unknown';\n return `Token successfully minted.\nTransaction ID: ${response.transactionId.toString()}\nToken ID: ${tokenIdStr}`;\n};\n\nconst mintNonFungibleToken = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof mintNonFungibleTokenParameters>>,\n) => {\n try {\n const normalisedParams = await HederaParameterNormaliser.normaliseMintNonFungibleTokenParams(\n params,\n context,\n client,\n );\n const tx = HederaBuilder.mintNonFungibleToken(normalisedParams);\n\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to mint non-fungible token';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[mint_non_fungible_token_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const MINT_NON_FUNGIBLE_TOKEN_TOOL = 'mint_non_fungible_token_tool';\n\nconst tool = (context: Context): Tool => ({\n method: MINT_NON_FUNGIBLE_TOKEN_TOOL,\n name: 'Mint Non-Fungible Token',\n description: mintNonFungibleTokenPrompt(context),\n parameters: mintNonFungibleTokenParameters(context),\n execute: mintNonFungibleToken,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { approveNftAllowanceParameters } from '@/shared/parameter-schemas/token.zod';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst approveNftAllowancePrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const ownerAccountDesc = PromptGenerator.getAccountParameterDescription(\n 'ownerAccountId',\n context,\n );\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool approves an HTS NFT allowance from the owner to the spender for specific NFT serial numbers of a token, or for all serials in the NFT collection.\n\nParameters:\n- ${ownerAccountDesc}\n- spenderAccountId (string, required): Spender account ID\n- tokenId (string, required): The NFT token ID (e.g., 0.0.xxxxx)\n- allSerials (boolean, optional): If true, approves allowance for all current and future serials of the NFT. When true, do not provide serialNumbers.\n- serialNumbers (number[], conditionally required): Array of NFT serial numbers to approve - accepts multiple serial numbers at once. Required when allSerials is not true.\n- transactionMemo (string, optional): Optional memo for the transaction\n${usageInstructions}\n\nIf multiple serial numbers are provided, they should all be included in a single tool call as a list of serial numbers.\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `NFT allowance approved successfully. Transaction ID: ${response.transactionId}`;\n};\n\nconst approveNftAllowance = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof approveNftAllowanceParameters>>,\n) => {\n try {\n const normalisedParams = HederaParameterNormaliser.normaliseApproveNftAllowance(\n params,\n context,\n client,\n );\n const tx = HederaBuilder.approveNftAllowance(normalisedParams);\n\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to Approve NFT allowance';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[approve_nft_allowance_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const APPROVE_NFT_ALLOWANCE_TOOL = 'approve_nft_allowance_tool';\n\nconst tool = (context: Context): Tool => ({\n method: APPROVE_NFT_ALLOWANCE_TOOL,\n name: 'Approve NFT Allowance',\n description: approveNftAllowancePrompt(context),\n parameters: approveNftAllowanceParameters(context),\n execute: approveNftAllowance,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { deleteNftAllowanceParameters } from '@/shared/parameter-schemas/token.zod';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst deleteNftAllowancePrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const ownerAccountDesc = PromptGenerator.getAccountParameterDescription(\n 'ownerAccountId',\n context,\n );\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool deletes HTS NFT allowance(s) from the owner. Removing an allowance for a serial number means clearing the currently approved spender.\n\nParameters:\n- ${ownerAccountDesc}\n- tokenId (string, required): The ID of the NFT token.\n- serialNumbers (number[], required): Array of serial numbers to remove allowance for.\n- transactionMemo (string, optional): Optional memo for the transaction.\n${usageInstructions}\n\nExample: \"Delete allowance for NFT 0.0.123 serials [1, 2]\"\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `NFT allowance(s) deleted successfully. Transaction ID: ${response.transactionId}`;\n};\n\nconst deleteNftAllowance = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof deleteNftAllowanceParameters>>,\n) => {\n try {\n const normalisedParams = HederaParameterNormaliser.normaliseDeleteNftAllowance(\n params,\n context,\n client,\n );\n const tx = HederaBuilder.deleteNftAllowance(normalisedParams);\n\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to delete NFT allowance';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[delete_non_fungible_token_allowance_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const DELETE_NFT_ALLOWANCE_TOOL = 'delete_non_fungible_token_allowance_tool';\n\nconst tool = (context: Context): Tool => ({\n method: DELETE_NFT_ALLOWANCE_TOOL,\n name: 'Delete Non Fungible Token Allowance',\n description: deleteNftAllowancePrompt(context),\n parameters: deleteNftAllowanceParameters(context),\n execute: deleteNftAllowance,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, PublicKey, Status } from '@hashgraph/sdk';\nimport { TokenInfo } from '@/shared/hedera-utils/mirrornode/types';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport {\n updateTokenParameters,\n updateTokenParametersNormalised,\n} from '@/shared/parameter-schemas/token.zod';\nimport { IHederaMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-service.interface';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { AccountResolver } from '@/shared';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst checkValidityOfUpdates = async (\n params: z.infer<ReturnType<typeof updateTokenParametersNormalised>>,\n mirrornode: IHederaMirrornodeService,\n userPublicKey: PublicKey,\n) => {\n const tokenDetails: TokenInfo = await mirrornode.getTokenInfo(params.tokenId.toString());\n if (!tokenDetails) {\n throw new Error('Token not found');\n }\n\n if (tokenDetails.admin_key?.key !== userPublicKey.toStringRaw()) {\n console.error(\n `tokenDetails.admin_key.key: ${tokenDetails.admin_key?.key} vs userPublicKey: ${userPublicKey.toStringRaw()}`,\n );\n throw new Error(\n 'You do not have permission to update this token. The adminKey does not match your public key.',\n );\n }\n\n const keyChecks: Partial<Record<keyof typeof params, keyof TokenInfo>> = {\n adminKey: 'admin_key',\n kycKey: 'kyc_key',\n freezeKey: 'freeze_key',\n wipeKey: 'wipe_key',\n supplyKey: 'supply_key',\n feeScheduleKey: 'fee_schedule_key',\n pauseKey: 'pause_key',\n metadataKey: 'metadata_key',\n };\n\n for (const [paramKey, tokenField] of Object.entries(keyChecks) as [\n keyof typeof params,\n keyof TokenInfo,\n ][]) {\n const userValue = params[paramKey];\n const tokenKey = tokenDetails[tokenField];\n\n if (userValue instanceof PublicKey && !tokenKey) {\n throw new Error(`Cannot update ${paramKey}: token was created without a ${paramKey}`);\n }\n }\n};\n\nconst updateTokenPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const tokenDesc = PromptGenerator.getAnyAddressParameterDescription('tokenId', context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will update an existing Hedera HTS token. Only the fields provided will be updated.\n\nKey fields (adminKey, kycKey, freezeKey, wipeKey, supplyKey, feeScheduleKey, pauseKey, metadataKey) must contain **Hedera-compatible public keys (as strings) or boolean (true/false)**. You can provide these in one of three ways:\n\n1. **Boolean true** – Set this field to use user/operator key. Injecting of the key will be handled automatically.\n2. **Not provided** – The field will not be updated.\n3. **String** – Provide a Hedera-compatible public key string to set a field explicitly.\n\nParameters:\n- ${tokenDesc}\n- tokenName (string, optional): New name for the token. Up to 100 characters.\n- tokenSymbol (string, optional): New symbol for the token. Up to 100 characters.\n- treasuryAccountId (string, optional): New treasury account for the token (Hedera account ID).\n- adminKey (boolean|string, optional): New admin key. Pass true to use your operator key, or provide a public key string.\n- kycKey (boolean|string, optional): New KYC key. Pass true to use your operator key, or provide a public key string.\n- freezeKey (boolean|string, optional): New freeze key. Pass true to use your operator key, or provide a public key string.\n- wipeKey (boolean|string, optional): New wipe key. Pass true to use your operator key, or provide a public key string.\n- supplyKey (boolean|string, optional): New supply key. Pass true to use your operator key, or provide a public key string.\n- feeScheduleKey (boolean|string, optional): New fee schedule key. Pass true to use your operator key, or provide a public key string.\n- pauseKey (boolean|string, optional): New pause key. Pass true to use your operator key, or provide a public key string.\n- metadataKey (boolean|string, optional): New metadata key. Pass true to use your operator key, or provide a public key string.\n- metadata (string, optional): New metadata for the token, in bytes (hex or base64).\n- tokenMemo (string, optional): Short public memo for the token, up to 100 characters.\n- autoRenewAccountId (string, optional): Account to automatically pay for renewal.\n\nExamples:\n- If the user asks for \"my key\" → set the field to \\`true\\`.\n- If the user does not mention the key → do not set the field.\n- If the user provides a key → set the field to the provided public key string.\n\nIf the user provides multiple fields in a single request, \ncombine them into **one tool call** with all parameters together.\n\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `Token successfully updated. Transaction ID: ${response.transactionId}`;\n};\n\nconst updateToken = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof updateTokenParameters>>,\n) => {\n try {\n const normalisedParams = await HederaParameterNormaliser.normaliseUpdateToken(\n params,\n context,\n client,\n );\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const userPublicKey = await AccountResolver.getDefaultPublicKey(context, client);\n\n await checkValidityOfUpdates(normalisedParams, mirrornodeService, userPublicKey);\n\n const tx = HederaBuilder.updateToken(normalisedParams);\n\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to update token';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[update_token_tool]', message);\n return {\n raw: { status: Status.InvalidTransaction, error: message },\n humanMessage: message,\n };\n }\n};\n\nexport const UPDATE_TOKEN_TOOL = 'update_token_tool';\n\nconst tool = (context: Context): Tool => ({\n method: UPDATE_TOKEN_TOOL,\n name: 'Update Token',\n description: updateTokenPrompt(context),\n parameters: updateTokenParameters(context),\n execute: updateToken,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport { dissociateTokenParameters } from '@/shared/parameter-schemas/token.zod';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst dissociateTokenPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const sourceAccountDesc = PromptGenerator.getAccountParameterDescription('accountId', context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will airdrop a HTS fungible token on Hedera.\n\nParameters:\n- tokenIds (array of strings, required): A list of Hedera token IDs to dissociate from the account. Example: [\"0.0.1234\", \"0.0.5678\"]\n- ${sourceAccountDesc}, account from which to dissociate the token(s)\n- transactionMemo (str, optional): Optional memo for the transaction\n\nExamples:\n- Dissociate a single token: { \"tokenIds\": [\"0.0.1234\"] }\n- Dissociate multiple tokens from a specific account: { \"tokenIds\": [\"0.0.1234\", \"0.0.5678\"], \"accountId\": \"0.0.4321\" }\n\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `Token(s) successfully dissociated with transaction id ${response.transactionId.toString()}`;\n};\n\nconst dissociateToken = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof dissociateTokenParameters>>,\n) => {\n try {\n const normalisedParams = await HederaParameterNormaliser.normaliseDissociateTokenParams(\n params,\n context,\n client,\n );\n const tx = HederaBuilder.dissociateToken(normalisedParams);\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to dissociate token';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[dissociate_token_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const DISSOCIATE_TOKEN_TOOL = 'dissociate_token_tool';\n\nconst tool = (context: Context): Tool => ({\n method: DISSOCIATE_TOKEN_TOOL,\n name: 'Dissociate Token',\n description: dissociateTokenPrompt(context),\n parameters: dissociateTokenParameters(context),\n execute: dissociateToken,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport { associateTokenParameters } from '@/shared/parameter-schemas/token.zod';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst associateTokenPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n const accountToAssociate = PromptGenerator.getAnyAddressParameterDescription(\n 'accountId',\n context,\n );\n\n return `\n${contextSnippet}\n\nThis tool will associate one or more HTS tokens with a Hedera account.\n\nParameters:\n${accountToAssociate}\n- tokenIds (string[], required): Array of token IDs to associate\n${usageInstructions}\n\nExample: \"Associate tokens 0.0.123 and 0.0.456 to account 0.0.789\".\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `Tokens successfully associated with transaction id ${response.transactionId.toString()}`;\n};\n\nconst associateToken = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof associateTokenParameters>>,\n) => {\n try {\n const normalisedParams = HederaParameterNormaliser.normaliseAssociateTokenParams(\n params,\n context,\n client,\n );\n const tx = HederaBuilder.associateToken(normalisedParams);\n const result = await handleTransaction(tx, client, context, postProcess);\n return result;\n } catch (error) {\n const desc = 'Failed to associate token(s)';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[associate_token_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const ASSOCIATE_TOKEN_TOOL = 'associate_token_tool';\n\nconst tool = (context: Context): Tool => ({\n method: ASSOCIATE_TOKEN_TOOL,\n name: 'Associate Token(s)',\n description: associateTokenPrompt(context),\n parameters: associateTokenParameters(context),\n execute: associateToken,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { transferNonFungibleTokenWithAllowanceParameters } from '@/shared/parameter-schemas/token.zod';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst transferNonFungibleTokenWithAllowancePrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\nThis tool will transfer HTS non-fungible tokens (NFTs) using an existing **token allowance**.\n\nParameters:\n- sourceAccountId (string, required): The token owner (allowance granter)\n- tokenId (string, required): The NFT token ID to transfer (e.g. \"0.0.12345\")\n- recipients (array, required): List of objects specifying recipients and serial numbers - accepts multiple transfers at once\n - recipientId (string, required): Account to transfer to\n - serialNumber (string, required): NFT serial number to transfer\n- transactionMemo (string, optional): Optional memo for the transaction\n\n${usageInstructions}\n\nIf multiple recipients are specified, the tool will create a single transaction for all transfers - they should be defined in recipients array.\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `Non-fungible tokens successfully transferred with allowance. Transaction ID: ${response.transactionId}`;\n};\n\nconst transferNonFungibleTokenWithAllowance = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof transferNonFungibleTokenWithAllowanceParameters>>,\n) => {\n try {\n const normalisedParams =\n HederaParameterNormaliser.normaliseTransferNonFungibleTokenWithAllowance(params, context);\n\n const tx = HederaBuilder.transferNonFungibleTokenWithAllowance(normalisedParams);\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to transfer non-fungible token with allowance';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[transfer_non_fungible_token_with_allowance_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const TRANSFER_NON_FUNGIBLE_TOKEN_WITH_ALLOWANCE_TOOL =\n 'transfer_non_fungible_token_with_allowance_tool';\n\nconst tool = (context: Context): Tool => ({\n method: TRANSFER_NON_FUNGIBLE_TOKEN_WITH_ALLOWANCE_TOOL,\n name: 'Transfer Non Fungible Token with Allowance',\n description: transferNonFungibleTokenWithAllowancePrompt(context),\n parameters: transferNonFungibleTokenWithAllowanceParameters(context),\n execute: transferNonFungibleTokenWithAllowance,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { transferNonFungibleTokenParameters } from '@/shared/parameter-schemas/token.zod';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst transferNonFungibleTokenPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\nThis tool will transfer HTS non-fungible tokens (NFTs) from the operator's account to specified recipients.\n\nParameters:\n- tokenId (string, required): The NFT token ID to transfer (e.g. \"0.0.12345\")\n- recipients (array, required): List of objects specifying recipients and serial numbers - accepts multiple transfers at once\n - recipientId (string, required): Account to transfer to\n - serialNumber (number, required): NFT serial number to transfer\n- transactionMemo (string, optional): Optional memo for the transaction\n${PromptGenerator.getScheduledTransactionParamsDescription(context)}\n\n${usageInstructions}\nIf multiple recipients are specified, the tool will create a single transaction for all transfers - they should be defined in recipients array.\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n if (response.scheduleId) {\n return `Scheduled non-fungible token transfer created successfully.\nTransaction ID: ${response.transactionId}\nSchedule ID: ${response.scheduleId.toString()}`;\n }\n return `Non-fungible tokens successfully transferred. Transaction ID: ${response.transactionId}`;\n};\n\nconst transferNonFungibleToken = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof transferNonFungibleTokenParameters>>,\n) => {\n try {\n const normalisedParams = await HederaParameterNormaliser.normaliseTransferNonFungibleToken(\n params,\n context,\n client,\n );\n\n const tx = HederaBuilder.transferNonFungibleToken(normalisedParams);\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to transfer non-fungible token';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[transfer_non_fungible_token_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const TRANSFER_NON_FUNGIBLE_TOKEN_TOOL = 'transfer_non_fungible_token_tool';\n\nconst tool = (context: Context): Tool => ({\n method: TRANSFER_NON_FUNGIBLE_TOKEN_TOOL,\n name: 'Transfer Non Fungible Token',\n description: transferNonFungibleTokenPrompt(context),\n parameters: transferNonFungibleTokenParameters(context),\n execute: transferNonFungibleToken,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { Context } from '@/shared';\nimport { Plugin } from '@/shared/plugin';\nimport airdropFungibleToken, {\n AIRDROP_FUNGIBLE_TOKEN_TOOL,\n} from '@/plugins/core-token-plugin/tools/fungible-token/airdrop-fungible-token';\nimport transferFungibleTokenWithAllowanceTool, {\n TRANSFER_FUNGIBLE_TOKEN_WITH_ALLOWANCE_TOOL,\n} from '@/plugins/core-token-plugin/tools/fungible-token/transfer-fungible-token-with-allowance';\nimport createFungibleTokenTool, {\n CREATE_FUNGIBLE_TOKEN_TOOL,\n} from '@/plugins/core-token-plugin/tools/fungible-token/create-fungible-token';\nimport mintFungibleTokenTool, {\n MINT_FUNGIBLE_TOKEN_TOOL,\n} from '@/plugins/core-token-plugin/tools/fungible-token/mint-fungible-token';\nimport createNonFungibleTokenTool, {\n CREATE_NON_FUNGIBLE_TOKEN_TOOL,\n} from '@/plugins/core-token-plugin/tools/non-fungible-token/create-non-fungible-token';\nimport mintNonFungibleTokenTool, {\n MINT_NON_FUNGIBLE_TOKEN_TOOL,\n} from '@/plugins/core-token-plugin/tools/non-fungible-token/mint-non-fungible-token';\nimport approveNftAllowanceTool, {\n APPROVE_NFT_ALLOWANCE_TOOL,\n} from '@/plugins/core-token-plugin/tools/non-fungible-token/approve-non-fungible-token-allowance';\nimport deleteNftAllowanceTool, {\n DELETE_NFT_ALLOWANCE_TOOL,\n} from '@/plugins/core-token-plugin/tools/non-fungible-token/delete-non-fungible-token-allowance';\nimport updateTokenTool, { UPDATE_TOKEN_TOOL } from '@/plugins/core-token-plugin/tools/update-token';\nimport dissociateTokenTool, {\n DISSOCIATE_TOKEN_TOOL,\n} from '@/plugins/core-token-plugin/tools/dissociate-token';\nimport associateTokenTool, {\n ASSOCIATE_TOKEN_TOOL,\n} from '@/plugins/core-token-plugin/tools/associate-token';\nimport transferNonFungibleTokenWithAllowanceTool, {\n TRANSFER_NON_FUNGIBLE_TOKEN_WITH_ALLOWANCE_TOOL,\n} from '@/plugins/core-token-plugin/tools/non-fungible-token/transfer-non-fungible-token-with-allowance';\nimport transferNonFungibleTokenTool, {\n TRANSFER_NON_FUNGIBLE_TOKEN_TOOL,\n} from '@/plugins/core-token-plugin/tools/non-fungible-token/transfer-non-fungible-token';\n\nexport const coreTokenPlugin: Plugin = {\n name: 'core-token-plugin',\n version: '1.0.0',\n description: 'A plugin for the Hedera Token Service',\n tools: (context: Context) => {\n return [\n createFungibleTokenTool(context),\n mintFungibleTokenTool(context),\n createNonFungibleTokenTool(context),\n airdropFungibleToken(context),\n mintNonFungibleTokenTool(context),\n approveNftAllowanceTool(context),\n deleteNftAllowanceTool(context),\n updateTokenTool(context),\n dissociateTokenTool(context),\n associateTokenTool(context),\n transferNonFungibleTokenWithAllowanceTool(context),\n transferNonFungibleTokenTool(context),\n transferFungibleTokenWithAllowanceTool(context),\n ];\n },\n};\n\n// Export tool names as an object for destructuring\nexport const coreTokenPluginToolNames = {\n AIRDROP_FUNGIBLE_TOKEN_TOOL,\n CREATE_FUNGIBLE_TOKEN_TOOL,\n MINT_FUNGIBLE_TOKEN_TOOL,\n CREATE_NON_FUNGIBLE_TOKEN_TOOL,\n MINT_NON_FUNGIBLE_TOKEN_TOOL,\n APPROVE_NFT_ALLOWANCE_TOOL,\n DELETE_NFT_ALLOWANCE_TOOL,\n DISSOCIATE_TOKEN_TOOL,\n ASSOCIATE_TOKEN_TOOL,\n UPDATE_TOKEN_TOOL,\n TRANSFER_NON_FUNGIBLE_TOKEN_WITH_ALLOWANCE_TOOL,\n TRANSFER_NON_FUNGIBLE_TOKEN_TOOL,\n TRANSFER_FUNGIBLE_TOKEN_WITH_ALLOWANCE_TOOL,\n} as const;\n\nexport default { coreTokenPlugin, coreTokenPluginToolNames };\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { transferHbarParameters } from '@/shared/parameter-schemas/account.zod';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst transferHbarPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const sourceAccountDesc = PromptGenerator.getAccountParameterDescription(\n 'sourceAccountId',\n context,\n );\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will transfer HBAR to an account.\n\nParameters:\n- transfers (array of objects, required): List of HBAR transfers to RECIPIENTS ONLY. CRITICAL: Do not include the sender/source account in this array. Each object should contain:\n - accountId (string, required): Recipient account ID (NOT the sender)\n - amount (number, required): Amount of HBAR to transfer\n- ${sourceAccountDesc} (Use this parameter for the sender. Do NOT put the sender in the transfers array).\n- transactionMemo (string, optional): Optional memo for the transfer HBAR transaction\n${PromptGenerator.getScheduledTransactionParamsDescription(context)}\n\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n if (response.scheduleId) {\n return `Scheduled HBAR transfer created successfully.\nTransaction ID: ${response.transactionId}\nSchedule ID: ${response.scheduleId.toString()}`;\n }\n return `HBAR successfully transferred.\nTransaction ID: ${response.transactionId}`;\n};\n\nconst transferHbar = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof transferHbarParameters>>,\n) => {\n try {\n const normalisedParams = await HederaParameterNormaliser.normaliseTransferHbar(\n params,\n context,\n client,\n );\n const tx = HederaBuilder.transferHbar(normalisedParams);\n\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to transfer HBAR';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[transfer_hbar_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const TRANSFER_HBAR_TOOL = 'transfer_hbar_tool';\n\nconst tool = (context: Context): Tool => ({\n method: TRANSFER_HBAR_TOOL,\n name: 'Transfer HBAR',\n description: transferHbarPrompt(context),\n parameters: transferHbarParameters(context),\n execute: transferHbar,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { transferHbarWithAllowanceParameters } from '@/shared/parameter-schemas/account.zod';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst transferHbarWithAllowancePrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will transfer HBAR using an existing allowance.\n\nParameters:\n- sourceAccountId (string, required): Account ID of the HBAR owner (the allowance granter)\n- transfers (array of objects, required): List of HBAR transfers. Each object should contain:\n - accountId (string, required): Recipient account ID\n - amount (number, required): Amount of HBAR to transfer\n- transactionMemo (string, optional): Optional memo for the transfer HBAR with allowance transaction\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `HBAR successfully transferred with allowance. Transaction ID: ${response.transactionId}`;\n};\n\nconst transferHbarWithAllowance = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof transferHbarWithAllowanceParameters>>,\n) => {\n try {\n const normalisedParams = HederaParameterNormaliser.normaliseTransferHbarWithAllowance(\n params,\n context,\n client,\n );\n\n const tx = HederaBuilder.transferHbarWithAllowance(normalisedParams);\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to transfer HBAR with allowance';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[transfer_hbar_with_allowance_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const TRANSFER_HBAR_WITH_ALLOWANCE_TOOL = 'transfer_hbar_with_allowance_tool';\n\nconst tool = (context: Context): Tool => ({\n method: TRANSFER_HBAR_WITH_ALLOWANCE_TOOL,\n name: 'Transfer HBAR with allowance',\n description: transferHbarWithAllowancePrompt(context),\n parameters: transferHbarWithAllowanceParameters(context),\n execute: transferHbarWithAllowance,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { approveHbarAllowanceParameters } from '@/shared/parameter-schemas/account.zod';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst approveHbarAllowancePrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const ownerAccountDesc = PromptGenerator.getAccountParameterDescription(\n 'ownerAccountId',\n context,\n );\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool approves an HBAR allowance from the owner to the spender.\n\nParameters:\n- ${ownerAccountDesc}\n- spenderAccountId (string, required): Spender account ID\n- amount (number, required): Amount of HBAR to approve (can be decimal, cannot be negative)\n- transactionMemo (string, optional): Optional memo for the transaction\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `HBAR allowance approved successfully. Transaction ID: ${response.transactionId}`;\n};\n\nconst approveHbarAllowance = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof approveHbarAllowanceParameters>>,\n) => {\n try {\n const normalisedParams = HederaParameterNormaliser.normaliseApproveHbarAllowance(\n params,\n context,\n client,\n );\n const tx = HederaBuilder.approveHbarAllowance(normalisedParams);\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to approve hbar allowance.';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[approve_hbar_allowance_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const APPROVE_HBAR_ALLOWANCE_TOOL = 'approve_hbar_allowance_tool';\n\nconst tool = (context: Context): Tool => ({\n method: APPROVE_HBAR_ALLOWANCE_TOOL,\n name: 'Approve HBAR Allowance',\n description: approveHbarAllowancePrompt(context),\n parameters: approveHbarAllowanceParameters(context),\n execute: approveHbarAllowance,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { createAccountParameters } from '@/shared/parameter-schemas/account.zod';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst createAccountPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will create a new Hedera account with a passed public key. If not passed, the tool will use operator's public key.\n\nIMPORTANT: All parameters are optional. If the user does not explicitly provide optional parameters, proceed immediately using the default values. Do NOT ask the user for optional parameters.\n\nParameters:\n- publicKey (string, optional): Public key to use for the account. If not provided, the tool will use the operator's public key.\n- accountMemo (string, optional): Optional memo for the account. Max 100 chars. Length will be validated in tool call.\n- initialBalance (number, optional, default 0): Initial HBAR to fund the account\n- maxAutomaticTokenAssociations (number, optional, default -1): -1 means unlimited\n- ${PromptGenerator.getScheduledTransactionParamsDescription(context)}\n\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n if (response.scheduleId) {\n return `Scheduled transaction created successfully.\\nTransaction ID: ${response.transactionId}\\nSchedule ID: ${response.scheduleId.toString()}\\n}`;\n }\n const accountIdStr = response.accountId ? response.accountId.toString() : 'unknown';\n return `Account created successfully.\\nTransaction ID: ${response.transactionId}\\nNew Account ID: ${accountIdStr}\\n}`;\n};\n\nconst createAccount = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof createAccountParameters>>,\n) => {\n try {\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n\n // Normalise params to match AccountCreateTransaction props\n const normalisedParams = await HederaParameterNormaliser.normaliseCreateAccount(\n params,\n context,\n client,\n mirrornodeService,\n );\n\n // Build transaction and wrap in SchedulingTransaction if needed\n const tx = HederaBuilder.createAccount(normalisedParams);\n\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to create account';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[create_account_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const CREATE_ACCOUNT_TOOL = 'create_account_tool';\n\nconst tool = (context: Context): Tool => ({\n method: CREATE_ACCOUNT_TOOL,\n name: 'Create Account',\n description: createAccountPrompt(context),\n parameters: createAccountParameters(context),\n execute: createAccount,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { deleteAccountParameters } from '@/shared/parameter-schemas/account.zod';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst deleteAccountPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const accountDesc = PromptGenerator.getAccountParameterDescription('accountId', context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will delete an existing Hedera account. The remaining balance of the account will be transferred to the transferAccountId if provided, otherwise the operator account will be used.\n\nParameters:\n- ${accountDesc}\n- accountId (str, required): The account ID to delete\n- transferAccountId (str, optional): The account ID to transfer the remaining balance to. If not provided, the operator account will be used.\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `Account successfully deleted. Transaction ID: ${response.transactionId}`;\n};\n\nconst deleteAccount = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof deleteAccountParameters>>,\n) => {\n try {\n const normalisedParams = HederaParameterNormaliser.normaliseDeleteAccount(\n params,\n context,\n client,\n );\n\n let tx = HederaBuilder.deleteAccount(normalisedParams);\n\n const result = await handleTransaction(tx, client, context, postProcess);\n return result;\n } catch (error) {\n const desc = 'Failed to delete account';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[delete_account_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const DELETE_ACCOUNT_TOOL = 'delete_account_tool';\n\nconst tool = (context: Context): Tool => ({\n method: DELETE_ACCOUNT_TOOL,\n name: 'Delete Account',\n description: deleteAccountPrompt(context),\n parameters: deleteAccountParameters(context),\n execute: deleteAccount,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { updateAccountParameters } from '@/shared/parameter-schemas/account.zod';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst updateAccountPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const accountDesc = PromptGenerator.getAccountParameterDescription('accountId', context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will update an existing Hedera account. Only provided fields will be updated.\n\nParameters:\n- ${accountDesc}\n- accountId (string, optional) Account ID to update (e.g., 0.0.xxxxx). If not provided, operator account ID will be used\n- maxAutomaticTokenAssociations (number, optional)\n- stakedAccountId (string, optional)\n- accountMemo (string, optional) - memo to be set for the upgraded account\n- declineStakingReward (boolean, optional)\n- ${PromptGenerator.getScheduledTransactionParamsDescription(context)}\n\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n if (response.scheduleId) {\n return `Scheduled account update created successfully.\nTransaction ID: ${response.transactionId}\nSchedule ID: ${response.scheduleId.toString()}`;\n }\n return `Account successfully updated.\nTransaction ID: ${response.transactionId}`;\n};\n\nconst updateAccount = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof updateAccountParameters>>,\n) => {\n try {\n const normalisedParams = await HederaParameterNormaliser.normaliseUpdateAccount(\n params,\n context,\n client,\n );\n\n // Build transaction and wrap in SchedulingTransaction if needed\n const tx = HederaBuilder.updateAccount(normalisedParams);\n\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to update account';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[update_account_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const UPDATE_ACCOUNT_TOOL = 'update_account_tool';\n\nconst tool = (context: Context): Tool => ({\n method: UPDATE_ACCOUNT_TOOL,\n name: 'Update Account',\n description: updateAccountPrompt(context),\n parameters: updateAccountParameters(context),\n execute: updateAccount,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { signScheduleTransactionParameters } from '@/shared/parameter-schemas/account.zod';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst signScheduleTransactionPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will sign a scheduled transaction and return the transaction ID.\n\nParameters:\n- scheduleId (string, required): The ID of the scheduled transaction to sign\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `Transaction successfully signed. Transaction ID: ${response.transactionId}`;\n};\n\nconst signScheduleTransaction = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof signScheduleTransactionParameters>>,\n) => {\n try {\n const tx = HederaBuilder.signScheduleTransaction(params);\n const result = await handleTransaction(tx, client, context, postProcess);\n return result;\n } catch (error) {\n const desc = 'Failed to sign scheduled transaction';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[sign_schedule_transaction_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const SIGN_SCHEDULE_TRANSACTION_TOOL = 'sign_schedule_transaction_tool';\n\nconst tool = (context: Context): Tool => ({\n method: SIGN_SCHEDULE_TRANSACTION_TOOL,\n name: 'Sign Scheduled Transaction',\n description: signScheduleTransactionPrompt(context),\n parameters: signScheduleTransactionParameters(context),\n execute: signScheduleTransaction,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { scheduleDeleteTransactionParameters } from '@/shared/parameter-schemas/account.zod';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst scheduleDeletePrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will delete a scheduled transaction (by admin) so it will not execute.\n\nParameters:\n- scheduleId (string, required): The ID of the scheduled transaction to delete\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `Scheduled transaction successfully deleted. Transaction ID: ${response.transactionId}`;\n};\n\nconst scheduleDelete = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof scheduleDeleteTransactionParameters>>,\n) => {\n try {\n const tx = HederaBuilder.deleteScheduleTransaction(params);\n const result = await handleTransaction(tx, client, context, postProcess);\n return result;\n } catch (error) {\n const desc = 'Failed to delete scheduled transaction';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[schedule_delete_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const SCHEDULE_DELETE_TOOL = 'schedule_delete_tool';\n\nconst tool = (context: Context): Tool => ({\n method: SCHEDULE_DELETE_TOOL,\n name: 'Delete Scheduled Transaction',\n description: scheduleDeletePrompt(context),\n parameters: scheduleDeleteTransactionParameters(context),\n execute: scheduleDelete,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { deleteHbarAllowanceParameters } from '@/shared/parameter-schemas/account.zod';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst deleteHbarAllowancePrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const ownerAccountDesc = PromptGenerator.getAccountParameterDescription(\n 'ownerAccountId',\n context,\n );\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool deletes an HBAR allowance from the owner to the spender.\n\nParameters:\n- ${ownerAccountDesc}\n- spenderAccountId (string, required): Spender account ID\n- transactionMemo (string, optional): Optional memo for the transaction\n${usageInstructions}\n\nExample: \"Delete HBAR allowance from 0.0.123 to 0.0.456\". Spender account ID is 0.0.456 and the owner account ID is 0.0.123.\nExample 2: \"Delete HBAR allowance for 0.0.123\". Spender account ID is 0.0.123 and the owner account ID was not specified.\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `HBAR allowance deleted successfully. Transaction ID: ${response.transactionId}`;\n};\n\nconst deleteHbarAllowance = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof deleteHbarAllowanceParameters>>,\n) => {\n try {\n const normalisedParams = HederaParameterNormaliser.normaliseDeleteHbarAllowance(\n params,\n context,\n client,\n );\n const tx = HederaBuilder.approveHbarAllowance(normalisedParams);\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to delete hbar allowance.';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[delete_hbar_allowance_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const DELETE_HBAR_ALLOWANCE_TOOL = 'delete_hbar_allowance_tool';\n\nconst tool = (context: Context): Tool => ({\n method: DELETE_HBAR_ALLOWANCE_TOOL,\n name: 'Delete HBAR Allowance',\n description: deleteHbarAllowancePrompt(context),\n parameters: deleteHbarAllowanceParameters(context),\n execute: deleteHbarAllowance,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport { approveTokenAllowanceParameters } from '@/shared/parameter-schemas/account.zod';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst approveTokenAllowancePrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const ownerAccountDesc = PromptGenerator.getAccountParameterDescription(\n 'ownerAccountId',\n context,\n );\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool approves allowances for one or more fungible HTS tokens from the owner to the spender.\n\nParameters:\n- ${ownerAccountDesc}\n- spenderAccountId (string, required): Spender account ID\n- tokenApprovals (array, required): List of approvals. Each item:\n - tokenId (string): Token ID\n - amount (number): Amount of tokens to approve (must be a positive number, can be float or int). Given in display units, the tool will handle parsing\n- transactionMemo (string, optional): Optional memo for the transaction\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `Fungible token allowance(s) approved successfully. Transaction ID: ${response.transactionId}`;\n};\n\nconst approveTokenAllowance = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof approveTokenAllowanceParameters>>,\n) => {\n try {\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const normalisedParams = await HederaParameterNormaliser.normaliseApproveTokenAllowance(\n params,\n context,\n client,\n mirrornodeService,\n );\n\n const tx = HederaBuilder.approveTokenAllowance(normalisedParams);\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to approve token allowance';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[approve_token_allowance_tool]', message);\n return {\n raw: { status: Status.InvalidTransaction.toString(), error: message },\n humanMessage: message,\n };\n }\n};\n\nexport const APPROVE_TOKEN_ALLOWANCE_TOOL = 'approve_token_allowance_tool';\n\nconst tool = (context: Context): Tool => ({\n method: APPROVE_TOKEN_ALLOWANCE_TOOL,\n name: 'Approve Token Allowance',\n description: approveTokenAllowancePrompt(context),\n parameters: approveTokenAllowanceParameters(context),\n execute: approveTokenAllowance,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { deleteTokenAllowanceParameters } from '@/shared/parameter-schemas/account.zod';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst deleteTokenAllowancePrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const ownerAccountDesc = PromptGenerator.getAccountParameterDescription(\n 'ownerAccountId',\n context,\n );\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\nThis tool deletes HTS token allowance(s) from the owner to the spender.\n\nParameters:\n- ${ownerAccountDesc}\n- spenderAccountId (string, required): Spender account ID\n- tokenIds (array, required): List of token IDs whose allowances should be removed\n- transactionMemo (string, optional): Optional memo for the transaction\n${usageInstructions}\nExample: \"Delete token allowance for account 0.0.123 on token 0.0.456\". Means that 0.0.123 is the spenderId, 0.0.456 is the tokenId and the ownerId is taken from context or default operator.\nExample 2: \"Delete token allowance given from 0.0.1001 to account 0.0.2002 for token 0.0.3003\". Means that 0.0.1001 is the ownerId, 0.0.2002 is the spenderId and 0.0.3003 is the tokenId.\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `Token allowance(s) deleted successfully. Transaction ID: ${response.transactionId}`;\n};\n\nconst deleteTokenAllowance = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof deleteTokenAllowanceParameters>>,\n) => {\n try {\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const normalisedParams = await HederaParameterNormaliser.normaliseDeleteTokenAllowance(\n params,\n context,\n client,\n mirrornodeService,\n );\n\n const tx = HederaBuilder.approveTokenAllowance(normalisedParams);\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to delete token allowance(s).';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[delete_token_allowance_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const DELETE_TOKEN_ALLOWANCE_TOOL = 'delete_token_allowance_tool';\n\nconst tool = (context: Context): Tool => ({\n method: DELETE_TOKEN_ALLOWANCE_TOOL,\n name: 'Delete Token Allowance',\n description: deleteTokenAllowancePrompt(context),\n parameters: deleteTokenAllowanceParameters(context),\n execute: deleteTokenAllowance,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { Context } from '@/shared';\nimport { Plugin } from '@/shared/plugin';\nimport transferHbarTool, {\n TRANSFER_HBAR_TOOL,\n} from '@/plugins/core-account-plugin/tools/account/transfer-hbar';\nimport transferHbarWithAllowanceTool, {\n TRANSFER_HBAR_WITH_ALLOWANCE_TOOL,\n} from '@/plugins/core-account-plugin/tools/account/transfer-hbar-with-allowance';\nimport approveHbarAllowanceTool, {\n APPROVE_HBAR_ALLOWANCE_TOOL,\n} from '@/plugins/core-account-plugin/tools/account/approve-hbar-allowance';\nimport createAccountTool, {\n CREATE_ACCOUNT_TOOL,\n} from '@/plugins/core-account-plugin/tools/account/create-account';\nimport deleteAccountTool, {\n DELETE_ACCOUNT_TOOL,\n} from '@/plugins/core-account-plugin/tools/account/delete-account';\nimport updateAccountTool, {\n UPDATE_ACCOUNT_TOOL,\n} from '@/plugins/core-account-plugin/tools/account/update-account';\nimport signScheduleTransactionTool, {\n SIGN_SCHEDULE_TRANSACTION_TOOL,\n} from '@/plugins/core-account-plugin/tools/account/sign-schedule-transaction';\nimport scheduleDeleteTool, {\n SCHEDULE_DELETE_TOOL,\n} from '@/plugins/core-account-plugin/tools/account/schedule-delete';\nimport deleteHbarAllowanceTool, {\n DELETE_HBAR_ALLOWANCE_TOOL,\n} from '@/plugins/core-account-plugin/tools/account/delete-hbar-allowance';\nimport approveTokenAllowanceTool, {\n APPROVE_TOKEN_ALLOWANCE_TOOL,\n} from '@/plugins/core-token-plugin/tools/fungible-token/approve-token-allowance';\nimport deleteTokenAllowanceTool, {\n DELETE_TOKEN_ALLOWANCE_TOOL,\n} from '@/plugins/core-token-plugin/tools/fungible-token/delete-token-allowance';\n\nexport const coreAccountPlugin: Plugin = {\n name: 'core-account-plugin',\n version: '1.0.0',\n description: 'A plugin for the Hedera Account Service',\n tools: (context: Context) => {\n return [\n transferHbarTool(context),\n approveHbarAllowanceTool(context),\n deleteHbarAllowanceTool(context),\n deleteAccountTool(context),\n updateAccountTool(context),\n createAccountTool(context),\n signScheduleTransactionTool(context),\n scheduleDeleteTool(context),\n approveTokenAllowanceTool(context),\n transferHbarWithAllowanceTool(context),\n deleteTokenAllowanceTool(context),\n ];\n },\n};\n\nexport const coreAccountPluginToolNames = {\n TRANSFER_HBAR_TOOL,\n APPROVE_HBAR_ALLOWANCE_TOOL,\n DELETE_HBAR_ALLOWANCE_TOOL,\n CREATE_ACCOUNT_TOOL,\n DELETE_ACCOUNT_TOOL,\n UPDATE_ACCOUNT_TOOL,\n SIGN_SCHEDULE_TRANSACTION_TOOL,\n SCHEDULE_DELETE_TOOL,\n APPROVE_TOKEN_ALLOWANCE_TOOL,\n DELETE_TOKEN_ALLOWANCE_TOOL,\n TRANSFER_HBAR_WITH_ALLOWANCE_TOOL,\n} as const;\n\nexport default { coreAccountPlugin, coreAccountPluginToolNames };\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { createTopicParameters } from '@/shared/parameter-schemas/consensus.zod';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { IHederaMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-service.interface';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst createTopicPrompt = (_context: Context = {}) => {\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\nThis tool will create a new topic on the Hedera network.\n\nParameters:\n- topicMemo (str, optional): A memo stored permanently on the topic itself (not the transaction)\n- transactionMemo (str, optional): A memo attached to the transaction (separate from topicMemo). Use this when the user says \"transaction memo\" or \"set the memo on the transaction\"\n- isSubmitKey (bool, optional): Whether to set a submit key for the topic. Set to true if user wants to set a submit key, otherwise false\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `Topic created successfully with topic id ${response.topicId?.toString()} and transaction id ${response.transactionId.toString()}`;\n};\n\nconst createTopic = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof createTopicParameters>>,\n) => {\n try {\n const mirrornodeService: IHederaMirrornodeService = getMirrornodeService(\n context.mirrornodeService!,\n client.ledgerId!,\n );\n const normalisedParams = await HederaParameterNormaliser.normaliseCreateTopicParams(\n params,\n context,\n client,\n mirrornodeService,\n );\n const tx = HederaBuilder.createTopic(normalisedParams);\n const result = await handleTransaction(tx, client, context, postProcess);\n return result;\n } catch (error) {\n const desc = 'Failed to create topic';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[create_topic_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const CREATE_TOPIC_TOOL = 'create_topic_tool';\n\nconst tool = (context: Context): Tool => ({\n method: CREATE_TOPIC_TOOL,\n name: 'Create Topic',\n description: createTopicPrompt(context),\n parameters: createTopicParameters(context),\n execute: createTopic,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { IHederaMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-service.interface';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { deleteTopicParameters } from '@/shared/parameter-schemas/consensus.zod';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst deleteTopicPrompt = (_context: Context = {}) => {\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\nThis tool will delete a given Hedera network topic.\n\nParameters:\n- topicId (str, required): id of topic to delete\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `Topic with id ${response.topicId?.toString()} deleted successfully. Transaction id ${response.transactionId.toString()}`;\n};\n\nconst deleteTopic = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof deleteTopicParameters>>,\n) => {\n try {\n const mirrornodeService: IHederaMirrornodeService = getMirrornodeService(\n context.mirrornodeService!,\n client.ledgerId!,\n );\n const normalisedParams = HederaParameterNormaliser.normaliseDeleteTopic(\n params,\n context,\n client,\n mirrornodeService,\n );\n const tx = HederaBuilder.deleteTopic(normalisedParams);\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to delete the topic';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[delete_topic_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const DELETE_TOPIC_TOOL = 'delete_topic_tool';\n\nconst tool = (context: Context): Tool => ({\n method: DELETE_TOPIC_TOOL,\n name: 'Delete Topic',\n description: deleteTopicPrompt(context),\n parameters: deleteTopicParameters(context),\n execute: deleteTopic,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { submitTopicMessageParameters } from '@/shared/parameter-schemas/consensus.zod';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst submitTopicMessagePrompt = (context: Context = {}) => {\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\nThis tool will submit a message to a topic on the Hedera network.\n\nParameters:\n- topicId (str, required): The ID of the topic to submit the message to\n- message (str, required): The message to submit to the topic\n- transactionMemo (str, optional): An optional memo to include on the transaction\n${PromptGenerator.getScheduledTransactionParamsDescription(context)}\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `Message submitted successfully with transaction id ${response.transactionId.toString()}`;\n};\n\nconst submitTopicMessage = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof submitTopicMessageParameters>>,\n) => {\n try {\n const normalisedParams = await HederaParameterNormaliser.normaliseSubmitTopicMessage(\n params,\n context,\n client,\n );\n const tx = HederaBuilder.submitTopicMessage(normalisedParams);\n\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to submit message to topic';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[submit_topic_message_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const SUBMIT_TOPIC_MESSAGE_TOOL = 'submit_topic_message_tool';\n\nconst tool = (context: Context): Tool => ({\n method: SUBMIT_TOPIC_MESSAGE_TOOL,\n name: 'Submit Topic Message',\n description: submitTopicMessagePrompt(context),\n parameters: submitTopicMessageParameters(context),\n execute: submitTopicMessage,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, PublicKey, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { IHederaMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-service.interface';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { AccountResolver } from '@/shared';\nimport {\n updateTopicParameters,\n updateTopicParametersNormalised,\n} from '@/shared/parameter-schemas/consensus.zod';\nimport { TopicInfo } from '@/shared/hedera-utils/mirrornode/types';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst checkValidityOfUpdates = async (\n params: z.infer<ReturnType<typeof updateTopicParametersNormalised>>,\n mirrornode: IHederaMirrornodeService,\n userPublicKey: PublicKey,\n) => {\n const topicDetails: TopicInfo = await mirrornode.getTopicInfo(params.topicId.toString());\n if (!topicDetails) {\n throw new Error('Topic not found');\n }\n\n if (topicDetails.admin_key === undefined) {\n throw new Error('Topic does not have an admin key. It cannot be updated.');\n }\n\n if (topicDetails.admin_key!.key !== userPublicKey.toStringRaw()) {\n console.error(\n `topicDetails.admin_key.key: ${topicDetails.admin_key?.key} vs userPublicKey: ${userPublicKey.toStringRaw()}`,\n );\n throw new Error(\n 'You do not have permission to update this topic. The adminKey does not match your public key.',\n );\n }\n\n // If a user attempts to set a key but the topic was created without that key, disallow\n const keyChecks: Partial<Record<keyof typeof params, keyof TopicInfo>> = {\n adminKey: 'admin_key',\n submitKey: 'submit_key',\n };\n\n for (const [paramKey, topicField] of Object.entries(keyChecks) as [\n keyof typeof params,\n keyof TopicInfo,\n ][]) {\n const userValue = params[paramKey];\n const topicKey = topicDetails[topicField as keyof TopicInfo];\n\n if (userValue instanceof PublicKey && !topicKey) {\n throw new Error(`Cannot update ${paramKey}: topic was created without a ${paramKey}`);\n }\n }\n};\n\nconst updateTopicPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const topicDesc = PromptGenerator.getAnyAddressParameterDescription('topicId', context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\nThis tool will update an existing Hedera Consensus Topic. Only the fields provided will be updated.\nKey fields (adminKey, submitKey) must contain **Hedera-compatible public keys (as strings) or boolean (true/false)**. You can provide these in one of three ways:\n1. **Boolean true** – Set this field to use user/operator key. Injecting of the key will be handled automatically.\n2. **Not provided** – The field will not be updated.\n3. **String** – Provide a Hedera-compatible public key string to set a field explicitly.\n\nParameters:\n- ${topicDesc}\n- topicMemo (string, optional): New memo for the topic.\n- adminKey (boolean|string, optional): New admin key. Pass true to use your operator key, or provide a public key string.\n- submitKey (boolean|string, optional): New submit key. Pass true to use your operator key, or provide a public key string.\n- autoRenewAccountId (string, optional): Account to automatically pay for renewal.\n- autoRenewPeriod (number, optional): Auto renew period in seconds.\n- expirationTime (string|Date, optional): New expiration time for the topic (ISO string or Date).\nExamples:\n- If the user asks for \"my key\" → set the field to \\`true\\`.\n- If the user does not mention the key → do not set the field.\n- If the user provides a key → set the field to the provided public key string.\n\nIf the user provides multiple fields in a single request, \ncombine them into **one tool call** with all parameters together.\n${usageInstructions}\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) => {\n return `Topic successfully updated. Transaction ID: ${response.transactionId}`;\n};\n\nconst updateTopic = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof updateTopicParameters>>,\n) => {\n try {\n const normalisedParams = await HederaParameterNormaliser.normaliseUpdateTopic(\n params,\n context,\n client,\n );\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const userPublicKey = await AccountResolver.getDefaultPublicKey(context, client);\n\n await checkValidityOfUpdates(normalisedParams, mirrornodeService, userPublicKey);\n\n const tx = HederaBuilder.updateTopic(normalisedParams);\n\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to update topic';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[update_topic_tool]', message);\n return {\n raw: { status: Status.InvalidTransaction, error: message },\n humanMessage: message,\n };\n }\n};\n\nexport const UPDATE_TOPIC_TOOL = 'update_topic_tool';\n\nconst tool = (context: Context): Tool => ({\n method: UPDATE_TOPIC_TOOL,\n name: 'Update Topic',\n description: updateTopicPrompt(context),\n parameters: updateTopicParameters(context),\n execute: updateTopic,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { Context } from '@/shared';\nimport { Plugin } from '@/shared/plugin';\nimport createTopicTool, {\n CREATE_TOPIC_TOOL,\n} from '@/plugins/core-consensus-plugin/tools/consensus/create-topic';\nimport deleteTopicTool, {\n DELETE_TOPIC_TOOL,\n} from '@/plugins/core-consensus-plugin/tools/consensus/delete-topic';\nimport submitTopicMessageTool, {\n SUBMIT_TOPIC_MESSAGE_TOOL,\n} from '@/plugins/core-consensus-plugin/tools/consensus/submit-topic-message';\nimport updateTopicTool, {\n UPDATE_TOPIC_TOOL,\n} from '@/plugins/core-consensus-plugin/tools/consensus/update-topic';\n\nexport const coreConsensusPlugin: Plugin = {\n name: 'core-consensus-plugin',\n version: '1.0.0',\n description: 'A plugin for the Hedera Consensus Service',\n tools: (context: Context) => {\n return [\n createTopicTool(context),\n submitTopicMessageTool(context),\n deleteTopicTool(context),\n updateTopicTool(context),\n ];\n },\n};\n\nexport const coreConsensusPluginToolNames = {\n CREATE_TOPIC_TOOL,\n SUBMIT_TOPIC_MESSAGE_TOOL,\n DELETE_TOPIC_TOOL,\n UPDATE_TOPIC_TOOL,\n} as const;\n\nexport default { coreConsensusPlugin, coreConsensusPluginToolNames };\n","/**\n * Converts a tinybar amount to a hbar amount.\n * @param tinyBars - The tinybar amount.\n * @returns The hbar amount.\n */\nexport function toHbar(tinyBars: BigNumber): BigNumber {\n return tinyBars.div(100000000);\n}\n","import { z } from 'zod';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { Context } from '@/shared/configuration';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { Tool } from '@/shared/tools';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { AccountResponse } from '@/shared/hedera-utils/mirrornode/types';\nimport { accountQueryParameters } from '@/shared/parameter-schemas/account.zod';\nimport { untypedQueryOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nexport const getAccountQueryPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will return the account information for a given Hedera account.\n\nParameters:\n- accountId (str, required): The account ID to query\n${usageInstructions}\n`;\n};\n\nconst postProcess = (account: AccountResponse) => {\n return `Details for ${account.accountId}\nBalance: ${account.balance.balance.toString()}\nPublic Key: ${account.accountPublicKey},\nEVM address: ${account.evmAddress},\n`;\n};\n\nexport const getAccountQuery = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof accountQueryParameters>>,\n) => {\n try {\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const account = await mirrornodeService.getAccount(params.accountId);\n return {\n raw: { accountId: params.accountId, account: account },\n humanMessage: postProcess(account),\n };\n } catch (error) {\n const desc = 'Failed to get account query';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[get_account_query_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const GET_ACCOUNT_QUERY_TOOL = 'get_account_query_tool';\n\nconst tool = (context: Context): Tool => ({\n method: GET_ACCOUNT_QUERY_TOOL,\n name: 'Get Account Query',\n description: getAccountQueryPrompt(context),\n parameters: accountQueryParameters(context),\n execute: getAccountQuery,\n outputParser: untypedQueryOutputParser,\n});\n\nexport default tool;\n","import { Context } from '@/shared/configuration';\nimport { z } from 'zod';\n\nexport const exchangeRateQueryParameters = (_context: Context) =>\n z.object({\n timestamp: z\n .string()\n .describe('Historical timestamp to query (seconds or nanos since epoch)')\n .optional(),\n });\n","import { z } from 'zod';\nimport { Client } from '@hashgraph/sdk';\nimport { Context } from '@/shared/configuration';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { Tool } from '@/shared/tools';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { ExchangeRateResponse } from '@/shared/hedera-utils/mirrornode/types';\nimport { exchangeRateQueryParameters } from '@/shared/parameter-schemas/core-misc.zod';\nimport { untypedQueryOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nexport const getExchangeRatePrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool returns the Hedera network HBAR exchange rate from the Mirror Node.\n\nParameters:\n- timestamp (str, optional): Historical timestamp to query. Pass seconds or nanos since epoch (e.g., 1726000000.123456789). If omitted, returns the latest rate.\n${usageInstructions}\n`;\n};\n\nconst calculateUsdPerHBAR = (cent_equivalent: number, hbar_equivalent: number) => {\n return cent_equivalent / 100 / hbar_equivalent;\n};\n\nconst postProcess = (rates: ExchangeRateResponse) => {\n const { current_rate, next_rate, timestamp } = rates;\n\n const usdPerHBAR = calculateUsdPerHBAR(\n current_rate.cent_equivalent,\n current_rate.hbar_equivalent,\n );\n const nextUsdPerHBAR = calculateUsdPerHBAR(next_rate.cent_equivalent, next_rate.hbar_equivalent);\n\n return `\n Details for timestamp: ${timestamp}\n \n Current exchange rate: ${usdPerHBAR}\n Expires at ${new Date(current_rate.expiration_time * 1000).toISOString()})\n \n Next exchange rate: ${nextUsdPerHBAR}\n Expires at ${new Date(next_rate.expiration_time * 1000).toISOString()})`;\n};\n\nexport const getExchangeRateQuery = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof exchangeRateQueryParameters>>,\n) => {\n try {\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const rates: ExchangeRateResponse = await mirrornodeService.getExchangeRate(params.timestamp);\n return {\n raw: rates,\n humanMessage: postProcess(rates),\n };\n } catch (error) {\n console.error('[GetExchangeRate] Error getting exchange rate', error);\n const message = error instanceof Error ? error.message : 'Failed to get exchange rate';\n\n return {\n raw: { error: message },\n humanMessage: message,\n };\n }\n};\n\nexport const GET_EXCHANGE_RATE_TOOL = 'get_exchange_rate_tool';\n\nconst tool = (context: Context): Tool => ({\n method: GET_EXCHANGE_RATE_TOOL,\n name: 'Get Exchange Rate',\n description: getExchangeRatePrompt(context),\n parameters: exchangeRateQueryParameters(context),\n execute: getExchangeRateQuery,\n outputParser: untypedQueryOutputParser,\n});\n\nexport default tool;\n","import { Plugin } from '@/shared/plugin';\nimport { Context } from '@/shared/configuration';\nimport getExchangeRateQuery, {\n GET_EXCHANGE_RATE_TOOL,\n} from '@/plugins/core-misc-query-plugin/tools/queries/get-exchange-rate-query';\n\nexport const coreMiscQueriesPlugin: Plugin = {\n name: 'core-misc-queries-plugin',\n version: '1.0.0',\n description: 'A plugin for Hedera Misc Queries',\n tools: (context: Context) => {\n return [getExchangeRateQuery(context)];\n },\n};\n\nexport const coreMiscQueriesPluginsToolNames = {\n GET_EXCHANGE_RATE_TOOL,\n} as const;\n\nexport default { coreMiscQueriesPluginsToolNames };\n","import { z } from 'zod';\nimport { AgentMode, type Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status, TransactionRecordQuery } from '@hashgraph/sdk';\nimport {\n ExecuteStrategyResult,\n handleTransaction,\n RawTransactionResponse,\n} from '@/shared/strategies/tx-mode-strategy';\nimport { createERC20Parameters } from '@/shared/parameter-schemas/evm.zod';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { getERC20FactoryAddress, ERC20_FACTORY_ABI } from '@/shared/constants/contracts';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst createERC20Prompt = (context: Context = {}) => `\n${PromptGenerator.getContextSnippet(context)}\n\nThis tool creates an ERC20 token on Hedera by calling the BaseERC20Factory contract. ERC20 is an EVM compatible fungible token.\n\nParameters:\n- tokenName (str, required): The name of the token\n- tokenSymbol (str, required): The symbol of the token\n- decimals (int, optional): The number of decimals the token supports. Defaults to 18\n- initialSupply (int, optional): The initial supply of the token. Defaults to 0\n- ${PromptGenerator.getScheduledTransactionParamsDescription(context)}\n\n${PromptGenerator.getParameterUsageInstructions()}\n`;\n\nconst getERC20Address = async (client: Client, tx: RawTransactionResponse) => {\n const record = await new TransactionRecordQuery()\n .setTransactionId(tx.transactionId)\n .execute(client);\n return '0x' + record.contractFunctionResult?.getAddress(0);\n};\n\nconst postProcess = (erc20Address?: string, response?: RawTransactionResponse) =>\n response?.scheduleId\n ? `Scheduled creation of ERC20 successfully.\nTransaction ID: ${response.transactionId}\nSchedule ID: ${response.scheduleId.toString()}`\n : `ERC20 token created successfully at address ${erc20Address ?? 'unknown'}`;\n\nconst createERC20 = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof createERC20Parameters>>,\n) => {\n try {\n const factoryAddress = getERC20FactoryAddress(client.ledgerId!);\n const txParams = await HederaParameterNormaliser.normaliseCreateERC20Params(\n params,\n factoryAddress,\n ERC20_FACTORY_ABI,\n 'deployToken',\n context,\n client,\n );\n\n const tx = HederaBuilder.executeTransaction(txParams);\n const result = await handleTransaction(tx, client, context);\n\n if (context.mode === AgentMode.RETURN_BYTES) return result;\n\n const raw = (result as ExecuteStrategyResult).raw;\n const erc20Address = await getERC20Address(client, raw);\n const humanMessage = postProcess(erc20Address, raw);\n\n return { ...result, erc20Address, humanMessage };\n } catch (error) {\n const message =\n 'Failed to create ERC20 token' + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[create_erc20_tool]', message);\n return {\n raw: { status: Status.InvalidTransaction, error: message },\n humanMessage: message,\n };\n }\n};\n\nexport const CREATE_ERC20_TOOL = 'create_erc20_tool';\n\nconst tool = (context: Context): Tool => ({\n method: CREATE_ERC20_TOOL,\n name: 'Create ERC20 Token',\n description: createERC20Prompt(context),\n parameters: createERC20Parameters(context),\n execute: createERC20,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport { transferERC20Parameters } from '@/shared/parameter-schemas/evm.zod';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport {\n ERC20_TRANSFER_FUNCTION_ABI,\n ERC20_TRANSFER_FUNCTION_NAME,\n} from '@/shared/constants/contracts';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst transferERC20Prompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will transfer a given amount of an existing ERC20 token on Hedera. ERC20 is an EVM compatible fungible token.\n\nParameters:\n- contractId (str, required): The id of the ERC20 contract. This can be the EVM address or the Hedera account id.\n- recipientAddress (str, required): The EVM or Hedera address to which the tokens will be transferred. This can be the EVM address or the Hedera account id.\n- amount (number, required): The amount to be transferred\n- ${PromptGenerator.getScheduledTransactionParamsDescription(context)}\n\n${usageInstructions}\n\nExample: \"Transfer 1 ERC20 token 0.0.6473135 to 0xd94dc7f82f103757f715514e4a37186be6e4580b\" means transferring the amount of 1 of the ERC20 token with contract id 0.0.6473135 to the 0xd94dc7f82f103757f715514e4a37186be6e4580b EVM address.\nExample: \"Transfer 1 ERC20 token 0xd94dc7f82f103757f715514e4a37186be6e4580b to 0.0.6473135\" means transferring the amount of 1 of the ERC20 token with contract id 0xd94dc7f82f103757f715514e4a37186be6e4580b to the 0.0.6473135 Hedera account id.\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) =>\n response?.scheduleId\n ? `Scheduled transfer of ERC20 successfully.\nTransaction ID: ${response.transactionId}\nSchedule ID: ${response.scheduleId.toString()}`\n : `ERC20 token transferred successfully.`;\n\nconst transferERC20 = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof transferERC20Parameters>>,\n) => {\n const mirrorNode = getMirrornodeService(context.mirrornodeService, client.ledgerId!);\n try {\n const normalisedParams = await HederaParameterNormaliser.normaliseTransferERC20Params(\n params,\n ERC20_TRANSFER_FUNCTION_ABI,\n ERC20_TRANSFER_FUNCTION_NAME,\n context,\n mirrorNode,\n client,\n );\n\n const tx = HederaBuilder.executeTransaction(normalisedParams);\n\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to transfer ERC20';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[transfer_erc20_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const TRANSFER_ERC20_TOOL = 'transfer_erc20_tool';\n\nconst tool = (context: Context): Tool => ({\n method: TRANSFER_ERC20_TOOL,\n name: 'Transfer ERC20',\n description: transferERC20Prompt(context),\n parameters: transferERC20Parameters(context),\n execute: transferERC20,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport {\n ERC721_TRANSFER_FUNCTION_ABI,\n ERC721_TRANSFER_FUNCTION_NAME,\n} from '@/shared/constants/contracts';\nimport { transferERC721Parameters } from '@/shared/parameter-schemas/evm.zod';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst transferERC721Prompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const fromAddressDesc = PromptGenerator.getAnyAddressParameterDescription('fromAddress', context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will transfer an existing ERC721 token on Hedera. ERC721 is an EVM compatible non fungible token (NFT).\n\nParameters:\n- contractId (str, required): The id of the ERC721 contract\n- ${fromAddressDesc}\n- toAddress (str, required): The address to which the token will be transferred. This can be the EVM address or the Hedera account id.\n- tokenId (number, required): The ID of the transferred token\n${PromptGenerator.getScheduledTransactionParamsDescription(context)}\n\n\n${PromptGenerator.getParameterUsageInstructions()}\n\n${usageInstructions}\n\nExample:\n\"Transfer ERC721 token 0.0.6486793 with id 0 from 0xd94...580b to 0.0.6486793\" transfers token ID 0 from the given EVM address to the given Hedera account.\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) =>\n response?.scheduleId\n ? `Scheduled transfer of ERC721 successfully.\nTransaction ID: ${response.transactionId}\nSchedule ID: ${response.scheduleId.toString()}`\n : `ERC721 token transferred successfully.\n Transaction ID: ${response.transactionId}`;\n\nconst transferERC721 = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof transferERC721Parameters>>,\n) => {\n const mirrorNode = getMirrornodeService(context.mirrornodeService, client.ledgerId!);\n\n try {\n const normalisedParams = await HederaParameterNormaliser.normaliseTransferERC721Params(\n params,\n ERC721_TRANSFER_FUNCTION_ABI,\n ERC721_TRANSFER_FUNCTION_NAME,\n context,\n mirrorNode,\n client,\n );\n\n const tx = HederaBuilder.executeTransaction(normalisedParams);\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const message =\n 'Failed to transfer ERC721' + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[transfer_erc721_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const TRANSFER_ERC721_TOOL = 'transfer_erc721_tool';\n\nconst tool = (context: Context): Tool => ({\n method: TRANSFER_ERC721_TOOL,\n name: 'Transfer ERC721',\n description: transferERC721Prompt(context),\n parameters: transferERC721Parameters(context),\n execute: transferERC721,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { handleTransaction, RawTransactionResponse } from '@/shared/strategies/tx-mode-strategy';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { ERC721_MINT_FUNCTION_ABI, ERC721_MINT_FUNCTION_NAME } from '@/shared/constants/contracts';\nimport { mintERC721Parameters } from '@/shared/parameter-schemas/evm.zod';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst mintERC721Prompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n const toAddressDesc = PromptGenerator.getAnyAddressParameterDescription(\n 'toAddress',\n context,\n false,\n );\n\n return `\n${contextSnippet}\n\nThis tool will mint (create a new token from existing contract) a new ERC721 token on Hedera. ERC721 is an EVM compatible non fungible token (NFT).\n\nParameters:\n- contractId (str, required): The id of the ERC721 contract\n- ${toAddressDesc}\n${PromptGenerator.getScheduledTransactionParamsDescription(context)}\n\n${usageInstructions}\n\nExample: \"Mint ERC721 token 0.0.6486793 to 0xd94dc7f82f103757f715514e4a37186be6e4580b\" means minting the ERC721 token with contract id 0.0.6486793 to the 0xd94dc7f82f103757f715514e4a37186be6e4580b EVM address.\nExample: \"Mint ERC721 token 0.0.6486793 to 0.0.6486793\" means minting the ERC721 token with contract id 0.0.6486793 to the 0.0.6486793 Hedera account id.\n\nNOTE: the 'toAddress' parameter is optional. If not provided, the minting will be performed to the default account as per the context.\n`;\n};\n\nconst postProcess = (response: RawTransactionResponse) =>\n response?.scheduleId\n ? `Scheduled minting of ERC721 successfully.\nTransaction ID: ${response.transactionId}\nSchedule ID: ${response.scheduleId.toString()}`\n : `ERC721 token minted successfully.\n Transaction ID: ${response.transactionId}`;\n\nconst mintERC721 = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof mintERC721Parameters>>,\n) => {\n try {\n const mirrorNode = getMirrornodeService(context.mirrornodeService, client.ledgerId!);\n\n const normalisedParams = await HederaParameterNormaliser.normaliseMintERC721Params(\n params,\n ERC721_MINT_FUNCTION_ABI,\n ERC721_MINT_FUNCTION_NAME,\n context,\n mirrorNode,\n client,\n );\n const tx = HederaBuilder.executeTransaction(normalisedParams);\n\n return await handleTransaction(tx, client, context, postProcess);\n } catch (error) {\n const desc = 'Failed to mint ERC721';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[mint_erc721_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const MINT_ERC721_TOOL = 'mint_erc721_tool';\n\nconst tool = (context: Context): Tool => ({\n method: MINT_ERC721_TOOL,\n name: 'Mint ERC721',\n description: mintERC721Prompt(context),\n parameters: mintERC721Parameters(context),\n execute: mintERC721,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport { AgentMode, type Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client, Status, TransactionRecordQuery } from '@hashgraph/sdk';\nimport {\n ExecuteStrategyResult,\n handleTransaction,\n RawTransactionResponse,\n} from '@/shared/strategies/tx-mode-strategy';\nimport { createERC721Parameters } from '@/shared/parameter-schemas/evm.zod';\nimport HederaBuilder from '@/shared/hedera-utils/hedera-builder';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { getERC721FactoryAddress, ERC721_FACTORY_ABI } from '@/shared/constants/contracts';\nimport { transactionToolOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nconst createERC721Prompt = (context: Context = {}) => `\n${PromptGenerator.getContextSnippet(context)}\n\nThis tool creates an ERC721 token on Hedera by calling the BaseERC721Factory contract. ERC721 is an EVM compatible non fungible token (NFT).\n\nParameters:\n- tokenName (str, required): The name of the token\n- tokenSymbol (str, required): The symbol of the token\n- baseURI (str, required): The base URI for token metadata\n${PromptGenerator.getScheduledTransactionParamsDescription(context)}\n\n${PromptGenerator.getParameterUsageInstructions()}\nThe contractId returned by the tool is the address of the ERC721 Factory contract, the address of the ERC721 token is the erc721Address returned by the tool.\n`;\n\nconst getERC721Address = async (client: Client, tx: RawTransactionResponse) => {\n const record = await new TransactionRecordQuery()\n .setTransactionId(tx.transactionId)\n .execute(client);\n return '0x' + record.contractFunctionResult?.getAddress(0);\n};\n\nconst postProcess = (erc721Address?: string, response?: RawTransactionResponse) =>\n response?.scheduleId\n ? `Scheduled creation of ERC721 successfully.\nTransaction ID: ${response.transactionId}\nSchedule ID: ${response.scheduleId.toString()}`\n : `ERC721 token created successfully at address ${erc721Address ?? 'unknown'}`;\n\nconst createERC721 = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof createERC721Parameters>>,\n) => {\n try {\n const factoryAddress = getERC721FactoryAddress(client.ledgerId!);\n const txParams = await HederaParameterNormaliser.normaliseCreateERC721Params(\n params,\n factoryAddress,\n ERC721_FACTORY_ABI,\n 'deployToken',\n context,\n client,\n );\n\n const tx = HederaBuilder.executeTransaction(txParams);\n const result = await handleTransaction(tx, client, context);\n\n if (context.mode === AgentMode.RETURN_BYTES) return result;\n\n const raw = (result as ExecuteStrategyResult).raw;\n const erc721Address = await getERC721Address(client, raw);\n const humanMessage = postProcess(erc721Address, raw);\n\n return { ...result, erc721Address, humanMessage };\n } catch (error) {\n const message =\n 'Failed to create ERC721 token' + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[create_erc721_tool]', message);\n return {\n raw: { status: Status.InvalidTransaction, error: message },\n humanMessage: message,\n };\n }\n};\n\nexport const CREATE_ERC721_TOOL = 'create_erc721_tool';\n\nconst tool = (context: Context): Tool => ({\n method: CREATE_ERC721_TOOL,\n name: 'Create ERC721 Token',\n description: createERC721Prompt(context),\n parameters: createERC721Parameters(context),\n execute: createERC721,\n outputParser: transactionToolOutputParser,\n});\n\nexport default tool;\n","import { Plugin } from '@/shared/plugin';\nimport { Context } from '@/shared/configuration';\nimport createERC20Tool, { CREATE_ERC20_TOOL } from './tools/erc20/create-erc20';\nimport transferERC20Tool, { TRANSFER_ERC20_TOOL } from './tools/erc20/transfer-erc20';\nimport transferERC721Tool, {\n TRANSFER_ERC721_TOOL,\n} from '@/plugins/core-evm-plugin/tools/erc721/transfer-erc721';\nimport mintERC721Tool, {\n MINT_ERC721_TOOL,\n} from '@/plugins/core-evm-plugin/tools/erc721/mint-erc721';\nimport createERC721Tool, {\n CREATE_ERC721_TOOL,\n} from '@/plugins/core-evm-plugin/tools/erc721/create-erc721';\n\nexport const coreEVMPlugin: Plugin = {\n name: 'core-evm-plugin',\n version: '1.0.0',\n description: 'A plugin for the Hedera EVM',\n tools: (context: Context) => {\n return [\n createERC20Tool(context),\n transferERC20Tool(context),\n transferERC721Tool(context),\n mintERC721Tool(context),\n createERC721Tool(context),\n ];\n },\n};\n\n// Export tool names as an object for destructuring\nexport const coreEVMPluginToolNames = {\n TRANSFER_ERC721_TOOL,\n MINT_ERC721_TOOL,\n CREATE_ERC20_TOOL,\n TRANSFER_ERC20_TOOL,\n CREATE_ERC721_TOOL,\n} as const;\n\nexport default { coreEVMPlugin, coreEVMPluginToolNames };\n","import { z } from 'zod';\nimport type { Context } from '@/shared/configuration';\nimport type { Tool } from '@/shared/tools';\nimport { Client } from '@hashgraph/sdk';\nimport { accountBalanceQueryParameters } from '@/shared/parameter-schemas/account.zod';\nimport BigNumber from 'bignumber.js';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { toHbar } from '@/shared/hedera-utils/hbar-conversion-utils';\nimport { untypedQueryOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nexport const getHbarBalanceQueryPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const accountDesc = PromptGenerator.getAccountParameterDescription('accountId', context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will return the HBAR balance for a given Hedera account.\n\nParameters:\n- ${accountDesc}\n${usageInstructions}\n`;\n};\n\nconst postProcess = (hbarBalance: string, accountId: string) => {\n return `Account ${accountId} has a balance of ${hbarBalance} HBAR`;\n};\n\nexport const getHbarBalanceQuery = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof accountBalanceQueryParameters>>,\n) => {\n try {\n const normalisedParams = HederaParameterNormaliser.normaliseHbarBalanceParams(\n params,\n context,\n client,\n );\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const balance: BigNumber = await mirrornodeService.getAccountHbarBalance(\n normalisedParams.accountId,\n );\n return {\n raw: { accountId: normalisedParams.accountId, hbarBalance: toHbar(balance).toString() },\n humanMessage: postProcess(toHbar(balance).toString() as string, normalisedParams.accountId),\n };\n } catch (error) {\n const desc = 'Failed to get HBAR balance';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[get_hbar_balance_query_tool]', message);\n return { raw: { error: message }, humanMessage: message };\n }\n};\n\nexport const GET_HBAR_BALANCE_QUERY_TOOL = 'get_hbar_balance_query_tool';\n\nconst tool = (context: Context): Tool => ({\n method: GET_HBAR_BALANCE_QUERY_TOOL,\n name: 'Get HBAR Balance',\n description: getHbarBalanceQueryPrompt(context),\n parameters: accountBalanceQueryParameters(context),\n execute: getHbarBalanceQuery,\n outputParser: untypedQueryOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport BigNumber from 'bignumber.js';\nimport { Client, Status } from '@hashgraph/sdk';\nimport { Context } from '@/shared/configuration';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { Tool } from '@/shared/tools';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { accountQueryParameters } from '@/shared/parameter-schemas/account.zod';\nimport { untypedQueryOutputParser } from '@/shared/utils/default-tool-output-parsing';\nimport { toHbar } from '@/shared/hedera-utils/hbar-conversion-utils';\n\nexport const getAccountQueryPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will return the account information for a given Hedera account. The returned account will contain the balance in HBAR, public key, and EVM address.\n\nParameters:\n- accountId (str, required): The account ID to query\n${usageInstructions}\n`;\n};\n\nconst postProcess = (account: any) => {\n return `Details for ${account.accountId}\nBalance: ${account.balance.balance} HBAR\nPublic Key: ${account.accountPublicKey},\nEVM address: ${account.evmAddress},\n`;\n};\n\nexport const getAccountQuery = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof accountQueryParameters>>,\n) => {\n try {\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const account = await mirrornodeService.getAccount(params.accountId);\n\n const hbarBalance = toHbar(new BigNumber(account.balance.balance)).toString();\n const accountWithHbar = {\n ...account,\n balance: {\n ...account.balance,\n balance: hbarBalance,\n },\n hbarBalance,\n };\n\n return {\n raw: { accountId: params.accountId, account: accountWithHbar },\n humanMessage: postProcess(accountWithHbar),\n };\n } catch (error) {\n const desc = 'Failed to get account query';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[get_account_query_tool]', message);\n return { raw: { status: Status.InvalidTransaction, error: message }, humanMessage: message };\n }\n};\n\nexport const GET_ACCOUNT_QUERY_TOOL = 'get_account_query_tool';\n\nconst tool = (context: Context): Tool => ({\n method: GET_ACCOUNT_QUERY_TOOL,\n name: 'Get Account Query',\n description: getAccountQueryPrompt(context),\n parameters: accountQueryParameters(context),\n execute: getAccountQuery,\n outputParser: untypedQueryOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport { Context } from '@/shared/configuration';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { accountTokenBalancesQueryParameters } from '@/shared/parameter-schemas/account.zod';\nimport { Client } from '@hashgraph/sdk';\nimport { Tool } from '@/shared/tools';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { TokenBalancesResponse } from '@/shared/hedera-utils/mirrornode/types';\nimport { untypedQueryOutputParser } from '@/shared/utils/default-tool-output-parsing';\nimport { toDisplayUnit } from '@/shared/hedera-utils/decimals-utils';\n\nexport const getAccountTokenBalancesQueryPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const accountDesc = PromptGenerator.getAccountParameterDescription('accountId', context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will return the token balances for a given Hedera account. The human message will contain parsed balances in display units whereas the extra field will contain the raw token balances response from the mirror node with .\n\nParameters:\n- ${accountDesc}\n- tokenId (str, optional): The token ID to query for. If not provided, all token balances will be returned\n${usageInstructions}\n`;\n};\n\nconst postProcess = (tokenBalances: TokenBalancesResponse, accountId: string) => {\n if (tokenBalances.tokens.length === 0) {\n return `No token balances found for account ${accountId}`;\n }\n const balancesText = tokenBalances.tokens\n .map(\n token =>\n ` Token: ${token.token_id}, Symbol: ${token.symbol} Balance: ${toDisplayUnit(token.balance, token.decimals)}, Decimals: ${token.decimals}`,\n )\n .join('\\n');\n\n return `Details for ${accountId}\n--- Token Balances ---\n${balancesText}\n\nThe token balances are returned in display units!\n`;\n};\n\nexport const getAccountTokenBalancesQuery = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof accountTokenBalancesQueryParameters>>,\n) => {\n try {\n const normalisedParams = HederaParameterNormaliser.normaliseAccountTokenBalancesParams(\n params,\n context,\n client,\n );\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const tokenBalances = await mirrornodeService.getAccountTokenBalances(\n normalisedParams.accountId,\n normalisedParams.tokenId,\n );\n return {\n raw: { accountId: normalisedParams.accountId, tokenBalances: tokenBalances },\n humanMessage: postProcess(tokenBalances, normalisedParams.accountId),\n };\n } catch (error) {\n const desc = 'Failed to get account token balances';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[get_account_token_balances_query_tool]', message);\n return { raw: { error: message }, humanMessage: message };\n }\n};\n\nexport const GET_ACCOUNT_TOKEN_BALANCES_QUERY_TOOL = 'get_account_token_balances_query_tool';\n\nconst tool = (context: Context): Tool => ({\n method: GET_ACCOUNT_TOKEN_BALANCES_QUERY_TOOL,\n name: 'Get Account Token Balances',\n description: getAccountTokenBalancesQueryPrompt(context),\n parameters: accountTokenBalancesQueryParameters(context),\n execute: getAccountTokenBalancesQuery,\n outputParser: untypedQueryOutputParser,\n});\n\nexport default tool;\n","import { Plugin } from '@/shared/plugin';\nimport { Context } from '@/shared/configuration';\nimport getHbarBalanceQuery, {\n GET_HBAR_BALANCE_QUERY_TOOL,\n} from '@/plugins/core-account-query-plugin/tools/queries/get-hbar-balance-query';\nimport getAccountQuery, {\n GET_ACCOUNT_QUERY_TOOL,\n} from '@/plugins/core-account-query-plugin/tools/queries/get-account-query';\nimport getAccountTokenBalancesQuery, {\n GET_ACCOUNT_TOKEN_BALANCES_QUERY_TOOL,\n} from '@/plugins/core-account-query-plugin/tools/queries/get-account-token-balances-query';\n\nexport const coreAccountQueryPlugin: Plugin = {\n name: 'core-account-query-plugin',\n version: '1.0.0',\n description: 'A plugin for Hedera Account Service queries',\n tools: (context: Context) => {\n return [\n getHbarBalanceQuery(context),\n getAccountQuery(context),\n getAccountTokenBalancesQuery(context),\n ];\n },\n};\n\nexport const coreAccountQueryPluginToolNames = {\n GET_HBAR_BALANCE_QUERY_TOOL,\n GET_ACCOUNT_QUERY_TOOL,\n GET_ACCOUNT_TOKEN_BALANCES_QUERY_TOOL,\n} as const;\n\nexport default { coreAccountQueryPlugin, coreAccountQueryPluginToolNames };\n","import { z } from 'zod';\nimport { Context } from '@/shared/configuration';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { tokenInfoQueryParameters } from '@/shared/parameter-schemas/token.zod';\nimport { Client } from '@hashgraph/sdk';\nimport { Tool } from '@/shared/tools';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { TokenInfo } from '@/shared/hedera-utils/mirrornode/types';\nimport { untypedQueryOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nexport const getTokenInfoQueryPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will return the information for a given Hedera token. Make sure to return token symbol.\n\nParameters:\n- tokenId (str): The token ID to query for.\n${usageInstructions}\n`;\n};\n\nconst postProcess = (tokenInfo: TokenInfo) => {\n const formatSupply = (supply?: string) => {\n if (!supply) return 'N/A';\n\n const decimals = Number(tokenInfo.decimals || '0');\n const amount = Number(supply);\n if (isNaN(amount)) return supply;\n\n return (amount / 10 ** decimals).toLocaleString();\n };\n\n const formatKey = (key?: { _type: string; key: string } | null) => {\n if (!key) return 'Not Set';\n return key._type ? `${key.key}` : 'Present';\n };\n\n const supplyType = tokenInfo.supply_type === 'INFINITE' ? 'Infinite' : 'Finite';\n const freezeStatus = tokenInfo.freeze_default ? 'Frozen' : 'Active';\n\n return `Here are the details for token **${tokenInfo.token_id}**:\n\n- **Token Name**: ${tokenInfo.name}\n- **Token Symbol**: ${tokenInfo.symbol}\n- **Token Type**: ${tokenInfo.type || 'N/A'}\n- **Decimals**: ${tokenInfo.decimals}\n- **Max Supply**: ${formatSupply(tokenInfo.max_supply)}\n- **Current Supply**: ${formatSupply(tokenInfo.total_supply)}\n- **Supply Type**: ${supplyType}\n- **Treasury Account ID**: ${tokenInfo.treasury_account_id || 'N/A'}\n- **Status (Deleted/Active)**: ${tokenInfo.deleted ? 'Deleted' : 'Active'}\n- **Status (Frozen/Active)**: ${freezeStatus}\n\n**Keys**:\n- Admin Key: ${formatKey(tokenInfo.admin_key)}\n- Supply Key: ${formatKey(tokenInfo.supply_key)}\n- Wipe Key: ${formatKey(tokenInfo.wipe_key)}\n- KYC Key: ${formatKey(tokenInfo.kyc_key)}\n- Freeze Key: ${formatKey(tokenInfo.freeze_key)}\n- Fee Schedule Key: ${formatKey(tokenInfo.fee_schedule_key)}\n- Pause Key: ${formatKey(tokenInfo.pause_key)}\n- Metadata Key: ${formatKey(tokenInfo.metadata_key)}\n\n${tokenInfo.memo ? `**Memo**: ${tokenInfo.memo}` : ''}\n`;\n};\n\nexport const getTokenInfoQuery = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof tokenInfoQueryParameters>>,\n) => {\n try {\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const tokenInfo: TokenInfo = {\n ...(await mirrornodeService.getTokenInfo(params.tokenId!)),\n token_id: params.tokenId!,\n };\n\n return {\n raw: { tokenId: params.tokenId, tokenInfo },\n humanMessage: postProcess(tokenInfo),\n };\n } catch (error) {\n const desc = 'Failed to get token info';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[get_token_info_query_tool]', message);\n return { raw: { error: message }, humanMessage: message };\n }\n};\n\nexport const GET_TOKEN_INFO_QUERY_TOOL = 'get_token_info_query_tool';\n\nconst tool = (context: Context): Tool => ({\n method: GET_TOKEN_INFO_QUERY_TOOL,\n name: 'Get Token Info',\n description: getTokenInfoQueryPrompt(context),\n parameters: tokenInfoQueryParameters(context),\n execute: getTokenInfoQuery,\n outputParser: untypedQueryOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport { Context } from '@/shared/configuration';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { Client } from '@hashgraph/sdk';\nimport { Tool } from '@/shared/tools';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport {\n TokenAirdropsResponse,\n TokenAirdrop,\n TokenInfo,\n} from '@/shared/hedera-utils/mirrornode/types';\nimport { pendingAirdropQueryParameters } from '@/shared/parameter-schemas/token.zod';\nimport { AccountResolver } from '@/shared/utils/account-resolver';\nimport { untypedQueryOutputParser } from '@/shared/utils/default-tool-output-parsing';\nimport { toDisplayUnit } from '@/shared/hedera-utils/decimals-utils';\nimport { IHederaMirrornodeService } from '@/shared';\nimport BigNumber from 'bignumber.js';\n\nexport const getPendingAirdropQueryPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const accountDesc = PromptGenerator.getAccountParameterDescription('accountId', context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will return pending airdrops for a given Hedera account.\n\nParameters:\n- ${accountDesc}\n${usageInstructions}\n`;\n};\n\ninterface EnrichedTokenAirdrop extends TokenAirdrop {\n decimals: number;\n symbol: string;\n}\n\ninterface EnrichedTokenAirdropsResponse {\n airdrops: EnrichedTokenAirdrop[];\n}\n\nconst enrichSingleAirdrop = async (\n airdrop: TokenAirdrop,\n mirrornodeService: IHederaMirrornodeService,\n): Promise<EnrichedTokenAirdrop> => {\n const enriched = airdrop as EnrichedTokenAirdrop;\n const tokenId = airdrop.token_id;\n\n // Default values\n let decimals = 0;\n let symbol = 'N/A';\n\n if (tokenId) {\n try {\n const info: TokenInfo = await mirrornodeService.getTokenInfo(tokenId);\n decimals = Number(info.decimals) ?? 0;\n symbol = info.symbol ?? 'N/A';\n } catch {\n symbol = 'UNKNOWN';\n }\n }\n\n enriched.decimals = decimals;\n enriched.symbol = symbol;\n\n return enriched;\n};\n\nconst postProcess = (accountId: string, enrichedAirdrops: EnrichedTokenAirdrop[]) => {\n const count = enrichedAirdrops.length;\n\n if (count === 0) {\n return `No pending airdrops found for account ${accountId}`;\n }\n\n const details = enrichedAirdrops.map(airdrop => {\n const symbol = airdrop.symbol;\n const decimals = airdrop.decimals;\n const serialNumber = airdrop.serial_number;\n\n if (serialNumber) {\n return `- **${symbol}** #${serialNumber}`;\n } else {\n const amount = new BigNumber(airdrop.amount ?? 0);\n const displayAmount = toDisplayUnit(amount, decimals);\n return `- ${displayAmount.toFixed(decimals)} **${symbol}**`;\n }\n });\n\n const detailsStr = details.join('\\n');\n return `Here are the pending airdrops for account **${accountId}** (total: ${count}):\\n\\n${detailsStr}`;\n};\n\nexport const getPendingAirdropQuery = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof pendingAirdropQueryParameters>>,\n) => {\n try {\n const accountId = params.accountId ?? AccountResolver.getDefaultAccount(context, client);\n if (!accountId) throw new Error('Account ID is required and was not provided');\n\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n\n // 1. Fetch the list of pending airdrops\n const response: TokenAirdropsResponse = await mirrornodeService.getPendingAirdrops(accountId);\n\n // 2. Parallel Fetch & Enrich\n const rawAirdrops = response.airdrops ?? [];\n const enrichedAirdrops = await Promise.all(\n rawAirdrops.map(airdrop => enrichSingleAirdrop(airdrop, mirrornodeService)),\n );\n\n // 3. Return response\n const enrichedResponse: EnrichedTokenAirdropsResponse = {\n airdrops: enrichedAirdrops,\n };\n\n return {\n raw: { accountId, pendingAirdrops: enrichedResponse },\n humanMessage: postProcess(accountId, enrichedAirdrops),\n };\n } catch (error) {\n const desc = 'Failed to get pending airdrops';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[get_pending_airdrop_query_tool]', message);\n return { raw: { error: message }, humanMessage: message };\n }\n};\n\nexport const GET_PENDING_AIRDROP_TOOL = 'get_pending_airdrop_tool';\n\nconst tool = (context: Context): Tool => ({\n method: GET_PENDING_AIRDROP_TOOL,\n name: 'Get Pending Airdrops',\n description: getPendingAirdropQueryPrompt(context),\n parameters: pendingAirdropQueryParameters(context),\n execute: getPendingAirdropQuery,\n outputParser: untypedQueryOutputParser,\n});\n\nexport default tool;\n","import { Plugin } from '@/shared/plugin';\nimport { Context } from '@/shared/configuration';\nimport getTokenInfoQuery, {\n GET_TOKEN_INFO_QUERY_TOOL,\n} from '@/plugins/core-token-query-plugin/tools/queries/get-token-info-query';\nimport getPendingAirdropQuery, {\n GET_PENDING_AIRDROP_TOOL,\n} from '@/plugins/core-token-query-plugin/tools/queries/get-pending-airdrop-query';\n\nexport const coreTokenQueryPlugin: Plugin = {\n name: 'core-token-query-plugin',\n version: '1.0.0',\n description: 'A plugin for Hedera Token Service queries',\n tools: (context: Context) => {\n return [getTokenInfoQuery(context), getPendingAirdropQuery(context)];\n },\n};\n\nexport const coreTokenQueryPluginToolNames = {\n GET_TOKEN_INFO_QUERY_TOOL,\n GET_PENDING_AIRDROP_TOOL,\n} as const;\n\nexport default { coreTokenQueryPlugin, coreTokenQueryPluginToolNames };\n","import { Context } from '@/shared/configuration';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { topicMessagesQueryParameters } from '@/shared/parameter-schemas/consensus.zod';\nimport { Client } from '@hashgraph/sdk';\nimport { z } from 'zod';\nimport { Tool } from '@/shared/tools';\nimport { TopicMessage, TopicMessagesQueryParams } from '@/shared/hedera-utils/mirrornode/types';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { untypedQueryOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nexport const getTopicMessagesQueryPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will return the messages for a given Hedera topic.\n\nParameters:\n- topicId (str, required): The topic ID to query\n- startTime (datetime, optional): The start datetime to query. If set, the messages will be returned after this datetime\n- endTime (datetime, optional): The end datetime to query. If set, the messages will be returned before this datetime\n- limit (int, optional): The limit of messages to query. If set, the number of messages to return\n${usageInstructions}\n`;\n};\n\nconst postProcess = (messages: TopicMessage[], topicId: string) => {\n if (messages.length === 0) {\n return `No messages found for topic ${topicId}.`;\n }\n\n const messagesText = messages.map(\n message =>\n `${Buffer.from(message.message, 'base64').toString('utf-8')} - posted at: ${message.consensus_timestamp}\\n`,\n );\n\n return `Messages for topic ${topicId}:\n --- Messages ---\n ${messagesText}\n `;\n};\n\nconst getTopicMessagesQueryParams = (\n params: z.infer<ReturnType<typeof topicMessagesQueryParameters>>,\n): TopicMessagesQueryParams => {\n return {\n topicId: params.topicId,\n lowerTimestamp: params.startTime\n ? `${Math.floor(new Date(params.startTime).getTime() / 1000)}.000000000`\n : '',\n upperTimestamp: params.endTime\n ? `${Math.floor(new Date(params.endTime).getTime() / 1000)}.000000000`\n : '',\n limit: params.limit || 100,\n };\n};\n\nconst convertMessagesFromBase64ToString = (messages: TopicMessage[]) => {\n return messages.map(message => {\n return {\n ...message,\n message: Buffer.from(message.message, 'base64').toString('utf-8'),\n };\n });\n};\n\nexport const getTopicMessagesQuery = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof topicMessagesQueryParameters>>,\n) => {\n try {\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const messages = await mirrornodeService.getTopicMessages(getTopicMessagesQueryParams(params));\n\n return {\n raw: {\n topicId: messages.topicId,\n messages: convertMessagesFromBase64ToString(messages.messages),\n },\n humanMessage: postProcess(messages.messages, params.topicId),\n };\n } catch (error) {\n const desc = 'Failed to get topic messages';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[get_topic_messages_query_tool]', message);\n return { raw: { error: message }, humanMessage: message };\n }\n};\n\nexport const GET_TOPIC_MESSAGES_QUERY_TOOL = 'get_topic_messages_query_tool';\n\nconst tool = (context: Context): Tool => ({\n method: GET_TOPIC_MESSAGES_QUERY_TOOL,\n name: 'Get Topic Messages',\n description: getTopicMessagesQueryPrompt(context),\n parameters: topicMessagesQueryParameters(context),\n execute: getTopicMessagesQuery,\n outputParser: untypedQueryOutputParser,\n});\n\nexport default tool;\n","import { z } from 'zod';\nimport { Context } from '@/shared/configuration';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { Client } from '@hashgraph/sdk';\nimport { Tool } from '@/shared/tools';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { TopicInfo } from '@/shared/hedera-utils/mirrornode/types';\nimport { getTopicInfoParameters } from '@/shared/parameter-schemas/consensus.zod';\nimport { untypedQueryOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nexport const getTopicInfoQueryPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will return the information for a given Hedera topic (HCS).\n\nParameters:\n- topicId (str): The topic ID to query for.\n${usageInstructions}\n`;\n};\n\nconst postProcess = (topic: TopicInfo) => {\n const formatKey = (key?: { _type?: string; key?: string } | null) => {\n if (!key) return 'Not Set';\n return key._type ? key.key || 'Present' : 'Present';\n };\n\n const formatTimestamp = (ts?: string | null) => {\n if (!ts) return 'N/A';\n const [seconds] = ts.split('.');\n const date = new Date(Number(seconds) * 1000);\n return date.toISOString();\n };\n\n return `Here are the details for topic **${topic.topic_id || 'N/A'}**:\n\n- **Memo**: ${topic.memo || 'N/A'}\n- **Deleted**: ${topic.deleted ? 'Yes' : 'No'}\n- **Sequence Number**: ${topic.sequence_number ?? 'N/A'}\n\n**Timestamps**:\n- Created: ${formatTimestamp(topic.created_timestamp)}\n\n**Entity IDs**:\n- Auto Renew Account: ${topic.auto_renew_account || 'N/A'}\n- Auto Renew Period: ${topic.auto_renew_period ?? 'N/A'}\n\n**Keys**:\n- Admin Key: ${formatKey(topic.admin_key)}\n- Submit Key: ${formatKey(topic.submit_key)}\n`;\n};\n\nexport const getTopicInfoQuery = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof getTopicInfoParameters>>,\n) => {\n try {\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const topicInfo: TopicInfo = {\n ...(await mirrornodeService.getTopicInfo(params.topicId)),\n topic_id: params.topicId,\n };\n\n return {\n raw: { topicId: params.topicId, topicInfo },\n humanMessage: postProcess(topicInfo),\n };\n } catch (error) {\n const desc = 'Failed to get topic info';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[get_topic_info_query_tool]', message);\n return { raw: { error: message }, humanMessage: message };\n }\n};\n\nexport const GET_TOPIC_INFO_QUERY_TOOL = 'get_topic_info_query_tool';\n\nconst tool = (context: Context): Tool => ({\n method: GET_TOPIC_INFO_QUERY_TOOL,\n name: 'Get Topic Info',\n description: getTopicInfoQueryPrompt(context),\n parameters: getTopicInfoParameters(context),\n execute: getTopicInfoQuery,\n outputParser: untypedQueryOutputParser,\n});\n\nexport default tool;\n","import { Plugin } from '@/shared/plugin';\nimport { Context } from '@/shared/configuration';\nimport getTopicMessagesQuery, {\n GET_TOPIC_MESSAGES_QUERY_TOOL,\n} from '@/plugins/core-consensus-query-plugin/tools/queries/get-topic-messages-query';\nimport getTopicInfoQuery, {\n GET_TOPIC_INFO_QUERY_TOOL,\n} from '@/plugins/core-consensus-query-plugin/tools/queries/get-topic-info-query';\n\nexport const coreConsensusQueryPlugin: Plugin = {\n name: 'core-consensus-query-plugin',\n version: '1.0.0',\n description: 'A plugin for Hedera Consensus Service queries',\n tools: (context: Context) => {\n return [getTopicMessagesQuery(context), getTopicInfoQuery(context)];\n },\n};\n\nexport const coreConsensusQueryPluginToolNames = {\n GET_TOPIC_MESSAGES_QUERY_TOOL,\n GET_TOPIC_INFO_QUERY_TOOL,\n} as const;\n\nexport default { coreConsensusQueryPlugin, coreConsensusQueryPluginToolNames };\n","import { z } from 'zod';\nimport { Context } from '@/shared/configuration';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { contractInfoQueryParameters } from '@/shared/parameter-schemas/evm.zod';\nimport { Client } from '@hashgraph/sdk';\nimport { Tool } from '@/shared/tools';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { ContractInfo } from '@/shared/hedera-utils/mirrornode/types';\nimport { untypedQueryOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nexport const getContractInfoQueryPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will return the information for a given Hedera contract.\n\nParameters:\n- contractId (str): The contract ID to query for.\n${usageInstructions}\n`;\n};\n\nconst postProcess = (contract: ContractInfo) => {\n const formatKey = (key?: { _type?: string; key?: string } | null) => {\n if (!key) return 'Not Set';\n return key._type ? key.key || 'Present' : 'Present';\n };\n\n const formatTimestamp = (ts?: string | null) => {\n if (!ts) return 'N/A';\n const [seconds, nanos] = ts.split('.');\n const date = new Date(Number(seconds) * 1000);\n return date.toISOString() + (nanos ? `.${nanos}` : '');\n };\n\n return `Here are the details for contract **${contract.contract_id || 'N/A'}**:\n\n- **Memo**: ${contract.memo || 'N/A'}\n- **Deleted**: ${contract.deleted ? 'Yes' : 'No'}\n- **Permanent Removal**: ${contract.permanent_removal ? 'Yes' : 'No'}\n- **Nonce**: ${contract.nonce ?? 'N/A'}\n\n**Timestamps**:\n- Created: ${formatTimestamp(contract.created_timestamp)}\n- Expiration: ${formatTimestamp(contract.expiration_timestamp)}\n- Valid From: ${contract.timestamp?.from || 'N/A'}\n- Valid To: ${contract.timestamp?.to || 'N/A'}\n\n**Entity IDs**:\n- Auto Renew Account: ${contract.auto_renew_account || 'N/A'}\n- File ID: ${contract.file_id || 'N/A'}\n- Obtainer ID: ${contract.obtainer_id || 'N/A'}\n- Proxy Account ID: ${contract.proxy_account_id || 'N/A'}\n\n**Keys**:\n- Admin Key: ${formatKey(contract.admin_key)}\n\n**EVM**:\n- Address: ${contract.evm_address || 'N/A'}\n`;\n};\n\nexport const getContractInfoQuery = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof contractInfoQueryParameters>>,\n) => {\n try {\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const contractInfo: ContractInfo = await mirrornodeService.getContractInfo(params.contractId);\n\n return {\n raw: { contractId: contractInfo.contract_id, contractInfo },\n humanMessage: postProcess(contractInfo),\n };\n } catch (error) {\n const desc = 'Failed to get contract info';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[get_contract_info_query_tool]', message);\n return { raw: { error: message }, humanMessage: message };\n }\n};\n\nexport const GET_CONTRACT_INFO_QUERY_TOOL = 'get_contract_info_query_tool';\n\nconst tool = (context: Context): Tool => ({\n method: GET_CONTRACT_INFO_QUERY_TOOL,\n name: 'Get Contract Info',\n description: getContractInfoQueryPrompt(context),\n parameters: contractInfoQueryParameters(context),\n execute: getContractInfoQuery,\n outputParser: untypedQueryOutputParser,\n});\n\nexport default tool;\n","import { Plugin } from '@/shared/plugin';\nimport { Context } from '@/shared/configuration';\nimport getContractInfoQuery, {\n GET_CONTRACT_INFO_QUERY_TOOL,\n} from '@/plugins/core-evm-query-plugin/tools/queries/get-contract-info-query';\n\nexport const coreEVMQueryPlugin: Plugin = {\n name: 'core-evm-query-plugin',\n version: '1.0.0',\n description: 'A plugin for Hedera EVM Service queries',\n tools: (context: Context) => {\n return [getContractInfoQuery(context)];\n },\n};\n\nexport const coreEVMQueryPluginToolNames = {\n GET_CONTRACT_INFO_QUERY_TOOL,\n} as const;\n\nexport default { coreEVMQueryPlugin, coreEVMQueryPluginToolNames };\n","import { z } from 'zod';\nimport { Client } from '@hashgraph/sdk';\nimport { Context } from '@/shared/configuration';\nimport { getMirrornodeService } from '@/shared/hedera-utils/mirrornode/hedera-mirrornode-utils';\nimport { Tool } from '@/shared/tools';\nimport { PromptGenerator } from '@/shared/utils/prompt-generator';\nimport { TransactionDetailsResponse } from '@/shared/hedera-utils/mirrornode/types';\nimport { toDisplayUnit } from '@/shared/hedera-utils/decimals-utils';\nimport HederaParameterNormaliser from '@/shared/hedera-utils/hedera-parameter-normaliser';\nimport { transactionRecordQueryParameters } from '@/shared/parameter-schemas/transaction.zod';\nimport { untypedQueryOutputParser } from '@/shared/utils/default-tool-output-parsing';\n\nexport const getTransactionRecordQueryPrompt = (context: Context = {}) => {\n const contextSnippet = PromptGenerator.getContextSnippet(context);\n const usageInstructions = PromptGenerator.getParameterUsageInstructions();\n\n return `\n${contextSnippet}\n\nThis tool will return the transaction record for a given Hedera transaction ID.\n\nParameters:\n- transactionId (str, required): The transaction ID to fetch record for. Should be in format \\\\\"shard.realm.num-sss-nnn\\\\\" format where sss are seconds and nnn are nanoseconds\n- nonce (number, optional): Optional nonce value for the transaction\n${usageInstructions}\n\nAdditional information:\nIf user provides transaction ID in format 0.0.4177806@1755169980.051721264, parse it to 0.0.4177806-1755169980-051721264 and use it as transaction ID. Do not remove the staring zeros.\n`;\n};\n\nconst postProcess = (transactionRecord: TransactionDetailsResponse, transactionId: string) => {\n if (!transactionRecord.transactions || transactionRecord.transactions.length === 0) {\n return `No transaction details found for transaction ID: ${transactionId}`;\n }\n\n const results = transactionRecord.transactions.map((tx, index) => {\n let transfersInfo = '';\n if (tx.transfers && tx.transfers.length > 0) {\n transfersInfo =\n '\\nTransfers:\\n' +\n tx.transfers\n .map(\n transfer =>\n ` Account: ${transfer.account}, Amount: ${toDisplayUnit(transfer.amount, 8)}ℏ`,\n )\n .join('\\n');\n }\n\n const transactionHeader =\n transactionRecord.transactions.length > 1\n ? `Transaction ${index + 1} Details for ${transactionId}`\n : `Transaction Details for ${transactionId}`;\n\n return `${transactionHeader}\nStatus: ${tx.result}\nConsensus Timestamp: ${tx.consensus_timestamp}\nTransaction Hash: ${tx.transaction_hash}\nTransaction Fee: ${tx.charged_tx_fee}\nType: ${tx.name}\nEntity ID: ${tx.entity_id}${transfersInfo}`;\n });\n\n return results.join('\\n\\n' + '='.repeat(50) + '\\n\\n');\n};\n\nexport const getTransactionRecordQuery = async (\n client: Client,\n context: Context,\n params: z.infer<ReturnType<typeof transactionRecordQueryParameters>>,\n) => {\n try {\n const mirrornodeService = getMirrornodeService(context.mirrornodeService!, client.ledgerId!);\n const normalisedParams = HederaParameterNormaliser.normaliseGetTransactionRecordParams(\n params,\n context,\n );\n\n const transactionRecord = await mirrornodeService.getTransactionRecord(\n normalisedParams.transactionId,\n normalisedParams.nonce,\n );\n\n return {\n raw: { transactionId: params.transactionId, transactionRecord: transactionRecord },\n humanMessage: postProcess(transactionRecord, params.transactionId),\n };\n } catch (error) {\n const desc = 'Failed to get transaction record';\n const message = desc + (error instanceof Error ? `: ${error.message}` : '');\n console.error('[get_transaction_record_query_tool]', message);\n return { raw: { error: message }, humanMessage: message };\n }\n};\n\nexport const GET_TRANSACTION_RECORD_QUERY_TOOL = 'get_transaction_record_query_tool';\n\nconst tool = (context: Context): Tool => ({\n method: GET_TRANSACTION_RECORD_QUERY_TOOL,\n name: 'Get Transaction Record Query',\n description: getTransactionRecordQueryPrompt(context),\n parameters: transactionRecordQueryParameters(context),\n execute: getTransactionRecordQuery,\n outputParser: untypedQueryOutputParser,\n});\n\nexport default tool;\n","import { Plugin } from '@/shared/plugin';\nimport { Context } from '@/shared/configuration';\nimport getTransactionRecordQuery, {\n GET_TRANSACTION_RECORD_QUERY_TOOL,\n} from '@/plugins/core-transactions-query-plugin/tools/queries/get-transaction-record-query';\n\nexport const coreTransactionQueryPlugin: Plugin = {\n name: 'core-transaction-query-plugin',\n version: '1.0.0',\n description: 'A plugin for Hedera Transactions queries',\n tools: (context: Context) => {\n return [getTransactionRecordQuery(context)];\n },\n};\n\nexport const coreTransactionQueryPluginToolNames = {\n GET_TRANSACTION_RECORD_QUERY_TOOL,\n} as const;\n\nexport default { coreTransactionQueryPlugin, coreTransactionQueryPluginToolNames };\n","import { Context } from './configuration';\nimport { Tool } from './tools';\nimport {\n coreAccountPlugin,\n coreTokenPlugin,\n coreConsensusPlugin,\n coreEVMPlugin,\n coreAccountQueryPlugin,\n coreTokenQueryPlugin,\n coreConsensusQueryPlugin,\n coreMiscQueriesPlugin,\n coreTransactionQueryPlugin,\n coreEVMQueryPlugin,\n} from '@/plugins';\n\nconst CORE_PLUGINS = [\n coreAccountPlugin,\n coreAccountQueryPlugin,\n coreConsensusPlugin,\n coreConsensusQueryPlugin,\n coreEVMPlugin,\n coreEVMQueryPlugin,\n coreMiscQueriesPlugin,\n coreTokenPlugin,\n coreTokenQueryPlugin,\n coreTransactionQueryPlugin,\n];\n\nexport interface Plugin {\n name: string;\n version?: string;\n description?: string;\n tools: (context: Context) => Tool[];\n}\n\nexport class PluginRegistry {\n private plugins = new Map<string, Plugin>();\n\n register(plugin: Plugin): void {\n if (this.plugins.has(plugin.name)) {\n console.warn(`Plugin \"${plugin.name}\" is already registered. Overwriting.`);\n }\n this.plugins.set(plugin.name, plugin);\n }\n\n getPlugins(): Plugin[] {\n return Array.from(this.plugins.values());\n }\n\n private loadCorePlugins(context: Context): Tool[] {\n const pluginTools: Tool[] = [];\n for (const plugin of CORE_PLUGINS) {\n try {\n const tools = plugin.tools(context);\n pluginTools.push(...tools);\n } catch (error) {\n console.error(`Error loading tools from plugin \"${plugin.name}\":`, error);\n }\n }\n return pluginTools;\n }\n\n private loadPlugins(context: Context): Tool[] {\n const pluginTools: Tool[] = [];\n for (const plugin of this.plugins.values()) {\n try {\n const tools = plugin.tools(context);\n pluginTools.push(...tools);\n } catch (error) {\n console.error(`Error loading tools from plugin \"${plugin.name}\":`, error);\n }\n }\n return pluginTools;\n }\n\n getTools(context: Context): Tool[] {\n if (this.plugins.size === 0) {\n return this.loadCorePlugins(context);\n } else {\n return this.loadPlugins(context);\n }\n }\n\n clear(): void {\n this.plugins.clear();\n }\n}\n","import { Context, Configuration } from './configuration';\nimport { Tool } from './tools';\nimport { Plugin, PluginRegistry } from './plugin';\n\nexport class ToolDiscovery {\n private pluginRegistry = new PluginRegistry();\n\n constructor(plugins: Plugin[] = []) {\n plugins.forEach(plugin => this.pluginRegistry.register(plugin));\n }\n\n getAllTools(context: Context, configuration?: Configuration): Tool[] {\n // Get plugin tools\n const pluginTools = this.pluginRegistry.getTools(context);\n\n // Merge all tools (core tools take precedence in case of name conflicts)\n const allTools: any = [];\n const allToolNames = new Set<string>();\n\n // Add plugin tools that don't conflict with core tools\n pluginTools.forEach(pluginTool => {\n if (!allToolNames.has(pluginTool.method)) {\n allTools.push(pluginTool);\n allToolNames.add(pluginTool.method);\n } else {\n console.warn(\n `Plugin tool \"${pluginTool.method}\" conflicts with core tool. Using core tool.`,\n );\n }\n });\n\n // Apply tool filtering if specified in configuration\n if (configuration?.tools && configuration.tools.length > 0) {\n return allTools.filter((tool: any) => configuration.tools!.includes(tool.method));\n }\n\n return allTools;\n }\n\n static createFromConfiguration(configuration: Configuration): ToolDiscovery {\n return new ToolDiscovery(configuration.plugins || []);\n }\n}\n","import {\n Action,\n ActionExample,\n ActionResult,\n composePromptFromState,\n Handler,\n type HandlerCallback,\n type IAgentRuntime,\n logger,\n type Memory,\n ModelType,\n type State,\n Validator,\n} from '@elizaos/core';\nimport { Client } from '@hashgraph/sdk';\nimport type { Tool } from '@/shared/tools';\nimport { Context } from '@/shared/configuration';\nimport { generateExtractionTemplate } from '@/elizaos/utils/extraction';\nimport { customParseJSONObjectFromText } from '@/elizaos/utils/parser';\n\nclass HederaAgentKitTool implements Action {\n description: string;\n handler: Handler;\n similes?: string[] | undefined;\n examples?: ActionExample[][] | undefined;\n name: string;\n validate: Validator;\n\n constructor(client: Client, context: Context, tool: Tool) {\n const parameterSchema = tool.parameters;\n this.description = tool.description;\n\n // Set Action properties\n this.name = tool.method.toUpperCase();\n this.similes = [tool.method.toUpperCase()];\n this.validate = async (_runtime: IAgentRuntime, _message: Memory) => true;\n\n this.handler = async (\n runtime: IAgentRuntime,\n _message: Memory,\n state: State | undefined,\n _options: any,\n callback?: HandlerCallback,\n ): Promise<ActionResult> => {\n logger.log(`Running ${tool.method} handler...`);\n if (!state) {\n throw new Error('State is undefined');\n }\n\n // create an extraction prompt for extracting tool parameters from recent user messages\n const prompt = composePromptFromState({\n state,\n template: generateExtractionTemplate(tool),\n });\n logger.debug(`prompt: ${prompt}`);\n\n // execute extraction prompt\n const modelOutput = await runtime.useModel(ModelType.TEXT_LARGE, { prompt });\n logger.debug(`Model extraction output: ${modelOutput}`);\n\n // custom parsing params from Markdown JSON notation to JS object\n const parsedParams = customParseJSONObjectFromText(modelOutput) as Record<string, any>;\n logger.debug('Parsed params object' + JSON.stringify(parsedParams, null, 2));\n\n // validating parameters with tools input zod schema\n const validation = parameterSchema.safeParse(parsedParams); // parsing extracted params before calling a tool\n logger.debug('Validated params:' + JSON.stringify(validation, null, 2));\n\n // print error if validation failed\n if (!validation.success) {\n // call llm to generate a comprehensive message to the user about missing params\n const promptText = `given the recent messages {{recent_messages}}, \n tool description: ${tool.description}\n and the error message: ${validation.error.format()}\n generate a comprehensive message to the user about missing params\n `;\n\n const modelOutput = await runtime.useModel(ModelType.TEXT_LARGE, { prompt: promptText });\n if (callback) {\n await callback({\n text: modelOutput,\n content: { error: validation.error.format() },\n });\n }\n return {\n success: false,\n text: modelOutput,\n error: validation.error.toString(),\n };\n }\n\n // call the action\n try {\n const result = await tool.execute(client, context, validation.data);\n const responseText = result.humanMessage; // extract the human-readable response provided by the tool\n\n if (callback) {\n await callback({\n text: responseText,\n content: result,\n });\n }\n\n return { success: true, text: responseText };\n } catch (err) {\n // handle other errors\n const message = err instanceof Error ? err.message : 'Unknown error';\n logger.error(`Error running tool ${tool.method}:` + err);\n\n if (callback) {\n await callback({\n text: `Execution failed: ${message}`,\n content: { error: message },\n });\n }\n\n return { success: false, text: `Execution failed: ${message}`, error: message };\n }\n };\n }\n [key: string]: unknown;\n}\n\nexport default HederaAgentKitTool;\n","import { Tool } from '@/shared';\nimport { zodToJsonSchema } from 'zod-to-json-schema';\n\n/**\n * Generates an extraction template based on the tool description, params and zod schema.\n * @param tool\n */\nexport function generateExtractionTemplate(tool: Tool): string {\n const zodSchema = tool.parameters; // Zod Schema of the tool parameters, used for generating JSON schema for extraction response\n const description = tool.description; // description of the tool, used for generating a list of required/optional params\n const actionName = tool.name;\n const toolParamsJSONSchema = zodToJsonSchema(zodSchema, actionName); // JSON schema created based on the tool's params\n\n return `Given the recent messages and Hedera wallet information below:\n{{recentMessages}}\n{{hederaAccountDetails}}\n\nExtract the following parameters based on the tool/action description and json schema below:\n\n### Tool/action description:\n${description}\n\n⚠️ Do **not** assume values or apply defaults. Do **not** set a field unless it is clearly specified in the latest user input.\n⚠️ **IMPORTANT**: Always ensure numeric values are provided as NUMBERS WITHOUT QUOTES in the JSON response.\n⚠️ **IMPORTANT**: Always ensure string values are provided as QUOTED STRINGS in the JSON response.\n⚠️ **CRITICAL**: Enum values must be provided as QUOTED STRINGS (e.g., \"finite\", not finite).\n⚠️ **CRITICAL**: The returned JSON must be a valid JSON object in markdown format. Don not include comments inside it. If no params is passed return an empty JSON object.\n\n---\n\n### Response format:\nRespond with a JSON markdown block including the fields that were explicitly mentioned in the most recent user message.\n\nResponse JSON schema:\n${JSON.stringify(toolParamsJSONSchema, null, 2)}\n\n---\n\nNumeric values should be numbers without quotes. Enum values must be quoted strings.`;\n}\n","const jsonBlockPattern = /```(?:json)?\\s*([\\s\\S]*?)```/;\n\n/**\n * Custom implementation of JSON Parser form ElizaOS\n * Parses a JSON object or array from a given text.\n * Extracts JSON from code blocks and handles normalization of improperly formatted JSON.\n * Preserves data types (numbers, booleans, arrays) in the parsed result.\n *\n * @param text - The input text from which to extract and parse the JSON.\n * @returns The parsed JSON object or array if successful; otherwise, null.\n */\nexport function customParseJSONObjectFromText(text: string): Record<string, any> | any[] | null {\n if (!text) return null;\n\n let jsonData = null;\n const jsonBlockMatch = text.match(jsonBlockPattern);\n\n try {\n if (jsonBlockMatch) {\n // Clean the extracted JSON content\n const jsonContent = jsonBlockMatch[1].trim().replace(/[\\u0000-\\u001F\\u007F-\\u009F]/g, ''); // Remove control characters\n jsonData = JSON.parse(jsonContent);\n } else {\n // Try direct parsing first for well-formatted JSON\n try {\n jsonData = JSON.parse(text.trim());\n } catch {\n // Fall back to normalization for poorly formatted JSON\n jsonData = JSON.parse(customNormalizeJsonString(text.trim()));\n }\n }\n } catch (error) {\n console.warn('Could not parse text as JSON:', error);\n return null;\n }\n\n // Accept both objects and arrays, but ensure we have something valid\n if (jsonData && typeof jsonData === 'object') {\n return jsonData;\n }\n\n console.warn('Parsed result is not a valid object or array');\n return null;\n}\n\n/**\n * Custom Implementation of JSON string normalization from ElizaOS\n * Normalizes a JSON-like string by correcting formatting issues without converting numbers or booleans to strings.\n *\n * @param str - The JSON-like string to normalize.\n * @returns A properly formatted JSON string.\n */\nfunction customNormalizeJsonString(str: string): string {\n if (!str) return str;\n\n // Remove extra spaces after '{' and before '}'\n str = str.replace(/\\{\\s+/, '{').replace(/\\s+\\}/, '}').trim();\n\n // Fix missing quotes around property names\n str = str.replace(/(\\s*)(\\w+)(\\s*):(\\s*)/g, '$1\"$2\"$3:$4');\n\n // Fix single quotes around property values but ONLY when they're strings\n // Don't convert numbers or booleans that are properly formatted\n str = str.replace(/\"([^\"]+)\"\\s*:\\s*'([^']*)'/g, (_, key, value) => `\"${key}\": \"${value}\"`);\n\n // Handle unquoted property values that should be strings\n // But skip numbers, true, false, and null which should remain unquoted\n str = str.replace(/\"([^\"]+)\"\\s*:\\s*([^\",\\{\\[\\]\\}0-9][^\",\\{\\[\\]\\}\\s]*)/g, (match, key, value) => {\n // Skip if value is true, false, or null\n if (value === 'true' || value === 'false' || value === 'null') {\n return `\"${key}\": ${value}`;\n }\n // Skip if value is a number\n if (!isNaN(Number(value))) {\n return `\"${key}\": ${value}`;\n }\n return `\"${key}\": \"${value}\"`;\n });\n\n return str;\n}\n","import { Client } from '@hashgraph/sdk';\nimport { Configuration, Context } from '@/shared/configuration';\nimport { ToolDiscovery } from '@/shared/tool-discovery';\nimport HederaAgentKitTool from '@/elizaos/tool';\n\nexport class HederaElizaOSToolkit {\n private readonly tools: HederaAgentKitTool[];\n private readonly client: Client;\n private readonly context: Context;\n\n constructor({ client, configuration }: { client: Client; configuration: Configuration }) {\n this.client = client;\n this.context = configuration.context || {};\n const toolDiscovery = ToolDiscovery.createFromConfiguration(configuration);\n const allTools = toolDiscovery.getAllTools(this.context, configuration);\n\n this.tools = allTools.map(tool => new HederaAgentKitTool(this.client, this.context, tool));\n }\n\n /**\n * Maps hedera-agent-kit tools and returns ElizaOS compatible actions\n */\n getTools(): HederaAgentKitTool[] {\n return this.tools;\n }\n}\n"],"mappings":";AACA,SAAS,KAAAA,UAAS;AAClB;AAAA,EACE,aAAAC;AAAA,EACA;AAAA,EACA,aAAAC;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;;;ACTP,SAAS,SAAS;AAClB,SAAS,WAAW,WAAW,iBAAiB;AAEzC,IAAM,qCAAqC,CAAC,WAAoB,CAAC,MACtE,EAAE,OAAO;AAAA,EACP,kBAAkB,EACf,OAAO;AAAA,IACN,aAAa,EACV,QAAQ,EACR,SAAS,EACT,QAAQ,KAAK,EACb;AAAA,MACC;AAAA,IACF;AAAA,IACF,UAAU,EACP,MAAM,CAAC,EAAE,QAAQ,GAAG,EAAE,OAAO,CAAC,CAAC,EAC/B,SAAS,EACT,QAAQ,KAAK,EACb;AAAA,MACC;AAAA,IACF;AAAA,IACF,gBAAgB,EACb,OAAO,EACP,SAAS,EACT;AAAA,MACC;AAAA,IACF;AAAA,IACF,gBAAgB,EACb,OAAO,EACP,SAAS,EACT;AAAA,MACC;AAAA,IACF;AAAA,IACF,eAAe,EACZ,QAAQ,EACR,SAAS,EACT,QAAQ,KAAK,EACb;AAAA,MACC;AAAA,IAKF;AAAA,EACJ,CAAC,EACA,SAAS,EACT;AAAA,IACC;AAAA,EACF;AACJ,CAAC;;;ADjCI,IAAM,gCAAgC,CAAC,WAAoB,CAAC,MACjE,mCAAmC,QAAQ,EAAE,OAAO;AAAA,EAClD,WAAWC,GAAE,OAAO,EAAE,SAAS,wBAAwB;AAAA,EACvD,aAAaA,GAAE,OAAO,EAAE,SAAS,0BAA0B;AAAA,EAC3D,eAAeA,GACZ,OAAO,EACP,IAAI,EACJ,SAAS,EACT,QAAQ,CAAC,EACT;AAAA,IACC;AAAA,EACF;AAAA,EACF,YAAYA,GACT,K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AAM,MAAM,GAAG;AAEvD,YAAI,UAAU;AACZ,gBAAM,SAAS;AAAA,YACb,MAAM,qBAAqB,OAAO;AAAA,YAClC,SAAS,EAAE,OAAO,QAAQ;AAAA,UAC5B,CAAC;AAAA,QACH;AAEA,eAAO,EAAE,SAAS,OAAO,MAAM,qBAAqB,OAAO,IAAI,OAAO,QAAQ;AAAA,MAChF;AAAA,IACF;AAAA,EACF;AAEF;AAEA,IAAO,eAAQ;;;AGtHR,IAAM,uBAAN,MAA2B;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,EAAE,QAAQ,cAAc,GAAqD;AACvF,SAAK,SAAS;AACd,SAAK,UAAU,cAAc,WAAW,CAAC;AACzC,UAAM,gBAAgB,cAAc,wBAAwB,aAAa;AACzE,UAAM,WAAW,cAAc,YAAY,KAAK,SAAS,aAAa;AAEtE,SAAK,QAAQ,SAAS,IAAI,CAAAE,WAAQ,IAAI,aAAmB,KAAK,QAAQ,KAAK,SAASA,MAAI,CAAC;AAAA,EAC3F;AAAA;AAAA;AAAA;AAAA,EAKA,WAAiC;AAC/B,WAAO,KAAK;AAAA,EACd;AACF;","names":["z","AccountId","PublicKey","z","z","z","z","z","z","z","z","z","z","z","z","z","z","AccountId","z","z","z","z","z","z","z","z","z","z","AccountId","PublicKey","z","z","z","AccountId","Hbar","Long","PublicKey","TokenId","TokenNftAllowance","TokenSupplyType","TokenType","TopicId","HbarAllowance","TokenAllowance","Timestamp","NftId","z","BigNumber","PublicKey","BigNumber","PublicKey","z","z","z","z","z","TokenSupplyType","PublicKey","TokenType","Long","Hbar","HbarAllowance","AccountId","TokenId","TokenNftAllowance","NftId","TokenAllowance","TopicId","Timestamp","postProcess","AccountId","Hbar","TokenId","LedgerId","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","PublicKey","Status","PublicKey","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","PublicKey","Status","checkValidityOfUpdates","PublicKey","postProcess","Status","tool","Status","z","postProcess","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","postProcess","Status","tool","Status","TransactionRecordQuery","TransactionRecordQuery","postProcess","Status","tool","postProcess","GET_HBAR_BALANCE_QUERY_TOOL","tool","get_hbar_balance_query_default","BigNumber","Status","postProcess","BigNumber","Status","GET_ACCOUNT_QUERY_TOOL","tool","get_account_query_default","postProcess","GET_ACCOUNT_TOKEN_BALANCES_QUERY_TOOL","tool","get_account_token_balances_query_default","get_hbar_balance_query_default","get_account_query_default","get_account_token_balances_query_default","postProcess","GET_TOKEN_INFO_QUERY_TOOL","tool","get_token_info_query_default","BigNumber","postProcess","tool","get_token_info_query_default","postProcess","GET_TOPIC_MESSAGES_QUERY_TOOL","tool","get_topic_messages_query_default","postProcess","tool","get_topic_messages_query_default","postProcess","tool","postProcess","tool","tool","tool","tool","modelOutput","tool"]}
|