@hashgraphonline/standards-agent-kit 0.2.123 → 0.2.124

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.
@@ -142,8 +142,7 @@ class InscribeFromUrlTool extends BaseInscriberQueryTool {
142
142
  url: params.url
143
143
  },
144
144
  message: `Quote generated for URL: ${params.url}
145
- Total cost: ${quote.totalCostHbar} HBAR
146
- Quote valid until: ${new Date(quote.validUntil).toLocaleString()}`
145
+ Total cost: ${quote.totalCostHbar} HBAR`
147
146
  };
148
147
  } catch (error) {
149
148
  const errorMessage = error instanceof Error ? error.message : "Failed to generate inscription quote";
@@ -1 +1 @@
1
- {"version":3,"file":"standards-agent-kit.es34.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('ONLY direct file download URLs with file extensions (.pdf, .jpg, .png, .json, .zip). NEVER use for web pages, articles, or when you already have 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 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 content from URL\n */\nexport class InscribeFromUrlTool extends BaseInscriberQueryTool<typeof inscribeFromUrlSchema> {\n name = 'inscribeFromUrl';\n description = 'ONLY for direct FILE DOWNLOAD URLs ending with file extensions (.pdf, .jpg, .png, .json, .zip). NEVER use for web pages, articles, or ANY HTML content - it WILL FAIL. If you have already retrieved content from any source (including MCP tools), you MUST use inscribeFromBuffer instead. This tool downloads files from URLs - it does NOT inscribe content you already have. When asked to \"inscribe it\" after retrieving content, ALWAYS use inscribeFromBuffer with the actual content. Set quoteOnly=true to get cost estimates without executing the inscription.';\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 \n } catch (error) {\n if (error instanceof Error && error.message.includes('Cannot inscribe content from')) {\n throw error;\n }\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 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 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 (!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 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 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.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 },\n message: `Quote generated for URL: ${params.url}\\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 content on the Hedera network!\\n\\nTransaction ID: ${(result.result as any).transactionId}\\nTopic ID: ${topicId || 'N/A'}${cdnUrl ? `\\nView inscription: ${cdnUrl}` : ''}\\n\\nThe inscription is now available.`;\n } else 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 } else {\n return 'Inscription operation completed.';\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,uKAAuK;AAAA,EACtM,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,wFAAwF;AAAA,EACpG,QAAQ,EACL,OAAA,EACA,SAAA,EACA,SAAS,iCAAiC;AAAA,EAC7C,WAAW,E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,MAAM,KAAK,EAAE;AAAA;AAAA;AAAA,MACtN,WAAW,CAAC,OAAO,SAAS,CAAC,OAAO,WAAW;AAC7C,eAAO;AAAA;AAAA,kBAAiF,OAAO,OAAe,aAAa;AAAA;AAAA;AAAA,MAC7H,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;"}
1
+ {"version":3,"file":"standards-agent-kit.es34.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('ONLY direct file download URLs with file extensions (.pdf, .jpg, .png, .json, .zip). NEVER use for web pages, articles, or when you already have 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 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 content from URL\n */\nexport class InscribeFromUrlTool extends BaseInscriberQueryTool<typeof inscribeFromUrlSchema> {\n name = 'inscribeFromUrl';\n description = 'ONLY for direct FILE DOWNLOAD URLs ending with file extensions (.pdf, .jpg, .png, .json, .zip). NEVER use for web pages, articles, or ANY HTML content - it WILL FAIL. If you have already retrieved content from any source (including MCP tools), you MUST use inscribeFromBuffer instead. This tool downloads files from URLs - it does NOT inscribe content you already have. When asked to \"inscribe it\" after retrieving content, ALWAYS use inscribeFromBuffer with the actual content. Set quoteOnly=true to get cost estimates without executing the inscription.';\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 \n } catch (error) {\n if (error instanceof Error && error.message.includes('Cannot inscribe content from')) {\n throw error;\n }\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 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 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 (!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 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 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.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 },\n message: `Quote generated for URL: ${params.url}\\nTotal cost: ${quote.totalCostHbar} HBAR`,\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 content on the Hedera network!\\n\\nTransaction ID: ${(result.result as any).transactionId}\\nTopic ID: ${topicId || 'N/A'}${cdnUrl ? `\\nView inscription: ${cdnUrl}` : ''}\\n\\nThe inscription is now available.`;\n } else 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 } else {\n return 'Inscription operation completed.';\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,uKAAuK;AAAA,EACtM,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,wFAAwF;AAAA,EACpG,QAAQ,EACL,OAAA,EACA,SAAA,EACA,SAAS,iCAAiC;AAAA,EAC7C,WAAW,EACR,UACA,SAAA,EACA,QAAQ,KAAK,EACb,SAAS,oEAAoE;AAClF,CAAC;AAMM,MAAM,4BAA4B,uBAAqD;AAAA,EAAvF,cAAA;AAAA,U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,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;"}
@@ -3,7 +3,9 @@ import { BaseInscriberQueryTool } from "./standards-agent-kit.es33.js";
3
3
  import * as fs from "fs/promises";
4
4
  import * as path from "path";
5
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."),
6
+ filePath: z.string().min(1, "File path cannot be empty").describe(
7
+ "The file path of the content to inscribe. Must point to a valid, non-empty file."
8
+ ),
7
9
  mode: z.enum(["file", "hashinal"]).optional().describe("Inscription mode: file or hashinal NFT"),
8
10
  metadata: z.record(z.unknown()).optional().describe("Metadata to attach to the inscription"),
9
11
  tags: z.array(z.string()).optional().describe("Tags to categorize the inscription"),
@@ -11,7 +13,9 @@ const inscribeFromFileSchema = z.object({
11
13
  waitForConfirmation: z.boolean().optional().describe("Whether to wait for inscription confirmation"),
12
14
  timeoutMs: z.number().int().positive().optional().describe("Timeout in milliseconds for inscription (default: no timeout)"),
13
15
  apiKey: z.string().optional().describe("API key for inscription service"),
14
- quoteOnly: z.boolean().optional().default(false).describe("If true, returns a cost quote instead of executing the inscription")
16
+ quoteOnly: z.boolean().optional().default(false).describe(
17
+ "If true, returns a cost quote instead of executing the inscription"
18
+ )
15
19
  });
16
20
  class InscribeFromFileTool extends BaseInscriberQueryTool {
17
21
  constructor() {
@@ -23,7 +27,9 @@ class InscribeFromFileTool extends BaseInscriberQueryTool {
23
27
  return inscribeFromFileSchema;
24
28
  }
25
29
  async executeQuery(params, _runManager) {
26
- console.log(`[DEBUG] InscribeFromFileTool.executeQuery called with: ${params.filePath}`);
30
+ console.log(
31
+ `[DEBUG] InscribeFromFileTool.executeQuery called with: ${params.filePath}`
32
+ );
27
33
  let fileContent;
28
34
  try {
29
35
  console.log(`[DEBUG] Checking file: ${params.filePath}`);
@@ -44,7 +50,9 @@ class InscribeFromFileTool extends BaseInscriberQueryTool {
44
50
  );
45
51
  }
46
52
  if (stats.size > 100 * 1024 * 1024) {
47
- console.log(`[InscribeFromFileTool] WARNING: Large file detected (${(stats.size / (1024 * 1024)).toFixed(2)} MB)`);
53
+ console.log(
54
+ `[InscribeFromFileTool] WARNING: Large file detected (${(stats.size / (1024 * 1024)).toFixed(2)} MB)`
55
+ );
48
56
  }
49
57
  this.logger?.info("Reading file content...");
50
58
  fileContent = await fs.readFile(params.filePath);
@@ -62,7 +70,11 @@ class InscribeFromFileTool extends BaseInscriberQueryTool {
62
70
  const fileName2 = path.basename(params.filePath);
63
71
  const mimeType2 = this.getMimeType(fileName2);
64
72
  if (mimeType2.startsWith("text/") || mimeType2 === "application/json") {
65
- const textContent = fileContent.toString("utf8", 0, Math.min(fileContent.length, 1e3));
73
+ const textContent = fileContent.toString(
74
+ "utf8",
75
+ 0,
76
+ Math.min(fileContent.length, 1e3)
77
+ );
66
78
  if (textContent.trim() === "") {
67
79
  throw new Error(
68
80
  `File "${params.filePath}" contains only whitespace or empty content. Cannot inscribe meaningless data.`
@@ -120,8 +132,7 @@ class InscribeFromFileTool extends BaseInscriberQueryTool {
120
132
  filePath: params.filePath
121
133
  },
122
134
  message: `Quote generated for file: ${fileName} (${(fileContent.length / 1024).toFixed(2)} KB)
123
- Total cost: ${quote.totalCostHbar} HBAR
124
- Quote valid until: ${new Date(quote.validUntil).toLocaleString()}`
135
+ Total cost: ${quote.totalCostHbar} HBAR`
125
136
  };
126
137
  } catch (error) {
127
138
  const errorMessage = error instanceof Error ? error.message : "Failed to generate inscription quote";
@@ -133,7 +144,9 @@ Quote valid until: ${new Date(quote.validUntil).toLocaleString()}`
133
144
  if (params.timeoutMs) {
134
145
  const timeoutPromise = new Promise((_, reject) => {
135
146
  setTimeout(
136
- () => reject(new Error(`Inscription timed out after ${params.timeoutMs}ms`)),
147
+ () => reject(
148
+ new Error(`Inscription timed out after ${params.timeoutMs}ms`)
149
+ ),
137
150
  params.timeoutMs
138
151
  );
139
152
  });
@@ -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 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,EA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,aAAa;AAAA;AAAA;AAAA,MAC/H,OAAO;AACL,eAAO;AAAA,MACT;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\n .string()\n .min(1, 'File path cannot be empty')\n .describe(\n 'The file path of the content to inscribe. Must point to a valid, non-empty file.'\n ),\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(\n 'If true, returns a cost quote instead of executing the inscription'\n ),\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(\n `[DEBUG] InscribeFromFileTool.executeQuery called with: ${params.filePath}`\n );\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(\n `[InscribeFromFileTool] WARNING: Large file detected (${(\n stats.size /\n (1024 * 1024)\n ).toFixed(2)} MB)`\n );\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(\n 'utf8',\n 0,\n Math.min(fileContent.length, 1000)\n );\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\n ? false\n : 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} (${(\n fileContent.length / 1024\n ).toFixed(2)} KB)\\nTotal cost: ${\n quote.totalCostHbar\n } HBAR`,\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : '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 () =>\n reject(\n new Error(`Inscription timed out after ${params.timeoutMs}ms`)\n ),\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 =\n inscriptionResult.inscription?.topic_id ||\n 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,EACP,OAAA,EACA,IAAI,GAAG,2BAA2B,EAClC;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,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,QAAA,EACA,WACA,QAAQ,KA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A;AAEV,WAAO,UAAU,GAAG,KAAK;AAAA,EAC3B;AACF;"}
@@ -76,8 +76,7 @@ class InscribeFromBufferTool extends BaseInscriberQueryTool {
76
76
  sizeBytes: buffer.length
77
77
  },
78
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()}`
79
+ Total cost: ${quote.totalCostHbar} HBAR`
81
80
  };
82
81
  } catch (error) {
83
82
  const errorMessage = error instanceof Error ? error.message : "Failed to generate inscription quote";
@@ -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 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":";;;;AAM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AW,KAAK,mBAAA,KAAwB,wBAAwB,YAAA;AAEtE,QAAI,CAAC,UAAU;AACb,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;AAEA,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`,\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,OAAA,EACA,IAAA,EACA,SAAA,EACA,SAAA,EACA,SAAS,4BAA4B;AAAA,EACxC,qBAAqB,EAClB,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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;"}
@@ -73,8 +73,7 @@ class InscribeHashinalTool extends BaseInscriberQueryTool {
73
73
  },
74
74
  message: `Quote generated for Hashinal NFT: ${params.name}
75
75
  Creator: ${params.creator}
76
- Total cost: ${quote.totalCostHbar} HBAR
77
- Quote valid until: ${new Date(quote.validUntil).toLocaleString()}`
76
+ Total cost: ${quote.totalCostHbar} HBAR`
78
77
  };
79
78
  } catch (error) {
80
79
  const errorMessage = error instanceof Error ? error.message : "Failed to generate inscription quote";
@@ -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 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}"],"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Tool.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`,\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,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,S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