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,472 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const api_1 = require("@opentelemetry/api");
40
+ const config_1 = __importDefault(require("../../config"));
41
+ const helpers_1 = __importStar(require("../../helpers"));
42
+ const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
43
+ const base_wrapper_1 = __importDefault(require("../base-wrapper"));
44
+ const TASK_OPERATION = {
45
+ // Generative chat-style (Python parity)
46
+ 'text-generation': { operation: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT, isEmbedding: false },
47
+ // Sequence-to-sequence / extractive text producers
48
+ 'text2text-generation': { operation: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, isEmbedding: false },
49
+ summarization: { operation: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, isEmbedding: false },
50
+ translation: { operation: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, isEmbedding: false },
51
+ 'fill-mask': { operation: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, isEmbedding: false },
52
+ 'question-answering': { operation: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, isEmbedding: false },
53
+ 'text-classification': { operation: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, isEmbedding: false },
54
+ 'token-classification': { operation: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, isEmbedding: false },
55
+ 'zero-shot-classification': { operation: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION, isEmbedding: false },
56
+ // Embedding producers
57
+ 'feature-extraction': { operation: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_EMBEDDING, isEmbedding: true },
58
+ 'sentence-similarity': { operation: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_EMBEDDING, isEmbedding: true },
59
+ };
60
+ /** Map a Pipeline subclass name to its canonical Transformers.js task string. */
61
+ const CLASS_TASK = {
62
+ TextGenerationPipeline: 'text-generation',
63
+ Text2TextGenerationPipeline: 'text2text-generation',
64
+ SummarizationPipeline: 'summarization',
65
+ TranslationPipeline: 'translation',
66
+ FillMaskPipeline: 'fill-mask',
67
+ QuestionAnsweringPipeline: 'question-answering',
68
+ TextClassificationPipeline: 'text-classification',
69
+ TokenClassificationPipeline: 'token-classification',
70
+ ZeroShotClassificationPipeline: 'zero-shot-classification',
71
+ FeatureExtractionPipeline: 'feature-extraction',
72
+ };
73
+ function resolveTask(instance, className) {
74
+ return ((typeof instance?.task === 'string' && instance.task) ||
75
+ CLASS_TASK[className] ||
76
+ 'text-generation');
77
+ }
78
+ function classifyTask(task) {
79
+ return (TASK_OPERATION[task] || {
80
+ operation: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_TEXT_COMPLETION,
81
+ isEmbedding: false,
82
+ });
83
+ }
84
+ /**
85
+ * Resolve the model identifier from a pipeline instance, mirroring Python's
86
+ * `instance.model.config.name_or_path`. HF configs expose the path under a few
87
+ * keys across versions, so we probe the common ones before falling back.
88
+ */
89
+ function resolveModel(instance) {
90
+ const config = instance?.model?.config ?? {};
91
+ return (config._name_or_path ||
92
+ config.name_or_path ||
93
+ config.model_type ||
94
+ instance?.model?.name_or_path ||
95
+ (typeof instance?.task === 'string' ? instance.task : '') ||
96
+ 'unknown');
97
+ }
98
+ /**
99
+ * Extract the generation parameters for a call, mirroring Python which reads
100
+ * `instance._forward_params` (set at pipeline construction) merged with the
101
+ * call-time options object.
102
+ */
103
+ function resolveGenerationParams(instance, options) {
104
+ const forward = instance?._forward_params ?? {};
105
+ const opts = options ?? {};
106
+ const pick = (key, altKey) => opts[key] ?? (altKey ? opts[altKey] : undefined) ?? forward[key] ?? (altKey ? forward[altKey] : undefined) ?? null;
107
+ return {
108
+ temperature: pick('temperature'),
109
+ topK: pick('top_k'),
110
+ topP: pick('top_p'),
111
+ maxTokens: pick('max_new_tokens', 'max_length'),
112
+ };
113
+ }
114
+ /**
115
+ * Convert a Transformers.js pipeline result into a flat text string per task,
116
+ * mirroring the task branches in Python's `process_chat_response`.
117
+ */
118
+ function extractCompletion(task, response) {
119
+ const first = Array.isArray(response) ? response[0] : response;
120
+ const fromEntry = (entry) => {
121
+ if (entry === null || entry === undefined)
122
+ return '';
123
+ if (typeof entry !== 'object')
124
+ return String(entry);
125
+ // text-generation may nest a chat-message list under generated_text
126
+ if (Array.isArray(entry.generated_text)) {
127
+ const last = entry.generated_text[entry.generated_text.length - 1];
128
+ return last?.content ?? String(last ?? '');
129
+ }
130
+ return (entry.generated_text ??
131
+ entry.summary_text ??
132
+ entry.translation_text ??
133
+ entry.answer ??
134
+ entry.sequence ??
135
+ entry.token_str ??
136
+ entry.label ??
137
+ entry.text ??
138
+ '');
139
+ };
140
+ switch (task) {
141
+ case 'automatic-speech-recognition':
142
+ return typeof response === 'object' && response !== null ? response.text ?? '' : '';
143
+ case 'feature-extraction':
144
+ case 'sentence-similarity':
145
+ return '';
146
+ default: {
147
+ const out = fromEntry(first);
148
+ if (out)
149
+ return out;
150
+ // Fall back to a stable serialization for unknown shapes.
151
+ try {
152
+ return typeof response === 'string' ? response : JSON.stringify(response);
153
+ }
154
+ catch {
155
+ return String(response ?? '');
156
+ }
157
+ }
158
+ }
159
+ }
160
+ function stringifyInputs(inputs) {
161
+ if (typeof inputs === 'string')
162
+ return inputs;
163
+ if (Array.isArray(inputs)) {
164
+ return inputs
165
+ .map((i) => (typeof i === 'string' ? i : i?.content ?? JSON.stringify(i)))
166
+ .join('\n');
167
+ }
168
+ if (inputs && typeof inputs === 'object') {
169
+ // question-answering style { question, context }
170
+ if (typeof inputs.question === 'string') {
171
+ return inputs.context
172
+ ? `question: ${inputs.question} context: ${inputs.context}`
173
+ : inputs.question;
174
+ }
175
+ try {
176
+ return JSON.stringify(inputs);
177
+ }
178
+ catch {
179
+ return String(inputs);
180
+ }
181
+ }
182
+ return String(inputs ?? '');
183
+ }
184
+ class TransformersWrapper extends base_wrapper_1.default {
185
+ /**
186
+ * Stamp `shield360.agent.version_hash` (auto) and `gen_ai.agent.version`
187
+ * (user override) on the span and return them so the caller can merge them
188
+ * into the inference-event extras.
189
+ */
190
+ static _stampAgentVersion(span, args) {
191
+ const out = {};
192
+ try {
193
+ const versionHash = helpers_1.default.computeAgentVersionHash({
194
+ systemInstructions: args.systemInstructionsJson ?? null,
195
+ toolDefinitions: null,
196
+ primaryModel: args.primaryModel ?? null,
197
+ runtimeConfig: {
198
+ temperature: args.temperature ?? null,
199
+ top_p: args.top_p ?? null,
200
+ max_tokens: args.max_tokens ?? null,
201
+ provider: semantic_convention_1.default.GEN_AI_SYSTEM_HUGGING_FACE,
202
+ },
203
+ providers: [semantic_convention_1.default.GEN_AI_SYSTEM_HUGGING_FACE],
204
+ });
205
+ if (versionHash) {
206
+ out[semantic_convention_1.default.SHIELD360_AGENT_VERSION_HASH] = versionHash;
207
+ span.setAttribute(semantic_convention_1.default.SHIELD360_AGENT_VERSION_HASH, versionHash);
208
+ }
209
+ }
210
+ catch {
211
+ /* Hash computation must never fail the wrapped call. */
212
+ }
213
+ const versionLabel = (0, helpers_1.getCurrentAgentVersion)();
214
+ if (versionLabel) {
215
+ out[semantic_convention_1.default.GEN_AI_AGENT_VERSION] = versionLabel;
216
+ span.setAttribute(semantic_convention_1.default.GEN_AI_AGENT_VERSION, versionLabel);
217
+ }
218
+ return out;
219
+ }
220
+ /**
221
+ * Patch a Pipeline subclass `_call` (the method invoked when the pipeline
222
+ * object is used as a function). `this` is the pipeline instance.
223
+ * args[0] = inputs, args[1] = generation options.
224
+ */
225
+ static _patchPipelineCall(tracer, className, sdkVersion) {
226
+ return (originalMethod) => {
227
+ return async function (...args) {
228
+ if ((0, helpers_1.isFrameworkLlmActive)())
229
+ return originalMethod.apply(this, args);
230
+ const task = resolveTask(this, className);
231
+ const requestModel = resolveModel(this);
232
+ const { operation } = classifyTask(task);
233
+ const genAIEndpoint = `transformers.${task}`;
234
+ const spanName = `${operation} ${requestModel}`;
235
+ const effectiveCtx = (0, helpers_1.getFrameworkParentContext)() ?? api_1.context.active();
236
+ const span = tracer.startSpan(spanName, { kind: api_1.SpanKind.CLIENT, attributes: spanCreationAttrs(operation, requestModel) }, effectiveCtx);
237
+ return api_1.context.with(api_1.trace.setSpan(effectiveCtx, span), async () => {
238
+ let metricParams;
239
+ const startTime = Date.now();
240
+ try {
241
+ const response = await originalMethod.apply(this, args);
242
+ metricParams = TransformersWrapper._handleResponse({
243
+ instance: this,
244
+ args,
245
+ response,
246
+ span,
247
+ requestModel,
248
+ task,
249
+ operation,
250
+ genAIEndpoint,
251
+ ttft: (Date.now() - startTime) / 1000,
252
+ sdkVersion,
253
+ });
254
+ return response;
255
+ }
256
+ catch (e) {
257
+ helpers_1.default.handleException(span, e);
258
+ base_wrapper_1.default.recordMetrics(span, {
259
+ genAIEndpoint,
260
+ model: requestModel,
261
+ aiSystem: TransformersWrapper.aiSystem,
262
+ serverAddress: TransformersWrapper.serverAddress,
263
+ serverPort: TransformersWrapper.serverPort,
264
+ errorType: e?.constructor?.name || '_OTHER',
265
+ });
266
+ throw e;
267
+ }
268
+ finally {
269
+ span.end();
270
+ if (metricParams) {
271
+ base_wrapper_1.default.recordMetrics(span, metricParams);
272
+ }
273
+ }
274
+ });
275
+ };
276
+ };
277
+ }
278
+ /**
279
+ * Patch the `pipeline()` factory as a fallback when no Pipeline subclass
280
+ * prototype is exported. Wraps the returned callable so each invocation
281
+ * emits a span. The original callable is invoked directly (not via the
282
+ * wrapper) so we never lose its prototype behavior.
283
+ */
284
+ static _patchPipelineFactory(tracer, sdkVersion) {
285
+ return (originalFactory) => {
286
+ return async function (...factoryArgs) {
287
+ const pipe = await originalFactory.apply(this, factoryArgs);
288
+ if (typeof pipe !== 'function')
289
+ return pipe;
290
+ const task = (typeof factoryArgs[0] === 'string' && factoryArgs[0]) ||
291
+ (typeof pipe.task === 'string' && pipe.task) ||
292
+ 'text-generation';
293
+ const { operation } = classifyTask(task);
294
+ const genAIEndpoint = `transformers.${task}`;
295
+ const wrappedPipe = async function (...callArgs) {
296
+ if ((0, helpers_1.isFrameworkLlmActive)())
297
+ return pipe.apply(this, callArgs);
298
+ const requestModel = resolveModel(pipe) ||
299
+ (typeof factoryArgs[1] === 'string' ? factoryArgs[1] : 'unknown');
300
+ const spanName = `${operation} ${requestModel}`;
301
+ const effectiveCtx = (0, helpers_1.getFrameworkParentContext)() ?? api_1.context.active();
302
+ const span = tracer.startSpan(spanName, { kind: api_1.SpanKind.CLIENT, attributes: spanCreationAttrs(operation, requestModel) }, effectiveCtx);
303
+ return api_1.context.with(api_1.trace.setSpan(effectiveCtx, span), async () => {
304
+ let metricParams;
305
+ const startTime = Date.now();
306
+ try {
307
+ const response = await pipe.apply(this, callArgs);
308
+ metricParams = TransformersWrapper._handleResponse({
309
+ instance: pipe,
310
+ args: callArgs,
311
+ response,
312
+ span,
313
+ requestModel,
314
+ task,
315
+ operation,
316
+ genAIEndpoint,
317
+ ttft: (Date.now() - startTime) / 1000,
318
+ sdkVersion,
319
+ });
320
+ return response;
321
+ }
322
+ catch (e) {
323
+ helpers_1.default.handleException(span, e);
324
+ base_wrapper_1.default.recordMetrics(span, {
325
+ genAIEndpoint,
326
+ model: requestModel,
327
+ aiSystem: TransformersWrapper.aiSystem,
328
+ serverAddress: TransformersWrapper.serverAddress,
329
+ serverPort: TransformersWrapper.serverPort,
330
+ errorType: e?.constructor?.name || '_OTHER',
331
+ });
332
+ throw e;
333
+ }
334
+ finally {
335
+ span.end();
336
+ if (metricParams) {
337
+ base_wrapper_1.default.recordMetrics(span, metricParams);
338
+ }
339
+ }
340
+ });
341
+ };
342
+ // Preserve callable identity so the wrapped pipe behaves like the original.
343
+ Object.setPrototypeOf(wrappedPipe, Object.getPrototypeOf(pipe));
344
+ Object.assign(wrappedPipe, pipe);
345
+ return wrappedPipe;
346
+ };
347
+ };
348
+ }
349
+ /**
350
+ * Synchronous attribute setter shared by the class- and factory-patch paths.
351
+ * Returns the metric params so the caller can record metrics in `finally`.
352
+ */
353
+ static _handleResponse({ instance, args, response, span, requestModel, task, operation, genAIEndpoint, ttft, sdkVersion, }) {
354
+ const captureContent = config_1.default.captureMessageContent;
355
+ const { isEmbedding } = classifyTask(task);
356
+ const inputs = args[0];
357
+ const options = args[1] || {};
358
+ const { temperature, topK, topP, maxTokens } = resolveGenerationParams(instance, options);
359
+ const inputStr = stringifyInputs(inputs);
360
+ const completion = extractCompletion(task, response);
361
+ const inputTokens = helpers_1.default.generalTokens(inputStr) ?? 0;
362
+ const outputTokens = isEmbedding ? 0 : helpers_1.default.generalTokens(completion) ?? 0;
363
+ const pricingInfo = config_1.default.pricingInfo || {};
364
+ const cost = helpers_1.default.getChatModelCost(requestModel, pricingInfo, inputTokens, outputTokens);
365
+ // Common attributes (telemetry sdk, env, app, request model, cost, server).
366
+ TransformersWrapper.setBaseSpanAttributes(span, {
367
+ genAIEndpoint,
368
+ model: requestModel,
369
+ cost,
370
+ aiSystem: TransformersWrapper.aiSystem,
371
+ serverAddress: TransformersWrapper.serverAddress,
372
+ serverPort: TransformersWrapper.serverPort,
373
+ });
374
+ // Parity: Python stamps gen_ai.system and the transformers package version
375
+ // (setBaseSpanAttributes uses Shield360's SDK version).
376
+ span.setAttribute(semantic_convention_1.default.GEN_AI_PROVIDER_NAME, TransformersWrapper.aiSystem);
377
+ if (sdkVersion) {
378
+ span.setAttribute(semantic_convention_1.default.GEN_AI_SDK_VERSION, sdkVersion);
379
+ }
380
+ // Request parameters (only when present, matching Python).
381
+ if (temperature !== null) {
382
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_TEMPERATURE, temperature);
383
+ }
384
+ if (topK !== null) {
385
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_TOP_K, topK);
386
+ }
387
+ if (topP !== null) {
388
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_TOP_P, topP);
389
+ }
390
+ if (maxTokens !== null) {
391
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, maxTokens);
392
+ }
393
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_IS_STREAM, false);
394
+ // Response parameters.
395
+ span.setAttribute(semantic_convention_1.default.GEN_AI_RESPONSE_MODEL, requestModel);
396
+ if (!isEmbedding) {
397
+ span.setAttribute(semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
398
+ span.setAttribute(semantic_convention_1.default.GEN_AI_OUTPUT_TYPE, semantic_convention_1.default.GEN_AI_OUTPUT_TYPE_TEXT);
399
+ }
400
+ // Tokens, cost, cache (cache stamped as 0 even when unused, like Python).
401
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
402
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
403
+ span.setAttribute(semantic_convention_1.default.GEN_AI_CLIENT_TOKEN_USAGE, inputTokens + outputTokens);
404
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, 0);
405
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS, 0);
406
+ // Timing (Python always sets these; tbt is 0 for non-streaming pipelines).
407
+ span.setAttribute(semantic_convention_1.default.GEN_AI_SERVER_TTFT, ttft);
408
+ span.setAttribute(semantic_convention_1.default.GEN_AI_SERVER_TBT, 0);
409
+ const versionExtras = TransformersWrapper._stampAgentVersion(span, {
410
+ systemInstructionsJson: null,
411
+ primaryModel: requestModel,
412
+ temperature,
413
+ top_p: topP,
414
+ max_tokens: maxTokens,
415
+ });
416
+ let inputMessagesJson;
417
+ let outputMessagesJson;
418
+ if (captureContent) {
419
+ inputMessagesJson = helpers_1.default.buildInputMessages([{ role: 'user', content: inputStr }]);
420
+ span.setAttribute(semantic_convention_1.default.GEN_AI_INPUT_MESSAGES, inputMessagesJson);
421
+ if (!isEmbedding) {
422
+ outputMessagesJson = helpers_1.default.buildOutputMessages(completion, 'stop');
423
+ span.setAttribute(semantic_convention_1.default.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
424
+ }
425
+ }
426
+ if (!config_1.default.disableEvents) {
427
+ const eventAttrs = {
428
+ [semantic_convention_1.default.GEN_AI_OPERATION]: operation,
429
+ [semantic_convention_1.default.GEN_AI_REQUEST_MODEL]: requestModel,
430
+ [semantic_convention_1.default.GEN_AI_RESPONSE_MODEL]: requestModel,
431
+ [semantic_convention_1.default.SERVER_ADDRESS]: TransformersWrapper.serverAddress,
432
+ [semantic_convention_1.default.SERVER_PORT]: TransformersWrapper.serverPort,
433
+ [semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
434
+ [semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
435
+ ...versionExtras,
436
+ };
437
+ if (!isEmbedding) {
438
+ eventAttrs[semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON] = ['stop'];
439
+ eventAttrs[semantic_convention_1.default.GEN_AI_OUTPUT_TYPE] = semantic_convention_1.default.GEN_AI_OUTPUT_TYPE_TEXT;
440
+ }
441
+ if (captureContent) {
442
+ if (inputMessagesJson)
443
+ eventAttrs[semantic_convention_1.default.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
444
+ if (outputMessagesJson)
445
+ eventAttrs[semantic_convention_1.default.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
446
+ }
447
+ helpers_1.default.emitInferenceEvent(span, eventAttrs);
448
+ }
449
+ return {
450
+ genAIEndpoint,
451
+ model: requestModel,
452
+ cost,
453
+ aiSystem: TransformersWrapper.aiSystem,
454
+ serverAddress: TransformersWrapper.serverAddress,
455
+ serverPort: TransformersWrapper.serverPort,
456
+ };
457
+ }
458
+ }
459
+ TransformersWrapper.aiSystem = semantic_convention_1.default.GEN_AI_SYSTEM_HUGGING_FACE;
460
+ TransformersWrapper.serverAddress = '127.0.0.1';
461
+ TransformersWrapper.serverPort = 80;
462
+ function spanCreationAttrs(operationName, requestModel) {
463
+ return {
464
+ [semantic_convention_1.default.GEN_AI_OPERATION]: operationName,
465
+ [semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL]: semantic_convention_1.default.GEN_AI_SYSTEM_HUGGING_FACE,
466
+ [semantic_convention_1.default.GEN_AI_REQUEST_MODEL]: requestModel,
467
+ [semantic_convention_1.default.SERVER_ADDRESS]: TransformersWrapper.serverAddress,
468
+ [semantic_convention_1.default.SERVER_PORT]: TransformersWrapper.serverPort,
469
+ };
470
+ }
471
+ exports.default = TransformersWrapper;
472
+ //# sourceMappingURL=wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../../src/instrumentation/transformers/wrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAwF;AACxF,0DAA2C;AAC3C,yDAIuB;AACvB,oFAA2D;AAC3D,mEAAkE;AAelE,MAAM,cAAc,GAA8B;IAChD,wCAAwC;IACxC,iBAAiB,EAAE,EAAE,SAAS,EAAE,6BAAkB,CAAC,0BAA0B,EAAE,WAAW,EAAE,KAAK,EAAE;IACnG,mDAAmD;IACnD,sBAAsB,EAAE,EAAE,SAAS,EAAE,6BAAkB,CAAC,qCAAqC,EA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ED,OAAO;YACL,aAAa;YACb,KAAK,EAAE,YAAY;YACnB,IAAI;YACJ,QAAQ,EAAE,mBAAmB,CAAC,QAAQ;YACtC,aAAa,EAAE,mBAAmB,CAAC,aAAa;YAChD,UAAU,EAAE,mBAAmB,CAAC,UAAU;SAC3C,CAAC;IACJ,CAAC;;AA3UM,4BAAQ,GAAG,6BAAkB,CAAC,0BAA0B,CAAC;AACzD,iCAAa,GAAG,WAAW,CAAC;AAC5B,8BAAU,GAAG,EAAE,CAAC;AA4UzB,SAAS,iBAAiB,CAAC,aAAqB,EAAE,YAAoB;IACpE,OAAO;QACL,CAAC,6BAAkB,CAAC,gBAAgB,CAAC,EAAE,aAAa;QACpD,CAAC,6BAAkB,CAAC,yBAAyB,CAAC,EAAE,6BAAkB,CAAC,0BAA0B;QAC7F,CAAC,6BAAkB,CAAC,oBAAoB,CAAC,EAAE,YAAY;QACvD,CAAC,6BAAkB,CAAC,cAAc,CAAC,EAAE,mBAAmB,CAAC,aAAa;QACtE,CAAC,6BAAkB,CAAC,WAAW,CAAC,EAAE,mBAAmB,CAAC,UAAU;KACjE,CAAC;AACJ,CAAC;AAED,kBAAe,mBAAmB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { InstrumentationBase, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';
2
+ import { InstrumentationConfig } from '@opentelemetry/instrumentation';
3
+ export interface VercelAIInstrumentationConfig extends InstrumentationConfig {
4
+ }
5
+ export default class Shield360VercelAIInstrumentation extends InstrumentationBase {
6
+ constructor(config?: VercelAIInstrumentationConfig);
7
+ protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[];
8
+ manualPatch(ai: any): any;
9
+ protected _patch(moduleExports: any): any;
10
+ }
@@ -0,0 +1,59 @@
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 instrumentation_1 = require("@opentelemetry/instrumentation");
7
+ const constant_1 = require("../../constant");
8
+ const wrapper_1 = __importDefault(require("./wrapper"));
9
+ // Functions to intercept from the `ai` module
10
+ const PATCHED_FNS = ['generateText', 'streamText', 'generateObject', 'embed'];
11
+ class Shield360VercelAIInstrumentation extends instrumentation_1.InstrumentationBase {
12
+ constructor(config = {}) {
13
+ super(`${constant_1.INSTRUMENTATION_PREFIX}/instrumentation-vercel-ai`, '1.0.0', config);
14
+ }
15
+ init() {
16
+ const module = new instrumentation_1.InstrumentationNodeModuleDefinition('ai', ['>=3.0.0 <5'], (moduleExports) => this._patch(moduleExports),
17
+ // No-op unpatch: Proxy is discarded when the module is re-required
18
+ () => { });
19
+ return [module];
20
+ }
21
+ manualPatch(ai) {
22
+ return this._patch(ai);
23
+ }
24
+ _patch(moduleExports) {
25
+ try {
26
+ const tracer = this.tracer;
27
+ // The `ai` package exports functions as non-configurable getter properties,
28
+ // so shimmer's Object.defineProperty-based wrapping fails. Instead, return a
29
+ // Proxy that intercepts property access and returns wrapped functions.
30
+ const patchers = {
31
+ generateText: wrapper_1.default._patchGenerateText,
32
+ streamText: wrapper_1.default._patchStreamText,
33
+ generateObject: wrapper_1.default._patchGenerateObject,
34
+ embed: wrapper_1.default._patchEmbed,
35
+ };
36
+ // Pre-build wrapped functions once (avoid re-wrapping on every get)
37
+ const wrapped = {};
38
+ for (const name of PATCHED_FNS) {
39
+ const original = moduleExports[name];
40
+ if (typeof original === 'function') {
41
+ wrapped[name] = patchers[name](tracer)(original);
42
+ }
43
+ }
44
+ return new Proxy(moduleExports, {
45
+ get(target, prop, receiver) {
46
+ if (prop in wrapped)
47
+ return wrapped[prop];
48
+ return Reflect.get(target, prop, receiver);
49
+ },
50
+ });
51
+ }
52
+ catch (e) {
53
+ console.error('Error in VercelAI _patch method:', e);
54
+ return moduleExports;
55
+ }
56
+ }
57
+ }
58
+ exports.default = Shield360VercelAIInstrumentation;
59
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @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gBACrC,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;oBACnC,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;gBACnD,CAAC;YACH,CAAC;YAED,OAAO,IAAI,KAAK,CAAC,aAAa,EAAE;gBAC9B,GAAG,CAAC,MAAM,EAAE,IAAY,EAAE,QAAQ;oBAChC,IAAI,IAAI,IAAI,OAAO;wBAAE,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;oBAC1C,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;gBAC7C,CAAC;aACF,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,CAAC,CAAC,CAAC;YACrD,OAAO,aAAa,CAAC;QACvB,CAAC;IACH,CAAC;CACF;AAtDD,mDAsDC"}
@@ -0,0 +1,50 @@
1
+ import { Span, Tracer } from '@opentelemetry/api';
2
+ import BaseWrapper from '../base-wrapper';
3
+ declare class VercelAIWrapper extends BaseWrapper {
4
+ static aiSystem: string;
5
+ static serverAddress: string;
6
+ static serverPort: number;
7
+ /**
8
+ * Stamp `shield360.agent.version_hash` (auto) and `gen_ai.agent.version`
9
+ * (user override, if set) on the span and return the same attributes so
10
+ * the caller can merge them into the inference event extras.
11
+ */
12
+ static _stampAgentVersion(span: Span, args: {
13
+ systemInstructionsJson?: string;
14
+ toolDefinitionsJson?: string;
15
+ primaryModel?: string;
16
+ temperature?: number | null;
17
+ top_p?: number | null;
18
+ max_tokens?: number | null;
19
+ }): Record<string, string>;
20
+ static _patchGenerateText(tracer: Tracer): any;
21
+ static _patchStreamText(tracer: Tracer): any;
22
+ static _patchGenerateObject(tracer: Tracer): any;
23
+ static _patchEmbed(tracer: Tracer): any;
24
+ static _chatComplete({ args, genAIEndpoint, response, span, outputType, resultOverride, }: {
25
+ args: any[];
26
+ genAIEndpoint: string;
27
+ response: any;
28
+ span: Span;
29
+ outputType: string;
30
+ resultOverride?: any;
31
+ }): Promise<any>;
32
+ static _chatCommonSetter({ args, genAIEndpoint, result, span, isStream, outputType, ttft, tbt, }: {
33
+ args: any[];
34
+ genAIEndpoint: string;
35
+ result: any;
36
+ span: Span;
37
+ isStream: boolean;
38
+ outputType: string;
39
+ ttft?: number;
40
+ tbt?: number;
41
+ }): Promise<{
42
+ genAIEndpoint: string;
43
+ model: any;
44
+ cost: number;
45
+ aiSystem: string;
46
+ serverAddress: string;
47
+ serverPort: number;
48
+ }>;
49
+ }
50
+ export default VercelAIWrapper;