@hashgraphonline/standards-sdk 0.0.64 → 0.0.65

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 (279) hide show
  1. package/dist/es/fees/fee-config-builder.d.ts.map +1 -0
  2. package/dist/es/fees/index.d.ts +3 -0
  3. package/dist/es/fees/index.d.ts.map +1 -0
  4. package/dist/es/fees/types.d.ts +24 -0
  5. package/dist/es/fees/types.d.ts.map +1 -0
  6. package/dist/es/hcs-10/base-client.d.ts +1 -1
  7. package/dist/es/hcs-10/base-client.d.ts.map +1 -1
  8. package/dist/es/hcs-10/browser.d.ts +20 -35
  9. package/dist/es/hcs-10/browser.d.ts.map +1 -1
  10. package/dist/es/hcs-10/index.d.ts +4 -6
  11. package/dist/es/hcs-10/index.d.ts.map +1 -1
  12. package/dist/es/hcs-10/registrations.d.ts.map +1 -1
  13. package/dist/es/hcs-10/sdk.d.ts +16 -8
  14. package/dist/es/hcs-10/sdk.d.ts.map +1 -1
  15. package/dist/es/hcs-10/types.d.ts +2 -62
  16. package/dist/es/hcs-10/types.d.ts.map +1 -1
  17. package/dist/es/hcs-11/agent-builder.d.ts +53 -0
  18. package/dist/es/hcs-11/agent-builder.d.ts.map +1 -0
  19. package/dist/es/hcs-11/client.d.ts +82 -0
  20. package/dist/es/hcs-11/client.d.ts.map +1 -0
  21. package/dist/es/hcs-11/index.d.ts +4 -190
  22. package/dist/es/hcs-11/index.d.ts.map +1 -1
  23. package/dist/es/hcs-11/person-builder.d.ts +29 -0
  24. package/dist/es/hcs-11/person-builder.d.ts.map +1 -0
  25. package/dist/es/hcs-11/types.d.ts +165 -0
  26. package/dist/es/hcs-11/types.d.ts.map +1 -0
  27. package/dist/es/index.d.ts +1 -0
  28. package/dist/es/index.d.ts.map +1 -1
  29. package/dist/es/services/mirror-node.d.ts +2 -1
  30. package/dist/es/services/mirror-node.d.ts.map +1 -1
  31. package/dist/es/services/types.d.ts +0 -1
  32. package/dist/es/services/types.d.ts.map +1 -1
  33. package/dist/es/standards-sdk.es.js +9 -7
  34. package/dist/es/standards-sdk.es.js.map +1 -1
  35. package/dist/es/standards-sdk.es10.js +114 -1046
  36. package/dist/es/standards-sdk.es10.js.map +1 -1
  37. package/dist/es/standards-sdk.es100.js +14 -786
  38. package/dist/es/standards-sdk.es100.js.map +1 -1
  39. package/dist/es/standards-sdk.es101.js +38 -168
  40. package/dist/es/standards-sdk.es101.js.map +1 -1
  41. package/dist/es/standards-sdk.es102.js +13 -138
  42. package/dist/es/standards-sdk.es102.js.map +1 -1
  43. package/dist/es/standards-sdk.es103.js +61 -3
  44. package/dist/es/standards-sdk.es103.js.map +1 -1
  45. package/dist/es/standards-sdk.es104.js +1289 -2
  46. package/dist/es/standards-sdk.es104.js.map +1 -1
  47. package/dist/es/standards-sdk.es105.js +32 -2
  48. package/dist/es/standards-sdk.es105.js.map +1 -1
  49. package/dist/es/standards-sdk.es106.js +5 -33
  50. package/dist/es/standards-sdk.es106.js.map +1 -1
  51. package/dist/es/standards-sdk.es107.js +155 -29
  52. package/dist/es/standards-sdk.es107.js.map +1 -1
  53. package/dist/es/standards-sdk.es108.js +793 -9
  54. package/dist/es/standards-sdk.es108.js.map +1 -1
  55. package/dist/es/standards-sdk.es109.js +139 -30
  56. package/dist/es/standards-sdk.es109.js.map +1 -1
  57. package/dist/es/standards-sdk.es11.js +80 -71
  58. package/dist/es/standards-sdk.es11.js.map +1 -1
  59. package/dist/es/standards-sdk.es110.js +169 -16
  60. package/dist/es/standards-sdk.es110.js.map +1 -1
  61. package/dist/es/standards-sdk.es111.js +19 -25
  62. package/dist/es/standards-sdk.es111.js.map +1 -1
  63. package/dist/es/standards-sdk.es112.js +24 -23
  64. package/dist/es/standards-sdk.es112.js.map +1 -1
  65. package/dist/es/standards-sdk.es113.js +23 -35
  66. package/dist/es/standards-sdk.es113.js.map +1 -1
  67. package/dist/es/standards-sdk.es114.js +41 -0
  68. package/dist/es/standards-sdk.es114.js.map +1 -0
  69. package/dist/es/standards-sdk.es12.js +650 -7
  70. package/dist/es/standards-sdk.es12.js.map +1 -1
  71. package/dist/es/standards-sdk.es13.js +10 -664
  72. package/dist/es/standards-sdk.es13.js.map +1 -1
  73. package/dist/es/standards-sdk.es14.js +4 -1
  74. package/dist/es/standards-sdk.es14.js.map +1 -1
  75. package/dist/es/standards-sdk.es17.js +2 -2
  76. package/dist/es/standards-sdk.es18.js +3 -3
  77. package/dist/es/standards-sdk.es18.js.map +1 -1
  78. package/dist/es/standards-sdk.es19.js +82 -1754
  79. package/dist/es/standards-sdk.es19.js.map +1 -1
  80. package/dist/es/standards-sdk.es20.js +5 -3
  81. package/dist/es/standards-sdk.es20.js.map +1 -1
  82. package/dist/es/standards-sdk.es21.js +1703 -4103
  83. package/dist/es/standards-sdk.es21.js.map +1 -1
  84. package/dist/es/standards-sdk.es22.js +3 -6627
  85. package/dist/es/standards-sdk.es22.js.map +1 -1
  86. package/dist/es/standards-sdk.es23.js +4167 -36
  87. package/dist/es/standards-sdk.es23.js.map +1 -1
  88. package/dist/es/standards-sdk.es24.js +6600 -21
  89. package/dist/es/standards-sdk.es24.js.map +1 -1
  90. package/dist/es/standards-sdk.es25.js +36 -2
  91. package/dist/es/standards-sdk.es25.js.map +1 -1
  92. package/dist/es/standards-sdk.es26.js +46 -1039
  93. package/dist/es/standards-sdk.es26.js.map +1 -1
  94. package/dist/es/standards-sdk.es27.js +2 -5
  95. package/dist/es/standards-sdk.es27.js.map +1 -1
  96. package/dist/es/standards-sdk.es28.js +1034 -94
  97. package/dist/es/standards-sdk.es28.js.map +1 -1
  98. package/dist/es/standards-sdk.es29.js +419 -2
  99. package/dist/es/standards-sdk.es29.js.map +1 -1
  100. package/dist/es/standards-sdk.es30.js +2 -16
  101. package/dist/es/standards-sdk.es30.js.map +1 -1
  102. package/dist/es/standards-sdk.es31.js +106 -395
  103. package/dist/es/standards-sdk.es31.js.map +1 -1
  104. package/dist/es/standards-sdk.es32.js +3 -2282
  105. package/dist/es/standards-sdk.es32.js.map +1 -1
  106. package/dist/es/standards-sdk.es34.js +4 -3
  107. package/dist/es/standards-sdk.es34.js.map +1 -1
  108. package/dist/es/standards-sdk.es35.js +87 -405
  109. package/dist/es/standards-sdk.es35.js.map +1 -1
  110. package/dist/es/standards-sdk.es36.js +2 -2
  111. package/dist/es/standards-sdk.es37.js +15 -119
  112. package/dist/es/standards-sdk.es37.js.map +1 -1
  113. package/dist/es/standards-sdk.es38.js +408 -3
  114. package/dist/es/standards-sdk.es38.js.map +1 -1
  115. package/dist/es/standards-sdk.es39.js +2281 -363
  116. package/dist/es/standards-sdk.es39.js.map +1 -1
  117. package/dist/es/standards-sdk.es4.js +1 -1
  118. package/dist/es/standards-sdk.es40.js +362 -4
  119. package/dist/es/standards-sdk.es40.js.map +1 -1
  120. package/dist/es/standards-sdk.es41.js +5 -178
  121. package/dist/es/standards-sdk.es41.js.map +1 -1
  122. package/dist/es/standards-sdk.es42.js +171 -73
  123. package/dist/es/standards-sdk.es42.js.map +1 -1
  124. package/dist/es/standards-sdk.es43.js +74 -107
  125. package/dist/es/standards-sdk.es43.js.map +1 -1
  126. package/dist/es/standards-sdk.es44.js +107 -45
  127. package/dist/es/standards-sdk.es44.js.map +1 -1
  128. package/dist/es/standards-sdk.es45.js +51 -9
  129. package/dist/es/standards-sdk.es45.js.map +1 -1
  130. package/dist/es/standards-sdk.es46.js +9 -96
  131. package/dist/es/standards-sdk.es46.js.map +1 -1
  132. package/dist/es/standards-sdk.es47.js +96 -3
  133. package/dist/es/standards-sdk.es47.js.map +1 -1
  134. package/dist/es/standards-sdk.es48.js +4 -2
  135. package/dist/es/standards-sdk.es48.js.map +1 -1
  136. package/dist/es/standards-sdk.es49.js +2 -113
  137. package/dist/es/standards-sdk.es49.js.map +1 -1
  138. package/dist/es/standards-sdk.es5.js +393 -891
  139. package/dist/es/standards-sdk.es5.js.map +1 -1
  140. package/dist/es/standards-sdk.es50.js +109 -70
  141. package/dist/es/standards-sdk.es50.js.map +1 -1
  142. package/dist/es/standards-sdk.es51.js +73 -5
  143. package/dist/es/standards-sdk.es51.js.map +1 -1
  144. package/dist/es/standards-sdk.es52.js +5 -4
  145. package/dist/es/standards-sdk.es52.js.map +1 -1
  146. package/dist/es/standards-sdk.es53.js +4 -220
  147. package/dist/es/standards-sdk.es53.js.map +1 -1
  148. package/dist/es/standards-sdk.es54.js +214 -51
  149. package/dist/es/standards-sdk.es54.js.map +1 -1
  150. package/dist/es/standards-sdk.es55.js +56 -67
  151. package/dist/es/standards-sdk.es55.js.map +1 -1
  152. package/dist/es/standards-sdk.es56.js +69 -32
  153. package/dist/es/standards-sdk.es56.js.map +1 -1
  154. package/dist/es/standards-sdk.es57.js +26 -57
  155. package/dist/es/standards-sdk.es57.js.map +1 -1
  156. package/dist/es/standards-sdk.es58.js +58 -45
  157. package/dist/es/standards-sdk.es58.js.map +1 -1
  158. package/dist/es/standards-sdk.es59.js +48 -8
  159. package/dist/es/standards-sdk.es59.js.map +1 -1
  160. package/dist/es/standards-sdk.es60.js +8 -63
  161. package/dist/es/standards-sdk.es60.js.map +1 -1
  162. package/dist/es/standards-sdk.es61.js +64 -5
  163. package/dist/es/standards-sdk.es61.js.map +1 -1
  164. package/dist/es/standards-sdk.es62.js +6 -15
  165. package/dist/es/standards-sdk.es62.js.map +1 -1
  166. package/dist/es/standards-sdk.es63.js +15 -7
  167. package/dist/es/standards-sdk.es63.js.map +1 -1
  168. package/dist/es/standards-sdk.es64.js +6 -44
  169. package/dist/es/standards-sdk.es64.js.map +1 -1
  170. package/dist/es/standards-sdk.es65.js +45 -2
  171. package/dist/es/standards-sdk.es65.js.map +1 -1
  172. package/dist/es/standards-sdk.es66.js +2 -136
  173. package/dist/es/standards-sdk.es66.js.map +1 -1
  174. package/dist/es/standards-sdk.es67.js +126 -162
  175. package/dist/es/standards-sdk.es67.js.map +1 -1
  176. package/dist/es/standards-sdk.es68.js +172 -2
  177. package/dist/es/standards-sdk.es68.js.map +1 -1
  178. package/dist/es/standards-sdk.es69.js +3 -3
  179. package/dist/es/standards-sdk.es7.js +959 -94
  180. package/dist/es/standards-sdk.es7.js.map +1 -1
  181. package/dist/es/standards-sdk.es71.js +1 -1
  182. package/dist/es/standards-sdk.es72.js +3 -3
  183. package/dist/es/standards-sdk.es75.js +1 -1
  184. package/dist/es/standards-sdk.es77.js +3 -3
  185. package/dist/es/standards-sdk.es78.js +8 -8
  186. package/dist/es/standards-sdk.es79.js +3 -3
  187. package/dist/es/standards-sdk.es8.js +1049 -393
  188. package/dist/es/standards-sdk.es8.js.map +1 -1
  189. package/dist/es/standards-sdk.es81.js +3 -195
  190. package/dist/es/standards-sdk.es81.js.map +1 -1
  191. package/dist/es/standards-sdk.es82.js +2 -438
  192. package/dist/es/standards-sdk.es82.js.map +1 -1
  193. package/dist/es/standards-sdk.es83.js +2 -25
  194. package/dist/es/standards-sdk.es83.js.map +1 -1
  195. package/dist/es/standards-sdk.es84.js +33 -138
  196. package/dist/es/standards-sdk.es84.js.map +1 -1
  197. package/dist/es/standards-sdk.es85.js +32 -17
  198. package/dist/es/standards-sdk.es85.js.map +1 -1
  199. package/dist/es/standards-sdk.es86.js +9 -29
  200. package/dist/es/standards-sdk.es86.js.map +1 -1
  201. package/dist/es/standards-sdk.es87.js +31 -26
  202. package/dist/es/standards-sdk.es87.js.map +1 -1
  203. package/dist/es/standards-sdk.es88.js +2 -21
  204. package/dist/es/standards-sdk.es88.js.map +1 -1
  205. package/dist/es/standards-sdk.es89.js +78 -38
  206. package/dist/es/standards-sdk.es89.js.map +1 -1
  207. package/dist/es/standards-sdk.es9.js +2 -2
  208. package/dist/es/standards-sdk.es9.js.map +1 -1
  209. package/dist/es/standards-sdk.es90.js +22 -17
  210. package/dist/es/standards-sdk.es90.js.map +1 -1
  211. package/dist/es/standards-sdk.es91.js +140 -53
  212. package/dist/es/standards-sdk.es91.js.map +1 -1
  213. package/dist/es/standards-sdk.es92.js +69 -1267
  214. package/dist/es/standards-sdk.es92.js.map +1 -1
  215. package/dist/es/standards-sdk.es93.js +181 -134
  216. package/dist/es/standards-sdk.es93.js.map +1 -1
  217. package/dist/es/standards-sdk.es94.js +425 -78
  218. package/dist/es/standards-sdk.es94.js.map +1 -1
  219. package/dist/es/standards-sdk.es95.js +21 -80
  220. package/dist/es/standards-sdk.es95.js.map +1 -1
  221. package/dist/es/standards-sdk.es96.js +134 -27
  222. package/dist/es/standards-sdk.es96.js.map +1 -1
  223. package/dist/es/standards-sdk.es97.js +17 -5
  224. package/dist/es/standards-sdk.es97.js.map +1 -1
  225. package/dist/es/standards-sdk.es98.js +21 -151
  226. package/dist/es/standards-sdk.es98.js.map +1 -1
  227. package/dist/es/standards-sdk.es99.js +28 -22
  228. package/dist/es/standards-sdk.es99.js.map +1 -1
  229. package/dist/es/utils/logger.d.ts +1 -0
  230. package/dist/es/utils/logger.d.ts.map +1 -1
  231. package/dist/es/utils/types.d.ts +2 -0
  232. package/dist/es/utils/types.d.ts.map +1 -0
  233. package/dist/umd/fees/fee-config-builder.d.ts.map +1 -0
  234. package/dist/umd/fees/index.d.ts +3 -0
  235. package/dist/umd/fees/index.d.ts.map +1 -0
  236. package/dist/umd/fees/types.d.ts +24 -0
  237. package/dist/umd/fees/types.d.ts.map +1 -0
  238. package/dist/umd/hcs-10/base-client.d.ts +1 -1
  239. package/dist/umd/hcs-10/base-client.d.ts.map +1 -1
  240. package/dist/umd/hcs-10/browser.d.ts +20 -35
  241. package/dist/umd/hcs-10/browser.d.ts.map +1 -1
  242. package/dist/umd/hcs-10/index.d.ts +4 -6
  243. package/dist/umd/hcs-10/index.d.ts.map +1 -1
  244. package/dist/umd/hcs-10/registrations.d.ts.map +1 -1
  245. package/dist/umd/hcs-10/sdk.d.ts +16 -8
  246. package/dist/umd/hcs-10/sdk.d.ts.map +1 -1
  247. package/dist/umd/hcs-10/types.d.ts +2 -62
  248. package/dist/umd/hcs-10/types.d.ts.map +1 -1
  249. package/dist/umd/hcs-11/agent-builder.d.ts +53 -0
  250. package/dist/umd/hcs-11/agent-builder.d.ts.map +1 -0
  251. package/dist/umd/hcs-11/client.d.ts +82 -0
  252. package/dist/umd/hcs-11/client.d.ts.map +1 -0
  253. package/dist/umd/hcs-11/index.d.ts +4 -190
  254. package/dist/umd/hcs-11/index.d.ts.map +1 -1
  255. package/dist/umd/hcs-11/person-builder.d.ts +29 -0
  256. package/dist/umd/hcs-11/person-builder.d.ts.map +1 -0
  257. package/dist/umd/hcs-11/types.d.ts +165 -0
  258. package/dist/umd/hcs-11/types.d.ts.map +1 -0
  259. package/dist/umd/index.d.ts +1 -0
  260. package/dist/umd/index.d.ts.map +1 -1
  261. package/dist/umd/services/mirror-node.d.ts +2 -1
  262. package/dist/umd/services/mirror-node.d.ts.map +1 -1
  263. package/dist/umd/services/types.d.ts +0 -1
  264. package/dist/umd/services/types.d.ts.map +1 -1
  265. package/dist/umd/standards-sdk.umd.js +7 -7
  266. package/dist/umd/standards-sdk.umd.js.map +1 -1
  267. package/dist/umd/utils/logger.d.ts +1 -0
  268. package/dist/umd/utils/logger.d.ts.map +1 -1
  269. package/dist/umd/utils/types.d.ts +2 -0
  270. package/dist/umd/utils/types.d.ts.map +1 -0
  271. package/package.json +3 -4
  272. package/dist/es/hcs-10/agent-builder.d.ts +0 -45
  273. package/dist/es/hcs-10/agent-builder.d.ts.map +0 -1
  274. package/dist/es/hcs-10/fee-config-builder.d.ts.map +0 -1
  275. package/dist/umd/hcs-10/agent-builder.d.ts +0 -45
  276. package/dist/umd/hcs-10/agent-builder.d.ts.map +0 -1
  277. package/dist/umd/hcs-10/fee-config-builder.d.ts.map +0 -1
  278. /package/dist/es/{hcs-10 → fees}/fee-config-builder.d.ts +0 -0
  279. /package/dist/umd/{hcs-10 → fees}/fee-config-builder.d.ts +0 -0
