@hashgraphonline/standards-agent-kit 0.2.136 → 0.2.138

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