@hashgraphonline/standards-sdk 0.0.56 → 0.0.58

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