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,282 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const api_1 = require("@opentelemetry/api");
7
+ const wrapper_1 = require("../langchain/wrapper");
8
+ const helpers_1 = __importDefault(require("../../helpers"));
9
+ const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
10
+ // `buildOutputMessages` is the observable surface for the fix — we check that
11
+ // it receives the normalised toolCalls array (not undefined).
12
+ jest.mock('../../../src/helpers', () => ({
13
+ __esModule: true,
14
+ default: {
15
+ buildInputMessages: jest.fn(() => '[]'),
16
+ buildOutputMessages: jest.fn(() => '[]'),
17
+ updatePricingJson: jest.fn(async () => ({})),
18
+ getChatModelCost: jest.fn(() => 0),
19
+ },
20
+ }));
21
+ jest.mock('../../../src/config', () => ({
22
+ __esModule: true,
23
+ default: {
24
+ traceContent: true,
25
+ pricing_json: {},
26
+ updatePricingJson: jest.fn(async () => ({})),
27
+ },
28
+ }));
29
+ jest.mock('../../../src/instrumentation/base-wrapper', () => {
30
+ class MockBaseWrapper {
31
+ }
32
+ MockBaseWrapper.setBaseSpanAttributes = jest.fn();
33
+ MockBaseWrapper.recordMetrics = jest.fn();
34
+ return {
35
+ __esModule: true,
36
+ default: MockBaseWrapper,
37
+ };
38
+ });
39
+ const mockTracer = api_1.trace.getTracer('test-tracer');
40
+ function makeSpan() {
41
+ const span = mockTracer.startSpan('test-span');
42
+ span.setAttribute = jest.fn();
43
+ return span;
44
+ }
45
+ function seedRun(handler, runId, span, modelName = 'test-model') {
46
+ // Reach into the private `spans` map so we don't need a real LangChain
47
+ // callback manager to set up a fake LLM run.
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
+ handler.spans.set(runId, {
50
+ span,
51
+ startTime: Date.now() - 10,
52
+ modelName,
53
+ streamingContent: [],
54
+ tokenTimestamps: [],
55
+ promptTokens: 0,
56
+ completionTokens: 0,
57
+ });
58
+ }
59
+ describe('LangChain wrapper — tool_calls propagation', () => {
60
+ let handler;
61
+ beforeEach(() => {
62
+ jest.clearAllMocks();
63
+ handler = new wrapper_1.Shield360CallbackHandler(mockTracer);
64
+ });
65
+ it('extracts tool_calls from AIMessage and forwards them to buildOutputMessages', async () => {
66
+ const span = makeSpan();
67
+ seedRun(handler, 'run-tc-1', span);
68
+ const output = {
69
+ generations: [
70
+ [
71
+ {
72
+ text: '',
73
+ message: {
74
+ content: '',
75
+ tool_calls: [
76
+ { id: 'call_1', name: 'get_weather', args: { city: 'Tokyo' } },
77
+ { id: 'call_2', name: 'calculator', args: { expression: '2+2' } },
78
+ ],
79
+ response_metadata: { finish_reason: 'tool_calls' },
80
+ },
81
+ },
82
+ ],
83
+ ],
84
+ };
85
+ handler.handleLLMEnd(output, 'run-tc-1');
86
+ // handleLLMEnd → _finalizeLLMSpan is async
87
+ await new Promise((r) => setImmediate(r));
88
+ expect(helpers_1.default.buildOutputMessages).toHaveBeenCalledTimes(1);
89
+ const [text, finish, toolCalls] = helpers_1.default.buildOutputMessages.mock.calls[0];
90
+ expect(text).toBe('');
91
+ expect(finish).toBe('tool_calls');
92
+ expect(toolCalls).toEqual([
93
+ {
94
+ id: 'call_1',
95
+ type: 'function',
96
+ name: 'get_weather',
97
+ arguments: { city: 'Tokyo' },
98
+ },
99
+ {
100
+ id: 'call_2',
101
+ type: 'function',
102
+ name: 'calculator',
103
+ arguments: { expression: '2+2' },
104
+ },
105
+ ]);
106
+ // Flat attributes for easy filtering
107
+ const setAttr = span.setAttribute;
108
+ expect(setAttr).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_TOOL_NAME, 'get_weather, calculator');
109
+ expect(setAttr).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_TOOL_CALL_ID, 'call_1, call_2');
110
+ const toolArgsCall = setAttr.mock.calls.find((c) => c[0] === semantic_convention_1.default.GEN_AI_TOOL_CALL_ARGUMENTS);
111
+ expect(toolArgsCall).toBeTruthy();
112
+ expect(toolArgsCall?.[1]).toEqual(['{"city":"Tokyo"}', '{"expression":"2+2"}']);
113
+ });
114
+ it('passes undefined as toolCalls for text-only completions (preserves existing behaviour)', async () => {
115
+ const span = makeSpan();
116
+ seedRun(handler, 'run-tc-2', span);
117
+ const output = {
118
+ generations: [
119
+ [
120
+ {
121
+ text: 'Hello world',
122
+ message: {
123
+ content: 'Hello world',
124
+ response_metadata: { finish_reason: 'stop' },
125
+ },
126
+ },
127
+ ],
128
+ ],
129
+ };
130
+ handler.handleLLMEnd(output, 'run-tc-2');
131
+ await new Promise((r) => setImmediate(r));
132
+ const calls = helpers_1.default.buildOutputMessages.mock.calls;
133
+ expect(calls).toHaveLength(1);
134
+ const [text, finish, toolCalls] = calls[0];
135
+ expect(text).toBe('Hello world');
136
+ expect(finish).toBe('stop');
137
+ expect(toolCalls).toBeUndefined();
138
+ // Flat tool attributes must NOT be set
139
+ const setAttr = span.setAttribute;
140
+ const toolNameCall = setAttr.mock.calls.find((c) => c[0] === semantic_convention_1.default.GEN_AI_TOOL_NAME);
141
+ expect(toolNameCall).toBeUndefined();
142
+ });
143
+ it('still emits output.messages when only tool_calls are present (no assistant text)', async () => {
144
+ const span = makeSpan();
145
+ seedRun(handler, 'run-tc-3', span);
146
+ const output = {
147
+ generations: [
148
+ [
149
+ {
150
+ text: '',
151
+ message: {
152
+ content: '',
153
+ tool_calls: [{ id: 'call_only', name: 'ping', args: {} }],
154
+ response_metadata: { finish_reason: 'tool_calls' },
155
+ },
156
+ },
157
+ ],
158
+ ],
159
+ };
160
+ handler.handleLLMEnd(output, 'run-tc-3');
161
+ await new Promise((r) => setImmediate(r));
162
+ const setAttr = span.setAttribute;
163
+ const outputMsgCall = setAttr.mock.calls.find((c) => c[0] === semantic_convention_1.default.GEN_AI_OUTPUT_MESSAGES);
164
+ expect(outputMsgCall).toBeTruthy();
165
+ expect(helpers_1.default.buildOutputMessages).toHaveBeenCalledTimes(1);
166
+ });
167
+ it('reads tool_calls from additional_kwargs when not on the top-level message', async () => {
168
+ const span = makeSpan();
169
+ seedRun(handler, 'run-tc-4', span);
170
+ const output = {
171
+ generations: [
172
+ [
173
+ {
174
+ text: '',
175
+ message: {
176
+ content: '',
177
+ additional_kwargs: {
178
+ tool_calls: [
179
+ {
180
+ id: 'legacy_1',
181
+ type: 'function',
182
+ function: { name: 'lookup', arguments: '{"k":"v"}' },
183
+ },
184
+ ],
185
+ },
186
+ response_metadata: { finish_reason: 'tool_calls' },
187
+ },
188
+ },
189
+ ],
190
+ ],
191
+ };
192
+ handler.handleLLMEnd(output, 'run-tc-4');
193
+ await new Promise((r) => setImmediate(r));
194
+ const [, , toolCalls] = helpers_1.default.buildOutputMessages.mock.calls[0];
195
+ expect(toolCalls).toEqual([
196
+ { id: 'legacy_1', type: 'function', name: 'lookup', arguments: '{"k":"v"}' },
197
+ ]);
198
+ });
199
+ it('does not merge tool_calls across multiple generations (n > 1)', async () => {
200
+ // When the provider returns multiple choices, LangChain still collapses to
201
+ // one assistant message and `finishReason`/`completionContent` take the
202
+ // last writer. Tool calls must follow the same last-writer-wins rule —
203
+ // otherwise calls from different choices get flattened into one message
204
+ // and flat tool-name / id attributes become cross-choice joins.
205
+ const span = makeSpan();
206
+ seedRun(handler, 'run-tc-5', span);
207
+ const output = {
208
+ generations: [
209
+ [
210
+ {
211
+ text: '',
212
+ message: {
213
+ content: '',
214
+ tool_calls: [{ id: 'choice_a_1', name: 'tool_a', args: {} }],
215
+ response_metadata: { finish_reason: 'tool_calls' },
216
+ },
217
+ },
218
+ {
219
+ text: '',
220
+ message: {
221
+ content: '',
222
+ tool_calls: [{ id: 'choice_b_1', name: 'tool_b', args: {} }],
223
+ response_metadata: { finish_reason: 'tool_calls' },
224
+ },
225
+ },
226
+ ],
227
+ ],
228
+ };
229
+ handler.handleLLMEnd(output, 'run-tc-5');
230
+ await new Promise((r) => setImmediate(r));
231
+ const [, , toolCalls] = helpers_1.default.buildOutputMessages.mock.calls[0];
232
+ // Expect only the last generation's tool_calls — NOT both merged.
233
+ expect(toolCalls).toHaveLength(1);
234
+ expect(toolCalls[0].name).toBe('tool_b');
235
+ // Flat attributes must not be a cross-choice join like "tool_a, tool_b".
236
+ const setAttr = span.setAttribute;
237
+ expect(setAttr).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_TOOL_NAME, 'tool_b');
238
+ expect(setAttr).toHaveBeenCalledWith(semantic_convention_1.default.GEN_AI_TOOL_CALL_ID, 'choice_b_1');
239
+ });
240
+ it('survives unserialisable tool arguments (circular refs / BigInt) and still ends the span', async () => {
241
+ // If JSON.stringify throws, the outer try/catch in _finalizeLLMSpan would
242
+ // swallow the error and leave the span un-ended + the `spans` entry
243
+ // leaked. Guard per-argument serialisation and fall back to a sentinel.
244
+ const span = makeSpan();
245
+ seedRun(handler, 'run-tc-6', span);
246
+ const circular = {};
247
+ circular.self = circular;
248
+ const output = {
249
+ generations: [
250
+ [
251
+ {
252
+ text: '',
253
+ message: {
254
+ content: '',
255
+ tool_calls: [
256
+ { id: 'call_circ', name: 'bad_args', args: circular },
257
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
258
+ { id: 'call_big', name: 'big_args', args: { n: 10n } },
259
+ { id: 'call_ok', name: 'ok_args', args: { x: 1 } },
260
+ ],
261
+ response_metadata: { finish_reason: 'tool_calls' },
262
+ },
263
+ },
264
+ ],
265
+ ],
266
+ };
267
+ expect(() => handler.handleLLMEnd(output, 'run-tc-6')).not.toThrow();
268
+ await new Promise((r) => setImmediate(r));
269
+ const setAttr = span.setAttribute;
270
+ const argsCall = setAttr.mock.calls.find((c) => c[0] === semantic_convention_1.default.GEN_AI_TOOL_CALL_ARGUMENTS);
271
+ expect(argsCall).toBeTruthy();
272
+ const [, argsValue] = argsCall;
273
+ expect(argsValue).toHaveLength(3);
274
+ expect(argsValue[0]).toBe('[unserializable]'); // circular
275
+ expect(argsValue[1]).toBe('[unserializable]'); // BigInt
276
+ expect(argsValue[2]).toBe('{"x":1}'); // ok
277
+ // Most important: the span was finalised, not leaked.
278
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
279
+ expect(handler.spans.has('run-tc-6')).toBe(false);
280
+ });
281
+ });
282
+ //# sourceMappingURL=langchain-wrapper.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langchain-wrapper.test.js","sourceRoot":"","sources":["../../../src/instrumentation/__tests__/langchain-wrapper.test.ts"],"names":[],"mappings":";;;;;AAAA,4CAAiD;AACjD,kDAAgE;AAChE,4DAA4C;AAC5C,oFAA2D;AAE3D,8EAA8E;AAC9E,8DAA8D;AAC9D,IAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,CAAC;IACvC,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE;QACP,kBA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AAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,6BAAkB,CAAC,0BAA0B,CAC9D,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,CAAC;QAC9B,MAAM,CAAC,EAAE,SAAS,CAAC,GAAG,QAAS,CAAC;QAChC,MAAM,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,WAAW;QAC1D,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS;QACxD,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAW,KAAK;QAErD,sDAAsD;QACtD,8DAA8D;QAC9D,MAAM,CAAE,OAAe,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,285 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const api_1 = require("@opentelemetry/api");
7
+ const core_1 = require("@opentelemetry/core");
8
+ const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
9
+ const config_1 = __importDefault(require("../../config"));
10
+ const helpers_1 = __importDefault(require("../../helpers"));
11
+ const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
12
+ const wrapper_1 = __importDefault(require("../letta/wrapper"));
13
+ const letta_1 = __importDefault(require("../letta"));
14
+ jest.mock('../../config');
15
+ jest.mock('../../helpers', () => ({
16
+ __esModule: true,
17
+ default: {
18
+ handleException: jest.fn(),
19
+ getChatModelCost: jest.fn().mockReturnValue(0.0025),
20
+ createStreamProxy: async (stream, gen) => new Proxy(stream, {
21
+ get(target, prop, receiver) {
22
+ if (prop === Symbol.asyncIterator)
23
+ return () => gen;
24
+ return Reflect.get(target, prop, receiver);
25
+ },
26
+ }),
27
+ },
28
+ applyCustomSpanAttributes: jest.fn(),
29
+ }));
30
+ jest.mock('@opentelemetry/core', () => ({
31
+ isTracingSuppressed: jest.fn().mockReturnValue(false),
32
+ }));
33
+ const flush = () => new Promise((resolve) => setImmediate(resolve));
34
+ describe('letta wrapper', () => {
35
+ let mockSpan;
36
+ let mockTracer;
37
+ beforeEach(() => {
38
+ mockSpan = {
39
+ setAttribute: jest.fn(),
40
+ setStatus: jest.fn(),
41
+ end: jest.fn(),
42
+ recordException: jest.fn(),
43
+ isRecording: jest.fn().mockReturnValue(true),
44
+ };
45
+ mockTracer = { startSpan: jest.fn(() => mockSpan) };
46
+ config_1.default.environment = 'shield360-testing';
47
+ config_1.default.applicationName = 'shield360-test';
48
+ config_1.default.captureMessageContent = true;
49
+ config_1.default.maxContentLength = null;
50
+ config_1.default.pricingInfo = { chat: {} };
51
+ core_1.isTracingSuppressed.mockReturnValue(false);
52
+ });
53
+ afterEach(() => {
54
+ jest.clearAllMocks();
55
+ });
56
+ function attrs() {
57
+ return Object.fromEntries(mockSpan.setAttribute.mock.calls);
58
+ }
59
+ async function runOp(endpoint, impl, args, agentScoped = true) {
60
+ const wrapped = wrapper_1.default._patchOperation(mockTracer, endpoint, agentScoped, '1.12.1')(impl);
61
+ const result = await wrapped.apply({}, args);
62
+ await flush();
63
+ return result;
64
+ }
65
+ it('opens a create_agent span with agent metadata', async () => {
66
+ const agent = {
67
+ id: 'agent-123',
68
+ name: 'Support Bot',
69
+ agent_type: 'memgpt_agent',
70
+ system: 'You are a helpful assistant.',
71
+ llm_config: { model: 'gpt-4o-mini', provider_name: 'openai', context_window: 8192 },
72
+ };
73
+ await runOp('letta.create', async () => agent, [{ name: 'Support Bot', model: 'gpt-4o-mini' }]);
74
+ expect(mockTracer.startSpan).toHaveBeenCalledWith('create_agent support_bot', {
75
+ kind: api_1.SpanKind.CLIENT,
76
+ attributes: {
77
+ [semantic_convention_1.default.GEN_AI_OPERATION]: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CREATE_AGENT,
78
+ [semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL]: semantic_convention_1.default.GEN_AI_SYSTEM_LETTA,
79
+ },
80
+ });
81
+ const a = attrs();
82
+ expect(a[semantic_conventions_1.ATTR_TELEMETRY_SDK_NAME]).toBe('shield360');
83
+ expect(a[semantic_conventions_1.ATTR_SERVICE_NAME]).toBe('shield360-test');
84
+ expect(a[semantic_convention_1.default.ATTR_DEPLOYMENT_ENVIRONMENT]).toBe('shield360-testing');
85
+ expect(a[semantic_convention_1.default.GEN_AI_PROVIDER_NAME]).toBe('letta');
86
+ expect(a[semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL]).toBe('letta');
87
+ expect(a[semantic_convention_1.default.GEN_AI_OPERATION]).toBe('create_agent');
88
+ expect(a[semantic_convention_1.default.GEN_AI_SDK_VERSION]).toBe('1.12.1');
89
+ expect(a[semantic_convention_1.default.SERVER_ADDRESS]).toBe('api.letta.com');
90
+ expect(a[semantic_convention_1.default.SERVER_PORT]).toBe(443);
91
+ expect(a[semantic_convention_1.default.GEN_AI_AGENT_ID]).toBe('agent-123');
92
+ expect(a[semantic_convention_1.default.GEN_AI_AGENT_NAME]).toBe('Support Bot');
93
+ expect(a[semantic_convention_1.default.GEN_AI_AGENT_TYPE]).toBe('memgpt_agent');
94
+ expect(a[semantic_convention_1.default.GEN_AI_AGENT_INSTRUCTIONS]).toBe('You are a helpful assistant.');
95
+ expect(a[semantic_convention_1.default.GEN_AI_REQUEST_MODEL]).toBe('gpt-4o-mini');
96
+ expect(a[semantic_convention_1.default.GEN_AI_REQUEST_CONTEXT_WINDOW]).toBe(8192);
97
+ expect(typeof a[semantic_convention_1.default.GEN_AI_CLIENT_OPERATION_DURATION]).toBe('number');
98
+ expect(mockSpan.setStatus).toHaveBeenCalledWith({ code: 1 });
99
+ expect(mockSpan.end).toHaveBeenCalledTimes(1);
100
+ });
101
+ it('applies custom span attributes on every span', async () => {
102
+ const { applyCustomSpanAttributes } = jest.requireMock('../../helpers');
103
+ await runOp('letta.retrieve', async () => ({ id: 'agent-1' }), ['agent-1']);
104
+ expect(applyCustomSpanAttributes).toHaveBeenCalledWith(mockSpan);
105
+ });
106
+ it('names a message create span chat {model} and records usage + cost', async () => {
107
+ const response = {
108
+ messages: [{ message_type: 'assistant_message', content: 'Hi there' }],
109
+ usage: { prompt_tokens: 12, completion_tokens: 4, total_tokens: 16, step_count: 1 },
110
+ };
111
+ await runOp('letta.create_message', async () => response, [
112
+ 'agent-1',
113
+ { messages: [{ role: 'user', content: 'hello' }], model: 'gpt-4o' },
114
+ ]);
115
+ expect(mockTracer.startSpan).toHaveBeenCalledWith('chat gpt-4o', {
116
+ kind: api_1.SpanKind.CLIENT,
117
+ attributes: {
118
+ [semantic_convention_1.default.GEN_AI_OPERATION]: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT,
119
+ [semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL]: semantic_convention_1.default.GEN_AI_SYSTEM_LETTA,
120
+ },
121
+ });
122
+ const a = attrs();
123
+ expect(a[semantic_convention_1.default.GEN_AI_OPERATION]).toBe('chat');
124
+ expect(a[semantic_convention_1.default.GEN_AI_AGENT_ID]).toBe('agent-1');
125
+ expect(a[semantic_convention_1.default.GEN_AI_REQUEST_MESSAGE_COUNT]).toBe(1);
126
+ expect(a[semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS]).toBe(12);
127
+ expect(a[semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS]).toBe(4);
128
+ expect(a[semantic_convention_1.default.GEN_AI_USAGE_TOTAL_TOKENS]).toBe(16);
129
+ expect(a[semantic_convention_1.default.GEN_AI_AGENT_STEP_COUNT]).toBe(1);
130
+ expect(a[semantic_convention_1.default.GEN_AI_USAGE_COST]).toBe(0.0025);
131
+ expect(JSON.parse(a[semantic_convention_1.default.GEN_AI_INPUT_MESSAGES])).toEqual([
132
+ { role: 'user', content: 'hello' },
133
+ ]);
134
+ expect(JSON.parse(a[semantic_convention_1.default.GEN_AI_OUTPUT_MESSAGES])).toEqual(response.messages);
135
+ expect(mockSpan.end).toHaveBeenCalledTimes(1);
136
+ });
137
+ it('wraps a streaming message response and records streaming attributes', async () => {
138
+ async function* stream() {
139
+ yield { message_type: 'assistant_message', content: 'Hel' };
140
+ yield { message_type: 'assistant_message', content: 'lo' };
141
+ yield {
142
+ message_type: 'usage_statistics',
143
+ prompt_tokens: 8,
144
+ completion_tokens: 2,
145
+ total_tokens: 10,
146
+ };
147
+ }
148
+ const proxy = await runOp('letta.create_stream', () => stream(), [
149
+ 'agent-1',
150
+ { messages: [{ role: 'user', content: 'hi' }] },
151
+ ]);
152
+ const seen = [];
153
+ for await (const chunk of proxy) {
154
+ seen.push(chunk);
155
+ }
156
+ await flush();
157
+ expect(seen).toHaveLength(3);
158
+ const a = attrs();
159
+ expect(a[semantic_convention_1.default.GEN_AI_OPERATION]).toBe('chat');
160
+ expect(a[semantic_convention_1.default.GEN_AI_STREAMING_CHUNK_COUNT]).toBe(3);
161
+ expect(a[semantic_convention_1.default.GEN_AI_STREAMING_RESPONSE_COUNT]).toBe(3);
162
+ expect(a[semantic_convention_1.default.GEN_AI_REQUEST_IS_STREAM]).toBe(true);
163
+ expect(a[semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS]).toBe(8);
164
+ expect(a[semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS]).toBe(2);
165
+ expect(mockSpan.setStatus).toHaveBeenCalledWith({ code: 1 });
166
+ expect(mockSpan.end).toHaveBeenCalledTimes(1);
167
+ });
168
+ it('names list operations workflow {method}', async () => {
169
+ await runOp('letta.list', async () => [{ id: 'b1' }, { id: 'b2' }], [{}]);
170
+ expect(mockTracer.startSpan).toHaveBeenCalledWith('workflow list', expect.objectContaining({ kind: api_1.SpanKind.CLIENT }));
171
+ expect(attrs()[semantic_convention_1.default.GEN_AI_OPERATION]).toBe('workflow');
172
+ });
173
+ it('names attach/detach operations tool {method} with execute_tool op', async () => {
174
+ await runOp('letta.attach', async () => ({ id: 'agent-1' }), ['tool-1', { agent_id: 'agent-1' }]);
175
+ expect(mockTracer.startSpan).toHaveBeenCalledWith('tool attach', expect.objectContaining({ kind: api_1.SpanKind.CLIENT }));
176
+ expect(attrs()[semantic_convention_1.default.GEN_AI_OPERATION]).toBe('execute_tool');
177
+ });
178
+ it('records the exception, ends the span, and rethrows on a chat error', async () => {
179
+ const boom = new Error('letta down');
180
+ const wrapped = wrapper_1.default._patchOperation(mockTracer, 'letta.create_message', true)(async () => {
181
+ throw boom;
182
+ });
183
+ await expect(wrapped.apply({}, ['agent-1', { messages: [] }])).rejects.toThrow('letta down');
184
+ expect(helpers_1.default.handleException).toHaveBeenCalledWith(mockSpan, boom);
185
+ expect(mockSpan.end).toHaveBeenCalledTimes(1);
186
+ expect(attrs()[semantic_convention_1.default.GEN_AI_PROVIDER_NAME]).toBe('letta');
187
+ });
188
+ it('ends the stream span exactly once when the consumer breaks early', async () => {
189
+ async function* stream() {
190
+ yield { message_type: 'assistant_message', content: 'one' };
191
+ yield { message_type: 'assistant_message', content: 'two' };
192
+ }
193
+ const proxy = await runOp('letta.create_stream', () => stream(), [
194
+ 'agent-1',
195
+ { messages: [{ role: 'user', content: 'hi' }] },
196
+ ]);
197
+ for await (const _chunk of proxy) {
198
+ break;
199
+ }
200
+ await flush();
201
+ expect(mockSpan.end).toHaveBeenCalledTimes(1);
202
+ });
203
+ it('does not treat a top-level resource id as an agent id', async () => {
204
+ await runOp('letta.retrieve', async () => ({ label: 'persona' }), ['block-id'], false);
205
+ expect(attrs()[semantic_convention_1.default.GEN_AI_AGENT_ID]).not.toBe('block-id');
206
+ });
207
+ it('maps an agent update to the invoke_agent operation', async () => {
208
+ await runOp('letta.modify', async () => ({ id: 'agent-1' }), ['agent-1', { name: 'renamed' }]);
209
+ expect(attrs()[semantic_convention_1.default.GEN_AI_OPERATION]).toBe('invoke_agent');
210
+ });
211
+ it('rejects and ends the span on a non-chat operation error', async () => {
212
+ const boom = new Error('list failed');
213
+ const wrapped = wrapper_1.default._patchOperation(mockTracer, 'letta.list', false)(async () => {
214
+ throw boom;
215
+ });
216
+ await expect(wrapped.apply({}, [{}])).rejects.toThrow('list failed');
217
+ await flush();
218
+ expect(helpers_1.default.handleException).toHaveBeenCalledWith(mockSpan, boom);
219
+ expect(mockSpan.end).toHaveBeenCalledTimes(1);
220
+ });
221
+ it('bypasses instrumentation when tracing is suppressed', async () => {
222
+ core_1.isTracingSuppressed.mockReturnValue(true);
223
+ const original = jest.fn().mockResolvedValue({ id: 'agent-1' });
224
+ const wrapped = wrapper_1.default._patchOperation(mockTracer, 'letta.create', false)(original);
225
+ await wrapped.apply({}, [{ name: 'bot' }]);
226
+ expect(original).toHaveBeenCalled();
227
+ expect(mockTracer.startSpan).not.toHaveBeenCalled();
228
+ });
229
+ });
230
+ describe('LettaInstrumentation patch targets', () => {
231
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
232
+ const { isWrapped } = require('@opentelemetry/instrumentation');
233
+ it('wraps resource-client prototype methods via manualPatch', () => {
234
+ class Agents {
235
+ async create() {
236
+ return null;
237
+ }
238
+ async retrieve() {
239
+ return null;
240
+ }
241
+ async update() {
242
+ return null;
243
+ }
244
+ async delete() {
245
+ return null;
246
+ }
247
+ async list() {
248
+ return null;
249
+ }
250
+ }
251
+ class Messages {
252
+ async create() {
253
+ return null;
254
+ }
255
+ async stream() {
256
+ return null;
257
+ }
258
+ async createAsync() {
259
+ return null;
260
+ }
261
+ async list() {
262
+ return null;
263
+ }
264
+ async cancel() {
265
+ return null;
266
+ }
267
+ async reset() {
268
+ return null;
269
+ }
270
+ }
271
+ const fakeModule = { Agents, Messages };
272
+ const instrumentation = new letta_1.default();
273
+ instrumentation.manualPatch(fakeModule);
274
+ for (const method of ['create', 'retrieve', 'update', 'delete', 'list']) {
275
+ expect(isWrapped(Agents.prototype[method])).toBe(true);
276
+ }
277
+ for (const method of ['create', 'stream', 'createAsync', 'list', 'cancel', 'reset']) {
278
+ expect(isWrapped(Messages.prototype[method])).toBe(true);
279
+ }
280
+ // Idempotent: a second patch must not throw or rewrap.
281
+ instrumentation.manualPatch(fakeModule);
282
+ expect(isWrapped(Agents.prototype.create)).toBe(true);
283
+ });
284
+ });
285
+ //# sourceMappingURL=letta-wrapper.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"letta-wrapper.test.js","sourceRoot":"","sources":["../../../src/instrumentation/__tests__/letta-wrapper.test.ts"],"names":[],"mappings":";;;;;AAAA,4CAA8C;AAC9C,8CAA0D;AAC1D,8EAAiG;AACjG,0DAA2C;AAC3C,4DAA4C;AAC5C,oFAA2D;AAC3D,+DAA4C;AAC5C,qDAA4C;AAE5C,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AAC1B,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC;IAChC,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE;QACP,eAAe,EAAE,IAAI,CAAC,EAAE,EAAE;QAC1B,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC;QACnD,iBAAiB,EAAE,KAAK,EAAE,MAAW,EAAE,GAAQ,EAAE,EAAE,CACjD,IAAI,KAAK,CAAC,MAAM,EAAE;YAChB,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ;gBACxB,IAAI,IAAI,KAAK,MAAM,CAAC,aAAa;oBAAE,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC;gBACpD,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,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+ /**
2
+ * Cross-Language Trace Comparison Tests for the mem0 Integration
3
+ *
4
+ * These verify that the TypeScript mem0 instrumentation emits the same spans /
5
+ * attributes as the Python SDK reference
6
+ * (sdk/python/src/shield360/instrumentation/mem0). mem0 is a memory layer, not an LLM
7
+ * provider: each operation (add / search / get / getAll / update / delete /
8
+ * deleteAll / history) becomes one CLIENT span named `memory <op>` carrying
9
+ * `gen_ai.*` attributes. There are no tokens, model, cost, or metrics. The same
10
+ * wrapper serves both the hosted `MemoryClient` and the OSS `Memory` clients, whose
11
+ * method surfaces are identical.
12
+ */
13
+ export {};