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,180 @@
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 helpers_1 = __importDefault(require("../../helpers"));
9
+ const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
10
+ const utils_1 = require("./utils");
11
+ let lettaSdkVersion = 'unknown';
12
+ try {
13
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
14
+ lettaSdkVersion = require('@letta-ai/letta-client/version').VERSION || 'unknown';
15
+ }
16
+ catch {
17
+ lettaSdkVersion = 'unknown';
18
+ }
19
+ /**
20
+ * Splits Letta method arguments into the request body and, for agent-scoped
21
+ * resources, the leading agent id. A leading string on a top-level resource is
22
+ * that resource's own id, so it is never treated as an agent id.
23
+ */
24
+ function resolveArgs(args, agentScoped) {
25
+ const agentId = agentScoped && typeof args[0] === 'string' ? args[0] : undefined;
26
+ const body = args.find((arg) => arg && typeof arg === 'object' && !Array.isArray(arg));
27
+ return { body, agentId };
28
+ }
29
+ function isAsyncIterable(value) {
30
+ return value != null && typeof value[Symbol.asyncIterator] === 'function';
31
+ }
32
+ /**
33
+ * Instrumentation for the Letta agent platform (`@letta-ai/letta-client`). Each
34
+ * patched resource method becomes one CLIENT span whose name and operation type
35
+ * mirror the Python reference (sdk/python/src/shield360/instrumentation/letta): the
36
+ * method suffix drives the operation type via OPERATION_TYPE_MAP, and chat
37
+ * (message) operations stream their response through a traced async iterator.
38
+ */
39
+ class LettaWrapper {
40
+ /**
41
+ * Wraps a Letta resource method. `endpoint` is the Python-style endpoint id
42
+ * (e.g. `letta.create`, `letta.create_message`) that drives the operation type
43
+ * and span name.
44
+ */
45
+ static _patchOperation(tracer, endpoint, agentScoped, version) {
46
+ const sdkVersion = version || lettaSdkVersion;
47
+ const operationType = (0, utils_1.getOperationType)(endpoint);
48
+ return (originalMethod) => {
49
+ return function (...args) {
50
+ if ((0, core_1.isTracingSuppressed)(api_1.context.active())) {
51
+ return originalMethod.apply(this, args);
52
+ }
53
+ const { body, agentId } = resolveArgs(args, agentScoped);
54
+ const spanBody = agentId && (!body || body.agent_id == null) ? { ...(body || {}), agent_id: agentId } : body;
55
+ const spanName = (0, utils_1.getSpanName)(operationType, endpoint, this, spanBody);
56
+ const span = tracer.startSpan(spanName, {
57
+ kind: api_1.SpanKind.CLIENT,
58
+ attributes: {
59
+ [semantic_convention_1.default.GEN_AI_OPERATION]: operationType,
60
+ [semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL]: LettaWrapper.aiSystem,
61
+ },
62
+ });
63
+ const startTime = Date.now();
64
+ if (operationType === semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT) {
65
+ return LettaWrapper._handleChat(originalMethod, this, args, span, startTime, body, operationType, sdkVersion, agentId);
66
+ }
67
+ return LettaWrapper._handleOperation(originalMethod, this, args, span, startTime, body, operationType, sdkVersion, agentId);
68
+ };
69
+ };
70
+ }
71
+ /**
72
+ * Non-chat operations return the SDK's own promise untouched. `list` yields a
73
+ * PagePromise whose async iterator drives auto-pagination, so flattening it here
74
+ * would break paging; the span is finalized from a completion callback instead.
75
+ */
76
+ static _handleOperation(originalMethod, instance, args, span, startTime, body, operationType, sdkVersion, agentId) {
77
+ return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), () => {
78
+ let result;
79
+ try {
80
+ result = originalMethod.apply(instance, args);
81
+ }
82
+ catch (e) {
83
+ LettaWrapper._finalizeError(span, e, body, operationType, instance, startTime, sdkVersion, agentId);
84
+ throw e;
85
+ }
86
+ Promise.resolve(result).then((response) => {
87
+ (0, utils_1.processLettaResponse)(span, response, body, operationType, instance, (Date.now() - startTime) / 1000, sdkVersion, agentId);
88
+ span.setStatus({ code: api_1.SpanStatusCode.OK });
89
+ span.end();
90
+ }, (e) => {
91
+ LettaWrapper._finalizeError(span, e, body, operationType, instance, startTime, sdkVersion, agentId);
92
+ });
93
+ return result;
94
+ });
95
+ }
96
+ /**
97
+ * Chat (message) operations may resolve to a streaming iterator. The resolved
98
+ * value is awaited so a stream can be wrapped in a traced async iterator; a
99
+ * non-streaming response is processed inline.
100
+ */
101
+ static async _handleChat(originalMethod, instance, args, span, startTime, body, operationType, sdkVersion, agentId) {
102
+ return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), async () => {
103
+ try {
104
+ const resolved = await originalMethod.apply(instance, args);
105
+ if (isAsyncIterable(resolved)) {
106
+ return LettaWrapper._traceStream(resolved, span, startTime, body, operationType, instance, sdkVersion, agentId);
107
+ }
108
+ (0, utils_1.processLettaResponse)(span, resolved, body, operationType, instance, (Date.now() - startTime) / 1000, sdkVersion, agentId);
109
+ span.setStatus({ code: api_1.SpanStatusCode.OK });
110
+ span.end();
111
+ return resolved;
112
+ }
113
+ catch (e) {
114
+ LettaWrapper._finalizeError(span, e, body, operationType, instance, startTime, sdkVersion, agentId);
115
+ throw e;
116
+ }
117
+ });
118
+ }
119
+ /**
120
+ * Wraps a Letta message stream so chunks flow through untouched while the span
121
+ * accumulates chunk count, TTFT, and the collected messages. Mirrors
122
+ * TracedLettaStream in the Python reference.
123
+ */
124
+ static _traceStream(stream, span, startTime, body, operationType, instance, sdkVersion, agentId) {
125
+ async function* traced() {
126
+ let chunkCount = 0;
127
+ let ttft = 0;
128
+ const messages = [];
129
+ try {
130
+ for await (const chunk of stream) {
131
+ chunkCount += 1;
132
+ if (chunkCount === 1) {
133
+ ttft = (Date.now() - startTime) / 1000;
134
+ }
135
+ messages.push(chunk);
136
+ if (span.isRecording()) {
137
+ span.setAttribute(semantic_convention_1.default.GEN_AI_STREAMING_CHUNK_COUNT, chunkCount);
138
+ if (ttft > 0)
139
+ span.setAttribute(semantic_convention_1.default.GEN_AI_SERVER_TTFT, ttft);
140
+ }
141
+ yield chunk;
142
+ }
143
+ const synthetic = { messages };
144
+ for (const msg of messages) {
145
+ if (msg?.message_type === 'usage_statistics') {
146
+ synthetic.usage = msg;
147
+ break;
148
+ }
149
+ }
150
+ (0, utils_1.processLettaResponse)(span, synthetic, body, operationType, instance, (Date.now() - startTime) / 1000, sdkVersion, agentId);
151
+ span.setAttribute(semantic_convention_1.default.GEN_AI_STREAMING_CHUNK_COUNT, chunkCount);
152
+ span.setAttribute(semantic_convention_1.default.GEN_AI_SERVER_TTFT, ttft);
153
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_IS_STREAM, true);
154
+ span.setAttribute(semantic_convention_1.default.GEN_AI_STREAMING_RESPONSE_COUNT, messages.length);
155
+ span.setStatus({ code: api_1.SpanStatusCode.OK });
156
+ }
157
+ catch (e) {
158
+ helpers_1.default.handleException(span, e);
159
+ throw e;
160
+ }
161
+ finally {
162
+ span.end();
163
+ }
164
+ }
165
+ return helpers_1.default.createStreamProxy(stream, traced());
166
+ }
167
+ static _finalizeError(span, error, body, operationType, instance, startTime, sdkVersion, agentId) {
168
+ try {
169
+ (0, utils_1.processLettaResponse)(span, undefined, body, operationType, instance, (Date.now() - startTime) / 1000, sdkVersion, agentId);
170
+ }
171
+ catch {
172
+ /* best-effort attributes on the error path */
173
+ }
174
+ helpers_1.default.handleException(span, error);
175
+ span.end();
176
+ }
177
+ }
178
+ LettaWrapper.aiSystem = semantic_convention_1.default.GEN_AI_SYSTEM_LETTA;
179
+ exports.default = LettaWrapper;
180
+ //# sourceMappingURL=wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../../src/instrumentation/letta/wrapper.ts"],"names":[],"mappings":";;;;;AAAA,4CAA4F;AAC5F,8CAA0D;AAC1D,4DAA4C;AAC5C,oFAA2D;AAC3D,mCAA8E;AAE9E,IAAI,eAAe,GAAG,SAAS,CAAC;AAChC,IAAI,CAAC;IACH,8DAA8D;IAC9D,eAAe,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC,OAAO,IAAI,SAAS,CAAC;AACnF,CAAC;AAAC,MAAM,CAAC;IACP,eAAe,GAAG,SAAS,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,IAAW,EAAE,WAAoB;IACpD,MAAM,OAAO,GAAG,WAAW,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACjF,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IACvF,OAAO,EAAE,IAAI,EAAE,OAAO,EA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,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7D,CAAC;IAEO,MAAM,CAAC,cAAc,CAC3B,IAAU,EACV,KAAU,EACV,IAAS,EACT,aAAqB,EACrB,QAAa,EACb,SAAiB,EACjB,UAAkB,EAClB,OAAgB;QAEhB,IAAI,CAAC;YACH,IAAA,4BAAoB,EAClB,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,aAAa,EACb,QAAQ,EACR,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,EAC/B,UAAU,EACV,OAAO,CACR,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,8CAA8C;QAChD,CAAC;QACD,iBAAe,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC7C,IAAI,CAAC,GAAG,EAAE,CAAC;IACb,CAAC;;AArQM,qBAAQ,GAAG,6BAAkB,CAAC,mBAAmB,CAAC;AAwQ3D,kBAAe,YAAY,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Shield360 LlamaIndex Instrumentation
3
+ *
4
+ * Monkey-patches LlamaIndex JS classes to emit OTel-compliant telemetry.
5
+ * Mirrors the Python SDK: sdk/python/src/shield360/instrumentation/llamaindex/__init__.py
6
+ *
7
+ * Targets the `llamaindex` npm package (>=0.3.0).
8
+ * Patches: LLM classes, query engines, chat engines, retrievers, embeddings,
9
+ * index construction, document loaders, splitters, and synthesizers.
10
+ */
11
+ import { InstrumentationBase, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';
12
+ import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
13
+ export default class Shield360LlamaIndexInstrumentation extends InstrumentationBase {
14
+ constructor(config?: InstrumentationConfig);
15
+ protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[];
16
+ manualPatch(llamaindex: any): void;
17
+ /**
18
+ * Wrap an instance method on the first class found that exposes it.
19
+ * Silently skips classes that aren't exported or don't have the method.
20
+ */
21
+ private _patchProto;
22
+ /**
23
+ * Wrap a static method on a class.
24
+ */
25
+ private _patchStatic;
26
+ /**
27
+ * Unwrap an instance method if it's wrapped.
28
+ */
29
+ private _unwrapProto;
30
+ /**
31
+ * Unwrap a static method if it's wrapped.
32
+ */
33
+ private _unwrapStatic;
34
+ protected _patch(m: any): void;
35
+ protected _unpatch(m: any): void;
36
+ }
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ /**
3
+ * Shield360 LlamaIndex Instrumentation
4
+ *
5
+ * Monkey-patches LlamaIndex JS classes to emit OTel-compliant telemetry.
6
+ * Mirrors the Python SDK: sdk/python/src/shield360/instrumentation/llamaindex/__init__.py
7
+ *
8
+ * Targets the `llamaindex` npm package (>=0.3.0).
9
+ * Patches: LLM classes, query engines, chat engines, retrievers, embeddings,
10
+ * index construction, document loaders, splitters, and synthesizers.
11
+ */
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ const instrumentation_1 = require("@opentelemetry/instrumentation");
17
+ const constant_1 = require("../../constant");
18
+ const wrapper_1 = __importDefault(require("./wrapper"));
19
+ class Shield360LlamaIndexInstrumentation extends instrumentation_1.InstrumentationBase {
20
+ constructor(config = {}) {
21
+ super(`${constant_1.INSTRUMENTATION_PREFIX}/instrumentation-llamaindex`, '1.0.0', config);
22
+ }
23
+ init() {
24
+ const mainModule = new instrumentation_1.InstrumentationNodeModuleDefinition('llamaindex', ['>=0.3.0'], (moduleExports) => {
25
+ this._patch(moduleExports);
26
+ return moduleExports;
27
+ }, (moduleExports) => {
28
+ if (moduleExports)
29
+ this._unpatch(moduleExports);
30
+ });
31
+ return [mainModule];
32
+ }
33
+ manualPatch(llamaindex) {
34
+ this._patch(llamaindex);
35
+ }
36
+ // ---------------------------------------------------------------------------
37
+ // Patch helpers
38
+ // ---------------------------------------------------------------------------
39
+ /**
40
+ * Wrap an instance method on the first class found that exposes it.
41
+ * Silently skips classes that aren't exported or don't have the method.
42
+ */
43
+ _patchProto(moduleExports, classNames, method, wrapper) {
44
+ for (const name of classNames) {
45
+ const Cls = moduleExports[name];
46
+ if (Cls?.prototype?.[method] && !(0, instrumentation_1.isWrapped)(Cls.prototype[method])) {
47
+ try {
48
+ this._wrap(Cls.prototype, method, wrapper);
49
+ }
50
+ catch { /* skip silently */ }
51
+ }
52
+ }
53
+ }
54
+ /**
55
+ * Wrap a static method on a class.
56
+ */
57
+ _patchStatic(Cls, method, wrapper) {
58
+ if (typeof Cls?.[method] === 'function' && !(0, instrumentation_1.isWrapped)(Cls[method])) {
59
+ try {
60
+ this._wrap(Cls, method, wrapper);
61
+ }
62
+ catch { /* skip silently */ }
63
+ }
64
+ }
65
+ /**
66
+ * Unwrap an instance method if it's wrapped.
67
+ */
68
+ _unwrapProto(moduleExports, classNames, method) {
69
+ for (const name of classNames) {
70
+ const Cls = moduleExports[name];
71
+ if (Cls?.prototype?.[method] && (0, instrumentation_1.isWrapped)(Cls.prototype[method])) {
72
+ try {
73
+ this._unwrap(Cls.prototype, method);
74
+ }
75
+ catch { /* ignore */ }
76
+ }
77
+ }
78
+ }
79
+ /**
80
+ * Unwrap a static method if it's wrapped.
81
+ */
82
+ _unwrapStatic(Cls, method) {
83
+ if (Cls && typeof Cls[method] === 'function' && (0, instrumentation_1.isWrapped)(Cls[method])) {
84
+ try {
85
+ this._unwrap(Cls, method);
86
+ }
87
+ catch { /* ignore */ }
88
+ }
89
+ }
90
+ // ---------------------------------------------------------------------------
91
+ // Main patch — mirrors Python _instrument() operation lists
92
+ // ---------------------------------------------------------------------------
93
+ _patch(m) {
94
+ try {
95
+ const tracer = this.tracer;
96
+ // === LLM OPERATIONS (chat spans) ===
97
+ // Mirrors Python: LLM.chat, LLM.complete
98
+ const llmClasses = [
99
+ 'OpenAI', 'Anthropic', 'Ollama', 'Gemini', 'Groq',
100
+ 'HuggingFaceInference', 'Replicate', 'DeepSeek', 'Portkey',
101
+ 'BaseLLM', 'LLM',
102
+ ];
103
+ this._patchProto(m, llmClasses, 'chat', wrapper_1.default._patchLLMChat(tracer));
104
+ this._patchProto(m, llmClasses, 'complete', wrapper_1.default._patchLLMComplete(tracer));
105
+ // === QUERY ENGINE OPERATIONS (retrieval spans) ===
106
+ // Mirrors Python: RetrieverQueryEngine.query, TransformQueryEngine.query
107
+ const queryEngineClasses = [
108
+ 'RetrieverQueryEngine', 'TransformQueryEngine',
109
+ 'SubQuestionQueryEngine', 'BaseQueryEngine', 'QueryEngine',
110
+ ];
111
+ this._patchProto(m, queryEngineClasses, 'query', wrapper_1.default._patchQueryEngineQuery(tracer));
112
+ // === CHAT ENGINE OPERATIONS (invoke_workflow spans) ===
113
+ const chatEngineClasses = [
114
+ 'ContextChatEngine', 'SimpleChatEngine',
115
+ 'CondenseQuestionChatEngine', 'BaseChatEngine', 'ChatEngine',
116
+ ];
117
+ this._patchProto(m, chatEngineClasses, 'chat', wrapper_1.default._patchChatEngineChat(tracer));
118
+ // === RETRIEVER OPERATIONS (retrieval spans) ===
119
+ // Mirrors Python: VectorIndexRetriever.retrieve, BaseRetriever.retrieve
120
+ const retrieverClasses = [
121
+ 'VectorIndexRetriever', 'BaseRetriever', 'Retriever',
122
+ ];
123
+ this._patchProto(m, retrieverClasses, 'retrieve', wrapper_1.default._patchRetrieverRetrieve(tracer));
124
+ // === EMBEDDING OPERATIONS (embeddings spans) ===
125
+ // Mirrors Python: BaseEmbedding.get_text_embedding_batch
126
+ const embeddingClasses = [
127
+ 'OpenAIEmbedding', 'BaseEmbedding', 'HuggingFaceEmbedding',
128
+ ];
129
+ this._patchProto(m, embeddingClasses, 'getTextEmbedding', wrapper_1.default._patchEmbedding(tracer, 'embedding_generate'));
130
+ this._patchProto(m, embeddingClasses, 'getQueryEmbedding', wrapper_1.default._patchEmbedding(tracer, 'embedding_generate'));
131
+ this._patchProto(m, embeddingClasses, 'getTextEmbeddingsBatch', wrapper_1.default._patchEmbedding(tracer, 'embedding_generate'));
132
+ // === INDEX OPERATIONS (invoke_workflow spans) ===
133
+ // Mirrors Python: VectorStoreIndex.from_documents, from_vector_store
134
+ const indexClasses = ['VectorStoreIndex', 'ListIndex', 'TreeIndex'];
135
+ for (const name of indexClasses) {
136
+ const Cls = m[name];
137
+ if (Cls) {
138
+ this._patchStatic(Cls, 'fromDocuments', wrapper_1.default._patchFrameworkMethod(tracer, 'index_construct'));
139
+ this._patchStatic(Cls, 'fromVectorStore', wrapper_1.default._patchFrameworkMethod(tracer, 'index_construct'));
140
+ }
141
+ }
142
+ // Mirrors Python: BaseIndex.as_query_engine, BaseIndex.as_retriever
143
+ const indexProtoClasses = [
144
+ 'VectorStoreIndex', 'ListIndex', 'TreeIndex', 'BaseIndex',
145
+ ];
146
+ this._patchProto(m, indexProtoClasses, 'asQueryEngine', wrapper_1.default._patchFrameworkMethod(tracer, 'query_engine_create'));
147
+ this._patchProto(m, indexProtoClasses, 'asRetriever', wrapper_1.default._patchFrameworkMethod(tracer, 'retriever_create'));
148
+ // === DOCUMENT OPERATIONS (framework / retrieval spans) ===
149
+ // Mirrors Python: SimpleDirectoryReader.load_data
150
+ this._patchProto(m, ['SimpleDirectoryReader'], 'loadData', wrapper_1.default._patchFrameworkMethod(tracer, 'document_load'));
151
+ // Mirrors Python: SentenceSplitter.get_nodes_from_documents
152
+ this._patchProto(m, ['SentenceSplitter', 'NodeParser'], 'getNodesFromDocuments', wrapper_1.default._patchFrameworkMethod(tracer, 'document_split'));
153
+ // Mirrors Python: SentenceSplitter.split_text
154
+ this._patchProto(m, ['SentenceSplitter'], 'splitText', wrapper_1.default._patchFrameworkMethod(tracer, 'text_splitter_split'));
155
+ // === SYNTHESIZER OPERATIONS (chat spans) ===
156
+ // Mirrors Python: BaseSynthesizer.synthesize
157
+ const synthesizerClasses = [
158
+ 'ResponseSynthesizer', 'CompactAndRefine', 'TreeSummarize',
159
+ 'BaseSynthesizer',
160
+ ];
161
+ this._patchProto(m, synthesizerClasses, 'synthesize', wrapper_1.default._patchFrameworkMethod(tracer, 'response_synthesize'));
162
+ // === POSTPROCESSOR OPERATIONS (framework spans) ===
163
+ this._patchProto(m, ['BaseNodePostprocessor', 'NodePostprocessor'], 'postprocessNodes', wrapper_1.default._patchFrameworkMethod(tracer, 'postprocessor_process'));
164
+ }
165
+ catch { /* graceful degradation — do not break the application */ }
166
+ }
167
+ // ---------------------------------------------------------------------------
168
+ // Unpatch
169
+ // ---------------------------------------------------------------------------
170
+ _unpatch(m) {
171
+ try {
172
+ const llmClasses = [
173
+ 'OpenAI', 'Anthropic', 'Ollama', 'Gemini', 'Groq',
174
+ 'HuggingFaceInference', 'Replicate', 'DeepSeek', 'Portkey',
175
+ 'BaseLLM', 'LLM',
176
+ ];
177
+ this._unwrapProto(m, llmClasses, 'chat');
178
+ this._unwrapProto(m, llmClasses, 'complete');
179
+ const queryEngineClasses = [
180
+ 'RetrieverQueryEngine', 'TransformQueryEngine',
181
+ 'SubQuestionQueryEngine', 'BaseQueryEngine', 'QueryEngine',
182
+ ];
183
+ this._unwrapProto(m, queryEngineClasses, 'query');
184
+ const chatEngineClasses = [
185
+ 'ContextChatEngine', 'SimpleChatEngine',
186
+ 'CondenseQuestionChatEngine', 'BaseChatEngine', 'ChatEngine',
187
+ ];
188
+ this._unwrapProto(m, chatEngineClasses, 'chat');
189
+ const retrieverClasses = ['VectorIndexRetriever', 'BaseRetriever', 'Retriever'];
190
+ this._unwrapProto(m, retrieverClasses, 'retrieve');
191
+ const embeddingClasses = ['OpenAIEmbedding', 'BaseEmbedding', 'HuggingFaceEmbedding'];
192
+ this._unwrapProto(m, embeddingClasses, 'getTextEmbedding');
193
+ this._unwrapProto(m, embeddingClasses, 'getQueryEmbedding');
194
+ this._unwrapProto(m, embeddingClasses, 'getTextEmbeddingsBatch');
195
+ const indexClasses = ['VectorStoreIndex', 'ListIndex', 'TreeIndex'];
196
+ for (const name of indexClasses) {
197
+ const Cls = m[name];
198
+ if (Cls) {
199
+ this._unwrapStatic(Cls, 'fromDocuments');
200
+ this._unwrapStatic(Cls, 'fromVectorStore');
201
+ }
202
+ }
203
+ const indexProtoClasses = [
204
+ 'VectorStoreIndex', 'ListIndex', 'TreeIndex', 'BaseIndex',
205
+ ];
206
+ this._unwrapProto(m, indexProtoClasses, 'asQueryEngine');
207
+ this._unwrapProto(m, indexProtoClasses, 'asRetriever');
208
+ this._unwrapProto(m, ['SimpleDirectoryReader'], 'loadData');
209
+ this._unwrapProto(m, ['SentenceSplitter', 'NodeParser'], 'getNodesFromDocuments');
210
+ this._unwrapProto(m, ['SentenceSplitter'], 'splitText');
211
+ const synthesizerClasses = [
212
+ 'ResponseSynthesizer', 'CompactAndRefine', 'TreeSummarize', 'BaseSynthesizer',
213
+ ];
214
+ this._unwrapProto(m, synthesizerClasses, 'synthesize');
215
+ this._unwrapProto(m, ['BaseNodePostprocessor', 'NodePostprocessor'], 'postprocessNodes');
216
+ }
217
+ catch { /* ignore */ }
218
+ }
219
+ }
220
+ exports.default = Shield360LlamaIndexInstrumentation;
221
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/instrumentation/llamaindex/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;AAEH,oEAKwC;AAExC,6CAAwD;AACxD,wDAA0C;AAE1C,MAAqB,kCAAmC,SAAQ,qCAAmB;IACjF,YAAY,SAAgC,EAAE;QAC5C,KAAK,CAAC,GAAG,iCAAsB,6BAA6B,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACjF,CAAC;IAES,IAAI;QAIZ,MAAM,UAAU,GAAG,IAAI,qDAAmC,CACxD,YAAY,EACZ,CAAC,SAAS,CAAC,EACX,CAAC,aAAa,EAAE,EAAE;YAChB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YAC3B,OAAO,aAAa,CAAC;QACvB,CAAC,EACD,CAAC,aAAa,EAAE,EAAE;YAChB,IAAI,aAAa;gBAAE,IAAI,CAAC,Q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F,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,iBAAiB,EAAE,eAAe,CAAC,CAAC;YACzD,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;YAEvD,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,uBAAuB,CAAC,EAAE,UAAU,CAAC,CAAC;YAC5D,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,kBAAkB,EAAE,YAAY,CAAC,EAAE,uBAAuB,CAAC,CAAC;YAClF,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,kBAAkB,CAAC,EAAE,WAAW,CAAC,CAAC;YAExD,MAAM,kBAAkB,GAAG;gBACzB,qBAAqB,EAAE,kBAAkB,EAAE,eAAe,EAAE,iBAAiB;aAC9E,CAAC;YACF,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,kBAAkB,EAAE,YAAY,CAAC,CAAC;YAEvD,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,uBAAuB,EAAE,mBAAmB,CAAC,EAAE,kBAAkB,CAAC,CAAC;QAC3F,CAAC;QAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IAC1B,CAAC;CACF;AAzQD,qDAyQC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Shield360 LlamaIndex Wrapper
3
+ *
4
+ * Mirrors Python SDK: sdk/python/src/shield360/instrumentation/llamaindex/
5
+ * Uses the same OPERATION_MAP and span semantics as the Python implementation.
6
+ *
7
+ * LLM operations get full provider-style telemetry (attributes, events, metrics).
8
+ * Framework operations (query engine, retriever, index, etc.) get framework-level spans.
9
+ */
10
+ import { Tracer, Span } from '@opentelemetry/api';
11
+ export default class LlamaIndexWrapper {
12
+ static aiSystem: string;
13
+ /**
14
+ * Stamp `shield360.agent.version_hash` (auto) and `gen_ai.agent.version`
15
+ * (user override, if set) on the span and return the same attributes so
16
+ * the caller can merge them into the inference event extras.
17
+ */
18
+ static _stampAgentVersion(span: Span, args: {
19
+ systemInstructionsJson?: string;
20
+ toolDefinitionsJson?: string;
21
+ primaryModel?: string;
22
+ temperature?: number | null;
23
+ top_p?: number | null;
24
+ max_tokens?: number | null;
25
+ }): Record<string, string>;
26
+ private static _extractModel;
27
+ private static _extractServerInfo;
28
+ static _patchLLMChat(tracer: Tracer): any;
29
+ static _patchLLMComplete(tracer: Tracer): any;
30
+ private static _processLLMResponse;
31
+ static _patchQueryEngineQuery(tracer: Tracer): any;
32
+ static _patchChatEngineChat(tracer: Tracer): any;
33
+ static _patchRetrieverRetrieve(tracer: Tracer): any;
34
+ static _patchEmbedding(tracer: Tracer, endpoint?: string): any;
35
+ static _patchFrameworkMethod(tracer: Tracer, endpoint: string): any;
36
+ }