@hashgraphonline/conversational-agent 0.2.216 → 0.2.217

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 (312) hide show
  1. package/cli/readme.md +181 -0
  2. package/dist/cjs/index.cjs +1 -1
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs/index.d.ts +1 -0
  5. package/dist/cjs/plugins/community/swarm/SwarmPlugin.d.ts +17 -0
  6. package/dist/cjs/plugins/community/swarm/__tests__/SwarmPlugin.mocks.d.ts +1 -0
  7. package/dist/cjs/plugins/community/swarm/__tests__/SwarmPlugin.test.d.ts +1 -0
  8. package/dist/cjs/plugins/community/swarm/__tests__/tools/CreatePostageStampTool.test.d.ts +1 -0
  9. package/dist/cjs/plugins/community/swarm/__tests__/tools/DownloadDataTool.test.d.ts +1 -0
  10. package/dist/cjs/plugins/community/swarm/__tests__/tools/DownloadFilesTool.test.d.ts +1 -0
  11. package/dist/cjs/plugins/community/swarm/__tests__/tools/ExtendPostageStampTool.test.d.ts +1 -0
  12. package/dist/cjs/plugins/community/swarm/__tests__/tools/GetPostageStampTool.test.d.ts +1 -0
  13. package/dist/cjs/plugins/community/swarm/__tests__/tools/ListPostageStampsTool.test.d.ts +1 -0
  14. package/dist/cjs/plugins/community/swarm/__tests__/tools/QueryUploadProgressTool.test.d.ts +1 -0
  15. package/dist/cjs/plugins/community/swarm/__tests__/tools/ReadFeedTool.test.d.ts +1 -0
  16. package/dist/cjs/plugins/community/swarm/__tests__/tools/SwarmTool.mocks.d.ts +14 -0
  17. package/dist/cjs/plugins/community/swarm/__tests__/tools/UpdateFeedTool.test.d.ts +1 -0
  18. package/dist/cjs/plugins/community/swarm/__tests__/tools/UploadDataTool.test.d.ts +1 -0
  19. package/dist/cjs/plugins/community/swarm/__tests__/tools/UploadFileTool.test.d.ts +1 -0
  20. package/dist/cjs/plugins/community/swarm/__tests__/tools/UploadFolderTool.test.d.ts +1 -0
  21. package/dist/cjs/plugins/community/swarm/config.d.ts +6 -0
  22. package/dist/cjs/plugins/community/swarm/constants.d.ts +8 -0
  23. package/dist/cjs/plugins/community/swarm/index.d.ts +2 -0
  24. package/dist/cjs/plugins/community/swarm/model.d.ts +23 -0
  25. package/dist/cjs/plugins/community/swarm/tools/CreatePostageStampTool.d.ts +47 -0
  26. package/dist/cjs/plugins/community/swarm/tools/DownloadDataTool.d.ts +35 -0
  27. package/dist/cjs/plugins/community/swarm/tools/DownloadFilesTool.d.ts +41 -0
  28. package/dist/cjs/plugins/community/swarm/tools/ExtendPostageStampTool.d.ts +47 -0
  29. package/dist/cjs/plugins/community/swarm/tools/GetPostageStampTool.d.ts +35 -0
  30. package/dist/cjs/plugins/community/swarm/tools/ListPostageStampsTool.d.ts +53 -0
  31. package/dist/cjs/plugins/community/swarm/tools/QueryUploadProgressTool.d.ts +35 -0
  32. package/dist/cjs/plugins/community/swarm/tools/ReadFeedTool.d.ts +41 -0
  33. package/dist/cjs/plugins/community/swarm/tools/UpdateFeedTool.d.ts +47 -0
  34. package/dist/cjs/plugins/community/swarm/tools/UploadDataTool.d.ts +47 -0
  35. package/dist/cjs/plugins/community/swarm/tools/UploadFileTool.d.ts +53 -0
  36. package/dist/cjs/plugins/community/swarm/tools/UploadFolderTool.d.ts +47 -0
  37. package/dist/cjs/plugins/community/swarm/utils.d.ts +22 -0
  38. package/dist/cjs/plugins/index.d.ts +1 -0
  39. package/dist/esm/index.js +33 -31
  40. package/dist/esm/index.js.map +1 -1
  41. package/dist/esm/index10.js +13 -677
  42. package/dist/esm/index10.js.map +1 -1
  43. package/dist/esm/index11.js +601 -234
  44. package/dist/esm/index11.js.map +1 -1
  45. package/dist/esm/index12.js +296 -136
  46. package/dist/esm/index12.js.map +1 -1
  47. package/dist/esm/index13.js +127 -235
  48. package/dist/esm/index13.js.map +1 -1
  49. package/dist/esm/index14.js +247 -84
  50. package/dist/esm/index14.js.map +1 -1
  51. package/dist/esm/index15.js +81 -159
  52. package/dist/esm/index15.js.map +1 -1
  53. package/dist/esm/index16.js +155 -229
  54. package/dist/esm/index16.js.map +1 -1
  55. package/dist/esm/index17.js +238 -140
  56. package/dist/esm/index17.js.map +1 -1
  57. package/dist/esm/index18.js +139 -493
  58. package/dist/esm/index18.js.map +1 -1
  59. package/dist/esm/index19.js +479 -91
  60. package/dist/esm/index19.js.map +1 -1
  61. package/dist/esm/index20.js +88 -147
  62. package/dist/esm/index20.js.map +1 -1
  63. package/dist/esm/index21.js +127 -666
  64. package/dist/esm/index21.js.map +1 -1
  65. package/dist/esm/index22.js +698 -44
  66. package/dist/esm/index22.js.map +1 -1
  67. package/dist/esm/index23.js +45 -304
  68. package/dist/esm/index23.js.map +1 -1
  69. package/dist/esm/index24.js +303 -153
  70. package/dist/esm/index24.js.map +1 -1
  71. package/dist/esm/index25.js +150 -117
  72. package/dist/esm/index25.js.map +1 -1
  73. package/dist/esm/index26.js +154 -18
  74. package/dist/esm/index26.js.map +1 -1
  75. package/dist/esm/index27.js +18 -22
  76. package/dist/esm/index27.js.map +1 -1
  77. package/dist/esm/index28.js +15 -74
  78. package/dist/esm/index28.js.map +1 -1
  79. package/dist/esm/index29.js +70 -295
  80. package/dist/esm/index29.js.map +1 -1
  81. package/dist/esm/index30.js +279 -100
  82. package/dist/esm/index30.js.map +1 -1
  83. package/dist/esm/index31.js +86 -922
  84. package/dist/esm/index31.js.map +1 -1
  85. package/dist/esm/index32.js +904 -189
  86. package/dist/esm/index32.js.map +1 -1
  87. package/dist/esm/index33.js +185 -1169
  88. package/dist/esm/index33.js.map +1 -1
  89. package/dist/esm/index34.js +1218 -112
  90. package/dist/esm/index34.js.map +1 -1
  91. package/dist/esm/index35.js +111 -99
  92. package/dist/esm/index35.js.map +1 -1
  93. package/dist/esm/index36.js +113 -8
  94. package/dist/esm/index36.js.map +1 -1
  95. package/dist/esm/index37.js +8 -45
  96. package/dist/esm/index37.js.map +1 -1
  97. package/dist/esm/index38.js +41 -102
  98. package/dist/esm/index38.js.map +1 -1
  99. package/dist/esm/index39.js +96 -55
  100. package/dist/esm/index39.js.map +1 -1
  101. package/dist/esm/index4.js +1 -1
  102. package/dist/esm/index40.js +58 -71
  103. package/dist/esm/index40.js.map +1 -1
  104. package/dist/esm/index41.js +79 -21
  105. package/dist/esm/index41.js.map +1 -1
  106. package/dist/esm/index42.js +21 -5
  107. package/dist/esm/index42.js.map +1 -1
  108. package/dist/esm/index43.js +4 -11
  109. package/dist/esm/index43.js.map +1 -1
  110. package/dist/esm/index44.js +12 -322
  111. package/dist/esm/index44.js.map +1 -1
  112. package/dist/esm/index45.js +280 -142
  113. package/dist/esm/index45.js.map +1 -1
  114. package/dist/esm/index46.js +181 -24
  115. package/dist/esm/index46.js.map +1 -1
  116. package/dist/esm/index47.js +7 -95
  117. package/dist/esm/index47.js.map +1 -1
  118. package/dist/esm/index48.js +77 -7
  119. package/dist/esm/index48.js.map +1 -1
  120. package/dist/esm/index49.js +75 -0
  121. package/dist/esm/index49.js.map +1 -0
  122. package/dist/esm/index5.js +2 -2
  123. package/dist/esm/index50.js +57 -0
  124. package/dist/esm/index50.js.map +1 -0
  125. package/dist/esm/index51.js +103 -0
  126. package/dist/esm/index51.js.map +1 -0
  127. package/dist/esm/index52.js +79 -0
  128. package/dist/esm/index52.js.map +1 -0
  129. package/dist/esm/index53.js +75 -0
  130. package/dist/esm/index53.js.map +1 -0
  131. package/dist/esm/index54.js +124 -0
  132. package/dist/esm/index54.js.map +1 -0
  133. package/dist/esm/index55.js +58 -0
  134. package/dist/esm/index55.js.map +1 -0
  135. package/dist/esm/index56.js +83 -0
  136. package/dist/esm/index56.js.map +1 -0
  137. package/dist/esm/index57.js +100 -0
  138. package/dist/esm/index57.js.map +1 -0
  139. package/dist/esm/index58.js +118 -0
  140. package/dist/esm/index58.js.map +1 -0
  141. package/dist/esm/index59.js +108 -0
  142. package/dist/esm/index59.js.map +1 -0
  143. package/dist/esm/index6.js +132 -833
  144. package/dist/esm/index6.js.map +1 -1
  145. package/dist/esm/index60.js +30 -0
  146. package/dist/esm/index60.js.map +1 -0
  147. package/dist/esm/index61.js +98 -0
  148. package/dist/esm/index61.js.map +1 -0
  149. package/dist/esm/index62.js +131 -0
  150. package/dist/esm/index62.js.map +1 -0
  151. package/dist/esm/index63.js +19 -0
  152. package/dist/esm/index63.js.map +1 -0
  153. package/dist/esm/index7.js +826 -75
  154. package/dist/esm/index7.js.map +1 -1
  155. package/dist/esm/index8.js +91 -13
  156. package/dist/esm/index8.js.map +1 -1
  157. package/dist/esm/index9.js +13 -17
  158. package/dist/esm/index9.js.map +1 -1
  159. package/dist/types/index.d.ts +1 -0
  160. package/dist/types/plugins/community/swarm/SwarmPlugin.d.ts +17 -0
  161. package/dist/types/plugins/community/swarm/__tests__/SwarmPlugin.mocks.d.ts +1 -0
  162. package/dist/types/plugins/community/swarm/__tests__/SwarmPlugin.test.d.ts +1 -0
  163. package/dist/types/plugins/community/swarm/__tests__/tools/CreatePostageStampTool.test.d.ts +1 -0
  164. package/dist/types/plugins/community/swarm/__tests__/tools/DownloadDataTool.test.d.ts +1 -0
  165. package/dist/types/plugins/community/swarm/__tests__/tools/DownloadFilesTool.test.d.ts +1 -0
  166. package/dist/types/plugins/community/swarm/__tests__/tools/ExtendPostageStampTool.test.d.ts +1 -0
  167. package/dist/types/plugins/community/swarm/__tests__/tools/GetPostageStampTool.test.d.ts +1 -0
  168. package/dist/types/plugins/community/swarm/__tests__/tools/ListPostageStampsTool.test.d.ts +1 -0
  169. package/dist/types/plugins/community/swarm/__tests__/tools/QueryUploadProgressTool.test.d.ts +1 -0
  170. package/dist/types/plugins/community/swarm/__tests__/tools/ReadFeedTool.test.d.ts +1 -0
  171. package/dist/types/plugins/community/swarm/__tests__/tools/SwarmTool.mocks.d.ts +14 -0
  172. package/dist/types/plugins/community/swarm/__tests__/tools/UpdateFeedTool.test.d.ts +1 -0
  173. package/dist/types/plugins/community/swarm/__tests__/tools/UploadDataTool.test.d.ts +1 -0
  174. package/dist/types/plugins/community/swarm/__tests__/tools/UploadFileTool.test.d.ts +1 -0
  175. package/dist/types/plugins/community/swarm/__tests__/tools/UploadFolderTool.test.d.ts +1 -0
  176. package/dist/types/plugins/community/swarm/config.d.ts +6 -0
  177. package/dist/types/plugins/community/swarm/constants.d.ts +8 -0
  178. package/dist/types/plugins/community/swarm/index.d.ts +2 -0
  179. package/dist/types/plugins/community/swarm/model.d.ts +23 -0
  180. package/dist/types/plugins/community/swarm/tools/CreatePostageStampTool.d.ts +47 -0
  181. package/dist/types/plugins/community/swarm/tools/DownloadDataTool.d.ts +35 -0
  182. package/dist/types/plugins/community/swarm/tools/DownloadFilesTool.d.ts +41 -0
  183. package/dist/types/plugins/community/swarm/tools/ExtendPostageStampTool.d.ts +47 -0
  184. package/dist/types/plugins/community/swarm/tools/GetPostageStampTool.d.ts +35 -0
  185. package/dist/types/plugins/community/swarm/tools/ListPostageStampsTool.d.ts +53 -0
  186. package/dist/types/plugins/community/swarm/tools/QueryUploadProgressTool.d.ts +35 -0
  187. package/dist/types/plugins/community/swarm/tools/ReadFeedTool.d.ts +41 -0
  188. package/dist/types/plugins/community/swarm/tools/UpdateFeedTool.d.ts +47 -0
  189. package/dist/types/plugins/community/swarm/tools/UploadDataTool.d.ts +47 -0
  190. package/dist/types/plugins/community/swarm/tools/UploadFileTool.d.ts +53 -0
  191. package/dist/types/plugins/community/swarm/tools/UploadFolderTool.d.ts +47 -0
  192. package/dist/types/plugins/community/swarm/utils.d.ts +22 -0
  193. package/dist/types/plugins/index.d.ts +1 -0
  194. package/package.json +36 -26
  195. package/src/index.ts +1 -0
  196. package/src/plugins/community/swarm/README.md +279 -0
  197. package/src/plugins/community/swarm/SwarmPlugin.ts +178 -0
  198. package/src/plugins/community/swarm/__tests__/SwarmPlugin.mocks.ts +105 -0
  199. package/src/plugins/community/swarm/__tests__/SwarmPlugin.test.ts +93 -0
  200. package/src/plugins/community/swarm/__tests__/tools/CreatePostageStampTool.test.ts +152 -0
  201. package/src/plugins/community/swarm/__tests__/tools/DownloadDataTool.test.ts +93 -0
  202. package/src/plugins/community/swarm/__tests__/tools/DownloadFilesTool.test.ts +163 -0
  203. package/src/plugins/community/swarm/__tests__/tools/ExtendPostageStampTool.test.ts +132 -0
  204. package/src/plugins/community/swarm/__tests__/tools/GetPostageStampTool.test.ts +83 -0
  205. package/src/plugins/community/swarm/__tests__/tools/ListPostageStampsTool.test.ts +219 -0
  206. package/src/plugins/community/swarm/__tests__/tools/QueryUploadProgressTool.test.ts +169 -0
  207. package/src/plugins/community/swarm/__tests__/tools/ReadFeedTool.test.ts +133 -0
  208. package/src/plugins/community/swarm/__tests__/tools/SwarmTool.mocks.ts +67 -0
  209. package/src/plugins/community/swarm/__tests__/tools/UpdateFeedTool.test.ts +148 -0
  210. package/src/plugins/community/swarm/__tests__/tools/UploadDataTool.test.ts +125 -0
  211. package/src/plugins/community/swarm/__tests__/tools/UploadFileTool.test.ts +194 -0
  212. package/src/plugins/community/swarm/__tests__/tools/UploadFolderTool.test.ts +118 -0
  213. package/src/plugins/community/swarm/config.ts +6 -0
  214. package/src/plugins/community/swarm/constants.ts +12 -0
  215. package/src/plugins/community/swarm/index.ts +2 -0
  216. package/src/plugins/community/swarm/model.ts +23 -0
  217. package/src/plugins/community/swarm/tools/CreatePostageStampTool.ts +137 -0
  218. package/src/plugins/community/swarm/tools/DownloadDataTool.ts +79 -0
  219. package/src/plugins/community/swarm/tools/DownloadFilesTool.ts +155 -0
  220. package/src/plugins/community/swarm/tools/ExtendPostageStampTool.ts +112 -0
  221. package/src/plugins/community/swarm/tools/GetPostageStampTool.ts +92 -0
  222. package/src/plugins/community/swarm/tools/ListPostageStampsTool.ts +124 -0
  223. package/src/plugins/community/swarm/tools/QueryUploadProgressTool.ts +109 -0
  224. package/src/plugins/community/swarm/tools/ReadFeedTool.ts +110 -0
  225. package/src/plugins/community/swarm/tools/UpdateFeedTool.ts +149 -0
  226. package/src/plugins/community/swarm/tools/UploadDataTool.ts +109 -0
  227. package/src/plugins/community/swarm/tools/UploadFileTool.ts +163 -0
  228. package/src/plugins/community/swarm/tools/UploadFolderTool.ts +150 -0
  229. package/src/plugins/community/swarm/utils.ts +172 -0
  230. package/src/plugins/index.ts +1 -0
  231. package/cli/dist/CLIApp.d.ts +0 -11
  232. package/cli/dist/CLIApp.d.ts.map +0 -1
  233. package/cli/dist/CLIApp.js +0 -128
  234. package/cli/dist/CLIApp.js.map +0 -1
  235. package/cli/dist/LocalConversationalAgent.d.ts +0 -37
  236. package/cli/dist/LocalConversationalAgent.js +0 -58
  237. package/cli/dist/app.d.ts +0 -18
  238. package/cli/dist/app.d.ts.map +0 -1
  239. package/cli/dist/app.js +0 -14
  240. package/cli/dist/app.js.map +0 -1
  241. package/cli/dist/cli.d.ts +0 -3
  242. package/cli/dist/cli.d.ts.map +0 -1
  243. package/cli/dist/cli.js +0 -87
  244. package/cli/dist/cli.js.map +0 -1
  245. package/cli/dist/components/AppContainer.d.ts +0 -16
  246. package/cli/dist/components/AppContainer.js +0 -24
  247. package/cli/dist/components/AppScreens.d.ts +0 -2
  248. package/cli/dist/components/AppScreens.js +0 -259
  249. package/cli/dist/components/ChatScreen.d.ts +0 -21
  250. package/cli/dist/components/ChatScreen.d.ts.map +0 -1
  251. package/cli/dist/components/ChatScreen.js +0 -40
  252. package/cli/dist/components/ChatScreen.js.map +0 -1
  253. package/cli/dist/components/DebugLoadingScreen.d.ts +0 -5
  254. package/cli/dist/components/DebugLoadingScreen.js +0 -31
  255. package/cli/dist/components/LoadingScreen.d.ts +0 -3
  256. package/cli/dist/components/LoadingScreen.d.ts.map +0 -1
  257. package/cli/dist/components/LoadingScreen.js +0 -17
  258. package/cli/dist/components/LoadingScreen.js.map +0 -1
  259. package/cli/dist/components/LoadingScreenDebug.d.ts +0 -5
  260. package/cli/dist/components/LoadingScreenDebug.js +0 -27
  261. package/cli/dist/components/MCPConfigScreen.d.ts +0 -28
  262. package/cli/dist/components/MCPConfigScreen.d.ts.map +0 -1
  263. package/cli/dist/components/MCPConfigScreen.js +0 -186
  264. package/cli/dist/components/MCPConfigScreen.js.map +0 -1
  265. package/cli/dist/components/ScreenRouter.d.ts +0 -13
  266. package/cli/dist/components/ScreenRouter.d.ts.map +0 -1
  267. package/cli/dist/components/ScreenRouter.js +0 -23
  268. package/cli/dist/components/ScreenRouter.js.map +0 -1
  269. package/cli/dist/components/SetupScreen.d.ts +0 -16
  270. package/cli/dist/components/SetupScreen.d.ts.map +0 -1
  271. package/cli/dist/components/SetupScreen.js +0 -67
  272. package/cli/dist/components/SetupScreen.js.map +0 -1
  273. package/cli/dist/components/SingleLoadingScreen.d.ts +0 -5
  274. package/cli/dist/components/SingleLoadingScreen.js +0 -27
  275. package/cli/dist/components/StatusBadge.d.ts +0 -10
  276. package/cli/dist/components/StatusBadge.d.ts.map +0 -1
  277. package/cli/dist/components/StatusBadge.js +0 -24
  278. package/cli/dist/components/StatusBadge.js.map +0 -1
  279. package/cli/dist/components/TerminalWindow.d.ts +0 -9
  280. package/cli/dist/components/TerminalWindow.d.ts.map +0 -1
  281. package/cli/dist/components/TerminalWindow.js +0 -19
  282. package/cli/dist/components/TerminalWindow.js.map +0 -1
  283. package/cli/dist/components/WelcomeScreen.d.ts +0 -12
  284. package/cli/dist/components/WelcomeScreen.d.ts.map +0 -1
  285. package/cli/dist/components/WelcomeScreen.js +0 -47
  286. package/cli/dist/components/WelcomeScreen.js.map +0 -1
  287. package/cli/dist/context/AppContext.d.ts +0 -68
  288. package/cli/dist/context/AppContext.js +0 -363
  289. package/cli/dist/headless-runner.d.ts +0 -17
  290. package/cli/dist/headless-runner.d.ts.map +0 -1
  291. package/cli/dist/headless-runner.js +0 -128
  292. package/cli/dist/headless-runner.js.map +0 -1
  293. package/cli/dist/hooks/useInitializeAgent.d.ts +0 -19
  294. package/cli/dist/hooks/useInitializeAgent.d.ts.map +0 -1
  295. package/cli/dist/hooks/useInitializeAgent.js +0 -29
  296. package/cli/dist/hooks/useInitializeAgent.js.map +0 -1
  297. package/cli/dist/hooks/useStableState.d.ts +0 -38
  298. package/cli/dist/hooks/useStableState.d.ts.map +0 -1
  299. package/cli/dist/hooks/useStableState.js +0 -69
  300. package/cli/dist/hooks/useStableState.js.map +0 -1
  301. package/cli/dist/managers/AgentManager.d.ts +0 -58
  302. package/cli/dist/managers/AgentManager.d.ts.map +0 -1
  303. package/cli/dist/managers/AgentManager.js +0 -121
  304. package/cli/dist/managers/AgentManager.js.map +0 -1
  305. package/cli/dist/managers/ConfigManager.d.ts +0 -54
  306. package/cli/dist/managers/ConfigManager.d.ts.map +0 -1
  307. package/cli/dist/managers/ConfigManager.js +0 -188
  308. package/cli/dist/managers/ConfigManager.js.map +0 -1
  309. package/cli/dist/types.d.ts +0 -52
  310. package/cli/dist/types.d.ts.map +0 -1
  311. package/cli/dist/types.js +0 -34
  312. package/cli/dist/types.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index7.js","sources":["../../src/base-agent.ts"],"sourcesContent":["import type { BaseMessage } from '@langchain/core/messages';\nimport type { StructuredTool } from '@langchain/core/tools';\nimport type { TransactionReceipt } from '@hashgraph/sdk';\nimport {\n HederaAgentKit,\n ServerSigner,\n TokenUsageCallbackHandler,\n TokenUsage,\n BasePlugin,\n} from 'hedera-agent-kit';\nimport type { CostCalculation } from 'hedera-agent-kit';\nimport type { AIProvider, VercelAIProvider, BAMLProvider } from './providers';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport type { MCPServerConfig, MCPConnectionStatus } from './mcp/types';\nimport type { FormSubmission } from './forms/types';\n\nexport interface ToolFilterConfig {\n namespaceWhitelist?: string[];\n toolBlacklist?: string[];\n toolPredicate?: (tool: StructuredTool) => boolean;\n}\n\nexport type ExecutionMode = 'direct' | 'bytes';\nexport type OperationalMode = 'autonomous' | 'returnBytes';\n\nexport interface HederaAgentConfiguration {\n signer: ServerSigner;\n execution?: {\n mode?: ExecutionMode;\n operationalMode?: OperationalMode;\n userAccountId?: string;\n scheduleUserTransactions?: boolean;\n scheduleUserTransactionsInBytesMode?: boolean;\n };\n ai?: {\n provider?: AIProvider;\n llm?: unknown;\n apiKey?: string;\n modelName?: string;\n temperature?: number;\n };\n filtering?: ToolFilterConfig;\n messaging?: {\n systemPreamble?: string;\n systemPostamble?: string;\n conciseMode?: boolean;\n };\n extensions?: {\n plugins?: BasePlugin[];\n mirrorConfig?: Record<string, unknown>;\n modelCapability?: string;\n };\n mcp?: {\n servers?: MCPServerConfig[];\n autoConnect?: boolean;\n };\n debug?: {\n verbose?: boolean;\n silent?: boolean;\n };\n}\n\nexport interface ConversationContext {\n messages: BaseMessage[];\n metadata?: Record<string, unknown>;\n}\n\nexport interface ChatResponse {\n output: string;\n message?: string;\n transactionBytes?: string;\n receipt?: TransactionReceipt | object;\n scheduleId?: string;\n transactionId?: string;\n notes?: string[];\n error?: string;\n intermediateSteps?: unknown;\n rawToolOutput?: unknown;\n tokenUsage?: TokenUsage;\n cost?: CostCalculation;\n metadata?: Record<string, unknown>;\n tool_calls?: Array<{\n id: string;\n name: string;\n args: Record<string, unknown>;\n output?: string;\n }>;\n formMessage?: unknown;\n requiresForm?: boolean;\n [key: string]: unknown;\n}\n\nexport interface UsageStats extends TokenUsage {\n cost: CostCalculation;\n}\n\nexport abstract class BaseAgent {\n protected logger: Logger;\n protected agentKit: HederaAgentKit | undefined;\n protected tools: StructuredTool[] = [];\n protected initialized = false;\n protected tokenTracker: TokenUsageCallbackHandler | undefined;\n\n constructor(protected config: HederaAgentConfiguration) {\n this.logger = new Logger({\n module: 'BaseAgent',\n silent: config.debug?.silent || false,\n });\n }\n\n abstract boot(): Promise<void>;\n abstract chat(\n message: string,\n context?: ConversationContext\n ): Promise<ChatResponse>;\n abstract processFormSubmission(\n submission: FormSubmission\n ): Promise<ChatResponse>;\n abstract shutdown(): Promise<void>;\n abstract switchMode(mode: OperationalMode): void;\n abstract getUsageStats(): UsageStats;\n abstract getUsageLog(): UsageStats[];\n abstract clearUsageStats(): void;\n abstract connectMCPServers(): Promise<void>;\n abstract getMCPConnectionStatus(): Map<string, MCPConnectionStatus>;\n\n public getCore(): HederaAgentKit | undefined {\n return this.agentKit;\n }\n\n protected filterTools(tools: StructuredTool[]): StructuredTool[] {\n let filtered = [...tools];\n const filter = this.config.filtering;\n\n if (!filter) return filtered;\n\n if (filter.namespaceWhitelist?.length) {\n filtered = filtered.filter((tool) => {\n const namespace = (tool as StructuredTool & { namespace?: string })\n .namespace;\n return !namespace || filter.namespaceWhitelist!.includes(namespace);\n });\n }\n\n if (filter.toolBlacklist?.length) {\n filtered = filtered.filter(\n (tool) => !filter.toolBlacklist!.includes(tool.name)\n );\n }\n\n if (filter.toolPredicate) {\n filtered = filtered.filter(filter.toolPredicate);\n }\n\n this.logger.debug(`Filtered tools: ${tools.length} → ${filtered.length}`);\n return filtered;\n }\n\n protected buildSystemPrompt(): string {\n const parts: string[] = [];\n const operatorId = this.config.signer.getAccountId().toString();\n const userAccId = this.config.execution?.userAccountId;\n\n if (this.config.messaging?.systemPreamble) {\n parts.push(this.config.messaging.systemPreamble);\n }\n\n parts.push(\n `You are a helpful Hedera assistant. Your primary operator account is ${operatorId}. ` +\n `You have tools to interact with the Hedera Hashgraph. ` +\n `When using any tool, provide all necessary parameters as defined by that tool's schema and description.`\n );\n\n parts.push(\n `\\nMETADATA QUALITY PRINCIPLES: When collecting user input for metadata creation across any tool:` +\n `\\n• Prioritize meaningful, valuable content over technical file information` +\n `\\n• Focus on attributes that add value for end users and collectors` +\n `\\n• Avoid auto-generating meaningless technical attributes as user-facing metadata` +\n `\\n• When fields are missing or inadequate, use forms to collect quality metadata` +\n `\\n• Encourage descriptive names, collectible traits, and storytelling elements`\n );\n\n if (userAccId) {\n parts.push(\n `The user you are assisting has a personal Hedera account ID: ${userAccId}. ` +\n `IMPORTANT: When the user says things like \"I want to send HBAR\" or \"transfer my tokens\", you MUST use ${userAccId} as the sender/from account. ` +\n `For example, if user says \"I want to send 2 HBAR to 0.0.800\", you must set up a transfer where ${userAccId} sends the HBAR, not your operator account.`\n );\n }\n\n const operationalMode =\n this.config.execution?.operationalMode || 'returnBytes';\n if (operationalMode === 'autonomous') {\n parts.push(\n `\\nOPERATIONAL MODE: 'autonomous'. Your goal is to execute transactions directly using your tools. ` +\n `Your account ${operatorId} will be the payer for these transactions. ` +\n `Even if the user's account (${\n userAccId || 'a specified account'\n }) is the actor in the transaction body (e.g., sender of HBAR), ` +\n `you (the agent with operator ${operatorId}) are still executing and paying. For HBAR transfers, ensure the amounts in the 'transfers' array sum to zero (as per tool schema), balancing with your operator account if necessary.`\n );\n } else {\n if (\n this.config.execution?.scheduleUserTransactionsInBytesMode &&\n userAccId\n ) {\n parts.push(\n `\\nOPERATIONAL MODE: 'returnBytes' with scheduled transactions for user actions. ` +\n `When a user asks for a transaction to be prepared (e.g., creating a token, topic, transferring assets for them to sign, etc), ` +\n `you MUST default to creating a Scheduled Transaction using the appropriate tool with the metaOption 'schedule: true'. ` +\n `The user (with account ID ${userAccId}) will be the one to ultimately pay for and (if needed) sign the inner transaction. ` +\n `Your operator account (${operatorId}) will pay for creating the schedule entity itself. ` +\n `You MUST return the ScheduleId and details of the scheduled operation in a structured JSON format with these fields: success, op, schedule_id, description, payer_account_id_scheduled_tx, and scheduled_transaction_details.`\n );\n } else {\n parts.push(\n `\\nOPERATIONAL MODE: 'returnBytes'. Your goal is to provide transaction bytes when possible. ` +\n `When a user asks for a transaction to be prepared (e.g., for them to sign, or for scheduling without the default scheduling flow), ` +\n `you MUST call the appropriate tool. ` +\n `IMPORTANT: Only use metaOption 'returnBytes: true' for tools that explicitly support it (like HBAR transfers, token operations). ` +\n `Many tools (inscriptions, HCS-2, HCS-20, etc.) do NOT support returnBytes and will execute directly - this is expected behavior. ` +\n `For tools without returnBytes support, simply call them with their standard parameters. ` +\n `If you need raw bytes for the user to sign for their own account ${\n userAccId || 'if specified'\n }, ensure the tool constructs the transaction body accordingly when returnBytes IS supported.`\n );\n }\n }\n\n if (this.config.messaging?.conciseMode !== false) {\n parts.push(\n '\\nAlways be concise. If the tool provides a JSON string as its primary output (especially in returnBytes mode), make your accompanying text brief. If the tool does not provide JSON output or an error occurs, your narrative becomes primary; if notes were generated by the tool in such cases, append them to your textual response.'\n );\n }\n\n if (this.config.messaging?.systemPostamble) {\n parts.push(this.config.messaging.systemPostamble);\n }\n\n return parts.join('\\n');\n }\n\n isReady(): boolean {\n return this.initialized;\n }\n}\n\nexport type { AIProvider, VercelAIProvider, BAMLProvider };\n"],"names":[],"mappings":";AAgGO,MAAe,UAAU;AAAA,EAO9B,YAAsB,QAAkC;AAAlC,SAAA,SAAA;AAJtB,SAAU,QAA0B,CAAA;AACpC,SAAU,cAAc;AAItB,SAAK,SAAS,IAAI,OAAO;AAAA,MACvB,QAAQ;AAAA,MACR,QAAQ,OAAO,OAAO,UAAU;AAAA,IAAA,CACjC;AAAA,EACH;AAAA,EAkBO,UAAsC;AAC3C,WAAO,KAAK;AAAA,EACd;AAAA,EAEU,YAAY,OAA2C;AAC/D,QAAI,WAAW,CAAC,GAAG,KAAK;AACxB,UAAM,SAAS,KAAK,OAAO;AAE3B,QAAI,CAAC,OAAQ,QAAO;AAEpB,QAAI,OAAO,oBAAoB,QAAQ;AACrC,iBAAW,SAAS,OAAO,CAAC,SAAS;AACnC,cAAM,YAAa,KAChB;AACH,eAAO,CAAC,aAAa,OAAO,mBAAoB,SAAS,SAAS;AAAA,MACpE,CAAC;AAAA,IACH;AAEA,QAAI,OAAO,eAAe,QAAQ;AAChC,iBAAW,SAAS;AAAA,QAClB,CAAC,SAAS,CAAC,OAAO,cAAe,SAAS,KAAK,IAAI;AAAA,MAAA;AAAA,IAEvD;AAEA,QAAI,OAAO,eAAe;AACxB,iBAAW,SAAS,OAAO,OAAO,aAAa;AAAA,IACjD;AAEA,SAAK,OAAO,MAAM,mBAAmB,MAAM,MAAM,MAAM,SAAS,MAAM,EAAE;AACxE,WAAO;AAAA,EACT;AAAA,EAEU,oBAA4B;AACpC,UAAM,QAAkB,CAAA;AACxB,UAAM,aAAa,KAAK,OAAO,OAAO,aAAA,EAAe,SAAA;AACrD,UAAM,YAAY,KAAK,OAAO,WAAW;AAEzC,QAAI,KAAK,OAAO,WAAW,gBAAgB;AACzC,YAAM,KAAK,KAAK,OAAO,UAAU,cAAc;AAAA,IACjD;AAEA,UAAM;AAAA,MACJ,wEAAwE,UAAU;AAAA,IAAA;AAKpF,UAAM;AAAA,MACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA;AAQF,QAAI,WAAW;AACb,YAAM;AAAA,QACJ,gEAAgE,SAAS,2GACkC,SAAS,+HAChB,SAAS;AAAA,MAAA;AAAA,IAEjH;AAEA,UAAM,kBACJ,KAAK,OAAO,WAAW,mBAAmB;AAC5C,QAAI,oBAAoB,cAAc;AACpC,YAAM;AAAA,QACJ;AAAA,+GACkB,UAAU,0EAExB,aAAa,qBACf,+FACgC,UAAU;AAAA,MAAA;AAAA,IAEhD,OAAO;AACL,UACE,KAAK,OAAO,WAAW,uCACvB,WACA;AACA,cAAM;AAAA,UACJ;AAAA,8VAG+B,SAAS,8GACZ,UAAU;AAAA,QAAA;AAAA,MAG1C,OAAO;AACL,cAAM;AAAA,UACJ;AAAA,8pBAOI,aAAa,cACf;AAAA,QAAA;AAAA,MAEN;AAAA,IACF;AAEA,QAAI,KAAK,OAAO,WAAW,gBAAgB,OAAO;AAChD,YAAM;AAAA,QACJ;AAAA,MAAA;AAAA,IAEJ;AAEA,QAAI,KAAK,OAAO,WAAW,iBAAiB;AAC1C,YAAM,KAAK,KAAK,OAAO,UAAU,eAAe;AAAA,IAClD;AAEA,WAAO,MAAM,KAAK,IAAI;AAAA,EACxB;AAAA,EAEA,UAAmB;AACjB,WAAO,KAAK;AAAA,EACd;AACF;"}
