@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,655 @@
1
+ import type { OpenAIClient, OpenAIClientOptions, OpenAIModelConfigOverrides, OpenAIModelNames, OpenAISpeechOptions } from './providers/OpenAI/OpenAI.typedefs';
2
+ import type { GoogleGenerativeAIClient, GoogleGenerativeAIClientOptions, GoogleGenerativeAIModelNames, GoogleGenerativeAISpeechOptions, GoogleGenerativeAIModelConfigOverrides } from './providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs';
3
+ import type { LLMAPIClient, LLMAPIClientOptions, LLMAPIModelNames, LLMAPIModelConfigOverrides, LLMAPISpeechOptions } from './providers/LLMAPI/LLMAPI.typedefs';
4
+ import type { LLMCompletionService, LLMAssistanceService, LLMSpeechToTextService, LLMTextToSpeechService } from './services';
5
+ import type { LLMLoggerInterface } from './utilities/logger';
6
+ import type { LLMReporterInterface } from './utilities/reporter';
7
+ import type { LLMSchemaInterface, InferSchema } from './utilities/schema';
8
+ import type { LLMTracedPrompt } from './utilities/llmTracing/llmTracing.typedefs';
9
+ /**
10
+ * Enum of supported LLM providers.
11
+ */
12
+ export declare enum LLMProviders {
13
+ OpenAI = "OpenAI",
14
+ GoogleGenerativeAI = "GoogleGenerativeAI",
15
+ LLMAPI = "LLMAPI"
16
+ }
17
+ /**
18
+ * Maps each LLM provider to its corresponding instance type.
19
+ */
20
+ export type LLMInstances = {
21
+ [LLMProviders.OpenAI]: OpenAIClient;
22
+ [LLMProviders.GoogleGenerativeAI]: GoogleGenerativeAIClient;
23
+ [LLMProviders.LLMAPI]: LLMAPIClient;
24
+ };
25
+ /**
26
+ * Configuration options for initializing each LLM provider's client.
27
+ */
28
+ export type LLMInstanceOptions = {
29
+ [LLMProviders.OpenAI]: OpenAIClientOptions;
30
+ [LLMProviders.GoogleGenerativeAI]: GoogleGenerativeAIClientOptions;
31
+ [LLMProviders.LLMAPI]: LLMAPIClientOptions;
32
+ };
33
+ /**
34
+ * Supported service purposes/types that the LLM gateway provides.
35
+ */
36
+ export declare enum LLMPurposes {
37
+ Completion = "completion",
38
+ Assistance = "assistance",
39
+ SpeechToText = "speech_to_text",
40
+ TextToSpeech = "text_to_speech"
41
+ }
42
+ /**
43
+ * Maps each LLM purpose to its corresponding service implementation for a specific provider.
44
+ * @template Provider - The LLM provider type
45
+ * @template Reporter - The reporter interface type
46
+ */
47
+ export type LLMServiceByPurpose<Provider extends LLMProviders, Reporter extends LLMReporterInterface<any> | undefined> = {
48
+ [LLMPurposes.Completion]: LLMCompletionService<Provider, Reporter>;
49
+ [LLMPurposes.Assistance]: LLMAssistanceService<Provider, Reporter>;
50
+ [LLMPurposes.SpeechToText]: LLMSpeechToTextService<Provider, Reporter>;
51
+ [LLMPurposes.TextToSpeech]: LLMTextToSpeechService<Provider, Reporter>;
52
+ };
53
+ /**
54
+ * Function type for building an LLM service instance for a specific provider and purpose.
55
+ * @template Provider - The LLM provider type
56
+ * @template Purpose - The service purpose type
57
+ * @template Reporter - Reporter interface type (optional)
58
+ * @param logger - Optional LLMLogger instance for service logging
59
+ * @param reporter - Optional reporter instance for metrics collection
60
+ * @param options - Provider-specific configuration options
61
+ * @returns An instance of the requested LLM service
62
+ */
63
+ export type LLMServiceBuilder<Provider extends LLMProviders, Purpose extends LLMPurposes, Reporter extends LLMReporterInterface<any> | undefined> = (logger: LLMLoggerInterface | undefined, reporter: Reporter, options?: LLMInstanceOptions[Provider]) => LLMServiceByPurpose<Provider, Reporter>[Purpose];
64
+ /**
65
+ * Defines token limits for LLM models.
66
+ */
67
+ export interface LLMLimits {
68
+ maxInputTokens: number;
69
+ maxOutputTokens: number;
70
+ }
71
+ /**
72
+ * Describes which capabilities an LLM model supports.
73
+ */
74
+ export interface LLMModelCapabilities {
75
+ vision: boolean;
76
+ tools: boolean;
77
+ reasoning: boolean;
78
+ webSearch: boolean;
79
+ jsonOutput?: boolean;
80
+ structuredOutputs?: boolean;
81
+ tts?: boolean;
82
+ stt?: boolean;
83
+ /**
84
+ * Whether the model's tool/function-result message can natively carry
85
+ * images. When absent or false, providers surface tool-returned images
86
+ * through a separate user message instead.
87
+ */
88
+ multimodalToolResults?: boolean;
89
+ }
90
+ /**
91
+ * Configuration parameters that control LLM generation behavior.
92
+ */
93
+ export type LLMConfig<Provider extends LLMProviders = any, ModelName extends LLMModelName[Provider] = any> = Partial<{
94
+ temperature: number;
95
+ top_p: number | null;
96
+ }> & (Provider extends LLMProviders.OpenAI ? OpenAIModelConfigOverrides<ModelName> : Provider extends LLMProviders.GoogleGenerativeAI ? GoogleGenerativeAIModelConfigOverrides<ModelName> : Provider extends LLMProviders.LLMAPI ? LLMAPIModelConfigOverrides<ModelName> : {});
97
+ /**
98
+ * Maps a provider to all available models it can access.
99
+ * @template Provider - The LLM provider type
100
+ */
101
+ export type LLMProviderAvailableModels<Provider extends LLMProviders> = {
102
+ [ModelName in LLMModelName[Provider]]: LLMModel<Provider, ModelName>;
103
+ };
104
+ /**
105
+ * Maps service purposes to the available models for a specific provider.
106
+ * @template Purpose - The service purpose type
107
+ * @template Provider - The LLM provider type
108
+ */
109
+ export type LLMProviderModelsByPurpose<Purpose extends LLMPurposes, Provider extends LLMProviders> = Record<Purpose, Partial<LLMProviderAvailableModels<Provider>>>;
110
+ /**
111
+ * Maps each provider to its supported model names.
112
+ */
113
+ export type LLMModelName = {
114
+ [LLMProviders.OpenAI]: OpenAIModelNames;
115
+ [LLMProviders.GoogleGenerativeAI]: GoogleGenerativeAIModelNames;
116
+ [LLMProviders.LLMAPI]: LLMAPIModelNames;
117
+ };
118
+ /**
119
+ * Represents an LLM model with its configuration and limitations.
120
+ * @template Provider - The LLM provider type
121
+ * @template ModelName - The specific model name for the provider
122
+ */
123
+ export interface LLMModel<Provider extends LLMProviders, ModelName extends LLMModelName[Provider] = LLMModelName[Provider]> {
124
+ name: ModelName;
125
+ limits: LLMLimits;
126
+ config: LLMConfig<Provider, ModelName>;
127
+ pricing: LLMModelPricing;
128
+ capabilities?: LLMModelCapabilities;
129
+ }
130
+ /**
131
+ * Pricing information for LLM models
132
+ */
133
+ export interface LLMModelPricing {
134
+ /**
135
+ * Pricing calculation for text input
136
+ */
137
+ getPriceForTextInput: (tokens: number) => number;
138
+ /**
139
+ * Pricing calculation for text output
140
+ */
141
+ getPriceForTextOutput: (tokens: number) => number;
142
+ /**
143
+ * Pricing calculation for audio input
144
+ */
145
+ getPriceForAudioInput: (audio_tokens: number) => number;
146
+ /**
147
+ * Pricing calculation for audio output
148
+ */
149
+ getPriceForAudioOutput: (audio_tokens: number) => number;
150
+ /**
151
+ * Pricing calculation for cached text input (optional)
152
+ * If not provided, cached tokens will be charged at regular text input rate
153
+ * OpenAI: 50% discount on cached tokens
154
+ * Google: 75-90% discount depending on model
155
+ */
156
+ getPriceForCachedTextInput?: (tokens: number) => number;
157
+ /**
158
+ * Pricing calculation for cached audio input (optional)
159
+ * If not provided, cached tokens will be charged at regular audio input rate
160
+ */
161
+ getPriceForCachedAudioInput?: (audio_tokens: number) => number;
162
+ /**
163
+ * Currency code for the pricing
164
+ */
165
+ currency: 'USD';
166
+ }
167
+ /**
168
+ * Roles that can be assigned to messages in an LLM conversation.
169
+ */
170
+ export declare enum LLMRoles {
171
+ User = "user",
172
+ Assistant = "assistant"
173
+ }
174
+ /**
175
+ * Possible content types for messages in an LLM conversation.
176
+ */
177
+ export declare enum LLMMessageContentType {
178
+ TEXT = "text",
179
+ IMAGE_URL = "image_url",
180
+ AUDIO_FILE = "audio_file"
181
+ }
182
+ /**
183
+ * Represents a text part in a message in an LLM conversation.
184
+ */
185
+ export interface LLMMessageTextContent {
186
+ type: LLMMessageContentType.TEXT;
187
+ text: string;
188
+ }
189
+ /**
190
+ * Represents an image part (by url) in a message in an LLM conversation.
191
+ */
192
+ export interface LLMMessageImageUrlContent {
193
+ type: LLMMessageContentType.IMAGE_URL;
194
+ image_url: {
195
+ url: string;
196
+ detail?: 'auto' | 'low' | 'high';
197
+ };
198
+ }
199
+ /**
200
+ * Union type for all possible message content types in an LLM completion.
201
+ */
202
+ export type LLMCompletionsMessageContent = LLMMessageTextContent | LLMMessageImageUrlContent;
203
+ /**
204
+ * Union type for all possible message content types in an LLM assistance.
205
+ */
206
+ export type LLMAssistanceMessageContent = LLMMessageTextContent | LLMMessageImageUrlContent;
207
+ /**
208
+ * Represents an audio file buffer
209
+ */
210
+ export type LLMAudioContent = {
211
+ type: LLMMessageContentType.AUDIO_FILE;
212
+ buffer: Buffer<ArrayBuffer>;
213
+ };
214
+ /**
215
+ * Represents a message in an LLM completion request.
216
+ */
217
+ export interface LLMCompletionMessage {
218
+ role: LLMRoles;
219
+ content: LLMCompletionsMessageContent[];
220
+ }
221
+ /**
222
+ * Represents a message in an LLM assistance request.
223
+ */
224
+ export interface LLMAssistanceMessage {
225
+ role: LLMRoles;
226
+ content: LLMAssistanceMessageContent[];
227
+ }
228
+ /**
229
+ * Represents an error that occurred during an LLM request.
230
+ */
231
+ export type LLMRequestError = Error;
232
+ /**
233
+ * Token usage reported by an LLM provider for a single call.
234
+ */
235
+ export interface LLMModelUsage {
236
+ inputTextTokens?: number;
237
+ outputTextTokens?: number;
238
+ inputAudioTokens?: number;
239
+ outputAudioTokens?: number;
240
+ inputCachedTextTokens?: number;
241
+ inputCachedAudioTokens?: number;
242
+ outputReasoningTokens?: number;
243
+ }
244
+ /**
245
+ * Absolute USD cost for a single LLM call, derived from usage and model pricing.
246
+ */
247
+ export interface LLMCostsResult {
248
+ input: number;
249
+ output: number;
250
+ total: number;
251
+ currency: string;
252
+ }
253
+ /**
254
+ * Generic result type for LLM requests that can either succeed or fail.
255
+ * @template ResponseType - The type of the successful result
256
+ */
257
+ export type LLMRequestResult<ResponseType> = ResponseType | {
258
+ error: LLMRequestError;
259
+ };
260
+ /**
261
+ * Result type for LLM completion requests.
262
+ */
263
+ export type LLMCompletionResult = LLMRequestResult<{
264
+ text: string;
265
+ usage?: LLMModelUsage;
266
+ cost?: LLMCostsResult;
267
+ }>;
268
+ /**
269
+ * Base options for LLM methods that can be extended by specific method options.
270
+ * Contains common properties like abort signal for cancellation.
271
+ * @template Reporter - Reporter interface type
272
+ */
273
+ export type LLMMethodBaseOptions<Reporter extends LLMReporterInterface<any> | undefined> = {
274
+ abortSignal?: AbortSignal;
275
+ traceContext?: LLMCallTraceContext;
276
+ } & (Reporter extends LLMReporterInterface<infer R> ? R extends undefined ? {
277
+ reporterContext?: never;
278
+ } : {
279
+ reporterContext: R;
280
+ } : {
281
+ reporterContext?: never;
282
+ });
283
+ /**
284
+ * Per-call trace context threaded into a single gateway call. When a prompt is
285
+ * present it names the observation instead of `<service>/<method>` and links
286
+ * the observation to its managed prompt version.
287
+ */
288
+ export type LLMCallTraceContext = {
289
+ prompt?: LLMTracedPrompt;
290
+ /**
291
+ * Names the observation. Wins over every other source, and is the only way to
292
+ * name a call that has no managed prompt to borrow a name from - speech-to-text
293
+ * and text-to-speech, which would otherwise read as `<service>/<method>` and
294
+ * lose the domain operation they belong to.
295
+ */
296
+ name?: string;
297
+ /**
298
+ * @deprecated Use `prompt`. Kept on 7.8 for compatibility; still names the
299
+ * observation when `prompt` is absent.
300
+ */
301
+ promptName?: string;
302
+ /**
303
+ * The user this call was made for, as a typed trace attribute. Travels beside
304
+ * the metadata bag rather than inside it, because the tracer promotes it to
305
+ * the trace's own user field.
306
+ */
307
+ userId?: string;
308
+ /**
309
+ * Groups every trace of one conversation, review, or agent run under a single
310
+ * Langfuse session. A typed trace attribute, never a metadata key.
311
+ */
312
+ sessionId?: string;
313
+ /** Langfuse trace tags. A typed trace attribute, never a metadata key. */
314
+ tags?: string[];
315
+ metadata?: Record<string, string | number | boolean>;
316
+ };
317
+ /**
318
+ * Options for sending a message to an LLM service.
319
+ * @template Provider - The LLM provider type
320
+ * @template Reporter - Reporter interface type
321
+ */
322
+ export type LLMSendMessageOptions<Provider extends LLMProviders, Reporter extends LLMReporterInterface<any> | undefined> = LLMMethodBaseOptions<Reporter> & {
323
+ message: LLMCompletionMessage;
324
+ model: LLMModel<Provider>;
325
+ history?: LLMCompletionMessage[];
326
+ instructions?: string;
327
+ };
328
+ /**
329
+ * Result type for structured output from LLM providers.
330
+ * @template T - The type of the structured data
331
+ */
332
+ export type LLMStructuredResult<T = any> = LLMRequestResult<{
333
+ text: string;
334
+ data?: T;
335
+ parseError?: string;
336
+ toolIterationsUsed?: number;
337
+ toolIterationsExhausted?: true;
338
+ stopReason?: LLMToolLoopStopReasons;
339
+ terminalTool?: LLMTerminalToolOutcome;
340
+ usage?: LLMModelUsage;
341
+ cost?: LLMCostsResult;
342
+ }>;
343
+ /**
344
+ * Limits for files that can be uploaded to LLM services.
345
+ */
346
+ export type LLMFileLimits = {
347
+ maxFileSize: number;
348
+ supportedMimeTypes: LLMUploadFileMimeTypes[];
349
+ };
350
+ /**
351
+ * Supported MIME types for files that can be uploaded to LLM services.
352
+ */
353
+ export declare enum LLMUploadFileMimeTypes {
354
+ IMAGE_PNG = "image/png",
355
+ IMAGE_JPEG = "image/jpeg",
356
+ IMAGE_JPG = "image/jpg",
357
+ IMAGE_GIF = "image/gif",
358
+ IMAGE_WEBP = "image/webp",
359
+ IMAGE_SVG_XML = "image/svg+xml",
360
+ IMAGE_BMP = "image/bmp",
361
+ PLAIN_TEXT = "text/plain",
362
+ MARKDOWN = "text/markdown",
363
+ AUDIO_MP3 = "audio/mp3",
364
+ AUDIO_MPEG = "audio/mpeg",
365
+ AUDIO_WAV = "audio/wav",
366
+ AUDIO_WEBM = "audio/webm",
367
+ AUDIO_OGG = "audio/ogg"
368
+ }
369
+ /**
370
+ * Represents the MIME types for images that can be uploaded to LLM services.
371
+ */
372
+ export type LLMImageMimeType = LLMUploadFileMimeTypes.IMAGE_PNG | LLMUploadFileMimeTypes.IMAGE_JPEG | LLMUploadFileMimeTypes.IMAGE_JPG | LLMUploadFileMimeTypes.IMAGE_GIF | LLMUploadFileMimeTypes.IMAGE_WEBP | LLMUploadFileMimeTypes.IMAGE_SVG_XML | LLMUploadFileMimeTypes.IMAGE_BMP;
373
+ /**
374
+ * Represents the MIME types for audio files that can be uploaded to LLM services.
375
+ */
376
+ export type LLMAudioMimeType = LLMUploadFileMimeTypes.AUDIO_MP3 | LLMUploadFileMimeTypes.AUDIO_MPEG | LLMUploadFileMimeTypes.AUDIO_WAV | LLMUploadFileMimeTypes.AUDIO_WEBM | LLMUploadFileMimeTypes.AUDIO_OGG;
377
+ /**
378
+ * Represents a file to be uploaded to an LLM service.
379
+ * @template Reporter - Reporter interface type
380
+ */
381
+ export type LLMUploadFileOptions<Reporter extends LLMReporterInterface<any> | undefined> = LLMMethodBaseOptions<Reporter> & {
382
+ mimeType: LLMUploadFileMimeTypes;
383
+ name: string;
384
+ path: string;
385
+ };
386
+ /**
387
+ * Represents a file that has been successfully uploaded to an LLM service.
388
+ */
389
+ export interface LLMUploadedFile extends Omit<LLMUploadFileOptions<any>, 'reporterContext' | 'abortSignal'> {
390
+ fileId: string;
391
+ }
392
+ /**
393
+ * Result type for file upload operations.
394
+ */
395
+ export type LLMUploadFileResult = LLMRequestResult<LLMUploadedFile>;
396
+ /**
397
+ * Options for creating a file storage for a specific LLM provider.
398
+ * @template Provider - The LLM provider type
399
+ * @template Reporter - Reporter interface type
400
+ */
401
+ export type LLMCreateFileStorageOptions<Provider extends LLMProviders, Reporter extends LLMReporterInterface<any> | undefined> = LLMMethodBaseOptions<Reporter> & {
402
+ uploadedFiles: LLMUploadedFile[];
403
+ model: LLMModel<Provider>;
404
+ instructions?: string;
405
+ };
406
+ /**
407
+ * Represents a created file storage in an LLM service.
408
+ */
409
+ export interface LLMCreatedFileStorage {
410
+ storageId: string;
411
+ }
412
+ /**
413
+ * Result type for file storage creation operations.
414
+ */
415
+ export type LLMCreateFileStorageResult = LLMRequestResult<LLMCreatedFileStorage>;
416
+ /**
417
+ * Options for creating a chat session with a specific LLM provider.
418
+ * @template Provider - The LLM provider type
419
+ * @template Reporter - Reporter interface type
420
+ */
421
+ export type LLMCreateChatOptions<Provider extends LLMProviders, Reporter extends LLMReporterInterface<any> | undefined> = LLMMethodBaseOptions<Reporter> & {
422
+ model: LLMModel<Provider>;
423
+ instructions?: string;
424
+ history?: LLMAssistanceMessage[];
425
+ storageId?: string;
426
+ files?: LLMUploadedFile[];
427
+ };
428
+ /**
429
+ * Represents a created chat session in an LLM service.
430
+ */
431
+ export interface LLMCreatedChat {
432
+ chatId: string;
433
+ }
434
+ /**
435
+ * Result type for chat creation operations.
436
+ */
437
+ export type LLMCreateChatResult = LLMRequestResult<LLMCreatedChat>;
438
+ /**
439
+ * Options for chat assistance with a specific LLM provider.
440
+ * @template Provider - The LLM provider type
441
+ * @template Reporter - Reporter interface type
442
+ */
443
+ export type LLMAssistanceOptions<Provider extends LLMProviders, Reporter extends LLMReporterInterface<any> | undefined> = LLMMethodBaseOptions<Reporter> & {
444
+ model: LLMModel<Provider>;
445
+ message: LLMAssistanceMessage;
446
+ chatId: string;
447
+ storageId?: string;
448
+ tools?: LLMToolDefinition[];
449
+ maxToolIterations?: number;
450
+ /** Groups this legacy tool loop under one agent trace observation. */
451
+ agentName?: string;
452
+ /**
453
+ * Invoked with the model's visible assistant text from a tool-calling round
454
+ * that will continue the loop (narration emitted alongside tool calls),
455
+ * before that round's tools execute. Never carries the final round's answer
456
+ * or reasoning/thinking content; the text may be empty when the round
457
+ * produced only tool calls, so the consumer skips empty/whitespace-only text.
458
+ * Observability-only: the callback must not throw — the tool loop does not
459
+ * guard the call.
460
+ */
461
+ onAssistantNarration?: (text: string) => void;
462
+ };
463
+ /**
464
+ * Result type for assistance requests.
465
+ */
466
+ export type LLMAssistanceResult = LLMRequestResult<{
467
+ text: string;
468
+ toolIterationsUsed?: number;
469
+ toolIterationsExhausted?: true;
470
+ stopReason?: LLMToolLoopStopReasons;
471
+ terminalTool?: LLMTerminalToolOutcome;
472
+ }>;
473
+ /**
474
+ * Options for a one-shot prompt in a newly created chat.
475
+ * Combines chat creation options with message sending options.
476
+ * @template Provider - The LLM provider type
477
+ * @template Reporter - Reporter interface type
478
+ */
479
+ export type LLMAssistInNewChatOptions<Provider extends LLMProviders, Reporter extends LLMReporterInterface<any> | undefined> = LLMCreateChatOptions<Provider, Reporter> & {
480
+ prompt: string;
481
+ tools?: LLMToolDefinition[];
482
+ maxToolIterations?: number;
483
+ };
484
+ /**
485
+ * An image returned by a tool's `execute` for the model to see.
486
+ */
487
+ export interface LLMToolResultImage {
488
+ /** Image location. An https URL, or a data URL for inline bytes. */
489
+ url: string;
490
+ /** Vision detail hint passed to providers that accept it. */
491
+ detail?: 'auto' | 'low' | 'high';
492
+ /**
493
+ * MIME type of the image. Defaults to `image/png`. Used by providers that
494
+ * require raw bytes (Gemini) when fetching and re-encoding the image.
495
+ */
496
+ mimeType?: string;
497
+ /** Optional caption rendered next to the image for the model. */
498
+ label?: string;
499
+ }
500
+ /**
501
+ * Structured result a tool's `execute` may return when it needs to surface
502
+ * images alongside text. The `content` string always becomes the
503
+ * tool/function-result message; `images` are surfaced to the model the way
504
+ * each provider's API allows.
505
+ */
506
+ export interface LLMStructuredToolResult {
507
+ content: string;
508
+ images?: LLMToolResultImage[];
509
+ }
510
+ /**
511
+ * What a tool's `execute` may return. A plain `string` keeps the legacy
512
+ * text-only behaviour; an `LLMStructuredToolResult` additionally carries
513
+ * images.
514
+ */
515
+ export type LLMToolResult = string | LLMStructuredToolResult;
516
+ /**
517
+ * The verdict of a tool's `canExecute` precondition. A refusal carries the
518
+ * `reason` the model is told, which is why it is required: a denial the model
519
+ * cannot explain to itself is a denial it will retry blindly.
520
+ */
521
+ export type LLMToolGateResult = {
522
+ allowed: true;
523
+ } | {
524
+ allowed: false;
525
+ reason: string;
526
+ };
527
+ export interface LLMToolDefinition<Schema extends LLMSchemaInterface = LLMSchemaInterface> {
528
+ name: string;
529
+ description: string;
530
+ parameters: Schema;
531
+ execute: (args: InferSchema<Schema>) => Promise<LLMToolResult> | LLMToolResult;
532
+ /**
533
+ * Decides whether this call may run, on the arguments the model supplied.
534
+ * Checked before `execute`, so a refused call never has its side effect. A
535
+ * refusal is ordinary control flow, not an error: the model is told the
536
+ * `reason` as the call's result and the run continues with its iteration
537
+ * budget untouched. Use it for permission, quota, and state preconditions
538
+ * that depend on the arguments rather than on the tool being present at all.
539
+ */
540
+ canExecute?: (args: InferSchema<Schema>) => Promise<LLMToolGateResult> | LLMToolGateResult;
541
+ /**
542
+ * Ends the turn once this tool runs. The round executes in full (every call
543
+ * of that round, including parallel ones), but its results are not fed back
544
+ * and no further model round starts — the loop stops with
545
+ * `LLMToolLoopStopReasons.TerminalTool` and this tool's output as the turn
546
+ * outcome. Use for tools that hand control back to the application, such as
547
+ * an `ask_user` tool that needs a human reply before the agent can continue.
548
+ */
549
+ terminal?: boolean;
550
+ }
551
+ /**
552
+ * Why a provider's model⇄tool loop stopped. `Completed` is the ordinary end
553
+ * (a model round returned no tool calls), `MaxIterations` means the loop hit
554
+ * `maxToolIterations` with tool calls still pending, and `TerminalTool` means
555
+ * a tool declaring `terminal` ran and ended the turn.
556
+ */
557
+ export declare enum LLMToolLoopStopReasons {
558
+ Completed = "completed",
559
+ MaxIterations = "max_iterations",
560
+ TerminalTool = "terminal_tool"
561
+ }
562
+ /**
563
+ * The terminal tool call that ended a turn: the tool's name and the output it
564
+ * returned, which the application handles instead of a model answer. When more
565
+ * than one terminal call lands in the same round, the first in the round's
566
+ * order is reported (all of them still execute).
567
+ */
568
+ export interface LLMTerminalToolOutcome {
569
+ name: string;
570
+ output: LLMToolResult;
571
+ }
572
+ /**
573
+ * Function type for counting tokens in messages for a specific provider's model.
574
+ * @template Provider - The LLM provider type
575
+ * @template ContentType - The type of the message content
576
+ * @param messages - Array of message strings to count tokens for
577
+ * @param model - The LLM model to use for token counting
578
+ * @returns Promise resolving to the number of tokens
579
+ */
580
+ export type LLMCountTokensFunction<Provider extends LLMProviders, ContentType> = (messagesContents: ContentType, model: LLMModel<Provider>) => Promise<number>;
581
+ /**
582
+ * Options for combining messages with a limit on the number of tokens.
583
+ * @template Provider - The LLM provider type
584
+ * @template TokenCountFunction - Function type for counting tokens
585
+ */
586
+ export interface CombineMessagesOptions<Provider extends LLMProviders, TokenCountFunction extends LLMCountTokensFunction<Provider, any[]>> {
587
+ history?: LLMCompletionMessage[];
588
+ message: LLMCompletionMessage;
589
+ model: LLMModel<Provider>;
590
+ instance: LLMInstances[Provider];
591
+ logger: LLMLoggerInterface | undefined;
592
+ countTokensFn: TokenCountFunction;
593
+ }
594
+ /**
595
+ * Options for transcribing audio to text using an LLM service.
596
+ * @template Provider - The LLM provider type
597
+ * @template Reporter - Reporter interface type
598
+ */
599
+ export type LLMTranscribeOptions<Provider extends LLMProviders, Reporter extends LLMReporterInterface<any> | undefined> = LLMMethodBaseOptions<Reporter> & {
600
+ pathToAudio: string;
601
+ mimeType?: LLMAudioMimeType;
602
+ model: LLMModel<Provider>;
603
+ instructions?: string;
604
+ language?: string;
605
+ };
606
+ /**
607
+ * Result type for LLM transcription requests.
608
+ */
609
+ export type LLMTranscribeResult = LLMRequestResult<{
610
+ text: string;
611
+ usage?: LLMModelUsage;
612
+ cost?: LLMCostsResult;
613
+ }>;
614
+ /**
615
+ * Provider-specific options for creating speech from text.
616
+ */
617
+ export type LLMSpeechOptions = {
618
+ [LLMProviders.OpenAI]: OpenAISpeechOptions;
619
+ [LLMProviders.GoogleGenerativeAI]: GoogleGenerativeAISpeechOptions;
620
+ [LLMProviders.LLMAPI]: LLMAPISpeechOptions;
621
+ };
622
+ /**
623
+ * Options for creating speech from text using an LLM service.
624
+ * @template Provider - The LLM provider type
625
+ * @template Reporter - Reporter interface type
626
+ */
627
+ export type LLMCreateSpeechOptions<Provider extends LLMProviders, Reporter extends LLMReporterInterface<any> | undefined> = LLMMethodBaseOptions<Reporter> & {
628
+ text: string;
629
+ model: LLMModel<Provider>;
630
+ instructions?: string;
631
+ speechOptions?: LLMSpeechOptions[Provider];
632
+ };
633
+ /**
634
+ * Result type for LLM speech creation requests.
635
+ * Contains the generated audio buffer and its MIME type.
636
+ */
637
+ export type LLMCreateSpeechResult = LLMRequestResult<{
638
+ audio: Buffer<ArrayBuffer>;
639
+ mimeType: string | null;
640
+ }>;
641
+ /**
642
+ * Options for creating LLM services.
643
+ * @template Provider - The LLM provider type
644
+ * @template Reporter - Reporter interface type
645
+ */
646
+ export interface LLMServiceOptions<Provider extends LLMProviders, Reporter extends LLMReporterInterface<any> | undefined> {
647
+ /** The LLM provider (OpenAI, GoogleGenerativeAI) */
648
+ provider: Provider;
649
+ /** Provider-specific configuration options */
650
+ options?: LLMInstanceOptions[Provider];
651
+ /** Logger instance (optional, no logging if not provided) */
652
+ logger?: LLMLoggerInterface;
653
+ /** Reporter instance (optional, no reporting if not provided) */
654
+ reporter?: Reporter;
655
+ }