@hashgraphonline/conversational-agent 0.2.216 → 0.2.218

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/cli/readme.md +181 -0
  2. package/dist/cjs/index.cjs +1 -1
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs/index.d.ts +1 -0
  5. package/dist/cjs/plugins/community/swarm/SwarmPlugin.d.ts +17 -0
  6. package/dist/cjs/plugins/community/swarm/__tests__/SwarmPlugin.mocks.d.ts +1 -0
  7. package/dist/cjs/plugins/community/swarm/__tests__/SwarmPlugin.test.d.ts +1 -0
  8. package/dist/cjs/plugins/community/swarm/__tests__/tools/CreatePostageStampTool.test.d.ts +1 -0
  9. package/dist/cjs/plugins/community/swarm/__tests__/tools/DownloadDataTool.test.d.ts +1 -0
  10. package/dist/cjs/plugins/community/swarm/__tests__/tools/DownloadFilesTool.test.d.ts +1 -0
  11. package/dist/cjs/plugins/community/swarm/__tests__/tools/ExtendPostageStampTool.test.d.ts +1 -0
  12. package/dist/cjs/plugins/community/swarm/__tests__/tools/GetPostageStampTool.test.d.ts +1 -0
  13. package/dist/cjs/plugins/community/swarm/__tests__/tools/ListPostageStampsTool.test.d.ts +1 -0
  14. package/dist/cjs/plugins/community/swarm/__tests__/tools/QueryUploadProgressTool.test.d.ts +1 -0
  15. package/dist/cjs/plugins/community/swarm/__tests__/tools/ReadFeedTool.test.d.ts +1 -0
  16. package/dist/cjs/plugins/community/swarm/__tests__/tools/SwarmTool.mocks.d.ts +14 -0
  17. package/dist/cjs/plugins/community/swarm/__tests__/tools/UpdateFeedTool.test.d.ts +1 -0
  18. package/dist/cjs/plugins/community/swarm/__tests__/tools/UploadDataTool.test.d.ts +1 -0
  19. package/dist/cjs/plugins/community/swarm/__tests__/tools/UploadFileTool.test.d.ts +1 -0
  20. package/dist/cjs/plugins/community/swarm/__tests__/tools/UploadFolderTool.test.d.ts +1 -0
  21. package/dist/cjs/plugins/community/swarm/config.d.ts +6 -0
  22. package/dist/cjs/plugins/community/swarm/constants.d.ts +8 -0
  23. package/dist/cjs/plugins/community/swarm/index.d.ts +2 -0
  24. package/dist/cjs/plugins/community/swarm/model.d.ts +23 -0
  25. package/dist/cjs/plugins/community/swarm/tools/CreatePostageStampTool.d.ts +47 -0
  26. package/dist/cjs/plugins/community/swarm/tools/DownloadDataTool.d.ts +35 -0
  27. package/dist/cjs/plugins/community/swarm/tools/DownloadFilesTool.d.ts +41 -0
  28. package/dist/cjs/plugins/community/swarm/tools/ExtendPostageStampTool.d.ts +47 -0
  29. package/dist/cjs/plugins/community/swarm/tools/GetPostageStampTool.d.ts +35 -0
  30. package/dist/cjs/plugins/community/swarm/tools/ListPostageStampsTool.d.ts +53 -0
  31. package/dist/cjs/plugins/community/swarm/tools/QueryUploadProgressTool.d.ts +35 -0
  32. package/dist/cjs/plugins/community/swarm/tools/ReadFeedTool.d.ts +41 -0
  33. package/dist/cjs/plugins/community/swarm/tools/UpdateFeedTool.d.ts +47 -0
  34. package/dist/cjs/plugins/community/swarm/tools/UploadDataTool.d.ts +47 -0
  35. package/dist/cjs/plugins/community/swarm/tools/UploadFileTool.d.ts +53 -0
  36. package/dist/cjs/plugins/community/swarm/tools/UploadFolderTool.d.ts +47 -0
  37. package/dist/cjs/plugins/community/swarm/utils.d.ts +22 -0
  38. package/dist/cjs/plugins/index.d.ts +1 -0
  39. package/dist/esm/index.js +33 -31
  40. package/dist/esm/index.js.map +1 -1
  41. package/dist/esm/index10.js +13 -677
  42. package/dist/esm/index10.js.map +1 -1
  43. package/dist/esm/index11.js +601 -234
  44. package/dist/esm/index11.js.map +1 -1
  45. package/dist/esm/index12.js +296 -136
  46. package/dist/esm/index12.js.map +1 -1
  47. package/dist/esm/index13.js +127 -235
  48. package/dist/esm/index13.js.map +1 -1
  49. package/dist/esm/index14.js +247 -84
  50. package/dist/esm/index14.js.map +1 -1
  51. package/dist/esm/index15.js +81 -159
  52. package/dist/esm/index15.js.map +1 -1
  53. package/dist/esm/index16.js +155 -229
  54. package/dist/esm/index16.js.map +1 -1
  55. package/dist/esm/index17.js +238 -140
  56. package/dist/esm/index17.js.map +1 -1
  57. package/dist/esm/index18.js +139 -493
  58. package/dist/esm/index18.js.map +1 -1
  59. package/dist/esm/index19.js +479 -91
  60. package/dist/esm/index19.js.map +1 -1
  61. package/dist/esm/index20.js +88 -147
  62. package/dist/esm/index20.js.map +1 -1
  63. package/dist/esm/index21.js +127 -666
  64. package/dist/esm/index21.js.map +1 -1
  65. package/dist/esm/index22.js +698 -44
  66. package/dist/esm/index22.js.map +1 -1
  67. package/dist/esm/index23.js +45 -304
  68. package/dist/esm/index23.js.map +1 -1
  69. package/dist/esm/index24.js +303 -153
  70. package/dist/esm/index24.js.map +1 -1
  71. package/dist/esm/index25.js +150 -117
  72. package/dist/esm/index25.js.map +1 -1
  73. package/dist/esm/index26.js +154 -18
  74. package/dist/esm/index26.js.map +1 -1
  75. package/dist/esm/index27.js +18 -22
  76. package/dist/esm/index27.js.map +1 -1
  77. package/dist/esm/index28.js +15 -74
  78. package/dist/esm/index28.js.map +1 -1
  79. package/dist/esm/index29.js +70 -295
  80. package/dist/esm/index29.js.map +1 -1
  81. package/dist/esm/index30.js +279 -100
  82. package/dist/esm/index30.js.map +1 -1
  83. package/dist/esm/index31.js +86 -922
  84. package/dist/esm/index31.js.map +1 -1
  85. package/dist/esm/index32.js +904 -189
  86. package/dist/esm/index32.js.map +1 -1
  87. package/dist/esm/index33.js +185 -1169
  88. package/dist/esm/index33.js.map +1 -1
  89. package/dist/esm/index34.js +1218 -112
  90. package/dist/esm/index34.js.map +1 -1
  91. package/dist/esm/index35.js +111 -99
  92. package/dist/esm/index35.js.map +1 -1
  93. package/dist/esm/index36.js +113 -8
  94. package/dist/esm/index36.js.map +1 -1
  95. package/dist/esm/index37.js +8 -45
  96. package/dist/esm/index37.js.map +1 -1
  97. package/dist/esm/index38.js +41 -102
  98. package/dist/esm/index38.js.map +1 -1
  99. package/dist/esm/index39.js +96 -55
  100. package/dist/esm/index39.js.map +1 -1
  101. package/dist/esm/index4.js +1 -1
  102. package/dist/esm/index40.js +58 -71
  103. package/dist/esm/index40.js.map +1 -1
  104. package/dist/esm/index41.js +79 -21
  105. package/dist/esm/index41.js.map +1 -1
  106. package/dist/esm/index42.js +21 -5
  107. package/dist/esm/index42.js.map +1 -1
  108. package/dist/esm/index43.js +26 -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 +66 -173
  113. package/dist/esm/index45.js.map +1 -1
  114. package/dist/esm/index46.js +69 -24
  115. package/dist/esm/index46.js.map +1 -1
  116. package/dist/esm/index47.js +47 -88
  117. package/dist/esm/index47.js.map +1 -1
  118. package/dist/esm/index48.js +100 -7
  119. package/dist/esm/index48.js.map +1 -1
  120. package/dist/esm/index49.js +79 -0
  121. package/dist/esm/index49.js.map +1 -0
  122. package/dist/esm/index5.js +2 -2
  123. package/dist/esm/index50.js +75 -0
  124. package/dist/esm/index50.js.map +1 -0
  125. package/dist/esm/index51.js +124 -0
  126. package/dist/esm/index51.js.map +1 -0
  127. package/dist/esm/index52.js +58 -0
  128. package/dist/esm/index52.js.map +1 -0
  129. package/dist/esm/index53.js +83 -0
  130. package/dist/esm/index53.js.map +1 -0
  131. package/dist/esm/index54.js +100 -0
  132. package/dist/esm/index54.js.map +1 -0
  133. package/dist/esm/index55.js +118 -0
  134. package/dist/esm/index55.js.map +1 -0
  135. package/dist/esm/index56.js +108 -0
  136. package/dist/esm/index56.js.map +1 -0
  137. package/dist/esm/index57.js +8 -0
  138. package/dist/esm/index57.js.map +1 -0
  139. package/dist/esm/index58.js +325 -0
  140. package/dist/esm/index58.js.map +1 -0
  141. package/dist/esm/index59.js +187 -0
  142. package/dist/esm/index59.js.map +1 -0
  143. package/dist/esm/index6.js +132 -833
  144. package/dist/esm/index6.js.map +1 -1
  145. package/dist/esm/index60.js +10 -0
  146. package/dist/esm/index60.js.map +1 -0
  147. package/dist/esm/index61.js +98 -0
  148. package/dist/esm/index61.js.map +1 -0
  149. package/dist/esm/index62.js +131 -0
  150. package/dist/esm/index62.js.map +1 -0
  151. package/dist/esm/index63.js +19 -0
  152. package/dist/esm/index63.js.map +1 -0
  153. package/dist/esm/index7.js +826 -75
  154. package/dist/esm/index7.js.map +1 -1
  155. package/dist/esm/index8.js +91 -13
  156. package/dist/esm/index8.js.map +1 -1
  157. package/dist/esm/index9.js +13 -17
  158. package/dist/esm/index9.js.map +1 -1
  159. package/dist/types/index.d.ts +1 -0
  160. package/dist/types/plugins/community/swarm/SwarmPlugin.d.ts +17 -0
  161. package/dist/types/plugins/community/swarm/__tests__/SwarmPlugin.mocks.d.ts +1 -0
  162. package/dist/types/plugins/community/swarm/__tests__/SwarmPlugin.test.d.ts +1 -0
  163. package/dist/types/plugins/community/swarm/__tests__/tools/CreatePostageStampTool.test.d.ts +1 -0
  164. package/dist/types/plugins/community/swarm/__tests__/tools/DownloadDataTool.test.d.ts +1 -0
  165. package/dist/types/plugins/community/swarm/__tests__/tools/DownloadFilesTool.test.d.ts +1 -0
  166. package/dist/types/plugins/community/swarm/__tests__/tools/ExtendPostageStampTool.test.d.ts +1 -0
  167. package/dist/types/plugins/community/swarm/__tests__/tools/GetPostageStampTool.test.d.ts +1 -0
  168. package/dist/types/plugins/community/swarm/__tests__/tools/ListPostageStampsTool.test.d.ts +1 -0
  169. package/dist/types/plugins/community/swarm/__tests__/tools/QueryUploadProgressTool.test.d.ts +1 -0
  170. package/dist/types/plugins/community/swarm/__tests__/tools/ReadFeedTool.test.d.ts +1 -0
  171. package/dist/types/plugins/community/swarm/__tests__/tools/SwarmTool.mocks.d.ts +14 -0
  172. package/dist/types/plugins/community/swarm/__tests__/tools/UpdateFeedTool.test.d.ts +1 -0
  173. package/dist/types/plugins/community/swarm/__tests__/tools/UploadDataTool.test.d.ts +1 -0
  174. package/dist/types/plugins/community/swarm/__tests__/tools/UploadFileTool.test.d.ts +1 -0
  175. package/dist/types/plugins/community/swarm/__tests__/tools/UploadFolderTool.test.d.ts +1 -0
  176. package/dist/types/plugins/community/swarm/config.d.ts +6 -0
  177. package/dist/types/plugins/community/swarm/constants.d.ts +8 -0
  178. package/dist/types/plugins/community/swarm/index.d.ts +2 -0
  179. package/dist/types/plugins/community/swarm/model.d.ts +23 -0
  180. package/dist/types/plugins/community/swarm/tools/CreatePostageStampTool.d.ts +47 -0
  181. package/dist/types/plugins/community/swarm/tools/DownloadDataTool.d.ts +35 -0
  182. package/dist/types/plugins/community/swarm/tools/DownloadFilesTool.d.ts +41 -0
  183. package/dist/types/plugins/community/swarm/tools/ExtendPostageStampTool.d.ts +47 -0
  184. package/dist/types/plugins/community/swarm/tools/GetPostageStampTool.d.ts +35 -0
  185. package/dist/types/plugins/community/swarm/tools/ListPostageStampsTool.d.ts +53 -0
  186. package/dist/types/plugins/community/swarm/tools/QueryUploadProgressTool.d.ts +35 -0
  187. package/dist/types/plugins/community/swarm/tools/ReadFeedTool.d.ts +41 -0
  188. package/dist/types/plugins/community/swarm/tools/UpdateFeedTool.d.ts +47 -0
  189. package/dist/types/plugins/community/swarm/tools/UploadDataTool.d.ts +47 -0
  190. package/dist/types/plugins/community/swarm/tools/UploadFileTool.d.ts +53 -0
  191. package/dist/types/plugins/community/swarm/tools/UploadFolderTool.d.ts +47 -0
  192. package/dist/types/plugins/community/swarm/utils.d.ts +22 -0
  193. package/dist/types/plugins/index.d.ts +1 -0
  194. package/package.json +37 -27
  195. package/src/index.ts +1 -0
  196. package/src/plugins/community/swarm/README.md +279 -0
  197. package/src/plugins/community/swarm/SwarmPlugin.ts +178 -0
  198. package/src/plugins/community/swarm/__tests__/SwarmPlugin.mocks.ts +105 -0
  199. package/src/plugins/community/swarm/__tests__/SwarmPlugin.test.ts +93 -0
  200. package/src/plugins/community/swarm/__tests__/tools/CreatePostageStampTool.test.ts +152 -0
  201. package/src/plugins/community/swarm/__tests__/tools/DownloadDataTool.test.ts +93 -0
  202. package/src/plugins/community/swarm/__tests__/tools/DownloadFilesTool.test.ts +163 -0
  203. package/src/plugins/community/swarm/__tests__/tools/ExtendPostageStampTool.test.ts +132 -0
  204. package/src/plugins/community/swarm/__tests__/tools/GetPostageStampTool.test.ts +83 -0
  205. package/src/plugins/community/swarm/__tests__/tools/ListPostageStampsTool.test.ts +219 -0
  206. package/src/plugins/community/swarm/__tests__/tools/QueryUploadProgressTool.test.ts +169 -0
  207. package/src/plugins/community/swarm/__tests__/tools/ReadFeedTool.test.ts +133 -0
  208. package/src/plugins/community/swarm/__tests__/tools/SwarmTool.mocks.ts +67 -0
  209. package/src/plugins/community/swarm/__tests__/tools/UpdateFeedTool.test.ts +148 -0
  210. package/src/plugins/community/swarm/__tests__/tools/UploadDataTool.test.ts +125 -0
  211. package/src/plugins/community/swarm/__tests__/tools/UploadFileTool.test.ts +194 -0
  212. package/src/plugins/community/swarm/__tests__/tools/UploadFolderTool.test.ts +118 -0
  213. package/src/plugins/community/swarm/config.ts +6 -0
  214. package/src/plugins/community/swarm/constants.ts +12 -0
  215. package/src/plugins/community/swarm/index.ts +2 -0
  216. package/src/plugins/community/swarm/model.ts +23 -0
  217. package/src/plugins/community/swarm/tools/CreatePostageStampTool.ts +137 -0
  218. package/src/plugins/community/swarm/tools/DownloadDataTool.ts +79 -0
  219. package/src/plugins/community/swarm/tools/DownloadFilesTool.ts +155 -0
  220. package/src/plugins/community/swarm/tools/ExtendPostageStampTool.ts +112 -0
  221. package/src/plugins/community/swarm/tools/GetPostageStampTool.ts +92 -0
  222. package/src/plugins/community/swarm/tools/ListPostageStampsTool.ts +124 -0
  223. package/src/plugins/community/swarm/tools/QueryUploadProgressTool.ts +109 -0
  224. package/src/plugins/community/swarm/tools/ReadFeedTool.ts +110 -0
  225. package/src/plugins/community/swarm/tools/UpdateFeedTool.ts +149 -0
  226. package/src/plugins/community/swarm/tools/UploadDataTool.ts +109 -0
  227. package/src/plugins/community/swarm/tools/UploadFileTool.ts +163 -0
  228. package/src/plugins/community/swarm/tools/UploadFolderTool.ts +150 -0
  229. package/src/plugins/community/swarm/utils.ts +172 -0
  230. package/src/plugins/index.ts +1 -0
  231. package/cli/dist/CLIApp.d.ts +0 -11
  232. package/cli/dist/CLIApp.d.ts.map +0 -1
  233. package/cli/dist/CLIApp.js +0 -128
  234. package/cli/dist/CLIApp.js.map +0 -1
  235. package/cli/dist/LocalConversationalAgent.d.ts +0 -37
  236. package/cli/dist/LocalConversationalAgent.js +0 -58
  237. package/cli/dist/app.d.ts +0 -18
  238. package/cli/dist/app.d.ts.map +0 -1
  239. package/cli/dist/app.js +0 -14
  240. package/cli/dist/app.js.map +0 -1
  241. package/cli/dist/cli.d.ts +0 -3
  242. package/cli/dist/cli.d.ts.map +0 -1
  243. package/cli/dist/cli.js +0 -87
  244. package/cli/dist/cli.js.map +0 -1
  245. package/cli/dist/components/AppContainer.d.ts +0 -16
  246. package/cli/dist/components/AppContainer.js +0 -24
  247. package/cli/dist/components/AppScreens.d.ts +0 -2
  248. package/cli/dist/components/AppScreens.js +0 -259
  249. package/cli/dist/components/ChatScreen.d.ts +0 -21
  250. package/cli/dist/components/ChatScreen.d.ts.map +0 -1
  251. package/cli/dist/components/ChatScreen.js +0 -40
  252. package/cli/dist/components/ChatScreen.js.map +0 -1
  253. package/cli/dist/components/DebugLoadingScreen.d.ts +0 -5
  254. package/cli/dist/components/DebugLoadingScreen.js +0 -31
  255. package/cli/dist/components/LoadingScreen.d.ts +0 -3
  256. package/cli/dist/components/LoadingScreen.d.ts.map +0 -1
  257. package/cli/dist/components/LoadingScreen.js +0 -17
  258. package/cli/dist/components/LoadingScreen.js.map +0 -1
  259. package/cli/dist/components/LoadingScreenDebug.d.ts +0 -5
  260. package/cli/dist/components/LoadingScreenDebug.js +0 -27
  261. package/cli/dist/components/MCPConfigScreen.d.ts +0 -28
  262. package/cli/dist/components/MCPConfigScreen.d.ts.map +0 -1
  263. package/cli/dist/components/MCPConfigScreen.js +0 -186
  264. package/cli/dist/components/MCPConfigScreen.js.map +0 -1
  265. package/cli/dist/components/ScreenRouter.d.ts +0 -13
  266. package/cli/dist/components/ScreenRouter.d.ts.map +0 -1
  267. package/cli/dist/components/ScreenRouter.js +0 -23
  268. package/cli/dist/components/ScreenRouter.js.map +0 -1
  269. package/cli/dist/components/SetupScreen.d.ts +0 -16
  270. package/cli/dist/components/SetupScreen.d.ts.map +0 -1
  271. package/cli/dist/components/SetupScreen.js +0 -67
  272. package/cli/dist/components/SetupScreen.js.map +0 -1
  273. package/cli/dist/components/SingleLoadingScreen.d.ts +0 -5
  274. package/cli/dist/components/SingleLoadingScreen.js +0 -27
  275. package/cli/dist/components/StatusBadge.d.ts +0 -10
  276. package/cli/dist/components/StatusBadge.d.ts.map +0 -1
  277. package/cli/dist/components/StatusBadge.js +0 -24
  278. package/cli/dist/components/StatusBadge.js.map +0 -1
  279. package/cli/dist/components/TerminalWindow.d.ts +0 -9
  280. package/cli/dist/components/TerminalWindow.d.ts.map +0 -1
  281. package/cli/dist/components/TerminalWindow.js +0 -19
  282. package/cli/dist/components/TerminalWindow.js.map +0 -1
  283. package/cli/dist/components/WelcomeScreen.d.ts +0 -12
  284. package/cli/dist/components/WelcomeScreen.d.ts.map +0 -1
  285. package/cli/dist/components/WelcomeScreen.js +0 -47
  286. package/cli/dist/components/WelcomeScreen.js.map +0 -1
  287. package/cli/dist/context/AppContext.d.ts +0 -68
  288. package/cli/dist/context/AppContext.js +0 -363
  289. package/cli/dist/headless-runner.d.ts +0 -17
  290. package/cli/dist/headless-runner.d.ts.map +0 -1
  291. package/cli/dist/headless-runner.js +0 -128
  292. package/cli/dist/headless-runner.js.map +0 -1
  293. package/cli/dist/hooks/useInitializeAgent.d.ts +0 -19
  294. package/cli/dist/hooks/useInitializeAgent.d.ts.map +0 -1
  295. package/cli/dist/hooks/useInitializeAgent.js +0 -29
  296. package/cli/dist/hooks/useInitializeAgent.js.map +0 -1
  297. package/cli/dist/hooks/useStableState.d.ts +0 -38
  298. package/cli/dist/hooks/useStableState.d.ts.map +0 -1
  299. package/cli/dist/hooks/useStableState.js +0 -69
  300. package/cli/dist/hooks/useStableState.js.map +0 -1
  301. package/cli/dist/managers/AgentManager.d.ts +0 -58
  302. package/cli/dist/managers/AgentManager.d.ts.map +0 -1
  303. package/cli/dist/managers/AgentManager.js +0 -121
  304. package/cli/dist/managers/AgentManager.js.map +0 -1
  305. package/cli/dist/managers/ConfigManager.d.ts +0 -54
  306. package/cli/dist/managers/ConfigManager.d.ts.map +0 -1
  307. package/cli/dist/managers/ConfigManager.js +0 -188
  308. package/cli/dist/managers/ConfigManager.js.map +0 -1
  309. package/cli/dist/types.d.ts +0 -52
  310. package/cli/dist/types.d.ts.map +0 -1
  311. package/cli/dist/types.js +0 -34
  312. package/cli/dist/types.js.map +0 -1
