@hashgraphonline/standards-agent-kit 0.2.132 → 0.2.135

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/dist/cjs/builders/hcs10/hcs10-builder.d.ts +0 -2
  2. package/dist/cjs/builders/inscriber/inscriber-builder.d.ts +2 -39
  3. package/dist/cjs/lib/zod-render/config-extractor.d.ts +0 -21
  4. package/dist/cjs/lib/zod-render/index.d.ts +3 -3
  5. package/dist/cjs/lib/zod-render/schema-extension.d.ts +1 -9
  6. package/dist/cjs/standards-agent-kit.cjs +1 -1
  7. package/dist/cjs/standards-agent-kit.cjs.map +1 -1
  8. package/dist/cjs/tools/index.d.ts +0 -1
  9. package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +42 -1
  10. package/dist/cjs/tools/inscriber/base-inscriber-tools.d.ts +19 -0
  11. package/dist/es/builders/hcs10/hcs10-builder.d.ts +0 -2
  12. package/dist/es/builders/inscriber/inscriber-builder.d.ts +2 -39
  13. package/dist/es/lib/zod-render/config-extractor.d.ts +0 -21
  14. package/dist/es/lib/zod-render/index.d.ts +3 -3
  15. package/dist/es/lib/zod-render/schema-extension.d.ts +1 -9
  16. package/dist/es/standards-agent-kit.es.js +47 -6228
  17. package/dist/es/standards-agent-kit.es.js.map +1 -1
  18. package/dist/es/standards-agent-kit.es10.js +91 -0
  19. package/dist/es/standards-agent-kit.es10.js.map +1 -0
  20. package/dist/es/standards-agent-kit.es11.js +40 -0
  21. package/dist/es/standards-agent-kit.es11.js.map +1 -0
  22. package/dist/es/standards-agent-kit.es12.js +40 -0
  23. package/dist/es/standards-agent-kit.es12.js.map +1 -0
  24. package/dist/es/standards-agent-kit.es13.js +50 -0
  25. package/dist/es/standards-agent-kit.es13.js.map +1 -0
  26. package/dist/es/standards-agent-kit.es14.js +62 -0
  27. package/dist/es/standards-agent-kit.es14.js.map +1 -0
  28. package/dist/es/standards-agent-kit.es15.js +72 -0
  29. package/dist/es/standards-agent-kit.es15.js.map +1 -0
  30. package/dist/es/standards-agent-kit.es16.js +35 -0
  31. package/dist/es/standards-agent-kit.es16.js.map +1 -0
  32. package/dist/es/standards-agent-kit.es17.js +35 -0
  33. package/dist/es/standards-agent-kit.es17.js.map +1 -0
  34. package/dist/es/standards-agent-kit.es18.js +45 -0
  35. package/dist/es/standards-agent-kit.es18.js.map +1 -0
  36. package/dist/es/standards-agent-kit.es19.js +21 -0
  37. package/dist/es/standards-agent-kit.es19.js.map +1 -0
  38. package/dist/es/standards-agent-kit.es2.js +25 -0
  39. package/dist/es/standards-agent-kit.es2.js.map +1 -0
  40. package/dist/es/standards-agent-kit.es20.js +143 -0
  41. package/dist/es/standards-agent-kit.es20.js.map +1 -0
  42. package/dist/es/standards-agent-kit.es21.js +32 -0
  43. package/dist/es/standards-agent-kit.es21.js.map +1 -0
  44. package/dist/es/standards-agent-kit.es22.js +46 -0
  45. package/dist/es/standards-agent-kit.es22.js.map +1 -0
  46. package/dist/es/standards-agent-kit.es23.js +48 -0
  47. package/dist/es/standards-agent-kit.es23.js.map +1 -0
  48. package/dist/es/standards-agent-kit.es24.js +51 -0
  49. package/dist/es/standards-agent-kit.es24.js.map +1 -0
  50. package/dist/es/standards-agent-kit.es25.js +45 -0
  51. package/dist/es/standards-agent-kit.es25.js.map +1 -0
  52. package/dist/es/standards-agent-kit.es26.js +48 -0
  53. package/dist/es/standards-agent-kit.es26.js.map +1 -0
  54. package/dist/es/standards-agent-kit.es27.js +45 -0
  55. package/dist/es/standards-agent-kit.es27.js.map +1 -0
  56. package/dist/es/standards-agent-kit.es28.js +32 -0
  57. package/dist/es/standards-agent-kit.es28.js.map +1 -0
  58. package/dist/es/standards-agent-kit.es29.js +35 -0
  59. package/dist/es/standards-agent-kit.es29.js.map +1 -0
  60. package/dist/es/standards-agent-kit.es3.js +1568 -0
  61. package/dist/es/standards-agent-kit.es3.js.map +1 -0
  62. package/dist/es/standards-agent-kit.es30.js +48 -0
  63. package/dist/es/standards-agent-kit.es30.js.map +1 -0
  64. package/dist/es/standards-agent-kit.es31.js +46 -0
  65. package/dist/es/standards-agent-kit.es31.js.map +1 -0
  66. package/dist/es/standards-agent-kit.es32.js +48 -0
  67. package/dist/es/standards-agent-kit.es32.js.map +1 -0
  68. package/dist/es/standards-agent-kit.es33.js +98 -0
  69. package/dist/es/standards-agent-kit.es33.js.map +1 -0
  70. package/dist/es/standards-agent-kit.es34.js +241 -0
  71. package/dist/es/standards-agent-kit.es34.js.map +1 -0
  72. package/dist/es/standards-agent-kit.es35.js +223 -0
  73. package/dist/es/standards-agent-kit.es35.js.map +1 -0
  74. package/dist/es/standards-agent-kit.es36.js +187 -0
  75. package/dist/es/standards-agent-kit.es36.js.map +1 -0
  76. package/dist/es/standards-agent-kit.es37.js +636 -0
  77. package/dist/es/standards-agent-kit.es37.js.map +1 -0
  78. package/dist/es/standards-agent-kit.es38.js +46 -0
  79. package/dist/es/standards-agent-kit.es38.js.map +1 -0
  80. package/dist/es/standards-agent-kit.es39.js +249 -0
  81. package/dist/es/standards-agent-kit.es39.js.map +1 -0
  82. package/dist/es/standards-agent-kit.es4.js +95 -0
  83. package/dist/es/standards-agent-kit.es4.js.map +1 -0
  84. package/dist/es/standards-agent-kit.es40.js +141 -0
  85. package/dist/es/standards-agent-kit.es40.js.map +1 -0
  86. package/dist/es/standards-agent-kit.es41.js +33 -0
  87. package/dist/es/standards-agent-kit.es41.js.map +1 -0
  88. package/dist/es/standards-agent-kit.es42.js +427 -0
  89. package/dist/es/standards-agent-kit.es42.js.map +1 -0
  90. package/dist/es/standards-agent-kit.es43.js +189 -0
  91. package/dist/es/standards-agent-kit.es43.js.map +1 -0
  92. package/dist/es/standards-agent-kit.es44.js +7 -0
  93. package/dist/es/standards-agent-kit.es44.js.map +1 -0
  94. package/dist/es/standards-agent-kit.es45.js +28 -0
  95. package/dist/es/standards-agent-kit.es45.js.map +1 -0
  96. package/dist/es/standards-agent-kit.es46.js +7 -0
  97. package/dist/es/standards-agent-kit.es46.js.map +1 -0
  98. package/dist/es/standards-agent-kit.es47.js +57 -0
  99. package/dist/es/standards-agent-kit.es47.js.map +1 -0
  100. package/dist/es/standards-agent-kit.es48.js +6 -0
  101. package/dist/es/standards-agent-kit.es48.js.map +1 -0
  102. package/dist/es/standards-agent-kit.es49.js +43 -0
  103. package/dist/es/standards-agent-kit.es49.js.map +1 -0
  104. package/dist/es/standards-agent-kit.es5.js +113 -0
  105. package/dist/es/standards-agent-kit.es5.js.map +1 -0
  106. package/dist/es/standards-agent-kit.es50.js +22 -0
  107. package/dist/es/standards-agent-kit.es50.js.map +1 -0
  108. package/dist/es/standards-agent-kit.es51.js +57 -0
  109. package/dist/es/standards-agent-kit.es51.js.map +1 -0
  110. package/dist/es/standards-agent-kit.es6.js +56 -0
  111. package/dist/es/standards-agent-kit.es6.js.map +1 -0
  112. package/dist/es/standards-agent-kit.es7.js +332 -0
  113. package/dist/es/standards-agent-kit.es7.js.map +1 -0
  114. package/dist/es/standards-agent-kit.es8.js +32 -0
  115. package/dist/es/standards-agent-kit.es8.js.map +1 -0
  116. package/dist/es/standards-agent-kit.es9.js +244 -0
  117. package/dist/es/standards-agent-kit.es9.js.map +1 -0
  118. package/dist/es/tools/index.d.ts +0 -1
  119. package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +42 -1
  120. package/dist/es/tools/inscriber/base-inscriber-tools.d.ts +19 -0
  121. package/dist/umd/builders/hcs10/hcs10-builder.d.ts +0 -2
  122. package/dist/umd/builders/inscriber/inscriber-builder.d.ts +2 -39
  123. package/dist/umd/lib/zod-render/config-extractor.d.ts +0 -21
  124. package/dist/umd/lib/zod-render/index.d.ts +3 -3
  125. package/dist/umd/lib/zod-render/schema-extension.d.ts +1 -9
  126. package/dist/umd/standards-agent-kit.umd.js +1 -1
  127. package/dist/umd/standards-agent-kit.umd.js.map +1 -1
  128. package/dist/umd/tools/index.d.ts +0 -1
  129. package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +42 -1
  130. package/dist/umd/tools/inscriber/base-inscriber-tools.d.ts +19 -0
  131. package/package.json +33 -29
  132. package/src/builders/hcs10/hcs10-builder.ts +0 -4
  133. package/src/builders/inscriber/inscriber-builder.ts +2 -45
  134. package/src/lib/zod-render/config-extractor.ts +0 -92
  135. package/src/lib/zod-render/index.ts +1 -7
  136. package/src/lib/zod-render/schema-extension.ts +1 -69
  137. package/src/tools/index.ts +1 -2
  138. package/src/tools/inscriber/InscribeFromBufferTool.ts +2 -2
  139. package/src/tools/inscriber/InscribeFromUrlTool.ts +2 -2
  140. package/src/tools/inscriber/InscribeHashinalTool.ts +129 -20
  141. package/src/tools/inscriber/base-inscriber-tools.ts +26 -0
  142. package/src/types/inscription-response.ts +2 -2
  143. package/dist/cjs/lib/zod-render/__tests__/withRender.test.d.ts +0 -1
  144. package/dist/cjs/tools/hedera/HederaCreateNftTool.d.ts +0 -72
  145. package/dist/cjs/tools/hedera/index.d.ts +0 -1
  146. package/dist/es/lib/zod-render/__tests__/withRender.test.d.ts +0 -1
  147. package/dist/es/tools/hedera/HederaCreateNftTool.d.ts +0 -72
  148. package/dist/es/tools/hedera/index.d.ts +0 -1
  149. package/dist/umd/lib/zod-render/__tests__/withRender.test.d.ts +0 -1
  150. package/dist/umd/tools/hedera/HederaCreateNftTool.d.ts +0 -72
  151. package/dist/umd/tools/hedera/index.d.ts +0 -1
  152. package/src/lib/zod-render/__tests__/withRender.test.ts +0 -205
  153. package/src/tools/hedera/HederaCreateNftTool.ts +0 -294
  154. package/src/tools/hedera/index.ts +0 -1
