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,371 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const instrumentation_1 = require("@opentelemetry/instrumentation");
7
+ const api_1 = require("@opentelemetry/api");
8
+ const constant_1 = require("../../constant");
9
+ const utils_1 = require("./utils");
10
+ const wrapper_1 = require("./wrapper");
11
+ const config_1 = __importDefault(require("../../config"));
12
+ /**
13
+ * OTel GenAI semantic convention compliant instrumentor for Google ADK.
14
+ *
15
+ * Monkey-patches Runner, BaseAgent, and LlmAgent from @google/adk.
16
+ * Replaces ADK's internal tracers with PassthroughTracer to suppress
17
+ * duplicate spans. Enriches ADK's LLM and tool spans with OTel attributes.
18
+ */
19
+ class GoogleADKInstrumentation extends instrumentation_1.InstrumentationBase {
20
+ constructor(config = {}) {
21
+ super(`${constant_1.INSTRUMENTATION_PREFIX}/instrumentation-google-adk`, '1.0.0', config);
22
+ this._registry = new wrapper_1.AgentCreationRegistry();
23
+ this._originalTracers = {};
24
+ this._originalTraceCallLlm = null;
25
+ this._originalTraceToolCall = null;
26
+ this._originalTraceMergedToolCalls = null;
27
+ }
28
+ init() {
29
+ const module = new instrumentation_1.InstrumentationNodeModuleDefinition('@google/adk', ['>=1.2.0'], (moduleExports) => {
30
+ this._patchAll(moduleExports);
31
+ return moduleExports;
32
+ }, (moduleExports) => {
33
+ if (moduleExports !== undefined) {
34
+ this._unpatchAll(moduleExports);
35
+ }
36
+ });
37
+ return [module];
38
+ }
39
+ manualPatch(adkModule) {
40
+ this._patchAll(adkModule);
41
+ }
42
+ // ---------------------------------------------------------------------------
43
+ // Patching
44
+ // ---------------------------------------------------------------------------
45
+ _patchAll(moduleExports) {
46
+ try {
47
+ this._disableExistingTracers(moduleExports);
48
+ this._wrapTraceCallLlm(moduleExports);
49
+ this._wrapTraceToolCall(moduleExports);
50
+ this._wrapTraceMergedToolCalls(moduleExports);
51
+ this._patchLlmAgent(moduleExports);
52
+ this._patchRunner(moduleExports);
53
+ this._patchBaseAgent(moduleExports);
54
+ }
55
+ catch { /* graceful degradation */ }
56
+ }
57
+ /**
58
+ * Replace ADK's internal tracers with PassthroughTracer to suppress
59
+ * duplicate top-level spans (mirrors Python _disable_existing_tracers).
60
+ */
61
+ _disableExistingTracers(moduleExports) {
62
+ try {
63
+ const runners = this._resolveSubmodule(moduleExports, 'runners');
64
+ if (runners && runners.tracer) {
65
+ this._originalTracers['runners.tracer'] = runners.tracer;
66
+ runners.tracer = new utils_1.PassthroughTracer(runners.tracer);
67
+ }
68
+ }
69
+ catch { /* ignore */ }
70
+ try {
71
+ const baseAgentMod = this._resolveSubmodule(moduleExports, 'agents', 'base_agent') ??
72
+ this._resolveSubmodule(moduleExports, 'agents');
73
+ if (baseAgentMod && baseAgentMod.tracer) {
74
+ this._originalTracers['base_agent.tracer'] = baseAgentMod.tracer;
75
+ baseAgentMod.tracer = new utils_1.PassthroughTracer(baseAgentMod.tracer);
76
+ }
77
+ }
78
+ catch { /* ignore */ }
79
+ }
80
+ /**
81
+ * Wrap ADK's trace_call_llm to enrich the current span with OTel GenAI attributes.
82
+ */
83
+ _wrapTraceCallLlm(moduleExports) {
84
+ try {
85
+ const blfMod = this._resolveSubmodule(moduleExports, 'flows', 'llm_flows', 'base_llm_flow') ??
86
+ this._resolveSubmodule(moduleExports, 'flows');
87
+ if (!blfMod)
88
+ return;
89
+ const originalFn = blfMod.trace_call_llm ?? blfMod.traceCallLlm;
90
+ if (!originalFn)
91
+ return;
92
+ this._originalTraceCallLlm = originalFn;
93
+ const captureContent = () => config_1.default.captureMessageContent ?? true;
94
+ const enriched = (...args) => {
95
+ const result = originalFn(...args);
96
+ try {
97
+ const span = api_1.trace.getActiveSpan();
98
+ if (span) {
99
+ const llmRequest = args[2];
100
+ const llmResponse = args[3];
101
+ (0, utils_1.enrichLlmSpan)(span, llmRequest, llmResponse, captureContent());
102
+ }
103
+ }
104
+ catch { /* ignore */ }
105
+ return result;
106
+ };
107
+ if (blfMod.trace_call_llm) {
108
+ blfMod.trace_call_llm = enriched;
109
+ }
110
+ else if (blfMod.traceCallLlm) {
111
+ blfMod.traceCallLlm = enriched;
112
+ }
113
+ }
114
+ catch { /* ignore */ }
115
+ }
116
+ /**
117
+ * Wrap ADK's trace_tool_call to enrich the current span with tool attributes.
118
+ */
119
+ _wrapTraceToolCall(moduleExports) {
120
+ try {
121
+ const fnMod = this._resolveSubmodule(moduleExports, 'flows', 'llm_flows', 'functions') ??
122
+ this._resolveSubmodule(moduleExports, 'flows');
123
+ if (!fnMod)
124
+ return;
125
+ const originalFn = fnMod.trace_tool_call ?? fnMod.traceToolCall;
126
+ if (!originalFn)
127
+ return;
128
+ this._originalTraceToolCall = originalFn;
129
+ const captureContent = () => config_1.default.captureMessageContent ?? true;
130
+ const enriched = (...args) => {
131
+ const result = originalFn(...args);
132
+ try {
133
+ const span = api_1.trace.getActiveSpan();
134
+ if (span) {
135
+ const tool = args[0];
136
+ const functionArgs = args[1];
137
+ const functionResponseEvent = args[2];
138
+ const toolError = args[3];
139
+ (0, utils_1.enrichToolSpan)(span, tool, functionArgs, functionResponseEvent, captureContent(), toolError);
140
+ }
141
+ }
142
+ catch { /* ignore */ }
143
+ return result;
144
+ };
145
+ if (fnMod.trace_tool_call) {
146
+ fnMod.trace_tool_call = enriched;
147
+ }
148
+ else if (fnMod.traceToolCall) {
149
+ fnMod.traceToolCall = enriched;
150
+ }
151
+ }
152
+ catch { /* ignore */ }
153
+ }
154
+ /**
155
+ * Wrap ADK's trace_merged_tool_calls to enrich the current span with merged tool attributes.
156
+ */
157
+ _wrapTraceMergedToolCalls(moduleExports) {
158
+ try {
159
+ const fnMod = this._resolveSubmodule(moduleExports, 'flows', 'llm_flows', 'functions') ??
160
+ this._resolveSubmodule(moduleExports, 'flows');
161
+ if (!fnMod)
162
+ return;
163
+ const originalFn = fnMod.trace_merged_tool_calls ?? fnMod.traceMergedToolCalls;
164
+ if (!originalFn)
165
+ return;
166
+ this._originalTraceMergedToolCalls = originalFn;
167
+ const captureContent = () => config_1.default.captureMessageContent ?? true;
168
+ const enriched = (...args) => {
169
+ const result = originalFn(...args);
170
+ try {
171
+ const span = api_1.trace.getActiveSpan();
172
+ if (span) {
173
+ const responseEventId = args[0];
174
+ const functionResponseEvent = args[1];
175
+ (0, utils_1.enrichMergedToolSpan)(span, responseEventId, functionResponseEvent, captureContent());
176
+ }
177
+ }
178
+ catch { /* ignore */ }
179
+ return result;
180
+ };
181
+ if (fnMod.trace_merged_tool_calls) {
182
+ fnMod.trace_merged_tool_calls = enriched;
183
+ }
184
+ else if (fnMod.traceMergedToolCalls) {
185
+ fnMod.traceMergedToolCalls = enriched;
186
+ }
187
+ }
188
+ catch { /* ignore */ }
189
+ }
190
+ /**
191
+ * Patch LlmAgent constructor to create create_agent spans.
192
+ */
193
+ _patchLlmAgent(moduleExports) {
194
+ try {
195
+ const LlmAgent = moduleExports.LlmAgent ?? moduleExports.Agent;
196
+ if (!LlmAgent?.prototype)
197
+ return;
198
+ const originalClass = LlmAgent;
199
+ const patchFn = (0, wrapper_1.wrapAgentInit)(this.tracer, this._registry);
200
+ // Wrap any init-like method if available; otherwise wrap the class prototype methods
201
+ // ADK's LlmAgent may expose initialization through sub_agents, tools setters, etc.
202
+ // The most reliable approach is patching the constructor via a proxy pattern.
203
+ if (typeof originalClass === 'function') {
204
+ const wrappedConstructor = patchFn(function (...args) {
205
+ return Reflect.construct(originalClass, args, new.target || originalClass);
206
+ });
207
+ // Copy static properties
208
+ Object.setPrototypeOf(wrappedConstructor, originalClass);
209
+ wrappedConstructor.prototype = originalClass.prototype;
210
+ // ESM-to-CJS interop may define exports as getter-only properties;
211
+ // both defineProperty and assignment may fail for ESM Module Namespace objects.
212
+ const exportName = moduleExports.LlmAgent ? 'LlmAgent' : 'Agent';
213
+ try {
214
+ Object.defineProperty(moduleExports, exportName, {
215
+ enumerable: true,
216
+ configurable: true,
217
+ writable: true,
218
+ value: wrappedConstructor,
219
+ });
220
+ }
221
+ catch {
222
+ try {
223
+ moduleExports[exportName] = wrappedConstructor;
224
+ }
225
+ catch { /* strict mode */ }
226
+ }
227
+ }
228
+ }
229
+ catch { /* ignore */ }
230
+ }
231
+ /**
232
+ * Patch Runner.run and Runner.runAsync (or run_async).
233
+ */
234
+ _patchRunner(moduleExports) {
235
+ try {
236
+ const Runner = moduleExports.Runner;
237
+ if (!Runner?.prototype)
238
+ return;
239
+ // Runner.run (sync)
240
+ const runMethod = Runner.prototype.run;
241
+ if (runMethod && !(0, instrumentation_1.isWrapped)(runMethod)) {
242
+ this._wrap(Runner.prototype, 'run', (0, wrapper_1.wrapRunnerRun)(this.tracer, 'runner_run', this._registry));
243
+ }
244
+ // Runner.runAsync or Runner.run_async (async generator)
245
+ const runAsyncName = Runner.prototype.runAsync ? 'runAsync' : 'run_async';
246
+ const runAsyncMethod = Runner.prototype[runAsyncName];
247
+ if (runAsyncMethod) {
248
+ if ((0, instrumentation_1.isWrapped)(runAsyncMethod))
249
+ this._unwrap(Runner.prototype, runAsyncName);
250
+ this._wrap(Runner.prototype, runAsyncName, (0, wrapper_1.wrapRunnerRunAsync)(this.tracer, 'runner_run_async', this._registry));
251
+ }
252
+ // Runner.runLive or Runner.run_live (async generator)
253
+ const runLiveName = Runner.prototype.runLive ? 'runLive' : 'run_live';
254
+ const runLiveMethod = Runner.prototype[runLiveName];
255
+ if (runLiveMethod) {
256
+ if ((0, instrumentation_1.isWrapped)(runLiveMethod))
257
+ this._unwrap(Runner.prototype, runLiveName);
258
+ this._wrap(Runner.prototype, runLiveName, (0, wrapper_1.wrapRunnerRunAsync)(this.tracer, 'runner_run_live', this._registry));
259
+ }
260
+ }
261
+ catch { /* ignore */ }
262
+ }
263
+ /**
264
+ * Patch BaseAgent.runAsync (or run_async).
265
+ */
266
+ _patchBaseAgent(moduleExports) {
267
+ try {
268
+ const BaseAgent = moduleExports.BaseAgent;
269
+ if (!BaseAgent?.prototype)
270
+ return;
271
+ const runAsyncName = BaseAgent.prototype.runAsync ? 'runAsync' : 'run_async';
272
+ const runAsyncMethod = BaseAgent.prototype[runAsyncName];
273
+ if (runAsyncMethod) {
274
+ if ((0, instrumentation_1.isWrapped)(runAsyncMethod))
275
+ this._unwrap(BaseAgent.prototype, runAsyncName);
276
+ this._wrap(BaseAgent.prototype, runAsyncName, (0, wrapper_1.wrapAgentRunAsync)(this.tracer, 'agent_run_async', this._registry));
277
+ }
278
+ }
279
+ catch { /* ignore */ }
280
+ }
281
+ // ---------------------------------------------------------------------------
282
+ // Submodule resolution
283
+ // ---------------------------------------------------------------------------
284
+ /**
285
+ * Attempt to resolve a nested submodule from the ADK exports.
286
+ * ADK's JS package may organize exports differently from Python.
287
+ */
288
+ _resolveSubmodule(moduleExports, ...path) {
289
+ let current = moduleExports;
290
+ for (const segment of path) {
291
+ if (!current)
292
+ return null;
293
+ current = current[segment];
294
+ }
295
+ return current || null;
296
+ }
297
+ // ---------------------------------------------------------------------------
298
+ // Unpatching
299
+ // ---------------------------------------------------------------------------
300
+ _unpatchAll(moduleExports) {
301
+ try {
302
+ // Restore original tracers
303
+ if (this._originalTracers['runners.tracer']) {
304
+ const runners = this._resolveSubmodule(moduleExports, 'runners');
305
+ if (runners)
306
+ runners.tracer = this._originalTracers['runners.tracer'];
307
+ }
308
+ if (this._originalTracers['base_agent.tracer']) {
309
+ const baseAgentMod = this._resolveSubmodule(moduleExports, 'agents', 'base_agent') ??
310
+ this._resolveSubmodule(moduleExports, 'agents');
311
+ if (baseAgentMod)
312
+ baseAgentMod.tracer = this._originalTracers['base_agent.tracer'];
313
+ }
314
+ // Restore original tracing functions
315
+ if (this._originalTraceCallLlm) {
316
+ const blfMod = this._resolveSubmodule(moduleExports, 'flows', 'llm_flows', 'base_llm_flow') ??
317
+ this._resolveSubmodule(moduleExports, 'flows');
318
+ if (blfMod) {
319
+ if (blfMod.trace_call_llm)
320
+ blfMod.trace_call_llm = this._originalTraceCallLlm;
321
+ else if (blfMod.traceCallLlm)
322
+ blfMod.traceCallLlm = this._originalTraceCallLlm;
323
+ }
324
+ }
325
+ if (this._originalTraceToolCall) {
326
+ const fnMod = this._resolveSubmodule(moduleExports, 'flows', 'llm_flows', 'functions') ??
327
+ this._resolveSubmodule(moduleExports, 'flows');
328
+ if (fnMod) {
329
+ if (fnMod.trace_tool_call)
330
+ fnMod.trace_tool_call = this._originalTraceToolCall;
331
+ else if (fnMod.traceToolCall)
332
+ fnMod.traceToolCall = this._originalTraceToolCall;
333
+ }
334
+ }
335
+ if (this._originalTraceMergedToolCalls) {
336
+ const fnMod = this._resolveSubmodule(moduleExports, 'flows', 'llm_flows', 'functions') ??
337
+ this._resolveSubmodule(moduleExports, 'flows');
338
+ if (fnMod) {
339
+ if (fnMod.trace_merged_tool_calls)
340
+ fnMod.trace_merged_tool_calls = this._originalTraceMergedToolCalls;
341
+ else if (fnMod.traceMergedToolCalls)
342
+ fnMod.traceMergedToolCalls = this._originalTraceMergedToolCalls;
343
+ }
344
+ }
345
+ // Unwrap patched methods
346
+ const Runner = moduleExports.Runner;
347
+ if (Runner?.prototype) {
348
+ if ((0, instrumentation_1.isWrapped)(Runner.prototype.run))
349
+ this._unwrap(Runner.prototype, 'run');
350
+ const runAsyncName = Runner.prototype.runAsync ? 'runAsync' : 'run_async';
351
+ if (Runner.prototype[runAsyncName] && (0, instrumentation_1.isWrapped)(Runner.prototype[runAsyncName])) {
352
+ this._unwrap(Runner.prototype, runAsyncName);
353
+ }
354
+ const runLiveName = Runner.prototype.runLive ? 'runLive' : 'run_live';
355
+ if (Runner.prototype[runLiveName] && (0, instrumentation_1.isWrapped)(Runner.prototype[runLiveName])) {
356
+ this._unwrap(Runner.prototype, runLiveName);
357
+ }
358
+ }
359
+ const BaseAgent = moduleExports.BaseAgent;
360
+ if (BaseAgent?.prototype) {
361
+ const runAsyncName = BaseAgent.prototype.runAsync ? 'runAsync' : 'run_async';
362
+ if (BaseAgent.prototype[runAsyncName] && (0, instrumentation_1.isWrapped)(BaseAgent.prototype[runAsyncName])) {
363
+ this._unwrap(BaseAgent.prototype, runAsyncName);
364
+ }
365
+ }
366
+ }
367
+ catch { /* ignore */ }
368
+ }
369
+ }
370
+ exports.default = GoogleADKInstrumentation;
371
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/instrumentation/google-adk/index.ts"],"names":[],"mappings":";;;;;AAAA,oEAKwC;AAExC,4CAA2C;AAC3C,6CAAwD;AACxD,mCAKiB;AACjB,uCAMmB;AACnB,0DAA2C;AAI3C;;;;;;GAMG;AACH,MAAqB,wBAAyB,SAAQ,qCAAmB;IAOvE,YAAY,SAAyC,EAAE;QACrD,KAAK,CAAC,GAAG,iCAAsB,6BAA6B,EAAE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+ import { Span, SpanKind } from '@opentelemetry/api';
2
+ import { AsyncLocalStorage } from 'async_hooks';
3
+ /**
4
+ * Prevents Runner.run_async from creating a second invoke_agent span
5
+ * when called internally by Runner.run (mirrors Python _ADK_WORKFLOW_ACTIVE).
6
+ */
7
+ export declare const adkWorkflowActive: AsyncLocalStorage<boolean>;
8
+ export declare function isAdkWorkflowActive(): boolean;
9
+ export declare const OPERATION_MAP: Record<string, string>;
10
+ export declare function getOperationType(endpoint: string): string;
11
+ export declare function getSpanKind(operationType: string): SpanKind;
12
+ export declare function generateSpanName(endpoint: string, instance: any): string;
13
+ /**
14
+ * Drop-in replacement for ADK's tracer objects. Overrides
15
+ * `startActiveSpan` to yield the current span instead of creating a new one,
16
+ * letting Shield360 own top-level spans while ADK's code still runs.
17
+ */
18
+ export declare class PassthroughTracer {
19
+ private _wrapped;
20
+ constructor(wrapped: any);
21
+ startActiveSpan(...args: any[]): any;
22
+ startSpan(...args: any[]): any;
23
+ }
24
+ export declare function resolveModelString(modelObj: any): string | null;
25
+ export declare function extractModelName(instance: any): string;
26
+ export declare function resolveServerInfo(instance?: any, modelName?: string | null): [string, number, string];
27
+ export declare function setCommonSpanAttributes(span: Span, operationType: string): void;
28
+ export declare function captureInputMessages(span: Span, llmRequest: any, captureContent: boolean): void;
29
+ export declare function captureOutputMessages(span: Span, llmResponse: any, captureContent: boolean, finishReason?: string): void;
30
+ export declare function captureEventOutput(span: Span, event: any, captureContent: boolean): void;
31
+ export interface TokenUsage {
32
+ inputTokens?: number;
33
+ outputTokens?: number;
34
+ reasoningTokens?: number;
35
+ cachedTokens?: number;
36
+ totalTokens?: number;
37
+ }
38
+ export declare function extractTokenUsage(llmResponse: any): TokenUsage;
39
+ export declare function enrichLlmSpan(span: Span, llmRequest: any, llmResponse: any, captureMessageContent: boolean): void;
40
+ export declare function enrichToolSpan(span: Span, tool: any, functionArgs: any, functionResponseEvent: any, captureMessageContent: boolean, error?: any): void;
41
+ export declare function enrichMergedToolSpan(span: Span, responseEventId: any, functionResponseEvent: any, captureMessageContent: boolean): void;
42
+ export declare function setRunnerAgentAttributes(span: Span, instance: any, endpoint: string): void;
43
+ export declare function setAgentAttributes(span: Span, instance: any): void;
44
+ export declare function processGoogleAdkResponse(span: Span, endpoint: string, instance: any, startTime: number, _captureMessageContent: boolean): void;
45
+ export declare function recordGoogleAdkMetrics(operationType: string, duration: number, requestModel: string, serverAddress: string, serverPort: number): void;