@hashgraphonline/standards-agent-kit 0.2.121 → 0.2.123
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/cjs/tools/hcs6/CreateDynamicRegistryTool.d.ts +0 -6
- package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +6 -0
- package/dist/cjs/tools/inscriber/InscribeFromFileTool.d.ts +3 -0
- package/dist/cjs/tools/inscriber/InscribeFromUrlTool.d.ts +6 -0
- package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +6 -0
- package/dist/cjs/tools/inscriber/base-inscriber-tools.d.ts +15 -0
- package/dist/es/standards-agent-kit.es29.js +0 -2
- package/dist/es/standards-agent-kit.es29.js.map +1 -1
- package/dist/es/standards-agent-kit.es33.js +44 -0
- package/dist/es/standards-agent-kit.es33.js.map +1 -1
- package/dist/es/standards-agent-kit.es34.js +35 -6
- package/dist/es/standards-agent-kit.es34.js.map +1 -1
- package/dist/es/standards-agent-kit.es35.js +47 -9
- package/dist/es/standards-agent-kit.es35.js.map +1 -1
- package/dist/es/standards-agent-kit.es36.js +43 -6
- package/dist/es/standards-agent-kit.es36.js.map +1 -1
- package/dist/es/standards-agent-kit.es37.js +39 -6
- package/dist/es/standards-agent-kit.es37.js.map +1 -1
- package/dist/es/standards-agent-kit.es5.js +28 -4
- package/dist/es/standards-agent-kit.es5.js.map +1 -1
- package/dist/es/tools/hcs6/CreateDynamicRegistryTool.d.ts +0 -6
- package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +6 -0
- package/dist/es/tools/inscriber/InscribeFromFileTool.d.ts +3 -0
- package/dist/es/tools/inscriber/InscribeFromUrlTool.d.ts +6 -0
- package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +6 -0
- package/dist/es/tools/inscriber/base-inscriber-tools.d.ts +15 -0
- package/dist/umd/standards-agent-kit.umd.js +1 -1
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/dist/umd/tools/hcs6/CreateDynamicRegistryTool.d.ts +0 -6
- package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +6 -0
- package/dist/umd/tools/inscriber/InscribeFromFileTool.d.ts +3 -0
- package/dist/umd/tools/inscriber/InscribeFromUrlTool.d.ts +6 -0
- package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +6 -0
- package/dist/umd/tools/inscriber/base-inscriber-tools.d.ts +15 -0
- package/package.json +31 -27
- package/src/builders/hcs6/hcs6-builder.ts +33 -4
- package/src/tools/hcs6/CreateDynamicRegistryTool.ts +4 -6
- package/src/tools/inscriber/InscribeFromBufferTool.ts +49 -9
- package/src/tools/inscriber/InscribeFromFileTool.ts +50 -8
- package/src/tools/inscriber/InscribeFromUrlTool.ts +40 -11
- package/src/tools/inscriber/InscribeHashinalTool.ts +43 -6
- package/src/tools/inscriber/base-inscriber-tools.ts +87 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es35.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,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,KAAK,EAC7C;AAAA;AAAA;AAAA,MACF,OAAO;AACL,eAAO;AAAA;AAAA,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
|
+
{"version":3,"file":"standards-agent-kit.es35.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 quoteOnly: z\n .boolean()\n .optional()\n .default(false)\n .describe('If true, returns a cost quote instead of executing the inscription'),\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. Set quoteOnly=true to get cost estimates without executing the inscription.';\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 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.quoteOnly ? false : (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 quoteOnly: params.quoteOnly,\n };\n\n if (params.quoteOnly) {\n try {\n const quote = await this.generateInscriptionQuote(\n {\n type: 'buffer',\n buffer: Buffer.from(base64Data, 'base64'),\n fileName,\n mimeType,\n },\n options\n );\n \n return {\n success: true,\n quote: {\n totalCostHbar: quote.totalCostHbar,\n validUntil: quote.validUntil,\n breakdown: quote.breakdown,\n },\n contentInfo: {\n fileName,\n mimeType,\n sizeBytes: fileContent.length,\n filePath: params.filePath,\n },\n message: `Quote generated for file: ${fileName} (${(fileContent.length / 1024).toFixed(2)} KB)\\nTotal cost: ${quote.totalCostHbar} HBAR\\nQuote valid until: ${new Date(quote.validUntil).toLocaleString()}`,\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'Failed to generate inscription quote';\n throw new Error(`Quote generation failed: ${errorMessage}`);\n }\n }\n\n try {\n let result: unknown;\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 const inscriptionResult = result as any;\n if (inscriptionResult.confirmed && !inscriptionResult.quote) {\n const topicId = inscriptionResult.inscription?.topic_id || inscriptionResult.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 inscriptionResult.result.transactionId\n }\\nTopic ID: ${topicId || 'N/A'}${\n cdnUrl ? `\\nView inscription: ${cdnUrl}` : ''\n }\\n\\nThe inscription is now available.`;\n } else if (!inscriptionResult.quote && !inscriptionResult.confirmed) {\n return `Successfully submitted inscription to the Hedera network!\\n\\nTransaction ID: ${inscriptionResult.result.transactionId}\\n\\nThe inscription is processing and will be confirmed shortly.`;\n } else {\n return 'Inscription operation completed.';\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,oCAAoC;AAAA,EAChD,WAAW,EACR,OAAA,EACA,IAAA,EACA,SAAA,EACA,SAAA,EACA,SAAS,4BAA4B;AAAA,EACxC,qBAAqB,EAClB,QAAA,EACA,SAAA,EACA,SAAS,8CAA8C;AAAA,EAC1D,WAAW,EACR,OAAA,EACA,IAAA,EACA,SAAA,EACA,SAAA,EACA,SAAS,+DAA+D;AAAA,EAC3E,QAAQ,EAAE,OAAA,EAAS,SAAA,EAAW,SAAS,iCAAiC;AAAA,EACxE,WAAW,EACR,UACA,SAAA,EACA,QAAQ,KAAK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AA;AAEV,WAAO,UAAU,GAAG,KAAK;AAAA,EAC3B;AACF;"}
|
|
@@ -16,13 +16,14 @@ const inscribeFromBufferSchema = z.object({
|
|
|
16
16
|
timeoutMs: z.number().int().positive().optional().describe(
|
|
17
17
|
"Timeout in milliseconds for inscription (default: no timeout - waits until completion)"
|
|
18
18
|
),
|
|
19
|
-
apiKey: z.string().optional().describe("API key for inscription service")
|
|
19
|
+
apiKey: z.string().optional().describe("API key for inscription service"),
|
|
20
|
+
quoteOnly: z.boolean().optional().default(false).describe("If true, returns a cost quote instead of executing the inscription")
|
|
20
21
|
});
|
|
21
22
|
class InscribeFromBufferTool extends BaseInscriberQueryTool {
|
|
22
23
|
constructor() {
|
|
23
24
|
super(...arguments);
|
|
24
25
|
this.name = "inscribeFromBuffer";
|
|
25
|
-
this.description = 'Inscribe content that you have already retrieved or displayed. When user says "inscribe it" after you showed search results or other content, use THIS tool. The base64Data field accepts PLAIN TEXT (not just base64) and content reference IDs in format "content-ref:[id]". Pass the EXACT content from your previous response or MCP tool output. DO NOT generate new content or create repetitive text. Content references are automatically resolved to the original content for inscription.';
|
|
26
|
+
this.description = 'Inscribe content that you have already retrieved or displayed. When user says "inscribe it" after you showed search results or other content, use THIS tool. The base64Data field accepts PLAIN TEXT (not just base64) and content reference IDs in format "content-ref:[id]". Pass the EXACT content from your previous response or MCP tool output. DO NOT generate new content or create repetitive text. Content references are automatically resolved to the original content for inscription. Set quoteOnly=true to get cost estimates without executing the inscription.';
|
|
26
27
|
this.config = loadConfig();
|
|
27
28
|
}
|
|
28
29
|
get specificInputSchema() {
|
|
@@ -44,12 +45,45 @@ class InscribeFromBufferTool extends BaseInscriberQueryTool {
|
|
|
44
45
|
metadata: params.metadata,
|
|
45
46
|
tags: params.tags,
|
|
46
47
|
chunkSize: params.chunkSize,
|
|
47
|
-
waitForConfirmation: params.waitForConfirmation ?? true,
|
|
48
|
+
waitForConfirmation: params.quoteOnly ? false : params.waitForConfirmation ?? true,
|
|
48
49
|
waitMaxAttempts: 10,
|
|
49
50
|
waitIntervalMs: 3e3,
|
|
50
51
|
apiKey: params.apiKey,
|
|
51
|
-
network: this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet"
|
|
52
|
+
network: this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet",
|
|
53
|
+
quoteOnly: params.quoteOnly
|
|
52
54
|
};
|
|
55
|
+
if (params.quoteOnly) {
|
|
56
|
+
try {
|
|
57
|
+
const quote = await this.generateInscriptionQuote(
|
|
58
|
+
{
|
|
59
|
+
type: "buffer",
|
|
60
|
+
buffer,
|
|
61
|
+
fileName: resolvedFileName,
|
|
62
|
+
mimeType: resolvedMimeType
|
|
63
|
+
},
|
|
64
|
+
options
|
|
65
|
+
);
|
|
66
|
+
return {
|
|
67
|
+
success: true,
|
|
68
|
+
quote: {
|
|
69
|
+
totalCostHbar: quote.totalCostHbar,
|
|
70
|
+
validUntil: quote.validUntil,
|
|
71
|
+
breakdown: quote.breakdown
|
|
72
|
+
},
|
|
73
|
+
contentInfo: {
|
|
74
|
+
fileName: resolvedFileName,
|
|
75
|
+
mimeType: resolvedMimeType,
|
|
76
|
+
sizeBytes: buffer.length
|
|
77
|
+
},
|
|
78
|
+
message: `Quote generated for buffer content: ${resolvedFileName} (${(buffer.length / 1024).toFixed(2)} KB)
|
|
79
|
+
Total cost: ${quote.totalCostHbar} HBAR
|
|
80
|
+
Quote valid until: ${new Date(quote.validUntil).toLocaleString()}`
|
|
81
|
+
};
|
|
82
|
+
} catch (error) {
|
|
83
|
+
const errorMessage = error instanceof Error ? error.message : "Failed to generate inscription quote";
|
|
84
|
+
throw new Error(`Quote generation failed: ${errorMessage}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
53
87
|
const timeoutMs = params.timeoutMs || (options.waitForConfirmation ? 6e4 : void 0);
|
|
54
88
|
try {
|
|
55
89
|
const result = await this.executeInscription(
|
|
@@ -131,7 +165,7 @@ class InscribeFromBufferTool extends BaseInscriberQueryTool {
|
|
|
131
165
|
return this.inscriberBuilder.inscribe(inscriptionData, options);
|
|
132
166
|
}
|
|
133
167
|
formatInscriptionResult(result, options) {
|
|
134
|
-
if (result.confirmed) {
|
|
168
|
+
if (result.confirmed && !result.quote) {
|
|
135
169
|
const topicId = result.inscription?.topic_id || result.result.topicId;
|
|
136
170
|
const network = options.network || "testnet";
|
|
137
171
|
const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;
|
|
@@ -143,11 +177,14 @@ View inscription: ${cdnUrl}` : ""}
|
|
|
143
177
|
|
|
144
178
|
The inscription is now available.`;
|
|
145
179
|
}
|
|
146
|
-
|
|
180
|
+
if (!result.quote && !result.confirmed) {
|
|
181
|
+
return `Successfully submitted inscription to the Hedera network!
|
|
147
182
|
|
|
148
183
|
Transaction ID: ${result.result.transactionId}
|
|
149
184
|
|
|
150
185
|
The inscription is processing and will be confirmed shortly.`;
|
|
186
|
+
}
|
|
187
|
+
return "Inscription operation completed.";
|
|
151
188
|
}
|
|
152
189
|
async resolveContent(input, providedMimeType, providedFileName) {
|
|
153
190
|
const trimmedInput = input.trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es36.js","sources":["../../src/tools/inscriber/InscribeFromBufferTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport { InscriptionOptions, ContentResolverRegistry } from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\nimport { loadConfig } from '../../config/ContentReferenceConfig';\n\nconst inscribeFromBufferSchema = z.object({\n base64Data: z\n .string()\n .min(1, 'Data cannot be empty')\n .describe(\n 'The content to inscribe. Accept BOTH plain text AND base64. Also accepts content reference IDs in format \"content-ref:[id]\". When user says \"inscribe it\" or \"inscribe the content\", use the EXACT content from your previous message or from MCP tool results. DO NOT generate new content. DO NOT create repetitive text. Pass the actual search results or other retrieved content EXACTLY as you received it.'\n ),\n fileName: z\n .string()\n .min(1, 'File name cannot be empty')\n .describe('Name for the inscribed content. Required for all inscriptions.'),\n mimeType: z.string().optional().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(\n 'Timeout in milliseconds for inscription (default: no timeout - waits until completion)'\n ),\n apiKey: z.string().optional().describe('API key for inscription service'),\n});\n\nexport class InscribeFromBufferTool extends BaseInscriberQueryTool<\n typeof inscribeFromBufferSchema\n> {\n name = 'inscribeFromBuffer';\n description =\n 'Inscribe content that you have already retrieved or displayed. When user says \"inscribe it\" after you showed search results or other content, use THIS tool. The base64Data field accepts PLAIN TEXT (not just base64) and content reference IDs in format \"content-ref:[id]\". Pass the EXACT content from your previous response or MCP tool output. DO NOT generate new content or create repetitive text. Content references are automatically resolved to the original content for inscription.';\n\n private config = loadConfig();\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 this.validateInput(params);\n\n const resolvedContent = await this.resolveContent(\n params.base64Data,\n params.mimeType,\n params.fileName\n );\n\n this.validateContent(resolvedContent.buffer);\n\n const buffer = resolvedContent.buffer;\n const resolvedMimeType = resolvedContent.mimeType || params.mimeType;\n const resolvedFileName = resolvedContent.fileName || params.fileName;\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 const timeoutMs =\n params.timeoutMs || (options.waitForConfirmation ? 60000 : undefined);\n\n try {\n const result = await this.executeInscription(\n buffer,\n resolvedFileName,\n resolvedMimeType,\n options,\n timeoutMs\n );\n return this.formatInscriptionResult(result, options);\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : 'Failed to inscribe from buffer';\n throw new Error(`Inscription failed: ${errorMessage}`);\n }\n }\n\n private validateInput(\n params: z.infer<typeof inscribeFromBufferSchema>\n ): void {\n if (!params.base64Data || params.base64Data.trim() === '') {\n throw new Error(\n 'No data provided. Cannot inscribe empty content. Please provide valid content, plain text, base64 encoded data, or a content reference ID.'\n );\n }\n\n if (!params.fileName || params.fileName.trim() === '') {\n throw new Error(\n 'No fileName provided. A valid fileName is required for inscription.'\n );\n }\n }\n\n private validateContent(buffer: Buffer): void {\n if (buffer.length === 0) {\n throw new Error(\n 'Buffer is empty after conversion. The provided data appears to be invalid or empty.'\n );\n }\n\n if (buffer.length > this.config.maxInscriptionSize) {\n const maxSizeKB = Math.round(this.config.maxInscriptionSize / 1024);\n const bufferSizeKB = Math.round(buffer.length / 1024);\n throw new Error(\n `Content is too large for inscription (${bufferSizeKB}KB, max ${maxSizeKB}KB). Please summarize or extract key information before inscribing.`\n );\n }\n\n if (buffer.length < this.config.minContentSize) {\n throw new Error(\n `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\n if (\n buffer.toString('utf8', 0, Math.min(buffer.length, 100)).trim() === ''\n ) {\n throw new Error(\n 'Buffer contains only whitespace or empty content. Cannot inscribe meaningless data.'\n );\n }\n\n const contentStr = buffer.toString('utf8');\n const emptyHtmlPattern = /<a\\s+href=[\"'][^\"']+[\"']\\s*>\\s*<\\/a>/i;\n const hasOnlyEmptyLinks =\n emptyHtmlPattern.test(contentStr) &&\n contentStr.replace(/<[^>]+>/g, '').trim().length < 50;\n\n if (hasOnlyEmptyLinks) {\n throw new Error(\n 'Buffer contains empty HTML with only links and no actual content. When inscribing content from external sources, use the actual article text you retrieved, not empty HTML with links.'\n );\n }\n }\n\n private async executeInscription(\n buffer: Buffer,\n fileName: string,\n mimeType: string | undefined,\n options: InscriptionOptions,\n timeoutMs?: number\n ): Promise<Awaited<ReturnType<typeof this.inscriberBuilder.inscribe>>> {\n const inscriptionData = {\n type: 'buffer' as const,\n buffer,\n fileName,\n mimeType,\n };\n\n if (timeoutMs) {\n const timeoutPromise = new Promise<never>((_, reject) => {\n setTimeout(\n () => reject(new Error(`Inscription timed out after ${timeoutMs}ms`)),\n timeoutMs\n );\n });\n\n return Promise.race([\n this.inscriberBuilder.inscribe(inscriptionData, options),\n timeoutPromise,\n ]);\n }\n\n return this.inscriberBuilder.inscribe(inscriptionData, options);\n }\n\n private formatInscriptionResult(\n result: Awaited<ReturnType<typeof this.inscriberBuilder.inscribe>>,\n options: InscriptionOptions\n ): string {\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 }\n\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\n private async resolveContent(\n input: string,\n providedMimeType?: string,\n providedFileName?: string\n ): Promise<{\n buffer: Buffer;\n mimeType?: string;\n fileName?: string;\n wasReference?: boolean;\n }> {\n const trimmedInput = input.trim();\n \n // Try to get resolver from either injected dependency or registry\n const resolver = this.getContentResolver() || ContentResolverRegistry.getResolver();\n \n if (!resolver) {\n // No resolver available, handle content directly\n return this.handleDirectContent(trimmedInput, providedMimeType, providedFileName);\n }\n \n const referenceId = resolver.extractReferenceId(trimmedInput);\n\n if (referenceId) {\n try {\n const resolution = await resolver.resolveReference(referenceId);\n\n return {\n buffer: resolution.content,\n mimeType: resolution.metadata?.mimeType || providedMimeType,\n fileName: resolution.metadata?.fileName || providedFileName,\n wasReference: true,\n };\n } catch (error) {\n const errorMsg =\n error instanceof Error\n ? error.message\n : 'Unknown error resolving reference';\n throw new Error(`Reference resolution failed: ${errorMsg}`);\n }\n }\n\n // No reference found, handle as direct content\n return this.handleDirectContent(trimmedInput, providedMimeType, providedFileName);\n }\n\n private handleDirectContent(\n input: string,\n providedMimeType?: string,\n providedFileName?: string\n ): {\n buffer: Buffer;\n mimeType?: string;\n fileName?: string;\n wasReference?: boolean;\n } {\n const isValidBase64 = /^[A-Za-z0-9+/]*={0,2}$/.test(input);\n\n if (isValidBase64) {\n try {\n const buffer = Buffer.from(input, 'base64');\n return {\n buffer,\n mimeType: providedMimeType,\n fileName: providedFileName,\n wasReference: false,\n };\n } catch (error) {\n throw new Error(\n 'Failed to decode base64 data. Please ensure the data is properly encoded.'\n );\n }\n }\n\n const buffer = Buffer.from(input, 'utf8');\n return {\n buffer,\n mimeType: providedMimeType || 'text/plain',\n fileName: providedFileName,\n wasReference: false,\n };\n }\n}\n"],"names":["buffer"],"mappings":";;;;AAMA,MAAM,2BAA2B,EAAE,OAAO;AAAA,EACxC,YAAY,EACT,OAAA,EACA,IAAI,GAAG,sBAAsB,EAC7B;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,UAAU,EACP,SACA,IAAI,GAAG,2BAA2B,EAClC,SAAS,gEAAgE;AAAA,EAC5E,UAAU,EAAE,OAAA,EAAS,SAAA,EAAW,SAAS,0BAA0B;AAAA,EACnE,MAAM,EACH,KAAK,CAAC,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AM,eAAe,MAAM,KAAA;AAG3B,UAAM,WAAW,KAAK,mBAAA,KAAwB,wBAAwB,YAAA;AAEtE,QAAI,CAAC,UAAU;AAEb,aAAO,KAAK,oBAAoB,cAAc,kBAAkB,gBAAgB;AAAA,IAClF;AAEA,UAAM,cAAc,SAAS,mBAAmB,YAAY;AAE5D,QAAI,aAAa;AACf,UAAI;AACF,cAAM,aAAa,MAAM,SAAS,iBAAiB,WAAW;AAE9D,eAAO;AAAA,UACL,QAAQ,WAAW;AAAA,UACnB,UAAU,WAAW,UAAU,YAAY;AAAA,UAC3C,UAAU,WAAW,UAAU,YAAY;AAAA,UAC3C,cAAc;AAAA,QAAA;AAAA,MAElB,SAAS,OAAO;AACd,cAAM,WACJ,iBAAiB,QACb,MAAM,UACN;AACN,cAAM,IAAI,MAAM,gCAAgC,QAAQ,EAAE;AAAA,MAC5D;AAAA,IACF;AAGA,WAAO,KAAK,oBAAoB,cAAc,kBAAkB,gBAAgB;AAAA,EAClF;AAAA,EAEQ,oBACN,OACA,kBACA,kBAMA;AACA,UAAM,gBAAgB,yBAAyB,KAAK,KAAK;AAEzD,QAAI,eAAe;AACjB,UAAI;AACF,cAAMA,UAAS,OAAO,KAAK,OAAO,QAAQ;AAC1C,eAAO;AAAA,UACL,QAAAA;AAAAA,UACA,UAAU;AAAA,UACV,UAAU;AAAA,UACV,cAAc;AAAA,QAAA;AAAA,MAElB,SAAS,OAAO;AACd,cAAM,IAAI;AAAA,UACR;AAAA,QAAA;AAAA,MAEJ;AAAA,IACF;AAEA,UAAM,SAAS,OAAO,KAAK,OAAO,MAAM;AACxC,WAAO;AAAA,MACL;AAAA,MACA,UAAU,oBAAoB;AAAA,MAC9B,UAAU;AAAA,MACV,cAAc;AAAA,IAAA;AAAA,EAElB;AACF;"}
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es36.js","sources":["../../src/tools/inscriber/InscribeFromBufferTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport { InscriptionOptions, ContentResolverRegistry } from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\nimport { loadConfig } from '../../config/ContentReferenceConfig';\n\nconst inscribeFromBufferSchema = z.object({\n base64Data: z\n .string()\n .min(1, 'Data cannot be empty')\n .describe(\n 'The content to inscribe. Accept BOTH plain text AND base64. Also accepts content reference IDs in format \"content-ref:[id]\". When user says \"inscribe it\" or \"inscribe the content\", use the EXACT content from your previous message or from MCP tool results. DO NOT generate new content. DO NOT create repetitive text. Pass the actual search results or other retrieved content EXACTLY as you received it.'\n ),\n fileName: z\n .string()\n .min(1, 'File name cannot be empty')\n .describe('Name for the inscribed content. Required for all inscriptions.'),\n mimeType: z.string().optional().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(\n 'Timeout in milliseconds for inscription (default: no timeout - waits until completion)'\n ),\n apiKey: z.string().optional().describe('API key for inscription service'),\n quoteOnly: z\n .boolean()\n .optional()\n .default(false)\n .describe('If true, returns a cost quote instead of executing the inscription'),\n});\n\nexport class InscribeFromBufferTool extends BaseInscriberQueryTool<\n typeof inscribeFromBufferSchema\n> {\n name = 'inscribeFromBuffer';\n description =\n 'Inscribe content that you have already retrieved or displayed. When user says \"inscribe it\" after you showed search results or other content, use THIS tool. The base64Data field accepts PLAIN TEXT (not just base64) and content reference IDs in format \"content-ref:[id]\". Pass the EXACT content from your previous response or MCP tool output. DO NOT generate new content or create repetitive text. Content references are automatically resolved to the original content for inscription. Set quoteOnly=true to get cost estimates without executing the inscription.';\n\n private config = loadConfig();\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 this.validateInput(params);\n\n const resolvedContent = await this.resolveContent(\n params.base64Data,\n params.mimeType,\n params.fileName\n );\n\n this.validateContent(resolvedContent.buffer);\n\n const buffer = resolvedContent.buffer;\n const resolvedMimeType = resolvedContent.mimeType || params.mimeType;\n const resolvedFileName = resolvedContent.fileName || params.fileName;\n\n const options: InscriptionOptions = {\n mode: params.mode,\n metadata: params.metadata,\n tags: params.tags,\n chunkSize: params.chunkSize,\n waitForConfirmation: params.quoteOnly ? false : (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 quoteOnly: params.quoteOnly,\n };\n\n if (params.quoteOnly) {\n try {\n const quote = await this.generateInscriptionQuote(\n {\n type: 'buffer',\n buffer,\n fileName: resolvedFileName,\n mimeType: resolvedMimeType,\n },\n options\n );\n \n return {\n success: true,\n quote: {\n totalCostHbar: quote.totalCostHbar,\n validUntil: quote.validUntil,\n breakdown: quote.breakdown,\n },\n contentInfo: {\n fileName: resolvedFileName,\n mimeType: resolvedMimeType,\n sizeBytes: buffer.length,\n },\n message: `Quote generated for buffer content: ${resolvedFileName} (${(buffer.length / 1024).toFixed(2)} KB)\\nTotal cost: ${quote.totalCostHbar} HBAR\\nQuote valid until: ${new Date(quote.validUntil).toLocaleString()}`,\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'Failed to generate inscription quote';\n throw new Error(`Quote generation failed: ${errorMessage}`);\n }\n }\n\n const timeoutMs =\n params.timeoutMs || (options.waitForConfirmation ? 60000 : undefined);\n\n try {\n const result = await this.executeInscription(\n buffer,\n resolvedFileName,\n resolvedMimeType,\n options,\n timeoutMs\n );\n return this.formatInscriptionResult(result, options);\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : 'Failed to inscribe from buffer';\n throw new Error(`Inscription failed: ${errorMessage}`);\n }\n }\n\n private validateInput(\n params: z.infer<typeof inscribeFromBufferSchema>\n ): void {\n if (!params.base64Data || params.base64Data.trim() === '') {\n throw new Error(\n 'No data provided. Cannot inscribe empty content. Please provide valid content, plain text, base64 encoded data, or a content reference ID.'\n );\n }\n\n if (!params.fileName || params.fileName.trim() === '') {\n throw new Error(\n 'No fileName provided. A valid fileName is required for inscription.'\n );\n }\n }\n\n private validateContent(buffer: Buffer): void {\n if (buffer.length === 0) {\n throw new Error(\n 'Buffer is empty after conversion. The provided data appears to be invalid or empty.'\n );\n }\n\n if (buffer.length > this.config.maxInscriptionSize) {\n const maxSizeKB = Math.round(this.config.maxInscriptionSize / 1024);\n const bufferSizeKB = Math.round(buffer.length / 1024);\n throw new Error(\n `Content is too large for inscription (${bufferSizeKB}KB, max ${maxSizeKB}KB). Please summarize or extract key information before inscribing.`\n );\n }\n\n if (buffer.length < this.config.minContentSize) {\n throw new Error(\n `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\n if (\n buffer.toString('utf8', 0, Math.min(buffer.length, 100)).trim() === ''\n ) {\n throw new Error(\n 'Buffer contains only whitespace or empty content. Cannot inscribe meaningless data.'\n );\n }\n\n const contentStr = buffer.toString('utf8');\n const emptyHtmlPattern = /<a\\s+href=[\"'][^\"']+[\"']\\s*>\\s*<\\/a>/i;\n const hasOnlyEmptyLinks =\n emptyHtmlPattern.test(contentStr) &&\n contentStr.replace(/<[^>]+>/g, '').trim().length < 50;\n\n if (hasOnlyEmptyLinks) {\n throw new Error(\n 'Buffer contains empty HTML with only links and no actual content. When inscribing content from external sources, use the actual article text you retrieved, not empty HTML with links.'\n );\n }\n }\n\n private async executeInscription(\n buffer: Buffer,\n fileName: string,\n mimeType: string | undefined,\n options: InscriptionOptions,\n timeoutMs?: number\n ): Promise<Awaited<ReturnType<typeof this.inscriberBuilder.inscribe>>> {\n const inscriptionData = {\n type: 'buffer' as const,\n buffer,\n fileName,\n mimeType,\n };\n\n if (timeoutMs) {\n const timeoutPromise = new Promise<never>((_, reject) => {\n setTimeout(\n () => reject(new Error(`Inscription timed out after ${timeoutMs}ms`)),\n timeoutMs\n );\n });\n\n return Promise.race([\n this.inscriberBuilder.inscribe(inscriptionData, options),\n timeoutPromise,\n ]);\n }\n\n return this.inscriberBuilder.inscribe(inscriptionData, options);\n }\n\n private formatInscriptionResult(\n result: Awaited<ReturnType<typeof this.inscriberBuilder.inscribe>>,\n options: InscriptionOptions\n ): string {\n if (result.confirmed && !result.quote) {\n const topicId = result.inscription?.topic_id || (result.result as any).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 as any).transactionId\n }\\nTopic ID: ${topicId || 'N/A'}${\n cdnUrl ? `\\nView inscription: ${cdnUrl}` : ''\n }\\n\\nThe inscription is now available.`;\n }\n\n if (!result.quote && !result.confirmed) {\n return `Successfully submitted inscription to the Hedera network!\\n\\nTransaction ID: ${(result.result as any).transactionId}\\n\\nThe inscription is processing and will be confirmed shortly.`;\n }\n\n return 'Inscription operation completed.';\n }\n\n private async resolveContent(\n input: string,\n providedMimeType?: string,\n providedFileName?: string\n ): Promise<{\n buffer: Buffer;\n mimeType?: string;\n fileName?: string;\n wasReference?: boolean;\n }> {\n const trimmedInput = input.trim();\n \n const resolver = this.getContentResolver() || ContentResolverRegistry.getResolver();\n \n if (!resolver) {\n return this.handleDirectContent(trimmedInput, providedMimeType, providedFileName);\n }\n \n const referenceId = resolver.extractReferenceId(trimmedInput);\n\n if (referenceId) {\n try {\n const resolution = await resolver.resolveReference(referenceId);\n\n return {\n buffer: resolution.content,\n mimeType: resolution.metadata?.mimeType || providedMimeType,\n fileName: resolution.metadata?.fileName || providedFileName,\n wasReference: true,\n };\n } catch (error) {\n const errorMsg =\n error instanceof Error\n ? error.message\n : 'Unknown error resolving reference';\n throw new Error(`Reference resolution failed: ${errorMsg}`);\n }\n }\n\n return this.handleDirectContent(trimmedInput, providedMimeType, providedFileName);\n }\n\n private handleDirectContent(\n input: string,\n providedMimeType?: string,\n providedFileName?: string\n ): {\n buffer: Buffer;\n mimeType?: string;\n fileName?: string;\n wasReference?: boolean;\n } {\n const isValidBase64 = /^[A-Za-z0-9+/]*={0,2}$/.test(input);\n\n if (isValidBase64) {\n try {\n const buffer = Buffer.from(input, 'base64');\n return {\n buffer,\n mimeType: providedMimeType,\n fileName: providedFileName,\n wasReference: false,\n };\n } catch (error) {\n throw new Error(\n 'Failed to decode base64 data. Please ensure the data is properly encoded.'\n );\n }\n }\n\n const buffer = Buffer.from(input, 'utf8');\n return {\n buffer,\n mimeType: providedMimeType || 'text/plain',\n fileName: providedFileName,\n wasReference: false,\n };\n }\n}\n"],"names":["buffer"],"mappings":";;;;AAMA,MAAM,2BAA2B,EAAE,OAAO;AAAA,EACxC,YAAY,EACT,OAAA,EACA,IAAI,GAAG,sBAAsB,EAC7B;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,UAAU,EACP,SACA,IAAI,GAAG,2BAA2B,EAClC,SAAS,gEAAgE;AAAA,EAC5E,UAAU,EAAE,OAAA,EAAS,SAAA,EAAW,SAAS,0BAA0B;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,SAAS,uCAAuC;AAAA,EACnD,MAAM,EACH,MAAM,EAAE,OAAA,CAAQ,EAChB,SAAA,EACA,SAAS,oCAAoC;AAAA,EAChD,WAAW,EACR,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AEA,WAAO,KAAK,oBAAoB,cAAc,kBAAkB,gBAAgB;AAAA,EAClF;AAAA,EAEQ,oBACN,OACA,kBACA,kBAMA;AACA,UAAM,gBAAgB,yBAAyB,KAAK,KAAK;AAEzD,QAAI,eAAe;AACjB,UAAI;AACF,cAAMA,UAAS,OAAO,KAAK,OAAO,QAAQ;AAC1C,eAAO;AAAA,UACL,QAAAA;AAAAA,UACA,UAAU;AAAA,UACV,UAAU;AAAA,UACV,cAAc;AAAA,QAAA;AAAA,MAElB,SAAS,OAAO;AACd,cAAM,IAAI;AAAA,UACR;AAAA,QAAA;AAAA,MAEJ;AAAA,IACF;AAEA,UAAM,SAAS,OAAO,KAAK,OAAO,MAAM;AACxC,WAAO;AAAA,MACL;AAAA,MACA,UAAU,oBAAoB;AAAA,MAC9B,UAAU;AAAA,MACV,cAAc;AAAA,IAAA;AAAA,EAElB;AACF;"}
|
|
@@ -18,13 +18,14 @@ const inscribeHashinalSchema = z.object({
|
|
|
18
18
|
chunkSize: z.number().int().positive().optional().describe("Chunk size for large files"),
|
|
19
19
|
waitForConfirmation: z.boolean().optional().describe("Whether to wait for inscription confirmation"),
|
|
20
20
|
timeoutMs: z.number().int().positive().optional().describe("Timeout in milliseconds for inscription (default: no timeout - waits until completion)"),
|
|
21
|
-
apiKey: z.string().optional().describe("API key for inscription service")
|
|
21
|
+
apiKey: z.string().optional().describe("API key for inscription service"),
|
|
22
|
+
quoteOnly: z.boolean().optional().default(false).describe("If true, returns a cost quote instead of executing the inscription")
|
|
22
23
|
});
|
|
23
24
|
class InscribeHashinalTool extends BaseInscriberQueryTool {
|
|
24
25
|
constructor() {
|
|
25
26
|
super(...arguments);
|
|
26
27
|
this.name = "inscribeHashinal";
|
|
27
|
-
this.description = "Inscribe content as a Hashinal NFT on the Hedera network";
|
|
28
|
+
this.description = "Inscribe content as a Hashinal NFT on the Hedera network. Set quoteOnly=true to get cost estimates without executing the inscription.";
|
|
28
29
|
}
|
|
29
30
|
get specificInputSchema() {
|
|
30
31
|
return inscribeHashinalSchema;
|
|
@@ -44,12 +45,42 @@ class InscribeHashinalTool extends BaseInscriberQueryTool {
|
|
|
44
45
|
jsonFileURL: params.jsonFileURL,
|
|
45
46
|
tags: params.tags,
|
|
46
47
|
chunkSize: params.chunkSize,
|
|
47
|
-
waitForConfirmation: params.waitForConfirmation ?? true,
|
|
48
|
+
waitForConfirmation: params.quoteOnly ? false : params.waitForConfirmation ?? true,
|
|
48
49
|
waitMaxAttempts: 10,
|
|
49
50
|
waitIntervalMs: 3e3,
|
|
50
51
|
apiKey: params.apiKey,
|
|
51
|
-
network: this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet"
|
|
52
|
+
network: this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet",
|
|
53
|
+
quoteOnly: params.quoteOnly
|
|
52
54
|
};
|
|
55
|
+
if (params.quoteOnly) {
|
|
56
|
+
try {
|
|
57
|
+
const quote = await this.generateInscriptionQuote(
|
|
58
|
+
{ type: "url", url: params.url },
|
|
59
|
+
options
|
|
60
|
+
);
|
|
61
|
+
return {
|
|
62
|
+
success: true,
|
|
63
|
+
quote: {
|
|
64
|
+
totalCostHbar: quote.totalCostHbar,
|
|
65
|
+
validUntil: quote.validUntil,
|
|
66
|
+
breakdown: quote.breakdown
|
|
67
|
+
},
|
|
68
|
+
contentInfo: {
|
|
69
|
+
url: params.url,
|
|
70
|
+
name: params.name,
|
|
71
|
+
creator: params.creator,
|
|
72
|
+
type: params.type
|
|
73
|
+
},
|
|
74
|
+
message: `Quote generated for Hashinal NFT: ${params.name}
|
|
75
|
+
Creator: ${params.creator}
|
|
76
|
+
Total cost: ${quote.totalCostHbar} HBAR
|
|
77
|
+
Quote valid until: ${new Date(quote.validUntil).toLocaleString()}`
|
|
78
|
+
};
|
|
79
|
+
} catch (error) {
|
|
80
|
+
const errorMessage = error instanceof Error ? error.message : "Failed to generate inscription quote";
|
|
81
|
+
throw new Error(`Quote generation failed: ${errorMessage}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
53
84
|
try {
|
|
54
85
|
let result;
|
|
55
86
|
if (params.timeoutMs) {
|
|
@@ -72,7 +103,7 @@ class InscribeHashinalTool extends BaseInscriberQueryTool {
|
|
|
72
103
|
options
|
|
73
104
|
);
|
|
74
105
|
}
|
|
75
|
-
if (result.confirmed) {
|
|
106
|
+
if (result.confirmed && !result.quote) {
|
|
76
107
|
const topicId = result.inscription?.topic_id || result.result.topicId;
|
|
77
108
|
const network = options.network || "testnet";
|
|
78
109
|
const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;
|
|
@@ -83,12 +114,14 @@ Topic ID: ${topicId || "N/A"}${cdnUrl ? `
|
|
|
83
114
|
View inscription: ${cdnUrl}` : ""}
|
|
84
115
|
|
|
85
116
|
The Hashinal NFT is now available.`;
|
|
86
|
-
} else {
|
|
117
|
+
} else if (!result.quote && !result.confirmed) {
|
|
87
118
|
return `Successfully submitted Hashinal NFT inscription to the Hedera network!
|
|
88
119
|
|
|
89
120
|
Transaction ID: ${result.result.transactionId}
|
|
90
121
|
|
|
91
122
|
The inscription is processing and will be confirmed shortly.`;
|
|
123
|
+
} else {
|
|
124
|
+
return "Inscription operation completed.";
|
|
92
125
|
}
|
|
93
126
|
} catch (error) {
|
|
94
127
|
const errorMessage = error instanceof Error ? error.message : "Failed to inscribe Hashinal NFT";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es37.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 timeoutMs: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Timeout in milliseconds for inscription (default: no timeout - waits until completion)'),\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 let result: Awaited<ReturnType<typeof this.inscriberBuilder.inscribe>>;\n \n if (params.timeoutMs) {\n const timeoutPromise = new Promise<never>((_, 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 { type: 'url', url: params.url },\n options\n ),\n timeoutPromise\n ]);\n } else {\n result = await this.inscriberBuilder.inscribe(\n { type: 'url', url: params.url },\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 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,OAAA,EACA,IAAA,EACA,SAAA,EACA,SAAA,EACA,SAAS,4BAA4B;AAAA,EACxC,qBAAqB,EAClB,QAAA,EACA,SAAA,EACA,SAAS,8CAA8C;AAAA,EAC1D,WAAW,EACR,OAAA,EACA,IAAA,EACA,SAAA,EACA,SAAA,EACA,SAAS,wFAAwF;AAAA,EACpG,QAAQ,EACL,OAAA,EACA,SAAA,EACA,SAAS,iCAAiC;
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es37.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 timeoutMs: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Timeout in milliseconds for inscription (default: no timeout - waits until completion)'),\n apiKey: z\n .string()\n .optional()\n .describe('API key for inscription service'),\n quoteOnly: z\n .boolean()\n .optional()\n .default(false)\n .describe('If true, returns a cost quote instead of executing the inscription'),\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. Set quoteOnly=true to get cost estimates without executing the inscription.';\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.quoteOnly ? false : (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 quoteOnly: params.quoteOnly,\n };\n\n if (params.quoteOnly) {\n try {\n const quote = await this.generateInscriptionQuote(\n { type: 'url', url: params.url },\n options\n );\n \n return {\n success: true,\n quote: {\n totalCostHbar: quote.totalCostHbar,\n validUntil: quote.validUntil,\n breakdown: quote.breakdown,\n },\n contentInfo: {\n url: params.url,\n name: params.name,\n creator: params.creator,\n type: params.type,\n },\n message: `Quote generated for Hashinal NFT: ${params.name}\\nCreator: ${params.creator}\\nTotal cost: ${quote.totalCostHbar} HBAR\\nQuote valid until: ${new Date(quote.validUntil).toLocaleString()}`,\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'Failed to generate inscription quote';\n throw new Error(`Quote generation failed: ${errorMessage}`);\n }\n }\n\n try {\n let result: Awaited<ReturnType<typeof this.inscriberBuilder.inscribe>>;\n \n if (params.timeoutMs) {\n const timeoutPromise = new Promise<never>((_, 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 { type: 'url', url: params.url },\n options\n ),\n timeoutPromise\n ]);\n } else {\n result = await this.inscriberBuilder.inscribe(\n { type: 'url', url: params.url },\n options\n );\n }\n\n if (result.confirmed && !result.quote) {\n const topicId = result.inscription?.topic_id || (result.result as any).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 as any).transactionId}\\nTopic ID: ${topicId || 'N/A'}${cdnUrl ? `\\nView inscription: ${cdnUrl}` : ''}\\n\\nThe Hashinal NFT is now available.`;\n } else if (!result.quote && !result.confirmed) {\n return `Successfully submitted Hashinal NFT inscription to the Hedera network!\\n\\nTransaction ID: ${(result.result as any).transactionId}\\n\\nThe inscription is processing and will be confirmed shortly.`;\n } else {\n return 'Inscription operation completed.';\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,EAC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AO,IAAI,MAAM,+BAA+B,OAAO,SAAS,IAAI,CAAC;AAAA,YAC3E,OAAO;AAAA,UAAA;AAAA,QAEX,CAAC;AAED,iBAAS,MAAM,QAAQ,KAAK;AAAA,UAC1B,KAAK,iBAAiB;AAAA,YACpB,EAAE,MAAM,OAAO,KAAK,OAAO,IAAA;AAAA,YAC3B;AAAA,UAAA;AAAA,UAEF;AAAA,QAAA,CACD;AAAA,MACH,OAAO;AACL,iBAAS,MAAM,KAAK,iBAAiB;AAAA,UACnC,EAAE,MAAM,OAAO,KAAK,OAAO,IAAA;AAAA,UAC3B;AAAA,QAAA;AAAA,MAEJ;AAEA,UAAI,OAAO,aAAa,CAAC,OAAO,OAAO;AACrC,cAAM,UAAU,OAAO,aAAa,YAAa,OAAO,OAAe;AACvE,cAAM,UAAU,QAAQ,WAAW;AACnC,cAAM,SAAS,UAAU,8CAA8C,OAAO,YAAY,OAAO,KAAK;AACtG,eAAO;AAAA;AAAA,kBAAgG,OAAO,OAAe,aAAa;AAAA,YAAe,WAAW,KAAK,GAAG,SAAS;AAAA,oBAAuB,MAAM,KAAK,EAAE;AAAA;AAAA;AAAA,MAC3N,WAAW,CAAC,OAAO,SAAS,CAAC,OAAO,WAAW;AAC7C,eAAO;AAAA;AAAA,kBAA8F,OAAO,OAAe,aAAa;AAAA;AAAA;AAAA,MAC1I,OAAO;AACL,eAAO;AAAA,MACT;AAAA,IACF,SAAS,OAAO;AACd,YAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU;AAC9D,YAAM,IAAI,MAAM,uBAAuB,YAAY,EAAE;AAAA,IACvD;AAAA,EACF;AACF;"}
|
|
@@ -10,7 +10,7 @@ class HCS6Builder extends BaseServiceBuilder {
|
|
|
10
10
|
async getHCS6Client() {
|
|
11
11
|
if (!this.hcs6Client) {
|
|
12
12
|
const operatorId = this.hederaKit.signer.getAccountId().toString();
|
|
13
|
-
const operatorPrivateKey = this.hederaKit.signer?.getOperatorPrivateKey() ? this.hederaKit.signer.getOperatorPrivateKey().
|
|
13
|
+
const operatorPrivateKey = this.hederaKit.signer?.getOperatorPrivateKey() ? this.hederaKit.signer.getOperatorPrivateKey().toString() : "";
|
|
14
14
|
const network = this.hederaKit.client.network;
|
|
15
15
|
const networkType = network.toString().includes("mainnet") ? "mainnet" : "testnet";
|
|
16
16
|
const config = {
|
|
@@ -28,7 +28,11 @@ class HCS6Builder extends BaseServiceBuilder {
|
|
|
28
28
|
*/
|
|
29
29
|
async createRegistry(options = {}) {
|
|
30
30
|
const client = await this.getHCS6Client();
|
|
31
|
-
|
|
31
|
+
const sanitized = { ...options };
|
|
32
|
+
if ("adminKey" in sanitized) {
|
|
33
|
+
delete sanitized.adminKey;
|
|
34
|
+
}
|
|
35
|
+
return await client.createRegistry(sanitized);
|
|
32
36
|
}
|
|
33
37
|
/**
|
|
34
38
|
* Register a new dynamic hashinal entry in an HCS-6 registry
|
|
@@ -49,7 +53,17 @@ class HCS6Builder extends BaseServiceBuilder {
|
|
|
49
53
|
*/
|
|
50
54
|
async createHashinal(options) {
|
|
51
55
|
const client = await this.getHCS6Client();
|
|
52
|
-
|
|
56
|
+
const metadata = {
|
|
57
|
+
name: options.metadata?.name || "Dynamic Hashinal",
|
|
58
|
+
creator: options.metadata?.creator || this.hederaKit.signer.getAccountId().toString(),
|
|
59
|
+
description: options.metadata?.description || "Dynamic hashinal metadata",
|
|
60
|
+
type: options.metadata?.type || "json",
|
|
61
|
+
...options.metadata
|
|
62
|
+
};
|
|
63
|
+
return await client.createHashinal({
|
|
64
|
+
...options,
|
|
65
|
+
metadata
|
|
66
|
+
});
|
|
53
67
|
}
|
|
54
68
|
/**
|
|
55
69
|
* Register a dynamic hashinal with combined inscription and registry creation
|
|
@@ -57,7 +71,17 @@ class HCS6Builder extends BaseServiceBuilder {
|
|
|
57
71
|
*/
|
|
58
72
|
async register(options) {
|
|
59
73
|
const client = await this.getHCS6Client();
|
|
60
|
-
|
|
74
|
+
const metadata = {
|
|
75
|
+
name: options.metadata?.name || "Dynamic Hashinal",
|
|
76
|
+
creator: options.metadata?.creator || this.hederaKit.signer.getAccountId().toString(),
|
|
77
|
+
description: options.metadata?.description || "Dynamic hashinal registration",
|
|
78
|
+
type: options.metadata?.type || "json",
|
|
79
|
+
...options.metadata
|
|
80
|
+
};
|
|
81
|
+
return await client.register({
|
|
82
|
+
...options,
|
|
83
|
+
metadata
|
|
84
|
+
});
|
|
61
85
|
}
|
|
62
86
|
/**
|
|
63
87
|
* Submit a raw message to an HCS-6 topic
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es5.js","sources":["../../src/builders/hcs6/hcs6-builder.ts"],"sourcesContent":["import { BaseServiceBuilder } from 'hedera-agent-kit';\nimport type { HederaAgentKit } from 'hedera-agent-kit';\nimport {\n HCS6Client,\n SDKHCS6ClientConfig,\n HCS6CreateRegistryOptions,\n HCS6RegisterEntryOptions,\n HCS6QueryRegistryOptions,\n HCS6RegisterOptions,\n HCS6CreateHashinalOptions,\n HCS6TopicRegistrationResponse,\n HCS6RegistryOperationResponse,\n HCS6TopicRegistry,\n HCS6CreateHashinalResponse,\n NetworkType,\n} from '@hashgraphonline/standards-sdk';\n\n/**\n * Builder for HCS-6 operations that delegates to HCS6Client\n */\nexport class HCS6Builder extends BaseServiceBuilder {\n protected hcs6Client?: HCS6Client;\n\n constructor(hederaKit: HederaAgentKit) {\n super(hederaKit);\n }\n\n /**\n * Get or create HCS-6 client\n */\n protected async getHCS6Client(): Promise<HCS6Client> {\n if (!this.hcs6Client) {\n const operatorId = this.hederaKit.signer.getAccountId().toString();\n const operatorPrivateKey = this.hederaKit.signer?.getOperatorPrivateKey()\n ? this.hederaKit.signer.getOperatorPrivateKey().
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es5.js","sources":["../../src/builders/hcs6/hcs6-builder.ts"],"sourcesContent":["import { BaseServiceBuilder } from 'hedera-agent-kit';\nimport type { HederaAgentKit } from 'hedera-agent-kit';\nimport {\n HCS6Client,\n SDKHCS6ClientConfig,\n HCS6CreateRegistryOptions,\n HCS6RegisterEntryOptions,\n HCS6QueryRegistryOptions,\n HCS6RegisterOptions,\n HCS6CreateHashinalOptions,\n HCS6TopicRegistrationResponse,\n HCS6RegistryOperationResponse,\n HCS6TopicRegistry,\n HCS6CreateHashinalResponse,\n NetworkType,\n} from '@hashgraphonline/standards-sdk';\n\n/**\n * Builder for HCS-6 operations that delegates to HCS6Client\n */\nexport class HCS6Builder extends BaseServiceBuilder {\n protected hcs6Client?: HCS6Client;\n\n constructor(hederaKit: HederaAgentKit) {\n super(hederaKit);\n }\n\n /**\n * Get or create HCS-6 client\n */\n protected async getHCS6Client(): Promise<HCS6Client> {\n if (!this.hcs6Client) {\n const operatorId = this.hederaKit.signer.getAccountId().toString();\n const operatorPrivateKey = this.hederaKit.signer?.getOperatorPrivateKey()\n ? this.hederaKit.signer.getOperatorPrivateKey().toString()\n : '';\n\n const network = this.hederaKit.client.network;\n const networkType: NetworkType = network.toString().includes('mainnet')\n ? 'mainnet'\n : 'testnet';\n\n const config: SDKHCS6ClientConfig = {\n network: networkType,\n operatorId: operatorId,\n operatorKey: operatorPrivateKey,\n };\n\n this.hcs6Client = new HCS6Client(config);\n }\n return this.hcs6Client;\n }\n\n /**\n * Create a new HCS-6 dynamic registry\n * Note: This executes the transaction directly via HCS6Client\n */\n async createRegistry(\n options: HCS6CreateRegistryOptions = {}\n ): Promise<HCS6TopicRegistrationResponse> {\n const client = await this.getHCS6Client();\n const sanitized = { ...options };\n if ('adminKey' in sanitized) {\n delete (sanitized as any).adminKey;\n }\n return await client.createRegistry(sanitized);\n }\n\n /**\n * Register a new dynamic hashinal entry in an HCS-6 registry\n */\n async registerEntry(\n registryTopicId: string,\n options: HCS6RegisterEntryOptions\n ): Promise<HCS6RegistryOperationResponse> {\n const client = await this.getHCS6Client();\n return await client.registerEntry(registryTopicId, options);\n }\n\n /**\n * Query entries from an HCS-6 registry\n */\n async getRegistry(\n topicId: string,\n options: HCS6QueryRegistryOptions = {}\n ): Promise<HCS6TopicRegistry> {\n const client = await this.getHCS6Client();\n return await client.getRegistry(topicId, options);\n }\n\n /**\n * Create a complete dynamic hashinal with inscription and registry\n */\n async createHashinal(\n options: HCS6CreateHashinalOptions\n ): Promise<HCS6CreateHashinalResponse> {\n const client = await this.getHCS6Client();\n const metadata = {\n name: options.metadata?.name || 'Dynamic Hashinal',\n creator:\n options.metadata?.creator || this.hederaKit.signer.getAccountId().toString(),\n description: options.metadata?.description || 'Dynamic hashinal metadata',\n type: options.metadata?.type || 'json',\n ...options.metadata,\n } as Record<string, unknown>;\n\n return await client.createHashinal({\n ...options,\n metadata,\n });\n }\n\n /**\n * Register a dynamic hashinal with combined inscription and registry creation\n * This is the main method for creating and updating dynamic hashinals\n */\n async register(\n options: HCS6RegisterOptions\n ): Promise<HCS6CreateHashinalResponse> {\n const client = await this.getHCS6Client();\n const metadata = {\n name: options.metadata?.name || 'Dynamic Hashinal',\n creator:\n options.metadata?.creator || this.hederaKit.signer.getAccountId().toString(),\n description:\n options.metadata?.description || 'Dynamic hashinal registration',\n type: options.metadata?.type || 'json',\n ...options.metadata,\n } as Record<string, unknown>;\n\n return await client.register({\n ...options,\n metadata,\n });\n }\n\n /**\n * Submit a raw message to an HCS-6 topic\n */\n async submitMessage(\n topicId: string,\n payload: any\n ): Promise<any> {\n const client = await this.getHCS6Client();\n return await client.submitMessage(topicId, payload);\n }\n\n /**\n * Get topic info from mirror node\n */\n async getTopicInfo(topicId: string): Promise<any> {\n const client = await this.getHCS6Client();\n return await client.getTopicInfo(topicId);\n }\n\n /**\n * Close the HCS-6 client\n */\n async close(): Promise<void> {\n if (this.hcs6Client) {\n this.hcs6Client.close();\n this.hcs6Client = undefined;\n }\n }\n}"],"names":[],"mappings":";;AAoBO,MAAM,oBAAoB,mBAAmB;AAAA,EAGlD,YAAY,WAA2B;AACrC,UAAM,SAAS;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAgB,gBAAqC;AACnD,QA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,QAAQ,UAAU,QAAQ;AAAA,MAChC,GAAG,QAAQ;AAAA,IAAA;AAGb,WAAO,MAAM,OAAO,eAAe;AAAA,MACjC,GAAG;AAAA,MACH;AAAA,IAAA,CACD;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,SACJ,SACqC;AACrC,UAAM,SAAS,MAAM,KAAK,cAAA;AAC1B,UAAM,WAAW;AAAA,MACf,MAAM,QAAQ,UAAU,QAAQ;AAAA,MAChC,SACE,QAAQ,UAAU,WAAW,KAAK,UAAU,OAAO,aAAA,EAAe,SAAA;AAAA,MACpE,aACE,QAAQ,UAAU,eAAe;AAAA,MACnC,MAAM,QAAQ,UAAU,QAAQ;AAAA,MAChC,GAAG,QAAQ;AAAA,IAAA;AAGb,WAAO,MAAM,OAAO,SAAS;AAAA,MAC3B,GAAG;AAAA,MACH;AAAA,IAAA,CACD;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,cACJ,SACA,SACc;AACd,UAAM,SAAS,MAAM,KAAK,cAAA;AAC1B,WAAO,MAAM,OAAO,cAAc,SAAS,OAAO;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAAa,SAA+B;AAChD,UAAM,SAAS,MAAM,KAAK,cAAA;AAC1B,WAAO,MAAM,OAAO,aAAa,OAAO;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,QAAuB;AAC3B,QAAI,KAAK,YAAY;AACnB,WAAK,WAAW,MAAA;AAChB,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AACF;"}
|
|
@@ -7,15 +7,12 @@ import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
|
7
7
|
*/
|
|
8
8
|
declare const CreateDynamicRegistrySchema: z.ZodObject<{
|
|
9
9
|
ttl: z.ZodDefault<z.ZodNumber>;
|
|
10
|
-
adminKey: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
11
10
|
submitKey: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
12
11
|
}, "strip", z.ZodTypeAny, {
|
|
13
12
|
ttl: number;
|
|
14
|
-
adminKey?: string | boolean | undefined;
|
|
15
13
|
submitKey?: string | boolean | undefined;
|
|
16
14
|
}, {
|
|
17
15
|
ttl?: number | undefined;
|
|
18
|
-
adminKey?: string | boolean | undefined;
|
|
19
16
|
submitKey?: string | boolean | undefined;
|
|
20
17
|
}>;
|
|
21
18
|
export type CreateDynamicRegistryInput = z.infer<typeof CreateDynamicRegistrySchema>;
|
|
@@ -27,15 +24,12 @@ export declare class CreateDynamicRegistryTool extends BaseHCS6QueryTool<typeof
|
|
|
27
24
|
description: string;
|
|
28
25
|
get specificInputSchema(): z.ZodObject<{
|
|
29
26
|
ttl: z.ZodDefault<z.ZodNumber>;
|
|
30
|
-
adminKey: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
31
27
|
submitKey: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
32
28
|
}, "strip", z.ZodTypeAny, {
|
|
33
29
|
ttl: number;
|
|
34
|
-
adminKey?: string | boolean | undefined;
|
|
35
30
|
submitKey?: string | boolean | undefined;
|
|
36
31
|
}, {
|
|
37
32
|
ttl?: number | undefined;
|
|
38
|
-
adminKey?: string | boolean | undefined;
|
|
39
33
|
submitKey?: string | boolean | undefined;
|
|
40
34
|
}>;
|
|
41
35
|
constructor(params: HCS6QueryToolParams);
|
|
@@ -12,7 +12,9 @@ declare const inscribeFromBufferSchema: z.ZodObject<{
|
|
|
12
12
|
waitForConfirmation: z.ZodOptional<z.ZodBoolean>;
|
|
13
13
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
14
14
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
15
|
+
quoteOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
15
16
|
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
quoteOnly: boolean;
|
|
16
18
|
fileName: string;
|
|
17
19
|
base64Data: string;
|
|
18
20
|
tags?: string[] | undefined;
|
|
@@ -34,6 +36,7 @@ declare const inscribeFromBufferSchema: z.ZodObject<{
|
|
|
34
36
|
waitForConfirmation?: boolean | undefined;
|
|
35
37
|
timeoutMs?: number | undefined;
|
|
36
38
|
apiKey?: string | undefined;
|
|
39
|
+
quoteOnly?: boolean | undefined;
|
|
37
40
|
}>;
|
|
38
41
|
export declare class InscribeFromBufferTool extends BaseInscriberQueryTool<typeof inscribeFromBufferSchema> {
|
|
39
42
|
name: string;
|
|
@@ -50,7 +53,9 @@ export declare class InscribeFromBufferTool extends BaseInscriberQueryTool<typeo
|
|
|
50
53
|
waitForConfirmation: z.ZodOptional<z.ZodBoolean>;
|
|
51
54
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
52
55
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
56
|
+
quoteOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
53
57
|
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
quoteOnly: boolean;
|
|
54
59
|
fileName: string;
|
|
55
60
|
base64Data: string;
|
|
56
61
|
tags?: string[] | undefined;
|
|
@@ -72,6 +77,7 @@ export declare class InscribeFromBufferTool extends BaseInscriberQueryTool<typeo
|
|
|
72
77
|
waitForConfirmation?: boolean | undefined;
|
|
73
78
|
timeoutMs?: number | undefined;
|
|
74
79
|
apiKey?: string | undefined;
|
|
80
|
+
quoteOnly?: boolean | undefined;
|
|
75
81
|
}>;
|
|
76
82
|
protected executeQuery(params: z.infer<typeof inscribeFromBufferSchema>, _runManager?: CallbackManagerForToolRun): Promise<unknown>;
|
|
77
83
|
private validateInput;
|
|
@@ -13,7 +13,9 @@ declare const inscribeFromFileSchema: z.ZodObject<{
|
|
|
13
13
|
waitForConfirmation: z.ZodOptional<z.ZodBoolean>;
|
|
14
14
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
15
15
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
16
|
+
quoteOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
16
17
|
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
quoteOnly: boolean;
|
|
17
19
|
filePath: string;
|
|
18
20
|
tags?: string[] | undefined;
|
|
19
21
|
metadata?: Record<string, unknown> | undefined;
|
|
@@ -31,6 +33,7 @@ declare const inscribeFromFileSchema: z.ZodObject<{
|
|
|
31
33
|
waitForConfirmation?: boolean | undefined;
|
|
32
34
|
timeoutMs?: number | undefined;
|
|
33
35
|
apiKey?: string | undefined;
|
|
36
|
+
quoteOnly?: boolean | undefined;
|
|
34
37
|
}>;
|
|
35
38
|
/**
|
|
36
39
|
* Tool for inscribing content from file
|
|
@@ -13,8 +13,10 @@ declare const inscribeFromUrlSchema: z.ZodObject<{
|
|
|
13
13
|
waitForConfirmation: z.ZodOptional<z.ZodBoolean>;
|
|
14
14
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
15
15
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
16
|
+
quoteOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
16
17
|
}, "strip", z.ZodTypeAny, {
|
|
17
18
|
url: string;
|
|
19
|
+
quoteOnly: boolean;
|
|
18
20
|
tags?: string[] | undefined;
|
|
19
21
|
metadata?: Record<string, unknown> | undefined;
|
|
20
22
|
mode?: "file" | "hashinal" | undefined;
|
|
@@ -31,6 +33,7 @@ declare const inscribeFromUrlSchema: z.ZodObject<{
|
|
|
31
33
|
waitForConfirmation?: boolean | undefined;
|
|
32
34
|
timeoutMs?: number | undefined;
|
|
33
35
|
apiKey?: string | undefined;
|
|
36
|
+
quoteOnly?: boolean | undefined;
|
|
34
37
|
}>;
|
|
35
38
|
/**
|
|
36
39
|
* Tool for inscribing content from URL
|
|
@@ -47,8 +50,10 @@ export declare class InscribeFromUrlTool extends BaseInscriberQueryTool<typeof i
|
|
|
47
50
|
waitForConfirmation: z.ZodOptional<z.ZodBoolean>;
|
|
48
51
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
49
52
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
53
|
+
quoteOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
50
54
|
}, "strip", z.ZodTypeAny, {
|
|
51
55
|
url: string;
|
|
56
|
+
quoteOnly: boolean;
|
|
52
57
|
tags?: string[] | undefined;
|
|
53
58
|
metadata?: Record<string, unknown> | undefined;
|
|
54
59
|
mode?: "file" | "hashinal" | undefined;
|
|
@@ -65,6 +70,7 @@ export declare class InscribeFromUrlTool extends BaseInscriberQueryTool<typeof i
|
|
|
65
70
|
waitForConfirmation?: boolean | undefined;
|
|
66
71
|
timeoutMs?: number | undefined;
|
|
67
72
|
apiKey?: string | undefined;
|
|
73
|
+
quoteOnly?: boolean | undefined;
|
|
68
74
|
}>;
|
|
69
75
|
protected executeQuery(params: z.infer<typeof inscribeFromUrlSchema>, _runManager?: CallbackManagerForToolRun): Promise<unknown>;
|
|
70
76
|
}
|