@hashgraphonline/standards-agent-kit 0.2.119 → 0.2.121

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 (132) hide show
  1. package/dist/cjs/config/ContentReferenceConfig.d.ts +8 -0
  2. package/dist/cjs/index.d.ts +2 -0
  3. package/dist/cjs/standards-agent-kit.cjs +1 -1
  4. package/dist/cjs/standards-agent-kit.cjs.map +1 -1
  5. package/dist/cjs/tools/hcs6/CreateDynamicRegistryTool.d.ts +7 -7
  6. package/dist/cjs/tools/hcs6/QueryDynamicRegistryTool.d.ts +3 -3
  7. package/dist/cjs/tools/hcs6/RegisterDynamicHashinalTool.d.ts +7 -7
  8. package/dist/cjs/tools/hcs6/UpdateDynamicHashinalTool.d.ts +7 -7
  9. package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +7 -6
  10. package/dist/cjs/tools/inscriber/base-inscriber-tools.d.ts +11 -0
  11. package/dist/cjs/tools/inscriber/inscriber-tool-params.d.ts +3 -0
  12. package/dist/cjs/types/content-resolver.d.ts +6 -0
  13. package/dist/es/config/ContentReferenceConfig.d.ts +8 -0
  14. package/dist/es/index.d.ts +2 -0
  15. package/dist/es/standards-agent-kit.es.js +42 -40
  16. package/dist/es/standards-agent-kit.es.js.map +1 -1
  17. package/dist/es/standards-agent-kit.es10.js +72 -23
  18. package/dist/es/standards-agent-kit.es10.js.map +1 -1
  19. package/dist/es/standards-agent-kit.es11.js +27 -27
  20. package/dist/es/standards-agent-kit.es11.js.map +1 -1
  21. package/dist/es/standards-agent-kit.es12.js +20 -30
  22. package/dist/es/standards-agent-kit.es12.js.map +1 -1
  23. package/dist/es/standards-agent-kit.es13.js +27 -37
  24. package/dist/es/standards-agent-kit.es13.js.map +1 -1
  25. package/dist/es/standards-agent-kit.es14.js +48 -60
  26. package/dist/es/standards-agent-kit.es14.js.map +1 -1
  27. package/dist/es/standards-agent-kit.es15.js +60 -23
  28. package/dist/es/standards-agent-kit.es15.js.map +1 -1
  29. package/dist/es/standards-agent-kit.es16.js +23 -23
  30. package/dist/es/standards-agent-kit.es16.js.map +1 -1
  31. package/dist/es/standards-agent-kit.es17.js +23 -33
  32. package/dist/es/standards-agent-kit.es17.js.map +1 -1
  33. package/dist/es/standards-agent-kit.es18.js +34 -10
  34. package/dist/es/standards-agent-kit.es18.js.map +1 -1
  35. package/dist/es/standards-agent-kit.es19.js +16 -155
  36. package/dist/es/standards-agent-kit.es19.js.map +1 -1
  37. package/dist/es/standards-agent-kit.es2.js +21 -1567
  38. package/dist/es/standards-agent-kit.es2.js.map +1 -1
  39. package/dist/es/standards-agent-kit.es20.js +150 -22
  40. package/dist/es/standards-agent-kit.es20.js.map +1 -1
  41. package/dist/es/standards-agent-kit.es21.js +25 -39
  42. package/dist/es/standards-agent-kit.es21.js.map +1 -1
  43. package/dist/es/standards-agent-kit.es22.js +26 -28
  44. package/dist/es/standards-agent-kit.es22.js.map +1 -1
  45. package/dist/es/standards-agent-kit.es23.js +16 -19
  46. package/dist/es/standards-agent-kit.es23.js.map +1 -1
  47. package/dist/es/standards-agent-kit.es24.js +21 -15
  48. package/dist/es/standards-agent-kit.es24.js.map +1 -1
  49. package/dist/es/standards-agent-kit.es25.js +18 -21
  50. package/dist/es/standards-agent-kit.es25.js.map +1 -1
  51. package/dist/es/standards-agent-kit.es26.js +35 -32
  52. package/dist/es/standards-agent-kit.es26.js.map +1 -1
  53. package/dist/es/standards-agent-kit.es27.js +38 -25
  54. package/dist/es/standards-agent-kit.es27.js.map +1 -1
  55. package/dist/es/standards-agent-kit.es28.js +24 -37
  56. package/dist/es/standards-agent-kit.es28.js.map +1 -1
  57. package/dist/es/standards-agent-kit.es29.js +26 -43
  58. package/dist/es/standards-agent-kit.es29.js.map +1 -1
  59. package/dist/es/standards-agent-kit.es3.js +1532 -55
  60. package/dist/es/standards-agent-kit.es3.js.map +1 -1
  61. package/dist/es/standards-agent-kit.es30.js +35 -40
  62. package/dist/es/standards-agent-kit.es30.js.map +1 -1
  63. package/dist/es/standards-agent-kit.es31.js +35 -39
  64. package/dist/es/standards-agent-kit.es31.js.map +1 -1
  65. package/dist/es/standards-agent-kit.es32.js +39 -23
  66. package/dist/es/standards-agent-kit.es32.js.map +1 -1
  67. package/dist/es/standards-agent-kit.es33.js +39 -168
  68. package/dist/es/standards-agent-kit.es33.js.map +1 -1
  69. package/dist/es/standards-agent-kit.es34.js +93 -96
  70. package/dist/es/standards-agent-kit.es34.js.map +1 -1
  71. package/dist/es/standards-agent-kit.es35.js +99 -64
  72. package/dist/es/standards-agent-kit.es35.js.map +1 -1
  73. package/dist/es/standards-agent-kit.es36.js +166 -64
  74. package/dist/es/standards-agent-kit.es36.js.map +1 -1
  75. package/dist/es/standards-agent-kit.es37.js +87 -30
  76. package/dist/es/standards-agent-kit.es37.js.map +1 -1
  77. package/dist/es/standards-agent-kit.es38.js +38 -242
  78. package/dist/es/standards-agent-kit.es38.js.map +1 -1
  79. package/dist/es/standards-agent-kit.es39.js +246 -138
  80. package/dist/es/standards-agent-kit.es39.js.map +1 -1
  81. package/dist/es/standards-agent-kit.es4.js +39 -33
  82. package/dist/es/standards-agent-kit.es4.js.map +1 -1
  83. package/dist/es/standards-agent-kit.es40.js +134 -26
  84. package/dist/es/standards-agent-kit.es40.js.map +1 -1
  85. package/dist/es/standards-agent-kit.es41.js +27 -22
  86. package/dist/es/standards-agent-kit.es41.js.map +1 -1
  87. package/dist/es/standards-agent-kit.es42.js +24 -3
  88. package/dist/es/standards-agent-kit.es42.js.map +1 -1
  89. package/dist/es/standards-agent-kit.es43.js +7 -0
  90. package/dist/es/standards-agent-kit.es43.js.map +1 -0
  91. package/dist/es/standards-agent-kit.es5.js +65 -32
  92. package/dist/es/standards-agent-kit.es5.js.map +1 -1
  93. package/dist/es/standards-agent-kit.es6.js +35 -311
  94. package/dist/es/standards-agent-kit.es6.js.map +1 -1
  95. package/dist/es/standards-agent-kit.es7.js +320 -20
  96. package/dist/es/standards-agent-kit.es7.js.map +1 -1
  97. package/dist/es/standards-agent-kit.es8.js +19 -227
  98. package/dist/es/standards-agent-kit.es8.js.map +1 -1
  99. package/dist/es/standards-agent-kit.es9.js +216 -65
  100. package/dist/es/standards-agent-kit.es9.js.map +1 -1
  101. package/dist/es/tools/hcs6/CreateDynamicRegistryTool.d.ts +7 -7
  102. package/dist/es/tools/hcs6/QueryDynamicRegistryTool.d.ts +3 -3
  103. package/dist/es/tools/hcs6/RegisterDynamicHashinalTool.d.ts +7 -7
  104. package/dist/es/tools/hcs6/UpdateDynamicHashinalTool.d.ts +7 -7
  105. package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +7 -6
  106. package/dist/es/tools/inscriber/base-inscriber-tools.d.ts +11 -0
  107. package/dist/es/tools/inscriber/inscriber-tool-params.d.ts +3 -0
  108. package/dist/es/types/content-resolver.d.ts +6 -0
  109. package/dist/umd/config/ContentReferenceConfig.d.ts +8 -0
  110. package/dist/umd/index.d.ts +2 -0
  111. package/dist/umd/standards-agent-kit.umd.js +1 -1
  112. package/dist/umd/standards-agent-kit.umd.js.map +1 -1
  113. package/dist/umd/tools/hcs6/CreateDynamicRegistryTool.d.ts +7 -7
  114. package/dist/umd/tools/hcs6/QueryDynamicRegistryTool.d.ts +3 -3
  115. package/dist/umd/tools/hcs6/RegisterDynamicHashinalTool.d.ts +7 -7
  116. package/dist/umd/tools/hcs6/UpdateDynamicHashinalTool.d.ts +7 -7
  117. package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +7 -6
  118. package/dist/umd/tools/inscriber/base-inscriber-tools.d.ts +11 -0
  119. package/dist/umd/tools/inscriber/inscriber-tool-params.d.ts +3 -0
  120. package/dist/umd/types/content-resolver.d.ts +6 -0
  121. package/package.json +2 -2
  122. package/src/builders/hcs10/hcs10-builder.ts +2 -3
  123. package/src/config/ContentReferenceConfig.ts +30 -0
  124. package/src/index.ts +3 -1
  125. package/src/tools/hcs6/CreateDynamicRegistryTool.ts +22 -33
  126. package/src/tools/hcs6/QueryDynamicRegistryTool.ts +23 -33
  127. package/src/tools/hcs6/RegisterDynamicHashinalTool.ts +25 -35
  128. package/src/tools/hcs6/UpdateDynamicHashinalTool.ts +25 -36
  129. package/src/tools/inscriber/InscribeFromBufferTool.ts +239 -120
  130. package/src/tools/inscriber/base-inscriber-tools.ts +19 -0
  131. package/src/tools/inscriber/inscriber-tool-params.ts +3 -0
  132. package/src/types/content-resolver.ts +11 -0
