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,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Sensitive topic detection guard.
|
|
4
|
+
*
|
|
5
|
+
* Uses keyword/regex dictionaries for fast-path detection of sensitive
|
|
6
|
+
* content categories. An optional user-provided classifier handles
|
|
7
|
+
* ambiguous cases.
|
|
8
|
+
*
|
|
9
|
+
* Patterns must stay in sync with: sdk/python/src/shield360/guard/sensitive_topic.py
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SensitiveTopic = void 0;
|
|
13
|
+
const base_1 = require("./base");
|
|
14
|
+
const DEFAULT_CATEGORIES = {
|
|
15
|
+
violence: [
|
|
16
|
+
/\b(?:kill|murder|assault|attack|weapon|bomb|shoot|stab|torture|terrorism|massacre|genocide)\b/i,
|
|
17
|
+
],
|
|
18
|
+
politics: [
|
|
19
|
+
/\b(?:democrat|republican|election\s+fraud|political\s+party|vote\s+rigging|coup|insurrection)\b/i,
|
|
20
|
+
],
|
|
21
|
+
substance_use: [
|
|
22
|
+
/\b(?:cocaine|heroin|methamphetamine|fentanyl|drug\s+(?:deal|traffick)|overdose|illegal\s+drugs)\b/i,
|
|
23
|
+
],
|
|
24
|
+
mental_health: [
|
|
25
|
+
/\b(?:suicid(?:e|al)|self[- ]harm|eating\s+disorder|anorexia|bulimia)\b/i,
|
|
26
|
+
],
|
|
27
|
+
discrimination: [
|
|
28
|
+
/\b(?:racial\s+slur|white\s+supremac|ethnic\s+cleansing|hate\s+(?:speech|crime))\b/i,
|
|
29
|
+
],
|
|
30
|
+
adult_content: [
|
|
31
|
+
/\b(?:pornograph|explicit\s+sexual|nude\s+images|sex\s+trafficking)\b/i,
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
class SensitiveTopic extends base_1.Guard {
|
|
35
|
+
constructor(opts = {}) {
|
|
36
|
+
super({ action: opts.action ?? 'warn', maxScanLength: opts.maxScanLength });
|
|
37
|
+
this.name = 'sensitive_topic';
|
|
38
|
+
this.phases = [base_1.GuardPhase.PREFLIGHT, base_1.GuardPhase.POSTFLIGHT];
|
|
39
|
+
this._classifier = opts.classifier;
|
|
40
|
+
const allowedCategories = opts.categories
|
|
41
|
+
? new Set(opts.categories)
|
|
42
|
+
: null;
|
|
43
|
+
this._patterns = {};
|
|
44
|
+
for (const [cat, pats] of Object.entries(DEFAULT_CATEGORIES)) {
|
|
45
|
+
if (allowedCategories === null || allowedCategories.has(cat)) {
|
|
46
|
+
this._patterns[cat] = [...pats];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (opts.customCategories) {
|
|
50
|
+
for (const [cat, rawPats] of Object.entries(opts.customCategories)) {
|
|
51
|
+
const compiled = rawPats.map((p) => new RegExp(p, 'i'));
|
|
52
|
+
if (!this._patterns[cat]) {
|
|
53
|
+
this._patterns[cat] = [];
|
|
54
|
+
}
|
|
55
|
+
this._patterns[cat].push(...compiled);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
evaluate(text) {
|
|
60
|
+
const detected = [];
|
|
61
|
+
for (const [cat, patterns] of Object.entries(this._patterns)) {
|
|
62
|
+
for (const pat of patterns) {
|
|
63
|
+
if (pat.test(text)) {
|
|
64
|
+
detected.push(cat);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (detected.length === 0 && this._classifier) {
|
|
70
|
+
const result = this._classifier(text);
|
|
71
|
+
if (result) {
|
|
72
|
+
detected.push(result);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (detected.length > 0) {
|
|
76
|
+
const classification = [...detected].sort().join(', ');
|
|
77
|
+
return (0, base_1.makeGuardResult)({
|
|
78
|
+
action: this._action,
|
|
79
|
+
score: Math.round(Math.min(1.0, detected.length * 0.3 + 0.4) * 100) / 100,
|
|
80
|
+
guardName: this.name,
|
|
81
|
+
classification,
|
|
82
|
+
explanation: `Sensitive topic(s) detected: ${classification}`,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return (0, base_1.makeGuardResult)({ guardName: this.name });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.SensitiveTopic = SensitiveTopic;
|
|
89
|
+
//# sourceMappingURL=sensitive-topic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sensitive-topic.js","sourceRoot":"","sources":["../../src/guard/sensitive-topic.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,iCAAuF;AAEvF,MAAM,kBAAkB,GAA6B;IACnD,QAAQ,EAAE;QACR,gGAAgG;KACjG;IACD,QAAQ,EAAE;QACR,kGAAkG;KACnG;IACD,aAAa,EAAE;QACb,oGAAoG;KACrG;IACD,aAAa,EAAE;QACb,yEAAyE;KAC1E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,GAAG,CAAC,GAAG,GAAG;gBACzE,SAAS,EAAE,IAAI,CAAC,IAAI;gBACpB,cAAc;gBACd,WAAW,EAAE,gCAAgC,cAAc,EAAE;aAC9D,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAA,sBAAe,EAAC,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;CACF;AAjED,wCAiEC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Topic restriction guard.
|
|
3
|
+
*
|
|
4
|
+
* Enforces allow/deny topic lists using a user-provided topic classifier.
|
|
5
|
+
*
|
|
6
|
+
* Must stay in sync with: sdk/python/src/shield360/guard/topic_restriction.py
|
|
7
|
+
*/
|
|
8
|
+
import { Guard, GuardPhase, GuardResult, GuardOptions } from './base';
|
|
9
|
+
export interface TopicRestrictionOptions extends GuardOptions {
|
|
10
|
+
classifier: (text: string) => string;
|
|
11
|
+
allowed?: string[];
|
|
12
|
+
denied?: string[];
|
|
13
|
+
}
|
|
14
|
+
export declare class TopicRestriction extends Guard {
|
|
15
|
+
readonly name = "topic_restriction";
|
|
16
|
+
readonly phases: GuardPhase[];
|
|
17
|
+
private readonly _classifier;
|
|
18
|
+
private readonly _allowed;
|
|
19
|
+
private readonly _denied;
|
|
20
|
+
constructor(opts: TopicRestrictionOptions);
|
|
21
|
+
evaluate(text: string): GuardResult;
|
|
22
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Topic restriction guard.
|
|
4
|
+
*
|
|
5
|
+
* Enforces allow/deny topic lists using a user-provided topic classifier.
|
|
6
|
+
*
|
|
7
|
+
* Must stay in sync with: sdk/python/src/shield360/guard/topic_restriction.py
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.TopicRestriction = void 0;
|
|
11
|
+
const base_1 = require("./base");
|
|
12
|
+
class TopicRestriction extends base_1.Guard {
|
|
13
|
+
constructor(opts) {
|
|
14
|
+
super({ action: opts.action ?? 'deny', maxScanLength: opts.maxScanLength });
|
|
15
|
+
this.name = 'topic_restriction';
|
|
16
|
+
this.phases = [base_1.GuardPhase.PREFLIGHT];
|
|
17
|
+
if (typeof opts.classifier !== 'function') {
|
|
18
|
+
throw new base_1.GuardConfigError("TopicRestriction requires a callable 'classifier'");
|
|
19
|
+
}
|
|
20
|
+
if (opts.allowed && opts.denied) {
|
|
21
|
+
throw new base_1.GuardConfigError("Provide either 'allowed' or 'denied', not both");
|
|
22
|
+
}
|
|
23
|
+
if (!opts.allowed && !opts.denied) {
|
|
24
|
+
throw new base_1.GuardConfigError("Provide either 'allowed' or 'denied' topic list");
|
|
25
|
+
}
|
|
26
|
+
this._classifier = opts.classifier;
|
|
27
|
+
this._allowed = opts.allowed ? new Set(opts.allowed.map((t) => t.toLowerCase())) : null;
|
|
28
|
+
this._denied = opts.denied ? new Set(opts.denied.map((t) => t.toLowerCase())) : null;
|
|
29
|
+
}
|
|
30
|
+
evaluate(text) {
|
|
31
|
+
const topic = this._classifier(text).toLowerCase().trim();
|
|
32
|
+
if (this._allowed !== null && !this._allowed.has(topic)) {
|
|
33
|
+
return (0, base_1.makeGuardResult)({
|
|
34
|
+
action: this._action,
|
|
35
|
+
score: 1.0,
|
|
36
|
+
guardName: this.name,
|
|
37
|
+
classification: topic,
|
|
38
|
+
explanation: `Topic '${topic}' is not in the allowed list`,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (this._denied !== null && this._denied.has(topic)) {
|
|
42
|
+
return (0, base_1.makeGuardResult)({
|
|
43
|
+
action: this._action,
|
|
44
|
+
score: 1.0,
|
|
45
|
+
guardName: this.name,
|
|
46
|
+
classification: topic,
|
|
47
|
+
explanation: `Topic '${topic}' is in the denied list`,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return (0, base_1.makeGuardResult)({ guardName: this.name, classification: topic });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.TopicRestriction = TopicRestriction;
|
|
54
|
+
//# sourceMappingURL=topic-restriction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topic-restriction.js","sourceRoot":"","sources":["../../src/guard/topic-restriction.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,iCAAyG;AAQzG,MAAa,gBAAiB,SAAQ,YAAK;IAQzC,YAAY,IAA6B;QACvC,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,MAAM,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;QARrE,SAAI,GAAG,mBAAmB,CAAC;QAC3B,WAAM,GAAG,CAAC,iBAAU,CAAC,SAAS,CAAC,CAAC;QASvC,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;YAC1C,MAAM,IAAI,uBAAgB,CAAC,mDAAmD,CAAC,CAAC;QAClF,CAAC;QACD,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChC,MAAM,IAAI,uBAAgB,CAAC,gDAAgD,CAAC,CAAC;QAC/E,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YAClC,MAAM,IAAI,uBAAgB,CAAC,iDAAiD,CAAC,CAAC;QAChF,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACxF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC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entor (LangChain, LiteLLM, etc.)
|
|
4
|
+
* owns the current LLM span. Provider-level wrappers (OpenAI, Anthropic, …)
|
|
5
|
+
* must skip their own span creation when this returns true.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isFrameworkLlmActive(): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Run `fn` with the framework-LLM-active flag set. All provider wrappers
|
|
10
|
+
* invoked inside `fn` will see `isFrameworkLlmActive() === true`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function runWithFrameworkLlm<T>(fn: () => T): T;
|
|
13
|
+
/**
|
|
14
|
+
* Set framework-LLM-active flag in the current execution context.
|
|
15
|
+
* Used by SpanProcessor-based instrumentations (Strands) where
|
|
16
|
+
* the processor observes spans rather than controlling execution.
|
|
17
|
+
* Mirrors Python's ContextVar.set(True) in Strands processor.
|
|
18
|
+
*/
|
|
19
|
+
export declare function setFrameworkLlmActive(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Reset framework-LLM-active flag in the current execution context.
|
|
22
|
+
* Mirrors Python's ContextVar.reset(token) in Strands processor.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resetFrameworkLlmActive(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the user-supplied agent version label set via
|
|
27
|
+
* `Shield360.setAgentVersion()` / `runWithAgentVersion()`, if any.
|
|
28
|
+
*
|
|
29
|
+
* Provider wrappers stamp this on `gen_ai.agent.version` so the server-side
|
|
30
|
+
* materializer can group traces by the user's preferred label in addition to
|
|
31
|
+
* the auto-computed `shield360.agent.version_hash` fingerprint.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getCurrentAgentVersion(): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Set the agent version label for the current execution context.
|
|
36
|
+
*
|
|
37
|
+
* IMPORTANT: this uses `AsyncLocalStorage.enterWith` which permanently
|
|
38
|
+
* mutates the current async resource. Sequential requests handled on the
|
|
39
|
+
* same Node worker (or reused thread/connection) will inherit the label
|
|
40
|
+
* until something overwrites or clears it. **Always pair with a matching
|
|
41
|
+
* `resetAgentVersion()` in a `finally` block**, or prefer
|
|
42
|
+
* `runWithAgentVersion(label, fn)` which guarantees scoped cleanup.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* try {
|
|
46
|
+
* setAgentVersion('hotfix-2026-05-12');
|
|
47
|
+
* await runAgent();
|
|
48
|
+
* } finally {
|
|
49
|
+
* resetAgentVersion();
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // Preferred — automatic scope cleanup, no leak risk:
|
|
54
|
+
* await runWithAgentVersion('hotfix-2026-05-12', () => runAgent());
|
|
55
|
+
*/
|
|
56
|
+
export declare function setAgentVersion(version: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* Clear the agent version label set by `setAgentVersion()`. No-op if no
|
|
59
|
+
* label is active. See the `setAgentVersion` docstring for the leak
|
|
60
|
+
* scenario this guards against.
|
|
61
|
+
*/
|
|
62
|
+
export declare function resetAgentVersion(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Run `fn` with the given agent version label bound to the current async
|
|
65
|
+
* scope. Mirrors `shield360.agent_version_context()` in Python and is the
|
|
66
|
+
* recommended way to attach a label — the store is automatically restored
|
|
67
|
+
* when `fn` resolves so there is no risk of leaking the label across
|
|
68
|
+
* subsequent requests.
|
|
69
|
+
*/
|
|
70
|
+
export declare function runWithAgentVersion<T>(version: string, fn: () => T): T;
|
|
71
|
+
/**
|
|
72
|
+
* Returns true when a LangGraph wrapper is controlling execution.
|
|
73
|
+
* LangChain's callback handler skips its own invoke_workflow span when true.
|
|
74
|
+
*/
|
|
75
|
+
export declare function isLangGraphActive(): boolean;
|
|
76
|
+
export declare function runWithLangGraph<T>(fn: () => T): T;
|
|
77
|
+
/**
|
|
78
|
+
* Returns true when a create_agent span is already being handled
|
|
79
|
+
* (prevents duplicate spans between LangChain and LangGraph).
|
|
80
|
+
*/
|
|
81
|
+
export declare function isCreateAgentActive(): boolean;
|
|
82
|
+
export declare function runWithCreateAgent<T>(fn: () => T): T;
|
|
83
|
+
/**
|
|
84
|
+
* Propagate conversation ID from invoke_workflow to child node spans.
|
|
85
|
+
* Mirrors Python's set_langgraph_conversation_id / get_langgraph_conversation_id.
|
|
86
|
+
*/
|
|
87
|
+
export declare function getLangGraphConversationId(): string | undefined;
|
|
88
|
+
export declare function runWithLangGraphConversationId<T>(conversationId: string, fn: () => T): T;
|
|
89
|
+
/**
|
|
90
|
+
* Returns the OTel context set by a framework processor (OpenAI Agents, etc.)
|
|
91
|
+
* so that provider wrappers can create spans as children of framework spans.
|
|
92
|
+
* Mirrors Python's context_api.attach(set_span_in_context(span)).
|
|
93
|
+
*/
|
|
94
|
+
export declare function getFrameworkParentContext(): Context | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Set the OTel parent context for provider span creation.
|
|
97
|
+
* Called by processor-based frameworks that cannot use context.with().
|
|
98
|
+
*/
|
|
99
|
+
export declare function setFrameworkParentContext(ctx: Context): void;
|
|
100
|
+
/**
|
|
101
|
+
* Clear the framework parent context.
|
|
102
|
+
*/
|
|
103
|
+
export declare function clearFrameworkParentContext(): void;
|
|
104
|
+
export declare function getServerAddressForProvider(provider: string): [string, number];
|
|
105
|
+
/** LangChain/LangGraph message type → OTel GenAI role (mirrors Python LANGCHAIN_ROLE_MAPPING). */
|
|
106
|
+
export declare const LANGCHAIN_ROLE_MAP: Record<string, string>;
|
|
107
|
+
export declare const OTEL_ASSISTANT_ROLE: string;
|
|
108
|
+
/** Map a raw LangChain message type/role to the OTel GenAI convention value. */
|
|
109
|
+
export declare function mapLangChainRole(rawRole: string | undefined | null): string;
|
|
110
|
+
/**
|
|
111
|
+
* Apply global (from init) and context-scoped (from usingAttributes /
|
|
112
|
+
* injectAdditionalAttributes) custom attributes to a span.
|
|
113
|
+
* Global attributes are applied first; context attributes override on conflict.
|
|
114
|
+
* Matches Python's _apply_custom_span_attributes().
|
|
115
|
+
*/
|
|
116
|
+
export declare function applyCustomSpanAttributes(span: Span): void;
|
|
117
|
+
/**
|
|
118
|
+
* Get merged custom attributes (global + context) for use in events.
|
|
119
|
+
* Returns a flat object; context attributes override global on conflict.
|
|
120
|
+
*/
|
|
121
|
+
export declare function getMergedCustomAttributes(): Record<string, any>;
|
|
122
|
+
/**
|
|
123
|
+
* Run a function with custom span attributes attached to all
|
|
124
|
+
* auto-instrumented spans created during its execution.
|
|
125
|
+
* Matches Python's shield360.inject_additional_attributes().
|
|
126
|
+
*/
|
|
127
|
+
export declare function injectAdditionalAttributes<T>(fn: () => T, attributes: Record<string, any>): T;
|
|
128
|
+
/**
|
|
129
|
+
* Context wrapper that adds custom attributes to all auto-instrumented
|
|
130
|
+
* spans created within its callback scope.
|
|
131
|
+
* Matches Python's shield360.using_attributes() context manager.
|
|
132
|
+
*
|
|
133
|
+
* Usage:
|
|
134
|
+
* await usingAttributes({"user.id": "u1", "team": "ml"}, async () => {
|
|
135
|
+
* await client.chat.completions.create(...);
|
|
136
|
+
* });
|
|
137
|
+
*/
|
|
138
|
+
export declare function usingAttributes<T>(attributes: Record<string, any>, fn: () => T): T;
|
|
139
|
+
export default class Shield360Helper {
|
|
140
|
+
static readonly PROMPT_TOKEN_FACTOR = 1000;
|
|
141
|
+
static openaiTokens(text: string, model: string): number;
|
|
142
|
+
static generalTokens(text: string): number;
|
|
143
|
+
/**
|
|
144
|
+
* Compute chat completion cost, optionally accounting for prompt-cache tokens.
|
|
145
|
+
*
|
|
146
|
+
* When the model's pricing entry defines `cacheReadPrice` / `cacheCreationPrice`,
|
|
147
|
+
* the matching cache tokens are billed at those rates instead of the regular
|
|
148
|
+
* prompt price.
|
|
149
|
+
*
|
|
150
|
+
* Token accounting differs across providers:
|
|
151
|
+
* - Anthropic's native API reports `promptTokens` exclusive of cache tokens,
|
|
152
|
+
* so cache tokens are added on top (keep `promptTokensIncludeCache` false).
|
|
153
|
+
* - OpenAI / LangChain report `promptTokens` inclusive of cache read tokens,
|
|
154
|
+
* so pass `promptTokensIncludeCache: true` to subtract the re-priced cache
|
|
155
|
+
* tokens from the prompt base and avoid billing them twice.
|
|
156
|
+
*
|
|
157
|
+
* Cache tokens are only re-priced (and, when inclusive, only subtracted) when a
|
|
158
|
+
* dedicated cache price exists, so the result is identical to the legacy
|
|
159
|
+
* behaviour for any model without cache pricing configured.
|
|
160
|
+
*/
|
|
161
|
+
static getChatModelCost(model: string, pricingInfo: any, promptTokens: number, completionTokens: number, cacheReadTokens?: number, cacheCreationTokens?: number, promptTokensIncludeCache?: boolean): number;
|
|
162
|
+
static getEmbedModelCost(model: string, pricingInfo: any, promptTokens: number): number;
|
|
163
|
+
static getImageModelCost(model: string, pricingInfo: any, size: string, quality: number): number;
|
|
164
|
+
static getAudioModelCost(model: string, pricingInfo: any, prompt: string, duration?: number): number;
|
|
165
|
+
static fetchPricingInfo(pricingJson: any): Promise<any>;
|
|
166
|
+
/**
|
|
167
|
+
* Build OTel-spec input messages JSON string from provider messages array.
|
|
168
|
+
* Format: [{"role": "user", "parts": [{"type": "text", "content": "..."}]}]
|
|
169
|
+
*/
|
|
170
|
+
static buildInputMessages(messages: any[], system?: string): string;
|
|
171
|
+
/**
|
|
172
|
+
* Extract system message(s) from a chat-completions messages array.
|
|
173
|
+
* Returns an OTel ``gen_ai.system_instructions`` payload
|
|
174
|
+
* (``[{"type": "text", "content": "..."}]``) JSON-encoded as a string,
|
|
175
|
+
* or ``undefined`` when no system message is present.
|
|
176
|
+
*
|
|
177
|
+
* Mirrors Python's ``build_system_instructions_from_messages``.
|
|
178
|
+
*/
|
|
179
|
+
static buildSystemInstructionsFromMessages(messages: any[]): string | undefined;
|
|
180
|
+
/**
|
|
181
|
+
* Normalize a request ``tools`` array into the OTel
|
|
182
|
+
* ``gen_ai.tool.definitions`` schema and return it as a JSON string,
|
|
183
|
+
* or ``undefined`` when there is nothing usable.
|
|
184
|
+
*
|
|
185
|
+
* Accepts both the OpenAI-style schema
|
|
186
|
+
* (``{"type": "function", "function": {...}}``) and the flat schema
|
|
187
|
+
* (``{"name": ..., "description": ..., "parameters": ...}``), and
|
|
188
|
+
* Anthropic's ``input_schema`` synonym for ``parameters``.
|
|
189
|
+
*
|
|
190
|
+
* Mirrors Python's ``build_tool_definitions``.
|
|
191
|
+
*/
|
|
192
|
+
static buildToolDefinitions(tools: any): string | undefined;
|
|
193
|
+
/**
|
|
194
|
+
* Compute the canonical agent-version fingerprint.
|
|
195
|
+
*
|
|
196
|
+
* Mirrors `fingerprint()` in
|
|
197
|
+
* `src/client/src/lib/platform/agents/snapshot.ts` so that the SDK stamps
|
|
198
|
+
* `shield360.agent.version_hash` with the same value the server-side
|
|
199
|
+
* materializer derives from `otel_traces`. The hash covers the parts that
|
|
200
|
+
* meaningfully change agent behavior: system prompt, tool set (name +
|
|
201
|
+
* schema), primary model, and sampling config.
|
|
202
|
+
*
|
|
203
|
+
* Accepts the same shapes used by the SDK chat finalizers:
|
|
204
|
+
* - `systemInstructions`: the JSON string emitted on
|
|
205
|
+
* `gen_ai.system_instructions`, the original list of `{type,content}`
|
|
206
|
+
* parts, or a plain string.
|
|
207
|
+
* - `toolDefinitions`: the JSON string emitted on
|
|
208
|
+
* `gen_ai.tool.definitions`, or the original list of
|
|
209
|
+
* `{type, name, description, parameters}` items.
|
|
210
|
+
*/
|
|
211
|
+
static computeAgentVersionHash(args: {
|
|
212
|
+
systemInstructions?: string | unknown[] | null;
|
|
213
|
+
toolDefinitions?: string | unknown[] | null;
|
|
214
|
+
primaryModel?: string | null;
|
|
215
|
+
runtimeConfig?: {
|
|
216
|
+
temperature?: number | null;
|
|
217
|
+
top_p?: number | null;
|
|
218
|
+
max_tokens?: number | null;
|
|
219
|
+
provider?: string | null;
|
|
220
|
+
} | null;
|
|
221
|
+
providers?: string[] | null;
|
|
222
|
+
}): string;
|
|
223
|
+
private static readonly _VERSION_HASH_CACHE_MAX;
|
|
224
|
+
private static _versionHashCache;
|
|
225
|
+
/**
|
|
226
|
+
* Build a stable, cheap cache key for the version-hash memoization. Uses
|
|
227
|
+
* `JSON.stringify` of inputs (orders-of-magnitude cheaper than the full
|
|
228
|
+
* canonical pass we want to skip on a cache hit). Returns `null` if
|
|
229
|
+
* inputs can't be stringified (circular refs etc.) — the caller falls
|
|
230
|
+
* back to uncached computation.
|
|
231
|
+
*/
|
|
232
|
+
private static _buildAgentVersionCacheKey;
|
|
233
|
+
/**
|
|
234
|
+
* Build OTel-spec output messages JSON string from provider response.
|
|
235
|
+
* Format: [{"role": "assistant", "parts": [{"type": "text", "content": "..."}], "finish_reason": "stop"}]
|
|
236
|
+
*/
|
|
237
|
+
static buildOutputMessages(text: string, finishReason: string, toolCalls?: any[]): string;
|
|
238
|
+
/**
|
|
239
|
+
* Emit an inference event via the LoggerProvider, matching Python SDK's
|
|
240
|
+
* gen_ai.client.inference.operation.details event.
|
|
241
|
+
* Falls back to span.addEvent if LoggerProvider is not available.
|
|
242
|
+
*/
|
|
243
|
+
static emitInferenceEvent(span: Span, attrs: Attributes): void;
|
|
244
|
+
static handleException(span: Span, error: Error): void;
|
|
245
|
+
static createStreamProxy(stream: any, generatorFuncResponse: any): Promise<any>;
|
|
246
|
+
}
|