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,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.llmResponseAnthropic = llmResponseAnthropic;
|
|
4
|
+
async function llmResponseAnthropic({ prompt, model, apiKey }) {
|
|
5
|
+
let Anthropic;
|
|
6
|
+
try {
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
8
|
+
Anthropic = require('@anthropic-ai/sdk').default;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
throw new Error("shield360 guard/eval features require the '@anthropic-ai/sdk' package. Install it with: npm install @anthropic-ai/sdk");
|
|
12
|
+
}
|
|
13
|
+
const client = new Anthropic({ apiKey });
|
|
14
|
+
const usedModel = model || 'claude-3-opus-20240229';
|
|
15
|
+
const response = await client.messages.create({
|
|
16
|
+
model: usedModel,
|
|
17
|
+
max_tokens: 2000,
|
|
18
|
+
messages: [
|
|
19
|
+
{ role: 'user', content: prompt }
|
|
20
|
+
],
|
|
21
|
+
temperature: 0.0,
|
|
22
|
+
// Anthropic does not support response_format, so we expect JSON in text
|
|
23
|
+
});
|
|
24
|
+
if (typeof response.content === 'string')
|
|
25
|
+
return response.content;
|
|
26
|
+
if (Array.isArray(response.content)) {
|
|
27
|
+
for (const part of response.content) {
|
|
28
|
+
if (part.type === 'text' && typeof part.text === 'string' && part.text.trim().startsWith('{')) {
|
|
29
|
+
return part.text;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return response.content
|
|
33
|
+
.filter((p) => p.type === 'text' && typeof p.text === 'string')
|
|
34
|
+
.map((p) => p.text)
|
|
35
|
+
.join(' ');
|
|
36
|
+
}
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=anthropic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/llm/anthropic.ts"],"names":[],"mappings":";;AAAA,oDA0CC;AA1CM,KAAK,UAAU,oBAAoB,CAAC,EACzC,MAAM,EACN,KAAK,EACL,MAAM,EAKP;IACC,IAAI,SAAc,CAAC;IACnB,IAAI,CAAC;QACH,8DAA8D;QAC9D,SAAS,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC;IACnD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,uHAAuH,CACxH,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACzC,MAAM,SAAS,GAAG,KAAK,IAAI,wBAAwB,CAAC;IACpD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC5C,KAAK,EAAE,SAAS;QAChB,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE;YACR,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;SAClC;QACD,WAAW,EAAE,GAAG;QAChB,wEAAwE;KACzE,CAAC,CAAC;IACH,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC,OAAO,CAAC;IAClE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACpC,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9F,OAAO,IAAI,CAAC,IAAI,CAAC;YACnB,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAC,OAAO;aACpB,MAAM,CAAC,CAAC,CAAmC,EAAwC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC;aACtI,GAAG,CAAC,CAAC,CAAmB,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;aACpC,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface LegacyGuardResult {
|
|
2
|
+
score: number;
|
|
3
|
+
verdict: 'yes' | 'no' | 'none';
|
|
4
|
+
guard: string;
|
|
5
|
+
classification: string;
|
|
6
|
+
explanation: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function llmResponse(provider: string, prompt: string, model?: string, baseUrl?: string, apiKey?: string): Promise<string>;
|
|
9
|
+
export declare function parseLlmResponse(response: string | object): LegacyGuardResult;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.llmResponse = llmResponse;
|
|
37
|
+
exports.parseLlmResponse = parseLlmResponse;
|
|
38
|
+
async function llmResponse(provider, prompt, model, baseUrl, apiKey) {
|
|
39
|
+
if (provider.toLowerCase() === 'openai') {
|
|
40
|
+
const { llmResponseOpenAI } = await Promise.resolve().then(() => __importStar(require('./openai')));
|
|
41
|
+
return llmResponseOpenAI({ prompt, model, baseUrl, apiKey });
|
|
42
|
+
}
|
|
43
|
+
else if (provider.toLowerCase() === 'anthropic') {
|
|
44
|
+
const { llmResponseAnthropic } = await Promise.resolve().then(() => __importStar(require('./anthropic')));
|
|
45
|
+
return llmResponseAnthropic({ prompt, model, apiKey });
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
throw new Error(`Unsupported provider: ${provider}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function parseLlmResponse(response) {
|
|
52
|
+
try {
|
|
53
|
+
let data;
|
|
54
|
+
if (typeof response === 'string') {
|
|
55
|
+
data = JSON.parse(response);
|
|
56
|
+
}
|
|
57
|
+
else if (typeof response === 'object') {
|
|
58
|
+
data = response;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
throw new Error('Response must be a JSON string or an object.');
|
|
62
|
+
}
|
|
63
|
+
let verdict = 'none';
|
|
64
|
+
if (typeof data.verdict === 'string') {
|
|
65
|
+
if (data.verdict === 'yes' || data.verdict === 'no') {
|
|
66
|
+
verdict = data.verdict;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// eslint-disable-next-line no-console
|
|
70
|
+
console.warn(`Unexpected verdict value in LLM response: "${data.verdict}". Coercing to 'none'.`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
score: typeof data.score === 'number' ? data.score : 0,
|
|
75
|
+
verdict,
|
|
76
|
+
guard: typeof data.guard === 'string' ? data.guard : 'none',
|
|
77
|
+
classification: typeof data.classification === 'string' ? data.classification : 'none',
|
|
78
|
+
explanation: typeof data.explanation === 'string' ? data.explanation : 'none',
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
// eslint-disable-next-line no-console
|
|
83
|
+
console.error('Error parsing LLM response:', e);
|
|
84
|
+
return {
|
|
85
|
+
score: 0,
|
|
86
|
+
verdict: 'none',
|
|
87
|
+
guard: 'none',
|
|
88
|
+
classification: 'none',
|
|
89
|
+
explanation: 'none'
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,kCAUC;AAED,4CAuCC;AAnDM,KAAK,UAAU,WAAW,CAAC,QAAgB,EAAE,MAAc,EAAE,KAAc,EAAE,OAAgB,EAAE,MAAe;IACnH,IAAI,QAAQ,CAAC,WAAW,EAAE,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,EAAE,iBAAiB,EAAE,GAAG,wDAAa,UAAU,GAAC,CAAC;QACvD,OAAO,iBAAiB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/D,CAAC;SAAM,IAAI,QAAQ,CAAC,WAAW,EAAE,KAAK,WAAW,EAAE,CAAC;QAClD,MAAM,EAAE,oBAAoB,EAAE,GAAG,wDAAa,aAAa,GAAC,CAAC;QAC7D,OAAO,oBAAoB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IACzD,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAC;IACvD,CAAC;AACH,CAAC;AAED,SAAgB,gBAAgB,CAAC,QAAyB;IACxD,IAAI,CAAC;QACH,IAAI,IAA6B,CAAC;QAClC,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjC,IAAI,GAAG,IAAI,CAAC,KAAK,CAA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OAAO,EAAE,MAAM;YACf,KAAK,EAAE,MAAM;YACb,cAAc,EAAE,MAAM;YACtB,WAAW,EAAE,MAAM;SACpB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.llmResponseOpenAI = llmResponseOpenAI;
|
|
4
|
+
async function llmResponseOpenAI({ prompt, model, apiKey, baseUrl }) {
|
|
5
|
+
let OpenAI;
|
|
6
|
+
try {
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
8
|
+
OpenAI = require('openai').default;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
throw new Error("shield360 guard/eval features require the 'openai' package. Install it with: npm install openai");
|
|
12
|
+
}
|
|
13
|
+
const client = new OpenAI({
|
|
14
|
+
apiKey,
|
|
15
|
+
baseURL: baseUrl || 'https://api.openai.com/v1',
|
|
16
|
+
});
|
|
17
|
+
const usedModel = model || 'gpt-4o';
|
|
18
|
+
const response = await client.chat.completions.create({
|
|
19
|
+
model: usedModel,
|
|
20
|
+
messages: [
|
|
21
|
+
{ role: 'user', content: prompt }
|
|
22
|
+
],
|
|
23
|
+
temperature: 0.0,
|
|
24
|
+
response_format: { type: 'json_object' }
|
|
25
|
+
});
|
|
26
|
+
if (!response) {
|
|
27
|
+
console.error('OpenAI API did not return a response object:', response);
|
|
28
|
+
throw new Error('OpenAI API did not return a response object.');
|
|
29
|
+
}
|
|
30
|
+
if (!response.choices) {
|
|
31
|
+
console.error('OpenAI API response missing "choices":', response);
|
|
32
|
+
throw new Error('OpenAI API response missing "choices".');
|
|
33
|
+
}
|
|
34
|
+
if (!Array.isArray(response.choices) || response.choices.length === 0) {
|
|
35
|
+
console.error('OpenAI API response "choices" is empty or not an array:', response.choices);
|
|
36
|
+
throw new Error('OpenAI API response "choices" is empty or not an array.');
|
|
37
|
+
}
|
|
38
|
+
if (!response.choices[0]) {
|
|
39
|
+
console.error('OpenAI API response "choices[0]" is missing:', response.choices);
|
|
40
|
+
throw new Error('OpenAI API response "choices[0]" is missing.');
|
|
41
|
+
}
|
|
42
|
+
if (!response.choices[0].message) {
|
|
43
|
+
console.error('OpenAI API response "choices[0].message" is missing:', response.choices[0]);
|
|
44
|
+
throw new Error('OpenAI API response "choices[0].message" is missing.');
|
|
45
|
+
}
|
|
46
|
+
if (typeof response.choices[0].message.content !== 'string') {
|
|
47
|
+
console.error('OpenAI API response "choices[0].message.content" is missing or not a string:', response.choices[0].message);
|
|
48
|
+
throw new Error('OpenAI API response "choices[0].message.content" is missing or not a string.');
|
|
49
|
+
}
|
|
50
|
+
return response.choices[0].message.content || '';
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=openai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/llm/openai.ts"],"names":[],"mappings":";;AAAA,8CA0DC;AA1DM,KAAK,UAAU,iBAAiB,CAAC,EACtC,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EAMR;IACC,IAAI,MAAW,CAAC;IAChB,IAAI,CAAC;QACH,8DAA8D;QAC9D,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,iGAAiG,CAClG,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;QACxB,MAAM;QACN,OAAO,EAAE,OAAO,IAAI,2BAA2B;KAChD,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,KAAK,IAAI,QAAQ,CAAC;IACpC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;QACpD,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE;YACR,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,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KAAK,QAAQ,EAAE,CAAC;QAC5D,OAAO,CAAC,KAAK,CAAC,8EAA8E,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC3H,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;IAClG,CAAC;IACD,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.llmProviders = void 0;
|
|
4
|
+
const openai_1 = require("./openai");
|
|
5
|
+
const anthropic_1 = require("./anthropic");
|
|
6
|
+
exports.llmProviders = {
|
|
7
|
+
openai: openai_1.llmResponseOpenAI,
|
|
8
|
+
anthropic: anthropic_1.llmResponseAnthropic,
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/llm/providers.ts"],"names":[],"mappings":";;;AAAA,qCAA6C;AAC7C,2CAAmD;AAStC,QAAA,YAAY,GAAkC;IACzD,MAAM,EAAE,0BAAiB;IACzB,SAAS,EAAE,gCAAoB;CAChC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Span } from '@opentelemetry/api';
|
|
2
|
+
/**
|
|
3
|
+
* Wrapper for an OpenTelemetry span with helpers to set result and metadata.
|
|
4
|
+
* Mirrors Python's TracedSpan — the span lifecycle is managed by startTrace() /
|
|
5
|
+
* trace(), so you do not call end() yourself (like Python's `with` block).
|
|
6
|
+
*/
|
|
7
|
+
export declare class TracedSpan {
|
|
8
|
+
private readonly _span;
|
|
9
|
+
constructor(span: Span);
|
|
10
|
+
/** Record the AI output or function return value on the span. */
|
|
11
|
+
setResult(result: string): void;
|
|
12
|
+
/** Stamp arbitrary key/value attributes onto the span. */
|
|
13
|
+
setMetadata(metadata: Record<string, string | number | boolean>): void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Start a named CLIENT span scoped to a callback — the TypeScript equivalent of
|
|
17
|
+
* Python's `with start_trace(name) as span:`.
|
|
18
|
+
*
|
|
19
|
+
* The span is active for the duration of `fn`, so child LLM spans nest correctly.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const answer = await shield360.startTrace('my-operation', async (span) => {
|
|
23
|
+
* const result = await doWork();
|
|
24
|
+
* span.setResult(String(result));
|
|
25
|
+
* return result;
|
|
26
|
+
* });
|
|
27
|
+
*/
|
|
28
|
+
export declare function startTrace<T>(name: string, fn: (span: TracedSpan) => T | Promise<T>): T | Promise<T>;
|
|
29
|
+
/**
|
|
30
|
+
* Wrap a function call in a CLIENT span — the TypeScript equivalent of
|
|
31
|
+
* Python's `@shield360.trace` decorator.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const answer = await shield360.trace('my-chain', async (span) => {
|
|
35
|
+
* const result = await chain.invoke({ question });
|
|
36
|
+
* span.setResult(result.content);
|
|
37
|
+
* return result;
|
|
38
|
+
* });
|
|
39
|
+
*/
|
|
40
|
+
export declare function trace<T>(name: string, fn: (span: TracedSpan) => T | Promise<T>): T | Promise<T>;
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
exports.TracedSpan = void 0;
|
|
7
|
+
exports.startTrace = startTrace;
|
|
8
|
+
exports.trace = trace;
|
|
9
|
+
const api_1 = require("@opentelemetry/api");
|
|
10
|
+
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
11
|
+
const config_1 = __importDefault(require("./config"));
|
|
12
|
+
const semantic_convention_1 = __importDefault(require("./semantic-convention"));
|
|
13
|
+
function getTracer() {
|
|
14
|
+
const provider = config_1.default.tracer;
|
|
15
|
+
return provider?.getTracer?.('shield360') ?? api_1.trace.getTracer('shield360');
|
|
16
|
+
}
|
|
17
|
+
function attachAppAttrs(span) {
|
|
18
|
+
span.setAttribute(semantic_conventions_1.ATTR_SERVICE_NAME, config_1.default.applicationName ?? 'default');
|
|
19
|
+
span.setAttribute(semantic_convention_1.default.ATTR_DEPLOYMENT_ENVIRONMENT, config_1.default.environment ?? 'default');
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Wrapper for an OpenTelemetry span with helpers to set result and metadata.
|
|
23
|
+
* Mirrors Python's TracedSpan — the span lifecycle is managed by startTrace() /
|
|
24
|
+
* trace(), so you do not call end() yourself (like Python's `with` block).
|
|
25
|
+
*/
|
|
26
|
+
class TracedSpan {
|
|
27
|
+
constructor(span) {
|
|
28
|
+
this._span = span;
|
|
29
|
+
}
|
|
30
|
+
/** Record the AI output or function return value on the span. */
|
|
31
|
+
setResult(result) {
|
|
32
|
+
this._span.setAttribute(semantic_convention_1.default.GEN_AI_OUTPUT_MESSAGES, result);
|
|
33
|
+
}
|
|
34
|
+
/** Stamp arbitrary key/value attributes onto the span. */
|
|
35
|
+
setMetadata(metadata) {
|
|
36
|
+
this._span.setAttributes(metadata);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.TracedSpan = TracedSpan;
|
|
40
|
+
function runInActiveSpan(name, fn) {
|
|
41
|
+
return getTracer().startActiveSpan(name, { kind: api_1.SpanKind.CLIENT }, (rawSpan) => {
|
|
42
|
+
attachAppAttrs(rawSpan);
|
|
43
|
+
const handle = new TracedSpan(rawSpan);
|
|
44
|
+
const endOk = () => {
|
|
45
|
+
rawSpan.setStatus({ code: api_1.SpanStatusCode.OK });
|
|
46
|
+
rawSpan.end();
|
|
47
|
+
};
|
|
48
|
+
const endError = (err) => {
|
|
49
|
+
rawSpan.recordException(err);
|
|
50
|
+
rawSpan.setStatus({
|
|
51
|
+
code: api_1.SpanStatusCode.ERROR,
|
|
52
|
+
message: String(err),
|
|
53
|
+
});
|
|
54
|
+
rawSpan.end();
|
|
55
|
+
throw err;
|
|
56
|
+
};
|
|
57
|
+
try {
|
|
58
|
+
const result = fn(handle);
|
|
59
|
+
if (result !== null && typeof result?.then === 'function') {
|
|
60
|
+
return result.then((val) => {
|
|
61
|
+
endOk();
|
|
62
|
+
return val;
|
|
63
|
+
}, (err) => endError(err));
|
|
64
|
+
}
|
|
65
|
+
endOk();
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
return endError(err);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Start a named CLIENT span scoped to a callback — the TypeScript equivalent of
|
|
75
|
+
* Python's `with start_trace(name) as span:`.
|
|
76
|
+
*
|
|
77
|
+
* The span is active for the duration of `fn`, so child LLM spans nest correctly.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* const answer = await shield360.startTrace('my-operation', async (span) => {
|
|
81
|
+
* const result = await doWork();
|
|
82
|
+
* span.setResult(String(result));
|
|
83
|
+
* return result;
|
|
84
|
+
* });
|
|
85
|
+
*/
|
|
86
|
+
function startTrace(name, fn) {
|
|
87
|
+
return runInActiveSpan(name, fn);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Wrap a function call in a CLIENT span — the TypeScript equivalent of
|
|
91
|
+
* Python's `@shield360.trace` decorator.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* const answer = await shield360.trace('my-chain', async (span) => {
|
|
95
|
+
* const result = await chain.invoke({ question });
|
|
96
|
+
* span.setResult(result.content);
|
|
97
|
+
* return result;
|
|
98
|
+
* });
|
|
99
|
+
*/
|
|
100
|
+
function trace(name, fn) {
|
|
101
|
+
return runInActiveSpan(name, fn);
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=manual-trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manual-trace.js","sourceRoot":"","sources":["../src/manual-trace.ts"],"names":[],"mappings":";;;;;;AAoGA,gCAKC;AAaD,sBAKC;AA3HD,4CAAwF;AACxF,8EAAwE;AACxE,sDAAuC;AACvC,gFAAuD;AAEvD,SAAS,SAAS;IAChB,MAAM,QAAQ,GAAG,gBAAe,CAAC,MAAa,CAAC;IAC/C,OAAO,QAAQ,EAAE,SAAS,EAAE,CAAC,WAAW,CAAC,IAAI,WAAS,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,cAAc,CAAC,IAAU;IAChC,IAAI,CAAC,YAAY,CAAC,wCAAiB,EAAE,gBAAe,CAAC,eAAe,IAAI,SAAS,CAAC,CAAC;IACnF,IAAI,CAAC,YAAY,CACf,6BAAkB,CAAC,2BAA2B,EAC9C,gBAAe,CAAC,WAAW,IAAI,SAAS,CACzC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAa,UAAU;IAGrB,YAAY,IAAU;QACpB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,iEAAiE;IACjE,SAAS,CAAC,MAAc;QACtB,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,6BAAkB,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;IAC7E,CAAC;IAED,0DAA0D;IAC1D,WAAW,CAAC,QAAmD;QAC7D,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;CACF;AAhBD,gCAgBC;AAED,SAAS,eAAe,CACtB,IAAY,EACZ,EAAwC;IAExC,OAAO,SAAS,EAAE,CAAC,eAAe,CAChC,IAAI,EACJ,EAAE,IAAI,EAAE,cAAQ,CAAC,MAAM,EAAE,EACzB,CAAC,OAAa,EAAE,EAAE;QAChB,cAAc,CAAC,OAAO,CA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;;;;;;;;;GAUG;AACH,SAAgB,KAAK,CACnB,IAAY,EACZ,EAAwC;IAExC,OAAO,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
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 metrics_1 = __importDefault(require("../metrics"));
|
|
7
|
+
const semantic_convention_1 = __importDefault(require("../../semantic-convention"));
|
|
8
|
+
const resources_1 = require("@opentelemetry/resources");
|
|
9
|
+
const setupOpts = {
|
|
10
|
+
resource: (0, resources_1.defaultResource)(),
|
|
11
|
+
otlpEndpoint: 'http://localhost:4318',
|
|
12
|
+
environment: 'default',
|
|
13
|
+
applicationName: 'default',
|
|
14
|
+
disableBatch: false,
|
|
15
|
+
captureMessageContent: true,
|
|
16
|
+
disableMetrics: false,
|
|
17
|
+
disableEvents: false,
|
|
18
|
+
};
|
|
19
|
+
describe('Metrics creation', () => {
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
metrics_1.default.resetForTesting();
|
|
22
|
+
metrics_1.default.setup(setupOpts);
|
|
23
|
+
});
|
|
24
|
+
it('should create genaiClientUsageTokens histogram and allow record', () => {
|
|
25
|
+
expect(metrics_1.default.genaiClientUsageTokens).toBeDefined();
|
|
26
|
+
expect(typeof metrics_1.default.genaiClientUsageTokens.record).toBe('function');
|
|
27
|
+
expect(() => metrics_1.default.genaiClientUsageTokens.record(42, { [semantic_convention_1.default.GEN_AI_PROVIDER_NAME]: 'openai' })).not.toThrow();
|
|
28
|
+
});
|
|
29
|
+
it('should create genaiClientOperationDuration histogram and allow record', () => {
|
|
30
|
+
expect(metrics_1.default.genaiClientOperationDuration).toBeDefined();
|
|
31
|
+
expect(typeof metrics_1.default.genaiClientOperationDuration.record).toBe('function');
|
|
32
|
+
expect(() => metrics_1.default.genaiClientOperationDuration.record(1.23, { [semantic_convention_1.default.GEN_AI_PROVIDER_NAME]: 'openai' })).not.toThrow();
|
|
33
|
+
});
|
|
34
|
+
it('should create genaiCost histogram and allow record', () => {
|
|
35
|
+
expect(metrics_1.default.genaiCost).toBeDefined();
|
|
36
|
+
expect(typeof metrics_1.default.genaiCost.record).toBe('function');
|
|
37
|
+
expect(() => metrics_1.default.genaiCost.record(0.99, { [semantic_convention_1.default.GEN_AI_PROVIDER_NAME]: 'openai' })).not.toThrow();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=metrics.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.test.js","sourceRoot":"","sources":["../../../src/otel/__tests__/metrics.test.ts"],"names":[],"mappings":";;;;;AAAA,yDAAiC;AACjC,oFAA2D;AAC3D,wDAA2D;AAE3D,MAAM,SAAS,GAAG;IAChB,QAAQ,EAAE,IAAA,2BAAe,GAAE;IAC3B,YAAY,EAAE,uBAAuB;IACrC,WAAW,EAAE,SAAS;IACtB,eAAe,EAAE,SAAS;IAC1B,YAAY,EAAE,KAAK;IACnB,qBAAqB,EAAE,IAAI;IAC3B,cAAc,EAAE,KAAK;IACrB,aAAa,EAAE,KAAK;CACrB,CAAC;AAEF,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,UAAU,CAAC,GAAG,EAAE;QACd,iBAAO,CAAC,eAAe,EAAE,CAAC;QAC1B,iBAAO,CAAC,KAAK,CAAC,SAAgB,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,CAAC,iBAAO,CAAC,sBAAsB,CAAC,CAAC,WAAW,EAAE,CAAC;QACrD,MAAM,CAAC,OAAO,iBAAO,CAAC,sBAAsB,CAAC,MA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
import { LoggerProvider } from '@opentelemetry/sdk-logs';
|
|
3
|
+
import { SetupEventsOptions } from '../types';
|
|
4
|
+
export default class Events {
|
|
5
|
+
static loggerProvider: LoggerProvider;
|
|
6
|
+
static logger: ReturnType<typeof logs.getLogger>;
|
|
7
|
+
static setup(options: SetupEventsOptions): import("@opentelemetry/api-logs").Logger | null;
|
|
8
|
+
private static buildLoggerProvider;
|
|
9
|
+
private static createOTLPProcessor;
|
|
10
|
+
static resetForTesting(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const api_logs_1 = require("@opentelemetry/api-logs");
|
|
4
|
+
const sdk_logs_1 = require("@opentelemetry/sdk-logs");
|
|
5
|
+
const exporter_logs_otlp_http_1 = require("@opentelemetry/exporter-logs-otlp-http");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
let EVENTS_SET = false;
|
|
8
|
+
class Events {
|
|
9
|
+
static setup(options) {
|
|
10
|
+
try {
|
|
11
|
+
if (!EVENTS_SET) {
|
|
12
|
+
const existingProvider = api_logs_1.logs.getLoggerProvider();
|
|
13
|
+
const isSDKProvider = existingProvider &&
|
|
14
|
+
typeof existingProvider.forceFlush === 'function' &&
|
|
15
|
+
existingProvider.constructor.name !== 'NoopLoggerProvider';
|
|
16
|
+
if (isSDKProvider) {
|
|
17
|
+
this.loggerProvider = existingProvider;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this.loggerProvider = Events.buildLoggerProvider(options);
|
|
21
|
+
api_logs_1.logs.setGlobalLoggerProvider(this.loggerProvider);
|
|
22
|
+
}
|
|
23
|
+
this.logger = this.loggerProvider.getLogger('shield360');
|
|
24
|
+
EVENTS_SET = true;
|
|
25
|
+
}
|
|
26
|
+
return this.logger;
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
console.error('[Events] Failed to initialize events:', e);
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
static buildLoggerProvider(options) {
|
|
34
|
+
const exporterList = (0, utils_1.parseExporters)('OTEL_LOGS_EXPORTER');
|
|
35
|
+
const processors = [];
|
|
36
|
+
if (exporterList) {
|
|
37
|
+
for (const name of exporterList) {
|
|
38
|
+
if (name === 'otlp') {
|
|
39
|
+
processors.push(Events.createOTLPProcessor(options));
|
|
40
|
+
}
|
|
41
|
+
else if (name === 'console') {
|
|
42
|
+
processors.push(new sdk_logs_1.SimpleLogRecordProcessor({ exporter: new sdk_logs_1.ConsoleLogRecordExporter() }));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
if (options.otlpEndpoint) {
|
|
48
|
+
processors.push(Events.createOTLPProcessor(options));
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
processors.push(new sdk_logs_1.SimpleLogRecordProcessor({ exporter: new sdk_logs_1.ConsoleLogRecordExporter() }));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return new sdk_logs_1.LoggerProvider({
|
|
55
|
+
resource: options.resource,
|
|
56
|
+
processors,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
static createOTLPProcessor(options) {
|
|
60
|
+
const url = (options.otlpEndpoint || '') + '/v1/logs';
|
|
61
|
+
const exporter = new exporter_logs_otlp_http_1.OTLPLogExporter({
|
|
62
|
+
url,
|
|
63
|
+
headers: options.otlpHeaders,
|
|
64
|
+
});
|
|
65
|
+
return options.disableBatch
|
|
66
|
+
? new sdk_logs_1.SimpleLogRecordProcessor({ exporter })
|
|
67
|
+
: new sdk_logs_1.BatchLogRecordProcessor({ exporter });
|
|
68
|
+
}
|
|
69
|
+
static resetForTesting() {
|
|
70
|
+
EVENTS_SET = false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.default = Events;
|
|
74
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 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pB,UAAU,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAzED,yBAyEC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { MeterProvider, PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';
|
|
2
|
+
import { metrics } from '@opentelemetry/api';
|
|
3
|
+
import { SetupMetricsOptions } from '../types';
|
|
4
|
+
export default class Metrics {
|
|
5
|
+
static meterProvider: MeterProvider;
|
|
6
|
+
static meter: ReturnType<typeof metrics.getMeter>;
|
|
7
|
+
static metricReaders: PeriodicExportingMetricReader[];
|
|
8
|
+
static genaiClientUsageTokens: ReturnType<ReturnType<typeof metrics.getMeter>['createHistogram']>;
|
|
9
|
+
static genaiClientOperationDuration: ReturnType<ReturnType<typeof metrics.getMeter>['createHistogram']>;
|
|
10
|
+
static genaiServerTbt: ReturnType<ReturnType<typeof metrics.getMeter>['createHistogram']>;
|
|
11
|
+
static genaiServerTtft: ReturnType<ReturnType<typeof metrics.getMeter>['createHistogram']>;
|
|
12
|
+
static genaiClientTimeToFirstChunk: ReturnType<ReturnType<typeof metrics.getMeter>['createHistogram']>;
|
|
13
|
+
static genaiClientTimePerOutputChunk: ReturnType<ReturnType<typeof metrics.getMeter>['createHistogram']>;
|
|
14
|
+
static genaiServerRequestDuration: ReturnType<ReturnType<typeof metrics.getMeter>['createHistogram']>;
|
|
15
|
+
static dbClientOperationDuration: ReturnType<ReturnType<typeof metrics.getMeter>['createHistogram']>;
|
|
16
|
+
static genaiCost: ReturnType<ReturnType<typeof metrics.getMeter>['createHistogram']>;
|
|
17
|
+
static dbRequests: ReturnType<ReturnType<typeof metrics.getMeter>['createCounter']>;
|
|
18
|
+
static guardRequests: ReturnType<ReturnType<typeof metrics.getMeter>['createCounter']>;
|
|
19
|
+
static mcpRequests: ReturnType<ReturnType<typeof metrics.getMeter>['createCounter']>;
|
|
20
|
+
static mcpClientOperationDuration: ReturnType<ReturnType<typeof metrics.getMeter>['createHistogram']>;
|
|
21
|
+
static mcpRequestSize: ReturnType<ReturnType<typeof metrics.getMeter>['createHistogram']>;
|
|
22
|
+
static mcpResponseSize: ReturnType<ReturnType<typeof metrics.getMeter>['createHistogram']>;
|
|
23
|
+
static mcpToolCalls: ReturnType<ReturnType<typeof metrics.getMeter>['createCounter']>;
|
|
24
|
+
static mcpResourceReads: ReturnType<ReturnType<typeof metrics.getMeter>['createCounter']>;
|
|
25
|
+
static mcpPromptGets: ReturnType<ReturnType<typeof metrics.getMeter>['createCounter']>;
|
|
26
|
+
static mcpTransportUsage: ReturnType<ReturnType<typeof metrics.getMeter>['createCounter']>;
|
|
27
|
+
static mcpErrors: ReturnType<ReturnType<typeof metrics.getMeter>['createCounter']>;
|
|
28
|
+
static mcpOperationSuccessRate: ReturnType<ReturnType<typeof metrics.getMeter>['createHistogram']>;
|
|
29
|
+
static initializeMetrics(): void;
|
|
30
|
+
static setup(options: SetupMetricsOptions): import("@opentelemetry/api").Meter | null;
|
|
31
|
+
private static buildMetricReaders;
|
|
32
|
+
private static createOTLPReader;
|
|
33
|
+
private static createConsoleReader;
|
|
34
|
+
static resetForTesting(): void;
|
|
35
|
+
}
|