@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.
Files changed (193) hide show
  1. package/dist/cjs/builders/hcs10/hcs10-builder.d.ts +4 -0
  2. package/dist/cjs/builders/hcs2/hcs2-builder.d.ts +50 -0
  3. package/dist/cjs/builders/hcs2/index.d.ts +1 -0
  4. package/dist/cjs/builders/index.d.ts +2 -0
  5. package/dist/cjs/builders/inscriber/index.d.ts +1 -0
  6. package/dist/cjs/builders/inscriber/inscriber-builder.d.ts +46 -0
  7. package/dist/cjs/index.d.ts +1 -1
  8. package/dist/cjs/standards-agent-kit.cjs +1 -1
  9. package/dist/cjs/standards-agent-kit.cjs.map +1 -1
  10. package/dist/cjs/tools/hcs10/FindRegistrationsTool.d.ts +4 -4
  11. package/dist/cjs/tools/hcs10/RegisterAgentTool.d.ts +24 -8
  12. package/dist/cjs/tools/hcs10/index.d.ts +1 -0
  13. package/dist/cjs/tools/hcs10/natural-language-mapper.d.ts +19 -0
  14. package/dist/cjs/tools/hcs2/CreateRegistryTool.d.ts +48 -0
  15. package/dist/cjs/tools/hcs2/DeleteEntryTool.d.ts +41 -0
  16. package/dist/cjs/tools/hcs2/MigrateRegistryTool.d.ts +47 -0
  17. package/dist/cjs/tools/hcs2/QueryRegistryTool.d.ts +47 -0
  18. package/dist/cjs/tools/hcs2/RegisterEntryTool.d.ts +47 -0
  19. package/dist/cjs/tools/hcs2/UpdateEntryTool.d.ts +53 -0
  20. package/dist/cjs/tools/hcs2/base-hcs2-tools.d.ts +28 -0
  21. package/dist/cjs/tools/hcs2/hcs2-tool-params.d.ts +18 -0
  22. package/dist/cjs/tools/hcs2/index.d.ts +8 -0
  23. package/dist/cjs/tools/index.d.ts +2 -0
  24. package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +77 -0
  25. package/dist/cjs/tools/inscriber/InscribeFromFileTool.d.ts +65 -0
  26. package/dist/cjs/tools/inscriber/InscribeFromUrlTool.d.ts +65 -0
  27. package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +125 -0
  28. package/dist/cjs/tools/inscriber/RetrieveInscriptionTool.d.ts +35 -0
  29. package/dist/cjs/tools/inscriber/base-inscriber-tools.d.ts +28 -0
  30. package/dist/cjs/tools/inscriber/index.d.ts +7 -0
  31. package/dist/cjs/tools/inscriber/inscriber-tool-params.d.ts +18 -0
  32. package/dist/es/builders/hcs10/hcs10-builder.d.ts +4 -0
  33. package/dist/es/builders/hcs2/hcs2-builder.d.ts +50 -0
  34. package/dist/es/builders/hcs2/index.d.ts +1 -0
  35. package/dist/es/builders/index.d.ts +2 -0
  36. package/dist/es/builders/inscriber/index.d.ts +1 -0
  37. package/dist/es/builders/inscriber/inscriber-builder.d.ts +46 -0
  38. package/dist/es/index.d.ts +1 -1
  39. package/dist/es/standards-agent-kit.es.js +50 -16
  40. package/dist/es/standards-agent-kit.es.js.map +1 -1
  41. package/dist/es/standards-agent-kit.es10.js +17 -23
  42. package/dist/es/standards-agent-kit.es10.js.map +1 -1
  43. package/dist/es/standards-agent-kit.es11.js +36 -58
  44. package/dist/es/standards-agent-kit.es11.js.map +1 -1
  45. package/dist/es/standards-agent-kit.es12.js +43 -18
  46. package/dist/es/standards-agent-kit.es12.js.map +1 -1
  47. package/dist/es/standards-agent-kit.es13.js +53 -16
  48. package/dist/es/standards-agent-kit.es13.js.map +1 -1
  49. package/dist/es/standards-agent-kit.es14.js +18 -28
  50. package/dist/es/standards-agent-kit.es14.js.map +1 -1
  51. package/dist/es/standards-agent-kit.es15.js +26 -12
  52. package/dist/es/standards-agent-kit.es15.js.map +1 -1
  53. package/dist/es/standards-agent-kit.es16.js +37 -241
  54. package/dist/es/standards-agent-kit.es16.js.map +1 -1
  55. package/dist/es/standards-agent-kit.es17.js +16 -136
  56. package/dist/es/standards-agent-kit.es17.js.map +1 -1
  57. package/dist/es/standards-agent-kit.es18.js +154 -27
  58. package/dist/es/standards-agent-kit.es18.js.map +1 -1
  59. package/dist/es/standards-agent-kit.es19.js +26 -22
  60. package/dist/es/standards-agent-kit.es19.js.map +1 -1
  61. package/dist/es/standards-agent-kit.es2.js +27 -13
  62. package/dist/es/standards-agent-kit.es2.js.map +1 -1
  63. package/dist/es/standards-agent-kit.es20.js +42 -3
  64. package/dist/es/standards-agent-kit.es20.js.map +1 -1
  65. package/dist/es/standards-agent-kit.es21.js +48 -0
  66. package/dist/es/standards-agent-kit.es21.js.map +1 -0
  67. package/dist/es/standards-agent-kit.es22.js +51 -0
  68. package/dist/es/standards-agent-kit.es22.js.map +1 -0
  69. package/dist/es/standards-agent-kit.es23.js +45 -0
  70. package/dist/es/standards-agent-kit.es23.js.map +1 -0
  71. package/dist/es/standards-agent-kit.es24.js +48 -0
  72. package/dist/es/standards-agent-kit.es24.js.map +1 -0
  73. package/dist/es/standards-agent-kit.es25.js +45 -0
  74. package/dist/es/standards-agent-kit.es25.js.map +1 -0
  75. package/dist/es/standards-agent-kit.es26.js +32 -0
  76. package/dist/es/standards-agent-kit.es26.js.map +1 -0
  77. package/dist/es/standards-agent-kit.es27.js +71 -0
  78. package/dist/es/standards-agent-kit.es27.js.map +1 -0
  79. package/dist/es/standards-agent-kit.es28.js +71 -0
  80. package/dist/es/standards-agent-kit.es28.js.map +1 -0
  81. package/dist/es/standards-agent-kit.es29.js +79 -0
  82. package/dist/es/standards-agent-kit.es29.js.map +1 -0
  83. package/dist/es/standards-agent-kit.es3.js +59 -296
  84. package/dist/es/standards-agent-kit.es3.js.map +1 -1
  85. package/dist/es/standards-agent-kit.es30.js +90 -0
  86. package/dist/es/standards-agent-kit.es30.js.map +1 -0
  87. package/dist/es/standards-agent-kit.es31.js +45 -0
  88. package/dist/es/standards-agent-kit.es31.js.map +1 -0
  89. package/dist/es/standards-agent-kit.es32.js +249 -0
  90. package/dist/es/standards-agent-kit.es32.js.map +1 -0
  91. package/dist/es/standards-agent-kit.es33.js +141 -0
  92. package/dist/es/standards-agent-kit.es33.js.map +1 -0
  93. package/dist/es/standards-agent-kit.es34.js +33 -0
  94. package/dist/es/standards-agent-kit.es34.js.map +1 -0
  95. package/dist/es/standards-agent-kit.es35.js +28 -0
  96. package/dist/es/standards-agent-kit.es35.js.map +1 -0
  97. package/dist/es/standards-agent-kit.es36.js +7 -0
  98. package/dist/es/standards-agent-kit.es36.js.map +1 -0
  99. package/dist/es/standards-agent-kit.es4.js +44 -20
  100. package/dist/es/standards-agent-kit.es4.js.map +1 -1
  101. package/dist/es/standards-agent-kit.es5.js +312 -121
  102. package/dist/es/standards-agent-kit.es5.js.map +1 -1
  103. package/dist/es/standards-agent-kit.es6.js +24 -23
  104. package/dist/es/standards-agent-kit.es6.js.map +1 -1
  105. package/dist/es/standards-agent-kit.es7.js +220 -20
  106. package/dist/es/standards-agent-kit.es7.js.map +1 -1
  107. package/dist/es/standards-agent-kit.es8.js +20 -29
  108. package/dist/es/standards-agent-kit.es8.js.map +1 -1
  109. package/dist/es/standards-agent-kit.es9.js +26 -36
  110. package/dist/es/standards-agent-kit.es9.js.map +1 -1
  111. package/dist/es/tools/hcs10/FindRegistrationsTool.d.ts +4 -4
  112. package/dist/es/tools/hcs10/RegisterAgentTool.d.ts +24 -8
  113. package/dist/es/tools/hcs10/index.d.ts +1 -0
  114. package/dist/es/tools/hcs10/natural-language-mapper.d.ts +19 -0
  115. package/dist/es/tools/hcs2/CreateRegistryTool.d.ts +48 -0
  116. package/dist/es/tools/hcs2/DeleteEntryTool.d.ts +41 -0
  117. package/dist/es/tools/hcs2/MigrateRegistryTool.d.ts +47 -0
  118. package/dist/es/tools/hcs2/QueryRegistryTool.d.ts +47 -0
  119. package/dist/es/tools/hcs2/RegisterEntryTool.d.ts +47 -0
  120. package/dist/es/tools/hcs2/UpdateEntryTool.d.ts +53 -0
  121. package/dist/es/tools/hcs2/base-hcs2-tools.d.ts +28 -0
  122. package/dist/es/tools/hcs2/hcs2-tool-params.d.ts +18 -0
  123. package/dist/es/tools/hcs2/index.d.ts +8 -0
  124. package/dist/es/tools/index.d.ts +2 -0
  125. package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +77 -0
  126. package/dist/es/tools/inscriber/InscribeFromFileTool.d.ts +65 -0
  127. package/dist/es/tools/inscriber/InscribeFromUrlTool.d.ts +65 -0
  128. package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +125 -0
  129. package/dist/es/tools/inscriber/RetrieveInscriptionTool.d.ts +35 -0
  130. package/dist/es/tools/inscriber/base-inscriber-tools.d.ts +28 -0
  131. package/dist/es/tools/inscriber/index.d.ts +7 -0
  132. package/dist/es/tools/inscriber/inscriber-tool-params.d.ts +18 -0
  133. package/dist/umd/builders/hcs10/hcs10-builder.d.ts +4 -0
  134. package/dist/umd/builders/hcs2/hcs2-builder.d.ts +50 -0
  135. package/dist/umd/builders/hcs2/index.d.ts +1 -0
  136. package/dist/umd/builders/index.d.ts +2 -0
  137. package/dist/umd/builders/inscriber/index.d.ts +1 -0
  138. package/dist/umd/builders/inscriber/inscriber-builder.d.ts +46 -0
  139. package/dist/umd/index.d.ts +1 -1
  140. package/dist/umd/standards-agent-kit.umd.js +1 -1
  141. package/dist/umd/standards-agent-kit.umd.js.map +1 -1
  142. package/dist/umd/tools/hcs10/FindRegistrationsTool.d.ts +4 -4
  143. package/dist/umd/tools/hcs10/RegisterAgentTool.d.ts +24 -8
  144. package/dist/umd/tools/hcs10/index.d.ts +1 -0
  145. package/dist/umd/tools/hcs10/natural-language-mapper.d.ts +19 -0
  146. package/dist/umd/tools/hcs2/CreateRegistryTool.d.ts +48 -0
  147. package/dist/umd/tools/hcs2/DeleteEntryTool.d.ts +41 -0
  148. package/dist/umd/tools/hcs2/MigrateRegistryTool.d.ts +47 -0
  149. package/dist/umd/tools/hcs2/QueryRegistryTool.d.ts +47 -0
  150. package/dist/umd/tools/hcs2/RegisterEntryTool.d.ts +47 -0
  151. package/dist/umd/tools/hcs2/UpdateEntryTool.d.ts +53 -0
  152. package/dist/umd/tools/hcs2/base-hcs2-tools.d.ts +28 -0
  153. package/dist/umd/tools/hcs2/hcs2-tool-params.d.ts +18 -0
  154. package/dist/umd/tools/hcs2/index.d.ts +8 -0
  155. package/dist/umd/tools/index.d.ts +2 -0
  156. package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +77 -0
  157. package/dist/umd/tools/inscriber/InscribeFromFileTool.d.ts +65 -0
  158. package/dist/umd/tools/inscriber/InscribeFromUrlTool.d.ts +65 -0
  159. package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +125 -0
  160. package/dist/umd/tools/inscriber/RetrieveInscriptionTool.d.ts +35 -0
  161. package/dist/umd/tools/inscriber/base-inscriber-tools.d.ts +28 -0
  162. package/dist/umd/tools/inscriber/index.d.ts +7 -0
  163. package/dist/umd/tools/inscriber/inscriber-tool-params.d.ts +18 -0
  164. package/package.json +32 -30
  165. package/src/builders/hcs10/hcs10-builder.ts +37 -16
  166. package/src/builders/hcs2/hcs2-builder.ts +148 -0
  167. package/src/builders/hcs2/index.ts +1 -0
  168. package/src/builders/index.ts +3 -1
  169. package/src/builders/inscriber/index.ts +1 -0
  170. package/src/builders/inscriber/inscriber-builder.ts +112 -0
  171. package/src/index.ts +1 -1
  172. package/src/tools/hcs10/FindRegistrationsTool.ts +19 -4
  173. package/src/tools/hcs10/RegisterAgentTool.ts +147 -9
  174. package/src/tools/hcs10/index.ts +2 -1
  175. package/src/tools/hcs10/natural-language-mapper.ts +194 -0
  176. package/src/tools/hcs2/CreateRegistryTool.ts +63 -0
  177. package/src/tools/hcs2/DeleteEntryTool.ts +58 -0
  178. package/src/tools/hcs2/MigrateRegistryTool.ts +64 -0
  179. package/src/tools/hcs2/QueryRegistryTool.ts +70 -0
  180. package/src/tools/hcs2/RegisterEntryTool.ts +63 -0
  181. package/src/tools/hcs2/UpdateEntryTool.ts +68 -0
  182. package/src/tools/hcs2/base-hcs2-tools.ts +65 -0
  183. package/src/tools/hcs2/hcs2-tool-params.ts +21 -0
  184. package/src/tools/hcs2/index.ts +8 -0
  185. package/src/tools/index.ts +3 -2
  186. package/src/tools/inscriber/InscribeFromBufferTool.ts +105 -0
  187. package/src/tools/inscriber/InscribeFromFileTool.ts +93 -0
  188. package/src/tools/inscriber/InscribeFromUrlTool.ts +93 -0
  189. package/src/tools/inscriber/InscribeHashinalTool.ts +117 -0
  190. package/src/tools/inscriber/RetrieveInscriptionTool.ts +59 -0
  191. package/src/tools/inscriber/base-inscriber-tools.ts +65 -0
  192. package/src/tools/inscriber/index.ts +7 -0
  193. 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';
@@ -1,2 +1,3 @@
1
- // Export all HCS10 tools from the subdirectory
2
- export * from './hcs10';
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
+ }