@hashgraphonline/standards-agent-kit 0.2.136 → 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 (211) hide show
  1. package/README.md +3 -4
  2. package/dist/cjs/builders/hcs10/hcs10-builder.d.ts +1 -0
  3. package/dist/cjs/builders/hcs2/hcs2-builder.d.ts +8 -7
  4. package/dist/cjs/builders/hcs6/hcs6-builder.d.ts +5 -4
  5. package/dist/cjs/builders/inscriber/inscriber-builder.d.ts +32 -1
  6. package/dist/cjs/index.d.ts +4 -0
  7. package/dist/cjs/signing/bytes-registry.d.ts +17 -0
  8. package/dist/cjs/signing/signer-provider.d.ts +45 -0
  9. package/dist/cjs/standards-agent-kit.cjs +1 -1
  10. package/dist/cjs/standards-agent-kit.cjs.map +1 -1
  11. package/dist/cjs/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
  12. package/dist/cjs/tools/hcs2/CreateRegistryTool.d.ts +2 -2
  13. package/dist/cjs/tools/hcs2/DeleteEntryTool.d.ts +2 -2
  14. package/dist/cjs/tools/hcs2/UpdateEntryTool.d.ts +2 -2
  15. package/dist/cjs/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
  16. package/dist/cjs/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
  17. package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
  18. package/dist/cjs/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
  19. package/dist/cjs/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
  20. package/dist/cjs/tools/inscriber/InscribeHashinalTool.d.ts +3 -3
  21. package/dist/cjs/types/inscription-response.d.ts +8 -0
  22. package/dist/cjs/types/tx-results.d.ts +15 -0
  23. package/dist/cjs/utils/CodedError.d.ts +4 -0
  24. package/dist/cjs/utils/inscription-utils.d.ts +21 -0
  25. package/dist/cjs/validation/hip412-schemas.d.ts +2 -2
  26. package/dist/es/builders/hcs10/hcs10-builder.d.ts +1 -0
  27. package/dist/es/builders/hcs2/hcs2-builder.d.ts +8 -7
  28. package/dist/es/builders/hcs6/hcs6-builder.d.ts +5 -4
  29. package/dist/es/builders/inscriber/inscriber-builder.d.ts +32 -1
  30. package/dist/es/index.d.ts +4 -0
  31. package/dist/es/signing/bytes-registry.d.ts +17 -0
  32. package/dist/es/signing/signer-provider.d.ts +45 -0
  33. package/dist/es/standards-agent-kit.es.js +46 -42
  34. package/dist/es/standards-agent-kit.es.js.map +1 -1
  35. package/dist/es/standards-agent-kit.es10.js +24 -83
  36. package/dist/es/standards-agent-kit.es10.js.map +1 -1
  37. package/dist/es/standards-agent-kit.es11.js +224 -20
  38. package/dist/es/standards-agent-kit.es11.js.map +1 -1
  39. package/dist/es/standards-agent-kit.es12.js +78 -27
  40. package/dist/es/standards-agent-kit.es12.js.map +1 -1
  41. package/dist/es/standards-agent-kit.es13.js +26 -36
  42. package/dist/es/standards-agent-kit.es13.js.map +1 -1
  43. package/dist/es/standards-agent-kit.es14.js +17 -39
  44. package/dist/es/standards-agent-kit.es14.js.map +1 -1
  45. package/dist/es/standards-agent-kit.es15.js +36 -58
  46. package/dist/es/standards-agent-kit.es15.js.map +1 -1
  47. package/dist/es/standards-agent-kit.es16.js +45 -18
  48. package/dist/es/standards-agent-kit.es16.js.map +1 -1
  49. package/dist/es/standards-agent-kit.es17.js +53 -16
  50. package/dist/es/standards-agent-kit.es17.js.map +1 -1
  51. package/dist/es/standards-agent-kit.es18.js +18 -28
  52. package/dist/es/standards-agent-kit.es18.js.map +1 -1
  53. package/dist/es/standards-agent-kit.es19.js +26 -12
  54. package/dist/es/standards-agent-kit.es19.js.map +1 -1
  55. package/dist/es/standards-agent-kit.es20.js +38 -136
  56. package/dist/es/standards-agent-kit.es20.js.map +1 -1
  57. package/dist/es/standards-agent-kit.es21.js +13 -24
  58. package/dist/es/standards-agent-kit.es21.js.map +1 -1
  59. package/dist/es/standards-agent-kit.es22.js +136 -39
  60. package/dist/es/standards-agent-kit.es22.js.map +1 -1
  61. package/dist/es/standards-agent-kit.es23.js +25 -41
  62. package/dist/es/standards-agent-kit.es23.js.map +1 -1
  63. package/dist/es/standards-agent-kit.es24.js +49 -31
  64. package/dist/es/standards-agent-kit.es24.js.map +1 -1
  65. package/dist/es/standards-agent-kit.es25.js +34 -18
  66. package/dist/es/standards-agent-kit.es25.js.map +1 -1
  67. package/dist/es/standards-agent-kit.es26.js +35 -19
  68. package/dist/es/standards-agent-kit.es26.js.map +1 -1
  69. package/dist/es/standards-agent-kit.es27.js +45 -32
  70. package/dist/es/standards-agent-kit.es27.js.map +1 -1
  71. package/dist/es/standards-agent-kit.es28.js +54 -25
  72. package/dist/es/standards-agent-kit.es28.js.map +1 -1
  73. package/dist/es/standards-agent-kit.es29.js +35 -23
  74. package/dist/es/standards-agent-kit.es29.js.map +1 -1
  75. package/dist/es/standards-agent-kit.es3.js +41 -1545
  76. package/dist/es/standards-agent-kit.es3.js.map +1 -1
  77. package/dist/es/standards-agent-kit.es30.js +23 -39
  78. package/dist/es/standards-agent-kit.es30.js.map +1 -1
  79. package/dist/es/standards-agent-kit.es31.js +30 -28
  80. package/dist/es/standards-agent-kit.es31.js.map +1 -1
  81. package/dist/es/standards-agent-kit.es32.js +45 -32
  82. package/dist/es/standards-agent-kit.es32.js.map +1 -1
  83. package/dist/es/standards-agent-kit.es33.js +50 -89
  84. package/dist/es/standards-agent-kit.es33.js.map +1 -1
  85. package/dist/es/standards-agent-kit.es34.js +35 -228
  86. package/dist/es/standards-agent-kit.es34.js.map +1 -1
  87. package/dist/es/standards-agent-kit.es35.js +87 -212
  88. package/dist/es/standards-agent-kit.es35.js.map +1 -1
  89. package/dist/es/standards-agent-kit.es36.js +188 -128
  90. package/dist/es/standards-agent-kit.es36.js.map +1 -1
  91. package/dist/es/standards-agent-kit.es37.js +167 -561
  92. package/dist/es/standards-agent-kit.es37.js.map +1 -1
  93. package/dist/es/standards-agent-kit.es38.js +236 -31
  94. package/dist/es/standards-agent-kit.es38.js.map +1 -1
  95. package/dist/es/standards-agent-kit.es39.js +483 -206
  96. package/dist/es/standards-agent-kit.es39.js.map +1 -1
  97. package/dist/es/standards-agent-kit.es4.js +359 -81
  98. package/dist/es/standards-agent-kit.es4.js.map +1 -1
  99. package/dist/es/standards-agent-kit.es40.js +39 -135
  100. package/dist/es/standards-agent-kit.es40.js.map +1 -1
  101. package/dist/es/standards-agent-kit.es41.js +244 -28
  102. package/dist/es/standards-agent-kit.es41.js.map +1 -1
  103. package/dist/es/standards-agent-kit.es42.js +132 -418
  104. package/dist/es/standards-agent-kit.es42.js.map +1 -1
  105. package/dist/es/standards-agent-kit.es43.js +28 -184
  106. package/dist/es/standards-agent-kit.es43.js.map +1 -1
  107. package/dist/es/standards-agent-kit.es44.js +423 -3
  108. package/dist/es/standards-agent-kit.es44.js.map +1 -1
  109. package/dist/es/standards-agent-kit.es45.js +185 -24
  110. package/dist/es/standards-agent-kit.es45.js.map +1 -1
  111. package/dist/es/standards-agent-kit.es46.js +3 -3
  112. package/dist/es/standards-agent-kit.es46.js.map +1 -1
  113. package/dist/es/standards-agent-kit.es47.js +21 -50
  114. package/dist/es/standards-agent-kit.es47.js.map +1 -1
  115. package/dist/es/standards-agent-kit.es48.js +8 -3
  116. package/dist/es/standards-agent-kit.es48.js.map +1 -1
  117. package/dist/es/standards-agent-kit.es49.js +3 -39
  118. package/dist/es/standards-agent-kit.es49.js.map +1 -1
  119. package/dist/es/standards-agent-kit.es5.js +1747 -73
  120. package/dist/es/standards-agent-kit.es5.js.map +1 -1
  121. package/dist/es/standards-agent-kit.es50.js +18 -16
  122. package/dist/es/standards-agent-kit.es50.js.map +1 -1
  123. package/dist/es/standards-agent-kit.es51.js +49 -49
  124. package/dist/es/standards-agent-kit.es51.js.map +1 -1
  125. package/dist/es/standards-agent-kit.es52.js +6 -0
  126. package/dist/es/standards-agent-kit.es52.js.map +1 -0
  127. package/dist/es/standards-agent-kit.es53.js +43 -0
  128. package/dist/es/standards-agent-kit.es53.js.map +1 -0
  129. package/dist/es/standards-agent-kit.es54.js +22 -0
  130. package/dist/es/standards-agent-kit.es54.js.map +1 -0
  131. package/dist/es/standards-agent-kit.es55.js +77 -0
  132. package/dist/es/standards-agent-kit.es55.js.map +1 -0
  133. package/dist/es/standards-agent-kit.es56.js +7 -0
  134. package/dist/es/standards-agent-kit.es56.js.map +1 -0
  135. package/dist/es/standards-agent-kit.es6.js +347 -32
  136. package/dist/es/standards-agent-kit.es6.js.map +1 -1
  137. package/dist/es/standards-agent-kit.es7.js +142 -293
  138. package/dist/es/standards-agent-kit.es7.js.map +1 -1
  139. package/dist/es/standards-agent-kit.es8.js +201 -21
  140. package/dist/es/standards-agent-kit.es8.js.map +1 -1
  141. package/dist/es/standards-agent-kit.es9.js +301 -213
  142. package/dist/es/standards-agent-kit.es9.js.map +1 -1
  143. package/dist/es/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
  144. package/dist/es/tools/hcs2/CreateRegistryTool.d.ts +2 -2
  145. package/dist/es/tools/hcs2/DeleteEntryTool.d.ts +2 -2
  146. package/dist/es/tools/hcs2/UpdateEntryTool.d.ts +2 -2
  147. package/dist/es/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
  148. package/dist/es/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
  149. package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
  150. package/dist/es/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
  151. package/dist/es/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
  152. package/dist/es/tools/inscriber/InscribeHashinalTool.d.ts +3 -3
  153. package/dist/es/types/inscription-response.d.ts +8 -0
  154. package/dist/es/types/tx-results.d.ts +15 -0
  155. package/dist/es/utils/CodedError.d.ts +4 -0
  156. package/dist/es/utils/inscription-utils.d.ts +21 -0
  157. package/dist/es/validation/hip412-schemas.d.ts +2 -2
  158. package/dist/umd/builders/hcs10/hcs10-builder.d.ts +1 -0
  159. package/dist/umd/builders/hcs2/hcs2-builder.d.ts +8 -7
  160. package/dist/umd/builders/hcs6/hcs6-builder.d.ts +5 -4
  161. package/dist/umd/builders/inscriber/inscriber-builder.d.ts +32 -1
  162. package/dist/umd/index.d.ts +4 -0
  163. package/dist/umd/signing/bytes-registry.d.ts +17 -0
  164. package/dist/umd/signing/signer-provider.d.ts +45 -0
  165. package/dist/umd/standards-agent-kit.umd.js +1 -1
  166. package/dist/umd/standards-agent-kit.umd.js.map +1 -1
  167. package/dist/umd/tools/hcs10/InitiateConnectionTool.d.ts +4 -4
  168. package/dist/umd/tools/hcs2/CreateRegistryTool.d.ts +2 -2
  169. package/dist/umd/tools/hcs2/DeleteEntryTool.d.ts +2 -2
  170. package/dist/umd/tools/hcs2/UpdateEntryTool.d.ts +2 -2
  171. package/dist/umd/tools/hcs6/RegisterDynamicHashinalTool.d.ts +10 -10
  172. package/dist/umd/tools/hcs6/UpdateDynamicHashinalTool.d.ts +8 -8
  173. package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +5 -4
  174. package/dist/umd/tools/inscriber/InscribeFromFileTool.d.ts +2 -2
  175. package/dist/umd/tools/inscriber/InscribeFromUrlTool.d.ts +4 -4
  176. package/dist/umd/tools/inscriber/InscribeHashinalTool.d.ts +3 -3
  177. package/dist/umd/types/inscription-response.d.ts +8 -0
  178. package/dist/umd/types/tx-results.d.ts +15 -0
  179. package/dist/umd/utils/CodedError.d.ts +4 -0
  180. package/dist/umd/utils/inscription-utils.d.ts +21 -0
  181. package/dist/umd/validation/hip412-schemas.d.ts +2 -2
  182. package/package.json +10 -5
  183. package/src/builders/hcs10/hcs10-builder.ts +239 -6
  184. package/src/builders/hcs2/hcs2-builder.ts +302 -9
  185. package/src/builders/hcs6/hcs6-builder.ts +79 -4
  186. package/src/builders/inscriber/inscriber-builder.ts +235 -2
  187. package/src/hcs10/HCS10Client.ts +1 -1
  188. package/src/index.ts +5 -1
  189. package/src/lib/zod-render/schema-extension.ts +0 -1
  190. package/src/signing/bytes-registry.ts +501 -0
  191. package/src/signing/signer-provider.ts +120 -0
  192. package/src/tools/hcs2/CreateRegistryTool.ts +30 -5
  193. package/src/tools/hcs2/DeleteEntryTool.ts +16 -2
  194. package/src/tools/hcs2/MigrateRegistryTool.ts +16 -2
  195. package/src/tools/hcs2/QueryRegistryTool.ts +11 -2
  196. package/src/tools/hcs2/RegisterEntryTool.ts +17 -3
  197. package/src/tools/hcs2/UpdateEntryTool.ts +16 -2
  198. package/src/tools/hcs6/CreateDynamicRegistryTool.ts +17 -3
  199. package/src/tools/hcs6/RegisterDynamicHashinalTool.ts +17 -3
  200. package/src/tools/hcs6/UpdateDynamicHashinalTool.ts +17 -3
  201. package/src/tools/inscriber/InscribeFromBufferTool.ts +126 -21
  202. package/src/tools/inscriber/InscribeFromFileTool.ts +10 -13
  203. package/src/tools/inscriber/InscribeFromUrlTool.ts +15 -11
  204. package/src/tools/inscriber/InscribeHashinalTool.ts +40 -168
  205. package/src/tools/inscriber/RetrieveInscriptionTool.ts +15 -16
  206. package/src/types/inscription-response.ts +27 -0
  207. package/src/types/tx-results.ts +18 -0
  208. package/src/utils/CodedError.ts +8 -0
  209. package/src/utils/Encryption.ts +0 -2
  210. package/src/utils/ensure-agent-has-hbar.ts +4 -5
  211. package/src/utils/inscription-utils.ts +53 -0
