@hashgraphonline/standards-agent-kit 0.2.137 → 0.2.138

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 (195) hide show
  1. package/dist/cjs/builders/hcs10/hcs10-builder.d.ts +1 -0
  2. package/dist/cjs/builders/hcs2/hcs2-builder.d.ts +8 -7
  3. package/dist/cjs/builders/hcs6/hcs6-builder.d.ts +5 -4
  4. package/dist/cjs/index.d.ts +4 -0
  5. package/dist/cjs/signing/bytes-registry.d.ts +17 -0
  6. package/dist/cjs/signing/signer-provider.d.ts +45 -0
  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/InitiateConnectionTool.d.ts +4 -4
  10. package/dist/cjs/tools/hcs2/CreateRegistryTool.d.ts +2 -2
  11. package/dist/cjs/tools/hcs2/DeleteEntryTool.d.ts +2 -2
  12. package/dist/cjs/tools/hcs2/UpdateEntryTool.d.ts +2 -2
  13. package/dist/cjs/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
  14. package/dist/cjs/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
  15. package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
  16. package/dist/cjs/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
  17. package/dist/cjs/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
  18. package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +1 -1
  19. package/dist/cjs/types/tx-results.d.ts +15 -0
  20. package/dist/cjs/utils/CodedError.d.ts +4 -0
  21. package/dist/cjs/validation/hip412-schemas.d.ts +2 -2
  22. package/dist/es/builders/hcs10/hcs10-builder.d.ts +1 -0
  23. package/dist/es/builders/hcs2/hcs2-builder.d.ts +8 -7
  24. package/dist/es/builders/hcs6/hcs6-builder.d.ts +5 -4
  25. package/dist/es/index.d.ts +4 -0
  26. package/dist/es/signing/bytes-registry.d.ts +17 -0
  27. package/dist/es/signing/signer-provider.d.ts +45 -0
  28. package/dist/es/standards-agent-kit.es.js +46 -42
  29. package/dist/es/standards-agent-kit.es.js.map +1 -1
  30. package/dist/es/standards-agent-kit.es10.js +24 -83
  31. package/dist/es/standards-agent-kit.es10.js.map +1 -1
  32. package/dist/es/standards-agent-kit.es11.js +224 -20
  33. package/dist/es/standards-agent-kit.es11.js.map +1 -1
  34. package/dist/es/standards-agent-kit.es12.js +78 -27
  35. package/dist/es/standards-agent-kit.es12.js.map +1 -1
  36. package/dist/es/standards-agent-kit.es13.js +26 -36
  37. package/dist/es/standards-agent-kit.es13.js.map +1 -1
  38. package/dist/es/standards-agent-kit.es14.js +17 -39
  39. package/dist/es/standards-agent-kit.es14.js.map +1 -1
  40. package/dist/es/standards-agent-kit.es15.js +36 -58
  41. package/dist/es/standards-agent-kit.es15.js.map +1 -1
  42. package/dist/es/standards-agent-kit.es16.js +45 -18
  43. package/dist/es/standards-agent-kit.es16.js.map +1 -1
  44. package/dist/es/standards-agent-kit.es17.js +53 -16
  45. package/dist/es/standards-agent-kit.es17.js.map +1 -1
  46. package/dist/es/standards-agent-kit.es18.js +18 -28
  47. package/dist/es/standards-agent-kit.es18.js.map +1 -1
  48. package/dist/es/standards-agent-kit.es19.js +26 -12
  49. package/dist/es/standards-agent-kit.es19.js.map +1 -1
  50. package/dist/es/standards-agent-kit.es20.js +38 -136
  51. package/dist/es/standards-agent-kit.es20.js.map +1 -1
  52. package/dist/es/standards-agent-kit.es21.js +13 -24
  53. package/dist/es/standards-agent-kit.es21.js.map +1 -1
  54. package/dist/es/standards-agent-kit.es22.js +136 -39
  55. package/dist/es/standards-agent-kit.es22.js.map +1 -1
  56. package/dist/es/standards-agent-kit.es23.js +25 -41
  57. package/dist/es/standards-agent-kit.es23.js.map +1 -1
  58. package/dist/es/standards-agent-kit.es24.js +49 -31
  59. package/dist/es/standards-agent-kit.es24.js.map +1 -1
  60. package/dist/es/standards-agent-kit.es25.js +34 -18
  61. package/dist/es/standards-agent-kit.es25.js.map +1 -1
  62. package/dist/es/standards-agent-kit.es26.js +35 -19
  63. package/dist/es/standards-agent-kit.es26.js.map +1 -1
  64. package/dist/es/standards-agent-kit.es27.js +45 -32
  65. package/dist/es/standards-agent-kit.es27.js.map +1 -1
  66. package/dist/es/standards-agent-kit.es28.js +54 -25
  67. package/dist/es/standards-agent-kit.es28.js.map +1 -1
  68. package/dist/es/standards-agent-kit.es29.js +35 -23
  69. package/dist/es/standards-agent-kit.es29.js.map +1 -1
  70. package/dist/es/standards-agent-kit.es3.js +41 -1549
  71. package/dist/es/standards-agent-kit.es3.js.map +1 -1
  72. package/dist/es/standards-agent-kit.es30.js +23 -39
  73. package/dist/es/standards-agent-kit.es30.js.map +1 -1
  74. package/dist/es/standards-agent-kit.es31.js +30 -28
  75. package/dist/es/standards-agent-kit.es31.js.map +1 -1
  76. package/dist/es/standards-agent-kit.es32.js +45 -32
  77. package/dist/es/standards-agent-kit.es32.js.map +1 -1
  78. package/dist/es/standards-agent-kit.es33.js +50 -89
  79. package/dist/es/standards-agent-kit.es33.js.map +1 -1
  80. package/dist/es/standards-agent-kit.es34.js +35 -234
  81. package/dist/es/standards-agent-kit.es34.js.map +1 -1
  82. package/dist/es/standards-agent-kit.es35.js +87 -213
  83. package/dist/es/standards-agent-kit.es35.js.map +1 -1
  84. package/dist/es/standards-agent-kit.es36.js +185 -129
  85. package/dist/es/standards-agent-kit.es36.js.map +1 -1
  86. package/dist/es/standards-agent-kit.es37.js +167 -563
  87. package/dist/es/standards-agent-kit.es37.js.map +1 -1
  88. package/dist/es/standards-agent-kit.es38.js +236 -30
  89. package/dist/es/standards-agent-kit.es38.js.map +1 -1
  90. package/dist/es/standards-agent-kit.es39.js +483 -206
  91. package/dist/es/standards-agent-kit.es39.js.map +1 -1
  92. package/dist/es/standards-agent-kit.es4.js +359 -81
  93. package/dist/es/standards-agent-kit.es4.js.map +1 -1
  94. package/dist/es/standards-agent-kit.es40.js +39 -135
  95. package/dist/es/standards-agent-kit.es40.js.map +1 -1
  96. package/dist/es/standards-agent-kit.es41.js +244 -28
  97. package/dist/es/standards-agent-kit.es41.js.map +1 -1
  98. package/dist/es/standards-agent-kit.es42.js +132 -418
  99. package/dist/es/standards-agent-kit.es42.js.map +1 -1
  100. package/dist/es/standards-agent-kit.es43.js +28 -184
  101. package/dist/es/standards-agent-kit.es43.js.map +1 -1
  102. package/dist/es/standards-agent-kit.es44.js +423 -3
  103. package/dist/es/standards-agent-kit.es44.js.map +1 -1
  104. package/dist/es/standards-agent-kit.es45.js +185 -24
  105. package/dist/es/standards-agent-kit.es45.js.map +1 -1
  106. package/dist/es/standards-agent-kit.es46.js +3 -3
  107. package/dist/es/standards-agent-kit.es46.js.map +1 -1
  108. package/dist/es/standards-agent-kit.es47.js +24 -20
  109. package/dist/es/standards-agent-kit.es47.js.map +1 -1
  110. package/dist/es/standards-agent-kit.es48.js +6 -52
  111. package/dist/es/standards-agent-kit.es48.js.map +1 -1
  112. package/dist/es/standards-agent-kit.es49.js +4 -3
  113. package/dist/es/standards-agent-kit.es49.js.map +1 -1
  114. package/dist/es/standards-agent-kit.es5.js +1747 -73
  115. package/dist/es/standards-agent-kit.es5.js.map +1 -1
  116. package/dist/es/standards-agent-kit.es50.js +20 -39
  117. package/dist/es/standards-agent-kit.es50.js.map +1 -1
  118. package/dist/es/standards-agent-kit.es51.js +50 -15
  119. package/dist/es/standards-agent-kit.es51.js.map +1 -1
  120. package/dist/es/standards-agent-kit.es52.js +3 -74
  121. package/dist/es/standards-agent-kit.es52.js.map +1 -1
  122. package/dist/es/standards-agent-kit.es53.js +43 -0
  123. package/dist/es/standards-agent-kit.es53.js.map +1 -0
  124. package/dist/es/standards-agent-kit.es54.js +22 -0
  125. package/dist/es/standards-agent-kit.es54.js.map +1 -0
  126. package/dist/es/standards-agent-kit.es55.js +77 -0
  127. package/dist/es/standards-agent-kit.es55.js.map +1 -0
  128. package/dist/es/standards-agent-kit.es56.js +7 -0
  129. package/dist/es/standards-agent-kit.es56.js.map +1 -0
  130. package/dist/es/standards-agent-kit.es6.js +332 -173
  131. package/dist/es/standards-agent-kit.es6.js.map +1 -1
  132. package/dist/es/standards-agent-kit.es7.js +142 -293
  133. package/dist/es/standards-agent-kit.es7.js.map +1 -1
  134. package/dist/es/standards-agent-kit.es8.js +201 -21
  135. package/dist/es/standards-agent-kit.es8.js.map +1 -1
  136. package/dist/es/standards-agent-kit.es9.js +301 -213
  137. package/dist/es/standards-agent-kit.es9.js.map +1 -1
  138. package/dist/es/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
  139. package/dist/es/tools/hcs2/CreateRegistryTool.d.ts +2 -2
  140. package/dist/es/tools/hcs2/DeleteEntryTool.d.ts +2 -2
  141. package/dist/es/tools/hcs2/UpdateEntryTool.d.ts +2 -2
  142. package/dist/es/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
  143. package/dist/es/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
  144. package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
  145. package/dist/es/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
  146. package/dist/es/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
  147. package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +1 -1
  148. package/dist/es/types/tx-results.d.ts +15 -0
  149. package/dist/es/utils/CodedError.d.ts +4 -0
  150. package/dist/es/validation/hip412-schemas.d.ts +2 -2
  151. package/dist/umd/builders/hcs10/hcs10-builder.d.ts +1 -0
  152. package/dist/umd/builders/hcs2/hcs2-builder.d.ts +8 -7
  153. package/dist/umd/builders/hcs6/hcs6-builder.d.ts +5 -4
  154. package/dist/umd/index.d.ts +4 -0
  155. package/dist/umd/signing/bytes-registry.d.ts +17 -0
  156. package/dist/umd/signing/signer-provider.d.ts +45 -0
  157. package/dist/umd/standards-agent-kit.umd.js +1 -1
  158. package/dist/umd/standards-agent-kit.umd.js.map +1 -1
  159. package/dist/umd/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
  160. package/dist/umd/tools/hcs2/CreateRegistryTool.d.ts +2 -2
  161. package/dist/umd/tools/hcs2/DeleteEntryTool.d.ts +2 -2
  162. package/dist/umd/tools/hcs2/UpdateEntryTool.d.ts +2 -2
  163. package/dist/umd/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
  164. package/dist/umd/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
  165. package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
  166. package/dist/umd/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
  167. package/dist/umd/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
  168. package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +1 -1
  169. package/dist/umd/types/tx-results.d.ts +15 -0
  170. package/dist/umd/utils/CodedError.d.ts +4 -0
  171. package/dist/umd/validation/hip412-schemas.d.ts +2 -2
  172. package/package.json +3 -3
  173. package/src/builders/hcs10/hcs10-builder.ts +239 -10
  174. package/src/builders/hcs2/hcs2-builder.ts +302 -9
  175. package/src/builders/hcs6/hcs6-builder.ts +79 -4
  176. package/src/hcs10/HCS10Client.ts +1 -1
  177. package/src/index.ts +5 -1
  178. package/src/lib/zod-render/schema-extension.ts +0 -1
  179. package/src/signing/bytes-registry.ts +501 -0
  180. package/src/signing/signer-provider.ts +120 -0
  181. package/src/tools/hcs2/CreateRegistryTool.ts +30 -5
  182. package/src/tools/hcs2/DeleteEntryTool.ts +16 -2
  183. package/src/tools/hcs2/MigrateRegistryTool.ts +16 -2
  184. package/src/tools/hcs2/QueryRegistryTool.ts +11 -2
  185. package/src/tools/hcs2/RegisterEntryTool.ts +17 -3
  186. package/src/tools/hcs2/UpdateEntryTool.ts +16 -2
  187. package/src/tools/hcs6/CreateDynamicRegistryTool.ts +17 -3
  188. package/src/tools/hcs6/RegisterDynamicHashinalTool.ts +17 -3
  189. package/src/tools/hcs6/UpdateDynamicHashinalTool.ts +17 -3
  190. package/src/tools/inscriber/InscribeFromBufferTool.ts +78 -2
  191. package/src/tools/inscriber/InscribeHashinalTool.ts +22 -131
  192. package/src/types/tx-results.ts +18 -0
  193. package/src/utils/CodedError.ts +8 -0
  194. package/src/utils/Encryption.ts +0 -2
  195. package/src/utils/ensure-agent-has-hbar.ts +4 -5
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseHCS2QueryTool } from './base-hcs2-tools';
3
3
  import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
