@hashgraphonline/standards-agent-kit 0.2.1 → 0.2.102
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/builders/hcs10/hcs10-builder.d.ts +4 -0
- package/dist/cjs/builders/hcs2/hcs2-builder.d.ts +50 -0
- package/dist/cjs/builders/hcs2/index.d.ts +1 -0
- package/dist/cjs/builders/index.d.ts +2 -0
- package/dist/cjs/builders/inscriber/index.d.ts +1 -0
- package/dist/cjs/builders/inscriber/inscriber-builder.d.ts +46 -0
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/cjs/tools/hcs10/FindRegistrationsTool.d.ts +4 -4
- package/dist/cjs/tools/hcs10/RegisterAgentTool.d.ts +24 -8
- package/dist/cjs/tools/hcs10/index.d.ts +1 -0
- package/dist/cjs/tools/hcs10/natural-language-mapper.d.ts +19 -0
- package/dist/cjs/tools/hcs2/CreateRegistryTool.d.ts +48 -0
- package/dist/cjs/tools/hcs2/DeleteEntryTool.d.ts +41 -0
- package/dist/cjs/tools/hcs2/MigrateRegistryTool.d.ts +47 -0
- package/dist/cjs/tools/hcs2/QueryRegistryTool.d.ts +47 -0
- package/dist/cjs/tools/hcs2/RegisterEntryTool.d.ts +47 -0
- package/dist/cjs/tools/hcs2/UpdateEntryTool.d.ts +53 -0
- package/dist/cjs/tools/hcs2/base-hcs2-tools.d.ts +28 -0
- package/dist/cjs/tools/hcs2/hcs2-tool-params.d.ts +18 -0
- package/dist/cjs/tools/hcs2/index.d.ts +8 -0
- package/dist/cjs/tools/index.d.ts +2 -0
- package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +77 -0
- package/dist/cjs/tools/inscriber/InscribeFromFileTool.d.ts +65 -0
- package/dist/cjs/tools/inscriber/InscribeFromUrlTool.d.ts +65 -0
- package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +125 -0
- package/dist/cjs/tools/inscriber/RetrieveInscriptionTool.d.ts +35 -0
- package/dist/cjs/tools/inscriber/base-inscriber-tools.d.ts +28 -0
- package/dist/cjs/tools/inscriber/index.d.ts +7 -0
- package/dist/cjs/tools/inscriber/inscriber-tool-params.d.ts +18 -0
- package/dist/es/builders/hcs10/hcs10-builder.d.ts +4 -0
- package/dist/es/builders/hcs2/hcs2-builder.d.ts +50 -0
- package/dist/es/builders/hcs2/index.d.ts +1 -0
- package/dist/es/builders/index.d.ts +2 -0
- package/dist/es/builders/inscriber/index.d.ts +1 -0
- package/dist/es/builders/inscriber/inscriber-builder.d.ts +46 -0
- package/dist/es/index.d.ts +1 -1
- package/dist/es/standards-agent-kit.es.js +50 -16
- package/dist/es/standards-agent-kit.es.js.map +1 -1
- package/dist/es/standards-agent-kit.es10.js +17 -23
- package/dist/es/standards-agent-kit.es10.js.map +1 -1
- package/dist/es/standards-agent-kit.es11.js +36 -58
- package/dist/es/standards-agent-kit.es11.js.map +1 -1
- package/dist/es/standards-agent-kit.es12.js +43 -18
- package/dist/es/standards-agent-kit.es12.js.map +1 -1
- package/dist/es/standards-agent-kit.es13.js +53 -16
- package/dist/es/standards-agent-kit.es13.js.map +1 -1
- package/dist/es/standards-agent-kit.es14.js +18 -28
- package/dist/es/standards-agent-kit.es14.js.map +1 -1
- package/dist/es/standards-agent-kit.es15.js +26 -12
- package/dist/es/standards-agent-kit.es15.js.map +1 -1
- package/dist/es/standards-agent-kit.es16.js +37 -241
- package/dist/es/standards-agent-kit.es16.js.map +1 -1
- package/dist/es/standards-agent-kit.es17.js +16 -136
- package/dist/es/standards-agent-kit.es17.js.map +1 -1
- package/dist/es/standards-agent-kit.es18.js +154 -27
- package/dist/es/standards-agent-kit.es18.js.map +1 -1
- package/dist/es/standards-agent-kit.es19.js +26 -22
- package/dist/es/standards-agent-kit.es19.js.map +1 -1
- package/dist/es/standards-agent-kit.es2.js +27 -13
- package/dist/es/standards-agent-kit.es2.js.map +1 -1
- package/dist/es/standards-agent-kit.es20.js +42 -3
- package/dist/es/standards-agent-kit.es20.js.map +1 -1
- package/dist/es/standards-agent-kit.es21.js +48 -0
- package/dist/es/standards-agent-kit.es21.js.map +1 -0
- package/dist/es/standards-agent-kit.es22.js +51 -0
- package/dist/es/standards-agent-kit.es22.js.map +1 -0
- package/dist/es/standards-agent-kit.es23.js +45 -0
- package/dist/es/standards-agent-kit.es23.js.map +1 -0
- package/dist/es/standards-agent-kit.es24.js +48 -0
- package/dist/es/standards-agent-kit.es24.js.map +1 -0
- package/dist/es/standards-agent-kit.es25.js +45 -0
- package/dist/es/standards-agent-kit.es25.js.map +1 -0
- package/dist/es/standards-agent-kit.es26.js +32 -0
- package/dist/es/standards-agent-kit.es26.js.map +1 -0
- package/dist/es/standards-agent-kit.es27.js +71 -0
- package/dist/es/standards-agent-kit.es27.js.map +1 -0
- package/dist/es/standards-agent-kit.es28.js +71 -0
- package/dist/es/standards-agent-kit.es28.js.map +1 -0
- package/dist/es/standards-agent-kit.es29.js +79 -0
- package/dist/es/standards-agent-kit.es29.js.map +1 -0
- package/dist/es/standards-agent-kit.es3.js +59 -296
- package/dist/es/standards-agent-kit.es3.js.map +1 -1
- package/dist/es/standards-agent-kit.es30.js +90 -0
- package/dist/es/standards-agent-kit.es30.js.map +1 -0
- package/dist/es/standards-agent-kit.es31.js +45 -0
- package/dist/es/standards-agent-kit.es31.js.map +1 -0
- package/dist/es/standards-agent-kit.es32.js +249 -0
- package/dist/es/standards-agent-kit.es32.js.map +1 -0
- package/dist/es/standards-agent-kit.es33.js +141 -0
- package/dist/es/standards-agent-kit.es33.js.map +1 -0
- package/dist/es/standards-agent-kit.es34.js +33 -0
- package/dist/es/standards-agent-kit.es34.js.map +1 -0
- package/dist/es/standards-agent-kit.es35.js +28 -0
- package/dist/es/standards-agent-kit.es35.js.map +1 -0
- package/dist/es/standards-agent-kit.es36.js +7 -0
- package/dist/es/standards-agent-kit.es36.js.map +1 -0
- package/dist/es/standards-agent-kit.es4.js +44 -20
- package/dist/es/standards-agent-kit.es4.js.map +1 -1
- package/dist/es/standards-agent-kit.es5.js +312 -121
- package/dist/es/standards-agent-kit.es5.js.map +1 -1
- package/dist/es/standards-agent-kit.es6.js +24 -23
- package/dist/es/standards-agent-kit.es6.js.map +1 -1
- package/dist/es/standards-agent-kit.es7.js +220 -20
- package/dist/es/standards-agent-kit.es7.js.map +1 -1
- package/dist/es/standards-agent-kit.es8.js +20 -29
- package/dist/es/standards-agent-kit.es8.js.map +1 -1
- package/dist/es/standards-agent-kit.es9.js +26 -36
- package/dist/es/standards-agent-kit.es9.js.map +1 -1
- package/dist/es/tools/hcs10/FindRegistrationsTool.d.ts +4 -4
- package/dist/es/tools/hcs10/RegisterAgentTool.d.ts +24 -8
- package/dist/es/tools/hcs10/index.d.ts +1 -0
- package/dist/es/tools/hcs10/natural-language-mapper.d.ts +19 -0
- package/dist/es/tools/hcs2/CreateRegistryTool.d.ts +48 -0
- package/dist/es/tools/hcs2/DeleteEntryTool.d.ts +41 -0
- package/dist/es/tools/hcs2/MigrateRegistryTool.d.ts +47 -0
- package/dist/es/tools/hcs2/QueryRegistryTool.d.ts +47 -0
- package/dist/es/tools/hcs2/RegisterEntryTool.d.ts +47 -0
- package/dist/es/tools/hcs2/UpdateEntryTool.d.ts +53 -0
- package/dist/es/tools/hcs2/base-hcs2-tools.d.ts +28 -0
- package/dist/es/tools/hcs2/hcs2-tool-params.d.ts +18 -0
- package/dist/es/tools/hcs2/index.d.ts +8 -0
- package/dist/es/tools/index.d.ts +2 -0
- package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +77 -0
- package/dist/es/tools/inscriber/InscribeFromFileTool.d.ts +65 -0
- package/dist/es/tools/inscriber/InscribeFromUrlTool.d.ts +65 -0
- package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +125 -0
- package/dist/es/tools/inscriber/RetrieveInscriptionTool.d.ts +35 -0
- package/dist/es/tools/inscriber/base-inscriber-tools.d.ts +28 -0
- package/dist/es/tools/inscriber/index.d.ts +7 -0
- package/dist/es/tools/inscriber/inscriber-tool-params.d.ts +18 -0
- package/dist/umd/builders/hcs10/hcs10-builder.d.ts +4 -0
- package/dist/umd/builders/hcs2/hcs2-builder.d.ts +50 -0
- package/dist/umd/builders/hcs2/index.d.ts +1 -0
- package/dist/umd/builders/index.d.ts +2 -0
- package/dist/umd/builders/inscriber/index.d.ts +1 -0
- package/dist/umd/builders/inscriber/inscriber-builder.d.ts +46 -0
- package/dist/umd/index.d.ts +1 -1
- 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/FindRegistrationsTool.d.ts +4 -4
- package/dist/umd/tools/hcs10/RegisterAgentTool.d.ts +24 -8
- package/dist/umd/tools/hcs10/index.d.ts +1 -0
- package/dist/umd/tools/hcs10/natural-language-mapper.d.ts +19 -0
- package/dist/umd/tools/hcs2/CreateRegistryTool.d.ts +48 -0
- package/dist/umd/tools/hcs2/DeleteEntryTool.d.ts +41 -0
- package/dist/umd/tools/hcs2/MigrateRegistryTool.d.ts +47 -0
- package/dist/umd/tools/hcs2/QueryRegistryTool.d.ts +47 -0
- package/dist/umd/tools/hcs2/RegisterEntryTool.d.ts +47 -0
- package/dist/umd/tools/hcs2/UpdateEntryTool.d.ts +53 -0
- package/dist/umd/tools/hcs2/base-hcs2-tools.d.ts +28 -0
- package/dist/umd/tools/hcs2/hcs2-tool-params.d.ts +18 -0
- package/dist/umd/tools/hcs2/index.d.ts +8 -0
- package/dist/umd/tools/index.d.ts +2 -0
- package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +77 -0
- package/dist/umd/tools/inscriber/InscribeFromFileTool.d.ts +65 -0
- package/dist/umd/tools/inscriber/InscribeFromUrlTool.d.ts +65 -0
- package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +125 -0
- package/dist/umd/tools/inscriber/RetrieveInscriptionTool.d.ts +35 -0
- package/dist/umd/tools/inscriber/base-inscriber-tools.d.ts +28 -0
- package/dist/umd/tools/inscriber/index.d.ts +7 -0
- package/dist/umd/tools/inscriber/inscriber-tool-params.d.ts +18 -0
- package/package.json +32 -30
- package/src/builders/hcs10/hcs10-builder.ts +37 -16
- package/src/builders/hcs2/hcs2-builder.ts +148 -0
- package/src/builders/hcs2/index.ts +1 -0
- package/src/builders/index.ts +3 -1
- package/src/builders/inscriber/index.ts +1 -0
- package/src/builders/inscriber/inscriber-builder.ts +112 -0
- package/src/index.ts +1 -1
- package/src/tools/hcs10/FindRegistrationsTool.ts +19 -4
- package/src/tools/hcs10/RegisterAgentTool.ts +147 -9
- package/src/tools/hcs10/index.ts +2 -1
- package/src/tools/hcs10/natural-language-mapper.ts +194 -0
- package/src/tools/hcs2/CreateRegistryTool.ts +63 -0
- package/src/tools/hcs2/DeleteEntryTool.ts +58 -0
- package/src/tools/hcs2/MigrateRegistryTool.ts +64 -0
- package/src/tools/hcs2/QueryRegistryTool.ts +70 -0
- package/src/tools/hcs2/RegisterEntryTool.ts +63 -0
- package/src/tools/hcs2/UpdateEntryTool.ts +68 -0
- package/src/tools/hcs2/base-hcs2-tools.ts +65 -0
- package/src/tools/hcs2/hcs2-tool-params.ts +21 -0
- package/src/tools/hcs2/index.ts +8 -0
- package/src/tools/index.ts +3 -2
- package/src/tools/inscriber/InscribeFromBufferTool.ts +105 -0
- package/src/tools/inscriber/InscribeFromFileTool.ts +93 -0
- package/src/tools/inscriber/InscribeFromUrlTool.ts +93 -0
- package/src/tools/inscriber/InscribeHashinalTool.ts +117 -0
- package/src/tools/inscriber/RetrieveInscriptionTool.ts +59 -0
- package/src/tools/inscriber/base-inscriber-tools.ts +65 -0
- package/src/tools/inscriber/index.ts +7 -0
- package/src/tools/inscriber/inscriber-tool-params.ts +21 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseInscriberQueryTool } from './base-inscriber-tools';
|
|
3
|
+
import { InscriptionOptions } from '@hashgraphonline/standards-sdk';
|
|
4
|
+
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Schema for inscribing from URL
|
|
8
|
+
*/
|
|
9
|
+
const inscribeFromUrlSchema = z.object({
|
|
10
|
+
url: z.string().url().describe('The URL of the content to inscribe'),
|
|
11
|
+
mode: z
|
|
12
|
+
.enum(['file', 'hashinal'])
|
|
13
|
+
.optional()
|
|
14
|
+
.describe('Inscription mode: file or hashinal NFT'),
|
|
15
|
+
metadata: z
|
|
16
|
+
.record(z.unknown())
|
|
17
|
+
.optional()
|
|
18
|
+
.describe('Metadata to attach to the inscription'),
|
|
19
|
+
tags: z
|
|
20
|
+
.array(z.string())
|
|
21
|
+
.optional()
|
|
22
|
+
.describe('Tags to categorize the inscription'),
|
|
23
|
+
chunkSize: z
|
|
24
|
+
.number()
|
|
25
|
+
.int()
|
|
26
|
+
.positive()
|
|
27
|
+
.optional()
|
|
28
|
+
.describe('Chunk size for large files'),
|
|
29
|
+
waitForConfirmation: z
|
|
30
|
+
.boolean()
|
|
31
|
+
.optional()
|
|
32
|
+
.describe('Whether to wait for inscription confirmation'),
|
|
33
|
+
apiKey: z
|
|
34
|
+
.string()
|
|
35
|
+
.optional()
|
|
36
|
+
.describe('API key for inscription service'),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Tool for inscribing content from URL
|
|
42
|
+
*/
|
|
43
|
+
export class InscribeFromUrlTool extends BaseInscriberQueryTool<typeof inscribeFromUrlSchema> {
|
|
44
|
+
name = 'inscribeFromUrl';
|
|
45
|
+
description = 'Inscribe content from a URL to the Hedera network';
|
|
46
|
+
|
|
47
|
+
get specificInputSchema() {
|
|
48
|
+
return inscribeFromUrlSchema;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected async executeQuery(
|
|
52
|
+
params: z.infer<typeof inscribeFromUrlSchema>,
|
|
53
|
+
_runManager?: CallbackManagerForToolRun
|
|
54
|
+
): Promise<unknown> {
|
|
55
|
+
const options: InscriptionOptions = {
|
|
56
|
+
mode: params.mode,
|
|
57
|
+
metadata: params.metadata,
|
|
58
|
+
tags: params.tags,
|
|
59
|
+
chunkSize: params.chunkSize,
|
|
60
|
+
waitForConfirmation: params.waitForConfirmation ?? true,
|
|
61
|
+
waitMaxAttempts: 10,
|
|
62
|
+
waitIntervalMs: 3000,
|
|
63
|
+
apiKey: params.apiKey,
|
|
64
|
+
network: this.inscriberBuilder['hederaKit'].client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet',
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
69
|
+
setTimeout(() => reject(new Error('Inscription timed out after 30 seconds')), 30000);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const result = await Promise.race([
|
|
73
|
+
this.inscriberBuilder.inscribe(
|
|
74
|
+
{ type: 'url', url: params.url },
|
|
75
|
+
options
|
|
76
|
+
),
|
|
77
|
+
timeoutPromise
|
|
78
|
+
]) as any;
|
|
79
|
+
|
|
80
|
+
if (result.confirmed) {
|
|
81
|
+
const topicId = result.inscription?.topic_id || result.result.topicId;
|
|
82
|
+
const network = options.network || 'testnet';
|
|
83
|
+
const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;
|
|
84
|
+
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.`;
|
|
85
|
+
} else {
|
|
86
|
+
return `Successfully submitted inscription to the Hedera network!\n\nTransaction ID: ${result.result.transactionId}\n\nThe inscription is processing and will be confirmed shortly.`;
|
|
87
|
+
}
|
|
88
|
+
} catch (error) {
|
|
89
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to inscribe from URL';
|
|
90
|
+
throw new Error(`Inscription failed: ${errorMessage}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseInscriberQueryTool } from './base-inscriber-tools';
|
|
3
|
+
import { InscriptionOptions } from '@hashgraphonline/standards-sdk';
|
|
4
|
+
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Schema for inscribing Hashinal NFT
|
|
8
|
+
*/
|
|
9
|
+
const inscribeHashinalSchema = z.object({
|
|
10
|
+
url: z.string().url().describe('The URL of the content to inscribe as Hashinal NFT'),
|
|
11
|
+
name: z.string().describe('Name of the Hashinal NFT'),
|
|
12
|
+
creator: z.string().describe('Creator account ID or name'),
|
|
13
|
+
description: z.string().describe('Description of the Hashinal NFT'),
|
|
14
|
+
type: z.string().describe('Type of NFT (e.g., "image", "video", "audio")'),
|
|
15
|
+
attributes: z
|
|
16
|
+
.array(
|
|
17
|
+
z.object({
|
|
18
|
+
trait_type: z.string(),
|
|
19
|
+
value: z.union([z.string(), z.number()]),
|
|
20
|
+
})
|
|
21
|
+
)
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('NFT attributes'),
|
|
24
|
+
properties: z
|
|
25
|
+
.record(z.unknown())
|
|
26
|
+
.optional()
|
|
27
|
+
.describe('Additional properties'),
|
|
28
|
+
jsonFileURL: z
|
|
29
|
+
.string()
|
|
30
|
+
.url()
|
|
31
|
+
.optional()
|
|
32
|
+
.describe('URL to JSON metadata file'),
|
|
33
|
+
tags: z
|
|
34
|
+
.array(z.string())
|
|
35
|
+
.optional()
|
|
36
|
+
.describe('Tags to categorize the NFT'),
|
|
37
|
+
chunkSize: z
|
|
38
|
+
.number()
|
|
39
|
+
.int()
|
|
40
|
+
.positive()
|
|
41
|
+
.optional()
|
|
42
|
+
.describe('Chunk size for large files'),
|
|
43
|
+
waitForConfirmation: z
|
|
44
|
+
.boolean()
|
|
45
|
+
.optional()
|
|
46
|
+
.describe('Whether to wait for inscription confirmation'),
|
|
47
|
+
apiKey: z
|
|
48
|
+
.string()
|
|
49
|
+
.optional()
|
|
50
|
+
.describe('API key for inscription service'),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Tool for inscribing Hashinal NFTs
|
|
56
|
+
*/
|
|
57
|
+
export class InscribeHashinalTool extends BaseInscriberQueryTool<typeof inscribeHashinalSchema> {
|
|
58
|
+
name = 'inscribeHashinal';
|
|
59
|
+
description = 'Inscribe content as a Hashinal NFT on the Hedera network';
|
|
60
|
+
|
|
61
|
+
get specificInputSchema() {
|
|
62
|
+
return inscribeHashinalSchema;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
protected async executeQuery(
|
|
66
|
+
params: z.infer<typeof inscribeHashinalSchema>,
|
|
67
|
+
_runManager?: CallbackManagerForToolRun
|
|
68
|
+
): Promise<unknown> {
|
|
69
|
+
const metadata = {
|
|
70
|
+
name: params.name,
|
|
71
|
+
creator: params.creator,
|
|
72
|
+
description: params.description,
|
|
73
|
+
type: params.type,
|
|
74
|
+
attributes: params.attributes,
|
|
75
|
+
properties: params.properties,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const options: InscriptionOptions = {
|
|
79
|
+
mode: 'hashinal',
|
|
80
|
+
metadata,
|
|
81
|
+
jsonFileURL: params.jsonFileURL,
|
|
82
|
+
tags: params.tags,
|
|
83
|
+
chunkSize: params.chunkSize,
|
|
84
|
+
waitForConfirmation: params.waitForConfirmation ?? true,
|
|
85
|
+
waitMaxAttempts: 10,
|
|
86
|
+
waitIntervalMs: 3000,
|
|
87
|
+
apiKey: params.apiKey,
|
|
88
|
+
network: this.inscriberBuilder['hederaKit'].client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet',
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
93
|
+
setTimeout(() => reject(new Error('Inscription timed out after 30 seconds')), 30000);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const result = await Promise.race([
|
|
97
|
+
this.inscriberBuilder.inscribe(
|
|
98
|
+
{ type: 'url', url: params.url },
|
|
99
|
+
options
|
|
100
|
+
),
|
|
101
|
+
timeoutPromise
|
|
102
|
+
]) as any;
|
|
103
|
+
|
|
104
|
+
if (result.confirmed) {
|
|
105
|
+
const topicId = result.inscription?.topic_id || result.result.topicId;
|
|
106
|
+
const network = options.network || 'testnet';
|
|
107
|
+
const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;
|
|
108
|
+
return `Successfully inscribed and confirmed Hashinal NFT on the Hedera network!\n\nTransaction ID: ${result.result.transactionId}\nTopic ID: ${topicId || 'N/A'}${cdnUrl ? `\nView inscription: ${cdnUrl}` : ''}\n\nThe Hashinal NFT is now available.`;
|
|
109
|
+
} else {
|
|
110
|
+
return `Successfully submitted Hashinal NFT inscription to the Hedera network!\n\nTransaction ID: ${result.result.transactionId}\n\nThe inscription is processing and will be confirmed shortly.`;
|
|
111
|
+
}
|
|
112
|
+
} catch (error) {
|
|
113
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to inscribe Hashinal NFT';
|
|
114
|
+
throw new Error(`Inscription failed: ${errorMessage}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseInscriberQueryTool } from './base-inscriber-tools';
|
|
3
|
+
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema for retrieving inscription
|
|
7
|
+
*/
|
|
8
|
+
const retrieveInscriptionSchema = z.object({
|
|
9
|
+
transactionId: z
|
|
10
|
+
.string()
|
|
11
|
+
.describe('The transaction ID of the inscription to retrieve'),
|
|
12
|
+
apiKey: z
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe('API key for inscription service'),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Tool for retrieving inscriptions
|
|
21
|
+
*/
|
|
22
|
+
export class RetrieveInscriptionTool extends BaseInscriberQueryTool<typeof retrieveInscriptionSchema> {
|
|
23
|
+
name = 'retrieveInscription';
|
|
24
|
+
description = 'Retrieve details of an existing inscription from the Hedera network';
|
|
25
|
+
|
|
26
|
+
get specificInputSchema() {
|
|
27
|
+
return retrieveInscriptionSchema;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
protected async executeQuery(
|
|
31
|
+
params: z.infer<typeof retrieveInscriptionSchema>,
|
|
32
|
+
_runManager?: CallbackManagerForToolRun
|
|
33
|
+
): Promise<unknown> {
|
|
34
|
+
const result = await this.inscriberBuilder.retrieveInscription(
|
|
35
|
+
params.transactionId,
|
|
36
|
+
{
|
|
37
|
+
apiKey: params.apiKey,
|
|
38
|
+
network: this.inscriberBuilder['hederaKit'].client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet',
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
inscriptionId: (result as any).inscriptionId,
|
|
44
|
+
transactionId: result.transactionId,
|
|
45
|
+
topicId: (result as any).topic_id,
|
|
46
|
+
status: result.status,
|
|
47
|
+
holderId: (result as any).holderId,
|
|
48
|
+
metadata: result.metadata,
|
|
49
|
+
tags: (result as any).tags,
|
|
50
|
+
mode: result.mode,
|
|
51
|
+
chunks: (result as any).chunks,
|
|
52
|
+
createdAt: (result as any).createdAt,
|
|
53
|
+
completedAt: (result as any).completed || (result as any).completedAt,
|
|
54
|
+
fileUrl: result.fileUrl,
|
|
55
|
+
mimeType: (result as any).mimeType,
|
|
56
|
+
fileSize: (result as any).fileSize,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseHederaTransactionTool,
|
|
3
|
+
BaseHederaQueryTool,
|
|
4
|
+
BaseServiceBuilder,
|
|
5
|
+
} from 'hedera-agent-kit';
|
|
6
|
+
import { InscriberBuilder } from '../../builders/inscriber/inscriber-builder';
|
|
7
|
+
import {
|
|
8
|
+
InscriberTransactionToolParams,
|
|
9
|
+
InscriberQueryToolParams,
|
|
10
|
+
} from './inscriber-tool-params';
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Base class for Inscriber transaction tools
|
|
15
|
+
*/
|
|
16
|
+
export abstract class BaseInscriberTransactionTool<
|
|
17
|
+
T extends z.ZodObject<
|
|
18
|
+
z.ZodRawShape,
|
|
19
|
+
z.UnknownKeysParam,
|
|
20
|
+
z.ZodTypeAny
|
|
21
|
+
> = z.ZodObject<z.ZodRawShape>
|
|
22
|
+
> extends BaseHederaTransactionTool<T> {
|
|
23
|
+
protected inscriberBuilder: InscriberBuilder;
|
|
24
|
+
namespace = 'inscriber' as const;
|
|
25
|
+
|
|
26
|
+
constructor(params: InscriberTransactionToolParams) {
|
|
27
|
+
super(params);
|
|
28
|
+
this.inscriberBuilder = params.inscriberBuilder;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Override to return the InscriberBuilder
|
|
33
|
+
*/
|
|
34
|
+
protected getServiceBuilder(): BaseServiceBuilder {
|
|
35
|
+
return this.inscriberBuilder;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Base class for Inscriber query tools
|
|
41
|
+
*/
|
|
42
|
+
export abstract class BaseInscriberQueryTool<
|
|
43
|
+
T extends z.ZodObject<
|
|
44
|
+
z.ZodRawShape,
|
|
45
|
+
z.UnknownKeysParam,
|
|
46
|
+
z.ZodTypeAny,
|
|
47
|
+
Record<string, unknown>,
|
|
48
|
+
Record<string, unknown>
|
|
49
|
+
> = z.ZodObject<z.ZodRawShape>
|
|
50
|
+
> extends BaseHederaQueryTool<T> {
|
|
51
|
+
protected inscriberBuilder: InscriberBuilder;
|
|
52
|
+
namespace = 'inscriber' as const;
|
|
53
|
+
|
|
54
|
+
constructor(params: InscriberQueryToolParams) {
|
|
55
|
+
super(params);
|
|
56
|
+
this.inscriberBuilder = params.inscriberBuilder;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Override to return the InscriberBuilder
|
|
61
|
+
*/
|
|
62
|
+
protected getServiceBuilder(): BaseServiceBuilder {
|
|
63
|
+
return this.inscriberBuilder;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './base-inscriber-tools';
|
|
2
|
+
export * from './inscriber-tool-params';
|
|
3
|
+
export * from './InscribeFromUrlTool';
|
|
4
|
+
export * from './InscribeFromFileTool';
|
|
5
|
+
export * from './InscribeFromBufferTool';
|
|
6
|
+
export * from './InscribeHashinalTool';
|
|
7
|
+
export * from './RetrieveInscriptionTool';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HederaAgentKit } from 'hedera-agent-kit';
|
|
2
|
+
import type { BasePluginContext } from 'hedera-agent-kit';
|
|
3
|
+
import { InscriberBuilder } from '../../builders/inscriber/inscriber-builder';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parameters for Inscriber transaction tools
|
|
7
|
+
*/
|
|
8
|
+
export interface InscriberTransactionToolParams {
|
|
9
|
+
hederaKit: HederaAgentKit;
|
|
10
|
+
inscriberBuilder: InscriberBuilder;
|
|
11
|
+
logger?: BasePluginContext['logger'];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Parameters for Inscriber query tools
|
|
16
|
+
*/
|
|
17
|
+
export interface InscriberQueryToolParams {
|
|
18
|
+
hederaKit: HederaAgentKit;
|
|
19
|
+
inscriberBuilder: InscriberBuilder;
|
|
20
|
+
logger?: BasePluginContext['logger'];
|
|
21
|
+
}
|