@@ -1,249 +1,526 @@
1
- import { updateEnvFile } from "./standards-agent-kit.es45.js";
2
- import { Logger, ConnectionsManager } from "@hashgraphonline/standards-sdk";
3
- class OpenConvaiState {
4
- /**
5
- * Creates a new OpenConvaiState instance
6
- * @param options - Options for environment variable persistence
7
- */
8
- constructor(options) {
9
- this.currentAgent = null;
10
- this.connectionMessageTimestamps = {};
11
- this.connectionsManager = null;
12
- this.defaultEnvFilePath = options?.defaultEnvFilePath;
13
- this.defaultPrefix = options?.defaultPrefix ?? "TODD";
14
- const shouldSilence = options?.disableLogging || process.env.DISABLE_LOGGING === "true";
15
- this.logger = new Logger({ module: "OpenConvaiState", silent: shouldSilence });
16
- if (options?.baseClient) {
17
- this.initializeConnectionsManager(options.baseClient);
18
- }
1
+ import { z } from "zod";
2
+ import { BaseInscriberQueryTool } from "./standards-agent-kit.es35.js";
3
+ import { Logger, ContentResolverRegistry } from "@hashgraphonline/standards-sdk";
4
+ import { validateHIP412Metadata } from "./standards-agent-kit.es53.js";
5
+ import { contentRefSchema } from "./standards-agent-kit.es52.js";
6
+ import { generateDefaultMetadata } from "./standards-agent-kit.es54.js";
7
+ import { extendZodSchema, renderConfigs } from "./standards-agent-kit.es44.js";
8
+ import { createInscriptionError, createInscriptionQuote, createInscriptionSuccess, createInscriptionPending } from "./standards-agent-kit.es55.js";
9
+ import { extractTopicIds, buildInscriptionLinks } from "./standards-agent-kit.es50.js";
10
+ const HASHLINK_BLOCK_CONFIG = {
11
+ testnet: {
12
+ blockId: "0.0.6617393",
13
+ hashLink: "hcs://12/0.0.6617393",
14
+ template: "0.0.6617393"
15
+ },
16
+ mainnet: {
17
+ blockId: "0.0.TBD",
18
+ hashLink: "hcs://12/0.0.TBD",
19
+ template: "0.0.TBD"
19
20
  }
20
- /**
21
- * Initializes the ConnectionsManager
22
- * @param baseClient - HCS10BaseClient instance to use
23
- */
24
- initializeConnectionsManager(baseClient) {
25
- if (!this.connectionsManager) {
26
- this.logger.debug("Initializing ConnectionsManager");
27
- this.connectionsManager = new ConnectionsManager({
28
- baseClient,
29
- logLevel: "error"
30
- });
31
- } else {
32
- this.logger.debug("ConnectionsManager already initialized");
33
- }
34
- return this.connectionsManager;
35
- }
36
- /**
37
- * Gets the ConnectionsManager instance
38
- * @returns The ConnectionsManager instance, or null if not initialized
39
- */
40
- getConnectionsManager() {
41
- return this.connectionsManager;
21
+ };
22
+ function getHashLinkBlockId(network) {
23
+ const config = network === "mainnet" ? HASHLINK_BLOCK_CONFIG.mainnet : HASHLINK_BLOCK_CONFIG.testnet;
24
+ if (!config || config.blockId === "0.0.TBD") {
25
+ return HASHLINK_BLOCK_CONFIG.testnet;
42
26
  }
43
- /**
44
- * Sets the current active agent and clears any previous connection data.
45
- * This should be called when switching between agents.
46
- */
47
- setCurrentAgent(agent) {
48
- this.currentAgent = agent;
49
- this.connectionMessageTimestamps = {};
50
- if (this.connectionsManager) {
51
- this.connectionsManager.clearAll();
52
- }
27
+ return config;
28
+ }
29
+ const inscribeHashinalSchema = extendZodSchema(
30
+ z.object({
31
+ url: z.string().optional().describe(
32
+ "The URL of the content to inscribe as Hashinal NFT (use this OR contentRef)"
33
+ ),
34
+ contentRef: contentRefSchema.optional().describe(
35
+ 'Content reference ID in format "content-ref:[id]" for already stored content (use this OR url)'
36
+ ),
37
+ base64Data: z.string().optional().describe(
38
+ "Base64 encoded content data (use this if neither url nor contentRef provided)"
39
+ ),
40
+ fileName: z.string().optional().describe(
41
+ "File name for the content (required when using base64Data or contentRef)"
42
+ ),
43
+ mimeType: z.string().optional().describe('MIME type of the content (e.g., "image/png", "image/jpeg")'),
44
+ name: z.string().optional().describe(
45
+ 'Display name for the NFT (e.g., "Sunset Landscape #42", "Digital Abstract Art")'
46
+ ),
47
+ creator: z.string().optional().describe(
48
+ 'Creator account ID, artist name, or brand (e.g., "0.0.123456", "ArtistName", "StudioBrand")'
49
+ ),
50
+ description: z.string().optional().describe(
51
+ "Meaningful description of the artwork, story, or concept behind this NFT"
52
+ ),
53
+ type: z.string().optional().describe(
54
+ 'Category or genre of the NFT (e.g., "Digital Art", "Photography", "Collectible Card")'
55
+ ),
56
+ attributes: extendZodSchema(
57
+ z.array(
58
+ z.object({
59
+ trait_type: z.string(),
60
+ value: z.union([z.string(), z.number()])
61
+ })
62
+ )
63
+ ).withRender(renderConfigs.array("NFT Attributes", "Attribute")).optional().describe(
64
+ 'Collectible traits and characteristics (e.g., "Rarity": "Epic", "Color": "Blue", "Style": "Abstract")'
65
+ ),
66
+ properties: z.record(z.unknown()).optional().describe("Additional properties"),
67
+ jsonFileURL: z.string().url().optional().describe("URL to JSON metadata file"),
68
+ fileStandard: z.enum(["1", "6"]).optional().default("1").describe(
69
+ "HCS file standard: 1 for static Hashinals (HCS-5), 6 for dynamic Hashinals (HCS-6)"
70
+ ),
71
+ tags: z.array(z.string()).optional().describe("Tags to categorize the NFT"),
72
+ chunkSize: z.number().int().positive().optional().describe("Chunk size for large files"),
73
+ waitForConfirmation: z.boolean().optional().describe("Whether to wait for inscription confirmation"),
74
+ timeoutMs: z.number().int().positive().optional().describe(
75
+ "Timeout in milliseconds for inscription (default: no timeout - waits until completion)"
76
+ ),
77
+ quoteOnly: z.boolean().optional().default(false).describe(
78
+ "If true, returns a cost quote instead of executing the inscription"
79
+ ),
80
+ withHashLinkBlocks: z.boolean().optional().default(true).describe(
81
+ "If true, creates interactive HashLink blocks for the inscribed content and returns block data alongside the inscription response"
82
+ ),
83
+ renderForm: z.boolean().optional().default(true).describe(
84
+ "Whether to show a form to collect metadata. Set to false only if user provided complete metadata including name, description, creator, and attributes."
85
+ )
86
+ })
87
+ ).withRender({
88
+ fieldType: "object",
89
+ ui: {
90
+ label: "Inscribe Hashinal NFT",
91
+ description: "Create a Hashinal inscription for NFT minting"
53
92
  }
54
- /**
55
- * Returns the currently active agent or null if none is set.
56
- */
57
- getCurrentAgent() {
58
- return this.currentAgent;
93
+ });
94
+ class InscribeHashinalTool extends BaseInscriberQueryTool {
95
+ constructor() {
96
+ super(...arguments);
97
+ this.name = "inscribeHashinal";
98
+ this.description = "Tool for inscribing Hashinal NFTs. CRITICAL: When user provides content (url/contentRef/base64Data), call with ONLY the content parameters - DO NOT auto-generate name, description, creator, or attributes. A form will be automatically shown to collect metadata from the user. Only include metadata parameters if the user explicitly provided them in their message.";
59
99
  }
60
- /**
61
- * Adds a new connection to the active connections list.
62
- * Ensures no duplicates are added based on connectionTopicId.
63
- * Initializes timestamp tracking for the connection.
64
- */
65
- addActiveConnection(connection) {
66
- if (!this.connectionsManager) {
67
- this.logger.error(
68
- "ConnectionsManager not initialized. Call initializeConnectionsManager before adding connections."
69
- );
70
- throw new Error(
71
- "ConnectionsManager not initialized. Call initializeConnectionsManager before adding connections."
72
- );
73
- }
74
- const sdkConnection = {
75
- connectionTopicId: connection.connectionTopicId,
76
- targetAccountId: connection.targetAccountId,
77
- targetAgentName: connection.targetAgentName,
78
- targetInboundTopicId: connection.targetInboundTopicId,
79
- status: this.convertConnectionStatus(connection.status || "established"),
80
- isPending: connection.isPending || false,
81
- needsConfirmation: connection.needsConfirmation || false,
82
- created: connection.created || /* @__PURE__ */ new Date(),
83
- lastActivity: connection.lastActivity,
84
- profileInfo: connection.profileInfo,
85
- connectionRequestId: connection.connectionRequestId,
86
- processed: true
100
+ getEntityResolutionPreferences() {
101
+ return {
102
+ name: "literal",
103
+ description: "literal",
104
+ creator: "literal",
105
+ attributes: "literal",
106
+ properties: "literal"
87
107
  };
88
- this.connectionsManager.updateOrAddConnection(sdkConnection);
89
- this.initializeTimestampIfNeeded(connection.connectionTopicId);
90
108
  }
91
- /**
92
- * Updates an existing connection or adds it if not found.
93
- * Preserves existing properties when updating by merging objects.
94
- */
95
- updateOrAddConnection(connection) {
96
- this.addActiveConnection(connection);
109
+ get specificInputSchema() {
110
+ const baseSchema = inscribeHashinalSchema._def?.schema || inscribeHashinalSchema;
111
+ return baseSchema;
97
112
  }
98
- /**
99
- * Returns a copy of all active connections.
100
- */
101
- listConnections() {
102
- if (!this.connectionsManager) {
103
- this.logger.debug(
104
- "ConnectionsManager not initialized, returning empty connections list"
105
- );
106
- return [];
113
+ get schema() {
114
+ if (!this._schemaWithRenderConfig) {
115
+ const baseSchema = this.specificInputSchema;
116
+ const schemaWithRender = baseSchema;
117
+ if (!schemaWithRender._renderConfig) {
118
+ schemaWithRender._renderConfig = {
119
+ fieldType: "object",
120
+ ui: {
121
+ label: "Inscribe Hashinal NFT",
122
+ description: "Create a Hashinal inscription for NFT minting"
123
+ }
124
+ };
125
+ }
126
+ this._schemaWithRenderConfig = baseSchema;
107
127
  }
108
- return this.connectionsManager.getAllConnections().map((conn) => this.convertToActiveConnection(conn));
128
+ return this._schemaWithRenderConfig;
109
129
  }
110
130
  /**
111
- * Finds a connection by its identifier, which can be:
112
- * - A 1-based index as displayed in the connection list
113
- * - A target account ID string
114
- * - A connection topic ID string
131
+ * Implementation of FormValidatable interface
132
+ * Determines if a form should be generated for the given input
115
133
  */
116
- getConnectionByIdentifier(identifier) {
117
- if (!this.connectionsManager) {
118
- return void 0;
119
- }
120
- const connections = this.listConnections();
121
- const numericIndex = parseInt(identifier) - 1;
122
- if (!isNaN(numericIndex) && numericIndex >= 0 && numericIndex < connections.length) {
123
- return connections[numericIndex];
134
+ shouldGenerateForm(input) {
135
+ const logger = new Logger({ module: "InscribeHashinalTool" });
136
+ const inputObj = input;
137
+ logger.info("InscribeHashinalTool: Checking if form should be generated", {
138
+ inputKeys: Object.keys(inputObj || {}),
139
+ hasContent: !!(inputObj.url || inputObj.contentRef || inputObj.base64Data),
140
+ renderFormProvided: "renderForm" in inputObj,
141
+ renderFormValue: inputObj.renderForm
142
+ });
143
+ const hasContentSource = !!(inputObj.url || inputObj.contentRef || inputObj.base64Data);
144
+ if (!hasContentSource) {
145
+ logger.info("InscribeHashinalTool: No content source provided");
146
+ return false;
124
147
  }
125
- const byTopicId = this.connectionsManager.getConnectionByTopicId(identifier);
126
- if (byTopicId) {
127
- return this.convertToActiveConnection(byTopicId);
148
+ if ("renderForm" in inputObj && inputObj.renderForm === false) {
149
+ logger.info(
150
+ "InscribeHashinalTool: renderForm=false, skipping form generation"
151
+ );
152
+ return false;
128
153
  }
129
- const byAccountId = this.connectionsManager.getConnectionByAccountId(identifier);
130
- if (byAccountId) {
131
- return this.convertToActiveConnection(byAccountId);
154
+ const isNonEmptyString = (v) => {
155
+ if (typeof v !== "string") {
156
+ return false;
157
+ }
158
+ if (v.trim().length === 0) {
159
+ return false;
160
+ }
161
+ return true;
162
+ };
163
+ const hasRequiredMetadata = isNonEmptyString(inputObj.name) && isNonEmptyString(inputObj.description) && isNonEmptyString(inputObj.creator);
164
+ if (hasRequiredMetadata) {
165
+ logger.info(
166
+ "InscribeHashinalTool: Required metadata present, skipping form generation"
167
+ );
168
+ return false;
132
169
  }
133
- return void 0;
170
+ logger.info(
171
+ "InscribeHashinalTool: Content provided, showing form for metadata collection"
172
+ );
173
+ return true;
134
174
  }
135
175
  /**
136
- * Gets the last processed message timestamp for a connection.
137
- * Returns 0 if no timestamp has been recorded.
176
+ * Implementation of FormValidatable interface
177
+ * Returns the focused schema for form generation
138
178
  */
139
- getLastTimestamp(connectionTopicId) {
140
- return this.connectionMessageTimestamps[connectionTopicId] || 0;
179
+ getFormSchema() {
180
+ const focusedSchema = extendZodSchema(
181
+ z.object({
182
+ name: z.string().min(1, "Name is required").describe(
183
+ 'Display name for the NFT (e.g., "Sunset Landscape #42", "Digital Abstract Art")'
184
+ ),
185
+ description: z.string().min(1, "Description is required").describe(
186
+ "Meaningful description of the artwork, story, or concept behind this NFT"
187
+ ),
188
+ creator: z.string().min(1, "Creator is required").describe(
189
+ 'Creator account ID, artist name, or brand (e.g., "0.0.123456", "ArtistName", "StudioBrand")'
190
+ ),
191
+ attributes: extendZodSchema(
192
+ z.array(
193
+ z.object({
194
+ trait_type: z.string().describe('Trait name (e.g., "Rarity", "Color", "Style")'),
195
+ value: z.union([z.string(), z.number()]).describe('Trait value (e.g., "Epic", "Blue", 85)')
196
+ })
197
+ )
198
+ ).withRender(renderConfigs.array("NFT Attributes", "Attribute")).optional().describe("Collectible traits and characteristics."),
199
+ type: z.string().optional().describe(
200
+ 'Category or genre of the NFT (e.g., "Digital Art", "Photography", "Collectible Card)'
201
+ )
202
+ })
203
+ ).withRender({
204
+ fieldType: "object",
205
+ ui: {
206
+ label: "Complete NFT Metadata",
207
+ description: "Provide meaningful metadata to create a valuable NFT"
208
+ }
209
+ });
210
+ return focusedSchema;
141
211
  }
142
- /**
143
- * Updates the last processed message timestamp for a connection,
144
- * but only if the new timestamp is more recent than the existing one.
145
- */
146
- updateTimestamp(connectionTopicId, timestampNanos) {
147
- if (!(connectionTopicId in this.connectionMessageTimestamps)) {
148
- this.connectionMessageTimestamps[connectionTopicId] = timestampNanos;
149
- return;
212
+ async executeQuery(params, _runManager) {
213
+ if (!params.url && !params.contentRef && !params.base64Data) {
214
+ return createInscriptionError({
215
+ code: "MISSING_CONTENT",
216
+ details: "No content source provided",
217
+ suggestions: [
218
+ "Provide a URL to content you want to inscribe",
219
+ "Upload a file and use the content reference",
220
+ "Provide base64-encoded content data"
221
+ ]
222
+ });
150
223
  }
151
- const currentTimestamp = this.connectionMessageTimestamps[connectionTopicId];
152
- if (timestampNanos > currentTimestamp) {
153
- this.connectionMessageTimestamps[connectionTopicId] = timestampNanos;
224
+ const operatorAccount = this.inscriberBuilder["hederaKit"]?.client?.operatorAccountId?.toString() || "0.0.unknown";
225
+ const rawMetadata = {
226
+ ...generateDefaultMetadata({
227
+ name: params.name,
228
+ creator: params.creator,
229
+ description: params.description,
230
+ type: params.type,
231
+ fileName: params.fileName,
232
+ mimeType: params.mimeType,
233
+ operatorAccount
234
+ }),
235
+ attributes: Array.isArray(params.attributes) ? params.attributes : [],
236
+ properties: params.properties || {}
237
+ };
238
+ let validatedMetadata;
239
+ try {
240
+ validatedMetadata = validateHIP412Metadata(rawMetadata);
241
+ } catch (error) {
242
+ const errorMessage = error instanceof Error ? error.message : String(error);
243
+ return createInscriptionError({
244
+ code: "METADATA_VALIDATION_FAILED",
245
+ details: `Metadata validation error: ${errorMessage}`,
246
+ suggestions: [
247
+ "Ensure all required metadata fields are provided",
248
+ "Check that attribute values are valid",
249
+ "Verify metadata follows HIP-412 standard"
250
+ ]
251
+ });
252
+ }
253
+ const options = {
254
+ mode: "hashinal",
255
+ metadata: validatedMetadata,
256
+ jsonFileURL: params.jsonFileURL,
257
+ fileStandard: params.fileStandard,
258
+ tags: params.tags,
259
+ chunkSize: params.chunkSize,
260
+ waitForConfirmation: params.quoteOnly ? false : params.waitForConfirmation ?? true,
261
+ waitMaxAttempts: 60,
262
+ waitIntervalMs: 5e3,
263
+ network: this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet",
264
+ quoteOnly: params.quoteOnly
265
+ };
266
+ let inscriptionData;
267
+ if (params.url) {
268
+ inscriptionData = { type: "url", url: params.url };
269
+ } else if (params.contentRef || params.base64Data) {
270
+ const inputData = params.contentRef || params.base64Data || "";
271
+ const { buffer, mimeType, fileName } = await this.resolveContent(
272
+ inputData,
273
+ params.mimeType,
274
+ params.fileName
275
+ );
276
+ inscriptionData = {
277
+ type: "buffer",
278
+ buffer,
279
+ fileName: fileName || params.fileName || "hashinal-content",
280
+ mimeType: mimeType || params.mimeType
281
+ };
282
+ } else {
283
+ throw new Error("No valid input data provided for inscription");
284
+ }
285
+ if (params.quoteOnly) {
286
+ try {
287
+ const quote = await this.generateInscriptionQuote(
288
+ inscriptionData,
289
+ options
290
+ );
291
+ return createInscriptionQuote({
292
+ totalCostHbar: quote.totalCostHbar,
293
+ validUntil: quote.validUntil,
294
+ breakdown: quote.breakdown,
295
+ content: {
296
+ name: params.name,
297
+ creator: params.creator,
298
+ type: params.type
299
+ }
300
+ });
301
+ } catch (error) {
302
+ const errorMessage = error instanceof Error ? error.message : "Failed to generate inscription quote";
303
+ return createInscriptionError({
304
+ code: "QUOTE_GENERATION_FAILED",
305
+ details: `Quote generation failed: ${errorMessage}`,
306
+ suggestions: [
307
+ "Check network connectivity",
308
+ "Verify content is accessible",
309
+ "Try again in a moment"
310
+ ]
311
+ });
312
+ }
313
+ }
314
+ try {
315
+ let result;
316
+ if (params.timeoutMs) {
317
+ const timeoutPromise = new Promise((_, reject) => {
318
+ setTimeout(
319
+ () => reject(
320
+ new Error(`Inscription timed out after ${params.timeoutMs}ms`)
321
+ ),
322
+ params.timeoutMs
323
+ );
324
+ });
325
+ result = await Promise.race([
326
+ this.inscriberBuilder.inscribeAuto ? this.inscriberBuilder.inscribeAuto(inscriptionData, options) : this.inscriberBuilder.inscribe(inscriptionData, options),
327
+ timeoutPromise
328
+ ]);
329
+ } else {
330
+ result = this.inscriberBuilder.inscribeAuto ? await this.inscriberBuilder.inscribeAuto(inscriptionData, options) : await this.inscriberBuilder.inscribe(inscriptionData, options);
331
+ }
332
+ if (result.confirmed && !result.quote) {
333
+ const ids = extractTopicIds(result.inscription, result.result);
334
+ const network = options.network || "testnet";
335
+ const fileStandard = params.fileStandard || "1";
336
+ const { hrl, topicId, cdnUrl } = buildInscriptionLinks(
337
+ ids,
338
+ network,
339
+ fileStandard
340
+ );
341
+ const txId = result.result?.transactionId ?? "unknown";
342
+ return createInscriptionSuccess({
343
+ hrl: hrl || "hcs://1/unknown",
344
+ topicId: topicId || "unknown",
345
+ standard: fileStandard === "6" ? "Dynamic" : "Static",
346
+ cdnUrl,
347
+ transactionId: txId,
348
+ metadata: {
349
+ name: params.name,
350
+ creator: params.creator,
351
+ description: params.description,
352
+ type: params.type,
353
+ attributes: Array.isArray(params.attributes) ? params.attributes : []
354
+ }
355
+ });
356
+ } else if (!result.quote && !result.confirmed) {
357
+ const txId = result.result?.transactionId ?? "unknown";
358
+ return createInscriptionPending({
359
+ transactionId: txId,
360
+ details: "Successfully submitted Hashinal inscription. Waiting for network confirmation..."
361
+ });
362
+ } else {
363
+ return createInscriptionError({
364
+ code: "UNEXPECTED_RESULT",
365
+ details: "Received an unexpected inscription result state",
366
+ suggestions: ["Try again or verify network status"]
367
+ });
368
+ }
369
+ } catch (error) {
370
+ const errorMessage = error instanceof Error ? error.message : "Failed to inscribe Hashinal NFT";
371
+ throw new Error(`Inscription failed: ${errorMessage}`);
154
372
  }
155
373
  }
156
374
  /**
157
- * Helper method to initialize timestamp tracking for a connection
158
- * if it doesn't already exist.
375
+ * Creates HashLink block configuration for Hashinal inscriptions.
376
+ * Automatically detects network and selects appropriate block ID configuration.
377
+ * Uses testnet block as fallback for unknown networks or undeployed mainnet blocks.
378
+ *
379
+ * @param response The inscription response containing metadata and network information
380
+ * @param _mimeType Optional MIME type (currently unused, preserved for compatibility)
381
+ * @returns HCS12BlockResult with network-specific block configuration
382
+ *
383
+ * @example
384
+ * ```typescript
385
+ * // Testnet usage (automatic detection from client)
386
+ * const testnetClient = Client.forTestnet();
387
+ * const tool = new InscribeHashinalTool(testnetClient);
388
+ * const block = await tool.createHashLinkBlock(inscriptionResponse);
389
+ * console.log(block.blockId); // '0.0.6617393'
390
+ * console.log(block.hashLink); // 'hcs://12/0.0.6617393'
391
+ *
392
+ * // Mainnet usage (automatic detection from client)
393
+ * const mainnetClient = Client.forMainnet();
394
+ * const tool = new InscribeHashinalTool(mainnetClient);
395
+ * const block = await tool.createHashLinkBlock(inscriptionResponse);
396
+ * console.log(block.blockId); // Network-specific mainnet block ID
397
+ *
398
+ * // HashLink Block Response Structure:
399
+ * {
400
+ * blockId: string; // Hedera account ID format (e.g., '0.0.6617393')
401
+ * hashLink: string; // HCS-12 URL format: 'hcs://12/{blockId}'
402
+ * template: string; // Block template reference matching blockId
403
+ * attributes: { // Metadata for client-side processing
404
+ * name: string; // Content display name
405
+ * creator: string; // Creator account ID
406
+ * topicId: string; // HCS topic containing the inscription
407
+ * hrl: string; // Hedera Resource Locator
408
+ * network: string; // Network type: 'testnet' | 'mainnet'
409
+ * }
410
+ * }
411
+ *
412
+ * // Render function usage in HashLink blocks:
413
+ * // The block's JavaScript render function receives this structure
414
+ * // and can access network-specific resources through attributes.network
415
+ * ```
159
416
  */
160
- initializeTimestampIfNeeded(connectionTopicId) {
161
- if (!(connectionTopicId in this.connectionMessageTimestamps)) {
162
- this.connectionMessageTimestamps[connectionTopicId] = Date.now() * 1e6;
417
+ async createHashLinkBlock(response, _mimeType) {
418
+ const clientNetwork = this.inscriberBuilder["hederaKit"].client.network.toString().includes("mainnet") ? "mainnet" : "testnet";
419
+ const cdnNetwork = response.inscription.cdnUrl?.includes("mainnet") ? "mainnet" : "testnet";
420
+ if (clientNetwork !== cdnNetwork) {
421
+ const logger = new Logger({ module: "InscribeHashinalTool" });
422
+ logger.warn(
423
+ `Network mismatch detected: client=${clientNetwork}, cdn=${cdnNetwork}. Using client network.`
424
+ );
163
425
  }
426
+ const network = clientNetwork;
427
+ const config = getHashLinkBlockId(network);
428
+ return {
429
+ blockId: config.blockId,
430
+ hashLink: config.hashLink,
431
+ template: config.template,
432
+ attributes: {
433
+ name: response.metadata.name || "Untitled Content",
434
+ creator: response.metadata.creator || "",
435
+ topicId: response.inscription.topicId,
436
+ hrl: response.inscription.hrl,
437
+ network
438
+ }
439
+ };
164
440
  }
165
- /**
166
- * Converts ConnectionStatus to SDK status format
167
- */
168
- convertConnectionStatus(status) {
169
- switch (status) {
170
- case "pending":
171
- return "pending";
172
- case "established":
173
- return "established";
174
- case "needs confirmation":
175
- return "needs_confirmation";
176
- default:
177
- return "established";
441
+ async resolveContent(input, providedMimeType, providedFileName) {
442
+ const trimmedInput = input.trim();
443
+ const resolver = this.getContentResolver() || ContentResolverRegistry.getResolver();
444
+ if (!resolver) {
445
+ return this.handleDirectContent(
446
+ trimmedInput,
447
+ providedMimeType,
448
+ providedFileName
449
+ );
450
+ }
451
+ const referenceId = resolver.extractReferenceId(trimmedInput);
452
+ if (referenceId) {
453
+ try {
454
+ const resolution = await resolver.resolveReference(referenceId);
455
+ return {
456
+ buffer: resolution.content,
457
+ mimeType: resolution.metadata?.mimeType || providedMimeType,
458
+ fileName: resolution.metadata?.fileName || providedFileName,
459
+ wasReference: true
460
+ };
461
+ } catch (error) {
462
+ const errorMsg = error instanceof Error ? error.message : "Unknown error resolving reference";
463
+ throw new Error(`Reference resolution failed: ${errorMsg}`);
464
+ }
178
465
  }
466
+ return this.handleDirectContent(
467
+ trimmedInput,
468
+ providedMimeType,
469
+ providedFileName
470
+ );
179
471
  }
180
- /**
181
- * Converts SDK Connection to ActiveConnection
182
- */
183
- convertToActiveConnection(conn) {
472
+ handleDirectContent(input, providedMimeType, providedFileName) {
473
+ const isValidBase64 = /^[A-Za-z0-9+/]*={0,2}$/.test(input);
474
+ if (isValidBase64) {
475
+ try {
476
+ const buffer2 = Buffer.from(input, "base64");
477
+ return {
478
+ buffer: buffer2,
479
+ mimeType: providedMimeType,
480
+ fileName: providedFileName,
481
+ wasReference: false
482
+ };
483
+ } catch (error) {
484
+ throw new Error(
485
+ "Failed to decode base64 data. Please ensure the data is properly encoded."
486
+ );
487
+ }
488
+ }
489
+ const buffer = Buffer.from(input, "utf8");
184
490
  return {
185
- targetAccountId: conn.targetAccountId,
186
- targetAgentName: conn.targetAgentName || `Agent ${conn.targetAccountId}`,
187
- targetInboundTopicId: conn.targetInboundTopicId || "",
188
- connectionTopicId: conn.connectionTopicId,
189
- status: this.convertToStateStatus(conn.status),
190
- created: conn.created,
191
- lastActivity: conn.lastActivity,
192
- isPending: conn.isPending,
193
- needsConfirmation: conn.needsConfirmation,
194
- profileInfo: conn.profileInfo,
195
- connectionRequestId: conn.connectionRequestId
491
+ buffer,
492
+ mimeType: providedMimeType || "text/plain",
493
+ fileName: providedFileName,
494
+ wasReference: false
196
495
  };
197
496
  }
198
497
  /**
199
- * Converts SDK status to state status format
498
+ * Implementation of FormValidatable interface
499
+ * Returns essential fields that should always be shown in forms
200
500
  */
201
- convertToStateStatus(status) {
202
- switch (status) {
203
- case "pending":
204
- return "pending";
205
- case "established":
206
- return "established";
207
- case "needs_confirmation":
208
- return "needs confirmation";
209
- case "closed":
210
- return "established";
211
- // Mapping closed to established for compatibility
212
- default:
213
- return "unknown";
214
- }
501
+ getEssentialFields() {
502
+ return ["name", "description", "creator", "attributes"];
215
503
  }
216
504
  /**
217
- * Persists agent data to environment variables
218
- * @param agent - The agent data to persist
219
- * @param options - Environment file persistence options
505
+ * Implementation of FormValidatable interface
506
+ * Determines if a field value should be considered empty for this tool
220
507
  */
221
- async persistAgentData(agent, options) {
222
- if (options?.type && options.type !== "env-file") {
223
- throw new Error(
224
- `Unsupported persistence type: ${options.type}. Only 'env-file' is supported.`
225
- );
508
+ isFieldEmpty(fieldName, value) {
509
+ if (value === void 0 || value === null || value === "") {
510
+ return true;
226
511
  }
227
- const envFilePath = options?.envFilePath || this.defaultEnvFilePath || process.env.ENV_FILE_PATH || ".env";
228
- const prefix = options?.prefix || this.defaultPrefix;
229
- if (!agent.accountId || !agent.inboundTopicId || !agent.outboundTopicId) {
230
- throw new Error("Agent data incomplete, cannot persist to environment");
512
+ if (Array.isArray(value) && value.length === 0) {
513
+ return true;
231
514
  }
232
- const updates = {
233
- [`${prefix}_ACCOUNT_ID`]: agent.accountId,
234
- [`${prefix}_INBOUND_TOPIC_ID`]: agent.inboundTopicId,
235
- [`${prefix}_OUTBOUND_TOPIC_ID`]: agent.outboundTopicId
236
- };
237
- if (agent.privateKey) {
238
- updates[`${prefix}_PRIVATE_KEY`] = agent.privateKey;
239
- }
240
- if (agent.profileTopicId) {
241
- updates[`${prefix}_PROFILE_TOPIC_ID`] = agent.profileTopicId;
515
+ if (fieldName === "attributes" && Array.isArray(value)) {
516
+ return value.every(
517
+ (attr) => !attr || typeof attr === "object" && (!attr.trait_type || !attr.value)
518
+ );
242
519
  }
243
- await updateEnvFile(envFilePath, updates);
520
+ return false;
244
521
  }
245
522
  }
246
523
  export {
247
- OpenConvaiState
524
+ InscribeHashinalTool
248
525
  };
249
526
  //# sourceMappingURL=standards-agent-kit.es39.js.map