@hashgraphonline/conversational-agent 0.1.209 → 0.1.211

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/bin/conversational-agent-cli.js +30 -0
  2. package/cli/readme.md +181 -0
  3. package/dist/cjs/base-agent.d.ts +3 -1
  4. package/dist/cjs/conversational-agent.d.ts +14 -22
  5. package/dist/cjs/index.cjs +1 -1
  6. package/dist/cjs/index.cjs.map +1 -1
  7. package/dist/cjs/index.d.ts +5 -3
  8. package/dist/cjs/langchain-agent.d.ts +6 -3
  9. package/dist/cjs/memory/SmartMemoryManager.d.ts +7 -1
  10. package/dist/cjs/memory/TokenCounter.d.ts +1 -1
  11. package/dist/cjs/plugins/hbar/AirdropToolWrapper.d.ts +43 -0
  12. package/dist/{types/plugins/hbar-transfer/HbarTransferPlugin.d.ts → cjs/plugins/hbar/HbarPlugin.d.ts} +2 -1
  13. package/dist/{types/plugins/hbar-transfer → cjs/plugins/hbar}/TransferHbarTool.d.ts +1 -1
  14. package/dist/cjs/plugins/hbar/index.d.ts +3 -0
  15. package/dist/cjs/plugins/index.d.ts +2 -1
  16. package/dist/cjs/services/EntityResolver.d.ts +26 -0
  17. package/dist/cjs/tools/EntityResolverTool.d.ts +104 -0
  18. package/dist/cjs/types/inscription.d.ts +37 -0
  19. package/dist/esm/index.js +8 -2
  20. package/dist/esm/index.js.map +1 -1
  21. package/dist/esm/index12.js +1 -4
  22. package/dist/esm/index12.js.map +1 -1
  23. package/dist/esm/index13.js +0 -1
  24. package/dist/esm/index13.js.map +1 -1
  25. package/dist/esm/index14.js +2 -7
  26. package/dist/esm/index14.js.map +1 -1
  27. package/dist/esm/index15.js +31 -69
  28. package/dist/esm/index15.js.map +1 -1
  29. package/dist/esm/index16.js +126 -39
  30. package/dist/esm/index16.js.map +1 -1
  31. package/dist/esm/index17.js +148 -13
  32. package/dist/esm/index17.js.map +1 -1
  33. package/dist/esm/index18.js +44 -146
  34. package/dist/esm/index18.js.map +1 -1
  35. package/dist/esm/index19.js +100 -6
  36. package/dist/esm/index19.js.map +1 -1
  37. package/dist/esm/index20.js +20 -174
  38. package/dist/esm/index20.js.map +1 -1
  39. package/dist/esm/index21.js +7 -151
  40. package/dist/esm/index21.js.map +1 -1
  41. package/dist/esm/index22.js +154 -45
  42. package/dist/esm/index22.js.map +1 -1
  43. package/dist/esm/index23.js +149 -24
  44. package/dist/esm/index23.js.map +1 -1
  45. package/dist/esm/index24.js +56 -83
  46. package/dist/esm/index24.js.map +1 -1
  47. package/dist/esm/index25.js +24 -236
  48. package/dist/esm/index25.js.map +1 -1
  49. package/dist/esm/index26.js +95 -0
  50. package/dist/esm/index26.js.map +1 -0
  51. package/dist/esm/index27.js +242 -0
  52. package/dist/esm/index27.js.map +1 -0
  53. package/dist/esm/index5.js +32 -19
  54. package/dist/esm/index5.js.map +1 -1
  55. package/dist/esm/index6.js +156 -195
  56. package/dist/esm/index6.js.map +1 -1
  57. package/dist/esm/index7.js +2 -2
  58. package/dist/esm/index7.js.map +1 -1
  59. package/dist/esm/index8.js +80 -48
  60. package/dist/esm/index8.js.map +1 -1
  61. package/dist/types/base-agent.d.ts +3 -1
  62. package/dist/types/conversational-agent.d.ts +14 -22
  63. package/dist/types/index.d.ts +5 -3
  64. package/dist/types/langchain-agent.d.ts +6 -3
  65. package/dist/types/memory/SmartMemoryManager.d.ts +7 -1
  66. package/dist/types/memory/TokenCounter.d.ts +1 -1
  67. package/dist/types/plugins/hbar/AirdropToolWrapper.d.ts +43 -0
  68. package/dist/{cjs/plugins/hbar-transfer/HbarTransferPlugin.d.ts → types/plugins/hbar/HbarPlugin.d.ts} +2 -1
  69. package/dist/{cjs/plugins/hbar-transfer → types/plugins/hbar}/TransferHbarTool.d.ts +1 -1
  70. package/dist/types/plugins/hbar/index.d.ts +3 -0
  71. package/dist/types/plugins/index.d.ts +2 -1
  72. package/dist/types/services/EntityResolver.d.ts +26 -0
  73. package/dist/types/tools/EntityResolverTool.d.ts +104 -0
  74. package/dist/types/types/inscription.d.ts +37 -0
  75. package/package.json +13 -4
  76. package/src/base-agent.ts +14 -9
  77. package/src/config/system-message.ts +11 -2
  78. package/src/context/ReferenceContextManager.ts +1 -1
  79. package/src/conversational-agent.ts +221 -254
  80. package/src/index.ts +17 -3
  81. package/src/langchain-agent.ts +130 -78
  82. package/src/mcp/ContentProcessor.ts +0 -2
  83. package/src/mcp/adapters/langchain.ts +0 -1
  84. package/src/memory/ContentStorage.ts +0 -5
  85. package/src/memory/MemoryWindow.ts +0 -1
  86. package/src/memory/ReferenceIdGenerator.ts +4 -4
  87. package/src/memory/SmartMemoryManager.ts +53 -92
  88. package/src/memory/TokenCounter.ts +4 -7
  89. package/src/plugins/hbar/AirdropToolWrapper.ts +157 -0
  90. package/src/plugins/hbar/HbarPlugin.ts +86 -0
  91. package/src/plugins/{hbar-transfer → hbar}/TransferHbarTool.ts +3 -3
  92. package/src/plugins/hbar/index.ts +3 -0
  93. package/src/plugins/index.ts +2 -1
  94. package/src/services/EntityResolver.ts +135 -0
  95. package/src/tools/EntityResolverTool.ts +170 -0
  96. package/src/types/inscription.ts +40 -0
  97. package/dist/cjs/plugins/hbar-transfer/index.d.ts +0 -1
  98. package/dist/types/plugins/hbar-transfer/index.d.ts +0 -1
  99. package/src/plugins/hbar-transfer/HbarTransferPlugin.ts +0 -66
  100. package/src/plugins/hbar-transfer/index.ts +0 -1
  101. /package/dist/cjs/plugins/{hbar-transfer → hbar}/AccountBuilder.d.ts +0 -0
  102. /package/dist/cjs/plugins/{hbar-transfer → hbar}/types.d.ts +0 -0
  103. /package/dist/types/plugins/{hbar-transfer → hbar}/AccountBuilder.d.ts +0 -0
  104. /package/dist/types/plugins/{hbar-transfer → hbar}/types.d.ts +0 -0
  105. /package/src/plugins/{hbar-transfer → hbar}/AccountBuilder.ts +0 -0
  106. /package/src/plugins/{hbar-transfer → hbar}/types.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index18.js","sources":["../../src/services/ContentStoreManager.ts"],"sourcesContent":["import { ContentStorage } from '../memory/ContentStorage';\nimport { \n ContentStoreService, \n extractReferenceId, \n shouldUseReference,\n ContentResolverRegistry,\n type ContentStoreInterface, \n type ContentResolverInterface, \n type ReferenceResolutionResult \n} from '@hashgraphonline/standards-sdk';\nimport type { ContentReferenceConfig } from '../types/content-reference';\nimport { Logger } from '@hashgraphonline/standards-sdk';\n\n/**\n * Adapter to make ContentStorage compatible with ContentStoreInterface\n */\nclass ContentStorageAdapter implements ContentStoreInterface {\n constructor(private storage: ContentStorage) {}\n\n async storeContent(content: Buffer, metadata: any) {\n const contentRef = await this.storage.storeContent(content, metadata);\n return contentRef.referenceId;\n }\n\n async resolveReference(referenceId: string): Promise<ReferenceResolutionResult> {\n const result = await this.storage.resolveReference(referenceId);\n if (result.success && result.content) {\n const response: ReferenceResolutionResult = {\n content: result.content\n };\n if (result.metadata) {\n response.metadata = {\n ...(result.metadata.mimeType !== undefined && { mimeType: result.metadata.mimeType }),\n ...(result.metadata.fileName !== undefined && { fileName: result.metadata.fileName }),\n originalSize: result.metadata.sizeBytes\n };\n }\n return response;\n } else {\n throw new Error(result.error || 'Reference not found');\n }\n }\n\n async hasReference(referenceId: string) {\n return await this.storage.hasReference(referenceId);\n }\n\n async cleanupReference(referenceId: string) {\n await this.storage.cleanupReference(referenceId);\n }\n\n async getStats() {\n return await this.storage.getStats();\n }\n\n async updateConfig(config: any) {\n return await this.storage.updateConfig(config);\n }\n\n async performCleanup() {\n await this.storage.performCleanup();\n }\n\n async dispose() {\n return Promise.resolve(this.storage.dispose());\n }\n}\n\n/**\n * Content resolver implementation for dependency injection\n */\nclass ContentResolver implements ContentResolverInterface {\n constructor(private adapter: ContentStorageAdapter) {}\n\n async resolveReference(referenceId: string): Promise<ReferenceResolutionResult> {\n return await this.adapter.resolveReference(referenceId);\n }\n\n shouldUseReference(content: string | Buffer): boolean {\n return shouldUseReference(content);\n }\n\n extractReferenceId(input: string): string | null {\n return extractReferenceId(input);\n }\n}\n\n/**\n * Manages content store lifecycle and cross-package registration\n */\nexport class ContentStoreManager {\n private contentStorage: ContentStorage;\n private adapter: ContentStorageAdapter;\n private resolver: ContentResolver;\n private logger: Logger;\n private isRegistered = false;\n\n constructor(\n maxMessageStorage: number = 1000,\n referenceConfig?: Partial<ContentReferenceConfig>,\n logger?: Logger\n ) {\n this.logger = logger || {\n info: console.log,\n debug: console.log,\n warn: console.warn,\n error: console.error\n } as Logger;\n\n this.contentStorage = new ContentStorage(maxMessageStorage, referenceConfig);\n this.adapter = new ContentStorageAdapter(this.contentStorage);\n this.resolver = new ContentResolver(this.adapter);\n }\n\n /**\n * Initialize and register content storage for cross-package access\n */\n async initialize(): Promise<void> {\n if (this.isRegistered) {\n this.logger.warn('ContentStoreManager is already initialized');\n return;\n }\n\n try {\n await ContentStoreService.setInstance(this.adapter);\n ContentResolverRegistry.register(this.resolver);\n this.isRegistered = true;\n this.logger.info('ContentStoreManager initialized and registered for cross-package access');\n } catch (error) {\n this.logger.error('Failed to initialize ContentStoreManager:', error);\n throw error;\n }\n }\n\n /**\n * Get the underlying ContentStorage instance\n */\n getContentStorage(): ContentStorage {\n return this.contentStorage;\n }\n\n /**\n * Get storage statistics\n */\n async getStats() {\n return await this.contentStorage.getStats();\n }\n\n /**\n * Update configuration\n */\n async updateConfig(config: Partial<ContentReferenceConfig>) {\n return await this.contentStorage.updateConfig(config);\n }\n\n /**\n * Perform manual cleanup\n */\n async performCleanup() {\n return await this.contentStorage.performCleanup();\n }\n\n /**\n * Check if content should be stored as reference\n */\n shouldUseReference(content: Buffer | string): boolean {\n return this.contentStorage.shouldUseReference(content);\n }\n\n /**\n * Store content if it's large enough\n */\n async storeContentIfLarge(content: Buffer | string, metadata: any) {\n return await this.contentStorage.storeContentIfLarge(content, metadata);\n }\n\n /**\n * Cleanup and unregister\n */\n async dispose(): Promise<void> {\n if (this.isRegistered) {\n this.contentStorage.dispose();\n ContentStoreService.dispose();\n ContentResolverRegistry.unregister();\n this.isRegistered = false;\n this.logger.info('ContentStoreManager disposed and unregistered');\n }\n }\n\n /**\n * Check if the manager is initialized\n */\n isInitialized(): boolean {\n return this.isRegistered;\n }\n}"],"names":[],"mappings":";;AAgBA,MAAM,sBAAuD;AAAA,EAC3D,YAAoB,SAAyB;AAAzB,SAAA,UAAA;AAAA,EAA0B;AAAA,EAE9C,MAAM,aAAa,SAAiB,UAAe;AACjD,UAAM,aAAa,MAAM,KAAK,QAAQ,aAAa,SAAS,QAAQ;AACpE,WAAO,WAAW;AAAA,EACpB;AAAA,EAEA,MAAM,iBAAiB,aAAyD;AAC9E,UAAM,SAAS,MAAM,KAAK,QAAQ,iBAAiB,WAAW;AAC9D,QAAI,OAAO,WAAW,OAAO,SAAS;AACpC,YAAM,WAAsC;AAAA,QAC1C,SAAS,OAAO;AAAA,MAAA;AAElB,UAAI,OAAO,UAAU;AACnB,iBAAS,WAAW;AAAA,UAClB,GAAI,OAAO,SAAS,aAAa,UAAa,EAAE,UAAU,OAAO,SAAS,SAAA;AAAA,UAC1E,GAAI,OAAO,SAAS,aAAa,UAAa,EAAE,UAAU,OAAO,SAAS,SAAA;AAAA,UAC1E,cAAc,OAAO,SAAS;AAAA,QAAA;AAAA,MAElC;AACA,aAAO;AAAA,IACT,OAAO;AACL,YAAM,IAAI,MAAM,OAAO,SAAS,qBAAqB;AAAA,IACvD;AAAA,EACF;AAAA,EAEA,MAAM,aAAa,aAAqB;AACtC,WAAO,MAAM,KAAK,QAAQ,aAAa,WAAW;AAAA,EACpD;AAAA,EAEA,MAAM,iBAAiB,aAAqB;AAC1C,UAAM,KAAK,QAAQ,iBAAiB,WAAW;AAAA,EACjD;AAAA,EAEA,MAAM,WAAW;AACf,WAAO,MAAM,KAAK,QAAQ,SAAA;AAAA,EAC5B;AAAA,EAEA,MAAM,aAAa,QAAa;AAC9B,WAAO,MAAM,KAAK,QAAQ,aAAa,MAAM;AAAA,EAC/C;AAAA,EAEA,MAAM,iBAAiB;AACrB,UAAM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;AAAA,EAKA,MAAM,WAAW;AACf,WAAO,MAAM,KAAK,eAAe,SAAA;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAAa,QAAyC;AAC1D,WAAO,MAAM,KAAK,eAAe,aAAa,MAAM;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,iBAAiB;AACrB,WAAO,MAAM,KAAK,eAAe,eAAA;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA,EAKA,mBAAmB,SAAmC;AACpD,WAAO,KAAK,eAAe,mBAAmB,OAAO;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,oBAAoB,SAA0B,UAAe;AACjE,WAAO,MAAM,KAAK,eAAe,oBAAoB,SAAS,QAAQ;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,UAAyB;AAC7B,QAAI,KAAK,cAAc;AACrB,WAAK,eAAe,QAAA;AACpB,0BAAoB,QAAA;AACpB,8BAAwB,WAAA;AACxB,WAAK,eAAe;AACpB,WAAK,OAAO,KAAK,+CAA+C;AAAA,IAClE;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAyB;AACvB,WAAO,KAAK;AAAA,EACd;AACF;"}
