@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,58 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseHCS2QueryTool } from './base-hcs2-tools';
|
|
3
|
+
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema for deleting an entry from HCS-2
|
|
7
|
+
*/
|
|
8
|
+
const deleteEntrySchema = z.object({
|
|
9
|
+
registryTopicId: z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^\d+\.\d+\.\d+$/)
|
|
12
|
+
.describe('The HCS-2 registry topic ID (must be indexed)'),
|
|
13
|
+
uid: z
|
|
14
|
+
.string()
|
|
15
|
+
.describe('The unique ID of the entry to delete'),
|
|
16
|
+
memo: z
|
|
17
|
+
.string()
|
|
18
|
+
.max(500)
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('Optional memo (max 500 characters)'),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Tool for deleting entries from HCS-2 registries
|
|
26
|
+
*/
|
|
27
|
+
export class DeleteEntryTool extends BaseHCS2QueryTool<typeof deleteEntrySchema> {
|
|
28
|
+
name = 'deleteHCS2Entry';
|
|
29
|
+
description = 'Delete an entry from an indexed HCS-2 registry';
|
|
30
|
+
|
|
31
|
+
get specificInputSchema() {
|
|
32
|
+
return deleteEntrySchema;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
protected async executeQuery(
|
|
36
|
+
params: z.infer<typeof deleteEntrySchema>,
|
|
37
|
+
_runManager?: CallbackManagerForToolRun
|
|
38
|
+
): Promise<unknown> {
|
|
39
|
+
try {
|
|
40
|
+
const result = await this.hcs2Builder.deleteEntry(
|
|
41
|
+
params.registryTopicId,
|
|
42
|
+
{
|
|
43
|
+
uid: params.uid,
|
|
44
|
+
memo: params.memo,
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (!result.success) {
|
|
49
|
+
throw new Error(result.error || 'Failed to delete entry');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return `Successfully deleted entry from HCS-2 registry!\n\nRegistry Topic: ${params.registryTopicId}\nUID: ${params.uid}${params.memo ? `\nMemo: ${params.memo}` : ''}\n\nThe entry has been removed from the registry.`;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to delete entry';
|
|
55
|
+
throw new Error(`Entry deletion failed: ${errorMessage}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseHCS2QueryTool } from './base-hcs2-tools';
|
|
3
|
+
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema for migrating an HCS-2 registry
|
|
7
|
+
*/
|
|
8
|
+
const migrateRegistrySchema = z.object({
|
|
9
|
+
registryTopicId: z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^\d+\.\d+\.\d+$/)
|
|
12
|
+
.describe('The current HCS-2 registry topic ID'),
|
|
13
|
+
targetTopicId: z
|
|
14
|
+
.string()
|
|
15
|
+
.regex(/^\d+\.\d+\.\d+$/)
|
|
16
|
+
.describe('The new topic ID to migrate to'),
|
|
17
|
+
metadata: z
|
|
18
|
+
.string()
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('Optional metadata URI for migration details'),
|
|
21
|
+
memo: z
|
|
22
|
+
.string()
|
|
23
|
+
.max(500)
|
|
24
|
+
.optional()
|
|
25
|
+
.describe('Optional memo (max 500 characters)'),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Tool for migrating HCS-2 registries
|
|
31
|
+
*/
|
|
32
|
+
export class MigrateRegistryTool extends BaseHCS2QueryTool<typeof migrateRegistrySchema> {
|
|
33
|
+
name = 'migrateHCS2Registry';
|
|
34
|
+
description = 'Migrate an HCS-2 registry to a new topic';
|
|
35
|
+
|
|
36
|
+
get specificInputSchema() {
|
|
37
|
+
return migrateRegistrySchema;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
protected async executeQuery(
|
|
41
|
+
params: z.infer<typeof migrateRegistrySchema>,
|
|
42
|
+
_runManager?: CallbackManagerForToolRun
|
|
43
|
+
): Promise<unknown> {
|
|
44
|
+
try {
|
|
45
|
+
const result = await this.hcs2Builder.migrateRegistry(
|
|
46
|
+
params.registryTopicId,
|
|
47
|
+
{
|
|
48
|
+
targetTopicId: params.targetTopicId,
|
|
49
|
+
metadata: params.metadata,
|
|
50
|
+
memo: params.memo,
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
if (!result.success) {
|
|
55
|
+
throw new Error(result.error || 'Failed to migrate registry');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return `Successfully migrated HCS-2 registry!\n\nFrom Registry Topic: ${params.registryTopicId}\nTo Target Topic: ${params.targetTopicId}${params.metadata ? `\nMetadata: ${params.metadata}` : ''}${params.memo ? `\nMemo: ${params.memo}` : ''}\n\nThe registry has been migrated to the new topic.`;
|
|
59
|
+
} catch (error) {
|
|
60
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to migrate registry';
|
|
61
|
+
throw new Error(`Registry migration failed: ${errorMessage}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseHCS2QueryTool } from './base-hcs2-tools';
|
|
3
|
+
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema for querying HCS-2 registry
|
|
7
|
+
*/
|
|
8
|
+
const queryRegistrySchema = z.object({
|
|
9
|
+
topicId: z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^\d+\.\d+\.\d+$/)
|
|
12
|
+
.describe('The HCS-2 registry topic ID to query'),
|
|
13
|
+
limit: z
|
|
14
|
+
.number()
|
|
15
|
+
.int()
|
|
16
|
+
.positive()
|
|
17
|
+
.optional()
|
|
18
|
+
.describe('Maximum number of entries to return'),
|
|
19
|
+
order: z
|
|
20
|
+
.enum(['asc', 'desc'])
|
|
21
|
+
.optional()
|
|
22
|
+
.describe('Order of results (ascending or descending)'),
|
|
23
|
+
skip: z
|
|
24
|
+
.number()
|
|
25
|
+
.int()
|
|
26
|
+
.min(0)
|
|
27
|
+
.optional()
|
|
28
|
+
.describe('Number of entries to skip'),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Tool for querying HCS-2 registries
|
|
34
|
+
*/
|
|
35
|
+
export class QueryRegistryTool extends BaseHCS2QueryTool<typeof queryRegistrySchema> {
|
|
36
|
+
name = 'queryHCS2Registry';
|
|
37
|
+
description = 'Query entries from an HCS-2 registry';
|
|
38
|
+
|
|
39
|
+
get specificInputSchema() {
|
|
40
|
+
return queryRegistrySchema;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
protected async executeQuery(
|
|
44
|
+
params: z.infer<typeof queryRegistrySchema>,
|
|
45
|
+
_runManager?: CallbackManagerForToolRun
|
|
46
|
+
): Promise<unknown> {
|
|
47
|
+
const registry = await this.hcs2Builder.getRegistry(params.topicId, {
|
|
48
|
+
limit: params.limit,
|
|
49
|
+
order: params.order,
|
|
50
|
+
skip: params.skip,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
topicId: registry.topicId,
|
|
55
|
+
registryType: registry.registryType === 0 ? 'indexed' : 'non-indexed',
|
|
56
|
+
ttl: registry.ttl,
|
|
57
|
+
totalEntries: registry.entries.length,
|
|
58
|
+
entries: registry.entries.map(entry => ({
|
|
59
|
+
sequence: entry.sequence,
|
|
60
|
+
timestamp: entry.timestamp,
|
|
61
|
+
payer: entry.payer,
|
|
62
|
+
operation: entry.message.op,
|
|
63
|
+
targetTopicId: entry.message.t_id,
|
|
64
|
+
uid: entry.message.uid,
|
|
65
|
+
metadata: entry.message.metadata,
|
|
66
|
+
memo: entry.message.m,
|
|
67
|
+
})),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseHCS2QueryTool } from './base-hcs2-tools';
|
|
3
|
+
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema for registering an entry in HCS-2
|
|
7
|
+
*/
|
|
8
|
+
const registerEntrySchema = z.object({
|
|
9
|
+
registryTopicId: z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^\d+\.\d+\.\d+$/)
|
|
12
|
+
.describe('The HCS-2 registry topic ID (e.g., 0.0.123456)'),
|
|
13
|
+
targetTopicId: z
|
|
14
|
+
.string()
|
|
15
|
+
.regex(/^\d+\.\d+\.\d+$/)
|
|
16
|
+
.describe('The target topic ID to register (e.g., 0.0.123456)'),
|
|
17
|
+
metadata: z
|
|
18
|
+
.string()
|
|
19
|
+
.optional()
|
|
20
|
+
.describe('Optional metadata URI (HIP-412 format)'),
|
|
21
|
+
memo: z
|
|
22
|
+
.string()
|
|
23
|
+
.max(500)
|
|
24
|
+
.optional()
|
|
25
|
+
.describe('Optional memo (max 500 characters)'),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Tool for registering entries in HCS-2 registries
|
|
30
|
+
*/
|
|
31
|
+
export class RegisterEntryTool extends BaseHCS2QueryTool<typeof registerEntrySchema> {
|
|
32
|
+
name = 'registerHCS2Entry';
|
|
33
|
+
description = 'Register a new entry in an HCS-2 registry';
|
|
34
|
+
|
|
35
|
+
get specificInputSchema() {
|
|
36
|
+
return registerEntrySchema;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
protected async executeQuery(
|
|
40
|
+
params: z.infer<typeof registerEntrySchema>,
|
|
41
|
+
_runManager?: CallbackManagerForToolRun
|
|
42
|
+
): Promise<unknown> {
|
|
43
|
+
try {
|
|
44
|
+
const result = await this.hcs2Builder.registerEntry(
|
|
45
|
+
params.registryTopicId,
|
|
46
|
+
{
|
|
47
|
+
targetTopicId: params.targetTopicId,
|
|
48
|
+
metadata: params.metadata,
|
|
49
|
+
memo: params.memo,
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
if (!result.success) {
|
|
54
|
+
throw new Error(result.error || 'Failed to register entry');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return `Successfully registered entry in HCS-2 registry!\n\nRegistry Topic: ${params.registryTopicId}\nTarget Topic ID: ${params.targetTopicId}${params.metadata ? `\nMetadata: ${params.metadata}` : ''}${params.memo ? `\nMemo: ${params.memo}` : ''}\n\nThe entry has been added to the registry.`;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to register entry';
|
|
60
|
+
throw new Error(`Entry registration failed: ${errorMessage}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseHCS2QueryTool } from './base-hcs2-tools';
|
|
3
|
+
import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Schema for updating an entry in HCS-2
|
|
7
|
+
*/
|
|
8
|
+
const updateEntrySchema = z.object({
|
|
9
|
+
registryTopicId: z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^\d+\.\d+\.\d+$/)
|
|
12
|
+
.describe('The HCS-2 registry topic ID (must be indexed)'),
|
|
13
|
+
targetTopicId: z
|
|
14
|
+
.string()
|
|
15
|
+
.regex(/^\d+\.\d+\.\d+$/)
|
|
16
|
+
.describe('The new topic ID to point to'),
|
|
17
|
+
uid: z
|
|
18
|
+
.string()
|
|
19
|
+
.describe('The unique ID of the entry to update'),
|
|
20
|
+
metadata: z
|
|
21
|
+
.string()
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('Optional metadata URI (HIP-412 format)'),
|
|
24
|
+
memo: z
|
|
25
|
+
.string()
|
|
26
|
+
.max(500)
|
|
27
|
+
.optional()
|
|
28
|
+
.describe('Optional memo (max 500 characters)'),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Tool for updating entries in HCS-2 registries
|
|
34
|
+
*/
|
|
35
|
+
export class UpdateEntryTool extends BaseHCS2QueryTool<typeof updateEntrySchema> {
|
|
36
|
+
name = 'updateHCS2Entry';
|
|
37
|
+
description = 'Update an existing entry in an indexed HCS-2 registry';
|
|
38
|
+
|
|
39
|
+
get specificInputSchema() {
|
|
40
|
+
return updateEntrySchema;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
protected async executeQuery(
|
|
44
|
+
params: z.infer<typeof updateEntrySchema>,
|
|
45
|
+
_runManager?: CallbackManagerForToolRun
|
|
46
|
+
): Promise<unknown> {
|
|
47
|
+
try {
|
|
48
|
+
const result = await this.hcs2Builder.updateEntry(
|
|
49
|
+
params.registryTopicId,
|
|
50
|
+
{
|
|
51
|
+
targetTopicId: params.targetTopicId,
|
|
52
|
+
uid: params.uid,
|
|
53
|
+
metadata: params.metadata,
|
|
54
|
+
memo: params.memo,
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (!result.success) {
|
|
59
|
+
throw new Error(result.error || 'Failed to update entry');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return `Successfully updated entry in HCS-2 registry!\n\nRegistry Topic: ${params.registryTopicId}\nUID: ${params.uid}\nNew Target Topic ID: ${params.targetTopicId}${params.metadata ? `\nMetadata: ${params.metadata}` : ''}${params.memo ? `\nMemo: ${params.memo}` : ''}\n\nThe entry has been updated in the registry.`;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to update entry';
|
|
65
|
+
throw new Error(`Entry update failed: ${errorMessage}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseHederaTransactionTool,
|
|
3
|
+
BaseHederaQueryTool,
|
|
4
|
+
BaseServiceBuilder,
|
|
5
|
+
} from 'hedera-agent-kit';
|
|
6
|
+
import { HCS2Builder } from '../../builders/hcs2/hcs2-builder';
|
|
7
|
+
import {
|
|
8
|
+
HCS2TransactionToolParams,
|
|
9
|
+
HCS2QueryToolParams,
|
|
10
|
+
} from './hcs2-tool-params';
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Base class for HCS2 transaction tools
|
|
15
|
+
*/
|
|
16
|
+
export abstract class BaseHCS2TransactionTool<
|
|
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 hcs2Builder: HCS2Builder;
|
|
24
|
+
namespace = 'hcs2' as const;
|
|
25
|
+
|
|
26
|
+
constructor(params: HCS2TransactionToolParams) {
|
|
27
|
+
super(params);
|
|
28
|
+
this.hcs2Builder = params.hcs2Builder;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Override to return the HCS2Builder
|
|
33
|
+
*/
|
|
34
|
+
protected getServiceBuilder(): BaseServiceBuilder {
|
|
35
|
+
return this.hcs2Builder;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Base class for HCS2 query tools
|
|
41
|
+
*/
|
|
42
|
+
export abstract class BaseHCS2QueryTool<
|
|
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 hcs2Builder: HCS2Builder;
|
|
52
|
+
namespace = 'hcs2' as const;
|
|
53
|
+
|
|
54
|
+
constructor(params: HCS2QueryToolParams) {
|
|
55
|
+
super(params);
|
|
56
|
+
this.hcs2Builder = params.hcs2Builder;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Override to return the HCS2Builder
|
|
61
|
+
*/
|
|
62
|
+
protected getServiceBuilder(): BaseServiceBuilder {
|
|
63
|
+
return this.hcs2Builder;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HederaAgentKit } from 'hedera-agent-kit';
|
|
2
|
+
import type { BasePluginContext } from 'hedera-agent-kit';
|
|
3
|
+
import { HCS2Builder } from '../../builders/hcs2/hcs2-builder';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parameters for HCS2 transaction tools
|
|
7
|
+
*/
|
|
8
|
+
export interface HCS2TransactionToolParams {
|
|
9
|
+
hederaKit: HederaAgentKit;
|
|
10
|
+
hcs2Builder: HCS2Builder;
|
|
11
|
+
logger?: BasePluginContext['logger'];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Parameters for HCS2 query tools
|
|
16
|
+
*/
|
|
17
|
+
export interface HCS2QueryToolParams {
|
|
18
|
+
hederaKit: HederaAgentKit;
|
|
19
|
+
hcs2Builder: HCS2Builder;
|
|
20
|
+
logger?: BasePluginContext['logger'];
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './base-hcs2-tools';
|
|
2
|
+
export * from './hcs2-tool-params';
|
|
3
|
+
export * from './CreateRegistryTool';
|
|
4
|
+
export * from './RegisterEntryTool';
|
|
5
|
+
export * from './UpdateEntryTool';
|
|
6
|
+
export * from './DeleteEntryTool';
|
|
7
|
+
export * from './MigrateRegistryTool';
|
|
8
|
+
export * from './QueryRegistryTool';
|
package/src/tools/index.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './hcs10';
|
|
2
|
+
export * from './hcs2';
|
|
3
|
+
export * from './inscriber';
|
|
@@ -0,0 +1,105 @@
|
|
|
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 buffer
|
|
8
|
+
*/
|
|
9
|
+
const inscribeFromBufferSchema = z.object({
|
|
10
|
+
base64Data: z.string().describe('Base64 encoded content to inscribe'),
|
|
11
|
+
fileName: z.string().describe('Name for the inscribed content'),
|
|
12
|
+
mimeType: z
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe('MIME type of the content'),
|
|
16
|
+
mode: z
|
|
17
|
+
.enum(['file', 'hashinal'])
|
|
18
|
+
.optional()
|
|
19
|
+
.describe('Inscription mode: file or hashinal NFT'),
|
|
20
|
+
metadata: z
|
|
21
|
+
.record(z.unknown())
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('Metadata to attach to the inscription'),
|
|
24
|
+
tags: z
|
|
25
|
+
.array(z.string())
|
|
26
|
+
.optional()
|
|
27
|
+
.describe('Tags to categorize the inscription'),
|
|
28
|
+
chunkSize: z
|
|
29
|
+
.number()
|
|
30
|
+
.int()
|
|
31
|
+
.positive()
|
|
32
|
+
.optional()
|
|
33
|
+
.describe('Chunk size for large files'),
|
|
34
|
+
waitForConfirmation: z
|
|
35
|
+
.boolean()
|
|
36
|
+
.optional()
|
|
37
|
+
.describe('Whether to wait for inscription confirmation'),
|
|
38
|
+
apiKey: z
|
|
39
|
+
.string()
|
|
40
|
+
.optional()
|
|
41
|
+
.describe('API key for inscription service'),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Tool for inscribing content from buffer
|
|
47
|
+
*/
|
|
48
|
+
export class InscribeFromBufferTool extends BaseInscriberQueryTool<typeof inscribeFromBufferSchema> {
|
|
49
|
+
name = 'inscribeFromBuffer';
|
|
50
|
+
description = 'Inscribe content from a buffer/base64 data to the Hedera network';
|
|
51
|
+
|
|
52
|
+
get specificInputSchema() {
|
|
53
|
+
return inscribeFromBufferSchema;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
protected async executeQuery(
|
|
57
|
+
params: z.infer<typeof inscribeFromBufferSchema>,
|
|
58
|
+
_runManager?: CallbackManagerForToolRun
|
|
59
|
+
): Promise<unknown> {
|
|
60
|
+
const buffer = Buffer.from(params.base64Data, 'base64');
|
|
61
|
+
|
|
62
|
+
const options: InscriptionOptions = {
|
|
63
|
+
mode: params.mode,
|
|
64
|
+
metadata: params.metadata,
|
|
65
|
+
tags: params.tags,
|
|
66
|
+
chunkSize: params.chunkSize,
|
|
67
|
+
waitForConfirmation: params.waitForConfirmation ?? true,
|
|
68
|
+
waitMaxAttempts: 10,
|
|
69
|
+
waitIntervalMs: 3000,
|
|
70
|
+
apiKey: params.apiKey,
|
|
71
|
+
network: this.inscriberBuilder['hederaKit'].client.network.toString().includes('mainnet') ? 'mainnet' : 'testnet',
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
76
|
+
setTimeout(() => reject(new Error('Inscription timed out after 30 seconds')), 30000);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const result = await Promise.race([
|
|
80
|
+
this.inscriberBuilder.inscribe(
|
|
81
|
+
{
|
|
82
|
+
type: 'buffer',
|
|
83
|
+
buffer,
|
|
84
|
+
fileName: params.fileName,
|
|
85
|
+
mimeType: params.mimeType,
|
|
86
|
+
},
|
|
87
|
+
options
|
|
88
|
+
),
|
|
89
|
+
timeoutPromise
|
|
90
|
+
]) as any;
|
|
91
|
+
|
|
92
|
+
if (result.confirmed) {
|
|
93
|
+
const topicId = result.inscription?.topic_id || result.result.topicId;
|
|
94
|
+
const network = options.network || 'testnet';
|
|
95
|
+
const cdnUrl = topicId ? `https://kiloscribe.com/api/inscription-cdn/${topicId}?network=${network}` : null;
|
|
96
|
+
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.`;
|
|
97
|
+
} else {
|
|
98
|
+
return `Successfully submitted inscription to the Hedera network!\n\nTransaction ID: ${result.result.transactionId}\n\nThe inscription is processing and will be confirmed shortly.`;
|
|
99
|
+
}
|
|
100
|
+
} catch (error) {
|
|
101
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to inscribe from buffer';
|
|
102
|
+
throw new Error(`Inscription failed: ${errorMessage}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -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 file
|
|
8
|
+
*/
|
|
9
|
+
const inscribeFromFileSchema = z.object({
|
|
10
|
+
filePath: z.string().describe('The file path 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 file
|
|
42
|
+
*/
|
|
43
|
+
export class InscribeFromFileTool extends BaseInscriberQueryTool<typeof inscribeFromFileSchema> {
|
|
44
|
+
name = 'inscribeFromFile';
|
|
45
|
+
description = 'Inscribe content from a local file to the Hedera network';
|
|
46
|
+
|
|
47
|
+
get specificInputSchema() {
|
|
48
|
+
return inscribeFromFileSchema;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected async executeQuery(
|
|
52
|
+
params: z.infer<typeof inscribeFromFileSchema>,
|
|
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: 'file', path: params.filePath },
|
|
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 file';
|
|
90
|
+
throw new Error(`Inscription failed: ${errorMessage}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|