openlit 1.12.0 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/README.md +34 -1
  2. package/dist/__tests__/manual-trace.test.js +118 -0
  3. package/dist/__tests__/manual-trace.test.js.map +1 -0
  4. package/dist/__tests__/register.test.js +90 -0
  5. package/dist/__tests__/register.test.js.map +1 -0
  6. package/dist/config.d.ts +7 -1
  7. package/dist/config.js +3 -1
  8. package/dist/config.js.map +1 -1
  9. package/dist/evals/__tests__/offline.test.js +418 -0
  10. package/dist/evals/__tests__/offline.test.js.map +1 -0
  11. package/dist/evals/index.d.ts +2 -5
  12. package/dist/evals/index.js +12 -26
  13. package/dist/evals/index.js.map +1 -1
  14. package/dist/evals/offline.d.ts +6 -0
  15. package/dist/evals/offline.js +347 -0
  16. package/dist/evals/offline.js.map +1 -0
  17. package/dist/evals/types.d.ts +69 -18
  18. package/dist/evals/types.js +20 -0
  19. package/dist/evals/types.js.map +1 -1
  20. package/dist/guard/__tests__/integration.test.js +178 -0
  21. package/dist/guard/__tests__/integration.test.js.map +1 -0
  22. package/dist/guard/__tests__/pii.test.js +109 -0
  23. package/dist/guard/__tests__/pii.test.js.map +1 -0
  24. package/dist/guard/__tests__/pipeline.test.js +162 -0
  25. package/dist/guard/__tests__/pipeline.test.js.map +1 -0
  26. package/dist/guard/__tests__/prompt-injection.test.js +92 -0
  27. package/dist/guard/__tests__/prompt-injection.test.js.map +1 -0
  28. package/dist/guard/base.d.ts +75 -14
  29. package/dist/guard/base.js +130 -53
  30. package/dist/guard/base.js.map +1 -1
  31. package/dist/guard/custom.d.ts +19 -0
  32. package/dist/guard/custom.js +46 -0
  33. package/dist/guard/custom.js.map +1 -0
  34. package/dist/guard/index.d.ts +24 -5
  35. package/dist/guard/index.js +39 -21
  36. package/dist/guard/index.js.map +1 -1
  37. package/dist/guard/integration.d.ts +32 -0
  38. package/dist/guard/integration.js +328 -0
  39. package/dist/guard/integration.js.map +1 -0
  40. package/dist/guard/moderation.d.ts +18 -0
  41. package/dist/guard/moderation.js +61 -0
  42. package/dist/guard/moderation.js.map +1 -0
  43. package/dist/guard/pii.d.ts +17 -0
  44. package/dist/guard/pii.js +94 -0
  45. package/dist/guard/pii.js.map +1 -0
  46. package/dist/guard/pipeline.d.ts +18 -0
  47. package/dist/guard/pipeline.js +96 -0
  48. package/dist/guard/pipeline.js.map +1 -0
  49. package/dist/guard/prompt-injection.d.ts +20 -6
  50. package/dist/guard/prompt-injection.js +59 -68
  51. package/dist/guard/prompt-injection.js.map +1 -1
  52. package/dist/guard/schema.d.ts +20 -0
  53. package/dist/guard/schema.js +99 -0
  54. package/dist/guard/schema.js.map +1 -0
  55. package/dist/guard/sensitive-topic.d.ts +22 -6
  56. package/dist/guard/sensitive-topic.js +78 -64
  57. package/dist/guard/sensitive-topic.js.map +1 -1
  58. package/dist/guard/topic-restriction.d.ts +21 -6
  59. package/dist/guard/topic-restriction.js +43 -64
  60. package/dist/guard/topic-restriction.js.map +1 -1
  61. package/dist/helpers.d.ts +133 -2
  62. package/dist/helpers.js +416 -5
  63. package/dist/helpers.js.map +1 -1
  64. package/dist/index.d.ts +54 -30
  65. package/dist/index.js +104 -22
  66. package/dist/index.js.map +1 -1
  67. package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.d.ts +13 -0
  68. package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.js +176 -0
  69. package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.js.map +1 -0
  70. package/dist/instrumentation/__tests__/ai21-trace-comparison.test.d.ts +10 -0
  71. package/dist/instrumentation/__tests__/ai21-trace-comparison.test.js +203 -0
  72. package/dist/instrumentation/__tests__/ai21-trace-comparison.test.js.map +1 -0
  73. package/dist/instrumentation/__tests__/assemblyai-wrapper.test.js +262 -0
  74. package/dist/instrumentation/__tests__/assemblyai-wrapper.test.js.map +1 -0
  75. package/dist/instrumentation/__tests__/astra-trace-comparison.test.d.ts +7 -0
  76. package/dist/instrumentation/__tests__/astra-trace-comparison.test.js +160 -0
  77. package/dist/instrumentation/__tests__/astra-trace-comparison.test.js.map +1 -0
  78. package/dist/instrumentation/__tests__/browser-use-wrapper.test.js +284 -0
  79. package/dist/instrumentation/__tests__/browser-use-wrapper.test.js.map +1 -0
  80. package/dist/instrumentation/__tests__/cache-pricing.test.d.ts +12 -0
  81. package/dist/instrumentation/__tests__/cache-pricing.test.js +95 -0
  82. package/dist/instrumentation/__tests__/cache-pricing.test.js.map +1 -0
  83. package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.d.ts +1 -0
  84. package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.js +282 -0
  85. package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.js.map +1 -0
  86. package/dist/instrumentation/__tests__/firecrawl-wrapper.test.d.ts +1 -0
  87. package/dist/instrumentation/__tests__/firecrawl-wrapper.test.js +238 -0
  88. package/dist/instrumentation/__tests__/firecrawl-wrapper.test.js.map +1 -0
  89. package/dist/instrumentation/__tests__/gpu-collector.test.d.ts +1 -0
  90. package/dist/instrumentation/__tests__/gpu-collector.test.js +247 -0
  91. package/dist/instrumentation/__tests__/gpu-collector.test.js.map +1 -0
  92. package/dist/instrumentation/__tests__/gradient-trace-comparison.test.d.ts +11 -0
  93. package/dist/instrumentation/__tests__/gradient-trace-comparison.test.js +391 -0
  94. package/dist/instrumentation/__tests__/gradient-trace-comparison.test.js.map +1 -0
  95. package/dist/instrumentation/__tests__/groq-trace-comparison.test.js +150 -0
  96. package/dist/instrumentation/__tests__/groq-trace-comparison.test.js.map +1 -1
  97. package/dist/instrumentation/__tests__/helpers-genai.test.d.ts +14 -0
  98. package/dist/instrumentation/__tests__/helpers-genai.test.js +347 -0
  99. package/dist/instrumentation/__tests__/helpers-genai.test.js.map +1 -0
  100. package/dist/instrumentation/__tests__/langchain-role-map.test.d.ts +1 -0
  101. package/dist/instrumentation/__tests__/langchain-role-map.test.js +19 -0
  102. package/dist/instrumentation/__tests__/langchain-role-map.test.js.map +1 -0
  103. package/dist/instrumentation/__tests__/mem0-trace-comparison.test.d.ts +13 -0
  104. package/dist/instrumentation/__tests__/mem0-trace-comparison.test.js +208 -0
  105. package/dist/instrumentation/__tests__/mem0-trace-comparison.test.js.map +1 -0
  106. package/dist/instrumentation/__tests__/pg-trace-comparison.test.d.ts +21 -0
  107. package/dist/instrumentation/__tests__/pg-trace-comparison.test.js +455 -0
  108. package/dist/instrumentation/__tests__/pg-trace-comparison.test.js.map +1 -0
  109. package/dist/instrumentation/__tests__/transformers-trace-comparison.test.d.ts +11 -0
  110. package/dist/instrumentation/__tests__/transformers-trace-comparison.test.js +214 -0
  111. package/dist/instrumentation/__tests__/transformers-trace-comparison.test.js.map +1 -0
  112. package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.d.ts +6 -0
  113. package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.js +409 -0
  114. package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.js.map +1 -0
  115. package/dist/instrumentation/__tests__/vllm-trace-comparison.test.d.ts +1 -0
  116. package/dist/instrumentation/__tests__/vllm-trace-comparison.test.js +519 -0
  117. package/dist/instrumentation/__tests__/vllm-trace-comparison.test.js.map +1 -0
  118. package/dist/instrumentation/ai21/index.d.ts +11 -0
  119. package/dist/instrumentation/ai21/index.js +67 -0
  120. package/dist/instrumentation/ai21/index.js.map +1 -0
  121. package/dist/instrumentation/ai21/wrapper.d.ts +54 -0
  122. package/dist/instrumentation/ai21/wrapper.js +511 -0
  123. package/dist/instrumentation/ai21/wrapper.js.map +1 -0
  124. package/dist/instrumentation/anthropic/wrapper.js +56 -2
  125. package/dist/instrumentation/anthropic/wrapper.js.map +1 -1
  126. package/dist/instrumentation/assemblyai/index.d.ts +12 -0
  127. package/dist/instrumentation/assemblyai/index.js +91 -0
  128. package/dist/instrumentation/assemblyai/index.js.map +1 -0
  129. package/dist/instrumentation/assemblyai/wrapper.d.ts +35 -0
  130. package/dist/instrumentation/assemblyai/wrapper.js +233 -0
  131. package/dist/instrumentation/assemblyai/wrapper.js.map +1 -0
  132. package/dist/instrumentation/astra/index.d.ts +11 -0
  133. package/dist/instrumentation/astra/index.js +87 -0
  134. package/dist/instrumentation/astra/index.js.map +1 -0
  135. package/dist/instrumentation/astra/wrapper.d.ts +39 -0
  136. package/dist/instrumentation/astra/wrapper.js +349 -0
  137. package/dist/instrumentation/astra/wrapper.js.map +1 -0
  138. package/dist/instrumentation/azure-ai-inference/wrapper.d.ts +13 -0
  139. package/dist/instrumentation/azure-ai-inference/wrapper.js +60 -1
  140. package/dist/instrumentation/azure-ai-inference/wrapper.js.map +1 -1
  141. package/dist/instrumentation/bedrock/wrapper.d.ts +13 -0
  142. package/dist/instrumentation/bedrock/wrapper.js +78 -2
  143. package/dist/instrumentation/bedrock/wrapper.js.map +1 -1
  144. package/dist/instrumentation/browser-use/index.d.ts +11 -0
  145. package/dist/instrumentation/browser-use/index.js +98 -0
  146. package/dist/instrumentation/browser-use/index.js.map +1 -0
  147. package/dist/instrumentation/browser-use/wrapper.d.ts +12 -0
  148. package/dist/instrumentation/browser-use/wrapper.js +706 -0
  149. package/dist/instrumentation/browser-use/wrapper.js.map +1 -0
  150. package/dist/instrumentation/claude-agent-sdk/wrapper.js +90 -4
  151. package/dist/instrumentation/claude-agent-sdk/wrapper.js.map +1 -1
  152. package/dist/instrumentation/cohere/wrapper.d.ts +13 -0
  153. package/dist/instrumentation/cohere/wrapper.js +59 -0
  154. package/dist/instrumentation/cohere/wrapper.js.map +1 -1
  155. package/dist/instrumentation/cursor-sdk/index.d.ts +21 -0
  156. package/dist/instrumentation/cursor-sdk/index.js +58 -0
  157. package/dist/instrumentation/cursor-sdk/index.js.map +1 -0
  158. package/dist/instrumentation/cursor-sdk/wrapper.d.ts +17 -0
  159. package/dist/instrumentation/cursor-sdk/wrapper.js +785 -0
  160. package/dist/instrumentation/cursor-sdk/wrapper.js.map +1 -0
  161. package/dist/instrumentation/elevenlabs/index.d.ts +12 -0
  162. package/dist/instrumentation/elevenlabs/index.js +92 -0
  163. package/dist/instrumentation/elevenlabs/index.js.map +1 -0
  164. package/dist/instrumentation/elevenlabs/wrapper.d.ts +34 -0
  165. package/dist/instrumentation/elevenlabs/wrapper.js +280 -0
  166. package/dist/instrumentation/elevenlabs/wrapper.js.map +1 -0
  167. package/dist/instrumentation/firecrawl/index.d.ts +13 -0
  168. package/dist/instrumentation/firecrawl/index.js +115 -0
  169. package/dist/instrumentation/firecrawl/index.js.map +1 -0
  170. package/dist/instrumentation/firecrawl/wrapper.d.ts +22 -0
  171. package/dist/instrumentation/firecrawl/wrapper.js +378 -0
  172. package/dist/instrumentation/firecrawl/wrapper.js.map +1 -0
  173. package/dist/instrumentation/google-ai/wrapper.d.ts +13 -0
  174. package/dist/instrumentation/google-ai/wrapper.js +85 -1
  175. package/dist/instrumentation/google-ai/wrapper.js.map +1 -1
  176. package/dist/instrumentation/gpu/index.d.ts +38 -0
  177. package/dist/instrumentation/gpu/index.js +233 -0
  178. package/dist/instrumentation/gpu/index.js.map +1 -0
  179. package/dist/instrumentation/gradient/index.d.ts +12 -0
  180. package/dist/instrumentation/gradient/index.js +74 -0
  181. package/dist/instrumentation/gradient/index.js.map +1 -0
  182. package/dist/instrumentation/gradient/utils.d.ts +14 -0
  183. package/dist/instrumentation/gradient/utils.js +119 -0
  184. package/dist/instrumentation/gradient/utils.js.map +1 -0
  185. package/dist/instrumentation/gradient/wrapper.d.ts +76 -0
  186. package/dist/instrumentation/gradient/wrapper.js +584 -0
  187. package/dist/instrumentation/gradient/wrapper.js.map +1 -0
  188. package/dist/instrumentation/groq/wrapper.js +42 -0
  189. package/dist/instrumentation/groq/wrapper.js.map +1 -1
  190. package/dist/instrumentation/huggingface/wrapper.d.ts +13 -0
  191. package/dist/instrumentation/huggingface/wrapper.js +66 -0
  192. package/dist/instrumentation/huggingface/wrapper.js.map +1 -1
  193. package/dist/instrumentation/index.js +28 -0
  194. package/dist/instrumentation/index.js.map +1 -1
  195. package/dist/instrumentation/langchain/wrapper.js +5 -8
  196. package/dist/instrumentation/langchain/wrapper.js.map +1 -1
  197. package/dist/instrumentation/langgraph/wrapper.js +12 -11
  198. package/dist/instrumentation/langgraph/wrapper.js.map +1 -1
  199. package/dist/instrumentation/llamaindex/wrapper.d.ts +14 -1
  200. package/dist/instrumentation/llamaindex/wrapper.js +68 -0
  201. package/dist/instrumentation/llamaindex/wrapper.js.map +1 -1
  202. package/dist/instrumentation/mcp/index.d.ts +20 -0
  203. package/dist/instrumentation/mcp/index.js +282 -0
  204. package/dist/instrumentation/mcp/index.js.map +1 -0
  205. package/dist/instrumentation/mcp/wrapper.d.ts +72 -0
  206. package/dist/instrumentation/mcp/wrapper.js +571 -0
  207. package/dist/instrumentation/mcp/wrapper.js.map +1 -0
  208. package/dist/instrumentation/mem0/index.d.ts +17 -0
  209. package/dist/instrumentation/mem0/index.js +113 -0
  210. package/dist/instrumentation/mem0/index.js.map +1 -0
  211. package/dist/instrumentation/mem0/wrapper.d.ts +37 -0
  212. package/dist/instrumentation/mem0/wrapper.js +298 -0
  213. package/dist/instrumentation/mem0/wrapper.js.map +1 -0
  214. package/dist/instrumentation/mistral/wrapper.d.ts +13 -0
  215. package/dist/instrumentation/mistral/wrapper.js +60 -1
  216. package/dist/instrumentation/mistral/wrapper.js.map +1 -1
  217. package/dist/instrumentation/ollama/wrapper.d.ts +13 -0
  218. package/dist/instrumentation/ollama/wrapper.js +67 -1
  219. package/dist/instrumentation/ollama/wrapper.js.map +1 -1
  220. package/dist/instrumentation/openai/wrapper.d.ts +13 -0
  221. package/dist/instrumentation/openai/wrapper.js +89 -3
  222. package/dist/instrumentation/openai/wrapper.js.map +1 -1
  223. package/dist/instrumentation/pg/index.d.ts +20 -0
  224. package/dist/instrumentation/pg/index.js +74 -0
  225. package/dist/instrumentation/pg/index.js.map +1 -0
  226. package/dist/instrumentation/pg/wrapper.d.ts +66 -0
  227. package/dist/instrumentation/pg/wrapper.js +441 -0
  228. package/dist/instrumentation/pg/wrapper.js.map +1 -0
  229. package/dist/instrumentation/replicate/wrapper.d.ts +13 -0
  230. package/dist/instrumentation/replicate/wrapper.js +61 -0
  231. package/dist/instrumentation/replicate/wrapper.js.map +1 -1
  232. package/dist/instrumentation/strands/processor.d.ts +6 -0
  233. package/dist/instrumentation/strands/processor.js +73 -3
  234. package/dist/instrumentation/strands/processor.js.map +1 -1
  235. package/dist/instrumentation/strands/utils.d.ts +2 -2
  236. package/dist/instrumentation/strands/utils.js +15 -2
  237. package/dist/instrumentation/strands/utils.js.map +1 -1
  238. package/dist/instrumentation/together/wrapper.d.ts +13 -0
  239. package/dist/instrumentation/together/wrapper.js +59 -1
  240. package/dist/instrumentation/together/wrapper.js.map +1 -1
  241. package/dist/instrumentation/transformers/index.d.ts +35 -0
  242. package/dist/instrumentation/transformers/index.js +119 -0
  243. package/dist/instrumentation/transformers/index.js.map +1 -0
  244. package/dist/instrumentation/transformers/wrapper.d.ts +49 -0
  245. package/dist/instrumentation/transformers/wrapper.js +472 -0
  246. package/dist/instrumentation/transformers/wrapper.js.map +1 -0
  247. package/dist/instrumentation/vercel-ai/wrapper.d.ts +13 -0
  248. package/dist/instrumentation/vercel-ai/wrapper.js +106 -1
  249. package/dist/instrumentation/vercel-ai/wrapper.js.map +1 -1
  250. package/dist/instrumentation/vertexai/index.d.ts +11 -0
  251. package/dist/instrumentation/vertexai/index.js +70 -0
  252. package/dist/instrumentation/vertexai/index.js.map +1 -0
  253. package/dist/instrumentation/vertexai/wrapper.d.ts +67 -0
  254. package/dist/instrumentation/vertexai/wrapper.js +529 -0
  255. package/dist/instrumentation/vertexai/wrapper.js.map +1 -0
  256. package/dist/instrumentation/vllm/index.d.ts +13 -0
  257. package/dist/instrumentation/vllm/index.js +67 -0
  258. package/dist/instrumentation/vllm/index.js.map +1 -0
  259. package/dist/instrumentation/vllm/wrapper.d.ts +60 -0
  260. package/dist/instrumentation/vllm/wrapper.js +482 -0
  261. package/dist/instrumentation/vllm/wrapper.js.map +1 -0
  262. package/dist/llm/index.d.ts +9 -2
  263. package/dist/llm/index.js.map +1 -1
  264. package/dist/manual-trace.d.ts +40 -0
  265. package/dist/manual-trace.js +103 -0
  266. package/dist/manual-trace.js.map +1 -0
  267. package/dist/otel/metrics.d.ts +11 -0
  268. package/dist/otel/metrics.js +48 -0
  269. package/dist/otel/metrics.js.map +1 -1
  270. package/dist/register.d.ts +4 -0
  271. package/dist/register.js +52 -0
  272. package/dist/register.js.map +1 -0
  273. package/dist/score/__tests__/score.test.d.ts +1 -0
  274. package/dist/score/__tests__/score.test.js +143 -0
  275. package/dist/score/__tests__/score.test.js.map +1 -0
  276. package/dist/score/index.d.ts +2 -0
  277. package/dist/score/index.js +6 -0
  278. package/dist/score/index.js.map +1 -0
  279. package/dist/score/score.d.ts +15 -0
  280. package/dist/score/score.js +135 -0
  281. package/dist/score/score.js.map +1 -0
  282. package/dist/semantic-convention.d.ts +278 -0
  283. package/dist/semantic-convention.js +322 -0
  284. package/dist/semantic-convention.js.map +1 -1
  285. package/dist/types.d.ts +15 -1
  286. package/package.json +18 -1
  287. package/dist/evals/__tests__/anthropic.test.js +0 -9
  288. package/dist/evals/__tests__/anthropic.test.js.map +0 -1
  289. package/dist/evals/__tests__/base.test.js +0 -37
  290. package/dist/evals/__tests__/base.test.js.map +0 -1
  291. package/dist/evals/__tests__/core.test.js +0 -33
  292. package/dist/evals/__tests__/core.test.js.map +0 -1
  293. package/dist/evals/__tests__/metrics.test.js +0 -59
  294. package/dist/evals/__tests__/metrics.test.js.map +0 -1
  295. package/dist/evals/__tests__/openai.test.js +0 -9
  296. package/dist/evals/__tests__/openai.test.js.map +0 -1
  297. package/dist/evals/__tests__/providers.test.js +0 -14
  298. package/dist/evals/__tests__/providers.test.js.map +0 -1
  299. package/dist/evals/__tests__/utils.test.js +0 -46
  300. package/dist/evals/__tests__/utils.test.js.map +0 -1
  301. package/dist/evals/all.d.ts +0 -4
  302. package/dist/evals/all.js +0 -35
  303. package/dist/evals/all.js.map +0 -1
  304. package/dist/evals/base.d.ts +0 -15
  305. package/dist/evals/base.js +0 -51
  306. package/dist/evals/base.js.map +0 -1
  307. package/dist/evals/bias.d.ts +0 -4
  308. package/dist/evals/bias.js +0 -35
  309. package/dist/evals/bias.js.map +0 -1
  310. package/dist/evals/hallucination.d.ts +0 -4
  311. package/dist/evals/hallucination.js +0 -32
  312. package/dist/evals/hallucination.js.map +0 -1
  313. package/dist/evals/llm/anthropic.d.ts +0 -5
  314. package/dist/evals/llm/anthropic.js +0 -42
  315. package/dist/evals/llm/anthropic.js.map +0 -1
  316. package/dist/evals/llm/openai.d.ts +0 -6
  317. package/dist/evals/llm/openai.js +0 -28
  318. package/dist/evals/llm/openai.js.map +0 -1
  319. package/dist/evals/llm/providers.d.ts +0 -7
  320. package/dist/evals/llm/providers.js +0 -10
  321. package/dist/evals/llm/providers.js.map +0 -1
  322. package/dist/evals/metrics.d.ts +0 -9
  323. package/dist/evals/metrics.js +0 -38
  324. package/dist/evals/metrics.js.map +0 -1
  325. package/dist/evals/toxicity.d.ts +0 -4
  326. package/dist/evals/toxicity.js +0 -33
  327. package/dist/evals/toxicity.js.map +0 -1
  328. package/dist/evals/utils.d.ts +0 -4
  329. package/dist/evals/utils.js +0 -39
  330. package/dist/evals/utils.js.map +0 -1
  331. package/dist/guard/__tests__/gaurd.test.js +0 -136
  332. package/dist/guard/__tests__/gaurd.test.js.map +0 -1
  333. package/dist/guard/__tests__/utils.test.js +0 -64
  334. package/dist/guard/__tests__/utils.test.js.map +0 -1
  335. package/dist/guard/all.d.ts +0 -8
  336. package/dist/guard/all.js +0 -28
  337. package/dist/guard/all.js.map +0 -1
  338. package/dist/guard/types.d.ts +0 -26
  339. package/dist/guard/types.js +0 -4
  340. package/dist/guard/types.js.map +0 -1
  341. package/dist/guard/utils.d.ts +0 -13
  342. package/dist/guard/utils.js +0 -79
  343. package/dist/guard/utils.js.map +0 -1
  344. /package/dist/{evals/__tests__/anthropic.test.d.ts → __tests__/manual-trace.test.d.ts} +0 -0
  345. /package/dist/{evals/__tests__/metrics.test.d.ts → __tests__/register.test.d.ts} +0 -0
  346. /package/dist/evals/__tests__/{base.test.d.ts → offline.test.d.ts} +0 -0
  347. /package/dist/{evals/__tests__/core.test.d.ts → guard/__tests__/integration.test.d.ts} +0 -0
  348. /package/dist/{evals/__tests__/openai.test.d.ts → guard/__tests__/pii.test.d.ts} +0 -0
  349. /package/dist/{evals/__tests__/providers.test.d.ts → guard/__tests__/pipeline.test.d.ts} +0 -0
  350. /package/dist/{evals/__tests__/utils.test.d.ts → guard/__tests__/prompt-injection.test.d.ts} +0 -0
  351. /package/dist/{guard/__tests__/gaurd.test.d.ts → instrumentation/__tests__/assemblyai-wrapper.test.d.ts} +0 -0
  352. /package/dist/{guard/__tests__/utils.test.d.ts → instrumentation/__tests__/browser-use-wrapper.test.d.ts} +0 -0
