@hashgraphonline/standards-agent-kit 0.2.136 → 0.2.138
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -4
- package/dist/cjs/builders/hcs10/hcs10-builder.d.ts +1 -0
- package/dist/cjs/builders/hcs2/hcs2-builder.d.ts +8 -7
- package/dist/cjs/builders/hcs6/hcs6-builder.d.ts +5 -4
- package/dist/cjs/builders/inscriber/inscriber-builder.d.ts +32 -1
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/signing/bytes-registry.d.ts +17 -0
- package/dist/cjs/signing/signer-provider.d.ts +45 -0
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/cjs/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
- package/dist/cjs/tools/hcs2/CreateRegistryTool.d.ts +2 -2
- package/dist/cjs/tools/hcs2/DeleteEntryTool.d.ts +2 -2
- package/dist/cjs/tools/hcs2/UpdateEntryTool.d.ts +2 -2
- package/dist/cjs/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
- package/dist/cjs/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
- package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
- package/dist/cjs/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
- package/dist/cjs/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
- package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +3 -3
- package/dist/cjs/types/inscription-response.d.ts +8 -0
- package/dist/cjs/types/tx-results.d.ts +15 -0
- package/dist/cjs/utils/CodedError.d.ts +4 -0
- package/dist/cjs/utils/inscription-utils.d.ts +21 -0
- package/dist/cjs/validation/hip412-schemas.d.ts +2 -2
- package/dist/es/builders/hcs10/hcs10-builder.d.ts +1 -0
- package/dist/es/builders/hcs2/hcs2-builder.d.ts +8 -7
- package/dist/es/builders/hcs6/hcs6-builder.d.ts +5 -4
- package/dist/es/builders/inscriber/inscriber-builder.d.ts +32 -1
- package/dist/es/index.d.ts +4 -0
- package/dist/es/signing/bytes-registry.d.ts +17 -0
- package/dist/es/signing/signer-provider.d.ts +45 -0
- package/dist/es/standards-agent-kit.es.js +46 -42
- package/dist/es/standards-agent-kit.es.js.map +1 -1
- package/dist/es/standards-agent-kit.es10.js +24 -83
- package/dist/es/standards-agent-kit.es10.js.map +1 -1
- package/dist/es/standards-agent-kit.es11.js +224 -20
- package/dist/es/standards-agent-kit.es11.js.map +1 -1
- package/dist/es/standards-agent-kit.es12.js +78 -27
- package/dist/es/standards-agent-kit.es12.js.map +1 -1
- package/dist/es/standards-agent-kit.es13.js +26 -36
- package/dist/es/standards-agent-kit.es13.js.map +1 -1
- package/dist/es/standards-agent-kit.es14.js +17 -39
- package/dist/es/standards-agent-kit.es14.js.map +1 -1
- package/dist/es/standards-agent-kit.es15.js +36 -58
- package/dist/es/standards-agent-kit.es15.js.map +1 -1
- package/dist/es/standards-agent-kit.es16.js +45 -18
- package/dist/es/standards-agent-kit.es16.js.map +1 -1
- package/dist/es/standards-agent-kit.es17.js +53 -16
- package/dist/es/standards-agent-kit.es17.js.map +1 -1
- package/dist/es/standards-agent-kit.es18.js +18 -28
- package/dist/es/standards-agent-kit.es18.js.map +1 -1
- package/dist/es/standards-agent-kit.es19.js +26 -12
- package/dist/es/standards-agent-kit.es19.js.map +1 -1
- package/dist/es/standards-agent-kit.es20.js +38 -136
- package/dist/es/standards-agent-kit.es20.js.map +1 -1
- package/dist/es/standards-agent-kit.es21.js +13 -24
- package/dist/es/standards-agent-kit.es21.js.map +1 -1
- package/dist/es/standards-agent-kit.es22.js +136 -39
- package/dist/es/standards-agent-kit.es22.js.map +1 -1
- package/dist/es/standards-agent-kit.es23.js +25 -41
- package/dist/es/standards-agent-kit.es23.js.map +1 -1
- package/dist/es/standards-agent-kit.es24.js +49 -31
- package/dist/es/standards-agent-kit.es24.js.map +1 -1
- package/dist/es/standards-agent-kit.es25.js +34 -18
- package/dist/es/standards-agent-kit.es25.js.map +1 -1
- package/dist/es/standards-agent-kit.es26.js +35 -19
- package/dist/es/standards-agent-kit.es26.js.map +1 -1
- package/dist/es/standards-agent-kit.es27.js +45 -32
- package/dist/es/standards-agent-kit.es27.js.map +1 -1
- package/dist/es/standards-agent-kit.es28.js +54 -25
- package/dist/es/standards-agent-kit.es28.js.map +1 -1
- package/dist/es/standards-agent-kit.es29.js +35 -23
- package/dist/es/standards-agent-kit.es29.js.map +1 -1
- package/dist/es/standards-agent-kit.es3.js +41 -1545
- package/dist/es/standards-agent-kit.es3.js.map +1 -1
- package/dist/es/standards-agent-kit.es30.js +23 -39
- package/dist/es/standards-agent-kit.es30.js.map +1 -1
- package/dist/es/standards-agent-kit.es31.js +30 -28
- package/dist/es/standards-agent-kit.es31.js.map +1 -1
- package/dist/es/standards-agent-kit.es32.js +45 -32
- package/dist/es/standards-agent-kit.es32.js.map +1 -1
- package/dist/es/standards-agent-kit.es33.js +50 -89
- package/dist/es/standards-agent-kit.es33.js.map +1 -1
- package/dist/es/standards-agent-kit.es34.js +35 -228
- package/dist/es/standards-agent-kit.es34.js.map +1 -1
- package/dist/es/standards-agent-kit.es35.js +87 -212
- package/dist/es/standards-agent-kit.es35.js.map +1 -1
- package/dist/es/standards-agent-kit.es36.js +188 -128
- package/dist/es/standards-agent-kit.es36.js.map +1 -1
- package/dist/es/standards-agent-kit.es37.js +167 -561
- package/dist/es/standards-agent-kit.es37.js.map +1 -1
- package/dist/es/standards-agent-kit.es38.js +236 -31
- package/dist/es/standards-agent-kit.es38.js.map +1 -1
- package/dist/es/standards-agent-kit.es39.js +483 -206
- package/dist/es/standards-agent-kit.es39.js.map +1 -1
- package/dist/es/standards-agent-kit.es4.js +359 -81
- package/dist/es/standards-agent-kit.es4.js.map +1 -1
- package/dist/es/standards-agent-kit.es40.js +39 -135
- package/dist/es/standards-agent-kit.es40.js.map +1 -1
- package/dist/es/standards-agent-kit.es41.js +244 -28
- package/dist/es/standards-agent-kit.es41.js.map +1 -1
- package/dist/es/standards-agent-kit.es42.js +132 -418
- package/dist/es/standards-agent-kit.es42.js.map +1 -1
- package/dist/es/standards-agent-kit.es43.js +28 -184
- package/dist/es/standards-agent-kit.es43.js.map +1 -1
- package/dist/es/standards-agent-kit.es44.js +423 -3
- package/dist/es/standards-agent-kit.es44.js.map +1 -1
- package/dist/es/standards-agent-kit.es45.js +185 -24
- package/dist/es/standards-agent-kit.es45.js.map +1 -1
- package/dist/es/standards-agent-kit.es46.js +3 -3
- package/dist/es/standards-agent-kit.es46.js.map +1 -1
- package/dist/es/standards-agent-kit.es47.js +21 -50
- package/dist/es/standards-agent-kit.es47.js.map +1 -1
- package/dist/es/standards-agent-kit.es48.js +8 -3
- package/dist/es/standards-agent-kit.es48.js.map +1 -1
- package/dist/es/standards-agent-kit.es49.js +3 -39
- package/dist/es/standards-agent-kit.es49.js.map +1 -1
- package/dist/es/standards-agent-kit.es5.js +1747 -73
- package/dist/es/standards-agent-kit.es5.js.map +1 -1
- package/dist/es/standards-agent-kit.es50.js +18 -16
- package/dist/es/standards-agent-kit.es50.js.map +1 -1
- package/dist/es/standards-agent-kit.es51.js +49 -49
- package/dist/es/standards-agent-kit.es51.js.map +1 -1
- package/dist/es/standards-agent-kit.es52.js +6 -0
- package/dist/es/standards-agent-kit.es52.js.map +1 -0
- package/dist/es/standards-agent-kit.es53.js +43 -0
- package/dist/es/standards-agent-kit.es53.js.map +1 -0
- package/dist/es/standards-agent-kit.es54.js +22 -0
- package/dist/es/standards-agent-kit.es54.js.map +1 -0
- package/dist/es/standards-agent-kit.es55.js +77 -0
- package/dist/es/standards-agent-kit.es55.js.map +1 -0
- package/dist/es/standards-agent-kit.es56.js +7 -0
- package/dist/es/standards-agent-kit.es56.js.map +1 -0
- package/dist/es/standards-agent-kit.es6.js +347 -32
- package/dist/es/standards-agent-kit.es6.js.map +1 -1
- package/dist/es/standards-agent-kit.es7.js +142 -293
- package/dist/es/standards-agent-kit.es7.js.map +1 -1
- package/dist/es/standards-agent-kit.es8.js +201 -21
- package/dist/es/standards-agent-kit.es8.js.map +1 -1
- package/dist/es/standards-agent-kit.es9.js +301 -213
- package/dist/es/standards-agent-kit.es9.js.map +1 -1
- package/dist/es/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
- package/dist/es/tools/hcs2/CreateRegistryTool.d.ts +2 -2
- package/dist/es/tools/hcs2/DeleteEntryTool.d.ts +2 -2
- package/dist/es/tools/hcs2/UpdateEntryTool.d.ts +2 -2
- package/dist/es/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
- package/dist/es/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
- package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
- package/dist/es/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
- package/dist/es/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
- package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +3 -3
- package/dist/es/types/inscription-response.d.ts +8 -0
- package/dist/es/types/tx-results.d.ts +15 -0
- package/dist/es/utils/CodedError.d.ts +4 -0
- package/dist/es/utils/inscription-utils.d.ts +21 -0
- package/dist/es/validation/hip412-schemas.d.ts +2 -2
- package/dist/umd/builders/hcs10/hcs10-builder.d.ts +1 -0
- package/dist/umd/builders/hcs2/hcs2-builder.d.ts +8 -7
- package/dist/umd/builders/hcs6/hcs6-builder.d.ts +5 -4
- package/dist/umd/builders/inscriber/inscriber-builder.d.ts +32 -1
- package/dist/umd/index.d.ts +4 -0
- package/dist/umd/signing/bytes-registry.d.ts +17 -0
- package/dist/umd/signing/signer-provider.d.ts +45 -0
- package/dist/umd/standards-agent-kit.umd.js +1 -1
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/dist/umd/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
- package/dist/umd/tools/hcs2/CreateRegistryTool.d.ts +2 -2
- package/dist/umd/tools/hcs2/DeleteEntryTool.d.ts +2 -2
- package/dist/umd/tools/hcs2/UpdateEntryTool.d.ts +2 -2
- package/dist/umd/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
- package/dist/umd/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
- package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
- package/dist/umd/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
- package/dist/umd/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
- package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +3 -3
- package/dist/umd/types/inscription-response.d.ts +8 -0
- package/dist/umd/types/tx-results.d.ts +15 -0
- package/dist/umd/utils/CodedError.d.ts +4 -0
- package/dist/umd/utils/inscription-utils.d.ts +21 -0
- package/dist/umd/validation/hip412-schemas.d.ts +2 -2
- package/package.json +10 -5
- package/src/builders/hcs10/hcs10-builder.ts +239 -6
- package/src/builders/hcs2/hcs2-builder.ts +302 -9
- package/src/builders/hcs6/hcs6-builder.ts +79 -4
- package/src/builders/inscriber/inscriber-builder.ts +235 -2
- package/src/hcs10/HCS10Client.ts +1 -1
- package/src/index.ts +5 -1
- package/src/lib/zod-render/schema-extension.ts +0 -1
- package/src/signing/bytes-registry.ts +501 -0
- package/src/signing/signer-provider.ts +120 -0
- package/src/tools/hcs2/CreateRegistryTool.ts +30 -5
- package/src/tools/hcs2/DeleteEntryTool.ts +16 -2
- package/src/tools/hcs2/MigrateRegistryTool.ts +16 -2
- package/src/tools/hcs2/QueryRegistryTool.ts +11 -2
- package/src/tools/hcs2/RegisterEntryTool.ts +17 -3
- package/src/tools/hcs2/UpdateEntryTool.ts +16 -2
- package/src/tools/hcs6/CreateDynamicRegistryTool.ts +17 -3
- package/src/tools/hcs6/RegisterDynamicHashinalTool.ts +17 -3
- package/src/tools/hcs6/UpdateDynamicHashinalTool.ts +17 -3
- package/src/tools/inscriber/InscribeFromBufferTool.ts +126 -21
- package/src/tools/inscriber/InscribeFromFileTool.ts +10 -13
- package/src/tools/inscriber/InscribeFromUrlTool.ts +15 -11
- package/src/tools/inscriber/InscribeHashinalTool.ts +40 -168
- package/src/tools/inscriber/RetrieveInscriptionTool.ts +15 -16
- package/src/types/inscription-response.ts +27 -0
- package/src/types/tx-results.ts +18 -0
- package/src/utils/CodedError.ts +8 -0
- package/src/utils/Encryption.ts +0 -2
- package/src/utils/ensure-agent-has-hbar.ts +4 -5
- package/src/utils/inscription-utils.ts +53 -0
|
@@ -1,223 +1,98 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
),
|
|
9
|
-
mode: z.enum(["file", "hashinal"]).optional().describe("Inscription mode: file or hashinal NFT"),
|
|
10
|
-
metadata: z.record(z.unknown()).optional().describe("Metadata to attach to the inscription"),
|
|
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("Whether to wait for inscription confirmation"),
|
|
14
|
-
timeoutMs: z.number().int().positive().optional().describe("Timeout in milliseconds for inscription (default: no timeout)"),
|
|
15
|
-
apiKey: z.string().optional().describe("API key for inscription service"),
|
|
16
|
-
quoteOnly: z.boolean().optional().default(false).describe(
|
|
17
|
-
"If true, returns a cost quote instead of executing the inscription"
|
|
18
|
-
)
|
|
19
|
-
});
|
|
20
|
-
class InscribeFromFileTool extends BaseInscriberQueryTool {
|
|
21
|
-
constructor() {
|
|
22
|
-
super(...arguments);
|
|
23
|
-
this.name = "inscribeFromFile";
|
|
24
|
-
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. Set quoteOnly=true to get cost estimates without executing the inscription.";
|
|
1
|
+
import { BaseHederaTransactionTool, BaseHederaQueryTool } from "hedera-agent-kit";
|
|
2
|
+
class BaseInscriberTransactionTool extends BaseHederaTransactionTool {
|
|
3
|
+
constructor(params) {
|
|
4
|
+
super(params);
|
|
5
|
+
this.namespace = "inscriber";
|
|
6
|
+
this.inscriberBuilder = params.inscriberBuilder;
|
|
7
|
+
this.contentResolver = params.contentResolver || null;
|
|
25
8
|
}
|
|
26
|
-
|
|
27
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Override to return the InscriberBuilder
|
|
11
|
+
*/
|
|
12
|
+
getServiceBuilder() {
|
|
13
|
+
return this.inscriberBuilder;
|
|
28
14
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (!fileContent || fileContent.length === 0) {
|
|
55
|
-
throw new Error(
|
|
56
|
-
`File "${params.filePath}" has no content after reading. Cannot inscribe empty files.`
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
if (fileContent.length < 10) {
|
|
60
|
-
throw new Error(
|
|
61
|
-
`File "${params.filePath}" content is too small (${fileContent.length} bytes). Files must contain at least 10 bytes of meaningful content.`
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
const fileName2 = path.basename(params.filePath);
|
|
65
|
-
const mimeType2 = this.getMimeType(fileName2);
|
|
66
|
-
if (mimeType2.startsWith("text/") || mimeType2 === "application/json") {
|
|
67
|
-
const textContent = fileContent.toString(
|
|
68
|
-
"utf8",
|
|
69
|
-
0,
|
|
70
|
-
Math.min(fileContent.length, 1e3)
|
|
71
|
-
);
|
|
72
|
-
if (textContent.trim() === "") {
|
|
73
|
-
throw new Error(
|
|
74
|
-
`File "${params.filePath}" contains only whitespace or empty content. Cannot inscribe meaningless data.`
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
} catch (error) {
|
|
79
|
-
if (error instanceof Error) {
|
|
80
|
-
if (error.message.includes("ENOENT")) {
|
|
81
|
-
throw new Error(`File not found: "${params.filePath}"`);
|
|
82
|
-
}
|
|
83
|
-
throw error;
|
|
84
|
-
}
|
|
85
|
-
throw new Error(`Failed to read file: ${error}`);
|
|
86
|
-
}
|
|
87
|
-
const base64Data = fileContent.toString("base64");
|
|
88
|
-
this.logger?.info(`Converted to base64: ${base64Data.length} characters`);
|
|
89
|
-
const fileName = path.basename(params.filePath);
|
|
90
|
-
const mimeType = this.getMimeType(fileName);
|
|
91
|
-
this.logger?.info(`File: ${fileName}, MIME type: ${mimeType}`);
|
|
92
|
-
const options = {
|
|
93
|
-
mode: params.mode,
|
|
94
|
-
metadata: params.metadata,
|
|
95
|
-
tags: params.tags,
|
|
96
|
-
chunkSize: params.chunkSize,
|
|
97
|
-
waitForConfirmation: params.quoteOnly ? false : params.waitForConfirmation ?? true,
|
|
98
|
-
waitMaxAttempts: 10,
|
|
99
|
-
waitIntervalMs: 3e3,
|
|
100
|
-
apiKey: params.apiKey,
|
|
101
|
-
network: this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet",
|
|
102
|
-
quoteOnly: params.quoteOnly
|
|
15
|
+
/**
|
|
16
|
+
* Get content resolver with fallback to registry
|
|
17
|
+
*/
|
|
18
|
+
getContentResolver() {
|
|
19
|
+
return this.contentResolver;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Set entity creation handler for automatic entity storage
|
|
23
|
+
*/
|
|
24
|
+
setEntityCreationHandler(handler) {
|
|
25
|
+
this.onEntityCreated = handler;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Generate a quote for an inscription without executing it
|
|
29
|
+
* @param input - The inscription input data
|
|
30
|
+
* @param options - Inscription options
|
|
31
|
+
* @returns Promise containing the quote result
|
|
32
|
+
*/
|
|
33
|
+
async generateInscriptionQuote(input, options) {
|
|
34
|
+
const network = this.inscriberBuilder["hederaKit"].client.network;
|
|
35
|
+
const networkType = network.toString().includes("mainnet") ? "mainnet" : "testnet";
|
|
36
|
+
const quoteOptions = {
|
|
37
|
+
...options,
|
|
38
|
+
quoteOnly: true,
|
|
39
|
+
network: networkType
|
|
103
40
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
{
|
|
108
|
-
type: "buffer",
|
|
109
|
-
buffer: Buffer.from(base64Data, "base64"),
|
|
110
|
-
fileName,
|
|
111
|
-
mimeType
|
|
112
|
-
},
|
|
113
|
-
options
|
|
114
|
-
);
|
|
115
|
-
return {
|
|
116
|
-
success: true,
|
|
117
|
-
quote: {
|
|
118
|
-
totalCostHbar: quote.totalCostHbar,
|
|
119
|
-
validUntil: quote.validUntil,
|
|
120
|
-
breakdown: quote.breakdown
|
|
121
|
-
},
|
|
122
|
-
contentInfo: {
|
|
123
|
-
fileName,
|
|
124
|
-
mimeType,
|
|
125
|
-
sizeBytes: fileContent.length,
|
|
126
|
-
filePath: params.filePath
|
|
127
|
-
},
|
|
128
|
-
message: `Estimated Quote for file: ${fileName} (${(fileContent.length / 1024).toFixed(2)} KB)
|
|
129
|
-
Total cost: ${quote.totalCostHbar} HBAR`
|
|
130
|
-
};
|
|
131
|
-
} catch (error) {
|
|
132
|
-
const errorMessage = error instanceof Error ? error.message : "Failed to generate inscription quote";
|
|
133
|
-
throw new Error(`Quote generation failed: ${errorMessage}`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
try {
|
|
137
|
-
let result;
|
|
138
|
-
if (params.timeoutMs) {
|
|
139
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
140
|
-
setTimeout(
|
|
141
|
-
() => reject(
|
|
142
|
-
new Error(`Inscription timed out after ${params.timeoutMs}ms`)
|
|
143
|
-
),
|
|
144
|
-
params.timeoutMs
|
|
145
|
-
);
|
|
146
|
-
});
|
|
147
|
-
result = await Promise.race([
|
|
148
|
-
this.inscriberBuilder.inscribe(
|
|
149
|
-
{
|
|
150
|
-
type: "buffer",
|
|
151
|
-
buffer: Buffer.from(base64Data, "base64"),
|
|
152
|
-
fileName,
|
|
153
|
-
mimeType
|
|
154
|
-
},
|
|
155
|
-
options
|
|
156
|
-
),
|
|
157
|
-
timeoutPromise
|
|
158
|
-
]);
|
|
159
|
-
} else {
|
|
160
|
-
result = await this.inscriberBuilder.inscribe(
|
|
161
|
-
{
|
|
162
|
-
type: "buffer",
|
|
163
|
-
buffer: Buffer.from(base64Data, "base64"),
|
|
164
|
-
fileName,
|
|
165
|
-
mimeType
|
|
166
|
-
},
|
|
167
|
-
options
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
const inscriptionResult = result;
|
|
171
|
-
if (inscriptionResult.confirmed && !inscriptionResult.quote) {
|
|
172
|
-
const topicId = inscriptionResult.inscription?.topic_id || inscriptionResult.result.topicId;
|
|
173
|
-
const network = options.network || "testnet";
|
|
174
|
-
const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;
|
|
175
|
-
return `Successfully inscribed and confirmed content on the Hedera network!
|
|
176
|
-
|
|
177
|
-
Transaction ID: ${inscriptionResult.result.transactionId}
|
|
178
|
-
Topic ID: ${topicId || "N/A"}${cdnUrl ? `
|
|
179
|
-
View inscription: ${cdnUrl}` : ""}
|
|
180
|
-
|
|
181
|
-
The inscription is now available.`;
|
|
182
|
-
} else if (!inscriptionResult.quote && !inscriptionResult.confirmed) {
|
|
183
|
-
return `Successfully submitted inscription to the Hedera network!
|
|
184
|
-
|
|
185
|
-
Transaction ID: ${inscriptionResult.result.transactionId}
|
|
186
|
-
|
|
187
|
-
The inscription is processing and will be confirmed shortly.`;
|
|
188
|
-
} else {
|
|
189
|
-
return "Inscription operation completed.";
|
|
190
|
-
}
|
|
191
|
-
} catch (error) {
|
|
192
|
-
const errorMessage = error instanceof Error ? error.message : "Failed to inscribe from file";
|
|
193
|
-
throw new Error(`Inscription failed: ${errorMessage}`);
|
|
41
|
+
const result = await this.inscriberBuilder.inscribe(input, quoteOptions);
|
|
42
|
+
if (!result.quote || result.confirmed) {
|
|
43
|
+
throw new Error("Failed to generate quote - unexpected response type");
|
|
194
44
|
}
|
|
45
|
+
return result.result;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
class BaseInscriberQueryTool extends BaseHederaQueryTool {
|
|
49
|
+
constructor(params) {
|
|
50
|
+
super(params);
|
|
51
|
+
this.namespace = "inscriber";
|
|
52
|
+
this.inscriberBuilder = params.inscriberBuilder;
|
|
53
|
+
this.contentResolver = params.contentResolver || null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Override to return the InscriberBuilder
|
|
57
|
+
*/
|
|
58
|
+
getServiceBuilder() {
|
|
59
|
+
return this.inscriberBuilder;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get content resolver with fallback to registry
|
|
63
|
+
*/
|
|
64
|
+
getContentResolver() {
|
|
65
|
+
return this.contentResolver;
|
|
195
66
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
".zip": "application/zip"
|
|
67
|
+
/**
|
|
68
|
+
* Set entity creation handler for automatic entity storage
|
|
69
|
+
*/
|
|
70
|
+
setEntityCreationHandler(handler) {
|
|
71
|
+
this.onEntityCreated = handler;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Generate a quote for an inscription without executing it
|
|
75
|
+
* @param input - The inscription input data
|
|
76
|
+
* @param options - Inscription options
|
|
77
|
+
* @returns Promise containing the quote result
|
|
78
|
+
*/
|
|
79
|
+
async generateInscriptionQuote(input, options) {
|
|
80
|
+
const network = this.inscriberBuilder["hederaKit"].client.network;
|
|
81
|
+
const networkType = network.toString().includes("mainnet") ? "mainnet" : "testnet";
|
|
82
|
+
const quoteOptions = {
|
|
83
|
+
...options,
|
|
84
|
+
quoteOnly: true,
|
|
85
|
+
network: networkType
|
|
216
86
|
};
|
|
217
|
-
|
|
87
|
+
const result = await this.inscriberBuilder.inscribe(input, quoteOptions);
|
|
88
|
+
if (!result.quote || result.confirmed) {
|
|
89
|
+
throw new Error("Failed to generate quote - unexpected response type");
|
|
90
|
+
}
|
|
91
|
+
return result.result;
|
|
218
92
|
}
|
|
219
93
|
}
|
|
220
94
|
export {
|
|
221
|
-
|
|
95
|
+
BaseInscriberQueryTool,
|
|
96
|
+
BaseInscriberTransactionTool
|
|
222
97
|
};
|
|
223
98
|
//# sourceMappingURL=standards-agent-kit.es35.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es35.js","sources":["../../src/tools/inscriber/InscribeFromFileTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport { InscriptionOptions } from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\n\n/**\n * Schema for inscribing from file\n */\nconst inscribeFromFileSchema = z.object({\n filePath: z\n .string()\n .min(1, 'File path cannot be empty')\n .describe(\n 'The file path of the content to inscribe. Must point to a valid, non-empty file.'\n ),\n mode: z\n .enum(['file', 'hashinal'])\n .optional()\n .describe('Inscription mode: file or hashinal NFT'),\n metadata: z\n .record(z.unknown())\n .optional()\n .describe('Metadata to attach to the inscription'),\n tags: z\n .array(z.string())\n .optional()\n .describe('Tags to categorize the inscription'),\n chunkSize: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Chunk size for large files'),\n waitForConfirmation: z\n .boolean()\n .optional()\n .describe('Whether to wait for inscription confirmation'),\n timeoutMs: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Timeout in milliseconds for inscription (default: no timeout)'),\n apiKey: z.string().optional().describe('API key for inscription service'),\n quoteOnly: z\n .boolean()\n .optional()\n .default(false)\n .describe(\n 'If true, returns a cost quote instead of executing the inscription'\n ),\n});\n\n/**\n * Tool for inscribing content from file\n */\nexport class InscribeFromFileTool extends BaseInscriberQueryTool<\n typeof inscribeFromFileSchema\n> {\n name = 'inscribeFromFile';\n description =\n 'Inscribe content from a local file to the Hedera network using a file path. IMPORTANT: Only use this tool when you have a valid file path to actual content. The file must exist and contain meaningful data (minimum 10 bytes). For files accessed through MCP filesystem tools, consider reading the file content first and using inscribeFromBuffer instead. Set quoteOnly=true to get cost estimates without executing the inscription.';\n\n get specificInputSchema(): typeof inscribeFromFileSchema {\n return inscribeFromFileSchema;\n }\n\n protected async executeQuery(\n params: z.infer<typeof inscribeFromFileSchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<unknown> {\n let fileContent: Buffer;\n try {\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 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 this.logger?.warn(\n `Large file detected (${(\n stats.size /\n (1024 * 1024)\n ).toFixed(2)} MB)`\n );\n }\n\n this.logger?.info('Reading file content...');\n fileContent = await fs.readFile(params.filePath);\n this.logger?.info(`Read ${fileContent.length} bytes from file`);\n\n if (!fileContent || fileContent.length === 0) {\n throw new Error(\n `File \"${params.filePath}\" has no content after reading. Cannot inscribe empty files.`\n );\n }\n\n if (fileContent.length < 10) {\n throw new Error(\n `File \"${params.filePath}\" content is too small (${fileContent.length} bytes). Files must contain at least 10 bytes of meaningful content.`\n );\n }\n\n const fileName = path.basename(params.filePath);\n const mimeType = this.getMimeType(fileName);\n if (mimeType.startsWith('text/') || mimeType === 'application/json') {\n const textContent = fileContent.toString(\n 'utf8',\n 0,\n Math.min(fileContent.length, 1000)\n );\n if (textContent.trim() === '') {\n throw new Error(\n `File \"${params.filePath}\" contains only whitespace or empty content. Cannot inscribe meaningless data.`\n );\n }\n }\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('ENOENT')) {\n throw new Error(`File not found: \"${params.filePath}\"`);\n }\n throw error;\n }\n throw new Error(`Failed to read file: ${error}`);\n }\n\n const base64Data = fileContent.toString('base64');\n this.logger?.info(`Converted to base64: ${base64Data.length} characters`);\n\n const fileName = path.basename(params.filePath);\n const mimeType = this.getMimeType(fileName);\n this.logger?.info(`File: ${fileName}, MIME type: ${mimeType}`);\n\n const options: InscriptionOptions = {\n mode: params.mode,\n metadata: params.metadata,\n tags: params.tags,\n chunkSize: params.chunkSize,\n waitForConfirmation: params.quoteOnly\n ? false\n : params.waitForConfirmation ?? true,\n waitMaxAttempts: 10,\n waitIntervalMs: 3000,\n apiKey: params.apiKey,\n network: this.inscriberBuilder['hederaKit'].client.network\n .toString()\n .includes('mainnet')\n ? 'mainnet'\n : 'testnet',\n quoteOnly: params.quoteOnly,\n };\n\n if (params.quoteOnly) {\n try {\n const quote = await this.generateInscriptionQuote(\n {\n type: 'buffer',\n buffer: Buffer.from(base64Data, 'base64'),\n fileName,\n mimeType,\n },\n options\n );\n\n return {\n success: true,\n quote: {\n totalCostHbar: quote.totalCostHbar,\n validUntil: quote.validUntil,\n breakdown: quote.breakdown,\n },\n contentInfo: {\n fileName,\n mimeType,\n sizeBytes: fileContent.length,\n filePath: params.filePath,\n },\n message: `Estimated Quote for file: ${fileName} (${(\n fileContent.length / 1024\n ).toFixed(2)} KB)\\nTotal cost: ${\n quote.totalCostHbar\n } HBAR`,\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : 'Failed to generate inscription quote';\n throw new Error(`Quote generation failed: ${errorMessage}`);\n }\n }\n\n try {\n let result: unknown;\n\n if (params.timeoutMs) {\n const timeoutPromise = new Promise((_, reject) => {\n setTimeout(\n () =>\n reject(\n new Error(`Inscription timed out after ${params.timeoutMs}ms`)\n ),\n params.timeoutMs\n );\n });\n\n result = await Promise.race([\n this.inscriberBuilder.inscribe(\n {\n type: 'buffer',\n buffer: Buffer.from(base64Data, 'base64'),\n fileName,\n mimeType,\n },\n options\n ),\n timeoutPromise,\n ]);\n } else {\n result = await this.inscriberBuilder.inscribe(\n {\n type: 'buffer',\n buffer: Buffer.from(base64Data, 'base64'),\n fileName,\n mimeType,\n },\n options\n );\n }\n\n const inscriptionResult = result as any;\n if (inscriptionResult.confirmed && !inscriptionResult.quote) {\n const topicId =\n inscriptionResult.inscription?.topic_id ||\n inscriptionResult.result.topicId;\n const network = options.network || 'testnet';\n const cdnUrl = topicId\n ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}`\n : null;\n return `Successfully inscribed and confirmed content on the Hedera network!\\n\\nTransaction ID: ${\n inscriptionResult.result.transactionId\n }\\nTopic ID: ${topicId || 'N/A'}${\n cdnUrl ? `\\nView inscription: ${cdnUrl}` : ''\n }\\n\\nThe inscription is now available.`;\n } else if (!inscriptionResult.quote && !inscriptionResult.confirmed) {\n return `Successfully submitted inscription to the Hedera network!\\n\\nTransaction ID: ${inscriptionResult.result.transactionId}\\n\\nThe inscription is processing and will be confirmed shortly.`;\n } else {\n return 'Inscription operation completed.';\n }\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'Failed to inscribe from file';\n throw new Error(`Inscription failed: ${errorMessage}`);\n }\n }\n\n private getMimeType(fileName: string): string {\n const ext = path.extname(fileName).toLowerCase();\n const mimeTypes: Record<string, string> = {\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.gif': 'image/gif',\n '.webp': 'image/webp',\n '.svg': 'image/svg+xml',\n '.pdf': 'application/pdf',\n '.json': 'application/json',\n '.txt': 'text/plain',\n '.html': 'text/html',\n '.css': 'text/css',\n '.js': 'application/javascript',\n '.ts': 'application/typescript',\n '.mp4': 'video/mp4',\n '.mp3': 'audio/mpeg',\n '.wav': 'audio/wav',\n '.zip': 'application/zip',\n };\n return mimeTypes[ext] || 'application/octet-stream';\n }\n}\n"],"names":["fileName","mimeType"],"mappings":";;;;AAUA,MAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,UAAU,EACP,OAAA,EACA,IAAI,GAAG,2BAA2B,EAClC;AAAA,IACC;AAAA,EAAA;AAAA,EAEJ,MAAM,EACH,KAAK,CAAC,QAAQ,UAAU,CAAC,EACzB,SAAA,EACA,SAAS,wCAAwC;AAAA,EACpD,UAAU,EACP,OAAO,EAAE,QAAA,CAAS,EAClB,SAAA,EACA,SAAS,uCAAuC;AAAA,EACnD,MAAM,EACH,MAAM,EAAE,OAAA,CAAQ,EAChB,SAAA,EACA,SAAS,oCAAoC;AAAA,EAChD,WAAW,EACR,OAAA,EACA,IAAA,EACA,SAAA,EACA,SAAA,EACA,SAAS,4BAA4B;AAAA,EACxC,qBAAqB,EAClB,QAAA,EACA,SAAA,EACA,SAAS,8CAA8C;AAAA,EAC1D,WAAW,EACR,OAAA,EACA,IAAA,EACA,SAAA,EACA,SAAA,EACA,SAAS,+DAA+D;AAAA,EAC3E,QAAQ,EAAE,OAAA,EAAS,SAAA,EAAW,SAAS,iCAAiC;AAAA,EACxE,WAAW,EACR,QAAA,EACA,WACA,QAAQ,KAAK,EACb;AAAA,IACC;AAAA,EAAA;AAEN,CAAC;AAKM,MAAM,6BAA6B,uBAExC;AAAA,EAFK,cAAA;AAAA,UAAA,GAAA,SAAA;AAGL,SAAA,OAAO;AACP,SAAA,cACE;AAAA,EAAA;AAAA,EAEF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AAY,OAAO,KACxE;AACJ,eAAO;AAAA;AAAA,kBACL,kBAAkB,OAAO,aAC3B;AAAA,YAAe,WAAW,KAAK,GAC7B,SAAS;AAAA,oBAAuB,MAAM,KAAK,EAC7C;AAAA;AAAA;AAAA,MACF,WAAW,CAAC,kBAAkB,SAAS,CAAC,kBAAkB,WAAW;AACnE,eAAO;AAAA;AAAA,kBAAgF,kBAAkB,OAAO,aAAa;AAAA;AAAA;AAAA,MAC/H,OAAO;AACL,eAAO;AAAA,MACT;AAAA,IACF,SAAS,OAAO;AACd,YAAM,eACJ,iBAAiB,QAAQ,MAAM,UAAU;AAC3C,YAAM,IAAI,MAAM,uBAAuB,YAAY,EAAE;AAAA,IACvD;AAAA,EACF;AAAA,EAEQ,YAAY,UAA0B;AAC5C,UAAM,MAAM,KAAK,QAAQ,QAAQ,EAAE,YAAA;AACnC,UAAM,YAAoC;AAAA,MACxC,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,QAAQ;AAAA,IAAA;AAEV,WAAO,UAAU,GAAG,KAAK;AAAA,EAC3B;AACF;"}
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es35.js","sources":["../../src/tools/inscriber/base-inscriber-tools.ts"],"sourcesContent":["import {\n BaseHederaTransactionTool,\n BaseHederaQueryTool,\n BaseServiceBuilder,\n} from 'hedera-agent-kit';\nimport { InscriberBuilder } from '../../builders/inscriber/inscriber-builder';\nimport {\n InscriberTransactionToolParams,\n InscriberQueryToolParams,\n} from './inscriber-tool-params';\nimport type { ContentResolverInterface } from '../../types/content-resolver';\nimport {\n InscriptionInput,\n InscriptionOptions,\n QuoteResult,\n} from '@hashgraphonline/standards-sdk';\nimport { z } from 'zod';\n\n/**\n * Event emitted when an entity is created during inscription\n */\nexport interface EntityCreationEvent {\n entityId: string;\n entityName: string;\n entityType: string;\n transactionId?: string;\n}\n\n/**\n * Base class for Inscriber transaction tools\n */\nexport abstract class BaseInscriberTransactionTool<\n T extends z.ZodObject<\n z.ZodRawShape,\n z.UnknownKeysParam,\n z.ZodTypeAny\n > = z.ZodObject<z.ZodRawShape>\n> extends BaseHederaTransactionTool<T> {\n protected inscriberBuilder: InscriberBuilder;\n protected contentResolver: ContentResolverInterface | null;\n protected onEntityCreated?: (event: EntityCreationEvent) => void;\n namespace = 'inscriber' as const;\n\n constructor(params: InscriberTransactionToolParams) {\n super(params);\n this.inscriberBuilder = params.inscriberBuilder;\n this.contentResolver = params.contentResolver || null;\n }\n\n /**\n * Override to return the InscriberBuilder\n */\n protected getServiceBuilder(): BaseServiceBuilder {\n return this.inscriberBuilder;\n }\n\n /**\n * Get content resolver with fallback to registry\n */\n protected getContentResolver(): ContentResolverInterface | null {\n return this.contentResolver;\n }\n\n /**\n * Set entity creation handler for automatic entity storage\n */\n setEntityCreationHandler(handler: (event: EntityCreationEvent) => void): void {\n this.onEntityCreated = handler;\n }\n\n /**\n * Generate a quote for an inscription without executing it\n * @param input - The inscription input data\n * @param options - Inscription options\n * @returns Promise containing the quote result\n */\n protected async generateInscriptionQuote(\n input: InscriptionInput,\n options: InscriptionOptions\n ): Promise<QuoteResult> {\n const network = this.inscriberBuilder['hederaKit'].client.network;\n const networkType = network.toString().includes('mainnet')\n ? 'mainnet'\n : 'testnet';\n\n const quoteOptions = {\n ...options,\n quoteOnly: true,\n network: networkType as 'mainnet' | 'testnet',\n };\n\n const result = await this.inscriberBuilder.inscribe(input, quoteOptions);\n\n if (!result.quote || result.confirmed) {\n throw new Error('Failed to generate quote - unexpected response type');\n }\n\n return result.result as QuoteResult;\n }\n}\n\n/**\n * Base class for Inscriber query tools\n */\nexport abstract class BaseInscriberQueryTool<\n T extends z.ZodObject<\n z.ZodRawShape,\n z.UnknownKeysParam,\n z.ZodTypeAny\n > = z.ZodObject<z.ZodRawShape>\n> extends BaseHederaQueryTool<T> {\n protected inscriberBuilder: InscriberBuilder;\n protected contentResolver: ContentResolverInterface | null;\n protected onEntityCreated?: (event: EntityCreationEvent) => void;\n namespace = 'inscriber' as const;\n\n constructor(params: InscriberQueryToolParams) {\n super(params);\n this.inscriberBuilder = params.inscriberBuilder;\n this.contentResolver = params.contentResolver || null;\n }\n\n /**\n * Override to return the InscriberBuilder\n */\n protected getServiceBuilder(): BaseServiceBuilder {\n return this.inscriberBuilder;\n }\n\n /**\n * Get content resolver with fallback to registry\n */\n protected getContentResolver(): ContentResolverInterface | null {\n return this.contentResolver;\n }\n\n /**\n * Set entity creation handler for automatic entity storage\n */\n setEntityCreationHandler(handler: (event: EntityCreationEvent) => void): void {\n this.onEntityCreated = handler;\n }\n\n /**\n * Generate a quote for an inscription without executing it\n * @param input - The inscription input data\n * @param options - Inscription options\n * @returns Promise containing the quote result\n */\n protected async generateInscriptionQuote(\n input: InscriptionInput,\n options: InscriptionOptions\n ): Promise<QuoteResult> {\n const network = this.inscriberBuilder['hederaKit'].client.network;\n const networkType = network.toString().includes('mainnet')\n ? 'mainnet'\n : 'testnet';\n\n const quoteOptions = {\n ...options,\n quoteOnly: true,\n network: networkType as 'mainnet' | 'testnet',\n };\n\n const result = await this.inscriberBuilder.inscribe(input, quoteOptions);\n\n if (!result.quote || result.confirmed) {\n throw new Error('Failed to generate quote - unexpected response type');\n }\n\n return result.result as QuoteResult;\n }\n}"],"names":[],"mappings":";AA+BO,MAAe,qCAMZ,0BAA6B;AAAA,EAMrC,YAAY,QAAwC;AAClD,UAAM,MAAM;AAHd,SAAA,YAAY;AAIV,SAAK,mBAAmB,OAAO;AAC/B,SAAK,kBAAkB,OAAO,mBAAmB;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA,EAKU,oBAAwC;AAChD,WAAO,K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