@hashgraphonline/standards-agent-kit 0.2.119 → 0.2.121

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 (132) hide show
  1. package/dist/cjs/config/ContentReferenceConfig.d.ts +8 -0
  2. package/dist/cjs/index.d.ts +2 -0
  3. package/dist/cjs/standards-agent-kit.cjs +1 -1
  4. package/dist/cjs/standards-agent-kit.cjs.map +1 -1
  5. package/dist/cjs/tools/hcs6/CreateDynamicRegistryTool.d.ts +7 -7
  6. package/dist/cjs/tools/hcs6/QueryDynamicRegistryTool.d.ts +3 -3
  7. package/dist/cjs/tools/hcs6/RegisterDynamicHashinalTool.d.ts +7 -7
  8. package/dist/cjs/tools/hcs6/UpdateDynamicHashinalTool.d.ts +7 -7
  9. package/dist/cjs/tools/inscriber/InscribeFromBufferTool.d.ts +7 -6
  10. package/dist/cjs/tools/inscriber/base-inscriber-tools.d.ts +11 -0
  11. package/dist/cjs/tools/inscriber/inscriber-tool-params.d.ts +3 -0
  12. package/dist/cjs/types/content-resolver.d.ts +6 -0
  13. package/dist/es/config/ContentReferenceConfig.d.ts +8 -0
  14. package/dist/es/index.d.ts +2 -0
  15. package/dist/es/standards-agent-kit.es.js +42 -40
  16. package/dist/es/standards-agent-kit.es.js.map +1 -1
  17. package/dist/es/standards-agent-kit.es10.js +72 -23
  18. package/dist/es/standards-agent-kit.es10.js.map +1 -1
  19. package/dist/es/standards-agent-kit.es11.js +27 -27
  20. package/dist/es/standards-agent-kit.es11.js.map +1 -1
  21. package/dist/es/standards-agent-kit.es12.js +20 -30
  22. package/dist/es/standards-agent-kit.es12.js.map +1 -1
  23. package/dist/es/standards-agent-kit.es13.js +27 -37
  24. package/dist/es/standards-agent-kit.es13.js.map +1 -1
  25. package/dist/es/standards-agent-kit.es14.js +48 -60
  26. package/dist/es/standards-agent-kit.es14.js.map +1 -1
  27. package/dist/es/standards-agent-kit.es15.js +60 -23
  28. package/dist/es/standards-agent-kit.es15.js.map +1 -1
  29. package/dist/es/standards-agent-kit.es16.js +23 -23
  30. package/dist/es/standards-agent-kit.es16.js.map +1 -1
  31. package/dist/es/standards-agent-kit.es17.js +23 -33
  32. package/dist/es/standards-agent-kit.es17.js.map +1 -1
  33. package/dist/es/standards-agent-kit.es18.js +34 -10
  34. package/dist/es/standards-agent-kit.es18.js.map +1 -1
  35. package/dist/es/standards-agent-kit.es19.js +16 -155
  36. package/dist/es/standards-agent-kit.es19.js.map +1 -1
  37. package/dist/es/standards-agent-kit.es2.js +21 -1567
  38. package/dist/es/standards-agent-kit.es2.js.map +1 -1
  39. package/dist/es/standards-agent-kit.es20.js +150 -22
  40. package/dist/es/standards-agent-kit.es20.js.map +1 -1
  41. package/dist/es/standards-agent-kit.es21.js +25 -39
  42. package/dist/es/standards-agent-kit.es21.js.map +1 -1
  43. package/dist/es/standards-agent-kit.es22.js +26 -28
  44. package/dist/es/standards-agent-kit.es22.js.map +1 -1
  45. package/dist/es/standards-agent-kit.es23.js +16 -19
  46. package/dist/es/standards-agent-kit.es23.js.map +1 -1
  47. package/dist/es/standards-agent-kit.es24.js +21 -15
  48. package/dist/es/standards-agent-kit.es24.js.map +1 -1
  49. package/dist/es/standards-agent-kit.es25.js +18 -21
  50. package/dist/es/standards-agent-kit.es25.js.map +1 -1
  51. package/dist/es/standards-agent-kit.es26.js +35 -32
  52. package/dist/es/standards-agent-kit.es26.js.map +1 -1
  53. package/dist/es/standards-agent-kit.es27.js +38 -25
  54. package/dist/es/standards-agent-kit.es27.js.map +1 -1
  55. package/dist/es/standards-agent-kit.es28.js +24 -37
  56. package/dist/es/standards-agent-kit.es28.js.map +1 -1
  57. package/dist/es/standards-agent-kit.es29.js +26 -43
  58. package/dist/es/standards-agent-kit.es29.js.map +1 -1
  59. package/dist/es/standards-agent-kit.es3.js +1532 -55
  60. package/dist/es/standards-agent-kit.es3.js.map +1 -1
  61. package/dist/es/standards-agent-kit.es30.js +35 -40
  62. package/dist/es/standards-agent-kit.es30.js.map +1 -1
  63. package/dist/es/standards-agent-kit.es31.js +35 -39
  64. package/dist/es/standards-agent-kit.es31.js.map +1 -1
  65. package/dist/es/standards-agent-kit.es32.js +39 -23
  66. package/dist/es/standards-agent-kit.es32.js.map +1 -1
  67. package/dist/es/standards-agent-kit.es33.js +39 -168
  68. package/dist/es/standards-agent-kit.es33.js.map +1 -1
  69. package/dist/es/standards-agent-kit.es34.js +93 -96
  70. package/dist/es/standards-agent-kit.es34.js.map +1 -1
  71. package/dist/es/standards-agent-kit.es35.js +99 -64
  72. package/dist/es/standards-agent-kit.es35.js.map +1 -1
  73. package/dist/es/standards-agent-kit.es36.js +166 -64
  74. package/dist/es/standards-agent-kit.es36.js.map +1 -1
  75. package/dist/es/standards-agent-kit.es37.js +87 -30
  76. package/dist/es/standards-agent-kit.es37.js.map +1 -1
  77. package/dist/es/standards-agent-kit.es38.js +38 -242
  78. package/dist/es/standards-agent-kit.es38.js.map +1 -1
  79. package/dist/es/standards-agent-kit.es39.js +246 -138
  80. package/dist/es/standards-agent-kit.es39.js.map +1 -1
  81. package/dist/es/standards-agent-kit.es4.js +39 -33
  82. package/dist/es/standards-agent-kit.es4.js.map +1 -1
  83. package/dist/es/standards-agent-kit.es40.js +134 -26
  84. package/dist/es/standards-agent-kit.es40.js.map +1 -1
  85. package/dist/es/standards-agent-kit.es41.js +27 -22
  86. package/dist/es/standards-agent-kit.es41.js.map +1 -1
  87. package/dist/es/standards-agent-kit.es42.js +24 -3
  88. package/dist/es/standards-agent-kit.es42.js.map +1 -1
  89. package/dist/es/standards-agent-kit.es43.js +7 -0
  90. package/dist/es/standards-agent-kit.es43.js.map +1 -0
  91. package/dist/es/standards-agent-kit.es5.js +65 -32
  92. package/dist/es/standards-agent-kit.es5.js.map +1 -1
  93. package/dist/es/standards-agent-kit.es6.js +35 -311
  94. package/dist/es/standards-agent-kit.es6.js.map +1 -1
  95. package/dist/es/standards-agent-kit.es7.js +320 -20
  96. package/dist/es/standards-agent-kit.es7.js.map +1 -1
  97. package/dist/es/standards-agent-kit.es8.js +19 -227
  98. package/dist/es/standards-agent-kit.es8.js.map +1 -1
  99. package/dist/es/standards-agent-kit.es9.js +216 -65
  100. package/dist/es/standards-agent-kit.es9.js.map +1 -1
  101. package/dist/es/tools/hcs6/CreateDynamicRegistryTool.d.ts +7 -7
  102. package/dist/es/tools/hcs6/QueryDynamicRegistryTool.d.ts +3 -3
  103. package/dist/es/tools/hcs6/RegisterDynamicHashinalTool.d.ts +7 -7
  104. package/dist/es/tools/hcs6/UpdateDynamicHashinalTool.d.ts +7 -7
  105. package/dist/es/tools/inscriber/InscribeFromBufferTool.d.ts +7 -6
  106. package/dist/es/tools/inscriber/base-inscriber-tools.d.ts +11 -0
  107. package/dist/es/tools/inscriber/inscriber-tool-params.d.ts +3 -0
  108. package/dist/es/types/content-resolver.d.ts +6 -0
  109. package/dist/umd/config/ContentReferenceConfig.d.ts +8 -0
  110. package/dist/umd/index.d.ts +2 -0
  111. package/dist/umd/standards-agent-kit.umd.js +1 -1
  112. package/dist/umd/standards-agent-kit.umd.js.map +1 -1
  113. package/dist/umd/tools/hcs6/CreateDynamicRegistryTool.d.ts +7 -7
  114. package/dist/umd/tools/hcs6/QueryDynamicRegistryTool.d.ts +3 -3
  115. package/dist/umd/tools/hcs6/RegisterDynamicHashinalTool.d.ts +7 -7
  116. package/dist/umd/tools/hcs6/UpdateDynamicHashinalTool.d.ts +7 -7
  117. package/dist/umd/tools/inscriber/InscribeFromBufferTool.d.ts +7 -6
  118. package/dist/umd/tools/inscriber/base-inscriber-tools.d.ts +11 -0
  119. package/dist/umd/tools/inscriber/inscriber-tool-params.d.ts +3 -0
  120. package/dist/umd/types/content-resolver.d.ts +6 -0
  121. package/package.json +2 -2
  122. package/src/builders/hcs10/hcs10-builder.ts +2 -3
  123. package/src/config/ContentReferenceConfig.ts +30 -0
  124. package/src/index.ts +3 -1
  125. package/src/tools/hcs6/CreateDynamicRegistryTool.ts +22 -33
  126. package/src/tools/hcs6/QueryDynamicRegistryTool.ts +23 -33
  127. package/src/tools/hcs6/RegisterDynamicHashinalTool.ts +25 -35
  128. package/src/tools/hcs6/UpdateDynamicHashinalTool.ts +25 -36
  129. package/src/tools/inscriber/InscribeFromBufferTool.ts +239 -120
  130. package/src/tools/inscriber/base-inscriber-tools.ts +19 -0
  131. package/src/tools/inscriber/inscriber-tool-params.ts +3 -0
  132. package/src/types/content-resolver.ts +11 -0
