@hashgraphonline/conversational-agent 0.2.215 → 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 (310) 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/index48.js +67 -85
  117. package/dist/esm/index48.js.map +1 -1
  118. package/dist/esm/index49.js +75 -0
  119. package/dist/esm/index49.js.map +1 -0
  120. package/dist/esm/index5.js +2 -2
  121. package/dist/esm/index50.js +57 -0
  122. package/dist/esm/index50.js.map +1 -0
  123. package/dist/esm/index51.js +103 -0
  124. package/dist/esm/index51.js.map +1 -0
  125. package/dist/esm/index52.js +79 -0
  126. package/dist/esm/index52.js.map +1 -0
  127. package/dist/esm/index53.js +75 -0
  128. package/dist/esm/index53.js.map +1 -0
  129. package/dist/esm/index54.js +124 -0
  130. package/dist/esm/index54.js.map +1 -0
  131. package/dist/esm/index55.js +58 -0
  132. package/dist/esm/index55.js.map +1 -0
  133. package/dist/esm/index56.js +83 -0
  134. package/dist/esm/index56.js.map +1 -0
  135. package/dist/esm/index57.js +100 -0
  136. package/dist/esm/index57.js.map +1 -0
  137. package/dist/esm/index58.js +118 -0
  138. package/dist/esm/index58.js.map +1 -0
  139. package/dist/esm/index59.js +108 -0
  140. package/dist/esm/index59.js.map +1 -0
  141. package/dist/esm/index6.js +132 -833
  142. package/dist/esm/index6.js.map +1 -1
  143. package/dist/esm/index60.js +30 -0
  144. package/dist/esm/index60.js.map +1 -0
  145. package/dist/esm/index61.js +98 -0
  146. package/dist/esm/index61.js.map +1 -0
  147. package/dist/esm/index62.js +131 -0
  148. package/dist/esm/index62.js.map +1 -0
  149. package/dist/esm/index63.js +19 -0
  150. package/dist/esm/index63.js.map +1 -0
  151. package/dist/esm/index7.js +826 -75
  152. package/dist/esm/index7.js.map +1 -1
  153. package/dist/esm/index8.js +91 -13
  154. package/dist/esm/index8.js.map +1 -1
  155. package/dist/esm/index9.js +13 -17
  156. package/dist/esm/index9.js.map +1 -1
  157. package/dist/types/index.d.ts +1 -0
  158. package/dist/types/plugins/community/swarm/SwarmPlugin.d.ts +17 -0
  159. package/dist/types/plugins/community/swarm/__tests__/SwarmPlugin.mocks.d.ts +1 -0
  160. package/dist/types/plugins/community/swarm/__tests__/SwarmPlugin.test.d.ts +1 -0
  161. package/dist/types/plugins/community/swarm/__tests__/tools/CreatePostageStampTool.test.d.ts +1 -0
  162. package/dist/types/plugins/community/swarm/__tests__/tools/DownloadDataTool.test.d.ts +1 -0
  163. package/dist/types/plugins/community/swarm/__tests__/tools/DownloadFilesTool.test.d.ts +1 -0
  164. package/dist/types/plugins/community/swarm/__tests__/tools/ExtendPostageStampTool.test.d.ts +1 -0
  165. package/dist/types/plugins/community/swarm/__tests__/tools/GetPostageStampTool.test.d.ts +1 -0
  166. package/dist/types/plugins/community/swarm/__tests__/tools/ListPostageStampsTool.test.d.ts +1 -0
  167. package/dist/types/plugins/community/swarm/__tests__/tools/QueryUploadProgressTool.test.d.ts +1 -0
  168. package/dist/types/plugins/community/swarm/__tests__/tools/ReadFeedTool.test.d.ts +1 -0
  169. package/dist/types/plugins/community/swarm/__tests__/tools/SwarmTool.mocks.d.ts +14 -0
  170. package/dist/types/plugins/community/swarm/__tests__/tools/UpdateFeedTool.test.d.ts +1 -0
  171. package/dist/types/plugins/community/swarm/__tests__/tools/UploadDataTool.test.d.ts +1 -0
  172. package/dist/types/plugins/community/swarm/__tests__/tools/UploadFileTool.test.d.ts +1 -0
  173. package/dist/types/plugins/community/swarm/__tests__/tools/UploadFolderTool.test.d.ts +1 -0
  174. package/dist/types/plugins/community/swarm/config.d.ts +6 -0
  175. package/dist/types/plugins/community/swarm/constants.d.ts +8 -0
  176. package/dist/types/plugins/community/swarm/index.d.ts +2 -0
  177. package/dist/types/plugins/community/swarm/model.d.ts +23 -0
  178. package/dist/types/plugins/community/swarm/tools/CreatePostageStampTool.d.ts +47 -0
  179. package/dist/types/plugins/community/swarm/tools/DownloadDataTool.d.ts +35 -0
  180. package/dist/types/plugins/community/swarm/tools/DownloadFilesTool.d.ts +41 -0
  181. package/dist/types/plugins/community/swarm/tools/ExtendPostageStampTool.d.ts +47 -0
  182. package/dist/types/plugins/community/swarm/tools/GetPostageStampTool.d.ts +35 -0
  183. package/dist/types/plugins/community/swarm/tools/ListPostageStampsTool.d.ts +53 -0
  184. package/dist/types/plugins/community/swarm/tools/QueryUploadProgressTool.d.ts +35 -0
  185. package/dist/types/plugins/community/swarm/tools/ReadFeedTool.d.ts +41 -0
  186. package/dist/types/plugins/community/swarm/tools/UpdateFeedTool.d.ts +47 -0
  187. package/dist/types/plugins/community/swarm/tools/UploadDataTool.d.ts +47 -0
  188. package/dist/types/plugins/community/swarm/tools/UploadFileTool.d.ts +53 -0
  189. package/dist/types/plugins/community/swarm/tools/UploadFolderTool.d.ts +47 -0
  190. package/dist/types/plugins/community/swarm/utils.d.ts +22 -0
  191. package/dist/types/plugins/index.d.ts +1 -0
  192. package/package.json +37 -27
  193. package/src/index.ts +1 -0
  194. package/src/plugins/community/swarm/README.md +279 -0
  195. package/src/plugins/community/swarm/SwarmPlugin.ts +178 -0
  196. package/src/plugins/community/swarm/__tests__/SwarmPlugin.mocks.ts +105 -0
  197. package/src/plugins/community/swarm/__tests__/SwarmPlugin.test.ts +93 -0
  198. package/src/plugins/community/swarm/__tests__/tools/CreatePostageStampTool.test.ts +152 -0
  199. package/src/plugins/community/swarm/__tests__/tools/DownloadDataTool.test.ts +93 -0
  200. package/src/plugins/community/swarm/__tests__/tools/DownloadFilesTool.test.ts +163 -0
  201. package/src/plugins/community/swarm/__tests__/tools/ExtendPostageStampTool.test.ts +132 -0
  202. package/src/plugins/community/swarm/__tests__/tools/GetPostageStampTool.test.ts +83 -0
  203. package/src/plugins/community/swarm/__tests__/tools/ListPostageStampsTool.test.ts +219 -0
  204. package/src/plugins/community/swarm/__tests__/tools/QueryUploadProgressTool.test.ts +169 -0
  205. package/src/plugins/community/swarm/__tests__/tools/ReadFeedTool.test.ts +133 -0
  206. package/src/plugins/community/swarm/__tests__/tools/SwarmTool.mocks.ts +67 -0
  207. package/src/plugins/community/swarm/__tests__/tools/UpdateFeedTool.test.ts +148 -0
  208. package/src/plugins/community/swarm/__tests__/tools/UploadDataTool.test.ts +125 -0
  209. package/src/plugins/community/swarm/__tests__/tools/UploadFileTool.test.ts +194 -0
  210. package/src/plugins/community/swarm/__tests__/tools/UploadFolderTool.test.ts +118 -0
  211. package/src/plugins/community/swarm/config.ts +6 -0
  212. package/src/plugins/community/swarm/constants.ts +12 -0
  213. package/src/plugins/community/swarm/index.ts +2 -0
  214. package/src/plugins/community/swarm/model.ts +23 -0
  215. package/src/plugins/community/swarm/tools/CreatePostageStampTool.ts +137 -0
  216. package/src/plugins/community/swarm/tools/DownloadDataTool.ts +79 -0
  217. package/src/plugins/community/swarm/tools/DownloadFilesTool.ts +155 -0
  218. package/src/plugins/community/swarm/tools/ExtendPostageStampTool.ts +112 -0
  219. package/src/plugins/community/swarm/tools/GetPostageStampTool.ts +92 -0
  220. package/src/plugins/community/swarm/tools/ListPostageStampsTool.ts +124 -0
  221. package/src/plugins/community/swarm/tools/QueryUploadProgressTool.ts +109 -0
  222. package/src/plugins/community/swarm/tools/ReadFeedTool.ts +110 -0
  223. package/src/plugins/community/swarm/tools/UpdateFeedTool.ts +149 -0
  224. package/src/plugins/community/swarm/tools/UploadDataTool.ts +109 -0
  225. package/src/plugins/community/swarm/tools/UploadFileTool.ts +163 -0
  226. package/src/plugins/community/swarm/tools/UploadFolderTool.ts +150 -0
  227. package/src/plugins/community/swarm/utils.ts +172 -0
  228. package/src/plugins/index.ts +1 -0
  229. package/cli/dist/CLIApp.d.ts +0 -11
  230. package/cli/dist/CLIApp.d.ts.map +0 -1
  231. package/cli/dist/CLIApp.js +0 -128
  232. package/cli/dist/CLIApp.js.map +0 -1
  233. package/cli/dist/LocalConversationalAgent.d.ts +0 -37
  234. package/cli/dist/LocalConversationalAgent.js +0 -58
  235. package/cli/dist/app.d.ts +0 -18
  236. package/cli/dist/app.d.ts.map +0 -1
  237. package/cli/dist/app.js +0 -14
  238. package/cli/dist/app.js.map +0 -1
  239. package/cli/dist/cli.d.ts +0 -3
  240. package/cli/dist/cli.d.ts.map +0 -1
  241. package/cli/dist/cli.js +0 -87
  242. package/cli/dist/cli.js.map +0 -1
  243. package/cli/dist/components/AppContainer.d.ts +0 -16
  244. package/cli/dist/components/AppContainer.js +0 -24
  245. package/cli/dist/components/AppScreens.d.ts +0 -2
  246. package/cli/dist/components/AppScreens.js +0 -259
  247. package/cli/dist/components/ChatScreen.d.ts +0 -21
  248. package/cli/dist/components/ChatScreen.d.ts.map +0 -1
  249. package/cli/dist/components/ChatScreen.js +0 -40
  250. package/cli/dist/components/ChatScreen.js.map +0 -1
  251. package/cli/dist/components/DebugLoadingScreen.d.ts +0 -5
  252. package/cli/dist/components/DebugLoadingScreen.js +0 -31
  253. package/cli/dist/components/LoadingScreen.d.ts +0 -3
  254. package/cli/dist/components/LoadingScreen.d.ts.map +0 -1
  255. package/cli/dist/components/LoadingScreen.js +0 -17
  256. package/cli/dist/components/LoadingScreen.js.map +0 -1
  257. package/cli/dist/components/LoadingScreenDebug.d.ts +0 -5
  258. package/cli/dist/components/LoadingScreenDebug.js +0 -27
  259. package/cli/dist/components/MCPConfigScreen.d.ts +0 -28
  260. package/cli/dist/components/MCPConfigScreen.d.ts.map +0 -1
  261. package/cli/dist/components/MCPConfigScreen.js +0 -186
  262. package/cli/dist/components/MCPConfigScreen.js.map +0 -1
  263. package/cli/dist/components/ScreenRouter.d.ts +0 -13
  264. package/cli/dist/components/ScreenRouter.d.ts.map +0 -1
  265. package/cli/dist/components/ScreenRouter.js +0 -23
  266. package/cli/dist/components/ScreenRouter.js.map +0 -1
  267. package/cli/dist/components/SetupScreen.d.ts +0 -16
  268. package/cli/dist/components/SetupScreen.d.ts.map +0 -1
  269. package/cli/dist/components/SetupScreen.js +0 -67
  270. package/cli/dist/components/SetupScreen.js.map +0 -1
  271. package/cli/dist/components/SingleLoadingScreen.d.ts +0 -5
  272. package/cli/dist/components/SingleLoadingScreen.js +0 -27
  273. package/cli/dist/components/StatusBadge.d.ts +0 -10
  274. package/cli/dist/components/StatusBadge.d.ts.map +0 -1
  275. package/cli/dist/components/StatusBadge.js +0 -24
  276. package/cli/dist/components/StatusBadge.js.map +0 -1
  277. package/cli/dist/components/TerminalWindow.d.ts +0 -9
  278. package/cli/dist/components/TerminalWindow.d.ts.map +0 -1
  279. package/cli/dist/components/TerminalWindow.js +0 -19
  280. package/cli/dist/components/TerminalWindow.js.map +0 -1
  281. package/cli/dist/components/WelcomeScreen.d.ts +0 -12
  282. package/cli/dist/components/WelcomeScreen.d.ts.map +0 -1
  283. package/cli/dist/components/WelcomeScreen.js +0 -47
  284. package/cli/dist/components/WelcomeScreen.js.map +0 -1
  285. package/cli/dist/context/AppContext.d.ts +0 -68
  286. package/cli/dist/context/AppContext.js +0 -363
  287. package/cli/dist/headless-runner.d.ts +0 -17
  288. package/cli/dist/headless-runner.d.ts.map +0 -1
  289. package/cli/dist/headless-runner.js +0 -128
  290. package/cli/dist/headless-runner.js.map +0 -1
  291. package/cli/dist/hooks/useInitializeAgent.d.ts +0 -19
  292. package/cli/dist/hooks/useInitializeAgent.d.ts.map +0 -1
  293. package/cli/dist/hooks/useInitializeAgent.js +0 -29
  294. package/cli/dist/hooks/useInitializeAgent.js.map +0 -1
  295. package/cli/dist/hooks/useStableState.d.ts +0 -38
  296. package/cli/dist/hooks/useStableState.d.ts.map +0 -1
  297. package/cli/dist/hooks/useStableState.js +0 -69
  298. package/cli/dist/hooks/useStableState.js.map +0 -1
  299. package/cli/dist/managers/AgentManager.d.ts +0 -58
  300. package/cli/dist/managers/AgentManager.d.ts.map +0 -1
  301. package/cli/dist/managers/AgentManager.js +0 -121
  302. package/cli/dist/managers/AgentManager.js.map +0 -1
  303. package/cli/dist/managers/ConfigManager.d.ts +0 -54
  304. package/cli/dist/managers/ConfigManager.d.ts.map +0 -1
  305. package/cli/dist/managers/ConfigManager.js +0 -188
  306. package/cli/dist/managers/ConfigManager.js.map +0 -1
  307. package/cli/dist/types.d.ts +0 -52
  308. package/cli/dist/types.d.ts.map +0 -1
  309. package/cli/dist/types.js +0 -34
  310. package/cli/dist/types.js.map +0 -1
