@hashgraphonline/standards-agent-kit 0.2.112 → 0.2.113

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 (126) hide show
  1. package/dist/cjs/index.d.ts +1 -1
  2. package/dist/cjs/standards-agent-kit.cjs +1 -1
  3. package/dist/cjs/standards-agent-kit.cjs.map +1 -1
  4. package/dist/cjs/tools/hcs6/CreateDynamicRegistryTool.d.ts +44 -0
  5. package/dist/cjs/tools/hcs6/QueryDynamicRegistryTool.d.ts +50 -0
  6. package/dist/cjs/tools/hcs6/RegisterDynamicHashinalTool.d.ts +102 -0
  7. package/dist/cjs/tools/hcs6/UpdateDynamicHashinalTool.d.ts +96 -0
  8. package/dist/cjs/tools/hcs6/base-hcs6-tools.d.ts +28 -0
  9. package/dist/cjs/tools/hcs6/hcs6-tool-params.d.ts +18 -0
  10. package/dist/cjs/tools/hcs6/index.d.ts +6 -0
  11. package/dist/cjs/tools/index.d.ts +1 -0
  12. package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +4 -4
  13. package/dist/es/index.d.ts +1 -1
  14. package/dist/es/standards-agent-kit.es.js +44 -31
  15. package/dist/es/standards-agent-kit.es.js.map +1 -1
  16. package/dist/es/standards-agent-kit.es10.js +27 -27
  17. package/dist/es/standards-agent-kit.es10.js.map +1 -1
  18. package/dist/es/standards-agent-kit.es11.js +20 -30
  19. package/dist/es/standards-agent-kit.es11.js.map +1 -1
  20. package/dist/es/standards-agent-kit.es12.js +27 -37
  21. package/dist/es/standards-agent-kit.es12.js.map +1 -1
  22. package/dist/es/standards-agent-kit.es13.js +48 -60
  23. package/dist/es/standards-agent-kit.es13.js.map +1 -1
  24. package/dist/es/standards-agent-kit.es14.js +60 -23
  25. package/dist/es/standards-agent-kit.es14.js.map +1 -1
  26. package/dist/es/standards-agent-kit.es15.js +23 -23
  27. package/dist/es/standards-agent-kit.es15.js.map +1 -1
  28. package/dist/es/standards-agent-kit.es16.js +23 -33
  29. package/dist/es/standards-agent-kit.es16.js.map +1 -1
  30. package/dist/es/standards-agent-kit.es17.js +34 -10
  31. package/dist/es/standards-agent-kit.es17.js.map +1 -1
  32. package/dist/es/standards-agent-kit.es18.js +16 -155
  33. package/dist/es/standards-agent-kit.es18.js.map +1 -1
  34. package/dist/es/standards-agent-kit.es19.js +150 -22
  35. package/dist/es/standards-agent-kit.es19.js.map +1 -1
  36. package/dist/es/standards-agent-kit.es20.js +25 -39
  37. package/dist/es/standards-agent-kit.es20.js.map +1 -1
  38. package/dist/es/standards-agent-kit.es21.js +26 -28
  39. package/dist/es/standards-agent-kit.es21.js.map +1 -1
  40. package/dist/es/standards-agent-kit.es22.js +16 -19
  41. package/dist/es/standards-agent-kit.es22.js.map +1 -1
  42. package/dist/es/standards-agent-kit.es23.js +21 -15
  43. package/dist/es/standards-agent-kit.es23.js.map +1 -1
  44. package/dist/es/standards-agent-kit.es24.js +18 -21
  45. package/dist/es/standards-agent-kit.es24.js.map +1 -1
  46. package/dist/es/standards-agent-kit.es25.js +35 -32
  47. package/dist/es/standards-agent-kit.es25.js.map +1 -1
  48. package/dist/es/standards-agent-kit.es26.js +38 -25
  49. package/dist/es/standards-agent-kit.es26.js.map +1 -1
  50. package/dist/es/standards-agent-kit.es27.js +25 -116
  51. package/dist/es/standards-agent-kit.es27.js.map +1 -1
  52. package/dist/es/standards-agent-kit.es28.js +33 -166
  53. package/dist/es/standards-agent-kit.es28.js.map +1 -1
  54. package/dist/es/standards-agent-kit.es29.js +42 -121
  55. package/dist/es/standards-agent-kit.es29.js.map +1 -1
  56. package/dist/es/standards-agent-kit.es30.js +40 -77
  57. package/dist/es/standards-agent-kit.es30.js.map +1 -1
  58. package/dist/es/standards-agent-kit.es31.js +42 -37
  59. package/dist/es/standards-agent-kit.es31.js.map +1 -1
  60. package/dist/es/standards-agent-kit.es32.js +20 -237
  61. package/dist/es/standards-agent-kit.es32.js.map +1 -1
  62. package/dist/es/standards-agent-kit.es33.js +154 -135
  63. package/dist/es/standards-agent-kit.es33.js.map +1 -1
  64. package/dist/es/standards-agent-kit.es34.js +168 -23
  65. package/dist/es/standards-agent-kit.es34.js.map +1 -1
  66. package/dist/es/standards-agent-kit.es35.js +126 -21
  67. package/dist/es/standards-agent-kit.es35.js.map +1 -1
  68. package/dist/es/standards-agent-kit.es36.js +86 -3
  69. package/dist/es/standards-agent-kit.es36.js.map +1 -1
  70. package/dist/es/standards-agent-kit.es37.js +45 -0
  71. package/dist/es/standards-agent-kit.es37.js.map +1 -0
  72. package/dist/es/standards-agent-kit.es38.js +249 -0
  73. package/dist/es/standards-agent-kit.es38.js.map +1 -0
  74. package/dist/es/standards-agent-kit.es39.js +141 -0
  75. package/dist/es/standards-agent-kit.es39.js.map +1 -0
  76. package/dist/es/standards-agent-kit.es4.js +65 -32
  77. package/dist/es/standards-agent-kit.es4.js.map +1 -1
  78. package/dist/es/standards-agent-kit.es40.js +33 -0
  79. package/dist/es/standards-agent-kit.es40.js.map +1 -0
  80. package/dist/es/standards-agent-kit.es41.js +28 -0
  81. package/dist/es/standards-agent-kit.es41.js.map +1 -0
  82. package/dist/es/standards-agent-kit.es42.js +7 -0
  83. package/dist/es/standards-agent-kit.es42.js.map +1 -0
  84. package/dist/es/standards-agent-kit.es5.js +35 -311
  85. package/dist/es/standards-agent-kit.es5.js.map +1 -1
  86. package/dist/es/standards-agent-kit.es6.js +320 -20
  87. package/dist/es/standards-agent-kit.es6.js.map +1 -1
  88. package/dist/es/standards-agent-kit.es7.js +19 -227
  89. package/dist/es/standards-agent-kit.es7.js.map +1 -1
  90. package/dist/es/standards-agent-kit.es8.js +216 -65
  91. package/dist/es/standards-agent-kit.es8.js.map +1 -1
  92. package/dist/es/standards-agent-kit.es9.js +72 -23
  93. package/dist/es/standards-agent-kit.es9.js.map +1 -1
  94. package/dist/es/tools/hcs6/CreateDynamicRegistryTool.d.ts +44 -0
  95. package/dist/es/tools/hcs6/QueryDynamicRegistryTool.d.ts +50 -0
  96. package/dist/es/tools/hcs6/RegisterDynamicHashinalTool.d.ts +102 -0
  97. package/dist/es/tools/hcs6/UpdateDynamicHashinalTool.d.ts +96 -0
  98. package/dist/es/tools/hcs6/base-hcs6-tools.d.ts +28 -0
  99. package/dist/es/tools/hcs6/hcs6-tool-params.d.ts +18 -0
  100. package/dist/es/tools/hcs6/index.d.ts +6 -0
  101. package/dist/es/tools/index.d.ts +1 -0
  102. package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +4 -4
  103. package/dist/umd/index.d.ts +1 -1
  104. package/dist/umd/standards-agent-kit.umd.js +1 -1
  105. package/dist/umd/standards-agent-kit.umd.js.map +1 -1
  106. package/dist/umd/tools/hcs6/CreateDynamicRegistryTool.d.ts +44 -0
  107. package/dist/umd/tools/hcs6/QueryDynamicRegistryTool.d.ts +50 -0
  108. package/dist/umd/tools/hcs6/RegisterDynamicHashinalTool.d.ts +102 -0
  109. package/dist/umd/tools/hcs6/UpdateDynamicHashinalTool.d.ts +96 -0
  110. package/dist/umd/tools/hcs6/base-hcs6-tools.d.ts +28 -0
  111. package/dist/umd/tools/hcs6/hcs6-tool-params.d.ts +18 -0
  112. package/dist/umd/tools/hcs6/index.d.ts +6 -0
  113. package/dist/umd/tools/index.d.ts +1 -0
  114. package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +4 -4
  115. package/package.json +1 -1
  116. package/src/index.ts +1 -1
  117. package/src/tools/hcs6/CreateDynamicRegistryTool.ts +66 -0
  118. package/src/tools/hcs6/QueryDynamicRegistryTool.ts +72 -0
  119. package/src/tools/hcs6/RegisterDynamicHashinalTool.ts +79 -0
  120. package/src/tools/hcs6/UpdateDynamicHashinalTool.ts +74 -0
  121. package/src/tools/hcs6/base-hcs6-tools.ts +63 -0
  122. package/src/tools/hcs6/hcs6-tool-params.ts +21 -0
  123. package/src/tools/hcs6/index.ts +6 -0
  124. package/src/tools/index.ts +1 -0
  125. package/src/tools/inscriber/InscribeFromBufferTool.ts +1 -1
  126. package/src/tools/inscriber/InscribeFromUrlTool.ts +60 -7