@@ -1,75 +1,87 @@
1
1
  import { z } from "zod";
2
- import { BaseInscriberQueryTool } from "./standards-agent-kit.es32.js";
3
- const inscribeFromBufferSchema = z.object({
4
- base64Data: z.string().min(1, "Data cannot be empty").describe('The FULL content to inscribe as plain text or base64. When asked to "inscribe it" after retrieving content, pass ALL the content you retrieved here as plain text - NOT a summary, NOT URLs, NOT truncated. Example: if you fetched Wikipedia articles, pass the complete article text you received.'),
5
- fileName: z.string().min(1, "File name cannot be empty").describe("Name for the inscribed content. Required for all inscriptions."),
6
- mimeType: z.string().optional().describe("MIME type of the content"),
2
+ import { BaseInscriberQueryTool } from "./standards-agent-kit.es33.js";
3
+ import * as fs from "fs/promises";
4
+ import * as path from "path";
5
+ const inscribeFromFileSchema = z.object({
6
+ filePath: z.string().min(1, "File path cannot be empty").describe("The file path of the content to inscribe. Must point to a valid, non-empty file."),
7
7
  mode: z.enum(["file", "hashinal"]).optional().describe("Inscription mode: file or hashinal NFT"),
8
8
  metadata: z.record(z.unknown()).optional().describe("Metadata to attach to the inscription"),
9
9
  tags: z.array(z.string()).optional().describe("Tags to categorize the inscription"),
10
10
  chunkSize: z.number().int().positive().optional().describe("Chunk size for large files"),
11
11
  waitForConfirmation: z.boolean().optional().describe("Whether to wait for inscription confirmation"),
12
- timeoutMs: z.number().int().positive().optional().describe("Timeout in milliseconds for inscription (default: no timeout - waits until completion)"),
12
+ timeoutMs: z.number().int().positive().optional().describe("Timeout in milliseconds for inscription (default: no timeout)"),
13
13
  apiKey: z.string().optional().describe("API key for inscription service")
14
14
  });
15
- class InscribeFromBufferTool extends BaseInscriberQueryTool {
15
+ class InscribeFromFileTool extends BaseInscriberQueryTool {
16
16
  constructor() {
17
17
  super(...arguments);
18
- this.name = "inscribeFromBuffer";
19
- this.description = 'PRIMARY inscription tool for ANY content you have already retrieved. USE THIS when asked to "inscribe it" after fetching content from MCP tools, search results, or any text data. Pass THE FULL CONTENT as plain text in base64Data field - the tool accepts both plain text and base64. CRITICAL: Pass the COMPLETE content you retrieved, NOT a summary or truncated version. Example: If you fetched Wikipedia articles with full text, pass ALL that text here as plain text.';
18
+ this.name = "inscribeFromFile";
19
+ this.description = "Inscribe content from a local file to the Hedera network using a file path. IMPORTANT: Only use this tool when you have a valid file path to actual content. The file must exist and contain meaningful data (minimum 10 bytes). For files accessed through MCP filesystem tools, consider reading the file content first and using inscribeFromBuffer instead.";
20
20
  }
21
21
  get specificInputSchema() {
22
- return inscribeFromBufferSchema;
22
+ return inscribeFromFileSchema;
23
23
  }
24
24
  async executeQuery(params, _runManager) {
25
- console.log(`[DEBUG] InscribeFromBufferTool.executeQuery called`);
26
- console.log(`[DEBUG] Buffer tool received base64Data length: ${params.base64Data?.length || 0}`);
27
- console.log(`[DEBUG] Buffer tool fileName: ${params.fileName}`);
28
- console.log(`[DEBUG] Buffer tool mimeType: ${params.mimeType}`);
29
- if (!params.base64Data || params.base64Data.trim() === "") {
30
- console.log(`[InscribeFromBufferTool] ERROR: No data provided`);
31
- throw new Error("No data provided. Cannot inscribe empty content. Please provide valid base64 encoded data.");
32
- }
33
- if (!params.fileName || params.fileName.trim() === "") {
34
- console.log(`[InscribeFromBufferTool] ERROR: No fileName provided`);
35
- throw new Error("No fileName provided. A valid fileName is required for inscription.");
36
- }
37
- let buffer;
38
- const isValidBase64 = /^[A-Za-z0-9+/]*={0,2}$/.test(params.base64Data);
39
- if (isValidBase64) {
40
- try {
41
- buffer = Buffer.from(params.base64Data, "base64");
42
- console.log(`[InscribeFromBufferTool] Successfully decoded base64 data`);
43
- } catch (error) {
44
- console.log(`[InscribeFromBufferTool] ERROR: Failed to decode base64`);
45
- throw new Error("Failed to decode base64 data. Please ensure the data is properly encoded.");
25
+ console.log(`[DEBUG] InscribeFromFileTool.executeQuery called with: ${params.filePath}`);
26
+ let fileContent;
27
+ try {
28
+ console.log(`[DEBUG] Checking file: ${params.filePath}`);
29
+ console.log(`[DEBUG] Current working directory: ${process.cwd()}`);
30
+ const stats = await fs.stat(params.filePath);
31
+ if (!stats.isFile()) {
32
+ throw new Error(`Path "${params.filePath}" is not a file`);
46
33
  }
47
- } else {
48
- console.log(`[InscribeFromBufferTool] WARNING: Data is not base64 encoded, treating as plain text`);
49
- buffer = Buffer.from(params.base64Data, "utf8");
50
- console.log(`[InscribeFromBufferTool] Converted plain text to buffer`);
51
- }
52
- console.log(`[InscribeFromBufferTool] Buffer length after conversion: ${buffer.length}`);
53
- if (buffer.length === 0) {
54
- console.log(`[InscribeFromBufferTool] ERROR: Buffer is empty after conversion`);
55
- throw new Error("Buffer is empty after conversion. The provided data appears to be invalid or empty.");
56
- }
57
- if (buffer.length < 10) {
58
- console.log(`[InscribeFromBufferTool] WARNING: Buffer is very small (${buffer.length} bytes)`);
59
- console.log(`[InscribeFromBufferTool] Buffer content preview: ${buffer.toString("utf8", 0, Math.min(buffer.length, 50))}`);
60
- throw new Error(`Buffer content is too small (${buffer.length} bytes). This may indicate empty or invalid content. Please verify the source data contains actual content.`);
61
- }
62
- if (buffer.toString("utf8", 0, Math.min(buffer.length, 100)).trim() === "") {
63
- console.log(`[InscribeFromBufferTool] ERROR: Buffer contains only whitespace or empty content`);
64
- throw new Error("Buffer contains only whitespace or empty content. Cannot inscribe meaningless data.");
65
- }
66
- const contentStr = buffer.toString("utf8");
67
- const emptyHtmlPattern = /<a\s+href=["'][^"']+["']\s*>\s*<\/a>/i;
68
- const hasOnlyEmptyLinks = emptyHtmlPattern.test(contentStr) && contentStr.replace(/<[^>]+>/g, "").trim().length < 50;
69
- if (hasOnlyEmptyLinks) {
70
- console.log(`[InscribeFromBufferTool] ERROR: Buffer contains empty HTML with just links and no content`);
71
- throw new Error("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.");
34
+ console.log(`[DEBUG] File size: ${stats.size} bytes`);
35
+ if (stats.size === 0) {
36
+ throw new Error(
37
+ `File "${params.filePath}" is empty (0 bytes). Cannot inscribe empty files.`
38
+ );
39
+ }
40
+ if (stats.size < 10) {
41
+ throw new Error(
42
+ `File "${params.filePath}" is too small (${stats.size} bytes). Files must contain at least 10 bytes of meaningful content.`
43
+ );
44
+ }
45
+ if (stats.size > 100 * 1024 * 1024) {
46
+ console.log(`[InscribeFromFileTool] WARNING: Large file detected (${(stats.size / (1024 * 1024)).toFixed(2)} MB)`);
47
+ }
48
+ this.logger?.info("Reading file content...");
49
+ fileContent = await fs.readFile(params.filePath);
50
+ this.logger?.info(`Read ${fileContent.length} bytes from file`);
51
+ if (!fileContent || fileContent.length === 0) {
52
+ throw new Error(
53
+ `File "${params.filePath}" has no content after reading. Cannot inscribe empty files.`
54
+ );
55
+ }
56
+ if (fileContent.length < 10) {
57
+ throw new Error(
58
+ `File "${params.filePath}" content is too small (${fileContent.length} bytes). Files must contain at least 10 bytes of meaningful content.`
59
+ );
60
+ }
61
+ const fileName2 = path.basename(params.filePath);
62
+ const mimeType2 = this.getMimeType(fileName2);
63
+ if (mimeType2.startsWith("text/") || mimeType2 === "application/json") {
64
+ const textContent = fileContent.toString("utf8", 0, Math.min(fileContent.length, 1e3));
65
+ if (textContent.trim() === "") {
66
+ throw new Error(
67
+ `File "${params.filePath}" contains only whitespace or empty content. Cannot inscribe meaningless data.`
68
+ );
69
+ }
70
+ }
71
+ } catch (error) {
72
+ if (error instanceof Error) {
73
+ if (error.message.includes("ENOENT")) {
74
+ throw new Error(`File not found: "${params.filePath}"`);
75
+ }
76
+ throw error;
77
+ }
78
+ throw new Error(`Failed to read file: ${error}`);
72
79
  }
80
+ const base64Data = fileContent.toString("base64");
81
+ this.logger?.info(`Converted to base64: ${base64Data.length} characters`);
82
+ const fileName = path.basename(params.filePath);
83
+ const mimeType = this.getMimeType(fileName);
84
+ this.logger?.info(`File: ${fileName}, MIME type: ${mimeType}`);
73
85
  const options = {
74
86
  mode: params.mode,
75
87
  metadata: params.metadata,
@@ -94,9 +106,9 @@ class InscribeFromBufferTool extends BaseInscriberQueryTool {
94
106
  this.inscriberBuilder.inscribe(
95
107
  {
96
108
  type: "buffer",
97
- buffer,
98
- fileName: params.fileName,
99
- mimeType: params.mimeType
109
+ buffer: Buffer.from(base64Data, "base64"),
110
+ fileName,
111
+ mimeType
100
112
  },
101
113
  options
102
114
  ),
@@ -106,9 +118,9 @@ class InscribeFromBufferTool extends BaseInscriberQueryTool {
106
118
  result = await this.inscriberBuilder.inscribe(
107
119
  {
108
120
  type: "buffer",
109
- buffer,
110
- fileName: params.fileName,
111
- mimeType: params.mimeType
121
+ buffer: Buffer.from(base64Data, "base64"),
122
+ fileName,
123
+ mimeType
112
124
  },
113
125
  options
114
126
  );
@@ -132,12 +144,35 @@ Transaction ID: ${result.result.transactionId}
132
144
  The inscription is processing and will be confirmed shortly.`;
133
145
  }
134
146
  } catch (error) {
135
- const errorMessage = error instanceof Error ? error.message : "Failed to inscribe from buffer";
147
+ const errorMessage = error instanceof Error ? error.message : "Failed to inscribe from file";
136
148
  throw new Error(`Inscription failed: ${errorMessage}`);
137
149
  }
138
150
  }
151
+ getMimeType(fileName) {
152
+ const ext = path.extname(fileName).toLowerCase();
153
+ const mimeTypes = {
154
+ ".png": "image/png",
155
+ ".jpg": "image/jpeg",
156
+ ".jpeg": "image/jpeg",
157
+ ".gif": "image/gif",
158
+ ".webp": "image/webp",
159
+ ".svg": "image/svg+xml",
160
+ ".pdf": "application/pdf",
161
+ ".json": "application/json",
162
+ ".txt": "text/plain",
163
+ ".html": "text/html",
164
+ ".css": "text/css",
165
+ ".js": "application/javascript",
166
+ ".ts": "application/typescript",
167
+ ".mp4": "video/mp4",
168
+ ".mp3": "audio/mpeg",
169
+ ".wav": "audio/wav",
170
+ ".zip": "application/zip"
171
+ };
172
+ return mimeTypes[ext] || "application/octet-stream";
173
+ }
139
174
  }
140
175
  export {
141
- InscribeFromBufferTool
176
+ InscribeFromFileTool
142
177
  };
143
178
  //# sourceMappingURL=standards-agent-kit.es35.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-agent-kit.es35.js","sources":["../../src/tools/inscriber/InscribeFromBufferTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport { InscriptionOptions } from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\n\n/**\n * Schema for inscribing from buffer\n */\nconst inscribeFromBufferSchema = z.object({\n base64Data: z.string().min(1, 'Data cannot be empty').describe('The FULL content to inscribe as plain text or base64. When asked to \"inscribe it\" after retrieving content, pass ALL the content you retrieved here as plain text - NOT a summary, NOT URLs, NOT truncated. Example: if you fetched Wikipedia articles, pass the complete article text you received.'),\n fileName: z.string().min(1, 'File name cannot be empty').describe('Name for the inscribed content. Required for all inscriptions.'),\n mimeType: z\n .string()\n .optional()\n .describe('MIME type of the content'),\n mode: z\n .enum(['file', 'hashinal'])\n .optional()\n .describe('Inscription mode: file or hashinal NFT'),\n metadata: z\n .record(z.unknown())\n .optional()\n .describe('Metadata to attach to the inscription'),\n tags: z\n .array(z.string())\n .optional()\n .describe('Tags to categorize the inscription'),\n chunkSize: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Chunk size for large files'),\n waitForConfirmation: z\n .boolean()\n .optional()\n .describe('Whether to wait for inscription confirmation'),\n timeoutMs: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Timeout in milliseconds for inscription (default: no timeout - waits until completion)'),\n apiKey: z\n .string()\n .optional()\n .describe('API key for inscription service'),\n});\n\n\n/**\n * Tool for inscribing content from buffer\n */\nexport class InscribeFromBufferTool extends BaseInscriberQueryTool<typeof inscribeFromBufferSchema> {\n name = 'inscribeFromBuffer';\n description = 'PRIMARY inscription tool for ANY content you have already retrieved. USE THIS when asked to \"inscribe it\" after fetching content from MCP tools, search results, or any text data. Pass THE FULL CONTENT as plain text in base64Data field - the tool accepts both plain text and base64. CRITICAL: Pass the COMPLETE content you retrieved, NOT a summary or truncated version. Example: If you fetched Wikipedia articles with full text, pass ALL that text here as plain text.';\n\n get specificInputSchema() {\n return inscribeFromBufferSchema;\n }\n\n protected async executeQuery(\n params: z.infer<typeof inscribeFromBufferSchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<unknown> {\n console.log(`[DEBUG] InscribeFromBufferTool.executeQuery called`);\n console.log(`[DEBUG] Buffer tool received base64Data length: ${params.base64Data?.length || 0}`);\n console.log(`[DEBUG] Buffer tool fileName: ${params.fileName}`);\n console.log(`[DEBUG] Buffer tool mimeType: ${params.mimeType}`);\n \n if (!params.base64Data || params.base64Data.trim() === '') {\n console.log(`[InscribeFromBufferTool] ERROR: No data provided`);\n throw new Error('No data provided. Cannot inscribe empty content. Please provide valid base64 encoded data.');\n }\n\n if (!params.fileName || params.fileName.trim() === '') {\n console.log(`[InscribeFromBufferTool] ERROR: No fileName provided`);\n throw new Error('No fileName provided. A valid fileName is required for inscription.');\n }\n\n let buffer: Buffer;\n \n // First check if it's valid base64\n const isValidBase64 = /^[A-Za-z0-9+/]*={0,2}$/.test(params.base64Data);\n \n if (isValidBase64) {\n // Try to decode as base64\n try {\n buffer = Buffer.from(params.base64Data, 'base64');\n console.log(`[InscribeFromBufferTool] Successfully decoded base64 data`);\n } catch (error) {\n console.log(`[InscribeFromBufferTool] ERROR: Failed to decode base64`);\n throw new Error('Failed to decode base64 data. Please ensure the data is properly encoded.');\n }\n } else {\n // Not base64, treat as plain text and encode it\n console.log(`[InscribeFromBufferTool] WARNING: Data is not base64 encoded, treating as plain text`);\n buffer = Buffer.from(params.base64Data, 'utf8');\n console.log(`[InscribeFromBufferTool] Converted plain text to buffer`);\n }\n \n console.log(`[InscribeFromBufferTool] Buffer length after conversion: ${buffer.length}`);\n \n if (buffer.length === 0) {\n console.log(`[InscribeFromBufferTool] ERROR: Buffer is empty after conversion`);\n throw new Error('Buffer is empty after conversion. The provided data appears to be invalid or empty.');\n }\n\n if (buffer.length < 10) {\n console.log(`[InscribeFromBufferTool] WARNING: Buffer is very small (${buffer.length} bytes)`);\n console.log(`[InscribeFromBufferTool] Buffer content preview: ${buffer.toString('utf8', 0, Math.min(buffer.length, 50))}`);\n throw new Error(`Buffer content is too small (${buffer.length} bytes). This may indicate empty or invalid content. Please verify the source data contains actual content.`);\n }\n\n if (buffer.toString('utf8', 0, Math.min(buffer.length, 100)).trim() === '') {\n console.log(`[InscribeFromBufferTool] ERROR: Buffer contains only whitespace or empty content`);\n throw new Error('Buffer contains only whitespace or empty content. Cannot inscribe meaningless data.');\n }\n\n // Check for empty HTML pattern (just links with no content)\n const contentStr = buffer.toString('utf8');\n const emptyHtmlPattern = /<a\\s+href=[\"'][^\"']+[\"']\\s*>\\s*<\\/a>/i;\n const hasOnlyEmptyLinks = emptyHtmlPattern.test(contentStr) && \n contentStr.replace(/<[^>]+>/g, '').trim().length < 50;\n \n if (hasOnlyEmptyLinks) {\n console.log(`[InscribeFromBufferTool] ERROR: Buffer contains empty HTML with just links and no content`);\n throw new Error('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 const options: InscriptionOptions = {\n mode: params.mode,\n metadata: params.metadata,\n tags: params.tags,\n chunkSize: params.chunkSize,\n waitForConfirmation: params.waitForConfirmation ?? true,\n waitMaxAttempts: 10,\n waitIntervalMs: 3000,\n apiKey: params.apiKey,\n network: this.inscriberBuilder['hederaKit'].client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet',\n };\n\n try {\n let result: 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 {\n type: 'buffer',\n buffer,\n fileName: params.fileName,\n mimeType: params.mimeType,\n },\n options\n ),\n timeoutPromise,\n ]);\n } else {\n result = await this.inscriberBuilder.inscribe(\n {\n type: 'buffer',\n buffer,\n fileName: params.fileName,\n mimeType: params.mimeType,\n },\n options\n );\n }\n\n if (result.confirmed) {\n const topicId = result.inscription?.topic_id || result.result.topicId;\n const network = options.network || 'testnet';\n const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;\n return `Successfully inscribed and confirmed content on the Hedera network!\\n\\nTransaction ID: ${result.result.transactionId}\\nTopic ID: ${topicId || 'N/A'}${cdnUrl ? `\\nView inscription: ${cdnUrl}` : ''}\\n\\nThe inscription is now available.`;\n } else {\n return `Successfully submitted inscription to the Hedera network!\\n\\nTransaction ID: ${result.result.transactionId}\\n\\nThe inscription is processing and will be confirmed shortly.`;\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Failed to inscribe from buffer';\n throw new Error(`Inscription failed: ${errorMessage}`);\n }\n }\n}"],"names":[],"mappings":";;AAQA,MAAM,2BAA2B,EAAE,OAAO;AAAA,EACxC,YAAY,EAAE,SAAS,IAAI,GAAG,sBAAsB,EAAE,SAAS,sSAAsS;AAAA,EACrW,UAAU,EAAE,SAAS,IAAI,GAAG,2BAA2B,EAAE,SAAS,gEAAgE;AAAA,EAClI,UAAU,EACP,OAAA,EACA,SAAA,EACA,SAAS,0BAA0B;AAAA,EACtC,MAAM,EACH,KAAK,CAAC,QAAQ,UAAU,CAAC,EACzB,SAAA,EACA,SAAS,wCAAwC;AAAA,EACpD,UAAU,EACP,OAAO,EAAE,QAAA,CAAS,EAClB,SAAA,EACA,SAAS,uCAAuC;AAAA,EACnD,MAAM,EACH,MAAM,EAAE,OAAA,CAAQ,EAChB,SAAA,EACA,SAAS,oCAAoC;AAAA,EAChD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,QAAI;AACF,UAAI;AAEJ,UAAI,OAAO,WAAW;AACpB,cAAM,iBAAiB,IAAI,QAAe,CAAC,GAAG,WAAW;AACvD;AAAA,YACE,MAAM,OAAO,IAAI,MAAM,+BAA+B,OAAO,SAAS,IAAI,CAAC;AAAA,YAC3E,OAAO;AAAA,UAAA;AAAA,QAEX,CAAC;AAED,iBAAS,MAAM,QAAQ,KAAK;AAAA,UAC1B,KAAK,iBAAiB;AAAA,YACpB;AAAA,cACE,MAAM;AAAA,cACN;AAAA,cACA,UAAU,OAAO;AAAA,cACjB,UAAU,OAAO;AAAA,YAAA;AAAA,YAEnB;AAAA,UAAA;AAAA,UAEF;AAAA,QAAA,CACD;AAAA,MACH,OAAO;AACL,iBAAS,MAAM,KAAK,iBAAiB;AAAA,UACnC;AAAA,YACE,MAAM;AAAA,YACN;AAAA,YACA,UAAU,OAAO;AAAA,YACjB,UAAU,OAAO;AAAA,UAAA;AAAA,UAEnB;AAAA,QAAA;AAAA,MAEJ;AAEA,UAAI,OAAO,WAAW;AACpB,cAAM,UAAU,OAAO,aAAa,YAAY,OAAO,OAAO;AAC9D,cAAM,UAAU,QAAQ,WAAW;AACnC,cAAM,SAAS,UAAU,8CAA8C,OAAO,YAAY,OAAO,KAAK;AACtG,eAAO;AAAA;AAAA,kBAA0F,OAAO,OAAO,aAAa;AAAA,YAAe,WAAW,KAAK,GAAG,SAAS;AAAA,oBAAuB,MAAM,KAAK,EAAE;AAAA;AAAA;AAAA,MAC7M,OAAO;AACL,eAAO;AAAA;AAAA,kBAAgF,OAAO,OAAO,aAAa;AAAA;AAAA;AAAA,MACpH;AAAA,IACF,SAAS,OAAO;AACd,YAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU;AAC9D,YAAM,IAAI,MAAM,uBAAuB,YAAY,EAAE;AAAA,IACvD;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"standards-agent-kit.es35.js","sources":["../../src/tools/inscriber/InscribeFromFileTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport { InscriptionOptions } from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\n\n/**\n * Schema for inscribing from file\n */\nconst inscribeFromFileSchema = z.object({\n filePath: z.string().min(1, 'File path cannot be empty').describe('The file path of the content to inscribe. Must point to a valid, non-empty file.'),\n mode: z\n .enum(['file', 'hashinal'])\n .optional()\n .describe('Inscription mode: file or hashinal NFT'),\n metadata: z\n .record(z.unknown())\n .optional()\n .describe('Metadata to attach to the inscription'),\n tags: z\n .array(z.string())\n .optional()\n .describe('Tags to categorize the inscription'),\n chunkSize: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Chunk size for large files'),\n waitForConfirmation: z\n .boolean()\n .optional()\n .describe('Whether to wait for inscription confirmation'),\n timeoutMs: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Timeout in milliseconds for inscription (default: no timeout)'),\n apiKey: z.string().optional().describe('API key for inscription service'),\n});\n\n/**\n * Tool for inscribing content from file\n */\nexport class InscribeFromFileTool extends BaseInscriberQueryTool<\n typeof inscribeFromFileSchema\n> {\n name = 'inscribeFromFile';\n description =\n 'Inscribe content from a local file to the Hedera network using a file path. IMPORTANT: Only use this tool when you have a valid file path to actual content. The file must exist and contain meaningful data (minimum 10 bytes). For files accessed through MCP filesystem tools, consider reading the file content first and using inscribeFromBuffer instead.';\n\n get specificInputSchema(): typeof inscribeFromFileSchema {\n return inscribeFromFileSchema;\n }\n\n protected async executeQuery(\n params: z.infer<typeof inscribeFromFileSchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<unknown> {\n console.log(`[DEBUG] InscribeFromFileTool.executeQuery called with: ${params.filePath}`);\n \n // File validation\n let fileContent: Buffer;\n try {\n console.log(`[DEBUG] Checking file: ${params.filePath}`);\n console.log(`[DEBUG] Current working directory: ${process.cwd()}`);\n\n const stats = await fs.stat(params.filePath);\n if (!stats.isFile()) {\n throw new Error(`Path \"${params.filePath}\" is not a file`);\n }\n\n console.log(`[DEBUG] File size: ${stats.size} bytes`);\n\n if (stats.size === 0) {\n throw new Error(\n `File \"${params.filePath}\" is empty (0 bytes). Cannot inscribe empty files.`\n );\n }\n\n if (stats.size < 10) {\n throw new Error(\n `File \"${params.filePath}\" is too small (${stats.size} bytes). Files must contain at least 10 bytes of meaningful content.`\n );\n }\n\n if (stats.size > 100 * 1024 * 1024) {\n console.log(`[InscribeFromFileTool] WARNING: Large file detected (${(stats.size / (1024 * 1024)).toFixed(2)} MB)`);\n }\n\n this.logger?.info('Reading file content...');\n fileContent = await fs.readFile(params.filePath);\n this.logger?.info(`Read ${fileContent.length} bytes from file`);\n\n if (!fileContent || fileContent.length === 0) {\n throw new Error(\n `File \"${params.filePath}\" has no content after reading. Cannot inscribe empty files.`\n );\n }\n\n if (fileContent.length < 10) {\n throw new Error(\n `File \"${params.filePath}\" content is too small (${fileContent.length} bytes). Files must contain at least 10 bytes of meaningful content.`\n );\n }\n\n const fileName = path.basename(params.filePath);\n const mimeType = this.getMimeType(fileName);\n if (mimeType.startsWith('text/') || mimeType === 'application/json') {\n const textContent = fileContent.toString('utf8', 0, Math.min(fileContent.length, 1000));\n if (textContent.trim() === '') {\n throw new Error(\n `File \"${params.filePath}\" contains only whitespace or empty content. Cannot inscribe meaningless data.`\n );\n }\n }\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('ENOENT')) {\n throw new Error(`File not found: \"${params.filePath}\"`);\n }\n throw error;\n }\n throw new Error(`Failed to read file: ${error}`);\n }\n\n const base64Data = fileContent.toString('base64');\n this.logger?.info(`Converted to base64: ${base64Data.length} characters`);\n\n const fileName = path.basename(params.filePath);\n const mimeType = this.getMimeType(fileName);\n this.logger?.info(`File: ${fileName}, MIME type: ${mimeType}`);\n\n const options: InscriptionOptions = {\n mode: params.mode,\n metadata: params.metadata,\n tags: params.tags,\n chunkSize: params.chunkSize,\n waitForConfirmation: params.waitForConfirmation ?? true,\n waitMaxAttempts: 10,\n waitIntervalMs: 3000,\n apiKey: params.apiKey,\n network: this.inscriberBuilder['hederaKit'].client.network\n .toString()\n .includes('mainnet')\n ? 'mainnet'\n : 'testnet',\n };\n\n try {\n let result: any;\n \n if (params.timeoutMs) {\n const timeoutPromise = new Promise((_, reject) => {\n setTimeout(\n () => reject(new Error(`Inscription timed out after ${params.timeoutMs}ms`)),\n params.timeoutMs\n );\n });\n\n result = await Promise.race([\n this.inscriberBuilder.inscribe(\n {\n type: 'buffer',\n buffer: Buffer.from(base64Data, 'base64'),\n fileName,\n mimeType,\n },\n options\n ),\n timeoutPromise,\n ]);\n } else {\n result = await this.inscriberBuilder.inscribe(\n {\n type: 'buffer',\n buffer: Buffer.from(base64Data, 'base64'),\n fileName,\n mimeType,\n },\n options\n );\n }\n\n if (result.confirmed) {\n const topicId = result.inscription?.topic_id || result.result.topicId;\n const network = options.network || 'testnet';\n const cdnUrl = topicId\n ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}`\n : null;\n return `Successfully inscribed and confirmed content on the Hedera network!\\n\\nTransaction ID: ${\n result.result.transactionId\n }\\nTopic ID: ${topicId || 'N/A'}${\n cdnUrl ? `\\nView inscription: ${cdnUrl}` : ''\n }\\n\\nThe inscription is now available.`;\n } else {\n return `Successfully submitted inscription to the Hedera network!\\n\\nTransaction ID: ${result.result.transactionId}\\n\\nThe inscription is processing and will be confirmed shortly.`;\n }\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'Failed to inscribe from file';\n throw new Error(`Inscription failed: ${errorMessage}`);\n }\n }\n\n private getMimeType(fileName: string): string {\n const ext = path.extname(fileName).toLowerCase();\n const mimeTypes: Record<string, string> = {\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.gif': 'image/gif',\n '.webp': 'image/webp',\n '.svg': 'image/svg+xml',\n '.pdf': 'application/pdf',\n '.json': 'application/json',\n '.txt': 'text/plain',\n '.html': 'text/html',\n '.css': 'text/css',\n '.js': 'application/javascript',\n '.ts': 'application/typescript',\n '.mp4': 'video/mp4',\n '.mp3': 'audio/mpeg',\n '.wav': 'audio/wav',\n '.zip': 'application/zip',\n };\n return mimeTypes[ext] || 'application/octet-stream';\n }\n}\n"],"names":["fileName","mimeType"],"mappings":";;;;AAUA,MAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,UAAU,EAAE,SAAS,IAAI,GAAG,2BAA2B,EAAE,SAAS,kFAAkF;AAAA,EACpJ,MAAM,EACH,KAAK,CAAC,QAAQ,UAAU,CAAC,EACzB,SAAA,EACA,SAAS,wCAAwC;AAAA,EACpD,UAAU,EACP,OAAO,EAAE,QAAA,CAAS,EAClB,SAAA,EACA,SAAS,uCAAuC;AAAA,EACnD,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;AAC1E,CAAC;AAKM,MAAM,6BAA6B,uBAExC;AAAA,EAFK,cAAA;AAAA,UAAA,GAAA,SAAA;AAGL,SAAA,OAAO;AACP,SAAA,cACE;AAAA,EAAA;AAAA,EAEF,IAAI,sBAAqD;AACvD,WAAO;AAAA,EACT;AAAA,EAEA,MAAgB,aACd,QACA,aACkB;AAClB,YAAQ,IAAI,0DAA0D,OAAO,QAAQ,EAAE;AAGvF,QAAI;AACJ,QAAI;AACF,cAAQ,IAAI,0BAA0B,OAAO,QAAQ,EAAE;AACvD,cAAQ,IAAI,sCAAsC,QAAQ,IAAA,CAAK,EA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
  import { z } from "zod";
2
- import { BaseInscriberQueryTool } from "./standards-agent-kit.es32.js";
3
- const inscribeHashinalSchema = z.object({
4
- url: z.string().url().describe("The URL of the content to inscribe as Hashinal NFT"),
5
- name: z.string().describe("Name of the Hashinal NFT"),
6
- creator: z.string().describe("Creator account ID or name"),
7
- description: z.string().describe("Description of the Hashinal NFT"),
8
- type: z.string().describe('Type of NFT (e.g., "image", "video", "audio")'),
9
- attributes: z.array(
10
- z.object({
11
- trait_type: z.string(),
12
- value: z.union([z.string(), z.number()])
13
- })
14
- ).optional().describe("NFT attributes"),
15
- properties: z.record(z.unknown()).optional().describe("Additional properties"),
16
- jsonFileURL: z.string().url().optional().describe("URL to JSON metadata file"),
17
- tags: z.array(z.string()).optional().describe("Tags to categorize the NFT"),
2
+ import { BaseInscriberQueryTool } from "./standards-agent-kit.es33.js";
3
+ import { ContentResolverRegistry } from "@hashgraphonline/standards-sdk";
4
+ import { loadConfig } from "./standards-agent-kit.es2.js";
5
+ const inscribeFromBufferSchema = z.object({
6
+ base64Data: z.string().min(1, "Data cannot be empty").describe(
7
+ '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.'
8
+ ),
9
+ fileName: z.string().min(1, "File name cannot be empty").describe("Name for the inscribed content. Required for all inscriptions."),
10
+ mimeType: z.string().optional().describe("MIME type of the content"),
11
+ mode: z.enum(["file", "hashinal"]).optional().describe("Inscription mode: file or hashinal NFT"),
12
+ metadata: z.record(z.unknown()).optional().describe("Metadata to attach to the inscription"),
13
+ tags: z.array(z.string()).optional().describe("Tags to categorize the inscription"),
18
14
  chunkSize: z.number().int().positive().optional().describe("Chunk size for large files"),
19
15
  waitForConfirmation: z.boolean().optional().describe("Whether to wait for inscription confirmation"),
20
- timeoutMs: z.number().int().positive().optional().describe("Timeout in milliseconds for inscription (default: no timeout - waits until completion)"),
16
+ timeoutMs: z.number().int().positive().optional().describe(
17
+ "Timeout in milliseconds for inscription (default: no timeout - waits until completion)"
18
+ ),
21
19
  apiKey: z.string().optional().describe("API key for inscription service")
22
20
  });
23
- class InscribeHashinalTool extends BaseInscriberQueryTool {
21
+ class InscribeFromBufferTool extends BaseInscriberQueryTool {
24
22
  constructor() {
25
23
  super(...arguments);
26
- this.name = "inscribeHashinal";
27
- this.description = "Inscribe content as a Hashinal NFT on the Hedera network";
24
+ this.name = "inscribeFromBuffer";
25
+ this.description = 'Inscribe content that you have already retrieved or displayed. When user says "inscribe it" after you showed search results or other content, use THIS tool. The base64Data field accepts PLAIN TEXT (not just base64) and content reference IDs in format "content-ref:[id]". Pass the EXACT content from your previous response or MCP tool output. DO NOT generate new content or create repetitive text. Content references are automatically resolved to the original content for inscription.';
26
+ this.config = loadConfig();
28
27
  }
29
28
  get specificInputSchema() {
30
- return inscribeHashinalSchema;
29
+ return inscribeFromBufferSchema;
31
30
  }
32
31
  async executeQuery(params, _runManager) {
33
- const metadata = {
34
- name: params.name,
35
- creator: params.creator,
36
- description: params.description,
37
- type: params.type,
38
- attributes: params.attributes,
39
- properties: params.properties
40
- };
32
+ this.validateInput(params);
33
+ const resolvedContent = await this.resolveContent(
34
+ params.base64Data,
35
+ params.mimeType,
36
+ params.fileName
37
+ );
38
+ this.validateContent(resolvedContent.buffer);
39
+ const buffer = resolvedContent.buffer;
40
+ const resolvedMimeType = resolvedContent.mimeType || params.mimeType;
41
+ const resolvedFileName = resolvedContent.fileName || params.fileName;
41
42
  const options = {
42
- mode: "hashinal",
43
- metadata,
44
- jsonFileURL: params.jsonFileURL,
43
+ mode: params.mode,
44
+ metadata: params.metadata,
45
45
  tags: params.tags,
46
46
  chunkSize: params.chunkSize,
47
47
  waitForConfirmation: params.waitForConfirmation ?? true,
@@ -50,53 +50,155 @@ class InscribeHashinalTool extends BaseInscriberQueryTool {
50
50
  apiKey: params.apiKey,
51
51
  network: this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet"
52
52
  };
53
+ const timeoutMs = params.timeoutMs || (options.waitForConfirmation ? 6e4 : void 0);
53
54
  try {
54
- let result;
55
- if (params.timeoutMs) {
56
- const timeoutPromise = new Promise((_, reject) => {
57
- setTimeout(
58
- () => reject(new Error(`Inscription timed out after ${params.timeoutMs}ms`)),
59
- params.timeoutMs
60
- );
61
- });
62
- result = await Promise.race([
63
- this.inscriberBuilder.inscribe(
64
- { type: "url", url: params.url },
65
- options
66
- ),
67
- timeoutPromise
68
- ]);
69
- } else {
70
- result = await this.inscriberBuilder.inscribe(
71
- { type: "url", url: params.url },
72
- options
55
+ const result = await this.executeInscription(
56
+ buffer,
57
+ resolvedFileName,
58
+ resolvedMimeType,
59
+ options,
60
+ timeoutMs
61
+ );
62
+ return this.formatInscriptionResult(result, options);
63
+ } catch (error) {
64
+ const errorMessage = error instanceof Error ? error.message : "Failed to inscribe from buffer";
65
+ throw new Error(`Inscription failed: ${errorMessage}`);
66
+ }
67
+ }
68
+ validateInput(params) {
69
+ if (!params.base64Data || params.base64Data.trim() === "") {
70
+ throw new Error(
71
+ "No data provided. Cannot inscribe empty content. Please provide valid content, plain text, base64 encoded data, or a content reference ID."
72
+ );
73
+ }
74
+ if (!params.fileName || params.fileName.trim() === "") {
75
+ throw new Error(
76
+ "No fileName provided. A valid fileName is required for inscription."
77
+ );
78
+ }
79
+ }
80
+ validateContent(buffer) {
81
+ if (buffer.length === 0) {
82
+ throw new Error(
83
+ "Buffer is empty after conversion. The provided data appears to be invalid or empty."
84
+ );
85
+ }
86
+ if (buffer.length > this.config.maxInscriptionSize) {
87
+ const maxSizeKB = Math.round(this.config.maxInscriptionSize / 1024);
88
+ const bufferSizeKB = Math.round(buffer.length / 1024);
89
+ throw new Error(
90
+ `Content is too large for inscription (${bufferSizeKB}KB, max ${maxSizeKB}KB). Please summarize or extract key information before inscribing.`
91
+ );
92
+ }
93
+ if (buffer.length < this.config.minContentSize) {
94
+ throw new Error(
95
+ `Buffer content is too small (${buffer.length} bytes). This may indicate empty or invalid content. Please verify the source data contains actual content.`
96
+ );
97
+ }
98
+ if (buffer.toString("utf8", 0, Math.min(buffer.length, 100)).trim() === "") {
99
+ throw new Error(
100
+ "Buffer contains only whitespace or empty content. Cannot inscribe meaningless data."
101
+ );
102
+ }
103
+ const contentStr = buffer.toString("utf8");
104
+ const emptyHtmlPattern = /<a\s+href=["'][^"']+["']\s*>\s*<\/a>/i;
105
+ const hasOnlyEmptyLinks = emptyHtmlPattern.test(contentStr) && contentStr.replace(/<[^>]+>/g, "").trim().length < 50;
106
+ if (hasOnlyEmptyLinks) {
107
+ throw new Error(
108
+ "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."
109
+ );
110
+ }
111
+ }
112
+ async executeInscription(buffer, fileName, mimeType, options, timeoutMs) {
113
+ const inscriptionData = {
114
+ type: "buffer",
115
+ buffer,
116
+ fileName,
117
+ mimeType
118
+ };
119
+ if (timeoutMs) {
120
+ const timeoutPromise = new Promise((_, reject) => {
121
+ setTimeout(
122
+ () => reject(new Error(`Inscription timed out after ${timeoutMs}ms`)),
123
+ timeoutMs
73
124
  );
74
- }
75
- if (result.confirmed) {
76
- const topicId = result.inscription?.topic_id || result.result.topicId;
77
- const network = options.network || "testnet";
78
- const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;
79
- return `Successfully inscribed and confirmed Hashinal NFT on the Hedera network!
125
+ });
126
+ return Promise.race([
127
+ this.inscriberBuilder.inscribe(inscriptionData, options),
128
+ timeoutPromise
129
+ ]);
130
+ }
131
+ return this.inscriberBuilder.inscribe(inscriptionData, options);
132
+ }
133
+ formatInscriptionResult(result, options) {
134
+ if (result.confirmed) {
135
+ const topicId = result.inscription?.topic_id || result.result.topicId;
136
+ const network = options.network || "testnet";
137
+ const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;
138
+ return `Successfully inscribed and confirmed content on the Hedera network!
80
139
 
81
140
  Transaction ID: ${result.result.transactionId}
82
141
  Topic ID: ${topicId || "N/A"}${cdnUrl ? `
83
142
  View inscription: ${cdnUrl}` : ""}
84
143
 
85
- The Hashinal NFT is now available.`;
86
- } else {
87
- return `Successfully submitted Hashinal NFT inscription to the Hedera network!
144
+ The inscription is now available.`;
145
+ }
146
+ return `Successfully submitted inscription to the Hedera network!
88
147
 
89
148
  Transaction ID: ${result.result.transactionId}
90
149
 
91
150
  The inscription is processing and will be confirmed shortly.`;
151
+ }
152
+ async resolveContent(input, providedMimeType, providedFileName) {
153
+ const trimmedInput = input.trim();
154
+ const resolver = this.getContentResolver() || ContentResolverRegistry.getResolver();
155
+ if (!resolver) {
156
+ return this.handleDirectContent(trimmedInput, providedMimeType, providedFileName);
157
+ }
158
+ const referenceId = resolver.extractReferenceId(trimmedInput);
159
+ if (referenceId) {
160
+ try {
161
+ const resolution = await resolver.resolveReference(referenceId);
162
+ return {
163
+ buffer: resolution.content,
164
+ mimeType: resolution.metadata?.mimeType || providedMimeType,
165
+ fileName: resolution.metadata?.fileName || providedFileName,
166
+ wasReference: true
167
+ };
168
+ } catch (error) {
169
+ const errorMsg = error instanceof Error ? error.message : "Unknown error resolving reference";
170
+ throw new Error(`Reference resolution failed: ${errorMsg}`);
92
171
  }
93
- } catch (error) {
94
- const errorMessage = error instanceof Error ? error.message : "Failed to inscribe Hashinal NFT";
95
- throw new Error(`Inscription failed: ${errorMessage}`);
96
172
  }
173
+ return this.handleDirectContent(trimmedInput, providedMimeType, providedFileName);
174
+ }
175
+ handleDirectContent(input, providedMimeType, providedFileName) {
176
+ const isValidBase64 = /^[A-Za-z0-9+/]*={0,2}$/.test(input);
177
+ if (isValidBase64) {
178
+ try {
179
+ const buffer2 = Buffer.from(input, "base64");
180
+ return {
181
+ buffer: buffer2,
182
+ mimeType: providedMimeType,
183
+ fileName: providedFileName,
184
+ wasReference: false
185
+ };
186
+ } catch (error) {
187
+ throw new Error(
188
+ "Failed to decode base64 data. Please ensure the data is properly encoded."
189
+ );
190
+ }
191
+ }
192
+ const buffer = Buffer.from(input, "utf8");
193
+ return {
194
+ buffer,
195
+ mimeType: providedMimeType || "text/plain",
196
+ fileName: providedFileName,
197
+ wasReference: false
198
+ };
97
199
  }
98
200
  }
99
201
  export {
100
- InscribeHashinalTool
202
+ InscribeFromBufferTool
101
203
  };
102
204
  //# sourceMappingURL=standards-agent-kit.es36.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-agent-kit.es36.js","sources":["../../src/tools/inscriber/InscribeHashinalTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport { InscriptionOptions } from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\n\n/**\n * Schema for inscribing Hashinal NFT\n */\nconst inscribeHashinalSchema = z.object({\n url: z.string().url().describe('The URL of the content to inscribe as Hashinal NFT'),\n name: z.string().describe('Name of the Hashinal NFT'),\n creator: z.string().describe('Creator account ID or name'),\n description: z.string().describe('Description of the Hashinal NFT'),\n type: z.string().describe('Type of NFT (e.g., \"image\", \"video\", \"audio\")'),\n attributes: z\n .array(\n z.object({\n trait_type: z.string(),\n value: z.union([z.string(), z.number()]),\n })\n )\n .optional()\n .describe('NFT attributes'),\n properties: z\n .record(z.unknown())\n .optional()\n .describe('Additional properties'),\n jsonFileURL: z\n .string()\n .url()\n .optional()\n .describe('URL to JSON metadata file'),\n tags: z\n .array(z.string())\n .optional()\n .describe('Tags to categorize the NFT'),\n chunkSize: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Chunk size for large files'),\n waitForConfirmation: z\n .boolean()\n .optional()\n .describe('Whether to wait for inscription confirmation'),\n timeoutMs: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Timeout in milliseconds for inscription (default: no timeout - waits until completion)'),\n apiKey: z\n .string()\n .optional()\n .describe('API key for inscription service'),\n});\n\n\n/**\n * Tool for inscribing Hashinal NFTs\n */\nexport class InscribeHashinalTool extends BaseInscriberQueryTool<typeof inscribeHashinalSchema> {\n name = 'inscribeHashinal';\n description = 'Inscribe content as a Hashinal NFT on the Hedera network';\n\n get specificInputSchema() {\n return inscribeHashinalSchema;\n }\n\n protected async executeQuery(\n params: z.infer<typeof inscribeHashinalSchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<unknown> {\n const metadata = {\n name: params.name,\n creator: params.creator,\n description: params.description,\n type: params.type,\n attributes: params.attributes,\n properties: params.properties,\n };\n\n const options: InscriptionOptions = {\n mode: 'hashinal',\n metadata,\n jsonFileURL: params.jsonFileURL,\n tags: params.tags,\n chunkSize: params.chunkSize,\n waitForConfirmation: params.waitForConfirmation ?? true,\n waitMaxAttempts: 10,\n waitIntervalMs: 3000,\n apiKey: params.apiKey,\n network: this.inscriberBuilder['hederaKit'].client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet',\n };\n\n try {\n let result: Awaited<ReturnType<typeof this.inscriberBuilder.inscribe>>;\n \n if (params.timeoutMs) {\n const timeoutPromise = new Promise<never>((_, reject) => {\n setTimeout(\n () => reject(new Error(`Inscription timed out after ${params.timeoutMs}ms`)),\n params.timeoutMs\n );\n });\n\n result = await Promise.race([\n this.inscriberBuilder.inscribe(\n { type: 'url', url: params.url },\n options\n ),\n timeoutPromise\n ]);\n } else {\n result = await this.inscriberBuilder.inscribe(\n { type: 'url', url: params.url },\n options\n );\n }\n\n if (result.confirmed) {\n const topicId = result.inscription?.topic_id || result.result.topicId;\n const network = options.network || 'testnet';\n const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;\n return `Successfully inscribed and confirmed Hashinal NFT on the Hedera network!\\n\\nTransaction ID: ${result.result.transactionId}\\nTopic ID: ${topicId || 'N/A'}${cdnUrl ? `\\nView inscription: ${cdnUrl}` : ''}\\n\\nThe Hashinal NFT is now available.`;\n } else {\n return `Successfully submitted Hashinal NFT inscription to the Hedera network!\\n\\nTransaction ID: ${result.result.transactionId}\\n\\nThe inscription is processing and will be confirmed shortly.`;\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Failed to inscribe Hashinal NFT';\n throw new Error(`Inscription failed: ${errorMessage}`);\n }\n }\n}"],"names":[],"mappings":";;AAQA,MAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,KAAK,EAAE,OAAA,EAAS,IAAA,EAAM,SAAS,oDAAoD;AAAA,EACnF,MAAM,EAAE,SAAS,SAAS,0BAA0B;AAAA,EACpD,SAAS,EAAE,SAAS,SAAS,4BAA4B;AAAA,EACzD,aAAa,EAAE,SAAS,SAAS,iCAAiC;AAAA,EAClE,MAAM,EAAE,SAAS,SAAS,+CAA+C;AAAA,EACzE,YAAY,EACT;AAAA,IACC,EAAE,OAAO;AAAA,MACP,YAAY,EAAE,OAAA;AAAA,MACd,OAAO,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC;AAAA,IAAA,CACxC;AAAA,EAAA,EAEF,SAAA,EACA,SAAS,gBAAgB;AAAA,EAC5B,YAAY,EACT,OAAO,EAAE,QAAA,CAAS,EAClB,SAAA,EACA,SAAS,uBAAuB;AAAA,EACnC,aAAa,EACV,SACA,MACA,SAAA,EACA,SAAS,2BAA2B;AAAA,EACvC,MAAM,EACH,MAAM,EAAE,OAAA,CAAQ,EAChB,SAAA,EACA,SAAS,4BAA4B;AAAA,EACxC,WAAW,EACR,OAAA,EACA,IAAA,EACA,SAAA,EACA,SAAA,EACA,SAAS,4BAA4B;AAAA,EACxC,qBAAqB,EAClB,QAAA,EACA,SAAA,EACA,SAAS,8CAA8C;AAAA,EAC1D,WAAW,EACR,OAAA,EACA,IAAA,EACA,SAAA,EACA,SAAA,EACA,SAAS,wFAAwF;AAAA,EACpG,QAAQ,EACL,OAAA,EACA,SAAA,EACA,SAAS,iCAAiC;AAC/C,CAAC;AAMM,MAAM,6BAA6B,uBA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AO,aAAa,YAAY,OAAO,OAAO;AAC9D,cAAM,UAAU,QAAQ,WAAW;AACnC,cAAM,SAAS,UAAU,8CAA8C,OAAO,YAAY,OAAO,KAAK;AACtG,eAAO;AAAA;AAAA,kBAA+F,OAAO,OAAO,aAAa;AAAA,YAAe,WAAW,KAAK,GAAG,SAAS;AAAA,oBAAuB,MAAM,KAAK,EAAE;AAAA;AAAA;AAAA,MAClN,OAAO;AACL,eAAO;AAAA;AAAA,kBAA6F,OAAO,OAAO,aAAa;AAAA;AAAA;AAAA,MACjI;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.es36.js","sources":["../../src/tools/inscriber/InscribeFromBufferTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport { InscriptionOptions, ContentResolverRegistry } from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\nimport { loadConfig } from '../../config/ContentReferenceConfig';\n\nconst inscribeFromBufferSchema = z.object({\n base64Data: z\n .string()\n .min(1, 'Data cannot be empty')\n .describe(\n 'The content to inscribe. Accept BOTH plain text AND base64. Also accepts content reference IDs in format \"content-ref:[id]\". When user says \"inscribe it\" or \"inscribe the content\", use the EXACT content from your previous message or from MCP tool results. DO NOT generate new content. DO NOT create repetitive text. Pass the actual search results or other retrieved content EXACTLY as you received it.'\n ),\n fileName: z\n .string()\n .min(1, 'File name cannot be empty')\n .describe('Name for the inscribed content. Required for all inscriptions.'),\n mimeType: z.string().optional().describe('MIME type of the content'),\n mode: z\n .enum(['file', 'hashinal'])\n .optional()\n .describe('Inscription mode: file or hashinal NFT'),\n metadata: z\n .record(z.unknown())\n .optional()\n .describe('Metadata to attach to the inscription'),\n tags: z\n .array(z.string())\n .optional()\n .describe('Tags to categorize the inscription'),\n chunkSize: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Chunk size for large files'),\n waitForConfirmation: z\n .boolean()\n .optional()\n .describe('Whether to wait for inscription confirmation'),\n timeoutMs: z\n .number()\n .int()\n .positive()\n .optional()\n .describe(\n 'Timeout in milliseconds for inscription (default: no timeout - waits until completion)'\n ),\n apiKey: z.string().optional().describe('API key for inscription service'),\n});\n\nexport class InscribeFromBufferTool extends BaseInscriberQueryTool<\n typeof inscribeFromBufferSchema\n> {\n name = 'inscribeFromBuffer';\n description =\n 'Inscribe content that you have already retrieved or displayed. When user says \"inscribe it\" after you showed search results or other content, use THIS tool. The base64Data field accepts PLAIN TEXT (not just base64) and content reference IDs in format \"content-ref:[id]\". Pass the EXACT content from your previous response or MCP tool output. DO NOT generate new content or create repetitive text. Content references are automatically resolved to the original content for inscription.';\n\n private config = loadConfig();\n\n get specificInputSchema() {\n return inscribeFromBufferSchema;\n }\n\n protected async executeQuery(\n params: z.infer<typeof inscribeFromBufferSchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<unknown> {\n this.validateInput(params);\n\n const resolvedContent = await this.resolveContent(\n params.base64Data,\n params.mimeType,\n params.fileName\n );\n\n this.validateContent(resolvedContent.buffer);\n\n const buffer = resolvedContent.buffer;\n const resolvedMimeType = resolvedContent.mimeType || params.mimeType;\n const resolvedFileName = resolvedContent.fileName || params.fileName;\n\n const options: InscriptionOptions = {\n mode: params.mode,\n metadata: params.metadata,\n tags: params.tags,\n chunkSize: params.chunkSize,\n waitForConfirmation: params.waitForConfirmation ?? true,\n waitMaxAttempts: 10,\n waitIntervalMs: 3000,\n apiKey: params.apiKey,\n network: this.inscriberBuilder['hederaKit'].client.network\n .toString()\n .includes('mainnet')\n ? 'mainnet'\n : 'testnet',\n };\n\n const timeoutMs =\n params.timeoutMs || (options.waitForConfirmation ? 60000 : undefined);\n\n try {\n const result = await this.executeInscription(\n buffer,\n resolvedFileName,\n resolvedMimeType,\n options,\n timeoutMs\n );\n return this.formatInscriptionResult(result, options);\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : 'Failed to inscribe from buffer';\n throw new Error(`Inscription failed: ${errorMessage}`);\n }\n }\n\n private validateInput(\n params: z.infer<typeof inscribeFromBufferSchema>\n ): void {\n if (!params.base64Data || params.base64Data.trim() === '') {\n throw new Error(\n 'No data provided. Cannot inscribe empty content. Please provide valid content, plain text, base64 encoded data, or a content reference ID.'\n );\n }\n\n if (!params.fileName || params.fileName.trim() === '') {\n throw new Error(\n 'No fileName provided. A valid fileName is required for inscription.'\n );\n }\n }\n\n private validateContent(buffer: Buffer): void {\n if (buffer.length === 0) {\n throw new Error(\n 'Buffer is empty after conversion. The provided data appears to be invalid or empty.'\n );\n }\n\n if (buffer.length > this.config.maxInscriptionSize) {\n const maxSizeKB = Math.round(this.config.maxInscriptionSize / 1024);\n const bufferSizeKB = Math.round(buffer.length / 1024);\n throw new Error(\n `Content is too large for inscription (${bufferSizeKB}KB, max ${maxSizeKB}KB). Please summarize or extract key information before inscribing.`\n );\n }\n\n if (buffer.length < this.config.minContentSize) {\n throw new Error(\n `Buffer content is too small (${buffer.length} bytes). This may indicate empty or invalid content. Please verify the source data contains actual content.`\n );\n }\n\n if (\n buffer.toString('utf8', 0, Math.min(buffer.length, 100)).trim() === ''\n ) {\n throw new Error(\n 'Buffer contains only whitespace or empty content. Cannot inscribe meaningless data.'\n );\n }\n\n const contentStr = buffer.toString('utf8');\n const emptyHtmlPattern = /<a\\s+href=[\"'][^\"']+[\"']\\s*>\\s*<\\/a>/i;\n const hasOnlyEmptyLinks =\n emptyHtmlPattern.test(contentStr) &&\n contentStr.replace(/<[^>]+>/g, '').trim().length < 50;\n\n if (hasOnlyEmptyLinks) {\n throw new Error(\n 'Buffer contains empty HTML with only links and no actual content. When inscribing content from external sources, use the actual article text you retrieved, not empty HTML with links.'\n );\n }\n }\n\n private async executeInscription(\n buffer: Buffer,\n fileName: string,\n mimeType: string | undefined,\n options: InscriptionOptions,\n timeoutMs?: number\n ): Promise<Awaited<ReturnType<typeof this.inscriberBuilder.inscribe>>> {\n const inscriptionData = {\n type: 'buffer' as const,\n buffer,\n fileName,\n mimeType,\n };\n\n if (timeoutMs) {\n const timeoutPromise = new Promise<never>((_, reject) => {\n setTimeout(\n () => reject(new Error(`Inscription timed out after ${timeoutMs}ms`)),\n timeoutMs\n );\n });\n\n return Promise.race([\n this.inscriberBuilder.inscribe(inscriptionData, options),\n timeoutPromise,\n ]);\n }\n\n return this.inscriberBuilder.inscribe(inscriptionData, options);\n }\n\n private formatInscriptionResult(\n result: Awaited<ReturnType<typeof this.inscriberBuilder.inscribe>>,\n options: InscriptionOptions\n ): string {\n if (result.confirmed) {\n const topicId = result.inscription?.topic_id || result.result.topicId;\n const network = options.network || 'testnet';\n const cdnUrl = topicId\n ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}`\n : null;\n return `Successfully inscribed and confirmed content on the Hedera network!\\n\\nTransaction ID: ${\n result.result.transactionId\n }\\nTopic ID: ${topicId || 'N/A'}${\n cdnUrl ? `\\nView inscription: ${cdnUrl}` : ''\n }\\n\\nThe inscription is now available.`;\n }\n\n return `Successfully submitted inscription to the Hedera network!\\n\\nTransaction ID: ${result.result.transactionId}\\n\\nThe inscription is processing and will be confirmed shortly.`;\n }\n\n private async resolveContent(\n input: string,\n providedMimeType?: string,\n providedFileName?: string\n ): Promise<{\n buffer: Buffer;\n mimeType?: string;\n fileName?: string;\n wasReference?: boolean;\n }> {\n const trimmedInput = input.trim();\n \n // Try to get resolver from either injected dependency or registry\n const resolver = this.getContentResolver() || ContentResolverRegistry.getResolver();\n \n if (!resolver) {\n // No resolver available, handle content directly\n return this.handleDirectContent(trimmedInput, providedMimeType, providedFileName);\n }\n \n const referenceId = resolver.extractReferenceId(trimmedInput);\n\n if (referenceId) {\n try {\n const resolution = await resolver.resolveReference(referenceId);\n\n return {\n buffer: resolution.content,\n mimeType: resolution.metadata?.mimeType || providedMimeType,\n fileName: resolution.metadata?.fileName || providedFileName,\n wasReference: true,\n };\n } catch (error) {\n const errorMsg =\n error instanceof Error\n ? error.message\n : 'Unknown error resolving reference';\n throw new Error(`Reference resolution failed: ${errorMsg}`);\n }\n }\n\n // No reference found, handle as direct content\n return this.handleDirectContent(trimmedInput, providedMimeType, providedFileName);\n }\n\n private handleDirectContent(\n input: string,\n providedMimeType?: string,\n providedFileName?: string\n ): {\n buffer: Buffer;\n mimeType?: string;\n fileName?: string;\n wasReference?: boolean;\n } {\n const isValidBase64 = /^[A-Za-z0-9+/]*={0,2}$/.test(input);\n\n if (isValidBase64) {\n try {\n const buffer = Buffer.from(input, 'base64');\n return {\n buffer,\n mimeType: providedMimeType,\n fileName: providedFileName,\n wasReference: false,\n };\n } catch (error) {\n throw new Error(\n 'Failed to decode base64 data. Please ensure the data is properly encoded.'\n );\n }\n }\n\n const buffer = Buffer.from(input, 'utf8');\n return {\n buffer,\n mimeType: providedMimeType || 'text/plain',\n fileName: providedFileName,\n wasReference: false,\n };\n }\n}\n"],"names":["buffer"],"mappings":";;;;AAMA,MAAM,2BAA2B,EAAE,OAAO;AAAA,EACxC,YAAY,EACT,OAAA,EACA,IAAI,GAAG,sBAAsB,EAC7B;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,UAAU,EACP,SACA,IAAI,GAAG,2BAA2B,EAClC,SAAS,gEAAgE;AAAA,EAC5E,UAAU,EAAE,OAAA,EAAS,SAAA,EAAW,SAAS,0BAA0B;AAAA,EACnE,MAAM,EACH,KAAK,CAAC,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,S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