@ixo/common 1.1.0

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 (328) hide show
  1. package/.eslintrc.js +9 -0
  2. package/.prettierignore +3 -0
  3. package/.prettierrc.cjs +4 -0
  4. package/.turbo/turbo-build.log +4 -0
  5. package/CHANGELOG.md +76 -0
  6. package/README.md +245 -0
  7. package/dist/ai/checkpointer/index.d.ts +2 -0
  8. package/dist/ai/checkpointer/index.d.ts.map +1 -0
  9. package/dist/ai/checkpointer/index.js +2 -0
  10. package/dist/ai/checkpointer/index.js.map +1 -0
  11. package/dist/ai/index.d.ts +9 -0
  12. package/dist/ai/index.d.ts.map +1 -0
  13. package/dist/ai/index.js +9 -0
  14. package/dist/ai/index.js.map +1 -0
  15. package/dist/ai/models/index.d.ts +2 -0
  16. package/dist/ai/models/index.d.ts.map +1 -0
  17. package/dist/ai/models/index.js +2 -0
  18. package/dist/ai/models/index.js.map +1 -0
  19. package/dist/ai/models/openai.d.ts +10 -0
  20. package/dist/ai/models/openai.d.ts.map +1 -0
  21. package/dist/ai/models/openai.js +38 -0
  22. package/dist/ai/models/openai.js.map +1 -0
  23. package/dist/ai/models/openai.test.d.ts +2 -0
  24. package/dist/ai/models/openai.test.d.ts.map +1 -0
  25. package/dist/ai/models/openai.test.js +58 -0
  26. package/dist/ai/models/openai.test.js.map +1 -0
  27. package/dist/ai/nodes/create-fake-node.d.ts +2 -0
  28. package/dist/ai/nodes/create-fake-node.d.ts.map +1 -0
  29. package/dist/ai/nodes/create-fake-node.js +2 -0
  30. package/dist/ai/nodes/create-fake-node.js.map +1 -0
  31. package/dist/ai/nodes/find-docs/find-docs.prompt.d.ts +3 -0
  32. package/dist/ai/nodes/find-docs/find-docs.prompt.d.ts.map +1 -0
  33. package/dist/ai/nodes/find-docs/find-docs.prompt.js +61 -0
  34. package/dist/ai/nodes/find-docs/find-docs.prompt.js.map +1 -0
  35. package/dist/ai/nodes/find-docs/index.d.ts +3 -0
  36. package/dist/ai/nodes/find-docs/index.d.ts.map +1 -0
  37. package/dist/ai/nodes/find-docs/index.js +3 -0
  38. package/dist/ai/nodes/find-docs/index.js.map +1 -0
  39. package/dist/ai/nodes/find-docs/node.d.ts +17 -0
  40. package/dist/ai/nodes/find-docs/node.d.ts.map +1 -0
  41. package/dist/ai/nodes/find-docs/node.js +46 -0
  42. package/dist/ai/nodes/find-docs/node.js.map +1 -0
  43. package/dist/ai/nodes/generic-chat/generic-chat.node.d.ts +12 -0
  44. package/dist/ai/nodes/generic-chat/generic-chat.node.d.ts.map +1 -0
  45. package/dist/ai/nodes/generic-chat/generic-chat.node.js +34 -0
  46. package/dist/ai/nodes/generic-chat/generic-chat.node.js.map +1 -0
  47. package/dist/ai/nodes/generic-chat/generic-chat.prompt.d.ts +10 -0
  48. package/dist/ai/nodes/generic-chat/generic-chat.prompt.d.ts.map +1 -0
  49. package/dist/ai/nodes/generic-chat/generic-chat.prompt.js +58 -0
  50. package/dist/ai/nodes/generic-chat/generic-chat.prompt.js.map +1 -0
  51. package/dist/ai/nodes/generic-chat/index.d.ts +2 -0
  52. package/dist/ai/nodes/generic-chat/index.d.ts.map +1 -0
  53. package/dist/ai/nodes/generic-chat/index.js +2 -0
  54. package/dist/ai/nodes/generic-chat/index.js.map +1 -0
  55. package/dist/ai/nodes/index.d.ts +4 -0
  56. package/dist/ai/nodes/index.d.ts.map +1 -0
  57. package/dist/ai/nodes/index.js +4 -0
  58. package/dist/ai/nodes/index.js.map +1 -0
  59. package/dist/ai/semantic-router-factory/create-semantic-router.d.ts +7 -0
  60. package/dist/ai/semantic-router-factory/create-semantic-router.d.ts.map +1 -0
  61. package/dist/ai/semantic-router-factory/create-semantic-router.js +71 -0
  62. package/dist/ai/semantic-router-factory/create-semantic-router.js.map +1 -0
  63. package/dist/ai/semantic-router-factory/create-semantic-router.test.d.ts +2 -0
  64. package/dist/ai/semantic-router-factory/create-semantic-router.test.d.ts.map +1 -0
  65. package/dist/ai/semantic-router-factory/create-semantic-router.test.js +68 -0
  66. package/dist/ai/semantic-router-factory/create-semantic-router.test.js.map +1 -0
  67. package/dist/ai/semantic-router-factory/index.d.ts +4 -0
  68. package/dist/ai/semantic-router-factory/index.d.ts.map +1 -0
  69. package/dist/ai/semantic-router-factory/index.js +4 -0
  70. package/dist/ai/semantic-router-factory/index.js.map +1 -0
  71. package/dist/ai/semantic-router-factory/semantic-router-prompt.d.ts +2 -0
  72. package/dist/ai/semantic-router-factory/semantic-router-prompt.d.ts.map +1 -0
  73. package/dist/ai/semantic-router-factory/semantic-router-prompt.js +169 -0
  74. package/dist/ai/semantic-router-factory/semantic-router-prompt.js.map +1 -0
  75. package/dist/ai/semantic-router-factory/validate-routes.d.ts +2 -0
  76. package/dist/ai/semantic-router-factory/validate-routes.d.ts.map +1 -0
  77. package/dist/ai/semantic-router-factory/validate-routes.js +16 -0
  78. package/dist/ai/semantic-router-factory/validate-routes.js.map +1 -0
  79. package/dist/ai/tools/action-caller.d.ts +14 -0
  80. package/dist/ai/tools/action-caller.d.ts.map +1 -0
  81. package/dist/ai/tools/action-caller.js +12 -0
  82. package/dist/ai/tools/action-caller.js.map +1 -0
  83. package/dist/ai/tools/ask-ixo-guru/ask-ixo-guru.d.ts +25 -0
  84. package/dist/ai/tools/ask-ixo-guru/ask-ixo-guru.d.ts.map +1 -0
  85. package/dist/ai/tools/ask-ixo-guru/ask-ixo-guru.js +46 -0
  86. package/dist/ai/tools/ask-ixo-guru/ask-ixo-guru.js.map +1 -0
  87. package/dist/ai/tools/ask-ixo-guru/index.d.ts +2 -0
  88. package/dist/ai/tools/ask-ixo-guru/index.d.ts.map +1 -0
  89. package/dist/ai/tools/ask-ixo-guru/index.js +2 -0
  90. package/dist/ai/tools/ask-ixo-guru/index.js.map +1 -0
  91. package/dist/ai/tools/browser-tool-caller.d.ts +14 -0
  92. package/dist/ai/tools/browser-tool-caller.d.ts.map +1 -0
  93. package/dist/ai/tools/browser-tool-caller.js +12 -0
  94. package/dist/ai/tools/browser-tool-caller.js.map +1 -0
  95. package/dist/ai/tools/frontend-tool-caller.d.ts +10 -0
  96. package/dist/ai/tools/frontend-tool-caller.d.ts.map +1 -0
  97. package/dist/ai/tools/frontend-tool-caller.js +50 -0
  98. package/dist/ai/tools/frontend-tool-caller.js.map +1 -0
  99. package/dist/ai/tools/index.d.ts +11 -0
  100. package/dist/ai/tools/index.d.ts.map +1 -0
  101. package/dist/ai/tools/index.js +11 -0
  102. package/dist/ai/tools/index.js.map +1 -0
  103. package/dist/ai/tools/log-action-to-matrix.d.ts +13 -0
  104. package/dist/ai/tools/log-action-to-matrix.d.ts.map +1 -0
  105. package/dist/ai/tools/log-action-to-matrix.js +14 -0
  106. package/dist/ai/tools/log-action-to-matrix.js.map +1 -0
  107. package/dist/ai/tools/parser-action-tool.d.ts +8 -0
  108. package/dist/ai/tools/parser-action-tool.d.ts.map +1 -0
  109. package/dist/ai/tools/parser-action-tool.js +40 -0
  110. package/dist/ai/tools/parser-action-tool.js.map +1 -0
  111. package/dist/ai/tools/parser-browser-tool.d.ts +8 -0
  112. package/dist/ai/tools/parser-browser-tool.d.ts.map +1 -0
  113. package/dist/ai/tools/parser-browser-tool.js +38 -0
  114. package/dist/ai/tools/parser-browser-tool.js.map +1 -0
  115. package/dist/ai/tools/retriever-tool/index.d.ts +2 -0
  116. package/dist/ai/tools/retriever-tool/index.d.ts.map +1 -0
  117. package/dist/ai/tools/retriever-tool/index.js +2 -0
  118. package/dist/ai/tools/retriever-tool/index.js.map +1 -0
  119. package/dist/ai/tools/retriever-tool/retriever-tool.d.ts +18 -0
  120. package/dist/ai/tools/retriever-tool/retriever-tool.d.ts.map +1 -0
  121. package/dist/ai/tools/retriever-tool/retriever-tool.js +62 -0
  122. package/dist/ai/tools/retriever-tool/retriever-tool.js.map +1 -0
  123. package/dist/ai/tools/retriever-tool/retriever-tool.test.d.ts +2 -0
  124. package/dist/ai/tools/retriever-tool/retriever-tool.test.d.ts.map +1 -0
  125. package/dist/ai/tools/retriever-tool/retriever-tool.test.js +119 -0
  126. package/dist/ai/tools/retriever-tool/retriever-tool.test.js.map +1 -0
  127. package/dist/ai/tools/scrape-web-page.d.ts +7 -0
  128. package/dist/ai/tools/scrape-web-page.d.ts.map +1 -0
  129. package/dist/ai/tools/scrape-web-page.js +65 -0
  130. package/dist/ai/tools/scrape-web-page.js.map +1 -0
  131. package/dist/ai/tools/web-search-tool.d.ts +10 -0
  132. package/dist/ai/tools/web-search-tool.d.ts.map +1 -0
  133. package/dist/ai/tools/web-search-tool.js +30 -0
  134. package/dist/ai/tools/web-search-tool.js.map +1 -0
  135. package/dist/ai/types.d.ts +4 -0
  136. package/dist/ai/types.d.ts.map +1 -0
  137. package/dist/ai/types.js +2 -0
  138. package/dist/ai/types.js.map +1 -0
  139. package/dist/ai/utils/__tests__/chunk-arr.test.d.ts +2 -0
  140. package/dist/ai/utils/__tests__/chunk-arr.test.d.ts.map +1 -0
  141. package/dist/ai/utils/__tests__/chunk-arr.test.js +37 -0
  142. package/dist/ai/utils/__tests__/chunk-arr.test.js.map +1 -0
  143. package/dist/ai/utils/__tests__/doc-relevance-checker.test.d.ts +2 -0
  144. package/dist/ai/utils/__tests__/doc-relevance-checker.test.d.ts.map +1 -0
  145. package/dist/ai/utils/__tests__/doc-relevance-checker.test.js +80 -0
  146. package/dist/ai/utils/__tests__/doc-relevance-checker.test.js.map +1 -0
  147. package/dist/ai/utils/__tests__/doc-splitter.test.d.ts +2 -0
  148. package/dist/ai/utils/__tests__/doc-splitter.test.d.ts.map +1 -0
  149. package/dist/ai/utils/__tests__/doc-splitter.test.js +35 -0
  150. package/dist/ai/utils/__tests__/doc-splitter.test.js.map +1 -0
  151. package/dist/ai/utils/__tests__/filter-similarity-search-results.test.d.ts +2 -0
  152. package/dist/ai/utils/__tests__/filter-similarity-search-results.test.d.ts.map +1 -0
  153. package/dist/ai/utils/__tests__/filter-similarity-search-results.test.js +47 -0
  154. package/dist/ai/utils/__tests__/filter-similarity-search-results.test.js.map +1 -0
  155. package/dist/ai/utils/__tests__/json-to-yaml.test.d.ts +2 -0
  156. package/dist/ai/utils/__tests__/json-to-yaml.test.d.ts.map +1 -0
  157. package/dist/ai/utils/__tests__/json-to-yaml.test.js +63 -0
  158. package/dist/ai/utils/__tests__/json-to-yaml.test.js.map +1 -0
  159. package/dist/ai/utils/__tests__/stringify-docs.test.d.ts +2 -0
  160. package/dist/ai/utils/__tests__/stringify-docs.test.d.ts.map +1 -0
  161. package/dist/ai/utils/__tests__/stringify-docs.test.js +54 -0
  162. package/dist/ai/utils/__tests__/stringify-docs.test.js.map +1 -0
  163. package/dist/ai/utils/chunk-arr.d.ts +3 -0
  164. package/dist/ai/utils/chunk-arr.d.ts.map +1 -0
  165. package/dist/ai/utils/chunk-arr.js +13 -0
  166. package/dist/ai/utils/chunk-arr.js.map +1 -0
  167. package/dist/ai/utils/doc-relevance-checker.d.ts +10 -0
  168. package/dist/ai/utils/doc-relevance-checker.d.ts.map +1 -0
  169. package/dist/ai/utils/doc-relevance-checker.js +37 -0
  170. package/dist/ai/utils/doc-relevance-checker.js.map +1 -0
  171. package/dist/ai/utils/doc-splitter.d.ts +3 -0
  172. package/dist/ai/utils/doc-splitter.d.ts.map +1 -0
  173. package/dist/ai/utils/doc-splitter.js +20 -0
  174. package/dist/ai/utils/doc-splitter.js.map +1 -0
  175. package/dist/ai/utils/filter-similarity-search-results.d.ts +4 -0
  176. package/dist/ai/utils/filter-similarity-search-results.d.ts.map +1 -0
  177. package/dist/ai/utils/filter-similarity-search-results.js +11 -0
  178. package/dist/ai/utils/filter-similarity-search-results.js.map +1 -0
  179. package/dist/ai/utils/generate-questions-from-chunks.d.ts +15 -0
  180. package/dist/ai/utils/generate-questions-from-chunks.d.ts.map +1 -0
  181. package/dist/ai/utils/generate-questions-from-chunks.js +101 -0
  182. package/dist/ai/utils/generate-questions-from-chunks.js.map +1 -0
  183. package/dist/ai/utils/index.d.ts +11 -0
  184. package/dist/ai/utils/index.d.ts.map +1 -0
  185. package/dist/ai/utils/index.js +11 -0
  186. package/dist/ai/utils/index.js.map +1 -0
  187. package/dist/ai/utils/json-to-yaml.d.ts +2 -0
  188. package/dist/ai/utils/json-to-yaml.d.ts.map +1 -0
  189. package/dist/ai/utils/json-to-yaml.js +25 -0
  190. package/dist/ai/utils/json-to-yaml.js.map +1 -0
  191. package/dist/ai/utils/load-file.d.ts +3 -0
  192. package/dist/ai/utils/load-file.d.ts.map +1 -0
  193. package/dist/ai/utils/load-file.js +133 -0
  194. package/dist/ai/utils/load-file.js.map +1 -0
  195. package/dist/ai/utils/stringify-docs.d.ts +3 -0
  196. package/dist/ai/utils/stringify-docs.d.ts.map +1 -0
  197. package/dist/ai/utils/stringify-docs.js +6 -0
  198. package/dist/ai/utils/stringify-docs.js.map +1 -0
  199. package/dist/ai/utils/transformGraphStateMessageToListMessageResponse.d.ts +35 -0
  200. package/dist/ai/utils/transformGraphStateMessageToListMessageResponse.d.ts.map +1 -0
  201. package/dist/ai/utils/transformGraphStateMessageToListMessageResponse.js +55 -0
  202. package/dist/ai/utils/transformGraphStateMessageToListMessageResponse.js.map +1 -0
  203. package/dist/ai/utils/verify-matrix-openId-token.d.ts +6 -0
  204. package/dist/ai/utils/verify-matrix-openId-token.d.ts.map +1 -0
  205. package/dist/ai/utils/verify-matrix-openId-token.js +36 -0
  206. package/dist/ai/utils/verify-matrix-openId-token.js.map +1 -0
  207. package/dist/index.d.ts +4 -0
  208. package/dist/index.d.ts.map +1 -0
  209. package/dist/index.js +4 -0
  210. package/dist/index.js.map +1 -0
  211. package/dist/services/env/env-service.test.d.ts +2 -0
  212. package/dist/services/env/env-service.test.d.ts.map +1 -0
  213. package/dist/services/env/env-service.test.js +99 -0
  214. package/dist/services/env/env-service.test.js.map +1 -0
  215. package/dist/services/env/env.service.d.ts +11 -0
  216. package/dist/services/env/env.service.d.ts.map +1 -0
  217. package/dist/services/env/env.service.js +42 -0
  218. package/dist/services/env/env.service.js.map +1 -0
  219. package/dist/services/env/index.d.ts +2 -0
  220. package/dist/services/env/index.d.ts.map +1 -0
  221. package/dist/services/env/index.js +2 -0
  222. package/dist/services/env/index.js.map +1 -0
  223. package/dist/services/index.d.ts +5 -0
  224. package/dist/services/index.d.ts.map +1 -0
  225. package/dist/services/index.js +5 -0
  226. package/dist/services/index.js.map +1 -0
  227. package/dist/services/memory-engine/memory-engine.service.d.ts +35 -0
  228. package/dist/services/memory-engine/memory-engine.service.d.ts.map +1 -0
  229. package/dist/services/memory-engine/memory-engine.service.js +295 -0
  230. package/dist/services/memory-engine/memory-engine.service.js.map +1 -0
  231. package/dist/services/memory-engine/types.d.ts +88 -0
  232. package/dist/services/memory-engine/types.d.ts.map +1 -0
  233. package/dist/services/memory-engine/types.js +2 -0
  234. package/dist/services/memory-engine/types.js.map +1 -0
  235. package/dist/services/session-manager/dto.d.ts +40 -0
  236. package/dist/services/session-manager/dto.d.ts.map +1 -0
  237. package/dist/services/session-manager/dto.js +170 -0
  238. package/dist/services/session-manager/dto.js.map +1 -0
  239. package/dist/services/session-manager/errors.d.ts +22 -0
  240. package/dist/services/session-manager/errors.d.ts.map +1 -0
  241. package/dist/services/session-manager/errors.js +41 -0
  242. package/dist/services/session-manager/errors.js.map +1 -0
  243. package/dist/services/session-manager/index.d.ts +4 -0
  244. package/dist/services/session-manager/index.d.ts.map +1 -0
  245. package/dist/services/session-manager/index.js +4 -0
  246. package/dist/services/session-manager/index.js.map +1 -0
  247. package/dist/services/session-manager/session-manager.service.d.ts +40 -0
  248. package/dist/services/session-manager/session-manager.service.d.ts.map +1 -0
  249. package/dist/services/session-manager/session-manager.service.js +251 -0
  250. package/dist/services/session-manager/session-manager.service.js.map +1 -0
  251. package/dist/utils/get-user-subscription.d.ts +21 -0
  252. package/dist/utils/get-user-subscription.d.ts.map +1 -0
  253. package/dist/utils/get-user-subscription.js +44 -0
  254. package/dist/utils/get-user-subscription.js.map +1 -0
  255. package/dist/utils/index.d.ts +2 -0
  256. package/dist/utils/index.d.ts.map +1 -0
  257. package/dist/utils/index.js +2 -0
  258. package/dist/utils/index.js.map +1 -0
  259. package/docs/ai-module.md +84 -0
  260. package/docs/services.md +168 -0
  261. package/docs/tools.md +325 -0
  262. package/jest.config.js +6 -0
  263. package/package.json +81 -0
  264. package/src/ai/checkpointer/index.ts +1 -0
  265. package/src/ai/index.ts +8 -0
  266. package/src/ai/models/index.ts +1 -0
  267. package/src/ai/models/openai.test.ts +72 -0
  268. package/src/ai/models/openai.ts +54 -0
  269. package/src/ai/nodes/create-fake-node.ts +1 -0
  270. package/src/ai/nodes/find-docs/find-docs.prompt.ts +61 -0
  271. package/src/ai/nodes/find-docs/index.ts +2 -0
  272. package/src/ai/nodes/find-docs/node.ts +83 -0
  273. package/src/ai/nodes/generic-chat/generic-chat.node.ts +58 -0
  274. package/src/ai/nodes/generic-chat/generic-chat.prompt.ts +66 -0
  275. package/src/ai/nodes/generic-chat/index.ts +1 -0
  276. package/src/ai/nodes/index.ts +3 -0
  277. package/src/ai/semantic-router-factory/create-semantic-router.test.ts +98 -0
  278. package/src/ai/semantic-router-factory/create-semantic-router.ts +136 -0
  279. package/src/ai/semantic-router-factory/index.ts +3 -0
  280. package/src/ai/semantic-router-factory/semantic-router-prompt.ts +168 -0
  281. package/src/ai/semantic-router-factory/validate-routes.ts +26 -0
  282. package/src/ai/tools/action-caller.ts +37 -0
  283. package/src/ai/tools/ask-ixo-guru/ask-ixo-guru.ts +73 -0
  284. package/src/ai/tools/ask-ixo-guru/index.ts +1 -0
  285. package/src/ai/tools/browser-tool-caller.ts +37 -0
  286. package/src/ai/tools/frontend-tool-caller.ts +86 -0
  287. package/src/ai/tools/index.ts +10 -0
  288. package/src/ai/tools/log-action-to-matrix.ts +30 -0
  289. package/src/ai/tools/parser-action-tool.ts +61 -0
  290. package/src/ai/tools/parser-browser-tool.ts +55 -0
  291. package/src/ai/tools/retriever-tool/index.ts +1 -0
  292. package/src/ai/tools/retriever-tool/retriever-tool.test.ts +156 -0
  293. package/src/ai/tools/retriever-tool/retriever-tool.ts +107 -0
  294. package/src/ai/tools/scrape-web-page.ts +75 -0
  295. package/src/ai/tools/web-search-tool.ts +38 -0
  296. package/src/ai/types.ts +6 -0
  297. package/src/ai/utils/__tests__/chunk-arr.test.ts +46 -0
  298. package/src/ai/utils/__tests__/doc-relevance-checker.test.ts +90 -0
  299. package/src/ai/utils/__tests__/doc-splitter.test.ts +42 -0
  300. package/src/ai/utils/__tests__/filter-similarity-search-results.test.ts +57 -0
  301. package/src/ai/utils/__tests__/json-to-yaml.test.ts +70 -0
  302. package/src/ai/utils/__tests__/stringify-docs.test.ts +61 -0
  303. package/src/ai/utils/chunk-arr.ts +13 -0
  304. package/src/ai/utils/doc-relevance-checker.ts +58 -0
  305. package/src/ai/utils/doc-splitter.ts +28 -0
  306. package/src/ai/utils/filter-similarity-search-results.ts +15 -0
  307. package/src/ai/utils/generate-questions-from-chunks.ts +114 -0
  308. package/src/ai/utils/index.ts +10 -0
  309. package/src/ai/utils/json-to-yaml.ts +32 -0
  310. package/src/ai/utils/load-file.ts +170 -0
  311. package/src/ai/utils/stringify-docs.ts +14 -0
  312. package/src/ai/utils/transformGraphStateMessageToListMessageResponse.ts +108 -0
  313. package/src/ai/utils/verify-matrix-openId-token.ts +46 -0
  314. package/src/index.ts +3 -0
  315. package/src/services/env/env-service.test.ts +153 -0
  316. package/src/services/env/env.service.ts +65 -0
  317. package/src/services/env/index.ts +1 -0
  318. package/src/services/index.ts +4 -0
  319. package/src/services/memory-engine/memory-engine.service.ts +486 -0
  320. package/src/services/memory-engine/types.ts +208 -0
  321. package/src/services/session-manager/dto.ts +120 -0
  322. package/src/services/session-manager/errors.ts +56 -0
  323. package/src/services/session-manager/index.ts +3 -0
  324. package/src/services/session-manager/session-manager.service.ts +405 -0
  325. package/src/utils/get-user-subscription.ts +84 -0
  326. package/src/utils/index.ts +1 -0
  327. package/tsconfig.json +16 -0
  328. package/tsconfig.tsbuildinfo +1 -0