4
+ import { isWalletBytesResponse, type RegistryOperationResult } from '../../types/tx-results';
4
5
 
5
6
  /**
6
7
  * Schema for deleting an entry from HCS-2
@@ -37,7 +38,7 @@ export class DeleteEntryTool extends BaseHCS2QueryTool<typeof deleteEntrySchema>
37
38
  _runManager?: CallbackManagerForToolRun
38
39
  ): Promise<unknown> {
39
40
  try {
40
- const result = await this.hcs2Builder.deleteEntry(
41
+ const result: RegistryOperationResult = await this.hcs2Builder.deleteEntry(
41
42
  params.registryTopicId,
42
43
  {
43
44
  uid: params.uid,
@@ -45,10 +46,23 @@ export class DeleteEntryTool extends BaseHCS2QueryTool<typeof deleteEntrySchema>
45
46
  }
46
47
  );
47
48
 
48
- if (!result.success) {
49
+ if (!('success' in result) || !result.success) {
49
50
  throw new Error(result.error || 'Failed to delete entry');
50
51
  }
51
52
 
53
+ if (isWalletBytesResponse(result)) {
54
+ const txBytes = result.transactionBytes;
55
+ return {
56
+ message: 'I prepared an unsigned transaction to delete the HCS-2 registry entry. Please review and approve to submit.',
57
+ transactionBytes: txBytes,
58
+ metadata: {
59
+ transactionBytes: txBytes,
60
+ pendingApproval: true,
61
+ description: `Delete HCS-2 entry (registry ${params.registryTopicId}, uid ${params.uid})`,
62
+ },
63
+ };
64
+ }
65
+
52
66
  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
67
  } catch (error) {
54
68
  const errorMessage = error instanceof Error ? error.message : 'Failed to delete entry';
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseHCS2QueryTool } from './base-hcs2-tools';
3
3
  import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
4
+ import { isWalletBytesResponse, type RegistryOperationResult } from '../../types/tx-results';
4
5
 
5
6
  /**
6
7
  * Schema for migrating an HCS-2 registry
@@ -42,7 +43,7 @@ export class MigrateRegistryTool extends BaseHCS2QueryTool<typeof migrateRegistr
42
43
  _runManager?: CallbackManagerForToolRun
43
44
  ): Promise<unknown> {
44
45
  try {
45
- const result = await this.hcs2Builder.migrateRegistry(
46
+ const result: RegistryOperationResult = await this.hcs2Builder.migrateRegistry(
46
47
  params.registryTopicId,
47
48
  {
48
49
  targetTopicId: params.targetTopicId,
@@ -51,10 +52,23 @@ export class MigrateRegistryTool extends BaseHCS2QueryTool<typeof migrateRegistr
51
52
  }
52
53
  );
53
54
 
54
- if (!result.success) {
55
+ if (!('success' in result) || !result.success) {
55
56
  throw new Error(result.error || 'Failed to migrate registry');
56
57
  }
57
58
 
59
+ if (isWalletBytesResponse(result)) {
60
+ const txBytes = result.transactionBytes;
61
+ return {
62
+ message: 'I prepared an unsigned transaction to migrate the HCS-2 registry. Please review and approve to submit.',
63
+ transactionBytes: txBytes,
64
+ metadata: {
65
+ transactionBytes: txBytes,
66
+ pendingApproval: true,
67
+ description: `Migrate HCS-2 registry (from ${params.registryTopicId} to ${params.targetTopicId})`,
68
+ },
69
+ };
70
+ }
71
+
58
72
  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
73
  } catch (error) {
60
74
  const errorMessage = error instanceof Error ? error.message : 'Failed to migrate registry';
@@ -34,7 +34,7 @@ const queryRegistrySchema = z.object({
34
34
  */
