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,539 @@
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
+ function spanCreationAttrs(operationName, requestModel) {
45
+ return {
46
+ [semantic_convention_1.default.GEN_AI_OPERATION]: operationName,
47
+ [semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL]: VercelAIWrapper.aiSystem,
48
+ [semantic_convention_1.default.GEN_AI_REQUEST_MODEL]: requestModel,
49
+ [semantic_convention_1.default.SERVER_ADDRESS]: VercelAIWrapper.serverAddress,
50
+ [semantic_convention_1.default.SERVER_PORT]: VercelAIWrapper.serverPort,
51
+ };
52
+ }
53
+ class VercelAIWrapper extends base_wrapper_1.default {
54
+ /**
55
+ * Stamp `shield360.agent.version_hash` (auto) and `gen_ai.agent.version`
56
+ * (user override, if set) on the span and return the same attributes so
57
+ * the caller can merge them into the inference event extras.
58
+ */
59
+ static _stampAgentVersion(span, args) {
60
+ const out = {};
61
+ try {
62
+ const versionHash = helpers_1.default.computeAgentVersionHash({
63
+ systemInstructions: args.systemInstructionsJson ?? null,
64
+ toolDefinitions: args.toolDefinitionsJson ?? null,
65
+ primaryModel: args.primaryModel ?? null,
66
+ runtimeConfig: {
67
+ temperature: args.temperature ?? null,
68
+ top_p: args.top_p ?? null,
69
+ max_tokens: args.max_tokens ?? null,
70
+ provider: semantic_convention_1.default.GEN_AI_SYSTEM_VERCEL_AI,
71
+ },
72
+ providers: [semantic_convention_1.default.GEN_AI_SYSTEM_VERCEL_AI],
73
+ });
74
+ if (versionHash) {
75
+ out[semantic_convention_1.default.SHIELD360_AGENT_VERSION_HASH] = versionHash;
76
+ span.setAttribute(semantic_convention_1.default.SHIELD360_AGENT_VERSION_HASH, versionHash);
77
+ }
78
+ }
79
+ catch {
80
+ // Hash computation must never fail the wrapped call.
81
+ }
82
+ const versionLabel = (0, helpers_1.getCurrentAgentVersion)();
83
+ if (versionLabel) {
84
+ out[semantic_convention_1.default.GEN_AI_AGENT_VERSION] = versionLabel;
85
+ span.setAttribute(semantic_convention_1.default.GEN_AI_AGENT_VERSION, versionLabel);
86
+ }
87
+ return out;
88
+ }
89
+ static _patchGenerateText(tracer) {
90
+ const genAIEndpoint = 'vercel_ai.generateText';
91
+ return (originalMethod) => {
92
+ return async function (...args) {
93
+ const params = args[0] || {};
94
+ const modelId = params.model?.modelId || 'unknown';
95
+ const spanName = `${semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT} ${modelId}`;
96
+ const span = tracer.startSpan(spanName, {
97
+ kind: api_1.SpanKind.CLIENT,
98
+ attributes: spanCreationAttrs(semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT, modelId),
99
+ });
100
+ return api_1.context
101
+ .with(api_1.trace.setSpan(api_1.context.active(), span), async () => {
102
+ return originalMethod.apply(this, args);
103
+ })
104
+ .then((response) => {
105
+ return VercelAIWrapper._chatComplete({
106
+ args,
107
+ genAIEndpoint,
108
+ response,
109
+ span,
110
+ outputType: semantic_convention_1.default.GEN_AI_OUTPUT_TYPE_TEXT,
111
+ });
112
+ })
113
+ .catch((e) => {
114
+ helpers_1.default.handleException(span, e);
115
+ base_wrapper_1.default.recordMetrics(span, {
116
+ genAIEndpoint,
117
+ model: modelId,
118
+ aiSystem: VercelAIWrapper.aiSystem,
119
+ serverAddress: VercelAIWrapper.serverAddress,
120
+ serverPort: VercelAIWrapper.serverPort,
121
+ errorType: e?.constructor?.name || '_OTHER',
122
+ });
123
+ span.end();
124
+ throw e;
125
+ });
126
+ };
127
+ };
128
+ }
129
+ static _patchStreamText(tracer) {
130
+ const genAIEndpoint = 'vercel_ai.streamText';
131
+ return (originalMethod) => {
132
+ return async function (...args) {
133
+ const params = args[0] || {};
134
+ const modelId = params.model?.modelId || 'unknown';
135
+ const spanName = `${semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT} ${modelId}`;
136
+ const span = tracer.startSpan(spanName, {
137
+ kind: api_1.SpanKind.CLIENT,
138
+ attributes: spanCreationAttrs(semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT, modelId),
139
+ });
140
+ const startTime = Date.now();
141
+ const chunkTimestamps = [];
142
+ try {
143
+ const response = await api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), async () => originalMethod.apply(this, args));
144
+ try {
145
+ const originalTextStream = response.textStream;
146
+ if (originalTextStream && typeof originalTextStream.getReader === 'function') {
147
+ const reader = originalTextStream.getReader();
148
+ const wrappedTextStream = new ReadableStream({
149
+ async pull(controller) {
150
+ const { done, value } = await reader.read();
151
+ if (done) {
152
+ controller.close();
153
+ }
154
+ else {
155
+ chunkTimestamps.push(Date.now());
156
+ controller.enqueue(value);
157
+ }
158
+ },
159
+ cancel() {
160
+ reader.cancel();
161
+ },
162
+ });
163
+ Object.defineProperty(response, 'textStream', {
164
+ value: wrappedTextStream,
165
+ writable: true,
166
+ configurable: true,
167
+ });
168
+ }
169
+ }
170
+ catch (_) {
171
+ // Stream interception is best-effort; TTFT/TBT won't be captured
172
+ }
173
+ Promise.resolve(response.usage)
174
+ .then(async (usage) => {
175
+ let metricParams;
176
+ try {
177
+ const ttft = chunkTimestamps.length > 0 ? (chunkTimestamps[0] - startTime) / 1000 : 0;
178
+ let tbt = 0;
179
+ if (chunkTimestamps.length > 1) {
180
+ const timeDiffs = chunkTimestamps.slice(1).map((t, i) => t - chunkTimestamps[i]);
181
+ tbt = timeDiffs.reduce((a, b) => a + b, 0) / timeDiffs.length / 1000;
182
+ }
183
+ const finishReason = await Promise.resolve(response.finishReason).catch(() => 'stop');
184
+ const text = await Promise.resolve(response.text).catch(() => '');
185
+ const toolCalls = await Promise.resolve(response.toolCalls).catch(() => undefined);
186
+ const responseDetails = await Promise.resolve(response.response).catch(() => undefined);
187
+ const result = {
188
+ usage: {
189
+ promptTokens: usage?.promptTokens || 0,
190
+ completionTokens: usage?.completionTokens || 0,
191
+ },
192
+ finishReason: finishReason || 'stop',
193
+ text: text || '',
194
+ toolCalls,
195
+ response: responseDetails,
196
+ };
197
+ metricParams = await VercelAIWrapper._chatCommonSetter({
198
+ args,
199
+ genAIEndpoint,
200
+ result,
201
+ span,
202
+ isStream: true,
203
+ outputType: semantic_convention_1.default.GEN_AI_OUTPUT_TYPE_TEXT,
204
+ ttft,
205
+ tbt,
206
+ });
207
+ }
208
+ catch (e) {
209
+ helpers_1.default.handleException(span, e);
210
+ }
211
+ finally {
212
+ span.end();
213
+ if (metricParams) {
214
+ base_wrapper_1.default.recordMetrics(span, metricParams);
215
+ }
216
+ }
217
+ })
218
+ .catch((e) => {
219
+ helpers_1.default.handleException(span, e);
220
+ base_wrapper_1.default.recordMetrics(span, {
221
+ genAIEndpoint,
222
+ model: modelId,
223
+ aiSystem: VercelAIWrapper.aiSystem,
224
+ serverAddress: VercelAIWrapper.serverAddress,
225
+ serverPort: VercelAIWrapper.serverPort,
226
+ errorType: e?.constructor?.name || '_OTHER',
227
+ });
228
+ span.end();
229
+ });
230
+ return response;
231
+ }
232
+ catch (e) {
233
+ helpers_1.default.handleException(span, e);
234
+ base_wrapper_1.default.recordMetrics(span, {
235
+ genAIEndpoint,
236
+ model: modelId,
237
+ aiSystem: VercelAIWrapper.aiSystem,
238
+ serverAddress: VercelAIWrapper.serverAddress,
239
+ serverPort: VercelAIWrapper.serverPort,
240
+ errorType: e?.constructor?.name || '_OTHER',
241
+ });
242
+ span.end();
243
+ throw e;
244
+ }
245
+ };
246
+ };
247
+ }
248
+ static _patchGenerateObject(tracer) {
249
+ const genAIEndpoint = 'vercel_ai.generateObject';
250
+ return (originalMethod) => {
251
+ return async function (...args) {
252
+ const params = args[0] || {};
253
+ const modelId = params.model?.modelId || 'unknown';
254
+ const spanName = `${semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT} ${modelId}`;
255
+ const span = tracer.startSpan(spanName, {
256
+ kind: api_1.SpanKind.CLIENT,
257
+ attributes: spanCreationAttrs(semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT, modelId),
258
+ });
259
+ return api_1.context
260
+ .with(api_1.trace.setSpan(api_1.context.active(), span), async () => {
261
+ return originalMethod.apply(this, args);
262
+ })
263
+ .then((response) => {
264
+ const result = {
265
+ ...response,
266
+ text: JSON.stringify(response.object || {}),
267
+ };
268
+ return VercelAIWrapper._chatComplete({
269
+ args,
270
+ genAIEndpoint,
271
+ response,
272
+ span,
273
+ outputType: semantic_convention_1.default.GEN_AI_OUTPUT_TYPE_JSON,
274
+ resultOverride: result,
275
+ });
276
+ })
277
+ .catch((e) => {
278
+ helpers_1.default.handleException(span, e);
279
+ base_wrapper_1.default.recordMetrics(span, {
280
+ genAIEndpoint,
281
+ model: modelId,
282
+ aiSystem: VercelAIWrapper.aiSystem,
283
+ serverAddress: VercelAIWrapper.serverAddress,
284
+ serverPort: VercelAIWrapper.serverPort,
285
+ errorType: e?.constructor?.name || '_OTHER',
286
+ });
287
+ span.end();
288
+ throw e;
289
+ });
290
+ };
291
+ };
292
+ }
293
+ static _patchEmbed(tracer) {
294
+ const genAIEndpoint = 'vercel_ai.embed';
295
+ return (originalMethod) => {
296
+ return async function (...args) {
297
+ const params = args[0] || {};
298
+ const modelId = params.model?.modelId || 'unknown';
299
+ const spanName = `${semantic_convention_1.default.GEN_AI_OPERATION_TYPE_EMBEDDING} ${modelId}`;
300
+ const span = tracer.startSpan(spanName, {
301
+ kind: api_1.SpanKind.CLIENT,
302
+ attributes: spanCreationAttrs(semantic_convention_1.default.GEN_AI_OPERATION_TYPE_EMBEDDING, modelId),
303
+ });
304
+ return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), async () => {
305
+ const captureContent = config_1.default.captureMessageContent;
306
+ let metricParams;
307
+ try {
308
+ const response = await originalMethod.apply(this, args);
309
+ const pricingInfo = config_1.default.pricingInfo || {};
310
+ const inputTokens = response.usage?.tokens || 0;
311
+ const cost = helpers_1.default.getEmbedModelCost(modelId, pricingInfo, inputTokens);
312
+ VercelAIWrapper.setBaseSpanAttributes(span, {
313
+ genAIEndpoint,
314
+ model: modelId,
315
+ cost,
316
+ aiSystem: VercelAIWrapper.aiSystem,
317
+ serverAddress: VercelAIWrapper.serverAddress,
318
+ serverPort: VercelAIWrapper.serverPort,
319
+ });
320
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_IS_STREAM, false);
321
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
322
+ if (captureContent && params.value !== undefined) {
323
+ const inputStr = typeof params.value === 'string' ? params.value : JSON.stringify(params.value);
324
+ span.setAttribute(semantic_convention_1.default.GEN_AI_INPUT_MESSAGES, inputStr);
325
+ }
326
+ metricParams = {
327
+ genAIEndpoint,
328
+ model: modelId,
329
+ cost,
330
+ aiSystem: VercelAIWrapper.aiSystem,
331
+ serverAddress: VercelAIWrapper.serverAddress,
332
+ serverPort: VercelAIWrapper.serverPort,
333
+ };
334
+ return response;
335
+ }
336
+ catch (e) {
337
+ helpers_1.default.handleException(span, e);
338
+ metricParams = {
339
+ genAIEndpoint,
340
+ model: modelId,
341
+ aiSystem: VercelAIWrapper.aiSystem,
342
+ serverAddress: VercelAIWrapper.serverAddress,
343
+ serverPort: VercelAIWrapper.serverPort,
344
+ errorType: e?.constructor?.name || '_OTHER',
345
+ };
346
+ throw e;
347
+ }
348
+ finally {
349
+ span.end();
350
+ if (metricParams)
351
+ base_wrapper_1.default.recordMetrics(span, metricParams);
352
+ }
353
+ });
354
+ };
355
+ };
356
+ }
357
+ static async _chatComplete({ args, genAIEndpoint, response, span, outputType, resultOverride, }) {
358
+ let metricParams;
359
+ try {
360
+ metricParams = await VercelAIWrapper._chatCommonSetter({
361
+ args,
362
+ genAIEndpoint,
363
+ result: resultOverride || response,
364
+ span,
365
+ isStream: false,
366
+ outputType,
367
+ });
368
+ return response;
369
+ }
370
+ catch (e) {
371
+ helpers_1.default.handleException(span, e);
372
+ throw e;
373
+ }
374
+ finally {
375
+ span.end();
376
+ if (metricParams) {
377
+ base_wrapper_1.default.recordMetrics(span, metricParams);
378
+ }
379
+ }
380
+ }
381
+ static async _chatCommonSetter({ args, genAIEndpoint, result, span, isStream, outputType, ttft = 0, tbt = 0, }) {
382
+ const captureContent = config_1.default.captureMessageContent;
383
+ const params = args[0] || {};
384
+ const modelId = params.model?.modelId || 'unknown';
385
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_TEMPERATURE, params.temperature ?? 1);
386
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_TOP_P, params.topP ?? 1);
387
+ if (params.maxTokens != null) {
388
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, params.maxTokens);
389
+ }
390
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_IS_STREAM, isStream);
391
+ if (params.seed != null) {
392
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_SEED, Number(params.seed));
393
+ }
394
+ if (params.frequencyPenalty) {
395
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_FREQUENCY_PENALTY, params.frequencyPenalty);
396
+ }
397
+ if (params.presencePenalty) {
398
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_PRESENCE_PENALTY, params.presencePenalty);
399
+ }
400
+ if (params.stopSequences) {
401
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_STOP_SEQUENCES, Array.isArray(params.stopSequences) ? params.stopSequences : [params.stopSequences]);
402
+ }
403
+ if (params.topK != null) {
404
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_TOP_K, params.topK);
405
+ }
406
+ const messages = params.messages || (params.prompt ? [{ role: 'user', content: params.prompt }] : []);
407
+ if (captureContent) {
408
+ span.setAttribute(semantic_convention_1.default.GEN_AI_INPUT_MESSAGES, helpers_1.default.buildInputMessages(messages, params.system));
409
+ }
410
+ const responseId = result.response?.id;
411
+ const responseModel = result.response?.modelId || modelId;
412
+ const inputTokens = result.usage?.promptTokens || 0;
413
+ const outputTokens = result.usage?.completionTokens || 0;
414
+ const pricingInfo = config_1.default.pricingInfo || {};
415
+ const cost = helpers_1.default.getChatModelCost(modelId, pricingInfo, inputTokens, outputTokens);
416
+ VercelAIWrapper.setBaseSpanAttributes(span, {
417
+ genAIEndpoint,
418
+ model: modelId,
419
+ cost,
420
+ aiSystem: VercelAIWrapper.aiSystem,
421
+ serverAddress: VercelAIWrapper.serverAddress,
422
+ serverPort: VercelAIWrapper.serverPort,
423
+ });
424
+ span.setAttribute(semantic_convention_1.default.GEN_AI_RESPONSE_MODEL, responseModel);
425
+ if (responseId) {
426
+ span.setAttribute(semantic_convention_1.default.GEN_AI_RESPONSE_ID, responseId);
427
+ }
428
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
429
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
430
+ const finishReason = result.finishReason || 'stop';
431
+ span.setAttribute(semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON, [finishReason]);
432
+ span.setAttribute(semantic_convention_1.default.GEN_AI_OUTPUT_TYPE, outputType);
433
+ if (ttft > 0) {
434
+ span.setAttribute(semantic_convention_1.default.GEN_AI_SERVER_TTFT, ttft);
435
+ }
436
+ if (tbt > 0) {
437
+ span.setAttribute(semantic_convention_1.default.GEN_AI_SERVER_TBT, tbt);
438
+ }
439
+ if (result.toolCalls?.length > 0) {
440
+ const toolNames = result.toolCalls.map((t) => t.toolName || '').filter(Boolean);
441
+ const toolIds = result.toolCalls.map((t) => t.toolCallId || '').filter(Boolean);
442
+ const toolArgs = result.toolCalls.map((t) => JSON.stringify(t.args || {})).filter(Boolean);
443
+ if (toolNames.length > 0) {
444
+ span.setAttribute(semantic_convention_1.default.GEN_AI_TOOL_NAME, toolNames.join(', '));
445
+ }
446
+ if (toolIds.length > 0) {
447
+ span.setAttribute(semantic_convention_1.default.GEN_AI_TOOL_CALL_ID, toolIds.join(', '));
448
+ }
449
+ if (toolArgs.length > 0) {
450
+ span.setAttribute(semantic_convention_1.default.GEN_AI_TOOL_ARGS, toolArgs.join(', '));
451
+ }
452
+ }
453
+ const normalizedToolCalls = result.toolCalls?.map((t) => ({
454
+ id: t.toolCallId || '',
455
+ name: t.toolName || '',
456
+ arguments: t.args || {},
457
+ }));
458
+ // Vercel AI `tools` is an object map keyed by tool name: { toolName: { description, parameters } }
459
+ // Normalize to the flat array shape that buildToolDefinitions understands.
460
+ let toolsForDefinitions = params.tools;
461
+ if (toolsForDefinitions && !Array.isArray(toolsForDefinitions) && typeof toolsForDefinitions === 'object') {
462
+ toolsForDefinitions = Object.entries(toolsForDefinitions).map(([name, def]) => ({
463
+ name,
464
+ description: def?.description ?? '',
465
+ parameters: def?.parameters ?? def?.inputSchema ?? {},
466
+ }));
467
+ }
468
+ const toolDefinitionsJson = helpers_1.default.buildToolDefinitions(toolsForDefinitions);
469
+ let inputMessagesJson;
470
+ let outputMessagesJson;
471
+ // Compute system_instructions JSON regardless of captureContent so the
472
+ // version hash is stable across runs even when content capture is off.
473
+ // Vercel AI exposes the system prompt either via a top-level `system`
474
+ // field or as a `{ role: 'system' }` message in the `messages` array.
475
+ const systemInstructionsJson = params.system
476
+ ? JSON.stringify([{ type: 'text', content: String(params.system) }])
477
+ : helpers_1.default.buildSystemInstructionsFromMessages(messages);
478
+ const versionExtras = VercelAIWrapper._stampAgentVersion(span, {
479
+ systemInstructionsJson,
480
+ toolDefinitionsJson,
481
+ primaryModel: responseModel || modelId,
482
+ temperature: typeof params.temperature === 'number' ? params.temperature : null,
483
+ top_p: typeof params.topP === 'number' ? params.topP : null,
484
+ max_tokens: typeof params.maxTokens === 'number' ? params.maxTokens : null,
485
+ });
486
+ if (captureContent) {
487
+ outputMessagesJson = helpers_1.default.buildOutputMessages(result.text || '', finishReason, normalizedToolCalls);
488
+ span.setAttribute(semantic_convention_1.default.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
489
+ inputMessagesJson = helpers_1.default.buildInputMessages(messages, params.system);
490
+ if (systemInstructionsJson) {
491
+ span.setAttribute(semantic_convention_1.default.GEN_AI_SYSTEM_INSTRUCTIONS, systemInstructionsJson);
492
+ }
493
+ }
494
+ if (toolDefinitionsJson) {
495
+ span.setAttribute(semantic_convention_1.default.GEN_AI_TOOL_DEFINITIONS, toolDefinitionsJson);
496
+ }
497
+ if (!config_1.default.disableEvents) {
498
+ const eventAttrs = {
499
+ [semantic_convention_1.default.GEN_AI_OPERATION]: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT,
500
+ [semantic_convention_1.default.GEN_AI_REQUEST_MODEL]: modelId,
501
+ [semantic_convention_1.default.GEN_AI_RESPONSE_MODEL]: responseModel,
502
+ [semantic_convention_1.default.SERVER_ADDRESS]: VercelAIWrapper.serverAddress,
503
+ [semantic_convention_1.default.SERVER_PORT]: VercelAIWrapper.serverPort,
504
+ [semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON]: [finishReason],
505
+ [semantic_convention_1.default.GEN_AI_OUTPUT_TYPE]: outputType,
506
+ [semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
507
+ [semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
508
+ ...versionExtras,
509
+ };
510
+ if (responseId) {
511
+ eventAttrs[semantic_convention_1.default.GEN_AI_RESPONSE_ID] = responseId;
512
+ }
513
+ if (captureContent) {
514
+ if (inputMessagesJson)
515
+ eventAttrs[semantic_convention_1.default.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
516
+ if (outputMessagesJson)
517
+ eventAttrs[semantic_convention_1.default.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
518
+ if (systemInstructionsJson)
519
+ eventAttrs[semantic_convention_1.default.GEN_AI_SYSTEM_INSTRUCTIONS] = systemInstructionsJson;
520
+ }
521
+ if (toolDefinitionsJson)
522
+ eventAttrs[semantic_convention_1.default.GEN_AI_TOOL_DEFINITIONS] = toolDefinitionsJson;
523
+ helpers_1.default.emitInferenceEvent(span, eventAttrs);
524
+ }
525
+ return {
526
+ genAIEndpoint,
527
+ model: modelId,
528
+ cost,
529
+ aiSystem: VercelAIWrapper.aiSystem,
530
+ serverAddress: VercelAIWrapper.serverAddress,
531
+ serverPort: VercelAIWrapper.serverPort,
532
+ };
533
+ }
534
+ }
535
+ VercelAIWrapper.aiSystem = semantic_convention_1.default.GEN_AI_SYSTEM_VERCEL_AI;
536
+ VercelAIWrapper.serverAddress = 'vercel.ai';
537
+ VercelAIWrapper.serverPort = 443;
538
+ exports.default = VercelAIWrapper;
539
+ //# sourceMappingURL=wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../../src/instrumentation/vercel-ai/wrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAwF;AACxF,0DAA2C;AAC3C,yDAAwE;AACxE,oFAA2D;AAC3D,mEAAkE;AAElE,SAAS,iBAAiB,CACxB,aAAqB,EACrB,YAAoB;IAEpB,OAAO;QACL,CAAC,6BAAkB,CAAC,gBAAgB,CAAC,EAAE,aAA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,uBAAuB,CAAC,GAAG,mBAAmB,CAAC;YACtG,iBAAe,CAAC,kBAAkB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACvD,CAAC;QAED,OAAO;YACL,aAAa;YACb,KAAK,EAAE,OAAO;YACd,IAAI;YACJ,QAAQ,EAAE,eAAe,CAAC,QAAQ;YAClC,aAAa,EAAE,eAAe,CAAC,aAAa;YAC5C,UAAU,EAAE,eAAe,CAAC,UAAU;SACvC,CAAC;IACJ,CAAC;;AAhjBM,wBAAQ,GAAG,6BAAkB,CAAC,uBAAuB,CAAC;AACtD,6BAAa,GAAG,WAAW,CAAC;AAC5B,0BAAU,GAAG,GAAG,CAAC;AAijB1B,kBAAe,eAAe,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { InstrumentationBase, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';
2
+ import { InstrumentationConfig } from '@opentelemetry/instrumentation';
3
+ export interface VertexAIInstrumentationConfig extends InstrumentationConfig {
4
+ }
5
+ export default class Shield360VertexAIInstrumentation extends InstrumentationBase {
6
+ constructor(config?: VertexAIInstrumentationConfig);
7
+ protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[];
8
+ manualPatch(vertexAI: any): void;
9
+ protected _patch(moduleExports: any): void;
10
+ protected _unpatch(moduleExports: any): void;
11
+ }
@@ -0,0 +1,70 @@
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
+ class Shield360VertexAIInstrumentation extends instrumentation_1.InstrumentationBase {
10
+ constructor(config = {}) {
11
+ super(`${constant_1.INSTRUMENTATION_PREFIX}/instrumentation-vertexai`, '1.0.0', config);
12
+ }
13
+ init() {
14
+ const module = new instrumentation_1.InstrumentationNodeModuleDefinition('@google-cloud/vertexai', ['>=0.1.0'], (moduleExports) => {
15
+ this._patch(moduleExports);
16
+ return moduleExports;
17
+ }, (moduleExports) => {
18
+ if (moduleExports !== undefined) {
19
+ this._unpatch(moduleExports);
20
+ }
21
+ });
22
+ return [module];
23
+ }
24
+ manualPatch(vertexAI) {
25
+ this._patch(vertexAI);
26
+ }
27
+ _patch(moduleExports) {
28
+ try {
29
+ const GenerativeModel = moduleExports.GenerativeModel || moduleExports.GenerativeModelPreview;
30
+ const ChatSession = moduleExports.ChatSession || moduleExports.ChatSessionPreview;
31
+ if (GenerativeModel) {
32
+ if ((0, instrumentation_1.isWrapped)(GenerativeModel.prototype.generateContent)) {
33
+ this._unwrap(GenerativeModel.prototype, 'generateContent');
34
+ }
35
+ if ((0, instrumentation_1.isWrapped)(GenerativeModel.prototype.generateContentStream)) {
36
+ this._unwrap(GenerativeModel.prototype, 'generateContentStream');
37
+ }
38
+ this._wrap(GenerativeModel.prototype, 'generateContent', wrapper_1.default._patchGenerateContent(this.tracer));
39
+ this._wrap(GenerativeModel.prototype, 'generateContentStream', wrapper_1.default._patchGenerateContentStream(this.tracer));
40
+ }
41
+ if (ChatSession) {
42
+ if ((0, instrumentation_1.isWrapped)(ChatSession.prototype.sendMessage)) {
43
+ this._unwrap(ChatSession.prototype, 'sendMessage');
44
+ }
45
+ if ((0, instrumentation_1.isWrapped)(ChatSession.prototype.sendMessageStream)) {
46
+ this._unwrap(ChatSession.prototype, 'sendMessageStream');
47
+ }
48
+ this._wrap(ChatSession.prototype, 'sendMessage', wrapper_1.default._patchSendMessage(this.tracer));
49
+ this._wrap(ChatSession.prototype, 'sendMessageStream', wrapper_1.default._patchSendMessageStream(this.tracer));
50
+ }
51
+ }
52
+ catch (e) {
53
+ console.error('Error in _patch method:', e);
54
+ }
55
+ }
56
+ _unpatch(moduleExports) {
57
+ const GenerativeModel = moduleExports.GenerativeModel || moduleExports.GenerativeModelPreview;
58
+ const ChatSession = moduleExports.ChatSession || moduleExports.ChatSessionPreview;
59
+ if (GenerativeModel) {
60
+ this._unwrap(GenerativeModel.prototype, 'generateContent');
61
+ this._unwrap(GenerativeModel.prototype, 'generateContentStream');
62
+ }
63
+ if (ChatSession) {
64
+ this._unwrap(ChatSession.prototype, 'sendMessage');
65
+ this._unwrap(ChatSession.prototype, 'sendMessageStream');
66
+ }
67
+ }
68
+ }
69
+ exports.default = Shield360VertexAIInstrumentation;
70
+ //# sourceMappingURL=index.js.map