shield360 1.0.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 (520) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +310 -0
  3. package/dist/__tests__/manual-trace.test.d.ts +1 -0
  4. package/dist/__tests__/manual-trace.test.js +118 -0
  5. package/dist/__tests__/manual-trace.test.js.map +1 -0
  6. package/dist/__tests__/register.test.d.ts +0 -0
  7. package/dist/__tests__/register.test.js +90 -0
  8. package/dist/__tests__/register.test.js.map +1 -0
  9. package/dist/config.d.ts +28 -0
  10. package/dist/config.js +22 -0
  11. package/dist/config.js.map +1 -0
  12. package/dist/constant.d.ts +6 -0
  13. package/dist/constant.js +14 -0
  14. package/dist/constant.js.map +1 -0
  15. package/dist/evals/__tests__/offline.test.d.ts +1 -0
  16. package/dist/evals/__tests__/offline.test.js +427 -0
  17. package/dist/evals/__tests__/offline.test.js.map +1 -0
  18. package/dist/evals/index.d.ts +2 -0
  19. package/dist/evals/index.js +15 -0
  20. package/dist/evals/index.js.map +1 -0
  21. package/dist/evals/offline.d.ts +6 -0
  22. package/dist/evals/offline.js +350 -0
  23. package/dist/evals/offline.js.map +1 -0
  24. package/dist/evals/types.d.ts +74 -0
  25. package/dist/evals/types.js +23 -0
  26. package/dist/evals/types.js.map +1 -0
  27. package/dist/features/__tests__/rule-engine.test.d.ts +1 -0
  28. package/dist/features/__tests__/rule-engine.test.js +146 -0
  29. package/dist/features/__tests__/rule-engine.test.js.map +1 -0
  30. package/dist/features/base.d.ts +8 -0
  31. package/dist/features/base.js +15 -0
  32. package/dist/features/base.js.map +1 -0
  33. package/dist/features/prompt-hub.d.ts +4 -0
  34. package/dist/features/prompt-hub.js +66 -0
  35. package/dist/features/prompt-hub.js.map +1 -0
  36. package/dist/features/rule-engine.d.ts +6 -0
  37. package/dist/features/rule-engine.js +60 -0
  38. package/dist/features/rule-engine.js.map +1 -0
  39. package/dist/features/vault.d.ts +4 -0
  40. package/dist/features/vault.js +63 -0
  41. package/dist/features/vault.js.map +1 -0
  42. package/dist/guard/__tests__/findings.test.d.ts +1 -0
  43. package/dist/guard/__tests__/findings.test.js +79 -0
  44. package/dist/guard/__tests__/findings.test.js.map +1 -0
  45. package/dist/guard/__tests__/integration.test.d.ts +1 -0
  46. package/dist/guard/__tests__/integration.test.js +215 -0
  47. package/dist/guard/__tests__/integration.test.js.map +1 -0
  48. package/dist/guard/__tests__/pii.test.d.ts +1 -0
  49. package/dist/guard/__tests__/pii.test.js +131 -0
  50. package/dist/guard/__tests__/pii.test.js.map +1 -0
  51. package/dist/guard/__tests__/pipeline.test.d.ts +1 -0
  52. package/dist/guard/__tests__/pipeline.test.js +162 -0
  53. package/dist/guard/__tests__/pipeline.test.js.map +1 -0
  54. package/dist/guard/__tests__/prompt-injection.test.d.ts +1 -0
  55. package/dist/guard/__tests__/prompt-injection.test.js +92 -0
  56. package/dist/guard/__tests__/prompt-injection.test.js.map +1 -0
  57. package/dist/guard/__tests__/report.test.d.ts +1 -0
  58. package/dist/guard/__tests__/report.test.js +50 -0
  59. package/dist/guard/__tests__/report.test.js.map +1 -0
  60. package/dist/guard/base.d.ts +79 -0
  61. package/dist/guard/base.js +136 -0
  62. package/dist/guard/base.js.map +1 -0
  63. package/dist/guard/custom.d.ts +19 -0
  64. package/dist/guard/custom.js +46 -0
  65. package/dist/guard/custom.js.map +1 -0
  66. package/dist/guard/findings.d.ts +31 -0
  67. package/dist/guard/findings.js +156 -0
  68. package/dist/guard/findings.js.map +1 -0
  69. package/dist/guard/index.d.ts +24 -0
  70. package/dist/guard/index.js +42 -0
  71. package/dist/guard/index.js.map +1 -0
  72. package/dist/guard/integration.d.ts +44 -0
  73. package/dist/guard/integration.js +363 -0
  74. package/dist/guard/integration.js.map +1 -0
  75. package/dist/guard/moderation.d.ts +18 -0
  76. package/dist/guard/moderation.js +61 -0
  77. package/dist/guard/moderation.js.map +1 -0
  78. package/dist/guard/pii.d.ts +17 -0
  79. package/dist/guard/pii.js +114 -0
  80. package/dist/guard/pii.js.map +1 -0
  81. package/dist/guard/pipeline.d.ts +26 -0
  82. package/dist/guard/pipeline.js +139 -0
  83. package/dist/guard/pipeline.js.map +1 -0
  84. package/dist/guard/prompt-injection.d.ts +21 -0
  85. package/dist/guard/prompt-injection.js +70 -0
  86. package/dist/guard/prompt-injection.js.map +1 -0
  87. package/dist/guard/report.d.ts +34 -0
  88. package/dist/guard/report.js +182 -0
  89. package/dist/guard/report.js.map +1 -0
  90. package/dist/guard/schema.d.ts +20 -0
  91. package/dist/guard/schema.js +99 -0
  92. package/dist/guard/schema.js.map +1 -0
  93. package/dist/guard/sensitive-topic.d.ts +23 -0
  94. package/dist/guard/sensitive-topic.js +89 -0
  95. package/dist/guard/sensitive-topic.js.map +1 -0
  96. package/dist/guard/topic-restriction.d.ts +22 -0
  97. package/dist/guard/topic-restriction.js +54 -0
  98. package/dist/guard/topic-restriction.js.map +1 -0
  99. package/dist/helpers.d.ts +246 -0
  100. package/dist/helpers.js +903 -0
  101. package/dist/helpers.js.map +1 -0
  102. package/dist/index.d.ts +71 -0
  103. package/dist/index.js +234 -0
  104. package/dist/index.js.map +1 -0
  105. package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.d.ts +13 -0
  106. package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.js +176 -0
  107. package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.js.map +1 -0
  108. package/dist/instrumentation/__tests__/ai21-trace-comparison.test.d.ts +10 -0
  109. package/dist/instrumentation/__tests__/ai21-trace-comparison.test.js +203 -0
  110. package/dist/instrumentation/__tests__/ai21-trace-comparison.test.js.map +1 -0
  111. package/dist/instrumentation/__tests__/anthropic-wrapper.test.d.ts +1 -0
  112. package/dist/instrumentation/__tests__/anthropic-wrapper.test.js +284 -0
  113. package/dist/instrumentation/__tests__/anthropic-wrapper.test.js.map +1 -0
  114. package/dist/instrumentation/__tests__/assemblyai-wrapper.test.d.ts +1 -0
  115. package/dist/instrumentation/__tests__/assemblyai-wrapper.test.js +284 -0
  116. package/dist/instrumentation/__tests__/assemblyai-wrapper.test.js.map +1 -0
  117. package/dist/instrumentation/__tests__/astra-trace-comparison.test.d.ts +7 -0
  118. package/dist/instrumentation/__tests__/astra-trace-comparison.test.js +160 -0
  119. package/dist/instrumentation/__tests__/astra-trace-comparison.test.js.map +1 -0
  120. package/dist/instrumentation/__tests__/base-wrapper.test.d.ts +1 -0
  121. package/dist/instrumentation/__tests__/base-wrapper.test.js +171 -0
  122. package/dist/instrumentation/__tests__/base-wrapper.test.js.map +1 -0
  123. package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.d.ts +1 -0
  124. package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.js +422 -0
  125. package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.js.map +1 -0
  126. package/dist/instrumentation/__tests__/browser-use-wrapper.test.d.ts +1 -0
  127. package/dist/instrumentation/__tests__/browser-use-wrapper.test.js +284 -0
  128. package/dist/instrumentation/__tests__/browser-use-wrapper.test.js.map +1 -0
  129. package/dist/instrumentation/__tests__/cache-pricing.test.d.ts +15 -0
  130. package/dist/instrumentation/__tests__/cache-pricing.test.js +155 -0
  131. package/dist/instrumentation/__tests__/cache-pricing.test.js.map +1 -0
  132. package/dist/instrumentation/__tests__/chroma-trace-comparison.test.d.ts +18 -0
  133. package/dist/instrumentation/__tests__/chroma-trace-comparison.test.js +209 -0
  134. package/dist/instrumentation/__tests__/chroma-trace-comparison.test.js.map +1 -0
  135. package/dist/instrumentation/__tests__/cohere-wrapper.test.d.ts +1 -0
  136. package/dist/instrumentation/__tests__/cohere-wrapper.test.js +256 -0
  137. package/dist/instrumentation/__tests__/cohere-wrapper.test.js.map +1 -0
  138. package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.d.ts +1 -0
  139. package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.js +282 -0
  140. package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.js.map +1 -0
  141. package/dist/instrumentation/__tests__/firecrawl-wrapper.test.d.ts +1 -0
  142. package/dist/instrumentation/__tests__/firecrawl-wrapper.test.js +238 -0
  143. package/dist/instrumentation/__tests__/firecrawl-wrapper.test.js.map +1 -0
  144. package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.d.ts +4 -0
  145. package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.js +229 -0
  146. package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.js.map +1 -0
  147. package/dist/instrumentation/__tests__/gpu-collector.test.d.ts +1 -0
  148. package/dist/instrumentation/__tests__/gpu-collector.test.js +247 -0
  149. package/dist/instrumentation/__tests__/gpu-collector.test.js.map +1 -0
  150. package/dist/instrumentation/__tests__/gradient-trace-comparison.test.d.ts +11 -0
  151. package/dist/instrumentation/__tests__/gradient-trace-comparison.test.js +391 -0
  152. package/dist/instrumentation/__tests__/gradient-trace-comparison.test.js.map +1 -0
  153. package/dist/instrumentation/__tests__/groq-trace-comparison.test.d.ts +7 -0
  154. package/dist/instrumentation/__tests__/groq-trace-comparison.test.js +687 -0
  155. package/dist/instrumentation/__tests__/groq-trace-comparison.test.js.map +1 -0
  156. package/dist/instrumentation/__tests__/helpers-genai.test.d.ts +14 -0
  157. package/dist/instrumentation/__tests__/helpers-genai.test.js +347 -0
  158. package/dist/instrumentation/__tests__/helpers-genai.test.js.map +1 -0
  159. package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.d.ts +7 -0
  160. package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.js +529 -0
  161. package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.js.map +1 -0
  162. package/dist/instrumentation/__tests__/langchain-role-map.test.d.ts +1 -0
  163. package/dist/instrumentation/__tests__/langchain-role-map.test.js +19 -0
  164. package/dist/instrumentation/__tests__/langchain-role-map.test.js.map +1 -0
  165. package/dist/instrumentation/__tests__/langchain-wrapper.test.d.ts +1 -0
  166. package/dist/instrumentation/__tests__/langchain-wrapper.test.js +282 -0
  167. package/dist/instrumentation/__tests__/langchain-wrapper.test.js.map +1 -0
  168. package/dist/instrumentation/__tests__/letta-wrapper.test.d.ts +1 -0
  169. package/dist/instrumentation/__tests__/letta-wrapper.test.js +285 -0
  170. package/dist/instrumentation/__tests__/letta-wrapper.test.js.map +1 -0
  171. package/dist/instrumentation/__tests__/mem0-trace-comparison.test.d.ts +13 -0
  172. package/dist/instrumentation/__tests__/mem0-trace-comparison.test.js +208 -0
  173. package/dist/instrumentation/__tests__/mem0-trace-comparison.test.js.map +1 -0
  174. package/dist/instrumentation/__tests__/milvus-trace-comparison.test.d.ts +17 -0
  175. package/dist/instrumentation/__tests__/milvus-trace-comparison.test.js +206 -0
  176. package/dist/instrumentation/__tests__/milvus-trace-comparison.test.js.map +1 -0
  177. package/dist/instrumentation/__tests__/mistral-trace-comparison.test.d.ts +1 -0
  178. package/dist/instrumentation/__tests__/mistral-trace-comparison.test.js +345 -0
  179. package/dist/instrumentation/__tests__/mistral-trace-comparison.test.js.map +1 -0
  180. package/dist/instrumentation/__tests__/openai-wrapper.test.d.ts +1 -0
  181. package/dist/instrumentation/__tests__/openai-wrapper.test.js +179 -0
  182. package/dist/instrumentation/__tests__/openai-wrapper.test.js.map +1 -0
  183. package/dist/instrumentation/__tests__/pg-trace-comparison.test.d.ts +21 -0
  184. package/dist/instrumentation/__tests__/pg-trace-comparison.test.js +455 -0
  185. package/dist/instrumentation/__tests__/pg-trace-comparison.test.js.map +1 -0
  186. package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.d.ts +17 -0
  187. package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.js +182 -0
  188. package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.js.map +1 -0
  189. package/dist/instrumentation/__tests__/replicate-trace-comparison.test.d.ts +8 -0
  190. package/dist/instrumentation/__tests__/replicate-trace-comparison.test.js +346 -0
  191. package/dist/instrumentation/__tests__/replicate-trace-comparison.test.js.map +1 -0
  192. package/dist/instrumentation/__tests__/together-trace-comparison.test.d.ts +4 -0
  193. package/dist/instrumentation/__tests__/together-trace-comparison.test.js +289 -0
  194. package/dist/instrumentation/__tests__/together-trace-comparison.test.js.map +1 -0
  195. package/dist/instrumentation/__tests__/trace-comparison-utils.d.ts +67 -0
  196. package/dist/instrumentation/__tests__/trace-comparison-utils.js +255 -0
  197. package/dist/instrumentation/__tests__/trace-comparison-utils.js.map +1 -0
  198. package/dist/instrumentation/__tests__/transformers-trace-comparison.test.d.ts +11 -0
  199. package/dist/instrumentation/__tests__/transformers-trace-comparison.test.js +214 -0
  200. package/dist/instrumentation/__tests__/transformers-trace-comparison.test.js.map +1 -0
  201. package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.d.ts +8 -0
  202. package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.js +446 -0
  203. package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.js.map +1 -0
  204. package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.d.ts +6 -0
  205. package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.js +409 -0
  206. package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.js.map +1 -0
  207. package/dist/instrumentation/__tests__/vllm-trace-comparison.test.d.ts +1 -0
  208. package/dist/instrumentation/__tests__/vllm-trace-comparison.test.js +519 -0
  209. package/dist/instrumentation/__tests__/vllm-trace-comparison.test.js.map +1 -0
  210. package/dist/instrumentation/ai21/index.d.ts +11 -0
  211. package/dist/instrumentation/ai21/index.js +67 -0
  212. package/dist/instrumentation/ai21/index.js.map +1 -0
  213. package/dist/instrumentation/ai21/wrapper.d.ts +54 -0
  214. package/dist/instrumentation/ai21/wrapper.js +511 -0
  215. package/dist/instrumentation/ai21/wrapper.js.map +1 -0
  216. package/dist/instrumentation/anthropic/index.d.ts +11 -0
  217. package/dist/instrumentation/anthropic/index.js +45 -0
  218. package/dist/instrumentation/anthropic/index.js.map +1 -0
  219. package/dist/instrumentation/anthropic/wrapper.d.ts +34 -0
  220. package/dist/instrumentation/anthropic/wrapper.js +426 -0
  221. package/dist/instrumentation/anthropic/wrapper.js.map +1 -0
  222. package/dist/instrumentation/assemblyai/index.d.ts +12 -0
  223. package/dist/instrumentation/assemblyai/index.js +91 -0
  224. package/dist/instrumentation/assemblyai/index.js.map +1 -0
  225. package/dist/instrumentation/assemblyai/wrapper.d.ts +35 -0
  226. package/dist/instrumentation/assemblyai/wrapper.js +238 -0
  227. package/dist/instrumentation/assemblyai/wrapper.js.map +1 -0
  228. package/dist/instrumentation/astra/index.d.ts +11 -0
  229. package/dist/instrumentation/astra/index.js +87 -0
  230. package/dist/instrumentation/astra/index.js.map +1 -0
  231. package/dist/instrumentation/astra/wrapper.d.ts +39 -0
  232. package/dist/instrumentation/astra/wrapper.js +349 -0
  233. package/dist/instrumentation/astra/wrapper.js.map +1 -0
  234. package/dist/instrumentation/azure-ai-inference/index.d.ts +11 -0
  235. package/dist/instrumentation/azure-ai-inference/index.js +76 -0
  236. package/dist/instrumentation/azure-ai-inference/index.js.map +1 -0
  237. package/dist/instrumentation/azure-ai-inference/wrapper.d.ts +55 -0
  238. package/dist/instrumentation/azure-ai-inference/wrapper.js +580 -0
  239. package/dist/instrumentation/azure-ai-inference/wrapper.js.map +1 -0
  240. package/dist/instrumentation/base-wrapper.d.ts +16 -0
  241. package/dist/instrumentation/base-wrapper.js +139 -0
  242. package/dist/instrumentation/base-wrapper.js.map +1 -0
  243. package/dist/instrumentation/bedrock/index.d.ts +11 -0
  244. package/dist/instrumentation/bedrock/index.js +52 -0
  245. package/dist/instrumentation/bedrock/index.js.map +1 -0
  246. package/dist/instrumentation/bedrock/wrapper.d.ts +41 -0
  247. package/dist/instrumentation/bedrock/wrapper.js +494 -0
  248. package/dist/instrumentation/bedrock/wrapper.js.map +1 -0
  249. package/dist/instrumentation/browser-use/index.d.ts +11 -0
  250. package/dist/instrumentation/browser-use/index.js +98 -0
  251. package/dist/instrumentation/browser-use/index.js.map +1 -0
  252. package/dist/instrumentation/browser-use/wrapper.d.ts +12 -0
  253. package/dist/instrumentation/browser-use/wrapper.js +706 -0
  254. package/dist/instrumentation/browser-use/wrapper.js.map +1 -0
  255. package/dist/instrumentation/chroma/index.d.ts +11 -0
  256. package/dist/instrumentation/chroma/index.js +70 -0
  257. package/dist/instrumentation/chroma/index.js.map +1 -0
  258. package/dist/instrumentation/chroma/wrapper.d.ts +10 -0
  259. package/dist/instrumentation/chroma/wrapper.js +127 -0
  260. package/dist/instrumentation/chroma/wrapper.js.map +1 -0
  261. package/dist/instrumentation/claude-agent-sdk/index.d.ts +23 -0
  262. package/dist/instrumentation/claude-agent-sdk/index.js +83 -0
  263. package/dist/instrumentation/claude-agent-sdk/index.js.map +1 -0
  264. package/dist/instrumentation/claude-agent-sdk/wrapper.d.ts +13 -0
  265. package/dist/instrumentation/claude-agent-sdk/wrapper.js +1123 -0
  266. package/dist/instrumentation/claude-agent-sdk/wrapper.js.map +1 -0
  267. package/dist/instrumentation/cohere/index.d.ts +11 -0
  268. package/dist/instrumentation/cohere/index.js +53 -0
  269. package/dist/instrumentation/cohere/index.js.map +1 -0
  270. package/dist/instrumentation/cohere/wrapper.d.ts +50 -0
  271. package/dist/instrumentation/cohere/wrapper.js +452 -0
  272. package/dist/instrumentation/cohere/wrapper.js.map +1 -0
  273. package/dist/instrumentation/cursor-sdk/index.d.ts +21 -0
  274. package/dist/instrumentation/cursor-sdk/index.js +58 -0
  275. package/dist/instrumentation/cursor-sdk/index.js.map +1 -0
  276. package/dist/instrumentation/cursor-sdk/wrapper.d.ts +17 -0
  277. package/dist/instrumentation/cursor-sdk/wrapper.js +789 -0
  278. package/dist/instrumentation/cursor-sdk/wrapper.js.map +1 -0
  279. package/dist/instrumentation/elevenlabs/index.d.ts +12 -0
  280. package/dist/instrumentation/elevenlabs/index.js +92 -0
  281. package/dist/instrumentation/elevenlabs/index.js.map +1 -0
  282. package/dist/instrumentation/elevenlabs/wrapper.d.ts +34 -0
  283. package/dist/instrumentation/elevenlabs/wrapper.js +280 -0
  284. package/dist/instrumentation/elevenlabs/wrapper.js.map +1 -0
  285. package/dist/instrumentation/firecrawl/index.d.ts +13 -0
  286. package/dist/instrumentation/firecrawl/index.js +115 -0
  287. package/dist/instrumentation/firecrawl/index.js.map +1 -0
  288. package/dist/instrumentation/firecrawl/wrapper.d.ts +22 -0
  289. package/dist/instrumentation/firecrawl/wrapper.js +378 -0
  290. package/dist/instrumentation/firecrawl/wrapper.js.map +1 -0
  291. package/dist/instrumentation/google-adk/index.d.ts +57 -0
  292. package/dist/instrumentation/google-adk/index.js +371 -0
  293. package/dist/instrumentation/google-adk/index.js.map +1 -0
  294. package/dist/instrumentation/google-adk/utils.d.ts +45 -0
  295. package/dist/instrumentation/google-adk/utils.js +663 -0
  296. package/dist/instrumentation/google-adk/utils.js.map +1 -0
  297. package/dist/instrumentation/google-adk/wrapper.d.ts +11 -0
  298. package/dist/instrumentation/google-adk/wrapper.js +391 -0
  299. package/dist/instrumentation/google-adk/wrapper.js.map +1 -0
  300. package/dist/instrumentation/google-ai/index.d.ts +11 -0
  301. package/dist/instrumentation/google-ai/index.js +48 -0
  302. package/dist/instrumentation/google-ai/index.js.map +1 -0
  303. package/dist/instrumentation/google-ai/wrapper.d.ts +52 -0
  304. package/dist/instrumentation/google-ai/wrapper.js +466 -0
  305. package/dist/instrumentation/google-ai/wrapper.js.map +1 -0
  306. package/dist/instrumentation/gpu/index.d.ts +38 -0
  307. package/dist/instrumentation/gpu/index.js +233 -0
  308. package/dist/instrumentation/gpu/index.js.map +1 -0
  309. package/dist/instrumentation/gradient/index.d.ts +12 -0
  310. package/dist/instrumentation/gradient/index.js +74 -0
  311. package/dist/instrumentation/gradient/index.js.map +1 -0
  312. package/dist/instrumentation/gradient/utils.d.ts +14 -0
  313. package/dist/instrumentation/gradient/utils.js +119 -0
  314. package/dist/instrumentation/gradient/utils.js.map +1 -0
  315. package/dist/instrumentation/gradient/wrapper.d.ts +76 -0
  316. package/dist/instrumentation/gradient/wrapper.js +584 -0
  317. package/dist/instrumentation/gradient/wrapper.js.map +1 -0
  318. package/dist/instrumentation/groq/index.d.ts +11 -0
  319. package/dist/instrumentation/groq/index.js +43 -0
  320. package/dist/instrumentation/groq/index.js.map +1 -0
  321. package/dist/instrumentation/groq/wrapper.d.ts +35 -0
  322. package/dist/instrumentation/groq/wrapper.js +442 -0
  323. package/dist/instrumentation/groq/wrapper.js.map +1 -0
  324. package/dist/instrumentation/huggingface/index.d.ts +13 -0
  325. package/dist/instrumentation/huggingface/index.js +110 -0
  326. package/dist/instrumentation/huggingface/index.js.map +1 -0
  327. package/dist/instrumentation/huggingface/wrapper.d.ts +54 -0
  328. package/dist/instrumentation/huggingface/wrapper.js +514 -0
  329. package/dist/instrumentation/huggingface/wrapper.js.map +1 -0
  330. package/dist/instrumentation/index.d.ts +7 -0
  331. package/dist/instrumentation/index.js +176 -0
  332. package/dist/instrumentation/index.js.map +1 -0
  333. package/dist/instrumentation/langchain/index.d.ts +16 -0
  334. package/dist/instrumentation/langchain/index.js +91 -0
  335. package/dist/instrumentation/langchain/index.js.map +1 -0
  336. package/dist/instrumentation/langchain/wrapper.d.ts +41 -0
  337. package/dist/instrumentation/langchain/wrapper.js +1235 -0
  338. package/dist/instrumentation/langchain/wrapper.js.map +1 -0
  339. package/dist/instrumentation/langgraph/index.d.ts +12 -0
  340. package/dist/instrumentation/langgraph/index.js +99 -0
  341. package/dist/instrumentation/langgraph/index.js.map +1 -0
  342. package/dist/instrumentation/langgraph/wrapper.d.ts +20 -0
  343. package/dist/instrumentation/langgraph/wrapper.js +620 -0
  344. package/dist/instrumentation/langgraph/wrapper.js.map +1 -0
  345. package/dist/instrumentation/letta/index.d.ts +10 -0
  346. package/dist/instrumentation/letta/index.js +122 -0
  347. package/dist/instrumentation/letta/index.js.map +1 -0
  348. package/dist/instrumentation/letta/utils.d.ts +24 -0
  349. package/dist/instrumentation/letta/utils.js +343 -0
  350. package/dist/instrumentation/letta/utils.js.map +1 -0
  351. package/dist/instrumentation/letta/wrapper.d.ts +37 -0
  352. package/dist/instrumentation/letta/wrapper.js +180 -0
  353. package/dist/instrumentation/letta/wrapper.js.map +1 -0
  354. package/dist/instrumentation/llamaindex/index.d.ts +36 -0
  355. package/dist/instrumentation/llamaindex/index.js +221 -0
  356. package/dist/instrumentation/llamaindex/index.js.map +1 -0
  357. package/dist/instrumentation/llamaindex/wrapper.d.ts +36 -0
  358. package/dist/instrumentation/llamaindex/wrapper.js +811 -0
  359. package/dist/instrumentation/llamaindex/wrapper.js.map +1 -0
  360. package/dist/instrumentation/mcp/index.d.ts +20 -0
  361. package/dist/instrumentation/mcp/index.js +282 -0
  362. package/dist/instrumentation/mcp/index.js.map +1 -0
  363. package/dist/instrumentation/mcp/wrapper.d.ts +72 -0
  364. package/dist/instrumentation/mcp/wrapper.js +571 -0
  365. package/dist/instrumentation/mcp/wrapper.js.map +1 -0
  366. package/dist/instrumentation/mem0/index.d.ts +17 -0
  367. package/dist/instrumentation/mem0/index.js +113 -0
  368. package/dist/instrumentation/mem0/index.js.map +1 -0
  369. package/dist/instrumentation/mem0/wrapper.d.ts +37 -0
  370. package/dist/instrumentation/mem0/wrapper.js +298 -0
  371. package/dist/instrumentation/mem0/wrapper.js.map +1 -0
  372. package/dist/instrumentation/milvus/index.d.ts +11 -0
  373. package/dist/instrumentation/milvus/index.js +67 -0
  374. package/dist/instrumentation/milvus/index.js.map +1 -0
  375. package/dist/instrumentation/milvus/wrapper.d.ts +15 -0
  376. package/dist/instrumentation/milvus/wrapper.js +219 -0
  377. package/dist/instrumentation/milvus/wrapper.js.map +1 -0
  378. package/dist/instrumentation/mistral/index.d.ts +11 -0
  379. package/dist/instrumentation/mistral/index.js +66 -0
  380. package/dist/instrumentation/mistral/index.js.map +1 -0
  381. package/dist/instrumentation/mistral/wrapper.d.ts +49 -0
  382. package/dist/instrumentation/mistral/wrapper.js +482 -0
  383. package/dist/instrumentation/mistral/wrapper.js.map +1 -0
  384. package/dist/instrumentation/ollama/index.d.ts +11 -0
  385. package/dist/instrumentation/ollama/index.js +72 -0
  386. package/dist/instrumentation/ollama/index.js.map +1 -0
  387. package/dist/instrumentation/ollama/wrapper.d.ts +73 -0
  388. package/dist/instrumentation/ollama/wrapper.js +629 -0
  389. package/dist/instrumentation/ollama/wrapper.js.map +1 -0
  390. package/dist/instrumentation/openai/index.d.ts +11 -0
  391. package/dist/instrumentation/openai/index.js +79 -0
  392. package/dist/instrumentation/openai/index.js.map +1 -0
  393. package/dist/instrumentation/openai/wrapper.d.ts +80 -0
  394. package/dist/instrumentation/openai/wrapper.js +1121 -0
  395. package/dist/instrumentation/openai/wrapper.js.map +1 -0
  396. package/dist/instrumentation/openai-agents/index.d.ts +20 -0
  397. package/dist/instrumentation/openai-agents/index.js +174 -0
  398. package/dist/instrumentation/openai-agents/index.js.map +1 -0
  399. package/dist/instrumentation/openai-agents/processor.d.ts +35 -0
  400. package/dist/instrumentation/openai-agents/processor.js +249 -0
  401. package/dist/instrumentation/openai-agents/processor.js.map +1 -0
  402. package/dist/instrumentation/openai-agents/utils.d.ts +20 -0
  403. package/dist/instrumentation/openai-agents/utils.js +624 -0
  404. package/dist/instrumentation/openai-agents/utils.js.map +1 -0
  405. package/dist/instrumentation/pg/index.d.ts +20 -0
  406. package/dist/instrumentation/pg/index.js +74 -0
  407. package/dist/instrumentation/pg/index.js.map +1 -0
  408. package/dist/instrumentation/pg/wrapper.d.ts +66 -0
  409. package/dist/instrumentation/pg/wrapper.js +441 -0
  410. package/dist/instrumentation/pg/wrapper.js.map +1 -0
  411. package/dist/instrumentation/pinecone/index.d.ts +11 -0
  412. package/dist/instrumentation/pinecone/index.js +79 -0
  413. package/dist/instrumentation/pinecone/index.js.map +1 -0
  414. package/dist/instrumentation/pinecone/wrapper.d.ts +14 -0
  415. package/dist/instrumentation/pinecone/wrapper.js +198 -0
  416. package/dist/instrumentation/pinecone/wrapper.js.map +1 -0
  417. package/dist/instrumentation/qdrant/index.d.ts +11 -0
  418. package/dist/instrumentation/qdrant/index.js +67 -0
  419. package/dist/instrumentation/qdrant/index.js.map +1 -0
  420. package/dist/instrumentation/qdrant/wrapper.d.ts +14 -0
  421. package/dist/instrumentation/qdrant/wrapper.js +213 -0
  422. package/dist/instrumentation/qdrant/wrapper.js.map +1 -0
  423. package/dist/instrumentation/replicate/index.d.ts +11 -0
  424. package/dist/instrumentation/replicate/index.js +57 -0
  425. package/dist/instrumentation/replicate/index.js.map +1 -0
  426. package/dist/instrumentation/replicate/wrapper.d.ts +28 -0
  427. package/dist/instrumentation/replicate/wrapper.js +242 -0
  428. package/dist/instrumentation/replicate/wrapper.js.map +1 -0
  429. package/dist/instrumentation/strands/index.d.ts +21 -0
  430. package/dist/instrumentation/strands/index.js +83 -0
  431. package/dist/instrumentation/strands/index.js.map +1 -0
  432. package/dist/instrumentation/strands/processor.d.ts +51 -0
  433. package/dist/instrumentation/strands/processor.js +625 -0
  434. package/dist/instrumentation/strands/processor.js.map +1 -0
  435. package/dist/instrumentation/strands/utils.d.ts +24 -0
  436. package/dist/instrumentation/strands/utils.js +373 -0
  437. package/dist/instrumentation/strands/utils.js.map +1 -0
  438. package/dist/instrumentation/together/index.d.ts +11 -0
  439. package/dist/instrumentation/together/index.js +43 -0
  440. package/dist/instrumentation/together/index.js.map +1 -0
  441. package/dist/instrumentation/together/wrapper.d.ts +48 -0
  442. package/dist/instrumentation/together/wrapper.js +409 -0
  443. package/dist/instrumentation/together/wrapper.js.map +1 -0
  444. package/dist/instrumentation/transformers/index.d.ts +35 -0
  445. package/dist/instrumentation/transformers/index.js +119 -0
  446. package/dist/instrumentation/transformers/index.js.map +1 -0
  447. package/dist/instrumentation/transformers/wrapper.d.ts +49 -0
  448. package/dist/instrumentation/transformers/wrapper.js +472 -0
  449. package/dist/instrumentation/transformers/wrapper.js.map +1 -0
  450. package/dist/instrumentation/vercel-ai/index.d.ts +10 -0
  451. package/dist/instrumentation/vercel-ai/index.js +59 -0
  452. package/dist/instrumentation/vercel-ai/index.js.map +1 -0
  453. package/dist/instrumentation/vercel-ai/wrapper.d.ts +50 -0
  454. package/dist/instrumentation/vercel-ai/wrapper.js +539 -0
  455. package/dist/instrumentation/vercel-ai/wrapper.js.map +1 -0
  456. package/dist/instrumentation/vertexai/index.d.ts +11 -0
  457. package/dist/instrumentation/vertexai/index.js +70 -0
  458. package/dist/instrumentation/vertexai/index.js.map +1 -0
  459. package/dist/instrumentation/vertexai/wrapper.d.ts +67 -0
  460. package/dist/instrumentation/vertexai/wrapper.js +530 -0
  461. package/dist/instrumentation/vertexai/wrapper.js.map +1 -0
  462. package/dist/instrumentation/vllm/index.d.ts +13 -0
  463. package/dist/instrumentation/vllm/index.js +67 -0
  464. package/dist/instrumentation/vllm/index.js.map +1 -0
  465. package/dist/instrumentation/vllm/wrapper.d.ts +60 -0
  466. package/dist/instrumentation/vllm/wrapper.js +482 -0
  467. package/dist/instrumentation/vllm/wrapper.js.map +1 -0
  468. package/dist/llm/anthropic.d.ts +5 -0
  469. package/dist/llm/anthropic.js +39 -0
  470. package/dist/llm/anthropic.js.map +1 -0
  471. package/dist/llm/index.d.ts +10 -0
  472. package/dist/llm/index.js +93 -0
  473. package/dist/llm/index.js.map +1 -0
  474. package/dist/llm/openai.d.ts +6 -0
  475. package/dist/llm/openai.js +52 -0
  476. package/dist/llm/openai.js.map +1 -0
  477. package/dist/llm/providers.d.ts +7 -0
  478. package/dist/llm/providers.js +10 -0
  479. package/dist/llm/providers.js.map +1 -0
  480. package/dist/manual-trace.d.ts +40 -0
  481. package/dist/manual-trace.js +103 -0
  482. package/dist/manual-trace.js.map +1 -0
  483. package/dist/otel/__tests__/metrics.test.d.ts +1 -0
  484. package/dist/otel/__tests__/metrics.test.js +40 -0
  485. package/dist/otel/__tests__/metrics.test.js.map +1 -0
  486. package/dist/otel/events.d.ts +11 -0
  487. package/dist/otel/events.js +74 -0
  488. package/dist/otel/events.js.map +1 -0
  489. package/dist/otel/metrics.d.ts +35 -0
  490. package/dist/otel/metrics.js +219 -0
  491. package/dist/otel/metrics.js.map +1 -0
  492. package/dist/otel/tracing.d.ts +12 -0
  493. package/dist/otel/tracing.js +93 -0
  494. package/dist/otel/tracing.js.map +1 -0
  495. package/dist/otel/utils.d.ts +11 -0
  496. package/dist/otel/utils.js +34 -0
  497. package/dist/otel/utils.js.map +1 -0
  498. package/dist/pricing.json +951 -0
  499. package/dist/prompt-hub.d.ts +4 -0
  500. package/dist/prompt-hub.js +66 -0
  501. package/dist/prompt-hub.js.map +1 -0
  502. package/dist/register.d.ts +4 -0
  503. package/dist/register.js +52 -0
  504. package/dist/register.js.map +1 -0
  505. package/dist/score/__tests__/score.test.d.ts +1 -0
  506. package/dist/score/__tests__/score.test.js +143 -0
  507. package/dist/score/__tests__/score.test.js.map +1 -0
  508. package/dist/score/index.d.ts +2 -0
  509. package/dist/score/index.js +6 -0
  510. package/dist/score/index.js.map +1 -0
  511. package/dist/score/score.d.ts +15 -0
  512. package/dist/score/score.js +135 -0
  513. package/dist/score/score.js.map +1 -0
  514. package/dist/semantic-convention.d.ts +555 -0
  515. package/dist/semantic-convention.js +630 -0
  516. package/dist/semantic-convention.js.map +1 -0
  517. package/dist/types.d.ts +131 -0
  518. package/dist/types.js +3 -0
  519. package/dist/types.js.map +1 -0
  520. package/package.json +136 -0
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ /**
3
+ * Cross-Language Trace Comparison Tests for the AI21 Integration
4
+ *
5
+ * These verify that the TypeScript AI21 instrumentation emits the same span
6
+ * attributes / events as the Python SDK reference
7
+ * (sdk/python/src/shield360/instrumentation/ai21). AI21's request surface has no
8
+ * seed / frequency_penalty / presence_penalty, and its responses carry no
9
+ * `model` field, so the response model falls back to the request model.
10
+ */
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const wrapper_1 = __importDefault(require("../ai21/wrapper"));
16
+ const config_1 = __importDefault(require("../../config"));
17
+ const helpers_1 = __importDefault(require("../../helpers"));
18
+ const base_wrapper_1 = __importDefault(require("../base-wrapper"));
19
+ const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
20
+ jest.mock('../../config');
21
+ jest.mock('../../helpers');
22
+ jest.mock('../base-wrapper');
23
+ describe('AI21 Cross-Language Trace Comparison', () => {
24
+ let mockSpan;
25
+ beforeEach(() => {
26
+ mockSpan = {
27
+ setAttribute: jest.fn(),
28
+ addEvent: jest.fn(),
29
+ end: jest.fn(),
30
+ setStatus: jest.fn(),
31
+ };
32
+ config_1.default.environment = 'shield360-testing';
33
+ config_1.default.applicationName = 'shield360-test';
34
+ config_1.default.captureMessageContent = true;
35
+ config_1.default.pricingInfo = {};
36
+ config_1.default.disableEvents = false;
37
+ helpers_1.default.getChatModelCost = jest.fn().mockReturnValue(0.001);
38
+ helpers_1.default.openaiTokens = jest.fn().mockReturnValue(5);
39
+ helpers_1.default.handleException = jest.fn();
40
+ helpers_1.default.createStreamProxy = jest
41
+ .fn()
42
+ .mockImplementation((stream, _generator) => stream);
43
+ helpers_1.default.buildInputMessages = jest
44
+ .fn()
45
+ .mockReturnValue('[{"role":"user","parts":[{"type":"text","content":"Test"}]}]');
46
+ helpers_1.default.buildOutputMessages = jest
47
+ .fn()
48
+ .mockReturnValue('[{"role":"assistant","parts":[{"type":"text","content":"Response"}],"finish_reason":"stop"}]');
49
+ helpers_1.default.buildSystemInstructionsFromMessages = jest
50
+ .fn()
51
+ .mockImplementation((messages) => {
52
+ const sys = (messages || []).find((m) => m?.role === 'system');
53
+ return sys ? JSON.stringify([{ type: 'text', content: String(sys.content) }]) : undefined;
54
+ });
55
+ helpers_1.default.buildToolDefinitions = jest.fn().mockReturnValue(undefined);
56
+ helpers_1.default.emitInferenceEvent = jest.fn();
57
+ helpers_1.default.computeAgentVersionHash = jest
58
+ .fn()
59
+ .mockReturnValue('ts-test-version-hash');
60
+ base_wrapper_1.default.recordMetrics = jest.fn();
61
+ base_wrapper_1.default.setBaseSpanAttributes = jest
62
+ .fn()
63
+ .mockImplementation((span, attrs) => {
64
+ span.setAttribute(semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL, attrs.aiSystem);
65
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_MODEL, attrs.model);
66
+ if (attrs.cost !== undefined) {
67
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_COST, attrs.cost);
68
+ }
69
+ if (attrs.serverAddress) {
70
+ span.setAttribute(semantic_convention_1.default.SERVER_ADDRESS, attrs.serverAddress);
71
+ }
72
+ if (attrs.serverPort !== undefined) {
73
+ span.setAttribute(semantic_convention_1.default.SERVER_PORT, attrs.serverPort);
74
+ }
75
+ span.setAttribute(semantic_convention_1.default.GEN_AI_SDK_VERSION, '1.9.0');
76
+ });
77
+ });
78
+ afterEach(() => {
79
+ jest.clearAllMocks();
80
+ });
81
+ // AI21 ChatCompletionResponse shape: no `model`, OpenAI-compatible choices/usage.
82
+ const mockResponse = () => ({
83
+ id: 'ai21-test-id',
84
+ choices: [
85
+ { index: 0, finish_reason: 'stop', message: { role: 'assistant', content: 'Jamba says hi' } },
86
+ ],
87
+ usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
88
+ });
89
+ describe('Chat Completion Trace Consistency', () => {
90
+ it('should set the same core attributes as the Python SDK', async () => {
91
+ const mockArgs = [
92
+ {
93
+ messages: [{ role: 'user', content: 'What is LLM Observability?' }],
94
+ model: 'jamba-large',
95
+ max_tokens: 100,
96
+ temperature: 0.7,
97
+ stream: false,
98
+ },
99
+ ];
100
+ await wrapper_1.default._chatCompletion({
101
+ args: mockArgs,
102
+ genAIEndpoint: 'ai21.chat.completions',
103
+ response: mockResponse(),
104
+ span: mockSpan,
105
+ });
106
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL, 'ai21');
107
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_MODEL, 'jamba-large');
108
+ // AI21 responses carry no `model`, so it falls back to the request model.
109
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_RESPONSE_MODEL, 'jamba-large');
110
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_RESPONSE_ID, 'ai21-test-id');
111
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS, 10);
112
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS, 20);
113
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_TEMPERATURE, 0.7);
114
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, 100);
115
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_IS_STREAM, false);
116
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
117
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_OUTPUT_TYPE, 'text');
118
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.SERVER_ADDRESS, 'api.ai21.com');
119
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.SERVER_PORT, 443);
120
+ });
121
+ it('stamps shield360.agent.version_hash on the chat span', async () => {
122
+ const mockArgs = [
123
+ { messages: [{ role: 'user', content: 'Hash me' }], model: 'jamba-mini', stream: false },
124
+ ];
125
+ await wrapper_1.default._chatCompletion({
126
+ args: mockArgs,
127
+ genAIEndpoint: 'ai21.chat.completions',
128
+ response: mockResponse(),
129
+ span: mockSpan,
130
+ });
131
+ expect(helpers_1.default.computeAgentVersionHash).toHaveBeenCalled();
132
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.SHIELD360_AGENT_VERSION_HASH, 'ts-test-version-hash');
133
+ });
134
+ it('should NOT set total_tokens or client.token.usage on the span', async () => {
135
+ const mockArgs = [
136
+ { messages: [{ role: 'user', content: 'Test' }], model: 'jamba-mini', stream: false },
137
+ ];
138
+ await wrapper_1.default._chatCompletion({
139
+ args: mockArgs,
140
+ genAIEndpoint: 'ai21.chat.completions',
141
+ response: mockResponse(),
142
+ span: mockSpan,
143
+ });
144
+ const attributeKeys = mockSpan.setAttribute.mock.calls.map(([key]) => key);
145
+ expect(attributeKeys).not.toContain(semantic_convention_1.default.GEN_AI_USAGE_TOTAL_TOKENS);
146
+ expect(attributeKeys).not.toContain(semantic_convention_1.default.GEN_AI_CLIENT_TOKEN_USAGE);
147
+ });
148
+ it('should never emit seed / penalty attrs and omits unset optionals', async () => {
149
+ const mockArgs = [
150
+ { messages: [{ role: 'user', content: 'Test' }], model: 'jamba-mini', stream: false },
151
+ ];
152
+ await wrapper_1.default._chatCompletion({
153
+ args: mockArgs,
154
+ genAIEndpoint: 'ai21.chat.completions',
155
+ response: mockResponse(),
156
+ span: mockSpan,
157
+ });
158
+ const attributeKeys = mockSpan.setAttribute.mock.calls.map(([key]) => key);
159
+ // AI21 has no seed / frequency_penalty / presence_penalty.
160
+ expect(attributeKeys).not.toContain(semantic_convention_1.default.GEN_AI_REQUEST_SEED);
161
+ expect(attributeKeys).not.toContain(semantic_convention_1.default.GEN_AI_REQUEST_FREQUENCY_PENALTY);
162
+ expect(attributeKeys).not.toContain(semantic_convention_1.default.GEN_AI_REQUEST_PRESENCE_PENALTY);
163
+ // Optionals not supplied in this request.
164
+ expect(attributeKeys).not.toContain(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS);
165
+ expect(attributeKeys).not.toContain(semantic_convention_1.default.GEN_AI_REQUEST_STOP_SEQUENCES);
166
+ expect(attributeKeys).not.toContain(semantic_convention_1.default.GEN_AI_REQUEST_CHOICE_COUNT);
167
+ });
168
+ it('should set max_tokens, stop and choice_count only when explicitly provided', async () => {
169
+ const mockArgs = [
170
+ {
171
+ messages: [{ role: 'user', content: 'Test' }],
172
+ model: 'jamba-mini',
173
+ max_tokens: 200,
174
+ stop: ['END'],
175
+ n: 2,
176
+ stream: false,
177
+ },
178
+ ];
179
+ await wrapper_1.default._chatCompletion({
180
+ args: mockArgs,
181
+ genAIEndpoint: 'ai21.chat.completions',
182
+ response: mockResponse(),
183
+ span: mockSpan,
184
+ });
185
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, 200);
186
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_STOP_SEQUENCES, ['END']);
187
+ expect(mockSpan.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_CHOICE_COUNT, 2);
188
+ });
189
+ it('should emit an inference event via the LoggerProvider', async () => {
190
+ const mockArgs = [
191
+ { messages: [{ role: 'user', content: 'Test' }], model: 'jamba-mini', stream: false },
192
+ ];
193
+ await wrapper_1.default._chatCompletion({
194
+ args: mockArgs,
195
+ genAIEndpoint: 'ai21.chat.completions',
196
+ response: mockResponse(),
197
+ span: mockSpan,
198
+ });
199
+ expect(helpers_1.default.emitInferenceEvent).toHaveBeenCalled();
200
+ });
201
+ });
202
+ });
203
+ //# sourceMappingURL=ai21-trace-comparison.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai21-trace-comparison.test.js","sourceRoot":"","sources":["../../../src/instrumentation/__tests__/ai21-trace-comparison.test.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;AAEH,8DAA0C;AAC1C,0DAA2C;AAC3C,4DAA4C;AAC5C,mEAA0C;AAC1C,oFAA2D;AAE3D,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AAC1B,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAC3B,IAAI,CAA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AC,CAAC;QACxG,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;YACrE,MAAM,QAAQ,GAAG;gBACf,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE;aACtF,CAAC;YAEF,MAAM,iBAAW,CAAC,eAAe,CAAC;gBAChC,IAAI,EAAE,QAAQ;gBACd,aAAa,EAAE,uBAAuB;gBACtC,QAAQ,EAAE,YAAY,EAAE;gBACxB,IAAI,EAAE,QAAQ;aACf,CAAC,CAAC;YAEH,MAAM,CAAE,iBAAuB,CAAC,kBAAkB,CAAC,CAAC,gBAAgB,EAAE,CAAC;QACzE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,284 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const api_1 = require("@opentelemetry/api");
7
+ const wrapper_1 = __importDefault(require("../anthropic/wrapper"));
8
+ const config_1 = __importDefault(require("../../config"));
9
+ const helpers_1 = __importDefault(require("../../helpers"));
10
+ const base_wrapper_1 = __importDefault(require("../base-wrapper"));
11
+ const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
12
+ jest.mock('../../../src/config');
13
+ jest.mock('../../../src/helpers');
14
+ jest.mock('../../../src/instrumentation/base-wrapper');
15
+ const mockTracer = api_1.trace.getTracer('test-tracer');
16
+ describe('AnthropicWrapper', () => {
17
+ let span;
18
+ beforeEach(() => {
19
+ span = mockTracer.startSpan('test-span');
20
+ span.setAttribute = jest.fn();
21
+ jest.clearAllMocks();
22
+ });
23
+ afterEach(() => {
24
+ span.end();
25
+ });
26
+ describe('_messageCreate', () => {
27
+ it('should call recordMetrics after span ends', async () => {
28
+ const mockArgs = [{ model: 'claude-3-5-sonnet-latest', messages: [{ role: 'user', content: 'test' }] }];
29
+ const mockResponse = {
30
+ id: 'msg_123',
31
+ model: 'claude-3-5-sonnet-latest',
32
+ content: [{ type: 'text', text: 'Hello' }],
33
+ stop_reason: 'end_turn',
34
+ usage: { input_tokens: 10, output_tokens: 20 },
35
+ };
36
+ jest.spyOn(base_wrapper_1.default, 'recordMetrics').mockImplementation(() => { });
37
+ jest.spyOn(wrapper_1.default, '_messageCreateCommonSetter').mockImplementationOnce(async ({ genAIEndpoint, span }) => {
38
+ span.setAttribute(semantic_convention_1.default.GEN_AI_RESPONSE_ID, 'msg_123');
39
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, 100);
40
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_TEMPERATURE, 0.7);
41
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS, 10);
42
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS, 20);
43
+ span.setAttribute(semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
44
+ return {
45
+ genAIEndpoint,
46
+ model: 'claude-3-5-sonnet-latest',
47
+ user: undefined,
48
+ cost: 0.5,
49
+ aiSystem: 'anthropic',
50
+ };
51
+ });
52
+ await wrapper_1.default._messageCreate({
53
+ args: mockArgs,
54
+ genAIEndpoint: 'anthropic.resources.messages',
55
+ response: mockResponse,
56
+ span,
57
+ });
58
+ expect(base_wrapper_1.default.recordMetrics).toHaveBeenCalledWith(span, {
59
+ model: 'claude-3-5-sonnet-latest',
60
+ user: undefined,
61
+ cost: 0.5,
62
+ aiSystem: 'anthropic',
63
+ genAIEndpoint: 'anthropic.resources.messages',
64
+ });
65
+ });
66
+ it('should re-throw errors from commonSetter', async () => {
67
+ const mockArgs = [{ model: 'claude-3-5-sonnet-latest', messages: [] }];
68
+ const mockResponse = {};
69
+ jest.spyOn(base_wrapper_1.default, 'recordMetrics').mockImplementation(() => { });
70
+ jest.spyOn(wrapper_1.default, '_messageCreateCommonSetter').mockRejectedValueOnce(new Error('test error'));
71
+ await expect(wrapper_1.default._messageCreate({
72
+ args: mockArgs,
73
+ genAIEndpoint: 'anthropic.resources.messages',
74
+ response: mockResponse,
75
+ span,
76
+ })).rejects.toThrow('test error');
77
+ });
78
+ });
79
+ describe('_messageCreateCommonSetter', () => {
80
+ it('should set span attributes and return metric parameters', async () => {
81
+ const mockArgs = [{
82
+ model: 'claude-3-5-sonnet-latest',
83
+ messages: [{ role: 'user', content: 'test message' }],
84
+ max_tokens: 100,
85
+ temperature: 0.7,
86
+ }];
87
+ const mockResult = {
88
+ id: 'msg_123',
89
+ usage: { input_tokens: 10, output_tokens: 20 },
90
+ model: 'claude-3-5-sonnet-20241022',
91
+ stop_reason: 'end_turn',
92
+ content: [{ type: 'text', text: 'Hello' }],
93
+ };
94
+ config_1.default.pricingInfo = {};
95
+ config_1.default.disableEvents = true;
96
+ jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0.5);
97
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
98
+ const metricParams = await wrapper_1.default._messageCreateCommonSetter({
99
+ args: mockArgs,
100
+ genAIEndpoint: 'anthropic.resources.messages',
101
+ result: mockResult,
102
+ span,
103
+ });
104
+ expect(setAttributeSpy).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_RESPONSE_ID, 'msg_123');
105
+ expect(setAttributeSpy).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, 100);
106
+ expect(setAttributeSpy).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_TEMPERATURE, 0.7);
107
+ expect(setAttributeSpy).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS, 10);
108
+ expect(setAttributeSpy).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS, 20);
109
+ expect(setAttributeSpy).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
110
+ expect(setAttributeSpy).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_RESPONSE_MODEL, 'claude-3-5-sonnet-20241022');
111
+ expect(setAttributeSpy).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_OUTPUT_TYPE, 'text');
112
+ expect(setAttributeSpy).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_IS_STREAM, false);
113
+ expect(setAttributeSpy).not.toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_USAGE_TOTAL_TOKENS, expect.anything());
114
+ expect(metricParams).toEqual({
115
+ genAIEndpoint: 'anthropic.resources.messages',
116
+ model: 'claude-3-5-sonnet-latest',
117
+ user: undefined,
118
+ cost: 0.5,
119
+ aiSystem: 'anthropic',
120
+ });
121
+ });
122
+ it('should map Anthropic finish reasons to OTel standard', async () => {
123
+ const makeResult = (stop_reason) => ({
124
+ id: 'msg_1',
125
+ usage: { input_tokens: 5, output_tokens: 5 },
126
+ model: 'claude-3-5-sonnet-latest',
127
+ stop_reason,
128
+ content: [{ type: 'text', text: 'hi' }],
129
+ });
130
+ config_1.default.pricingInfo = {};
131
+ config_1.default.disableEvents = true;
132
+ jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0);
133
+ const testCases = [
134
+ { anthropic: 'end_turn', otel: 'stop' },
135
+ { anthropic: 'max_tokens', otel: 'length' },
136
+ { anthropic: 'stop_sequence', otel: 'stop' },
137
+ { anthropic: 'tool_use', otel: 'tool_call' },
138
+ ];
139
+ for (const { anthropic, otel } of testCases) {
140
+ jest.clearAllMocks();
141
+ span.setAttribute = jest.fn();
142
+ await wrapper_1.default._messageCreateCommonSetter({
143
+ args: [{ model: 'claude-3-5-sonnet-latest', messages: [] }],
144
+ genAIEndpoint: 'anthropic.resources.messages',
145
+ result: makeResult(anthropic),
146
+ span,
147
+ });
148
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON, [otel]);
149
+ }
150
+ });
151
+ it('should not set max_tokens when not provided', async () => {
152
+ const mockArgs = [{ model: 'claude-3-5-sonnet-latest', messages: [], temperature: 1 }];
153
+ const mockResult = {
154
+ id: 'msg_1',
155
+ usage: { input_tokens: 5, output_tokens: 5 },
156
+ model: 'claude-3-5-sonnet-latest',
157
+ stop_reason: 'end_turn',
158
+ content: [{ type: 'text', text: 'hi' }],
159
+ };
160
+ config_1.default.pricingInfo = {};
161
+ config_1.default.disableEvents = true;
162
+ jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0);
163
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
164
+ await wrapper_1.default._messageCreateCommonSetter({
165
+ args: mockArgs,
166
+ genAIEndpoint: 'anthropic.resources.messages',
167
+ result: mockResult,
168
+ span,
169
+ });
170
+ expect(setAttributeSpy).not.toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, expect.anything());
171
+ });
172
+ it('should not set seed when not provided', async () => {
173
+ const mockArgs = [{ model: 'claude-3-5-sonnet-latest', messages: [] }];
174
+ const mockResult = {
175
+ id: 'msg_1',
176
+ usage: { input_tokens: 5, output_tokens: 5 },
177
+ model: 'claude-3-5-sonnet-latest',
178
+ stop_reason: 'end_turn',
179
+ content: [{ type: 'text', text: 'hi' }],
180
+ };
181
+ config_1.default.pricingInfo = {};
182
+ config_1.default.disableEvents = true;
183
+ jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0);
184
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
185
+ await wrapper_1.default._messageCreateCommonSetter({
186
+ args: mockArgs,
187
+ genAIEndpoint: 'anthropic.resources.messages',
188
+ result: mockResult,
189
+ span,
190
+ });
191
+ expect(setAttributeSpy).not.toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_SEED, expect.anything());
192
+ });
193
+ it('should emit inference event when events are enabled', async () => {
194
+ const mockArgs = [{
195
+ model: 'claude-3-5-sonnet-latest',
196
+ messages: [{ role: 'user', content: 'hello' }],
197
+ }];
198
+ const mockResult = {
199
+ id: 'msg_123',
200
+ usage: { input_tokens: 10, output_tokens: 20 },
201
+ model: 'claude-3-5-sonnet-latest',
202
+ stop_reason: 'end_turn',
203
+ content: [{ type: 'text', text: 'Hi there' }],
204
+ };
205
+ config_1.default.pricingInfo = {};
206
+ config_1.default.disableEvents = false;
207
+ jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0.5);
208
+ const emitSpy = jest.spyOn(helpers_1.default, 'emitInferenceEvent').mockImplementation(() => { });
209
+ await wrapper_1.default._messageCreateCommonSetter({
210
+ args: mockArgs,
211
+ genAIEndpoint: 'anthropic.resources.messages',
212
+ result: mockResult,
213
+ span,
214
+ });
215
+ expect(emitSpy).toHaveBeenCalledWith(span, expect.objectContaining({
216
+ [semantic_convention_1.default.GEN_AI_OPERATION]: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT,
217
+ [semantic_convention_1.default.GEN_AI_REQUEST_MODEL]: 'claude-3-5-sonnet-latest',
218
+ [semantic_convention_1.default.GEN_AI_RESPONSE_MODEL]: 'claude-3-5-sonnet-latest',
219
+ [semantic_convention_1.default.SERVER_ADDRESS]: 'api.anthropic.com',
220
+ [semantic_convention_1.default.SERVER_PORT]: 443,
221
+ [semantic_convention_1.default.GEN_AI_RESPONSE_ID]: 'msg_123',
222
+ [semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON]: ['stop'],
223
+ [semantic_convention_1.default.GEN_AI_OUTPUT_TYPE]: 'text',
224
+ [semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS]: 10,
225
+ [semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS]: 20,
226
+ }));
227
+ });
228
+ it('should set tool call attributes when tool_use blocks are present', async () => {
229
+ const mockArgs = [{ model: 'claude-3-5-sonnet-latest', messages: [] }];
230
+ const mockResult = {
231
+ id: 'msg_1',
232
+ usage: { input_tokens: 10, output_tokens: 20 },
233
+ model: 'claude-3-5-sonnet-latest',
234
+ stop_reason: 'tool_use',
235
+ content: [
236
+ { type: 'text', text: '' },
237
+ { type: 'tool_use', id: 'toolu_123', name: 'get_weather', input: { location: 'Paris' } },
238
+ ],
239
+ };
240
+ config_1.default.pricingInfo = {};
241
+ config_1.default.disableEvents = true;
242
+ jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0);
243
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
244
+ await wrapper_1.default._messageCreateCommonSetter({
245
+ args: mockArgs,
246
+ genAIEndpoint: 'anthropic.resources.messages',
247
+ result: mockResult,
248
+ span,
249
+ });
250
+ expect(setAttributeSpy).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_OUTPUT_TYPE, 'json');
251
+ expect(setAttributeSpy).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_TOOL_NAME, 'get_weather');
252
+ expect(setAttributeSpy).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_TOOL_CALL_ID, 'toolu_123');
253
+ expect(setAttributeSpy).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON, ['tool_call']);
254
+ });
255
+ it('should set cache token attributes when present', async () => {
256
+ const mockArgs = [{ model: 'claude-3-5-sonnet-latest', messages: [] }];
257
+ const mockResult = {
258
+ id: 'msg_1',
259
+ usage: {
260
+ input_tokens: 10,
261
+ output_tokens: 20,
262
+ cache_creation_input_tokens: 5,
263
+ cache_read_input_tokens: 3,
264
+ },
265
+ model: 'claude-3-5-sonnet-latest',
266
+ stop_reason: 'end_turn',
267
+ content: [{ type: 'text', text: 'cached response' }],
268
+ };
269
+ config_1.default.pricingInfo = {};
270
+ config_1.default.disableEvents = true;
271
+ jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0);
272
+ const setAttributeSpy = jest.spyOn(span, 'setAttribute');
273
+ await wrapper_1.default._messageCreateCommonSetter({
274
+ args: mockArgs,
275
+ genAIEndpoint: 'anthropic.resources.messages',
276
+ result: mockResult,
277
+ span,
278
+ });
279
+ expect(setAttributeSpy).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS, 5);
280
+ expect(setAttributeSpy).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, 3);
281
+ });
282
+ });
283
+ });
284
+ //# sourceMappingURL=anthropic-wrapper.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic-wrapper.test.js","sourceRoot":"","sources":["../../../src/instrumentation/__tests__/anthropic-wrapper.test.ts"],"names":[],"mappings":";;;;;AAAA,4CAAiD;AACjD,mEAAoD;AACpD,0DAA2C;AAC3C,4DAA4C;AAC5C,mEAA0C;AAC1C,oFAA2D;AAE3D,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AACjC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;AAClC,IAAI,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;AAEvD,MAAM,UAAU,GAAG,WAAK,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;AAElD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,IAAI,IAAU,CAAC;IAEf,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,GAAG,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAC9B,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,GAAG,EAAE,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,gBAAgB,EAAE,GAAG,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