35
35
  export class QueryRegistryTool extends BaseHCS2QueryTool<typeof queryRegistrySchema> {
36
36
  name = 'queryHCS2Registry';
37
- description = 'Query entries from an HCS-2 registry';
37
+ description = 'Query entries from an HCS-2 registry (standard HCS-2). Retrieves indexed or latest entries and returns a structured summary.'
38
38
 
39
39
  get specificInputSchema() {
40
40
  return queryRegistrySchema;
@@ -50,9 +50,18 @@ export class QueryRegistryTool extends BaseHCS2QueryTool<typeof queryRegistrySch
50
50
  skip: params.skip,
51
51
  });
52
52
 
53
+ const typeVal = (registry as unknown as { registryType: unknown }).registryType;
54
+ const isIndexed =
55
+ typeVal === 0 ||
56
+ typeVal === '0' ||
57
+ String(typeVal).toLowerCase() === 'indexed' ||
58
+ String(typeVal).toLowerCase() === 'index' ||
59
+ String(typeVal).toLowerCase() === 'index_topic' ||
60
+ String(typeVal).toLowerCase() === 'indexed_registry';
61
+
53
62
  return {
54
63
  topicId: registry.topicId,
55
- registryType: registry.registryType === 0 ? 'indexed' : 'non-indexed',
64
+ registryType: isIndexed ? 'indexed' : 'non-indexed',
56
65
  ttl: registry.ttl,
57
66
  totalEntries: registry.entries.length,
58
67
  entries: registry.entries.map(entry => ({
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseHCS2QueryTool } from './base-hcs2-tools';
3
3
  import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
4
+ import { isWalletBytesResponse, type RegistryOperationResult } from '../../types/tx-results';
4
5
 
5
6
  /**
6
7
  * Schema for registering an entry in HCS-2
@@ -30,7 +31,7 @@ const registerEntrySchema = z.object({
30
31
  */
31
32
  export class RegisterEntryTool extends BaseHCS2QueryTool<typeof registerEntrySchema> {
32
33
  name = 'registerHCS2Entry';
33
- description = 'Register a new entry in an HCS-2 registry';
34
+ description = 'Register an entry in an HCS-2 registry (standard HCS-2). Use this to add a target topic to an existing HCS-2 registry.'
34
35
 
35
36
  get specificInputSchema(): typeof registerEntrySchema {
36
37
  return registerEntrySchema;
@@ -41,7 +42,7 @@ export class RegisterEntryTool extends BaseHCS2QueryTool<typeof registerEntrySch
41
42
  _runManager?: CallbackManagerForToolRun
42
43
  ): Promise<unknown> {
43
44
  try {
44
- const result = await this.hcs2Builder.registerEntry(
45
+ const result: RegistryOperationResult = await this.hcs2Builder.registerEntry(
45
46
  params.registryTopicId,
46
47
  {
47
48
  targetTopicId: params.targetTopicId,
@@ -50,10 +51,23 @@ export class RegisterEntryTool extends BaseHCS2QueryTool<typeof registerEntrySch
50
51
  }
51
52
  );
52
53
 
53
- if (!result.success) {
54
+ if (!('success' in result) || !result.success) {
54
55
  throw new Error(result.error || 'Failed to register entry');
55
56
  }
56
57
 
58
+ if (isWalletBytesResponse(result)) {
59
+ const txBytes = result.transactionBytes;
60
+ return {
61
+ message: 'I prepared an unsigned transaction to register the entry in the HCS-2 registry. Please review and approve to submit.',
62
+ transactionBytes: txBytes,
63
+ metadata: {
64
+ transactionBytes: txBytes,
65
+ pendingApproval: true,
66
+ description: `Register HCS-2 entry (registry ${params.registryTopicId} -> target ${params.targetTopicId})`,
67
+ },
68
+ };
69
+ }
70
+
57
71
  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
72
  } catch (error) {
59
73
  const errorMessage = error instanceof Error ? error.message : 'Failed to register entry';
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseHCS2QueryTool } from './base-hcs2-tools';
3
3
  import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
4
+ import { isWalletBytesResponse, type RegistryOperationResult } from '../../types/tx-results';
4
5
 
5
6
  /**
6
7
  * Schema for updating an entry in HCS-2
@@ -45,7 +46,7 @@ export class UpdateEntryTool extends BaseHCS2QueryTool<typeof updateEntrySchema>
45
46
  _runManager?: CallbackManagerForToolRun
46
47
  ): Promise<unknown> {
47
48
  try {
48
- const result = await this.hcs2Builder.updateEntry(
49
+ const result: RegistryOperationResult = await this.hcs2Builder.updateEntry(
49
50
  params.registryTopicId,
50
51
  {
51
52
  targetTopicId: params.targetTopicId,
@@ -55,10 +56,23 @@ export class UpdateEntryTool extends BaseHCS2QueryTool<typeof updateEntrySchema>
55
56
  }
56
57
  );
57
58
 
58
- if (!result.success) {
59
+ if (!('success' in result) || !result.success) {
59
60
  throw new Error(result.error || 'Failed to update entry');
60
61
  }
61
62
 
63
+ if (isWalletBytesResponse(result)) {
64
+ const txBytes = result.transactionBytes;
65
+ return {
66
+ message: 'I prepared an unsigned transaction to update the HCS-2 registry entry. Please review and approve to submit.',
67
+ transactionBytes: txBytes,
68
+ metadata: {
69
+ transactionBytes: txBytes,
70
+ pendingApproval: true,
71
+ description: `Update HCS-2 entry (registry ${params.registryTopicId}, uid ${params.uid} -> ${params.targetTopicId})`,
72
+ },
73
+ };
74
+ }
75
+
62
76
  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
77
  } catch (error) {
64
78
  const errorMessage = error instanceof Error ? error.message : 'Failed to update entry';
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseHCS6QueryTool } from './base-hcs6-tools';
3
+ import { isWalletBytesResponse } from '../../types/tx-results';
3
4
  import { HCS6QueryToolParams } from './hcs6-tool-params';
4
5
  import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
5
6
 
@@ -44,10 +45,23 @@ export class CreateDynamicRegistryTool extends BaseHCS6QueryTool<typeof CreateDy
44
45
  submitKey: params.submitKey,
45
46
  });
46
47
 
47
- if (!result.success) {
48
- throw new Error(result.error || 'Failed to create dynamic registry');
48
+ if (!('success' in result) || !result.success) {
49
+ throw new Error((result as any).error || 'Failed to create dynamic registry');
49
50
  }
50
51
 
51
- return `Successfully created HCS-6 dynamic registry!\n\nTopic ID: ${result.topicId}\nTTL: ${params.ttl} seconds\n\nYou can now register dynamic hashinals to this registry using the topic ID.`;
52
+ if (isWalletBytesResponse(result)) {
53
+ const txBytes = result.transactionBytes;
54
+ return {
55
+ message: 'I prepared an unsigned transaction to create your HCS-6 dynamic registry. Please review and approve to submit.',
56
+ transactionBytes: txBytes,
57
+ metadata: {
58
+ transactionBytes: txBytes,
59
+ pendingApproval: true,
60
+ description: `Create HCS-6 dynamic registry (TTL: ${params.ttl}s)`,
61
+ },
62
+ };
63
+ }
64
+
65
+ return `Successfully created HCS-6 dynamic registry!\n\nTopic ID: ${(result as any).topicId}\nTTL: ${params.ttl} seconds\n\nYou can now register dynamic hashinals to this registry using the topic ID.`;
52
66
  }
53
67
  }
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseHCS6QueryTool } from './base-hcs6-tools';
3
+ import { isWalletBytesResponse } from '../../types/tx-results';
3
4
  import { HCS6QueryToolParams } from './hcs6-tool-params';
4
5
  import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
5
6
 
@@ -60,10 +61,23 @@ export class RegisterDynamicHashinalTool extends BaseHCS6QueryTool<typeof Regist
60
61
  submitKey: params.submitKey,
61
62
  });
62
63
 
63
- if (!result.success) {
64
- throw new Error(result.error || 'Failed to register dynamic hashinal');
64
+ if (!('success' in result) || !result.success) {
65
+ throw new Error((result as any).error || 'Failed to register dynamic hashinal');
65
66
  }
66
67
 
67
- return `Successfully registered dynamic hashinal!\n\nRegistry Topic ID: ${result.registryTopicId}\nInscription Topic ID: ${result.inscriptionTopicId}${params.memo ? `\nMemo: ${params.memo}` : ''}\n\nThe dynamic hashinal has been created and can be updated using the registry topic ID.`;
68
+ if (isWalletBytesResponse(result as any)) {
69
+ const txBytes = (result as any).transactionBytes as string;
70
+ return {
71
+ message: 'I prepared an unsigned transaction to register a dynamic hashinal. Please review and approve to submit.',
72
+ transactionBytes: txBytes,
73
+ metadata: {
74
+ transactionBytes: txBytes,
75
+ pendingApproval: true,
76
+ description: `Register dynamic hashinal${params.memo ? ` (Memo: ${params.memo})` : ''}`,
77
+ },
78
+ };
79
+ }
80
+
81
+ return `Successfully registered dynamic hashinal!\n\nRegistry Topic ID: ${(result as any).registryTopicId}\nInscription Topic ID: ${(result as any).inscriptionTopicId}${params.memo ? `\nMemo: ${params.memo}` : ''}\n\nThe dynamic hashinal has been created and can be updated using the registry topic ID.`;
68
82
  }
69
83
  }
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { BaseHCS6QueryTool } from './base-hcs6-tools';
3
+ import { isWalletBytesResponse } from '../../types/tx-results';
3
4
  import { HCS6QueryToolParams } from './hcs6-tool-params';
4
5
  import { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';
5
6
 
@@ -54,10 +55,23 @@ export class UpdateDynamicHashinalTool extends BaseHCS6QueryTool<typeof UpdateDy
54
55
  submitKey: params.submitKey,
55
56
  });
56
57
 
57
- if (!result.success) {
58
- throw new Error(result.error || 'Failed to update dynamic hashinal');
58
+ if (!('success' in result) || !result.success) {
59
+ throw new Error((result as any).error || 'Failed to update dynamic hashinal');
59
60
  }
60
61
 
61
- return `Successfully updated dynamic hashinal!\n\nRegistry Topic ID: ${params.registryTopicId}\nInscription Topic ID: ${result.inscriptionTopicId}${params.memo ? `\nUpdate Memo: ${params.memo}` : ''}\n\nThe dynamic hashinal has been updated with new content.`;
62
+ if (isWalletBytesResponse(result as any)) {
63
+ const txBytes = (result as any).transactionBytes as string;
64
+ return {
65
+ message: 'I prepared an unsigned transaction to update a dynamic hashinal. Please review and approve to submit.',
66
+ transactionBytes: txBytes,
67
+ metadata: {
68
+ transactionBytes: txBytes,
69
+ pendingApproval: true,
70
+ description: `Update dynamic hashinal (registry ${params.registryTopicId})${params.memo ? ` (Memo: ${params.memo})` : ''}`,
71
+ },
72
+ };
73
+ }
74
+
75
+ return `Successfully updated dynamic hashinal!\n\nRegistry Topic ID: ${params.registryTopicId}\nInscription Topic ID: ${(result as any).inscriptionTopicId}${params.memo ? `\nUpdate Memo: ${params.memo}` : ''}\n\nThe dynamic hashinal has been updated with new content.`;
62
76
  }
63
77
  }
@@ -64,19 +64,92 @@ export class InscribeFromBufferTool extends BaseInscriberQueryTool<
64
64
  return inscribeFromBufferSchema;
65
65
  }
66
66
 
67
+ protected override async _call(
68
+ args: z.infer<typeof inscribeFromBufferSchema>,
69
+ _runManager?: CallbackManagerForToolRun
70
+ ): Promise<string> {
71
+ try {
72
+ const input = typeof args.base64Data === 'string' ? args.base64Data : '';
73
+ const buffer = /^[A-Za-z0-9+/]*={0,2}$/.test(input)
74
+ ? Buffer.from(input, 'base64')
75
+ : Buffer.from(input, 'utf8');
76
+
77
+ const fileName = args.fileName;
78
+ const mimeType = args.mimeType;
79
+
80
+ const network = this.inscriberBuilder['hederaKit'].client.network
81
+ .toString()
82
+ .includes('mainnet')
83
+ ? 'mainnet'
84
+ : 'testnet';
85
+
86
+ const options: InscriptionOptions = {
87
+ mode: 'file',
88
+ metadata: args.metadata,
89
+ tags: args.tags,
90
+ chunkSize: args.chunkSize,
91
+ waitForConfirmation: args.quoteOnly ? false : args.waitForConfirmation ?? true,
92
+ waitMaxAttempts: 60,
93
+ waitIntervalMs: 5000,
94
+ apiKey: args.apiKey,
95
+ network,
96
+ quoteOnly: args.quoteOnly,
97
+ };
98
+
99
+ const result = await this.inscriberBuilder.inscribe(
100
+ { type: 'buffer', buffer, fileName, mimeType },
101
+ options
102
+ );
103
+
104
+ const typed = result as InscriptionResponse;
105
+ if (typed.confirmed && !typed.quote) {
106
+ const ids = extractTopicIds(typed.inscription, typed.result);
107
+ const { topicId, cdnUrl } = buildInscriptionLinks(ids, network, '1');
108
+ return JSON.stringify({
109
+ success: true,
110
+ data: `Successfully inscribed and confirmed content on the Hedera network!\n\nTransaction ID: ${
111
+ (typed.result as InscriptionResult)?.transactionId ?? 'unknown'
112
+ }\nTopic ID: ${topicId || 'N/A'}${
113
+ cdnUrl ? `\nView inscription: ${cdnUrl}` : ''
114
+ }\n\nThe inscription is now available.`,
115
+ });
116
+ }
117
+
118
+ return JSON.stringify({
119
+ success: true,
120
+ data: `Successfully submitted inscription to the Hedera network!\n\nTransaction ID: ${
121
+ (typed.result as InscriptionResult)?.transactionId ?? 'unknown'
122
+ }\n\nThe inscription is processing and will be confirmed shortly.`,
123
+ });
124
+ } catch (error) {
125
+ const errorMessage = error instanceof Error ? error.message : String(error);
126
+ return JSON.stringify({ success: false, error: `Inscription failed: ${errorMessage}` });
127
+ }
128
+ }
129
+
67
130
  protected async executeQuery(
68
131
  params: z.infer<typeof inscribeFromBufferSchema>,
69
132
  _runManager?: CallbackManagerForToolRun
70
133
  ): Promise<unknown> {
71
- this.validateInput(params);
72
134
 
73
135
  const resolvedContent = await resolveContent(
74
136
  params.base64Data,
75
137
  params.mimeType,
76
138
  params.fileName
77
139
  );
140
+ console.log('[InscribeFromBufferTool] Resolved content bytes:', resolvedContent.buffer?.length ?? -1);
78
141
 
79
- this.validateContent(resolvedContent.buffer);
142
+ try {
143
+ this.validateContent(resolvedContent.buffer);
144
+ } catch (validationError) {
145
+ this.logger?.warn(
146
+ `Content validation warning: ${
147
+ validationError instanceof Error
148
+ ? validationError.message
149
+ : String(validationError)
150
+ }`
151
+ );
152
+ }
80
153
 
81
154
  const buffer = resolvedContent.buffer;
82
155
  const resolvedMimeType = resolvedContent.mimeType || params.mimeType;
@@ -139,6 +212,7 @@ export class InscribeFromBufferTool extends BaseInscriberQueryTool<
139
212
  }
140
213
 
141
214
  try {
215
+ console.log('[InscribeFromBufferTool] Calling inscribe with fileName:', resolvedFileName, 'mime:', resolvedMimeType);
142
216
  const result = await this.executeInscription(
143
217
  buffer,
144
218
  resolvedFileName,
@@ -146,8 +220,10 @@ export class InscribeFromBufferTool extends BaseInscriberQueryTool<
146
220
  options,
147
221
  params.timeoutMs
148
222
  );
223
+ console.log('[InscribeFromBufferTool] Inscribe result (confirmed):', Boolean((result as any)?.confirmed));
149
224
  return this.formatInscriptionResult(result, options);
150
225
  } catch (error) {
226
+ console.warn('[InscribeFromBufferTool] Error during inscription:', error);
151
227
  const errorMessage =
152
228
  error instanceof Error
153
229
  ? error.message
@@ -51,7 +51,9 @@ const HASHLINK_BLOCK_CONFIG = {
51
51
  * @param network The network type to get configuration for
52
52
  * @returns Network-specific block configuration with blockId, hashLink, and template
53
53
  */
54
- function getHashLinkBlockId(network) {
54
+ function getHashLinkBlockId(
55
+ network: 'mainnet' | 'testnet',
56
+ ): { blockId: string; hashLink: string; template: string } {
55
57
  const config =
56
58
  network === 'mainnet'
57
59
  ? HASHLINK_BLOCK_CONFIG.mainnet
@@ -534,143 +536,41 @@ export class InscribeHashinalTool
534
536
 
535
537
  if (result.confirmed && !result.quote) {
536
538
  const ids = extractTopicIds(result.inscription, result.result);
537
- const network = options.network || 'testnet';
539
+ const network = (options.network || 'testnet') as 'mainnet' | 'testnet';
538
540
  const fileStandard = params.fileStandard || '1';
539
- const { hrl, cdnUrl, topicId } = buildInscriptionLinks(
541
+ const { hrl, topicId, cdnUrl } = buildInscriptionLinks(
540
542
  ids,
541
543
  network,
542
544
  fileStandard
543
545
  );
544
- const standardType = fileStandard === '6' ? 'Dynamic' : 'Static';
545
-
546
- if (!hrl) {
547
- return createInscriptionError({
548
- code: 'MISSING_TOPIC_ID',
549
- details: 'Inscription completed but topic ID is missing',
550
- suggestions: [
551
- 'Try the inscription again',
552
- 'Contact support if the issue persists',
553
- ],
554
- });
555
- }
556
-
557
- const inscriptionResponse = createInscriptionSuccess({
558
- hrl,
546
+
547
+ const txId = (result.result as InscriptionResult)?.transactionId ?? 'unknown';
548
+ return createInscriptionSuccess({
549
+ hrl: hrl || 'hcs://1/unknown',
559
550
  topicId: topicId || 'unknown',
560
- standard: standardType as 'Static' | 'Dynamic',
561
- cdnUrl: cdnUrl || undefined,
562
- transactionId: (result.result as InscriptionResult)?.transactionId,
551
+ standard: fileStandard === '6' ? 'Dynamic' : 'Static',
552
+ cdnUrl,
553
+ transactionId: txId,
563
554
  metadata: {
564
555
  name: params.name,
565
556
  creator: params.creator,
566
557
  description: params.description,
567
558
  type: params.type,
568
- attributes: params.attributes,
559
+ attributes: Array.isArray(params.attributes) ? params.attributes : [],
569
560
  },
570
561
  });
571
-
572
- this.onEntityCreated?.({
573
- entityId: topicId || 'unknown',
574
- entityName: params.name || 'Unnamed Inscription',
575
- entityType: 'topicId',
576
- transactionId: (result.result as InscriptionResult)?.transactionId,
577
- });
578
-
579
- if (params.withHashLinkBlocks) {
580
- try {
581
- const blockData = await this.createHashLinkBlock(
582
- inscriptionResponse,
583
- inscriptionData.type === 'buffer'
584
- ? inscriptionData.mimeType
585
- : undefined
586
- );
587
-
588
- inscriptionResponse.hashLinkBlock = blockData;
589
- } catch (blockError) {
590
- const logger = new Logger({ module: 'InscribeHashinalTool' });
591
- logger.error('Failed to create HashLink block', {
592
- error: blockError,
593
- });
594
- }
595
- }
596
-
597
- return inscriptionResponse;
598
562
  } else if (!result.quote && !result.confirmed) {
599
- const ids = extractTopicIds(result.inscription, result.result);
600
- if (ids.jsonTopicId || ids.topicId) {
601
- const network = options.network || 'testnet';
602
- const fileStandard = params.fileStandard || '1';
603
- const { hrl, cdnUrl, topicId } = buildInscriptionLinks(
604
- ids,
605
- network,
606
- fileStandard
607
- );
608
- const standardType = fileStandard === '6' ? 'Dynamic' : 'Static';
609
-
610
- if (hrl) {
611
- const inscriptionResponse = createInscriptionSuccess({
612
- hrl,
613
- topicId: topicId || 'unknown',
614
- standard: standardType as 'Static' | 'Dynamic',
615
- cdnUrl: cdnUrl || undefined,
616
- transactionId: (result.result as InscriptionResult)
617
- ?.transactionId,
618
- metadata: {
619
- name: params.name,
620
- creator: params.creator,
621
- description: params.description,
622
- type: params.type,
623
- attributes: params.attributes,
624
- },
625
- });
626
-
627
- this.onEntityCreated?.({
628
- entityId: topicId || 'unknown',
629
- entityName: params.name || 'Unnamed Inscription',
630
- entityType: 'topicId',
631
- transactionId: (result.result as InscriptionResult)
632
- ?.transactionId,
633
- });
634
-
635
- if (params.withHashLinkBlocks) {
636
- try {
637
- const blockData = await this.createHashLinkBlock(
638
- inscriptionResponse,
639
- inscriptionData.type === 'buffer'
640
- ? inscriptionData.mimeType
641
- : undefined
642
- );
643
-
644
- inscriptionResponse.hashLinkBlock = blockData;
645
- } catch (blockError) {
646
- const logger = new Logger({ module: 'InscribeHashinalTool' });
647
- logger.error('Failed to create HashLink block', {
648
- error: blockError,
649
- });
650
- }
651
- }
652
-
653
- return inscriptionResponse;
654
- }
655
- }
656
-
657
- const transactionId =
658
- (result.result as InscriptionResult)?.transactionId || 'unknown';
659
- const pending = createInscriptionPending({
660
- transactionId,
563
+ const txId = (result.result as InscriptionResult)?.transactionId ?? 'unknown';
564
+ return createInscriptionPending({
565
+ transactionId: txId,
566
+ details:
567
+ 'Successfully submitted Hashinal inscription. Waiting for network confirmation...'
661
568
  });
662
- return {
663
- ...pending,
664
- metadata: { transactionId },
665
- } as unknown as InscriptionResponse;
666
569
  } else {
667
570
  return createInscriptionError({
668
- code: 'UNKNOWN_STATE',
669
- details: 'Inscription completed but result state is unclear',
670
- suggestions: [
671
- 'Check if the inscription was successful manually',
672
- 'Try the inscription again',
673
- ],
571
+ code: 'UNEXPECTED_RESULT',
572
+ details: 'Received an unexpected inscription result state',
573
+ suggestions: ['Try again or verify network status']
674
574
  });
675
575
  }
676
576
  } catch (error) {
@@ -678,16 +578,7 @@ export class InscribeHashinalTool
678
578
  error instanceof Error
679
579
  ? error.message
680
580
  : 'Failed to inscribe Hashinal NFT';
681
- return createInscriptionError({
682
- code: 'INSCRIPTION_FAILED',
683
- details: `Inscription failed: ${errorMessage}`,
684
- suggestions: [
685
- 'Check network connectivity',
686
- 'Verify you have sufficient HBAR balance',
687
- 'Ensure content is accessible and valid',
688
- 'Try again in a moment',
689
- ],
690
- });
581
+ throw new Error(`Inscription failed: ${errorMessage}`);
691
582
  }
692
583
  }
693
584
 
@@ -0,0 +1,18 @@
1
+ import type { TopicRegistrationResponse, RegistryOperationResponse, HCS6TopicRegistrationResponse, HCS6RegistryOperationResponse, HCS6CreateHashinalResponse } from '@hashgraphonline/standards-sdk';
2
+
3
+ export interface WalletBytesResponse {
4
+ success: true;
5
+ transactionBytes: string;
6
+ }
7
+
8
+ export function isWalletBytesResponse(value: unknown): value is WalletBytesResponse {
9
+ return !!value && typeof (value as any).transactionBytes === 'string';
10
+ }
11
+
12
+ export type TopicRegistrationResult = TopicRegistrationResponse | WalletBytesResponse;
13
+ export type RegistryOperationResult = RegistryOperationResponse | WalletBytesResponse;
14
+ export type SubmitMessageResult = { success: true; transactionId?: string } | WalletBytesResponse;
15
+
16
+ export type HCS6TopicRegistrationResult = HCS6TopicRegistrationResponse | WalletBytesResponse;
17
+ export type HCS6RegistryOperationResult = HCS6RegistryOperationResponse | WalletBytesResponse;
18
+ export type HCS6CreateHashinalResult = HCS6CreateHashinalResponse | WalletBytesResponse;
@@ -0,0 +1,8 @@
1
+ export class CodedError extends Error {
2
+ code: string;
3
+ constructor(code: string, message: string) {
4
+ super(message);
5
+ this.code = code;
6
+ Object.setPrototypeOf(this, CodedError.prototype);
7
+ }
8
+ }
@@ -6,11 +6,9 @@
6
6
  */
7
7
 
8
8
  export function encryptMessage(message: string): string {
9
- // TODO: Add encryption logic here if useEncryption flag is true.
10
9
  return message; // currently returns plaintext.
11
10
  }
12
11
 
13
12
  export function decryptMessage(encryptedMessage: string): string {
14
- // TODO: Add decryption logic here.
15
13
  return encryptedMessage;
16
14
  }