@@ -1,686 +1,22 @@
1
- import { zodToJsonSchema } from "zod-to-json-schema";
2
- import { extractRenderConfigs, generateFieldOrdering } from "@hashgraphonline/standards-agent-kit";
3
- import { Logger } from "@hashgraphonline/standards-sdk";
4
- import { fieldTypeRegistry } from "./index12.js";
5
- import { fieldGuidanceRegistry } from "./index13.js";
6
- import "./index43.js";
7
- import { FIELD_PRIORITIES } from "./index48.js";
8
- function isZodObjectSchema(schema) {
9
- return typeof schema === "object" && schema !== null && "shape" in schema;
10
- }
11
- class FormGenerator {
12
- constructor() {
13
- this.logger = new Logger({ module: "FormGenerator" });
14
- }
15
- /**
16
- * Creates a form message from a Zod validation error
17
- * @param error The Zod validation error
18
- * @param schema The original Zod schema
19
- * @param toolName Name of the tool that failed validation
20
- * @param originalPrompt The user's original request
21
- * @returns FormMessage to send to the chat UI
22
- */
23
- generateFormFromError(error, schema, toolName, originalPrompt) {
24
- const validationErrors = this.extractValidationErrors(error);
25
- const missingFields = this.identifyMissingFields(validationErrors, schema);
26
- const formConfig = this.createFormConfig(schema, missingFields, toolName);
27
- return {
28
- type: "form",
29
- id: `form_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
30
- formConfig,
31
- originalPrompt,
32
- toolName,
33
- validationErrors
34
- };
35
- }
36
- /**
37
- * Generates a form from a schema and partial input
38
- * @param schema The Zod schema to generate a form from
39
- * @param partialInput Any partial input already provided
40
- * @param context Additional context about the tool
41
- * @param preCalculatedMissingFields Optional pre-calculated missing fields set. If undefined, includes all fields from schema.
42
- * @returns FormMessage to send to the chat UI
43
- */
44
- async generateFormFromSchema(schema, partialInput, context, preCalculatedMissingFields) {
45
- let missingFields;
46
- this.logger.info(`🏁 FormGenerator.generateFormFromSchema starting`, {
47
- toolName: context.toolName,
48
- partialInput,
49
- hasSchema: !!schema,
50
- hasShape: !!(schema && isZodObjectSchema(schema)),
51
- hasPreCalculatedFields: preCalculatedMissingFields !== void 0,
52
- preCalculatedFieldsSize: preCalculatedMissingFields?.size || 0
53
- });
54
- if (preCalculatedMissingFields !== void 0) {
55
- missingFields = preCalculatedMissingFields;
56
- this.logger.info(`📋 Using pre-calculated missing fields`, {
57
- missingFieldsCount: missingFields.size,
58
- missingFields: Array.from(missingFields)
59
- });
60
- } else {
61
- missingFields = /* @__PURE__ */ new Set();
62
- const zodObject = this.extractZodObject(schema);
63
- if (zodObject) {
64
- const shape = zodObject.shape;
65
- for (const fieldName of Object.keys(shape)) {
66
- missingFields.add(fieldName);
67
- this.logger.info(
68
- `⭐ Including all fields from focused schema: ${fieldName}`
69
- );
70
- }
71
- }
72
- this.logger.info(`📋 Using ALL fields from focused schema`, {
73
- totalFields: zodObject ? Object.keys(zodObject.shape).length : 0,
74
- missingFieldsCount: missingFields.size,
75
- missingFields: Array.from(missingFields)
76
- });
77
- }
78
- const formConfig = this.createFormConfig(
79
- schema,
80
- missingFields,
81
- context.toolName,
82
- preCalculatedMissingFields
83
- );
84
- return {
85
- type: "form",
86
- id: `form_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
87
- formConfig,
88
- originalPrompt: context.toolDescription || `Complete ${context.toolName}`,
89
- toolName: context.toolName,
90
- validationErrors: []
91
- };
92
- }
93
- /**
94
- * Extracts validation errors from ZodError
95
- */
96
- extractValidationErrors(error) {
97
- return error.issues.map((issue) => ({
98
- path: issue.path.map((p) => String(p)),
99
- message: issue.message,
100
- code: issue.code
101
- }));
102
- }
103
- /**
104
- * Identifies which fields are missing or invalid from validation errors
105
- */
106
- identifyMissingFields(errors, _schema) {
107
- const missingFields = /* @__PURE__ */ new Set();
108
- errors.forEach((error) => {
109
- const fieldPath = error.path.join(".");
110
- if (fieldPath) {
111
- missingFields.add(fieldPath);
112
- }
113
- });
114
- return missingFields;
115
- }
116
- /**
117
- * Creates form configuration from schema
118
- */
119
- createFormConfig(schema, missingFields, toolName, preCalculatedMissingFields) {
120
- const extractedConfig = this.extractRenderConfigsSafely(schema);
121
- const fieldOrdering = this.generateFieldOrderingSafely(schema);
122
- const fields = this.generateFormFields(
123
- schema,
124
- extractedConfig,
125
- missingFields,
126
- fieldOrdering,
127
- preCalculatedMissingFields,
128
- toolName
129
- );
130
- const globalGuidance = fieldGuidanceRegistry.getGlobalGuidance(toolName);
131
- let description = this.generateFormDescription(
132
- toolName,
133
- missingFields.size
134
- );
135
- if (globalGuidance?.qualityStandards) {
136
- description += "\n\nQuality Guidelines:\n" + globalGuidance.qualityStandards.map((standard) => `• ${standard}`).join("\n");
137
- }
138
- return {
139
- title: this.generateFormTitle(toolName),
140
- description,
141
- fields,
142
- submitLabel: "Continue",
143
- cancelLabel: "Cancel",
144
- metadata: {
145
- toolName,
146
- missingFieldCount: missingFields.size,
147
- globalGuidance
148
- }
149
- };
150
- }
151
- /**
152
- * Safely extracts render configs from schema
153
- */
154
- extractRenderConfigsSafely(schema) {
155
- try {
156
- if (typeof extractRenderConfigs === "function") {
157
- return extractRenderConfigs(schema);
158
- }
159
- } catch (error) {
160
- this.logger.warn("Could not extract render configs:", error);
161
- }
162
- return {
163
- fields: {},
164
- groups: {},
165
- order: [],
166
- metadata: {}
167
- };
168
- }
169
- /**
170
- * Safely generates field ordering from schema
171
- */
172
- generateFieldOrderingSafely(schema) {
173
- try {
174
- if (typeof generateFieldOrdering === "function") {
175
- const ordering = generateFieldOrdering(
176
- schema
177
- );
178
- const sections = Object.values(ordering.sections).map((section) => ({
179
- fields: section.fields
180
- }));
181
- return { sections };
182
- }
183
- } catch (error) {
184
- this.logger.warn("Could not generate field ordering:", error);
185
- }
186
- return { sections: [] };
1
+ class LangChainProvider {
2
+ constructor(model) {
3
+ this.model = model;
187
4
  }
188
- /**
189
- * Determines field priority for progressive disclosure
190
- */
191
- getFieldPriority(name, renderConfig, isRequired) {
192
- if (renderConfig?.ui?.priority) {
193
- const priority = renderConfig.ui.priority;
194
- if (Object.values(FIELD_PRIORITIES).includes(priority)) {
195
- return priority;
196
- }
197
- }
198
- if (isRequired === true) {
199
- return FIELD_PRIORITIES.ESSENTIAL;
200
- }
201
- const ui = renderConfig?.ui;
202
- if (ui?.advanced === true) {
203
- return FIELD_PRIORITIES.ADVANCED;
204
- }
205
- if (ui?.expert === true) {
206
- return FIELD_PRIORITIES.EXPERT;
207
- }
208
- return FIELD_PRIORITIES.COMMON;
209
- }
210
- /**
211
- * Determines which fields should be included in the form
212
- */
213
- determineFieldsToInclude(schema, missingFields, preCalculatedMissingFields) {
214
- const fieldsToInclude = /* @__PURE__ */ new Set();
215
- if (preCalculatedMissingFields === void 0) {
216
- this.logger.info(
217
- `⭐ Focused schema mode - including ALL fields from schema`
218
- );
219
- const allSchemaFields = this.extractFieldsFromSchema(schema);
220
- allSchemaFields.forEach((fieldName) => {
221
- fieldsToInclude.add(fieldName);
222
- this.logger.info(`✅ Including focused schema field: ${fieldName}`);
223
- });
224
- } else if (preCalculatedMissingFields.size > 0) {
225
- this.logger.info(
226
- `📋 Using ONLY pre-calculated missing fields (${preCalculatedMissingFields.size} fields)`,
227
- { fields: Array.from(preCalculatedMissingFields) }
228
- );
229
- preCalculatedMissingFields.forEach((fieldName) => {
230
- fieldsToInclude.add(fieldName);
231
- this.logger.info(`✅ Including pre-calculated field: ${fieldName}`);
232
- });
233
- } else {
234
- this.logger.info(
235
- "⚠️ No pre-calculated fields, falling back to schema analysis"
236
- );
237
- this.includeRequiredMissingFields(schema, missingFields, fieldsToInclude);
238
- }
239
- return fieldsToInclude;
5
+ async generate(prompt, options) {
6
+ const result = await this.model.invoke(prompt, options);
7
+ return typeof result === "string" ? result : result.toString();
240
8
  }
241
- /**
242
- * Includes required fields that are missing
243
- */
244
- includeRequiredMissingFields(schema, missingFields, fieldsToInclude) {
245
- const allSchemaFields = this.extractFieldsFromSchema(schema);
246
- allSchemaFields.forEach((fieldName) => {
247
- const isRequired = this.isFieldRequired(schema, fieldName);
248
- const isMissing = missingFields.has(fieldName);
249
- const shouldInclude = isMissing && isRequired;
250
- this.logger.info(`🔍 FormGenerator field inclusion check: ${fieldName}`, {
251
- isRequired,
252
- isMissing,
253
- shouldInclude
254
- });
255
- if (shouldInclude) {
256
- fieldsToInclude.add(fieldName);
257
- }
258
- });
259
- }
260
- /**
261
- * Creates form fields from ordered field names
262
- */
263
- createOrderedFields(fieldsToInclude, fieldOrdering, extractedConfig, schema, toolName) {
264
- const fields = [];
265
- const processedFields = /* @__PURE__ */ new Set();
266
- if (fieldOrdering.sections.length > 0) {
267
- const orderedFieldNames = fieldOrdering.sections.flatMap((s) => s.fields);
268
- orderedFieldNames.forEach((fieldName) => {
269
- if (fieldsToInclude.has(fieldName) && !processedFields.has(fieldName)) {
270
- const field = this.createFormField(
271
- fieldName,
272
- extractedConfig.fields[fieldName],
273
- schema,
274
- fieldName,
275
- toolName
276
- );
277
- if (field) {
278
- fields.push(field);
279
- processedFields.add(fieldName);
280
- }
281
- }
282
- });
283
- }
284
- fieldsToInclude.forEach((fieldName) => {
285
- if (!processedFields.has(fieldName)) {
286
- const field = this.createFormField(
287
- fieldName,
288
- extractedConfig.fields[fieldName],
289
- schema,
290
- fieldName,
291
- toolName
292
- );
293
- if (field) {
294
- fields.push(field);
295
- }
296
- }
297
- });
298
- return fields;
299
- }
300
- /**
301
- * Generates form fields from schema and validation errors
302
- */
303
- generateFormFields(schema, extractedConfig, missingFields, fieldOrdering, preCalculatedMissingFields, toolName) {
304
- const fieldsToInclude = this.determineFieldsToInclude(
305
- schema,
306
- missingFields,
307
- preCalculatedMissingFields
308
- );
309
- let fields = this.createOrderedFields(
310
- fieldsToInclude,
311
- fieldOrdering,
312
- extractedConfig,
313
- schema,
314
- toolName
315
- );
316
- if (fields.length === 0 && missingFields.size > 0) {
317
- fields = Array.from(missingFields).map(
318
- (fieldName) => this.createFormField(
319
- fieldName,
320
- extractedConfig.fields[fieldName],
321
- schema,
322
- fieldName,
323
- toolName
324
- )
325
- ).filter(
326
- (field) => field !== null && field !== void 0
327
- );
9
+ async *stream(prompt, options) {
10
+ const stream = await this.model.stream(prompt, options);
11
+ for await (const chunk of stream) {
12
+ yield typeof chunk === "string" ? chunk : chunk.toString();
328
13
  }
329
- return fields;
330
14
  }
331
- /**
332
- * Creates a single form field
333
- */
334
- createFormField(fieldName, renderConfig, schema, fieldPath, toolName) {
335
- const type = this.mapFieldType(renderConfig?.fieldType, schema, fieldPath);
336
- const isRequired = this.isFieldRequired(schema, fieldPath || fieldName);
337
- const guidance = toolName ? fieldGuidanceRegistry.getFieldGuidance(toolName, fieldName) : null;
338
- const finalType = guidance?.fieldTypeOverride || type;
339
- const field = {
340
- name: fieldName,
341
- label: renderConfig?.ui?.label || this.humanizeFieldName(fieldName),
342
- type: finalType,
343
- required: isRequired,
344
- priority: this.getFieldPriority(fieldName, renderConfig, isRequired)
345
- };
346
- if (guidance) {
347
- if (guidance.suggestions && guidance.suggestions.length > 0) {
348
- field.suggestions = guidance.suggestions;
349
- if (!field.placeholder) {
350
- field.placeholder = `e.g., ${guidance.suggestions[0]}`;
351
- }
352
- }
353
- if (guidance.predefinedOptions) {
354
- field.options = [
355
- ...field.options || [],
356
- ...guidance.predefinedOptions
357
- ];
358
- }
359
- if (guidance.contextualHelpText) {
360
- field.helpText = guidance.contextualHelpText;
361
- }
362
- if (guidance.warnings) {
363
- field.warnings = guidance.warnings.map((w) => w.message);
364
- }
365
- if (guidance.validationRules) {
366
- const { qualityChecks } = guidance.validationRules;
367
- if (qualityChecks) {
368
- field.contextualGuidance = {
369
- qualityStandards: [],
370
- examples: guidance.suggestions || [],
371
- avoidPatterns: qualityChecks.forbidTechnicalTerms || []
372
- };
373
- if (qualityChecks.minNonTechnicalWords) {
374
- field.contextualGuidance.qualityStandards?.push(
375
- `Use at least ${qualityChecks.minNonTechnicalWords} meaningful words`
376
- );
377
- }
378
- if (qualityChecks.forbidTechnicalTerms) {
379
- field.contextualGuidance.qualityStandards?.push(
380
- `Avoid technical terms like: ${qualityChecks.forbidTechnicalTerms.join(
381
- ", "
382
- )}`
383
- );
384
- }
385
- }
386
- }
387
- }
388
- if (renderConfig) {
389
- field.renderConfig = renderConfig;
390
- }
391
- if (renderConfig?.ui?.placeholder) {
392
- field.placeholder = renderConfig.ui.placeholder;
393
- }
394
- if (renderConfig?.ui?.helpText) {
395
- field.helpText = renderConfig.ui.helpText;
396
- }
397
- if (renderConfig?.constraints) {
398
- const validation = {};
399
- if (renderConfig.constraints.min !== void 0)
400
- validation.min = renderConfig.constraints.min;
401
- if (renderConfig.constraints.max !== void 0)
402
- validation.max = renderConfig.constraints.max;
403
- if (renderConfig.constraints.minLength !== void 0)
404
- validation.minLength = renderConfig.constraints.minLength;
405
- if (renderConfig.constraints.maxLength !== void 0)
406
- validation.maxLength = renderConfig.constraints.maxLength;
407
- if (renderConfig.constraints.pattern !== void 0)
408
- validation.pattern = renderConfig.constraints.pattern;
409
- if (Object.keys(validation).length > 0) {
410
- field.validation = validation;
411
- }
412
- }
413
- if (renderConfig?.options) {
414
- field.options = renderConfig.options.map((opt) => ({
415
- value: String(opt.value),
416
- label: opt.label,
417
- ...opt.disabled !== void 0 && { disabled: opt.disabled }
418
- }));
419
- }
420
- return field;
421
- }
422
- /**
423
- * Maps render config field type to form field type with fallback inference
424
- */
425
- mapFieldType(fieldType, schema, fieldPath) {
426
- if (!fieldType && schema && fieldPath) {
427
- const inferredType = this.inferTypeFromSchema(schema, fieldPath);
428
- if (inferredType) {
429
- return inferredType;
430
- }
431
- }
432
- if (!fieldType && fieldPath) {
433
- const registryType = fieldTypeRegistry.detectType(fieldPath);
434
- if (registryType) {
435
- return registryType;
436
- }
437
- }
438
- if (!fieldType) {
439
- return "text";
440
- }
441
- const normalizedType = fieldType.toLowerCase();
442
- if (["text", "string"].includes(normalizedType)) return "text";
443
- if (["number", "integer", "float", "decimal"].includes(normalizedType))
444
- return "number";
445
- if (["select", "enum", "dropdown"].includes(normalizedType))
446
- return "select";
447
- if (["checkbox", "boolean", "bool"].includes(normalizedType))
448
- return "checkbox";
449
- if (["textarea", "longtext", "multiline"].includes(normalizedType))
450
- return "textarea";
451
- if (["file", "upload", "attachment"].includes(normalizedType))
452
- return "file";
453
- if (["array", "list"].includes(normalizedType)) return "array";
454
- if (["object", "json"].includes(normalizedType)) return "object";
455
- if (["currency", "money", "price"].includes(normalizedType))
456
- return "currency";
457
- if (["percentage", "percent"].includes(normalizedType)) return "percentage";
458
- return "text";
459
- }
460
- /**
461
- * Converts field name to human-readable label
462
- */
463
- humanizeFieldName(fieldName) {
464
- return fieldName.replace(/([A-Z])/g, " $1").replace(/_/g, " ").replace(/\./g, " ").trim().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
465
- }
466
- /**
467
- * Generates a title for the form
468
- */
469
- generateFormTitle(toolName) {
470
- const cleanName = toolName.replace(/Tool$/, "").replace(/Hedera/g, "").replace(/([A-Z])/g, " $1").trim();
471
- return `Complete ${cleanName} Information`;
472
- }
473
- /**
474
- * Safely extracts ZodObject from a schema, returns null if not an object schema
475
- */
476
- extractZodObject(schema) {
477
- try {
478
- const def = schema._def;
479
- if (def && def.typeName === "ZodObject") {
480
- return schema;
481
- }
482
- } catch (error) {
483
- this.logger.debug("Could not extract ZodObject from schema:", error);
484
- }
485
- return null;
486
- }
487
- /**
488
- * Extracts field names from Zod schema structure
489
- */
490
- extractFieldsFromSchema(schema) {
491
- const fields = [];
492
- const zodObject = this.extractZodObject(schema);
493
- if (zodObject) {
494
- fields.push(...Object.keys(zodObject.shape));
495
- return fields;
496
- }
497
- try {
498
- const def = schema._def;
499
- if (def && def.typeName === "ZodUnion" && def.options) {
500
- const firstOption = def.options[0];
501
- const firstOptionObject = this.extractZodObject(firstOption);
502
- if (firstOptionObject) {
503
- fields.push(...Object.keys(firstOptionObject.shape));
504
- }
505
- }
506
- } catch (error) {
507
- this.logger.debug(
508
- "Could not extract fields from schema structure:",
509
- error
510
- );
511
- }
512
- return fields;
513
- }
514
- /**
515
- * Infers field type from Zod schema
516
- */
517
- inferTypeFromSchema(schema, fieldPath) {
518
- try {
519
- const zodObject = this.extractZodObject(schema);
520
- if (!zodObject) return null;
521
- const shape = zodObject.shape;
522
- if (!shape) return null;
523
- let fieldSchema = shape[fieldPath];
524
- if (!fieldSchema) return null;
525
- const fieldDef = fieldSchema._def;
526
- if (fieldDef && fieldDef.typeName === "ZodOptional" && fieldDef.innerType) {
527
- fieldSchema = fieldDef.innerType;
528
- }
529
- if (!fieldSchema || !fieldSchema._def) return null;
530
- const typeDef = fieldSchema._def;
531
- const fieldTypeName = typeDef.typeName;
532
- const lowerPath = fieldPath.toLowerCase();
533
- switch (fieldTypeName) {
534
- case "ZodString":
535
- if (lowerPath.includes("memo") || lowerPath.includes("description")) {
536
- return "textarea";
537
- }
538
- return "text";
539
- case "ZodNumber":
540
- if (lowerPath.includes("percent")) {
541
- return "percentage";
542
- }
543
- if (lowerPath.includes("price") || lowerPath.includes("cost")) {
544
- return "currency";
545
- }
546
- return "number";
547
- case "ZodBoolean":
548
- return "checkbox";
549
- case "ZodEnum":
550
- case "ZodNativeEnum":
551
- return "select";
552
- case "ZodArray":
553
- return "array";
554
- case "ZodObject":
555
- return "object";
556
- default:
557
- return "text";
558
- }
559
- } catch (error) {
560
- this.logger.debug("Could not infer type from schema:", error);
561
- }
562
- return null;
563
- }
564
- /**
565
- * Determines if a field is required based on the Zod schema
566
- */
567
- isFieldRequired(schema, fieldPath) {
568
- if (!schema || !fieldPath) {
569
- return false;
570
- }
571
- try {
572
- const zodObject = this.extractZodObject(schema);
573
- if (!zodObject) return false;
574
- const shape = zodObject.shape;
575
- if (!shape || !shape[fieldPath]) return false;
576
- const fieldSchema = shape[fieldPath];
577
- if (!fieldSchema || !fieldSchema._def) return true;
578
- const fieldDef = fieldSchema._def;
579
- const typeName = fieldDef.typeName;
580
- if (typeName === "ZodOptional") {
581
- return false;
582
- }
583
- if (typeName === "ZodDefault") {
584
- return false;
585
- }
586
- if (fieldDef.defaultValue !== void 0) {
587
- return false;
588
- }
589
- return true;
590
- } catch (error) {
591
- this.logger.debug(
592
- `Could not determine if field ${fieldPath} is required:`,
593
- error
594
- );
595
- }
596
- return false;
597
- }
598
- /**
599
- * Generates a description for the form
600
- */
601
- generateFormDescription(toolName, fieldCount) {
602
- if (fieldCount === 0) {
603
- return "Please provide the required information to continue with your request.";
604
- }
605
- return `Please provide the following ${fieldCount} required field${fieldCount !== 1 ? "s" : ""} to continue with your request.`;
606
- }
607
- /**
608
- * Generates JSON Schema and uiSchema from a Zod schema for use with @rjsf/core
609
- * @param zodSchema The Zod schema to convert
610
- * @param partialInput Existing input data to filter out fields that already have values
611
- * @param missingFields Set of fields that are missing and should be shown
612
- * @returns Object containing jsonSchema and uiSchema
613
- */
614
- generateJsonSchemaForm(zodSchema, partialInput, missingFields) {
615
- const fullJsonSchema = zodToJsonSchema(zodSchema, {
616
- target: "jsonSchema7"
617
- });
618
- const uiSchema = {};
619
- let jsonSchema = fullJsonSchema;
620
- if (missingFields && missingFields.size > 0) {
621
- const fullSchemaAsObject = fullJsonSchema;
622
- if (fullSchemaAsObject.properties && typeof fullSchemaAsObject.properties === "object") {
623
- const filteredSchema = {
624
- ...fullSchemaAsObject,
625
- type: "object",
626
- properties: {},
627
- required: []
628
- };
629
- let fieldsAdded = 0;
630
- missingFields.forEach((fieldName) => {
631
- if (fullSchemaAsObject.properties && fullSchemaAsObject.properties[fieldName]) {
632
- filteredSchema.properties[fieldName] = fullSchemaAsObject.properties[fieldName];
633
- fieldsAdded++;
634
- }
635
- });
636
- if (Array.isArray(fullSchemaAsObject.required)) {
637
- filteredSchema.required = fullSchemaAsObject.required.filter(
638
- (field) => missingFields.has(field)
639
- );
640
- }
641
- if (fieldsAdded > 0) {
642
- jsonSchema = filteredSchema;
643
- }
644
- }
645
- }
646
- const fieldNames = this.extractFieldsFromSchema(zodSchema);
647
- fieldNames.forEach((fieldName) => {
648
- const isRequired = this.isFieldRequired(zodSchema, fieldName);
649
- const priority = this.getFieldPriority(fieldName, void 0, isRequired);
650
- const lower = fieldName.toLowerCase();
651
- if (lower === "attributes" || lower === "metadata" || lower === "properties") {
652
- uiSchema[fieldName] = {
653
- "ui:options": {
654
- collapsible: true,
655
- collapsed: true
656
- }
657
- };
658
- }
659
- switch (priority) {
660
- case "essential":
661
- if (isRequired) {
662
- uiSchema[fieldName] = {
663
- ...uiSchema[fieldName],
664
- "ui:help": "Required field"
665
- };
666
- }
667
- break;
668
- case "advanced":
669
- case "expert":
670
- uiSchema[fieldName] = {
671
- ...uiSchema[fieldName],
672
- "ui:options": {
673
- ...uiSchema[fieldName]?.["ui:options"],
674
- collapsed: true
675
- }
676
- };
677
- break;
678
- }
679
- });
680
- return { jsonSchema, uiSchema };
15
+ getModel() {
16
+ return this.model;
681
17
  }
682
18
  }
683
19
  export {
684
- FormGenerator
20
+ LangChainProvider
685
21
  };
686
22
  //# sourceMappingURL=index10.js.map