@hashgraphonline/standards-agent-kit 0.2.121 → 0.2.123
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/cjs/tools/hcs6/CreateDynamicRegistryTool.d.ts +0 -6
- package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +6 -0
- package/dist/cjs/tools/inscriber/InscribeFromFileTool.d.ts +3 -0
- package/dist/cjs/tools/inscriber/InscribeFromUrlTool.d.ts +6 -0
- package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +6 -0
- package/dist/cjs/tools/inscriber/base-inscriber-tools.d.ts +15 -0
- package/dist/es/standards-agent-kit.es29.js +0 -2
- package/dist/es/standards-agent-kit.es29.js.map +1 -1
- package/dist/es/standards-agent-kit.es33.js +44 -0
- package/dist/es/standards-agent-kit.es33.js.map +1 -1
- package/dist/es/standards-agent-kit.es34.js +35 -6
- package/dist/es/standards-agent-kit.es34.js.map +1 -1
- package/dist/es/standards-agent-kit.es35.js +47 -9
- package/dist/es/standards-agent-kit.es35.js.map +1 -1
- package/dist/es/standards-agent-kit.es36.js +43 -6
- package/dist/es/standards-agent-kit.es36.js.map +1 -1
- package/dist/es/standards-agent-kit.es37.js +39 -6
- package/dist/es/standards-agent-kit.es37.js.map +1 -1
- package/dist/es/standards-agent-kit.es5.js +28 -4
- package/dist/es/standards-agent-kit.es5.js.map +1 -1
- package/dist/es/tools/hcs6/CreateDynamicRegistryTool.d.ts +0 -6
- package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +6 -0
- package/dist/es/tools/inscriber/InscribeFromFileTool.d.ts +3 -0
- package/dist/es/tools/inscriber/InscribeFromUrlTool.d.ts +6 -0
- package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +6 -0
- package/dist/es/tools/inscriber/base-inscriber-tools.d.ts +15 -0
- package/dist/umd/standards-agent-kit.umd.js +1 -1
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/dist/umd/tools/hcs6/CreateDynamicRegistryTool.d.ts +0 -6
- package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +6 -0
- package/dist/umd/tools/inscriber/InscribeFromFileTool.d.ts +3 -0
- package/dist/umd/tools/inscriber/InscribeFromUrlTool.d.ts +6 -0
- package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +6 -0
- package/dist/umd/tools/inscriber/base-inscriber-tools.d.ts +15 -0
- package/package.json +31 -27
- package/src/builders/hcs6/hcs6-builder.ts +33 -4
- package/src/tools/hcs6/CreateDynamicRegistryTool.ts +4 -6
- package/src/tools/inscriber/InscribeFromBufferTool.ts +49 -9
- package/src/tools/inscriber/InscribeFromFileTool.ts +50 -8
- package/src/tools/inscriber/InscribeFromUrlTool.ts +40 -11
- package/src/tools/inscriber/InscribeHashinalTool.ts +43 -6
- package/src/tools/inscriber/base-inscriber-tools.ts +87 -0
|
@@ -7,15 +7,12 @@ import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
|
7
7
|
*/
|
|
8
8
|
declare const CreateDynamicRegistrySchema: z.ZodObject<{
|
|
9
9
|
ttl: z.ZodDefault<z.ZodNumber>;
|
|
10
|
-
adminKey: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
11
10
|
submitKey: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
12
11
|
}, "strip", z.ZodTypeAny, {
|
|
13
12
|
ttl: number;
|
|
14
|
-
adminKey?: string | boolean | undefined;
|
|
15
13
|
submitKey?: string | boolean | undefined;
|
|
16
14
|
}, {
|
|
17
15
|
ttl?: number | undefined;
|
|
18
|
-
adminKey?: string | boolean | undefined;
|
|
19
16
|
submitKey?: string | boolean | undefined;
|
|
20
17
|
}>;
|
|
21
18
|
export type CreateDynamicRegistryInput = z.infer<typeof CreateDynamicRegistrySchema>;
|
|
@@ -27,15 +24,12 @@ export declare class CreateDynamicRegistryTool extends BaseHCS6QueryTool<typeof
|
|
|
27
24
|
description: string;
|
|
28
25
|
get specificInputSchema(): z.ZodObject<{
|
|
29
26
|
ttl: z.ZodDefault<z.ZodNumber>;
|
|
30
|
-
adminKey: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
31
27
|
submitKey: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodString]>>;
|
|
32
28
|
}, "strip", z.ZodTypeAny, {
|
|
33
29
|
ttl: number;
|
|
34
|
-
adminKey?: string | boolean | undefined;
|
|
35
30
|
submitKey?: string | boolean | undefined;
|
|
36
31
|
}, {
|
|
37
32
|
ttl?: number | undefined;
|
|
38
|
-
adminKey?: string | boolean | undefined;
|
|
39
33
|
submitKey?: string | boolean | undefined;
|
|
40
34
|
}>;
|
|
41
35
|
constructor(params: HCS6QueryToolParams);
|
|
@@ -12,7 +12,9 @@ declare const inscribeFromBufferSchema: z.ZodObject<{
|
|
|
12
12
|
waitForConfirmation: z.ZodOptional<z.ZodBoolean>;
|
|
13
13
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
14
14
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
15
|
+
quoteOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
15
16
|
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
quoteOnly: boolean;
|
|
16
18
|
fileName: string;
|
|
17
19
|
base64Data: string;
|
|
18
20
|
tags?: string[] | undefined;
|
|
@@ -34,6 +36,7 @@ declare const inscribeFromBufferSchema: z.ZodObject<{
|
|
|
34
36
|
waitForConfirmation?: boolean | undefined;
|
|
35
37
|
timeoutMs?: number | undefined;
|
|
36
38
|
apiKey?: string | undefined;
|
|
39
|
+
quoteOnly?: boolean | undefined;
|
|
37
40
|
}>;
|
|
38
41
|
export declare class InscribeFromBufferTool extends BaseInscriberQueryTool<typeof inscribeFromBufferSchema> {
|
|
39
42
|
name: string;
|
|
@@ -50,7 +53,9 @@ export declare class InscribeFromBufferTool extends BaseInscriberQueryTool<typeo
|
|
|
50
53
|
waitForConfirmation: z.ZodOptional<z.ZodBoolean>;
|
|
51
54
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
52
55
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
56
|
+
quoteOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
53
57
|
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
quoteOnly: boolean;
|
|
54
59
|
fileName: string;
|
|
55
60
|
base64Data: string;
|
|
56
61
|
tags?: string[] | undefined;
|
|
@@ -72,6 +77,7 @@ export declare class InscribeFromBufferTool extends BaseInscriberQueryTool<typeo
|
|
|
72
77
|
waitForConfirmation?: boolean | undefined;
|
|
73
78
|
timeoutMs?: number | undefined;
|
|
74
79
|
apiKey?: string | undefined;
|
|
80
|
+
quoteOnly?: boolean | undefined;
|
|
75
81
|
}>;
|
|
76
82
|
protected executeQuery(params: z.infer<typeof inscribeFromBufferSchema>, _runManager?: CallbackManagerForToolRun): Promise<unknown>;
|
|
77
83
|
private validateInput;
|
|
@@ -13,7 +13,9 @@ declare const inscribeFromFileSchema: z.ZodObject<{
|
|
|
13
13
|
waitForConfirmation: z.ZodOptional<z.ZodBoolean>;
|
|
14
14
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
15
15
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
16
|
+
quoteOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
16
17
|
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
quoteOnly: boolean;
|
|
17
19
|
filePath: string;
|
|
18
20
|
tags?: string[] | undefined;
|
|
19
21
|
metadata?: Record<string, unknown> | undefined;
|
|
@@ -31,6 +33,7 @@ declare const inscribeFromFileSchema: z.ZodObject<{
|
|
|
31
33
|
waitForConfirmation?: boolean | undefined;
|
|
32
34
|
timeoutMs?: number | undefined;
|
|
33
35
|
apiKey?: string | undefined;
|
|
36
|
+
quoteOnly?: boolean | undefined;
|
|
34
37
|
}>;
|
|
35
38
|
/**
|
|
36
39
|
* Tool for inscribing content from file
|
|
@@ -13,8 +13,10 @@ declare const inscribeFromUrlSchema: z.ZodObject<{
|
|
|
13
13
|
waitForConfirmation: z.ZodOptional<z.ZodBoolean>;
|
|
14
14
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
15
15
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
16
|
+
quoteOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
16
17
|
}, "strip", z.ZodTypeAny, {
|
|
17
18
|
url: string;
|
|
19
|
+
quoteOnly: boolean;
|
|
18
20
|
tags?: string[] | undefined;
|
|
19
21
|
metadata?: Record<string, unknown> | undefined;
|
|
20
22
|
mode?: "file" | "hashinal" | undefined;
|
|
@@ -31,6 +33,7 @@ declare const inscribeFromUrlSchema: z.ZodObject<{
|
|
|
31
33
|
waitForConfirmation?: boolean | undefined;
|
|
32
34
|
timeoutMs?: number | undefined;
|
|
33
35
|
apiKey?: string | undefined;
|
|
36
|
+
quoteOnly?: boolean | undefined;
|
|
34
37
|
}>;
|
|
35
38
|
/**
|
|
36
39
|
* Tool for inscribing content from URL
|
|
@@ -47,8 +50,10 @@ export declare class InscribeFromUrlTool extends BaseInscriberQueryTool<typeof i
|
|
|
47
50
|
waitForConfirmation: z.ZodOptional<z.ZodBoolean>;
|
|
48
51
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
49
52
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
53
|
+
quoteOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
50
54
|
}, "strip", z.ZodTypeAny, {
|
|
51
55
|
url: string;
|
|
56
|
+
quoteOnly: boolean;
|
|
52
57
|
tags?: string[] | undefined;
|
|
53
58
|
metadata?: Record<string, unknown> | undefined;
|
|
54
59
|
mode?: "file" | "hashinal" | undefined;
|
|
@@ -65,6 +70,7 @@ export declare class InscribeFromUrlTool extends BaseInscriberQueryTool<typeof i
|
|
|
65
70
|
waitForConfirmation?: boolean | undefined;
|
|
66
71
|
timeoutMs?: number | undefined;
|
|
67
72
|
apiKey?: string | undefined;
|
|
73
|
+
quoteOnly?: boolean | undefined;
|
|
68
74
|
}>;
|
|
69
75
|
protected executeQuery(params: z.infer<typeof inscribeFromUrlSchema>, _runManager?: CallbackManagerForToolRun): Promise<unknown>;
|
|
70
76
|
}
|
|
@@ -27,12 +27,14 @@ declare const inscribeHashinalSchema: z.ZodObject<{
|
|
|
27
27
|
waitForConfirmation: z.ZodOptional<z.ZodBoolean>;
|
|
28
28
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
29
29
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
30
|
+
quoteOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
30
31
|
}, "strip", z.ZodTypeAny, {
|
|
31
32
|
url: string;
|
|
32
33
|
type: string;
|
|
33
34
|
name: string;
|
|
34
35
|
description: string;
|
|
35
36
|
creator: string;
|
|
37
|
+
quoteOnly: boolean;
|
|
36
38
|
tags?: string[] | undefined;
|
|
37
39
|
properties?: Record<string, unknown> | undefined;
|
|
38
40
|
chunkSize?: number | undefined;
|
|
@@ -56,6 +58,7 @@ declare const inscribeHashinalSchema: z.ZodObject<{
|
|
|
56
58
|
waitForConfirmation?: boolean | undefined;
|
|
57
59
|
timeoutMs?: number | undefined;
|
|
58
60
|
apiKey?: string | undefined;
|
|
61
|
+
quoteOnly?: boolean | undefined;
|
|
59
62
|
attributes?: {
|
|
60
63
|
value: string | number;
|
|
61
64
|
trait_type: string;
|
|
@@ -91,12 +94,14 @@ export declare class InscribeHashinalTool extends BaseInscriberQueryTool<typeof
|
|
|
91
94
|
waitForConfirmation: z.ZodOptional<z.ZodBoolean>;
|
|
92
95
|
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
93
96
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
97
|
+
quoteOnly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
94
98
|
}, "strip", z.ZodTypeAny, {
|
|
95
99
|
url: string;
|
|
96
100
|
type: string;
|
|
97
101
|
name: string;
|
|
98
102
|
description: string;
|
|
99
103
|
creator: string;
|
|
104
|
+
quoteOnly: boolean;
|
|
100
105
|
tags?: string[] | undefined;
|
|
101
106
|
properties?: Record<string, unknown> | undefined;
|
|
102
107
|
chunkSize?: number | undefined;
|
|
@@ -120,6 +125,7 @@ export declare class InscribeHashinalTool extends BaseInscriberQueryTool<typeof
|
|
|
120
125
|
waitForConfirmation?: boolean | undefined;
|
|
121
126
|
timeoutMs?: number | undefined;
|
|
122
127
|
apiKey?: string | undefined;
|
|
128
|
+
quoteOnly?: boolean | undefined;
|
|
123
129
|
attributes?: {
|
|
124
130
|
value: string | number;
|
|
125
131
|
trait_type: string;
|
|
@@ -2,6 +2,7 @@ import { BaseHederaTransactionTool, BaseHederaQueryTool, BaseServiceBuilder } fr
|
|
|
2
2
|
import { InscriberBuilder } from '../../builders/inscriber/inscriber-builder';
|
|
3
3
|
import { InscriberTransactionToolParams, InscriberQueryToolParams } from './inscriber-tool-params';
|
|
4
4
|
import { ContentResolverInterface } from '../../types/content-resolver';
|
|
5
|
+
import { InscriptionInput, InscriptionOptions, QuoteResult } from '@hashgraphonline/standards-sdk';
|
|
5
6
|
import { z } from 'zod';
|
|
6
7
|
/**
|
|
7
8
|
* Base class for Inscriber transaction tools
|
|
@@ -19,6 +20,13 @@ export declare abstract class BaseInscriberTransactionTool<T extends z.ZodObject
|
|
|
19
20
|
* Get content resolver with fallback to registry
|
|
20
21
|
*/
|
|
21
22
|
protected getContentResolver(): ContentResolverInterface | null;
|
|
23
|
+
/**
|
|
24
|
+
* Generate a quote for an inscription without executing it
|
|
25
|
+
* @param input - The inscription input data
|
|
26
|
+
* @param options - Inscription options
|
|
27
|
+
* @returns Promise containing the quote result
|
|
28
|
+
*/
|
|
29
|
+
protected generateInscriptionQuote(input: InscriptionInput, options: InscriptionOptions): Promise<QuoteResult>;
|
|
22
30
|
}
|
|
23
31
|
/**
|
|
24
32
|
* Base class for Inscriber query tools
|
|
@@ -36,4 +44,11 @@ export declare abstract class BaseInscriberQueryTool<T extends z.ZodObject<z.Zod
|
|
|
36
44
|
* Get content resolver with fallback to registry
|
|
37
45
|
*/
|
|
38
46
|
protected getContentResolver(): ContentResolverInterface | null;
|
|
47
|
+
/**
|
|
48
|
+
* Generate a quote for an inscription without executing it
|
|
49
|
+
* @param input - The inscription input data
|
|
50
|
+
* @param options - Inscription options
|
|
51
|
+
* @returns Promise containing the quote result
|
|
52
|
+
*/
|
|
53
|
+
protected generateInscriptionQuote(input: InscriptionInput, options: InscriptionOptions): Promise<QuoteResult>;
|
|
39
54
|
}
|
|
@@ -2,7 +2,6 @@ import { z } from "zod";
|
|
|
2
2
|
import { BaseHCS6QueryTool } from "./standards-agent-kit.es28.js";
|
|
3
3
|
const CreateDynamicRegistrySchema = z.object({
|
|
4
4
|
ttl: z.number().min(3600).default(86400).describe("Time-to-live in seconds (minimum 3600 seconds/1 hour)"),
|
|
5
|
-
adminKey: z.union([z.boolean(), z.string()]).optional().describe("Admin key for the registry topic. Can be boolean (use operator key) or a public key string"),
|
|
6
5
|
submitKey: z.union([z.boolean(), z.string()]).optional().describe("Submit key for the registry topic. Can be boolean (use operator key) or a public key string")
|
|
7
6
|
});
|
|
8
7
|
class CreateDynamicRegistryTool extends BaseHCS6QueryTool {
|
|
@@ -17,7 +16,6 @@ class CreateDynamicRegistryTool extends BaseHCS6QueryTool {
|
|
|
17
16
|
async executeQuery(params, _runManager) {
|
|
18
17
|
const result = await this.hcs6Builder.createRegistry({
|
|
19
18
|
ttl: params.ttl,
|
|
20
|
-
adminKey: params.adminKey,
|
|
21
19
|
submitKey: params.submitKey
|
|
22
20
|
});
|
|
23
21
|
if (!result.success) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es29.js","sources":["../../src/tools/hcs6/CreateDynamicRegistryTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseHCS6QueryTool } from './base-hcs6-tools';\nimport { HCS6QueryToolParams } from './hcs6-tool-params';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\n\n/**\n * Schema for creating a dynamic hashinal registry\n */\nconst CreateDynamicRegistrySchema = z.object({\n ttl: z.number()\n .min(3600)\n .default(86400)\n .describe('Time-to-live in seconds (minimum 3600 seconds/1 hour)'),\n
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es29.js","sources":["../../src/tools/hcs6/CreateDynamicRegistryTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseHCS6QueryTool } from './base-hcs6-tools';\nimport { HCS6QueryToolParams } from './hcs6-tool-params';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\n\n/**\n * Schema for creating a dynamic hashinal registry\n */\nconst CreateDynamicRegistrySchema = z.object({\n ttl: z\n .number()\n .min(3600)\n .default(86400)\n .describe('Time-to-live in seconds (minimum 3600 seconds/1 hour)'),\n submitKey: z\n .union([z.boolean(), z.string()])\n .optional()\n .describe('Submit key for the registry topic. Can be boolean (use operator key) or a public key string'),\n});\n\nexport type CreateDynamicRegistryInput = z.infer<typeof CreateDynamicRegistrySchema>;\n\n/**\n * Tool for creating HCS-6 dynamic registries\n */\nexport class CreateDynamicRegistryTool extends BaseHCS6QueryTool<typeof CreateDynamicRegistrySchema> {\n name = 'createDynamicRegistry';\n description = 'Create a new HCS-6 dynamic registry for managing evolving content';\n \n get specificInputSchema() {\n return CreateDynamicRegistrySchema;\n }\n\n constructor(params: HCS6QueryToolParams) {\n super(params);\n }\n\n protected async executeQuery(\n params: CreateDynamicRegistryInput,\n _runManager?: CallbackManagerForToolRun\n ): Promise<unknown> {\n const result = await this.hcs6Builder.createRegistry({\n ttl: params.ttl,\n submitKey: params.submitKey,\n });\n\n if (!result.success) {\n throw new Error(result.error || 'Failed to create dynamic registry');\n }\n\n return `Successfully created HCS-6 dynamic registry!\\n\\nTopic ID: ${result.topicId}\\nTTL: ${params.ttl} seconds\\n\\nYou can now register dynamic hashinals to this registry using the topic ID.`;\n }\n}"],"names":[],"mappings":";;AAQA,MAAM,8BAA8B,EAAE,OAAO;AAAA,EAC3C,KAAK,EACF,OAAA,EACA,IAAI,IAAI,EACR,QAAQ,KAAK,EACb,SAAS,uDAAuD;AAAA,EACnE,WAAW,EACR,MAAM,CAAC,EAAE,QAAA,GAAW,EAAE,OAAA,CAAQ,CAAC,EAC/B,SAAA,EACA,SAAS,6FAA6F;AAC3G,CAAC;AAOM,MAAM,kCAAkC,kBAAsD;AAAA,EAQnG,YAAY,QAA6B;AACvC,UAAM,MAAM;AARd,SAAA,OAAO;AACP,SAAA,cAAc;AAAA,EAQd;AAAA,EANA,IAAI,sBAAsB;AACxB,WAAO;AAAA,EACT;AAAA,EAMA,MAAgB,aACd,QACA,aACkB;AAClB,UAAM,SAAS,MAAM,KAAK,YAAY,eAAe;AAAA,MACnD,KAAK,OAAO;AAAA,MACZ,WAAW,OAAO;AAAA,IAAA,CACnB;AAED,QAAI,CAAC,OAAO,SAAS;AACnB,YAAM,IAAI,MAAM,OAAO,SAAS,mCAAmC;AAAA,IACrE;AAEA,WAAO;AAAA;AAAA,YAA6D,OAAO,OAAO;AAAA,OAAU,OAAO,GAAG;AAAA;AAAA;AAAA,EACxG;AACF;"}
|
|
@@ -18,6 +18,28 @@ class BaseInscriberTransactionTool extends BaseHederaTransactionTool {
|
|
|
18
18
|
getContentResolver() {
|
|
19
19
|
return this.contentResolver;
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Generate a quote for an inscription without executing it
|
|
23
|
+
* @param input - The inscription input data
|
|
24
|
+
* @param options - Inscription options
|
|
25
|
+
* @returns Promise containing the quote result
|
|
26
|
+
*/
|
|
27
|
+
async generateInscriptionQuote(input, options) {
|
|
28
|
+
this.inscriberBuilder["hederaKit"].signer.getAccountId().toString();
|
|
29
|
+
this.inscriberBuilder["hederaKit"].signer?.getOperatorPrivateKey() ? this.inscriberBuilder["hederaKit"].signer.getOperatorPrivateKey().toStringRaw() : "";
|
|
30
|
+
const network = this.inscriberBuilder["hederaKit"].client.network;
|
|
31
|
+
const networkType = network.toString().includes("mainnet") ? "mainnet" : "testnet";
|
|
32
|
+
const quoteOptions = {
|
|
33
|
+
...options,
|
|
34
|
+
quoteOnly: true,
|
|
35
|
+
network: networkType
|
|
36
|
+
};
|
|
37
|
+
const result = await this.inscriberBuilder.inscribe(input, quoteOptions);
|
|
38
|
+
if (!result.quote || result.confirmed) {
|
|
39
|
+
throw new Error("Failed to generate quote - unexpected response type");
|
|
40
|
+
}
|
|
41
|
+
return result.result;
|
|
42
|
+
}
|
|
21
43
|
}
|
|
22
44
|
class BaseInscriberQueryTool extends BaseHederaQueryTool {
|
|
23
45
|
constructor(params) {
|
|
@@ -38,6 +60,28 @@ class BaseInscriberQueryTool extends BaseHederaQueryTool {
|
|
|
38
60
|
getContentResolver() {
|
|
39
61
|
return this.contentResolver;
|
|
40
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Generate a quote for an inscription without executing it
|
|
65
|
+
* @param input - The inscription input data
|
|
66
|
+
* @param options - Inscription options
|
|
67
|
+
* @returns Promise containing the quote result
|
|
68
|
+
*/
|
|
69
|
+
async generateInscriptionQuote(input, options) {
|
|
70
|
+
this.inscriberBuilder["hederaKit"].signer.getAccountId().toString();
|
|
71
|
+
this.inscriberBuilder["hederaKit"].signer?.getOperatorPrivateKey() ? this.inscriberBuilder["hederaKit"].signer.getOperatorPrivateKey().toStringRaw() : "";
|
|
72
|
+
const network = this.inscriberBuilder["hederaKit"].client.network;
|
|
73
|
+
const networkType = network.toString().includes("mainnet") ? "mainnet" : "testnet";
|
|
74
|
+
const quoteOptions = {
|
|
75
|
+
...options,
|
|
76
|
+
quoteOnly: true,
|
|
77
|
+
network: networkType
|
|
78
|
+
};
|
|
79
|
+
const result = await this.inscriberBuilder.inscribe(input, quoteOptions);
|
|
80
|
+
if (!result.quote || result.confirmed) {
|
|
81
|
+
throw new Error("Failed to generate quote - unexpected response type");
|
|
82
|
+
}
|
|
83
|
+
return result.result;
|
|
84
|
+
}
|
|
41
85
|
}
|
|
42
86
|
export {
|
|
43
87
|
BaseInscriberQueryTool,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es33.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 { z } from 'zod';\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 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/**\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 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}"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"standards-agent-kit.es33.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 * 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 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 * 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 operatorId = this.inscriberBuilder['hederaKit'].signer.getAccountId().toString();\n const operatorPrivateKey = this.inscriberBuilder['hederaKit'].signer?.getOperatorPrivateKey()\n ? this.inscriberBuilder['hederaKit'].signer.getOperatorPrivateKey().toStringRaw()\n : '';\n\n const network = this.inscriberBuilder['hederaKit'].client.network;\n const networkType = network.toString().includes('mainnet')\n ? 'mainnet'\n : 'testnet';\n\n const clientConfig = {\n accountId: operatorId,\n privateKey: operatorPrivateKey,\n network: networkType as 'mainnet' | 'testnet',\n };\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 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 * 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 operatorId = this.inscriberBuilder['hederaKit'].signer.getAccountId().toString();\n const operatorPrivateKey = this.inscriberBuilder['hederaKit'].signer?.getOperatorPrivateKey()\n ? this.inscriberBuilder['hederaKit'].signer.getOperatorPrivateKey().toStringRaw()\n : '';\n\n const network = this.inscriberBuilder['hederaKit'].client.network;\n const networkType = network.toString().includes('mainnet')\n ? 'mainnet'\n : 'testnet';\n\n const clientConfig = {\n accountId: operatorId,\n privateKey: operatorPrivateKey,\n network: networkType as 'mainnet' | 'testnet',\n };\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":";AAqBO,MAAe,qCAMZ,0BAA6B;AAAA,EAKrC,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,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKU,qBAAsD;AAC9D,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAgB,yBACd,OACA,SACsB;AACH,SAAK,iBAAiB,WAAW,EAAE,OAAO,aAAA,EAAe,SAAA;AACjD,SAAK,iBAAiB,WAAW,EAAE,QAAQ,sBAAA,IAClE,KAAK,iBAAiB,WAAW,EAAE,OAAO,sBAAA,EAAwB,gBAClE;AAEJ,UAAM,UAAU,KAAK,iBAAiB,WAAW,EAAE,OAAO;AAC1D,UAAM,cAAc,QAAQ,SAAA,EAAW,SAAS,SAAS,IACrD,YACA;AAQJ,UAAM,eAAe;AAAA,MACnB,GAAG;AAAA,MACH,WAAW;A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
|
waitForConfirmation: z.boolean().optional().describe("Whether to wait for inscription confirmation"),
|
|
10
10
|
timeoutMs: z.number().int().positive().optional().describe("Timeout in milliseconds for inscription (default: no timeout - waits until completion)"),
|
|
11
|
-
apiKey: z.string().optional().describe("API key for inscription service")
|
|
11
|
+
apiKey: z.string().optional().describe("API key for inscription service"),
|
|
12
|
+
quoteOnly: z.boolean().optional().default(false).describe("If true, returns a cost quote instead of executing the inscription")
|
|
12
13
|
});
|
|
13
14
|
class InscribeFromUrlTool extends BaseInscriberQueryTool {
|
|
14
15
|
constructor() {
|
|
15
16
|
super(...arguments);
|
|
16
17
|
this.name = "inscribeFromUrl";
|
|
17
|
-
this.description = 'ONLY for direct FILE DOWNLOAD URLs ending with file extensions (.pdf, .jpg, .png, .json, .zip). NEVER use for web pages, articles, or ANY HTML content - it WILL FAIL. If you have already retrieved content from any source (including MCP tools), you MUST use inscribeFromBuffer instead. This tool downloads files from URLs - it does NOT inscribe content you already have. When asked to "inscribe it" after retrieving content, ALWAYS use inscribeFromBuffer with the actual content.';
|
|
18
|
+
this.description = 'ONLY for direct FILE DOWNLOAD URLs ending with file extensions (.pdf, .jpg, .png, .json, .zip). NEVER use for web pages, articles, or ANY HTML content - it WILL FAIL. If you have already retrieved content from any source (including MCP tools), you MUST use inscribeFromBuffer instead. This tool downloads files from URLs - it does NOT inscribe content you already have. When asked to "inscribe it" after retrieving content, ALWAYS use inscribeFromBuffer with the actual content. Set quoteOnly=true to get cost estimates without executing the inscription.';
|
|
18
19
|
}
|
|
19
20
|
get specificInputSchema() {
|
|
20
21
|
return inscribeFromUrlSchema;
|
|
@@ -117,12 +118,38 @@ class InscribeFromUrlTool extends BaseInscriberQueryTool {
|
|
|
117
118
|
metadata: params.metadata,
|
|
118
119
|
tags: params.tags,
|
|
119
120
|
chunkSize: params.chunkSize,
|
|
120
|
-
waitForConfirmation: params.waitForConfirmation ?? true,
|
|
121
|
+
waitForConfirmation: params.quoteOnly ? false : params.waitForConfirmation ?? true,
|
|
121
122
|
waitMaxAttempts: 10,
|
|
122
123
|
waitIntervalMs: 3e3,
|
|
123
124
|
apiKey: params.apiKey,
|
|
124
|
-
network: this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet"
|
|
125
|
+
network: this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet",
|
|
126
|
+
quoteOnly: params.quoteOnly
|
|
125
127
|
};
|
|
128
|
+
if (params.quoteOnly) {
|
|
129
|
+
try {
|
|
130
|
+
const quote = await this.generateInscriptionQuote(
|
|
131
|
+
{ type: "url", url: params.url },
|
|
132
|
+
options
|
|
133
|
+
);
|
|
134
|
+
return {
|
|
135
|
+
success: true,
|
|
136
|
+
quote: {
|
|
137
|
+
totalCostHbar: quote.totalCostHbar,
|
|
138
|
+
validUntil: quote.validUntil,
|
|
139
|
+
breakdown: quote.breakdown
|
|
140
|
+
},
|
|
141
|
+
contentInfo: {
|
|
142
|
+
url: params.url
|
|
143
|
+
},
|
|
144
|
+
message: `Quote generated for URL: ${params.url}
|
|
145
|
+
Total cost: ${quote.totalCostHbar} HBAR
|
|
146
|
+
Quote valid until: ${new Date(quote.validUntil).toLocaleString()}`
|
|
147
|
+
};
|
|
148
|
+
} catch (error) {
|
|
149
|
+
const errorMessage = error instanceof Error ? error.message : "Failed to generate inscription quote";
|
|
150
|
+
throw new Error(`Quote generation failed: ${errorMessage}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
126
153
|
try {
|
|
127
154
|
let result;
|
|
128
155
|
if (params.timeoutMs) {
|
|
@@ -145,7 +172,7 @@ class InscribeFromUrlTool extends BaseInscriberQueryTool {
|
|
|
145
172
|
options
|
|
146
173
|
);
|
|
147
174
|
}
|
|
148
|
-
if (result.confirmed) {
|
|
175
|
+
if (result.confirmed && !result.quote) {
|
|
149
176
|
const topicId = result.inscription?.topic_id || result.result.topicId;
|
|
150
177
|
const network = options.network || "testnet";
|
|
151
178
|
const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;
|
|
@@ -156,12 +183,14 @@ Topic ID: ${topicId || "N/A"}${cdnUrl ? `
|
|
|
156
183
|
View inscription: ${cdnUrl}` : ""}
|
|
157
184
|
|
|
158
185
|
The inscription is now available.`;
|
|
159
|
-
} else {
|
|
186
|
+
} else if (!result.quote && !result.confirmed) {
|
|
160
187
|
return `Successfully submitted inscription to the Hedera network!
|
|
161
188
|
|
|
162
189
|
Transaction ID: ${result.result.transactionId}
|
|
163
190
|
|
|
164
191
|
The inscription is processing and will be confirmed shortly.`;
|
|
192
|
+
} else {
|
|
193
|
+
return "Inscription operation completed.";
|
|
165
194
|
}
|
|
166
195
|
} catch (error) {
|
|
167
196
|
const errorMessage = error instanceof Error ? error.message : "Failed to inscribe from URL";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-agent-kit.es34.js","sources":["../../src/tools/inscriber/InscribeFromUrlTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport { InscriptionOptions } from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\n\n/**\n * Schema for inscribing from URL\n */\nconst inscribeFromUrlSchema = z.object({\n url: z.string().url().describe('ONLY direct file download URLs with file extensions (.pdf, .jpg, .png, .json, .zip). NEVER use for web pages, articles, or when you already have content to inscribe.'),\n mode: z\n .enum(['file', 'hashinal'])\n .optional()\n .describe('Inscription mode: file or hashinal NFT'),\n metadata: z\n .record(z.unknown())\n .optional()\n .describe('Metadata to attach to the inscription'),\n tags: z\n .array(z.string())\n .optional()\n .describe('Tags to categorize the inscription'),\n chunkSize: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Chunk size for large files'),\n waitForConfirmation: z\n .boolean()\n .optional()\n .describe('Whether to wait for inscription confirmation'),\n timeoutMs: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Timeout in milliseconds for inscription (default: no timeout - waits until completion)'),\n apiKey: z\n .string()\n .optional()\n .describe('API key for inscription service'),\n});\n\n\n/**\n * Tool for inscribing content from URL\n */\nexport class InscribeFromUrlTool extends BaseInscriberQueryTool<typeof inscribeFromUrlSchema> {\n name = 'inscribeFromUrl';\n description = 'ONLY for direct FILE DOWNLOAD URLs ending with file extensions (.pdf, .jpg, .png, .json, .zip). NEVER use for web pages, articles, or ANY HTML content - it WILL FAIL. If you have already retrieved content from any source (including MCP tools), you MUST use inscribeFromBuffer instead. This tool downloads files from URLs - it does NOT inscribe content you already have. When asked to \"inscribe it\" after retrieving content, ALWAYS use inscribeFromBuffer with the actual content.';\n\n get specificInputSchema() {\n return inscribeFromUrlSchema;\n }\n\n protected async executeQuery(\n params: z.infer<typeof inscribeFromUrlSchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<unknown> {\n console.log(`[DEBUG] InscribeFromUrlTool.executeQuery called with URL: ${params.url}`);\n \n if (!params.url || params.url.trim() === '') {\n throw new Error('URL cannot be empty. Please provide a valid URL.');\n }\n\n try {\n const urlObj = new URL(params.url);\n if (!urlObj.protocol || !urlObj.host) {\n throw new Error('Invalid URL format. Please provide a complete URL with protocol (http/https).');\n }\n if (!['http:', 'https:'].includes(urlObj.protocol)) {\n throw new Error('Only HTTP and HTTPS URLs are supported for inscription.');\n }\n \n } catch (error) {\n if (error instanceof Error && error.message.includes('Cannot inscribe content from')) {\n throw error;\n }\n throw new Error(`Invalid URL: ${params.url}. Please provide a valid URL.`);\n }\n\n console.log(`[InscribeFromUrlTool] Validating URL content before inscription...`);\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n \n try {\n // First try HEAD request\n const headResponse = await fetch(params.url, {\n method: 'HEAD',\n signal: controller.signal,\n });\n \n clearTimeout(timeoutId);\n \n if (!headResponse.ok) {\n throw new Error(`URL returned error status ${headResponse.status}: ${headResponse.statusText}. Cannot inscribe content from inaccessible URLs.`);\n }\n\n const contentType = headResponse.headers.get('content-type') || '';\n const contentLength = headResponse.headers.get('content-length');\n \n // Check if content type indicates HTML/web page\n const webPageContentTypes = [\n 'text/html',\n 'application/xhtml+xml',\n 'text/xml'\n ];\n \n if (webPageContentTypes.some(type => contentType.toLowerCase().includes(type))) {\n throw new Error(`URL returns HTML/web page content (Content-Type: ${contentType}). This tool only works with direct file URLs (PDFs, images, JSON, etc.). For web page content, first retrieve the content using the appropriate MCP tool or web scraper, then use inscribeFromBuffer to inscribe it.`);\n }\n \n if (contentLength && parseInt(contentLength) === 0) {\n throw new Error('URL returns empty content (Content-Length: 0). Cannot inscribe empty content.');\n }\n\n if (contentLength && parseInt(contentLength) < 10) {\n throw new Error(`URL content is too small (${contentLength} bytes). Content must be at least 10 bytes.`);\n }\n \n // If HEAD doesn't provide content-type, do a partial GET to check\n if (!contentType || contentType === 'application/octet-stream') {\n console.log(`[InscribeFromUrlTool] Content-Type unclear, fetching first 1KB to verify...`);\n \n const getController = new AbortController();\n const getTimeoutId = setTimeout(() => getController.abort(), 5000);\n \n try {\n const getResponse = await fetch(params.url, {\n signal: getController.signal,\n headers: {\n 'Range': 'bytes=0-1023' // Get first 1KB\n }\n });\n \n clearTimeout(getTimeoutId);\n \n if (getResponse.ok || getResponse.status === 206) { // 206 is partial content\n const buffer = await getResponse.arrayBuffer();\n const bytes = new Uint8Array(buffer);\n const text = new TextDecoder('utf-8', { fatal: false }).decode(bytes.slice(0, 512));\n \n // Check if it looks like HTML\n if (text.toLowerCase().includes('<!doctype html') || \n text.toLowerCase().includes('<html') ||\n text.match(/<meta\\s+[^>]*>/i) ||\n text.match(/<title>/i)) {\n throw new Error(`URL returns HTML content. This tool only works with direct file URLs. For web page content, first retrieve it using the appropriate tool, then use inscribeFromBuffer.`);\n }\n }\n } catch (getError) {\n clearTimeout(getTimeoutId);\n if (getError instanceof Error && getError.message.includes('HTML content')) {\n throw getError;\n }\n // If partial GET fails, continue anyway\n console.log(`[InscribeFromUrlTool] Could not perform partial GET validation: ${getError instanceof Error ? getError.message : 'Unknown error'}`);\n }\n }\n\n console.log(`[InscribeFromUrlTool] URL validation passed. Content-Type: ${contentType}, Content-Length: ${contentLength || 'unknown'}`);\n } catch (fetchError) {\n clearTimeout(timeoutId);\n throw fetchError;\n }\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n console.log(`[InscribeFromUrlTool] Warning: URL validation timed out after 10 seconds. Proceeding with inscription attempt.`);\n } else if (error.message.includes('URL returned error') || error.message.includes('empty content') || error.message.includes('too small') || error.message.includes('HTML')) {\n throw error;\n } else {\n console.log(`[InscribeFromUrlTool] Warning: Could not validate URL with HEAD request: ${error.message}. Proceeding with inscription attempt.`);\n }\n }\n }\n\n const options: InscriptionOptions = {\n mode: params.mode,\n metadata: params.metadata,\n tags: params.tags,\n chunkSize: params.chunkSize,\n waitForConfirmation: params.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 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 URL';\n throw new Error(`Inscription failed: ${errorMessage}`);\n }\n }\n}"],"names":[],"mappings":";;AAQA,MAAM,wBAAwB,EAAE,OAAO;AAAA,EACrC,KAAK,EAAE,OAAA,EAAS,IAAA,EAAM,SAAS,uKAAuK;AAAA,EACtM,MAAM,EACH,KAAK,CAAC,QAAQ,UAAU,CAAC,EACzB,SAAA,EACA,SAAS,wCAAwC;AAAA,EACpD,UAAU,EACP,OAAO,EAAE,QAAA,CAAS,EAClB,SAAA,EACA,SAAS,uCAAuC;AAAA,EACnD,MAAM,EACH,MAAM,EAAE,OAAA,CAAQ,EAChB,SAAA,EACA,SAAS,oCAAoC;AAAA,EAChD,WAAW,EACR,OAAA,EACA,IAAA,EACA,SAAA,EACA,SAAA,EACA,SAAS,4BAA4B;AAAA,EACxC,qBAAqB,EAClB,QAAA,EACA,SAAA,EACA,SAAS,8CAA8C;AAAA,EAC1D,WAAW,EACR,OAAA,EACA,IAAA,EACA,SAAA,EACA,SAAA,EACA,SAAS,wFAAwF;AAAA,EACpG,QAAQ,EACL,OAAA,EACA,SAAA,EACA,SAAS,iCAAiC;AAC/C,CAAC;AAMM,MAAM,4BAA4B,uBAAqD;AAAA,EAAvF,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAA,OAAO;AACP,SAAA,cAAc;AAAA,EAAA;AAAA,EAEd,IAAI,sBAAsB;AACxB,WAAO;AAAA,EACT;AAAA,EAEA,MAAgB,aACd,QACA,aACkB;AAClB,YAAQ,IAAI,6DAA6D,OAAO,GAAG,EAAE;AAErF,QAAI,CAAC,OAAO,OAAO,OAAO,IAAI,KAAA,MAAW,IAAI;AAC3C,YAAM,IAAI,MAAM,kDAAkD;AAAA,IACpE;AAEA,QAAI;AACF,YA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AS,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.es34.js","sources":["../../src/tools/inscriber/InscribeFromUrlTool.ts"],"sourcesContent":["import { z } from 'zod';\nimport { BaseInscriberQueryTool } from './base-inscriber-tools';\nimport { InscriptionOptions } from '@hashgraphonline/standards-sdk';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\n\n/**\n * Schema for inscribing from URL\n */\nconst inscribeFromUrlSchema = z.object({\n url: z.string().url().describe('ONLY direct file download URLs with file extensions (.pdf, .jpg, .png, .json, .zip). NEVER use for web pages, articles, or when you already have content to inscribe.'),\n mode: z\n .enum(['file', 'hashinal'])\n .optional()\n .describe('Inscription mode: file or hashinal NFT'),\n metadata: z\n .record(z.unknown())\n .optional()\n .describe('Metadata to attach to the inscription'),\n tags: z\n .array(z.string())\n .optional()\n .describe('Tags to categorize the inscription'),\n chunkSize: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Chunk size for large files'),\n waitForConfirmation: z\n .boolean()\n .optional()\n .describe('Whether to wait for inscription confirmation'),\n timeoutMs: z\n .number()\n .int()\n .positive()\n .optional()\n .describe('Timeout in milliseconds for inscription (default: no timeout - waits until completion)'),\n apiKey: z\n .string()\n .optional()\n .describe('API key for inscription service'),\n quoteOnly: z\n .boolean()\n .optional()\n .default(false)\n .describe('If true, returns a cost quote instead of executing the inscription'),\n});\n\n\n/**\n * Tool for inscribing content from URL\n */\nexport class InscribeFromUrlTool extends BaseInscriberQueryTool<typeof inscribeFromUrlSchema> {\n name = 'inscribeFromUrl';\n description = 'ONLY for direct FILE DOWNLOAD URLs ending with file extensions (.pdf, .jpg, .png, .json, .zip). NEVER use for web pages, articles, or ANY HTML content - it WILL FAIL. If you have already retrieved content from any source (including MCP tools), you MUST use inscribeFromBuffer instead. This tool downloads files from URLs - it does NOT inscribe content you already have. When asked to \"inscribe it\" after retrieving content, ALWAYS use inscribeFromBuffer with the actual content. Set quoteOnly=true to get cost estimates without executing the inscription.';\n\n get specificInputSchema() {\n return inscribeFromUrlSchema;\n }\n\n protected async executeQuery(\n params: z.infer<typeof inscribeFromUrlSchema>,\n _runManager?: CallbackManagerForToolRun\n ): Promise<unknown> {\n console.log(`[DEBUG] InscribeFromUrlTool.executeQuery called with URL: ${params.url}`);\n \n if (!params.url || params.url.trim() === '') {\n throw new Error('URL cannot be empty. Please provide a valid URL.');\n }\n\n try {\n const urlObj = new URL(params.url);\n if (!urlObj.protocol || !urlObj.host) {\n throw new Error('Invalid URL format. Please provide a complete URL with protocol (http/https).');\n }\n if (!['http:', 'https:'].includes(urlObj.protocol)) {\n throw new Error('Only HTTP and HTTPS URLs are supported for inscription.');\n }\n \n } catch (error) {\n if (error instanceof Error && error.message.includes('Cannot inscribe content from')) {\n throw error;\n }\n throw new Error(`Invalid URL: ${params.url}. Please provide a valid URL.`);\n }\n\n console.log(`[InscribeFromUrlTool] Validating URL content before inscription...`);\n try {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), 10000);\n \n try {\n const headResponse = await fetch(params.url, {\n method: 'HEAD',\n signal: controller.signal,\n });\n \n clearTimeout(timeoutId);\n \n if (!headResponse.ok) {\n throw new Error(`URL returned error status ${headResponse.status}: ${headResponse.statusText}. Cannot inscribe content from inaccessible URLs.`);\n }\n\n const contentType = headResponse.headers.get('content-type') || '';\n const contentLength = headResponse.headers.get('content-length');\n \n const webPageContentTypes = [\n 'text/html',\n 'application/xhtml+xml',\n 'text/xml'\n ];\n \n if (webPageContentTypes.some(type => contentType.toLowerCase().includes(type))) {\n throw new Error(`URL returns HTML/web page content (Content-Type: ${contentType}). This tool only works with direct file URLs (PDFs, images, JSON, etc.). For web page content, first retrieve the content using the appropriate MCP tool or web scraper, then use inscribeFromBuffer to inscribe it.`);\n }\n \n if (contentLength && parseInt(contentLength) === 0) {\n throw new Error('URL returns empty content (Content-Length: 0). Cannot inscribe empty content.');\n }\n\n if (contentLength && parseInt(contentLength) < 10) {\n throw new Error(`URL content is too small (${contentLength} bytes). Content must be at least 10 bytes.`);\n }\n \n if (!contentType || contentType === 'application/octet-stream') {\n console.log(`[InscribeFromUrlTool] Content-Type unclear, fetching first 1KB to verify...`);\n \n const getController = new AbortController();\n const getTimeoutId = setTimeout(() => getController.abort(), 5000);\n \n try {\n const getResponse = await fetch(params.url, {\n signal: getController.signal,\n headers: {\n 'Range': 'bytes=0-1023' // Get first 1KB\n }\n });\n \n clearTimeout(getTimeoutId);\n \n if (getResponse.ok || getResponse.status === 206) { // 206 is partial content\n const buffer = await getResponse.arrayBuffer();\n const bytes = new Uint8Array(buffer);\n const text = new TextDecoder('utf-8', { fatal: false }).decode(bytes.slice(0, 512));\n \n if (text.toLowerCase().includes('<!doctype html') || \n text.toLowerCase().includes('<html') ||\n text.match(/<meta\\s+[^>]*>/i) ||\n text.match(/<title>/i)) {\n throw new Error(`URL returns HTML content. This tool only works with direct file URLs. For web page content, first retrieve it using the appropriate tool, then use inscribeFromBuffer.`);\n }\n }\n } catch (getError) {\n clearTimeout(getTimeoutId);\n if (getError instanceof Error && getError.message.includes('HTML content')) {\n throw getError;\n }\n console.log(`[InscribeFromUrlTool] Could not perform partial GET validation: ${getError instanceof Error ? getError.message : 'Unknown error'}`);\n }\n }\n\n console.log(`[InscribeFromUrlTool] URL validation passed. Content-Type: ${contentType}, Content-Length: ${contentLength || 'unknown'}`);\n } catch (fetchError) {\n clearTimeout(timeoutId);\n throw fetchError;\n }\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n console.log(`[InscribeFromUrlTool] Warning: URL validation timed out after 10 seconds. Proceeding with inscription attempt.`);\n } else if (error.message.includes('URL returned error') || error.message.includes('empty content') || error.message.includes('too small') || error.message.includes('HTML')) {\n throw error;\n } else {\n console.log(`[InscribeFromUrlTool] Warning: Could not validate URL with HEAD request: ${error.message}. Proceeding with inscription attempt.`);\n }\n }\n }\n\n const options: InscriptionOptions = {\n mode: params.mode,\n metadata: params.metadata,\n tags: params.tags,\n chunkSize: params.chunkSize,\n waitForConfirmation: params.quoteOnly ? false : (params.waitForConfirmation ?? true),\n waitMaxAttempts: 10,\n waitIntervalMs: 3000,\n apiKey: params.apiKey,\n network: this.inscriberBuilder['hederaKit'].client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet',\n quoteOnly: params.quoteOnly,\n };\n\n if (params.quoteOnly) {\n try {\n const quote = await this.generateInscriptionQuote(\n { type: 'url', url: params.url },\n options\n );\n \n return {\n success: true,\n quote: {\n totalCostHbar: quote.totalCostHbar,\n validUntil: quote.validUntil,\n breakdown: quote.breakdown,\n },\n contentInfo: {\n url: params.url,\n },\n message: `Quote generated for URL: ${params.url}\\nTotal cost: ${quote.totalCostHbar} HBAR\\nQuote valid until: ${new Date(quote.validUntil).toLocaleString()}`,\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : 'Failed to generate inscription quote';\n throw new Error(`Quote generation failed: ${errorMessage}`);\n }\n }\n\n try {\n let result: Awaited<ReturnType<typeof this.inscriberBuilder.inscribe>>;\n \n if (params.timeoutMs) {\n const timeoutPromise = new Promise<never>((_, reject) => {\n setTimeout(\n () => reject(new Error(`Inscription timed out after ${params.timeoutMs}ms`)),\n params.timeoutMs\n );\n });\n\n result = await Promise.race([\n this.inscriberBuilder.inscribe(\n { type: 'url', url: params.url },\n options\n ),\n timeoutPromise\n ]);\n } else {\n result = await this.inscriberBuilder.inscribe(\n { type: 'url', url: params.url },\n options\n );\n }\n\n if (result.confirmed && !result.quote) {\n const topicId = result.inscription?.topic_id || (result.result as any).topicId;\n const network = options.network || 'testnet';\n const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;\n return `Successfully inscribed and confirmed content on the Hedera network!\\n\\nTransaction ID: ${(result.result as any).transactionId}\\nTopic ID: ${topicId || 'N/A'}${cdnUrl ? `\\nView inscription: ${cdnUrl}` : ''}\\n\\nThe inscription is now available.`;\n } else if (!result.quote && !result.confirmed) {\n return `Successfully submitted inscription to the Hedera network!\\n\\nTransaction ID: ${(result.result as any).transactionId}\\n\\nThe inscription is processing and will be confirmed shortly.`;\n } else {\n return 'Inscription operation completed.';\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : 'Failed to inscribe from URL';\n throw new Error(`Inscription failed: ${errorMessage}`);\n }\n }\n}"],"names":[],"mappings":";;AAQA,MAAM,wBAAwB,EAAE,OAAO;AAAA,EACrC,KAAK,EAAE,OAAA,EAAS,IAAA,EAAM,SAAS,uKAAuK;AAAA,EACtM,MAAM,EACH,KAAK,CAAC,QAAQ,UAAU,CAAC,EACzB,SAAA,EACA,SAAS,wCAAwC;AAAA,EACpD,UAAU,EACP,OAAO,EAAE,QAAA,CAAS,EAClB,SAAA,EACA,SAAS,uCAAuC;AAAA,EACnD,MAAM,EACH,MAAM,EAAE,OAAA,CAAQ,EAChB,SAAA,EACA,SAAS,oCAAoC;AAAA,EAChD,WAAW,EACR,OAAA,EACA,IAAA,EACA,SAAA,EACA,SAAA,EACA,SAAS,4BAA4B;AAAA,EACxC,qBAAqB,EAClB,QAAA,EACA,SAAA,EACA,SAAS,8CAA8C;AAAA,EAC1D,WAAW,EACR,OAAA,EACA,IAAA,EACA,SAAA,EACA,SAAA,EACA,SAAS,wFAAwF;AAAA,EACpG,QAAQ,EACL,OAAA,EACA,SAAA,EACA,SAAS,iCAAiC;AAAA,EAC7C,WAAW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uB,MAAM,KAAK,EAAE;AAAA;AAAA;AAAA,MACtN,WAAW,CAAC,OAAO,SAAS,CAAC,OAAO,WAAW;AAC7C,eAAO;AAAA;AAAA,kBAAiF,OAAO,OAAe,aAAa;AAAA;AAAA;AAAA,MAC7H,OAAO;AACL,eAAO;AAAA,MACT;AAAA,IACF,SAAS,OAAO;AACd,YAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU;AAC9D,YAAM,IAAI,MAAM,uBAAuB,YAAY,EAAE;AAAA,IACvD;AAAA,EACF;AACF;"}
|
|
@@ -10,13 +10,14 @@ const inscribeFromFileSchema = z.object({
|
|
|
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
12
|
timeoutMs: z.number().int().positive().optional().describe("Timeout in milliseconds for inscription (default: no timeout)"),
|
|
13
|
-
apiKey: z.string().optional().describe("API key for inscription service")
|
|
13
|
+
apiKey: z.string().optional().describe("API key for inscription service"),
|
|
14
|
+
quoteOnly: z.boolean().optional().default(false).describe("If true, returns a cost quote instead of executing the inscription")
|
|
14
15
|
});
|
|
15
16
|
class InscribeFromFileTool extends BaseInscriberQueryTool {
|
|
16
17
|
constructor() {
|
|
17
18
|
super(...arguments);
|
|
18
19
|
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
|
+
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.";
|
|
20
21
|
}
|
|
21
22
|
get specificInputSchema() {
|
|
22
23
|
return inscribeFromFileSchema;
|
|
@@ -87,12 +88,46 @@ class InscribeFromFileTool extends BaseInscriberQueryTool {
|
|
|
87
88
|
metadata: params.metadata,
|
|
88
89
|
tags: params.tags,
|
|
89
90
|
chunkSize: params.chunkSize,
|
|
90
|
-
waitForConfirmation: params.waitForConfirmation ?? true,
|
|
91
|
+
waitForConfirmation: params.quoteOnly ? false : params.waitForConfirmation ?? true,
|
|
91
92
|
waitMaxAttempts: 10,
|
|
92
93
|
waitIntervalMs: 3e3,
|
|
93
94
|
apiKey: params.apiKey,
|
|
94
|
-
network: this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet"
|
|
95
|
+
network: this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet",
|
|
96
|
+
quoteOnly: params.quoteOnly
|
|
95
97
|
};
|
|
98
|
+
if (params.quoteOnly) {
|
|
99
|
+
try {
|
|
100
|
+
const quote = await this.generateInscriptionQuote(
|
|
101
|
+
{
|
|
102
|
+
type: "buffer",
|
|
103
|
+
buffer: Buffer.from(base64Data, "base64"),
|
|
104
|
+
fileName,
|
|
105
|
+
mimeType
|
|
106
|
+
},
|
|
107
|
+
options
|
|
108
|
+
);
|
|
109
|
+
return {
|
|
110
|
+
success: true,
|
|
111
|
+
quote: {
|
|
112
|
+
totalCostHbar: quote.totalCostHbar,
|
|
113
|
+
validUntil: quote.validUntil,
|
|
114
|
+
breakdown: quote.breakdown
|
|
115
|
+
},
|
|
116
|
+
contentInfo: {
|
|
117
|
+
fileName,
|
|
118
|
+
mimeType,
|
|
119
|
+
sizeBytes: fileContent.length,
|
|
120
|
+
filePath: params.filePath
|
|
121
|
+
},
|
|
122
|
+
message: `Quote generated for file: ${fileName} (${(fileContent.length / 1024).toFixed(2)} KB)
|
|
123
|
+
Total cost: ${quote.totalCostHbar} HBAR
|
|
124
|
+
Quote valid until: ${new Date(quote.validUntil).toLocaleString()}`
|
|
125
|
+
};
|
|
126
|
+
} catch (error) {
|
|
127
|
+
const errorMessage = error instanceof Error ? error.message : "Failed to generate inscription quote";
|
|
128
|
+
throw new Error(`Quote generation failed: ${errorMessage}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
96
131
|
try {
|
|
97
132
|
let result;
|
|
98
133
|
if (params.timeoutMs) {
|
|
@@ -125,23 +160,26 @@ class InscribeFromFileTool extends BaseInscriberQueryTool {
|
|
|
125
160
|
options
|
|
126
161
|
);
|
|
127
162
|
}
|
|
128
|
-
|
|
129
|
-
|
|
163
|
+
const inscriptionResult = result;
|
|
164
|
+
if (inscriptionResult.confirmed && !inscriptionResult.quote) {
|
|
165
|
+
const topicId = inscriptionResult.inscription?.topic_id || inscriptionResult.result.topicId;
|
|
130
166
|
const network = options.network || "testnet";
|
|
131
167
|
const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;
|
|
132
168
|
return `Successfully inscribed and confirmed content on the Hedera network!
|
|
133
169
|
|
|
134
|
-
Transaction ID: ${
|
|
170
|
+
Transaction ID: ${inscriptionResult.result.transactionId}
|
|
135
171
|
Topic ID: ${topicId || "N/A"}${cdnUrl ? `
|
|
136
172
|
View inscription: ${cdnUrl}` : ""}
|
|
137
173
|
|
|
138
174
|
The inscription is now available.`;
|
|
139
|
-
} else {
|
|
175
|
+
} else if (!inscriptionResult.quote && !inscriptionResult.confirmed) {
|
|
140
176
|
return `Successfully submitted inscription to the Hedera network!
|
|
141
177
|
|
|
142
|
-
Transaction ID: ${
|
|
178
|
+
Transaction ID: ${inscriptionResult.result.transactionId}
|
|
143
179
|
|
|
144
180
|
The inscription is processing and will be confirmed shortly.`;
|
|
181
|
+
} else {
|
|
182
|
+
return "Inscription operation completed.";
|
|
145
183
|
}
|
|
146
184
|
} catch (error) {
|
|
147
185
|
const errorMessage = error instanceof Error ? error.message : "Failed to inscribe from file";
|