@hashgraphonline/standards-agent-kit 0.2.101 → 0.2.103

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