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,289 @@
1
+ "use strict";
2
+ /**
3
+ * Cross-Language Trace Comparison Tests for Together AI Integration
4
+ */
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const api_1 = require("@opentelemetry/api");
10
+ const wrapper_1 = __importDefault(require("../together/wrapper"));
11
+ const config_1 = __importDefault(require("../../config"));
12
+ const helpers_1 = __importDefault(require("../../helpers"));
13
+ const base_wrapper_1 = __importDefault(require("../base-wrapper"));
14
+ const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
15
+ jest.mock('../../../src/config');
16
+ jest.mock('../../../src/helpers');
17
+ jest.mock('../../../src/instrumentation/base-wrapper');
18
+ const mockTracer = api_1.trace.getTracer('test-tracer');
19
+ describe('Together AI Cross-Language Trace Comparison', () => {
20
+ let span;
21
+ beforeEach(() => {
22
+ span = mockTracer.startSpan('test-span');
23
+ span.setAttribute = jest.fn();
24
+ span.addEvent = jest.fn();
25
+ jest.clearAllMocks();
26
+ config_1.default.environment = 'shield360-testing';
27
+ config_1.default.applicationName = 'shield360-test';
28
+ config_1.default.captureMessageContent = true;
29
+ config_1.default.pricingInfo = {};
30
+ config_1.default.disableEvents = false;
31
+ });
32
+ afterEach(() => {
33
+ span.end();
34
+ });
35
+ describe('Chat Completion Trace Consistency', () => {
36
+ it('should set same attributes as Python SDK', async () => {
37
+ const mockArgs = [
38
+ {
39
+ messages: [{ role: 'user', content: 'What is Together AI?' }],
40
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
41
+ max_tokens: 50,
42
+ temperature: 0.7,
43
+ top_p: 0.9,
44
+ stream: false,
45
+ },
46
+ ];
47
+ const mockResponse = {
48
+ id: 'together-test-id',
49
+ created: Date.now(),
50
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
51
+ choices: [
52
+ {
53
+ index: 0,
54
+ finish_reason: 'stop',
55
+ message: { role: 'assistant', content: 'Together AI is...' },
56
+ },
57
+ ],
58
+ usage: {
59
+ prompt_tokens: 9,
60
+ completion_tokens: 12,
61
+ total_tokens: 21,
62
+ },
63
+ };
64
+ jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0.001);
65
+ await wrapper_1.default._chatCompletion({
66
+ args: mockArgs,
67
+ genAIEndpoint: 'together.chat.completions',
68
+ response: mockResponse,
69
+ span,
70
+ });
71
+ // setBaseSpanAttributes is mocked; verify it was called with Together-specific params
72
+ expect(base_wrapper_1.default.setBaseSpanAttributes).toHaveBeenCalledWith(span, expect.objectContaining({
73
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
74
+ aiSystem: 'together',
75
+ serverAddress: 'api.together.xyz',
76
+ serverPort: 443,
77
+ }));
78
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_RESPONSE_MODEL, 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo');
79
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS, 9);
80
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS, 12);
81
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_RESPONSE_ID, 'together-test-id');
82
+ expect(span.setAttribute).not.toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_USAGE_TOTAL_TOKENS, expect.anything());
83
+ expect(span.setAttribute).not.toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_CLIENT_TOKEN_USAGE, expect.anything());
84
+ });
85
+ it('should set request parameters correctly with no sentinel values', async () => {
86
+ const mockArgs = [
87
+ {
88
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
89
+ messages: [{ role: 'user', content: 'test message' }],
90
+ max_tokens: 100,
91
+ temperature: 0.7,
92
+ top_p: 0.9,
93
+ presence_penalty: 0.5,
94
+ frequency_penalty: 0.3,
95
+ seed: 42,
96
+ stream: false,
97
+ stop: ['STOP'],
98
+ n: 2,
99
+ },
100
+ ];
101
+ const mockResult = {
102
+ id: 'test-123',
103
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
104
+ usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
105
+ choices: [
106
+ {
107
+ message: { content: 'response text', role: 'assistant' },
108
+ finish_reason: 'stop',
109
+ },
110
+ ],
111
+ };
112
+ jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0.5);
113
+ const metricParams = await wrapper_1.default._chatCompletionCommonSetter({
114
+ args: mockArgs,
115
+ genAIEndpoint: 'together.chat.completions',
116
+ result: mockResult,
117
+ span,
118
+ });
119
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_TOP_P, 0.9);
120
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, 100);
121
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_TEMPERATURE, 0.7);
122
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_PRESENCE_PENALTY, 0.5);
123
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_FREQUENCY_PENALTY, 0.3);
124
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_SEED, 42);
125
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_IS_STREAM, false);
126
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_STOP_SEQUENCES, ['STOP']);
127
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_CHOICE_COUNT, 2);
128
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
129
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_OUTPUT_TYPE, 'text');
130
+ expect(metricParams).toEqual({
131
+ genAIEndpoint: 'together.chat.completions',
132
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
133
+ user: undefined,
134
+ cost: 0.5,
135
+ aiSystem: 'together',
136
+ });
137
+ });
138
+ it('should not set sentinel values for optional attributes', async () => {
139
+ const mockArgs = [
140
+ {
141
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
142
+ messages: [{ role: 'user', content: 'test' }],
143
+ stream: false,
144
+ },
145
+ ];
146
+ const mockResult = {
147
+ id: 'test-123',
148
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
149
+ usage: { prompt_tokens: 5, completion_tokens: 10, total_tokens: 15 },
150
+ choices: [
151
+ {
152
+ message: { content: 'response', role: 'assistant' },
153
+ finish_reason: 'stop',
154
+ },
155
+ ],
156
+ };
157
+ jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0);
158
+ await wrapper_1.default._chatCompletionCommonSetter({
159
+ args: mockArgs,
160
+ genAIEndpoint: 'together.chat.completions',
161
+ result: mockResult,
162
+ span,
163
+ });
164
+ expect(span.setAttribute).not.toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, -1);
165
+ expect(span.setAttribute).not.toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, 0);
166
+ expect(span.setAttribute).not.toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_SEED, 0);
167
+ expect(span.setAttribute).not.toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_SEED, '');
168
+ expect(span.setAttribute).not.toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_PRESENCE_PENALTY, 0);
169
+ expect(span.setAttribute).not.toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_FREQUENCY_PENALTY, 0);
170
+ expect(span.setAttribute).not.toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_REQUEST_CHOICE_COUNT, 1);
171
+ });
172
+ it('should handle tool calls properly', async () => {
173
+ const mockArgs = [
174
+ {
175
+ messages: [{ role: 'user', content: 'test message' }],
176
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
177
+ tools: [{ type: 'function', function: { name: 'get_weather' } }],
178
+ stream: false,
179
+ },
180
+ ];
181
+ const mockResult = {
182
+ id: '123',
183
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
184
+ usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
185
+ choices: [
186
+ {
187
+ message: {
188
+ content: null,
189
+ role: 'assistant',
190
+ tool_calls: [
191
+ {
192
+ id: 'call_123',
193
+ type: 'function',
194
+ function: { name: 'get_weather', arguments: '{"location":"SF"}' },
195
+ },
196
+ ],
197
+ },
198
+ finish_reason: 'tool_calls',
199
+ },
200
+ ],
201
+ };
202
+ jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0.5);
203
+ await wrapper_1.default._chatCompletionCommonSetter({
204
+ args: mockArgs,
205
+ genAIEndpoint: 'together.chat.completions',
206
+ result: mockResult,
207
+ span,
208
+ });
209
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_TOOL_NAME, 'get_weather');
210
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_TOOL_CALL_ID, 'call_123');
211
+ expect(span.setAttribute).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_TOOL_ARGS, '{"location":"SF"}');
212
+ });
213
+ it('should emit inference event via LoggerProvider', async () => {
214
+ const mockArgs = [
215
+ {
216
+ messages: [{ role: 'user', content: 'Hello' }],
217
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
218
+ stream: false,
219
+ },
220
+ ];
221
+ const mockResult = {
222
+ id: 'test-event-id',
223
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
224
+ usage: { prompt_tokens: 5, completion_tokens: 10, total_tokens: 15 },
225
+ choices: [
226
+ {
227
+ message: { content: 'Hi there', role: 'assistant' },
228
+ finish_reason: 'stop',
229
+ },
230
+ ],
231
+ };
232
+ jest.spyOn(helpers_1.default, 'getChatModelCost').mockReturnValue(0);
233
+ const emitSpy = jest.spyOn(helpers_1.default, 'emitInferenceEvent').mockImplementation();
234
+ await wrapper_1.default._chatCompletionCommonSetter({
235
+ args: mockArgs,
236
+ genAIEndpoint: 'together.chat.completions',
237
+ result: mockResult,
238
+ span,
239
+ });
240
+ expect(emitSpy).toHaveBeenCalledWith(span, expect.objectContaining({
241
+ [semantic_convention_1.default.GEN_AI_OPERATION]: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT,
242
+ [semantic_convention_1.default.GEN_AI_REQUEST_MODEL]: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
243
+ [semantic_convention_1.default.GEN_AI_RESPONSE_MODEL]: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
244
+ [semantic_convention_1.default.SERVER_ADDRESS]: 'api.together.xyz',
245
+ [semantic_convention_1.default.SERVER_PORT]: 443,
246
+ [semantic_convention_1.default.GEN_AI_RESPONSE_ID]: 'test-event-id',
247
+ [semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS]: 5,
248
+ [semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS]: 10,
249
+ }));
250
+ });
251
+ it('should call recordMetrics after span ends', async () => {
252
+ const mockArgs = [{ messages: [{ role: 'user', content: 'test message' }], model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo' }];
253
+ const mockResponse = {
254
+ id: '123',
255
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
256
+ usage: { prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 },
257
+ choices: [
258
+ {
259
+ message: { content: 'response text', role: 'assistant' },
260
+ finish_reason: 'stop',
261
+ },
262
+ ],
263
+ };
264
+ jest
265
+ .spyOn(wrapper_1.default, '_chatCompletionCommonSetter')
266
+ .mockImplementationOnce(async () => ({
267
+ genAIEndpoint: 'together.chat.completions',
268
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
269
+ user: undefined,
270
+ cost: 0.5,
271
+ aiSystem: 'together',
272
+ }));
273
+ await wrapper_1.default._chatCompletion({
274
+ args: mockArgs,
275
+ genAIEndpoint: 'together.chat.completions',
276
+ response: mockResponse,
277
+ span,
278
+ });
279
+ expect(base_wrapper_1.default.recordMetrics).toHaveBeenCalledWith(span, {
280
+ genAIEndpoint: 'together.chat.completions',
281
+ model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
282
+ user: undefined,
283
+ cost: 0.5,
284
+ aiSystem: 'together',
285
+ });
286
+ });
287
+ });
288
+ });
289
+ //# sourceMappingURL=together-trace-comparison.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"together-trace-comparison.test.js","sourceRoot":"","sources":["../../../src/instrumentation/__tests__/together-trace-comparison.test.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;AAEH,4CAAiD;AACjD,kEAAkD;AAClD,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,6CAA6C,EAAE,GAAG,EAAE;IAC3D,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,QAAQ,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAC1B,IAAI,CAAC,aAAa,EAAE,CAAC;QAEpB,gBAAuB,CAAC,WAAW,GAAG,mBAAmB,CAAC;QAC1D,gBAAuB,CAAC,eAAe,GAAG,gBAAgB,CAAC;QAC3D,gBAAuB,CAAC,qBAAqB,GAAG,IAAI,CAAC;QACrD,gBAAuB,CAAC,WAAW,GAAG,EAAE,CAAC;QACzC,gBAAuB,CAAC,aAAa,GAAG,KAAK,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;Q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EAAE,6CAA6C;gBACpD,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,GAAG;gBACT,QAAQ,EAAE,UAAU;aACrB,CAAC,CAAC,CAAC;YAEN,MAAM,iBAAe,CAAC,eAAe,CAAC;gBACpC,IAAI,EAAE,QAAQ;gBACd,aAAa,EAAE,2BAA2B;gBAC1C,QAAQ,EAAE,YAAY;gBACtB,IAAI;aACL,CAAC,CAAC;YAEH,MAAM,CAAC,sBAAW,CAAC,aAAa,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE;gBAC3D,aAAa,EAAE,2BAA2B;gBAC1C,KAAK,EAAE,6CAA6C;gBACpD,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,GAAG;gBACT,QAAQ,EAAE,UAAU;aACrB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Cross-Language Trace Comparison Utilities
3
+ *
4
+ * This module provides utilities to compare traces generated by Python and TypeScript
5
+ * Shield360 SDKs to ensure consistency across implementations.
6
+ * Uses SemanticConvention keys so comparisons stay in sync with the SDK.
7
+ */
8
+ import { Span } from '@opentelemetry/api';
9
+ import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
10
+ export interface NormalizedTrace {
11
+ spanName: string;
12
+ spanKind: string;
13
+ attributes: Record<string, any>;
14
+ events: Array<{
15
+ name: string;
16
+ attributes?: Record<string, any>;
17
+ }>;
18
+ status: {
19
+ code: string;
20
+ message?: string;
21
+ };
22
+ duration?: number;
23
+ }
24
+ export interface TraceComparisonResult {
25
+ match: boolean;
26
+ differences: string[];
27
+ pythonTrace?: NormalizedTrace;
28
+ typescriptTrace?: NormalizedTrace;
29
+ }
30
+ /**
31
+ * Normalize a TypeScript span to a comparable format
32
+ */
33
+ export declare function normalizeTypeScriptSpan(span: ReadableSpan | Span): NormalizedTrace;
34
+ /**
35
+ * Compare two normalized traces
36
+ */
37
+ export declare function compareTraces(pythonTrace: NormalizedTrace, typescriptTrace: NormalizedTrace): TraceComparisonResult;
38
+ /**
39
+ * Extract key metrics from a trace for comparison
40
+ */
41
+ export declare function extractKeyMetrics(trace: NormalizedTrace): {
42
+ tokens: {
43
+ input: number;
44
+ output: number;
45
+ total: number;
46
+ };
47
+ cost: number;
48
+ model: string;
49
+ operation: string;
50
+ system: string;
51
+ };
52
+ /**
53
+ * Compare key metrics between Python and TypeScript traces
54
+ */
55
+ export declare function compareMetrics(pythonTrace: NormalizedTrace, typescriptTrace: NormalizedTrace): {
56
+ match: boolean;
57
+ differences: string[];
58
+ };
59
+ /**
60
+ * Create a test helper that validates trace consistency
61
+ */
62
+ export declare function createTraceValidator(providerName: string, expectedAttributes?: string[]): {
63
+ validateTrace: (trace: NormalizedTrace) => {
64
+ valid: boolean;
65
+ errors: string[];
66
+ };
67
+ };
@@ -0,0 +1,255 @@
1
+ "use strict";
2
+ /**
3
+ * Cross-Language Trace Comparison Utilities
4
+ *
5
+ * This module provides utilities to compare traces generated by Python and TypeScript
6
+ * Shield360 SDKs to ensure consistency across implementations.
7
+ * Uses SemanticConvention keys so comparisons stay in sync with the SDK.
8
+ */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.normalizeTypeScriptSpan = normalizeTypeScriptSpan;
14
+ exports.compareTraces = compareTraces;
15
+ exports.extractKeyMetrics = extractKeyMetrics;
16
+ exports.compareMetrics = compareMetrics;
17
+ exports.createTraceValidator = createTraceValidator;
18
+ const api_1 = require("@opentelemetry/api");
19
+ const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
20
+ /**
21
+ * Normalize a TypeScript span to a comparable format
22
+ */
23
+ function normalizeTypeScriptSpan(span) {
24
+ const spanData = span;
25
+ return {
26
+ spanName: spanData.name || '',
27
+ spanKind: spanData.kind?.toString() || 'INTERNAL',
28
+ attributes: normalizeAttributes(spanData.attributes || {}),
29
+ events: (spanData.events || []).map((event) => ({
30
+ name: event.name || '',
31
+ attributes: normalizeAttributes(event.attributes || {}),
32
+ })),
33
+ status: {
34
+ code: spanData.status?.code === api_1.SpanStatusCode.OK ? 'OK' :
35
+ spanData.status?.code === api_1.SpanStatusCode.ERROR ? 'ERROR' : 'UNSET',
36
+ message: spanData.status?.message,
37
+ },
38
+ duration: spanData.duration?.[0] ? spanData.duration[0] * 1e9 + spanData.duration[1] : undefined,
39
+ };
40
+ }
41
+ /**
42
+ * Normalize attributes for comparison (handles array/object differences)
43
+ */
44
+ function normalizeAttributes(attrs) {
45
+ const normalized = {};
46
+ for (const [key, value] of Object.entries(attrs)) {
47
+ // Normalize arrays - sort for comparison
48
+ if (Array.isArray(value)) {
49
+ normalized[key] = [...value].sort();
50
+ }
51
+ // Normalize numbers (handle float precision)
52
+ else if (typeof value === 'number') {
53
+ normalized[key] = Math.round(value * 1000) / 1000; // Round to 3 decimal places
54
+ }
55
+ // Normalize strings (trim whitespace)
56
+ else if (typeof value === 'string') {
57
+ normalized[key] = value.trim();
58
+ }
59
+ // Keep other types as-is
60
+ else {
61
+ normalized[key] = value;
62
+ }
63
+ }
64
+ return normalized;
65
+ }
66
+ /**
67
+ * Compare two normalized traces
68
+ */
69
+ function compareTraces(pythonTrace, typescriptTrace) {
70
+ const differences = [];
71
+ // Compare span names
72
+ if (pythonTrace.spanName !== typescriptTrace.spanName) {
73
+ differences.push(`Span name mismatch: Python="${pythonTrace.spanName}", TypeScript="${typescriptTrace.spanName}"`);
74
+ }
75
+ // Compare span kind
76
+ if (pythonTrace.spanKind !== typescriptTrace.spanKind) {
77
+ differences.push(`Span kind mismatch: Python="${pythonTrace.spanKind}", TypeScript="${typescriptTrace.spanKind}"`);
78
+ }
79
+ // Compare status
80
+ if (pythonTrace.status.code !== typescriptTrace.status.code) {
81
+ differences.push(`Status code mismatch: Python="${pythonTrace.status.code}", TypeScript="${typescriptTrace.status.code}"`);
82
+ }
83
+ // Compare attributes
84
+ const attrDiff = compareAttributes(pythonTrace.attributes, typescriptTrace.attributes);
85
+ differences.push(...attrDiff);
86
+ // Compare events (optional - events may differ slightly)
87
+ const eventDiff = compareEvents(pythonTrace.events, typescriptTrace.events);
88
+ if (eventDiff.length > 0) {
89
+ differences.push(`Event differences: ${eventDiff.join(', ')}`);
90
+ }
91
+ return {
92
+ match: differences.length === 0,
93
+ differences,
94
+ pythonTrace,
95
+ typescriptTrace,
96
+ };
97
+ }
98
+ /**
99
+ * Compare attributes between two traces
100
+ */
101
+ function compareAttributes(pythonAttrs, typescriptAttrs) {
102
+ const differences = [];
103
+ const allKeys = new Set([...Object.keys(pythonAttrs), ...Object.keys(typescriptAttrs)]);
104
+ // Critical attributes that must match (use SemanticConvention so keys stay in sync)
105
+ const criticalAttributes = [
106
+ semantic_convention_1.default.GEN_AI_PROVIDER_NAME,
107
+ semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL,
108
+ semantic_convention_1.default.GEN_AI_OPERATION,
109
+ semantic_convention_1.default.GEN_AI_REQUEST_MODEL,
110
+ semantic_convention_1.default.GEN_AI_RESPONSE_MODEL,
111
+ semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS,
112
+ semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS,
113
+ semantic_convention_1.default.GEN_AI_USAGE_TOTAL_TOKENS,
114
+ semantic_convention_1.default.GEN_AI_USAGE_COST,
115
+ semantic_convention_1.default.GEN_AI_ENDPOINT,
116
+ semantic_convention_1.default.GEN_AI_ENVIRONMENT,
117
+ semantic_convention_1.default.GEN_AI_APPLICATION_NAME,
118
+ semantic_convention_1.default.SERVER_ADDRESS,
119
+ semantic_convention_1.default.SERVER_PORT,
120
+ semantic_convention_1.default.GEN_AI_SDK_VERSION,
121
+ ];
122
+ for (const key of allKeys) {
123
+ const pythonValue = pythonAttrs[key];
124
+ const typescriptValue = typescriptAttrs[key];
125
+ const isCritical = criticalAttributes.includes(key);
126
+ if (pythonValue === undefined && typescriptValue !== undefined) {
127
+ if (isCritical) {
128
+ differences.push(`Missing in Python: ${key} (TypeScript has: ${typescriptValue})`);
129
+ }
130
+ }
131
+ else if (typescriptValue === undefined && pythonValue !== undefined) {
132
+ if (isCritical) {
133
+ differences.push(`Missing in TypeScript: ${key} (Python has: ${pythonValue})`);
134
+ }
135
+ }
136
+ else if (pythonValue !== typescriptValue) {
137
+ // For critical attributes, always report differences
138
+ if (isCritical) {
139
+ differences.push(`Attribute "${key}" mismatch: Python="${pythonValue}", TypeScript="${typescriptValue}"`);
140
+ }
141
+ // For non-critical, only report if significantly different
142
+ else if (typeof pythonValue === 'number' && typeof typescriptValue === 'number') {
143
+ const diff = Math.abs(pythonValue - typescriptValue);
144
+ if (diff > 0.01) { // Allow small floating point differences
145
+ differences.push(`Attribute "${key}" significant difference: Python=${pythonValue}, TypeScript=${typescriptValue}`);
146
+ }
147
+ }
148
+ }
149
+ }
150
+ return differences;
151
+ }
152
+ /**
153
+ * Compare events between two traces
154
+ */
155
+ function compareEvents(pythonEvents, typescriptEvents) {
156
+ const differences = [];
157
+ if (pythonEvents.length !== typescriptEvents.length) {
158
+ differences.push(`Event count mismatch: Python=${pythonEvents.length}, TypeScript=${typescriptEvents.length}`);
159
+ }
160
+ // Compare event names (order may differ)
161
+ const pythonEventNames = pythonEvents.map(e => e.name).sort();
162
+ const typescriptEventNames = typescriptEvents.map(e => e.name).sort();
163
+ if (JSON.stringify(pythonEventNames) !== JSON.stringify(typescriptEventNames)) {
164
+ differences.push(`Event names differ: Python=[${pythonEventNames.join(', ')}], TypeScript=[${typescriptEventNames.join(', ')}]`);
165
+ }
166
+ return differences;
167
+ }
168
+ /**
169
+ * Extract key metrics from a trace for comparison
170
+ */
171
+ function extractKeyMetrics(trace) {
172
+ const attrs = trace.attributes;
173
+ return {
174
+ tokens: {
175
+ input: attrs[semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS] || 0,
176
+ output: attrs[semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS] || 0,
177
+ total: attrs[semantic_convention_1.default.GEN_AI_USAGE_TOTAL_TOKENS] || 0,
178
+ },
179
+ cost: attrs[semantic_convention_1.default.GEN_AI_USAGE_COST] || 0,
180
+ model: attrs[semantic_convention_1.default.GEN_AI_REQUEST_MODEL] || attrs[semantic_convention_1.default.GEN_AI_RESPONSE_MODEL] || '',
181
+ operation: attrs[semantic_convention_1.default.GEN_AI_OPERATION] || '',
182
+ system: attrs[semantic_convention_1.default.GEN_AI_PROVIDER_NAME] || attrs[semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL] || '',
183
+ };
184
+ }
185
+ /**
186
+ * Compare key metrics between Python and TypeScript traces
187
+ */
188
+ function compareMetrics(pythonTrace, typescriptTrace) {
189
+ const pythonMetrics = extractKeyMetrics(pythonTrace);
190
+ const typescriptMetrics = extractKeyMetrics(typescriptTrace);
191
+ const differences = [];
192
+ // Compare tokens (allow small differences due to estimation)
193
+ const tokenTolerance = 5; // Allow 5 token difference
194
+ if (Math.abs(pythonMetrics.tokens.input - typescriptMetrics.tokens.input) > tokenTolerance) {
195
+ differences.push(`Input tokens differ significantly: Python=${pythonMetrics.tokens.input}, TypeScript=${typescriptMetrics.tokens.input}`);
196
+ }
197
+ if (Math.abs(pythonMetrics.tokens.output - typescriptMetrics.tokens.output) > tokenTolerance) {
198
+ differences.push(`Output tokens differ significantly: Python=${pythonMetrics.tokens.output}, TypeScript=${typescriptMetrics.tokens.output}`);
199
+ }
200
+ // Compare cost (allow small differences due to rounding)
201
+ const costTolerance = 0.0001;
202
+ if (Math.abs(pythonMetrics.cost - typescriptMetrics.cost) > costTolerance) {
203
+ differences.push(`Cost differs: Python=${pythonMetrics.cost}, TypeScript=${typescriptMetrics.cost}`);
204
+ }
205
+ // Compare model (must match exactly)
206
+ if (pythonMetrics.model !== typescriptMetrics.model) {
207
+ differences.push(`Model mismatch: Python="${pythonMetrics.model}", TypeScript="${typescriptMetrics.model}"`);
208
+ }
209
+ // Compare operation (must match exactly)
210
+ if (pythonMetrics.operation !== typescriptMetrics.operation) {
211
+ differences.push(`Operation mismatch: Python="${pythonMetrics.operation}", TypeScript="${typescriptMetrics.operation}"`);
212
+ }
213
+ // Compare system (must match exactly)
214
+ if (pythonMetrics.system !== typescriptMetrics.system) {
215
+ differences.push(`System mismatch: Python="${pythonMetrics.system}", TypeScript="${typescriptMetrics.system}"`);
216
+ }
217
+ return {
218
+ match: differences.length === 0,
219
+ differences,
220
+ };
221
+ }
222
+ /**
223
+ * Create a test helper that validates trace consistency
224
+ */
225
+ function createTraceValidator(providerName, expectedAttributes = []) {
226
+ return {
227
+ validateTrace: (trace) => {
228
+ const errors = [];
229
+ // Check required attributes
230
+ for (const attr of expectedAttributes) {
231
+ if (!(attr in trace.attributes)) {
232
+ errors.push(`Missing required attribute: ${attr}`);
233
+ }
234
+ }
235
+ // Check system matches provider (legacy + OTel keys from SemanticConvention)
236
+ const providerAttr = trace.attributes[semantic_convention_1.default.GEN_AI_PROVIDER_NAME] ?? trace.attributes[semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL];
237
+ if (providerAttr !== providerName) {
238
+ errors.push(`System mismatch: expected "${providerName}", got "${providerAttr}"`);
239
+ }
240
+ // Check operation is set
241
+ if (!trace.attributes[semantic_convention_1.default.GEN_AI_OPERATION]) {
242
+ errors.push('Missing operation name');
243
+ }
244
+ // Check tokens are present
245
+ if (!trace.attributes[semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS] && !trace.attributes[semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS]) {
246
+ errors.push('Missing token usage information');
247
+ }
248
+ return {
249
+ valid: errors.length === 0,
250
+ errors,
251
+ };
252
+ },
253
+ };
254
+ }
255
+ //# sourceMappingURL=trace-comparison-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace-comparison-utils.js","sourceRoot":"","sources":["../../../src/instrumentation/__tests__/trace-comparison-utils.ts"],"names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comparison Tests for local HuggingFace inference
3
+ * (Transformers.js) instrumentation.
4
+ *
5
+ * Verifies that the TypeScript SDK produces traces consistent with the Python
6
+ * `transformers` instrumentation and the OTel GenAI semantic conventions:
7
+ * - text-generation reports the `chat` operation (Python parity)
8
+ * - other local pipelines map to the closest OTel operation
9
+ * - token usage, cache tokens, timing, and package version are stamped
10
+ */
11
+ export {};