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.
- package/LICENSE +201 -0
- package/README.md +310 -0
- package/dist/__tests__/manual-trace.test.d.ts +1 -0
- package/dist/__tests__/manual-trace.test.js +118 -0
- package/dist/__tests__/manual-trace.test.js.map +1 -0
- package/dist/__tests__/register.test.d.ts +0 -0
- package/dist/__tests__/register.test.js +90 -0
- package/dist/__tests__/register.test.js.map +1 -0
- package/dist/config.d.ts +28 -0
- package/dist/config.js +22 -0
- package/dist/config.js.map +1 -0
- package/dist/constant.d.ts +6 -0
- package/dist/constant.js +14 -0
- package/dist/constant.js.map +1 -0
- package/dist/evals/__tests__/offline.test.d.ts +1 -0
- package/dist/evals/__tests__/offline.test.js +427 -0
- package/dist/evals/__tests__/offline.test.js.map +1 -0
- package/dist/evals/index.d.ts +2 -0
- package/dist/evals/index.js +15 -0
- package/dist/evals/index.js.map +1 -0
- package/dist/evals/offline.d.ts +6 -0
- package/dist/evals/offline.js +350 -0
- package/dist/evals/offline.js.map +1 -0
- package/dist/evals/types.d.ts +74 -0
- package/dist/evals/types.js +23 -0
- package/dist/evals/types.js.map +1 -0
- package/dist/features/__tests__/rule-engine.test.d.ts +1 -0
- package/dist/features/__tests__/rule-engine.test.js +146 -0
- package/dist/features/__tests__/rule-engine.test.js.map +1 -0
- package/dist/features/base.d.ts +8 -0
- package/dist/features/base.js +15 -0
- package/dist/features/base.js.map +1 -0
- package/dist/features/prompt-hub.d.ts +4 -0
- package/dist/features/prompt-hub.js +66 -0
- package/dist/features/prompt-hub.js.map +1 -0
- package/dist/features/rule-engine.d.ts +6 -0
- package/dist/features/rule-engine.js +60 -0
- package/dist/features/rule-engine.js.map +1 -0
- package/dist/features/vault.d.ts +4 -0
- package/dist/features/vault.js +63 -0
- package/dist/features/vault.js.map +1 -0
- package/dist/guard/__tests__/findings.test.d.ts +1 -0
- package/dist/guard/__tests__/findings.test.js +79 -0
- package/dist/guard/__tests__/findings.test.js.map +1 -0
- package/dist/guard/__tests__/integration.test.d.ts +1 -0
- package/dist/guard/__tests__/integration.test.js +215 -0
- package/dist/guard/__tests__/integration.test.js.map +1 -0
- package/dist/guard/__tests__/pii.test.d.ts +1 -0
- package/dist/guard/__tests__/pii.test.js +131 -0
- package/dist/guard/__tests__/pii.test.js.map +1 -0
- package/dist/guard/__tests__/pipeline.test.d.ts +1 -0
- package/dist/guard/__tests__/pipeline.test.js +162 -0
- package/dist/guard/__tests__/pipeline.test.js.map +1 -0
- package/dist/guard/__tests__/prompt-injection.test.d.ts +1 -0
- package/dist/guard/__tests__/prompt-injection.test.js +92 -0
- package/dist/guard/__tests__/prompt-injection.test.js.map +1 -0
- package/dist/guard/__tests__/report.test.d.ts +1 -0
- package/dist/guard/__tests__/report.test.js +50 -0
- package/dist/guard/__tests__/report.test.js.map +1 -0
- package/dist/guard/base.d.ts +79 -0
- package/dist/guard/base.js +136 -0
- package/dist/guard/base.js.map +1 -0
- package/dist/guard/custom.d.ts +19 -0
- package/dist/guard/custom.js +46 -0
- package/dist/guard/custom.js.map +1 -0
- package/dist/guard/findings.d.ts +31 -0
- package/dist/guard/findings.js +156 -0
- package/dist/guard/findings.js.map +1 -0
- package/dist/guard/index.d.ts +24 -0
- package/dist/guard/index.js +42 -0
- package/dist/guard/index.js.map +1 -0
- package/dist/guard/integration.d.ts +44 -0
- package/dist/guard/integration.js +363 -0
- package/dist/guard/integration.js.map +1 -0
- package/dist/guard/moderation.d.ts +18 -0
- package/dist/guard/moderation.js +61 -0
- package/dist/guard/moderation.js.map +1 -0
- package/dist/guard/pii.d.ts +17 -0
- package/dist/guard/pii.js +114 -0
- package/dist/guard/pii.js.map +1 -0
- package/dist/guard/pipeline.d.ts +26 -0
- package/dist/guard/pipeline.js +139 -0
- package/dist/guard/pipeline.js.map +1 -0
- package/dist/guard/prompt-injection.d.ts +21 -0
- package/dist/guard/prompt-injection.js +70 -0
- package/dist/guard/prompt-injection.js.map +1 -0
- package/dist/guard/report.d.ts +34 -0
- package/dist/guard/report.js +182 -0
- package/dist/guard/report.js.map +1 -0
- package/dist/guard/schema.d.ts +20 -0
- package/dist/guard/schema.js +99 -0
- package/dist/guard/schema.js.map +1 -0
- package/dist/guard/sensitive-topic.d.ts +23 -0
- package/dist/guard/sensitive-topic.js +89 -0
- package/dist/guard/sensitive-topic.js.map +1 -0
- package/dist/guard/topic-restriction.d.ts +22 -0
- package/dist/guard/topic-restriction.js +54 -0
- package/dist/guard/topic-restriction.js.map +1 -0
- package/dist/helpers.d.ts +246 -0
- package/dist/helpers.js +903 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +234 -0
- package/dist/index.js.map +1 -0
- package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.d.ts +13 -0
- package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.js +176 -0
- package/dist/instrumentation/__tests__/ai21-rag-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/ai21-trace-comparison.test.d.ts +10 -0
- package/dist/instrumentation/__tests__/ai21-trace-comparison.test.js +203 -0
- package/dist/instrumentation/__tests__/ai21-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/anthropic-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/anthropic-wrapper.test.js +284 -0
- package/dist/instrumentation/__tests__/anthropic-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/assemblyai-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/assemblyai-wrapper.test.js +284 -0
- package/dist/instrumentation/__tests__/assemblyai-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/astra-trace-comparison.test.d.ts +7 -0
- package/dist/instrumentation/__tests__/astra-trace-comparison.test.js +160 -0
- package/dist/instrumentation/__tests__/astra-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/base-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/base-wrapper.test.js +171 -0
- package/dist/instrumentation/__tests__/base-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.js +422 -0
- package/dist/instrumentation/__tests__/bedrock-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/browser-use-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/browser-use-wrapper.test.js +284 -0
- package/dist/instrumentation/__tests__/browser-use-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/cache-pricing.test.d.ts +15 -0
- package/dist/instrumentation/__tests__/cache-pricing.test.js +155 -0
- package/dist/instrumentation/__tests__/cache-pricing.test.js.map +1 -0
- package/dist/instrumentation/__tests__/chroma-trace-comparison.test.d.ts +18 -0
- package/dist/instrumentation/__tests__/chroma-trace-comparison.test.js +209 -0
- package/dist/instrumentation/__tests__/chroma-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/cohere-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/cohere-wrapper.test.js +256 -0
- package/dist/instrumentation/__tests__/cohere-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.js +282 -0
- package/dist/instrumentation/__tests__/elevenlabs-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/firecrawl-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/firecrawl-wrapper.test.js +238 -0
- package/dist/instrumentation/__tests__/firecrawl-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.d.ts +4 -0
- package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.js +229 -0
- package/dist/instrumentation/__tests__/google-ai-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/gpu-collector.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/gpu-collector.test.js +247 -0
- package/dist/instrumentation/__tests__/gpu-collector.test.js.map +1 -0
- package/dist/instrumentation/__tests__/gradient-trace-comparison.test.d.ts +11 -0
- package/dist/instrumentation/__tests__/gradient-trace-comparison.test.js +391 -0
- package/dist/instrumentation/__tests__/gradient-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/groq-trace-comparison.test.d.ts +7 -0
- package/dist/instrumentation/__tests__/groq-trace-comparison.test.js +687 -0
- package/dist/instrumentation/__tests__/groq-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/helpers-genai.test.d.ts +14 -0
- package/dist/instrumentation/__tests__/helpers-genai.test.js +347 -0
- package/dist/instrumentation/__tests__/helpers-genai.test.js.map +1 -0
- package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.d.ts +7 -0
- package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.js +529 -0
- package/dist/instrumentation/__tests__/huggingface-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/langchain-role-map.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/langchain-role-map.test.js +19 -0
- package/dist/instrumentation/__tests__/langchain-role-map.test.js.map +1 -0
- package/dist/instrumentation/__tests__/langchain-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/langchain-wrapper.test.js +282 -0
- package/dist/instrumentation/__tests__/langchain-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/letta-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/letta-wrapper.test.js +285 -0
- package/dist/instrumentation/__tests__/letta-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/mem0-trace-comparison.test.d.ts +13 -0
- package/dist/instrumentation/__tests__/mem0-trace-comparison.test.js +208 -0
- package/dist/instrumentation/__tests__/mem0-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/milvus-trace-comparison.test.d.ts +17 -0
- package/dist/instrumentation/__tests__/milvus-trace-comparison.test.js +206 -0
- package/dist/instrumentation/__tests__/milvus-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/mistral-trace-comparison.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/mistral-trace-comparison.test.js +345 -0
- package/dist/instrumentation/__tests__/mistral-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/openai-wrapper.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/openai-wrapper.test.js +179 -0
- package/dist/instrumentation/__tests__/openai-wrapper.test.js.map +1 -0
- package/dist/instrumentation/__tests__/pg-trace-comparison.test.d.ts +21 -0
- package/dist/instrumentation/__tests__/pg-trace-comparison.test.js +455 -0
- package/dist/instrumentation/__tests__/pg-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.d.ts +17 -0
- package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.js +182 -0
- package/dist/instrumentation/__tests__/qdrant-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/replicate-trace-comparison.test.d.ts +8 -0
- package/dist/instrumentation/__tests__/replicate-trace-comparison.test.js +346 -0
- package/dist/instrumentation/__tests__/replicate-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/together-trace-comparison.test.d.ts +4 -0
- package/dist/instrumentation/__tests__/together-trace-comparison.test.js +289 -0
- package/dist/instrumentation/__tests__/together-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/trace-comparison-utils.d.ts +67 -0
- package/dist/instrumentation/__tests__/trace-comparison-utils.js +255 -0
- package/dist/instrumentation/__tests__/trace-comparison-utils.js.map +1 -0
- package/dist/instrumentation/__tests__/transformers-trace-comparison.test.d.ts +11 -0
- package/dist/instrumentation/__tests__/transformers-trace-comparison.test.js +214 -0
- package/dist/instrumentation/__tests__/transformers-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.d.ts +8 -0
- package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.js +446 -0
- package/dist/instrumentation/__tests__/vercel-ai-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.d.ts +6 -0
- package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.js +409 -0
- package/dist/instrumentation/__tests__/vertexai-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/__tests__/vllm-trace-comparison.test.d.ts +1 -0
- package/dist/instrumentation/__tests__/vllm-trace-comparison.test.js +519 -0
- package/dist/instrumentation/__tests__/vllm-trace-comparison.test.js.map +1 -0
- package/dist/instrumentation/ai21/index.d.ts +11 -0
- package/dist/instrumentation/ai21/index.js +67 -0
- package/dist/instrumentation/ai21/index.js.map +1 -0
- package/dist/instrumentation/ai21/wrapper.d.ts +54 -0
- package/dist/instrumentation/ai21/wrapper.js +511 -0
- package/dist/instrumentation/ai21/wrapper.js.map +1 -0
- package/dist/instrumentation/anthropic/index.d.ts +11 -0
- package/dist/instrumentation/anthropic/index.js +45 -0
- package/dist/instrumentation/anthropic/index.js.map +1 -0
- package/dist/instrumentation/anthropic/wrapper.d.ts +34 -0
- package/dist/instrumentation/anthropic/wrapper.js +426 -0
- package/dist/instrumentation/anthropic/wrapper.js.map +1 -0
- package/dist/instrumentation/assemblyai/index.d.ts +12 -0
- package/dist/instrumentation/assemblyai/index.js +91 -0
- package/dist/instrumentation/assemblyai/index.js.map +1 -0
- package/dist/instrumentation/assemblyai/wrapper.d.ts +35 -0
- package/dist/instrumentation/assemblyai/wrapper.js +238 -0
- package/dist/instrumentation/assemblyai/wrapper.js.map +1 -0
- package/dist/instrumentation/astra/index.d.ts +11 -0
- package/dist/instrumentation/astra/index.js +87 -0
- package/dist/instrumentation/astra/index.js.map +1 -0
- package/dist/instrumentation/astra/wrapper.d.ts +39 -0
- package/dist/instrumentation/astra/wrapper.js +349 -0
- package/dist/instrumentation/astra/wrapper.js.map +1 -0
- package/dist/instrumentation/azure-ai-inference/index.d.ts +11 -0
- package/dist/instrumentation/azure-ai-inference/index.js +76 -0
- package/dist/instrumentation/azure-ai-inference/index.js.map +1 -0
- package/dist/instrumentation/azure-ai-inference/wrapper.d.ts +55 -0
- package/dist/instrumentation/azure-ai-inference/wrapper.js +580 -0
- package/dist/instrumentation/azure-ai-inference/wrapper.js.map +1 -0
- package/dist/instrumentation/base-wrapper.d.ts +16 -0
- package/dist/instrumentation/base-wrapper.js +139 -0
- package/dist/instrumentation/base-wrapper.js.map +1 -0
- package/dist/instrumentation/bedrock/index.d.ts +11 -0
- package/dist/instrumentation/bedrock/index.js +52 -0
- package/dist/instrumentation/bedrock/index.js.map +1 -0
- package/dist/instrumentation/bedrock/wrapper.d.ts +41 -0
- package/dist/instrumentation/bedrock/wrapper.js +494 -0
- package/dist/instrumentation/bedrock/wrapper.js.map +1 -0
- package/dist/instrumentation/browser-use/index.d.ts +11 -0
- package/dist/instrumentation/browser-use/index.js +98 -0
- package/dist/instrumentation/browser-use/index.js.map +1 -0
- package/dist/instrumentation/browser-use/wrapper.d.ts +12 -0
- package/dist/instrumentation/browser-use/wrapper.js +706 -0
- package/dist/instrumentation/browser-use/wrapper.js.map +1 -0
- package/dist/instrumentation/chroma/index.d.ts +11 -0
- package/dist/instrumentation/chroma/index.js +70 -0
- package/dist/instrumentation/chroma/index.js.map +1 -0
- package/dist/instrumentation/chroma/wrapper.d.ts +10 -0
- package/dist/instrumentation/chroma/wrapper.js +127 -0
- package/dist/instrumentation/chroma/wrapper.js.map +1 -0
- package/dist/instrumentation/claude-agent-sdk/index.d.ts +23 -0
- package/dist/instrumentation/claude-agent-sdk/index.js +83 -0
- package/dist/instrumentation/claude-agent-sdk/index.js.map +1 -0
- package/dist/instrumentation/claude-agent-sdk/wrapper.d.ts +13 -0
- package/dist/instrumentation/claude-agent-sdk/wrapper.js +1123 -0
- package/dist/instrumentation/claude-agent-sdk/wrapper.js.map +1 -0
- package/dist/instrumentation/cohere/index.d.ts +11 -0
- package/dist/instrumentation/cohere/index.js +53 -0
- package/dist/instrumentation/cohere/index.js.map +1 -0
- package/dist/instrumentation/cohere/wrapper.d.ts +50 -0
- package/dist/instrumentation/cohere/wrapper.js +452 -0
- package/dist/instrumentation/cohere/wrapper.js.map +1 -0
- package/dist/instrumentation/cursor-sdk/index.d.ts +21 -0
- package/dist/instrumentation/cursor-sdk/index.js +58 -0
- package/dist/instrumentation/cursor-sdk/index.js.map +1 -0
- package/dist/instrumentation/cursor-sdk/wrapper.d.ts +17 -0
- package/dist/instrumentation/cursor-sdk/wrapper.js +789 -0
- package/dist/instrumentation/cursor-sdk/wrapper.js.map +1 -0
- package/dist/instrumentation/elevenlabs/index.d.ts +12 -0
- package/dist/instrumentation/elevenlabs/index.js +92 -0
- package/dist/instrumentation/elevenlabs/index.js.map +1 -0
- package/dist/instrumentation/elevenlabs/wrapper.d.ts +34 -0
- package/dist/instrumentation/elevenlabs/wrapper.js +280 -0
- package/dist/instrumentation/elevenlabs/wrapper.js.map +1 -0
- package/dist/instrumentation/firecrawl/index.d.ts +13 -0
- package/dist/instrumentation/firecrawl/index.js +115 -0
- package/dist/instrumentation/firecrawl/index.js.map +1 -0
- package/dist/instrumentation/firecrawl/wrapper.d.ts +22 -0
- package/dist/instrumentation/firecrawl/wrapper.js +378 -0
- package/dist/instrumentation/firecrawl/wrapper.js.map +1 -0
- package/dist/instrumentation/google-adk/index.d.ts +57 -0
- package/dist/instrumentation/google-adk/index.js +371 -0
- package/dist/instrumentation/google-adk/index.js.map +1 -0
- package/dist/instrumentation/google-adk/utils.d.ts +45 -0
- package/dist/instrumentation/google-adk/utils.js +663 -0
- package/dist/instrumentation/google-adk/utils.js.map +1 -0
- package/dist/instrumentation/google-adk/wrapper.d.ts +11 -0
- package/dist/instrumentation/google-adk/wrapper.js +391 -0
- package/dist/instrumentation/google-adk/wrapper.js.map +1 -0
- package/dist/instrumentation/google-ai/index.d.ts +11 -0
- package/dist/instrumentation/google-ai/index.js +48 -0
- package/dist/instrumentation/google-ai/index.js.map +1 -0
- package/dist/instrumentation/google-ai/wrapper.d.ts +52 -0
- package/dist/instrumentation/google-ai/wrapper.js +466 -0
- package/dist/instrumentation/google-ai/wrapper.js.map +1 -0
- package/dist/instrumentation/gpu/index.d.ts +38 -0
- package/dist/instrumentation/gpu/index.js +233 -0
- package/dist/instrumentation/gpu/index.js.map +1 -0
- package/dist/instrumentation/gradient/index.d.ts +12 -0
- package/dist/instrumentation/gradient/index.js +74 -0
- package/dist/instrumentation/gradient/index.js.map +1 -0
- package/dist/instrumentation/gradient/utils.d.ts +14 -0
- package/dist/instrumentation/gradient/utils.js +119 -0
- package/dist/instrumentation/gradient/utils.js.map +1 -0
- package/dist/instrumentation/gradient/wrapper.d.ts +76 -0
- package/dist/instrumentation/gradient/wrapper.js +584 -0
- package/dist/instrumentation/gradient/wrapper.js.map +1 -0
- package/dist/instrumentation/groq/index.d.ts +11 -0
- package/dist/instrumentation/groq/index.js +43 -0
- package/dist/instrumentation/groq/index.js.map +1 -0
- package/dist/instrumentation/groq/wrapper.d.ts +35 -0
- package/dist/instrumentation/groq/wrapper.js +442 -0
- package/dist/instrumentation/groq/wrapper.js.map +1 -0
- package/dist/instrumentation/huggingface/index.d.ts +13 -0
- package/dist/instrumentation/huggingface/index.js +110 -0
- package/dist/instrumentation/huggingface/index.js.map +1 -0
- package/dist/instrumentation/huggingface/wrapper.d.ts +54 -0
- package/dist/instrumentation/huggingface/wrapper.js +514 -0
- package/dist/instrumentation/huggingface/wrapper.js.map +1 -0
- package/dist/instrumentation/index.d.ts +7 -0
- package/dist/instrumentation/index.js +176 -0
- package/dist/instrumentation/index.js.map +1 -0
- package/dist/instrumentation/langchain/index.d.ts +16 -0
- package/dist/instrumentation/langchain/index.js +91 -0
- package/dist/instrumentation/langchain/index.js.map +1 -0
- package/dist/instrumentation/langchain/wrapper.d.ts +41 -0
- package/dist/instrumentation/langchain/wrapper.js +1235 -0
- package/dist/instrumentation/langchain/wrapper.js.map +1 -0
- package/dist/instrumentation/langgraph/index.d.ts +12 -0
- package/dist/instrumentation/langgraph/index.js +99 -0
- package/dist/instrumentation/langgraph/index.js.map +1 -0
- package/dist/instrumentation/langgraph/wrapper.d.ts +20 -0
- package/dist/instrumentation/langgraph/wrapper.js +620 -0
- package/dist/instrumentation/langgraph/wrapper.js.map +1 -0
- package/dist/instrumentation/letta/index.d.ts +10 -0
- package/dist/instrumentation/letta/index.js +122 -0
- package/dist/instrumentation/letta/index.js.map +1 -0
- package/dist/instrumentation/letta/utils.d.ts +24 -0
- package/dist/instrumentation/letta/utils.js +343 -0
- package/dist/instrumentation/letta/utils.js.map +1 -0
- package/dist/instrumentation/letta/wrapper.d.ts +37 -0
- package/dist/instrumentation/letta/wrapper.js +180 -0
- package/dist/instrumentation/letta/wrapper.js.map +1 -0
- package/dist/instrumentation/llamaindex/index.d.ts +36 -0
- package/dist/instrumentation/llamaindex/index.js +221 -0
- package/dist/instrumentation/llamaindex/index.js.map +1 -0
- package/dist/instrumentation/llamaindex/wrapper.d.ts +36 -0
- package/dist/instrumentation/llamaindex/wrapper.js +811 -0
- package/dist/instrumentation/llamaindex/wrapper.js.map +1 -0
- package/dist/instrumentation/mcp/index.d.ts +20 -0
- package/dist/instrumentation/mcp/index.js +282 -0
- package/dist/instrumentation/mcp/index.js.map +1 -0
- package/dist/instrumentation/mcp/wrapper.d.ts +72 -0
- package/dist/instrumentation/mcp/wrapper.js +571 -0
- package/dist/instrumentation/mcp/wrapper.js.map +1 -0
- package/dist/instrumentation/mem0/index.d.ts +17 -0
- package/dist/instrumentation/mem0/index.js +113 -0
- package/dist/instrumentation/mem0/index.js.map +1 -0
- package/dist/instrumentation/mem0/wrapper.d.ts +37 -0
- package/dist/instrumentation/mem0/wrapper.js +298 -0
- package/dist/instrumentation/mem0/wrapper.js.map +1 -0
- package/dist/instrumentation/milvus/index.d.ts +11 -0
- package/dist/instrumentation/milvus/index.js +67 -0
- package/dist/instrumentation/milvus/index.js.map +1 -0
- package/dist/instrumentation/milvus/wrapper.d.ts +15 -0
- package/dist/instrumentation/milvus/wrapper.js +219 -0
- package/dist/instrumentation/milvus/wrapper.js.map +1 -0
- package/dist/instrumentation/mistral/index.d.ts +11 -0
- package/dist/instrumentation/mistral/index.js +66 -0
- package/dist/instrumentation/mistral/index.js.map +1 -0
- package/dist/instrumentation/mistral/wrapper.d.ts +49 -0
- package/dist/instrumentation/mistral/wrapper.js +482 -0
- package/dist/instrumentation/mistral/wrapper.js.map +1 -0
- package/dist/instrumentation/ollama/index.d.ts +11 -0
- package/dist/instrumentation/ollama/index.js +72 -0
- package/dist/instrumentation/ollama/index.js.map +1 -0
- package/dist/instrumentation/ollama/wrapper.d.ts +73 -0
- package/dist/instrumentation/ollama/wrapper.js +629 -0
- package/dist/instrumentation/ollama/wrapper.js.map +1 -0
- package/dist/instrumentation/openai/index.d.ts +11 -0
- package/dist/instrumentation/openai/index.js +79 -0
- package/dist/instrumentation/openai/index.js.map +1 -0
- package/dist/instrumentation/openai/wrapper.d.ts +80 -0
- package/dist/instrumentation/openai/wrapper.js +1121 -0
- package/dist/instrumentation/openai/wrapper.js.map +1 -0
- package/dist/instrumentation/openai-agents/index.d.ts +20 -0
- package/dist/instrumentation/openai-agents/index.js +174 -0
- package/dist/instrumentation/openai-agents/index.js.map +1 -0
- package/dist/instrumentation/openai-agents/processor.d.ts +35 -0
- package/dist/instrumentation/openai-agents/processor.js +249 -0
- package/dist/instrumentation/openai-agents/processor.js.map +1 -0
- package/dist/instrumentation/openai-agents/utils.d.ts +20 -0
- package/dist/instrumentation/openai-agents/utils.js +624 -0
- package/dist/instrumentation/openai-agents/utils.js.map +1 -0
- package/dist/instrumentation/pg/index.d.ts +20 -0
- package/dist/instrumentation/pg/index.js +74 -0
- package/dist/instrumentation/pg/index.js.map +1 -0
- package/dist/instrumentation/pg/wrapper.d.ts +66 -0
- package/dist/instrumentation/pg/wrapper.js +441 -0
- package/dist/instrumentation/pg/wrapper.js.map +1 -0
- package/dist/instrumentation/pinecone/index.d.ts +11 -0
- package/dist/instrumentation/pinecone/index.js +79 -0
- package/dist/instrumentation/pinecone/index.js.map +1 -0
- package/dist/instrumentation/pinecone/wrapper.d.ts +14 -0
- package/dist/instrumentation/pinecone/wrapper.js +198 -0
- package/dist/instrumentation/pinecone/wrapper.js.map +1 -0
- package/dist/instrumentation/qdrant/index.d.ts +11 -0
- package/dist/instrumentation/qdrant/index.js +67 -0
- package/dist/instrumentation/qdrant/index.js.map +1 -0
- package/dist/instrumentation/qdrant/wrapper.d.ts +14 -0
- package/dist/instrumentation/qdrant/wrapper.js +213 -0
- package/dist/instrumentation/qdrant/wrapper.js.map +1 -0
- package/dist/instrumentation/replicate/index.d.ts +11 -0
- package/dist/instrumentation/replicate/index.js +57 -0
- package/dist/instrumentation/replicate/index.js.map +1 -0
- package/dist/instrumentation/replicate/wrapper.d.ts +28 -0
- package/dist/instrumentation/replicate/wrapper.js +242 -0
- package/dist/instrumentation/replicate/wrapper.js.map +1 -0
- package/dist/instrumentation/strands/index.d.ts +21 -0
- package/dist/instrumentation/strands/index.js +83 -0
- package/dist/instrumentation/strands/index.js.map +1 -0
- package/dist/instrumentation/strands/processor.d.ts +51 -0
- package/dist/instrumentation/strands/processor.js +625 -0
- package/dist/instrumentation/strands/processor.js.map +1 -0
- package/dist/instrumentation/strands/utils.d.ts +24 -0
- package/dist/instrumentation/strands/utils.js +373 -0
- package/dist/instrumentation/strands/utils.js.map +1 -0
- package/dist/instrumentation/together/index.d.ts +11 -0
- package/dist/instrumentation/together/index.js +43 -0
- package/dist/instrumentation/together/index.js.map +1 -0
- package/dist/instrumentation/together/wrapper.d.ts +48 -0
- package/dist/instrumentation/together/wrapper.js +409 -0
- package/dist/instrumentation/together/wrapper.js.map +1 -0
- package/dist/instrumentation/transformers/index.d.ts +35 -0
- package/dist/instrumentation/transformers/index.js +119 -0
- package/dist/instrumentation/transformers/index.js.map +1 -0
- package/dist/instrumentation/transformers/wrapper.d.ts +49 -0
- package/dist/instrumentation/transformers/wrapper.js +472 -0
- package/dist/instrumentation/transformers/wrapper.js.map +1 -0
- package/dist/instrumentation/vercel-ai/index.d.ts +10 -0
- package/dist/instrumentation/vercel-ai/index.js +59 -0
- package/dist/instrumentation/vercel-ai/index.js.map +1 -0
- package/dist/instrumentation/vercel-ai/wrapper.d.ts +50 -0
- package/dist/instrumentation/vercel-ai/wrapper.js +539 -0
- package/dist/instrumentation/vercel-ai/wrapper.js.map +1 -0
- package/dist/instrumentation/vertexai/index.d.ts +11 -0
- package/dist/instrumentation/vertexai/index.js +70 -0
- package/dist/instrumentation/vertexai/index.js.map +1 -0
- package/dist/instrumentation/vertexai/wrapper.d.ts +67 -0
- package/dist/instrumentation/vertexai/wrapper.js +530 -0
- package/dist/instrumentation/vertexai/wrapper.js.map +1 -0
- package/dist/instrumentation/vllm/index.d.ts +13 -0
- package/dist/instrumentation/vllm/index.js +67 -0
- package/dist/instrumentation/vllm/index.js.map +1 -0
- package/dist/instrumentation/vllm/wrapper.d.ts +60 -0
- package/dist/instrumentation/vllm/wrapper.js +482 -0
- package/dist/instrumentation/vllm/wrapper.js.map +1 -0
- package/dist/llm/anthropic.d.ts +5 -0
- package/dist/llm/anthropic.js +39 -0
- package/dist/llm/anthropic.js.map +1 -0
- package/dist/llm/index.d.ts +10 -0
- package/dist/llm/index.js +93 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/openai.d.ts +6 -0
- package/dist/llm/openai.js +52 -0
- package/dist/llm/openai.js.map +1 -0
- package/dist/llm/providers.d.ts +7 -0
- package/dist/llm/providers.js +10 -0
- package/dist/llm/providers.js.map +1 -0
- package/dist/manual-trace.d.ts +40 -0
- package/dist/manual-trace.js +103 -0
- package/dist/manual-trace.js.map +1 -0
- package/dist/otel/__tests__/metrics.test.d.ts +1 -0
- package/dist/otel/__tests__/metrics.test.js +40 -0
- package/dist/otel/__tests__/metrics.test.js.map +1 -0
- package/dist/otel/events.d.ts +11 -0
- package/dist/otel/events.js +74 -0
- package/dist/otel/events.js.map +1 -0
- package/dist/otel/metrics.d.ts +35 -0
- package/dist/otel/metrics.js +219 -0
- package/dist/otel/metrics.js.map +1 -0
- package/dist/otel/tracing.d.ts +12 -0
- package/dist/otel/tracing.js +93 -0
- package/dist/otel/tracing.js.map +1 -0
- package/dist/otel/utils.d.ts +11 -0
- package/dist/otel/utils.js +34 -0
- package/dist/otel/utils.js.map +1 -0
- package/dist/pricing.json +951 -0
- package/dist/prompt-hub.d.ts +4 -0
- package/dist/prompt-hub.js +66 -0
- package/dist/prompt-hub.js.map +1 -0
- package/dist/register.d.ts +4 -0
- package/dist/register.js +52 -0
- package/dist/register.js.map +1 -0
- package/dist/score/__tests__/score.test.d.ts +1 -0
- package/dist/score/__tests__/score.test.js +143 -0
- package/dist/score/__tests__/score.test.js.map +1 -0
- package/dist/score/index.d.ts +2 -0
- package/dist/score/index.js +6 -0
- package/dist/score/index.js.map +1 -0
- package/dist/score/score.d.ts +15 -0
- package/dist/score/score.js +135 -0
- package/dist/score/score.js.map +1 -0
- package/dist/semantic-convention.d.ts +555 -0
- package/dist/semantic-convention.js +630 -0
- package/dist/semantic-convention.js.map +1 -0
- package/dist/types.d.ts +131 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +136 -0
|
@@ -0,0 +1,238 @@
|
|
|
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
|
+
function spanCreationAttrs(operationName, requestModel, serverAddress, serverPort) {
|
|
45
|
+
return {
|
|
46
|
+
[semantic_convention_1.default.GEN_AI_OPERATION]: operationName,
|
|
47
|
+
[semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL]: AssemblyAIWrapper.aiSystem,
|
|
48
|
+
[semantic_convention_1.default.GEN_AI_REQUEST_MODEL]: requestModel,
|
|
49
|
+
[semantic_convention_1.default.SERVER_ADDRESS]: serverAddress,
|
|
50
|
+
[semantic_convention_1.default.SERVER_PORT]: serverPort,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
class AssemblyAIWrapper extends base_wrapper_1.default {
|
|
54
|
+
/**
|
|
55
|
+
* Parse the request arguments of `client.transcripts.transcribe` / `submit` / `get`.
|
|
56
|
+
* AssemblyAI accepts either a params object (`{ audio, speechModel, ... }`) or, for
|
|
57
|
+
* `get`, a transcript id string. Mirrors the Python instrumentor which reads
|
|
58
|
+
* `speech_model` from kwargs (default "best").
|
|
59
|
+
*/
|
|
60
|
+
static _parseAudioArgs(args) {
|
|
61
|
+
const options = typeof args[0] === 'object' && args[0] !== null ? args[0] : {};
|
|
62
|
+
const requestModel = options.speechModel || options.speech_model || 'best';
|
|
63
|
+
const rawAudioUrl = typeof args[0] === 'string'
|
|
64
|
+
? args[0]
|
|
65
|
+
: options.audio ?? options.audioUrl ?? options.audio_url;
|
|
66
|
+
// Only stringify when a real value is present, so undefined/null never
|
|
67
|
+
// becomes the literal string 'undefined'/'null'.
|
|
68
|
+
const audioUrl = rawAudioUrl === undefined || rawAudioUrl === null ? '' : String(rawAudioUrl);
|
|
69
|
+
return { options, requestModel, audioUrl };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Prefer the model stamped on the Transcript response (e.g. transcripts.get
|
|
73
|
+
* polls only pass a transcript id). Fall back to request args, then "best".
|
|
74
|
+
*/
|
|
75
|
+
static _resolveRequestModel(args, response) {
|
|
76
|
+
const { requestModel } = AssemblyAIWrapper._parseAudioArgs(args);
|
|
77
|
+
const responseModel = response?.speech_model ??
|
|
78
|
+
response?.speechModel ??
|
|
79
|
+
response?.config?.speech_model ??
|
|
80
|
+
response?.config?.speechModel;
|
|
81
|
+
if (typeof responseModel === 'string' && responseModel.length > 0) {
|
|
82
|
+
return responseModel;
|
|
83
|
+
}
|
|
84
|
+
return requestModel;
|
|
85
|
+
}
|
|
86
|
+
static _patchTranscribe(tracer, methodName, sdkVersion) {
|
|
87
|
+
const genAIEndpoint = `assemblyai.transcripts.${methodName}`;
|
|
88
|
+
return (originalMethod) => {
|
|
89
|
+
return async function (...args) {
|
|
90
|
+
if ((0, helpers_1.isFrameworkLlmActive)())
|
|
91
|
+
return originalMethod.apply(this, args);
|
|
92
|
+
const { requestModel } = AssemblyAIWrapper._parseAudioArgs(args);
|
|
93
|
+
const spanName = `${semantic_convention_1.default.GEN_AI_OPERATION_TYPE_AUDIO} ${requestModel}`;
|
|
94
|
+
const effectiveCtx = (0, helpers_1.getFrameworkParentContext)() ?? api_1.context.active();
|
|
95
|
+
const span = tracer.startSpan(spanName, {
|
|
96
|
+
kind: api_1.SpanKind.CLIENT,
|
|
97
|
+
attributes: spanCreationAttrs(semantic_convention_1.default.GEN_AI_OPERATION_TYPE_AUDIO, requestModel, AssemblyAIWrapper.serverAddress, AssemblyAIWrapper.serverPort),
|
|
98
|
+
}, effectiveCtx);
|
|
99
|
+
return api_1.context.with(api_1.trace.setSpan(effectiveCtx, span), async () => {
|
|
100
|
+
let metricParams;
|
|
101
|
+
const startTime = Date.now();
|
|
102
|
+
try {
|
|
103
|
+
const response = await originalMethod.apply(this, args);
|
|
104
|
+
const ttft = (Date.now() - startTime) / 1000;
|
|
105
|
+
metricParams = AssemblyAIWrapper._commonAudioSetter({
|
|
106
|
+
args,
|
|
107
|
+
genAIEndpoint,
|
|
108
|
+
response,
|
|
109
|
+
span,
|
|
110
|
+
ttft,
|
|
111
|
+
tbt: 0,
|
|
112
|
+
isStream: false,
|
|
113
|
+
sdkVersion,
|
|
114
|
+
});
|
|
115
|
+
return response;
|
|
116
|
+
}
|
|
117
|
+
catch (e) {
|
|
118
|
+
helpers_1.default.handleException(span, e);
|
|
119
|
+
base_wrapper_1.default.recordMetrics(span, {
|
|
120
|
+
genAIEndpoint,
|
|
121
|
+
model: requestModel,
|
|
122
|
+
aiSystem: AssemblyAIWrapper.aiSystem,
|
|
123
|
+
serverAddress: AssemblyAIWrapper.serverAddress,
|
|
124
|
+
serverPort: AssemblyAIWrapper.serverPort,
|
|
125
|
+
errorType: e?.constructor?.name || '_OTHER',
|
|
126
|
+
});
|
|
127
|
+
throw e;
|
|
128
|
+
}
|
|
129
|
+
finally {
|
|
130
|
+
span.end();
|
|
131
|
+
if (metricParams) {
|
|
132
|
+
base_wrapper_1.default.recordMetrics(span, metricParams);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
static _commonAudioSetter({ args, genAIEndpoint, response, span, ttft = 0, tbt = 0, isStream = false, sdkVersion, }) {
|
|
140
|
+
const captureContent = config_1.default.captureMessageContent;
|
|
141
|
+
const { audioUrl } = AssemblyAIWrapper._parseAudioArgs(args);
|
|
142
|
+
const requestModel = AssemblyAIWrapper._resolveRequestModel(args, response);
|
|
143
|
+
// Coerce to a string only when a real value is present, so undefined/null
|
|
144
|
+
// never becomes the literal string 'undefined'/'null'.
|
|
145
|
+
const toStr = (v) => v === undefined || v === null ? '' : String(v);
|
|
146
|
+
// Prefer values from the returned Transcript (matches the Python instrumentor,
|
|
147
|
+
// which reads audio_url / audio_duration / id / text off the response).
|
|
148
|
+
// Do not treat a bare transcript id (transcripts.get) as an audio URL for
|
|
149
|
+
// cost or message content — Python uses response.audio_url only.
|
|
150
|
+
const argsAudioPrompt = typeof args[0] === 'object' && args[0] !== null ? audioUrl : '';
|
|
151
|
+
const prompt = toStr(response?.audio_url ?? response?.audioUrl ?? argsAudioPrompt);
|
|
152
|
+
const audioDuration = response?.audio_duration ?? response?.audioDuration ?? 0;
|
|
153
|
+
const responseId = toStr(response?.id);
|
|
154
|
+
const responseText = toStr(response?.text);
|
|
155
|
+
// Request parameters
|
|
156
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_AUDIO_DURATION, audioDuration);
|
|
157
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_REQUEST_IS_STREAM, isStream);
|
|
158
|
+
// Response parameters
|
|
159
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_OUTPUT_TYPE, 'text');
|
|
160
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_RESPONSE_ID, responseId);
|
|
161
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON, ['stop']);
|
|
162
|
+
// Token usage (AssemblyAI transcription does not report token usage)
|
|
163
|
+
const usage = response?.usage;
|
|
164
|
+
const inputTokens = (usage && (usage.input_tokens ?? usage.inputTokens)) || 0;
|
|
165
|
+
const outputTokens = (usage && (usage.output_tokens ?? usage.outputTokens)) || 0;
|
|
166
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS, inputTokens);
|
|
167
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);
|
|
168
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_CLIENT_TOKEN_USAGE, inputTokens + outputTokens);
|
|
169
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, 0);
|
|
170
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS, 0);
|
|
171
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_SERVER_TTFT, ttft);
|
|
172
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_SERVER_TBT, tbt);
|
|
173
|
+
const pricingInfo = config_1.default.pricingInfo || {};
|
|
174
|
+
// AssemblyAI bills per second of audio (pricing.json best/nano rates).
|
|
175
|
+
// Do not pass audio_url as the prompt — getAudioModelCost treats a
|
|
176
|
+
// truthy prompt as character-length pricing (TTS-style), which made
|
|
177
|
+
// gen_ai.usage.cost track URL length instead of duration. Match Python
|
|
178
|
+
// assemblyai/utils.py: pass an empty prompt and the duration.
|
|
179
|
+
const cost = helpers_1.default.getAudioModelCost(requestModel, pricingInfo, '', audioDuration);
|
|
180
|
+
AssemblyAIWrapper.setBaseSpanAttributes(span, {
|
|
181
|
+
genAIEndpoint,
|
|
182
|
+
model: requestModel,
|
|
183
|
+
cost,
|
|
184
|
+
aiSystem: AssemblyAIWrapper.aiSystem,
|
|
185
|
+
serverAddress: AssemblyAIWrapper.serverAddress,
|
|
186
|
+
serverPort: AssemblyAIWrapper.serverPort,
|
|
187
|
+
});
|
|
188
|
+
// Python stamps gen_ai.system and the AssemblyAI package version (not Shield360's).
|
|
189
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_PROVIDER_NAME, AssemblyAIWrapper.aiSystem);
|
|
190
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_RESPONSE_MODEL, requestModel);
|
|
191
|
+
if (sdkVersion) {
|
|
192
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_SDK_VERSION, sdkVersion);
|
|
193
|
+
}
|
|
194
|
+
let inputMessagesJson;
|
|
195
|
+
let outputMessagesJson;
|
|
196
|
+
if (captureContent) {
|
|
197
|
+
inputMessagesJson = helpers_1.default.buildInputMessages([{ role: 'user', content: prompt }]);
|
|
198
|
+
outputMessagesJson = helpers_1.default.buildOutputMessages(responseText, 'stop');
|
|
199
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_INPUT_MESSAGES, inputMessagesJson);
|
|
200
|
+
span.setAttribute(semantic_convention_1.default.GEN_AI_OUTPUT_MESSAGES, outputMessagesJson);
|
|
201
|
+
}
|
|
202
|
+
// Match Python assemblyai: inference events are emitted only when content
|
|
203
|
+
// capture is enabled (messages are part of the event payload).
|
|
204
|
+
if (!config_1.default.disableEvents && captureContent) {
|
|
205
|
+
const eventAttrs = {
|
|
206
|
+
[semantic_convention_1.default.GEN_AI_OPERATION]: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_AUDIO,
|
|
207
|
+
[semantic_convention_1.default.GEN_AI_REQUEST_MODEL]: requestModel,
|
|
208
|
+
[semantic_convention_1.default.GEN_AI_RESPONSE_MODEL]: requestModel,
|
|
209
|
+
[semantic_convention_1.default.SERVER_ADDRESS]: AssemblyAIWrapper.serverAddress,
|
|
210
|
+
[semantic_convention_1.default.SERVER_PORT]: AssemblyAIWrapper.serverPort,
|
|
211
|
+
[semantic_convention_1.default.GEN_AI_OUTPUT_TYPE]: 'text',
|
|
212
|
+
[semantic_convention_1.default.GEN_AI_RESPONSE_ID]: responseId,
|
|
213
|
+
[semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS]: inputTokens,
|
|
214
|
+
[semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS]: outputTokens,
|
|
215
|
+
};
|
|
216
|
+
if (inputMessagesJson) {
|
|
217
|
+
eventAttrs[semantic_convention_1.default.GEN_AI_INPUT_MESSAGES] = inputMessagesJson;
|
|
218
|
+
}
|
|
219
|
+
if (outputMessagesJson) {
|
|
220
|
+
eventAttrs[semantic_convention_1.default.GEN_AI_OUTPUT_MESSAGES] = outputMessagesJson;
|
|
221
|
+
}
|
|
222
|
+
helpers_1.default.emitInferenceEvent(span, eventAttrs);
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
genAIEndpoint,
|
|
226
|
+
model: requestModel,
|
|
227
|
+
cost,
|
|
228
|
+
aiSystem: AssemblyAIWrapper.aiSystem,
|
|
229
|
+
serverAddress: AssemblyAIWrapper.serverAddress,
|
|
230
|
+
serverPort: AssemblyAIWrapper.serverPort,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
AssemblyAIWrapper.aiSystem = semantic_convention_1.default.GEN_AI_SYSTEM_ASSEMBLYAI;
|
|
235
|
+
AssemblyAIWrapper.serverAddress = 'api.assemblyai.com';
|
|
236
|
+
AssemblyAIWrapper.serverPort = 443;
|
|
237
|
+
exports.default = AssemblyAIWrapper;
|
|
238
|
+
//# sourceMappingURL=wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../../src/instrumentation/assemblyai/wrapper.ts"],"names":[],"mappings":";;;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B,CAAC,UAAU;SACzC,CAAC;IACJ,CAAC;;AAzPM,0BAAQ,GAAG,6BAAkB,CAAC,wBAAwB,CAAC;AACvD,+BAAa,GAAG,oBAAoB,CAAC;AACrC,4BAAU,GAAG,GAAG,CAAC;AA0P1B,kBAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
3
|
+
export interface AstraInstrumentationConfig extends InstrumentationConfig {
|
|
4
|
+
}
|
|
5
|
+
export default class Shield360AstraInstrumentation extends InstrumentationBase {
|
|
6
|
+
constructor(config?: AstraInstrumentationConfig);
|
|
7
|
+
protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[];
|
|
8
|
+
manualPatch(astra: any): void;
|
|
9
|
+
protected _patch(moduleExports: any): void;
|
|
10
|
+
protected _unpatch(moduleExports: any): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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 semantic_convention_1 = __importDefault(require("../../semantic-convention"));
|
|
10
|
+
const wrapper_1 = __importDefault(require("./wrapper"));
|
|
11
|
+
class Shield360AstraInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
12
|
+
constructor(config = {}) {
|
|
13
|
+
super(`${constant_1.INSTRUMENTATION_PREFIX}/instrumentation-astra`, '1.0.0', config);
|
|
14
|
+
}
|
|
15
|
+
init() {
|
|
16
|
+
const module = new instrumentation_1.InstrumentationNodeModuleDefinition('@datastax/astra-db-ts', ['>=1.0.0'], (moduleExports) => {
|
|
17
|
+
this._patch(moduleExports);
|
|
18
|
+
return moduleExports;
|
|
19
|
+
}, (moduleExports) => {
|
|
20
|
+
if (moduleExports !== undefined) {
|
|
21
|
+
this._unpatch(moduleExports);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return [module];
|
|
25
|
+
}
|
|
26
|
+
manualPatch(astra) {
|
|
27
|
+
this._patch(astra);
|
|
28
|
+
}
|
|
29
|
+
_patch(moduleExports) {
|
|
30
|
+
try {
|
|
31
|
+
const Collection = moduleExports.Collection;
|
|
32
|
+
if (!Collection?.prototype)
|
|
33
|
+
return;
|
|
34
|
+
// `find` returns a cursor synchronously — must not be wrapped as async
|
|
35
|
+
if (typeof Collection.prototype['find'] === 'function') {
|
|
36
|
+
if ((0, instrumentation_1.isWrapped)(Collection.prototype['find'])) {
|
|
37
|
+
this._unwrap(Collection.prototype, 'find');
|
|
38
|
+
}
|
|
39
|
+
this._wrap(Collection.prototype, 'find', wrapper_1.default._patchSyncFindMethod(this.tracer));
|
|
40
|
+
}
|
|
41
|
+
// All other methods return Promises and use the async wrapper
|
|
42
|
+
const asyncMethods = [
|
|
43
|
+
['insertOne', semantic_convention_1.default.DB_OPERATION_INSERT],
|
|
44
|
+
['insertMany', semantic_convention_1.default.DB_OPERATION_INSERT],
|
|
45
|
+
['updateOne', semantic_convention_1.default.DB_OPERATION_UPDATE],
|
|
46
|
+
['updateMany', semantic_convention_1.default.DB_OPERATION_UPDATE],
|
|
47
|
+
['replaceOne', semantic_convention_1.default.DB_OPERATION_REPLACE],
|
|
48
|
+
['findOne', semantic_convention_1.default.DB_OPERATION_SELECT],
|
|
49
|
+
['findOneAndUpdate', semantic_convention_1.default.DB_OPERATION_REPLACE],
|
|
50
|
+
['findOneAndReplace', semantic_convention_1.default.DB_OPERATION_REPLACE],
|
|
51
|
+
['findOneAndDelete', semantic_convention_1.default.DB_OPERATION_FIND_AND_DELETE],
|
|
52
|
+
['deleteOne', semantic_convention_1.default.DB_OPERATION_DELETE],
|
|
53
|
+
['deleteMany', semantic_convention_1.default.DB_OPERATION_DELETE],
|
|
54
|
+
];
|
|
55
|
+
for (const [method, dbOp] of asyncMethods) {
|
|
56
|
+
if (typeof Collection.prototype[method] === 'function') {
|
|
57
|
+
if ((0, instrumentation_1.isWrapped)(Collection.prototype[method])) {
|
|
58
|
+
this._unwrap(Collection.prototype, method);
|
|
59
|
+
}
|
|
60
|
+
this._wrap(Collection.prototype, method, wrapper_1.default._patchCollectionMethod(this.tracer, dbOp));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
api_1.diag.error('Astra instrumentation: error in _patch method', e);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
_unpatch(moduleExports) {
|
|
69
|
+
try {
|
|
70
|
+
const Collection = moduleExports.Collection;
|
|
71
|
+
if (!Collection?.prototype)
|
|
72
|
+
return;
|
|
73
|
+
for (const method of [
|
|
74
|
+
'insertOne', 'insertMany', 'updateOne', 'updateMany', 'replaceOne',
|
|
75
|
+
'find', 'findOne', 'findOneAndUpdate', 'findOneAndReplace',
|
|
76
|
+
'findOneAndDelete', 'deleteOne', 'deleteMany',
|
|
77
|
+
]) {
|
|
78
|
+
if (typeof Collection.prototype[method] === 'function') {
|
|
79
|
+
this._unwrap(Collection.prototype, method);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch { /* ignore */ }
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.default = Shield360AstraInstrumentation;
|
|
87
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/instrumentation/astra/index.ts"],"names":[],"mappings":";;;;;AAAA,oEAKwC;AAExC,4CAA0C;AAC1C,6CAAwD;AACxD,oFAA2D;AAC3D,w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E,CAAC;IACH,CAAC;IAES,QAAQ,CAAC,aAAkB;QACnC,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC;YAC5C,IAAI,CAAC,UAAU,EAAE,SAAS;gBAAE,OAAO;YACnC,KAAK,MAAM,MAAM,IAAI;gBACnB,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY;gBAClE,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,mBAAmB;gBAC1D,kBAAkB,EAAE,WAAW,EAAE,YAAY;aAC9C,EAAE,CAAC;gBACF,IAAI,OAAO,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC;oBACvD,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;gBAC7C,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IAC1B,CAAC;CACF;AAlFD,gDAkFC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Tracer } from '@opentelemetry/api';
|
|
2
|
+
import BaseWrapper from '../base-wrapper';
|
|
3
|
+
declare class AstraWrapper extends BaseWrapper {
|
|
4
|
+
static dbSystem: string;
|
|
5
|
+
static serverAddress: string;
|
|
6
|
+
static serverPort: number;
|
|
7
|
+
static _setCommonAttributes(span: any, dbOperation: string, collectionName: string, instance?: any): void;
|
|
8
|
+
/**
|
|
9
|
+
* Async wrapper for methods that return Promises (all Collection CRUD methods except `find`).
|
|
10
|
+
*/
|
|
11
|
+
static _patchCollectionMethod(tracer: Tracer, dbOperation: string): any;
|
|
12
|
+
/**
|
|
13
|
+
* Synchronous wrapper for `find()` which returns a cursor synchronously.
|
|
14
|
+
* Wrapping it as async would break the cursor API (e.g. `collection.find({}).toArray()`).
|
|
15
|
+
*/
|
|
16
|
+
static _patchSyncFindMethod(tracer: Tracer): any;
|
|
17
|
+
private static _setOperationAttributes;
|
|
18
|
+
private static _setInsertAttributes;
|
|
19
|
+
private static _setUpdateAttributes;
|
|
20
|
+
private static _setReplaceAttributes;
|
|
21
|
+
private static _setSelectAttributes;
|
|
22
|
+
private static _setDeleteAttributes;
|
|
23
|
+
private static _getActualDbOperation;
|
|
24
|
+
private static _hasUpsertOption;
|
|
25
|
+
private static _setFilterAttribute;
|
|
26
|
+
private static _getInsertReturnedRows;
|
|
27
|
+
private static _getUpdateReturnedRows;
|
|
28
|
+
private static _getSelectReturnedRows;
|
|
29
|
+
private static _getDeleteReturnedRows;
|
|
30
|
+
private static _objectCount;
|
|
31
|
+
private static _isCursorLike;
|
|
32
|
+
private static _summaryValue;
|
|
33
|
+
private static _safeStringify;
|
|
34
|
+
private static _truncate;
|
|
35
|
+
private static _getServerAddressAndPort;
|
|
36
|
+
private static _findEndpoint;
|
|
37
|
+
private static _parseEndpoint;
|
|
38
|
+
}
|
|
39
|
+
export default AstraWrapper;
|