1
+ {"version":3,"file":"index18.js","sources":["../../src/plugins/hbar/TransferHbarTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { HbarTransferParams } from './types';\nimport { AccountBuilder } from './AccountBuilder';\nimport { BaseHederaTransactionTool, BaseServiceBuilder } from 'hedera-agent-kit';\n\nconst HbarTransferInputSchema = z.object({\n accountId: z\n .string()\n .describe('Account ID for the transfer (e.g., \"0.0.xxxx\").'),\n amount: z\n .union([z.number(), z.string()])\n .describe(\n 'HBAR amount in decimal format (e.g., 1 for 1 HBAR, 0.5 for 0.5 HBAR). Positive for credit, negative for debit. DO NOT multiply by 10^8 for tinybars - just use the HBAR amount directly.'\n ),\n});\n\nconst TransferHbarZodSchemaCore = z.object({\n transfers: z\n .array(HbarTransferInputSchema)\n .min(1)\n .describe(\n 'Array of transfers. For simple transfers from your operator account, just include the recipient with positive amount: [{accountId: \"0.0.800\", amount: 1}]. For complex multi-party transfers, include all parties with negative amounts for senders and positive for receivers.'\n ),\n memo: z.string().optional().describe('Optional. Memo for the transaction.'),\n});\n\n/**\n * A Hedera transaction tool for transferring HBAR between accounts.\n * Supports single and multi-party transfers with automatic balance validation.\n * Extends BaseHederaTransactionTool to handle HBAR transfer transactions on the Hedera Hashgraph.\n */\nexport class TransferHbarTool extends BaseHederaTransactionTool<\n typeof TransferHbarZodSchemaCore\n> {\n name = 'hedera-account-transfer-hbar-v2';\n description =\n 'PRIMARY TOOL FOR HBAR TRANSFERS: Transfers HBAR between accounts. For simple transfers from the operator account, just specify the recipient with a positive amount (e.g., [{accountId: \"0.0.800\", amount: 1}] to send 1 HBAR to 0.0.800). The sender will be automatically added. For multi-party transfers (e.g., \"A sends 5 HBAR to C and B sends 3 HBAR to C\"), include ALL transfers with their amounts (negative for senders, positive for receivers).';\n specificInputSchema = TransferHbarZodSchemaCore;\n namespace = 'account';\n\n\n /**\n * Creates and returns the service builder for account operations.\n * \n * @returns BaseServiceBuilder instance configured for account operations\n */\n protected getServiceBuilder(): BaseServiceBuilder {\n return new AccountBuilder(this.hederaKit) as BaseServiceBuilder;\n }\n\n /**\n * Executes the HBAR transfer using the provided builder and arguments.\n * Validates that all transfers sum to zero before execution.\n * \n * @param builder - The service builder instance for executing transactions\n * @param specificArgs - The validated transfer parameters including transfers array and optional memo\n * @returns Promise that resolves when the transfer is complete\n */\n protected async callBuilderMethod(\n builder: BaseServiceBuilder,\n specificArgs: z.infer<typeof TransferHbarZodSchemaCore>\n ): Promise<void> {\n await (builder as AccountBuilder).transferHbar(\n specificArgs as unknown as HbarTransferParams\n );\n }\n}"],"names":[],"mappings":";;;AAKA,MAAM,0BAA0B,EAAE,OAAO;AAAA,EACvC,WAAW,EACR,SACA,SAAS,iDAAiD;AAAA,EAC7D,QAAQ,EACL,MAAM,CAAC,EAAE,OAAA,GAAU,EAAE,QAAQ,CAAC,EAC9B;AAAA,IACC;AAAA,EAAA;AAEN,CAAC;AAED,MAAM,4BAA4B,EAAE,OAAO;AAAA,EACzC,WAAW,EACR,MAAM,uBAAuB,EAC7B,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,MAAM,EAAE,OAAA,EAAS,SAAA,EAAW,SAAS,qCAAqC;AAC5E,CAAC;AAOM,MAAM,yBAAyB,0BAEpC;AAAA,EAFK,cAAA;AAAA,UAAA,GAAA,SAAA;AAGL,SAAA,OAAO;AACP,SAAA,cACE;AACF,SAAA,sBAAsB;AACtB,SAAA,YAAY;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQF,oBAAwC;AAChD,WAAO,IAAI,eAAe,KAAK,SAAS;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAgB,kBACd,SACA,cACe;AACf,UAAO,QAA2B;AAAA,MAChC;AAAA,IAAA;AAAA,EAEJ;AACF;"}
@@ -1,12 +1,106 @@
1
- import { AgentExecutor } from "langchain/agents";
1
+ import { StructuredTool } from "@langchain/core/tools";
2
+ import { z } from "zod";
2
3
  import { Logger } from "@hashgraphonline/standards-sdk";