@@ -1,95 +1,1572 @@
1
1
  import { BaseServiceBuilder } from "hedera-agent-kit";
2
- import { HCS2Client } from "@hashgraphonline/standards-sdk";
3
- class HCS2Builder extends BaseServiceBuilder {
4
- constructor(hederaKit) {
2
+ import { Logger, HCS10Client as HCS10Client$1, AgentBuilder, AIAgentCapability, InboundTopicType, FeeConfigBuilder } from "@hashgraphonline/standards-sdk";
3
+ import fs from "fs";
4
+ import path__default from "path";
5
+ import axios from "axios";
6
+ const NOT_INITIALIZED_ERROR = "ConnectionsManager not initialized";
7
+ class HCS10Builder extends BaseServiceBuilder {
8
+ constructor(hederaKit, stateManager, options) {
5
9
  super(hederaKit);
10
+ this.useEncryption = false;
11
+ this.guardedRegistryBaseUrl = "";
12
+ this.stateManager = stateManager;
13
+ this.useEncryption = options?.useEncryption || false;
14
+ this.guardedRegistryBaseUrl = options?.registryUrl || "";
15
+ const network = this.hederaKit.client.network;
16
+ this.network = network.toString().includes("mainnet") ? "mainnet" : "testnet";
17
+ const operatorId = this.hederaKit.signer.getAccountId().toString();
18
+ const operatorPrivateKey = this.hederaKit.signer?.getOperatorPrivateKey() ? this.hederaKit.signer.getOperatorPrivateKey().toStringRaw() : "";
19
+ this.sdkLogger = new Logger({
20
+ module: "HCS10Builder",
21
+ level: options?.logLevel || "info"
22
+ });
23
+ this.standardClient = new HCS10Client$1({
24
+ network: this.network,
25
+ operatorId,
26
+ operatorPrivateKey,
27
+ logLevel: options?.logLevel || "info"
28
+ });
29
+ if (this.stateManager) {
30
+ this.stateManager.initializeConnectionsManager(this.standardClient);
31
+ }
32
+ }
33
+ /**
34
+ * Get the operator account ID
35
+ */
36
+ getOperatorId() {
37
+ const operator = this.standardClient.getClient().operatorAccountId;
38
+ if (!operator) {
39
+ throw new Error("Operator Account ID not configured in standard client.");
40
+ }
41
+ return operator.toString();
42
+ }
43
+ /**
44
+ * Get the network type
45
+ */
46
+ getNetwork() {
47
+ return this.network;
48
+ }
49
+ /**
50
+ * Get state manager instance
51
+ */
52
+ getStateManager() {
53
+ return this.stateManager;
54
+ }
55
+ /**
56
+ * Get account and signer information
57
+ */
58
+ getAccountAndSigner() {
59
+ const result = this.standardClient.getAccountAndSigner();
60
+ return {
61
+ accountId: result.accountId,
62
+ signer: result.signer
63
+ };
64
+ }
65
+ /**
66
+ * Get the inbound topic ID for the current operator
67
+ */
68
+ async getInboundTopicId() {
69
+ try {
70
+ const operatorId = this.getOperatorId();
71
+ this.logger.info(
72
+ `[HCS10Builder] Retrieving profile for operator ${operatorId} to find inbound topic...`
73
+ );
74
+ const profileResponse = await this.getAgentProfile(operatorId);
75
+ if (profileResponse.success && profileResponse.topicInfo?.inboundTopic) {
76
+ this.logger.info(
77
+ `[HCS10Builder] Found inbound topic for operator ${operatorId}: ${profileResponse.topicInfo.inboundTopic}`
78
+ );
79
+ return profileResponse.topicInfo.inboundTopic;
80
+ } else {
81
+ throw new Error(
82
+ `Could not retrieve inbound topic from profile for ${operatorId}. Profile success: ${profileResponse.success}, Error: ${profileResponse.error}`
83
+ );
84
+ }
85
+ } catch (error) {
86
+ this.logger.error(
87
+ `[HCS10Builder] Error fetching operator's inbound topic ID (${this.getOperatorId()}):`,
88
+ error
89
+ );
90
+ const operatorId = this.getOperatorId();
91
+ let detailedMessage = `Failed to get inbound topic ID for operator ${operatorId}.`;
92
+ if (error instanceof Error && error.message.includes("does not have a valid HCS-11 memo")) {
93
+ detailedMessage += ` The account profile may not exist or is invalid. Please ensure this operator account (${operatorId}) is registered as an HCS-10 agent. You might need to register it first (e.g., using the 'register_agent' tool or SDK function).`;
94
+ } else if (error instanceof Error) {
95
+ detailedMessage += ` Reason: ${error.message}`;
96
+ } else {
97
+ detailedMessage += ` Unexpected error: ${String(error)}`;
98
+ }
99
+ throw new Error(detailedMessage);
100
+ }
101
+ }
102
+ /**
103
+ * Get agent profile
104
+ */
105
+ async getAgentProfile(accountId) {
106
+ try {
107
+ return await this.standardClient.retrieveProfile(accountId);
108
+ } catch (error) {
109
+ this.logger.error(
110
+ `[HCS10Builder] Error retrieving agent profile for account ${accountId}:`,
111
+ error
112
+ );
113
+ throw error;
114
+ }
115
+ }
116
+ /**
117
+ * Submit connection request
118
+ */
119
+ async submitConnectionRequest(inboundTopicId, memo) {
120
+ return this.standardClient.submitConnectionRequest(
121
+ inboundTopicId,
122
+ memo
123
+ );
124
+ }
125
+ /**
126
+ * Handle connection request
127
+ */
128
+ async handleConnectionRequest(inboundTopicId, requestingAccountId, connectionRequestId, feeConfig) {
129
+ try {
130
+ const result = await this.standardClient.handleConnectionRequest(
131
+ inboundTopicId,
132
+ requestingAccountId,
133
+ connectionRequestId,
134
+ feeConfig
135
+ );
136
+ if (result && result.connectionTopicId && typeof result.connectionTopicId === "object" && "toString" in result.connectionTopicId) {
137
+ result.connectionTopicId = result.connectionTopicId.toString();
138
+ }
139
+ return result;
140
+ } catch (error) {
141
+ this.logger.error(
142
+ `Error handling connection request #${connectionRequestId} for topic ${inboundTopicId}:`,
143
+ error
144
+ );
145
+ throw new Error(
146
+ `Failed to handle connection request: ${error instanceof Error ? error.message : String(error)}`
147
+ );
148
+ }
149
+ }
150
+ /**
151
+ * Send message to a topic
152
+ */
153
+ async sendMessage(topicId, data, memo) {
154
+ if (topicId && typeof topicId === "object" && "toString" in topicId) {
155
+ topicId = topicId?.toString();
156
+ }
157
+ if (!topicId || typeof topicId !== "string") {
158
+ throw new Error(
159
+ `Invalid topic ID provided to sendMessage: ${JSON.stringify(topicId)}`
160
+ );
161
+ }
162
+ try {
163
+ const messageResponse = await this.standardClient.sendMessage(
164
+ topicId,
165
+ data,
166
+ memo,
167
+ void 0
168
+ );
169
+ return {
170
+ sequenceNumber: messageResponse.topicSequenceNumber?.toNumber(),
171
+ receipt: messageResponse,
172
+ transactionId: "transactionId" in messageResponse ? messageResponse.transactionId?.toString() : void 0
173
+ };
174
+ } catch (error) {
175
+ this.logger.error(`Error sending message to topic ${topicId}:`, error);
176
+ throw new Error(
177
+ `Failed to send message: ${error instanceof Error ? error.message : String(error)}`
178
+ );
179
+ }
180
+ }
181
+ /**
182
+ * Get messages from a topic
183
+ */
184
+ async getMessages(topicId) {
185
+ if (topicId && typeof topicId === "object" && "toString" in topicId) {
186
+ topicId = topicId?.toString();
187
+ }
188
+ if (!topicId || typeof topicId !== "string") {
189
+ throw new Error(
190
+ `Invalid topic ID provided to getMessages: ${JSON.stringify(topicId)}`
191
+ );
192
+ }
193
+ try {
194
+ const result = await this.standardClient.getMessages(topicId);
195
+ const mappedMessages = result.messages.map(
196
+ (sdkMessage) => {
197
+ const timestamp = sdkMessage?.created?.getTime() || 0;
198
+ return {
199
+ ...sdkMessage,
200
+ timestamp,
201
+ data: sdkMessage.data || "",
202
+ sequence_number: sdkMessage.sequence_number,
203
+ p: "hcs-10"
204
+ };
205
+ }
206
+ );
207
+ mappedMessages.sort(
208
+ (a, b) => a.timestamp - b.timestamp
209
+ );
210
+ return { messages: mappedMessages };
211
+ } catch (error) {
212
+ this.logger.error(`Error getting messages from topic ${topicId}:`, error);
213
+ return { messages: [] };
214
+ }
215
+ }
216
+ /**
217
+ * Get message stream from a topic
218
+ */
219
+ async getMessageStream(topicId) {
220
+ if (topicId && typeof topicId === "object" && "toString" in topicId) {
221
+ topicId = topicId?.toString();
222
+ }
223
+ if (!topicId || typeof topicId !== "string") {
224
+ throw new Error(
225
+ `Invalid topic ID provided to getMessageStream: ${JSON.stringify(
226
+ topicId
227
+ )}`
228
+ );
229
+ }
230
+ return this.standardClient.getMessageStream(topicId);
231
+ }
232
+ /**
233
+ * Get message content
234
+ */
235
+ async getMessageContent(inscriptionIdOrData) {
236
+ try {
237
+ const content = await this.standardClient.getMessageContent(
238
+ inscriptionIdOrData
239
+ );
240
+ return content;
241
+ } catch (error) {
242
+ this.logger.error(
243
+ `Error retrieving message content for: ${inscriptionIdOrData}`,
244
+ error
245
+ );
246
+ throw new Error(
247
+ `Failed to retrieve message content: ${error instanceof Error ? error.message : String(error)}`
248
+ );
249
+ }
250
+ }
251
+ /**
252
+ * Get the standard client instance (for compatibility)
253
+ */
254
+ getStandardClient() {
255
+ return this.standardClient;
256
+ }
257
+ /**
258
+ * Load profile picture from URL or file path
259
+ */
260
+ async loadProfilePicture(profilePicture) {
261
+ try {
262
+ if (!profilePicture) {
263
+ return null;
264
+ }
265
+ if (typeof profilePicture === "string") {
266
+ const isUrl = profilePicture.startsWith("http://") || profilePicture.startsWith("https://");
267
+ if (isUrl) {
268
+ this.logger.info(
269
+ `Loading profile picture from URL: ${profilePicture}`
270
+ );
271
+ const response = await axios.get(profilePicture, {
272
+ responseType: "arraybuffer"
273
+ });
274
+ const buffer = Buffer.from(response.data);
275
+ const urlPathname = new URL(profilePicture).pathname;
276
+ const filename = path__default.basename(urlPathname) || "profile.png";
277
+ return { buffer, filename };
278
+ } else {
279
+ if (!fs.existsSync(profilePicture)) {
280
+ this.logger.warn(
281
+ `Profile picture file not found: ${profilePicture}`
282
+ );
283
+ return null;
284
+ }
285
+ this.logger.info(
286
+ `Loading profile picture from file: ${profilePicture}`
287
+ );
288
+ const buffer = fs.readFileSync(profilePicture);
289
+ const filename = path__default.basename(profilePicture);
290
+ return { buffer, filename };
291
+ }
292
+ } else if (profilePicture.url) {
293
+ this.logger.info(
294
+ `Loading profile picture from URL: ${profilePicture.url}`
295
+ );
296
+ const response = await axios.get(profilePicture.url, {
297
+ responseType: "arraybuffer"
298
+ });
299
+ const buffer = Buffer.from(response.data);
300
+ const filename = profilePicture.filename || "profile.png";
301
+ return { buffer, filename };
302
+ } else if (profilePicture.path) {
303
+ if (!fs.existsSync(profilePicture.path)) {
304
+ this.logger.warn(
305
+ `Profile picture file not found: ${profilePicture.path}`
306
+ );
307
+ return null;
308
+ }
309
+ this.logger.info(
310
+ `Loading profile picture from file: ${profilePicture.path}`
311
+ );
312
+ const buffer = fs.readFileSync(profilePicture.path);
313
+ const filename = profilePicture.filename || path__default.basename(profilePicture.path);
314
+ return { buffer, filename };
315
+ }
316
+ return null;
317
+ } catch (error) {
318
+ this.logger.error("Failed to load profile picture:", error);
319
+ return null;
320
+ }
321
+ }
322
+ /**
323
+ * Create and register an agent
324
+ */
325
+ async createAndRegisterAgent(data) {
326
+ const builder = new AgentBuilder().setName(data.name).setBio(data.bio || "").setCapabilities(
327
+ data.capabilities || [AIAgentCapability.TEXT_GENERATION]
328
+ ).setType(data.type || "autonomous").setModel(data.model || "agent-model-2024").setNetwork(this.getNetwork()).setInboundTopicType(InboundTopicType.PUBLIC);
329
+ if (data.alias) {
330
+ builder.setAlias(data.alias);
331
+ }
332
+ if (data.creator) {
333
+ builder.setCreator(data.creator);
334
+ }
335
+ if (data?.feeConfig) {
336
+ builder.setInboundTopicType(InboundTopicType.FEE_BASED);
337
+ builder.setFeeConfig(data.feeConfig);
338
+ }
339
+ if (data.existingProfilePictureTopicId) {
340
+ builder.setExistingProfilePicture(data.existingProfilePictureTopicId);
341
+ } else if (data.pfpBuffer && data.pfpFileName) {
342
+ if (data.pfpBuffer.byteLength === 0) {
343
+ this.logger.warn(
344
+ "Provided PFP buffer is empty. Skipping profile picture."
345
+ );
346
+ } else {
347
+ this.logger.info(
348
+ `Setting profile picture: ${data.pfpFileName} (${data.pfpBuffer.byteLength} bytes)`
349
+ );
350
+ builder.setProfilePicture(data.pfpBuffer, data.pfpFileName);
351
+ }
352
+ } else {
353
+ this.logger.warn(
354
+ "Profile picture not provided. Agent creation might fail if required by the underlying SDK builder."
355
+ );
356
+ }
357
+ if (data.socials) {
358
+ Object.entries(data.socials).forEach(([platform, handle]) => {
359
+ builder.addSocial(platform, handle);
360
+ });
361
+ }
362
+ if (data.properties) {
363
+ Object.entries(data.properties).forEach(([key, value]) => {
364
+ builder.addProperty(key, value);
365
+ });
366
+ }
367
+ try {
368
+ const hasFees = Boolean(data?.feeConfig);
369
+ const result = await this.standardClient.createAndRegisterAgent(builder, {
370
+ initialBalance: hasFees ? 50 : 10
371
+ });
372
+ return result;
373
+ } catch (error) {
374
+ this.logger.error("Error during agent creation/registration:", error);
375
+ throw new Error(
376
+ `Failed to create/register agent: ${error instanceof Error ? error.message : String(error)}`
377
+ );
378
+ }
379
+ }
380
+ /**
381
+ * Register a new HCS-10 agent
382
+ * Note: This performs multiple transactions and requires directExecution mode
383
+ */
384
+ async registerAgent(params) {
385
+ this.clearNotes();
386
+ if (this.hederaKit.operationalMode === "returnBytes") {
387
+ throw new Error(
388
+ "Agent registration requires multiple transactions and cannot be performed in returnBytes mode. Please use autonomous mode."
389
+ );
390
+ }
391
+ try {
392
+ let profilePictureData = null;
393
+ if (params.profilePicture) {
394
+ profilePictureData = await this.loadProfilePicture(
395
+ params.profilePicture
396
+ );
397
+ }
398
+ const registrationData = {
399
+ name: params.name,
400
+ ...params.bio !== void 0 && { bio: params.bio },
401
+ ...params.alias !== void 0 && { alias: params.alias },
402
+ ...params.type !== void 0 && { type: params.type },
403
+ ...params.model !== void 0 && { model: params.model },
404
+ ...params.capabilities !== void 0 && {
405
+ capabilities: params.capabilities
406
+ },
407
+ ...params.creator !== void 0 && { creator: params.creator },
408
+ ...params.socials !== void 0 && { socials: params.socials },
409
+ ...params.properties !== void 0 && {
410
+ properties: params.properties
411
+ },
412
+ ...params.existingProfilePictureTopicId !== void 0 && {
413
+ existingProfilePictureTopicId: params.existingProfilePictureTopicId
414
+ },
415
+ ...profilePictureData?.buffer !== void 0 && {
416
+ pfpBuffer: profilePictureData.buffer
417
+ },
418
+ ...profilePictureData?.filename !== void 0 && {
419
+ pfpFileName: profilePictureData.filename
420
+ }
421
+ };
422
+ if (params.hbarFee && params.hbarFee > 0) {
423
+ const feeConfigBuilder = new FeeConfigBuilder({
424
+ network: this.network,
425
+ logger: this.sdkLogger
426
+ });
427
+ const { accountId: collectorAccountId } = this.getAccountAndSigner();
428
+ if (!collectorAccountId) {
429
+ throw new Error("Could not determine account ID for fee collection.");
430
+ }
431
+ this.addNote(
432
+ `Setting the operator account (${collectorAccountId}) as the fee collector since no specific collector was provided.`
433
+ );
434
+ const effectiveExemptIds = params.exemptAccountIds?.filter(
435
+ (id) => id !== collectorAccountId && id.startsWith("0.0")
436
+ ) || [];
437
+ registrationData.feeConfig = feeConfigBuilder.addHbarFee(
438
+ params.hbarFee,
439
+ collectorAccountId,
440
+ effectiveExemptIds
441
+ );
442
+ }
443
+ const result = await this.createAndRegisterAgent(registrationData);
444
+ this.executeResult = {
445
+ success: true,
446
+ transactionId: result.transactionId,
447
+ receipt: void 0,
448
+ scheduleId: void 0,
449
+ rawResult: {
450
+ ...result,
451
+ name: params.name,
452
+ accountId: result?.metadata?.accountId || result.state?.agentMetadata?.accountId
453
+ }
454
+ };
455
+ } catch (error) {
456
+ this.logger.error("Failed to register agent:", error);
457
+ throw error;
458
+ }
459
+ return this;
6
460
  }
7
461
  /**
8
- * Get or create HCS-2 client
462
+ * Initiate a connection to another agent
9
463
  */
10
- async getHCS2Client() {
11
- if (!this.hcs2Client) {
12
- const operatorId = this.hederaKit.signer.getAccountId().toString();
13
- const operatorPrivateKey = this.hederaKit.signer?.getOperatorPrivateKey() ? this.hederaKit.signer.getOperatorPrivateKey().toStringRaw() : "";
14
- const network = this.hederaKit.client.network;
15
- const networkType = network.toString().includes("mainnet") ? "mainnet" : "testnet";
16
- const config = {
17
- network: networkType,
18
- operatorId,
19
- operatorKey: operatorPrivateKey
464
+ async initiateConnection(params) {
465
+ this.clearNotes();
466
+ try {
467
+ const targetProfile = await this.getAgentProfile(params.targetAccountId);
468
+ if (!targetProfile.success || !targetProfile.topicInfo?.inboundTopic) {
469
+ throw new Error(
470
+ `Could not retrieve inbound topic for target account ${params.targetAccountId}`
471
+ );
472
+ }
473
+ const targetInboundTopicId = targetProfile.topicInfo.inboundTopic;
474
+ let memo;
475
+ if (params.memo !== void 0) {
476
+ memo = params.memo;
477
+ } else {
478
+ memo = params.disableMonitor ? "false" : "true";
479
+ this.addNote(
480
+ `No custom memo was provided. Using default memo '${memo}' based on monitoring preference.`
481
+ );
482
+ }
483
+ if (!params.disableMonitor) {
484
+ this.addNote(
485
+ `Monitoring will be enabled for this connection request as disableMonitor was not specified.`
486
+ );
487
+ }
488
+ const result = await this.submitConnectionRequest(
489
+ targetInboundTopicId,
490
+ memo
491
+ );
492
+ this.executeResult = {
493
+ success: true,
494
+ transactionId: "transactionId" in result ? result.transactionId?.toString() : void 0,
495
+ receipt: result,
496
+ scheduleId: void 0,
497
+ rawResult: {
498
+ targetAccountId: params.targetAccountId,
499
+ targetInboundTopicId,
500
+ connectionRequestSent: true,
501
+ monitoringEnabled: !params.disableMonitor,
502
+ ...result
503
+ }
20
504
  };
21
- this.hcs2Client = new HCS2Client(config);
505
+ } catch (error) {
506
+ this.logger.error("Failed to initiate connection:", error);
507
+ throw error;
22
508
  }
23
- return this.hcs2Client;
509
+ return this;
24
510
  }
25
511
  /**
26
- * Create a new HCS-2 registry
27
- * Note: This executes the transaction directly via HCS2Client
512
+ * Accept a connection request
513
+ * Note: This performs multiple transactions and requires directExecution mode
28
514
  */
29
- async createRegistry(options = {}) {
30
- const client = await this.getHCS2Client();
31
- return await client.createRegistry(options);
515
+ async acceptConnection(params) {
516
+ this.clearNotes();
517
+ if (this.hederaKit.operationalMode === "returnBytes") {
518
+ throw new Error(
519
+ "Accepting connections requires multiple transactions and cannot be performed in returnBytes mode. Please use autonomous mode."
520
+ );
521
+ }
522
+ try {
523
+ const currentAgent = this.stateManager?.getCurrentAgent();
524
+ if (!currentAgent) {
525
+ throw new Error(
526
+ "Cannot accept connection request. No agent is currently active. Please register or select an agent first."
527
+ );
528
+ }
529
+ const connectionsManager = this.stateManager?.getConnectionsManager();
530
+ if (!connectionsManager) {
531
+ throw new Error(NOT_INITIALIZED_ERROR);
532
+ }
533
+ await connectionsManager.fetchConnectionData(currentAgent.accountId);
534
+ const allRequests = [
535
+ ...connectionsManager.getPendingRequests(),
536
+ ...connectionsManager.getConnectionsNeedingConfirmation()
537
+ ];
538
+ const request = allRequests.find(
539
+ (r) => r.uniqueRequestKey === params.requestKey || r.connectionRequestId?.toString() === params.requestKey || r.inboundRequestId?.toString() === params.requestKey
540
+ );
541
+ if (!request) {
542
+ throw new Error(
543
+ `Request with key ${params.requestKey} not found or no longer pending.`
544
+ );
545
+ }
546
+ if (!request.needsConfirmation || !request.inboundRequestId) {
547
+ throw new Error(
548
+ `Request with key ${params.requestKey} is not an inbound request that can be accepted.`
549
+ );
550
+ }
551
+ const targetAccountId = request.targetAccountId;
552
+ const inboundRequestId = request.inboundRequestId;
553
+ let feeConfig;
554
+ if (params.hbarFee && params.hbarFee > 0) {
555
+ const feeConfigBuilder = new FeeConfigBuilder({
556
+ network: this.network,
557
+ logger: this.sdkLogger
558
+ });
559
+ const { accountId: collectorAccountId } = this.getAccountAndSigner();
560
+ if (!collectorAccountId) {
561
+ throw new Error("Could not determine account ID for fee collection.");
562
+ }
563
+ this.addNote(
564
+ `Setting the operator account (${collectorAccountId}) as the fee collector since no specific collector was provided.`
565
+ );
566
+ const effectiveExemptIds = params.exemptAccountIds?.filter(
567
+ (id) => id !== collectorAccountId && id.startsWith("0.0")
568
+ ) || [];
569
+ feeConfig = feeConfigBuilder.addHbarFee(
570
+ params.hbarFee,
571
+ collectorAccountId,
572
+ effectiveExemptIds
573
+ );
574
+ }
575
+ const inboundTopicId = await this.getInboundTopicId();
576
+ const confirmationResult = await this.handleConnectionRequest(
577
+ inboundTopicId,
578
+ targetAccountId,
579
+ inboundRequestId,
580
+ feeConfig
581
+ );
582
+ let connectionTopicId = confirmationResult?.connectionTopicId;
583
+ if (connectionTopicId && typeof connectionTopicId === "object" && "toString" in connectionTopicId) {
584
+ connectionTopicId = connectionTopicId?.toString();
585
+ }
586
+ if (!connectionTopicId || typeof connectionTopicId !== "string") {
587
+ throw new Error(
588
+ `Failed to create connection topic. Got: ${JSON.stringify(
589
+ connectionTopicId
590
+ )}`
591
+ );
592
+ }
593
+ if (this.stateManager) {
594
+ const targetAgentName = request.targetAgentName || `Agent ${targetAccountId}`;
595
+ if (!request.targetAgentName) {
596
+ this.addNote(
597
+ `No agent name was provided in the connection request, using default name 'Agent ${targetAccountId}'.`
598
+ );
599
+ }
600
+ let targetInboundTopicId = request.targetInboundTopicId || "";
601
+ if (!targetInboundTopicId) {
602
+ try {
603
+ const targetProfile = await this.getAgentProfile(targetAccountId);
604
+ if (targetProfile.success && targetProfile.topicInfo?.inboundTopic) {
605
+ targetInboundTopicId = targetProfile.topicInfo.inboundTopic;
606
+ }
607
+ } catch (profileError) {
608
+ this.logger.warn(
609
+ `Could not fetch profile for ${targetAccountId}:`,
610
+ profileError
611
+ );
612
+ }
613
+ }
614
+ const newConnection = {
615
+ connectionId: `conn-${Date.now()}`,
616
+ targetAccountId,
617
+ targetAgentName,
618
+ targetInboundTopicId,
619
+ connectionTopicId,
620
+ status: "established",
621
+ created: /* @__PURE__ */ new Date()
622
+ };
623
+ this.stateManager.addActiveConnection(newConnection);
624
+ connectionsManager.markConnectionRequestProcessed(
625
+ request.targetInboundTopicId || "",
626
+ inboundRequestId
627
+ );
628
+ }
629
+ this.executeResult = {
630
+ success: true,
631
+ transactionId: void 0,
632
+ receipt: void 0,
633
+ scheduleId: void 0,
634
+ rawResult: {
635
+ targetAccountId,
636
+ connectionTopicId,
637
+ feeConfigured: !!params.hbarFee,
638
+ hbarFee: params.hbarFee || 0,
639
+ confirmationResult
640
+ }
641
+ };
642
+ } catch (error) {
643
+ this.logger.error("Failed to accept connection:", error);
644
+ throw error;
645
+ }
646
+ return this;
647
+ }
648
+ /**
649
+ * Send a message using HCS (for operations that need direct topic access)
650
+ */
651
+ async sendHCS10Message(params) {
652
+ this.clearNotes();
653
+ try {
654
+ const result = await this.sendMessage(params.topicId, params.message);
655
+ this.executeResult = {
656
+ success: true,
657
+ transactionId: result.transactionId,
658
+ receipt: result.receipt,
659
+ scheduleId: void 0,
660
+ rawResult: result
661
+ };
662
+ this.addNote(`Message sent to topic ${params.topicId}.`);
663
+ } catch (error) {
664
+ this.logger.error("Failed to send message:", error);
665
+ throw error;
666
+ }
667
+ return this;
32
668
  }
33
669
  /**
34
- * Register a new entry in an HCS-2 registry
670
+ * Send a message to a connected account with optional response monitoring
35
671
  */
36
- async registerEntry(registryTopicId, options) {
37
- const client = await this.getHCS2Client();
38
- return await client.registerEntry(registryTopicId, options);
672
+ async sendMessageToConnection(params) {
673
+ this.clearNotes();
674
+ if (!this.stateManager) {
675
+ throw new Error(
676
+ "StateManager is required to send messages to connections"
677
+ );
678
+ }
679
+ try {
680
+ const currentAgent = this.stateManager.getCurrentAgent();
681
+ if (!currentAgent) {
682
+ throw new Error(
683
+ "Cannot send message. No agent is currently active. Please register or select an agent first."
684
+ );
685
+ }
686
+ let connection;
687
+ const identifier = params.targetIdentifier;
688
+ if (identifier.includes("@")) {
689
+ const parts = identifier.split("@");
690
+ if (parts.length === 2) {
691
+ const accountId = parts[1];
692
+ connection = this.stateManager.getConnectionByIdentifier(accountId);
693
+ if (!connection) {
694
+ this.addNote(
695
+ `Could not find connection using request key '${identifier}', extracted account ID '${accountId}'.`
696
+ );
697
+ }
698
+ }
699
+ }
700
+ if (!connection) {
701
+ connection = this.stateManager.getConnectionByIdentifier(identifier);
702
+ }
703
+ if (!connection && !identifier.startsWith("0.0.") && /^\d+$/.test(identifier)) {
704
+ const accountIdWithPrefix = `0.0.${identifier}`;
705
+ connection = this.stateManager.getConnectionByIdentifier(accountIdWithPrefix);
706
+ if (connection) {
707
+ this.addNote(
708
+ `Found connection using account ID with prefix: ${accountIdWithPrefix}`
709
+ );
710
+ }
711
+ }
712
+ if (!connection && /^[1-9]\d*$/.test(identifier)) {
713
+ const connections = this.stateManager.listConnections();
714
+ const index = parseInt(identifier) - 1;
715
+ if (index >= 0 && index < connections.length) {
716
+ connection = connections[index];
717
+ if (connection) {
718
+ this.addNote(
719
+ `Found connection by index ${identifier}: ${connection.targetAccountId}`
720
+ );
721
+ }
722
+ }
723
+ }
724
+ if (!connection) {
725
+ const connections = this.stateManager.listConnections();
726
+ const availableIds = connections.map(
727
+ (c, i) => `${i + 1}. ${c.targetAccountId} (Topic: ${c.connectionTopicId})`
728
+ );
729
+ let errorMsg = `Connection not found for identifier: "${identifier}"
730
+ `;
731
+ errorMsg += `Available connections:
732
+ ${availableIds.join("\n") || "No active connections"}`;
733
+ errorMsg += `
734
+
735
+ You can use:
736
+ `;
737
+ errorMsg += `- Connection number (e.g., "1", "2")
738
+ `;
739
+ errorMsg += `- Account ID (e.g., "0.0.6412936")
740
+ `;
741
+ errorMsg += `- Connection topic ID
742
+ `;
743
+ errorMsg += `Use 'list_connections' to see all active connections.`;
744
+ throw new Error(errorMsg);
745
+ }
746
+ let connectionTopicId = connection.connectionTopicId;
747
+ if (connectionTopicId && typeof connectionTopicId === "object" && "toString" in connectionTopicId) {
748
+ connectionTopicId = connectionTopicId?.toString();
749
+ }
750
+ if (!connectionTopicId || typeof connectionTopicId !== "string") {
751
+ throw new Error(
752
+ `Invalid connection topic ID for ${connection.targetAccountId}: ${JSON.stringify(
753
+ connectionTopicId
754
+ )} (type: ${typeof connectionTopicId})`
755
+ );
756
+ }
757
+ const targetAgentName = connection.targetAgentName;
758
+ const operatorId = `${currentAgent.inboundTopicId}@${currentAgent.accountId}`;
759
+ const messageResult = await this.sendMessage(
760
+ connectionTopicId,
761
+ params.message,
762
+ `Agent message from ${currentAgent.name}`
763
+ );
764
+ if (!messageResult.sequenceNumber) {
765
+ throw new Error("Failed to send message");
766
+ }
767
+ let reply = null;
768
+ if (!params.disableMonitoring) {
769
+ reply = await this.monitorResponses(
770
+ connectionTopicId,
771
+ operatorId,
772
+ messageResult.sequenceNumber
773
+ );
774
+ } else {
775
+ this.addNote(
776
+ `Message sent successfully. Response monitoring was disabled.`
777
+ );
778
+ }
779
+ this.executeResult = {
780
+ success: true,
781
+ transactionId: messageResult.transactionId,
782
+ receipt: messageResult.receipt,
783
+ scheduleId: void 0,
784
+ rawResult: {
785
+ targetAgentName,
786
+ targetAccountId: connection.targetAccountId,
787
+ connectionTopicId,
788
+ sequenceNumber: messageResult.sequenceNumber,
789
+ reply,
790
+ monitoringEnabled: !params.disableMonitoring,
791
+ message: params.message,
792
+ messageResult
793
+ }
794
+ };
795
+ } catch (error) {
796
+ this.logger.error("Failed to send message to connection:", error);
797
+ throw error;
798
+ }
799
+ return this;
800
+ }
801
+ /**
802
+ * Monitor responses on a topic after sending a message
803
+ */
804
+ async monitorResponses(topicId, operatorId, sequenceNumber) {
805
+ const maxAttempts = 30;
806
+ let attempts = 0;
807
+ while (attempts < maxAttempts) {
808
+ try {
809
+ const messages = await this.getMessageStream(topicId);
810
+ for (const message of messages.messages) {
811
+ if (message.sequence_number < sequenceNumber || message.operator_id === operatorId) {
812
+ continue;
813
+ }
814
+ const content = await this.getMessageContent(message.data || "");
815
+ return content;
816
+ }
817
+ } catch (error) {
818
+ this.logger.error(`Error monitoring responses: ${error}`);
819
+ }
820
+ await new Promise((resolve) => setTimeout(resolve, 4e3));
821
+ attempts++;
822
+ }
823
+ return null;
824
+ }
825
+ /**
826
+ * Start passive monitoring for incoming connection requests
827
+ * This method monitors continuously in the background
828
+ */
829
+ async startPassiveConnectionMonitoring() {
830
+ this.clearNotes();
831
+ if (!this.stateManager) {
832
+ throw new Error("StateManager is required for passive monitoring");
833
+ }
834
+ const inboundTopicId = await this.getInboundTopicId();
835
+ this.logger.info(
836
+ `Starting passive connection monitoring on topic ${inboundTopicId}...`
837
+ );
838
+ this.executeResult = {
839
+ success: true,
840
+ transactionId: void 0,
841
+ receipt: void 0,
842
+ scheduleId: void 0,
843
+ rawResult: {
844
+ inboundTopicId,
845
+ message: `Started monitoring inbound topic ${inboundTopicId} for connection requests in the background.`
846
+ }
847
+ };
848
+ return this;
849
+ }
850
+ /**
851
+ * Monitor for incoming connection requests
852
+ */
853
+ async monitorConnections(params) {
854
+ this.clearNotes();
855
+ const {
856
+ acceptAll = false,
857
+ targetAccountId,
858
+ monitorDurationSeconds = 120,
859
+ hbarFees = [],
860
+ tokenFees = [],
861
+ exemptAccountIds = [],
862
+ defaultCollectorAccount
863
+ } = params;
864
+ if (!this.stateManager) {
865
+ throw new Error("StateManager is required for connection monitoring");
866
+ }
867
+ const currentAgent = this.stateManager.getCurrentAgent();
868
+ if (!currentAgent) {
869
+ throw new Error(
870
+ "Cannot monitor for connections. No agent is currently active."
871
+ );
872
+ }
873
+ const inboundTopicId = await this.getInboundTopicId();
874
+ const endTime = Date.now() + monitorDurationSeconds * 1e3;
875
+ const pollIntervalMs = 3e3;
876
+ let connectionRequestsFound = 0;
877
+ let acceptedConnections = 0;
878
+ const processedRequestIds = /* @__PURE__ */ new Set();
879
+ while (Date.now() < endTime) {
880
+ try {
881
+ const messagesResult = await this.getMessages(inboundTopicId);
882
+ const connectionRequests = messagesResult.messages.filter(
883
+ (msg) => msg.op === "connection_request" && typeof msg.sequence_number === "number"
884
+ );
885
+ for (const request of connectionRequests) {
886
+ const connectionRequestId = request.sequence_number;
887
+ if (!connectionRequestId || processedRequestIds.has(connectionRequestId)) {
888
+ continue;
889
+ }
890
+ const requestingAccountId = request.operator_id?.split("@")[1];
891
+ if (!requestingAccountId) {
892
+ continue;
893
+ }
894
+ connectionRequestsFound++;
895
+ if (targetAccountId && requestingAccountId !== targetAccountId) {
896
+ this.logger.info(
897
+ `Skipping request from ${requestingAccountId} (not target account)`
898
+ );
899
+ continue;
900
+ }
901
+ if (acceptAll || targetAccountId === requestingAccountId) {
902
+ this.logger.info(
903
+ `Accepting connection request from ${requestingAccountId}`
904
+ );
905
+ let feeConfig;
906
+ if (hbarFees.length > 0 || tokenFees.length > 0) {
907
+ const builder = new FeeConfigBuilder({
908
+ network: this.network,
909
+ logger: this.sdkLogger
910
+ });
911
+ for (const fee of hbarFees) {
912
+ const collectorAccount = fee.collectorAccount || defaultCollectorAccount || this.getOperatorId();
913
+ builder.addHbarFee(
914
+ fee.amount,
915
+ collectorAccount,
916
+ exemptAccountIds
917
+ );
918
+ }
919
+ for (const fee of tokenFees) {
920
+ const collectorAccount = fee.collectorAccount || defaultCollectorAccount || this.getOperatorId();
921
+ builder.addTokenFee(
922
+ fee.amount,
923
+ fee.tokenId,
924
+ collectorAccount,
925
+ void 0,
926
+ exemptAccountIds
927
+ );
928
+ }
929
+ feeConfig = builder;
930
+ }
931
+ await this.handleConnectionRequest(
932
+ inboundTopicId,
933
+ requestingAccountId,
934
+ connectionRequestId,
935
+ feeConfig
936
+ );
937
+ processedRequestIds.add(connectionRequestId);
938
+ acceptedConnections++;
939
+ }
940
+ }
941
+ } catch (error) {
942
+ this.logger.error("Error during connection monitoring:", error);
943
+ }
944
+ await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
945
+ }
946
+ this.executeResult = {
947
+ success: true,
948
+ transactionId: void 0,
949
+ receipt: void 0,
950
+ scheduleId: void 0,
951
+ rawResult: {
952
+ connectionRequestsFound,
953
+ acceptedConnections,
954
+ monitorDurationSeconds,
955
+ processedRequestIds: Array.from(processedRequestIds)
956
+ }
957
+ };
958
+ this.addNote(
959
+ `Monitoring completed. Found ${connectionRequestsFound} requests, accepted ${acceptedConnections}.`
960
+ );
961
+ return this;
39
962
  }
40
963
  /**
41
- * Update an existing entry in an HCS-2 registry
964
+ * Manage connection requests (list, view, or reject)
42
965
  */
43
- async updateEntry(registryTopicId, options) {
44
- const client = await this.getHCS2Client();
45
- return await client.updateEntry(registryTopicId, options);
966
+ async manageConnectionRequests(params) {
967
+ this.clearNotes();
968
+ if (!this.stateManager) {
969
+ throw new Error(
970
+ "StateManager is required for managing connection requests"
971
+ );
972
+ }
973
+ const currentAgent = this.stateManager.getCurrentAgent();
974
+ if (!currentAgent) {
975
+ throw new Error(
976
+ "Cannot manage connection requests. No agent is currently active."
977
+ );
978
+ }
979
+ const connectionsManager = this.stateManager.getConnectionsManager();
980
+ if (!connectionsManager) {
981
+ throw new Error(NOT_INITIALIZED_ERROR);
982
+ }
983
+ try {
984
+ const { accountId } = this.getAccountAndSigner();
985
+ await connectionsManager.fetchConnectionData(accountId);
986
+ const pendingRequests = connectionsManager.getPendingRequests();
987
+ const needsConfirmation = connectionsManager.getConnectionsNeedingConfirmation();
988
+ const allRequests = [...pendingRequests, ...needsConfirmation];
989
+ switch (params.action) {
990
+ case "list":
991
+ this.executeResult = {
992
+ success: true,
993
+ transactionId: void 0,
994
+ receipt: void 0,
995
+ scheduleId: void 0,
996
+ rawResult: {
997
+ requests: allRequests.map((request, index) => ({
998
+ index: index + 1,
999
+ type: request.needsConfirmation ? "incoming" : "outgoing",
1000
+ requestKey: request.uniqueRequestKey || `${request.connectionRequestId || request.inboundRequestId || "unknown"}`,
1001
+ targetAccountId: request.targetAccountId,
1002
+ targetAgentName: request.targetAgentName || `Agent ${request.targetAccountId}`,
1003
+ created: request.created.toISOString(),
1004
+ memo: request.memo,
1005
+ bio: request.profileInfo?.bio
1006
+ }))
1007
+ }
1008
+ };
1009
+ break;
1010
+ case "view": {
1011
+ if (!params.requestKey) {
1012
+ throw new Error("Request key is required for viewing a request");
1013
+ }
1014
+ const viewRequest = allRequests.find(
1015
+ (r) => r.uniqueRequestKey === params.requestKey || r.connectionRequestId?.toString() === params.requestKey || r.inboundRequestId?.toString() === params.requestKey
1016
+ );
1017
+ if (!viewRequest) {
1018
+ throw new Error(`Request with key ${params.requestKey} not found`);
1019
+ }
1020
+ this.executeResult = {
1021
+ success: true,
1022
+ transactionId: void 0,
1023
+ receipt: void 0,
1024
+ scheduleId: void 0,
1025
+ rawResult: {
1026
+ request: {
1027
+ type: viewRequest.needsConfirmation ? "incoming" : "outgoing",
1028
+ requestKey: viewRequest.uniqueRequestKey || `${viewRequest.connectionRequestId || viewRequest.inboundRequestId || "unknown"}`,
1029
+ targetAccountId: viewRequest.targetAccountId,
1030
+ targetAgentName: viewRequest.targetAgentName || `Agent ${viewRequest.targetAccountId}`,
1031
+ created: viewRequest.created.toISOString(),
1032
+ memo: viewRequest.memo,
1033
+ profileInfo: viewRequest.profileInfo
1034
+ }
1035
+ }
1036
+ };
1037
+ break;
1038
+ }
1039
+ case "reject": {
1040
+ if (!params.requestKey) {
1041
+ throw new Error("Request key is required for rejecting a request");
1042
+ }
1043
+ const rejectRequest = allRequests.find(
1044
+ (r) => r.uniqueRequestKey === params.requestKey || r.connectionRequestId?.toString() === params.requestKey || r.inboundRequestId?.toString() === params.requestKey
1045
+ );
1046
+ if (!rejectRequest) {
1047
+ throw new Error(`Request with key ${params.requestKey} not found`);
1048
+ }
1049
+ if (rejectRequest.inboundRequestId) {
1050
+ connectionsManager.markConnectionRequestProcessed(
1051
+ rejectRequest.targetInboundTopicId || "",
1052
+ rejectRequest.inboundRequestId
1053
+ );
1054
+ } else if (rejectRequest.connectionRequestId) {
1055
+ connectionsManager.markConnectionRequestProcessed(
1056
+ rejectRequest.originTopicId || "",
1057
+ rejectRequest.connectionRequestId
1058
+ );
1059
+ }
1060
+ this.executeResult = {
1061
+ success: true,
1062
+ transactionId: void 0,
1063
+ receipt: void 0,
1064
+ scheduleId: void 0,
1065
+ rawResult: {
1066
+ rejectedRequest: {
1067
+ requestKey: params.requestKey,
1068
+ targetAccountId: rejectRequest.targetAccountId,
1069
+ targetAgentName: rejectRequest.targetAgentName || `Agent ${rejectRequest.targetAccountId}`
1070
+ }
1071
+ }
1072
+ };
1073
+ break;
1074
+ }
1075
+ }
1076
+ } catch (error) {
1077
+ this.logger.error("Failed to manage connection requests:", error);
1078
+ throw error;
1079
+ }
1080
+ return this;
46
1081
  }
47
1082
  /**
48
- * Delete an entry from an HCS-2 registry
1083
+ * List unapproved connection requests
49
1084
  */
50
- async deleteEntry(registryTopicId, options) {
51
- const client = await this.getHCS2Client();
52
- return await client.deleteEntry(registryTopicId, options);
1085
+ async listUnapprovedConnectionRequests() {
1086
+ this.clearNotes();
1087
+ if (!this.stateManager) {
1088
+ throw new Error(
1089
+ "StateManager is required for listing connection requests"
1090
+ );
1091
+ }
1092
+ const currentAgent = this.stateManager.getCurrentAgent();
1093
+ if (!currentAgent) {
1094
+ throw new Error(
1095
+ "Cannot list connection requests. No agent is currently active."
1096
+ );
1097
+ }
1098
+ try {
1099
+ const inboundTopicId = await this.getInboundTopicId();
1100
+ const messages = await this.getMessages(inboundTopicId);
1101
+ const unapprovedRequests = messages.messages.filter(
1102
+ (msg) => msg.op === "connection_request"
1103
+ ).map((msg) => ({
1104
+ requestId: msg.sequence_number,
1105
+ fromAccountId: msg.operator_id?.split("@")[1] || "unknown",
1106
+ timestamp: msg.timestamp || new Date(msg?.created || "").getTime(),
1107
+ memo: msg.m || "",
1108
+ data: msg.data
1109
+ })).filter(
1110
+ (req) => req.fromAccountId !== "unknown"
1111
+ );
1112
+ this.executeResult = {
1113
+ success: true,
1114
+ transactionId: void 0,
1115
+ receipt: void 0,
1116
+ scheduleId: void 0,
1117
+ rawResult: {
1118
+ requests: unapprovedRequests,
1119
+ count: unapprovedRequests.length
1120
+ }
1121
+ };
1122
+ if (unapprovedRequests.length === 0) {
1123
+ this.addNote("No unapproved connection requests found.");
1124
+ } else {
1125
+ this.addNote(
1126
+ `Found ${unapprovedRequests.length} unapproved connection request(s).`
1127
+ );
1128
+ }
1129
+ } catch (error) {
1130
+ this.logger.error(
1131
+ "Failed to list unapproved connection requests:",
1132
+ error
1133
+ );
1134
+ throw error;
1135
+ }
1136
+ return this;
53
1137
  }
54
1138
  /**
55
- * Migrate an HCS-2 registry to a new topic
1139
+ * List connections with enhanced details
56
1140
  */
57
- async migrateRegistry(registryTopicId, options) {
58
- const client = await this.getHCS2Client();
59
- return await client.migrateRegistry(registryTopicId, options);
1141
+ async listConnections(params = {}) {
1142
+ this.clearNotes();
1143
+ if (!this.stateManager) {
1144
+ throw new Error("StateManager is required to list connections");
1145
+ }
1146
+ const includeDetails = params.includeDetails ?? true;
1147
+ const showPending = params.showPending ?? true;
1148
+ try {
1149
+ const connections = await this.getEnhancedConnections();
1150
+ if (connections.length === 0) {
1151
+ this.executeResult = {
1152
+ success: true,
1153
+ rawResult: {
1154
+ connections: [],
1155
+ message: "There are currently no active connections."
1156
+ }
1157
+ };
1158
+ return this;
1159
+ }
1160
+ const activeConnections = connections.filter(
1161
+ (c) => c.status === "established"
1162
+ );
1163
+ const pendingConnections = connections.filter(
1164
+ (c) => c.isPending
1165
+ );
1166
+ const needsConfirmation = connections.filter(
1167
+ (c) => c.needsConfirmation
1168
+ );
1169
+ let output = "";
1170
+ if (activeConnections.length > 0) {
1171
+ output += `🟢 Active Connections (${activeConnections.length}):
1172
+ `;
1173
+ activeConnections.forEach((conn, index) => {
1174
+ output += this.formatConnection(conn, index, includeDetails);
1175
+ });
1176
+ output += "\n";
1177
+ }
1178
+ if (showPending && needsConfirmation.length > 0) {
1179
+ output += `🟠 Connections Needing Confirmation (${needsConfirmation.length}):
1180
+ `;
1181
+ needsConfirmation.forEach((conn, index) => {
1182
+ output += this.formatConnection(conn, index, includeDetails);
1183
+ });
1184
+ output += "\n";
1185
+ }
1186
+ if (showPending && pendingConnections.length > 0) {
1187
+ output += `⚪ Pending Connection Requests (${pendingConnections.length}):
1188
+ `;
1189
+ pendingConnections.forEach((conn, index) => {
1190
+ output += this.formatConnection(conn, index, includeDetails);
1191
+ });
1192
+ }
1193
+ this.executeResult = {
1194
+ success: true,
1195
+ rawResult: {
1196
+ connections,
1197
+ formattedOutput: output.trim(),
1198
+ activeCount: activeConnections.length,
1199
+ pendingCount: pendingConnections.length,
1200
+ needsConfirmationCount: needsConfirmation.length
1201
+ }
1202
+ };
1203
+ } catch (error) {
1204
+ this.logger.error("Failed to list connections:", error);
1205
+ this.executeResult = {
1206
+ success: false,
1207
+ error: `Failed to list connections: ${error instanceof Error ? error.message : String(error)}`
1208
+ };
1209
+ }
1210
+ return this;
1211
+ }
1212
+ formatConnection(conn, index, includeDetails) {
1213
+ const connection = conn;
1214
+ let output = `${index + 1}. ${connection.profileInfo?.display_name || connection.targetAgentName || "Unknown Agent"} (${connection.targetAccountId})
1215
+ `;
1216
+ const displayTopicId = connection.isPending ? "(Pending Request)" : connection.connectionTopicId;
1217
+ output += ` Topic: ${displayTopicId}
1218
+ `;
1219
+ const statusText = connection.status || "unknown";
1220
+ output += ` Status: ${statusText}
1221
+ `;
1222
+ if (includeDetails) {
1223
+ if (connection.profileInfo?.bio) {
1224
+ output += ` Bio: ${connection.profileInfo.bio.substring(0, 100)}${connection.profileInfo.bio.length > 100 ? "..." : ""}
1225
+ `;
1226
+ }
1227
+ if (connection.created) {
1228
+ const createdLabel = connection.isPending ? "Request sent" : "Connection established";
1229
+ output += ` ${createdLabel}: ${connection.created.toLocaleString()}
1230
+ `;
1231
+ }
1232
+ if (connection.lastActivity) {
1233
+ output += ` Last activity: ${connection.lastActivity.toLocaleString()}
1234
+ `;
1235
+ }
1236
+ }
1237
+ return output;
1238
+ }
1239
+ async getEnhancedConnections() {
1240
+ try {
1241
+ const { accountId } = this.getAccountAndSigner();
1242
+ if (!accountId) {
1243
+ return this.stateManager.listConnections();
1244
+ }
1245
+ const connectionManager = this.stateManager.getConnectionsManager();
1246
+ if (!connectionManager) {
1247
+ this.logger.error(NOT_INITIALIZED_ERROR);
1248
+ return this.stateManager.listConnections();
1249
+ }
1250
+ const connections = await connectionManager.fetchConnectionData(
1251
+ accountId
1252
+ );
1253
+ for (const connection of connections) {
1254
+ this.stateManager.addActiveConnection(
1255
+ connection
1256
+ );
1257
+ }
1258
+ return connections;
1259
+ } catch (error) {
1260
+ this.logger.error("Failed to get enhanced connections:", error);
1261
+ return this.stateManager.listConnections();
1262
+ }
60
1263
  }
61
1264
  /**
62
- * Query entries from an HCS-2 registry
1265
+ * Check messages on a connection
63
1266
  */
64
- async getRegistry(topicId, options = {}) {
65
- const client = await this.getHCS2Client();
66
- return await client.getRegistry(topicId, options);
1267
+ async checkMessages(params) {
1268
+ this.clearNotes();
1269
+ if (!this.stateManager) {
1270
+ throw new Error("StateManager is required to check messages");
1271
+ }
1272
+ const connection = this.stateManager.getConnectionByIdentifier(
1273
+ params.targetIdentifier
1274
+ );
1275
+ if (!connection) {
1276
+ this.executeResult = {
1277
+ success: false,
1278
+ error: `Could not find an active connection matching identifier "${params.targetIdentifier}". Use 'list_connections' to see active connections.`
1279
+ };
1280
+ return this;
1281
+ }
1282
+ const connectionTopicId = connection.connectionTopicId || "";
1283
+ if (!connectionTopicId || !connectionTopicId.match(/^\d+\.\d+\.\d+$/)) {
1284
+ this.logger.error(
1285
+ `Invalid connection topic ID format: ${connectionTopicId}`
1286
+ );
1287
+ this.executeResult = {
1288
+ success: false,
1289
+ error: `Invalid connection topic ID format: ${connectionTopicId}. Expected format: 0.0.XXXXX`
1290
+ };
1291
+ return this;
1292
+ }
1293
+ const targetAgentName = connection.targetAgentName;
1294
+ const lastProcessedTimestamp = this.stateManager.getLastTimestamp(connectionTopicId);
1295
+ this.logger.info(
1296
+ `Checking messages for connection with ${targetAgentName} (${connection.targetAccountId}) on topic ${connectionTopicId} (fetchLatest: ${params.fetchLatest}, lastCount: ${params.lastMessagesCount}, since: ${lastProcessedTimestamp})`
1297
+ );
1298
+ try {
1299
+ const result = await this.getMessages(connectionTopicId);
1300
+ const allMessages = result.messages;
1301
+ if (!allMessages || allMessages.length === 0) {
1302
+ this.executeResult = {
1303
+ success: true,
1304
+ rawResult: {
1305
+ messages: [],
1306
+ message: `No messages found on connection topic ${connectionTopicId}.`
1307
+ }
1308
+ };
1309
+ return this;
1310
+ }
1311
+ let messagesToProcess = [];
1312
+ let latestTimestampNanos = lastProcessedTimestamp;
1313
+ const isFetchingLatest = params.fetchLatest === true;
1314
+ if (isFetchingLatest) {
1315
+ this.logger.info("Fetching latest messages regardless of timestamp.");
1316
+ const count = params.lastMessagesCount ?? 1;
1317
+ messagesToProcess = allMessages.slice(-count);
1318
+ } else {
1319
+ this.logger.info(
1320
+ `Filtering for messages newer than ${lastProcessedTimestamp}`
1321
+ );
1322
+ messagesToProcess = allMessages.filter(
1323
+ (msg) => {
1324
+ const msgTimestampNanos = msg.timestamp * 1e6;
1325
+ return msgTimestampNanos > lastProcessedTimestamp;
1326
+ }
1327
+ );
1328
+ if (messagesToProcess.length > 0) {
1329
+ latestTimestampNanos = messagesToProcess.reduce(
1330
+ (maxTs, msg) => Math.max(maxTs, msg.timestamp * 1e6),
1331
+ lastProcessedTimestamp
1332
+ );
1333
+ }
1334
+ }
1335
+ if (messagesToProcess.length === 0) {
1336
+ const message = isFetchingLatest ? `Could not retrieve the latest message(s). No messages found on topic ${connectionTopicId}.` : `No new messages found for connection with ${targetAgentName} since last check.`;
1337
+ this.executeResult = {
1338
+ success: true,
1339
+ rawResult: {
1340
+ messages: [],
1341
+ message
1342
+ }
1343
+ };
1344
+ return this;
1345
+ }
1346
+ this.logger.info(`Processing ${messagesToProcess.length} message(s).`);
1347
+ let outputString = isFetchingLatest ? `Latest message(s) from ${targetAgentName}:
1348
+ ` : `New messages from ${targetAgentName}:
1349
+ `;
1350
+ const processedMessages = [];
1351
+ for (const msg of messagesToProcess) {
1352
+ let content = msg.data;
1353
+ try {
1354
+ if (typeof content === "string" && content.startsWith("hcs://")) {
1355
+ this.logger.debug(`Resolving inscribed message: ${content}`);
1356
+ content = await this.getMessageContent(content);
1357
+ this.logger.debug(`Resolved content length: ${content?.length}`);
1358
+ }
1359
+ let displayContent = content;
1360
+ try {
1361
+ const parsed = JSON.parse(content || "{}");
1362
+ if (parsed.p === "hcs-10" && parsed.op === "message" && parsed.data) {
1363
+ const senderOpId = parsed.operator_id || "unknown_sender";
1364
+ displayContent = `[${senderOpId}]: ${parsed.data}`;
1365
+ } else {
1366
+ displayContent = content;
1367
+ }
1368
+ } catch {
1369
+ displayContent = content;
1370
+ }
1371
+ const messageDate = new Date(msg.timestamp);
1372
+ outputString += `
1373
+ [${messageDate.toLocaleString()}] (Seq: ${msg.sequence_number})
1374
+ ${displayContent}
1375
+ `;
1376
+ processedMessages.push({
1377
+ timestamp: msg.timestamp,
1378
+ sequenceNumber: msg.sequence_number,
1379
+ content: displayContent,
1380
+ raw: msg
1381
+ });
1382
+ } catch (error) {
1383
+ const errorMsg = `Error processing message (Seq: ${msg.sequence_number}): ${error instanceof Error ? error.message : String(error)}`;
1384
+ this.logger.error(errorMsg);
1385
+ outputString += `
1386
+ [Error processing message Seq: ${msg.sequence_number}]
1387
+ `;
1388
+ }
1389
+ }
1390
+ if (!isFetchingLatest && latestTimestampNanos > lastProcessedTimestamp) {
1391
+ this.logger.debug(
1392
+ `Updating timestamp for topic ${connectionTopicId} to ${latestTimestampNanos}`
1393
+ );
1394
+ this.stateManager.updateTimestamp(
1395
+ connectionTopicId,
1396
+ latestTimestampNanos
1397
+ );
1398
+ }
1399
+ this.executeResult = {
1400
+ success: true,
1401
+ rawResult: {
1402
+ messages: processedMessages,
1403
+ formattedOutput: outputString.trim(),
1404
+ targetAgentName,
1405
+ connectionTopicId
1406
+ }
1407
+ };
1408
+ } catch (error) {
1409
+ this.logger.error(
1410
+ `Failed to check messages for topic ${connectionTopicId}: ${error}`
1411
+ );
1412
+ this.executeResult = {
1413
+ success: false,
1414
+ error: `Error checking messages for ${targetAgentName}: ${error instanceof Error ? error.message : String(error)}`
1415
+ };
1416
+ }
1417
+ return this;
67
1418
  }
68
1419
  /**
69
- * Submit a raw message to an HCS-2 topic
1420
+ * Find registrations using the configured registry
70
1421
  */
71
- async submitMessage(topicId, payload) {
72
- const client = await this.getHCS2Client();
73
- return await client.submitMessage(topicId, payload);
1422
+ async findRegistrations(params) {
1423
+ this.clearNotes();
1424
+ try {
1425
+ const options = {
1426
+ network: this.network
1427
+ };
1428
+ if (params.accountId) {
1429
+ options.accountId = params.accountId;
1430
+ }
1431
+ if (params.tags && params.tags.length > 0) {
1432
+ options.tags = params.tags;
1433
+ }
1434
+ const result = await this.standardClient.findRegistrations(options);
1435
+ if (!result.success || result.error) {
1436
+ this.executeResult = {
1437
+ success: false,
1438
+ error: `Error finding registrations: ${result.error || "Unknown error"}`
1439
+ };
1440
+ return this;
1441
+ }
1442
+ if (!result.registrations || result.registrations.length === 0) {
1443
+ this.executeResult = {
1444
+ success: true,
1445
+ rawResult: {
1446
+ registrations: [],
1447
+ message: "No registrations found matching the criteria."
1448
+ }
1449
+ };
1450
+ return this;
1451
+ }
1452
+ const formattedRegistrations = result.registrations.map((reg) => {
1453
+ const registration = reg;
1454
+ const agentName = registration.agent?.name || "Unknown Agent";
1455
+ const accountId = registration.accountId || "Unknown Account";
1456
+ const capabilities = registration.agent?.capabilities?.join(", ") || "None";
1457
+ return `Agent: ${agentName} (${accountId}), Capabilities: ${capabilities}`;
1458
+ }).join("\\n");
1459
+ this.executeResult = {
1460
+ success: true,
1461
+ rawResult: {
1462
+ registrations: result.registrations,
1463
+ formattedOutput: `Found ${result.registrations.length} registration(s):\\n${formattedRegistrations}`
1464
+ }
1465
+ };
1466
+ } catch (error) {
1467
+ this.logger.error("Error during FindRegistrations execution:", error);
1468
+ this.executeResult = {
1469
+ success: false,
1470
+ error: `Failed to search registrations: ${error instanceof Error ? error.message : String(error)}`
1471
+ };
1472
+ }
1473
+ return this;
74
1474
  }
75
1475
  /**
76
- * Get topic info from mirror node
1476
+ * Retrieve detailed profile information for an agent
77
1477
  */
78
- async getTopicInfo(topicId) {
79
- const client = await this.getHCS2Client();
80
- return await client.getTopicInfo(topicId);
1478
+ async retrieveProfile(params) {
1479
+ this.clearNotes();
1480
+ try {
1481
+ const profileResponse = await this.standardClient.retrieveProfile(
1482
+ params.accountId,
1483
+ params.disableCache || false
1484
+ );
1485
+ if (!profileResponse.success) {
1486
+ this.executeResult = {
1487
+ success: false,
1488
+ error: `Failed to retrieve profile: ${profileResponse.error || "Unknown error"}`
1489
+ };
1490
+ return this;
1491
+ }
1492
+ const profile = profileResponse.profile;
1493
+ const topicInfo = profileResponse.topicInfo;
1494
+ let profileDetails = `Profile for ${params.accountId}:
1495
+ `;
1496
+ profileDetails += `Name: ${profile.name || "Unknown"}
1497
+ `;
1498
+ profileDetails += `Bio: ${profile.bio || "No bio provided"}
1499
+ `;
1500
+ profileDetails += `Type: ${profile.type || "Unknown"}
1501
+ `;
1502
+ profileDetails += `Model: ${profile.model || "Unknown"}
1503
+ `;
1504
+ if (profile.capabilities && profile.capabilities.length > 0) {
1505
+ profileDetails += `Capabilities: ${profile.capabilities.join(", ")}
1506
+ `;
1507
+ } else {
1508
+ profileDetails += `Capabilities: None listed
1509
+ `;
1510
+ }
1511
+ if (topicInfo) {
1512
+ profileDetails += `Inbound Topic: ${topicInfo.inboundTopic || "Unknown"}
1513
+ `;
1514
+ profileDetails += `Outbound Topic: ${topicInfo.outboundTopic || "Unknown"}
1515
+ `;
1516
+ profileDetails += `Profile Topic: ${topicInfo.profileTopicId || "Unknown"}
1517
+ `;
1518
+ }
1519
+ if (profile.social && Object.keys(profile.social).length > 0) {
1520
+ profileDetails += `Social: ${Object.entries(profile.social).map(
1521
+ ([platform, handle]) => `${platform}: ${handle}`
1522
+ ).join(", ")}
1523
+ `;
1524
+ }
1525
+ if (profile.properties && Object.keys(profile.properties).length > 0) {
1526
+ profileDetails += `Properties: ${JSON.stringify(profile.properties)}
1527
+ `;
1528
+ }
1529
+ this.executeResult = {
1530
+ success: true,
1531
+ rawResult: {
1532
+ profileDetails,
1533
+ rawProfile: profileResponse
1534
+ }
1535
+ };
1536
+ } catch (error) {
1537
+ this.logger.error(
1538
+ `Unexpected error retrieving profile for ${params.accountId}:`,
1539
+ error
1540
+ );
1541
+ this.executeResult = {
1542
+ success: false,
1543
+ error: `Unexpected error retrieving profile for ${params.accountId}: ${error instanceof Error ? error.message : String(error)}`
1544
+ };
1545
+ }
1546
+ return this;
81
1547
  }
82
1548
  /**
83
- * Close the HCS-2 client
1549
+ * Override execute to return stored HCS10 operation results
84
1550
  */
85
- async close() {
86
- if (this.hcs2Client) {
87
- this.hcs2Client.close();
88
- this.hcs2Client = void 0;
1551
+ async execute() {
1552
+ if (this.executeResult) {
1553
+ return {
1554
+ success: this.executeResult.success,
1555
+ transactionId: this.executeResult.transactionId,
1556
+ receipt: this.executeResult.receipt,
1557
+ scheduleId: this.executeResult.scheduleId,
1558
+ error: this.executeResult.error,
1559
+ rawResult: this.executeResult.rawResult,
1560
+ notes: this.notes
1561
+ };
89
1562
  }
1563
+ return {
1564
+ success: false,
1565
+ error: "No operation result available. Call a builder method first."
1566
+ };
90
1567
  }
91
1568
  }
92
1569
  export {
93
- HCS2Builder
1570
+ HCS10Builder
94
1571
  };
95
1572
  //# sourceMappingURL=standards-agent-kit.es3.js.map