@@ -1 +1 @@
1
- {"version":3,"file":"standards-agent-kit.es33.js","sources":["../../src/init/init.ts"],"sourcesContent":["import { HederaAgentKit, ServerSigner } from 'hedera-agent-kit';\nimport { HCS10Builder } from '../builders/hcs10/hcs10-builder';\nimport { RegisterAgentTool } from '../tools/hcs10/RegisterAgentTool';\nimport { FindRegistrationsTool } from '../tools/hcs10/FindRegistrationsTool';\nimport { InitiateConnectionTool } from '../tools/hcs10/InitiateConnectionTool';\nimport { ListConnectionsTool } from '../tools/hcs10/ListConnectionsTool';\nimport { SendMessageToConnectionTool } from '../tools/hcs10/SendMessageToConnectionTool';\nimport { CheckMessagesTool } from '../tools/hcs10/CheckMessagesTool';\nimport { ConnectionMonitorTool } from '../tools/hcs10/ConnectionMonitorTool';\nimport { ManageConnectionRequestsTool } from '../tools/hcs10/ManageConnectionRequestsTool';\nimport { AcceptConnectionRequestTool } from '../tools/hcs10/AcceptConnectionRequestTool';\nimport { RetrieveProfileTool } from '../tools/hcs10/RetrieveProfileTool';\nimport { ListUnapprovedConnectionRequestsTool } from '../tools/hcs10/ListUnapprovedConnectionRequestsTool';\nimport { IStateManager } from '../state/state-types';\nimport { OpenConvaiState } from '../state/open-convai-state';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport { ENV_FILE_PATH } from '../utils/state-tools';\n\nexport interface HCS10ClientConfig {\n operatorId?: string;\n operatorKey?: string;\n network?: 'mainnet' | 'testnet';\n useEncryption?: boolean;\n registryUrl?: string;\n logLevel?: 'debug' | 'info' | 'warn' | 'error';\n}\n\nexport interface HCS10InitializationOptions {\n clientConfig?: HCS10ClientConfig;\n stateManager?: IStateManager;\n createAllTools?: boolean;\n monitoringClient?: boolean;\n}\n\n/**\n * Tool collection containing all available tools from the standards-agent-kit\n */\nexport interface HCS10Tools {\n registerAgentTool: RegisterAgentTool;\n findRegistrationsTool: FindRegistrationsTool;\n retrieveProfileTool: RetrieveProfileTool;\n initiateConnectionTool: InitiateConnectionTool;\n listConnectionsTool: ListConnectionsTool;\n sendMessageToConnectionTool: SendMessageToConnectionTool;\n checkMessagesTool: CheckMessagesTool;\n connectionMonitorTool: ConnectionMonitorTool;\n manageConnectionRequestsTool: ManageConnectionRequestsTool;\n acceptConnectionRequestTool: AcceptConnectionRequestTool;\n listUnapprovedConnectionRequestsTool: ListUnapprovedConnectionRequestsTool;\n}\n\n/**\n * Initializes the HCS10 client and returns pre-registered LangChain tools.\n *\n * @param options - Initialization options\n * @returns Object containing hederaKit, hcs10Builder and requested tools\n */\nexport const initializeStandardsAgentKit = async (\n options?: HCS10InitializationOptions\n): Promise<{\n hederaKit: HederaAgentKit;\n hcs10Builder: HCS10Builder;\n monitoringHederaKit?: HederaAgentKit;\n monitoringHcs10Builder?: HCS10Builder;\n tools: Partial<HCS10Tools>;\n stateManager: IStateManager;\n}> => {\n const config = options?.clientConfig || {};\n\n const operatorId = config.operatorId || process.env.HEDERA_OPERATOR_ID;\n const operatorPrivateKey =\n config.operatorKey || process.env.HEDERA_OPERATOR_KEY;\n\n const networkEnv = config.network || process.env.HEDERA_NETWORK || 'testnet';\n\n let network: 'mainnet' | 'testnet';\n if (networkEnv === 'mainnet') {\n network = 'mainnet';\n } else if (networkEnv === 'testnet') {\n network = 'testnet';\n } else {\n console.warn(\n `Unsupported network specified: '${networkEnv}'. Defaulting to 'testnet'.`\n );\n network = 'testnet';\n }\n\n if (!operatorId || !operatorPrivateKey) {\n throw new Error(\n 'Operator ID and private key must be provided either through options or environment variables.'\n );\n }\n\n const shouldSilence = process.env.DISABLE_LOGGING === 'true';\n const logger = Logger.getInstance({\n level: config.logLevel || 'info',\n silent: shouldSilence,\n });\n\n const stateManager =\n options?.stateManager ||\n new OpenConvaiState({\n defaultEnvFilePath: ENV_FILE_PATH,\n defaultPrefix: 'TODD',\n });\n logger.info('State manager initialized');\n\n // Create HederaAgentKit\n const signer = new ServerSigner(operatorId, operatorPrivateKey, network);\n const hederaKit = new HederaAgentKit(signer);\n await hederaKit.initialize();\n logger.info(`HederaAgentKit initialized for ${operatorId} on ${network}`);\n\n // Create HCS10Builder\n const hcs10Builder = new HCS10Builder(hederaKit, stateManager, {\n useEncryption: config.useEncryption,\n registryUrl: config.registryUrl,\n logLevel: config.logLevel,\n });\n\n let monitoringHederaKit: HederaAgentKit | undefined;\n let monitoringHcs10Builder: HCS10Builder | undefined;\n\n if (options?.monitoringClient) {\n const monitoringSigner = new ServerSigner(operatorId, operatorPrivateKey, network);\n monitoringHederaKit = new HederaAgentKit(monitoringSigner);\n await monitoringHederaKit.initialize();\n monitoringHcs10Builder = new HCS10Builder(monitoringHederaKit, stateManager, {\n useEncryption: config.useEncryption,\n registryUrl: config.registryUrl,\n logLevel: 'error',\n });\n logger.info('Monitoring client initialized');\n }\n\n const tools: Partial<HCS10Tools> = {};\n\n // Always create RegisterAgentTool\n tools.registerAgentTool = new RegisterAgentTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n\n if (options?.createAllTools) {\n tools.findRegistrationsTool = new FindRegistrationsTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n tools.retrieveProfileTool = new RetrieveProfileTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n tools.initiateConnectionTool = new InitiateConnectionTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n tools.listConnectionsTool = new ListConnectionsTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n tools.sendMessageToConnectionTool = new SendMessageToConnectionTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n tools.checkMessagesTool = new CheckMessagesTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n tools.connectionMonitorTool = new ConnectionMonitorTool({\n hederaKit: monitoringHederaKit || hederaKit,\n hcs10Builder: monitoringHcs10Builder || hcs10Builder,\n logger: undefined,\n });\n tools.manageConnectionRequestsTool = new ManageConnectionRequestsTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n tools.acceptConnectionRequestTool = new AcceptConnectionRequestTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n tools.listUnapprovedConnectionRequestsTool =\n new ListUnapprovedConnectionRequestsTool({\n hederaKit,\n hcs10Builder,\n logger: undefined,\n });\n\n logger.info('All tools initialized');\n }\n\n return {\n hederaKit,\n hcs10Builder,\n monitoringHederaKit,\n monitoringHcs10Builder,\n tools,\n stateManager,\n };\n};"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAyDO,MAAM,8BAA8B,OACzC,YAQI;AACJ,QAAM,SAAS,SAAS,gBAAgB,CAAA;AAExC,QAAM,aAAa,OAAO,cAAc,QAAQ,IAAI;AACpD,QAAM,qBACJ,OAAO,eAAe,QAAQ,IAAI;AAEpC,QAAM,aAAa,OAAO,WAAW,QAAQ,IAAI,kBAAkB;AAEnE,MAAI;AACJ,MAAI,eAAe,WAAW;AAC5B,cAAU;AAAA,EACZ,WAAW,eAAe,WAAW;AACnC,cAAU;AAAA,EACZ,OAAO;AACL,YAAQ;AAAA,MACN,mCAAmC,UAAU;AAAA,IAAA;AAE/C,cAAU;AAAA,EACZ;AAEA,MAAI,CAAC,cAAc,CAAC,oBAAoB;AACtC,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAAA,EAEJ;AAEA,QAAM,gBAAgB,QAAQ,IAAI,oBAAoB;AACtD,QAAM,SAAS,OAAO,YAAY;AAAA,IAChC,OAAO,OAAO,YAAY;AAAA,IAC1B,QAAQ;AAAA,EAAA,CACT;AAED,QAAM,eACJ,SAAS,gBACT,IAAI,gBAAgB;AAAA,IAClB,oBAAoB;AAAA,IACpB,eAAe;AAAA,EAAA,CAChB;AACH,SAAO,KAAK,2BAA2B;AAGvC,QAAM,SAAS,IAAI,aAAa,YAAY,oBAAoB,OAAO;AACvE,QAAM,YAAY,IAAI,eAAe,MAAM;AAC3C,QAAM,UAAU,WAAA;AAChB,SAAO,KAAK,kCAAkC,UAAU,OAAO,OAAO,EAAE;AAGxE,QAAM,eAAe,IAAI,aAAa,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AAQ;AAAA,IAAA,CACT;AACD,UAAM,+BAA+B,IAAI,6BAA6B;AAAA,MACpE;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,IAAA,CACT;AACD,UAAM,8BAA8B,IAAI,4BAA4B;AAAA,MAClE;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,IAAA,CACT;AACD,UAAM,uCACJ,IAAI,qCAAqC;AAAA,MACvC;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,IAAA,CACT;AAEH,WAAO,KAAK,uBAAuB;AAAA,EACrC;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"standards-agent-kit.es33.js","sources":["../../src/tools/inscriber/InscribeFromUrlTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport { InscriptionOptions } from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\n\n/**\n * Schema for inscribing from URL\n */\nconst inscribeFromUrlSchema = z.object({\n url: z.string().url().describe('The URL of the content to inscribe'),\n mode: z\n .enum(['file', 'hashinal'])\n .optional()\n .describe('Inscription mode: file or hashinal NFT'),\n metadata: z\n .record(z.unknown())\n .optional()\n .describe('Metadata to attach to the inscription'),\n tags: z\n .array(z.string())\n .optional()\n .describe('Tags to categorize the inscription'),\n chunkSize: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Chunk size for large files'),\n waitForConfirmation: z\n .boolean()\n .optional()\n .describe('Whether to wait for inscription confirmation'),\n apiKey: z\n .string()\n .optional()\n .describe('API key for inscription service'),\n});\n\n\n/**\n * Tool for inscribing content from URL\n */\nexport class InscribeFromUrlTool extends BaseInscriberQueryTool<typeof inscribeFromUrlSchema> {\n name = 'inscribeFromUrl';\n description = 'Inscribe content ONLY from URLs that point directly to downloadable files (PDF, image, JSON, ZIP, etc). This tool will FAIL for web pages, news sites, or social media. Examples of VALID URLs: https://example.com/document.pdf, https://cdn.example.com/image.jpg, https://api.example.com/data.json. For web page articles or any content you retrieve via MCP tools, you MUST use inscribeFromBuffer instead after retrieving the content.';\n\n get specificInputSchema() {\n return inscribeFromUrlSchema;\n }\n\n protected async executeQuery(\n params: z.infer<typeof inscribeFromUrlSchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<unknown> {\n console.log(`[DEBUG] InscribeFromUrlTool.executeQuery called with URL: ${params.url}`);\n \n if (!params.url || params.url.trim() === '') {\n throw new Error('URL cannot be empty. Please provide a valid URL.');\n }\n\n try {\n const urlObj = new URL(params.url);\n if (!urlObj.protocol || !urlObj.host) {\n throw new Error('Invalid URL format. Please provide a complete URL with protocol (http/https).');\n }\n if (!['http:', 'https:'].includes(urlObj.protocol)) {\n throw new Error('Only HTTP and HTTPS URLs are supported for inscription.');\n }\n } catch (error) {\n throw new Error(`Invalid URL: ${params.url}. Please provide a valid URL.`);\n }\n\n console.log(`[InscribeFromUrlTool] Validating URL content before inscription...`);\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n \n try {\n // First try HEAD request\n const headResponse = await fetch(params.url, {\n method: 'HEAD',\n signal: controller.signal,\n });\n \n clearTimeout(timeoutId);\n \n if (!headResponse.ok) {\n throw new Error(`URL returned error status ${headResponse.status}: ${headResponse.statusText}. Cannot inscribe content from inaccessible URLs.`);\n }\n\n const contentType = headResponse.headers.get('content-type') || '';\n const contentLength = headResponse.headers.get('content-length');\n \n // Check if content type indicates HTML/web page\n const webPageContentTypes = [\n 'text/html',\n 'application/xhtml+xml',\n 'text/xml'\n ];\n \n if (webPageContentTypes.some(type => contentType.toLowerCase().includes(type))) {\n throw new Error(`URL returns HTML/web page content (Content-Type: ${contentType}). This tool only works with direct file URLs (PDFs, images, JSON, etc.). For web page content, first retrieve the content using the appropriate MCP tool or web scraper, then use inscribeFromBuffer to inscribe it.`);\n }\n \n if (contentLength && parseInt(contentLength) === 0) {\n throw new Error('URL returns empty content (Content-Length: 0). Cannot inscribe empty content.');\n }\n\n if (contentLength && parseInt(contentLength) < 10) {\n throw new Error(`URL content is too small (${contentLength} bytes). Content must be at least 10 bytes.`);\n }\n \n // If HEAD doesn't provide content-type, do a partial GET to check\n if (!contentType || contentType === 'application/octet-stream') {\n console.log(`[InscribeFromUrlTool] Content-Type unclear, fetching first 1KB to verify...`);\n \n const getController = new AbortController();\n const getTimeoutId = setTimeout(() => getController.abort(), 5000);\n \n try {\n const getResponse = await fetch(params.url, {\n signal: getController.signal,\n headers: {\n 'Range': 'bytes=0-1023' // Get first 1KB\n }\n });\n \n clearTimeout(getTimeoutId);\n \n if (getResponse.ok || getResponse.status === 206) { // 206 is partial content\n const buffer = await getResponse.arrayBuffer();\n const bytes = new Uint8Array(buffer);\n const text = new TextDecoder('utf-8', { fatal: false }).decode(bytes.slice(0, 512));\n \n // Check if it looks like HTML\n if (text.toLowerCase().includes('<!doctype html') || \n text.toLowerCase().includes('<html') ||\n text.match(/<meta\\s+[^>]*>/i) ||\n text.match(/<title>/i)) {\n throw new Error(`URL returns HTML content. This tool only works with direct file URLs. For web page content, first retrieve it using the appropriate tool, then use inscribeFromBuffer.`);\n }\n }\n } catch (getError) {\n clearTimeout(getTimeoutId);\n if (getError instanceof Error && getError.message.includes('HTML content')) {\n throw getError;\n }\n // If partial GET fails, continue anyway\n console.log(`[InscribeFromUrlTool] Could not perform partial GET validation: ${getError instanceof Error ? getError.message : 'Unknown error'}`);\n }\n }\n\n console.log(`[InscribeFromUrlTool] URL validation passed. Content-Type: ${contentType}, Content-Length: ${contentLength || 'unknown'}`);\n } catch (fetchError) {\n clearTimeout(timeoutId);\n throw fetchError;\n }\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n console.log(`[InscribeFromUrlTool] Warning: URL validation timed out after 10 seconds. Proceeding with inscription attempt.`);\n } else if (error.message.includes('URL returned error') || error.message.includes('empty content') || error.message.includes('too small') || error.message.includes('HTML')) {\n throw error;\n } else {\n console.log(`[InscribeFromUrlTool] Warning: Could not validate URL with HEAD request: ${error.message}. Proceeding with inscription attempt.`);\n }\n }\n }\n\n const options: InscriptionOptions = {\n mode: params.mode,\n metadata: params.metadata,\n tags: params.tags,\n chunkSize: params.chunkSize,\n waitForConfirmation: params.waitForConfirmation ?? true,\n waitMaxAttempts: 10,\n waitIntervalMs: 3000,\n apiKey: params.apiKey,\n network: this.inscriberBuilder['hederaKit'].client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet',\n };\n\n try {\n const timeoutPromise = new Promise((_, reject) => {\n setTimeout(() => reject(new Error('Inscription timed out after 30 seconds')), 30000);\n });\n\n const result = await Promise.race([\n this.inscriberBuilder.inscribe(\n { type: 'url', url: params.url },\n options\n ),\n timeoutPromise\n ]) as any;\n\n if (result.confirmed) {\n const topicId = result.inscription?.topic_id || result.result.topicId;\n const network = options.network || 'testnet';\n const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;\n return `Successfully inscribed and confirmed content on the Hedera network!\\n\\nTransaction ID: ${result.result.transactionId}\\nTopic ID: ${topicId || 'N/A'}${cdnUrl ? `\\nView inscription: ${cdnUrl}` : ''}\\n\\nThe inscription is now available.`;\n } else {\n return `Successfully submitted inscription to the Hedera network!\\n\\nTransaction ID: ${result.result.transactionId}\\n\\nThe inscription is processing and will be confirmed shortly.`;\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Failed to inscribe from URL';\n throw new Error(`Inscription failed: ${errorMessage}`);\n }\n }\n}"],"names":[],"mappings":";;AAQA,MAAM,wBAAwB,EAAE,OAAO;AAAA,EACrC,KAAK,EAAE,OAAA,EAAS,IAAA,EAAM,SAAS,oCAAoC;AAAA,EACnE,MAAM,EACH,KAAK,CAAC,QAAQ,UAAU,CAAC,EACzB,SAAA,EACA,SAAS,wCAAwC;AAAA,EACpD,UAAU,EACP,OAAO,EAAE,QAAA,CAAS,EAClB,SAAA,EACA,S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QAAQ,CAAC,GAAG,WAAW;AAChD,mBAAW,MAAM,OAAO,IAAI,MAAM,wCAAwC,CAAC,GAAG,GAAK;AAAA,MACrF,CAAC;AAED,YAAM,SAAS,MAAM,QAAQ,KAAK;AAAA,QAChC,KAAK,iBAAiB;AAAA,UACpB,EAAE,MAAM,OAAO,KAAK,OAAO,IAAA;AAAA,UAC3B;AAAA,QAAA;AAAA,QAEF;AAAA,MAAA,CACD;AAED,UAAI,OAAO,WAAW;AACpB,cAAM,UAAU,OAAO,aAAa,YAAY,OAAO,OAAO;AAC9D,cAAM,UAAU,QAAQ,WAAW;AACnC,cAAM,SAAS,UAAU,8CAA8C,OAAO,YAAY,OAAO,KAAK;AACtG,eAAO;AAAA;AAAA,kBAA0F,OAAO,OAAO,aAAa;AAAA,YAAe,WAAW,KAAK,GAAG,SAAS;AAAA,oBAAuB,MAAM,KAAK,EAAE;AAAA;AAAA;AAAA,MAC7M,OAAO;AACL,eAAO;AAAA;AAAA,kBAAgF,OAAO,OAAO,aAAa;AAAA;AAAA;AAAA,MACpH;AAAA,IACF,SAAS,OAAO;AACd,YAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU;AAC9D,YAAM,IAAI,MAAM,uBAAuB,YAAY,EAAE;AAAA,IACvD;AAAA,EACF;AACF;"}
@@ -1,33 +1,178 @@
1
- import { BasePlugin, HederaGetHbarPriceTool } from "hedera-agent-kit";
2
- import { HederaGetHbarPriceTool as HederaGetHbarPriceTool2 } from "hedera-agent-kit";
3
- class HbarPricePlugin extends BasePlugin {
1
+ import { z } from "zod";
2
+ import { BaseInscriberQueryTool } from "./standards-agent-kit.es32.js";
3
+ import * as fs from "fs/promises";
4
+ import * as path from "path";
5
+ const inscribeFromFileSchema = z.object({
6
+ filePath: z.string().min(1, "File path cannot be empty").describe("The file path of the content to inscribe. Must point to a valid, non-empty file."),
7
+ mode: z.enum(["file", "hashinal"]).optional().describe("Inscription mode: file or hashinal NFT"),
8
+ metadata: z.record(z.unknown()).optional().describe("Metadata to attach to the inscription"),
9
+ tags: z.array(z.string()).optional().describe("Tags to categorize the inscription"),
10
+ chunkSize: z.number().int().positive().optional().describe("Chunk size for large files"),
11
+ waitForConfirmation: z.boolean().optional().describe("Whether to wait for inscription confirmation"),
12
+ timeoutMs: z.number().int().positive().optional().describe("Timeout in milliseconds for inscription (default: no timeout)"),
13
+ apiKey: z.string().optional().describe("API key for inscription service")
14
+ });
15
+ class InscribeFromFileTool extends BaseInscriberQueryTool {
4
16
  constructor() {
5
17
  super(...arguments);
6
- this.id = "hedera-hbar-price";
7
- this.name = "Hedera HBAR Price Plugin";
8
- this.description = "Provides tools to interact with Hedera network data, specifically HBAR price.";
9
- this.version = "1.0.0";
10
- this.author = "Hashgraph Online";
11
- this.tools = [];
18
+ this.name = "inscribeFromFile";
19
+ this.description = "Inscribe content from a local file to the Hedera network using a file path. IMPORTANT: Only use this tool when you have a valid file path to actual content. The file must exist and contain meaningful data (minimum 10 bytes). For files accessed through MCP filesystem tools, consider reading the file content first and using inscribeFromBuffer instead.";
12
20
  }
13
- async initialize(context) {
14
- await super.initialize(context);
15
- this.initializeTools();
21
+ get specificInputSchema() {
22
+ return inscribeFromFileSchema;
16
23
  }
17
- initializeTools() {
18
- this.tools = [
19
- new HederaGetHbarPriceTool({
20
- hederaKit: this.context.config.hederaKit,
21
- logger: this.context.logger
22
- })
23
- ];
24
+ async executeQuery(params, _runManager) {
25
+ console.log(`[DEBUG] InscribeFromFileTool.executeQuery called with: ${params.filePath}`);
26
+ let fileContent;
27
+ try {
28
+ console.log(`[DEBUG] Checking file: ${params.filePath}`);
29
+ console.log(`[DEBUG] Current working directory: ${process.cwd()}`);
30
+ const stats = await fs.stat(params.filePath);
31
+ if (!stats.isFile()) {
32
+ throw new Error(`Path "${params.filePath}" is not a file`);
33
+ }
34
+ console.log(`[DEBUG] File size: ${stats.size} bytes`);
35
+ if (stats.size === 0) {
36
+ throw new Error(
37
+ `File "${params.filePath}" is empty (0 bytes). Cannot inscribe empty files.`
38
+ );
39
+ }
40
+ if (stats.size < 10) {
41
+ throw new Error(
42
+ `File "${params.filePath}" is too small (${stats.size} bytes). Files must contain at least 10 bytes of meaningful content.`
43
+ );
44
+ }
45
+ if (stats.size > 100 * 1024 * 1024) {
46
+ console.log(`[InscribeFromFileTool] WARNING: Large file detected (${(stats.size / (1024 * 1024)).toFixed(2)} MB)`);
47
+ }
48
+ this.logger?.info("Reading file content...");
49
+ fileContent = await fs.readFile(params.filePath);
50
+ this.logger?.info(`Read ${fileContent.length} bytes from file`);
51
+ if (!fileContent || fileContent.length === 0) {
52
+ throw new Error(
53
+ `File "${params.filePath}" has no content after reading. Cannot inscribe empty files.`
54
+ );
55
+ }
56
+ if (fileContent.length < 10) {
57
+ throw new Error(
58
+ `File "${params.filePath}" content is too small (${fileContent.length} bytes). Files must contain at least 10 bytes of meaningful content.`
59
+ );
60
+ }
61
+ const fileName2 = path.basename(params.filePath);
62
+ const mimeType2 = this.getMimeType(fileName2);
63
+ if (mimeType2.startsWith("text/") || mimeType2 === "application/json") {
64
+ const textContent = fileContent.toString("utf8", 0, Math.min(fileContent.length, 1e3));
65
+ if (textContent.trim() === "") {
66
+ throw new Error(
67
+ `File "${params.filePath}" contains only whitespace or empty content. Cannot inscribe meaningless data.`
68
+ );
69
+ }
70
+ }
71
+ } catch (error) {
72
+ if (error instanceof Error) {
73
+ if (error.message.includes("ENOENT")) {
74
+ throw new Error(`File not found: "${params.filePath}"`);
75
+ }
76
+ throw error;
77
+ }
78
+ throw new Error(`Failed to read file: ${error}`);
79
+ }
80
+ const base64Data = fileContent.toString("base64");
81
+ this.logger?.info(`Converted to base64: ${base64Data.length} characters`);
82
+ const fileName = path.basename(params.filePath);
83
+ const mimeType = this.getMimeType(fileName);
84
+ this.logger?.info(`File: ${fileName}, MIME type: ${mimeType}`);
85
+ const options = {
86
+ mode: params.mode,
87
+ metadata: params.metadata,
88
+ tags: params.tags,
89
+ chunkSize: params.chunkSize,
90
+ waitForConfirmation: params.waitForConfirmation ?? true,
91
+ waitMaxAttempts: 10,
92
+ waitIntervalMs: 3e3,
93
+ apiKey: params.apiKey,
94
+ network: this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet"
95
+ };
96
+ try {
97
+ let result;
98
+ if (params.timeoutMs) {
99
+ const timeoutPromise = new Promise((_, reject) => {
100
+ setTimeout(
101
+ () => reject(new Error(`Inscription timed out after ${params.timeoutMs}ms`)),
102
+ params.timeoutMs
103
+ );
104
+ });
105
+ result = await Promise.race([
106
+ this.inscriberBuilder.inscribe(
107
+ {
108
+ type: "buffer",
109
+ buffer: Buffer.from(base64Data, "base64"),
110
+ fileName,
111
+ mimeType
112
+ },
113
+ options
114
+ ),
115
+ timeoutPromise
116
+ ]);
117
+ } else {
118
+ result = await this.inscriberBuilder.inscribe(
119
+ {
120
+ type: "buffer",
121
+ buffer: Buffer.from(base64Data, "base64"),
122
+ fileName,
123
+ mimeType
124
+ },
125
+ options
126
+ );
127
+ }
128
+ if (result.confirmed) {
129
+ const topicId = result.inscription?.topic_id || result.result.topicId;
130
+ const network = options.network || "testnet";
131
+ const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;
132
+ return `Successfully inscribed and confirmed content on the Hedera network!
133
+
134
+ Transaction ID: ${result.result.transactionId}
135
+ Topic ID: ${topicId || "N/A"}${cdnUrl ? `
136
+ View inscription: ${cdnUrl}` : ""}
137
+
138
+ The inscription is now available.`;
139
+ } else {
140
+ return `Successfully submitted inscription to the Hedera network!
141
+
142
+ Transaction ID: ${result.result.transactionId}
143
+
144
+ The inscription is processing and will be confirmed shortly.`;
145
+ }
146
+ } catch (error) {
147
+ const errorMessage = error instanceof Error ? error.message : "Failed to inscribe from file";
148
+ throw new Error(`Inscription failed: ${errorMessage}`);
149
+ }
24
150
  }
25
- getTools() {
26
- return this.tools;
151
+ getMimeType(fileName) {
152
+ const ext = path.extname(fileName).toLowerCase();
153
+ const mimeTypes = {
154
+ ".png": "image/png",
155
+ ".jpg": "image/jpeg",
156
+ ".jpeg": "image/jpeg",
157
+ ".gif": "image/gif",
158
+ ".webp": "image/webp",
159
+ ".svg": "image/svg+xml",
160
+ ".pdf": "application/pdf",
161
+ ".json": "application/json",
162
+ ".txt": "text/plain",
163
+ ".html": "text/html",
164
+ ".css": "text/css",
165
+ ".js": "application/javascript",
166
+ ".ts": "application/typescript",
167
+ ".mp4": "video/mp4",
168
+ ".mp3": "audio/mpeg",
169
+ ".wav": "audio/wav",
170
+ ".zip": "application/zip"
171
+ };
172
+ return mimeTypes[ext] || "application/octet-stream";
27
173
  }
28
174
  }
29
175
  export {
30
- HederaGetHbarPriceTool2 as GetHbarPriceTool,
31
- HbarPricePlugin
176
+ InscribeFromFileTool
32
177
  };
33
178
  //# sourceMappingURL=standards-agent-kit.es34.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-agent-kit.es34.js","sources":["../../src/plugins/hedera/HbarPricePlugin.ts"],"sourcesContent":["// Re-export the HBAR price tool from hedera-agent-kit\nexport { HederaGetHbarPriceTool as GetHbarPriceTool } from 'hedera-agent-kit';\n\nimport { BasePlugin, GenericPluginContext, HederaTool, HederaAgentKit } from 'hedera-agent-kit';\nimport { HederaGetHbarPriceTool } from 'hedera-agent-kit';\n\n/**\n * Plugin to provide tools related to Hedera network information, like HBAR price.\n * Uses the built-in HederaGetHbarPriceTool from hedera-agent-kit.\n */\nexport class HbarPricePlugin extends BasePlugin<GenericPluginContext> {\n id = 'hedera-hbar-price';\n name = 'Hedera HBAR Price Plugin';\n description = 'Provides tools to interact with Hedera network data, specifically HBAR price.';\n version = '1.0.0';\n author = 'Hashgraph Online';\n\n private tools: HederaTool[] = [];\n\n override async initialize(context: GenericPluginContext): Promise<void> {\n await super.initialize(context);\n this.initializeTools();\n }\n\n private initializeTools(): void {\n this.tools = [\n new HederaGetHbarPriceTool({\n hederaKit: this.context.config.hederaKit as HederaAgentKit,\n logger: this.context.logger\n })\n ];\n }\n\n getTools(): HederaTool[] {\n return this.tools;\n }\n}"],"names":["HederaGetHbarPriceTool"],"mappings":";;AAUO,MAAM,wBAAwB,WAAiC;AAAA,EAA/D,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAA,KAAK;AACL,SAAA,OAAO;AACP,SAAA,cAAc;AACd,SAAA,UAAU;AACV,SAAA,SAAS;AAET,SAAQ,QAAsB,CAAA;AAAA,EAAC;AAAA,EAE/B,MAAe,WAAW,SAA8C;AACtE,UAAM,MAAM,WAAW,OAAO;AAC9B,SAAK,gBAAA;AAAA,EACP;AAAA,EAEQ,kBAAwB;AAC9B,SAAK,QAAQ;AAAA,MACX,IAAIA,uBAAuB;AAAA,QACzB,WAAW,KAAK,QAAQ,OAAO;AAAA,QAC/B,QAAQ,KAAK,QAAQ;AAAA,MAAA,CACtB;AAAA,IAAA;AAAA,EAEL;AAAA,EAEA,WAAyB;AACvB,WAAO,KAAK;AAAA,EACd;AACF;"}
1
+ {"version":3,"file":"standards-agent-kit.es34.js","sources":["../../src/tools/inscriber/InscribeFromFileTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport { InscriptionOptions } from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\n\n/**\n * Schema for inscribing from file\n */\nconst inscribeFromFileSchema = z.object({\n filePath: z.string().min(1, 'File path cannot be empty').describe('The file path of the content to inscribe. Must point to a valid, non-empty file.'),\n mode: z\n .enum(['file', 'hashinal'])\n .optional()\n .describe('Inscription mode: file or hashinal NFT'),\n metadata: z\n .record(z.unknown())\n .optional()\n .describe('Metadata to attach to the inscription'),\n tags: z\n .array(z.string())\n .optional()\n .describe('Tags to categorize the inscription'),\n chunkSize: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Chunk size for large files'),\n waitForConfirmation: z\n .boolean()\n .optional()\n .describe('Whether to wait for inscription confirmation'),\n timeoutMs: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Timeout in milliseconds for inscription (default: no timeout)'),\n apiKey: z.string().optional().describe('API key for inscription service'),\n});\n\n/**\n * Tool for inscribing content from file\n */\nexport class InscribeFromFileTool extends BaseInscriberQueryTool<\n typeof inscribeFromFileSchema\n> {\n name = 'inscribeFromFile';\n description =\n 'Inscribe content from a local file to the Hedera network using a file path. IMPORTANT: Only use this tool when you have a valid file path to actual content. The file must exist and contain meaningful data (minimum 10 bytes). For files accessed through MCP filesystem tools, consider reading the file content first and using inscribeFromBuffer instead.';\n\n get specificInputSchema(): typeof inscribeFromFileSchema {\n return inscribeFromFileSchema;\n }\n\n protected async executeQuery(\n params: z.infer<typeof inscribeFromFileSchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<unknown> {\n console.log(`[DEBUG] InscribeFromFileTool.executeQuery called with: ${params.filePath}`);\n \n // File validation\n let fileContent: Buffer;\n try {\n console.log(`[DEBUG] Checking file: ${params.filePath}`);\n console.log(`[DEBUG] Current working directory: ${process.cwd()}`);\n\n const stats = await fs.stat(params.filePath);\n if (!stats.isFile()) {\n throw new Error(`Path \"${params.filePath}\" is not a file`);\n }\n\n console.log(`[DEBUG] File size: ${stats.size} bytes`);\n\n if (stats.size === 0) {\n throw new Error(\n `File \"${params.filePath}\" is empty (0 bytes). Cannot inscribe empty files.`\n );\n }\n\n if (stats.size < 10) {\n throw new Error(\n `File \"${params.filePath}\" is too small (${stats.size} bytes). Files must contain at least 10 bytes of meaningful content.`\n );\n }\n\n if (stats.size > 100 * 1024 * 1024) {\n console.log(`[InscribeFromFileTool] WARNING: Large file detected (${(stats.size / (1024 * 1024)).toFixed(2)} MB)`);\n }\n\n this.logger?.info('Reading file content...');\n fileContent = await fs.readFile(params.filePath);\n this.logger?.info(`Read ${fileContent.length} bytes from file`);\n\n if (!fileContent || fileContent.length === 0) {\n throw new Error(\n `File \"${params.filePath}\" has no content after reading. Cannot inscribe empty files.`\n );\n }\n\n if (fileContent.length < 10) {\n throw new Error(\n `File \"${params.filePath}\" content is too small (${fileContent.length} bytes). Files must contain at least 10 bytes of meaningful content.`\n );\n }\n\n const fileName = path.basename(params.filePath);\n const mimeType = this.getMimeType(fileName);\n if (mimeType.startsWith('text/') || mimeType === 'application/json') {\n const textContent = fileContent.toString('utf8', 0, Math.min(fileContent.length, 1000));\n if (textContent.trim() === '') {\n throw new Error(\n `File \"${params.filePath}\" contains only whitespace or empty content. Cannot inscribe meaningless data.`\n );\n }\n }\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('ENOENT')) {\n throw new Error(`File not found: \"${params.filePath}\"`);\n }\n throw error;\n }\n throw new Error(`Failed to read file: ${error}`);\n }\n\n const base64Data = fileContent.toString('base64');\n this.logger?.info(`Converted to base64: ${base64Data.length} characters`);\n\n const fileName = path.basename(params.filePath);\n const mimeType = this.getMimeType(fileName);\n this.logger?.info(`File: ${fileName}, MIME type: ${mimeType}`);\n\n const options: InscriptionOptions = {\n mode: params.mode,\n metadata: params.metadata,\n tags: params.tags,\n chunkSize: params.chunkSize,\n waitForConfirmation: params.waitForConfirmation ?? true,\n waitMaxAttempts: 10,\n waitIntervalMs: 3000,\n apiKey: params.apiKey,\n network: this.inscriberBuilder['hederaKit'].client.network\n .toString()\n .includes('mainnet')\n ? 'mainnet'\n : 'testnet',\n };\n\n try {\n let result: any;\n \n if (params.timeoutMs) {\n const timeoutPromise = new Promise((_, reject) => {\n setTimeout(\n () => reject(new Error(`Inscription timed out after ${params.timeoutMs}ms`)),\n params.timeoutMs\n );\n });\n\n result = await Promise.race([\n this.inscriberBuilder.inscribe(\n {\n type: 'buffer',\n buffer: Buffer.from(base64Data, 'base64'),\n fileName,\n mimeType,\n },\n options\n ),\n timeoutPromise,\n ]);\n } else {\n result = await this.inscriberBuilder.inscribe(\n {\n type: 'buffer',\n buffer: Buffer.from(base64Data, 'base64'),\n fileName,\n mimeType,\n },\n options\n );\n }\n\n if (result.confirmed) {\n const topicId = result.inscription?.topic_id || result.result.topicId;\n const network = options.network || 'testnet';\n const cdnUrl = topicId\n ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}`\n : null;\n return `Successfully inscribed and confirmed content on the Hedera network!\\n\\nTransaction ID: ${\n result.result.transactionId\n }\\nTopic ID: ${topicId || 'N/A'}${\n cdnUrl ? `\\nView inscription: ${cdnUrl}` : ''\n }\\n\\nThe inscription is now available.`;\n } else {\n return `Successfully submitted inscription to the Hedera network!\\n\\nTransaction ID: ${result.result.transactionId}\\n\\nThe inscription is processing and will be confirmed shortly.`;\n }\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'Failed to inscribe from file';\n throw new Error(`Inscription failed: ${errorMessage}`);\n }\n }\n\n private getMimeType(fileName: string): string {\n const ext = path.extname(fileName).toLowerCase();\n const mimeTypes: Record<string, string> = {\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.gif': 'image/gif',\n '.webp': 'image/webp',\n '.svg': 'image/svg+xml',\n '.pdf': 'application/pdf',\n '.json': 'application/json',\n '.txt': 'text/plain',\n '.html': 'text/html',\n '.css': 'text/css',\n '.js': 'application/javascript',\n '.ts': 'application/typescript',\n '.mp4': 'video/mp4',\n '.mp3': 'audio/mpeg',\n '.wav': 'audio/wav',\n '.zip': 'application/zip',\n };\n return mimeTypes[ext] || 'application/octet-stream';\n }\n}\n"],"names":["fileName","mimeType"],"mappings":";;;;AAUA,MAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,UAAU,EAAE,SAAS,IAAI,GAAG,2BAA2B,EAAE,SAAS,kFAAkF;AAAA,EACpJ,MAAM,EACH,KAAK,CAAC,QAAQ,UAAU,CAAC,EACzB,SAAA,EACA,SAAS,wCAAwC;AAAA,EACpD,UAAU,EACP,OAAO,EAAE,QAAA,CAAS,EAClB,SAAA,EACA,SAAS,uCAAuC;AAAA,EACnD,MAAM,EACH,MAAM,EAAE,OAAA,CAAQ,EAChB,SAAA,EACA,SAAS,oCAA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A,kBAAgF,OAAO,OAAO,aAAa;AAAA;AAAA;AAAA,MACpH;AAAA,IACF,SAAS,OAAO;AACd,YAAM,eACJ,iBAAiB,QAAQ,MAAM,UAAU;AAC3C,YAAM,IAAI,MAAM,uBAAuB,YAAY,EAAE;AAAA,IACvD;AAAA,EACF;AAAA,EAEQ,YAAY,UAA0B;AAC5C,UAAM,MAAM,KAAK,QAAQ,QAAQ,EAAE,YAAA;AACnC,UAAM,YAAoC;AAAA,MACxC,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,QAAQ;AAAA,IAAA;AAEV,WAAO,UAAU,GAAG,KAAK;AAAA,EAC3B;AACF;"}
@@ -1,28 +1,133 @@
1
- import "@hashgraphonline/standards-sdk";
2
- import fs from "fs";
3
- import path__default from "path";
4
- const ENV_FILE_PATH = path__default.join(process.cwd(), ".env");
5
- async function updateEnvFile(envFilePath, variables) {
6
- let envContent = "";
7
- if (fs.existsSync(envFilePath)) {
8
- envContent = fs.readFileSync(envFilePath, "utf8");
1
+ import { z } from "zod";
2
+ import { BaseInscriberQueryTool } from "./standards-agent-kit.es32.js";
3
+ const inscribeFromBufferSchema = z.object({
4
+ base64Data: z.string().min(1, "Base64 data cannot be empty").describe("Base64 encoded content to inscribe. Must contain valid, non-empty content (minimum 10 bytes after decoding)."),
5
+ fileName: z.string().min(1, "File name cannot be empty").describe("Name for the inscribed content. Required for all inscriptions."),
6
+ mimeType: z.string().optional().describe("MIME type of the content"),
7
+ mode: z.enum(["file", "hashinal"]).optional().describe("Inscription mode: file or hashinal NFT"),
8
+ metadata: z.record(z.unknown()).optional().describe("Metadata to attach to the inscription"),
9
+ tags: z.array(z.string()).optional().describe("Tags to categorize the inscription"),
10
+ chunkSize: z.number().int().positive().optional().describe("Chunk size for large files"),
11
+ waitForConfirmation: z.boolean().optional().describe("Whether to wait for inscription confirmation"),
12
+ timeoutMs: z.number().int().positive().optional().describe("Timeout in milliseconds for inscription (default: no timeout)"),
13
+ apiKey: z.string().optional().describe("API key for inscription service")
14
+ });
15
+ class InscribeFromBufferTool extends BaseInscriberQueryTool {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.name = "inscribeFromBuffer";
19
+ this.description = "Inscribe content that you already have retrieved or generated. ALWAYS use this tool for: web page articles (after using MCP tools), API responses, text data, or any content from MCP tools. Steps: 1) Retrieve content using appropriate tool, 2) Convert to base64, 3) Use this tool. NEVER use inscribeFromUrl for web pages - that tool is ONLY for direct file downloads like PDFs or images.";
9
20
  }
10
- const envLines = envContent.split("\n");
11
- const updatedLines = [...envLines];
12
- for (const [key, value] of Object.entries(variables)) {
13
- const lineIndex = updatedLines.findIndex(
14
- (line) => line.startsWith(`${key}=`)
15
- );
16
- if (lineIndex !== -1) {
17
- updatedLines[lineIndex] = `${key}=${value}`;
18
- } else {
19
- updatedLines.push(`${key}=${value}`);
21
+ get specificInputSchema() {
22
+ return inscribeFromBufferSchema;
23
+ }
24
+ async executeQuery(params, _runManager) {
25
+ console.log(`[DEBUG] InscribeFromBufferTool.executeQuery called`);
26
+ console.log(`[DEBUG] Buffer tool received base64Data length: ${params.base64Data?.length || 0}`);
27
+ console.log(`[DEBUG] Buffer tool fileName: ${params.fileName}`);
28
+ console.log(`[DEBUG] Buffer tool mimeType: ${params.mimeType}`);
29
+ if (!params.base64Data || params.base64Data.trim() === "") {
30
+ console.log(`[InscribeFromBufferTool] ERROR: No data provided`);
31
+ throw new Error("No data provided. Cannot inscribe empty content. Please provide valid base64 encoded data.");
32
+ }
33
+ if (!params.fileName || params.fileName.trim() === "") {
34
+ console.log(`[InscribeFromBufferTool] ERROR: No fileName provided`);
35
+ throw new Error("No fileName provided. A valid fileName is required for inscription.");
36
+ }
37
+ let buffer;
38
+ try {
39
+ buffer = Buffer.from(params.base64Data, "base64");
40
+ } catch (error) {
41
+ console.log(`[InscribeFromBufferTool] ERROR: Invalid base64 data`);
42
+ throw new Error("Invalid base64 data provided. Please ensure the data is properly base64 encoded.");
43
+ }
44
+ console.log(`[InscribeFromBufferTool] Buffer length after conversion: ${buffer.length}`);
45
+ if (buffer.length === 0) {
46
+ console.log(`[InscribeFromBufferTool] ERROR: Buffer is empty after conversion`);
47
+ throw new Error("Buffer is empty after base64 conversion. The provided data appears to be invalid or empty.");
48
+ }
49
+ if (buffer.length < 10) {
50
+ console.log(`[InscribeFromBufferTool] WARNING: Buffer is very small (${buffer.length} bytes)`);
51
+ console.log(`[InscribeFromBufferTool] Buffer content preview: ${buffer.toString("utf8", 0, Math.min(buffer.length, 50))}`);
52
+ throw new Error(`Buffer content is too small (${buffer.length} bytes). This may indicate empty or invalid content. Please verify the source data contains actual content.`);
53
+ }
54
+ const isValidBase64 = /^[A-Za-z0-9+/]*={0,2}$/.test(params.base64Data);
55
+ if (!isValidBase64) {
56
+ console.log(`[InscribeFromBufferTool] ERROR: Invalid base64 format`);
57
+ throw new Error("Invalid base64 format. The data does not appear to be properly base64 encoded.");
58
+ }
59
+ if (buffer.toString("utf8", 0, Math.min(buffer.length, 100)).trim() === "") {
60
+ console.log(`[InscribeFromBufferTool] ERROR: Buffer contains only whitespace or empty content`);
61
+ throw new Error("Buffer contains only whitespace or empty content. Cannot inscribe meaningless data.");
62
+ }
63
+ const options = {
64
+ mode: params.mode,
65
+ metadata: params.metadata,
66
+ tags: params.tags,
67
+ chunkSize: params.chunkSize,
68
+ waitForConfirmation: params.waitForConfirmation ?? true,
69
+ waitMaxAttempts: 10,
70
+ waitIntervalMs: 3e3,
71
+ apiKey: params.apiKey,
72
+ network: this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet"
73
+ };
74
+ try {
75
+ let result;
76
+ if (params.timeoutMs) {
77
+ const timeoutPromise = new Promise((_, reject) => {
78
+ setTimeout(
79
+ () => reject(new Error(`Inscription timed out after ${params.timeoutMs}ms`)),
80
+ params.timeoutMs
81
+ );
82
+ });
83
+ result = await Promise.race([
84
+ this.inscriberBuilder.inscribe(
85
+ {
86
+ type: "buffer",
87
+ buffer,
88
+ fileName: params.fileName,
89
+ mimeType: params.mimeType
90
+ },
91
+ options
92
+ ),
93
+ timeoutPromise
94
+ ]);
95
+ } else {
96
+ result = await this.inscriberBuilder.inscribe(
97
+ {
98
+ type: "buffer",
99
+ buffer,
100
+ fileName: params.fileName,
101
+ mimeType: params.mimeType
102
+ },
103
+ options
104
+ );
105
+ }
106
+ if (result.confirmed) {
107
+ const topicId = result.inscription?.topic_id || result.result.topicId;
108
+ const network = options.network || "testnet";
109
+ const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;
110
+ return `Successfully inscribed and confirmed content on the Hedera network!
111
+
112
+ Transaction ID: ${result.result.transactionId}
113
+ Topic ID: ${topicId || "N/A"}${cdnUrl ? `
114
+ View inscription: ${cdnUrl}` : ""}
115
+
116
+ The inscription is now available.`;
117
+ } else {
118
+ return `Successfully submitted inscription to the Hedera network!
119
+
120
+ Transaction ID: ${result.result.transactionId}
121
+
122
+ The inscription is processing and will be confirmed shortly.`;
123
+ }
124
+ } catch (error) {
125
+ const errorMessage = error instanceof Error ? error.message : "Failed to inscribe from buffer";
126
+ throw new Error(`Inscription failed: ${errorMessage}`);
20
127
  }
21
128
  }
22
- fs.writeFileSync(envFilePath, updatedLines.join("\n"));
23
129
  }
24
130
  export {
25
- ENV_FILE_PATH,
26
- updateEnvFile
131
+ InscribeFromBufferTool
27
132
  };
28
133
  //# sourceMappingURL=standards-agent-kit.es35.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-agent-kit.es35.js","sources":["../../src/utils/state-tools.ts"],"sourcesContent":["import {\n HCS10Client,\n AgentBuilder,\n Logger,\n} from '@hashgraphonline/standards-sdk';\nimport fs from 'fs';\nimport path from 'path';\nimport { ensureAgentHasEnoughHbar } from './ensure-agent-has-hbar';\n\nexport const ENV_FILE_PATH = path.join(process.cwd(), '.env');\n\nexport interface AgentData {\n accountId: string;\n operatorId: string;\n inboundTopicId: string;\n outboundTopicId: string;\n client: HCS10Client;\n}\n\nexport interface RegistrationProgressData {\n registered: boolean;\n accountId?: string;\n privateKey?: string;\n publicKey?: string;\n inboundTopicId?: string;\n outboundTopicId?: string;\n}\n\nexport async function getAgentFromEnv(\n logger: Logger,\n baseClient: HCS10Client,\n agentName: string,\n envPrefix: string\n): Promise<AgentData | null> {\n const accountIdEnvVar = `${envPrefix}_ACCOUNT_ID`;\n const privateKeyEnvVar = `${envPrefix}_PRIVATE_KEY`;\n const inboundTopicIdEnvVar = `${envPrefix}_INBOUND_TOPIC_ID`;\n const outboundTopicIdEnvVar = `${envPrefix}_OUTBOUND_TOPIC_ID`;\n\n const accountId = process.env[accountIdEnvVar];\n const privateKey = process.env[privateKeyEnvVar];\n const inboundTopicId = process.env[inboundTopicIdEnvVar];\n const outboundTopicId = process.env[outboundTopicIdEnvVar];\n\n if (!accountId || !privateKey || !inboundTopicId || !outboundTopicId) {\n logger.info(`${agentName} agent not found in environment variables`);\n return null;\n }\n\n logger.info(`${agentName} agent found in environment variables`);\n logger.info(`${agentName} account ID: ${accountId}`);\n logger.info(`${agentName} inbound topic ID: ${inboundTopicId}`);\n logger.info(`${agentName} outbound topic ID: ${outboundTopicId}`);\n\n const client = new HCS10Client({\n network: 'testnet',\n operatorId: accountId,\n operatorPrivateKey: privateKey,\n guardedRegistryBaseUrl: process.env.REGISTRY_URL,\n prettyPrint: true,\n logLevel: 'debug',\n });\n\n await ensureAgentHasEnoughHbar(logger, baseClient, accountId, agentName);\n\n return {\n accountId,\n operatorId: `${inboundTopicId}@${accountId}`,\n inboundTopicId,\n outboundTopicId,\n client,\n };\n}\n\nexport async function createAgent(\n logger: Logger,\n baseClient: HCS10Client,\n agentName: string,\n agentBuilder: AgentBuilder,\n envPrefix: string\n): Promise<AgentData | null> {\n try {\n logger.info(`Creating ${agentName} agent...`);\n\n const result = await baseClient.createAndRegisterAgent(agentBuilder);\n\n if (!result.metadata) {\n logger.error(`${agentName} agent creation failed`);\n return null;\n }\n\n logger.info(`${agentName} agent created successfully`);\n logger.info(`${agentName} account ID: ${result.metadata.accountId}`);\n logger.info(`${agentName} private key: ${result.metadata.privateKey}`);\n logger.info(\n `${agentName} inbound topic ID: ${result.metadata.inboundTopicId}`\n );\n logger.info(\n `${agentName} outbound topic ID: ${result.metadata.outboundTopicId}`\n );\n\n const envVars = {\n [`${envPrefix}_ACCOUNT_ID`]: result.metadata.accountId,\n [`${envPrefix}_PRIVATE_KEY`]: result.metadata.privateKey,\n [`${envPrefix}_INBOUND_TOPIC_ID`]: result.metadata.inboundTopicId,\n [`${envPrefix}_OUTBOUND_TOPIC_ID`]: result.metadata.outboundTopicId,\n };\n\n await updateEnvFile(ENV_FILE_PATH, envVars);\n\n const client = new HCS10Client({\n network: 'testnet',\n operatorId: result.metadata.accountId,\n operatorPrivateKey: result.metadata.privateKey,\n guardedRegistryBaseUrl: process.env.REGISTRY_URL,\n prettyPrint: true,\n logLevel: 'debug',\n });\n\n return {\n accountId: result.metadata.accountId,\n operatorId: `${result.metadata.inboundTopicId}@${result.metadata.accountId}`,\n inboundTopicId: result.metadata.inboundTopicId,\n outboundTopicId: result.metadata.outboundTopicId,\n client,\n };\n } catch (error) {\n console.log('error', error, baseClient);\n logger.error(`Error creating ${agentName} agent:`, error);\n return null;\n }\n}\n\nexport async function updateEnvFile(\n envFilePath: string,\n variables: Record<string, string>\n): Promise<void> {\n let envContent = '';\n\n if (fs.existsSync(envFilePath)) {\n envContent = fs.readFileSync(envFilePath, 'utf8');\n }\n\n const envLines = envContent.split('\\n');\n const updatedLines = [...envLines];\n\n for (const [key, value] of Object.entries(variables)) {\n const lineIndex = updatedLines.findIndex((line) =>\n line.startsWith(`${key}=`)\n );\n\n if (lineIndex !== -1) {\n updatedLines[lineIndex] = `${key}=${value}`;\n } else {\n updatedLines.push(`${key}=${value}`);\n }\n }\n\n fs.writeFileSync(envFilePath, updatedLines.join('\\n'));\n}\n"],"names":["path"],"mappings":";;;AASO,MAAM,gBAAgBA,cAAK,KAAK,QAAQ,IAAA,GAAO,MAAM;AA4H5D,eAAsB,cACpB,aACA,WACe;AACf,MAAI,aAAa;AAEjB,MAAI,GAAG,WAAW,WAAW,GAAG;AAC9B,iBAAa,GAAG,aAAa,aAAa,MAAM;AAAA,EAClD;AAEA,QAAM,WAAW,WAAW,MAAM,IAAI;AACtC,QAAM,eAAe,CAAC,GAAG,QAAQ;AAEjC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,SAAS,GAAG;AACpD,UAAM,YAAY,aAAa;AAAA,MAAU,CAAC,SACxC,KAAK,WAAW,GAAG,GAAG,GAAG;AAAA,IAAA;AAG3B,QAAI,cAAc,IAAI;AACpB,mBAAa,SAAS,IAAI,GAAG,GAAG,IAAI,KAAK;AAAA,IAC3C,OAAO;AACL,mBAAa,KAAK,GAAG,GAAG,IAAI,KAAK,EAAE;AAAA,IACrC;AAAA,EACF;AAEA,KAAG,cAAc,aAAa,aAAa,KAAK,IAAI,CAAC;AACvD;"}
1
+ {"version":3,"file":"standards-agent-kit.es35.js","sources":["../../src/tools/inscriber/InscribeFromBufferTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport { InscriptionOptions } from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\n\n/**\n * Schema for inscribing from buffer\n */\nconst inscribeFromBufferSchema = z.object({\n base64Data: z.string().min(1, 'Base64 data cannot be empty').describe('Base64 encoded content to inscribe. Must contain valid, non-empty content (minimum 10 bytes after decoding).'),\n fileName: z.string().min(1, 'File name cannot be empty').describe('Name for the inscribed content. Required for all inscriptions.'),\n mimeType: z\n .string()\n .optional()\n .describe('MIME type of the content'),\n mode: z\n .enum(['file', 'hashinal'])\n .optional()\n .describe('Inscription mode: file or hashinal NFT'),\n metadata: z\n .record(z.unknown())\n .optional()\n .describe('Metadata to attach to the inscription'),\n tags: z\n .array(z.string())\n .optional()\n .describe('Tags to categorize the inscription'),\n chunkSize: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Chunk size for large files'),\n waitForConfirmation: z\n .boolean()\n .optional()\n .describe('Whether to wait for inscription confirmation'),\n timeoutMs: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Timeout in milliseconds for inscription (default: no timeout)'),\n apiKey: z\n .string()\n .optional()\n .describe('API key for inscription service'),\n});\n\n\n/**\n * Tool for inscribing content from buffer\n */\nexport class InscribeFromBufferTool extends BaseInscriberQueryTool<typeof inscribeFromBufferSchema> {\n name = 'inscribeFromBuffer';\n description = 'Inscribe content that you already have retrieved or generated. ALWAYS use this tool for: web page articles (after using MCP tools), API responses, text data, or any content from MCP tools. Steps: 1) Retrieve content using appropriate tool, 2) Convert to base64, 3) Use this tool. NEVER use inscribeFromUrl for web pages - that tool is ONLY for direct file downloads like PDFs or images.';\n\n get specificInputSchema() {\n return inscribeFromBufferSchema;\n }\n\n protected async executeQuery(\n params: z.infer<typeof inscribeFromBufferSchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<unknown> {\n console.log(`[DEBUG] InscribeFromBufferTool.executeQuery called`);\n console.log(`[DEBUG] Buffer tool received base64Data length: ${params.base64Data?.length || 0}`);\n console.log(`[DEBUG] Buffer tool fileName: ${params.fileName}`);\n console.log(`[DEBUG] Buffer tool mimeType: ${params.mimeType}`);\n \n if (!params.base64Data || params.base64Data.trim() === '') {\n console.log(`[InscribeFromBufferTool] ERROR: No data provided`);\n throw new Error('No data provided. Cannot inscribe empty content. Please provide valid base64 encoded data.');\n }\n\n if (!params.fileName || params.fileName.trim() === '') {\n console.log(`[InscribeFromBufferTool] ERROR: No fileName provided`);\n throw new Error('No fileName provided. A valid fileName is required for inscription.');\n }\n\n let buffer: Buffer;\n try {\n buffer = Buffer.from(params.base64Data, 'base64');\n } catch (error) {\n console.log(`[InscribeFromBufferTool] ERROR: Invalid base64 data`);\n throw new Error('Invalid base64 data provided. Please ensure the data is properly base64 encoded.');\n }\n \n console.log(`[InscribeFromBufferTool] Buffer length after conversion: ${buffer.length}`);\n \n if (buffer.length === 0) {\n console.log(`[InscribeFromBufferTool] ERROR: Buffer is empty after conversion`);\n throw new Error('Buffer is empty after base64 conversion. The provided data appears to be invalid or empty.');\n }\n\n if (buffer.length < 10) {\n console.log(`[InscribeFromBufferTool] WARNING: Buffer is very small (${buffer.length} bytes)`);\n console.log(`[InscribeFromBufferTool] Buffer content preview: ${buffer.toString('utf8', 0, Math.min(buffer.length, 50))}`);\n throw new Error(`Buffer content is too small (${buffer.length} bytes). This may indicate empty or invalid content. Please verify the source data contains actual content.`);\n }\n\n const isValidBase64 = /^[A-Za-z0-9+/]*={0,2}$/.test(params.base64Data);\n if (!isValidBase64) {\n console.log(`[InscribeFromBufferTool] ERROR: Invalid base64 format`);\n throw new Error('Invalid base64 format. The data does not appear to be properly base64 encoded.');\n }\n\n if (buffer.toString('utf8', 0, Math.min(buffer.length, 100)).trim() === '') {\n console.log(`[InscribeFromBufferTool] ERROR: Buffer contains only whitespace or empty content`);\n throw new Error('Buffer contains only whitespace or empty content. Cannot inscribe meaningless data.');\n }\n\n const options: InscriptionOptions = {\n mode: params.mode,\n metadata: params.metadata,\n tags: params.tags,\n chunkSize: params.chunkSize,\n waitForConfirmation: params.waitForConfirmation ?? true,\n waitMaxAttempts: 10,\n waitIntervalMs: 3000,\n apiKey: params.apiKey,\n network: this.inscriberBuilder['hederaKit'].client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet',\n };\n\n try {\n let result: any;\n \n if (params.timeoutMs) {\n const timeoutPromise = new Promise((_, reject) => {\n setTimeout(\n () => reject(new Error(`Inscription timed out after ${params.timeoutMs}ms`)),\n params.timeoutMs\n );\n });\n\n result = await Promise.race([\n this.inscriberBuilder.inscribe(\n {\n type: 'buffer',\n buffer,\n fileName: params.fileName,\n mimeType: params.mimeType,\n },\n options\n ),\n timeoutPromise,\n ]);\n } else {\n result = await this.inscriberBuilder.inscribe(\n {\n type: 'buffer',\n buffer,\n fileName: params.fileName,\n mimeType: params.mimeType,\n },\n options\n );\n }\n\n if (result.confirmed) {\n const topicId = result.inscription?.topic_id || result.result.topicId;\n const network = options.network || 'testnet';\n const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;\n return `Successfully inscribed and confirmed content on the Hedera network!\\n\\nTransaction ID: ${result.result.transactionId}\\nTopic ID: ${topicId || 'N/A'}${cdnUrl ? `\\nView inscription: ${cdnUrl}` : ''}\\n\\nThe inscription is now available.`;\n } else {\n return `Successfully submitted inscription to the Hedera network!\\n\\nTransaction ID: ${result.result.transactionId}\\n\\nThe inscription is processing and will be confirmed shortly.`;\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Failed to inscribe from buffer';\n throw new Error(`Inscription failed: ${errorMessage}`);\n }\n }\n}"],"names":[],"mappings":";;AAQA,MAAM,2BAA2B,EAAE,OAAO;AAAA,EACxC,YAAY,EAAE,SAAS,IAAI,GAAG,6BAA6B,EAAE,SAAS,8GAA8G;AAAA,EACpL,UAAU,EAAE,SAAS,IAAI,GAAG,2BAA2B,EAAE,SAAS,gEAAgE;AAAA,EAClI,UAAU,EACP,OAAA,EACA,SAAA,EACA,SAAS,0BAA0B;AAAA,EACtC,MAAM,EACH,KAAK,CAAC,QAAQ,UAAU,CAAC,EACzB,SAAA,EACA,SAAS,wCAAwC;AAAA,EACpD,UAAU,EACP,OAAO,EAAE,QAAA,CAAS,EAClB,SAAA,EACA,SAAS,uCAAuC;AAAA,EACnD,MAAM,EACH,MAAM,EAAE,OAAA,CAAQ,EAChB,SAAA,EACA,SAAS,oCAAoC;AAAA,EAChD,WAAW,EACR,OAA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cACjB,UAAU,OAAO;AAAA,YAAA;AAAA,YAEnB;AAAA,UAAA;AAAA,UAEF;AAAA,QAAA,CACD;AAAA,MACH,OAAO;AACL,iBAAS,MAAM,KAAK,iBAAiB;AAAA,UACnC;AAAA,YACE,MAAM;AAAA,YACN;AAAA,YACA,UAAU,OAAO;AAAA,YACjB,UAAU,OAAO;AAAA,UAAA;AAAA,UAEnB;AAAA,QAAA;AAAA,MAEJ;AAEA,UAAI,OAAO,WAAW;AACpB,cAAM,UAAU,OAAO,aAAa,YAAY,OAAO,OAAO;AAC9D,cAAM,UAAU,QAAQ,WAAW;AACnC,cAAM,SAAS,UAAU,8CAA8C,OAAO,YAAY,OAAO,KAAK;AACtG,eAAO;AAAA;AAAA,kBAA0F,OAAO,OAAO,aAAa;AAAA,YAAe,WAAW,KAAK,GAAG,SAAS;AAAA,oBAAuB,MAAM,KAAK,EAAE;AAAA;AAAA;AAAA,MAC7M,OAAO;AACL,eAAO;AAAA;AAAA,kBAAgF,OAAO,OAAO,aAAa;AAAA;AAAA;AAAA,MACpH;AAAA,IACF,SAAS,OAAO;AACd,YAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU;AAC9D,YAAM,IAAI,MAAM,uBAAuB,YAAY,EAAE;AAAA,IACvD;AAAA,EACF;AACF;"}
@@ -1,7 +1,90 @@
1
- function encryptMessage(message) {
2
- return message;
1
+ import { z } from "zod";
2
+ import { BaseInscriberQueryTool } from "./standards-agent-kit.es32.js";
3
+ const inscribeHashinalSchema = z.object({
4
+ url: z.string().url().describe("The URL of the content to inscribe as Hashinal NFT"),
5
+ name: z.string().describe("Name of the Hashinal NFT"),
6
+ creator: z.string().describe("Creator account ID or name"),
7
+ description: z.string().describe("Description of the Hashinal NFT"),
8
+ type: z.string().describe('Type of NFT (e.g., "image", "video", "audio")'),
9
+ attributes: z.array(
10
+ z.object({
11
+ trait_type: z.string(),
12
+ value: z.union([z.string(), z.number()])
13
+ })
14
+ ).optional().describe("NFT attributes"),
15
+ properties: z.record(z.unknown()).optional().describe("Additional properties"),
16
+ jsonFileURL: z.string().url().optional().describe("URL to JSON metadata file"),
17
+ tags: z.array(z.string()).optional().describe("Tags to categorize the NFT"),
18
+ chunkSize: z.number().int().positive().optional().describe("Chunk size for large files"),
19
+ waitForConfirmation: z.boolean().optional().describe("Whether to wait for inscription confirmation"),
20
+ apiKey: z.string().optional().describe("API key for inscription service")
21
+ });
22
+ class InscribeHashinalTool extends BaseInscriberQueryTool {
23
+ constructor() {
24
+ super(...arguments);
25
+ this.name = "inscribeHashinal";
26
+ this.description = "Inscribe content as a Hashinal NFT on the Hedera network";
27
+ }
28
+ get specificInputSchema() {
29
+ return inscribeHashinalSchema;
30
+ }
31
+ async executeQuery(params, _runManager) {
32
+ const metadata = {
33
+ name: params.name,
34
+ creator: params.creator,
35
+ description: params.description,
36
+ type: params.type,
37
+ attributes: params.attributes,
38
+ properties: params.properties
39
+ };
40
+ const options = {
41
+ mode: "hashinal",
42
+ metadata,
43
+ jsonFileURL: params.jsonFileURL,
44
+ tags: params.tags,
45
+ chunkSize: params.chunkSize,
46
+ waitForConfirmation: params.waitForConfirmation ?? true,
47
+ waitMaxAttempts: 10,
48
+ waitIntervalMs: 3e3,
49
+ apiKey: params.apiKey,
50
+ network: this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet"
51
+ };
52
+ try {
53
+ const timeoutPromise = new Promise((_, reject) => {
54
+ setTimeout(() => reject(new Error("Inscription timed out after 30 seconds")), 3e4);
55
+ });
56
+ const result = await Promise.race([
57
+ this.inscriberBuilder.inscribe(
58
+ { type: "url", url: params.url },
59
+ options
60
+ ),
61
+ timeoutPromise
62
+ ]);
63
+ if (result.confirmed) {
64
+ const topicId = result.inscription?.topic_id || result.result.topicId;
65
+ const network = options.network || "testnet";
66
+ const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;
67
+ return `Successfully inscribed and confirmed Hashinal NFT on the Hedera network!
68
+
69
+ Transaction ID: ${result.result.transactionId}
70
+ Topic ID: ${topicId || "N/A"}${cdnUrl ? `
71
+ View inscription: ${cdnUrl}` : ""}
72
+
73
+ The Hashinal NFT is now available.`;
74
+ } else {
75
+ return `Successfully submitted Hashinal NFT inscription to the Hedera network!
76
+
77
+ Transaction ID: ${result.result.transactionId}
78
+
79
+ The inscription is processing and will be confirmed shortly.`;
80
+ }
81
+ } catch (error) {
82
+ const errorMessage = error instanceof Error ? error.message : "Failed to inscribe Hashinal NFT";
83
+ throw new Error(`Inscription failed: ${errorMessage}`);
84
+ }
85
+ }
3
86
  }
4
87
  export {
5
- encryptMessage
88
+ InscribeHashinalTool
6
89
  };
7
90
  //# sourceMappingURL=standards-agent-kit.es36.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-agent-kit.es36.js","sources":["../../src/utils/Encryption.ts"],"sourcesContent":["// src/utils/Encryption.ts\n/**\n * Placeholder for encryption functionality.\n * Currently, encryption is disabled. The useEncryption flag is false by default.\n * TODO: Implement actual encryption/decryption logic.\n */\n\nexport function encryptMessage(message: string): string {\n // TODO: Add encryption logic here if useEncryption flag is true.\n return message; // currently returns plaintext.\n}\n\nexport function decryptMessage(encryptedMessage: string): string {\n // TODO: Add decryption logic here.\n return encryptedMessage;\n}\n"],"names":[],"mappings":"AAOO,SAAS,eAAe,SAAyB;AAEpD,SAAO;AACX;"}
1
+ {"version":3,"file":"standards-agent-kit.es36.js","sources":["../../src/tools/inscriber/InscribeHashinalTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport { InscriptionOptions } from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\n\n/**\n * Schema for inscribing Hashinal NFT\n */\nconst inscribeHashinalSchema = z.object({\n url: z.string().url().describe('The URL of the content to inscribe as Hashinal NFT'),\n name: z.string().describe('Name of the Hashinal NFT'),\n creator: z.string().describe('Creator account ID or name'),\n description: z.string().describe('Description of the Hashinal NFT'),\n type: z.string().describe('Type of NFT (e.g., \"image\", \"video\", \"audio\")'),\n attributes: z\n .array(\n z.object({\n trait_type: z.string(),\n value: z.union([z.string(), z.number()]),\n })\n )\n .optional()\n .describe('NFT attributes'),\n properties: z\n .record(z.unknown())\n .optional()\n .describe('Additional properties'),\n jsonFileURL: z\n .string()\n .url()\n .optional()\n .describe('URL to JSON metadata file'),\n tags: z\n .array(z.string())\n .optional()\n .describe('Tags to categorize the NFT'),\n chunkSize: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Chunk size for large files'),\n waitForConfirmation: z\n .boolean()\n .optional()\n .describe('Whether to wait for inscription confirmation'),\n apiKey: z\n .string()\n .optional()\n .describe('API key for inscription service'),\n});\n\n\n/**\n * Tool for inscribing Hashinal NFTs\n */\nexport class InscribeHashinalTool extends BaseInscriberQueryTool<typeof inscribeHashinalSchema> {\n name = 'inscribeHashinal';\n description = 'Inscribe content as a Hashinal NFT on the Hedera network';\n\n get specificInputSchema() {\n return inscribeHashinalSchema;\n }\n\n protected async executeQuery(\n params: z.infer<typeof inscribeHashinalSchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<unknown> {\n const metadata = {\n name: params.name,\n creator: params.creator,\n description: params.description,\n type: params.type,\n attributes: params.attributes,\n properties: params.properties,\n };\n\n const options: InscriptionOptions = {\n mode: 'hashinal',\n metadata,\n jsonFileURL: params.jsonFileURL,\n tags: params.tags,\n chunkSize: params.chunkSize,\n waitForConfirmation: params.waitForConfirmation ?? true,\n waitMaxAttempts: 10,\n waitIntervalMs: 3000,\n apiKey: params.apiKey,\n network: this.inscriberBuilder['hederaKit'].client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet',\n };\n\n try {\n const timeoutPromise = new Promise((_, reject) => {\n setTimeout(() => reject(new Error('Inscription timed out after 30 seconds')), 30000);\n });\n\n const result = await Promise.race([\n this.inscriberBuilder.inscribe(\n { type: 'url', url: params.url },\n options\n ),\n timeoutPromise\n ]) as any;\n\n if (result.confirmed) {\n const topicId = result.inscription?.topic_id || result.result.topicId;\n const network = options.network || 'testnet';\n const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;\n return `Successfully inscribed and confirmed Hashinal NFT on the Hedera network!\\n\\nTransaction ID: ${result.result.transactionId}\\nTopic ID: ${topicId || 'N/A'}${cdnUrl ? `\\nView inscription: ${cdnUrl}` : ''}\\n\\nThe Hashinal NFT is now available.`;\n } else {\n return `Successfully submitted Hashinal NFT inscription to the Hedera network!\\n\\nTransaction ID: ${result.result.transactionId}\\n\\nThe inscription is processing and will be confirmed shortly.`;\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Failed to inscribe Hashinal NFT';\n throw new Error(`Inscription failed: ${errorMessage}`);\n }\n }\n}"],"names":[],"mappings":";;AAQA,MAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,KAAK,EAAE,OAAA,EAAS,IAAA,EAAM,SAAS,oDAAoD;AAAA,EACnF,MAAM,EAAE,SAAS,SAAS,0BAA0B;AAAA,EACpD,SAAS,EAAE,SAAS,SAAS,4BAA4B;AAAA,EACzD,aAAa,EAAE,SAAS,SAAS,iCAAiC;AAAA,EAClE,MAAM,EAAE,SAAS,SAAS,+CAA+C;AAAA,EACzE,YAAY,EACT;AAAA,IACC,EAAE,OAAO;AAAA,MACP,YAAY,EAAE,OAAA;AAAA,MACd,OAAO,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC;AAAA,IAAA,CACxC;AAAA,EAAA,EAEF,SAAA,EACA,SAAS,gBAAgB;AAAA,EAC5B,YAAY,EACT,OAAO,EAAE,QAAA,CAAS,EAClB,SAAA,EACA,SAAS,uBAAuB;AAAA,EACnC,aAAa,EACV,SACA,MACA,SAAA,EACA,SAAS,2BAA2B;AAAA,EACvC,MAAM,EACH,MAAM,EAAE,OAAA,CAAQ,EAChB,SAAA,EACA,SAAS,4BAA4B;AAAA,EACxC,WAAW,EACR,OAA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