@@ -1,58 +1,135 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
2
+ /**
3
+ * Core types, base class, and errors for the OpenLIT guard system.
4
+ *
5
+ * Must stay in sync with: sdk/python/src/openlit/guard/_base.py
6
+ */
35
7
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.BaseGuard = void 0;
37
- class BaseGuard {
38
- constructor(config = {}) {
39
- this.provider = config.provider;
40
- this.apiKey = config.apiKey;
41
- this.model = config.model;
42
- this.baseUrl = config.baseUrl;
43
- this.thresholdScore = config.thresholdScore ?? 0.25;
44
- this.collectMetrics = config.collectMetrics ?? false;
45
- this.customRules = config.customRules;
46
- this.validTopics = config.validTopics;
47
- this.invalidTopics = config.invalidTopics;
48
- }
49
- async llmResponse(prompt) {
50
- if (!this.provider)
51
- throw new Error('No provider specified');
52
- // Use unified llmResponse from llm/index.ts and normalize provider
53
- const { llmResponse } = await Promise.resolve().then(() => __importStar(require('../llm')));
54
- return llmResponse(this.provider.toLowerCase(), prompt, this.model, this.baseUrl, this.apiKey);
8
+ exports.Guard = exports.GuardConfigError = exports.GuardTimeoutError = exports.GuardDeniedError = exports.GuardError = exports.PipelineResult = exports.ACTION_SEVERITY = exports.GuardAction = exports.GuardPhase = void 0;
9
+ exports.makeGuardResult = makeGuardResult;
10
+ var GuardPhase;
11
+ (function (GuardPhase) {
12
+ GuardPhase["PREFLIGHT"] = "preflight";
13
+ GuardPhase["POSTFLIGHT"] = "postflight";
14
+ })(GuardPhase || (exports.GuardPhase = GuardPhase = {}));
15
+ var GuardAction;
16
+ (function (GuardAction) {
17
+ GuardAction["ALLOW"] = "allow";
18
+ GuardAction["DENY"] = "deny";
19
+ GuardAction["REDACT"] = "redact";
20
+ GuardAction["WARN"] = "warn";
21
+ })(GuardAction || (exports.GuardAction = GuardAction = {}));
22
+ exports.ACTION_SEVERITY = {
23
+ [GuardAction.ALLOW]: 0,
24
+ [GuardAction.WARN]: 1,
25
+ [GuardAction.REDACT]: 2,
26
+ [GuardAction.DENY]: 3,
27
+ };
28
+ function makeGuardResult(overrides = {}) {
29
+ return {
30
+ action: GuardAction.ALLOW,
31
+ score: 0,
32
+ guardName: '',
33
+ classification: '',
34
+ explanation: '',
35
+ transformedText: null,
36
+ latencyMs: 0,
37
+ ...overrides,
38
+ };
39
+ }
40
+ class PipelineResult {
41
+ constructor(action = GuardAction.ALLOW, results = [], transformedText = null) {
42
+ this.action = action;
43
+ this.results = results;
44
+ this.transformedText = transformedText;
45
+ }
46
+ get explanation() {
47
+ return this.results
48
+ .map((r) => r.explanation)
49
+ .filter(Boolean)
50
+ .join('; ');
51
+ }
52
+ }
53
+ exports.PipelineResult = PipelineResult;
54
+ // ---------------------------------------------------------------------------
55
+ // Errors
56
+ // ---------------------------------------------------------------------------
57
+ class GuardError extends Error {
58
+ constructor(message) {
59
+ super(message);
60
+ this.name = 'GuardError';
61
+ }
62
+ }
63
+ exports.GuardError = GuardError;
64
+ class GuardDeniedError extends GuardError {
65
+ constructor(result) {
66
+ super(result.explanation);
67
+ this.name = 'GuardDeniedError';
68
+ this.result = result;
69
+ }
70
+ }
71
+ exports.GuardDeniedError = GuardDeniedError;
72
+ /**
73
+ * Reserved for future use -- a per-guard `timeoutMs` option may be
74
+ * added to Pipeline in a later release.
75
+ */
76
+ class GuardTimeoutError extends GuardError {
77
+ constructor(message) {
78
+ super(message);
79
+ this.name = 'GuardTimeoutError';
80
+ }
81
+ }
82
+ exports.GuardTimeoutError = GuardTimeoutError;
83
+ class GuardConfigError extends GuardError {
84
+ constructor(message) {
85
+ super(message);
86
+ this.name = 'GuardConfigError';
87
+ }
88
+ }
89
+ exports.GuardConfigError = GuardConfigError;
90
+ class Guard {
91
+ /**
92
+ * @param opts.action - Action to take on violation (`allow`, `deny`, `redact`, `warn`). Default: `deny`.
93
+ * @param opts.maxScanLength - Max characters to scan. Text beyond this limit is not evaluated. Default: 102400.
94
+ */
95
+ constructor(opts = {}) {
96
+ const actionStr = opts.action ?? 'deny';
97
+ const validActions = Object.values(GuardAction);
98
+ if (!validActions.includes(actionStr)) {
99
+ throw new GuardConfigError(`Invalid action '${actionStr}'. Must be one of: ${validActions.join(', ')}`);
100
+ }
101
+ this._action = actionStr;
102
+ const maxScan = opts.maxScanLength ?? 102400;
103
+ if (typeof maxScan !== 'number' || maxScan < 0) {
104
+ throw new GuardConfigError(`Invalid maxScanLength '${maxScan}'. Must be a non-negative number.`);
105
+ }
106
+ this._maxScanLength = maxScan;
107
+ }
108
+ get action() {
109
+ return this._action;
110
+ }
111
+ supportsPhase(phase) {
112
+ return this.phases.includes(phase);
113
+ }
114
+ /** Execute the guard with timing, text-length capping, and phase filtering. */
115
+ run(text, phase) {
116
+ if (!this.supportsPhase(phase)) {
117
+ return makeGuardResult({ guardName: this.name });
118
+ }
119
+ const capped = this._maxScanLength ? text.slice(0, this._maxScanLength) : text;
120
+ const start = performance.now();
121
+ const result = this.evaluate(capped);
122
+ const elapsedMs = performance.now() - start;
123
+ return makeGuardResult({
124
+ action: result.action,
125
+ score: result.score,
126
+ guardName: this.name,
127
+ classification: result.classification,
128
+ explanation: result.explanation,
129
+ transformedText: result.transformedText,
130
+ latencyMs: Math.round(elapsedMs * 1000) / 1000,
131
+ });
55
132
  }
56
133
  }
57
- exports.BaseGuard = BaseGuard;
134
+ exports.Guard = Guard;
58
135
  //# sourceMappingURL=base.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/guard/base.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAsB,SAAS;IAW7B,YAAY,SAAsB,EAAE;QAClC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK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AC;IAED,+EAA+E;IAC/E,GAAG,CAAC,IAAY,EAAE,KAAiB;QACjC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,eAAe,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE/E,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QAE5C,OAAO,eAAe,CAAC;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,SAAS,EAAE,IAAI,CAAC,IAAI;YACpB,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,IAAI;SAC/C,CAAC,CAAC;IACL,CAAC;CASF;AApED,sBAoEC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Custom guard -- user-defined regex or callable.
3
+ *
4
+ * Must stay in sync with: sdk/python/src/openlit/guard/custom.py
5
+ */
6
+ import { Guard, GuardPhase, GuardResult, GuardOptions } from './base';
7
+ export interface CustomOptions extends GuardOptions {
8
+ pattern?: string;
9
+ callable?: (text: string) => GuardResult;
10
+ phases?: string[];
11
+ }
12
+ export declare class Custom extends Guard {
13
+ readonly name = "custom";
14
+ readonly phases: GuardPhase[];
15
+ private readonly _pattern;
16
+ private readonly _callable?;
17
+ constructor(opts?: CustomOptions);
18
+ evaluate(text: string): GuardResult;
19
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ /**
3
+ * Custom guard -- user-defined regex or callable.
4
+ *
5
+ * Must stay in sync with: sdk/python/src/openlit/guard/custom.py
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.Custom = void 0;
9
+ const base_1 = require("./base");
10
+ class Custom extends base_1.Guard {
11
+ constructor(opts = {}) {
12
+ super({ action: opts.action ?? 'deny', maxScanLength: opts.maxScanLength });
13
+ this.name = 'custom';
14
+ if (!opts.pattern && !opts.callable) {
15
+ throw new base_1.GuardConfigError("Custom guard needs at least 'pattern' or 'callable'");
16
+ }
17
+ this._pattern = opts.pattern ? new RegExp(opts.pattern) : null;
18
+ this._callable = opts.callable;
19
+ if (opts.phases) {
20
+ this.phases = opts.phases.map((p) => p);
21
+ }
22
+ else {
23
+ this.phases = [base_1.GuardPhase.PREFLIGHT, base_1.GuardPhase.POSTFLIGHT];
24
+ }
25
+ }
26
+ evaluate(text) {
27
+ if (this._pattern) {
28
+ const match = this._pattern.exec(text);
29
+ if (match) {
30
+ return (0, base_1.makeGuardResult)({
31
+ action: this._action,
32
+ score: 1.0,
33
+ guardName: this.name,
34
+ classification: 'pattern_match',
35
+ explanation: `Custom pattern matched: '${match[0]}'`,
36
+ });
37
+ }
38
+ }
39
+ if (this._callable) {
40
+ return this._callable(text);
41
+ }
42
+ return (0, base_1.makeGuardResult)({ guardName: this.name });
43
+ }
44
+ }
45
+ exports.Custom = Custom;
46
+ //# sourceMappingURL=custom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom.js","sourceRoot":"","sources":["../../src/guard/custom.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,iCAOgB;AAQhB,MAAa,MAAO,SAAQ,YAAK;IAO/B,YAAY,OAAsB,EAAE;QAClC,KAAK,CAAC,EAAE,MAAM,EAAE,IA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AO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;QAED,OAAO,IAAA,sBAAe,EAAC,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;CACF;AA5CD,wBA4CC"}
@@ -1,5 +1,24 @@
1
- export * from './prompt-injection';
2
- export * from './sensitive-topic';
3
- export * from './topic-restriction';
4
- export * from './all';
5
- export * from './types';
1
+ /**
2
+ * OpenLIT Guard System -- public API.
3
+ *
4
+ * Re-exports all guard classes, pipeline, types, and errors.
5
+ */
6
+ export { Guard, GuardAction, GuardPhase, GuardConfigError, GuardDeniedError, GuardError, GuardTimeoutError, PipelineResult, ACTION_SEVERITY, makeGuardResult, } from './base';
7
+ export type { GuardResult, GuardOptions } from './base';
8
+ export { Pipeline } from './pipeline';
9
+ export type { PipelineOptions } from './pipeline';
10
+ export { PII } from './pii';
11
+ export type { PIIOptions } from './pii';
12
+ export { PromptInjection } from './prompt-injection';
13
+ export type { PromptInjectionOptions } from './prompt-injection';
14
+ export { Moderation } from './moderation';
15
+ export type { ModerationOptions } from './moderation';
16
+ export { SensitiveTopic } from './sensitive-topic';
17
+ export type { SensitiveTopicOptions } from './sensitive-topic';
18
+ export { TopicRestriction } from './topic-restriction';
19
+ export type { TopicRestrictionOptions } from './topic-restriction';
20
+ export { Schema } from './schema';
21
+ export type { SchemaOptions } from './schema';
22
+ export { Custom } from './custom';
23
+ export type { CustomOptions } from './custom';
24
+ export { setupAutoGuards } from './integration';
@@ -1,24 +1,42 @@
1
1
  "use strict";
2
- // Guard SDK for OpenLIT (TypeScript)
3
- // This folder contains guardrail detectors for prompt injection, sensitive topics, and topic restriction.
4
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
- if (k2 === undefined) k2 = k;
6
- var desc = Object.getOwnPropertyDescriptor(m, k);
7
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
- desc = { enumerable: true, get: function() { return m[k]; } };
9
- }
10
- Object.defineProperty(o, k2, desc);
11
- }) : (function(o, m, k, k2) {
12
- if (k2 === undefined) k2 = k;
13
- o[k2] = m[k];
14
- }));
15
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
- };
2
+ /**
3
+ * OpenLIT Guard System -- public API.
4
+ *
5
+ * Re-exports all guard classes, pipeline, types, and errors.
6
+ */
18
7
  Object.defineProperty(exports, "__esModule", { value: true });
