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,34 @@
1
+ import { Span, Tracer } from '@opentelemetry/api';
2
+ import BaseWrapper from '../base-wrapper';
3
+ export default class AnthropicWrapper extends BaseWrapper {
4
+ static aiSystem: string;
5
+ static serverAddress: string;
6
+ static serverPort: number;
7
+ static _patchMessageCreate(tracer: Tracer): any;
8
+ static _messageCreate({ args, genAIEndpoint, response, span, }: {
9
+ args: any[];
10
+ genAIEndpoint: string;
11
+ response: any;
12
+ span: Span;
13
+ }): Promise<any>;
14
+ static _messageCreateGenerator({ args, genAIEndpoint, response, span, }: {
15
+ args: any[];
16
+ genAIEndpoint: string;
17
+ response: any;
18
+ span: Span;
19
+ }): AsyncGenerator<unknown, any, unknown>;
20
+ static _messageCreateCommonSetter({ args, genAIEndpoint, result, span, ttft, tbt, }: {
21
+ args: any[];
22
+ genAIEndpoint: string;
23
+ result: any;
24
+ span: Span;
25
+ ttft?: number;
26
+ tbt?: number;
27
+ }): Promise<{
28
+ genAIEndpoint: string;
29
+ model: any;
30
+ user: any;
31
+ cost: number;
32
+ aiSystem: string;
33
+ }>;
34
+ }
@@ -0,0 +1,426 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const api_1 = require("@opentelemetry/api");
40
+ const config_1 = __importDefault(require("../../config"));
41
+ const helpers_1 = __importStar(require("../../helpers"));
42
+ const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
43
+ const base_wrapper_1 = __importDefault(require("../base-wrapper"));
44
+ const FINISH_REASON_MAP = {
45
+ end_turn: 'stop',
46
+ max_tokens: 'length',
47
+ stop_sequence: 'stop',
48
+ tool_use: 'tool_call',
49
+ };
50
+ function mapFinishReason(reason) {
51
+ return FINISH_REASON_MAP[reason] || reason || 'stop';
52
+ }
53
+ function spanCreationAttrs(operationName, requestModel) {
54
+ return {
55
+ [semantic_convention_1.default.GEN_AI_OPERATION]: operationName,
56
+ [semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL]: AnthropicWrapper.aiSystem,
57
+ [semantic_convention_1.default.GEN_AI_REQUEST_MODEL]: requestModel,
58
+ [semantic_convention_1.default.SERVER_ADDRESS]: AnthropicWrapper.serverAddress,
59
+ [semantic_convention_1.default.SERVER_PORT]: AnthropicWrapper.serverPort,
60
+ };
61
+ }
62
+ class AnthropicWrapper extends base_wrapper_1.default {
63
+ static _patchMessageCreate(tracer) {
64
+ const genAIEndpoint = 'anthropic.resources.messages';
65
+ return (originalMethod) => {
66
+ return async function (...args) {
67
+ if ((0, helpers_1.isFrameworkLlmActive)())
68
+ return originalMethod.apply(this, args);
69
+ const requestModel = args[0]?.model || 'claude-3-5-sonnet-latest';
70
+ const spanName = `${semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT} ${requestModel}`;
71
+ const effectiveCtx = (0, helpers_1.getFrameworkParentContext)() ?? api_1.context.active();
72
+ const span = tracer.startSpan(spanName, {
73
+ kind: api_1.SpanKind.CLIENT,
74
+ attributes: spanCreationAttrs(semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT, requestModel),
75
+ }, effectiveCtx);
76
+ return api_1.context
77
+ .with(api_1.trace.setSpan(effectiveCtx, span), async () => {
78
+ return originalMethod.apply(this, args);
79
+ })
80
+ .then((response) => {
81
+ const { stream = false } = args[0];
82
+ if (stream) {
83
+ return helpers_1.default.createStreamProxy(response, AnthropicWrapper._messageCreateGenerator({
84
+ args,
85
+ genAIEndpoint,
86
+ response,
87
+ span,
88
+ }));
89
+ }
90
+ return AnthropicWrapper._messageCreate({ args, genAIEndpoint, response, span });
91
+ })
92
+ .catch((e) => {
93
+ helpers_1.default.handleException(span, e);
94
+ base_wrapper_1.default.recordMetrics(span, {
95
+ genAIEndpoint,
96
+ model: requestModel,
97
+ aiSystem: AnthropicWrapper.aiSystem,
98
+ serverAddress: AnthropicWrapper.serverAddress,
99
+ serverPort: AnthropicWrapper.serverPort,
100
+ errorType: e?.constructor?.name || '_OTHER',
101
+ });
102
+ span.end();
103
+ throw e;
104
+ });
105
+ };
106
+ };
107
+ }
108
+ static async _messageCreate({ args, genAIEndpoint, response, span, }) {
109
+ let metricParams;
110
+ try {
111
+ metricParams = await AnthropicWrapper._messageCreateCommonSetter({
112
+ args,
113
+ genAIEndpoint,
114
+ result: response,
115
+ span,
116
+ });
117
+ return response;
118
+ }
119
+ catch (e) {
120
+ helpers_1.default.handleException(span, e);
121
+ throw e;
122
+ }
123
+ finally {
124
+ span.end();
125
+ if (metricParams) {
126
+ base_wrapper_1.default.recordMetrics(span, metricParams);
127
+ }
128
+ }
129
+ }
130
+ static async *_messageCreateGenerator({ args, genAIEndpoint, response, span, }) {
131
+ let metricParams;
132
+ const timestamps = [];
133
+ const startTime = Date.now();
134
+ try {
135
+ const result = {
136
+ id: '',
137
+ model: '',
138
+ stop_reason: '',
139
+ content: [],
140
+ usage: {
141
+ input_tokens: 0,
142
+ output_tokens: 0,
143
+ cache_creation_input_tokens: 0,
144
+ cache_read_input_tokens: 0,
145
+ },
146
+ };
147
+ let llmResponse = '';
148
+ let toolId = '';
149
+ let toolName = '';
150
+ let toolArguments = '';
151
+ for await (const chunk of response) {
152
+ timestamps.push(Date.now());
153
+ switch (chunk.type) {
154
+ case 'message_start':
155
+ if (chunk.message) {
156
+ result.id = chunk.message.id;
157
+ result.model = chunk.message.model;
158
+ result.usage.input_tokens = Number(chunk.message.usage?.input_tokens) || 0;
159
+ result.usage.output_tokens += Number(chunk.message.usage?.output_tokens) || 0;
160
+ result.usage.cache_creation_input_tokens =
161
+ Number(chunk.message.usage?.cache_creation_input_tokens) || 0;
162
+ result.usage.cache_read_input_tokens =
163
+ Number(chunk.message.usage?.cache_read_input_tokens) || 0;
164
+ result.stop_reason = chunk.message.stop_reason || '';
165
+ }
166
+ break;
167
+ case 'content_block_start':
168
+ if (chunk.content_block?.type === 'tool_use') {
169
+ toolId = chunk.content_block.id || '';
170
+ toolName = chunk.content_block.name || '';
171
+ toolArguments = '';
172
+ }
173
+ break;
174
+ case 'content_block_delta':
175
+ if (chunk.delta?.text) {
176
+ llmResponse += chunk.delta.text;
177
+ }
178
+ if (chunk.delta?.partial_json) {
179
+ toolArguments += chunk.delta.partial_json;
180
+ }
181
+ break;
182
+ case 'content_block_stop':
183
+ break;
184
+ case 'message_delta':
185
+ result.stop_reason = chunk.delta?.stop_reason || result.stop_reason;
186
+ result.usage.output_tokens += Number(chunk.usage?.output_tokens) || 0;
187
+ if (chunk.usage?.cache_creation_input_tokens != null) {
188
+ result.usage.cache_creation_input_tokens =
189
+ Number(chunk.usage.cache_creation_input_tokens) || 0;
190
+ }
191
+ if (chunk.usage?.cache_read_input_tokens != null) {
192
+ result.usage.cache_read_input_tokens =
193
+ Number(chunk.usage.cache_read_input_tokens) || 0;
194
+ }
195
+ break;
196
+ case 'message_stop':
197
+ break;
198
+ }
199
+ yield chunk;
200
+ }
201
+ if (llmResponse) {
202
+ result.content.push({ type: 'text', text: llmResponse });
203
+ }
204
+ if (toolId) {
205
+ let parsedInput = {};
206
+ try {
207
+ parsedInput = JSON.parse(toolArguments);
208
+ }
209
+ catch { /* keep empty */ }
210
+ result.content.push({
211
+ type: 'tool_use',
212
+ id: toolId,
213
+ name: toolName,
214
+ input: parsedInput,
215
+ });
216
+ }
217
+ const ttft = timestamps.length > 0 ? (timestamps[0] - startTime) / 1000 : 0;
218
+ let tbt = 0;
219
+ if (timestamps.length > 1) {
220
+ const timeDiffs = timestamps.slice(1).map((t, i) => t - timestamps[i]);
221
+ tbt = timeDiffs.reduce((a, b) => a + b, 0) / timeDiffs.length / 1000;
222
+ }
223
+ metricParams = await AnthropicWrapper._messageCreateCommonSetter({
224
+ args,
225
+ genAIEndpoint,
226
+ result,
227
+ span,
228
+ ttft,
229
+ tbt,
230
+ });
231
+ return result;
232
+ }
233
+ catch (e) {
234
+ helpers_1.default.handleException(span, e);
235
+ throw e;
236
+ }
237
+ finally {
238
+ span.end();
239
+ if (metricParams) {
240
+ base_wrapper_1.default.recordMetrics(span, metricParams);
241
+ }
242
+ }
243
+ }
244
+ static async _messageCreateCommonSetter({ args, genAIEndpoint, result, span, ttft = 0, tbt = 0, }) {
245
+ const captureContent = config_1.default.captureMessageContent;
246
+ const requestModel = args[0]?.model || 'claude-3-5-sonnet-latest';
247
+ const { messages, system, max_tokens = null, seed = null, temperature = 1, top_p, top_k, stop_sequences = null, stream = false, user, tools: _tools, } = args[0];
248
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_TEMPERATURE, temperature);
249
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_TOP_P, top_p || 1);
250
+ if (top_k != null) {
251
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_TOP_K, top_k);
252
+ }
253
+ if (max_tokens != null) {
254
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, max_tokens);
255
+ }
256
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_IS_STREAM, stream);
257
+ if (seed != null) {
258
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_SEED, Number(seed));
259
+ }
260
+ if (stop_sequences && Array.isArray(stop_sequences) && stop_sequences.length > 0) {
261
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_STOP_SEQUENCES, stop_sequences);
262
+ }
263
+ if (captureContent) {
264
+ const systemStr = typeof system === 'string' ? system : undefined;
265
+ span.setAttribute(semantic_convention_1.default.GEN_AI_INPUT_MESSAGES, helpers_1.default.buildInputMessages(messages || [], systemStr));
266
+ if (system) {
267
+ const sysAttr = typeof system === 'string' ? system : JSON.stringify(system);
268
+ span.setAttribute(semantic_convention_1.default.GEN_AI_SYSTEM_INSTRUCTIONS, sysAttr);
269
+ }
270
+ }
271
+ span.setAttribute(semantic_convention_1.default.GEN_AI_RESPONSE_ID, result.id);
272
+ const responseModel = result.model || requestModel;
273
+ const pricingInfo = config_1.default.pricingInfo || {};
274
+ // Anthropic reports input_tokens exclusive of cache read / creation tokens,
275
+ // so cache tokens are added on top (promptTokensIncludeCache stays false).
276
+ const cost = helpers_1.default.getChatModelCost(requestModel, pricingInfo, result.usage.input_tokens, result.usage.output_tokens, Number(result.usage.cache_read_input_tokens) || 0, Number(result.usage.cache_creation_input_tokens) || 0);
277
+ AnthropicWrapper.setBaseSpanAttributes(span, {
278
+ genAIEndpoint,
279
+ model: requestModel,
280
+ user,
281
+ cost,
282
+ aiSystem: AnthropicWrapper.aiSystem,
283
+ serverAddress: AnthropicWrapper.serverAddress,
284
+ serverPort: AnthropicWrapper.serverPort,
285
+ });
286
+ span.setAttribute(semantic_convention_1.default.GEN_AI_RESPONSE_MODEL, responseModel);
287
+ const inputTokens = result.usage.input_tokens;
288
+ const outputTokens = result.usage.output_tokens;
289
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
290
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
291
+ if (result.usage.cache_creation_input_tokens) {
292
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS, result.usage.cache_creation_input_tokens);
293
+ }
294
+ if (result.usage.cache_read_input_tokens) {
295
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, result.usage.cache_read_input_tokens);
296
+ }
297
+ if (ttft > 0) {
298
+ span.setAttribute(semantic_convention_1.default.GEN_AI_SERVER_TTFT, ttft);
299
+ }
300
+ if (tbt > 0) {
301
+ span.setAttribute(semantic_convention_1.default.GEN_AI_SERVER_TBT, tbt);
302
+ }
303
+ const finishReason = mapFinishReason(result.stop_reason);
304
+ span.setAttribute(semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON, [finishReason]);
305
+ const toolUseBlocks = (result.content || []).filter((b) => b.type === 'tool_use');
306
+ const outputType = toolUseBlocks.length > 0
307
+ ? semantic_convention_1.default.GEN_AI_OUTPUT_TYPE_JSON
308
+ : semantic_convention_1.default.GEN_AI_OUTPUT_TYPE_TEXT;
309
+ span.setAttribute(semantic_convention_1.default.GEN_AI_OUTPUT_TYPE, outputType);
310
+ if (toolUseBlocks.length > 0) {
311
+ const toolNames = toolUseBlocks.map((b) => b.name || '').filter(Boolean);
312
+ const toolIds = toolUseBlocks.map((b) => b.id || '').filter(Boolean);
313
+ const toolArgs = toolUseBlocks.map((b) => JSON.stringify(b.input || {}));
314
+ if (toolNames.length > 0)
315
+ span.setAttribute(semantic_convention_1.default.GEN_AI_TOOL_NAME, toolNames.join(', '));
316
+ if (toolIds.length > 0)
317
+ span.setAttribute(semantic_convention_1.default.GEN_AI_TOOL_CALL_ID, toolIds.join(', '));
318
+ if (toolArgs.length > 0)
319
+ span.setAttribute(semantic_convention_1.default.GEN_AI_TOOL_ARGS, toolArgs.join(', '));
320
+ }
321
+ let inputMessagesJson;
322
+ let outputMessagesJson;
323
+ // Anthropic tool schema uses `input_schema` instead of `parameters`; the
324
+ // shared helper already handles both shapes.
325
+ const toolDefinitionsJson = helpers_1.default.buildToolDefinitions(_tools);
326
+ const systemInstructionsJson = (() => {
327
+ if (!system)
328
+ return undefined;
329
+ if (typeof system === 'string') {
330
+ return JSON.stringify([{ type: 'text', content: system }]);
331
+ }
332
+ try {
333
+ return JSON.stringify(system);
334
+ }
335
+ catch {
336
+ return undefined;
337
+ }
338
+ })();
339
+ // Stamp `shield360.agent.version_hash` (auto) and `gen_ai.agent.version`
340
+ // (user override) regardless of content capture so versions still group
341
+ // correctly when capture_message_content=false.
342
+ const versionExtras = {};
343
+ try {
344
+ const versionHash = helpers_1.default.computeAgentVersionHash({
345
+ systemInstructions: systemInstructionsJson ?? null,
346
+ toolDefinitions: toolDefinitionsJson ?? null,
347
+ primaryModel: responseModel || requestModel,
348
+ runtimeConfig: {
349
+ temperature: temperature ?? null,
350
+ top_p: top_p ?? null,
351
+ max_tokens: max_tokens ?? null,
352
+ provider: semantic_convention_1.default.GEN_AI_SYSTEM_ANTHROPIC,
353
+ },
354
+ providers: [semantic_convention_1.default.GEN_AI_SYSTEM_ANTHROPIC],
355
+ });
356
+ if (versionHash) {
357
+ versionExtras[semantic_convention_1.default.SHIELD360_AGENT_VERSION_HASH] = versionHash;
358
+ span.setAttribute(semantic_convention_1.default.SHIELD360_AGENT_VERSION_HASH, versionHash);
359
+ }
360
+ }
361
+ catch {
362
+ // Never fail the wrapped call on hash issues.
363
+ }
364
+ const versionLabel = (0, helpers_1.getCurrentAgentVersion)();
365
+ if (versionLabel) {
366
+ versionExtras[semantic_convention_1.default.GEN_AI_AGENT_VERSION] = versionLabel;
367
+ span.setAttribute(semantic_convention_1.default.GEN_AI_AGENT_VERSION, versionLabel);
368
+ }
369
+ if (captureContent) {
370
+ const textContent = (result.content || [])
371
+ .filter((b) => b.type === 'text')
372
+ .map((b) => b.text || '')
373
+ .join('');
374
+ const toolCallsForOutput = toolUseBlocks.length > 0
375
+ ? toolUseBlocks.map((b) => ({
376
+ id: b.id || '',
377
+ name: b.name || '',
378
+ arguments: b.input || {},
379
+ }))
380
+ : undefined;
381
+ outputMessagesJson = helpers_1.default.buildOutputMessages(textContent, finishReason, toolCallsForOutput);
382
+ span.setAttribute(semantic_convention_1.default.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
383
+ const systemStr = typeof system === 'string' ? system : undefined;
384
+ inputMessagesJson = helpers_1.default.buildInputMessages(messages || [], systemStr);
385
+ }
386
+ if (toolDefinitionsJson) {
387
+ span.setAttribute(semantic_convention_1.default.GEN_AI_TOOL_DEFINITIONS, toolDefinitionsJson);
388
+ }
389
+ if (!config_1.default.disableEvents) {
390
+ const eventAttrs = {
391
+ [semantic_convention_1.default.GEN_AI_OPERATION]: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT,
392
+ [semantic_convention_1.default.GEN_AI_REQUEST_MODEL]: requestModel,
393
+ [semantic_convention_1.default.GEN_AI_RESPONSE_MODEL]: responseModel,
394
+ [semantic_convention_1.default.SERVER_ADDRESS]: AnthropicWrapper.serverAddress,
395
+ [semantic_convention_1.default.SERVER_PORT]: AnthropicWrapper.serverPort,
396
+ [semantic_convention_1.default.GEN_AI_RESPONSE_ID]: result.id,
397
+ [semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON]: [finishReason],
398
+ [semantic_convention_1.default.GEN_AI_OUTPUT_TYPE]: outputType,
399
+ [semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
400
+ [semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
401
+ ...versionExtras,
402
+ };
403
+ if (captureContent) {
404
+ if (inputMessagesJson)
405
+ eventAttrs[semantic_convention_1.default.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
406
+ if (outputMessagesJson)
407
+ eventAttrs[semantic_convention_1.default.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
408
+ }
409
+ if (toolDefinitionsJson)
410
+ eventAttrs[semantic_convention_1.default.GEN_AI_TOOL_DEFINITIONS] = toolDefinitionsJson;
411
+ helpers_1.default.emitInferenceEvent(span, eventAttrs);
412
+ }
413
+ return {
414
+ genAIEndpoint,
415
+ model: requestModel,
416
+ user,
417
+ cost,
418
+ aiSystem: AnthropicWrapper.aiSystem,
419
+ };
420
+ }
421
+ }
422
+ AnthropicWrapper.aiSystem = semantic_convention_1.default.GEN_AI_SYSTEM_ANTHROPIC;
423
+ AnthropicWrapper.serverAddress = 'api.anthropic.com';
424
+ AnthropicWrapper.serverPort = 443;
425
+ exports.default = AnthropicWrapper;
426
+ //# sourceMappingURL=wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../../src/instrumentation/anthropic/wrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAwF;AACxF,0DAA2C;AAC3C,yDAIuB;AACvB,oFAA2D;AAC3D,mEAA0C;AAE1C,MAAM,iBAAiB,GAA2B;IAChD,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,QAAQ;IACpB,aAAa,EAAE,MAAM;IACrB,QAAQ,EAAE,WAAW;CACtB,CAAC;AAEF,SAAS,eAAe,CAAC,MAAc;IACrC,OAAO,iBAAiB,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,MAAM,CAAC;AACvD,CAAC;AAED,SAAS,iBAAiB,CACxB,aAAqB,EACrB,YAAoB;IAEpB,OAAO;QACL,CAAC,6BAAkB,CAAC,gBAAgB,CAAC,EAAE,aAAa;QACpD,CAAC,6BAAkB,CAAC,yBAAyB,CAAC,EAAE,gBAAgB,CAAC,QAAQ;QACzE,CAAC,6BAAkB,CAAC,oBAAoB,CAAC,EAAE,YAAY;QACvD,CAAC,6BAAkB,CAAC,cAAc,CAAC,EAAE,gBAAgB,CAAC,aAAa;QACnE,CAAC,6BAAkB,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAC,UAAU;KAC9D,CAAC;AACJ,CAAC;AAED,MAAqB,gBAAiB,SAAQ,sBAAW;IAKvD,MAAM,CAAC,mBAAmB,CAAC,MAAc;QACvC,MAAM,aAAa,GAAG,8BAA8B,CAAC;QACrD,OAAO,CAAC,cAAuC,EAAE,EAAE;YACjD,OAAO,KAAK,WAAsB,GAAG,IAAW;gBAC9C,IAAI,IAAA,8BAAoB,GAAE;oBAAE,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,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G,GAAG,CAAC;kBAHL,gBAAgB"}
@@ -0,0 +1,12 @@
1
+ import { InstrumentationBase, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';
2
+ import { InstrumentationConfig } from '@opentelemetry/instrumentation';
3
+ export interface AssemblyAIInstrumentationConfig extends InstrumentationConfig {
4
+ }
5
+ export default class Shield360AssemblyAIInstrumentation extends InstrumentationBase {
6
+ private _transcriptsProto;
7
+ constructor(config?: AssemblyAIInstrumentationConfig);
8
+ protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[];
9
+ manualPatch(assemblyai: any): void;
10
+ protected _patch(moduleExports: any, moduleVersion?: string): void;
11
+ protected _unpatch(moduleExports: any): void;
12
+ }
@@ -0,0 +1,91 @@
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 wrapper_1 = __importDefault(require("./wrapper"));
10
+ const TRANSCRIBE_METHODS = ['transcribe', 'submit', 'get'];
11
+ class Shield360AssemblyAIInstrumentation extends instrumentation_1.InstrumentationBase {
12
+ constructor(config = {}) {
13
+ super(`${constant_1.INSTRUMENTATION_PREFIX}/instrumentation-assemblyai`, '1.0.0', config);
14
+ this._transcriptsProto = null;
15
+ }
16
+ init() {
17
+ const assemblyaiModule = new instrumentation_1.InstrumentationNodeModuleDefinition('assemblyai', ['>=4.0.0'], (moduleExports, moduleVersion) => {
18
+ this._patch(moduleExports, moduleVersion);
19
+ return moduleExports;
20
+ }, (moduleExports) => {
21
+ if (moduleExports !== undefined) {
22
+ this._unpatch(moduleExports);
23
+ }
24
+ });
25
+ return [assemblyaiModule];
26
+ }
27
+ manualPatch(assemblyai) {
28
+ this._patch(assemblyai);
29
+ }
30
+ _patch(moduleExports, moduleVersion) {
31
+ try {
32
+ const OriginalAssemblyAIClient = moduleExports.AssemblyAI;
33
+ if (!OriginalAssemblyAIClient || typeof OriginalAssemblyAIClient !== 'function') {
34
+ return;
35
+ }
36
+ if ((0, instrumentation_1.isWrapped)(OriginalAssemblyAIClient)) {
37
+ this._unwrap(moduleExports, 'AssemblyAI');
38
+ }
39
+ const tracer = this.tracer;
40
+ const sdkVersion = moduleVersion ? String(moduleVersion) : undefined;
41
+ // Capture instance helpers in closures so the wrapped constructor (a plain
42
+ // function expression, required to carry the original's static surface)
43
+ // never needs to alias `this`.
44
+ const wrap = this._wrap.bind(this);
45
+ const rememberTranscriptsProto = (proto) => {
46
+ this._transcriptsProto = proto;
47
+ };
48
+ this._wrap(moduleExports, 'AssemblyAI', (original) => {
49
+ const WrappedAssemblyAI = function (...clientArgs) {
50
+ const client = new original(...clientArgs);
51
+ if (client && client.transcripts) {
52
+ const transcriptsProto = Object.getPrototypeOf(client.transcripts);
53
+ if (transcriptsProto) {
54
+ rememberTranscriptsProto(transcriptsProto);
55
+ for (const methodName of TRANSCRIBE_METHODS) {
56
+ if (typeof transcriptsProto[methodName] === 'function' &&
57
+ !(0, instrumentation_1.isWrapped)(transcriptsProto[methodName])) {
58
+ wrap(transcriptsProto, methodName, wrapper_1.default._patchTranscribe(tracer, methodName, sdkVersion));
59
+ }
60
+ }
61
+ }
62
+ }
63
+ return client;
64
+ };
65
+ // Preserve the original constructor's static surface (static methods,
66
+ // properties and metadata) so consumers relying on them still work.
67
+ Object.setPrototypeOf(WrappedAssemblyAI, original);
68
+ Object.assign(WrappedAssemblyAI, original);
69
+ WrappedAssemblyAI.prototype = original.prototype;
70
+ return WrappedAssemblyAI;
71
+ });
72
+ }
73
+ catch (e) {
74
+ api_1.diag.error('assemblyai instrumentation: error in _patch method', e);
75
+ }
76
+ }
77
+ _unpatch(moduleExports) {
78
+ if (moduleExports.AssemblyAI) {
79
+ this._unwrap(moduleExports, 'AssemblyAI');
80
+ }
81
+ if (this._transcriptsProto) {
82
+ for (const methodName of TRANSCRIBE_METHODS) {
83
+ if ((0, instrumentation_1.isWrapped)(this._transcriptsProto[methodName])) {
84
+ this._unwrap(this._transcriptsProto, methodName);
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+ exports.default = Shield360AssemblyAIInstrumentation;
91
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/instrumentation/assemblyai/index.ts"],"names":[],"mappings":";;;;;AAAA,oEAKwC;AAExC,4CAA0C;AAC1C,6CAAwD;AACxD,wDAA0C;AAI1C,MAAM,kBAAkB,GAAG,CAAC,YAAY,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;AAE3D,MAAqB,kCAAmC,SAAQ,qCAAmB;IAGjF,YAAY,SAA0C,EAAE;QACtD,KAAK,CAAC,GAAG,iCAAsB,6BAA6B,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAHzE,sBAAiB,GAAQ,IAAI,CAAC;IAItC,CAAC;IAES,IAAI;QACZ,MAAM,gBAAgB,GAAG,IAAI,qDAAmC,CAC9D,YAAY,EACZ,CAAC,SAAS,CAAC,EACX,CAAC,aAAa,EAAE,aAAa,EAAE,EAAE;YAC/B,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;YAC1C,OAAO,aAAa,CAAC;QACvB,CAAC,EACD,CAAC,aAAa,EAAE,EAAE;YAChB,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAChC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC,CACF,CAAC;QAEF,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC5B,CAAC;IAEM,WAAW,CAAC,UAAe;QAChC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC1B,CAAC;IAES,MAAM,CAAC,aAAkB,EAAE,aAAsB;QACzD,IAAI,CAAC;YACH,MAAM,wBA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,CAAC,EACxC,CAAC;oCACD,IAAI,CACF,gBAAgB,EAChB,UAAU,EACV,iBAAiB,CAAC,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,CACnE,CAAC;gCACJ,CAAC;4BACH,CAAC;wBACH,CAAC;oBACH,CAAC;oBAED,OAAO,MAAM,CAAC;gBAChB,CAAC,CAAC;gBAEF,sEAAsE;gBACtE,oEAAoE;gBACpE,MAAM,CAAC,cAAc,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;gBACnD,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;gBAC3C,iBAAiB,CAAC,SAAS,GAAI,QAAgB,CAAC,SAAS,CAAC;gBAE1D,OAAO,iBAAiB,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,UAAI,CAAC,KAAK,CAAC,oDAAoD,EAAE,CAAC,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;IAES,QAAQ,CAAC,aAAkB;QACnC,IAAI,aAAa,CAAC,UAAU,EAAE,CAAC;YAC7B,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,KAAK,MAAM,UAAU,IAAI,kBAAkB,EAAE,CAAC;gBAC5C,IAAI,IAAA,2BAAS,EAAC,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;oBAClD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;gBACnD,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAvGD,qDAuGC"}
@@ -0,0 +1,35 @@
1
+ import { Span, Tracer } from '@opentelemetry/api';
2
+ import BaseWrapper, { BaseSpanAttributes } from '../base-wrapper';
3
+ declare class AssemblyAIWrapper extends BaseWrapper {
4
+ static aiSystem: string;
5
+ static serverAddress: string;
6
+ static serverPort: number;
7
+ /**
8
+ * Parse the request arguments of `client.transcripts.transcribe` / `submit` / `get`.
9
+ * AssemblyAI accepts either a params object (`{ audio, speechModel, ... }`) or, for
10
+ * `get`, a transcript id string. Mirrors the Python instrumentor which reads
11
+ * `speech_model` from kwargs (default "best").
12
+ */
13
+ static _parseAudioArgs(args: any[]): {
14
+ options: Record<string, any>;
15
+ requestModel: string;
16
+ audioUrl: string;
17
+ };
18
+ /**
19
+ * Prefer the model stamped on the Transcript response (e.g. transcripts.get
20
+ * polls only pass a transcript id). Fall back to request args, then "best".
21
+ */
22
+ static _resolveRequestModel(args: any[], response: any): string;
23
+ static _patchTranscribe(tracer: Tracer, methodName: string, sdkVersion?: string): any;
24
+ static _commonAudioSetter({ args, genAIEndpoint, response, span, ttft, tbt, isStream, sdkVersion, }: {
25
+ args: any[];
26
+ genAIEndpoint: string;
27
+ response: any;
28
+ span: Span;
29
+ ttft?: number;
30
+ tbt?: number;
31
+ isStream?: boolean;
32
+ sdkVersion?: string;
33
+ }): BaseSpanAttributes;
34
+ }
35
+ export default AssemblyAIWrapper;