1
+ {"version":3,"file":"index7.js","sources":["../../src/conversational-agent.ts"],"sourcesContent":["import {\n ServerSigner,\n getAllHederaCorePlugins,\n BasePlugin,\n AbstractSigner,\n} from 'hedera-agent-kit';\nimport { Logger, type NetworkType } from '@hashgraphonline/standards-sdk';\nimport { createAgent } from './agent-factory';\nimport BrowserSigner from './signers/browser-signer';\nimport { LangChainProvider } from './providers';\nimport type { ChatResponse, ConversationContext } from './base-agent';\nimport { ChatOpenAI } from '@langchain/openai';\nimport { ChatAnthropic } from '@langchain/anthropic';\nimport {\n HumanMessage,\n AIMessage,\n SystemMessage,\n} from '@langchain/core/messages';\nimport type { AgentOperationalMode, MirrorNodeConfig } from 'hedera-agent-kit';\nimport { HCS10Plugin } from './plugins/hcs-10/HCS10Plugin';\nimport { HCS2Plugin } from './plugins/hcs-2/HCS2Plugin';\nimport { InscribePlugin } from './plugins/inscribe/InscribePlugin';\nimport { getWalletBridgeProvider } from './runtime/wallet-bridge';\nimport {\n InscriberBuilder,\n SignerProviderRegistry,\n} from '@hashgraphonline/standards-agent-kit';\nimport { HbarPlugin } from './plugins/hbar/HbarPlugin';\nimport { WebBrowserPlugin } from './plugins/web-browser/WebBrowserPlugin';\nimport { OpenConvaiState } from '@hashgraphonline/standards-agent-kit';\nimport type { IStateManager } from '@hashgraphonline/standards-agent-kit';\nimport { getSystemMessage } from './config/system-message';\nimport type { MCPServerConfig, MCPConnectionStatus } from './mcp/types';\nimport { ContentStoreManager } from './services/content-store-manager';\nimport { SmartMemoryManager, type SmartMemoryConfig } from './memory';\nimport {\n createEntityTools,\n ResolveEntitiesTool,\n ExtractEntitiesTool,\n} from './tools/entity-resolver-tool';\nimport type { FormSubmission } from './forms/types';\nimport { ParameterService } from './services/parameter-service';\nimport { FormatConverterRegistry } from './services/formatters/format-converter-registry';\nimport { TopicIdToHrlConverter } from './services/formatters/converters/topic-id-to-hrl-converter';\nimport { StringNormalizationConverter } from './services/formatters/converters/string-normalization-converter';\n\nexport type ToolDescriptor = {\n name: string;\n namespace?: string;\n};\n\nexport type ChatHistoryItem = {\n type: 'human' | 'ai' | 'system';\n content: string;\n};\n\nexport type AgentInstance = ReturnType<typeof createAgent>;\n\nexport type MirrorNetwork = 'testnet' | 'mainnet' | 'previewnet';\n\nconst DEFAULT_MODEL_NAME = 'gpt-4o';\nconst DEFAULT_OPENAI_MODEL = 'gpt-4o-mini';\nconst DEFAULT_OPENROUTER_MODEL = 'openai/gpt-4o-mini';\nconst DEFAULT_CLAUDE_MODEL = 'claude-3-7-sonnet-latest';\nconst DEFAULT_TEMPERATURE = 0.1;\nconst DEFAULT_NETWORK = 'testnet';\nconst DEFAULT_OPERATIONAL_MODE: AgentOperationalMode = 'autonomous';\n\nexport interface ConversationalAgentOptions {\n accountId: string;\n privateKey: string;\n network?: NetworkType;\n openAIApiKey: string;\n openAIModelName?: string;\n llmProvider?: 'openai' | 'anthropic' | 'openrouter';\n verbose?: boolean;\n operationalMode?: AgentOperationalMode;\n userAccountId?: string;\n customSystemMessagePreamble?: string;\n customSystemMessagePostamble?: string;\n additionalPlugins?: BasePlugin[];\n stateManager?: IStateManager;\n scheduleUserTransactionsInBytesMode?: boolean;\n mirrorNodeConfig?: MirrorNodeConfig;\n disableLogging?: boolean;\n enabledPlugins?: string[];\n disabledPlugins?: string[];\n toolFilter?: (tool: { name: string; namespace?: string }) => boolean;\n mcpServers?: MCPServerConfig[];\n walletExecutor?: (\n base64: string,\n network: 'mainnet' | 'testnet'\n ) => Promise<{ transactionId: string }>;\n /** Optional: provide a signer factory to override default signer selection */\n customSignerFactory?: (args: {\n operationalMode: AgentOperationalMode;\n accountId: string;\n network: NetworkType;\n }) => AbstractSigner;\n\n /** Enable automatic entity memory functionality (default: true) */\n entityMemoryEnabled?: boolean;\n\n /** Configuration for entity memory system */\n entityMemoryConfig?: SmartMemoryConfig;\n\n /**\n * Provider used for entity extraction/resolution tools (defaults to llmProvider or 'openai')\n */\n entityMemoryProvider?: 'openai' | 'anthropic' | 'openrouter';\n\n /**\n * Model name for entity extraction/resolution tools (defaults per provider)\n */\n entityMemoryModelName?: string;\n\n openRouterApiKey?: string;\n openRouterBaseURL?: string;\n}\n\n/**\n * The ConversationalAgent class is an optional wrapper around the HederaConversationalAgent class,\n * which includes the OpenConvAIPlugin and the OpenConvaiState by default.\n * If you want to use a different plugin or state manager, you can pass them in the options.\n * This class is not required and the plugin can be used directly with the HederaConversationalAgent class.\n *\n * @param options - The options for the ConversationalAgent.\n * @returns A new instance of the ConversationalAgent class.\n */\nexport class ConversationalAgent {\n private static readonly NOT_INITIALIZED_ERROR =\n 'Agent not initialized. Call initialize() first.';\n protected agent?: AgentInstance;\n public hcs10Plugin: HCS10Plugin;\n public hcs2Plugin: HCS2Plugin;\n public inscribePlugin: InscribePlugin;\n public hbarPlugin: HbarPlugin;\n public webBrowserPlugin: WebBrowserPlugin;\n public stateManager: IStateManager;\n private options: ConversationalAgentOptions;\n public logger: Logger;\n public contentStoreManager?: ContentStoreManager;\n public memoryManager?: SmartMemoryManager | undefined;\n private entityTools?: {\n resolveEntities: ResolveEntitiesTool;\n extractEntities: ExtractEntitiesTool;\n };\n\n constructor(options: ConversationalAgentOptions) {\n this.options = options;\n this.stateManager = options.stateManager || new OpenConvaiState();\n this.hcs10Plugin = new HCS10Plugin();\n this.hcs2Plugin = new HCS2Plugin();\n this.inscribePlugin = new InscribePlugin();\n this.hbarPlugin = new HbarPlugin();\n this.webBrowserPlugin = new WebBrowserPlugin();\n this.logger = new Logger({\n module: 'ConversationalAgent',\n silent: options.disableLogging || false,\n });\n\n if (this.options.entityMemoryEnabled !== false) {\n if (!options.openAIApiKey) {\n throw new Error(\n 'OpenAI/Anthropic API key is required when entity memory is enabled'\n );\n }\n\n this.memoryManager = new SmartMemoryManager(\n this.options.entityMemoryConfig\n );\n this.logger.info('Entity memory initialized');\n\n const provider =\n options.entityMemoryProvider || options.llmProvider || 'openai';\n let modelName = options.entityMemoryModelName;\n if (!modelName) {\n if (provider === 'anthropic') {\n modelName = DEFAULT_CLAUDE_MODEL;\n } else if (provider === 'openrouter') {\n modelName = DEFAULT_OPENROUTER_MODEL;\n } else {\n modelName = DEFAULT_OPENAI_MODEL;\n }\n }\n\n let resolverLLM: ChatOpenAI | ChatAnthropic;\n if (provider === 'anthropic') {\n resolverLLM = new ChatAnthropic({\n apiKey: options.openAIApiKey,\n model: modelName,\n temperature: 0,\n });\n } else if (provider === 'openrouter') {\n const baseURL =\n options.openRouterBaseURL || 'https://openrouter.ai/api/v1';\n const apiKey = options.openRouterApiKey || options.openAIApiKey;\n resolverLLM = new ChatOpenAI({\n apiKey,\n model: modelName,\n temperature: 0,\n configuration: {\n baseURL,\n defaultHeaders: {\n 'HTTP-Referer':\n process.env.OPENROUTER_REFERRER ||\n 'https://hashgraphonline.com',\n 'X-Title':\n process.env.OPENROUTER_TITLE ||\n 'Hashgraph Online Conversational Agent',\n },\n },\n });\n } else {\n resolverLLM = new ChatOpenAI({\n apiKey: options.openAIApiKey,\n model: modelName,\n temperature: 0,\n });\n }\n\n this.entityTools = createEntityTools(resolverLLM);\n this.logger.info('LLM-based entity resolver tools initialized');\n }\n }\n\n /**\n * Initialize the conversational agent with Hedera Hashgraph connection and AI configuration\n * @throws {Error} If account ID or private key is missing\n * @throws {Error} If initialization fails\n */\n async initialize(): Promise<void> {\n const {\n accountId,\n privateKey,\n network = DEFAULT_NETWORK,\n openAIApiKey,\n openAIModelName = DEFAULT_MODEL_NAME,\n llmProvider = 'openai',\n } = this.options;\n\n this.validateOptions(accountId, privateKey);\n\n try {\n const opMode = (this.options.operationalMode ||\n DEFAULT_OPERATIONAL_MODE) as string;\n const bytesMode = opMode !== 'autonomous';\n let signer: AbstractSigner;\n\n try {\n type InscriberBuilderWithWalletMethods = typeof InscriberBuilder & {\n setPreferWalletOnly?: (prefer: boolean) => void;\n setWalletInfoResolver?: (\n fn: () => Promise<{ accountId: string; network: string } | null>\n ) => void;\n setWalletExecutor?: (\n fn: (\n base64: string,\n network: 'mainnet' | 'testnet'\n ) => Promise<{ transactionId: string }>\n ) => void;\n setStartInscriptionDelegate?: (\n fn: (\n request: Record<string, unknown>,\n network: 'mainnet' | 'testnet'\n ) => Promise<unknown>\n ) => void;\n };\n const IB = InscriberBuilder as InscriberBuilderWithWalletMethods;\n if (typeof IB.setPreferWalletOnly === 'function') {\n IB.setPreferWalletOnly(false);\n }\n } catch (e) {\n this.logger.warn('Failed to set wallet-only preference', e as Error);\n }\n if (!bytesMode) {\n signer = new ServerSigner(\n accountId!,\n privateKey!,\n network as MirrorNetwork\n );\n } else {\n const chain: 'mainnet' | 'testnet' =\n String(network || 'testnet') === 'mainnet' ? 'mainnet' : 'testnet';\n const effectiveAccount = (this.options.userAccountId || accountId)!;\n signer = new BrowserSigner(\n effectiveAccount,\n chain,\n this.options.walletExecutor\n );\n }\n\n this.logger.info('Signer configured', {\n operationalMode: opMode,\n bytesMode,\n signerClass:\n Object.getPrototypeOf(signer)?.constructor?.name || 'unknown',\n });\n\n try {\n const bridge = getWalletBridgeProvider();\n if (bridge) {\n type InscriberBuilderWithWalletMethods = typeof InscriberBuilder & {\n setWalletInfoResolver?: (\n fn: () => Promise<{ accountId: string; network: string } | null>\n ) => void;\n setWalletExecutor?: (\n fn: (\n base64: string,\n network: 'mainnet' | 'testnet'\n ) => Promise<{ transactionId: string }>\n ) => void;\n setStartInscriptionDelegate?: (\n fn: (\n request: Record<string, unknown>,\n network: 'mainnet' | 'testnet'\n ) => Promise<unknown>\n ) => void;\n };\n const IB = InscriberBuilder as InscriberBuilderWithWalletMethods;\n if (typeof IB.setWalletInfoResolver === 'function') {\n IB.setWalletInfoResolver(async () => {\n const status = await bridge.status();\n if (status.connected && status.accountId && status.network) {\n return { accountId: status.accountId, network: status.network };\n }\n return null;\n });\n }\n if (typeof IB.setWalletExecutor === 'function') {\n IB.setWalletExecutor(\n async (base64: string, network: 'mainnet' | 'testnet') => {\n return await bridge.executeBytes(base64, network);\n }\n );\n }\n if (\n typeof IB.setStartInscriptionDelegate === 'function' &&\n bridge.startInscription\n ) {\n IB.setStartInscriptionDelegate(\n async (\n request: Record<string, unknown>,\n network: 'mainnet' | 'testnet'\n ) => {\n return await bridge.startInscription!(request, network);\n }\n );\n }\n\n try {\n type HCSOp =\n | 'submitConnectionRequest'\n | 'handleConnectionRequest'\n | 'sendMessage'\n | 'hcs2.createRegistry'\n | 'hcs2.migrateRegistry'\n | 'hcs2.registerEntry'\n | 'hcs2.updateEntry'\n | 'hcs2.deleteEntry'\n | 'hcs2.submitMessage'\n | 'hcs6.createRegistry'\n | 'hcs6.registerEntry'\n | 'hcs6.submitMessage';\n type WalletBridgeProviderExt = ReturnType<\n typeof getWalletBridgeProvider\n > & {\n startHCS?: (\n op: HCSOp,\n request: Record<string, unknown>,\n network: 'mainnet' | 'testnet'\n ) => Promise<{ transactionBytes: string }>;\n };\n\n const status = await bridge.status();\n const enforceWallet = !!(bytesMode && status.connected);\n\n SignerProviderRegistry.setWalletInfoResolver(async () => {\n const s = await bridge.status();\n if (s.connected && s.accountId && s.network) {\n return {\n accountId: s.accountId,\n network: s.network as 'mainnet' | 'testnet',\n };\n }\n return null;\n });\n\n SignerProviderRegistry.setWalletExecutor(\n async (base64: string, network: 'mainnet' | 'testnet') => {\n return await bridge.executeBytes(base64, network);\n }\n );\n\n const extended = bridge as WalletBridgeProviderExt;\n if (typeof extended?.startHCS === 'function') {\n SignerProviderRegistry.setStartHCSDelegate(\n async (op, request, network) => {\n return await extended.startHCS!(\n op as HCSOp,\n request,\n network\n );\n }\n );\n } else {\n SignerProviderRegistry.setStartHCSDelegate(null);\n }\n\n SignerProviderRegistry.setPreferWalletOnly(enforceWallet);\n\n type InscriberBuilderWithWalletMethods = typeof InscriberBuilder & {\n setPreferWalletOnly?: (prefer: boolean) => void;\n };\n const IB2 = InscriberBuilder as InscriberBuilderWithWalletMethods;\n if (typeof IB2.setPreferWalletOnly === 'function') {\n IB2.setPreferWalletOnly(enforceWallet);\n }\n } catch (sakWireErr) {\n this.logger.warn(\n 'Failed to wire SAK SignerProviderRegistry wallet delegates',\n sakWireErr as Error\n );\n }\n }\n } catch (e) {\n this.logger.warn(\n 'Failed to register wallet bridge providers',\n e as Error\n );\n }\n\n let llm: ChatOpenAI | ChatAnthropic;\n let providerInfo: Record<string, unknown> = { provider: llmProvider };\n if (llmProvider === 'anthropic') {\n llm = new ChatAnthropic({\n apiKey: openAIApiKey,\n model: openAIModelName || DEFAULT_CLAUDE_MODEL,\n temperature: DEFAULT_TEMPERATURE,\n });\n providerInfo = {\n ...providerInfo,\n model: openAIModelName || DEFAULT_CLAUDE_MODEL,\n keyPresent: !!openAIApiKey,\n };\n } else if (llmProvider === 'openrouter') {\n const baseURL =\n this.options.openRouterBaseURL || 'https://openrouter.ai/api/v1';\n const apiKey = this.options.openRouterApiKey || openAIApiKey;\n const modelName =\n openAIModelName || 'anthropic/claude-3-haiku-20240307';\n llm = new ChatOpenAI({\n apiKey,\n model: modelName,\n temperature: DEFAULT_TEMPERATURE,\n configuration: {\n baseURL,\n defaultHeaders: {\n 'HTTP-Referer':\n process.env.OPENROUTER_REFERRER ||\n 'https://hashgraphonline.com',\n 'X-Title':\n process.env.OPENROUTER_TITLE ||\n 'Hashgraph Online Conversational Agent',\n },\n },\n });\n providerInfo = {\n ...providerInfo,\n model: modelName,\n baseURL,\n keyPresent: !!apiKey,\n };\n } else {\n const modelName2 = openAIModelName || DEFAULT_OPENAI_MODEL;\n const isGPT5Model =\n modelName2.toLowerCase().includes('gpt-5') ||\n modelName2.toLowerCase().includes('gpt5');\n llm = new ChatOpenAI({\n apiKey: openAIApiKey,\n model: modelName2,\n ...(isGPT5Model\n ? { temperature: 1 }\n : { temperature: DEFAULT_TEMPERATURE }),\n });\n providerInfo = {\n ...providerInfo,\n model: modelName2,\n keyPresent: !!openAIApiKey,\n };\n }\n\n this.logger.info('AI provider configured', providerInfo);\n\n this.logger.info('Preparing plugins...');\n const allPlugins = this.preparePlugins();\n this.logger.info('Creating agent config...');\n const agentConfig = this.createAgentConfig(\n signer as ServerSigner,\n llm,\n allPlugins\n );\n\n this.logger.info('Creating agent...');\n this.agent = createAgent(agentConfig);\n this.logger.info('Agent created');\n\n this.logger.info('Configuring HCS10 plugin...');\n this.configureHCS10Plugin(allPlugins);\n this.logger.info('HCS10 plugin configured');\n\n this.contentStoreManager = new ContentStoreManager();\n await this.contentStoreManager.initialize();\n this.logger.info(\n 'ContentStoreManager initialized for content reference support'\n );\n\n this.logger.info('About to call agent.boot()');\n this.logger.info('🔥 About to call agent.boot()');\n await this.agent.boot();\n this.logger.info('agent.boot() completed');\n this.logger.info('🔥 agent.boot() completed');\n\n if (this.agent) {\n try {\n const registry = new FormatConverterRegistry();\n registry.register(new TopicIdToHrlConverter());\n registry.register(new StringNormalizationConverter());\n const paramService = new ParameterService(\n registry,\n (this.options.network as unknown as NetworkType) || 'testnet'\n );\n paramService.attachToAgent(this.agent, {\n getEntities: async () =>\n this.memoryManager?.getEntityAssociations() || [],\n });\n this.logger.info(\n 'Parameter preprocessing callback attached (internal)'\n );\n } catch (e) {\n this.logger.warn(\n 'Failed to attach internal parameter preprocessing callback',\n e\n );\n }\n\n const cfg = agentConfig;\n cfg.filtering = cfg.filtering || {};\n const originalPredicate = cfg.filtering.toolPredicate as\n | ((t: ToolDescriptor) => boolean)\n | undefined;\n const userPredicate = this.options.toolFilter;\n cfg.filtering.toolPredicate = (tool: ToolDescriptor): boolean => {\n if (tool && tool.name === 'hedera-account-transfer-hbar') {\n return false;\n }\n if (tool && tool.name === 'hedera-hts-airdrop-token') {\n return false;\n }\n if (originalPredicate && !originalPredicate(tool)) {\n return false;\n }\n if (userPredicate && !userPredicate(tool)) {\n return false;\n }\n return true;\n };\n }\n\n if (this.options.mcpServers && this.options.mcpServers.length > 0) {\n this.connectMCP();\n }\n } catch (error) {\n this.logger.error('Failed to initialize ConversationalAgent:', error);\n throw error;\n }\n }\n\n /**\n * Get the HCS-10 plugin instance\n * @returns {HCS10Plugin} The HCS-10 plugin instance\n */\n getPlugin(): HCS10Plugin {\n return this.hcs10Plugin;\n }\n\n /**\n * Get the state manager instance\n * @returns {IStateManager} The state manager instance\n */\n getStateManager(): IStateManager {\n return this.stateManager;\n }\n\n /**\n * Get the underlying agent instance\n * @returns {ReturnType<typeof createAgent>} The agent instance\n * @throws {Error} If agent is not initialized\n */\n getAgent(): ReturnType<typeof createAgent> {\n if (!this.agent) {\n throw new Error(ConversationalAgent.NOT_INITIALIZED_ERROR);\n }\n return this.agent;\n }\n\n /**\n * Get the conversational agent instance (alias for getAgent)\n * @returns {ReturnType<typeof createAgent>} The agent instance\n * @throws {Error} If agent is not initialized\n */\n getConversationalAgent(): ReturnType<typeof createAgent> {\n return this.getAgent();\n }\n\n /**\n * Process a message through the conversational agent\n * @param {string} message - The message to process\n * @param {Array<{type: 'human' | 'ai'; content: string}>} chatHistory - Previous chat history\n * @returns {Promise<ChatResponse>} The agent's response\n * @throws {Error} If agent is not initialized\n */\n async processMessage(\n message: string,\n chatHistory: ChatHistoryItem[] = []\n ): Promise<ChatResponse> {\n if (!this.agent) {\n throw new Error('Agent not initialized. Call initialize() first.');\n }\n\n try {\n const resolvedMessage = message;\n\n const messages = chatHistory.map((msg) => {\n const content = msg.content;\n if (msg.type === 'system') {\n return new SystemMessage(content);\n }\n return msg.type === 'human'\n ? new HumanMessage(content)\n : new AIMessage(content);\n });\n\n const context: ConversationContext = { messages };\n const response = await this.agent.chat(resolvedMessage, context);\n\n if (\n this.memoryManager &&\n this.options.operationalMode !== 'returnBytes'\n ) {\n await this.extractAndStoreEntities(response, message);\n }\n\n this.logger.info('Message processed successfully');\n return response;\n } catch (error) {\n this.logger.error('Error processing message:', error);\n throw error;\n }\n }\n\n /**\n * Process form submission through the conversational agent\n * @param {FormSubmission} submission - The form submission data\n * @returns {Promise<ChatResponse>} The agent's response after processing the form\n * @throws {Error} If agent is not initialized or doesn't support form processing\n */\n async processFormSubmission(\n submission: FormSubmission\n ): Promise<ChatResponse> {\n if (!this.agent) {\n throw new Error(ConversationalAgent.NOT_INITIALIZED_ERROR);\n }\n\n try {\n this.logger.info('Processing form submission:', {\n formId: submission.formId,\n toolName: submission.toolName,\n parameterKeys: Object.keys(submission.parameters || {}),\n hasContext: !!submission.context,\n });\n const response = await this.agent.processFormSubmission(submission);\n this.logger.info('Form submission processed successfully');\n return response;\n } catch (error) {\n this.logger.error('Error processing form submission:', error);\n throw error;\n }\n }\n\n /**\n * Validates initialization options and throws if required fields are missing.\n *\n * @param accountId - The Hedera account ID\n * @param privateKey - The private key for the account\n * @throws {Error} If required fields are missing\n */\n private validateOptions(accountId?: string, privateKey?: string): void {\n const opMode = (this.options.operationalMode ||\n DEFAULT_OPERATIONAL_MODE) as string;\n const bytesMode = opMode !== 'autonomous';\n if (!accountId) {\n throw new Error('Account ID is required');\n }\n if (!privateKey && !bytesMode) {\n throw new Error('Private key is required in autonomous mode');\n }\n\n if (typeof accountId !== 'string') {\n throw new Error(\n `Account ID must be a string, received ${typeof accountId}`\n );\n }\n\n if (!bytesMode && typeof privateKey !== 'string') {\n throw new Error(\n `Private key must be a string, received ${typeof privateKey}: ${JSON.stringify(\n privateKey\n )}`\n );\n }\n if (\n !bytesMode &&\n typeof privateKey === 'string' &&\n privateKey.length < 10\n ) {\n throw new Error('Private key appears to be invalid (too short)');\n }\n }\n\n /**\n * Prepares the list of plugins to use based on configuration.\n *\n * @returns Array of plugins to initialize with the agent\n */\n private preparePlugins(): BasePlugin[] {\n const { additionalPlugins = [], enabledPlugins, disabledPlugins } = this.options;\n\n const standardPlugins: BasePlugin[] = [\n this.hcs10Plugin,\n this.hcs2Plugin,\n this.inscribePlugin,\n this.hbarPlugin,\n ];\n standardPlugins.push(this.webBrowserPlugin);\n\n const corePlugins = getAllHederaCorePlugins();\n let pluginPool = [...standardPlugins, ...corePlugins];\n\n if (enabledPlugins) {\n const enabledSet = new Set(enabledPlugins);\n pluginPool = pluginPool.filter((plugin) => enabledSet.has(plugin.id));\n }\n\n if (disabledPlugins && disabledPlugins.length > 0) {\n const disabledSet = new Set(disabledPlugins);\n pluginPool = pluginPool.filter((plugin) => !disabledSet.has(plugin.id));\n }\n\n const additional = disabledPlugins && disabledPlugins.length > 0\n ? additionalPlugins.filter((plugin) => !disabledPlugins.includes(plugin.id))\n : additionalPlugins;\n\n return [...pluginPool, ...additional];\n }\n\n /**\n * Creates the agent configuration object.\n *\n * @param signer - The signer instance\n * @param llm - The language model instance\n * @param allPlugins - Array of plugins to use\n * @returns Configuration object for creating the agent\n */\n private createAgentConfig(\n signer: ServerSigner,\n llm: ChatOpenAI | ChatAnthropic,\n allPlugins: BasePlugin[]\n ): Parameters<typeof createAgent>[0] {\n const {\n operationalMode = DEFAULT_OPERATIONAL_MODE,\n userAccountId,\n scheduleUserTransactionsInBytesMode,\n customSystemMessagePreamble,\n customSystemMessagePostamble,\n verbose = false,\n mirrorNodeConfig,\n disableLogging,\n accountId = '',\n } = this.options;\n\n return {\n framework: 'langchain',\n signer,\n execution: {\n mode: operationalMode === 'autonomous' ? 'direct' : 'bytes',\n operationalMode: operationalMode,\n ...(userAccountId && { userAccountId }),\n ...(scheduleUserTransactionsInBytesMode !== undefined && {\n scheduleUserTransactionsInBytesMode:\n scheduleUserTransactionsInBytesMode,\n scheduleUserTransactions: scheduleUserTransactionsInBytesMode,\n }),\n },\n ai: {\n provider: new LangChainProvider(llm),\n temperature: DEFAULT_TEMPERATURE,\n },\n filtering: {\n toolPredicate: (tool: ToolDescriptor): boolean => {\n if (tool.name === 'hedera-account-transfer-hbar') return false;\n if (this.options.toolFilter && !this.options.toolFilter(tool)) {\n return false;\n }\n return true;\n },\n },\n messaging: {\n systemPreamble:\n customSystemMessagePreamble || getSystemMessage(accountId),\n ...(customSystemMessagePostamble && {\n systemPostamble: customSystemMessagePostamble,\n }),\n conciseMode: true,\n },\n extensions: {\n plugins: allPlugins,\n ...(mirrorNodeConfig && {\n mirrorConfig: mirrorNodeConfig as Record<string, unknown>,\n }),\n },\n ...(this.options.mcpServers && {\n mcp: {\n servers: this.options.mcpServers,\n autoConnect: false,\n },\n }),\n debug: {\n verbose,\n silent: disableLogging ?? false,\n },\n };\n }\n\n /**\n * Configures the HCS-10 plugin with the state manager.\n *\n * @param allPlugins - Array of all plugins\n */\n private configureHCS10Plugin(allPlugins: BasePlugin[]): void {\n const hcs10 = allPlugins.find((p) => p.id === 'hcs-10');\n if (hcs10) {\n (\n hcs10 as BasePlugin & { appConfig?: Record<string, unknown> }\n ).appConfig = {\n stateManager: this.stateManager,\n };\n }\n }\n\n /**\n * Create a ConversationalAgent with specific plugins enabled\n */\n private static withPlugins(\n options: ConversationalAgentOptions,\n plugins: string[]\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n enabledPlugins: plugins,\n });\n }\n\n /**\n * Create a ConversationalAgent with only HTS (Hedera Token Service) tools enabled\n */\n static withHTS(options: ConversationalAgentOptions): ConversationalAgent {\n return this.withPlugins(options, ['hts-token']);\n }\n\n /**\n * Create a ConversationalAgent with only HCS-2 tools enabled\n */\n static withHCS2(options: ConversationalAgentOptions): ConversationalAgent {\n return this.withPlugins(options, ['hcs-2']);\n }\n\n /**\n * Create a ConversationalAgent with only HCS-10 tools enabled\n */\n static withHCS10(options: ConversationalAgentOptions): ConversationalAgent {\n return this.withPlugins(options, ['hcs-10']);\n }\n\n /**\n * Create a ConversationalAgent with only inscription tools enabled\n */\n static withInscribe(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return this.withPlugins(options, ['inscribe']);\n }\n\n /**\n * Create a ConversationalAgent with only account management tools enabled\n */\n static withAccount(options: ConversationalAgentOptions): ConversationalAgent {\n return this.withPlugins(options, ['account']);\n }\n\n /**\n * Create a ConversationalAgent with only file service tools enabled\n */\n static withFileService(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return this.withPlugins(options, ['file-service']);\n }\n\n /**\n * Create a ConversationalAgent with only consensus service tools enabled\n */\n static withConsensusService(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return this.withPlugins(options, ['consensus-service']);\n }\n\n /**\n * Create a ConversationalAgent with only smart contract tools enabled\n */\n static withSmartContract(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return this.withPlugins(options, ['smart-contract']);\n }\n\n /**\n * Create a ConversationalAgent with all HCS standards plugins\n */\n static withAllStandards(\n options: ConversationalAgentOptions\n ): ConversationalAgent {\n return this.withPlugins(options, ['hcs-10', 'hcs-2', 'inscribe']);\n }\n\n /**\n * Create a ConversationalAgent with minimal Hedera tools (no HCS standards)\n */\n static minimal(options: ConversationalAgentOptions): ConversationalAgent {\n return this.withPlugins(options, []);\n }\n\n /**\n * Create a ConversationalAgent with MCP servers configured\n */\n static withMCP(\n options: ConversationalAgentOptions,\n mcpServers: MCPServerConfig[]\n ): ConversationalAgent {\n return new ConversationalAgent({\n ...options,\n mcpServers,\n });\n }\n\n /**\n * Extract and store entities from agent responses\n * @param response - Agent response containing potential entity information\n * @param originalMessage - Original user message for context\n */\n private async extractAndStoreEntities(\n response: unknown,\n originalMessage: string\n ): Promise<void> {\n if (!this.memoryManager || !this.entityTools) {\n return;\n }\n\n try {\n this.logger.info('Starting LLM-based entity extraction');\n\n const responseText = this.extractResponseText(response);\n\n const entitiesJson = await this.entityTools.extractEntities.call({\n response: responseText,\n userMessage: originalMessage,\n });\n\n try {\n const entities = JSON.parse(entitiesJson);\n\n for (const entity of entities) {\n if (\n entity &&\n typeof entity === 'object' &&\n 'name' in entity &&\n 'type' in entity &&\n 'id' in entity\n ) {\n this.logger.info(\n `Storing entity: ${entity.name} (${entity.type}) -> ${entity.id}`\n );\n\n const transactionId = this.extractTransactionId(response);\n const idStr = String(entity.id);\n const isHederaId = /^0\\.0\\.[0-9]+$/.test(idStr);\n if (!isHederaId) {\n this.logger.warn('Skipping non-ID entity from extraction', {\n id: idStr,\n name: String(entity.name),\n type: String(entity.type),\n });\n } else {\n this.memoryManager.storeEntityAssociation(\n idStr,\n String(entity.name),\n String(entity.type),\n transactionId\n );\n }\n }\n }\n\n if (entities.length > 0) {\n this.logger.info(\n `Stored ${entities.length} entities via LLM extraction`\n );\n } else {\n this.logger.info('No entities found in response via LLM extraction');\n }\n } catch (parseError) {\n this.logger.error(\n 'Failed to parse extracted entities JSON:',\n parseError\n );\n throw parseError;\n }\n } catch (error) {\n this.logger.error('Entity extraction failed:', error);\n throw error;\n }\n }\n\n /**\n * Extract transaction ID from response if available\n * @param response - Transaction response\n * @returns Transaction ID or undefined\n */\n private extractTransactionId(response: unknown): string | undefined {\n try {\n if (\n typeof response === 'object' &&\n response &&\n 'transactionId' in response\n ) {\n const responseWithTxId = response as { transactionId?: unknown };\n return typeof responseWithTxId.transactionId === 'string'\n ? responseWithTxId.transactionId\n : undefined;\n }\n if (typeof response === 'string') {\n const match = response.match(\n /transaction[\\s\\w]*ID[\\s:\"]*([0-9a-fA-F@._-]+)/i\n );\n return match ? match[1] : undefined;\n }\n return undefined;\n } catch {\n return undefined;\n }\n }\n\n /**\n * Connect to MCP servers asynchronously\n * @private\n */\n private connectMCP(): void {\n if (!this.agent || !this.options.mcpServers) {\n return;\n }\n\n this.agent\n .connectMCPServers()\n .catch((e) => {\n this.logger.error('Failed to connect MCP servers:', e);\n })\n .then(() => {\n this.logger.info('MCP servers connected successfully');\n });\n }\n\n /**\n * Get MCP connection status for all servers\n * @returns {Map<string, MCPConnectionStatus>} Connection status map\n */\n getMCPConnectionStatus(): Map<string, MCPConnectionStatus> {\n if (this.agent) {\n return this.agent.getMCPConnectionStatus();\n }\n return new Map();\n }\n\n /**\n * Check if a specific MCP server is connected\n * @param {string} serverName - Name of the server to check\n * @returns {boolean} True if connected, false otherwise\n */\n isMCPServerConnected(serverName: string): boolean {\n if (this.agent) {\n const statusMap = this.agent.getMCPConnectionStatus();\n const status = statusMap.get(serverName);\n return status?.connected ?? false;\n }\n return false;\n }\n\n /**\n * Clean up resources\n */\n async cleanup(): Promise<void> {\n try {\n this.logger.info('Cleaning up ConversationalAgent...');\n\n if (this.memoryManager) {\n try {\n this.memoryManager.dispose();\n this.logger.info('Memory manager cleaned up successfully');\n } catch (error) {\n this.logger.warn('Error cleaning up memory manager:', error);\n }\n this.memoryManager = undefined;\n }\n\n if (this.contentStoreManager) {\n await this.contentStoreManager.dispose();\n this.logger.info('ContentStoreManager cleaned up');\n }\n\n this.logger.info('ConversationalAgent cleanup completed');\n } catch (error) {\n this.logger.error('Error during cleanup:', error);\n }\n }\n\n /**\n * Switch operational mode\n */\n switchMode(mode?: AgentOperationalMode): void {\n if (this.agent?.switchMode) {\n this.agent.switchMode(mode || 'autonomous');\n }\n }\n\n /**\n * Get usage statistics\n */\n getUsageStats(): unknown {\n return this.agent?.getUsageStats?.() ?? {};\n }\n\n /**\n * Clear usage statistics\n */\n clearUsageStats(): void {\n if (this.agent?.clearUsageStats) {\n this.agent.clearUsageStats();\n }\n }\n\n /**\n * Shutdown the agent\n */\n shutdown(): Promise<void> {\n return this.agent?.shutdown?.() ?? Promise.resolve();\n }\n\n private extractResponseText(response: unknown): string {\n if (typeof response === 'string') {\n return response;\n }\n\n if (response && typeof response === 'object' && 'output' in response) {\n const responseWithOutput = response as { output: unknown };\n return String(responseWithOutput.output);\n }\n\n return JSON.stringify(response);\n }\n}\n"],"names":["network"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAM,qBAAqB;AAC3B,MAAM,uBAAuB;AAC7B,MAAM,2BAA2B;AACjC,MAAM,uBAAuB;AAC7B,MAAM,sBAAsB;AAC5B,MAAM,kBAAkB;AACxB,MAAM,2BAAiD;AA+DhD,MAAM,uBAAN,MAAM,qBAAoB;AAAA,EAmB/B,YAAY,SAAqC;AAC/C,SAAK,UAAU;AACf,SAAK,eAAe,QAAQ,gBAAgB,IAAI,gBAAA;AAChD,SAAK,cAAc,IAAI,YAAA;AACvB,SAAK,aAAa,IAAI,WAAA;AACtB,SAAK,iBAAiB,IAAI,eAAA;AAC1B,SAAK,aAAa,IAAI,WAAA;AACtB,SAAK,mBAAmB,IAAI,iBAAA;AAC5B,SAAK,SAAS,IAAI,OAAO;AAAA,MACvB,QAAQ;AAAA,MACR,QAAQ,QAAQ,kBAAkB;AAAA,IAAA,CACnC;AAED,QAAI,KAAK,QAAQ,wBAAwB,OAAO;AAC9C,UAAI,CAAC,QAAQ,cAAc;AACzB,cAAM,IAAI;AAAA,UACR;AAAA,QAAA;AAAA,MA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M,qBAAqB;AAC3B,aAAO,OAAO,mBAAmB,MAAM;AAAA,IACzC;AAEA,WAAO,KAAK,UAAU,QAAQ;AAAA,EAChC;AACF;AAniCE,qBAAwB,wBACtB;AAFG,IAAM,sBAAN;"}
@@ -1,18 +1,96 @@
1
- import { LangChainAgent } from "./index33.js";
2
- function createAgent(config) {
3
- const framework = config.framework || "langchain";
4
- switch (framework) {
5
- case "langchain":
6
- return new LangChainAgent(config);
7
- case "vercel":
8
- throw new Error("Vercel AI SDK support coming soon");
9
- case "baml":
10
- throw new Error("BAML support coming soon");
11
- default:
12
- throw new Error(`Unknown framework: ${framework}`);
1
+ import { Logger } from "@hashgraphonline/standards-sdk";
2
+ class BaseAgent {
3
+ constructor(config) {
4
+ this.config = config;
5
+ this.tools = [];
6
+ this.initialized = false;
7
+ this.logger = new Logger({
8
+ module: "BaseAgent",
9
+ silent: config.debug?.silent || false
10
+ });
11
+ }
12
+ getCore() {
13
+ return this.agentKit;
14
+ }
15
+ filterTools(tools) {
16
+ let filtered = [...tools];
17
+ const filter = this.config.filtering;
18
+ if (!filter) return filtered;
19
+ if (filter.namespaceWhitelist?.length) {
20
+ filtered = filtered.filter((tool) => {
21
+ const namespace = tool.namespace;
22
+ return !namespace || filter.namespaceWhitelist.includes(namespace);
23
+ });
24
+ }
25
+ if (filter.toolBlacklist?.length) {
26
+ filtered = filtered.filter(
27
+ (tool) => !filter.toolBlacklist.includes(tool.name)
28
+ );
29
+ }
30
+ if (filter.toolPredicate) {
31
+ filtered = filtered.filter(filter.toolPredicate);
32
+ }
33
+ this.logger.debug(`Filtered tools: ${tools.length} → ${filtered.length}`);
34
+ return filtered;
35
+ }
36
+ buildSystemPrompt() {
37
+ const parts = [];
38
+ const operatorId = this.config.signer.getAccountId().toString();
39
+ const userAccId = this.config.execution?.userAccountId;
40
+ if (this.config.messaging?.systemPreamble) {
41
+ parts.push(this.config.messaging.systemPreamble);
42
+ }
43
+ parts.push(
44
+ `You are a helpful Hedera assistant. Your primary operator account is ${operatorId}. You have tools to interact with the Hedera Hashgraph. When using any tool, provide all necessary parameters as defined by that tool's schema and description.`
45
+ );
46
+ parts.push(
47
+ `
48
+ METADATA QUALITY PRINCIPLES: When collecting user input for metadata creation across any tool:
49
+ • Prioritize meaningful, valuable content over technical file information
50
+ • Focus on attributes that add value for end users and collectors
51
+ • Avoid auto-generating meaningless technical attributes as user-facing metadata
52
+ • When fields are missing or inadequate, use forms to collect quality metadata
53
+ • Encourage descriptive names, collectible traits, and storytelling elements`
54
+ );
55
+ if (userAccId) {
56
+ parts.push(
57
+ `The user you are assisting has a personal Hedera account ID: ${userAccId}. IMPORTANT: When the user says things like "I want to send HBAR" or "transfer my tokens", you MUST use ${userAccId} as the sender/from account. For example, if user says "I want to send 2 HBAR to 0.0.800", you must set up a transfer where ${userAccId} sends the HBAR, not your operator account.`
58
+ );
59
+ }
60
+ const operationalMode = this.config.execution?.operationalMode || "returnBytes";
61
+ if (operationalMode === "autonomous") {
62
+ parts.push(
63
+ `
64
+ OPERATIONAL MODE: 'autonomous'. Your goal is to execute transactions directly using your tools. Your account ${operatorId} will be the payer for these transactions. Even if the user's account (${userAccId || "a specified account"}) is the actor in the transaction body (e.g., sender of HBAR), you (the agent with operator ${operatorId}) are still executing and paying. For HBAR transfers, ensure the amounts in the 'transfers' array sum to zero (as per tool schema), balancing with your operator account if necessary.`
65
+ );
66
+ } else {
67
+ if (this.config.execution?.scheduleUserTransactionsInBytesMode && userAccId) {
68
+ parts.push(
69
+ `
70
+ OPERATIONAL MODE: 'returnBytes' with scheduled transactions for user actions. When a user asks for a transaction to be prepared (e.g., creating a token, topic, transferring assets for them to sign, etc), you MUST default to creating a Scheduled Transaction using the appropriate tool with the metaOption 'schedule: true'. The user (with account ID ${userAccId}) will be the one to ultimately pay for and (if needed) sign the inner transaction. Your operator account (${operatorId}) will pay for creating the schedule entity itself. You MUST return the ScheduleId and details of the scheduled operation in a structured JSON format with these fields: success, op, schedule_id, description, payer_account_id_scheduled_tx, and scheduled_transaction_details.`
71
+ );
72
+ } else {
73
+ parts.push(
74
+ `
75
+ OPERATIONAL MODE: 'returnBytes'. Your goal is to provide transaction bytes when possible. When a user asks for a transaction to be prepared (e.g., for them to sign, or for scheduling without the default scheduling flow), you MUST call the appropriate tool. IMPORTANT: Only use metaOption 'returnBytes: true' for tools that explicitly support it (like HBAR transfers, token operations). Many tools (inscriptions, HCS-2, HCS-20, etc.) do NOT support returnBytes and will execute directly - this is expected behavior. For tools without returnBytes support, simply call them with their standard parameters. If you need raw bytes for the user to sign for their own account ${userAccId || "if specified"}, ensure the tool constructs the transaction body accordingly when returnBytes IS supported.`
76
+ );
77
+ }
78
+ }
79
+ if (this.config.messaging?.conciseMode !== false) {
80
+ parts.push(
81
+ "\nAlways be concise. If the tool provides a JSON string as its primary output (especially in returnBytes mode), make your accompanying text brief. If the tool does not provide JSON output or an error occurs, your narrative becomes primary; if notes were generated by the tool in such cases, append them to your textual response."
82
+ );
83
+ }
84
+ if (this.config.messaging?.systemPostamble) {
85
+ parts.push(this.config.messaging.systemPostamble);
86
+ }
87
+ return parts.join("\n");
88
+ }
89
+ isReady() {
90
+ return this.initialized;
13
91
  }
14
92
  }
15
93
  export {
16
- createAgent
94
+ BaseAgent
17
95
  };
18
96
  //# sourceMappingURL=index8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index8.js","sources":["../../src/agent-factory.ts"],"sourcesContent":["import { BaseAgent, type HederaAgentConfiguration } from './base-agent';\nimport { LangChainAgent } from './langchain/langchain-agent';\n\nexport function createAgent(\n config: HederaAgentConfiguration & {\n framework?: 'langchain' | 'vercel' | 'baml';\n }\n): BaseAgent {\n const framework = config.framework || 'langchain';\n\n switch (framework) {\n case 'langchain':\n return new LangChainAgent(config);\n case 'vercel':\n throw new Error('Vercel AI SDK support coming soon');\n case 'baml':\n throw new Error('BAML support coming soon');\n default:\n throw new Error(`Unknown framework: ${framework}`);\n }\n}"],"names":[],"mappings":";AAGO,SAAS,YACd,QAGW;AACX,QAAM,YAAY,OAAO,aAAa;AAEtC,UAAQ,WAAA;AAAA,IACN,KAAK;AACH,aAAO,IAAI,eAAe,MAAM;AAAA,IAClC,KAAK;AACH,YAAM,IAAI,MAAM,mCAAmC;AAAA,IACrD,KAAK;AACH,YAAM,IAAI,MAAM,0BAA0B;AAAA,IAC5C;AACE,YAAM,IAAI,MAAM,sBAAsB,SAAS,EAAE;AAAA,EAAA;AAEvD;"}
1
+ {"version":3,"file":"index8.js","sources":["../../src/base-agent.ts"],"sourcesContent":["import type { BaseMessage } from '@langchain/core/messages';\nimport type { StructuredTool } from '@langchain/core/tools';\nimport type { TransactionReceipt } from '@hashgraph/sdk';\nimport {\n HederaAgentKit,\n ServerSigner,\n TokenUsageCallbackHandler,\n TokenUsage,\n BasePlugin,\n} from 'hedera-agent-kit';\nimport type { CostCalculation } from 'hedera-agent-kit';\nimport type { AIProvider, VercelAIProvider, BAMLProvider } from './providers';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport type { MCPServerConfig, MCPConnectionStatus } from './mcp/types';\nimport type { FormSubmission } from './forms/types';\n\nexport interface ToolFilterConfig {\n namespaceWhitelist?: string[];\n toolBlacklist?: string[];\n toolPredicate?: (tool: StructuredTool) => boolean;\n}\n\nexport type ExecutionMode = 'direct' | 'bytes';\nexport type OperationalMode = 'autonomous' | 'returnBytes';\n\nexport interface HederaAgentConfiguration {\n signer: ServerSigner;\n execution?: {\n mode?: ExecutionMode;\n operationalMode?: OperationalMode;\n userAccountId?: string;\n scheduleUserTransactions?: boolean;\n scheduleUserTransactionsInBytesMode?: boolean;\n };\n ai?: {\n provider?: AIProvider;\n llm?: unknown;\n apiKey?: string;\n modelName?: string;\n temperature?: number;\n };\n filtering?: ToolFilterConfig;\n messaging?: {\n systemPreamble?: string;\n systemPostamble?: string;\n conciseMode?: boolean;\n };\n extensions?: {\n plugins?: BasePlugin[];\n mirrorConfig?: Record<string, unknown>;\n modelCapability?: string;\n };\n mcp?: {\n servers?: MCPServerConfig[];\n autoConnect?: boolean;\n };\n debug?: {\n verbose?: boolean;\n silent?: boolean;\n };\n}\n\nexport interface ConversationContext {\n messages: BaseMessage[];\n metadata?: Record<string, unknown>;\n}\n\nexport interface ChatResponse {\n output: string;\n message?: string;\n transactionBytes?: string;\n receipt?: TransactionReceipt | object;\n scheduleId?: string;\n transactionId?: string;\n notes?: string[];\n error?: string;\n intermediateSteps?: unknown;\n rawToolOutput?: unknown;\n tokenUsage?: TokenUsage;\n cost?: CostCalculation;\n metadata?: Record<string, unknown>;\n tool_calls?: Array<{\n id: string;\n name: string;\n args: Record<string, unknown>;\n output?: string;\n }>;\n formMessage?: unknown;\n requiresForm?: boolean;\n [key: string]: unknown;\n}\n\nexport interface UsageStats extends TokenUsage {\n cost: CostCalculation;\n}\n\nexport abstract class BaseAgent {\n protected logger: Logger;\n protected agentKit: HederaAgentKit | undefined;\n protected tools: StructuredTool[] = [];\n protected initialized = false;\n protected tokenTracker: TokenUsageCallbackHandler | undefined;\n\n constructor(protected config: HederaAgentConfiguration) {\n this.logger = new Logger({\n module: 'BaseAgent',\n silent: config.debug?.silent || false,\n });\n }\n\n abstract boot(): Promise<void>;\n abstract chat(\n message: string,\n context?: ConversationContext\n ): Promise<ChatResponse>;\n abstract processFormSubmission(\n submission: FormSubmission\n ): Promise<ChatResponse>;\n abstract shutdown(): Promise<void>;\n abstract switchMode(mode: OperationalMode): void;\n abstract getUsageStats(): UsageStats;\n abstract getUsageLog(): UsageStats[];\n abstract clearUsageStats(): void;\n abstract connectMCPServers(): Promise<void>;\n abstract getMCPConnectionStatus(): Map<string, MCPConnectionStatus>;\n\n public getCore(): HederaAgentKit | undefined {\n return this.agentKit;\n }\n\n protected filterTools(tools: StructuredTool[]): StructuredTool[] {\n let filtered = [...tools];\n const filter = this.config.filtering;\n\n if (!filter) return filtered;\n\n if (filter.namespaceWhitelist?.length) {\n filtered = filtered.filter((tool) => {\n const namespace = (tool as StructuredTool & { namespace?: string })\n .namespace;\n return !namespace || filter.namespaceWhitelist!.includes(namespace);\n });\n }\n\n if (filter.toolBlacklist?.length) {\n filtered = filtered.filter(\n (tool) => !filter.toolBlacklist!.includes(tool.name)\n );\n }\n\n if (filter.toolPredicate) {\n filtered = filtered.filter(filter.toolPredicate);\n }\n\n this.logger.debug(`Filtered tools: ${tools.length} → ${filtered.length}`);\n return filtered;\n }\n\n protected buildSystemPrompt(): string {\n const parts: string[] = [];\n const operatorId = this.config.signer.getAccountId().toString();\n const userAccId = this.config.execution?.userAccountId;\n\n if (this.config.messaging?.systemPreamble) {\n parts.push(this.config.messaging.systemPreamble);\n }\n\n parts.push(\n `You are a helpful Hedera assistant. Your primary operator account is ${operatorId}. ` +\n `You have tools to interact with the Hedera Hashgraph. ` +\n `When using any tool, provide all necessary parameters as defined by that tool's schema and description.`\n );\n\n parts.push(\n `\\nMETADATA QUALITY PRINCIPLES: When collecting user input for metadata creation across any tool:` +\n `\\n• Prioritize meaningful, valuable content over technical file information` +\n `\\n• Focus on attributes that add value for end users and collectors` +\n `\\n• Avoid auto-generating meaningless technical attributes as user-facing metadata` +\n `\\n• When fields are missing or inadequate, use forms to collect quality metadata` +\n `\\n• Encourage descriptive names, collectible traits, and storytelling elements`\n );\n\n if (userAccId) {\n parts.push(\n `The user you are assisting has a personal Hedera account ID: ${userAccId}. ` +\n `IMPORTANT: When the user says things like \"I want to send HBAR\" or \"transfer my tokens\", you MUST use ${userAccId} as the sender/from account. ` +\n `For example, if user says \"I want to send 2 HBAR to 0.0.800\", you must set up a transfer where ${userAccId} sends the HBAR, not your operator account.`\n );\n }\n\n const operationalMode =\n this.config.execution?.operationalMode || 'returnBytes';\n if (operationalMode === 'autonomous') {\n parts.push(\n `\\nOPERATIONAL MODE: 'autonomous'. Your goal is to execute transactions directly using your tools. ` +\n `Your account ${operatorId} will be the payer for these transactions. ` +\n `Even if the user's account (${\n userAccId || 'a specified account'\n }) is the actor in the transaction body (e.g., sender of HBAR), ` +\n `you (the agent with operator ${operatorId}) are still executing and paying. For HBAR transfers, ensure the amounts in the 'transfers' array sum to zero (as per tool schema), balancing with your operator account if necessary.`\n );\n } else {\n if (\n this.config.execution?.scheduleUserTransactionsInBytesMode &&\n userAccId\n ) {\n parts.push(\n `\\nOPERATIONAL MODE: 'returnBytes' with scheduled transactions for user actions. ` +\n `When a user asks for a transaction to be prepared (e.g., creating a token, topic, transferring assets for them to sign, etc), ` +\n `you MUST default to creating a Scheduled Transaction using the appropriate tool with the metaOption 'schedule: true'. ` +\n `The user (with account ID ${userAccId}) will be the one to ultimately pay for and (if needed) sign the inner transaction. ` +\n `Your operator account (${operatorId}) will pay for creating the schedule entity itself. ` +\n `You MUST return the ScheduleId and details of the scheduled operation in a structured JSON format with these fields: success, op, schedule_id, description, payer_account_id_scheduled_tx, and scheduled_transaction_details.`\n );\n } else {\n parts.push(\n `\\nOPERATIONAL MODE: 'returnBytes'. Your goal is to provide transaction bytes when possible. ` +\n `When a user asks for a transaction to be prepared (e.g., for them to sign, or for scheduling without the default scheduling flow), ` +\n `you MUST call the appropriate tool. ` +\n `IMPORTANT: Only use metaOption 'returnBytes: true' for tools that explicitly support it (like HBAR transfers, token operations). ` +\n `Many tools (inscriptions, HCS-2, HCS-20, etc.) do NOT support returnBytes and will execute directly - this is expected behavior. ` +\n `For tools without returnBytes support, simply call them with their standard parameters. ` +\n `If you need raw bytes for the user to sign for their own account ${\n userAccId || 'if specified'\n }, ensure the tool constructs the transaction body accordingly when returnBytes IS supported.`\n );\n }\n }\n\n if (this.config.messaging?.conciseMode !== false) {\n parts.push(\n '\\nAlways be concise. If the tool provides a JSON string as its primary output (especially in returnBytes mode), make your accompanying text brief. If the tool does not provide JSON output or an error occurs, your narrative becomes primary; if notes were generated by the tool in such cases, append them to your textual response.'\n );\n }\n\n if (this.config.messaging?.systemPostamble) {\n parts.push(this.config.messaging.systemPostamble);\n }\n\n return parts.join('\\n');\n }\n\n isReady(): boolean {\n return this.initialized;\n }\n}\n\nexport type { AIProvider, VercelAIProvider, BAMLProvider };\n"],"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AA,IAAA;AAQF,QAAI,WAAW;AACb,YAAM;AAAA,QACJ,gEAAgE,SAAS,2GACkC,SAAS,+HAChB,SAAS;AAAA,MAAA;AAAA,IAEjH;AAEA,UAAM,kBACJ,KAAK,OAAO,WAAW,mBAAmB;AAC5C,QAAI,oBAAoB,cAAc;AACpC,YAAM;AAAA,QACJ;AAAA,+GACkB,UAAU,0EAExB,aAAa,qBACf,+FACgC,UAAU;AAAA,MAAA;AAAA,IAEhD,OAAO;AACL,UACE,KAAK,OAAO,WAAW,uCACvB,WACA;AACA,cAAM;AAAA,UACJ;AAAA,8VAG+B,SAAS,8GACZ,UAAU;AAAA,QAAA;AAAA,MAG1C,OAAO;AACL,cAAM;AAAA,UACJ;AAAA,8pBAOI,aAAa,cACf;AAAA,QAAA;AAAA,MAEN;AAAA,IACF;AAEA,QAAI,KAAK,OAAO,WAAW,gBAAgB,OAAO;AAChD,YAAM;AAAA,QACJ;AAAA,MAAA;AAAA,IAEJ;AAEA,QAAI,KAAK,OAAO,WAAW,iBAAiB;AAC1C,YAAM,KAAK,KAAK,OAAO,UAAU,eAAe;AAAA,IAClD;AAEA,WAAO,MAAM,KAAK,IAAI;AAAA,EACxB;AAAA,EAEA,UAAmB;AACjB,WAAO,KAAK;AAAA,EACd;AACF;"}
@@ -1,22 +1,18 @@
1
- class LangChainProvider {
2
- constructor(model) {
3
- this.model = model;
4
- }
5
- async generate(prompt, options) {
6
- const result = await this.model.invoke(prompt, options);
7
- return typeof result === "string" ? result : result.toString();
8
- }
9
- async *stream(prompt, options) {
10
- const stream = await this.model.stream(prompt, options);
11
- for await (const chunk of stream) {
12
- yield typeof chunk === "string" ? chunk : chunk.toString();
13
- }
14
- }
15
- getModel() {
16
- return this.model;
1
+ import { LangChainAgent } from "./index34.js";
2
+ function createAgent(config) {
3
+ const framework = config.framework || "langchain";
4
+ switch (framework) {
5
+ case "langchain":
6
+ return new LangChainAgent(config);
7
+ case "vercel":
8
+ throw new Error("Vercel AI SDK support coming soon");
9
+ case "baml":
10
+ throw new Error("BAML support coming soon");
11
+ default:
12
+ throw new Error(`Unknown framework: ${framework}`);
17
13
  }
18
14
  }
19
15
  export {
20
- LangChainProvider
16
+ createAgent
21
17
  };
22
18
  //# sourceMappingURL=index9.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index9.js","sources":["../../src/providers.ts"],"sourcesContent":["import type { \n BaseLanguageModelCallOptions\n} from '@langchain/core/language_models/base';\nimport type { BaseChatModel } from '@langchain/core/language_models/chat_models';\n\n/**\n * Framework-agnostic AI provider interface for multi-framework support\n */\nexport interface AIProvider {\n /**\n * Generate a response from the AI model\n */\n generate(\n prompt: string,\n options?: BaseLanguageModelCallOptions\n ): Promise<string>;\n\n /**\n * Stream a response from the AI model\n */\n stream?(\n prompt: string,\n options?: BaseLanguageModelCallOptions\n ): AsyncGenerator<string>;\n\n /**\n * Get the underlying model if available\n */\n getModel?(): BaseChatModel | unknown;\n}\n\n/**\n * LangChain AI provider implementation\n */\nexport class LangChainProvider implements AIProvider {\n constructor(private model: BaseChatModel) {}\n\n async generate(\n prompt: string,\n options?: BaseLanguageModelCallOptions\n ): Promise<string> {\n const result = await this.model.invoke(prompt, options);\n return typeof result === 'string' ? result : result.toString();\n }\n\n async *stream(\n prompt: string,\n options?: BaseLanguageModelCallOptions\n ): AsyncGenerator<string> {\n const stream = await this.model.stream(prompt, options);\n for await (const chunk of stream) {\n yield typeof chunk === 'string' ? chunk : chunk.toString();\n }\n }\n\n getModel(): BaseChatModel {\n return this.model;\n }\n}\n\n/**\n * Vercel AI SDK provider interface (forward-thinking)\n */\nexport interface VercelAIProvider extends AIProvider {\n /**\n * Use Vercel AI SDK's streamText function\n */\n streamText?(prompt: string, options?: unknown): Promise<unknown>;\n}\n\n/**\n * BAML provider interface (forward-thinking)\n */\nexport interface BAMLProvider extends AIProvider {\n /**\n * Execute a BAML function\n */\n executeFunction?(\n name: string,\n args: Record<string, unknown>\n ): Promise<unknown>;\n}"],"names":[],"mappings":"AAkCO,MAAM,kBAAwC;AAAA,EACnD,YAAoB,OAAsB;AAAtB,SAAA,QAAA;AAAA,EAAuB;AAAA,EAE3C,MAAM,SACJ,QACA,SACiB;AACjB,UAAM,SAAS,MAAM,KAAK,MAAM,OAAO,QAAQ,OAAO;AACtD,WAAO,OAAO,WAAW,WAAW,SAAS,OAAO,SAAA;AAAA,EACtD;AAAA,EAEA,OAAO,OACL,QACA,SACwB;AACxB,UAAM,SAAS,MAAM,KAAK,MAAM,OAAO,QAAQ,OAAO;AACtD,qBAAiB,SAAS,QAAQ;AAChC,YAAM,OAAO,UAAU,WAAW,QAAQ,MAAM,SAAA;AAAA,IAClD;AAAA,EACF;AAAA,EAEA,WAA0B;AACxB,WAAO,KAAK;AAAA,EACd;AACF;"}
1
+ {"version":3,"file":"index9.js","sources":["../../src/agent-factory.ts"],"sourcesContent":["import { BaseAgent, type HederaAgentConfiguration } from './base-agent';\nimport { LangChainAgent } from './langchain/langchain-agent';\n\nexport function createAgent(\n config: HederaAgentConfiguration & {\n framework?: 'langchain' | 'vercel' | 'baml';\n }\n): BaseAgent {\n const framework = config.framework || 'langchain';\n\n switch (framework) {\n case 'langchain':\n return new LangChainAgent(config);\n case 'vercel':\n throw new Error('Vercel AI SDK support coming soon');\n case 'baml':\n throw new Error('BAML support coming soon');\n default:\n throw new Error(`Unknown framework: ${framework}`);\n }\n}"],"names":[],"mappings":";AAGO,SAAS,YACd,QAGW;AACX,QAAM,YAAY,OAAO,aAAa;AAEtC,UAAQ,WAAA;AAAA,IACN,KAAK;AACH,aAAO,IAAI,eAAe,MAAM;AAAA,IAClC,KAAK;AACH,YAAM,IAAI,MAAM,mCAAmC;AAAA,IACrD,KAAK;AACH,YAAM,IAAI,MAAM,0BAA0B;AAAA,IAC5C;AACE,YAAM,IAAI,MAAM,sBAAsB,SAAS,EAAE;AAAA,EAAA;AAEvD;"}
@@ -2,6 +2,7 @@ export { HCS10Plugin } from './plugins/hcs-10/HCS10Plugin';
2
2
  export { HCS2Plugin } from './plugins/hcs-2/HCS2Plugin';
3
3
  export { InscribePlugin } from './plugins/inscribe/InscribePlugin';
4
4
  export { HbarPlugin } from './plugins/hbar/HbarPlugin';
5
+ export { SwarmPlugin, type SwarmConfig } from './plugins/community/swarm';
5
6
  export { HCS10Plugin as OpenConvAIPlugin } from './plugins/hcs-10/HCS10Plugin';
6
7
  export { ConversationalAgent } from './conversational-agent';
7
8
  export type { ConversationalAgentOptions } from './conversational-agent';
@@ -0,0 +1,17 @@
1
+ import { BasePlugin, GenericPluginContext, HederaTool } from 'hedera-agent-kit';
2
+ import { SwarmConfig } from './config';
3
+
4
+ export declare class SwarmPlugin extends BasePlugin<GenericPluginContext> {
5
+ id: string;
6
+ name: string;
7
+ description: string;
8
+ version: string;
9
+ author: string;
10
+ namespace: string;
11
+ private config;
12
+ private tools;
13
+ constructor(config?: SwarmConfig);
14
+ initialize(context: GenericPluginContext): Promise<void>;
15
+ getTools(): HederaTool[];
16
+ cleanup(): Promise<void>;
17
+ }
@@ -0,0 +1,14 @@
1
+ import { Bee } from '@ethersphere/bee-js';
2
+ import { GenericPluginContext } from 'hedera-agent-kit';
3
+
4
+ import * as utils from '../../utils';
5
+ declare let beeMock: jest.Mocked<Bee>;
6
+ declare const swarmConfigMock: {
7
+ beeApiUrl: string;
8
+ beeFeedPK: string;
9
+ autoAssignStamp: boolean;
10
+ deferredUploadSizeThresholdMB: number;
11
+ };
12
+ declare const contextMock: GenericPluginContext;
13
+ declare const mockedUtils: jest.Mocked<typeof utils>;
14
+ export { beeMock, contextMock, swarmConfigMock, mockedUtils, };
@@ -0,0 +1,6 @@
1
+ export interface SwarmConfig {
2
+ beeApiUrl: string;
3
+ beeFeedPK: string;
4
+ autoAssignStamp?: boolean;
5
+ deferredUploadSizeThresholdMB?: number;
6
+ }
@@ -0,0 +1,8 @@
1
+ export declare const NOT_FOUND_STATUS = 404;
2
+ export declare const BAD_REQUEST_STATUS = 400;
3
+ export declare const GATEWAY_STAMP_ERROR_MESSAGE = "Endpoint not found. If using Swarm Gateway, postage stamp management endpoints are not available.";
4
+ export declare const GATEWAY_TAG_ERROR_MESSAGE = "If using Swarm Gateway, tag endpoints are not available.";
5
+ export declare const POSTAGE_CREATE_TIMEOUT_MESSAGE = "Purchase of postage batch is in progress, it may take a few minutes. Please list you batches after a few minutes to find it.";
6
+ export declare const CALL_TIMEOUT = 30000;
7
+ export declare const DEFAULT_DEFERRED_UPLOAD_SIZE_THRESHOLD_MB = 5;
8
+ export declare const DEFAULT_GATEWAY_BATCH_ID = "0000000000000000000000000000000000000000000000000000000000000000";
@@ -0,0 +1,2 @@
1
+ export * from './config';
2
+ export * from './SwarmPlugin';
@@ -0,0 +1,23 @@
1
+ import { PostageBatch } from '@ethersphere/bee-js';
2
+
3
+ export type PostageBatchCurated = Omit<PostageBatch, "batchID"> & {
4
+ batchID: string;
5
+ };
6
+ export interface PostageBatchSummary {
7
+ stampID: string;
8
+ usage: string;
9
+ capacity: string;
10
+ ttl: string;
11
+ immutable: boolean;
12
+ }
13
+ export interface ResponseContent<U, V> {
14
+ raw: U;
15
+ summary: V;
16
+ }
17
+ export interface ResponseWithStructuredContent<T> {
18
+ content: Array<{
19
+ type: "text";
20
+ text: string;
21
+ }>;
22
+ structuredContent: T;
23
+ }
@@ -0,0 +1,47 @@
1
+ import { BaseHederaQueryTool, HederaAgentKit, GenericPluginContext } from 'hedera-agent-kit';
2
+ import { Bee } from '@ethersphere/bee-js';
3
+ import { z } from 'zod';
4
+ import { ToolResponse } from '../utils';
5
+ import { SwarmConfig } from '../config';
6
+
7
+ declare const CreatePostageStampSchema: z.ZodObject<{
8
+ size: z.ZodNumber;
9
+ duration: z.ZodString;
10
+ label: z.ZodOptional<z.ZodString>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ duration: string;
13
+ size: number;
14
+ label?: string | undefined;
15
+ }, {
16
+ duration: string;
17
+ size: number;
18
+ label?: string | undefined;
19
+ }>;
20
+ export declare class CreatePostageStampTool extends BaseHederaQueryTool<typeof CreatePostageStampSchema> {
21
+ name: string;
22
+ description: string;
23
+ namespace: string;
24
+ specificInputSchema: z.ZodObject<{
25
+ size: z.ZodNumber;
26
+ duration: z.ZodString;
27
+ label: z.ZodOptional<z.ZodString>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ duration: string;
30
+ size: number;
31
+ label?: string | undefined;
32
+ }, {
33
+ duration: string;
34
+ size: number;
35
+ label?: string | undefined;
36
+ }>;
37
+ bee: Bee;
38
+ config: SwarmConfig;
39
+ constructor(params: {
40
+ hederaKit: HederaAgentKit;
41
+ config: SwarmConfig;
42
+ logger?: GenericPluginContext['logger'];
43
+ bee: Bee;
44
+ });
45
+ protected executeQuery(input: z.infer<typeof CreatePostageStampSchema>): Promise<ToolResponse | string>;
46
+ }
47
+ export {};
@@ -0,0 +1,35 @@
1
+ import { Bee } from '@ethersphere/bee-js';
2
+ import { z } from 'zod';
3
+ import { ToolResponse } from '../utils';
4
+ import { BaseHederaQueryTool, GenericPluginContext, HederaAgentKit } from 'hedera-agent-kit';
5
+ import { SwarmConfig } from '../config';
6
+
7
+ declare const DownloadDataSchema: z.ZodObject<{
8
+ reference: z.ZodString;
9
+ }, "strip", z.ZodTypeAny, {
10
+ reference: string;
11
+ }, {
12
+ reference: string;
13
+ }>;
14
+ export declare class DownloadDataTool extends BaseHederaQueryTool<typeof DownloadDataSchema> {
15
+ name: string;
16
+ description: string;
17
+ namespace: string;
18
+ specificInputSchema: z.ZodObject<{
19
+ reference: z.ZodString;
20
+ }, "strip", z.ZodTypeAny, {
21
+ reference: string;
22
+ }, {
23
+ reference: string;
24
+ }>;
25
+ bee: Bee;
26
+ config: SwarmConfig;
27
+ constructor(params: {
28
+ hederaKit: HederaAgentKit;
29
+ config: SwarmConfig;
30
+ logger?: GenericPluginContext['logger'];
31
+ bee: Bee;
32
+ });
33
+ protected executeQuery(input: z.infer<typeof DownloadDataSchema>): Promise<ToolResponse | string>;
34
+ }
35
+ export {};
@@ -0,0 +1,41 @@
1
+ import { Bee } from '@ethersphere/bee-js';
2
+ import { z } from 'zod';
3
+ import { BaseHederaQueryTool, GenericPluginContext, HederaAgentKit } from 'hedera-agent-kit';
4
+ import { ToolResponse } from '../utils';
5
+ import { SwarmConfig } from '../config';
6
+
7
+ declare const DownloadFilesSchema: z.ZodObject<{
8
+ reference: z.ZodString;
9
+ filePath: z.ZodOptional<z.ZodString>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ reference: string;
12
+ filePath?: string | undefined;
13
+ }, {
14
+ reference: string;
15
+ filePath?: string | undefined;
16
+ }>;
17
+ export declare class DownloadFilesTool extends BaseHederaQueryTool<typeof DownloadFilesSchema> {
18
+ name: string;
19
+ description: string;
20
+ namespace: string;
21
+ specificInputSchema: z.ZodObject<{
22
+ reference: z.ZodString;
23
+ filePath: z.ZodOptional<z.ZodString>;
24
+ }, "strip", z.ZodTypeAny, {
25
+ reference: string;
26
+ filePath?: string | undefined;
27
+ }, {
28
+ reference: string;
29
+ filePath?: string | undefined;
30
+ }>;
31
+ bee: Bee;
32
+ config: SwarmConfig;
33
+ constructor(params: {
34
+ hederaKit: HederaAgentKit;
35
+ config: SwarmConfig;
36
+ logger?: GenericPluginContext['logger'];
37
+ bee: Bee;
38
+ });
39
+ protected executeQuery(input: z.infer<typeof DownloadFilesSchema>): Promise<ToolResponse | string>;
40
+ }
41
+ export {};