19
- __exportStar(require("./prompt-injection"), exports);
20
- __exportStar(require("./sensitive-topic"), exports);
21
- __exportStar(require("./topic-restriction"), exports);
22
- __exportStar(require("./all"), exports);
23
- __exportStar(require("./types"), exports);
8
+ exports.setupAutoGuards = exports.Custom = exports.Schema = exports.TopicRestriction = exports.SensitiveTopic = exports.Moderation = exports.PromptInjection = exports.PII = exports.Pipeline = exports.makeGuardResult = exports.ACTION_SEVERITY = exports.PipelineResult = exports.GuardTimeoutError = exports.GuardError = exports.GuardDeniedError = exports.GuardConfigError = exports.GuardPhase = exports.GuardAction = exports.Guard = void 0;
9
+ // Foundation types and base class
10
+ var base_1 = require("./base");
11
+ Object.defineProperty(exports, "Guard", { enumerable: true, get: function () { return base_1.Guard; } });
12
+ Object.defineProperty(exports, "GuardAction", { enumerable: true, get: function () { return base_1.GuardAction; } });
13
+ Object.defineProperty(exports, "GuardPhase", { enumerable: true, get: function () { return base_1.GuardPhase; } });
14
+ Object.defineProperty(exports, "GuardConfigError", { enumerable: true, get: function () { return base_1.GuardConfigError; } });
15
+ Object.defineProperty(exports, "GuardDeniedError", { enumerable: true, get: function () { return base_1.GuardDeniedError; } });
16
+ Object.defineProperty(exports, "GuardError", { enumerable: true, get: function () { return base_1.GuardError; } });
17
+ Object.defineProperty(exports, "GuardTimeoutError", { enumerable: true, get: function () { return base_1.GuardTimeoutError; } });
18
+ Object.defineProperty(exports, "PipelineResult", { enumerable: true, get: function () { return base_1.PipelineResult; } });
19
+ Object.defineProperty(exports, "ACTION_SEVERITY", { enumerable: true, get: function () { return base_1.ACTION_SEVERITY; } });
20
+ Object.defineProperty(exports, "makeGuardResult", { enumerable: true, get: function () { return base_1.makeGuardResult; } });
21
+ // Pipeline
22
+ var pipeline_1 = require("./pipeline");
23
+ Object.defineProperty(exports, "Pipeline", { enumerable: true, get: function () { return pipeline_1.Pipeline; } });
24
+ // Guards
25
+ var pii_1 = require("./pii");
26
+ Object.defineProperty(exports, "PII", { enumerable: true, get: function () { return pii_1.PII; } });
27
+ var prompt_injection_1 = require("./prompt-injection");
28
+ Object.defineProperty(exports, "PromptInjection", { enumerable: true, get: function () { return prompt_injection_1.PromptInjection; } });
29
+ var moderation_1 = require("./moderation");
30
+ Object.defineProperty(exports, "Moderation", { enumerable: true, get: function () { return moderation_1.Moderation; } });
31
+ var sensitive_topic_1 = require("./sensitive-topic");
32
+ Object.defineProperty(exports, "SensitiveTopic", { enumerable: true, get: function () { return sensitive_topic_1.SensitiveTopic; } });
33
+ var topic_restriction_1 = require("./topic-restriction");
34
+ Object.defineProperty(exports, "TopicRestriction", { enumerable: true, get: function () { return topic_restriction_1.TopicRestriction; } });
35
+ var schema_1 = require("./schema");
36
+ Object.defineProperty(exports, "Schema", { enumerable: true, get: function () { return schema_1.Schema; } });
37
+ var custom_1 = require("./custom");
38
+ Object.defineProperty(exports, "Custom", { enumerable: true, get: function () { return custom_1.Custom; } });
39
+ // Integration
40
+ var integration_1 = require("./integration");
41
+ Object.defineProperty(exports, "setupAutoGuards", { enumerable: true, get: function () { return integration_1.setupAutoGuards; } });
24
42
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/guard/index.ts"],"names":[],"mappings":";AAAA,qCAAqC;AACrC,0GAA0G;;;;;;;;;;;;;;;;AAE1G,qDAAmC;AACnC,oDAAkC;AAClC,sDAAoC;AACpC,wCAAsB;AACtB,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/guard/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,kCAAkC;AAClC,+BAWgB;AAVd,6FAAA,KAAK,OAAA;AACL,mGAAA,WAAW,OAAA;AACX,kGAAA,UAAU,OAAA;AACV,wGAAA,gBAAgB,OAAA;AAChB,wGAAA,gBAAgB,OAAA;AAChB,kGAAA,UAAU,OAAA;AACV,yGAAA,iBAAiB,OAAA;AACjB,sGAAA,cAAc,OAAA;AACd,uGAAA,eAAe,OAAA;AACf,uGAAA,eAAe,OAAA;AAIjB,WAAW;AACX,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AAGjB,SAAS;AACT,6BAA4B;AAAnB,0FAAA,GAAG,OAAA;AAEZ,uDAAqD;AAA5C,mHAAA,eAAe,OAAA;AAExB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AAEnB,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AAEvB,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AAEzB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAEf,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAGf,cAAc;AACd,6CAAgD;AAAvC,8GAAA,eAAe,OAAA"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Auto-guard integration layer.
3
+ *
4
+ * setupAutoGuards wraps LLM provider methods so that guards run on every
5
+ * call without any changes to existing instrumentation code.
6
+ *
7
+ * Call chain after setup:
8
+ *
9
+ * User call
10
+ * -> Guard wrapper (preflight -> may deny/redact)
11
+ * -> Instrumentor wrapper (OTel telemetry)
12
+ * -> Original SDK method (actual API call)
13
+ * <- Instrumentor wrapper
14
+ * <- Guard wrapper (postflight -> may redact/warn)
15
+ * <- Returns to user
16
+ *
17
+ * **Streaming limitation**: postflight guards require a complete response
18
+ * object with `choices[].message.content` (or equivalent). Streaming
19
+ * responses yield incremental chunks that extractors cannot fully
20
+ * reassemble, so postflight guards are silently skipped for streamed
21
+ * completions. Preflight guards always run.
22
+ *
23
+ * Must stay in sync with: sdk/python/src/openlit/guard/_integration.py
24
+ */
25
+ import { Guard } from './base';
26
+ export declare function extractOpenAIInput(kwargs: Record<string, any>): string;
27
+ export declare function extractOpenAIOutput(response: any): string;
28
+ export declare function extractAnthropicInput(kwargs: Record<string, any>): string;
29
+ export declare function extractAnthropicOutput(response: any): string;
30
+ export declare function extractGenericInput(kwargs: Record<string, any>): string;
31
+ export declare function extractGenericOutput(response: any): string;
32
+ export declare function setupAutoGuards(guards: Guard[], failOpen?: boolean): void;