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,284 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const api_1 = require("@opentelemetry/api");
7
+ const core_1 = require("@opentelemetry/core");
8
+ const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
9
+ const config_1 = __importDefault(require("../../config"));
10
+ const helpers_1 = __importDefault(require("../../helpers"));
11
+ const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
12
+ const wrapper_1 = __importDefault(require("../browser-use/wrapper"));
13
+ const browser_use_1 = __importDefault(require("../browser-use"));
14
+ jest.mock('../../config');
15
+ jest.mock('../../helpers', () => ({
16
+ __esModule: true,
17
+ default: {
18
+ handleException: jest.fn(),
19
+ getChatModelCost: jest.fn().mockReturnValue(0.0025),
20
+ },
21
+ applyCustomSpanAttributes: jest.fn(),
22
+ }));
23
+ jest.mock('@opentelemetry/core', () => ({
24
+ isTracingSuppressed: jest.fn().mockReturnValue(false),
25
+ }));
26
+ describe('browser-use wrapper', () => {
27
+ let mockSpan;
28
+ let mockTracer;
29
+ beforeEach(() => {
30
+ mockSpan = {
31
+ setAttribute: jest.fn(),
32
+ setStatus: jest.fn(),
33
+ end: jest.fn(),
34
+ };
35
+ mockTracer = { startSpan: jest.fn(() => mockSpan) };
36
+ config_1.default.environment = 'shield360-testing';
37
+ config_1.default.applicationName = 'shield360-test';
38
+ config_1.default.captureMessageContent = true;
39
+ config_1.default.maxContentLength = null;
40
+ config_1.default.pricingInfo = {
41
+ chat: { 'gpt-4o-mini': { promptPrice: 0.15, completionPrice: 0.6 } },
42
+ };
43
+ core_1.isTracingSuppressed.mockReturnValue(false);
44
+ });
45
+ afterEach(() => {
46
+ jest.clearAllMocks();
47
+ });
48
+ function attrs() {
49
+ return Object.fromEntries(mockSpan.setAttribute.mock.calls);
50
+ }
51
+ it('wraps Agent.run into an invoke_agent span with browser-use metadata', async () => {
52
+ const mainSpan = {
53
+ setAttribute: jest.fn(),
54
+ setStatus: jest.fn(),
55
+ end: jest.fn(),
56
+ };
57
+ mockTracer.startSpan = jest.fn((name) => {
58
+ if (name === 'invoke_agent shopping-bot') {
59
+ return mainSpan;
60
+ }
61
+ return {
62
+ setAttribute: jest.fn(),
63
+ setStatus: jest.fn(),
64
+ end: jest.fn(),
65
+ };
66
+ });
67
+ class StubAgent {
68
+ constructor() {
69
+ this.name = 'shopping-bot';
70
+ this.task = 'Buy the cheapest laptop under $1000';
71
+ this.id = 'agent-1';
72
+ this.task_id = 'task-123';
73
+ this.session_id = 'session-456';
74
+ this.llm = { model: 'gpt-4o-mini' };
75
+ this.use_vision = true;
76
+ this.browser_profile = { headless: true, allowed_domains: ['example.com'] };
77
+ }
78
+ async run() {
79
+ return {
80
+ history: [{ result: [{ is_success: true }] }],
81
+ usage: { total_input_tokens: 10, total_output_tokens: 5 },
82
+ final_result: () => 'done',
83
+ total_duration_seconds: () => 1.5,
84
+ };
85
+ }
86
+ }
87
+ const agent = new StubAgent();
88
+ const wrapped = wrapper_1.default._patchAgentRun(mockTracer, '0.7.3')(StubAgent.prototype.run);
89
+ await wrapped.call(agent, 10);
90
+ expect(mockTracer.startSpan).toHaveBeenCalledWith('invoke_agent shopping-bot', {
91
+ kind: api_1.SpanKind.CLIENT,
92
+ attributes: {
93
+ [semantic_convention_1.default.GEN_AI_OPERATION]: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_AGENT,
94
+ [semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL]: semantic_convention_1.default.GEN_AI_SYSTEM_BROWSER_USE,
95
+ },
96
+ });
97
+ const a = Object.fromEntries(mainSpan.setAttribute.mock.calls);
98
+ expect(a[semantic_conventions_1.ATTR_TELEMETRY_SDK_NAME]).toBe('shield360');
99
+ expect(a[semantic_conventions_1.ATTR_SERVICE_NAME]).toBe('shield360-test');
100
+ expect(a[semantic_convention_1.default.ATTR_DEPLOYMENT_ENVIRONMENT]).toBe('shield360-testing');
101
+ expect(a[semantic_convention_1.default.GEN_AI_PROVIDER_NAME]).toBe('browser_use');
102
+ expect(a[semantic_convention_1.default.GEN_AI_OPERATION]).toBe('invoke_agent');
103
+ expect(a[semantic_convention_1.default.GEN_AI_OPERATION_TYPE]).toBe('invoke_agent');
104
+ expect(a[semantic_convention_1.default.GEN_AI_AGENT_TYPE]).toBe('browser');
105
+ expect(a[semantic_convention_1.default.GEN_AI_AGENT_ID]).toBe('agent-1');
106
+ expect(a[semantic_convention_1.default.GEN_AI_BROWSER_AGENT_TASK_ID]).toBe('task-123');
107
+ expect(a[semantic_convention_1.default.GEN_AI_AGENT_SESSION_ID]).toBe('session-456');
108
+ expect(a[semantic_convention_1.default.GEN_AI_AGENT_USE_VISION]).toBe(true);
109
+ expect(a[semantic_convention_1.default.GEN_AI_AGENT_HEADLESS]).toBe(true);
110
+ expect(a[semantic_convention_1.default.GEN_AI_AGENT_MAX_STEPS]).toBe(10);
111
+ expect(a[semantic_convention_1.default.GEN_AI_AGENT_STEP_COUNT]).toBe(1);
112
+ expect(a[semantic_convention_1.default.GEN_AI_AGENT_FINAL_RESULT]).toBe('done');
113
+ expect(a[semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS]).toBe(10);
114
+ expect(a[semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS]).toBe(5);
115
+ expect(typeof a[semantic_convention_1.default.GEN_AI_CLIENT_OPERATION_DURATION]).toBe('number');
116
+ expect(mainSpan.setStatus).toHaveBeenCalledWith({ code: 1 });
117
+ expect(mainSpan.end).toHaveBeenCalledTimes(1);
118
+ });
119
+ it('records Agent.run errors and still ends the span', async () => {
120
+ class StubAgent {
121
+ constructor() {
122
+ this.task = 'fail task';
123
+ }
124
+ async run() {
125
+ throw new Error('agent run failed');
126
+ }
127
+ }
128
+ const agent = new StubAgent();
129
+ const wrapped = wrapper_1.default._patchAgentRun(mockTracer, '0.7.3')(StubAgent.prototype.run);
130
+ await expect(wrapped.call(agent)).rejects.toThrow('agent run failed');
131
+ expect(helpers_1.default.handleException).toHaveBeenCalledWith(mockSpan, expect.objectContaining({ message: 'agent run failed' }));
132
+ expect(mockSpan.end).toHaveBeenCalledTimes(1);
133
+ });
134
+ it('bypasses instrumentation when tracing is suppressed', async () => {
135
+ core_1.isTracingSuppressed.mockReturnValue(true);
136
+ const original = jest.fn().mockResolvedValue({ ok: true });
137
+ const wrapped = wrapper_1.default._patchAgentRun(mockTracer, '0.7.3')(original);
138
+ await wrapped.call({ task: 'x' });
139
+ expect(original).toHaveBeenCalled();
140
+ expect(mockTracer.startSpan).not.toHaveBeenCalled();
141
+ });
142
+ it('wraps Controller.act into invoke_agent action spans (Python parity)', async () => {
143
+ class StubController {
144
+ constructor() {
145
+ this.registry = {
146
+ get_action: () => ({ description: 'Click element by index.' }),
147
+ };
148
+ }
149
+ async act(action) {
150
+ return { is_success: true, extracted_content: `done:${Object.keys(action)[0]}` };
151
+ }
152
+ }
153
+ const controller = new StubController();
154
+ const wrapped = wrapper_1.default._patchControllerAct(mockTracer, '0.7.3')(StubController.prototype.act);
155
+ await wrapped.call(controller, { go_to_url: { url: 'https://example.com/page' } }, {});
156
+ expect(mockTracer.startSpan).toHaveBeenCalledWith('invoke_agent go_to_url', {
157
+ kind: api_1.SpanKind.INTERNAL,
158
+ attributes: {
159
+ [semantic_convention_1.default.GEN_AI_OPERATION]: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_AGENT,
160
+ [semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL]: semantic_convention_1.default.GEN_AI_SYSTEM_BROWSER_USE,
161
+ },
162
+ });
163
+ const a = attrs();
164
+ expect(a[semantic_convention_1.default.GEN_AI_OPERATION]).toBe('invoke_agent');
165
+ expect(a[semantic_convention_1.default.GEN_AI_OPERATION_TYPE]).toBe('execute_task');
166
+ expect(a[semantic_convention_1.default.GEN_AI_ACTION_TYPE]).toBe('go_to_url');
167
+ expect(a[semantic_convention_1.default.GEN_AI_ACTION_INDEX]).toBe(1);
168
+ expect(a['gen_ai.action.url']).toBe('https://example.com/page');
169
+ expect(a[semantic_convention_1.default.GEN_AI_ACTION_SUCCESS]).toBe(true);
170
+ expect(a[semantic_convention_1.default.GEN_AI_TOOL_CALL_ARGUMENTS]).toBe('{"url":"https://example.com/page"}');
171
+ expect(mockSpan.end).toHaveBeenCalledTimes(1);
172
+ });
173
+ it('records controller errors and still ends the action span', async () => {
174
+ class StubController {
175
+ constructor() {
176
+ this.registry = {
177
+ get_action: () => ({ description: 'Navigate to URL.' }),
178
+ };
179
+ }
180
+ async act() {
181
+ throw new Error('navigation failed');
182
+ }
183
+ }
184
+ const controller = new StubController();
185
+ const wrapped = wrapper_1.default._patchControllerAct(mockTracer, '0.7.3')(StubController.prototype.act);
186
+ await expect(wrapped.call(controller, { go_to_url: { url: 'https://example.com' } }, {})).rejects.toThrow('navigation failed');
187
+ expect(helpers_1.default.handleException).toHaveBeenCalledWith(mockSpan, expect.objectContaining({ message: 'navigation failed' }));
188
+ expect(mockSpan.end).toHaveBeenCalledTimes(1);
189
+ });
190
+ it('wraps Agent.step into execute_task spans', async () => {
191
+ class StubAgent {
192
+ constructor() {
193
+ this.name = 'research-bot';
194
+ this.step_count = 2;
195
+ this.llm = { model: 'gpt-4o' };
196
+ }
197
+ async step() {
198
+ return { is_success: true };
199
+ }
200
+ }
201
+ const agent = new StubAgent();
202
+ const wrapped = wrapper_1.default._patchAgentStep(mockTracer, '0.7.3')(StubAgent.prototype.step);
203
+ await wrapped.call(agent);
204
+ expect(mockTracer.startSpan).toHaveBeenCalledWith('execute_task step 2', { kind: api_1.SpanKind.CLIENT });
205
+ expect(attrs()[semantic_convention_1.default.GEN_AI_OPERATION]).toBe('step');
206
+ expect(attrs()[semantic_convention_1.default.GEN_AI_OPERATION_TYPE]).toBe('execute_task');
207
+ });
208
+ it('wraps Agent.pause into browser lifecycle spans', async () => {
209
+ class StubAgent {
210
+ constructor() {
211
+ this.name = 'research-bot';
212
+ }
213
+ async pause() {
214
+ return undefined;
215
+ }
216
+ }
217
+ const agent = new StubAgent();
218
+ const wrapped = wrapper_1.default._patchAgentLifecycle(mockTracer, 'pause', '0.7.3')(StubAgent.prototype.pause);
219
+ await wrapped.call(agent);
220
+ expect(mockTracer.startSpan).toHaveBeenCalledWith('browser pause', { kind: api_1.SpanKind.CLIENT });
221
+ expect(attrs()[semantic_convention_1.default.GEN_AI_OPERATION]).toBe('pause');
222
+ expect(attrs()[semantic_convention_1.default.GEN_AI_OPERATION_TYPE]).toBe('invoke_workflow');
223
+ });
224
+ it('creates step and action spans from run history when step hooks do not fire', async () => {
225
+ class StubAgent {
226
+ constructor() {
227
+ this.name = 'history-bot';
228
+ this.task = 'complete checkout';
229
+ }
230
+ async run(_options) {
231
+ return {
232
+ history: [
233
+ {
234
+ model_output: { action: [{ click: { index: 1 } }] },
235
+ result: [{ is_success: true }],
236
+ state: { url: 'https://shop.example/cart', title: 'Cart' },
237
+ },
238
+ ],
239
+ usage: { total_input_tokens: 3, total_output_tokens: 2 },
240
+ final_result: () => 'checked out',
241
+ };
242
+ }
243
+ }
244
+ const agent = new StubAgent();
245
+ const wrapped = wrapper_1.default._patchAgentRun(mockTracer, '0.7.3')(StubAgent.prototype.run);
246
+ await wrapped.call(agent);
247
+ const spanNames = mockTracer.startSpan.mock.calls.map((call) => call[0]);
248
+ expect(spanNames).toContain('invoke_agent history-bot');
249
+ expect(spanNames).toContain('execute_task step 1');
250
+ expect(spanNames).toContain('invoke_agent click');
251
+ });
252
+ });
253
+ describe('BrowserUseInstrumentation patch targets', () => {
254
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
255
+ const { isWrapped } = require('@opentelemetry/instrumentation');
256
+ it('wraps Agent lifecycle methods and Controller.act', () => {
257
+ class Agent {
258
+ async run() {
259
+ return null;
260
+ }
261
+ async step() {
262
+ return null;
263
+ }
264
+ async pause() { }
265
+ async resume() { }
266
+ async stop() { }
267
+ }
268
+ class Controller {
269
+ async act() {
270
+ return null;
271
+ }
272
+ }
273
+ const fakeModule = { Agent, Controller };
274
+ const instrumentation = new browser_use_1.default();
275
+ instrumentation.manualPatch(fakeModule, '0.7.3');
276
+ expect(isWrapped(fakeModule.Agent.prototype.run)).toBe(true);
277
+ expect(isWrapped(fakeModule.Agent.prototype.step)).toBe(true);
278
+ expect(isWrapped(fakeModule.Agent.prototype.pause)).toBe(true);
279
+ expect(isWrapped(fakeModule.Agent.prototype.resume)).toBe(true);
280
+ expect(isWrapped(fakeModule.Agent.prototype.stop)).toBe(true);
281
+ expect(isWrapped(fakeModule.Controller.prototype.act)).toBe(true);
282
+ });
283
+ });
284
+ //# sourceMappingURL=browser-use-wrapper.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-use-wrapper.test.js","sourceRoot":"","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C,IAAI,CAAC,CAAC;QAC9D,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/D,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChE,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9D,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Unit tests for cache-aware cost calculation in `Shield360Helper.getChatModelCost`.
3
+ *
4
+ * Mirrors the Python `test_cache_pricing.py` coverage and validates the two
5
+ * provider token-accounting conventions:
6
+ * - Anthropic native API -> promptTokens is exclusive of cache tokens.
7
+ * - OpenAI / LangChain -> promptTokens is inclusive of cache tokens.
8
+ *
9
+ * The same cached tokens must never be billed twice, and models without cache
10
+ * pricing must produce exactly the legacy cost regardless of convention.
11
+ *
12
+ * Also covers instrumentor call-site patterns (claude-agent-sdk inclusive sum,
13
+ * bedrock exclusive, openai cache_write_tokens, strands/cursor heuristic).
14
+ */
15
+ export {};
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ /**
3
+ * Unit tests for cache-aware cost calculation in `Shield360Helper.getChatModelCost`.
4
+ *
5
+ * Mirrors the Python `test_cache_pricing.py` coverage and validates the two
6
+ * provider token-accounting conventions:
7
+ * - Anthropic native API -> promptTokens is exclusive of cache tokens.
8
+ * - OpenAI / LangChain -> promptTokens is inclusive of cache tokens.
9
+ *
10
+ * The same cached tokens must never be billed twice, and models without cache
11
+ * pricing must produce exactly the legacy cost regardless of convention.
12
+ *
13
+ * Also covers instrumentor call-site patterns (claude-agent-sdk inclusive sum,
14
+ * bedrock exclusive, openai cache_write_tokens, strands/cursor heuristic).
15
+ */
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ const helpers_1 = __importDefault(require("../../helpers"));
21
+ const PRICING = {
22
+ chat: {
23
+ 'claude-3-5-sonnet-20241022': {
24
+ promptPrice: 0.003,
25
+ completionPrice: 0.015,
26
+ cacheReadPrice: 0.0003,
27
+ cacheCreationPrice: 0.00375,
28
+ },
29
+ 'model-no-cache-price': {
30
+ promptPrice: 0.003,
31
+ completionPrice: 0.015,
32
+ },
33
+ 'gpt-cache-write': {
34
+ promptPrice: 0.0025,
35
+ completionPrice: 0.01,
36
+ cacheReadPrice: 0.00125,
37
+ cacheCreationPrice: 0.003125,
38
+ },
39
+ },
40
+ };
41
+ const MODEL = 'claude-3-5-sonnet-20241022';
42
+ // 200 uncached + 5000 cache-read + 1000 cache-creation + 300 output
43
+ const RAW_INPUT = 200;
44
+ const CACHE_READ = 5000;
45
+ const CACHE_CREATION = 1000;
46
+ const OUTPUT = 300;
47
+ const INCLUSIVE_INPUT = RAW_INPUT + CACHE_READ + CACHE_CREATION;
48
+ function groundTruth() {
49
+ return ((RAW_INPUT / 1000) * 0.003 +
50
+ (OUTPUT / 1000) * 0.015 +
51
+ (CACHE_READ / 1000) * 0.0003 +
52
+ (CACHE_CREATION / 1000) * 0.00375);
53
+ }
54
+ describe('Shield360Helper.getChatModelCost — cache pricing', () => {
55
+ describe('no cache tokens', () => {
56
+ it('matches the legacy formula', () => {
57
+ const cost = helpers_1.default.getChatModelCost(MODEL, PRICING, 1000, 500);
58
+ expect(cost).toBeCloseTo((1000 / 1000) * 0.003 + (500 / 1000) * 0.015, 10);
59
+ });
60
+ it('returns 0 for an unknown model', () => {
61
+ expect(helpers_1.default.getChatModelCost('nope', PRICING, 10, 10)).toBe(0);
62
+ });
63
+ it('returns 0 when pricing info is missing', () => {
64
+ expect(helpers_1.default.getChatModelCost(MODEL, {}, 10, 10)).toBe(0);
65
+ });
66
+ });
67
+ describe('Anthropic convention (promptTokens exclusive of cache)', () => {
68
+ it('adds cache cost on top of the prompt base', () => {
69
+ const cost = helpers_1.default.getChatModelCost(MODEL, PRICING, 800, 500, 100, 100);
70
+ const expected = (800 / 1000) * 0.003 +
71
+ (500 / 1000) * 0.015 +
72
+ (100 / 1000) * 0.0003 +
73
+ (100 / 1000) * 0.00375;
74
+ expect(cost).toBeCloseTo(expected, 10);
75
+ });
76
+ it('leaves the prompt base untouched when no cache price exists', () => {
77
+ const cost = helpers_1.default.getChatModelCost('model-no-cache-price', PRICING, 800, 500, 100, 100);
78
+ expect(cost).toBeCloseTo((800 / 1000) * 0.003 + (500 / 1000) * 0.015, 10);
79
+ });
80
+ });
81
+ describe('OpenAI / LangChain convention (promptTokens inclusive of cache)', () => {
82
+ it('does not bill cache tokens twice', () => {
83
+ // 1000 total input = 800 uncached + 100 cache read + 100 cache creation
84
+ const cost = helpers_1.default.getChatModelCost(MODEL, PRICING, 1000, 500, 100, 100, true);
85
+ const expected = (800 / 1000) * 0.003 +
86
+ (500 / 1000) * 0.015 +
87
+ (100 / 1000) * 0.0003 +
88
+ (100 / 1000) * 0.00375;
89
+ expect(cost).toBeCloseTo(expected, 10);
90
+ });
91
+ it('matches the exclusive call describing the same request', () => {
92
+ const inclusive = helpers_1.default.getChatModelCost(MODEL, PRICING, 1000, 500, 100, 100, true);
93
+ const exclusive = helpers_1.default.getChatModelCost(MODEL, PRICING, 800, 500, 100, 100);
94
+ expect(inclusive).toBeCloseTo(exclusive, 10);
95
+ });
96
+ it('matches the legacy total when no cache price exists (no regression)', () => {
97
+ const cost = helpers_1.default.getChatModelCost('model-no-cache-price', PRICING, 1000, 500, 100, 100, true);
98
+ expect(cost).toBeCloseTo((1000 / 1000) * 0.003 + (500 / 1000) * 0.015, 10);
99
+ });
100
+ it('handles OpenAI-style cache read only (no cache creation)', () => {
101
+ // OpenAI: prompt_tokens includes cached_tokens; no cache-creation charge.
102
+ const pricing = {
103
+ chat: { 'gpt-cache': { promptPrice: 0.0025, completionPrice: 0.01, cacheReadPrice: 0.00125 } },
104
+ };
105
+ const cost = helpers_1.default.getChatModelCost('gpt-cache', pricing, 1000, 200, 400, 0, true);
106
+ const expected = (600 / 1000) * 0.0025 + (200 / 1000) * 0.01 + (400 / 1000) * 0.00125;
107
+ expect(cost).toBeCloseTo(expected, 10);
108
+ });
109
+ it('clamps the prompt base at 0 for malformed token data', () => {
110
+ const cost = helpers_1.default.getChatModelCost(MODEL, PRICING, 100, 0, 200, 200, true);
111
+ const expected = (200 / 1000) * 0.0003 + (200 / 1000) * 0.00375;
112
+ expect(cost).toBeCloseTo(expected, 10);
113
+ });
114
+ });
115
+ describe('instrumentor call-site patterns', () => {
116
+ it('claude-agent-sdk: inclusive sum + cache args re-prices correctly', () => {
117
+ // extractUsage builds input = raw + cache_read + cache_creation
118
+ const cost = helpers_1.default.getChatModelCost(MODEL, PRICING, INCLUSIVE_INPUT, OUTPUT, CACHE_READ, CACHE_CREATION, true);
119
+ expect(cost).toBeCloseTo(groundTruth(), 10);
120
+ });
121
+ it('bedrock: exclusive cacheRead/cacheWrite does not undercharge', () => {
122
+ const cost = helpers_1.default.getChatModelCost(MODEL, PRICING, RAW_INPUT, OUTPUT, CACHE_READ, CACHE_CREATION, false);
123
+ expect(cost).toBeCloseTo(groundTruth(), 10);
124
+ });
125
+ it('openai: maps cache_write_tokens into creation (inclusive)', () => {
126
+ // prompt_tokens inclusive; cache_write_tokens billed at cacheCreationPrice
127
+ const cost = helpers_1.default.getChatModelCost('gpt-cache-write', PRICING, 1000, 200, 400, 100, true);
128
+ const expected = (500 / 1000) * 0.0025 +
129
+ (200 / 1000) * 0.01 +
130
+ (400 / 1000) * 0.00125 +
131
+ (100 / 1000) * 0.003125;
132
+ expect(cost).toBeCloseTo(expected, 10);
133
+ });
134
+ it('strands/cursor heuristic: input >= cache sum → inclusive', () => {
135
+ const cacheTotal = CACHE_READ + CACHE_CREATION;
136
+ const inclusive = INCLUSIVE_INPUT >= cacheTotal;
137
+ expect(inclusive).toBe(true);
138
+ const cost = helpers_1.default.getChatModelCost(MODEL, PRICING, INCLUSIVE_INPUT, OUTPUT, CACHE_READ, CACHE_CREATION, inclusive);
139
+ expect(cost).toBeCloseTo(groundTruth(), 10);
140
+ });
141
+ it('strands/cursor heuristic: input < cache sum → exclusive', () => {
142
+ const cacheTotal = CACHE_READ + CACHE_CREATION;
143
+ const inclusive = RAW_INPUT >= cacheTotal;
144
+ expect(inclusive).toBe(false);
145
+ const cost = helpers_1.default.getChatModelCost(MODEL, PRICING, RAW_INPUT, OUTPUT, CACHE_READ, CACHE_CREATION, inclusive);
146
+ expect(cost).toBeCloseTo(groundTruth(), 10);
147
+ });
148
+ it('billing inclusive total at prompt price overcharges (documents pre-fix)', () => {
149
+ const overcharged = helpers_1.default.getChatModelCost(MODEL, PRICING, INCLUSIVE_INPUT, OUTPUT);
150
+ expect(overcharged).toBeCloseTo((INCLUSIVE_INPUT / 1000) * 0.003 + (OUTPUT / 1000) * 0.015, 10);
151
+ expect(overcharged).toBeGreaterThan(groundTruth());
152
+ });
153
+ });
154
+ });
155
+ //# sourceMappingURL=cache-pricing.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-pricing.test.js","sourceRoot":"","sources":["../../../src/instrumentation/__tests__/cache-pricing.test.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;AAEH,4DAA4C;AAE5C,MAAM,OAAO,GAAG;IACd,IAAI,EAAE;QACJ,4BAA4B,EAAE;YAC5B,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,MAAM;YACtB,kBAAkB,EAAE,OAAO;SAC5B;QACD,sBAA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D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Cross-Language Trace Comparison Tests for ChromaDB Integration
3
+ *
4
+ * Verifies that TypeScript SDK generates traces consistent with the Python SDK
5
+ * for ChromaDB Collection operations.
6
+ *
7
+ * Python SDK reference: sdk/python/src/shield360/instrumentation/chroma/utils.py
8
+ *
9
+ * Key alignment:
10
+ * - db.system.name = 'chroma'
11
+ * - db.operation.name: INSERT (add), QUERY (query), GET (get), DELETE, PEEK, UPDATE, UPSERT
12
+ * - db.collection.name
13
+ * - server.address, server.port (default localhost:8000)
14
+ * - db.vector.query.top_k for query
15
+ * - db.filter for where-clause filtering
16
+ * - db.query.summary
17
+ */
18
+ export {};