@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 +1 @@
1
- {"version":3,"file":"index32.js","sources":["../../src/langchain/form-validating-tool-wrapper.ts"],"sourcesContent":["import { StructuredTool } from '@langchain/core/tools';\nimport { z } from 'zod';\nimport { CallbackManagerForToolRun } from '@langchain/core/callbacks/manager';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport { FormGenerator } from '../forms/form-generator';\nimport type { FormMessage } from '../forms/types';\nimport { isFormValidatable } from '@hashgraphonline/standards-agent-kit';\n\nexport interface FormValidationConfig {\n requireAllFields?: boolean;\n skipFields?: string[];\n customValidation?: (input: unknown) => boolean;\n}\n\n/**\n * Generic wrapper for StructuredTools that intercepts execution to check for missing required fields\n * and generates forms when validation would benefit from user input.\n *\n * Tools can implement the FormValidatable interface to provide custom validation logic.\n * Otherwise, falls back to schema-based validation.\n */\nexport class FormValidatingToolWrapper<\n TSchema extends z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny>\n> extends StructuredTool<TSchema> {\n private originalTool: StructuredTool<TSchema>;\n private formGenerator: FormGenerator;\n private validationConfig: FormValidationConfig;\n private logger: Logger;\n\n name: string;\n description: string;\n schema: TSchema;\n\n constructor(\n originalTool: StructuredTool<TSchema>,\n formGenerator: FormGenerator,\n config: FormValidationConfig = {}\n ) {\n super();\n this.originalTool = originalTool;\n this.formGenerator = formGenerator;\n this.validationConfig = config;\n this.logger = new Logger({ module: 'FormValidatingToolWrapper' });\n\n this.name = originalTool.name;\n this.description = originalTool.description;\n this.schema = originalTool.schema;\n \n this.logger.info(`🔧 FormValidatingToolWrapper created for tool: ${this.name}`, {\n originalToolName: originalTool.name,\n originalToolType: originalTool.constructor.name,\n wrapperType: this.constructor.name\n });\n }\n\n /**\n * Validate the input against the schema\n */\n private validateInput(input: Record<string, unknown>): { isValid: boolean; errors?: string[] } {\n try {\n this.schema.parse(input);\n return { isValid: true };\n } catch (error) {\n if (error instanceof z.ZodError) {\n const errors = error.errors\n .filter(err => {\n const fieldName = err.path[0] as string;\n return !this.validationConfig.skipFields?.includes(fieldName);\n })\n .map(err => `${err.path.join('.')}: ${err.message}`);\n return { isValid: false, errors };\n }\n return { isValid: false, errors: ['Validation failed'] };\n }\n }\n\n /**\n * Gets the shape keys from the schema if it's a ZodObject\n */\n private getSchemaShape(): string[] {\n if (this.isZodObject(this.schema)) {\n return Object.keys(this.schema.shape);\n }\n return [];\n }\n\n /**\n * Executes the wrapped tool's original implementation directly, bypassing wrapper logic.\n */\n public async executeOriginal(\n input: Record<string, unknown>,\n runManager?: CallbackManagerForToolRun\n ): Promise<string> {\n type CallableMethod = (\n args: Record<string, unknown>,\n runManager?: CallbackManagerForToolRun\n ) => Promise<string>;\n \n const tool = this.originalTool as unknown as Record<string, unknown>;\n \n if ('_call' in tool && typeof tool._call === 'function') {\n return (tool._call as CallableMethod)(input, runManager);\n }\n if ('call' in tool && typeof tool.call === 'function') {\n return (tool.call as CallableMethod)(input, runManager);\n }\n throw new Error('Original tool has no callable implementation');\n }\n\n /**\n * Provides access to the wrapped tool instance for executors that want to bypass the wrapper.\n */\n public getOriginalTool(): StructuredTool<TSchema> {\n return this.originalTool;\n }\n\n /**\n * Checks if tool implements FormValidatable method\n */\n private hasFormValidatableMethod<T>(\n tool: unknown,\n methodName: string\n ): tool is Record<string, T> {\n return (\n tool !== null &&\n typeof tool === 'object' &&\n methodName in tool &&\n typeof (tool as Record<string, unknown>)[methodName] === 'function'\n );\n }\n\n /**\n * Expose FormValidatable methods by delegating to the underlying tool when available.\n */\n public getFormSchema(): z.ZodSchema {\n if (this.hasFormValidatableMethod<() => z.ZodSchema>(this.originalTool, 'getFormSchema')) {\n return this.originalTool.getFormSchema();\n }\n return this.schema as z.ZodSchema;\n }\n\n public getEssentialFields(): string[] {\n if (this.hasFormValidatableMethod<() => string[]>(this.originalTool, 'getEssentialFields')) {\n return this.originalTool.getEssentialFields();\n }\n return [];\n }\n\n public isFieldEmpty(fieldName: string, value: unknown): boolean {\n if (this.hasFormValidatableMethod<(n: string, v: unknown) => boolean>(this.originalTool, 'isFieldEmpty')) {\n return this.originalTool.isFieldEmpty(fieldName, value);\n }\n if (value === undefined || value === null || value === '') {\n return true;\n }\n if (Array.isArray(value) && value.length === 0) {\n return true;\n }\n return false;\n }\n\n /**\n * Calculates which fields are missing from the input\n */\n private calculateMissingFields(\n input: Record<string, unknown>,\n isCustom: boolean\n ): Set<string> {\n const missingFields = new Set<string>();\n \n if (!isCustom) {\n return missingFields;\n }\n\n const essentialFields = this.getEssentialFields();\n for (const fieldName of essentialFields) {\n const value = input[fieldName];\n if (this.isFieldEmpty(fieldName, value)) {\n missingFields.add(fieldName);\n }\n }\n \n return missingFields;\n }\n\n /**\n * Creates a form message with optional JSON schema\n */\n private async createFormMessage(\n schema: z.ZodSchema,\n input: Record<string, unknown>,\n missingFields: Set<string>\n ): Promise<FormMessage> {\n let formMessage = await this.formGenerator.generateFormFromSchema(\n schema,\n input,\n {\n toolName: this.name,\n toolDescription: this.description\n },\n missingFields\n );\n\n if (this.isZodObject(schema)) {\n try {\n const { jsonSchema, uiSchema } = this.formGenerator.generateJsonSchemaForm(\n schema,\n input,\n missingFields\n );\n formMessage = {\n ...formMessage,\n jsonSchema,\n uiSchema\n };\n } catch (error) {\n this.logger.warn('Failed to generate JSON Schema for RJSF:', error);\n }\n }\n\n formMessage.partialInput = input;\n return formMessage;\n }\n\n /**\n * Type guard to check if a schema is a ZodObject\n */\n private isZodObject(schema: z.ZodSchema): schema is z.ZodObject<z.ZodRawShape> {\n const def = (schema as z.ZodType)._def as { typeName?: string };\n return !!(def && def.typeName === 'ZodObject');\n }\n\n /**\n * Check if we should generate a form for this tool invocation\n */\n private shouldGenerateForm(input: Record<string, unknown>): boolean {\n this.logger.info(`shouldGenerateForm called for ${this.name}/${this.originalTool.name}`, {\n input,\n hasCustomValidation: !!this.validationConfig.customValidation\n });\n\n if (this.validationConfig.customValidation) {\n const result = !this.validationConfig.customValidation(input);\n this.logger.info(`Custom validation result: ${result}`);\n return result;\n }\n\n if (isFormValidatable(this.originalTool)) {\n this.logger.info(`Tool ${this.originalTool.name} implements FormValidatable, using custom logic`);\n return this.originalTool.shouldGenerateForm(input);\n }\n\n this.logger.info(`Tool ${this.originalTool.name} using schema validation only`);\n const validation = this.validateInput(input);\n this.logger.info(`Schema validation for ${this.originalTool.name}:`, {\n isValid: validation.isValid,\n errors: validation.errors\n });\n return !validation.isValid;\n }\n\n /**\n * Checks if input has bypass flags that skip form generation\n */\n private hasFormBypassFlags(input: Record<string, unknown>): boolean {\n return (\n (input.__fromForm === true) ||\n (input.renderForm === false)\n );\n }\n\n /**\n * Override _call to intercept tool execution\n */\n protected async _call(\n input: z.infer<TSchema>,\n runManager?: CallbackManagerForToolRun\n ): Promise<string> {\n this.logger.info(`🚨🚨🚨 FormValidatingToolWrapper._call INTERCEPTING ${this.name} 🚨🚨🚨`, {\n input,\n inputKeys: Object.keys(input as Record<string, unknown>),\n schemaShape: this.getSchemaShape(),\n stackTrace: new Error().stack?.split('\\n').slice(0, 5)\n });\n\n const inputRecord = input as unknown as Record<string, unknown>;\n \n if (this.hasFormBypassFlags(inputRecord)) {\n this.logger.info('Bypassing form generation and executing original tool due to submission flags');\n return this.executeOriginal(inputRecord, runManager);\n }\n\n const shouldGenerate = this.shouldGenerateForm(input as Record<string, unknown>);\n this.logger.info(`FormValidatingToolWrapper decision for ${this.name}:`, {\n shouldGenerateForm: shouldGenerate,\n toolName: this.name,\n originalToolName: this.originalTool.name\n });\n\n if (shouldGenerate) {\n this.logger.info(`Generating form for incomplete input in ${this.name}`);\n\n try {\n const isCustom = isFormValidatable(this.originalTool);\n const schemaToUse = isCustom ? this.getFormSchema() : this.schema;\n const missingFields = this.calculateMissingFields(\n input as Record<string, unknown>,\n isCustom\n );\n\n const schemaFields = this.isZodObject(schemaToUse) \n ? Object.keys(schemaToUse.shape)\n : [];\n \n this.logger.info(`Using ${isCustom ? 'CUSTOM' : 'DEFAULT'} schema for form generation`, {\n toolName: this.originalTool.name,\n schemaType: schemaToUse.constructor?.name,\n schemaFields,\n isCustomSchema: isCustom\n });\n\n const formMessage = await this.createFormMessage(\n schemaToUse,\n input as Record<string, unknown>,\n missingFields\n );\n\n const result = {\n requiresForm: true,\n formMessage,\n message: `Please complete the form to provide the required information for ${this.name}.`\n };\n\n this.logger.info(`FormValidatingToolWrapper returning form result for ${this.name}`);\n return JSON.stringify(result);\n } catch (error) {\n this.logger.error('Failed to generate form:', error);\n }\n }\n\n this.logger.info(`FormValidatingToolWrapper passing through to original tool ${this.name}`);\n return this.executeOriginal(input as Record<string, unknown>, runManager);\n }\n\n}\n\n/**\n * Wrap a tool with form validation capabilities\n */\nexport function wrapToolWithFormValidation<TSchema extends z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny>>(\n tool: StructuredTool<TSchema>,\n formGenerator: FormGenerator,\n config: FormValidationConfig = {}\n): FormValidatingToolWrapper<TSchema> {\n return new FormValidatingToolWrapper(tool, formGenerator, config);\n}"],"names":[],"mappings":";;;;AAqBO,MAAM,kCAEH,eAAwB;AAAA,EAUhC,YACE,cACA,eACA,SAA+B,CAAA,GAC/B;AACA,UAAA;AACA,SAAK,eAAe;AACpB,SAAK,gBAAgB;AACrB,SAAK,mBAAmB;AACxB,SAAK,SAAS,IAAI,O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SAAS,WAAW,WAAW,SAAS,+BAA+B;AAAA,UACtF,UAAU,KAAK,aAAa;AAAA,UAC5B,YAAY,YAAY,aAAa;AAAA,UACrC;AAAA,UACA,gBAAgB;AAAA,QAAA,CACjB;AAED,cAAM,cAAc,MAAM,KAAK;AAAA,UAC7B;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAGF,cAAM,SAAS;AAAA,UACb,cAAc;AAAA,UACd;AAAA,UACA,SAAS,oEAAoE,KAAK,IAAI;AAAA,QAAA;AAGxF,aAAK,OAAO,KAAK,uDAAuD,KAAK,IAAI,EAAE;AACnF,eAAO,KAAK,UAAU,MAAM;AAAA,MAC9B,SAAS,OAAO;AACd,aAAK,OAAO,MAAM,4BAA4B,KAAK;AAAA,MACrD;AAAA,IACF;AAEA,SAAK,OAAO,KAAK,8DAA8D,KAAK,IAAI,EAAE;AAC1F,WAAO,KAAK,gBAAgB,OAAkC,UAAU;AAAA,EAC1E;AAEF;AAKO,SAAS,2BACd,MACA,eACA,SAA+B,CAAA,GACK;AACpC,SAAO,IAAI,0BAA0B,MAAM,eAAe,MAAM;AAClE;"}
1
+ {"version":3,"file":"index32.js","sources":["../../src/langchain/form-aware-agent-executor.ts"],"sourcesContent":["import { AgentExecutor } from 'langchain/agents';\nimport { ZodError, z } from 'zod';\nimport { FormGenerator } from '../forms/form-generator';\nimport type { FormMessage, FormSubmission } from '../forms/types';\nimport { FormEngine } from '../forms/form-engine';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport type { AgentAction, AgentFinish, AgentStep } from 'langchain/agents';\nimport type { ToolInterface } from '@langchain/core/tools';\nimport { isFormValidatable } from '@hashgraphonline/standards-agent-kit';\nimport type { ChainValues } from '@langchain/core/utils/types';\nimport type { CallbackManagerForChainRun } from '@langchain/core/callbacks/manager';\nimport type { RunnableConfig } from '@langchain/core/runnables';\nimport { ResponseFormatter } from '../utils/response-formatter';\n\ntype BasicFieldType = 'text' | 'number' | 'select' | 'checkbox' | 'textarea';\n\nconst globalPendingForms: Map<string, PendingFormData> = new Map();\n\ninterface HashLinkBlock {\n blockId: string;\n hashLink: string;\n template: string;\n attributes: Record<string, unknown>;\n}\n\ninterface HashLinkResponse {\n hasHashLinkBlocks: boolean;\n hashLinkBlock?: HashLinkBlock;\n message: string;\n}\n\ninterface ToolWithOriginal {\n originalTool?: {\n call?: (args: Record<string, unknown>) => Promise<string>;\n };\n}\n\ninterface ActionWithToolInput {\n toolInput?: Record<string, unknown>;\n}\n\ninterface ZodSchemaDefinition {\n _def?: {\n typeName?: string;\n shape?: (() => Record<string, z.ZodTypeAny>) | Record<string, z.ZodTypeAny>;\n innerType?: z.ZodTypeAny;\n defaultValue?: unknown;\n };\n}\n\ninterface ToolWrapper {\n executeOriginal?: (args: Record<string, unknown>) => Promise<string>;\n getOriginalTool?: () => {\n _call?: (args: Record<string, unknown>) => Promise<string>;\n call?: (args: Record<string, unknown>) => Promise<string>;\n };\n originalTool?: {\n _call?: (args: Record<string, unknown>) => Promise<string>;\n call?: (args: Record<string, unknown>) => Promise<string>;\n };\n call?: (args: Record<string, unknown>) => Promise<string>;\n}\n\ninterface CallableTool {\n _call?: (args: Record<string, unknown>) => Promise<string>;\n call?: (args: Record<string, unknown>) => Promise<string>;\n}\n\ninterface ToolWithSchema {\n schema?: Record<string, unknown>;\n}\n\ninterface PendingFormData {\n toolName: string;\n originalInput: unknown;\n originalToolInput?: unknown;\n schema: unknown;\n toolRef?: ToolInterface | undefined;\n originalToolRef?: ToolWithOriginal['originalTool'];\n}\n\ninterface ToolResponse {\n requiresForm?: boolean;\n formMessage?: {\n id: string;\n [key: string]: unknown;\n };\n message?: string;\n hashLinkBlock?: HashLinkBlock;\n success?: boolean;\n inscription?: Record<string, unknown>;\n metadata?: Record<string, unknown>;\n}\n\ninterface IntermediateStepData {\n action?: {\n tool?: string;\n [key: string]: unknown;\n };\n observation?: unknown;\n}\n\ninterface HashLinkBlock {\n blockId: string;\n hashLink: string;\n template: string;\n attributes: Record<string, unknown>;\n}\n\ninterface ResponseMetadataWithHashLink {\n hashLinkBlock?: HashLinkBlock;\n [key: string]: unknown;\n}\n\n/**\n * Parameter preprocessing callback interface\n */\nexport interface ParameterPreprocessingCallback {\n (toolName: string, parameters: Record<string, unknown>): Promise<\n Record<string, unknown>\n >;\n}\n\n/**\n * Agent executor that intercepts Zod validation errors and generates forms,\n * and processes HashLink block responses for rich UI rendering\n */\nexport class FormAwareAgentExecutor extends AgentExecutor {\n private formGenerator: FormGenerator;\n private formEngine: FormEngine;\n private formLogger: Logger;\n private pendingForms: Map<string, PendingFormData> = new Map();\n private parameterPreprocessingCallback:\n | ParameterPreprocessingCallback\n | undefined;\n\n /**\n * Type guard to check if a Zod type is a ZodObject\n */\n private isZodObject(schema: unknown): schema is z.ZodObject<z.ZodRawShape> {\n return schema instanceof z.ZodObject;\n }\n\n /**\n * Type guard to check if metadata has hashLinkBlock\n */\n private hasHashLinkBlock(\n metadata: unknown\n ): metadata is ResponseMetadataWithHashLink & {\n hashLinkBlock: HashLinkBlock;\n } {\n return (\n typeof metadata === 'object' &&\n metadata !== null &&\n 'hashLinkBlock' in metadata &&\n typeof (metadata as Record<string, unknown>).hashLinkBlock === 'object' &&\n (metadata as Record<string, unknown>).hashLinkBlock !== null\n );\n }\n\n constructor(...args: ConstructorParameters<typeof AgentExecutor>) {\n super(...args);\n this.formGenerator = new FormGenerator();\n this.formEngine = new FormEngine(\n new Logger({ module: 'FormAwareAgentExecutor.FormEngine' })\n );\n this.formLogger = new Logger({ module: 'FormAwareAgentExecutor' });\n this.parameterPreprocessingCallback = undefined;\n }\n\n /**\n * Set parameter preprocessing callback\n */\n setParameterPreprocessingCallback(\n callback: ParameterPreprocessingCallback | undefined\n ): void {\n this.parameterPreprocessingCallback = callback;\n }\n\n /**\n * BULLETPROOF TOOL INTERCEPTION\n * Override the single-step execution to intercept tool calls BEFORE LangChain processes them\n */\n override async _takeNextStep(\n nameToolMap: Record<string, ToolInterface>,\n inputs: ChainValues,\n intermediateSteps: AgentStep[],\n runManager?: CallbackManagerForChainRun,\n config?: RunnableConfig\n ): Promise<AgentFinish | AgentStep[]> {\n this.formLogger.info('🛡️ BULLETPROOF INTERCEPTION: _takeNextStep called', {\n availableTools: Object.keys(nameToolMap),\n inputKeys: Object.keys(inputs),\n });\n\n const result = await this.agent.plan(\n intermediateSteps,\n inputs,\n runManager?.getChild()\n );\n\n if ('returnValues' in result) {\n this.formLogger.info('Agent returned finish action, passing through');\n return result;\n }\n\n const action = result as AgentAction;\n const toolName = action.tool;\n const toolInput = action.toolInput;\n\n this.formLogger.info(`🎯 INTERCEPTING TOOL CALL: ${toolName}`, {\n toolInput,\n hasInNameToolMap: toolName in nameToolMap,\n toolInputKeys: Object.keys(toolInput || {}),\n });\n\n const tool =\n nameToolMap[toolName] || this.tools.find((t) => t.name === toolName);\n\n if (!tool) {\n this.formLogger.error(`Tool ${toolName} not found in registry`);\n throw new Error(`Tool \"${toolName}\" not found`);\n }\n\n let shouldGenerateForm = false;\n\n if (isFormValidatable(tool)) {\n this.formLogger.info(\n `🔍 Tool ${toolName} implements FormValidatable, checking shouldGenerateForm()`,\n {\n toolInput,\n }\n );\n\n try {\n shouldGenerateForm = tool.shouldGenerateForm(toolInput);\n this.formLogger.info(\n `FormValidatable.shouldGenerateForm() result: ${shouldGenerateForm}`,\n {\n toolName,\n toolInput,\n }\n );\n } catch (error) {\n this.formLogger.error(\n `Error calling shouldGenerateForm() on ${toolName}:`,\n error\n );\n shouldGenerateForm = false;\n }\n }\n\n if (shouldGenerateForm) {\n this.formLogger.info(`🚨 FORM GENERATION TRIGGERED for ${toolName}`);\n\n try {\n let schemaToUse: z.ZodSchema;\n let isFocusedSchema = false;\n\n if (isFormValidatable(tool)) {\n this.formLogger.info(\n `🎯 Tool ${toolName} is FormValidatable, attempting to get focused schema`\n );\n try {\n const focusedSchema = tool.getFormSchema();\n if (focusedSchema) {\n schemaToUse = focusedSchema;\n isFocusedSchema = true;\n this.formLogger.info(\n `✅ Successfully obtained focused schema for ${toolName}`\n );\n } else {\n this.formLogger.warn(\n `getFormSchema() returned null/undefined for ${toolName}, using default schema`\n );\n schemaToUse = tool.schema;\n isFocusedSchema = false;\n }\n } catch (error) {\n this.formLogger.error(\n `Failed to get focused schema from ${toolName}:`,\n error\n );\n this.formLogger.info(\n `Falling back to default schema for ${toolName}`\n );\n schemaToUse = tool.schema;\n isFocusedSchema = false;\n }\n } else {\n this.formLogger.info(\n `Tool ${toolName} is not FormValidatable, using default schema`\n );\n schemaToUse = tool.schema;\n isFocusedSchema = false;\n }\n\n let schemaFieldCount = 'unknown';\n try {\n if (this.isZodObject(schemaToUse)) {\n const zodObject = schemaToUse as z.ZodObject<z.ZodRawShape>;\n const shape = zodObject.shape;\n if (shape && typeof shape === 'object') {\n schemaFieldCount = Object.keys(shape).length.toString();\n }\n }\n } catch {}\n\n this.formLogger.info(\n `📋 Generating form with ${\n isFocusedSchema ? 'FOCUSED' : 'DEFAULT'\n } schema`,\n {\n toolName,\n schemaType: schemaToUse?.constructor?.name,\n estimatedFieldCount: schemaFieldCount,\n isFocusedSchema,\n }\n );\n\n let missingFields: Set<string> | undefined;\n\n if (isFocusedSchema) {\n this.formLogger.info(\n `⭐ Using focused schema - letting FormGenerator determine fields from schema`\n );\n missingFields = undefined;\n } else {\n missingFields = new Set<string>();\n if (this.isZodObject(schemaToUse)) {\n const zodObject = schemaToUse as z.ZodObject<z.ZodRawShape>;\n const shape = zodObject.shape || {};\n for (const fieldName of Object.keys(shape)) {\n const value = (toolInput || {})[fieldName];\n\n const isEmpty =\n isFormValidatable(tool) && tool.isFieldEmpty\n ? tool.isFieldEmpty(fieldName, value)\n : value === undefined ||\n value === '' ||\n value === null ||\n (Array.isArray(value) && value.length === 0);\n\n const isRequired = this.isFieldRequired(schemaToUse, fieldName);\n\n const isEssential =\n isFormValidatable(tool) && tool.getEssentialFields\n ? tool.getEssentialFields().includes(fieldName)\n : false;\n\n this.formLogger.info(`🔍 Field analysis: ${fieldName}`, {\n value: value,\n isEmpty: isEmpty,\n isRequired: isRequired,\n isEssential: isEssential,\n willAddToMissingFields: isEmpty && (isRequired || isEssential),\n });\n\n if (isEmpty && (isRequired || isEssential)) {\n missingFields.add(fieldName);\n }\n }\n }\n\n this.formLogger.info(`📋 Missing fields analysis complete`, {\n totalFields: this.isZodObject(schemaToUse)\n ? Object.keys(schemaToUse.shape).length\n : 0,\n missingFieldsCount: missingFields.size,\n missingFields: Array.from(missingFields),\n });\n }\n\n const formMessage = await this.formGenerator.generateFormFromSchema(\n schemaToUse,\n toolInput,\n {\n toolName: toolName,\n toolDescription: tool.description,\n },\n missingFields\n );\n\n if (this.isZodObject(schemaToUse)) {\n try {\n const { jsonSchema, uiSchema } =\n this.formGenerator.generateJsonSchemaForm(\n schemaToUse,\n toolInput as Record<string, unknown> | undefined,\n missingFields\n );\n formMessage.jsonSchema = jsonSchema;\n formMessage.uiSchema = uiSchema;\n } catch (error) {\n this.formLogger.warn(\n 'Failed to generate JSON Schema for RJSF:',\n error\n );\n }\n }\n\n formMessage.partialInput = toolInput;\n\n const formData: PendingFormData = {\n toolName: toolName,\n originalInput: inputs,\n originalToolInput: toolInput,\n schema: schemaToUse,\n toolRef: tool as ToolInterface | undefined,\n originalToolRef: (tool as ToolWithOriginal).originalTool,\n };\n this.pendingForms.set(formMessage.id, formData);\n globalPendingForms.set(formMessage.id, formData);\n\n this.formLogger.info(`✅ FORM INTERCEPT SUCCESS for ${toolName}`);\n\n const formResult = {\n requiresForm: true,\n formMessage,\n };\n\n return [\n {\n action: action,\n observation: JSON.stringify(formResult),\n },\n ];\n } catch (error) {\n this.formLogger.error(`Form generation failed for ${toolName}:`, error);\n }\n }\n\n this.formLogger.info(\n `⚪ Passing through to normal tool execution for ${toolName}`\n );\n\n if (this.parameterPreprocessingCallback && toolInput) {\n this.formLogger.info(\n `🔄 Applying parameter preprocessing for ${toolName}`\n );\n try {\n const preprocessedInput = await this.parameterPreprocessingCallback(\n toolName,\n toolInput as Record<string, unknown>\n );\n\n if (\n preprocessedInput &&\n typeof preprocessedInput === 'object' &&\n '__requestForm' in (preprocessedInput as Record<string, unknown>)\n ) {\n const rf = (preprocessedInput as Record<string, unknown>)\n .__requestForm as {\n id?: string;\n title?: string;\n description?: string;\n fields?: Array<{\n name: string;\n label: string;\n type: string;\n required?: boolean;\n options?: Array<{ value: string; label: string }>;\n }>;\n submitLabel?: string;\n };\n\n const formId =\n rf.id ||\n `form_${Date.now()}_${Math.random().toString(36).slice(2)}`;\n const formMessage = {\n type: 'form',\n id: formId,\n originalPrompt: 'Parameter validation required',\n toolName,\n formConfig: {\n title: rf.title || 'Complete required parameters',\n description:\n rf.description ||\n 'One or more parameters require confirmation. Please review and submit.',\n submitLabel: rf.submitLabel || 'Continue',\n fields: (rf.fields || []).map((f) => {\n const allowedTypes: BasicFieldType[] = [\n 'text',\n 'number',\n 'select',\n 'checkbox',\n 'textarea',\n ];\n const resolvedType: BasicFieldType = allowedTypes.includes(\n f.type as BasicFieldType\n )\n ? (f.type as BasicFieldType)\n : 'text';\n\n return {\n name: f.name,\n label: f.label,\n type: resolvedType,\n required: f.required ?? true,\n options: f.options,\n };\n }),\n },\n };\n\n const resolvedSchema = isFormValidatable(tool)\n ? (() => {\n try {\n const s = tool.getFormSchema();\n return s || tool.schema;\n } catch {\n return tool.schema;\n }\n })()\n : tool.schema;\n\n this.pendingForms.set(formId, {\n toolName,\n originalInput: inputs,\n originalToolInput: toolInput,\n schema: resolvedSchema,\n toolRef: tool as ToolInterface | undefined,\n originalToolRef: (tool as ToolWithOriginal).originalTool,\n });\n globalPendingForms.set(formId, {\n toolName,\n originalInput: inputs,\n originalToolInput: toolInput,\n schema: resolvedSchema,\n });\n\n return [\n {\n action,\n observation: JSON.stringify({ requiresForm: true, formMessage }),\n },\n ];\n }\n\n if (JSON.stringify(preprocessedInput) !== JSON.stringify(toolInput)) {\n this.formLogger.info(`📝 Parameters preprocessed for ${toolName}:`, {\n original: Object.keys(toolInput as Record<string, unknown>),\n preprocessed: Object.keys(preprocessedInput),\n hasChanges: true,\n });\n\n try {\n (action as ActionWithToolInput).toolInput = preprocessedInput;\n } catch {}\n } else {\n this.formLogger.debug(`No parameter changes needed for ${toolName}`);\n }\n } catch (preprocessError) {\n this.formLogger.warn(\n `Parameter preprocessing failed for ${toolName}, using original parameters:`,\n preprocessError\n );\n }\n }\n\n return super._takeNextStep(\n nameToolMap,\n inputs,\n intermediateSteps,\n runManager,\n config\n );\n }\n\n /**\n * Helper to determine if a field is required in the schema\n */\n private isFieldRequired(schema: unknown, fieldPath: string): boolean {\n if (!schema || !fieldPath) {\n return false;\n }\n\n try {\n const obj = schema as ZodSchemaDefinition;\n const def = obj._def;\n if (!def || def.typeName !== 'ZodObject') {\n return false;\n }\n const rawShape: unknown =\n typeof def.shape === 'function' ? def.shape() : def.shape;\n if (!rawShape || typeof rawShape !== 'object') {\n return false;\n }\n const shape = rawShape as Record<string, z.ZodTypeAny>;\n const fieldSchema = shape[fieldPath];\n if (!fieldSchema) {\n return false;\n }\n const unwrapOptional = (s: z.ZodTypeAny): z.ZodTypeAny => {\n const inner = (s as ZodSchemaDefinition)._def;\n if (inner && inner.typeName === 'ZodOptional' && inner.innerType) {\n return inner.innerType;\n }\n return s;\n };\n const unwrapped = unwrapOptional(fieldSchema);\n const fdef = (unwrapped as ZodSchemaDefinition)._def;\n if (!fdef) {\n return true;\n }\n if (fdef.typeName === 'ZodOptional' || fdef.typeName === 'ZodDefault') {\n return false;\n }\n if (fdef.defaultValue !== undefined) {\n return false;\n }\n return true;\n } catch (error) {\n this.formLogger.debug(\n `Could not determine if field ${fieldPath} is required:`,\n error\n );\n }\n return false;\n }\n\n /**\n * Override _call to intercept Zod validation errors at the execution level\n */\n override async _call(\n inputs: Record<string, unknown>\n ): Promise<Record<string, unknown>> {\n try {\n const result = await super._call(inputs);\n\n if (result.intermediateSteps && Array.isArray(result.intermediateSteps)) {\n for (const step of result.intermediateSteps) {\n if (step.observation) {\n try {\n const parsed: ToolResponse =\n typeof step.observation === 'string'\n ? JSON.parse(step.observation)\n : (step.observation as ToolResponse);\n\n if (parsed.requiresForm && parsed.formMessage) {\n this.formLogger.info('Tool requested form generation', {\n toolName: step.action?.tool,\n hasForm: true,\n });\n\n const actionToolName =\n (step as IntermediateStepData).action?.tool || 'unknown';\n const toolInstance = this.tools.find(\n (t) => t.name === actionToolName\n ) as ToolInterface | undefined;\n const originalToolCandidate =\n (toolInstance as ToolWithOriginal) || {};\n const pf: PendingFormData = {\n toolName: actionToolName,\n originalInput: inputs,\n originalToolInput: (step as IntermediateStepData).action\n ?.toolInput as Record<string, unknown> | undefined,\n schema: null,\n toolRef: toolInstance,\n originalToolRef: originalToolCandidate?.originalTool,\n };\n this.pendingForms.set(parsed.formMessage.id, pf);\n globalPendingForms.set(parsed.formMessage.id, pf);\n\n return {\n ...result,\n requiresForm: true,\n formMessage: parsed.formMessage,\n output:\n parsed.message || 'Please complete the form to continue.',\n };\n }\n\n if (\n parsed.hashLinkBlock ||\n (parsed.success && parsed.inscription && parsed.hashLinkBlock)\n ) {\n this.formLogger.info('Tool returned HashLink blocks', {\n toolName: (step as IntermediateStepData).action?.tool,\n hasHashLink: true,\n blockId: parsed.hashLinkBlock?.blockId,\n });\n\n const hashLinkResponse = this.processHashLinkResponse(parsed);\n\n return {\n ...result,\n hasHashLinkBlocks: true,\n hashLinkBlock: hashLinkResponse.hashLinkBlock,\n output: hashLinkResponse.message,\n };\n }\n } catch {}\n }\n }\n }\n\n return result;\n } catch (error) {\n if (error instanceof ZodError) {\n this.formLogger.info('Intercepted ZodError during agent execution');\n return this.handleValidationError(error, inputs, []);\n }\n throw error;\n }\n }\n\n /**\n * Handles Zod validation errors by generating forms\n */\n private async handleValidationError(\n error: ZodError,\n inputs: Record<string, unknown>,\n intermediateSteps: AgentStep[]\n ): Promise<Record<string, unknown>> {\n this.formLogger.info('Zod validation error detected, generating form', {\n errorIssues: error.issues.length,\n inputKeys: Object.keys(inputs),\n });\n\n let toolInfo = this.extractToolInfoFromError(\n error,\n inputs,\n intermediateSteps\n );\n\n if (!toolInfo) {\n this.formLogger.warn(\n 'Could not extract tool info from validation error, trying fallback detection'\n );\n const fallbackTool = this.detectToolFromErrorContext(error);\n if (!fallbackTool) {\n this.formLogger.error(\n 'No tool detected for form generation, rethrowing error'\n );\n throw error;\n }\n toolInfo = fallbackTool;\n }\n\n this.formLogger.info('Generating form for tool:', {\n toolName: toolInfo.toolName,\n hasSchema: !!toolInfo.schema,\n });\n\n const formMessage = this.formGenerator.generateFormFromError(\n error,\n toolInfo.schema as z.ZodType<unknown, z.ZodTypeDef, unknown>,\n toolInfo.toolName,\n (inputs.input as string) || ''\n );\n\n this.pendingForms.set(formMessage.id, {\n toolName: toolInfo.toolName,\n originalInput: inputs,\n schema: toolInfo.schema,\n });\n\n globalPendingForms.set(formMessage.id, {\n toolName: toolInfo.toolName,\n originalInput: inputs,\n schema: toolInfo.schema,\n });\n\n return {\n output: this.formatFormResponse(formMessage),\n formMessage,\n requiresForm: true,\n intermediateSteps: intermediateSteps || [],\n };\n }\n\n /**\n * Get a copy of pending forms for preservation during executor recreation\n */\n getPendingForms(): Map<string, PendingFormData> {\n return new Map(this.pendingForms);\n }\n\n /**\n * Restore pending forms from a previous executor instance\n */\n restorePendingForms(forms: Map<string, PendingFormData>): void {\n for (const [formId, formData] of forms) {\n this.pendingForms.set(formId, formData);\n }\n }\n\n /**\n * Processes form submission and continues tool execution\n */\n async processFormSubmission(\n submission: FormSubmission\n ): Promise<Record<string, unknown>> {\n this.formLogger.info(\n '🚀 FormAwareAgentExecutor.processFormSubmission called!',\n {\n submissionFormId: submission.formId,\n submissionToolName: submission.toolName,\n }\n );\n if (!submission) {\n throw new Error('Form submission is null or undefined');\n }\n\n if (!submission.formId) {\n throw new Error('Form submission missing formId');\n }\n\n if (\n !submission.parameters ||\n submission.parameters === null ||\n typeof submission.parameters !== 'object' ||\n Array.isArray(submission.parameters)\n ) {\n throw new Error(\n `Form submission parameters are invalid: ${typeof submission.parameters}, isNull: ${\n submission.parameters === null\n }, isArray: ${Array.isArray(\n submission.parameters\n )}, parameters: ${JSON.stringify(submission.parameters)}`\n );\n }\n\n this.formLogger.info('Processing form submission:', {\n formId: submission.formId,\n toolName: submission.toolName,\n parameterKeys: Object.keys(submission.parameters),\n parametersType: typeof submission.parameters,\n parametersIsNull: submission.parameters === null,\n parametersIsUndefined: submission.parameters === undefined,\n hasContext: !!submission.context,\n });\n\n let pendingForm = this.pendingForms.get(submission.formId);\n\n if (!pendingForm) {\n pendingForm = globalPendingForms.get(submission.formId);\n if (!pendingForm) {\n throw new Error(`No pending form found for ID: ${submission.formId}`);\n }\n }\n\n this.pendingForms.delete(submission.formId);\n globalPendingForms.delete(submission.formId);\n\n const tool =\n pendingForm.toolRef ||\n this.tools.find((t) => t.name === pendingForm.toolName);\n if (!tool) {\n throw new Error(\n `Tool not found for form submission: ${pendingForm.toolName}`\n );\n }\n\n let baseToolInput: Record<string, unknown> = {};\n try {\n if (\n pendingForm.originalToolInput &&\n typeof pendingForm.originalToolInput === 'object'\n ) {\n baseToolInput = {\n ...(pendingForm.originalToolInput as Record<string, unknown>),\n };\n }\n } catch (error) {\n this.formLogger.warn(\n 'Failed to extract base tool input, using empty object:',\n error\n );\n baseToolInput = {};\n }\n\n let submissionData: Record<string, unknown> = {};\n try {\n if (submission.parameters && typeof submission.parameters === 'object') {\n submissionData = {\n ...(submission.parameters as Record<string, unknown>),\n };\n }\n } catch (error) {\n this.formLogger.warn(\n 'Failed to extract submission parameters, using empty object:',\n error\n );\n submissionData = {};\n }\n\n const mergedToolInput: Record<string, unknown> = {};\n try {\n Object.keys(baseToolInput).forEach((key) => {\n const value = baseToolInput[key];\n if (value !== undefined && value !== null) {\n mergedToolInput[key] = value;\n }\n });\n\n Object.keys(submissionData).forEach((key) => {\n const value = submissionData[key];\n if (value !== undefined && value !== null) {\n mergedToolInput[key] = value;\n }\n });\n\n mergedToolInput.renderForm = false;\n mergedToolInput.__fromForm = true;\n\n this.formLogger.info('Successfully merged tool input:', {\n baseKeys: Object.keys(baseToolInput),\n submissionKeys: Object.keys(submissionData),\n mergedKeys: Object.keys(mergedToolInput),\n });\n } catch (error) {\n this.formLogger.error('Failed to merge tool input data:', error);\n throw new Error(\n `Failed to merge tool input data: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`\n );\n }\n\n try {\n const maybeWrapper = tool as ToolWrapper;\n let toolOutput: string;\n if (typeof maybeWrapper.executeOriginal === 'function') {\n toolOutput = await maybeWrapper.executeOriginal(mergedToolInput);\n } else if (typeof maybeWrapper.getOriginalTool === 'function') {\n const ot = maybeWrapper.getOriginalTool();\n const otCall = ot as CallableTool;\n if (ot && typeof otCall._call === 'function') {\n toolOutput = await otCall._call(mergedToolInput);\n } else if (ot && typeof otCall.call === 'function') {\n toolOutput = await otCall.call(mergedToolInput);\n } else {\n const tcall = tool as CallableTool;\n if (typeof tcall.call === 'function') {\n toolOutput = await tcall.call(mergedToolInput);\n } else {\n throw new Error(\n 'No callable tool implementation found for form submission'\n );\n }\n }\n } else if (\n maybeWrapper.originalTool &&\n typeof maybeWrapper.originalTool._call === 'function'\n ) {\n toolOutput = await maybeWrapper.originalTool._call(mergedToolInput);\n } else if (\n maybeWrapper.originalTool &&\n typeof maybeWrapper.originalTool.call === 'function'\n ) {\n toolOutput = await maybeWrapper.originalTool.call(mergedToolInput);\n } else if (typeof (tool as CallableTool).call === 'function') {\n toolOutput = await (tool as CallableTool).call!(mergedToolInput);\n } else {\n throw new Error(\n 'No callable tool implementation found for form submission'\n );\n }\n\n let responseMetadata: Record<string, unknown> = {};\n let formattedOutput: string;\n\n try {\n const parsed = JSON.parse(toolOutput);\n this.formLogger.info(\n '✅ METADATA EXTRACTION: Successfully parsed JSON',\n {\n jsonKeys: Object.keys(parsed),\n hasHashLinkBlock: !!(parsed as Record<string, unknown>)\n .hashLinkBlock,\n }\n );\n\n if (parsed && typeof parsed === 'object') {\n if (ResponseFormatter.isHashLinkResponse(parsed)) {\n this.formLogger.info(\n '🔗 HASHLINK DETECTED: Processing HashLink response separately to preserve metadata'\n );\n\n const parsedRecord = parsed as Record<string, unknown>;\n responseMetadata = {\n ...responseMetadata,\n hashLinkBlock: parsedRecord.hashLinkBlock,\n ...parsedRecord,\n };\n\n formattedOutput = ResponseFormatter.formatHashLinkResponse(parsed);\n\n this.formLogger.info(\n '🔗 METADATA PRESERVED: HashLink metadata extracted for component rendering',\n {\n blockId: this.hasHashLinkBlock(responseMetadata)\n ? responseMetadata.hashLinkBlock.blockId\n : undefined,\n hasTemplate: this.hasHashLinkBlock(responseMetadata)\n ? !!responseMetadata.hashLinkBlock.template\n : false,\n }\n );\n } else {\n formattedOutput = ResponseFormatter.formatResponse(toolOutput);\n\n responseMetadata = {\n ...responseMetadata,\n hashLinkBlock: (parsed as Record<string, unknown>).hashLinkBlock,\n ...parsed,\n };\n }\n } else {\n formattedOutput = ResponseFormatter.formatResponse(toolOutput);\n }\n } catch (error) {\n this.formLogger.warn(\n '❌ METADATA EXTRACTION: Tool output is not JSON',\n {\n error: error instanceof Error ? error.message : 'unknown error',\n outputSample:\n typeof toolOutput === 'string'\n ? toolOutput.substring(0, 200)\n : 'not-string',\n }\n );\n\n formattedOutput = ResponseFormatter.formatResponse(toolOutput);\n }\n\n return {\n output: formattedOutput,\n formCompleted: true,\n originalFormId: submission.formId,\n intermediateSteps: [],\n metadata: responseMetadata,\n rawToolOutput: toolOutput,\n toolName: pendingForm.toolName,\n };\n } catch (error) {\n if (error instanceof ZodError) {\n return this.handleValidationError(error, mergedToolInput, []);\n }\n throw error;\n }\n }\n\n /**\n * Extracts tool information from the execution context\n */\n private extractToolInfoFromError(\n error: ZodError,\n inputs: Record<string, unknown>,\n intermediateSteps: AgentStep[]\n ): { toolName: string; schema: unknown } | null {\n try {\n if (intermediateSteps.length > 0) {\n const lastStep = intermediateSteps[intermediateSteps.length - 1];\n if (lastStep.action && lastStep.action.tool) {\n const tool = this.tools.find((t) => t.name === lastStep.action.tool);\n if (tool && 'schema' in tool) {\n this.formLogger.info(\n 'Found tool from intermediate steps:',\n lastStep.action.tool\n );\n return {\n toolName: lastStep.action.tool,\n schema: (tool as ToolWithSchema).schema,\n };\n }\n }\n }\n\n const inputSteps = (inputs.intermediateSteps as unknown[]) || [];\n if (inputSteps.length > 0) {\n const lastStep = inputSteps[inputSteps.length - 1];\n let action: AgentAction;\n\n if (Array.isArray(lastStep) && lastStep.length > 0) {\n action = lastStep[0] as AgentAction;\n } else if ((lastStep as Record<string, unknown>).action) {\n action = (lastStep as Record<string, unknown>).action as AgentAction;\n } else {\n action = lastStep as AgentAction;\n }\n\n if (action && action.tool) {\n const tool = this.tools.find((t) => t.name === action.tool);\n if (tool && 'schema' in tool) {\n this.formLogger.info('Found tool from input steps:', action.tool);\n return {\n toolName: action.tool,\n schema: (tool as ToolWithSchema).schema,\n };\n }\n }\n }\n\n const toolFromContext = this.findToolFromContext(inputs);\n if (toolFromContext) {\n this.formLogger.info(\n 'Found tool from context:',\n toolFromContext.toolName\n );\n return toolFromContext;\n }\n\n return null;\n } catch (err) {\n this.formLogger.error('Error extracting tool info:', err);\n return null;\n }\n }\n\n /**\n * Attempts to find tool from execution context\n */\n private findToolFromContext(inputs: Record<string, unknown>): {\n toolName: string;\n schema: unknown;\n } | null {\n const inputText = (inputs.input as string) || '';\n\n for (const tool of this.tools) {\n const keywords = this.extractToolKeywords(tool.name);\n\n if (\n keywords.some((keyword) =>\n inputText.toLowerCase().includes(keyword.toLowerCase())\n )\n ) {\n if ('schema' in tool) {\n return {\n toolName: tool.name,\n schema: (tool as ToolWithSchema).schema,\n };\n }\n }\n }\n\n return null;\n }\n\n /**\n * Additional fallback to detect tool from error context\n */\n private detectToolFromErrorContext(\n error: ZodError\n ): { toolName: string; schema: unknown } | null {\n const errorPaths = error.issues.map((issue) => issue.path.join('.'));\n\n for (const tool of this.tools) {\n if ('schema' in tool) {\n const toolSchema = (tool as ToolWithSchema).schema;\n if (this.schemaMatchesErrorPaths(toolSchema, errorPaths)) {\n this.formLogger.info(\n 'Detected tool from error path analysis:',\n tool.name\n );\n return {\n toolName: tool.name,\n schema: toolSchema,\n };\n }\n }\n }\n\n return null;\n }\n\n /**\n * Checks if a schema structure matches error paths\n */\n private schemaMatchesErrorPaths(\n schema: unknown,\n errorPaths: string[]\n ): boolean {\n const schemaRecord = schema as Record<string, unknown>;\n if (!schemaRecord || !schemaRecord._def) return false;\n\n try {\n const def = schemaRecord._def as Record<string, unknown>;\n if (def.typeName === 'ZodObject') {\n const shape = def.shape as Record<string, unknown>;\n const schemaKeys = Object.keys(shape || {});\n return errorPaths.some((path) => {\n const topLevelKey = path.split('.')[0];\n return schemaKeys.includes(topLevelKey);\n });\n }\n } catch (err) {\n this.formLogger.debug('Error analyzing schema structure:', err);\n }\n\n return false;\n }\n\n /**\n * Extracts keywords from tool name for matching\n */\n private extractToolKeywords(toolName: string): string[] {\n const words = toolName\n .replace(/([A-Z])/g, ' $1')\n .toLowerCase()\n .split(/[\\s_-]+/)\n .filter((w) => w.length > 2);\n\n return [...words, toolName.toLowerCase()];\n }\n\n /**\n * Formats the form message for display\n */\n private formatFormResponse(formMessage: FormMessage): string {\n const fieldCount = formMessage.formConfig.fields.length;\n const fieldList = formMessage.formConfig.fields\n .slice(0, 3)\n .map((f) => `• ${f.label}`)\n .join('\\n');\n\n return `I need some additional information to complete your request.\n\n${formMessage.formConfig.description}\n\nRequired fields:\n${fieldList}${fieldCount > 3 ? `\\n... and ${fieldCount - 3} more` : ''}\n\nPlease fill out the form below to continue.`;\n }\n\n /**\n * Check if there are pending forms\n */\n hasPendingForms(): boolean {\n return this.pendingForms.size > 0;\n }\n\n /**\n * Get information about pending forms\n */\n getPendingFormsInfo(): Array<{ formId: string; toolName: string }> {\n return Array.from(this.pendingForms.entries()).map(([formId, info]) => ({\n formId,\n toolName: info.toolName,\n }));\n }\n\n\n /**\n * Processes HashLink block responses from tools\n */\n private processHashLinkResponse(\n toolResponse: ToolResponse\n ): HashLinkResponse {\n try {\n let hashLinkBlock: HashLinkBlock | undefined;\n\n if (toolResponse.hashLinkBlock) {\n hashLinkBlock = toolResponse.hashLinkBlock;\n } else if (toolResponse.success && toolResponse.hashLinkBlock) {\n hashLinkBlock = toolResponse.hashLinkBlock;\n }\n\n if (!hashLinkBlock) {\n throw new Error('HashLink block data not found in response');\n }\n\n if (\n !hashLinkBlock.blockId ||\n !hashLinkBlock.hashLink ||\n !hashLinkBlock.attributes\n ) {\n throw new Error(\n 'Invalid HashLink block structure - missing required fields'\n );\n }\n\n let message = 'Content processed successfully!';\n\n if (toolResponse.success && toolResponse.inscription) {\n const inscription = toolResponse.inscription;\n const metadata = toolResponse.metadata || {};\n\n message = `✅ ${inscription.standard} Hashinal inscription completed!\\n\\n`;\n\n if (metadata.name) {\n message += `**${metadata.name}**\\n`;\n }\n\n if (metadata.description) {\n message += `${metadata.description}\\n\\n`;\n }\n\n message += `📍 **Topic ID:** ${inscription.topicId}\\n`;\n message += `🔗 **HRL:** ${inscription.hrl}\\n`;\n\n if (inscription.cdnUrl) {\n message += `🌐 **CDN URL:** ${inscription.cdnUrl}\\n`;\n }\n\n if (metadata.creator) {\n message += `👤 **Creator:** ${metadata.creator}\\n`;\n }\n }\n\n this.formLogger.info('Processed HashLink response', {\n blockId: hashLinkBlock.blockId,\n hashLink: hashLinkBlock.hashLink,\n hasTemplate: !!hashLinkBlock.template,\n attributeCount: Object.keys(hashLinkBlock.attributes || {}).length,\n });\n\n return {\n hasHashLinkBlocks: true,\n hashLinkBlock,\n message,\n };\n } catch (error) {\n this.formLogger.error('Error processing HashLink response:', error);\n\n return {\n hasHashLinkBlocks: false,\n message: 'Content processed, but interactive display is not available.',\n };\n }\n }\n\n /**\n * Get FormEngine statistics for debugging\n */\n getFormEngineStatistics(): {\n strategies: string[];\n middleware: string[];\n } {\n return {\n strategies: this.formEngine.getRegisteredStrategies(),\n middleware: this.formEngine.getRegisteredMiddleware(),\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;AAgBA,MAAM,yCAAuD,IAAA;AA+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