@@ -0,0 +1,187 @@
1
+ import { z } from "zod";
2
+ import { BaseInscriberQueryTool } from "./standards-agent-kit.es33.js";
3
+ import { resolveContent } from "./standards-agent-kit.es47.js";
4
+ import { contentRefSchema } from "./standards-agent-kit.es48.js";
5
+ import { loadConfig } from "./standards-agent-kit.es2.js";
6
+ const inscribeFromBufferSchema = z.object({
7
+ base64Data: z.union([z.string(), contentRefSchema]).describe("Content to inscribe as base64 data, plain text, or content reference"),
8
+ fileName: z.string().min(1).describe("Name for the inscribed content"),
9
+ mimeType: z.string().optional().describe("MIME type of the content"),
10
+ metadata: z.record(z.unknown()).optional().describe("Metadata to attach"),
11
+ tags: z.array(z.string()).optional().describe("Tags to categorize the inscription"),
12
+ chunkSize: z.number().int().positive().optional().describe("Chunk size for large files"),
13
+ waitForConfirmation: z.boolean().optional().describe("Wait for inscription confirmation"),
14
+ timeoutMs: z.number().int().positive().optional().describe("Timeout in milliseconds"),
15
+ apiKey: z.string().optional().describe("API key for inscription service"),
16
+ quoteOnly: z.boolean().optional().default(false).describe("Return cost quote only")
17
+ });
18
+ class InscribeFromBufferTool extends BaseInscriberQueryTool {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.name = "inscribeFromBuffer";
22
+ this.description = 'Use ONLY for inscribing regular files or content (NOT for NFT/Hashinal inscriptions). When user says "inscribe it" after you showed search results or other content WITHOUT mentioning NFT/hashinal, 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. NEVER use this for Hashinal NFTs - always use InscribeHashinalTool instead when user mentions hashinal, NFT, dynamic, or minting.';
23
+ this.config = loadConfig();
24
+ }
25
+ get specificInputSchema() {
26
+ return inscribeFromBufferSchema;
27
+ }
28
+ async executeQuery(params, _runManager) {
29
+ this.validateInput(params);
30
+ const resolvedContent = await resolveContent(
31
+ params.base64Data,
32
+ params.mimeType,
33
+ params.fileName
34
+ );
35
+ this.validateContent(resolvedContent.buffer);
36
+ const buffer = resolvedContent.buffer;
37
+ const resolvedMimeType = resolvedContent.mimeType || params.mimeType;
38
+ const resolvedFileName = resolvedContent.fileName || params.fileName;
39
+ const options = {
40
+ mode: "file",
41
+ metadata: params.metadata,
42
+ tags: params.tags,
43
+ chunkSize: params.chunkSize,
44
+ waitForConfirmation: params.quoteOnly ? false : params.waitForConfirmation ?? true,
45
+ waitMaxAttempts: 60,
46
+ waitIntervalMs: 5e3,
47
+ apiKey: params.apiKey,
48
+ network: this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet",
49
+ quoteOnly: params.quoteOnly
50
+ };
51
+ if (params.quoteOnly) {
52
+ try {
53
+ const quote = await this.generateInscriptionQuote(
54
+ {
55
+ type: "buffer",
56
+ buffer,
57
+ fileName: resolvedFileName,
58
+ mimeType: resolvedMimeType
59
+ },
60
+ options
61
+ );
62
+ return {
63
+ success: true,
64
+ quote: {
65
+ totalCostHbar: quote.totalCostHbar,
66
+ validUntil: quote.validUntil,
67
+ breakdown: quote.breakdown
68
+ },
69
+ contentInfo: {
70
+ fileName: resolvedFileName,
71
+ mimeType: resolvedMimeType,
72
+ sizeBytes: buffer.length
73
+ },
74
+ message: `Estimated Quote for buffer content: ${resolvedFileName} (${(buffer.length / 1024).toFixed(2)} KB)
75
+ Total cost: ${quote.totalCostHbar} HBAR`
76
+ };
77
+ } catch (error) {
78
+ const errorMessage = error instanceof Error ? error.message : "Failed to generate inscription quote";
79
+ throw new Error(`Quote generation failed: ${errorMessage}`);
80
+ }
81
+ }
82
+ try {
83
+ const result = await this.executeInscription(
84
+ buffer,
85
+ resolvedFileName,
86
+ resolvedMimeType,
87
+ options,
88
+ params.timeoutMs
89
+ );
90
+ return this.formatInscriptionResult(result, options);
91
+ } catch (error) {
92
+ const errorMessage = error instanceof Error ? error.message : "Failed to inscribe from buffer";
93
+ throw new Error(`Inscription failed: ${errorMessage}`);
94
+ }
95
+ }
96
+ validateInput(params) {
97
+ if (!params.base64Data || params.base64Data.trim() === "") {
98
+ throw new Error(
99
+ "No data provided. Cannot inscribe empty content. Please provide valid content, plain text, base64 encoded data, or a content reference ID."
100
+ );
101
+ }
102
+ if (!params.fileName || params.fileName.trim() === "") {
103
+ throw new Error(
104
+ "No fileName provided. A valid fileName is required for inscription."
105
+ );
106
+ }
107
+ }
108
+ validateContent(buffer) {
109
+ if (buffer.length === 0) {
110
+ throw new Error(
111
+ "Buffer is empty after conversion. The provided data appears to be invalid or empty."
112
+ );
113
+ }
114
+ if (buffer.length > this.config.maxInscriptionSize) {
115
+ const maxSizeKB = Math.round(this.config.maxInscriptionSize / 1024);
116
+ const bufferSizeKB = Math.round(buffer.length / 1024);
117
+ throw new Error(
118
+ `Content is too large for inscription (${bufferSizeKB}KB, max ${maxSizeKB}KB). Please summarize or extract key information before inscribing.`
119
+ );
120
+ }
121
+ if (buffer.length < this.config.minContentSize) {
122
+ throw new Error(
123
+ `Buffer content is too small (${buffer.length} bytes). This may indicate empty or invalid content. Please verify the source data contains actual content.`
124
+ );
125
+ }
126
+ if (buffer.toString("utf8", 0, Math.min(buffer.length, 100)).trim() === "") {
127
+ throw new Error(
128
+ "Buffer contains only whitespace or empty content. Cannot inscribe meaningless data."
129
+ );
130
+ }
131
+ const contentStr = buffer.toString("utf8");
132
+ const emptyHtmlPattern = /<a\s+href=["'][^"']+["']\s*>\s*<\/a>/i;
133
+ const hasOnlyEmptyLinks = emptyHtmlPattern.test(contentStr) && contentStr.replace(/<[^>]+>/g, "").trim().length < 50;
134
+ if (hasOnlyEmptyLinks) {
135
+ throw new Error(
136
+ "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."
137
+ );
138
+ }
139
+ }
140
+ async executeInscription(buffer, fileName, mimeType, options, timeoutMs) {
141
+ const inscriptionData = {
142
+ type: "buffer",
143
+ buffer,
144
+ fileName,
145
+ mimeType
146
+ };
147
+ if (timeoutMs) {
148
+ const timeoutPromise = new Promise((_, reject) => {
149
+ setTimeout(
150
+ () => reject(new Error(`Inscription timed out after ${timeoutMs}ms`)),
151
+ timeoutMs
152
+ );
153
+ });
154
+ return Promise.race([
155
+ this.inscriberBuilder.inscribe(inscriptionData, options),
156
+ timeoutPromise
157
+ ]);
158
+ }
159
+ return this.inscriberBuilder.inscribe(inscriptionData, options);
160
+ }
161
+ formatInscriptionResult(result, options) {
162
+ if (result.confirmed && !result.quote) {
163
+ const topicId = result.inscription?.topic_id || result.result.topicId;
164
+ const network = options.network || "testnet";
165
+ const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;
166
+ return `Successfully inscribed and confirmed content on the Hedera network!
167
+
168
+ Transaction ID: ${result.result.transactionId}
169
+ Topic ID: ${topicId || "N/A"}${cdnUrl ? `
170
+ View inscription: ${cdnUrl}` : ""}
171
+
172
+ The inscription is now available.`;
173
+ }
174
+ if (!result.quote && !result.confirmed) {
175
+ return `Successfully submitted inscription to the Hedera network!
176
+
177
+ Transaction ID: ${result.result.transactionId}
178
+
179
+ The inscription is processing and will be confirmed shortly.`;
180
+ }
181
+ return "Inscription operation completed.";
182
+ }
183
+ }
184
+ export {
185
+ InscribeFromBufferTool
186
+ };
187
+ //# sourceMappingURL=standards-agent-kit.es36.js.map
@@ -0,0 +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 } from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\nimport { resolveContent } from '../../utils/content-resolver';\nimport { contentRefSchema } from '../../validation/content-ref-schemas';\nimport { loadConfig } from '../../config/ContentReferenceConfig';\n\nconst inscribeFromBufferSchema = z.object({\n base64Data: z.union([z.string(), contentRefSchema])\n .describe('Content to inscribe as base64 data, plain text, or content reference'),\n fileName: z.string().min(1).describe('Name for the inscribed content'),\n mimeType: z.string().optional().describe('MIME type of the content'),\n metadata: z.record(z.unknown()).optional().describe('Metadata to attach'),\n tags: z.array(z.string()).optional().describe('Tags to categorize the inscription'),\n chunkSize: z.number().int().positive().optional().describe('Chunk size for large files'),\n waitForConfirmation: z.boolean().optional().describe('Wait for inscription confirmation'),\n timeoutMs: z.number().int().positive().optional().describe('Timeout in milliseconds'),\n apiKey: z.string().optional().describe('API key for inscription service'),\n quoteOnly: z.boolean().optional().default(false).describe('Return cost quote only'),\n});\n\nexport class InscribeFromBufferTool extends BaseInscriberQueryTool<\n typeof inscribeFromBufferSchema\n> {\n name = 'inscribeFromBuffer';\n description =\n 'Use ONLY for inscribing regular files or content (NOT for NFT/Hashinal inscriptions). When user says \"inscribe it\" after you showed search results or other content WITHOUT mentioning NFT/hashinal, 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. NEVER use this for Hashinal NFTs - always use InscribeHashinalTool instead when user mentions hashinal, NFT, dynamic, or minting.';\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 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: 'file',\n metadata: params.metadata,\n tags: params.tags,\n chunkSize: params.chunkSize,\n waitForConfirmation: params.quoteOnly\n ? false\n : params.waitForConfirmation ?? true,\n waitMaxAttempts: 60,\n waitIntervalMs: 5000,\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: `Estimated Quote for buffer content: ${resolvedFileName} (${(\n buffer.length / 1024\n ).toFixed(2)} KB)\\nTotal cost: ${quote.totalCostHbar} 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 const result = await this.executeInscription(\n buffer,\n resolvedFileName,\n resolvedMimeType,\n options,\n params.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 =\n 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: ${\n (result.result as any).transactionId\n }\\n\\nThe inscription is processing and will be confirmed shortly.`;\n }\n\n return 'Inscription operation completed.';\n }\n\n}\n"],"names":[],"mappings":";;;;;AAQA,MAAM,2BAA2B,EAAE,OAAO;AAAA,EACxC,YAAY,EAAE,MAAM,CAAC,EAAE,OAAA,GAAU,gBAAgB,CAAC,EAC/C,SAAS,sEAAsE;AAAA,EAClF,UAAU,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,SAAS,gCAAgC;AAAA,EACrE,UAAU,EAAE,OAAA,EAAS,SAAA,EAAW,SAAS,0BAA0B;AAAA,EACnE,UAAU,EAAE,OAAO,EAAE,QAAA,CAAS,EAAE,SAAA,EAAW,SAAS,oBAAoB;AAAA,EACxE,MAAM,EAAE,MAAM,EAAE,OAAA,CAAQ,EAAE,SAAA,EAAW,SAAS,oCAAoC;AAAA,EAClF,WAAW,EAAE,OAAA,EAAS,IAAA,EAAM,SAAA,EAAW,SAAA,EAAW,SAAS,4BAA4B;AAAA,EACvF,qBAAqB,EAAE,QAAA,EAAU,SAAA,EAAW,SAAS,mCAAmC;AAAA,EACxF,WAAW,EAAE,OAAA,EAAS,IAAA,EAAM,SAAA,EAAW,SAAA,EAAW,SAAS,yBAAyB;AAAA,EACpF,QAAQ,EAAE,OAAA,EAAS,SAAA,EAAW,SAAS,iCAAiC;AAAA,EACxE,WAAW,EAAE,UAAU,SAAA,EAAW,QAAQ,KAAK,EAAE,SAAS,wBAAwB;AACpF,CAAC;AAEM,MAAM,+BAA+B,uBAE1C;AAAA,EAFK,cAAA;AAAA,UAAA,GAAA,SAAA;AAGL,SAAA,OAAO;AACP,SAAA,cACE;AAEF,SAAQ,SAAS,WAAA;AAAA,EAAW;AAAA,EAE5B,IAAI,sBAAsB;AACxB,WAAO;AAAA,EACT;AAAA,EAEA,MAAgB,aACd,QACA,aACkB;AAClB,SAAK,cAAc,MAAM;AAEzB,UAAM,kBAAkB,MAAM;AAAA,M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