@@ -1,190 +1,340 @@
1
- import { ContentStorage } from "./index21.js";
2
- import { Logger, ContentStoreService, ContentResolverRegistry, shouldUseReference, extractReferenceId } from "@hashgraphonline/standards-sdk";
3
- class ContentStorageAdapter {
4
- constructor(storage) {
5
- this.storage = storage;
6
- }
7
- async storeContent(content, metadata) {
8
- const storeMetadata = {
9
- contentType: "binary",
10
- sizeBytes: content.length,
11
- source: "system",
12
- ...metadata
13
- };
14
- const contentRef = await this.storage.storeContent(content, storeMetadata);
15
- return contentRef.referenceId;
16
- }
17
- async resolveReference(referenceId) {
18
- const result = await this.storage.resolveReference(referenceId);
19
- if (result.success && result.content) {
20
- const response = {
21
- content: result.content
22
- };
23
- if (result.metadata) {
24
- response.metadata = {
25
- ...result.metadata.mimeType !== void 0 && {
26
- mimeType: result.metadata.mimeType
27
- },
28
- ...result.metadata.fileName !== void 0 && {
29
- fileName: result.metadata.fileName
30
- },
31
- originalSize: result.metadata.sizeBytes
32
- };
33
- }
34
- return response;
35
- } else {
36
- throw new Error(result.error || "Reference not found");
37
- }
38
- }
39
- async hasReference(referenceId) {
40
- return await this.storage.hasReference(referenceId);
41
- }
42
- async cleanupReference(referenceId) {
43
- await this.storage.cleanupReference(referenceId);
44
- }
45
- async getStats() {
46
- return await this.storage.getStats();
47
- }
48
- async updateConfig(config) {
49
- const referenceConfig = {
50
- sizeThresholdBytes: config.maxSize || 10240,
51
- enableAutoCleanup: config.enableCompression || true,
52
- ...config
53
- };
54
- return await this.storage.updateConfig(referenceConfig);
55
- }
56
- async performCleanup() {
57
- await this.storage.performCleanup();
58
- }
59
- async dispose() {
60
- return Promise.resolve(this.storage.dispose());
61
- }
62
- }
63
- class ContentResolver {
64
- constructor(adapter) {
65
- this.adapter = adapter;
66
- }
67
- async resolveReference(referenceId) {
68
- return await this.adapter.resolveReference(referenceId);
69
- }
70
- shouldUseReference(content) {
71
- return shouldUseReference(content);
72
- }
73
- extractReferenceId(input) {
74
- return extractReferenceId(input);
75
- }
76
- }
77
- class ContentStoreManager {
78
- constructor(maxMessageStorage = 1e3, referenceConfig, logger) {
79
- this.isRegistered = false;
80
- this.logger = logger || new Logger({ module: "ContentStoreManager" });
81
- this.contentStorage = new ContentStorage(
82
- maxMessageStorage,
83
- referenceConfig
84
- );
85
- this.adapter = new ContentStorageAdapter(this.contentStorage);
86
- this.resolver = new ContentResolver(this.adapter);
1
+ import { ChatOpenAI } from "@langchain/openai";
2
+ import { Logger } from "@hashgraphonline/standards-sdk";
3
+ import { ENTITY_PATTERNS } from "./index44.js";
4
+ import "hedera-agent-kit";
5
+ import "@hashgraphonline/standards-agent-kit";
6
+ import "./index14.js";
7
+ import "./index38.js";
8
+ import "@langchain/core/tools";
9
+ import "zod";
10
+ import "@ethersphere/bee-js";
11
+ import "./index48.js";
12
+ import "./index49.js";
13
+ import "./index50.js";
14
+ import "./index51.js";
15
+ import "./index52.js";
16
+ import "./index53.js";
17
+ import "./index54.js";
18
+ import "./index55.js";
19
+ import "./index56.js";
20
+ import "./index57.js";
21
+ import "./index58.js";
22
+ import "./index59.js";
23
+ import "./index7.js";
24
+ import "langchain/agents";
25
+ import "zod-to-json-schema";
26
+ import "./index13.js";
27
+ import "@langchain/core/prompts";
28
+ import "@modelcontextprotocol/sdk/client/index.js";
29
+ import "@modelcontextprotocol/sdk/client/stdio.js";
30
+ import "./index19.js";
31
+ import "@langchain/core/messages";
32
+ import "./index20.js";
33
+ import "./index21.js";
34
+ import "./index22.js";
35
+ import "crypto";
36
+ import { EntityFormat } from "./index27.js";
37
+ import "./index29.js";
38
+ import "./index35.js";
39
+ class EntityResolver {
40
+ constructor(config) {
41
+ this.llm = new ChatOpenAI({
42
+ apiKey: config.apiKey,
43
+ modelName: config.modelName || "gpt-4o-mini",
44
+ temperature: 0
45
+ });
46
+ this.logger = new Logger({ module: "EntityResolver" });
87
47
  }
88
48
  /**
89
- * Initialize and register content storage for cross-package access
49
+ * Resolve entity references using LLM instead of regex
90
50
  */
91
- async initialize() {
92
- if (this.isRegistered) {
93
- this.logger.warn("ContentStoreManager is already initialized");
94
- return;
51
+ async resolveReferences(message, entities) {
52
+ if (!entities || entities.length === 0) {
53
+ return message;
54
+ }
55
+ const byType = entities.reduce((acc, e) => {
56
+ if (!acc[e.entityType]) acc[e.entityType] = [];
57
+ acc[e.entityType].push(e);
58
+ return acc;
59
+ }, {});
60
+ try {
61
+ const stats = Object.fromEntries(
62
+ Object.entries(byType).map(([type, list]) => [
63
+ type,
64
+ {
65
+ count: list.length,
66
+ mostRecent: list[0]?.entityId
67
+ }
68
+ ])
69
+ );
70
+ this.logger.info("resolveReferences: input summary", {
71
+ messagePreview: message.substring(0, 200),
72
+ entityStats: stats
73
+ });
74
+ } catch {
75
+ }
76
+ let context = "Available entities in memory:\n";
77
+ for (const [type, list] of Object.entries(byType)) {
78
+ const recent = list[0];
79
+ context += `Most recent ${type}: "${recent.entityName}" = ${recent.entityId}
80
+ `;
81
+ if (list.length > 1) {
82
+ context += ` (${list.length - 1} other ${type}s in memory)
83
+ `;
84
+ }
95
85
  }
86
+ const prompt = `Task: Replace entity references with their IDs from memory. STRICT TYPE RULES:
87
+
88
+ - For phrases referring to "${ENTITY_PATTERNS.TOKEN_REFERENCE}" or actions that clearly require a token (create/mint/airdrop/associate/etc.), resolve to the most recent TOKEN entity ID (never a topic or account).
89
+ - For phrases referring to "${ENTITY_PATTERNS.TOPIC_REFERENCE}" or actions that clearly require a topic (inscribe/publish/consensus/etc.), resolve to the most recent TOPIC entity ID (never a token or account).
90
+ - Do not infer or invent entity IDs. Only use those present in the provided context.
91
+
92
+ ${context}
93
+
94
+ User message: "${message}"
95
+
96
+ Instructions:
97
+ - If the user says "${ENTITY_PATTERNS.TOPIC_REFERENCE}" or "that topic" → replace with the most recent topic ID
98
+ - If the user says "${ENTITY_PATTERNS.TOKEN_REFERENCE}" or "that token" → replace with the most recent token ID (never a topic)
99
+ - If the user says "it" or "that" after an action verb → replace with the most recent entity ID
100
+ - Examples:
101
+ * "submit on ${ENTITY_PATTERNS.TOPIC_REFERENCE}" → "submit on 0.0.6543472"
102
+ * "airdrop ${ENTITY_PATTERNS.TOKEN_REFERENCE}" → "airdrop 0.0.123456"
103
+ * "send a message to it" → "send a message to 0.0.6543472"
104
+
105
+ Return ONLY the message with replacements made. Do not add any explanations.
106
+ Resolved message:`;
96
107
  try {
97
- if (ContentStoreService && typeof ContentStoreService.setInstance === "function") {
98
- await ContentStoreService.setInstance(
99
- this.adapter
100
- );
101
- } else {
102
- this.logger.warn("ContentStoreService.setInstance is unavailable; skipping registration");
108
+ const response = await this.llm.invoke(prompt);
109
+ const resolved = response.content.trim();
110
+ const changed = resolved !== message;
111
+ try {
112
+ this.logger.info("resolveReferences: resolution result", {
113
+ changed,
114
+ hasEntityId: /\b0\.0\.\d+\b/.test(resolved),
115
+ resolvedPreview: resolved.substring(0, 200)
116
+ });
117
+ } catch {
103
118
  }
104
- if (ContentResolverRegistry && typeof ContentResolverRegistry.register === "function") {
105
- ContentResolverRegistry.register(
106
- this.resolver
107
- );
108
- } else {
109
- this.logger.warn("ContentResolverRegistry.register is unavailable; skipping registration");
119
+ if (changed && resolved.includes("0.0.")) {
120
+ return resolved;
110
121
  }
111
- this.isRegistered = true;
112
- this.logger.info(
113
- "ContentStoreManager initialized and registered for cross-package access"
114
- );
115
- } catch (error) {
116
- this.logger.error("Failed to initialize ContentStoreManager:", error);
117
- throw error;
122
+ return message;
123
+ } catch {
124
+ return message;
118
125
  }
119
126
  }
120
127
  /**
121
- * Get the underlying ContentStorage instance
128
+ * Extract entities from agent response using receipt data (preferred) or LLM fallback
122
129
  */
123
- getContentStorage() {
124
- return this.contentStorage;
130
+ async extractEntities(response, userMessage) {
131
+ const receiptEntities = this.extractFromReceipt(response, userMessage);
132
+ if (receiptEntities.length > 0) {
133
+ return receiptEntities;
134
+ }
135
+ return this.extractWithLLM(response, userMessage);
125
136
  }
126
137
  /**
127
- * Get storage statistics
138
+ * Extract entities from transaction receipt data (primary method)
128
139
  */
129
- async getStats() {
130
- return await this.contentStorage.getStats();
140
+ extractFromReceipt(response, userMessage) {
141
+ const entities = [];
142
+ let parsedResponse;
143
+ try {
144
+ parsedResponse = typeof response === "string" ? JSON.parse(response) : response;
145
+ } catch {
146
+ parsedResponse = response;
147
+ }
148
+ if (!parsedResponse || parsedResponse.success === false) {
149
+ return entities;
150
+ }
151
+ const receipt = parsedResponse.receipt || parsedResponse.result?.receipt || parsedResponse.data?.receipt;
152
+ if (!receipt) {
153
+ return entities;
154
+ }
155
+ const entityName = this.extractNameFromMessage(userMessage);
156
+ const transactionId = parsedResponse.transactionId || parsedResponse.result?.transactionId || void 0;
157
+ const extractEntityId = (entityId) => {
158
+ if (typeof entityId === "string") {
159
+ return entityId;
160
+ }
161
+ if (entityId && typeof entityId === "object" && typeof entityId.toString === "function") {
162
+ if (entityId.toString !== Object.prototype.toString) {
163
+ return entityId.toString();
164
+ }
165
+ }
166
+ return String(entityId);
167
+ };
168
+ if (receipt.tokenId) {
169
+ const entity = {
170
+ id: extractEntityId(receipt.tokenId),
171
+ name: entityName,
172
+ type: EntityFormat.TOKEN_ID
173
+ };
174
+ if (transactionId) {
175
+ entity.transactionId = transactionId;
176
+ }
177
+ entities.push(entity);
178
+ }
179
+ if (receipt.topicId) {
180
+ const entity = {
181
+ id: extractEntityId(receipt.topicId),
182
+ name: entityName,
183
+ type: EntityFormat.TOPIC_ID
184
+ };
185
+ if (transactionId) {
186
+ entity.transactionId = transactionId;
187
+ }
188
+ entities.push(entity);
189
+ }
190
+ if (receipt.accountId) {
191
+ const entity = {
192
+ id: extractEntityId(receipt.accountId),
193
+ name: entityName,
194
+ type: EntityFormat.ACCOUNT_ID
195
+ };
196
+ if (transactionId) {
197
+ entity.transactionId = transactionId;
198
+ }
199
+ entities.push(entity);
200
+ }
201
+ if (receipt.contractId) {
202
+ const entity = {
203
+ id: extractEntityId(receipt.contractId),
204
+ name: entityName,
205
+ type: EntityFormat.CONTRACT_ID
206
+ };
207
+ if (transactionId) {
208
+ entity.transactionId = transactionId;
209
+ }
210
+ entities.push(entity);
211
+ }
212
+ if (receipt.fileId) {
213
+ const entity = {
214
+ id: extractEntityId(receipt.fileId),
215
+ name: entityName,
216
+ type: EntityFormat.FILE_ID
217
+ };
218
+ if (transactionId) {
219
+ entity.transactionId = transactionId;
220
+ }
221
+ entities.push(entity);
222
+ }
223
+ if (receipt.scheduleId) {
224
+ const entity = {
225
+ id: extractEntityId(receipt.scheduleId),
226
+ name: entityName,
227
+ type: EntityFormat.SCHEDULE_ID
228
+ };
229
+ if (transactionId) {
230
+ entity.transactionId = transactionId;
231
+ }
232
+ entities.push(entity);
233
+ }
234
+ return entities;
131
235
  }
132
236
  /**
133
- * Update configuration
237
+ * Extract entity name from user message
134
238
  */
135
- async updateConfig(config) {
136
- return await this.contentStorage.updateConfig(config);
239
+ extractNameFromMessage(message) {
240
+ const quotedMatch = message.match(/"([^"]+)"/);
241
+ if (quotedMatch) return quotedMatch[1];
242
+ const calledMatch = message.match(/called\s+([A-Za-z0-9#\s_-]+?)(?:\s|$)/i);
243
+ if (calledMatch) return calledMatch[1].trim();
244
+ const forMatch = message.match(/for\s+([A-Za-z0-9#\s_-]+)/i);
245
+ if (forMatch) return forMatch[1].trim();
246
+ const namedMatch = message.match(
247
+ /(?:token|topic|account|contract)\s+([A-Za-z0-9#_-]+)/i
248
+ );
249
+ if (namedMatch) return namedMatch[1].trim();
250
+ if (message.includes("new account")) return "new account";
251
+ return "unnamed_entity";
137
252
  }
138
253
  /**
139
- * Perform manual cleanup
254
+ * Extract entities using LLM (fallback method)
140
255
  */
141
- async performCleanup() {
142
- return await this.contentStorage.performCleanup();
256
+ async extractWithLLM(response, userMessage) {
257
+ const text = typeof response === "string" ? response : JSON.stringify(response);
258
+ const prompt = `Analyze this agent response and extract ONLY newly created entities.
259
+
260
+ User asked: "${userMessage.substring(0, 200)}"
261
+
262
+ Agent response: ${text.substring(0, 3e3)}
263
+
264
+ CRITICAL: Only extract Hedera entity IDs in the format 0.0.XXXXX (shard.realm.number).
265
+ DO NOT extract:
266
+ - Token symbols (e.g., "FOREV", "USDC", "HBAR")
267
+ - Token names (e.g., "Forever", "My Token")
268
+ - Transaction IDs (format: 0.0.XXX@timestamp)
269
+ - Account aliases or mnemonics
270
+
271
+ Look for:
272
+ 1. Success messages with entity IDs (e.g., "Successfully created topic 0.0.6543472")
273
+ 2. Transaction confirmations that created new entities
274
+ 3. Entity IDs that appear after words like "created", "new", "successfully"
275
+
276
+ DO NOT include:
277
+ - Token symbols or names (these are NOT entity IDs)
278
+ - Account IDs that already existed (like sender/receiver accounts)
279
+ - Entity IDs that were parameters to the operation
280
+ - Failed operations
281
+ - Anything that doesn't match the 0.0.XXXXX format
282
+
283
+ Return a JSON array of newly created entities:
284
+ [{"id": "0.0.XXX", "name": "descriptive_name", "type": "topic|token|account"}]
285
+
286
+ If no entities were created, return: []
287
+
288
+ JSON:`;
289
+ try {
290
+ const response2 = await this.llm.invoke(prompt);
291
+ const content = response2.content;
292
+ const match = content.match(/\[[\s\S]*?\]/);
293
+ if (match) {
294
+ const entities = JSON.parse(match[0]);
295
+ return entities;
296
+ }
297
+ } catch {
298
+ }
299
+ return [];
143
300
  }
144
301
  /**
145
- * Check if content should be stored as reference
302
+ * Validate that an entity matches the expected type
146
303
  */
147
- shouldUseReference(content) {
148
- return this.contentStorage.shouldUseReference(content);
304
+ validateEntityType(entityId, expectedType, entities) {
305
+ const stored = entities.find((e) => e.entityId === entityId);
306
+ return !!stored && stored.entityType === expectedType;
149
307
  }
150
308
  /**
151
- * Store content if it's large enough
309
+ * Resolve entity references with type validation
152
310
  */
153
- async storeContentIfLarge(content, metadata) {
154
- const storeMetadata = {
155
- source: "system",
156
- contentType: "binary",
157
- ...metadata
158
- };
159
- return await this.contentStorage.storeContentIfLarge(
160
- content,
161
- storeMetadata
162
- );
311
+ async resolveWithTypeValidation(query, entities, expectedType) {
312
+ await this.resolveReferences(query, entities);
313
+ if (!expectedType) {
314
+ return entities;
315
+ }
316
+ return entities.filter((entity) => entity.entityType === expectedType);
163
317
  }
164
318
  /**
165
- * Cleanup and unregister
319
+ * Get entities filtered by type
166
320
  */
167
- async dispose() {
168
- if (this.isRegistered) {
169
- this.contentStorage.dispose();
170
- if (ContentStoreService && typeof ContentStoreService.dispose === "function") {
171
- ContentStoreService.dispose();
172
- }
173
- if (ContentResolverRegistry && typeof ContentResolverRegistry.unregister === "function") {
174
- ContentResolverRegistry.unregister();
175
- }
176
- this.isRegistered = false;
177
- this.logger.info("ContentStoreManager disposed and unregistered");
178
- }
321
+ getEntitiesByType(entities, entityType) {
322
+ return entities.filter((entity) => entity.entityType === entityType);
179
323
  }
180
324
  /**
181
- * Check if the manager is initialized
325
+ * Find the most recent entity of a specific type
182
326
  */
183
- isInitialized() {
184
- return this.isRegistered;
327
+ getMostRecentEntityByType(entities, entityType) {
328
+ const filtered = entities.filter(
329
+ (entity) => entity.entityType === entityType
330
+ );
331
+ if (filtered.length === 0) return null;
332
+ return filtered.reduce(
333
+ (most, current) => current.createdAt > most.createdAt ? current : most
334
+ );
185
335
  }
186
336
  }
187
337
  export {
188
- ContentStoreManager
338
+ EntityResolver
189
339
  };
190
340
  //# sourceMappingURL=index24.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index24.js","sources":["../../src/services/content-store-manager.ts"],"sourcesContent":["import { ContentStorage } from '../memory/content-storage';\nimport {\n ContentStoreService,\n extractReferenceId,\n shouldUseReference,\n ContentResolverRegistry,\n type ContentStoreInterface,\n type ContentResolverInterface,\n type ReferenceResolutionResult,\n} from '@hashgraphonline/standards-sdk';\nimport type {\n ContentReference,\n ContentReferenceConfig,\n ContentReferenceStats,\n} from '../types/content-reference';\nimport { Logger } from '@hashgraphonline/standards-sdk';\n\n/**\n * Content metadata interface for adapter compatibility\n */\ninterface AdapterContentMetadata {\n mimeType?: string;\n fileName?: string;\n sizeBytes?: number;\n [key: string]: unknown;\n}\n\n/**\n * Configuration interface for content storage\n */\ninterface ContentStoreConfig {\n maxSize?: number;\n enableCompression?: boolean;\n [key: string]: unknown;\n}\n\n/**\n * Adapter to make ContentStorage compatible with ContentStoreInterface\n */\nclass ContentStorageAdapter implements ContentStoreInterface {\n constructor(private storage: ContentStorage) {}\n\n async storeContent(\n content: Buffer,\n metadata: AdapterContentMetadata\n ): Promise<string> {\n const storeMetadata = {\n contentType: 'binary' as const,\n sizeBytes: content.length,\n source: 'system' as const,\n ...metadata,\n };\n const contentRef = await this.storage.storeContent(content, storeMetadata);\n return contentRef.referenceId;\n }\n\n async resolveReference(\n referenceId: string\n ): Promise<ReferenceResolutionResult> {\n const result = await this.storage.resolveReference(referenceId);\n if (result.success && result.content) {\n const response: ReferenceResolutionResult = {\n content: result.content,\n };\n if (result.metadata) {\n response.metadata = {\n ...(result.metadata.mimeType !== undefined && {\n mimeType: result.metadata.mimeType,\n }),\n ...(result.metadata.fileName !== undefined && {\n fileName: result.metadata.fileName,\n }),\n originalSize: result.metadata.sizeBytes,\n };\n }\n return response;\n } else {\n throw new Error(result.error || 'Reference not found');\n }\n }\n\n async hasReference(referenceId: string): Promise<boolean> {\n return await this.storage.hasReference(referenceId);\n }\n\n async cleanupReference(referenceId: string): Promise<void> {\n await this.storage.cleanupReference(referenceId);\n }\n\n async getStats(): Promise<unknown> {\n return await this.storage.getStats();\n }\n\n async updateConfig(config: ContentStoreConfig): Promise<void> {\n const referenceConfig = {\n sizeThresholdBytes: config.maxSize || 10240,\n enableAutoCleanup: config.enableCompression || true,\n ...config,\n };\n return await this.storage.updateConfig(referenceConfig);\n }\n\n async performCleanup(): Promise<void> {\n await this.storage.performCleanup();\n }\n\n async dispose(): Promise<void> {\n return Promise.resolve(this.storage.dispose());\n }\n}\n\n/**\n * Content resolver implementation for dependency injection\n */\nclass ContentResolver implements ContentResolverInterface {\n constructor(private adapter: ContentStorageAdapter) {}\n\n async resolveReference(\n referenceId: string\n ): Promise<ReferenceResolutionResult> {\n return await this.adapter.resolveReference(referenceId);\n }\n\n shouldUseReference(content: string | Buffer): boolean {\n return shouldUseReference(content);\n }\n\n extractReferenceId(input: string): string | null {\n return extractReferenceId(input);\n }\n}\n\n/**\n * Manages content store lifecycle and cross-package registration\n */\nexport class ContentStoreManager {\n private contentStorage: ContentStorage;\n private adapter: ContentStorageAdapter;\n private resolver: ContentResolver;\n private logger: Logger;\n protected isRegistered = false;\n\n constructor(\n maxMessageStorage: number = 1000,\n referenceConfig?: Partial<ContentReferenceConfig>,\n logger?: Logger\n ) {\n this.logger = logger || new Logger({ module: 'ContentStoreManager' });\n\n this.contentStorage = new ContentStorage(\n maxMessageStorage,\n referenceConfig\n );\n this.adapter = new ContentStorageAdapter(this.contentStorage);\n this.resolver = new ContentResolver(this.adapter);\n }\n\n /**\n * Initialize and register content storage for cross-package access\n */\n async initialize(): Promise<void> {\n if (this.isRegistered) {\n this.logger.warn('ContentStoreManager is already initialized');\n return;\n }\n\n try {\n if (\n ContentStoreService &&\n typeof (ContentStoreService as unknown as { setInstance?: Function }).setInstance === 'function'\n ) {\n await (ContentStoreService as unknown as { setInstance: (adapter: unknown) => Promise<void> }).setInstance(\n this.adapter\n );\n } else {\n this.logger.warn('ContentStoreService.setInstance is unavailable; skipping registration');\n }\n if (\n ContentResolverRegistry &&\n typeof (ContentResolverRegistry as unknown as { register?: Function }).register === 'function'\n ) {\n (ContentResolverRegistry as unknown as { register: (resolver: unknown) => void }).register(\n this.resolver\n );\n } else {\n this.logger.warn('ContentResolverRegistry.register is unavailable; skipping registration');\n }\n this.isRegistered = true;\n this.logger.info(\n 'ContentStoreManager initialized and registered for cross-package access'\n );\n } catch (error) {\n this.logger.error('Failed to initialize ContentStoreManager:', error);\n throw error;\n }\n }\n\n /**\n * Get the underlying ContentStorage instance\n */\n getContentStorage(): ContentStorage {\n return this.contentStorage;\n }\n\n /**\n * Get storage statistics\n */\n async getStats(): Promise<ContentReferenceStats> {\n return await this.contentStorage.getStats();\n }\n\n /**\n * Update configuration\n */\n async updateConfig(config: Partial<ContentReferenceConfig>): Promise<void> {\n return await this.contentStorage.updateConfig(config);\n }\n\n /**\n * Perform manual cleanup\n */\n async performCleanup(): Promise<{ cleanedUp: number; errors: string[] }> {\n return await this.contentStorage.performCleanup();\n }\n\n /**\n * Check if content should be stored as reference\n */\n shouldUseReference(content: Buffer | string): boolean {\n return this.contentStorage.shouldUseReference(content);\n }\n\n /**\n * Store content if it's large enough\n */\n async storeContentIfLarge(\n content: Buffer | string,\n metadata: AdapterContentMetadata\n ): Promise<ContentReference | null> {\n const storeMetadata = {\n source: 'system' as const,\n contentType: 'binary' as const,\n ...metadata,\n };\n return await this.contentStorage.storeContentIfLarge(\n content,\n storeMetadata\n );\n }\n\n /**\n * Cleanup and unregister\n */\n async dispose(): Promise<void> {\n if (this.isRegistered) {\n this.contentStorage.dispose();\n if (\n ContentStoreService &&\n typeof (ContentStoreService as unknown as { dispose?: Function }).dispose === 'function'\n ) {\n (ContentStoreService as unknown as { dispose: () => void }).dispose();\n }\n if (\n ContentResolverRegistry &&\n typeof (ContentResolverRegistry as unknown as { unregister?: Function }).unregister === 'function'\n ) {\n (ContentResolverRegistry as unknown as { unregister: () => void }).unregister();\n }\n this.isRegistered = false;\n this.logger.info('ContentStoreManager disposed and unregistered');\n }\n }\n\n /**\n * Check if the manager is initialized\n */\n isInitialized(): boolean {\n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F;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAyB;AACvB,WAAO,KAAK;AAAA,EACd;AACF;"}
1
+ {"version":3,"file":"index24.js","sources":["../../src/services/entity-resolver.ts"],"sourcesContent":["import { ChatOpenAI } from '@langchain/openai';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport type { EntityAssociation } from '../memory/smart-memory-manager';\nimport { ENTITY_PATTERNS } from '../constants';\nimport { EntityFormat } from '..';\n\nexport interface EntityResolverConfig {\n apiKey: string;\n modelName?: string;\n}\n\ninterface EntityIdValue {\n toString(): string;\n}\n\ninterface TransactionReceipt {\n tokenId?: EntityIdValue | string;\n topicId?: EntityIdValue | string;\n accountId?: EntityIdValue | string;\n contractId?: EntityIdValue | string;\n fileId?: EntityIdValue | string;\n scheduleId?: EntityIdValue | string;\n}\n\ninterface TransactionResponse {\n success?: boolean;\n receipt?: TransactionReceipt;\n result?: {\n receipt?: TransactionReceipt;\n transactionId?: string;\n };\n data?: {\n receipt?: TransactionReceipt;\n };\n transactionId?: string;\n}\n\ninterface ExtractedEntity {\n id: string;\n name: string;\n type: EntityFormat;\n transactionId?: string;\n}\n\n/**\n * LLM-based entity resolver that replaces brittle regex patterns\n */\nexport class EntityResolver {\n private llm: ChatOpenAI;\n private logger: Logger;\n\n constructor(config: EntityResolverConfig) {\n this.llm = new ChatOpenAI({\n apiKey: config.apiKey,\n modelName: config.modelName || 'gpt-4o-mini',\n temperature: 0,\n });\n this.logger = new Logger({ module: 'EntityResolver' });\n }\n\n /**\n * Resolve entity references using LLM instead of regex\n */\n async resolveReferences(\n message: string,\n entities: EntityAssociation[]\n ): Promise<string> {\n if (!entities || entities.length === 0) {\n return message;\n }\n\n const byType = entities.reduce((acc, e) => {\n if (!acc[e.entityType]) acc[e.entityType] = [];\n acc[e.entityType].push(e);\n return acc;\n }, {} as Record<string, EntityAssociation[]>);\n\n try {\n const stats = Object.fromEntries(\n Object.entries(byType).map(([type, list]) => [\n type,\n {\n count: list.length,\n mostRecent: list[0]?.entityId,\n },\n ])\n );\n this.logger.info('resolveReferences: input summary', {\n messagePreview: message.substring(0, 200),\n entityStats: stats,\n });\n } catch {}\n\n let context = 'Available entities in memory:\\n';\n for (const [type, list] of Object.entries(byType)) {\n const recent = list[0];\n context += `Most recent ${type}: \"${recent.entityName}\" = ${recent.entityId}\\n`;\n if (list.length > 1) {\n context += ` (${list.length - 1} other ${type}s in memory)\\n`;\n }\n }\n\n const prompt = `Task: Replace entity references with their IDs from memory. STRICT TYPE RULES:\n\n- For phrases referring to \"${ENTITY_PATTERNS.TOKEN_REFERENCE}\" or actions that clearly require a token (create/mint/airdrop/associate/etc.), resolve to the most recent TOKEN entity ID (never a topic or account).\n- For phrases referring to \"${ENTITY_PATTERNS.TOPIC_REFERENCE}\" or actions that clearly require a topic (inscribe/publish/consensus/etc.), resolve to the most recent TOPIC entity ID (never a token or account).\n- Do not infer or invent entity IDs. Only use those present in the provided context.\n\n${context}\n\nUser message: \"${message}\"\n\nInstructions:\n- If the user says \"${ENTITY_PATTERNS.TOPIC_REFERENCE}\" or \"that topic\" → replace with the most recent topic ID\n- If the user says \"${ENTITY_PATTERNS.TOKEN_REFERENCE}\" or \"that token\" → replace with the most recent token ID (never a topic)\n- If the user says \"it\" or \"that\" after an action verb → replace with the most recent entity ID\n- Examples:\n * \"submit on ${ENTITY_PATTERNS.TOPIC_REFERENCE}\" → \"submit on 0.0.6543472\"\n * \"airdrop ${ENTITY_PATTERNS.TOKEN_REFERENCE}\" → \"airdrop 0.0.123456\"\n * \"send a message to it\" → \"send a message to 0.0.6543472\"\n\nReturn ONLY the message with replacements made. Do not add any explanations.\nResolved message:`;\n\n try {\n const response = await this.llm.invoke(prompt);\n const resolved = (response.content as string).trim();\n\n const changed = resolved !== message;\n try {\n this.logger.info('resolveReferences: resolution result', {\n changed,\n hasEntityId: /\\b0\\.0\\.\\d+\\b/.test(resolved),\n resolvedPreview: resolved.substring(0, 200),\n });\n } catch {}\n\n if (changed && resolved.includes('0.0.')) {\n return resolved;\n }\n\n return message;\n } catch {\n return message;\n }\n }\n\n /**\n * Extract entities from agent response using receipt data (preferred) or LLM fallback\n */\n async extractEntities(\n response: unknown,\n userMessage: string\n ): Promise<ExtractedEntity[]> {\n const receiptEntities = this.extractFromReceipt(response, userMessage);\n if (receiptEntities.length > 0) {\n return receiptEntities;\n }\n\n return this.extractWithLLM(response, userMessage);\n }\n\n /**\n * Extract entities from transaction receipt data (primary method)\n */\n private extractFromReceipt(\n response: unknown,\n userMessage: string\n ): ExtractedEntity[] {\n const entities: ExtractedEntity[] = [];\n\n let parsedResponse: TransactionResponse;\n try {\n parsedResponse =\n typeof response === 'string'\n ? JSON.parse(response)\n : (response as TransactionResponse);\n } catch {\n parsedResponse = response as TransactionResponse;\n }\n\n if (!parsedResponse || parsedResponse.success === false) {\n return entities;\n }\n\n const receipt =\n parsedResponse.receipt ||\n parsedResponse.result?.receipt ||\n parsedResponse.data?.receipt;\n\n if (!receipt) {\n return entities;\n }\n\n const entityName = this.extractNameFromMessage(userMessage);\n\n const transactionId =\n parsedResponse.transactionId ||\n parsedResponse.result?.transactionId ||\n undefined;\n\n const extractEntityId = (entityId: EntityIdValue | string): string => {\n if (typeof entityId === 'string') {\n return entityId;\n }\n if (\n entityId &&\n typeof entityId === 'object' &&\n typeof entityId.toString === 'function'\n ) {\n if (entityId.toString !== Object.prototype.toString) {\n return entityId.toString();\n }\n }\n return String(entityId);\n };\n\n if (receipt.tokenId) {\n const entity: ExtractedEntity = {\n id: extractEntityId(receipt.tokenId),\n name: entityName,\n type: EntityFormat.TOKEN_ID,\n };\n if (transactionId) {\n entity.transactionId = transactionId;\n }\n entities.push(entity);\n }\n\n if (receipt.topicId) {\n const entity: ExtractedEntity = {\n id: extractEntityId(receipt.topicId),\n name: entityName,\n type: EntityFormat.TOPIC_ID,\n };\n if (transactionId) {\n entity.transactionId = transactionId;\n }\n entities.push(entity);\n }\n\n if (receipt.accountId) {\n const entity: ExtractedEntity = {\n id: extractEntityId(receipt.accountId),\n name: entityName,\n type: EntityFormat.ACCOUNT_ID,\n };\n if (transactionId) {\n entity.transactionId = transactionId;\n }\n entities.push(entity);\n }\n\n if (receipt.contractId) {\n const entity: ExtractedEntity = {\n id: extractEntityId(receipt.contractId),\n name: entityName,\n type: EntityFormat.CONTRACT_ID,\n };\n if (transactionId) {\n entity.transactionId = transactionId;\n }\n entities.push(entity);\n }\n\n if (receipt.fileId) {\n const entity: ExtractedEntity = {\n id: extractEntityId(receipt.fileId),\n name: entityName,\n type: EntityFormat.FILE_ID,\n };\n if (transactionId) {\n entity.transactionId = transactionId;\n }\n entities.push(entity);\n }\n\n if (receipt.scheduleId) {\n const entity: ExtractedEntity = {\n id: extractEntityId(receipt.scheduleId),\n name: entityName,\n type: EntityFormat.SCHEDULE_ID,\n };\n if (transactionId) {\n entity.transactionId = transactionId;\n }\n entities.push(entity);\n }\n\n return entities;\n }\n\n /**\n * Extract entity name from user message\n */\n private extractNameFromMessage(message: string): string {\n const quotedMatch = message.match(/\"([^\"]+)\"/);\n if (quotedMatch) return quotedMatch[1];\n\n const calledMatch = message.match(/called\\s+([A-Za-z0-9#\\s_-]+?)(?:\\s|$)/i);\n if (calledMatch) return calledMatch[1].trim();\n\n const forMatch = message.match(/for\\s+([A-Za-z0-9#\\s_-]+)/i);\n if (forMatch) return forMatch[1].trim();\n\n const namedMatch = message.match(\n /(?:token|topic|account|contract)\\s+([A-Za-z0-9#_-]+)/i\n );\n if (namedMatch) return namedMatch[1].trim();\n\n if (message.includes('new account')) return 'new account';\n\n return 'unnamed_entity';\n }\n\n /**\n * Extract entities using LLM (fallback method)\n */\n private async extractWithLLM(\n response: unknown,\n userMessage: string\n ): Promise<ExtractedEntity[]> {\n const text =\n typeof response === 'string' ? response : JSON.stringify(response);\n\n const prompt = `Analyze this agent response and extract ONLY newly created entities.\n\nUser asked: \"${userMessage.substring(0, 200)}\"\n\nAgent response: ${text.substring(0, 3000)}\n\nCRITICAL: Only extract Hedera entity IDs in the format 0.0.XXXXX (shard.realm.number).\nDO NOT extract:\n- Token symbols (e.g., \"FOREV\", \"USDC\", \"HBAR\")\n- Token names (e.g., \"Forever\", \"My Token\")\n- Transaction IDs (format: 0.0.XXX@timestamp)\n- Account aliases or mnemonics\n\nLook for:\n1. Success messages with entity IDs (e.g., \"Successfully created topic 0.0.6543472\")\n2. Transaction confirmations that created new entities\n3. Entity IDs that appear after words like \"created\", \"new\", \"successfully\"\n\nDO NOT include:\n- Token symbols or names (these are NOT entity IDs)\n- Account IDs that already existed (like sender/receiver accounts)\n- Entity IDs that were parameters to the operation\n- Failed operations\n- Anything that doesn't match the 0.0.XXXXX format\n\nReturn a JSON array of newly created entities:\n[{\"id\": \"0.0.XXX\", \"name\": \"descriptive_name\", \"type\": \"topic|token|account\"}]\n\nIf no entities were created, return: []\n\nJSON:`;\n\n try {\n const response = await this.llm.invoke(prompt);\n const content = response.content as string;\n const match = content.match(/\\[[\\s\\S]*?\\]/);\n if (match) {\n const entities = JSON.parse(match[0]);\n return entities;\n }\n } catch {}\n return [];\n }\n\n /**\n * Validate that an entity matches the expected type\n */\n validateEntityType(\n entityId: string,\n expectedType: string,\n entities: EntityAssociation[]\n ): boolean {\n const stored = entities.find((e) => e.entityId === entityId);\n return !!stored && stored.entityType === expectedType;\n }\n\n /**\n * Resolve entity references with type validation\n */\n async resolveWithTypeValidation(\n query: string,\n entities: EntityAssociation[],\n expectedType?: string\n ): Promise<EntityAssociation[]> {\n await this.resolveReferences(query, entities);\n\n if (!expectedType) {\n return entities;\n }\n\n return entities.filter((entity) => entity.entityType === expectedType);\n }\n\n /**\n * Get entities filtered by type\n */\n getEntitiesByType(\n entities: EntityAssociation[],\n entityType: string\n ): EntityAssociation[] {\n return entities.filter((entity) => entity.entityType === entityType);\n }\n\n /**\n * Find the most recent entity of a specific type\n */\n getMostRecentEntityByType(\n entities: EntityAssociation[],\n entityType: string\n ): EntityAssociation | null {\n const filtered = entities.filter(\n (entity) => entity.entityType === entityType\n );\n if (filtered.length === 0) return null;\n\n return filtered.reduce((most, current) =>\n current.createdAt > most.createdAt ? current : most\n );\n }\n}\n"],"names":["response"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CO,MAAM,eAAe;AAAA,EAI1B,YAAY,QAA8B;AACxC,SAAK,MAAM,IAAI,WAAW;AAAA,MACxB,QAAQ,OAAO;AAAA,MACf,WAAW,OAAO,aAAa;AAAA,MAC/B,aAAa;AAAA,IAAA,CACd;AACD,SAAK,SAAS,IAAI,OAAO,EAAE,QAAQ,kBAAkB;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,kBACJ,SACA,UACiB;AACjB,QAAI,CAAC,YAAY,SAAS,WAAW,GAAG;AACtC,aAAO;AAAA,IACT;AAEA,UAAM,SAAS,SAAS,OAAO,CAAC,KAAK,MAAM;AACzC,UAAI,CAAC,IAAI,EAAE,UAAU,EAAG,KAAI,EAAE,UAAU,IAAI,CAAA;AAC5C,UAAI,EAAE,UAAU,EAAE,KAAK,CAAC;AACxB,aAAO;AAAA,IACT,GAAG,CAAA,CAAyC;AAE5C,QAAI;AACF,YAAM,QAAQ,OAAO;AAAA,QACnB,OAAO,QAAQ,MAAM,EAAE,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM;AAAA,UAC3C;AAAA,UACA;AAAA,YACE,OAAO,KAAK;AAAA,YACZ,YAAY,KAAK,CAAC,GAAG;AAAA,UAAA;AAAA,QACvB,CACD;AAAA,MAAA;AAEH,WAAK,OAAO,KAAK,oCAAoC;AAAA,QACnD,gBAAgB,QAAQ,UAAU,GAAG,GAAG;AAAA,QACxC,aAAa;AAAA,MAAA,CACd;AAAA,IACH,QAAQ;AAAA,IAAC;AAET,QAAI,UAAU;AACd,eAAW,CAAC,MAAM,IAAI,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,YAAM,SAAS,KAAK,CAAC;AACrB,iBAAW,eAAe,IAAI,MAAM,OAAO,UAAU,OAAO,OAAO,QAAQ;AA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