3
- class ContentAwareAgentExecutor extends AgentExecutor {
4
- constructor(config) {
5
- super(config);
6
- this.logger = new Logger({ module: "ContentAwareAgentExecutor" });
4
+ class AirdropToolWrapper extends StructuredTool {
5
+ constructor(originalTool, agentKit) {
6
+ super();
7
+ this.name = "hedera-hts-airdrop-token";
8
+ this.description = "Airdrops fungible tokens to multiple recipients. Automatically converts human-readable amounts to smallest units based on token decimals.";
9
+ this.schema = z.object({
10
+ tokenId: z.string().describe('The ID of the fungible token to airdrop (e.g., "0.0.yyyy").'),
11
+ recipients: z.array(
12
+ z.object({
13
+ accountId: z.string().describe('Recipient account ID (e.g., "0.0.xxxx").'),
14
+ amount: z.union([z.number(), z.string()]).describe(
15
+ 'Amount in human-readable format (e.g., "10" for 10 tokens).'
16
+ )
17
+ })
18
+ ).min(1).describe("Array of recipient objects, each with accountId and amount."),
19
+ memo: z.string().optional().describe("Optional. Memo for the transaction.")
20
+ });
21
+ this.originalTool = originalTool;
22
+ this.agentKit = agentKit;
23
+ this.logger = new Logger({ module: "AirdropToolWrapper" });
24
+ }
25
+ async _call(input) {
26
+ try {
27
+ this.logger.info(
28
+ `Processing airdrop request for token ${input.tokenId} with ${input.recipients.length} recipients`
29
+ );
30
+ const tokenInfo = await this.getTokenInfo(input.tokenId);
31
+ const decimals = tokenInfo.decimals || 0;
32
+ this.logger.info(`Token ${input.tokenId} has ${decimals} decimal places`);
33
+ const convertedRecipients = input.recipients.map((recipient) => {
34
+ const humanAmount = typeof recipient.amount === "string" ? parseFloat(recipient.amount) : recipient.amount;
35
+ const smallestUnitAmount = this.convertToSmallestUnits(
36
+ humanAmount,
37
+ decimals
38
+ );
39
+ this.logger.info(
40
+ `Converting amount for ${recipient.accountId}: ${humanAmount} tokens → ${smallestUnitAmount} smallest units`
41
+ );
42
+ return {
43
+ ...recipient,
44
+ amount: smallestUnitAmount.toString()
45
+ };
46
+ });
47
+ const convertedInput = {
48
+ ...input,
49
+ recipients: convertedRecipients
50
+ };
51
+ this.logger.info(`Calling original airdrop tool with converted amounts`);
52
+ return await this.originalTool._call(convertedInput);
53
+ } catch (error) {
54
+ this.logger.error("Error in airdrop tool wrapper:", error);
55
+ throw error;
56
+ }
57
+ }
58
+ convertToSmallestUnits(amount, decimals) {
59
+ return Math.floor(amount * Math.pow(10, decimals));
60
+ }
61
+ async getTokenInfo(tokenId) {
62
+ return await this.queryTokenInfo(tokenId);
63
+ }
64
+ async queryTokenInfo(tokenId) {
65
+ try {
66
+ this.logger.info("Querying token info using mirror node");
67
+ const mirrorNode = this.agentKit.mirrorNode;
68
+ if (!mirrorNode) {
69
+ this.logger.info(
70
+ "MirrorNode not found in agentKit, attempting to access via fetch"
71
+ );
72
+ const network = this.agentKit.network || "testnet";
73
+ const mirrorNodeUrl = network === "mainnet" ? "https://mainnet.mirrornode.hedera.com" : "https://testnet.mirrornode.hedera.com";
74
+ const response = await fetch(
75
+ `${mirrorNodeUrl}/api/v1/tokens/${tokenId}`
76
+ );
77
+ if (response.ok) {
78
+ const tokenData = await response.json();
79
+ const decimals = parseInt(String(tokenData.decimals || "0"));
80
+ this.logger.info(
81
+ `Token ${tokenId} found with ${decimals} decimals via API`
82
+ );
83
+ return { ...tokenData, decimals };
84
+ }
85
+ } else {
86
+ const tokenData = await mirrorNode.getTokenInfo(tokenId);
87
+ if (tokenData && typeof tokenData.decimals !== "undefined") {
88
+ const decimals = parseInt(tokenData.decimals.toString()) || 0;
89
+ this.logger.info(`Token ${tokenId} found with ${decimals} decimals`);
90
+ return { ...tokenData, decimals };
91
+ }
92
+ }
93
+ throw new Error(`Token data not found or missing decimals field`);
94
+ } catch (error) {
95
+ this.logger.warn(`Failed to query token info for ${tokenId}:`, error);
96
+ this.logger.info(
97
+ "Falling back to assumed 0 decimal places (smallest units)"
98
+ );
99
+ return { decimals: 0 };
100
+ }
7
101
  }
8
102
  }
9
103
  export {
10
- ContentAwareAgentExecutor
104
+ AirdropToolWrapper
11
105
  };
12
106
  //# sourceMappingURL=index19.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index19.js","sources":["../../src/langchain/ContentAwareAgentExecutor.ts"],"sourcesContent":["import { AgentExecutor } from 'langchain/agents';\nimport { Logger } from '@hashgraphonline/standards-sdk';\n\n/**\n * Custom AgentExecutor that intercepts large tool outputs and converts them to content references\n * before they are sent to the LLM to avoid token limit issues.\n * \n * Note: The content reference conversion is already handled in the MCP adapter,\n * so this class currently just extends AgentExecutor without modifications.\n * We keep it as a placeholder for future enhancements.\n */\nexport class ContentAwareAgentExecutor extends AgentExecutor {\n private logger: Logger;\n\n constructor(config: any) {\n super(config);\n this.logger = new Logger({ module: 'ContentAwareAgentExecutor' });\n }\n}"],"names":[],"mappings":";;AAWO,MAAM,kCAAkC,cAAc;AAAA,EAG3D,YAAY,QAAa;AACvB,UAAM,MAAM;AACZ,SAAK,SAAS,IAAI,OAAO,EAAE,QAAQ,6BAA6B;AAAA,EAClE;AACF;"}
1
+ {"version":3,"file":"index19.js","sources":["../../src/plugins/hbar/AirdropToolWrapper.ts"],"sourcesContent":["import { StructuredTool } from '@langchain/core/tools';\nimport { z } from 'zod';\nimport { HederaAgentKit } from 'hedera-agent-kit';\nimport { Logger } from '@hashgraphonline/standards-sdk';\n\ninterface TokenInfo {\n decimals: number;\n [key: string]: unknown;\n}\n\ninterface ToolWithCall {\n _call(input: unknown): Promise<string>;\n}\n\ninterface AgentKitWithMirrorNode {\n mirrorNode?: {\n getTokenInfo(tokenId: string): Promise<TokenInfo>;\n };\n network: string;\n}\n\nexport class AirdropToolWrapper extends StructuredTool {\n name = 'hedera-hts-airdrop-token';\n description =\n 'Airdrops fungible tokens to multiple recipients. Automatically converts human-readable amounts to smallest units based on token decimals.';\n\n schema = z.object({\n tokenId: z\n .string()\n .describe('The ID of the fungible token to airdrop (e.g., \"0.0.yyyy\").'),\n recipients: z\n .array(\n z.object({\n accountId: z\n .string()\n .describe('Recipient account ID (e.g., \"0.0.xxxx\").'),\n amount: z\n .union([z.number(), z.string()])\n .describe(\n 'Amount in human-readable format (e.g., \"10\" for 10 tokens).'\n ),\n })\n )\n .min(1)\n .describe('Array of recipient objects, each with accountId and amount.'),\n memo: z.string().optional().describe('Optional. Memo for the transaction.'),\n });\n\n private originalTool: StructuredTool & ToolWithCall;\n private agentKit: HederaAgentKit & AgentKitWithMirrorNode;\n private logger: Logger;\n\n constructor(originalTool: StructuredTool, agentKit: unknown) {\n super();\n this.originalTool = originalTool as StructuredTool & ToolWithCall;\n this.agentKit = agentKit as HederaAgentKit & AgentKitWithMirrorNode;\n this.logger = new Logger({ module: 'AirdropToolWrapper' });\n }\n\n async _call(input: z.infer<typeof this.schema>): Promise<string> {\n try {\n this.logger.info(\n `Processing airdrop request for token ${input.tokenId} with ${input.recipients.length} recipients`\n );\n\n const tokenInfo = await this.getTokenInfo(input.tokenId);\n const decimals = tokenInfo.decimals || 0;\n\n this.logger.info(`Token ${input.tokenId} has ${decimals} decimal places`);\n\n const convertedRecipients = input.recipients.map((recipient) => {\n const humanAmount =\n typeof recipient.amount === 'string'\n ? parseFloat(recipient.amount)\n : recipient.amount;\n const smallestUnitAmount = this.convertToSmallestUnits(\n humanAmount,\n decimals\n );\n\n this.logger.info(\n `Converting amount for ${recipient.accountId}: ${humanAmount} tokens → ${smallestUnitAmount} smallest units`\n );\n\n return {\n ...recipient,\n amount: smallestUnitAmount.toString(),\n };\n });\n\n const convertedInput = {\n ...input,\n recipients: convertedRecipients,\n };\n\n this.logger.info(`Calling original airdrop tool with converted amounts`);\n return await this.originalTool._call(convertedInput);\n } catch (error) {\n this.logger.error('Error in airdrop tool wrapper:', error);\n throw error;\n }\n }\n\n private convertToSmallestUnits(amount: number, decimals: number): number {\n return Math.floor(amount * Math.pow(10, decimals));\n }\n\n private async getTokenInfo(tokenId: string): Promise<TokenInfo> {\n return await this.queryTokenInfo(tokenId);\n }\n\n private async queryTokenInfo(tokenId: string): Promise<TokenInfo> {\n try {\n this.logger.info('Querying token info using mirror node');\n const mirrorNode = this.agentKit.mirrorNode;\n if (!mirrorNode) {\n this.logger.info(\n 'MirrorNode not found in agentKit, attempting to access via fetch'\n );\n const network = this.agentKit.network || 'testnet';\n const mirrorNodeUrl =\n network === 'mainnet'\n ? 'https://mainnet.mirrornode.hedera.com'\n : 'https://testnet.mirrornode.hedera.com';\n\n const response = await fetch(\n `${mirrorNodeUrl}/api/v1/tokens/${tokenId}`\n );\n if (response.ok) {\n const tokenData = (await response.json()) as Record<string, unknown>;\n const decimals = parseInt(String(tokenData.decimals || '0'));\n this.logger.info(\n `Token ${tokenId} found with ${decimals} decimals via API`\n );\n return { ...tokenData, decimals };\n }\n } else {\n const tokenData = await mirrorNode.getTokenInfo(tokenId);\n\n if (tokenData && typeof tokenData.decimals !== 'undefined') {\n const decimals = parseInt(tokenData.decimals.toString()) || 0;\n this.logger.info(`Token ${tokenId} found with ${decimals} decimals`);\n return { ...tokenData, decimals };\n }\n }\n\n throw new Error(`Token data not found or missing decimals field`);\n } catch (error) {\n this.logger.warn(`Failed to query token info for ${tokenId}:`, error);\n\n this.logger.info(\n 'Falling back to assumed 0 decimal places (smallest units)'\n );\n return { decimals: 0 };\n }\n }\n}\n"],"names":[],"mappings":";;;AAqBO,MAAM,2BAA2B,eAAe;AAAA,EA+BrD,YAAY,cAA8B,UAAmB;AAC3D,UAAA;AA/BF,SAAA,OAAO;AACP,SAAA,cACE;AAEF,SAAA,SAAS,EAAE,OAAO;AAAA,MAChB,SAAS,EACN,SACA,SAAS,6DAA6D;AAAA,MACzE,YAAY,EACT;AAAA,QACC,EAAE,OAAO;AAAA,UACP,WAAW,EACR,SACA,SAAS,0CAA0C;AAAA,UACtD,QAAQ,EACL,MAAM,CAAC,EAAE,OAAA,GAAU,EAAE,QAAQ,CAAC,EAC9B;AAAA,YACC;AAAA,UAAA;AAAA,QACF,CACH;AAAA,MAAA,EAEF,IAAI,CAAC,EACL,SAAS,6DAA6D;AAAA,MACzE,MAAM,EAAE,OAAA,EAAS,SAAA,EAAW,SAAS,qCAAqC;AAAA,IAAA,CAC3E;AAQC,SAAK,eAAe;AACpB,SAAK,WAAW;AAChB,SAAK,SAAS,IAAI,OAAO,EAAE,QAAQ,sBAAsB;AAAA,EAC3D;AAAA,EAEA,MAAM,MAAM,OAAqD;AAC/D,QAAI;AACF,WAAK,OAAO;AAAA,QACV,wCAAwC,MAAM,OAAO,SAAS,MAAM,WAAW,MAAM;AAAA,MAAA;AAGvF,YAAM,YAAY,MAAM,KAAK,aAAa,MAAM,OAAO;AACvD,YAAM,WAAW,UAAU,YAAY;AAEvC,WAAK,OAAO,KAAK,SAAS,MAAM,OAAO,QAAQ,QAAQ,iBAAiB;AAExE,YAAM,sBAAsB,MAAM,WAAW,IAAI,CAA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,QAAQ;AAAA,UAAA;AAEzC,iBAAO,EAAE,GAAG,WAAW,SAAA;AAAA,QACzB;AAAA,MACF,OAAO;AACL,cAAM,YAAY,MAAM,WAAW,aAAa,OAAO;AAEvD,YAAI,aAAa,OAAO,UAAU,aAAa,aAAa;AAC1D,gBAAM,WAAW,SAAS,UAAU,SAAS,SAAA,CAAU,KAAK;AAC5D,eAAK,OAAO,KAAK,SAAS,OAAO,eAAe,QAAQ,WAAW;AACnE,iBAAO,EAAE,GAAG,WAAW,SAAA;AAAA,QACzB;AAAA,MACF;AAEA,YAAM,IAAI,MAAM,gDAAgD;AAAA,IAClE,SAAS,OAAO;AACd,WAAK,OAAO,KAAK,kCAAkC,OAAO,KAAK,KAAK;AAEpE,WAAK,OAAO;AAAA,QACV;AAAA,MAAA;AAEF,aAAO,EAAE,UAAU,EAAA;AAAA,IACrB;AAAA,EACF;AACF;"}
@@ -1,177 +1,23 @@
1
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
- import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
3
- import { MCPContentProcessor } from "./index25.js";
4
- class MCPClientManager {
5
- constructor(logger, contentStorage) {
6
- this.clients = /* @__PURE__ */ new Map();
7
- this.tools = /* @__PURE__ */ new Map();
8
- this.logger = logger;
9
- if (contentStorage) {
10
- this.contentProcessor = new MCPContentProcessor(contentStorage, logger);
11
- }
12
- }
13
- /**
14
- * Connect to an MCP server and discover its tools
15
- */
16
- async connectServer(config) {
17
- try {
18
- if (this.isServerConnected(config.name)) {
19
- return {
20
- serverName: config.name,
21
- connected: false,
22
- error: `Server ${config.name} is already connected`,
23
- tools: []
24
- };
25
- }
26
- if (config.transport && config.transport !== "stdio") {
27
- throw new Error(`Transport ${config.transport} not yet supported`);
28
- }
29
- const transport = new StdioClientTransport({
30
- command: config.command,
31
- args: config.args,
32
- ...config.env && { env: config.env }
33
- });
34
- const client = new Client({
35
- name: `conversational-agent-${config.name}`,
36
- version: "1.0.0"
37
- }, {
38
- capabilities: {}
39
- });
40
- await client.connect(transport);
41
- this.clients.set(config.name, client);
42
- const toolsResponse = await client.listTools();
43
- const toolsWithServer = toolsResponse.tools.map((tool) => ({
44
- ...tool,
45
- serverName: config.name
46
- }));
47
- this.tools.set(config.name, toolsWithServer);
48
- this.logger.info(`Connected to MCP server ${config.name} with ${toolsWithServer.length} tools`);
49
- return {
50
- serverName: config.name,
51
- connected: true,
52
- tools: toolsWithServer
53
- };
54
- } catch (error) {
55
- this.logger.error(`Failed to connect to MCP server ${config.name}:`, error);
56
- return {
57
- serverName: config.name,
58
- connected: false,
59
- error: error instanceof Error ? error.message : "Unknown error",
60
- tools: []
61
- };
62
- }
63
- }
64
- /**
65
- * Execute a tool on a specific MCP server
66
- */
67
- async executeTool(serverName, toolName, args) {
68
- const client = this.clients.get(serverName);
69
- if (!client) {
70
- throw new Error(`MCP server ${serverName} not connected`);
71
- }
72
- this.logger.debug(`Executing MCP tool ${toolName} on server ${serverName}`, args);
73
- try {
74
- const result = await client.callTool({
75
- name: toolName,
76
- arguments: args
77
- });
78
- if (this.contentProcessor) {
79
- const processed = await this.contentProcessor.processResponse(result, serverName, toolName);
80
- if (processed.wasProcessed) {
81
- this.logger.debug(
82
- `Processed MCP response from ${serverName}::${toolName}`,
83
- {
84
- referenceCreated: processed.referenceCreated,
85
- originalSize: processed.originalSize,
86
- errors: processed.errors
87
- }
88
- );
89
- if (processed.errors && processed.errors.length > 0) {
90
- this.logger.warn(`Content processing warnings for ${serverName}::${toolName}:`, processed.errors);
91
- }
92
- }
93
- return processed.content;
94
- }
95
- return result;
96
- } catch (error) {
97
- this.logger.error(`Error executing MCP tool ${toolName}:`, error);
98
- throw error;
99
- }
100
- }
101
- /**
102
- * Disconnect all MCP servers
103
- */
104
- async disconnectAll() {
105
- for (const [name, client] of this.clients) {
106
- try {
107
- await client.close();
108
- this.logger.info(`Disconnected from MCP server ${name}`);
109
- } catch (error) {
110
- this.logger.error(`Error disconnecting MCP server ${name}:`, error);
111
- }
112
- }
113
- this.clients.clear();
114
- this.tools.clear();
115
- }
116
- /**
117
- * Get all discovered tools from all connected servers
118
- */
119
- getAllTools() {
120
- const allTools = [];
121
- for (const tools of this.tools.values()) {
122
- allTools.push(...tools);
123
- }
124
- return allTools;
125
- }
126
- /**
127
- * Get tools from a specific server
128
- */
129
- getServerTools(serverName) {
130
- return this.tools.get(serverName) || [];
131
- }
132
- /**
133
- * Check if a server is connected
134
- */
135
- isServerConnected(serverName) {
136
- return this.clients.has(serverName);
137
- }
138
- /**
139
- * Get list of connected server names
140
- */
141
- getConnectedServers() {
142
- return Array.from(this.clients.keys());
143
- }
144
- /**
145
- * Enable content processing with content storage
146
- */
147
- enableContentProcessing(contentStorage) {
148
- this.contentProcessor = new MCPContentProcessor(contentStorage, this.logger);
149
- this.logger.info("Content processing enabled for MCP responses");
150
- }
151
- /**
152
- * Disable content processing
153
- */
154
- disableContentProcessing() {
155
- delete this.contentProcessor;
156
- this.logger.info("Content processing disabled for MCP responses");
157
- }
158
- /**
159
- * Check if content processing is enabled
160
- */
161
- isContentProcessingEnabled() {
162
- return this.contentProcessor !== void 0;
163
- }
164
- /**
165
- * Analyze a response without processing it (for testing/debugging)
166
- */
167
- analyzeResponseContent(response) {
168
- if (!this.contentProcessor) {
169
- throw new Error("Content processing is not enabled");
170
- }
171
- return this.contentProcessor.analyzeResponse(response);
172
- }
173
- }
1
+ const getSystemMessage = (accountId) => `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, content inscription, and Hedera Hashgraph operations.
2
+
3
+ You have access to tools for:
4
+ - HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages
5
+ - HCS-2: creating registries, registering entries, updating entries, deleting entries, migrating registries, and querying registry contents
6
+ - Inscription: inscribing content from URLs, files, or buffers, creating Hashinal NFTs, and retrieving inscriptions
7
+ - Hedera Token Service (HTS): creating tokens, transferring tokens, airdropping tokens, and managing token operations
8
+
9
+ *** IMPORTANT CONTEXT ***
10
+ You are currently operating as agent: ${accountId} on the Hashgraph Online network
11
+ When users ask about "my profile", "my account", "my connections", etc., use this account ID: ${accountId}
12
+
13
+ *** CRITICAL ENTITY HANDLING RULES ***
14
+ - When users refer to entities (tokens, topics, accounts) with pronouns like "it", "that", "the token/topic", etc., ALWAYS use the most recently created entity of that type
15
+ - Entity IDs look like "0.0.XXXXXX" and are stored in memory after creation
16
+ - NEVER use example or placeholder IDs like "0.0.123456" - always use actual created entity IDs
17
+ - Account ID ${accountId} is NOT a token - tokens and accounts are different entities
18
+
19
+ Remember the connection numbers when listing connections, as users might refer to them.`;
174
20
  export {
175
- MCPClientManager
21
+ getSystemMessage
176
22
  };
177
23
  //# sourceMappingURL=index20.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index20.js","sources":["../../src/mcp/MCPClientManager.ts"],"sourcesContent":["import { Client } from '@modelcontextprotocol/sdk/client/index.js';\nimport { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';\nimport type { MCPServerConfig, MCPToolInfo, MCPConnectionStatus } from './types';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport type { ContentStorage } from '../memory/ContentStorage';\nimport { MCPContentProcessor, ProcessedResponse } from './ContentProcessor';\n\n/**\n * Manages connections to MCP servers and tool discovery\n */\nexport class MCPClientManager {\n private clients: Map<string, Client> = new Map();\n private tools: Map<string, MCPToolInfo[]> = new Map();\n private logger: Logger;\n private contentProcessor?: MCPContentProcessor;\n\n constructor(logger: Logger, contentStorage?: ContentStorage) {\n this.logger = logger;\n if (contentStorage) {\n this.contentProcessor = new MCPContentProcessor(contentStorage, logger);\n }\n }\n\n /**\n * Connect to an MCP server and discover its tools\n */\n async connectServer(config: MCPServerConfig): Promise<MCPConnectionStatus> {\n try {\n if (this.isServerConnected(config.name)) {\n return {\n serverName: config.name,\n connected: false,\n error: `Server ${config.name} is already connected`,\n tools: [],\n };\n }\n\n if (config.transport && config.transport !== 'stdio') {\n throw new Error(`Transport ${config.transport} not yet supported`);\n }\n\n const transport = new StdioClientTransport({\n command: config.command,\n args: config.args,\n ...(config.env && { env: config.env }),\n });\n\n const client = new Client({\n name: `conversational-agent-${config.name}`,\n version: '1.0.0',\n }, {\n capabilities: {},\n });\n\n await client.connect(transport);\n this.clients.set(config.name, client);\n\n const toolsResponse = await client.listTools();\n const toolsWithServer: MCPToolInfo[] = toolsResponse.tools.map(tool => ({\n ...tool,\n serverName: config.name,\n }));\n\n this.tools.set(config.name, toolsWithServer);\n this.logger.info(`Connected to MCP server ${config.name} with ${toolsWithServer.length} tools`);\n\n return {\n serverName: config.name,\n connected: true,\n tools: toolsWithServer,\n };\n } catch (error) {\n this.logger.error(`Failed to connect to MCP server ${config.name}:`, error);\n return {\n serverName: config.name,\n connected: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n tools: [],\n };\n }\n }\n\n /**\n * Execute a tool on a specific MCP server\n */\n async executeTool(serverName: string, toolName: string, args: Record<string, unknown>): Promise<unknown> {\n const client = this.clients.get(serverName);\n if (!client) {\n throw new Error(`MCP server ${serverName} not connected`);\n }\n\n this.logger.debug(`Executing MCP tool ${toolName} on server ${serverName}`, args);\n\n try {\n const result = await client.callTool({\n name: toolName,\n arguments: args,\n });\n\n if (this.contentProcessor) {\n const processed = await this.contentProcessor.processResponse(result, serverName, toolName);\n \n if (processed.wasProcessed) {\n this.logger.debug(\n `Processed MCP response from ${serverName}::${toolName}`,\n {\n referenceCreated: processed.referenceCreated,\n originalSize: processed.originalSize,\n errors: processed.errors\n }\n );\n\n if (processed.errors && processed.errors.length > 0) {\n this.logger.warn(`Content processing warnings for ${serverName}::${toolName}:`, processed.errors);\n }\n }\n\n return processed.content;\n }\n\n return result;\n } catch (error) {\n this.logger.error(`Error executing MCP tool ${toolName}:`, error);\n throw error;\n }\n }\n\n /**\n * Disconnect all MCP servers\n */\n async disconnectAll(): Promise<void> {\n for (const [name, client] of this.clients) {\n try {\n await client.close();\n this.logger.info(`Disconnected from MCP server ${name}`);\n } catch (error) {\n this.logger.error(`Error disconnecting MCP server ${name}:`, error);\n }\n }\n this.clients.clear();\n this.tools.clear();\n }\n\n /**\n * Get all discovered tools from all connected servers\n */\n getAllTools(): MCPToolInfo[] {\n const allTools: MCPToolInfo[] = [];\n for (const tools of this.tools.values()) {\n allTools.push(...tools);\n }\n return allTools;\n }\n\n /**\n * Get tools from a specific server\n */\n getServerTools(serverName: string): MCPToolInfo[] {\n return this.tools.get(serverName) || [];\n }\n\n /**\n * Check if a server is connected\n */\n isServerConnected(serverName: string): boolean {\n return this.clients.has(serverName);\n }\n\n /**\n * Get list of connected server names\n */\n getConnectedServers(): string[] {\n return Array.from(this.clients.keys());\n }\n\n /**\n * Enable content processing with content storage\n */\n enableContentProcessing(contentStorage: ContentStorage): void {\n this.contentProcessor = new MCPContentProcessor(contentStorage, this.logger);\n this.logger.info('Content processing enabled for MCP responses');\n }\n\n /**\n * Disable content processing\n */\n disableContentProcessing(): void {\n delete this.contentProcessor;\n this.logger.info('Content processing disabled for MCP responses');\n }\n\n /**\n * Check if content processing is enabled\n */\n isContentProcessingEnabled(): boolean {\n return this.contentProcessor !== undefined;\n }\n\n /**\n * Analyze a response without processing it (for testing/debugging)\n */\n analyzeResponseContent(response: unknown): unknown {\n if (!this.contentProcessor) {\n throw new Error('Content processing is not enabled');\n }\n return this.contentProcessor.analyzeResponse(response);\n }\n}"],"names":[],"mappings":";;;AAUO,MAAM,iBAAiB;AAAA,EAM5B,YAAY,QAAgB,gBAAiC;AAL7D,SAAQ,8BAAmC,IAAA;AAC3C,SAAQ,4BAAwC,IAAA;AAK9C,SAAK,SAAS;AACd,QAAI,gBAAgB;AAClB,WAAK,mBAAmB,IAAI,oBAAoB,gBAAgB,MAAM;AAAA,IACxE;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,cAAc,QAAuD;AACzE,QAAI;AACF,UAAI,KAAK,kBAAkB,OAAO,IAAI,GAAG;AACvC,eAAO;AAAA,UACL,YAAY,OAAO;AAAA,UACn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AA0B,CAAA;AAChC,eAAW,SAAS,KAAK,MAAM,OAAA,GAAU;AACvC,eAAS,KAAK,GAAG,KAAK;AAAA,IACxB;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,eAAe,YAAmC;AAChD,WAAO,KAAK,MAAM,IAAI,UAAU,KAAK,CAAA;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAkB,YAA6B;AAC7C,WAAO,KAAK,QAAQ,IAAI,UAAU;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA,EAKA,sBAAgC;AAC9B,WAAO,MAAM,KAAK,KAAK,QAAQ,MAAM;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA,EAKA,wBAAwB,gBAAsC;AAC5D,SAAK,mBAAmB,IAAI,oBAAoB,gBAAgB,KAAK,MAAM;AAC3E,SAAK,OAAO,KAAK,8CAA8C;AAAA,EACjE;AAAA;AAAA;AAAA;AAAA,EAKA,2BAAiC;AAC/B,WAAO,KAAK;AACZ,SAAK,OAAO,KAAK,+CAA+C;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA,EAKA,6BAAsC;AACpC,WAAO,KAAK,qBAAqB;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA,EAKA,uBAAuB,UAA4B;AACjD,QAAI,CAAC,KAAK,kBAAkB;AAC1B,YAAM,IAAI,MAAM,mCAAmC;AAAA,IACrD;AACA,WAAO,KAAK,iBAAiB,gBAAgB,QAAQ;AAAA,EACvD;AACF;"}
1
+ {"version":3,"file":"index20.js","sources":["../../src/config/system-message.ts"],"sourcesContent":["export const getSystemMessage = (\n accountId: string\n): string => `You are a helpful assistant managing Hashgraph Online HCS-10 connections, messages, HCS-2 registries, content inscription, and Hedera Hashgraph operations.\n\nYou have access to tools for:\n- HCS-10: registering agents, finding registered agents, initiating connections, listing active connections, sending messages over connections, and checking for new messages\n- HCS-2: creating registries, registering entries, updating entries, deleting entries, migrating registries, and querying registry contents\n- Inscription: inscribing content from URLs, files, or buffers, creating Hashinal NFTs, and retrieving inscriptions\n- Hedera Token Service (HTS): creating tokens, transferring tokens, airdropping tokens, and managing token operations\n\n*** IMPORTANT CONTEXT ***\nYou are currently operating as agent: ${accountId} on the Hashgraph Online network\nWhen users ask about \"my profile\", \"my account\", \"my connections\", etc., use this account ID: ${accountId}\n\n*** CRITICAL ENTITY HANDLING RULES ***\n- When users refer to entities (tokens, topics, accounts) with pronouns like \"it\", \"that\", \"the token/topic\", etc., ALWAYS use the most recently created entity of that type\n- Entity IDs look like \"0.0.XXXXXX\" and are stored in memory after creation\n- NEVER use example or placeholder IDs like \"0.0.123456\" - always use actual created entity IDs\n- Account ID ${accountId} is NOT a token - tokens and accounts are different entities\n\nRemember the connection numbers when listing connections, as users might refer to them.`;\n"],"names":[],"mappings":"AAAO,MAAM,mBAAmB,CAC9B,cACW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAS2B,SAAS;AAAA,gGAC+C,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAM1F,SAAS;AAAA;AAAA;"}
@@ -1,156 +1,12 @@
1
- import { DynamicStructuredTool } from "@langchain/core/tools";
2
- import { z } from "zod";
3
- import { shouldUseReference, ContentStoreService } from "@hashgraphonline/standards-sdk";
4
- function convertMCPToolToLangChain(tool, mcpManager, serverConfig) {
5
- const zodSchema = jsonSchemaToZod(tool.inputSchema);
6
- const sanitizedName = `${tool.serverName}_${tool.name}`.replace(
7
- /[^a-zA-Z0-9_]/g,
8
- "_"
9
- );
10
- let description = tool.description || `MCP tool ${tool.name} from ${tool.serverName}`;
11
- if (serverConfig?.toolDescriptions?.[tool.name]) {
12
- description = `${description}
13
-
14
- ${serverConfig.toolDescriptions[tool.name]}`;
1
+ import { AgentExecutor } from "langchain/agents";
2
+ import { Logger } from "@hashgraphonline/standards-sdk";
3
+ class ContentAwareAgentExecutor extends AgentExecutor {
4
+ constructor(config) {
5
+ super(config);
6
+ this.logger = new Logger({ module: "ContentAwareAgentExecutor" });
15
7
  }
16
- if (serverConfig?.additionalContext) {
17
- description = `${description}
18
-
19
- Context: ${serverConfig.additionalContext}`;
20
- }
21
- return new DynamicStructuredTool({
22
- name: sanitizedName,
23
- description,
24
- schema: zodSchema,
25
- func: async (input) => {
26
- try {
27
- const result = await mcpManager.executeTool(
28
- tool.serverName,
29
- tool.name,
30
- input
31
- );
32
- let responseText = "";
33
- if (typeof result === "string") {
34
- responseText = result;
35
- } else if (result && typeof result === "object" && "content" in result) {
36
- const content = result.content;
37
- if (Array.isArray(content)) {
38
- const textParts = content.filter(
39
- (item) => typeof item === "object" && item !== null && "type" in item && item.type === "text" && "text" in item
40
- ).map((item) => item.text);
41
- responseText = textParts.join("\n");
42
- } else {
43
- responseText = JSON.stringify(content);
44
- }
45
- } else {
46
- responseText = JSON.stringify(result);
47
- }
48
- const responseBuffer = Buffer.from(responseText, "utf8");
49
- const MCP_REFERENCE_THRESHOLD = 10 * 1024;
50
- const shouldStoreMCPContent = responseBuffer.length > MCP_REFERENCE_THRESHOLD;
51
- if (shouldStoreMCPContent || shouldUseReference(responseBuffer)) {
52
- const contentStore = ContentStoreService.getInstance();
53
- if (contentStore) {
54
- try {
55
- const referenceId = await contentStore.storeContent(responseBuffer, {
56
- contentType: "text",
57
- source: "mcp",
58
- mcpToolName: `${tool.serverName}_${tool.name}`,
59
- originalSize: responseBuffer.length
60
- });
61
- return `content-ref:${referenceId}`;
62
- } catch (storeError) {
63
- console.warn("Failed to store large MCP content as reference:", storeError);
64
- }
65
- }
66
- }
67
- return responseText;
68
- } catch (error) {
69
- const errorMessage = error instanceof Error ? error.message : "Unknown error";
70
- return `Error executing MCP tool ${tool.name}: ${errorMessage}`;
71
- }
72
- }
73
- });
74
- }
75
- function jsonSchemaToZod(schema) {
76
- if (!schema || typeof schema !== "object") {
77
- return z.object({});
78
- }
79
- const schemaObj = schema;
80
- if (schemaObj.type && schemaObj.type !== "object") {
81
- return convertType(schemaObj);
82
- }
83
- if (!schemaObj.properties || typeof schemaObj.properties !== "object") {
84
- return z.object({});
85
- }
86
- const shape = {};
87
- for (const [key, value] of Object.entries(schemaObj.properties)) {
88
- let zodType = convertType(value);
89
- const isRequired = Array.isArray(schemaObj.required) && schemaObj.required.includes(key);
90
- if (!isRequired) {
91
- zodType = zodType.optional();
92
- }
93
- shape[key] = zodType;
94
- }
95
- return z.object(shape);
96
- }
97
- function convertType(schema) {
98
- if (!schema || typeof schema !== "object" || !("type" in schema)) {
99
- return z.unknown();
100
- }
101
- const schemaObj = schema;
102
- let zodType;
103
- switch (schemaObj.type) {
104
- case "string":
105
- zodType = z.string();
106
- if (schemaObj.enum && Array.isArray(schemaObj.enum)) {
107
- zodType = z.enum(schemaObj.enum);
108
- }
109
- break;
110
- case "number":
111
- zodType = z.number();
112
- if ("minimum" in schemaObj && typeof schemaObj.minimum === "number") {
113
- zodType = zodType.min(schemaObj.minimum);
114
- }
115
- if ("maximum" in schemaObj && typeof schemaObj.maximum === "number") {
116
- zodType = zodType.max(schemaObj.maximum);
117
- }
118
- break;
119
- case "integer":
120
- zodType = z.number().int();
121
- if ("minimum" in schemaObj && typeof schemaObj.minimum === "number") {
122
- zodType = zodType.min(schemaObj.minimum);
123
- }
124
- if ("maximum" in schemaObj && typeof schemaObj.maximum === "number") {
125
- zodType = zodType.max(schemaObj.maximum);
126
- }
127
- break;
128
- case "boolean":
129
- zodType = z.boolean();
130
- break;
131
- case "array":
132
- if (schemaObj.items) {
133
- zodType = z.array(convertType(schemaObj.items));
134
- } else {
135
- zodType = z.array(z.unknown());
136
- }
137
- break;
138
- case "object":
139
- if ("properties" in schemaObj) {
140
- zodType = jsonSchemaToZod(schemaObj);
141
- } else {
142
- zodType = z.object({}).passthrough();
143
- }
144
- break;
145
- default:
146
- zodType = z.unknown();
147
- }
148
- if ("description" in schemaObj && typeof schemaObj.description === "string") {
149
- zodType = zodType.describe(schemaObj.description);
150
- }
151
- return zodType;
152
8
  }
153
9
  export {
154
- convertMCPToolToLangChain
10
+ ContentAwareAgentExecutor
155
11
  };
156
12
  //# sourceMappingURL=index21.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index21.js","sources":["../../src/mcp/adapters/langchain.ts"],"sourcesContent":["import { DynamicStructuredTool } from '@langchain/core/tools';\nimport { z } from 'zod';\nimport type { MCPToolInfo, MCPServerConfig } from '../types';\nimport type { MCPClientManager } from '../MCPClientManager';\nimport { ContentStoreService, shouldUseReference } from '@hashgraphonline/standards-sdk';\nimport type { ContentSource } from '../../types/content-reference';\n\n/**\n * Convert an MCP tool to a LangChain DynamicStructuredTool\n */\nexport function convertMCPToolToLangChain(\n tool: MCPToolInfo,\n mcpManager: MCPClientManager,\n serverConfig?: MCPServerConfig\n): DynamicStructuredTool {\n const zodSchema = jsonSchemaToZod(tool.inputSchema);\n\n const sanitizedName = `${tool.serverName}_${tool.name}`.replace(\n /[^a-zA-Z0-9_]/g,\n '_'\n );\n\n let description = tool.description || `MCP tool ${tool.name} from ${tool.serverName}`;\n \n if (serverConfig?.toolDescriptions?.[tool.name]) {\n description = `${description}\\n\\n${serverConfig.toolDescriptions[tool.name]}`;\n }\n \n if (serverConfig?.additionalContext) {\n description = `${description}\\n\\nContext: ${serverConfig.additionalContext}`;\n }\n\n return new DynamicStructuredTool({\n name: sanitizedName,\n description,\n schema: zodSchema,\n func: async (input) => {\n try {\n const result = await mcpManager.executeTool(\n tool.serverName,\n tool.name,\n input\n );\n\n let responseText = '';\n \n if (typeof result === 'string') {\n responseText = result;\n } else if (\n result &&\n typeof result === 'object' &&\n 'content' in result\n ) {\n const content = (result as { content: unknown }).content;\n if (Array.isArray(content)) {\n const textParts = content\n .filter(\n (item): item is { type: string; text: string } =>\n typeof item === 'object' &&\n item !== null &&\n 'type' in item &&\n item.type === 'text' &&\n 'text' in item\n )\n .map((item) => item.text);\n responseText = textParts.join('\\n');\n } else {\n responseText = JSON.stringify(content);\n }\n } else {\n responseText = JSON.stringify(result);\n }\n\n const responseBuffer = Buffer.from(responseText, 'utf8');\n \n const MCP_REFERENCE_THRESHOLD = 10 * 1024;\n const shouldStoreMCPContent = responseBuffer.length > MCP_REFERENCE_THRESHOLD;\n \n if (shouldStoreMCPContent || shouldUseReference(responseBuffer)) {\n const contentStore = ContentStoreService.getInstance();\n if (contentStore) {\n try {\n const referenceId = await contentStore.storeContent(responseBuffer, {\n contentType: 'text' as ContentSource,\n source: 'mcp',\n mcpToolName: `${tool.serverName}_${tool.name}`,\n originalSize: responseBuffer.length\n });\n return `content-ref:${referenceId}`;\n } catch (storeError) {\n console.warn('Failed to store large MCP content as reference:', storeError);\n }\n }\n }\n\n return responseText;\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'Unknown error';\n return `Error executing MCP tool ${tool.name}: ${errorMessage}`;\n }\n },\n });\n}\n\n/**\n * Convert JSON Schema to Zod schema\n * This is a simplified converter that handles common cases\n */\nfunction jsonSchemaToZod(schema: unknown): z.ZodTypeAny {\n if (!schema || typeof schema !== 'object') {\n return z.object({});\n }\n\n const schemaObj = schema as Record<string, unknown>;\n\n if (schemaObj.type && schemaObj.type !== 'object') {\n return convertType(schemaObj);\n }\n\n if (!schemaObj.properties || typeof schemaObj.properties !== 'object') {\n return z.object({});\n }\n\n const shape: Record<string, z.ZodTypeAny> = {};\n\n for (const [key, value] of Object.entries(schemaObj.properties)) {\n let zodType = convertType(value);\n\n const isRequired =\n Array.isArray(schemaObj.required) && schemaObj.required.includes(key);\n if (!isRequired) {\n zodType = zodType.optional();\n }\n\n shape[key] = zodType;\n }\n\n return z.object(shape);\n}\n\n/**\n * Convert a single JSON Schema type to Zod\n */\nfunction convertType(schema: unknown): z.ZodTypeAny {\n if (!schema || typeof schema !== 'object' || !('type' in schema)) {\n return z.unknown();\n }\n\n const schemaObj = schema as {\n type: string;\n enum?: unknown[];\n items?: unknown;\n };\n let zodType: z.ZodTypeAny;\n\n switch (schemaObj.type) {\n case 'string':\n zodType = z.string();\n if (schemaObj.enum && Array.isArray(schemaObj.enum)) {\n zodType = z.enum(schemaObj.enum as [string, ...string[]]);\n }\n break;\n\n case 'number':\n zodType = z.number();\n if ('minimum' in schemaObj && typeof schemaObj.minimum === 'number') {\n zodType = (zodType as z.ZodNumber).min(schemaObj.minimum);\n }\n if ('maximum' in schemaObj && typeof schemaObj.maximum === 'number') {\n zodType = (zodType as z.ZodNumber).max(schemaObj.maximum);\n }\n break;\n\n case 'integer':\n zodType = z.number().int();\n if ('minimum' in schemaObj && typeof schemaObj.minimum === 'number') {\n zodType = (zodType as z.ZodNumber).min(schemaObj.minimum);\n }\n if ('maximum' in schemaObj && typeof schemaObj.maximum === 'number') {\n zodType = (zodType as z.ZodNumber).max(schemaObj.maximum);\n }\n break;\n\n case 'boolean':\n zodType = z.boolean();\n break;\n\n case 'array':\n if (schemaObj.items) {\n zodType = z.array(convertType(schemaObj.items));\n } else {\n zodType = z.array(z.unknown());\n }\n break;\n\n case 'object':\n if ('properties' in schemaObj) {\n zodType = jsonSchemaToZod(schemaObj);\n } else {\n zodType = z.object({}).passthrough();\n }\n break;\n\n default:\n zodType = z.unknown();\n }\n\n if ('description' in schemaObj && typeof schemaObj.description === 'string') {\n zodType = zodType.describe(schemaObj.description);\n }\n\n return zodType;\n}\n"],"names":[],"mappings":";;;AAUO,SAAS,0BACd,MACA,YACA,cACuB;AACvB,QAAM,YAAY,gBAAgB,KAAK,WAAW;AAElD,QAAM,gBAAgB,GAAG,KAAK,UAAU,IAAI,KAAK,IAAI,GAAG;AAAA,IACtD;AAAA,IACA;AAAA,EAAA;AAGF,MAAI,cAAc,KAAK,eAAe,YAAY,KAAK,IAAI,SAAS,KAAK,UAAU;AAEnF,MAAI,cAAc,mBAAmB,KAAK,IAAI,GAAG;AAC/C,kBAAc,GAAG,WAAW;AAAA;AAAA,EAAO,aAAa,iBAAiB,KAAK,IAAI,CAAC;AAAA,EAC7E;AAEA,MAAI,cAAc,mBAAmB;AACnC,kBAAc,GAAG,WAAW;AAAA;AAAA,WAAgB,aAAa,iBAAiB;AAAA,EAC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AI,UAAU,OAAO;AAAA,MAC1D;AACA,UAAI,aAAa,aAAa,OAAO,UAAU,YAAY,UAAU;AACnE,kBAAW,QAAwB,IAAI,UAAU,OAAO;AAAA,MAC1D;AACA;AAAA,IAEF,KAAK;AACH,gBAAU,EAAE,OAAA,EAAS,IAAA;AACrB,UAAI,aAAa,aAAa,OAAO,UAAU,YAAY,UAAU;AACnE,kBAAW,QAAwB,IAAI,UAAU,OAAO;AAAA,MAC1D;AACA,UAAI,aAAa,aAAa,OAAO,UAAU,YAAY,UAAU;AACnE,kBAAW,QAAwB,IAAI,UAAU,OAAO;AAAA,MAC1D;AACA;AAAA,IAEF,KAAK;AACH,gBAAU,EAAE,QAAA;AACZ;AAAA,IAEF,KAAK;AACH,UAAI,UAAU,OAAO;AACnB,kBAAU,EAAE,MAAM,YAAY,UAAU,KAAK,CAAC;AAAA,MAChD,OAAO;AACL,kBAAU,EAAE,MAAM,EAAE,QAAA,CAAS;AAAA,MAC/B;AACA;AAAA,IAEF,KAAK;AACH,UAAI,gBAAgB,WAAW;AAC7B,kBAAU,gBAAgB,SAAS;AAAA,MACrC,OAAO;AACL,kBAAU,EAAE,OAAO,CAAA,CAAE,EAAE,YAAA;AAAA,MACzB;AACA;AAAA,IAEF;AACE,gBAAU,EAAE,QAAA;AAAA,EAAQ;AAGxB,MAAI,iBAAiB,aAAa,OAAO,UAAU,gBAAgB,UAAU;AAC3E,cAAU,QAAQ,SAAS,UAAU,WAAW;AAAA,EAClD;AAEA,SAAO;AACT;"}
1
+ {"version":3,"file":"index21.js","sources":["../../src/langchain/ContentAwareAgentExecutor.ts"],"sourcesContent":["import { AgentExecutor } from 'langchain/agents';\nimport { Logger } from '@hashgraphonline/standards-sdk';\n\n/**\n * Custom AgentExecutor that intercepts large tool outputs and converts them to content references\n * before they are sent to the LLM to avoid token limit issues.\n * \n * Note: The content reference conversion is already handled in the MCP adapter,\n * so this class currently just extends AgentExecutor without modifications.\n * We keep it as a placeholder for future enhancements.\n */\nexport class ContentAwareAgentExecutor extends AgentExecutor {\n private logger: Logger;\n\n constructor(config: any) {\n super(config);\n this.logger = new Logger({ module: 'ContentAwareAgentExecutor' });\n }\n}"],"names":[],"mappings":";;AAWO,MAAM,kCAAkC,cAAc;AAAA,EAG3D,YAAY,QAAa;AACvB,UAAM,MAAM;AACZ,SAAK,SAAS,IAAI,OAAO,EAAE,QAAQ,6BAA6B;AAAA,EAClE;AACF;"}