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,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strands Agents instrumentation utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides model-to-provider mapping, server address inference, content
|
|
5
|
+
* extraction from Strands native span events, inference event emission,
|
|
6
|
+
* and metrics recording.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors: sdk/python/src/shield360/instrumentation/strands/utils.py
|
|
9
|
+
*/
|
|
10
|
+
export declare function inferServerAddress(modelName: string): [string, number];
|
|
11
|
+
export declare function inferProviderName(modelName: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Extract message content from Strands span events.
|
|
14
|
+
*
|
|
15
|
+
* Handles both legacy named events (gen_ai.user.message, gen_ai.choice, etc.)
|
|
16
|
+
* and the gen_ai.client.inference.operation.details event convention.
|
|
17
|
+
*
|
|
18
|
+
* Returns [inputMessages, outputMessages, systemInstructions, toolDefinitions].
|
|
19
|
+
*/
|
|
20
|
+
export declare function extractContentFromEvents(span: any, operation: string): [any[], any[], string | null, string | null];
|
|
21
|
+
export declare function truncateContent(content: string): string;
|
|
22
|
+
export declare function truncateMessageContent(messages: any[]): void;
|
|
23
|
+
export declare function recordStrandsMetrics(operation: string, duration: number, modelName: string, serverAddress: string, serverPort: number): void;
|
|
24
|
+
export declare function emitStrandsInferenceEvent(span: any, requestModel: string, serverAddress: string, serverPort: number, extra?: Record<string, any>): void;
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Strands Agents instrumentation utilities.
|
|
4
|
+
*
|
|
5
|
+
* Provides model-to-provider mapping, server address inference, content
|
|
6
|
+
* extraction from Strands native span events, inference event emission,
|
|
7
|
+
* and metrics recording.
|
|
8
|
+
*
|
|
9
|
+
* Mirrors: sdk/python/src/shield360/instrumentation/strands/utils.py
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
+
}) : function(o, v) {
|
|
25
|
+
o["default"] = v;
|
|
26
|
+
});
|
|
27
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
28
|
+
var ownKeys = function(o) {
|
|
29
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30
|
+
var ar = [];
|
|
31
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32
|
+
return ar;
|
|
33
|
+
};
|
|
34
|
+
return ownKeys(o);
|
|
35
|
+
};
|
|
36
|
+
return function (mod) {
|
|
37
|
+
if (mod && mod.__esModule) return mod;
|
|
38
|
+
var result = {};
|
|
39
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
40
|
+
__setModuleDefault(result, mod);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
})();
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.inferServerAddress = inferServerAddress;
|
|
49
|
+
exports.inferProviderName = inferProviderName;
|
|
50
|
+
exports.extractContentFromEvents = extractContentFromEvents;
|
|
51
|
+
exports.truncateContent = truncateContent;
|
|
52
|
+
exports.truncateMessageContent = truncateMessageContent;
|
|
53
|
+
exports.recordStrandsMetrics = recordStrandsMetrics;
|
|
54
|
+
exports.emitStrandsInferenceEvent = emitStrandsInferenceEvent;
|
|
55
|
+
const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
|
|
56
|
+
const config_1 = __importDefault(require("../../config"));
|
|
57
|
+
const helpers_1 = __importStar(require("../../helpers"));
|
|
58
|
+
const metrics_1 = __importDefault(require("../../otel/metrics"));
|
|
59
|
+
// -------------------------------------------------------------------------
|
|
60
|
+
// Model prefix → provider mapping (mirrors Python _MODEL_PREFIX_TO_PROVIDER)
|
|
61
|
+
// -------------------------------------------------------------------------
|
|
62
|
+
const MODEL_PREFIX_TO_PROVIDER = [
|
|
63
|
+
['anthropic.', 'aws.bedrock'],
|
|
64
|
+
['amazon.', 'aws.bedrock'],
|
|
65
|
+
['meta.', 'aws.bedrock'],
|
|
66
|
+
['us.anthropic.', 'aws.bedrock'],
|
|
67
|
+
['us.amazon.', 'aws.bedrock'],
|
|
68
|
+
['us.meta.', 'aws.bedrock'],
|
|
69
|
+
['eu.anthropic.', 'aws.bedrock'],
|
|
70
|
+
['eu.amazon.', 'aws.bedrock'],
|
|
71
|
+
['eu.meta.', 'aws.bedrock'],
|
|
72
|
+
['gpt-', 'openai'],
|
|
73
|
+
['o1', 'openai'],
|
|
74
|
+
['o3', 'openai'],
|
|
75
|
+
['o4', 'openai'],
|
|
76
|
+
['claude', 'anthropic'],
|
|
77
|
+
['gemini', 'google'],
|
|
78
|
+
['mistral', 'mistral_ai'],
|
|
79
|
+
['command', 'cohere'],
|
|
80
|
+
['deepseek', 'deepseek'],
|
|
81
|
+
];
|
|
82
|
+
function inferServerAddress(modelName) {
|
|
83
|
+
if (!modelName)
|
|
84
|
+
return ['', 0];
|
|
85
|
+
const lower = modelName.toLowerCase();
|
|
86
|
+
for (const [prefix, provider] of MODEL_PREFIX_TO_PROVIDER) {
|
|
87
|
+
if (lower.startsWith(prefix)) {
|
|
88
|
+
return (0, helpers_1.getServerAddressForProvider)(provider);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return ['', 0];
|
|
92
|
+
}
|
|
93
|
+
function inferProviderName(modelName) {
|
|
94
|
+
if (!modelName)
|
|
95
|
+
return '';
|
|
96
|
+
const lower = modelName.toLowerCase();
|
|
97
|
+
for (const [prefix, provider] of MODEL_PREFIX_TO_PROVIDER) {
|
|
98
|
+
if (lower.startsWith(prefix)) {
|
|
99
|
+
return provider;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return '';
|
|
103
|
+
}
|
|
104
|
+
// -------------------------------------------------------------------------
|
|
105
|
+
// Content extraction from Strands span events
|
|
106
|
+
// -------------------------------------------------------------------------
|
|
107
|
+
function safeJsonParse(value) {
|
|
108
|
+
if (typeof value === 'string') {
|
|
109
|
+
try {
|
|
110
|
+
return JSON.parse(value);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return value;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return value;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Convert Strands Bedrock-style content blocks to OTel message parts.
|
|
120
|
+
*/
|
|
121
|
+
function convertStrandsContentToParts(content) {
|
|
122
|
+
let blocks = safeJsonParse(content);
|
|
123
|
+
if (!Array.isArray(blocks)) {
|
|
124
|
+
blocks = blocks ? [blocks] : [];
|
|
125
|
+
}
|
|
126
|
+
const parts = [];
|
|
127
|
+
for (const block of blocks) {
|
|
128
|
+
if (typeof block === 'object' && block !== null) {
|
|
129
|
+
if ('text' in block) {
|
|
130
|
+
parts.push({ type: 'text', content: block.text });
|
|
131
|
+
}
|
|
132
|
+
else if ('toolUse' in block) {
|
|
133
|
+
const tu = block.toolUse;
|
|
134
|
+
parts.push({
|
|
135
|
+
type: 'tool_call',
|
|
136
|
+
id: tu.toolUseId || '',
|
|
137
|
+
name: tu.name || '',
|
|
138
|
+
arguments: tu.input || {},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
else if ('toolResult' in block) {
|
|
142
|
+
const tr = block.toolResult;
|
|
143
|
+
parts.push({
|
|
144
|
+
type: 'tool_call_response',
|
|
145
|
+
id: tr.toolUseId || '',
|
|
146
|
+
response: tr.content || '',
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
for (const [key, value] of Object.entries(block)) {
|
|
151
|
+
parts.push({ type: key, content: value });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else if (typeof block === 'string') {
|
|
156
|
+
parts.push({ type: 'text', content: block });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return parts.length > 0 ? parts : [{ type: 'text', content: String(content) }];
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Extract message content from Strands span events.
|
|
163
|
+
*
|
|
164
|
+
* Handles both legacy named events (gen_ai.user.message, gen_ai.choice, etc.)
|
|
165
|
+
* and the gen_ai.client.inference.operation.details event convention.
|
|
166
|
+
*
|
|
167
|
+
* Returns [inputMessages, outputMessages, systemInstructions, toolDefinitions].
|
|
168
|
+
*/
|
|
169
|
+
function extractContentFromEvents(span, operation) {
|
|
170
|
+
const inputMsgs = [];
|
|
171
|
+
const outputMsgs = [];
|
|
172
|
+
let systemInstructions = null;
|
|
173
|
+
let toolDefinitions = null;
|
|
174
|
+
for (const event of span.events || []) {
|
|
175
|
+
const ea = event.attributes || {};
|
|
176
|
+
if (event.name === semantic_convention_1.default.GEN_AI_CLIENT_INFERENCE_OPERATION_DETAILS) {
|
|
177
|
+
if (ea[semantic_convention_1.default.GEN_AI_INPUT_MESSAGES]) {
|
|
178
|
+
const raw = safeJsonParse(ea[semantic_convention_1.default.GEN_AI_INPUT_MESSAGES]);
|
|
179
|
+
if (Array.isArray(raw))
|
|
180
|
+
inputMsgs.push(...raw);
|
|
181
|
+
else if (raw)
|
|
182
|
+
inputMsgs.push(raw);
|
|
183
|
+
}
|
|
184
|
+
if (ea[semantic_convention_1.default.GEN_AI_OUTPUT_MESSAGES]) {
|
|
185
|
+
const raw = safeJsonParse(ea[semantic_convention_1.default.GEN_AI_OUTPUT_MESSAGES]);
|
|
186
|
+
if (Array.isArray(raw))
|
|
187
|
+
outputMsgs.push(...raw);
|
|
188
|
+
else if (raw)
|
|
189
|
+
outputMsgs.push(raw);
|
|
190
|
+
}
|
|
191
|
+
if (ea[semantic_convention_1.default.GEN_AI_SYSTEM_INSTRUCTIONS]) {
|
|
192
|
+
systemInstructions = String(ea[semantic_convention_1.default.GEN_AI_SYSTEM_INSTRUCTIONS]);
|
|
193
|
+
}
|
|
194
|
+
if (ea[semantic_convention_1.default.GEN_AI_TOOL_DEFINITIONS]) {
|
|
195
|
+
toolDefinitions = String(ea[semantic_convention_1.default.GEN_AI_TOOL_DEFINITIONS]);
|
|
196
|
+
}
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
if (event.name === 'gen_ai.system.message') {
|
|
200
|
+
systemInstructions = String(ea.content || '');
|
|
201
|
+
}
|
|
202
|
+
else if (event.name === 'gen_ai.user.message') {
|
|
203
|
+
const content = ea.content || '';
|
|
204
|
+
const parts = convertStrandsContentToParts(content);
|
|
205
|
+
inputMsgs.push({ role: 'user', parts });
|
|
206
|
+
}
|
|
207
|
+
else if (event.name === 'gen_ai.assistant.message') {
|
|
208
|
+
const content = ea.content || '';
|
|
209
|
+
const parts = convertStrandsContentToParts(content);
|
|
210
|
+
inputMsgs.push({ role: 'assistant', parts });
|
|
211
|
+
}
|
|
212
|
+
else if (event.name === 'gen_ai.tool.message') {
|
|
213
|
+
const content = ea.content || '';
|
|
214
|
+
const toolId = ea.id || '';
|
|
215
|
+
if (operation === 'execute_tool') {
|
|
216
|
+
inputMsgs.push({
|
|
217
|
+
role: 'tool',
|
|
218
|
+
parts: [{
|
|
219
|
+
type: 'tool_call',
|
|
220
|
+
id: toolId,
|
|
221
|
+
name: '',
|
|
222
|
+
arguments: safeJsonParse(content),
|
|
223
|
+
}],
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
inputMsgs.push({
|
|
228
|
+
role: 'tool',
|
|
229
|
+
parts: [{
|
|
230
|
+
type: 'tool_call_response',
|
|
231
|
+
id: toolId,
|
|
232
|
+
response: safeJsonParse(content),
|
|
233
|
+
}],
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
else if (event.name === 'gen_ai.choice') {
|
|
238
|
+
const message = ea.message || '';
|
|
239
|
+
const finishReason = ea.finish_reason || '';
|
|
240
|
+
if (operation === 'execute_tool') {
|
|
241
|
+
outputMsgs.push({
|
|
242
|
+
role: 'tool',
|
|
243
|
+
parts: convertStrandsContentToParts(message),
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
const parts = convertStrandsContentToParts(message);
|
|
248
|
+
const entry = { role: 'assistant', parts };
|
|
249
|
+
if (finishReason)
|
|
250
|
+
entry.finish_reason = String(finishReason);
|
|
251
|
+
outputMsgs.push(entry);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return [inputMsgs, outputMsgs, systemInstructions, toolDefinitions];
|
|
256
|
+
}
|
|
257
|
+
// -------------------------------------------------------------------------
|
|
258
|
+
// Content truncation
|
|
259
|
+
// -------------------------------------------------------------------------
|
|
260
|
+
function truncateContent(content) {
|
|
261
|
+
const maxLen = config_1.default.maxContentLength;
|
|
262
|
+
if (maxLen && content.length > maxLen) {
|
|
263
|
+
return content.substring(0, maxLen) + '...';
|
|
264
|
+
}
|
|
265
|
+
return content;
|
|
266
|
+
}
|
|
267
|
+
function truncateMessageContent(messages) {
|
|
268
|
+
for (const msg of messages) {
|
|
269
|
+
if (msg.parts && Array.isArray(msg.parts)) {
|
|
270
|
+
for (const part of msg.parts) {
|
|
271
|
+
if (part.content && typeof part.content === 'string') {
|
|
272
|
+
part.content = truncateContent(part.content);
|
|
273
|
+
}
|
|
274
|
+
if (part.response && typeof part.response === 'string') {
|
|
275
|
+
part.response = truncateContent(part.response);
|
|
276
|
+
}
|
|
277
|
+
if (part.arguments && typeof part.arguments === 'string') {
|
|
278
|
+
part.arguments = truncateContent(part.arguments);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// -------------------------------------------------------------------------
|
|
285
|
+
// Metrics recording (mirrors Python record_strands_metrics)
|
|
286
|
+
// -------------------------------------------------------------------------
|
|
287
|
+
function recordStrandsMetrics(operation, duration, modelName, serverAddress, serverPort) {
|
|
288
|
+
try {
|
|
289
|
+
const attributes = {
|
|
290
|
+
[semantic_convention_1.default.GEN_AI_OPERATION]: operation,
|
|
291
|
+
[semantic_convention_1.default.GEN_AI_PROVIDER_NAME_OTEL]: semantic_convention_1.default.GEN_AI_SYSTEM_STRANDS,
|
|
292
|
+
'service.name': config_1.default.applicationName || 'default',
|
|
293
|
+
'deployment.environment': config_1.default.environment || 'default',
|
|
294
|
+
};
|
|
295
|
+
if (modelName && modelName !== 'unknown') {
|
|
296
|
+
attributes[semantic_convention_1.default.GEN_AI_REQUEST_MODEL] = modelName;
|
|
297
|
+
}
|
|
298
|
+
if (serverAddress) {
|
|
299
|
+
attributes[semantic_convention_1.default.SERVER_ADDRESS] = serverAddress;
|
|
300
|
+
}
|
|
301
|
+
if (serverPort) {
|
|
302
|
+
attributes[semantic_convention_1.default.SERVER_PORT] = serverPort;
|
|
303
|
+
}
|
|
304
|
+
metrics_1.default.genaiClientOperationDuration?.record(duration, attributes);
|
|
305
|
+
}
|
|
306
|
+
catch {
|
|
307
|
+
// ignore
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
// -------------------------------------------------------------------------
|
|
311
|
+
// Inference event emission (mirrors Python emit_strands_inference_event)
|
|
312
|
+
// -------------------------------------------------------------------------
|
|
313
|
+
function emitStrandsInferenceEvent(span, requestModel, serverAddress, serverPort, extra = {}) {
|
|
314
|
+
try {
|
|
315
|
+
if (config_1.default.disableEvents)
|
|
316
|
+
return;
|
|
317
|
+
const eventAttrs = {
|
|
318
|
+
[semantic_convention_1.default.GEN_AI_OPERATION]: semantic_convention_1.default.GEN_AI_OPERATION_TYPE_CHAT,
|
|
319
|
+
};
|
|
320
|
+
if (requestModel) {
|
|
321
|
+
eventAttrs[semantic_convention_1.default.GEN_AI_REQUEST_MODEL] = requestModel;
|
|
322
|
+
}
|
|
323
|
+
if (serverAddress) {
|
|
324
|
+
eventAttrs[semantic_convention_1.default.SERVER_ADDRESS] = serverAddress;
|
|
325
|
+
}
|
|
326
|
+
if (serverPort) {
|
|
327
|
+
eventAttrs[semantic_convention_1.default.SERVER_PORT] = serverPort;
|
|
328
|
+
}
|
|
329
|
+
if (extra.inputTokens != null) {
|
|
330
|
+
eventAttrs[semantic_convention_1.default.GEN_AI_USAGE_INPUT_TOKENS] = extra.inputTokens;
|
|
331
|
+
}
|
|
332
|
+
if (extra.outputTokens != null) {
|
|
333
|
+
eventAttrs[semantic_convention_1.default.GEN_AI_USAGE_OUTPUT_TOKENS] = extra.outputTokens;
|
|
334
|
+
}
|
|
335
|
+
if (extra.cacheReadInputTokens != null) {
|
|
336
|
+
eventAttrs[semantic_convention_1.default.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS] = extra.cacheReadInputTokens;
|
|
337
|
+
}
|
|
338
|
+
if (extra.cacheCreationInputTokens != null) {
|
|
339
|
+
eventAttrs[semantic_convention_1.default.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS] = extra.cacheCreationInputTokens;
|
|
340
|
+
}
|
|
341
|
+
if (extra.responseId) {
|
|
342
|
+
eventAttrs[semantic_convention_1.default.GEN_AI_RESPONSE_ID] = extra.responseId;
|
|
343
|
+
}
|
|
344
|
+
if (extra.finishReasons) {
|
|
345
|
+
eventAttrs[semantic_convention_1.default.GEN_AI_RESPONSE_FINISH_REASON] = extra.finishReasons;
|
|
346
|
+
}
|
|
347
|
+
if (extra.systemInstructions) {
|
|
348
|
+
eventAttrs[semantic_convention_1.default.GEN_AI_SYSTEM_INSTRUCTIONS] = extra.systemInstructions;
|
|
349
|
+
}
|
|
350
|
+
if (extra.toolDefinitions) {
|
|
351
|
+
eventAttrs[semantic_convention_1.default.GEN_AI_TOOL_DEFINITIONS] = extra.toolDefinitions;
|
|
352
|
+
}
|
|
353
|
+
if (extra.versionExtras && typeof extra.versionExtras === 'object') {
|
|
354
|
+
for (const [k, v] of Object.entries(extra.versionExtras)) {
|
|
355
|
+
if (typeof v === 'string' && v)
|
|
356
|
+
eventAttrs[k] = v;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
if (config_1.default.captureMessageContent) {
|
|
360
|
+
if (extra.inputMessages) {
|
|
361
|
+
eventAttrs[semantic_convention_1.default.GEN_AI_INPUT_MESSAGES] = JSON.stringify(extra.inputMessages);
|
|
362
|
+
}
|
|
363
|
+
if (extra.outputMessages) {
|
|
364
|
+
eventAttrs[semantic_convention_1.default.GEN_AI_OUTPUT_MESSAGES] = JSON.stringify(extra.outputMessages);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
helpers_1.default.emitInferenceEvent(span, eventAttrs);
|
|
368
|
+
}
|
|
369
|
+
catch {
|
|
370
|
+
// ignore
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/instrumentation/strands/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCH,gDASC;AAED,8CASC;AAmED,4DAmFC;AAMD,0CAMC;AAED,wDAgBC;AAMD,oDA4BC;AAMD,8DAmEC;AAjVD,oFAA2D;AAC3D,0DAA2C;AAC3C,yDAA6E;AAC7E,iEAAyC;AAEzC,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAE5E,MAAM,wBAAwB,GAAuB;IACnD,CAAC,YAAY,EAAE,aAAa,CAAC;IAC7B,CAAC,SAAS,EAAE,aAAa,CAAC;IAC1B,CAAC,OAAO,EAAE,aAAa,CAAC;IACxB,CAAC,eAAe,EAAE,aAAa,CAAC;IAChC,CAAC,YAAY,EAAE,aAAa,CAAC;IAC7B,CAAC,UAAU,EAAE,aAAa,CAAC;IAC3B,CAAC,eAAe,EAAE,aAAa,CAAC;IAChC,CAAC,YAAY,EAAE,aAAa,CAAC;IAC7B,CAAC,UAAU,EAAE,aAAa,CAAC;IAC3B,CAAC,MAAM,EAAE,QAAQ,CAAC;IAClB,CAAC,IAAI,EAAE,QAAQ,CAAC;IAChB,CAAC,IAAI,EAAE,QAAQ,CAAC;IAChB,CAAC,IAAI,EAAE,QAA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C,KAAK,CAAC,cAAc,CAAC,CAAC;YAC/F,CAAC;QACH,CAAC;QAED,iBAAe,CAAC,kBAAkB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
3
|
+
export interface TogetherInstrumentationConfig extends InstrumentationConfig {
|
|
4
|
+
}
|
|
5
|
+
export default class Shield360TogetherInstrumentation extends InstrumentationBase {
|
|
6
|
+
constructor(config?: TogetherInstrumentationConfig);
|
|
7
|
+
protected init(): void | InstrumentationModuleDefinition | InstrumentationModuleDefinition[];
|
|
8
|
+
manualPatch(together: any): void;
|
|
9
|
+
protected _patch(moduleExports: any): void;
|
|
10
|
+
protected _unpatch(moduleExports: any): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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 constant_1 = require("../../constant");
|
|
8
|
+
const wrapper_1 = __importDefault(require("./wrapper"));
|
|
9
|
+
class Shield360TogetherInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
10
|
+
constructor(config = {}) {
|
|
11
|
+
super(`${constant_1.INSTRUMENTATION_PREFIX}/instrumentation-together`, '1.0.0', config);
|
|
12
|
+
}
|
|
13
|
+
init() {
|
|
14
|
+
const module = new instrumentation_1.InstrumentationNodeModuleDefinition('together-ai', ['>=0.1.0'], (moduleExports) => {
|
|
15
|
+
this._patch(moduleExports);
|
|
16
|
+
return moduleExports;
|
|
17
|
+
}, (moduleExports) => {
|
|
18
|
+
if (moduleExports !== undefined) {
|
|
19
|
+
this._unpatch(moduleExports);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return [module];
|
|
23
|
+
}
|
|
24
|
+
manualPatch(together) {
|
|
25
|
+
this._patch(together);
|
|
26
|
+
}
|
|
27
|
+
_patch(moduleExports) {
|
|
28
|
+
try {
|
|
29
|
+
if ((0, instrumentation_1.isWrapped)(moduleExports.Together.Chat.Completions.prototype.create)) {
|
|
30
|
+
this._unwrap(moduleExports.Together.Chat.Completions.prototype, 'create');
|
|
31
|
+
}
|
|
32
|
+
this._wrap(moduleExports.Together.Chat.Completions.prototype, 'create', wrapper_1.default._patchChatCompletionCreate(this.tracer));
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
console.error('Error in _patch method:', e);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
_unpatch(moduleExports) {
|
|
39
|
+
this._unwrap(moduleExports.Together.Chat.Completions.prototype, 'create');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.default = Shield360TogetherInstrumentation;
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/instrumentation/together/index.ts"],"names":[],"mappings":";;;;;AAAA,oEAKwC;AAExC,6CAAwD;AACxD,wDAAwC;AAIxC,MAAqB,gCAAiC,SAAQ,qCAAmB;IAC/E,YAAY,SAAwC,EAAE;QACpD,KAAK,CAAC,GAAG,iCAAsB,2BAA2B,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/E,CAAC;IAES,IAAI;QACZ,MAAM,MAAM,GAAG,IAAI,qDAAmC,CACpD,aAAa,EACb,CAAC,SAAS,CAAC,EACX,CAAC,aAAa,EAAE,EAAE;YAChB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YAC3B,OAAO,aAAa,CAAC;QACvB,CAAC,EACD,CAAC,aAAa,EAAE,EAAE;YAChB,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;gBAChC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC,CACF,CAAC;QACF,OAAO,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAEM,WAAW,CAAC,QAAa;QAC9B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxB,CAAC;IAES,MAAM,CAAC,aAAkB;QACjC,IAAI,CAAC;YACH,IAAI,IAAA,2BAAS,EAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;gBACxE,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YAC5E,CAAC;YAED,IAAI,CAAC,KAAK,CACR,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,EACjD,QAAQ,EACR,iBAAe,CAAC,0BAA0B,CAAC,IAAI,CAAC,MAAM,CAAC,CACxD,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,CAAC,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAES,QAAQ,CAAC,aAAkB;QACnC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC5E,CAAC;CACF;AA7CD,mDA6CC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Span, Tracer } from '@opentelemetry/api';
|
|
2
|
+
import BaseWrapper from '../base-wrapper';
|
|
3
|
+
declare class TogetherWrapper extends BaseWrapper {
|
|
4
|
+
static aiSystem: string;
|
|
5
|
+
static serverAddress: string;
|
|
6
|
+
static serverPort: number;
|
|
7
|
+
/**
|
|
8
|
+
* Stamp `shield360.agent.version_hash` (auto) and `gen_ai.agent.version`
|
|
9
|
+
* (user override, if set) on the span and return the same attributes so
|
|
10
|
+
* the caller can merge them into the inference event extras.
|
|
11
|
+
*/
|
|
12
|
+
static _stampAgentVersion(span: Span, args: {
|
|
13
|
+
systemInstructionsJson?: string;
|
|
14
|
+
toolDefinitionsJson?: string;
|
|
15
|
+
primaryModel?: string;
|
|
16
|
+
temperature?: number | null;
|
|
17
|
+
top_p?: number | null;
|
|
18
|
+
max_tokens?: number | null;
|
|
19
|
+
}): Record<string, string>;
|
|
20
|
+
static _patchChatCompletionCreate(tracer: Tracer): any;
|
|
21
|
+
static _chatCompletion({ args, genAIEndpoint, response, span, }: {
|
|
22
|
+
args: any[];
|
|
23
|
+
genAIEndpoint: string;
|
|
24
|
+
response: any;
|
|
25
|
+
span: Span;
|
|
26
|
+
}): Promise<any>;
|
|
27
|
+
static _chatCompletionGenerator({ args, genAIEndpoint, response, span, }: {
|
|
28
|
+
args: any[];
|
|
29
|
+
genAIEndpoint: string;
|
|
30
|
+
response: any;
|
|
31
|
+
span: Span;
|
|
32
|
+
}): AsyncGenerator<unknown, any, unknown>;
|
|
33
|
+
static _chatCompletionCommonSetter({ args, genAIEndpoint, result, span, ttft, tbt, }: {
|
|
34
|
+
args: any[];
|
|
35
|
+
genAIEndpoint: string;
|
|
36
|
+
result: any;
|
|
37
|
+
span: Span;
|
|
38
|
+
ttft?: number;
|
|
39
|
+
tbt?: number;
|
|
40
|
+
}): Promise<{
|
|
41
|
+
genAIEndpoint: string;
|
|
42
|
+
model: any;
|
|
43
|
+
user: any;
|
|
44
|
+
cost: number;
|
|
45
|
+
aiSystem: string;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
export default TogetherWrapper;
|