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,10 @@
1
+ import { InstrumentationBase, InstrumentationConfig, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';
2
+ export interface LettaInstrumentationConfig extends InstrumentationConfig {
3
+ }
4
+ export default class Shield360LettaInstrumentation extends InstrumentationBase {
5
+ constructor(config?: LettaInstrumentationConfig);
6
+ protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[];
7
+ manualPatch(letta: any): void;
8
+ private _patchClass;
9
+ private _unpatchClass;
10
+ }
@@ -0,0 +1,122 @@
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 AGENT_METHODS = [
11
+ ['create', 'letta.create'],
12
+ ['retrieve', 'letta.retrieve'],
13
+ ['update', 'letta.modify'],
14
+ ['delete', 'letta.delete'],
15
+ ['list', 'letta.list'],
16
+ ];
17
+ const MESSAGE_METHODS = [
18
+ ['create', 'letta.create_message'],
19
+ ['stream', 'letta.create_stream'],
20
+ ['createAsync', 'letta.create_async'],
21
+ ['list', 'letta.list'],
22
+ ['cancel', 'letta.cancel'],
23
+ ['reset', 'letta.reset'],
24
+ ];
25
+ const MEMORY_METHODS = [
26
+ ['create', 'letta.create'],
27
+ ['retrieve', 'letta.retrieve'],
28
+ ['update', 'letta.modify'],
29
+ ['delete', 'letta.delete'],
30
+ ['list', 'letta.list'],
31
+ ];
32
+ const AGENT_BLOCK_METHODS = [
33
+ ['retrieve', 'letta.retrieve'],
34
+ ['update', 'letta.modify'],
35
+ ['list', 'letta.list'],
36
+ ['attach', 'letta.attach'],
37
+ ['detach', 'letta.detach'],
38
+ ];
39
+ const AGENT_ATTACH_METHODS = [
40
+ ['list', 'letta.list'],
41
+ ['attach', 'letta.attach'],
42
+ ['detach', 'letta.detach'],
43
+ ];
44
+ const PASSAGE_METHODS = [
45
+ ['create', 'letta.create'],
46
+ ['list', 'letta.list'],
47
+ ['delete', 'letta.delete'],
48
+ ];
49
+ const LETTA_MODULES = [
50
+ { file: 'resources/agents/agents.js', className: 'Agents', methods: AGENT_METHODS, agentScoped: true },
51
+ { file: 'resources/agents/messages.js', className: 'Messages', methods: MESSAGE_METHODS, agentScoped: true },
52
+ { file: 'resources/blocks/blocks.js', className: 'Blocks', methods: MEMORY_METHODS, agentScoped: false },
53
+ { file: 'resources/agents/blocks.js', className: 'Blocks', methods: AGENT_BLOCK_METHODS, agentScoped: true },
54
+ { file: 'resources/tools.js', className: 'Tools', methods: MEMORY_METHODS, agentScoped: false },
55
+ { file: 'resources/agents/tools.js', className: 'Tools', methods: AGENT_ATTACH_METHODS, agentScoped: true },
56
+ { file: 'resources/folders/folders.js', className: 'Folders', methods: MEMORY_METHODS, agentScoped: false },
57
+ { file: 'resources/agents/folders.js', className: 'Folders', methods: AGENT_ATTACH_METHODS, agentScoped: true },
58
+ { file: 'resources/agents/passages.js', className: 'Passages', methods: PASSAGE_METHODS, agentScoped: true },
59
+ ];
60
+ const PACKAGE = '@letta-ai/letta-client';
61
+ const VERSIONS = ['>=0.1.0'];
62
+ class Shield360LettaInstrumentation extends instrumentation_1.InstrumentationBase {
63
+ constructor(config = {}) {
64
+ super(`${constant_1.INSTRUMENTATION_PREFIX}/instrumentation-letta`, '1.0.0', config);
65
+ }
66
+ init() {
67
+ // The Letta client exposes resource classes as nested objects (client.agents,
68
+ // client.agents.messages, ...), each defined in its own internal module file.
69
+ // require-in-the-middle reaches those files via the `files` array, so every
70
+ // resource class is registered as an InstrumentationNodeModuleFile.
71
+ const files = LETTA_MODULES.map((mod) => new instrumentation_1.InstrumentationNodeModuleFile(`${PACKAGE}/${mod.file}`, VERSIONS, (moduleExports, moduleVersion) => {
72
+ this._patchClass(moduleExports?.[mod.className], mod.methods, mod.agentScoped, moduleVersion);
73
+ return moduleExports;
74
+ }, (moduleExports) => {
75
+ if (moduleExports !== undefined)
76
+ this._unpatchClass(moduleExports?.[mod.className], mod.methods);
77
+ }));
78
+ const module = new instrumentation_1.InstrumentationNodeModuleDefinition(PACKAGE, VERSIONS, (moduleExports) => moduleExports, () => { }, files);
79
+ return [module];
80
+ }
81
+ manualPatch(letta) {
82
+ // Fallback entry point. Best-effort: look each resource class up by name on the
83
+ // object passed in; the isWrapped guard in _patchClass keeps repeat calls safe.
84
+ for (const mod of LETTA_MODULES) {
85
+ this._patchClass(letta?.[mod.className], mod.methods, mod.agentScoped);
86
+ }
87
+ }
88
+ _patchClass(target, methods, agentScoped, moduleVersion) {
89
+ try {
90
+ const proto = target?.prototype;
91
+ if (!proto)
92
+ return;
93
+ for (const [method, endpoint] of methods) {
94
+ if (typeof proto[method] !== 'function')
95
+ continue;
96
+ if ((0, instrumentation_1.isWrapped)(proto[method]))
97
+ continue;
98
+ this._wrap(proto, method, wrapper_1.default._patchOperation(this.tracer, endpoint, agentScoped, moduleVersion));
99
+ }
100
+ }
101
+ catch (e) {
102
+ api_1.diag.error('letta instrumentation: error in _patch method', e);
103
+ }
104
+ }
105
+ _unpatchClass(target, methods) {
106
+ try {
107
+ const proto = target?.prototype;
108
+ if (!proto)
109
+ return;
110
+ for (const [method] of methods) {
111
+ if (typeof proto[method] === 'function' && (0, instrumentation_1.isWrapped)(proto[method])) {
112
+ this._unwrap(proto, method);
113
+ }
114
+ }
115
+ }
116
+ catch {
117
+ /* ignore */
118
+ }
119
+ }
120
+ }
121
+ exports.default = Shield360LettaInstrumentation;
122
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/instrumentation/letta/index.ts"],"names":[],"mappings":";;;;;AAAA,oEAOwC;AACxC,4CAA0C;AAC1C,6CAAwD;AACxD,wDAAqC;AAqBrC,MAAM,aAAa,GAA4B;IAC7C,CAAC,QAAQ,EAAE,cAAc,CAAC;IAC1B,CAAC,UAAU,EAAE,gBAAgB,CAAC;IAC9B,CAAC,QAAQ,EAAE,cAAc,CAAC;IAC1B,CAAC,QAAQ,EAAE,cAAc,CAAC;IAC1B,CAAC,MAAM,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,MAAM,eAAe,GAA4B;IAC/C,CAAC,QAAQ,EAAE,sBAAsB,CAAC;IAClC,CAAC,QAAQ,EAAE,qBAAqB,CAAC;IACjC,CAAC,aAAa,EAAE,oBAAoB,CAAC;IACrC,CAAC,MAAM,EAAE,YAAY,CAAC;IACtB,CAAC,QAAQ,EAAE,cAAc,CAAC;IAC1B,CAAC,OAAO,EAAE,aAAa,CAAC;CACzB,CAAC;AAEF,MAAM,cAAc,GAA4B;I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AC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,UAAI,CAAC,KAAK,CAAC,+CAA+C,EAAE,CAAC,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAEO,aAAa,CAAC,MAAW,EAAE,OAAgC;QACjE,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,EAAE,SAAS,CAAC;YAChC,IAAI,CAAC,KAAK;gBAAE,OAAO;YACnB,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;gBAC/B,IAAI,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,UAAU,IAAI,IAAA,2BAAS,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;oBACpE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBAC9B,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,YAAY;QACd,CAAC;IACH,CAAC;CACF;AA5ED,gDA4EC"}
@@ -0,0 +1,24 @@
1
+ import { Span } from '@opentelemetry/api';
2
+ export declare const DEFAULT_MODEL = "gpt-4o";
3
+ export declare const DEFAULT_SERVER_ADDRESS = "api.letta.com";
4
+ export declare const DEFAULT_SERVER_PORT = 443;
5
+ /**
6
+ * Operation type per Letta method name. Mirrors OPERATION_TYPE_MAP in the Python
7
+ * reference (sdk/python/src/shield360/instrumentation/letta/utils.py). The type is
8
+ * keyed on the method suffix so identical calls emit identical telemetry in both
9
+ * SDKs. Anything unmapped falls back to `workflow`.
10
+ */
11
+ export declare const OPERATION_TYPE_MAP: Record<string, string>;
12
+ export declare function getOperationType(endpoint: string): string;
13
+ /**
14
+ * Span name generation ported from Python's get_span_name. The span name is built
15
+ * before the call runs, so it uses only the request: chat spans follow the
16
+ * provider pattern `chat {model}`; agent spans use `{operation} {agent_name}`;
17
+ * workflow/tool spans use the method suffix.
18
+ */
19
+ export declare function getSpanName(operationType: string, endpoint: string, instance?: any, body?: any): string;
20
+ /**
21
+ * Sets the common framework + Letta-specific attributes on a span. Mirrors
22
+ * process_letta_response + common_framework_span_attributes in the Python reference.
23
+ */
24
+ export declare function processLettaResponse(span: Span, response: any, body: any, operationType: string, instance: any, durationSeconds: number, sdkVersion: string, agentId?: string): void;
@@ -0,0 +1,343 @@
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
+ exports.OPERATION_TYPE_MAP = exports.DEFAULT_SERVER_PORT = exports.DEFAULT_SERVER_ADDRESS = exports.DEFAULT_MODEL = void 0;
40
+ exports.getOperationType = getOperationType;
41
+ exports.getSpanName = getSpanName;
42
+ exports.processLettaResponse = processLettaResponse;
43
+ const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
44
+ const config_1 = __importDefault(require("../../config"));
45
+ const constant_1 = require("../../constant");
46
+ const helpers_1 = __importStar(require("../../helpers"));
47
+ const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
48
+ exports.DEFAULT_MODEL = 'gpt-4o';
49
+ exports.DEFAULT_SERVER_ADDRESS = 'api.letta.com';
50
+ exports.DEFAULT_SERVER_PORT = 443;
51
+ /**
52
+ * Operation type per Letta method name. Mirrors OPERATION_TYPE_MAP in the Python
53
+ * reference (sdk/python/src/shield360/instrumentation/letta/utils.py). The type is
54
+ * keyed on the method suffix so identical calls emit identical telemetry in both
55
+ * SDKs. Anything unmapped falls back to `workflow`.
56
+ */
57
+ exports.OPERATION_TYPE_MAP = {
58
+ create: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CREATE_AGENT,
59
+ retrieve: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_AGENT,
60
+ modify: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_AGENT,
61
+ delete: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_AGENT,
62
+ list: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_WORKFLOW,
63
+ create_stream: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT,
64
+ create_message: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT,
65
+ create_async: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT,
66
+ cancel: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT,
67
+ reset: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT,
68
+ attach: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_TOOLS,
69
+ detach: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_TOOLS,
70
+ };
71
+ function getOperationType(endpoint) {
72
+ const method = endpoint.split('.').pop() || 'unknown';
73
+ return exports.OPERATION_TYPE_MAP[method] ?? semantic_convention_1.default.GEN_AI_OPERATION_TYPE_WORKFLOW;
74
+ }
75
+ /** Resolve the model name from response / request in the same priority order as Python. */
76
+ function resolveModel(response, body) {
77
+ if (response?.llm_config?.model)
78
+ return response.llm_config.model;
79
+ if (body?.model)
80
+ return body.model;
81
+ return exports.DEFAULT_MODEL;
82
+ }
83
+ /**
84
+ * Span name generation ported from Python's get_span_name. The span name is built
85
+ * before the call runs, so it uses only the request: chat spans follow the
86
+ * provider pattern `chat {model}`; agent spans use `{operation} {agent_name}`;
87
+ * workflow/tool spans use the method suffix.
88
+ */
89
+ function getSpanName(operationType, endpoint, instance, body) {
90
+ const method = endpoint.split('.').pop() || 'unknown';
91
+ if (operationType === semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT) {
92
+ return `chat ${body?.model || exports.DEFAULT_MODEL}`;
93
+ }
94
+ if (operationType === semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CREATE_AGENT ||
95
+ operationType === semantic_convention_1.default.GEN_AI_OPERATION_TYPE_AGENT) {
96
+ let agentName = 'agent';
97
+ if (body?.name)
98
+ agentName = body.name;
99
+ else if (body?.slug)
100
+ agentName = body.slug;
101
+ else if (instance?.name)
102
+ agentName = instance.name;
103
+ else if (instance?.slug)
104
+ agentName = instance.slug;
105
+ else if (body?.agent_id)
106
+ agentName = `agent-${String(body.agent_id).slice(0, 8)}`;
107
+ if (agentName && agentName !== 'agent') {
108
+ agentName = agentName.replace(/ /g, '_').replace(/-/g, '_').toLowerCase();
109
+ if (agentName.length > 20)
110
+ agentName = agentName.slice(0, 20);
111
+ }
112
+ return `${operationType} ${agentName}`;
113
+ }
114
+ if (operationType === semantic_convention_1.default.GEN_AI_OPERATION_TYPE_WORKFLOW) {
115
+ return `workflow ${method}`;
116
+ }
117
+ if (operationType === semantic_convention_1.default.GEN_AI_OPERATION_TYPE_TOOLS) {
118
+ return `tool ${method}`;
119
+ }
120
+ return `${operationType} ${method}`;
121
+ }
122
+ function truncateContent(content) {
123
+ const limit = config_1.default.maxContentLength;
124
+ if (typeof limit === 'number' && limit > 0 && content.length > limit) {
125
+ return content.slice(0, limit);
126
+ }
127
+ return content;
128
+ }
129
+ function resolveServerInfo(instance) {
130
+ let baseUrl;
131
+ if (instance) {
132
+ baseUrl =
133
+ instance._client?.baseURL ??
134
+ instance._client_wrapper?._base_url ??
135
+ instance._client?.base_url ??
136
+ instance.baseURL ??
137
+ instance.base_url ??
138
+ instance._base_url;
139
+ }
140
+ if (baseUrl) {
141
+ try {
142
+ const parsed = new URL(String(baseUrl));
143
+ if (parsed.hostname) {
144
+ const port = parsed.port
145
+ ? Number(parsed.port)
146
+ : parsed.protocol === 'https:'
147
+ ? 443
148
+ : 80;
149
+ return [parsed.hostname, port];
150
+ }
151
+ }
152
+ catch {
153
+ /* ignore malformed base url */
154
+ }
155
+ }
156
+ return [exports.DEFAULT_SERVER_ADDRESS, exports.DEFAULT_SERVER_PORT];
157
+ }
158
+ function setLlmConfigAttributes(span, llmConfig) {
159
+ if (!llmConfig)
160
+ return;
161
+ if (llmConfig.model)
162
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_MODEL, llmConfig.model);
163
+ if (llmConfig.provider_name) {
164
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_PROVIDER, llmConfig.provider_name);
165
+ }
166
+ if (llmConfig.model_endpoint) {
167
+ span.setAttribute(semantic_convention_1.default.GEN_AI_ENDPOINT, llmConfig.model_endpoint);
168
+ }
169
+ if (llmConfig.temperature != null) {
170
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_TEMPERATURE, llmConfig.temperature);
171
+ }
172
+ if (llmConfig.max_tokens != null) {
173
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, llmConfig.max_tokens);
174
+ }
175
+ if (llmConfig.frequency_penalty != null) {
176
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_FREQUENCY_PENALTY, llmConfig.frequency_penalty);
177
+ }
178
+ if (llmConfig.context_window != null) {
179
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_CONTEXT_WINDOW, llmConfig.context_window);
180
+ }
181
+ if (llmConfig.enable_reasoner != null) {
182
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_ENABLE_REASONER, llmConfig.enable_reasoner);
183
+ }
184
+ if (llmConfig.reasoning_effort != null) {
185
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_REASONING_EFFORT, llmConfig.reasoning_effort);
186
+ }
187
+ if (llmConfig.max_reasoning_tokens != null) {
188
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_REASONING_TOKENS, llmConfig.max_reasoning_tokens);
189
+ }
190
+ if (llmConfig.handle != null) {
191
+ span.setAttribute(semantic_convention_1.default.GEN_AI_MODEL_HANDLE, llmConfig.handle);
192
+ }
193
+ }
194
+ function setUsageAttributes(span, usage) {
195
+ if (!usage)
196
+ return;
197
+ if (usage.prompt_tokens != null) {
198
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS, usage.prompt_tokens);
199
+ }
200
+ if (usage.completion_tokens != null) {
201
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS, usage.completion_tokens);
202
+ }
203
+ if (usage.total_tokens != null) {
204
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_TOTAL_TOKENS, usage.total_tokens);
205
+ }
206
+ if (usage.step_count != null) {
207
+ span.setAttribute(semantic_convention_1.default.GEN_AI_AGENT_STEP_COUNT, usage.step_count);
208
+ }
209
+ if (usage.run_ids != null) {
210
+ span.setAttribute(semantic_convention_1.default.GEN_AI_RUN_ID, String(usage.run_ids));
211
+ }
212
+ if (usage.steps_messages != null) {
213
+ span.setAttribute(semantic_convention_1.default.GEN_AI_AGENT_STEP_MESSAGES, JSON.stringify(usage.steps_messages));
214
+ }
215
+ }
216
+ function setRequestAttributes(span, body, operationType) {
217
+ if (!body || typeof body !== 'object')
218
+ return;
219
+ if (body.model != null)
220
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_MODEL, String(body.model));
221
+ if (body.temperature != null) {
222
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_TEMPERATURE, body.temperature);
223
+ }
224
+ if (body.max_tokens != null) {
225
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_MAX_TOKENS, body.max_tokens);
226
+ }
227
+ if (body.frequency_penalty != null) {
228
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_FREQUENCY_PENALTY, body.frequency_penalty);
229
+ }
230
+ if (body.stream != null)
231
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_IS_STREAM, body.stream);
232
+ else if (body.streaming != null) {
233
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_IS_STREAM, body.streaming);
234
+ }
235
+ if (body.run_async != null)
236
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_ASYNC, body.run_async);
237
+ if (body.return_message_sequence_no != null) {
238
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_RETURN_SEQUENCE_NO, body.return_message_sequence_no);
239
+ }
240
+ if (body.include_final_message != null) {
241
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_INCLUDE_FINAL_MESSAGE, body.include_final_message);
242
+ }
243
+ if (operationType === semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT && Array.isArray(body.messages)) {
244
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_MESSAGE_COUNT, body.messages.length);
245
+ }
246
+ }
247
+ function setLettaSpecificAttributes(span, body, response, operationType, agentId) {
248
+ let resolvedAgentId = agentId;
249
+ if (!resolvedAgentId && body?.agent_id)
250
+ resolvedAgentId = String(body.agent_id);
251
+ else if (!resolvedAgentId && response?.id)
252
+ resolvedAgentId = String(response.id);
253
+ if (resolvedAgentId)
254
+ span.setAttribute(semantic_convention_1.default.GEN_AI_AGENT_ID, resolvedAgentId);
255
+ if (response) {
256
+ if (response.name != null)
257
+ span.setAttribute(semantic_convention_1.default.GEN_AI_AGENT_NAME, String(response.name));
258
+ if (response.slug != null)
259
+ span.setAttribute(semantic_convention_1.default.GEN_AI_AGENT_SLUG, String(response.slug));
260
+ if (response.description != null) {
261
+ span.setAttribute(semantic_convention_1.default.GEN_AI_AGENT_DESCRIPTION, String(response.description));
262
+ }
263
+ if (response.agent_type != null) {
264
+ span.setAttribute(semantic_convention_1.default.GEN_AI_AGENT_TYPE, response.agent_type);
265
+ }
266
+ if (response.system != null) {
267
+ span.setAttribute(semantic_convention_1.default.GEN_AI_AGENT_INSTRUCTIONS, truncateContent(String(response.system)));
268
+ }
269
+ if (response.llm_config)
270
+ setLlmConfigAttributes(span, response.llm_config);
271
+ if (operationType === semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT && response.usage) {
272
+ setUsageAttributes(span, response.usage);
273
+ }
274
+ }
275
+ setRequestAttributes(span, body, operationType);
276
+ if (body?.name != null)
277
+ span.setAttribute(semantic_convention_1.default.GEN_AI_AGENT_NAME, String(body.name));
278
+ if (body?.slug != null)
279
+ span.setAttribute(semantic_convention_1.default.GEN_AI_AGENT_SLUG, String(body.slug));
280
+ }
281
+ function serializeContent(value) {
282
+ try {
283
+ return JSON.stringify(value);
284
+ }
285
+ catch {
286
+ return String(value);
287
+ }
288
+ }
289
+ function setContentAttributes(span, body, response) {
290
+ if (body?.messages != null) {
291
+ span.setAttribute(semantic_convention_1.default.GEN_AI_INPUT_MESSAGES, serializeContent(body.messages));
292
+ }
293
+ if (response?.messages != null) {
294
+ span.setAttribute(semantic_convention_1.default.GEN_AI_OUTPUT_MESSAGES, serializeContent(response.messages));
295
+ }
296
+ }
297
+ function calculateCost(span, response, model) {
298
+ const pricingInfo = config_1.default.pricingInfo;
299
+ if (!pricingInfo || !response)
300
+ return;
301
+ let usage = response.usage;
302
+ if (!usage && Array.isArray(response)) {
303
+ for (let i = response.length - 1; i >= 0; i -= 1) {
304
+ if (response[i]?.message_type === 'usage_statistics') {
305
+ usage = response[i];
306
+ break;
307
+ }
308
+ }
309
+ }
310
+ if (usage && usage.prompt_tokens != null && usage.completion_tokens != null) {
311
+ const actualModel = response.llm_config?.model || model;
312
+ const cost = helpers_1.default.getChatModelCost(actualModel, pricingInfo, usage.prompt_tokens, usage.completion_tokens);
313
+ span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_COST, cost);
314
+ }
315
+ }
316
+ /**
317
+ * Sets the common framework + Letta-specific attributes on a span. Mirrors
318
+ * process_letta_response + common_framework_span_attributes in the Python reference.
319
+ */
320
+ function processLettaResponse(span, response, body, operationType, instance, durationSeconds, sdkVersion, agentId) {
321
+ const model = resolveModel(response, body);
322
+ const [serverAddress, serverPort] = resolveServerInfo(instance);
323
+ span.setAttribute(semantic_conventions_1.ATTR_TELEMETRY_SDK_NAME, constant_1.SDK_NAME);
324
+ span.setAttribute(semantic_convention_1.default.GEN_AI_SDK_VERSION, sdkVersion);
325
+ span.setAttribute(semantic_convention_1.default.GEN_AI_PROVIDER_NAME, semantic_convention_1.default.GEN_AI_SYSTEM_LETTA);
326
+ span.setAttribute(semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL, semantic_convention_1.default.GEN_AI_SYSTEM_LETTA);
327
+ span.setAttribute(semantic_convention_1.default.GEN_AI_OPERATION, operationType);
328
+ span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_MODEL, model);
329
+ span.setAttribute(semantic_convention_1.default.SERVER_ADDRESS, serverAddress);
330
+ span.setAttribute(semantic_convention_1.default.SERVER_PORT, serverPort);
331
+ span.setAttribute(semantic_convention_1.default.ATTR_DEPLOYMENT_ENVIRONMENT, config_1.default.environment || '');
332
+ span.setAttribute(semantic_conventions_1.ATTR_SERVICE_NAME, config_1.default.applicationName || '');
333
+ span.setAttribute(semantic_convention_1.default.GEN_AI_CLIENT_OPERATION_DURATION, durationSeconds);
334
+ setLettaSpecificAttributes(span, body, response, operationType, agentId);
335
+ if (operationType === semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT && config_1.default.captureMessageContent) {
336
+ setContentAttributes(span, body, response);
337
+ }
338
+ if (operationType === semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT) {
339
+ calculateCost(span, response, model);
340
+ }
341
+ (0, helpers_1.applyCustomSpanAttributes)(span);
342
+ }
343
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/instrumentation/letta/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,4CAGC;AAeD,kCAkCC;AAoND,oDAoCC;AA3UD,8EAAiG;AACjG,0DAA2C;AAC3C,6CAA0C;AAC1C,yDAA2E;AAC3E,oFAA2D;AAE9C,QAAA,aAAa,GAAG,QAAQ,CAAC;AACzB,QAAA,sBAAsB,GAAG,eAAe,CAAC;AACzC,QAAA,mBAAmB,GAAG,GAAG,CAAC;AAEvC;;;;;GAKG;AACU,QAAA,kBAAkB,GAA2B;IACxD,MAAM,EAAE,6BAAkB,CAAC,kCAAkC;IAC7D,QAAQ,EAAE,6BAAkB,CAAC,2BAA2B;IACxD,MAAM,EAAE,6BAAkB,CAAC,2BAA2B;IACtD,MAAM,EAAE,6BAAkB,CAAC,2BAA2B;IACtD,IAAI,EAAE,6BAAkB,CAAC,8BAA8B;IACvD,aAAa,EAAE,6BAAkB,CAAC,0BAA0B;IAC5D,cAAc,EAAE,6BAAkB,CAAC,0BAA0B;IAC7D,YAAY,EAAE,6BAAkB,CAAC,0BAA0B;IAC3D,MAAM,EAAE,6BAAkB,CAAC,0BAA0B;IACrD,KAAK,EAAE,6BAAkB,CAAC,0BAA0B;IACpD,MAAM,EAAE,6BAAkB,CAAC,2BAA2B;IACtD,MAAM,EAAE,6BAAkB,CAAC,2BAA2B;CACvD,CAAC;AA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IAAI,CAAC,YAAY,CAAC,wCAAiB,EAAE,gBAAe,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC;IAC5E,IAAI,CAAC,YAAY,CAAC,6BAAkB,CAAC,gCAAgC,EAAE,eAAe,CAAC,CAAC;IAExF,0BAA0B,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IAEzE,IAAI,aAAa,KAAK,6BAAkB,CAAC,0BAA0B,IAAI,gBAAe,CAAC,qBAAqB,EAAE,CAAC;QAC7G,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,aAAa,KAAK,6BAAkB,CAAC,0BAA0B,EAAE,CAAC;QACpE,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED,IAAA,mCAAyB,EAAC,IAAI,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { Tracer } from '@opentelemetry/api';
2
+ /**
3
+ * Instrumentation for the Letta agent platform (`@letta-ai/letta-client`). Each
4
+ * patched resource method becomes one CLIENT span whose name and operation type
5
+ * mirror the Python reference (sdk/python/src/shield360/instrumentation/letta): the
6
+ * method suffix drives the operation type via OPERATION_TYPE_MAP, and chat
7
+ * (message) operations stream their response through a traced async iterator.
8
+ */
9
+ declare class LettaWrapper {
10
+ static aiSystem: string;
11
+ /**
12
+ * Wraps a Letta resource method. `endpoint` is the Python-style endpoint id
13
+ * (e.g. `letta.create`, `letta.create_message`) that drives the operation type
14
+ * and span name.
15
+ */
16
+ static _patchOperation(tracer: Tracer, endpoint: string, agentScoped: boolean, version?: string): any;
17
+ /**
18
+ * Non-chat operations return the SDK's own promise untouched. `list` yields a
19
+ * PagePromise whose async iterator drives auto-pagination, so flattening it here
20
+ * would break paging; the span is finalized from a completion callback instead.
21
+ */
22
+ private static _handleOperation;
23
+ /**
24
+ * Chat (message) operations may resolve to a streaming iterator. The resolved
25
+ * value is awaited so a stream can be wrapped in a traced async iterator; a
26
+ * non-streaming response is processed inline.
27
+ */
28
+ private static _handleChat;
29
+ /**
30
+ * Wraps a Letta message stream so chunks flow through untouched while the span
31
+ * accumulates chunk count, TTFT, and the collected messages. Mirrors
32
+ * TracedLettaStream in the Python reference.
33
+ */
34
+ private static _traceStream;
35
+ private static _finalizeError;
36
+ }
37
+ export default LettaWrapper;