package/.eslintrc.js ADDED
@@ -0,0 +1,9 @@
1
+ /** @type {import("eslint").Linter.Config} */
2
+ module.exports = {
3
+ extends: ['@ixo/eslint-config/nest.js'],
4
+ parserOptions: {
5
+ project: 'tsconfig.json',
6
+ tsconfigRootDir: __dirname,
7
+ sourceType: 'module',
8
+ },
9
+ };
@@ -0,0 +1,3 @@
1
+ pnpm-lock.yaml
2
+
3
+ node_modules
@@ -0,0 +1,4 @@
1
+ /** @type {import("prettier").Config} */
2
+ module.exports = {
3
+ ...require('@ixo/eslint-config/prettier-base'),
4
+ };
@@ -0,0 +1,4 @@
1
+
2
+ > @ixo/common@1.1.0 build /home/runner/actions-runner/_work/ixo-oracles-boilerplate/ixo-oracles-boilerplate/packages/common
3
+ > tsc && tsc-alias
4
+
package/CHANGELOG.md ADDED
@@ -0,0 +1,76 @@
1
+ # @ixo/common
2
+
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#57](https://github.com/ixoworld/ixo-oracles-boilerplate/pull/57) [`2a3bbd3`](https://github.com/ixoworld/ixo-oracles-boilerplate/commit/2a3bbd3267e1ce9a413eba4a30757e92ee8fa87b) Thanks [@youssefhany-ixo](https://github.com/youssefhany-ixo)! - # Live Agent: Ultra-Secure Voice & Video Calls
8
+
9
+ This major release introduces **Live Agent Mode** - enabling real-time voice and video conversations with AI oracles through ultra-secure, end-to-end encrypted calls.
10
+
11
+ ## ✨ Key Features
12
+
13
+ - **Double Encryption Security**: Asymmetric key encryption + Matrix E2EE for maximum security
14
+ - **Real-time Communication**: LiveKit integration for professional-grade WebRTC infrastructure
15
+ - **Frontend-Controlled Keys**: True E2EE with user-generated encryption keys
16
+ - **Zero-Trust Architecture**: Backend services cannot decrypt call content
17
+ - **Per-Call Key Rotation**: Unique encryption keys for each call session
18
+
19
+ ## 🏗️ New Components
20
+
21
+ - `useLiveAgent` hook for voice chat integration
22
+ - `useLiveKitAgent` for E2EE connection management
23
+ - Complete call lifecycle with state validation
24
+ - Enhanced Matrix integration for encrypted events
25
+
26
+ ## 🛡️ Security Enhancements
27
+
28
+ - ECIES-based encryption/decryption utilities
29
+ - Cryptographically secure key generation
30
+ - Live Agent authentication via API keys
31
+ - Enhanced wallet generation with public key encoding
32
+
33
+ ## 📡 New API Endpoints
34
+
35
+ - `POST /calls/:callId/sync` - Sync call state from Matrix event
36
+ - `GET /calls/:callId/key` - Get encrypted key for Live Agent
37
+ - `PATCH /calls/:callId/update` - Update call status with validation
38
+ - `GET /calls/session/:sessionId` - List user's call history
39
+
40
+ ## ⚠️ Breaking Changes
41
+
42
+ - **Backend only**: New environment variables required in your backend configuration:
43
+ - `LIVE_AGENT_AUTH_API_KEY` - Authentication for Live Agent
44
+ - `MEMORY_MCP_URL` - Memory management service URL
45
+ - `MEMORY_MCP_API` - Memory management API endpoint
46
+ - Updated dependencies for LiveKit and enhanced Matrix client
47
+
48
+ ## 📚 Documentation
49
+
50
+ - [Live Agent Architecture](./docs/architecture/calls.md) - Complete technical documentation
51
+ - [Crypto Utilities](./packages/oracles-chain-client/docs/crypto.md) - Encryption implementation details
52
+
53
+ This release represents a major milestone in secure, real-time AI communication, enabling truly private voice conversations with AI oracles through state-of-the-art encryption and professional-grade infrastructure.
54
+
55
+ ### Patch Changes
56
+
57
+ - Updated dependencies [[`2a3bbd3`](https://github.com/ixoworld/ixo-oracles-boilerplate/commit/2a3bbd3267e1ce9a413eba4a30757e92ee8fa87b)]:
58
+ - @ixo/matrix@1.1.0
59
+
60
+ ## 1.0.2
61
+
62
+ ### Patch Changes
63
+
64
+ - [#53](https://github.com/ixoworld/ixo-oracles-boilerplate/pull/53) [`0a4a5a8`](https://github.com/ixoworld/ixo-oracles-boilerplate/commit/0a4a5a84194acb851e3824e0b74eea54f60c8257) Thanks [@youssefhany-ixo](https://github.com/youssefhany-ixo)! - Upgrade packages and publish events package and preformance upgrades
65
+
66
+ - Updated dependencies [[`b723472`](https://github.com/ixoworld/ixo-oracles-boilerplate/commit/b72347286054e037436a8be3da3cf840f75223ca), [`0a4a5a8`](https://github.com/ixoworld/ixo-oracles-boilerplate/commit/0a4a5a84194acb851e3824e0b74eea54f60c8257)]:
67
+ - @ixo/matrix@1.0.2
68
+
69
+ ## 1.0.1
70
+
71
+ ### Patch Changes
72
+
73
+ - [#44](https://github.com/ixoworld/ixo-oracles-boilerplate/pull/44) [`2b93cf8`](https://github.com/ixoworld/ixo-oracles-boilerplate/commit/2b93cf8ef3839c36f03249b9392606211a22a0db) Thanks [@youssefhany-ixo](https://github.com/youssefhany-ixo)! - use matrix spaces and reduce using user mx token
74
+
75
+ - Updated dependencies [[`2b93cf8`](https://github.com/ixoworld/ixo-oracles-boilerplate/commit/2b93cf8ef3839c36f03249b9392606211a22a0db)]:
76
+ - @ixo/matrix@1.0.1
package/README.md ADDED
@@ -0,0 +1,245 @@
1
+ # @ixo/common
2
+
3
+ ## Overview
4
+
5
+ The `@ixo/common` package serves as a foundational library for the ixo-oracles ecosystem, providing shared utilities, AI capabilities, and core services. It integrates with Matrix for communication and state management, OpenAI for AI capabilities, and provides various tools for document processing and semantic analysis.
6
+
7
+ ## Table of Contents
8
+
9
+ 1. [Getting Started](#getting-started)
10
+ - [Installation](#installation)
11
+ - [Basic Usage](#basic-usage)
12
+ 2. [Core Components](#core-components)
13
+ - [AI Module](#ai-module)
14
+ - [Services](#services)
15
+ 3. [Documentation](#documentation)
16
+
17
+ ## Getting Started
18
+
19
+ ### Installation
20
+
21
+ ```bash
22
+ # Install using pnpm (recommended)
23
+ pnpm install @ixo/common
24
+
25
+ # Or using npm
26
+ npm install @ixo/common
27
+
28
+ # Or using yarn
29
+ yarn add @ixo/common
30
+ ```
31
+
32
+ ### Environment Setup
33
+
34
+ The package requires several environment variables:
35
+
36
+ ```env
37
+ # OpenAI Configuration
38
+ OPENAI_API_KEY=your_openai_key
39
+
40
+ # Matrix Configuration
41
+ MATRIX_ORACLE_ADMIN_ACCESS_TOKEN=your_matrix_token
42
+
43
+ # Optional Tools Configuration
44
+ TAVILY_API_KEY=your_tavily_key # For web search capabilities
45
+ ```
46
+
47
+ ### Basic Usage
48
+
49
+ ```typescript
50
+ // Services for Matrix room and session management
51
+ import {
52
+ RoomManagerService,
53
+ SessionManagerService,
54
+ } from '@ixo/common/services';
55
+
56
+ // Initialize services
57
+ const sessionManager = new SessionManagerService();
58
+ const roomManager = new RoomManagerService();
59
+
60
+ // Create or get a Matrix room
61
+ const roomId = await roomManager.getOrCreateRoom({
62
+ did: 'user-did',
63
+ oracleName: 'oracle-name',
64
+ userAccessToken: 'matrix-token',
65
+ });
66
+
67
+ // Manage chat sessions
68
+ const session = await sessionManager.createSession({
69
+ did: 'user-did',
70
+ oracleName: 'oracle-name',
71
+ matrixAccessToken: 'matrix-token',
72
+ });
73
+
74
+ // AI utilities
75
+ import {
76
+ docSplitter,
77
+ checkDocRelevance,
78
+ createSemanticRouter,
79
+ webSearchTool,
80
+ } from '@ixo/common/ai';
81
+
82
+ // Process documents
83
+ const chunks = await docSplitter('Long text content...');
84
+
85
+ // Check document relevance
86
+ const isRelevant = await checkDocRelevance({
87
+ doc: 'document content',
88
+ query: 'search query',
89
+ });
90
+
91
+ // Create semantic routes
92
+ const router = createSemanticRouter({
93
+ routes: {
94
+ generateBlog: 'if the intent is blog',
95
+ generatePost: 'if the intent is post',
96
+ },
97
+ basedOn: ['intent'],
98
+ });
99
+ ```
100
+
101
+ ## Core Components
102
+
103
+ ### AI Module
104
+
105
+ The AI module provides a comprehensive suite of AI-powered tools and utilities:
106
+
107
+ - **Document Processing**
108
+
109
+ - Text splitting and chunking
110
+ - Document relevance checking
111
+ - File loading and format conversion
112
+ - Similarity search filtering
113
+
114
+ - **Semantic Routing**
115
+
116
+ - Intent-based routing
117
+ - OpenAI integration
118
+ - LangSmith tracing support
119
+
120
+ - **Search and Retrieval**
121
+
122
+ - Web search integration with Tavily
123
+ - Vector similarity search
124
+ - Document retrieval tools
125
+
126
+ - **Utility Functions**
127
+ - YAML/JSON conversion
128
+ - Document stringification
129
+ - Array manipulation
130
+
131
+ ### Services
132
+
133
+ Core services for Matrix integration and state management:
134
+
135
+ - **Room Manager**
136
+
137
+ - Matrix room creation and retrieval
138
+ - DID-based room management
139
+ - Access control and validation
140
+
141
+ - **Session Manager**
142
+
143
+ - Chat session management
144
+ - AI-powered session titling
145
+ - Matrix state persistence
146
+ - Session lifecycle handling
147
+
148
+ - **Environment Service**
149
+ - Type-safe environment variable management
150
+ - Zod schema validation
151
+ - Singleton pattern implementation
152
+ - Runtime environment validation
153
+
154
+ ### Using the Environment Service
155
+
156
+ The Environment Service provides a type-safe way to manage and access environment variables in your application. Here's the recommended way to structure and use it:
157
+
158
+ #### 1. Define Your Schema (schema.ts)
159
+
160
+ ```typescript
161
+ // src/services/env/schema.ts
162
+ import z from 'zod';
163
+
164
+ export const envSchema = z.object({
165
+ NODE_ENV: z.enum(['development', 'production', 'test']),
166
+ PORT: z.string().transform(Number),
167
+ API_KEY: z.string().min(1),
168
+ // Add more environment variables as needed
169
+ });
170
+
171
+ // Export the schema type for type-safety
172
+ export type Schema = typeof envSchema;
173
+ ```
174
+
175
+ #### 2. Create Singleton Instance (env.ts)
176
+
177
+ ```typescript
178
+ // src/services/env/env.ts
179
+ import { type Schema } from 'zod/v3';
180
+ import { EnvService } from './env.service';
181
+
182
+ const envService = EnvService.getInstance<Schema>();
183
+
184
+ export default envService;
185
+ ```
186
+
187
+ #### 3. Initialize in Application Entry Point
188
+
189
+ ```typescript
190
+ // src/main.ts or src/app.ts
191
+ import { EnvService } from '@ixo/common/services/env';
192
+ import { envSchema } from './services/env/schema';
193
+
194
+ async function bootstrap() {
195
+ // Initialize environment service first
196
+ EnvService.initialize(envSchema);
197
+
198
+ // Now you can start your application
199
+ const app = express();
200
+ // ... rest of your application setup
201
+ }
202
+
203
+ bootstrap();
204
+ ```
205
+
206
+ #### 4. Use Throughout Your Application
207
+
208
+ ```typescript
209
+ // Any file where you need env variables - use the singleton instance you created in your app
210
+ import env from './services/env/env';
211
+
212
+ // Type-safe environment usage
213
+ const port = env.get('PORT'); // TypeScript knows this is a number
214
+ const apiKey = env.get('API_KEY'); // TypeScript knows this is a string
215
+
216
+ // Example usage in a service
217
+ export class DatabaseService {
218
+ constructor() {
219
+ this.connect({
220
+ port: env.get('PORT'),
221
+ apiKey: env.get('API_KEY'),
222
+ });
223
+ }
224
+ }
225
+ ```
226
+
227
+ This pattern provides several benefits:
228
+
229
+ - **Single Source of Truth**: Environment schema is defined in one place
230
+ - **Type Safety**: TypeScript knows the types of all environment variables
231
+ - **Early Validation**: Environment is validated when the application starts
232
+ - **Clean Imports**: Simple import of the pre-configured service
233
+ - **Separation of Concerns**: Schema definition, initialization, and usage are separated
234
+
235
+ ## Documentation
236
+
237
+ Detailed documentation is available in the [docs](./docs) directory:
238
+
239
+ - [AI Module Documentation](./docs/ai-module.md) - AI tools and utilities
240
+ - [Services Documentation](./docs/services.md) - Matrix services
241
+ - [Tools Documentation](./docs/tools.md) - Utility tools and helpers
242
+
243
+ ## License
244
+
245
+ Internal package - All rights reserved.
@@ -0,0 +1,2 @@
1
+ export * from '@langchain/langgraph-checkpoint-sqlite';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ai/checkpointer/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from '@langchain/langgraph-checkpoint-sqlite';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ai/checkpointer/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export * from './checkpointer/index.js';
2
+ export * from './models/index.js';
3
+ export * from './nodes/index.js';
4
+ export * from './semantic-router-factory/index.js';
5
+ export * from './tools/index.js';
6
+ export * from './types.js';
7
+ export * from './utils/index.js';
8
+ export { zodResponseFormat } from 'openai/helpers/zod';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oCAAoC,CAAC;AACnD,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,9 @@
1
+ export * from './checkpointer/index.js';
2
+ export * from './models/index.js';
3
+ export * from './nodes/index.js';
4
+ export * from './semantic-router-factory/index.js';
5
+ export * from './tools/index.js';
6
+ export * from './types.js';
7
+ export * from './utils/index.js';
8
+ export { zodResponseFormat } from 'openai/helpers/zod';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oCAAoC,CAAC;AACnD,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './openai.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ai/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './openai.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ai/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
@@ -0,0 +1,10 @@
1
+ import 'dotenv/config';
2
+ import { ChatOpenAI, OpenAIEmbeddings, type ChatOpenAIFields, type ChatOpenAIResponseFormat } from '@langchain/openai';
3
+ import OpenAI, { type ClientOptions } from 'openai';
4
+ declare const getChatOpenAiModel: (params?: ChatOpenAIFields) => ChatOpenAI;
5
+ declare const getOpenAiClient: (params?: ClientOptions) => OpenAI;
6
+ declare const getOpenAiEmbeddings: (params?: ConstructorParameters<typeof OpenAIEmbeddings>[0]) => OpenAIEmbeddings;
7
+ export declare const getOpenRouterChatModel: (params?: ChatOpenAIFields) => ChatOpenAI<import("@langchain/openai").ChatOpenAICallOptions>;
8
+ export { getChatOpenAiModel, getOpenAiClient, getOpenAiEmbeddings };
9
+ export type { ChatOpenAIResponseFormat };
10
+ //# sourceMappingURL=openai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/ai/models/openai.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC9B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,MAAM,EAAE,EAAE,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEpD,QAAA,MAAM,kBAAkB,GAAI,SAAS,gBAAgB,KAAG,UAMpD,CAAC;AAEL,QAAA,MAAM,eAAe,GAAI,SAAS,aAAa,KAAG,MAI9C,CAAC;AAEL,QAAA,MAAM,mBAAmB,GACvB,SAAS,qBAAqB,CAAC,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,KACzD,gBAKC,CAAC;AAEL,eAAO,MAAM,sBAAsB,GAAI,SAAS,gBAAgB,kEAkB5D,CAAC;AACL,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,mBAAmB,EAAE,CAAC;AACpE,YAAY,EAAE,wBAAwB,EAAE,CAAC"}
@@ -0,0 +1,38 @@
1
+ import 'dotenv/config';
2
+ import { ChatOpenAI, OpenAIEmbeddings, } from '@langchain/openai';
3
+ import OpenAI from 'openai';
4
+ const getChatOpenAiModel = (params) => new ChatOpenAI({
5
+ temperature: 0.2,
6
+ model: 'gpt-4o-mini',
7
+ apiKey: process.env.OPENAI_API_KEY,
8
+ ...params,
9
+ });
10
+ const getOpenAiClient = (params) => new OpenAI({
11
+ apiKey: process.env.OPENAI_API_KEY,
12
+ ...params,
13
+ });
14
+ const getOpenAiEmbeddings = (params) => new OpenAIEmbeddings({
15
+ model: 'text-embedding-3-small',
16
+ apiKey: process.env.OPENAI_API_KEY,
17
+ ...params,
18
+ });
19
+ export const getOpenRouterChatModel = (params) => getChatOpenAiModel({
20
+ temperature: 0.8,
21
+ apiKey: process.env.OPEN_ROUTER_API_KEY,
22
+ model: params?.model ?? 'qwen/qwen3-14b',
23
+ ...params,
24
+ configuration: {
25
+ baseURL: 'https://openrouter.ai/api/v1',
26
+ ...params?.configuration,
27
+ defaultHeaders: {
28
+ 'HTTP-Referer': 'oracle-app.com',
29
+ 'X-Title': process.env.ORACLE_NAME ?? 'Oracle App',
30
+ },
31
+ },
32
+ modelKwargs: {
33
+ require_parameters: true,
34
+ ...params?.modelKwargs,
35
+ },
36
+ });
37
+ export { getChatOpenAiModel, getOpenAiClient, getOpenAiEmbeddings };
38
+ //# sourceMappingURL=openai.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai.js","sourceRoot":"","sources":["../../../src/ai/models/openai.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,EACL,UAAU,EACV,gBAAgB,GAGjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,MAA8B,MAAM,QAAQ,CAAC;AAEpD,MAAM,kBAAkB,GAAG,CAAC,MAAyB,EAAc,EAAE,CACnE,IAAI,UAAU,CAAC;IACb,WAAW,EAAE,GAAG;IAChB,KAAK,EAAE,aAAa;IACpB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;IAClC,GAAG,MAAM;CACV,CAAC,CAAC;AAEL,MAAM,eAAe,GAAG,CAAC,MAAsB,EAAU,EAAE,CACzD,IAAI,MAAM,CAAC;IACT,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;IAClC,GAAG,MAAM;CACV,CAAC,CAAC;AAEL,MAAM,mBAAmB,GAAG,CAC1B,MAA0D,EACxC,EAAE,CACpB,IAAI,gBAAgB,CAAC;IACnB,KAAK,EAAE,wBAAwB;IAC/B,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;IAClC,GAAG,MAAM;CACV,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,MAAyB,EAAE,EAAE,CAClE,kBAAkB,CAAC;IACjB,WAAW,EAAE,GAAG;IAChB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;IACvC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,gBAAgB;IACxC,GAAG,MAAM;IACT,aAAa,EAAE;QACb,OAAO,EAAE,8BAA8B;QACvC,GAAG,MAAM,EAAE,aAAa;QACxB,cAAc,EAAE;YACd,cAAc,EAAE,gBAAgB;YAChC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,YAAY;SACnD;KACF;IACD,WAAW,EAAE;QACX,kBAAkB,EAAE,IAAI;QACxB,GAAG,MAAM,EAAE,WAAW;KACvB;CACF,CAAC,CAAC;AACL,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=openai.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai.test.d.ts","sourceRoot":"","sources":["../../../src/ai/models/openai.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,58 @@
1
+ import { ChatOpenAI, OpenAIEmbeddings } from '@langchain/openai';
2
+ import { getChatOpenAiModel, getOpenAiEmbeddings } from './openai.js';
3
+ const originalEnv = process.env;
4
+ describe('OpenAI Models', () => {
5
+ beforeEach(() => {
6
+ jest.resetModules();
7
+ process.env = { ...originalEnv };
8
+ process.env.OPENAI_API_KEY = 'test-api-key';
9
+ });
10
+ afterEach(() => {
11
+ process.env = originalEnv;
12
+ });
13
+ describe('getChatOpenAiModel', () => {
14
+ it('should create a ChatOpenAI instance with default parameters', () => {
15
+ const model = getChatOpenAiModel();
16
+ expect(model).toBeInstanceOf(ChatOpenAI);
17
+ expect(model).toHaveProperty('temperature', 0.2);
18
+ expect(model).toHaveProperty('modelName', 'gpt-4o-mini');
19
+ expect(model).toHaveProperty('apiKey', 'test-api-key');
20
+ });
21
+ it('should override default parameters when provided', () => {
22
+ const customParams = {
23
+ temperature: 0.8,
24
+ model: 'gpt-4',
25
+ apiKey: 'custom-api-key',
26
+ };
27
+ const model = getChatOpenAiModel(customParams);
28
+ expect(model).toBeInstanceOf(ChatOpenAI);
29
+ expect(model).toHaveProperty('temperature', 0.8);
30
+ expect(model).toHaveProperty('modelName', 'gpt-4');
31
+ expect(model).toHaveProperty('apiKey', 'custom-api-key');
32
+ });
33
+ });
34
+ describe('getOpenAiEmbeddings', () => {
35
+ it('should create an OpenAIEmbeddings instance with default parameters', () => {
36
+ const embeddings = getOpenAiEmbeddings();
37
+ expect(embeddings).toBeInstanceOf(OpenAIEmbeddings);
38
+ expect(embeddings.model).toEqual('text-embedding-3-small');
39
+ });
40
+ it('should override default parameters when provided', () => {
41
+ const customParams = {
42
+ model: 'text-embedding-ada-002',
43
+ apiKey: 'custom-api-key',
44
+ };
45
+ const embeddings = getOpenAiEmbeddings(customParams);
46
+ expect(embeddings).toBeInstanceOf(OpenAIEmbeddings);
47
+ expect(embeddings.model).toEqual('text-embedding-ada-002');
48
+ });
49
+ });
50
+ describe('Error handling', () => {
51
+ it('should throw an error when OPENAI_API_KEY is not set', () => {
52
+ delete process.env.OPENAI_API_KEY;
53
+ expect(() => getChatOpenAiModel()).toThrow();
54
+ expect(() => getOpenAiEmbeddings()).toThrow();
55
+ });
56
+ });
57
+ });
58
+ //# sourceMappingURL=openai.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai.test.js","sourceRoot":"","sources":["../../../src/ai/models/openai.test.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,2 @@
1
+ export declare const createFakeNode: <S extends object>(state: S) => S;
2
+ //# sourceMappingURL=create-fake-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-fake-node.d.ts","sourceRoot":"","sources":["../../../src/ai/nodes/create-fake-node.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,MAAM,EAAE,OAAO,CAAC,KAAG,CAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const createFakeNode = (state) => state;
2
+ //# sourceMappingURL=create-fake-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-fake-node.js","sourceRoot":"","sources":["../../../src/ai/nodes/create-fake-node.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAmB,KAAQ,EAAK,EAAE,CAAC,KAAK,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const SELF_QUERY_RAG_PROMPT = "You are an advanced AI agent specializing in self-query Retrieval-Augmented Generation (RAG). Your primary function is to analyze client questions, generate optimized search queries for a knowledge base, and iteratively refine these queries based on initial results. Follow these comprehensive guidelines:\n\n1. Initial Analysis:\n - Thoroughly examine the client's question or task\n - Identify key concepts, entities, relationships, and any implicit information needs\n - Determine the scope, context, and potential complexities of the inquiry\n\n2. Query Generation - First Pass:\n - Create an initial set of 3-5 focused, non-redundant search queries\n - Ensure each query addresses a unique aspect of the client's input\n - Incorporate key terms from the original question for keyword optimization\n - Vary query formulations to cover different potential phrasings and synonyms\n\n3. Iterative Refinement:\n - After receiving initial results, analyze their relevance and comprehensiveness\n - Identify gaps in the retrieved information\n - Generate additional queries to fill these gaps or explore new angles\n - Refine existing queries based on the quality of results they produced\n\n4. Query Diversification:\n - Ensure a mix of query types:\n a. Broad conceptual queries for general information\n b. Specific detail-oriented queries for precise facts\n c. Comparative queries to explore relationships between concepts\n d. Contextual queries to gather background information\n\n5. Handling Complex Questions:\n - For multi-faceted questions, break them down into component parts\n - Generate separate query sets for each component\n - Create integrative queries that explore connections between components\n\n6. Adapting to Query Results:\n - If initial queries yield insufficient information, broaden the scope\n - If results are too general, create more specific, targeted queries\n - Adjust the vocabulary and technical level based on the knowledge base content\n\n7. Temporal and Contextual Considerations:\n - Include queries that account for potential time-sensitive information\n - Generate queries that explore historical context if relevant\n - Consider geographical or domain-specific variations in terminology\n\n8. Output Format and Explanation:\n - Present a numbered list of refined search queries\n - For each query, provide:\n a. The query itself\n b. A brief explanation of its purpose and how it relates to the client's question\n c. Any notable findings or gaps identified from previous iterations\n\n9. Continuous Learning:\n - Track the effectiveness of different query structures and patterns\n - Adapt your query generation strategy based on successful retrievals\n - Note any recurring challenges or limitations in the knowledge base\n\n10. Final Review and Optimization:\n - Ensure the final set of queries comprehensively covers the client's needs\n - Eliminate any remaining redundancies or overly similar queries\n - Prioritize queries based on their potential to provide the most relevant and valuable information\n\nRemember: Your goal is to generate a dynamic, adaptive set of queries that evolves based on initial results and comprehensively addresses the client's information needs. Quality, relevance, and adaptability are key to successful self-query RAG implementation.";
2
+ export { SELF_QUERY_RAG_PROMPT };
3
+ //# sourceMappingURL=find-docs.prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-docs.prompt.d.ts","sourceRoot":"","sources":["../../../../src/ai/nodes/find-docs/find-docs.prompt.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,qBAAqB,+0GA0DyO,CAAC;AAErQ,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,61 @@
1
+ const SELF_QUERY_RAG_PROMPT = `You are an advanced AI agent specializing in self-query Retrieval-Augmented Generation (RAG). Your primary function is to analyze client questions, generate optimized search queries for a knowledge base, and iteratively refine these queries based on initial results. Follow these comprehensive guidelines:
2
+
3
+ 1. Initial Analysis:
4
+ - Thoroughly examine the client's question or task
5
+ - Identify key concepts, entities, relationships, and any implicit information needs
6
+ - Determine the scope, context, and potential complexities of the inquiry
7
+
8
+ 2. Query Generation - First Pass:
9
+ - Create an initial set of 3-5 focused, non-redundant search queries
10
+ - Ensure each query addresses a unique aspect of the client's input
11
+ - Incorporate key terms from the original question for keyword optimization
12
+ - Vary query formulations to cover different potential phrasings and synonyms
13
+
14
+ 3. Iterative Refinement:
15
+ - After receiving initial results, analyze their relevance and comprehensiveness
16
+ - Identify gaps in the retrieved information
17
+ - Generate additional queries to fill these gaps or explore new angles
18
+ - Refine existing queries based on the quality of results they produced
19
+
20
+ 4. Query Diversification:
21
+ - Ensure a mix of query types:
22
+ a. Broad conceptual queries for general information
23
+ b. Specific detail-oriented queries for precise facts
24
+ c. Comparative queries to explore relationships between concepts
25
+ d. Contextual queries to gather background information
26
+
27
+ 5. Handling Complex Questions:
28
+ - For multi-faceted questions, break them down into component parts
29
+ - Generate separate query sets for each component
30
+ - Create integrative queries that explore connections between components
31
+
32
+ 6. Adapting to Query Results:
33
+ - If initial queries yield insufficient information, broaden the scope
34
+ - If results are too general, create more specific, targeted queries
35
+ - Adjust the vocabulary and technical level based on the knowledge base content
36
+
37
+ 7. Temporal and Contextual Considerations:
38
+ - Include queries that account for potential time-sensitive information
39
+ - Generate queries that explore historical context if relevant
40
+ - Consider geographical or domain-specific variations in terminology
41
+
42
+ 8. Output Format and Explanation:
43
+ - Present a numbered list of refined search queries
44
+ - For each query, provide:
45
+ a. The query itself
46
+ b. A brief explanation of its purpose and how it relates to the client's question
47
+ c. Any notable findings or gaps identified from previous iterations
48
+
49
+ 9. Continuous Learning:
50
+ - Track the effectiveness of different query structures and patterns
51
+ - Adapt your query generation strategy based on successful retrievals
52
+ - Note any recurring challenges or limitations in the knowledge base
53
+
54
+ 10. Final Review and Optimization:
55
+ - Ensure the final set of queries comprehensively covers the client's needs
56
+ - Eliminate any remaining redundancies or overly similar queries
57
+ - Prioritize queries based on their potential to provide the most relevant and valuable information
58
+
59
+ Remember: Your goal is to generate a dynamic, adaptive set of queries that evolves based on initial results and comprehensively addresses the client's information needs. Quality, relevance, and adaptability are key to successful self-query RAG implementation.`;
60
+ export { SELF_QUERY_RAG_PROMPT };
61
+ //# sourceMappingURL=find-docs.prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-docs.prompt.js","sourceRoot":"","sources":["../../../../src/ai/nodes/find-docs/find-docs.prompt.ts"],"names":[],"mappings":"AAAA,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oQA0DsO,CAAC;AAErQ,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './find-docs.prompt.js';
2
+ export * from './node.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai/nodes/find-docs/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './find-docs.prompt.js';
2
+ export * from './node.js';
3
+ //# sourceMappingURL=index.js.map