@mate-academy/llm-gateway 8.8.2 → 8.8.3

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 (352) hide show
  1. package/dist/LLMError.d.ts +12 -0
  2. package/dist/LLMError.js +36 -0
  3. package/dist/LLMError.js.map +1 -0
  4. package/dist/LLMGateway.d.ts +30 -0
  5. package/dist/LLMGateway.js +56 -0
  6. package/dist/LLMGateway.js.map +1 -0
  7. package/dist/LLMGateway.typedefs.d.ts +5 -0
  8. package/dist/LLMGateway.typedefs.js +3 -0
  9. package/dist/LLMGateway.typedefs.js.map +1 -0
  10. package/dist/LLMService.constants.d.ts +26309 -0
  11. package/dist/LLMService.constants.js +35 -0
  12. package/dist/LLMService.constants.js.map +1 -0
  13. package/dist/LLMService.factory.d.ts +71 -0
  14. package/dist/LLMService.factory.js +102 -0
  15. package/dist/LLMService.factory.js.map +1 -0
  16. package/dist/LLMService.typedefs.d.ts +655 -0
  17. package/dist/LLMService.typedefs.js +72 -0
  18. package/dist/LLMService.typedefs.js.map +1 -0
  19. package/dist/advanced.d.ts +11 -0
  20. package/dist/advanced.js +32 -0
  21. package/dist/advanced.js.map +1 -0
  22. package/dist/client/LLMAgent.d.ts +76 -0
  23. package/dist/client/LLMAgent.js +36 -0
  24. package/dist/client/LLMAgent.js.map +1 -0
  25. package/dist/client/LLMClientEngine.d.ts +110 -0
  26. package/dist/client/LLMClientEngine.js +406 -0
  27. package/dist/client/LLMClientEngine.js.map +1 -0
  28. package/dist/client/agentRun.typedefs.d.ts +200 -0
  29. package/dist/client/agentRun.typedefs.js +25 -0
  30. package/dist/client/agentRun.typedefs.js.map +1 -0
  31. package/dist/client/agentRunner.d.ts +161 -0
  32. package/dist/client/agentRunner.js +517 -0
  33. package/dist/client/agentRunner.js.map +1 -0
  34. package/dist/client/codegen/fetchPromptRecords.d.ts +14 -0
  35. package/dist/client/codegen/fetchPromptRecords.js +90 -0
  36. package/dist/client/codegen/fetchPromptRecords.js.map +1 -0
  37. package/dist/client/codegen/generateSnapshot.d.ts +19 -0
  38. package/dist/client/codegen/generateSnapshot.js +28 -0
  39. package/dist/client/codegen/generateSnapshot.js.map +1 -0
  40. package/dist/client/codegen/index.d.ts +6 -0
  41. package/dist/client/codegen/index.js +23 -0
  42. package/dist/client/codegen/index.js.map +1 -0
  43. package/dist/client/codegen/promptCatalog.typedefs.d.ts +51 -0
  44. package/dist/client/codegen/promptCatalog.typedefs.js +3 -0
  45. package/dist/client/codegen/promptCatalog.typedefs.js.map +1 -0
  46. package/dist/client/codegen/promptName.d.ts +8 -0
  47. package/dist/client/codegen/promptName.js +21 -0
  48. package/dist/client/codegen/promptName.js.map +1 -0
  49. package/dist/client/codegen/renderSnapshot.constants.d.ts +7 -0
  50. package/dist/client/codegen/renderSnapshot.constants.js +16 -0
  51. package/dist/client/codegen/renderSnapshot.constants.js.map +1 -0
  52. package/dist/client/codegen/renderSnapshot.d.ts +9 -0
  53. package/dist/client/codegen/renderSnapshot.js +109 -0
  54. package/dist/client/codegen/renderSnapshot.js.map +1 -0
  55. package/dist/client/codegen/renderSnapshot.typedefs.d.ts +19 -0
  56. package/dist/client/codegen/renderSnapshot.typedefs.js +3 -0
  57. package/dist/client/codegen/renderSnapshot.typedefs.js.map +1 -0
  58. package/dist/client/coerceToolResult.d.ts +10 -0
  59. package/dist/client/coerceToolResult.js +38 -0
  60. package/dist/client/coerceToolResult.js.map +1 -0
  61. package/dist/client/createLLMClient.d.ts +10 -0
  62. package/dist/client/createLLMClient.js +47 -0
  63. package/dist/client/createLLMClient.js.map +1 -0
  64. package/dist/client/defineLLMPrompts.d.ts +34 -0
  65. package/dist/client/defineLLMPrompts.js +13 -0
  66. package/dist/client/defineLLMPrompts.js.map +1 -0
  67. package/dist/client/errors.d.ts +57 -0
  68. package/dist/client/errors.js +70 -0
  69. package/dist/client/errors.js.map +1 -0
  70. package/dist/client/index.d.ts +13 -0
  71. package/dist/client/index.js +30 -0
  72. package/dist/client/index.js.map +1 -0
  73. package/dist/client/llmClient.typedefs.d.ts +265 -0
  74. package/dist/client/llmClient.typedefs.js +11 -0
  75. package/dist/client/llmClient.typedefs.js.map +1 -0
  76. package/dist/client/llmConfig.schema.d.ts +53 -0
  77. package/dist/client/llmConfig.schema.js +49 -0
  78. package/dist/client/llmConfig.schema.js.map +1 -0
  79. package/dist/client/plainMessages.d.ts +12 -0
  80. package/dist/client/plainMessages.js +19 -0
  81. package/dist/client/plainMessages.js.map +1 -0
  82. package/dist/client/promptClientPort.typedefs.d.ts +60 -0
  83. package/dist/client/promptClientPort.typedefs.js +3 -0
  84. package/dist/client/promptClientPort.typedefs.js.map +1 -0
  85. package/dist/client/promptRegistry.runtime.d.ts +121 -0
  86. package/dist/client/promptRegistry.runtime.js +264 -0
  87. package/dist/client/promptRegistry.runtime.js.map +1 -0
  88. package/dist/client/promptSnapshot.typedefs.d.ts +55 -0
  89. package/dist/client/promptSnapshot.typedefs.js +3 -0
  90. package/dist/client/promptSnapshot.typedefs.js.map +1 -0
  91. package/dist/client/promptVariables.d.ts +7 -0
  92. package/dist/client/promptVariables.js +13 -0
  93. package/dist/client/promptVariables.js.map +1 -0
  94. package/dist/client/snapshotRuntime.d.ts +17 -0
  95. package/dist/client/snapshotRuntime.js +42 -0
  96. package/dist/client/snapshotRuntime.js.map +1 -0
  97. package/dist/client/snapshotRuntime.typedefs.d.ts +13 -0
  98. package/dist/client/snapshotRuntime.typedefs.js +3 -0
  99. package/dist/client/snapshotRuntime.typedefs.js.map +1 -0
  100. package/dist/client/validationGate.d.ts +24 -0
  101. package/dist/client/validationGate.js +54 -0
  102. package/dist/client/validationGate.js.map +1 -0
  103. package/dist/codegen.d.ts +6 -0
  104. package/dist/codegen.js +23 -0
  105. package/dist/codegen.js.map +1 -0
  106. package/dist/index.d.ts +10 -0
  107. package/dist/index.js +27 -0
  108. package/dist/index.js.map +1 -0
  109. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.constants.d.ts +873 -0
  110. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.constants.js +269 -0
  111. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.constants.js.map +1 -0
  112. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.d.ts +24 -0
  113. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.js +210 -0
  114. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.js.map +1 -0
  115. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs.d.ts +22 -0
  116. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs.js +20 -0
  117. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs.js.map +1 -0
  118. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAIService.factory.d.ts +6 -0
  119. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAIService.factory.js +18 -0
  120. package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAIService.factory.js.map +1 -0
  121. package/dist/providers/GoogleGenerativeAI/index.d.ts +5 -0
  122. package/dist/providers/GoogleGenerativeAI/index.js +22 -0
  123. package/dist/providers/GoogleGenerativeAI/index.js.map +1 -0
  124. package/dist/providers/GoogleGenerativeAI/schemas/GoogleSchemaAdapter.d.ts +12 -0
  125. package/dist/providers/GoogleGenerativeAI/schemas/GoogleSchemaAdapter.js +72 -0
  126. package/dist/providers/GoogleGenerativeAI/schemas/GoogleSchemaAdapter.js.map +1 -0
  127. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.d.ts +71 -0
  128. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.js +876 -0
  129. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.js.map +1 -0
  130. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAICompletion.service.d.ts +25 -0
  131. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAICompletion.service.js +216 -0
  132. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAICompletion.service.js.map +1 -0
  133. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.d.ts +10 -0
  134. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.js +136 -0
  135. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.js.map +1 -0
  136. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAITextToSpeech.service.d.ts +11 -0
  137. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAITextToSpeech.service.js +97 -0
  138. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAITextToSpeech.service.js.map +1 -0
  139. package/dist/providers/GoogleGenerativeAI/services/index.d.ts +4 -0
  140. package/dist/providers/GoogleGenerativeAI/services/index.js +21 -0
  141. package/dist/providers/GoogleGenerativeAI/services/index.js.map +1 -0
  142. package/dist/providers/LLMAPI/LLMAPI.constants.d.ts +35832 -0
  143. package/dist/providers/LLMAPI/LLMAPI.constants.js +8601 -0
  144. package/dist/providers/LLMAPI/LLMAPI.constants.js.map +1 -0
  145. package/dist/providers/LLMAPI/LLMAPI.entity.d.ts +6 -0
  146. package/dist/providers/LLMAPI/LLMAPI.entity.js +48 -0
  147. package/dist/providers/LLMAPI/LLMAPI.entity.js.map +1 -0
  148. package/dist/providers/LLMAPI/LLMAPI.typedefs.d.ts +516 -0
  149. package/dist/providers/LLMAPI/LLMAPI.typedefs.js +564 -0
  150. package/dist/providers/LLMAPI/LLMAPI.typedefs.js.map +1 -0
  151. package/dist/providers/LLMAPI/LLMAPI.voices.d.ts +376 -0
  152. package/dist/providers/LLMAPI/LLMAPI.voices.js +739 -0
  153. package/dist/providers/LLMAPI/LLMAPI.voices.js.map +1 -0
  154. package/dist/providers/LLMAPI/LLMAPIService.factory.d.ts +6 -0
  155. package/dist/providers/LLMAPI/LLMAPIService.factory.js +19 -0
  156. package/dist/providers/LLMAPI/LLMAPIService.factory.js.map +1 -0
  157. package/dist/providers/LLMAPI/index.d.ts +7 -0
  158. package/dist/providers/LLMAPI/index.js +24 -0
  159. package/dist/providers/LLMAPI/index.js.map +1 -0
  160. package/dist/providers/LLMAPI/schemas/LLMAPISchemaAdapter.d.ts +3 -0
  161. package/dist/providers/LLMAPI/schemas/LLMAPISchemaAdapter.js +8 -0
  162. package/dist/providers/LLMAPI/schemas/LLMAPISchemaAdapter.js.map +1 -0
  163. package/dist/providers/LLMAPI/services/LLMAPIAssistance.service.d.ts +76 -0
  164. package/dist/providers/LLMAPI/services/LLMAPIAssistance.service.js +825 -0
  165. package/dist/providers/LLMAPI/services/LLMAPIAssistance.service.js.map +1 -0
  166. package/dist/providers/LLMAPI/services/LLMAPICompletion.service.d.ts +25 -0
  167. package/dist/providers/LLMAPI/services/LLMAPICompletion.service.js +177 -0
  168. package/dist/providers/LLMAPI/services/LLMAPICompletion.service.js.map +1 -0
  169. package/dist/providers/LLMAPI/services/LLMAPISpeechToText.service.d.ts +17 -0
  170. package/dist/providers/LLMAPI/services/LLMAPISpeechToText.service.js +34 -0
  171. package/dist/providers/LLMAPI/services/LLMAPISpeechToText.service.js.map +1 -0
  172. package/dist/providers/LLMAPI/services/LLMAPITextToSpeech.service.d.ts +20 -0
  173. package/dist/providers/LLMAPI/services/LLMAPITextToSpeech.service.js +36 -0
  174. package/dist/providers/LLMAPI/services/LLMAPITextToSpeech.service.js.map +1 -0
  175. package/dist/providers/LLMAPI/services/index.d.ts +4 -0
  176. package/dist/providers/LLMAPI/services/index.js +21 -0
  177. package/dist/providers/LLMAPI/services/index.js.map +1 -0
  178. package/dist/providers/LLMAPI/utilities/index.d.ts +4 -0
  179. package/dist/providers/LLMAPI/utilities/index.js +13 -0
  180. package/dist/providers/LLMAPI/utilities/index.js.map +1 -0
  181. package/dist/providers/LLMAPI/utilities/parseXmlToolCalls.d.ts +7 -0
  182. package/dist/providers/LLMAPI/utilities/parseXmlToolCalls.js +35 -0
  183. package/dist/providers/LLMAPI/utilities/parseXmlToolCalls.js.map +1 -0
  184. package/dist/providers/LLMAPI/utilities/stripThinkingTags.d.ts +1 -0
  185. package/dist/providers/LLMAPI/utilities/stripThinkingTags.js +7 -0
  186. package/dist/providers/LLMAPI/utilities/stripThinkingTags.js.map +1 -0
  187. package/dist/providers/LLMAPI/utilities/structuredOutput.d.ts +13 -0
  188. package/dist/providers/LLMAPI/utilities/structuredOutput.js +29 -0
  189. package/dist/providers/LLMAPI/utilities/structuredOutput.js.map +1 -0
  190. package/dist/providers/LLMAPI/utilities/validateStructuredResponse.d.ts +10 -0
  191. package/dist/providers/LLMAPI/utilities/validateStructuredResponse.js +21 -0
  192. package/dist/providers/LLMAPI/utilities/validateStructuredResponse.js.map +1 -0
  193. package/dist/providers/OpenAI/OpenAI.constants.d.ts +1664 -0
  194. package/dist/providers/OpenAI/OpenAI.constants.js +310 -0
  195. package/dist/providers/OpenAI/OpenAI.constants.js.map +1 -0
  196. package/dist/providers/OpenAI/OpenAI.entity.d.ts +15 -0
  197. package/dist/providers/OpenAI/OpenAI.entity.js +162 -0
  198. package/dist/providers/OpenAI/OpenAI.entity.js.map +1 -0
  199. package/dist/providers/OpenAI/OpenAI.typedefs.d.ts +61 -0
  200. package/dist/providers/OpenAI/OpenAI.typedefs.js +39 -0
  201. package/dist/providers/OpenAI/OpenAI.typedefs.js.map +1 -0
  202. package/dist/providers/OpenAI/OpenAIService.factory.d.ts +6 -0
  203. package/dist/providers/OpenAI/OpenAIService.factory.js +18 -0
  204. package/dist/providers/OpenAI/OpenAIService.factory.js.map +1 -0
  205. package/dist/providers/OpenAI/index.d.ts +5 -0
  206. package/dist/providers/OpenAI/index.js +22 -0
  207. package/dist/providers/OpenAI/index.js.map +1 -0
  208. package/dist/providers/OpenAI/schemas/OpenAISchemaAdapter.d.ts +14 -0
  209. package/dist/providers/OpenAI/schemas/OpenAISchemaAdapter.js +87 -0
  210. package/dist/providers/OpenAI/schemas/OpenAISchemaAdapter.js.map +1 -0
  211. package/dist/providers/OpenAI/services/OpenAIAssistance.service.d.ts +42 -0
  212. package/dist/providers/OpenAI/services/OpenAIAssistance.service.js +712 -0
  213. package/dist/providers/OpenAI/services/OpenAIAssistance.service.js.map +1 -0
  214. package/dist/providers/OpenAI/services/OpenAICompletion.service.d.ts +7 -0
  215. package/dist/providers/OpenAI/services/OpenAICompletion.service.js +12 -0
  216. package/dist/providers/OpenAI/services/OpenAICompletion.service.js.map +1 -0
  217. package/dist/providers/OpenAI/services/OpenAISpeechToText.service.d.ts +17 -0
  218. package/dist/providers/OpenAI/services/OpenAISpeechToText.service.js +40 -0
  219. package/dist/providers/OpenAI/services/OpenAISpeechToText.service.js.map +1 -0
  220. package/dist/providers/OpenAI/services/OpenAITextToSpeech.service.d.ts +13 -0
  221. package/dist/providers/OpenAI/services/OpenAITextToSpeech.service.js +32 -0
  222. package/dist/providers/OpenAI/services/OpenAITextToSpeech.service.js.map +1 -0
  223. package/dist/providers/OpenAI/services/buildFunctionCallOutput.d.ts +3 -0
  224. package/dist/providers/OpenAI/services/buildFunctionCallOutput.js +19 -0
  225. package/dist/providers/OpenAI/services/buildFunctionCallOutput.js.map +1 -0
  226. package/dist/providers/OpenAI/services/index.d.ts +4 -0
  227. package/dist/providers/OpenAI/services/index.js +21 -0
  228. package/dist/providers/OpenAI/services/index.js.map +1 -0
  229. package/dist/providers/OpenAICompatible/OpenAICompatibleCompletion.service.d.ts +30 -0
  230. package/dist/providers/OpenAICompatible/OpenAICompatibleCompletion.service.js +233 -0
  231. package/dist/providers/OpenAICompatible/OpenAICompatibleCompletion.service.js.map +1 -0
  232. package/dist/providers/OpenAICompatible/OpenAICompatibleSpeechToText.service.d.ts +22 -0
  233. package/dist/providers/OpenAICompatible/OpenAICompatibleSpeechToText.service.js +98 -0
  234. package/dist/providers/OpenAICompatible/OpenAICompatibleSpeechToText.service.js.map +1 -0
  235. package/dist/providers/OpenAICompatible/OpenAICompatibleTextToSpeech.service.d.ts +22 -0
  236. package/dist/providers/OpenAICompatible/OpenAICompatibleTextToSpeech.service.js +67 -0
  237. package/dist/providers/OpenAICompatible/OpenAICompatibleTextToSpeech.service.js.map +1 -0
  238. package/dist/providers/index.d.ts +3 -0
  239. package/dist/providers/index.js +20 -0
  240. package/dist/providers/index.js.map +1 -0
  241. package/dist/services/LLMAssistanceService.abstract.d.ts +39 -0
  242. package/dist/services/LLMAssistanceService.abstract.js +101 -0
  243. package/dist/services/LLMAssistanceService.abstract.js.map +1 -0
  244. package/dist/services/LLMBaseService.abstract.d.ts +161 -0
  245. package/dist/services/LLMBaseService.abstract.js +392 -0
  246. package/dist/services/LLMBaseService.abstract.js.map +1 -0
  247. package/dist/services/LLMCompletionService.abstract.d.ts +16 -0
  248. package/dist/services/LLMCompletionService.abstract.js +12 -0
  249. package/dist/services/LLMCompletionService.abstract.js.map +1 -0
  250. package/dist/services/LLMServicePurposeFactory.abstract.d.ts +12 -0
  251. package/dist/services/LLMServicePurposeFactory.abstract.js +7 -0
  252. package/dist/services/LLMServicePurposeFactory.abstract.js.map +1 -0
  253. package/dist/services/LLMSpeechToTextService.abstract.d.ts +8 -0
  254. package/dist/services/LLMSpeechToTextService.abstract.js +12 -0
  255. package/dist/services/LLMSpeechToTextService.abstract.js.map +1 -0
  256. package/dist/services/LLMTextToSpeechService.abstract.d.ts +8 -0
  257. package/dist/services/LLMTextToSpeechService.abstract.js +12 -0
  258. package/dist/services/LLMTextToSpeechService.abstract.js.map +1 -0
  259. package/dist/services/agentRounds/LLMAgentRounds.d.ts +32 -0
  260. package/dist/services/agentRounds/LLMAgentRounds.js +77 -0
  261. package/dist/services/agentRounds/LLMAgentRounds.js.map +1 -0
  262. package/dist/services/agentRounds/agentRounds.typedefs.d.ts +48 -0
  263. package/dist/services/agentRounds/agentRounds.typedefs.js +3 -0
  264. package/dist/services/agentRounds/agentRounds.typedefs.js.map +1 -0
  265. package/dist/services/agentRounds/index.d.ts +2 -0
  266. package/dist/services/agentRounds/index.js +19 -0
  267. package/dist/services/agentRounds/index.js.map +1 -0
  268. package/dist/services/chatState/CompletionsChatState.d.ts +35 -0
  269. package/dist/services/chatState/CompletionsChatState.js +118 -0
  270. package/dist/services/chatState/CompletionsChatState.js.map +1 -0
  271. package/dist/services/chatState/index.d.ts +1 -0
  272. package/dist/services/chatState/index.js +6 -0
  273. package/dist/services/chatState/index.js.map +1 -0
  274. package/dist/services/fileStorage/FileStorageToolExecutor.d.ts +15 -0
  275. package/dist/services/fileStorage/FileStorageToolExecutor.js +172 -0
  276. package/dist/services/fileStorage/FileStorageToolExecutor.js.map +1 -0
  277. package/dist/services/fileStorage/InMemoryFileStorage.d.ts +20 -0
  278. package/dist/services/fileStorage/InMemoryFileStorage.js +67 -0
  279. package/dist/services/fileStorage/InMemoryFileStorage.js.map +1 -0
  280. package/dist/services/fileStorage/fileStorageTools.d.ts +26 -0
  281. package/dist/services/fileStorage/fileStorageTools.js +68 -0
  282. package/dist/services/fileStorage/fileStorageTools.js.map +1 -0
  283. package/dist/services/fileStorage/index.d.ts +4 -0
  284. package/dist/services/fileStorage/index.js +11 -0
  285. package/dist/services/fileStorage/index.js.map +1 -0
  286. package/dist/services/index.d.ts +7 -0
  287. package/dist/services/index.js +24 -0
  288. package/dist/services/index.js.map +1 -0
  289. package/dist/utilities/calculateCosts.d.ts +4 -0
  290. package/dist/utilities/calculateCosts.js +56 -0
  291. package/dist/utilities/calculateCosts.js.map +1 -0
  292. package/dist/utilities/functional.utils.d.ts +1 -0
  293. package/dist/utilities/functional.utils.js +9 -0
  294. package/dist/utilities/functional.utils.js.map +1 -0
  295. package/dist/utilities/index.d.ts +9 -0
  296. package/dist/utilities/index.js +26 -0
  297. package/dist/utilities/index.js.map +1 -0
  298. package/dist/utilities/llmTracing/index.d.ts +3 -0
  299. package/dist/utilities/llmTracing/index.js +20 -0
  300. package/dist/utilities/llmTracing/index.js.map +1 -0
  301. package/dist/utilities/llmTracing/llmTracing.constants.d.ts +7 -0
  302. package/dist/utilities/llmTracing/llmTracing.constants.js +11 -0
  303. package/dist/utilities/llmTracing/llmTracing.constants.js.map +1 -0
  304. package/dist/utilities/llmTracing/llmTracing.typedefs.d.ts +126 -0
  305. package/dist/utilities/llmTracing/llmTracing.typedefs.js +3 -0
  306. package/dist/utilities/llmTracing/llmTracing.typedefs.js.map +1 -0
  307. package/dist/utilities/llmTracing/noopLLMTracing.d.ts +3 -0
  308. package/dist/utilities/llmTracing/noopLLMTracing.js +36 -0
  309. package/dist/utilities/llmTracing/noopLLMTracing.js.map +1 -0
  310. package/dist/utilities/logger/LLMLoggerInterface.d.ts +36 -0
  311. package/dist/utilities/logger/LLMLoggerInterface.js +3 -0
  312. package/dist/utilities/logger/LLMLoggerInterface.js.map +1 -0
  313. package/dist/utilities/logger/index.d.ts +1 -0
  314. package/dist/utilities/logger/index.js +18 -0
  315. package/dist/utilities/logger/index.js.map +1 -0
  316. package/dist/utilities/promptBuilder.d.ts +58 -0
  317. package/dist/utilities/promptBuilder.js +92 -0
  318. package/dist/utilities/promptBuilder.js.map +1 -0
  319. package/dist/utilities/reporter/LLMReporterInterface.d.ts +46 -0
  320. package/dist/utilities/reporter/LLMReporterInterface.js +3 -0
  321. package/dist/utilities/reporter/LLMReporterInterface.js.map +1 -0
  322. package/dist/utilities/reporter/index.d.ts +1 -0
  323. package/dist/utilities/reporter/index.js +18 -0
  324. package/dist/utilities/reporter/index.js.map +1 -0
  325. package/dist/utilities/schema/LLMSchema.d.ts +112 -0
  326. package/dist/utilities/schema/LLMSchema.js +223 -0
  327. package/dist/utilities/schema/LLMSchema.js.map +1 -0
  328. package/dist/utilities/schema/LLMSchema.typedefs.d.ts +55 -0
  329. package/dist/utilities/schema/LLMSchema.typedefs.js +3 -0
  330. package/dist/utilities/schema/LLMSchema.typedefs.js.map +1 -0
  331. package/dist/utilities/schema/SchemaAdapterRegistry.d.ts +26 -0
  332. package/dist/utilities/schema/SchemaAdapterRegistry.js +32 -0
  333. package/dist/utilities/schema/SchemaAdapterRegistry.js.map +1 -0
  334. package/dist/utilities/schema/index.d.ts +2 -0
  335. package/dist/utilities/schema/index.js +19 -0
  336. package/dist/utilities/schema/index.js.map +1 -0
  337. package/dist/utilities/serializeError.d.ts +9 -0
  338. package/dist/utilities/serializeError.js +69 -0
  339. package/dist/utilities/serializeError.js.map +1 -0
  340. package/dist/utilities/tokenizer.d.ts +4 -0
  341. package/dist/utilities/tokenizer.js +14 -0
  342. package/dist/utilities/tokenizer.js.map +1 -0
  343. package/dist/utilities/tools/LLMTool.d.ts +5 -0
  344. package/dist/utilities/tools/LLMTool.js +10 -0
  345. package/dist/utilities/tools/LLMTool.js.map +1 -0
  346. package/dist/utilities/tools/index.d.ts +2 -0
  347. package/dist/utilities/tools/index.js +8 -0
  348. package/dist/utilities/tools/index.js.map +1 -0
  349. package/dist/utilities/tools/normalizeToolResult.d.ts +15 -0
  350. package/dist/utilities/tools/normalizeToolResult.js +18 -0
  351. package/dist/utilities/tools/normalizeToolResult.js.map +1 -0
  352. package/package.json +1 -1
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ /**
3
+ * Utility types and functions for handling prompts with dynamic replacements and conditional sections.
4
+ * This allows for type-safe string templates with placeholders that can be replaced with actual values.
5
+ * The `createPromptTemplate` function helps create typed prompts with automatic extraction of replacement keys.
6
+ *
7
+ * @module promptBuilder
8
+ * @example
9
+ * // Example usage:
10
+ * const PROMPTS = {
11
+ * welcomeMessage: createPromptTemplate(`
12
+ * Generate a welcome message for a user who has just started their auto tech check attempt on {{topicTitle}}.
13
+ * {{#hasBonus}}
14
+ * This topic includes bonus content: {{bonusContent}}
15
+ * {{/hasBonus}}
16
+ *
17
+ * {{#valueAsCondition}}
18
+ * This is a conditional section that will only appear if the value is truthy.
19
+ * Value can be used inside the section: {{valueAsCondition}}
20
+ * {{/valueAsCondition}}
21
+ *
22
+ * {{#!skipSection}}
23
+ * This negative conditional section will only appear if skipSection is falsy.
24
+ * {{/skipSection}}
25
+ * `),
26
+ * };
27
+ *
28
+ * const instruction = PROMPTS.welcomeMessage({
29
+ * topicTitle: 'JavaScript Basics',
30
+ * hasBonus: true,
31
+ * bonusContent: 'Advanced debugging techniques',
32
+ * });
33
+ *
34
+ * // This will generate a prompt:
35
+ * // "Generate a welcome message for a user who has just started their auto tech check attempt on JavaScript Basics.
36
+ * // This topic includes bonus content: Advanced debugging techniques"
37
+ */
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.createPromptTemplate = createPromptTemplate;
40
+ function promptBuilder(prompt, variables) {
41
+ if (!variables) {
42
+ return prompt;
43
+ }
44
+ const replaceVariables = (source) => (
45
+ // Replace all occurrences of the variable in the source string
46
+ Object.entries(variables).reduce((acc, [key, value]) => (acc.replace(new RegExp(`{{\\s*${key}\\s*}}`, 'g'), String(value))), source));
47
+ const processConditionalSections = (source) => {
48
+ // Process negative conditional sections first ({{#!condition}})
49
+ let result = source.replace(/{{#!(\w+)}}([\s\S]*?){{\/\1}}/g, (_, sectionName, content) => {
50
+ const value = variables[sectionName];
51
+ if (!value) {
52
+ // Recursively process nested conditional sections and then replace variables
53
+ const processedContent = processConditionalSections(content);
54
+ return replaceVariables(processedContent);
55
+ }
56
+ return '';
57
+ });
58
+ // Then process positive conditional sections ({{#condition}})
59
+ result = result.replace(/{{#(\w+)}}([\s\S]*?){{\/\1}}/g, (_, sectionName, content) => {
60
+ const value = variables[sectionName];
61
+ if (value) {
62
+ // Recursively process nested conditional sections and then replace variables
63
+ const processedContent = processConditionalSections(content);
64
+ return replaceVariables(processedContent);
65
+ }
66
+ return '';
67
+ });
68
+ return result;
69
+ };
70
+ let result = prompt;
71
+ // Process conditional sections first (with recursive handling for nested sections)
72
+ result = processConditionalSections(result);
73
+ // Then process regular variable replacements
74
+ result = replaceVariables(result);
75
+ return result;
76
+ }
77
+ /**
78
+ * Creates a prompt template function that can be used to generate prompts
79
+ * with dynamic replacements and conditional sections.
80
+ * @template T The type of the template string. Inferred from the provided template.
81
+ * @param {T} template The template string with placeholders:
82
+ * - for dynamic values (e.g., `{{topicTitle}}`)
83
+ * - for conditional sections (e.g., `{{#section}}...{{/section}}`)
84
+ * - for negative conditional sections (e.g., `{{#!section}}...{{/section}}`)
85
+ * - for sections that use conditional variables as values (e.g., `{{#bonus}}...{{bonus}}...{{/bonus}}`)
86
+ * @returns A function that takes the dynamic values and returns the generated prompt.
87
+ */
88
+ function createPromptTemplate(template) {
89
+ const trimmedTemplate = template.trim();
90
+ return (...args) => promptBuilder(trimmedTemplate, ...args);
91
+ }
92
+ //# sourceMappingURL=promptBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promptBuilder.js","sourceRoot":"","sources":["../../src/utilities/promptBuilder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;AAgJH,oDAQC;AA3ED,SAAS,aAAa,CACpB,MAAc,EACd,SAA2D;IAE3D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC;IACnD,+DAA+D;IAC/D,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CACtD,GAAG,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,SAAS,GAAG,QAAQ,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAClE,EAAE,MAAM,CAAC,CACX,CAAC;IAEF,MAAM,0BAA0B,GAAG,CAAC,MAAc,EAAU,EAAE;QAC5D,gEAAgE;QAChE,IAAI,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,gCAAgC,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE;YACxF,MAAM,KAAK,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;YAErC,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,6EAA6E;gBAC7E,MAAM,gBAAgB,GAAG,0BAA0B,CAAC,OAAO,CAAC,CAAC;gBAC7D,OAAO,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;YAC5C,CAAC;YAED,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;QAEH,8DAA8D;QAC9D,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,+BAA+B,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE;YACnF,MAAM,KAAK,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;YAErC,IAAI,KAAK,EAAE,CAAC;gBACV,6EAA6E;gBAC7E,MAAM,gBAAgB,GAAG,0BAA0B,CAAC,OAAO,CAAC,CAAC;gBAC7D,OAAO,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;YAC5C,CAAC;YAED,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,IAAI,MAAM,GAAG,MAAM,CAAC;IAEpB,mFAAmF;IACnF,MAAM,GAAG,0BAA0B,CAAC,MAAM,CAAC,CAAC;IAE5C,6CAA6C;IAC7C,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAElC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,oBAAoB,CAAmB,QAAW;IAChE,MAAM,eAAe,GAAG,QAAQ,CAAC,IAAI,EAAO,CAAC;IAE7C,OAAO,CACL,GAAG,IAEqC,EAChC,EAAE,CAAC,aAAa,CAAC,eAAe,EAAE,GAAG,IAAI,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { LLMProviders, LLMPurposes } from '../../LLMService.typedefs';
2
+ /**
3
+ * Core LLM metrics that are always collected by the gateway.
4
+ * These metrics are automatically populated during operations.
5
+ */
6
+ export interface LLMMetrics {
7
+ provider: LLMProviders;
8
+ purpose: LLMPurposes;
9
+ model: string | null;
10
+ modelConfig: Record<string, any> | null;
11
+ method: string;
12
+ status: 'success' | 'error' | 'cancelled';
13
+ tokens: {
14
+ input: number;
15
+ output: number;
16
+ total: number;
17
+ };
18
+ costs: {
19
+ input: number;
20
+ output: number;
21
+ total: number;
22
+ currency: string;
23
+ };
24
+ }
25
+ /**
26
+ * Function type for writing LLM metrics.
27
+ *
28
+ * @param metrics - The LLM metrics to write
29
+ * @returns A promise that resolves when the metrics have been written
30
+ */
31
+ export type LLMMetricsWriter = (metrics: LLMMetrics) => Promise<void>;
32
+ /**
33
+ * Simplified reporter interface for LLM metrics collection.
34
+ *
35
+ * @template ReporterContext - User-defined context schema type
36
+ */
37
+ export interface LLMReporterInterface<ReporterContext extends Record<string, any> | undefined = undefined> {
38
+ /**
39
+ * Initializes a metrics writer that tracks timing and provides write function.
40
+ * The returned write function automatically includes duration and can only be called once.
41
+ *
42
+ * @param reporterContext - Optional user-defined context to include with metrics
43
+ * @returns Write function that stops timer and writes metrics
44
+ */
45
+ initWriter(...args: ReporterContext extends undefined ? [] : [reporterContext: ReporterContext]): LLMMetricsWriter;
46
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=LLMReporterInterface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LLMReporterInterface.js","sourceRoot":"","sources":["../../../src/utilities/reporter/LLMReporterInterface.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export * from './LLMReporterInterface';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./LLMReporterInterface"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utilities/reporter/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC"}
@@ -0,0 +1,112 @@
1
+ import type { LLMProviders } from '../../LLMService.typedefs';
2
+ import type { LLMSchemaInterface, ParseResult, InferSchema } from '../../utilities/schema/LLMSchema.typedefs';
3
+ /**
4
+ * Concrete implementation of schema builder using Zod as the underlying validator.
5
+ * This implementation can be replaced with another validator without changing the public API.
6
+ */
7
+ export declare class LLMSchema<T = any> implements LLMSchemaInterface<T> {
8
+ private readonly zodSchema;
9
+ private constructor();
10
+ /**
11
+ * Creates a string schema
12
+ */
13
+ static string(): LLMSchemaInterface<string>;
14
+ /**
15
+ * Creates a number schema
16
+ */
17
+ static number(): LLMSchemaInterface<number>;
18
+ /**
19
+ * Creates a boolean schema
20
+ */
21
+ static boolean(): LLMSchemaInterface<boolean>;
22
+ /**
23
+ * Creates an object schema
24
+ */
25
+ static object<T extends Record<string, LLMSchemaInterface>>(shape: T): LLMSchemaInterface<{
26
+ [K in keyof T]: InferSchema<T[K]>;
27
+ }>;
28
+ /**
29
+ * Creates an array schema
30
+ */
31
+ static array<T>(itemSchema: LLMSchemaInterface<T>): LLMSchemaInterface<T[]>;
32
+ /**
33
+ * Creates an enum schema
34
+ */
35
+ static enum<T extends readonly [string, ...string[]]>(values: T): LLMSchemaInterface<T[number]>;
36
+ /**
37
+ * Creates a union schema
38
+ */
39
+ static union<T extends readonly [LLMSchemaInterface, ...LLMSchemaInterface[]]>(schemas: T): LLMSchemaInterface<InferSchema<T[number]>>;
40
+ /**
41
+ * Creates a literal schema
42
+ */
43
+ static literal<T extends string | number | boolean>(value: T): LLMSchemaInterface<T>;
44
+ /**
45
+ * Makes the schema optional
46
+ * In Zod v4, this also makes the field nullable to support provider adapters
47
+ * that convert optional fields to required+nullable (e.g., OpenAI structured output)
48
+ */
49
+ optional(): LLMSchemaInterface<T | undefined | null>;
50
+ /**
51
+ * Makes the schema nullable
52
+ */
53
+ nullable(): LLMSchemaInterface<T | null>;
54
+ /**
55
+ * Sets a default value
56
+ */
57
+ default(value: any): LLMSchemaInterface<T>;
58
+ /**
59
+ * Adds a description (for documentation)
60
+ */
61
+ describe(description: string): LLMSchemaInterface<T>;
62
+ /**
63
+ * Sets minimum string length
64
+ */
65
+ min(length: number): LLMSchemaInterface<T>;
66
+ /**
67
+ * Sets maximum string length
68
+ */
69
+ max(length: number): LLMSchemaInterface<T>;
70
+ /**
71
+ * Validates as email
72
+ */
73
+ email(): LLMSchemaInterface<T>;
74
+ /**
75
+ * Validates as URL
76
+ */
77
+ url(): LLMSchemaInterface<T>;
78
+ /**
79
+ * Validates as UUID
80
+ */
81
+ uuid(): LLMSchemaInterface<T>;
82
+ /**
83
+ * Validates as integer
84
+ */
85
+ int(): LLMSchemaInterface<T>;
86
+ /**
87
+ * Validates as positive number
88
+ */
89
+ positive(): LLMSchemaInterface<T>;
90
+ /**
91
+ * Validates as negative number
92
+ */
93
+ negative(): LLMSchemaInterface<T>;
94
+ /**
95
+ * Validates as non-positive number
96
+ */
97
+ nonpositive(): LLMSchemaInterface<T>;
98
+ /**
99
+ * Validates as non-negative number
100
+ */
101
+ nonnegative(): LLMSchemaInterface<T>;
102
+ /**
103
+ * @internal
104
+ * Parses data using the schema
105
+ */
106
+ _parse(data: unknown): ParseResult<T>;
107
+ /**
108
+ * @internal
109
+ * Converts schema to provider-specific format using the adapter registry
110
+ */
111
+ _toProviderSchema(provider: LLMProviders): any;
112
+ }
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LLMSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const SchemaAdapterRegistry_1 = require("../../utilities/schema/SchemaAdapterRegistry");
6
+ /**
7
+ * Concrete implementation of schema builder using Zod as the underlying validator.
8
+ * This implementation can be replaced with another validator without changing the public API.
9
+ */
10
+ class LLMSchema {
11
+ zodSchema;
12
+ constructor(zodSchema) {
13
+ this.zodSchema = zodSchema;
14
+ }
15
+ // ============ Factory Methods ============
16
+ /**
17
+ * Creates a string schema
18
+ */
19
+ static string() {
20
+ return new LLMSchema(zod_1.z.string());
21
+ }
22
+ /**
23
+ * Creates a number schema
24
+ */
25
+ static number() {
26
+ return new LLMSchema(zod_1.z.number());
27
+ }
28
+ /**
29
+ * Creates a boolean schema
30
+ */
31
+ static boolean() {
32
+ return new LLMSchema(zod_1.z.boolean());
33
+ }
34
+ /**
35
+ * Creates an object schema
36
+ */
37
+ static object(shape) {
38
+ const zodShape = {};
39
+ for (const [key, schema] of Object.entries(shape)) {
40
+ zodShape[key] = schema.zodSchema;
41
+ }
42
+ return new LLMSchema(zod_1.z.object(zodShape));
43
+ }
44
+ /**
45
+ * Creates an array schema
46
+ */
47
+ static array(itemSchema) {
48
+ return new LLMSchema(zod_1.z.array(itemSchema.zodSchema));
49
+ }
50
+ /**
51
+ * Creates an enum schema
52
+ */
53
+ static enum(values) {
54
+ return new LLMSchema(zod_1.z.enum(values));
55
+ }
56
+ /**
57
+ * Creates a union schema
58
+ */
59
+ static union(schemas) {
60
+ const zodSchemas = schemas.map(s => s.zodSchema);
61
+ return new LLMSchema(zod_1.z.union(zodSchemas));
62
+ }
63
+ /**
64
+ * Creates a literal schema
65
+ */
66
+ static literal(value) {
67
+ return new LLMSchema(zod_1.z.literal(value));
68
+ }
69
+ // ============ Modifier Methods ============
70
+ /**
71
+ * Makes the schema optional
72
+ * In Zod v4, this also makes the field nullable to support provider adapters
73
+ * that convert optional fields to required+nullable (e.g., OpenAI structured output)
74
+ */
75
+ optional() {
76
+ return new LLMSchema(this.zodSchema.optional().nullable());
77
+ }
78
+ /**
79
+ * Makes the schema nullable
80
+ */
81
+ nullable() {
82
+ return new LLMSchema(this.zodSchema.nullable());
83
+ }
84
+ /**
85
+ * Sets a default value
86
+ */
87
+ default(value) {
88
+ return new LLMSchema(this.zodSchema.default(value));
89
+ }
90
+ /**
91
+ * Adds a description (for documentation)
92
+ */
93
+ describe(description) {
94
+ return new LLMSchema(this.zodSchema.describe(description));
95
+ }
96
+ // ============ String-specific Modifiers ============
97
+ /**
98
+ * Sets minimum string length
99
+ */
100
+ min(length) {
101
+ if (this.zodSchema instanceof zod_1.z.ZodString) {
102
+ return new LLMSchema(this.zodSchema.min(length));
103
+ }
104
+ return this;
105
+ }
106
+ /**
107
+ * Sets maximum string length
108
+ */
109
+ max(length) {
110
+ if (this.zodSchema instanceof zod_1.z.ZodString) {
111
+ return new LLMSchema(this.zodSchema.max(length));
112
+ }
113
+ return this;
114
+ }
115
+ /**
116
+ * Validates as email
117
+ */
118
+ email() {
119
+ if (this.zodSchema instanceof zod_1.z.ZodString) {
120
+ return new LLMSchema(this.zodSchema.email());
121
+ }
122
+ return this;
123
+ }
124
+ /**
125
+ * Validates as URL
126
+ */
127
+ url() {
128
+ if (this.zodSchema instanceof zod_1.z.ZodString) {
129
+ return new LLMSchema(this.zodSchema.url());
130
+ }
131
+ return this;
132
+ }
133
+ /**
134
+ * Validates as UUID
135
+ */
136
+ uuid() {
137
+ if (this.zodSchema instanceof zod_1.z.ZodString) {
138
+ return new LLMSchema(this.zodSchema.uuid());
139
+ }
140
+ return this;
141
+ }
142
+ // ============ Number-specific Modifiers ============
143
+ /**
144
+ * Validates as integer
145
+ */
146
+ int() {
147
+ if (this.zodSchema instanceof zod_1.z.ZodNumber) {
148
+ return new LLMSchema(this.zodSchema.int());
149
+ }
150
+ return this;
151
+ }
152
+ /**
153
+ * Validates as positive number
154
+ */
155
+ positive() {
156
+ if (this.zodSchema instanceof zod_1.z.ZodNumber) {
157
+ return new LLMSchema(this.zodSchema.positive());
158
+ }
159
+ return this;
160
+ }
161
+ /**
162
+ * Validates as negative number
163
+ */
164
+ negative() {
165
+ if (this.zodSchema instanceof zod_1.z.ZodNumber) {
166
+ return new LLMSchema(this.zodSchema.negative());
167
+ }
168
+ return this;
169
+ }
170
+ /**
171
+ * Validates as non-positive number
172
+ */
173
+ nonpositive() {
174
+ if (this.zodSchema instanceof zod_1.z.ZodNumber) {
175
+ return new LLMSchema(this.zodSchema.nonpositive());
176
+ }
177
+ return this;
178
+ }
179
+ /**
180
+ * Validates as non-negative number
181
+ */
182
+ nonnegative() {
183
+ if (this.zodSchema instanceof zod_1.z.ZodNumber) {
184
+ return new LLMSchema(this.zodSchema.nonnegative());
185
+ }
186
+ return this;
187
+ }
188
+ // ============ Internal Methods (Package Use Only) ============
189
+ /**
190
+ * @internal
191
+ * Parses data using the schema
192
+ */
193
+ _parse(data) {
194
+ const result = this.zodSchema.safeParse(data);
195
+ if (result.success) {
196
+ return {
197
+ success: true,
198
+ data: result.data,
199
+ };
200
+ }
201
+ return {
202
+ success: false,
203
+ error: result.error.message,
204
+ };
205
+ }
206
+ /**
207
+ * @internal
208
+ * Converts schema to provider-specific format using the adapter registry
209
+ */
210
+ _toProviderSchema(provider) {
211
+ const adapter = (0, SchemaAdapterRegistry_1.getSchemaAdapter)(provider);
212
+ if (!adapter) {
213
+ throw new Error(`Provider ${provider} does not support structured output`);
214
+ }
215
+ const jsonSchema = zod_1.z.toJSONSchema(this.zodSchema, {
216
+ target: 'draft-7',
217
+ reused: 'inline',
218
+ });
219
+ return adapter.convertSchema(jsonSchema);
220
+ }
221
+ }
222
+ exports.LLMSchema = LLMSchema;
223
+ //# sourceMappingURL=LLMSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LLMSchema.js","sourceRoot":"","sources":["../../../src/utilities/schema/LLMSchema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;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AE;YAChD,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;CAEF;AA1PD,8BA0PC"}
@@ -0,0 +1,55 @@
1
+ import type { LLMProviders } from '../../LLMService.typedefs';
2
+ /**
3
+ * Result of parsing data against a schema
4
+ */
5
+ export interface ParseResult<T> {
6
+ success: boolean;
7
+ data?: T;
8
+ error?: string;
9
+ }
10
+ /**
11
+ * Abstract interface for schema implementations
12
+ * This allows for different validation libraries to be used internally
13
+ */
14
+ export interface LLMSchemaInterface<T = any> {
15
+ /**
16
+ * Parse and validate data against the schema
17
+ * @internal - Used internally by the package
18
+ */
19
+ _parse(data: unknown): ParseResult<T>;
20
+ /**
21
+ * Convert schema to provider-specific format using registered adapters
22
+ * @internal - Used internally by the package
23
+ */
24
+ _toProviderSchema(provider: LLMProviders): any;
25
+ optional(): LLMSchemaInterface<T | undefined | null>;
26
+ nullable(): LLMSchemaInterface<T | null>;
27
+ default(value: any): LLMSchemaInterface<T>;
28
+ describe(description: string): LLMSchemaInterface<T>;
29
+ min(length: number): LLMSchemaInterface<T>;
30
+ max(length: number): LLMSchemaInterface<T>;
31
+ email(): LLMSchemaInterface<T>;
32
+ url(): LLMSchemaInterface<T>;
33
+ uuid(): LLMSchemaInterface<T>;
34
+ int(): LLMSchemaInterface<T>;
35
+ positive(): LLMSchemaInterface<T>;
36
+ negative(): LLMSchemaInterface<T>;
37
+ nonpositive(): LLMSchemaInterface<T>;
38
+ nonnegative(): LLMSchemaInterface<T>;
39
+ }
40
+ /**
41
+ * Type inference helper for schemas
42
+ */
43
+ export type InferSchema<T> = T extends LLMSchemaInterface<infer U> ? U : never;
44
+ /**
45
+ * Interface for schema adapters that convert generic JSON Schema
46
+ * to provider-specific formats
47
+ */
48
+ export interface SchemaAdapterInterface {
49
+ /**
50
+ * Converts a JSON Schema to provider-specific format
51
+ * @param jsonSchema - The JSON Schema to convert
52
+ * @returns The provider-specific schema format
53
+ */
54
+ convertSchema(jsonSchema: any): any;
55
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=LLMSchema.typedefs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LLMSchema.typedefs.js","sourceRoot":"","sources":["../../../src/utilities/schema/LLMSchema.typedefs.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import { LLMProviders } from '../../LLMService.typedefs';
2
+ import type { SchemaAdapterInterface } from '../../utilities/schema/LLMSchema.typedefs';
3
+ import { OpenAISchemaAdapter } from '../../providers/OpenAI/schemas/OpenAISchemaAdapter';
4
+ import { GoogleSchemaAdapter } from '../../providers/GoogleGenerativeAI/schemas/GoogleSchemaAdapter';
5
+ import { LLMAPISchemaAdapter } from '../../providers/LLMAPI/schemas/LLMAPISchemaAdapter';
6
+ /**
7
+ * Type-safe registry of schema adapters for all supported providers.
8
+ *
9
+ * When adding a new provider:
10
+ * 1. Add the provider to LLMProviders enum
11
+ * 2. Create the schema adapter implementing SchemaAdapterInterface
12
+ * 3. Add the adapter to this registry (TypeScript will enforce this)
13
+ * 4. Set to `null` if the provider doesn't support structured output
14
+ *
15
+ * This ensures compile-time safety and forces developers to handle all providers.
16
+ */
17
+ export declare const SCHEMA_ADAPTER_REGISTRY: {
18
+ readonly OpenAI: OpenAISchemaAdapter;
19
+ readonly GoogleGenerativeAI: GoogleSchemaAdapter;
20
+ readonly LLMAPI: LLMAPISchemaAdapter;
21
+ };
22
+ /**
23
+ * Type-safe helper to get a schema adapter for a provider.
24
+ * Returns null if the provider doesn't support structured output.
25
+ */
26
+ export declare function getSchemaAdapter(provider: LLMProviders): SchemaAdapterInterface | null;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SCHEMA_ADAPTER_REGISTRY = void 0;
4
+ exports.getSchemaAdapter = getSchemaAdapter;
5
+ const LLMService_typedefs_1 = require("../../LLMService.typedefs");
6
+ const OpenAISchemaAdapter_1 = require("../../providers/OpenAI/schemas/OpenAISchemaAdapter");
7
+ const GoogleSchemaAdapter_1 = require("../../providers/GoogleGenerativeAI/schemas/GoogleSchemaAdapter");
8
+ const LLMAPISchemaAdapter_1 = require("../../providers/LLMAPI/schemas/LLMAPISchemaAdapter");
9
+ /**
10
+ * Type-safe registry of schema adapters for all supported providers.
11
+ *
12
+ * When adding a new provider:
13
+ * 1. Add the provider to LLMProviders enum
14
+ * 2. Create the schema adapter implementing SchemaAdapterInterface
15
+ * 3. Add the adapter to this registry (TypeScript will enforce this)
16
+ * 4. Set to `null` if the provider doesn't support structured output
17
+ *
18
+ * This ensures compile-time safety and forces developers to handle all providers.
19
+ */
20
+ exports.SCHEMA_ADAPTER_REGISTRY = {
21
+ [LLMService_typedefs_1.LLMProviders.OpenAI]: new OpenAISchemaAdapter_1.OpenAISchemaAdapter(),
22
+ [LLMService_typedefs_1.LLMProviders.GoogleGenerativeAI]: new GoogleSchemaAdapter_1.GoogleSchemaAdapter(),
23
+ [LLMService_typedefs_1.LLMProviders.LLMAPI]: new LLMAPISchemaAdapter_1.LLMAPISchemaAdapter(),
24
+ };
25
+ /**
26
+ * Type-safe helper to get a schema adapter for a provider.
27
+ * Returns null if the provider doesn't support structured output.
28
+ */
29
+ function getSchemaAdapter(provider) {
30
+ return exports.SCHEMA_ADAPTER_REGISTRY[provider];
31
+ }
32
+ //# sourceMappingURL=SchemaAdapterRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaAdapterRegistry.js","sourceRoot":"","sources":["../../../src/utilities/schema/SchemaAdapterRegistry.ts"],"names":[],"mappings":";;;AA2BA,4CAEC;AA7BD,+DAAqD;AAErD,wFAAqF;AACrF,oGAAiG;AACjG,wFAAqF;AAErF;;;;;;;;;;GAUG;AACU,QAAA,uBAAuB,GAAG;IACrC,CAAC,kCAAY,CAAC,MAAM,CAAC,EAAE,IAAI,yCAAmB,EAAE;IAChD,CAAC,kCAAY,CAAC,kBAAkB,CAAC,EAAE,IAAI,yCAAmB,EAAE;IAC5D,CAAC,kCAAY,CAAC,MAAM,CAAC,EAAE,IAAI,yCAAmB,EAAE;CACsB,CAAC;AAEzE;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,QAAsB;IACrD,OAAO,+BAAuB,CAAC,QAAQ,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './LLMSchema.typedefs';
2
+ export * from './LLMSchema';