@@ -1,10 +1,653 @@
1
- var InboundTopicType = /* @__PURE__ */ ((InboundTopicType2) => {
2
- InboundTopicType2["PUBLIC"] = "PUBLIC";
3
- InboundTopicType2["CONTROLLED"] = "CONTROLLED";
4
- InboundTopicType2["FEE_BASED"] = "FEE_BASED";
5
- return InboundTopicType2;
6
- })(InboundTopicType || {});
1
+ import Buffer from "./standards-sdk.es21.js";
2
+ import { Client, PrivateKey, Status, AccountUpdateTransaction } from "@hashgraph/sdk";
3
+ import { inscribeWithSigner, inscribe } from "./standards-sdk.es17.js";
4
+ import { Logger } from "./standards-sdk.es14.js";
5
+ import { m as mimeTypesExports } from "./standards-sdk.es22.js";
6
+ import z from "./standards-sdk.es23.js";
7
+ import { ProgressReporter } from "./standards-sdk.es16.js";
8
+ import { HederaMirrorNode } from "./standards-sdk.es18.js";
9
+ import { AIAgentCapability, AIAgentType, ProfileType, capabilityNameToCapabilityMap } from "./standards-sdk.es13.js";
10
+ const SocialLinkSchema = z.object({
11
+ platform: z.string().min(1),
12
+ handle: z.string().min(1)
13
+ });
14
+ const AIAgentDetailsSchema = z.object({
15
+ type: z.nativeEnum(AIAgentType),
16
+ capabilities: z.array(z.nativeEnum(AIAgentCapability)).min(1),
17
+ model: z.string().min(1),
18
+ creator: z.string().optional()
19
+ });
20
+ const BaseProfileSchema = z.object({
21
+ version: z.string().min(1),
22
+ type: z.nativeEnum(ProfileType),
23
+ display_name: z.string().min(1),
24
+ alias: z.string().optional(),
25
+ bio: z.string().optional(),
26
+ socials: z.array(SocialLinkSchema).optional(),
27
+ profileImage: z.string().optional(),
28
+ properties: z.record(z.any()).optional(),
29
+ inboundTopicId: z.string().optional(),
30
+ outboundTopicId: z.string().optional()
31
+ });
32
+ const PersonalProfileSchema = BaseProfileSchema.extend({
33
+ type: z.literal(ProfileType.PERSONAL),
34
+ language: z.string().optional(),
35
+ timezone: z.string().optional()
36
+ });
37
+ const AIAgentProfileSchema = BaseProfileSchema.extend({
38
+ type: z.literal(ProfileType.AI_AGENT),
39
+ aiAgent: AIAgentDetailsSchema
40
+ });
41
+ const HCS11ProfileSchema = z.union([
42
+ PersonalProfileSchema,
43
+ AIAgentProfileSchema
44
+ ]);
45
+ class HCS11Client {
46
+ constructor(config) {
47
+ this.client = config.network === "mainnet" ? Client.forMainnet() : Client.forTestnet();
48
+ this.auth = config.auth;
49
+ this.network = config.network;
50
+ this.mirrorNode = new HederaMirrorNode(
51
+ this.network,
52
+ this.logger
53
+ );
54
+ if (this.auth.privateKey) {
55
+ const privateKey = PrivateKey.fromString(this.auth.privateKey);
56
+ this.client.setOperator(this.auth.operatorId, privateKey);
57
+ }
58
+ this.logger = Logger.getInstance({
59
+ level: config.logLevel || "info",
60
+ module: "HCS-11"
61
+ });
62
+ }
63
+ getClient() {
64
+ return this.client;
65
+ }
66
+ getOperatorId() {
67
+ return this.auth.operatorId;
68
+ }
69
+ createPersonalProfile(displayName, options) {
70
+ return {
71
+ version: "1.0",
72
+ type: ProfileType.PERSONAL,
73
+ display_name: displayName,
74
+ alias: options?.alias,
75
+ bio: options?.bio,
76
+ socials: options?.socials,
77
+ profileImage: options?.profileImage,
78
+ properties: options?.properties,
79
+ inboundTopicId: options?.inboundTopicId,
80
+ outboundTopicId: options?.outboundTopicId
81
+ };
82
+ }
83
+ createAIAgentProfile(displayName, agentType, capabilities, model, options) {
84
+ const validation = this.validateProfile({
85
+ version: "1.0",
86
+ type: ProfileType.AI_AGENT,
87
+ display_name: displayName,
88
+ alias: options?.alias,
89
+ bio: options?.bio,
90
+ socials: options?.socials,
91
+ profileImage: options?.profileImage,
92
+ properties: options?.properties,
93
+ inboundTopicId: options?.inboundTopicId,
94
+ outboundTopicId: options?.outboundTopicId,
95
+ aiAgent: {
96
+ type: agentType,
97
+ capabilities,
98
+ model,
99
+ creator: options?.creator
100
+ }
101
+ });
102
+ if (!validation.valid) {
103
+ throw new Error(
104
+ `Invalid AI Agent Profile: ${validation.errors.join(", ")}`
105
+ );
106
+ }
107
+ return {
108
+ version: "1.0",
109
+ type: ProfileType.AI_AGENT,
110
+ display_name: displayName,
111
+ alias: options?.alias,
112
+ bio: options?.bio,
113
+ socials: options?.socials,
114
+ profileImage: options?.profileImage,
115
+ properties: options?.properties,
116
+ inboundTopicId: options?.inboundTopicId,
117
+ outboundTopicId: options?.outboundTopicId,
118
+ aiAgent: {
119
+ type: agentType,
120
+ capabilities,
121
+ model,
122
+ creator: options?.creator
123
+ }
124
+ };
125
+ }
126
+ validateProfile(profile) {
127
+ const result = HCS11ProfileSchema.safeParse(profile);
128
+ if (result.success) {
129
+ return { valid: true, errors: [] };
130
+ }
131
+ const formattedErrors = result.error.errors.map((err) => {
132
+ const path = err.path.join(".");
133
+ let message = err.message;
134
+ if (err.code === "invalid_type") {
135
+ message = `Expected ${err.expected}, got ${err.received}`;
136
+ } else if (err.code === "invalid_enum_value") {
137
+ const validOptions = err.options?.join(", ");
138
+ message = `Invalid value. Valid options are: ${validOptions}`;
139
+ } else if (err.code === "too_small" && err.type === "string") {
140
+ message = "Cannot be empty";
141
+ }
142
+ return `${path}: ${message}`;
143
+ });
144
+ return { valid: false, errors: formattedErrors };
145
+ }
146
+ profileToJSONString(profile) {
147
+ return JSON.stringify(profile);
148
+ }
149
+ parseProfileFromString(profileStr) {
150
+ try {
151
+ const parsedProfile = JSON.parse(profileStr);
152
+ const validation = this.validateProfile(parsedProfile);
153
+ if (!validation.valid) {
154
+ this.logger.error("Invalid profile format:", validation.errors);
155
+ return null;
156
+ }
157
+ return parsedProfile;
158
+ } catch (error) {
159
+ this.logger.error("Error parsing profile:");
160
+ return null;
161
+ }
162
+ }
163
+ setProfileForAccountMemo(topicId, topicStandard = 1) {
164
+ return `hcs-11:hcs://${topicStandard}/${topicId}`;
165
+ }
166
+ async executeTransaction(transaction) {
167
+ try {
168
+ if (this.auth.privateKey) {
169
+ const signedTx = await transaction.signWithOperator(this.client);
170
+ const response2 = await signedTx.execute(this.client);
171
+ const receipt2 = await response2.getReceipt(this.client);
172
+ if (receipt2.status !== Status.Success) {
173
+ return {
174
+ success: false,
175
+ error: `Transaction failed: ${receipt2.status.toString()}`
176
+ };
177
+ }
178
+ return {
179
+ success: true,
180
+ result: receipt2
181
+ };
182
+ }
183
+ if (!this.auth.signer) {
184
+ throw new Error("No valid authentication method provided");
185
+ }
186
+ const signer = this.auth.signer;
187
+ const frozenTransaction = await transaction.freezeWithSigner(signer);
188
+ const response = await frozenTransaction.executeWithSigner(signer);
189
+ const receipt = await response.getReceiptWithSigner(signer);
190
+ if (receipt.status !== Status.Success) {
191
+ return {
192
+ success: false,
193
+ error: `Transaction failed: ${receipt.status.toString()}`
194
+ };
195
+ }
196
+ return {
197
+ success: true,
198
+ result: receipt
199
+ };
200
+ } catch (error) {
201
+ return {
202
+ success: false,
203
+ error: error instanceof Error ? error.message : "Unknown error during transaction execution"
204
+ };
205
+ }
206
+ }
207
+ async inscribeImage(buffer, fileName, options) {
208
+ try {
209
+ const progressCallback = options?.progressCallback;
210
+ const progressReporter = new ProgressReporter({
211
+ module: "HCS11-Image",
212
+ logger: this.logger,
213
+ callback: progressCallback
214
+ });
215
+ progressReporter.preparing("Preparing to inscribe image", 0);
216
+ const mimeType = mimeTypesExports.lookup(fileName) || "application/octet-stream";
217
+ const waitForConfirmation = options?.waitForConfirmation ?? true;
218
+ let inscriptionResponse;
219
+ if (this.auth.signer) {
220
+ if ("accountId" in this.auth.signer) {
221
+ progressReporter.preparing("Using signer for inscription", 10);
222
+ inscriptionResponse = await inscribeWithSigner(
223
+ {
224
+ type: "buffer",
225
+ buffer,
226
+ fileName,
227
+ mimeType
228
+ },
229
+ this.auth.signer,
230
+ {
231
+ network: this.network,
232
+ waitForConfirmation,
233
+ waitMaxAttempts: 150,
234
+ waitIntervalMs: 4e3,
235
+ logging: {
236
+ level: "debug"
237
+ },
238
+ progressCallback: (data) => {
239
+ const adjustedPercent = 10 + (data.progressPercent || 0) * 0.8;
240
+ progressReporter.report({
241
+ stage: data.stage,
242
+ message: data.message,
243
+ progressPercent: adjustedPercent,
244
+ details: data.details
245
+ });
246
+ }
247
+ }
248
+ );
249
+ } else {
250
+ progressReporter.failed(
251
+ "Signer must be a DAppSigner for inscription"
252
+ );
253
+ throw new Error("Signer must be a DAppSigner for inscription");
254
+ }
255
+ } else {
256
+ if (!this.auth.privateKey) {
257
+ progressReporter.failed("Private key is required for inscription");
258
+ this.logger.error("Private key is required for inscription");
259
+ throw new Error("Private key is required for inscription");
260
+ }
261
+ progressReporter.preparing("Using private key for inscription", 10);
262
+ inscriptionResponse = await inscribe(
263
+ {
264
+ type: "buffer",
265
+ buffer,
266
+ fileName,
267
+ mimeType
268
+ },
269
+ {
270
+ accountId: this.auth.operatorId,
271
+ privateKey: this.auth.privateKey,
272
+ network: this.network
273
+ },
274
+ {
275
+ waitForConfirmation,
276
+ waitMaxAttempts: 150,
277
+ waitIntervalMs: 2e3,
278
+ logging: {
279
+ level: "debug"
280
+ },
281
+ progressCallback: (data) => {
282
+ const adjustedPercent = 10 + (data.progressPercent || 0) * 0.8;
283
+ progressReporter.report({
284
+ stage: data.stage,
285
+ message: data.message,
286
+ progressPercent: adjustedPercent,
287
+ details: data.details
288
+ });
289
+ }
290
+ }
291
+ );
292
+ }
293
+ if (inscriptionResponse.confirmed) {
294
+ progressReporter.completed("Image inscription completed", {
295
+ topic_id: inscriptionResponse.inscription.topic_id
296
+ });
297
+ return {
298
+ imageTopicId: inscriptionResponse.inscription.topic_id || "",
299
+ transactionId: inscriptionResponse.result.jobId,
300
+ success: true
301
+ };
302
+ } else {
303
+ progressReporter.verifying("Waiting for inscription confirmation", 50, {
304
+ jobId: inscriptionResponse.result.jobId
305
+ });
306
+ return {
307
+ imageTopicId: "",
308
+ transactionId: inscriptionResponse.result.jobId,
309
+ success: false,
310
+ error: "Inscription not confirmed"
311
+ };
312
+ }
313
+ } catch (error) {
314
+ this.logger.error("Error inscribing image:", error);
315
+ return {
316
+ imageTopicId: "",
317
+ transactionId: "",
318
+ success: false,
319
+ error: error.message || "Error inscribing image"
320
+ };
321
+ }
322
+ }
323
+ async inscribeProfile(profile, options) {
324
+ this.logger.info("Inscribing HCS-11 profile");
325
+ const progressCallback = options?.progressCallback;
326
+ const progressReporter = new ProgressReporter({
327
+ module: "HCS11-Profile",
328
+ logger: this.logger,
329
+ callback: progressCallback
330
+ });
331
+ progressReporter.preparing("Validating profile data", 5);
332
+ const validation = this.validateProfile(profile);
333
+ if (!validation.valid) {
334
+ progressReporter.failed(
335
+ `Invalid profile: ${validation.errors.join(", ")}`
336
+ );
337
+ return {
338
+ profileTopicId: "",
339
+ transactionId: "",
340
+ success: false,
341
+ error: `Invalid profile: ${validation.errors.join(", ")}`
342
+ };
343
+ }
344
+ progressReporter.preparing("Formatting profile for inscription", 15);
345
+ const profileJson = this.profileToJSONString(profile);
346
+ const fileName = `profile-${profile.display_name.toLowerCase().replace(/\s+/g, "-")}.json`;
347
+ try {
348
+ const contentBuffer = Buffer.from(profileJson, "utf-8");
349
+ const contentType = "application/json";
350
+ progressReporter.preparing("Preparing profile for inscription", 20);
351
+ const input = {
352
+ type: "buffer",
353
+ buffer: contentBuffer,
354
+ fileName,
355
+ mimeType: contentType
356
+ };
357
+ const inscriptionOptions = {
358
+ waitForConfirmation: true,
359
+ mode: "file",
360
+ network: this.network,
361
+ waitMaxAttempts: 100,
362
+ waitIntervalMs: 2e3,
363
+ progressCallback: (data) => {
364
+ const adjustedPercent = 20 + Number(data?.progressPercent || 0) * 0.75;
365
+ progressReporter?.report({
366
+ stage: data.stage,
367
+ message: data.message,
368
+ progressPercent: adjustedPercent,
369
+ details: data.details
370
+ });
371
+ }
372
+ };
373
+ progressReporter.submitting("Submitting profile to Hedera network", 30);
374
+ const inscriptionResponse = this.auth.privateKey ? await inscribe(
375
+ input,
376
+ {
377
+ accountId: this.auth.operatorId,
378
+ privateKey: this.auth.privateKey,
379
+ network: this.network
380
+ },
381
+ inscriptionOptions
382
+ ) : await inscribeWithSigner(
383
+ input,
384
+ this.auth.signer,
385
+ inscriptionOptions
386
+ );
387
+ if (!inscriptionResponse.confirmed || !inscriptionResponse.inscription.topic_id) {
388
+ progressReporter.failed("Failed to inscribe profile content");
389
+ return {
390
+ profileTopicId: "",
391
+ transactionId: "",
392
+ success: false,
393
+ error: "Failed to inscribe profile content"
394
+ };
395
+ }
396
+ const topicId = inscriptionResponse.inscription.topic_id;
397
+ progressReporter.completed("Profile inscription completed", {
398
+ topicId,
399
+ transactionId: inscriptionResponse.result.transactionId
400
+ });
401
+ return {
402
+ profileTopicId: topicId,
403
+ transactionId: inscriptionResponse.result.transactionId,
404
+ success: true
405
+ };
406
+ } catch (error) {
407
+ progressReporter.failed(
408
+ `Error inscribing profile: ${error.message || "Unknown error"}`
409
+ );
410
+ return {
411
+ profileTopicId: "",
412
+ transactionId: "",
413
+ success: false,
414
+ error: error.message || "Unknown error during inscription"
415
+ };
416
+ }
417
+ }
418
+ async updateAccountMemoWithProfile(accountId, profileTopicId) {
419
+ try {
420
+ this.logger.info(
421
+ `Updating account memo for ${accountId} with profile ${profileTopicId}`
422
+ );
423
+ const memo = this.setProfileForAccountMemo(profileTopicId);
424
+ const transaction = new AccountUpdateTransaction().setAccountMemo(memo).setAccountId(accountId);
425
+ return this.executeTransaction(transaction);
426
+ } catch (error) {
427
+ this.logger.error(
428
+ `Error updating account memo: ${error instanceof Error ? error.message : "Unknown error"}`
429
+ );
430
+ return {
431
+ success: false,
432
+ error: error instanceof Error ? error.message : "Unknown error updating account memo"
433
+ };
434
+ }
435
+ }
436
+ /**
437
+ * Creates and inscribes a profile.
438
+ *
439
+ * @param profile - The profile to create and inscribe.
440
+ * @param updateAccountMemo - Whether to update the account memo with the profile.
441
+ * @param options - Optional configuration options.
442
+ * @returns A promise that resolves to the inscription result.
443
+ */
444
+ async createAndInscribeProfile(profile, updateAccountMemo = true, options) {
445
+ const progressCallback = options?.progressCallback;
446
+ const progressReporter = new ProgressReporter({
447
+ module: "HCS11-ProfileCreation",
448
+ logger: this.logger,
449
+ callback: progressCallback
450
+ });
451
+ progressReporter.preparing("Starting profile creation process", 0);
452
+ const inscriptionProgress = progressReporter.createSubProgress({
453
+ minPercent: 0,
454
+ maxPercent: 80,
455
+ logPrefix: "Inscription"
456
+ });
457
+ const inscriptionResult = await this.inscribeProfile(profile, {
458
+ ...options,
459
+ progressCallback: (data) => {
460
+ inscriptionProgress.report({
461
+ stage: data.stage,
462
+ message: data.message,
463
+ progressPercent: data.progressPercent,
464
+ details: data.details
465
+ });
466
+ }
467
+ });
468
+ if (!inscriptionResult?.success) {
469
+ progressReporter.failed("Profile inscription failed", {
470
+ error: inscriptionResult?.error
471
+ });
472
+ return inscriptionResult;
473
+ }
474
+ progressReporter.confirming("Profile inscribed, updating account memo", 85);
475
+ if (updateAccountMemo) {
476
+ const memoResult = await this.updateAccountMemoWithProfile(
477
+ this.auth.operatorId,
478
+ inscriptionResult.profileTopicId
479
+ );
480
+ if (!memoResult.success) {
481
+ progressReporter.failed("Failed to update account memo", {
482
+ error: memoResult?.error
483
+ });
484
+ return {
485
+ ...inscriptionResult,
486
+ success: false,
487
+ error: memoResult?.error
488
+ };
489
+ }
490
+ }
491
+ progressReporter.completed("Profile creation completed successfully", {
492
+ profileTopicId: inscriptionResult.profileTopicId,
493
+ transactionId: inscriptionResult.transactionId
494
+ });
495
+ return inscriptionResult;
496
+ }
497
+ /**
498
+ * Gets the capabilities from the capability names.
499
+ *
500
+ * @param capabilityNames - The capability names to get the capabilities for.
501
+ * @returns The capabilities.
502
+ */
503
+ async getCapabilitiesFromTags(capabilityNames) {
504
+ const capabilities = [];
505
+ if (capabilityNames.length === 0) {
506
+ return [AIAgentCapability.TEXT_GENERATION];
507
+ }
508
+ for (const capabilityName of capabilityNames) {
509
+ const capability = capabilityNameToCapabilityMap[capabilityName.toLowerCase()];
510
+ if (capability !== void 0 && !capabilities.includes(capability)) {
511
+ capabilities.push(capability);
512
+ }
513
+ }
514
+ if (capabilities.length === 0) {
515
+ capabilities.push(AIAgentCapability.TEXT_GENERATION);
516
+ }
517
+ return capabilities;
518
+ }
519
+ /**
520
+ * Gets the agent type from the metadata.
521
+ *
522
+ * @param metadata - The metadata of the agent.
523
+ * @returns The agent type.
524
+ */
525
+ getAgentTypeFromMetadata(metadata) {
526
+ if (metadata.type === "autonomous") {
527
+ return AIAgentType.AUTONOMOUS;
528
+ } else {
529
+ return AIAgentType.MANUAL;
530
+ }
531
+ }
532
+ /**
533
+ * Fetches a profile from the account memo.
534
+ *
535
+ * @param accountId - The account ID of the agent to fetch the profile for.
536
+ * @param network - The network to use for the fetch.
537
+ * @returns A promise that resolves to the profile.
538
+ */
539
+ async fetchProfileByAccountId(accountId, network) {
540
+ try {
541
+ this.logger.info(
542
+ `Fetching profile for account ${accountId.toString()} on ${this.network}`
543
+ );
544
+ const memo = await this.mirrorNode.getAccountMemo(accountId.toString());
545
+ this.logger.info(`Got account memo: ${memo}`);
546
+ if (!memo?.startsWith("hcs-11:")) {
547
+ return {
548
+ success: false,
549
+ error: `Account ${accountId.toString()} does not have a valid HCS-11 memo`
550
+ };
551
+ }
552
+ this.logger.info(`Found HCS-11 memo: ${memo}`);
553
+ const protocolReference = memo.substring(7);
554
+ if (protocolReference?.startsWith("hcs://")) {
555
+ const hcsFormat = protocolReference.match(/hcs:\/\/(\d+)\/(.+)/);
556
+ if (!hcsFormat) {
557
+ return {
558
+ success: false,
559
+ error: `Invalid HCS protocol reference format: ${protocolReference}`
560
+ };
561
+ }
562
+ const [_, protocolId, profileTopicId] = hcsFormat;
563
+ const networkParam = network || this.network || "mainnet";
564
+ this.logger.info(
565
+ `Retrieving profile from Kiloscribe CDN: ${profileTopicId}`
566
+ );
567
+ const cdnUrl = `https://kiloscribe.com/api/inscription-cdn/${profileTopicId}?network=${networkParam}`;
568
+ try {
569
+ const response = await fetch(cdnUrl);
570
+ if (!response.ok) {
571
+ return {
572
+ success: false,
573
+ error: `Failed to fetch profile from Kiloscribe CDN: ${response.statusText}`
574
+ };
575
+ }
576
+ const profileData = await response.json();
577
+ if (!profileData) {
578
+ return {
579
+ success: false,
580
+ error: `No profile data found for topic ${profileTopicId}`
581
+ };
582
+ }
583
+ return {
584
+ success: true,
585
+ profile: profileData,
586
+ topicInfo: {
587
+ inboundTopic: profileData.inboundTopicId,
588
+ outboundTopic: profileData.outboundTopicId,
589
+ profileTopicId
590
+ }
591
+ };
592
+ } catch (cdnError) {
593
+ this.logger.error(
594
+ `Error retrieving from Kiloscribe CDN: ${cdnError.message}`
595
+ );
596
+ return {
597
+ success: false,
598
+ error: `Error retrieving from Kiloscribe CDN: ${cdnError.message}`
599
+ };
600
+ }
601
+ } else if (protocolReference.startsWith("ipfs://")) {
602
+ this.logger.warn("IPFS protocol references are not fully supported");
603
+ const response = await fetch(
604
+ `https://ipfs.io/ipfs/${protocolReference.replace("ipfs://", "")}`
605
+ );
606
+ const profileData = await response.json();
607
+ return {
608
+ success: true,
609
+ profile: profileData,
610
+ topicInfo: {
611
+ inboundTopic: profileData.inboundTopicId,
612
+ outboundTopic: profileData.outboundTopicId,
613
+ profileTopicId: profileData.profileTopicId
614
+ }
615
+ };
616
+ } else if (protocolReference.startsWith("ar://")) {
617
+ const arTxId = protocolReference.replace("ar://", "");
618
+ const response = await fetch(`https://arweave.net/${arTxId}`);
619
+ if (!response.ok) {
620
+ return {
621
+ success: false,
622
+ error: `Failed to fetch profile from Arweave ${arTxId}: ${response.statusText}`
623
+ };
624
+ }
625
+ const profileData = await response.json();
626
+ return {
627
+ success: true,
628
+ profile: profileData,
629
+ topicInfo: {
630
+ inboundTopic: profileData.inboundTopicId,
631
+ outboundTopic: profileData.outboundTopicId,
632
+ profileTopicId: profileData.profileTopicId
633
+ }
634
+ };
635
+ } else {
636
+ return {
637
+ success: false,
638
+ error: `Invalid protocol reference format: ${protocolReference}`
639
+ };
640
+ }
641
+ } catch (error) {
642
+ this.logger.error(`Error fetching profile: ${error.message}`);
643
+ return {
644
+ success: false,
645
+ error: `Error fetching profile: ${error.message}`
646
+ };
647
+ }
648
+ }
649
+ }
7
650
  export {
8
- InboundTopicType
651
+ HCS11Client
9
652
  };
10
653
  //# sourceMappingURL=standards-sdk.es12.js.map