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,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Guard = exports.GuardConfigError = exports.GuardTimeoutError = exports.GuardDeniedError = exports.GuardError = exports.PipelineResult = exports.ACTION_SEVERITY = exports.GuardAction = exports.GuardPhase = void 0;
|
|
4
|
+
exports.makeGuardResult = makeGuardResult;
|
|
5
|
+
/**
|
|
6
|
+
* Core types, base class, and errors for the Shield360 guard system.
|
|
7
|
+
*
|
|
8
|
+
* Must stay in sync with: sdk/python/src/shield360/guard/_base.py
|
|
9
|
+
*/
|
|
10
|
+
var GuardPhase;
|
|
11
|
+
(function (GuardPhase) {
|
|
12
|
+
GuardPhase["PREFLIGHT"] = "preflight";
|
|
13
|
+
GuardPhase["POSTFLIGHT"] = "postflight";
|
|
14
|
+
})(GuardPhase || (exports.GuardPhase = GuardPhase = {}));
|
|
15
|
+
var GuardAction;
|
|
16
|
+
(function (GuardAction) {
|
|
17
|
+
GuardAction["ALLOW"] = "allow";
|
|
18
|
+
GuardAction["DENY"] = "deny";
|
|
19
|
+
GuardAction["REDACT"] = "redact";
|
|
20
|
+
GuardAction["WARN"] = "warn";
|
|
21
|
+
})(GuardAction || (exports.GuardAction = GuardAction = {}));
|
|
22
|
+
exports.ACTION_SEVERITY = {
|
|
23
|
+
[GuardAction.ALLOW]: 0,
|
|
24
|
+
[GuardAction.WARN]: 1,
|
|
25
|
+
[GuardAction.REDACT]: 2,
|
|
26
|
+
[GuardAction.DENY]: 3,
|
|
27
|
+
};
|
|
28
|
+
function makeGuardResult(overrides = {}) {
|
|
29
|
+
return {
|
|
30
|
+
action: GuardAction.ALLOW,
|
|
31
|
+
score: 0,
|
|
32
|
+
guardName: '',
|
|
33
|
+
classification: '',
|
|
34
|
+
explanation: '',
|
|
35
|
+
transformedText: null,
|
|
36
|
+
latencyMs: 0,
|
|
37
|
+
...overrides,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
class PipelineResult {
|
|
41
|
+
constructor(action = GuardAction.ALLOW, results = [], transformedText = null) {
|
|
42
|
+
this.action = action;
|
|
43
|
+
this.results = results;
|
|
44
|
+
this.transformedText = transformedText;
|
|
45
|
+
}
|
|
46
|
+
get explanation() {
|
|
47
|
+
return this.results
|
|
48
|
+
.map((r) => r.explanation)
|
|
49
|
+
.filter(Boolean)
|
|
50
|
+
.join('; ');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.PipelineResult = PipelineResult;
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
// Errors
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
class GuardError extends Error {
|
|
58
|
+
constructor(message) {
|
|
59
|
+
super(message);
|
|
60
|
+
this.name = 'GuardError';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.GuardError = GuardError;
|
|
64
|
+
class GuardDeniedError extends GuardError {
|
|
65
|
+
constructor(result) {
|
|
66
|
+
super(result.explanation);
|
|
67
|
+
this.name = 'GuardDeniedError';
|
|
68
|
+
this.result = result;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.GuardDeniedError = GuardDeniedError;
|
|
72
|
+
/**
|
|
73
|
+
* Reserved for future use -- a per-guard `timeoutMs` option may be
|
|
74
|
+
* added to Pipeline in a later release.
|
|
75
|
+
*/
|
|
76
|
+
class GuardTimeoutError extends GuardError {
|
|
77
|
+
constructor(message) {
|
|
78
|
+
super(message);
|
|
79
|
+
this.name = 'GuardTimeoutError';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.GuardTimeoutError = GuardTimeoutError;
|
|
83
|
+
class GuardConfigError extends GuardError {
|
|
84
|
+
constructor(message) {
|
|
85
|
+
super(message);
|
|
86
|
+
this.name = 'GuardConfigError';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.GuardConfigError = GuardConfigError;
|
|
90
|
+
class Guard {
|
|
91
|
+
/**
|
|
92
|
+
* @param opts.action - Action to take on violation (`allow`, `deny`, `redact`, `warn`). Default: `deny`.
|
|
93
|
+
* @param opts.maxScanLength - Max characters to scan. Text beyond this limit is not evaluated. Default: 102400.
|
|
94
|
+
*/
|
|
95
|
+
constructor(opts = {}) {
|
|
96
|
+
const actionStr = opts.action ?? 'deny';
|
|
97
|
+
const validActions = Object.values(GuardAction);
|
|
98
|
+
if (!validActions.includes(actionStr)) {
|
|
99
|
+
throw new GuardConfigError(`Invalid action '${actionStr}'. Must be one of: ${validActions.join(', ')}`);
|
|
100
|
+
}
|
|
101
|
+
this._action = actionStr;
|
|
102
|
+
const maxScan = opts.maxScanLength ?? 102400;
|
|
103
|
+
if (typeof maxScan !== 'number' || maxScan < 0) {
|
|
104
|
+
throw new GuardConfigError(`Invalid maxScanLength '${maxScan}'. Must be a non-negative number.`);
|
|
105
|
+
}
|
|
106
|
+
this._maxScanLength = maxScan;
|
|
107
|
+
}
|
|
108
|
+
get action() {
|
|
109
|
+
return this._action;
|
|
110
|
+
}
|
|
111
|
+
supportsPhase(phase) {
|
|
112
|
+
return this.phases.includes(phase);
|
|
113
|
+
}
|
|
114
|
+
/** Execute the guard with timing, text-length capping, and phase filtering. */
|
|
115
|
+
run(text, phase) {
|
|
116
|
+
if (!this.supportsPhase(phase)) {
|
|
117
|
+
return makeGuardResult({ guardName: this.name });
|
|
118
|
+
}
|
|
119
|
+
const capped = this._maxScanLength ? text.slice(0, this._maxScanLength) : text;
|
|
120
|
+
const start = performance.now();
|
|
121
|
+
const result = this.evaluate(capped);
|
|
122
|
+
const elapsedMs = performance.now() - start;
|
|
123
|
+
return makeGuardResult({
|
|
124
|
+
action: result.action,
|
|
125
|
+
score: result.score,
|
|
126
|
+
guardName: this.name,
|
|
127
|
+
classification: result.classification,
|
|
128
|
+
explanation: result.explanation,
|
|
129
|
+
transformedText: result.transformedText,
|
|
130
|
+
latencyMs: Math.round(elapsedMs * 1000) / 1000,
|
|
131
|
+
findings: result.findings,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.Guard = Guard;
|
|
136
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/guard/base.ts"],"names":[],"mappings":";;;AAuCA,0CAWC;AAhDD;;;;GAIG;AAEH,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,qCAAuB,CAAA;IACvB,uCAAyB,CAAA;AAC3B,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB;AAED,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,4BAAa,CAAA;IACb,gCAAiB,CAAA;IACjB,4BAAa,CAAA;AACf,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAEY,QAAA,eAAe,GAAgC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O,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,+EAA+E;IAC/E,GAAG,CAAC,IAAY,EAAE,KAAiB;QACjC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,eAAe,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE/E,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QAE5C,OAAO,eAAe,CAAC;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,SAAS,EAAE,IAAI,CAAC,IAAI;YACpB,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,IAAI;YAC9C,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC,CAAC;IACL,CAAC;CASF;AArED,sBAqEC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom guard -- user-defined regex or callable.
|
|
3
|
+
*
|
|
4
|
+
* Must stay in sync with: sdk/python/src/shield360/guard/custom.py
|
|
5
|
+
*/
|
|
6
|
+
import { Guard, GuardPhase, GuardResult, GuardOptions } from './base';
|
|
7
|
+
export interface CustomOptions extends GuardOptions {
|
|
8
|
+
pattern?: string;
|
|
9
|
+
callable?: (text: string) => GuardResult;
|
|
10
|
+
phases?: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare class Custom extends Guard {
|
|
13
|
+
readonly name = "custom";
|
|
14
|
+
readonly phases: GuardPhase[];
|
|
15
|
+
private readonly _pattern;
|
|
16
|
+
private readonly _callable?;
|
|
17
|
+
constructor(opts?: CustomOptions);
|
|
18
|
+
evaluate(text: string): GuardResult;
|
|
19
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Custom guard -- user-defined regex or callable.
|
|
4
|
+
*
|
|
5
|
+
* Must stay in sync with: sdk/python/src/shield360/guard/custom.py
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.Custom = void 0;
|
|
9
|
+
const base_1 = require("./base");
|
|
10
|
+
class Custom extends base_1.Guard {
|
|
11
|
+
constructor(opts = {}) {
|
|
12
|
+
super({ action: opts.action ?? 'deny', maxScanLength: opts.maxScanLength });
|
|
13
|
+
this.name = 'custom';
|
|
14
|
+
if (!opts.pattern && !opts.callable) {
|
|
15
|
+
throw new base_1.GuardConfigError("Custom guard needs at least 'pattern' or 'callable'");
|
|
16
|
+
}
|
|
17
|
+
this._pattern = opts.pattern ? new RegExp(opts.pattern) : null;
|
|
18
|
+
this._callable = opts.callable;
|
|
19
|
+
if (opts.phases) {
|
|
20
|
+
this.phases = opts.phases.map((p) => p);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
this.phases = [base_1.GuardPhase.PREFLIGHT, base_1.GuardPhase.POSTFLIGHT];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
evaluate(text) {
|
|
27
|
+
if (this._pattern) {
|
|
28
|
+
const match = this._pattern.exec(text);
|
|
29
|
+
if (match) {
|
|
30
|
+
return (0, base_1.makeGuardResult)({
|
|
31
|
+
action: this._action,
|
|
32
|
+
score: 1.0,
|
|
33
|
+
guardName: this.name,
|
|
34
|
+
classification: 'pattern_match',
|
|
35
|
+
explanation: `Custom pattern matched: '${match[0]}'`,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (this._callable) {
|
|
40
|
+
return this._callable(text);
|
|
41
|
+
}
|
|
42
|
+
return (0, base_1.makeGuardResult)({ guardName: this.name });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.Custom = Custom;
|
|
46
|
+
//# sourceMappingURL=custom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom.js","sourceRoot":"","sources":["../../src/guard/custom.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,iCAOgB;AAQhB,MAAa,MAAO,SAAQ,YAAK;IAO/B,YAAY,OAAsB,EAAE;QAClC,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,MAAM,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;QAPrE,SAAI,GAAG,QAAQ,CAAC;QASvB,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpC,MAAM,IAAI,uBAAgB,CAAC,qDAAqD,CAAC,CAAC;QACpF,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC/D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC;QAE/B,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAe,CAAC,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,GAAG,CAAC,iBAAU,CAAC,SAAS,EAAE,iBAAU,CAAC,UAAU,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvC,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,IAAA,sBAAe,EAAC;oBACrB,MAAM,EAAE,IAAI,CAAC,OAAO;oBACpB,KAAK,EAAE,GAAG;oBACV,SAAS,EAAE,IAAI,CAAC,IAAI;oBACpB,cAAc,EAAE,eAAe;oBAC/B,WAAW,EAAE,4BAA4B,KAAK,CAAC,CAAC,CAAC,GAAG;iBACrD,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;QAED,OAAO,IAAA,sBAAe,EAAC,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;CACF;AA5CD,wBA4CC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a reviewer may see of a sensitive value a guard found: its kind, a
|
|
3
|
+
* masked form (the last four digits of an SSN, the prefix of an API key) and a
|
|
4
|
+
* fingerprint that is the same every time the same value turns up, in this app
|
|
5
|
+
* or anywhere else in the organisation. The value itself is never kept or
|
|
6
|
+
* reported.
|
|
7
|
+
*
|
|
8
|
+
* The fingerprint is an HMAC keyed with the organisation's secret, which
|
|
9
|
+
* Shield360 hands to apps with an API key. Unkeyed it could be reversed (there
|
|
10
|
+
* are only a billion SSNs), so without a key none is made.
|
|
11
|
+
*
|
|
12
|
+
* Must stay in sync with: sdk/python/src/shield360/guard/_findings.py and
|
|
13
|
+
* cli/internal/coding/guard/findings.go
|
|
14
|
+
*/
|
|
15
|
+
export interface Finding {
|
|
16
|
+
kind: string;
|
|
17
|
+
masked: string;
|
|
18
|
+
fingerprint?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const MAX_FINDINGS = 10;
|
|
21
|
+
/** Sets (or clears) the organisation's fingerprint key. */
|
|
22
|
+
export declare function setFingerprintKey(value: string | null): void;
|
|
23
|
+
export declare const canonicalKind: (label: string) => string;
|
|
24
|
+
export declare function fingerprint(label: string, value: string): string;
|
|
25
|
+
/** Enough of a value to recognise it, never enough to use it. */
|
|
26
|
+
export declare function mask(label: string, value: string): string;
|
|
27
|
+
export declare function makeFinding(label: string, value: string): Finding;
|
|
28
|
+
/** Fingerprints a finding made before the key arrived, now that it has. */
|
|
29
|
+
export declare function completeFinding(f: Finding): Finding;
|
|
30
|
+
/** Findings for `[label, value]` pairs, de-duplicated and capped. */
|
|
31
|
+
export declare function collectFindings(matches: Array<[string, string]>): Finding[];
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* What a reviewer may see of a sensitive value a guard found: its kind, a
|
|
4
|
+
* masked form (the last four digits of an SSN, the prefix of an API key) and a
|
|
5
|
+
* fingerprint that is the same every time the same value turns up, in this app
|
|
6
|
+
* or anywhere else in the organisation. The value itself is never kept or
|
|
7
|
+
* reported.
|
|
8
|
+
*
|
|
9
|
+
* The fingerprint is an HMAC keyed with the organisation's secret, which
|
|
10
|
+
* Shield360 hands to apps with an API key. Unkeyed it could be reversed (there
|
|
11
|
+
* are only a billion SSNs), so without a key none is made.
|
|
12
|
+
*
|
|
13
|
+
* Must stay in sync with: sdk/python/src/shield360/guard/_findings.py and
|
|
14
|
+
* cli/internal/coding/guard/findings.go
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.canonicalKind = exports.MAX_FINDINGS = void 0;
|
|
18
|
+
exports.setFingerprintKey = setFingerprintKey;
|
|
19
|
+
exports.fingerprint = fingerprint;
|
|
20
|
+
exports.mask = mask;
|
|
21
|
+
exports.makeFinding = makeFinding;
|
|
22
|
+
exports.completeFinding = completeFinding;
|
|
23
|
+
exports.collectFindings = collectFindings;
|
|
24
|
+
const crypto_1 = require("crypto");
|
|
25
|
+
exports.MAX_FINDINGS = 10;
|
|
26
|
+
let key = null;
|
|
27
|
+
// Values of findings made before the key arrived, kept in this process only —
|
|
28
|
+
// never serialised, gone with the finding — so they can be fingerprinted when
|
|
29
|
+
// reported. The app already holds the text they came from.
|
|
30
|
+
const awaitingKey = new WeakMap();
|
|
31
|
+
/** Sets (or clears) the organisation's fingerprint key. */
|
|
32
|
+
function setFingerprintKey(value) {
|
|
33
|
+
key = value || null;
|
|
34
|
+
}
|
|
35
|
+
// The CLI's kind for each SDK label, so the same value fingerprints the same
|
|
36
|
+
// whether a coding agent or an app stopped it.
|
|
37
|
+
const CANONICAL = {
|
|
38
|
+
'credit-card': 'payment_card',
|
|
39
|
+
'env-secret': 'password',
|
|
40
|
+
'private-key': 'private_key',
|
|
41
|
+
'connection-string': 'connection_string',
|
|
42
|
+
'aws-access-key': 'cloud_credential',
|
|
43
|
+
'openai-api-key': 'api_key',
|
|
44
|
+
'anthropic-api-key': 'api_key',
|
|
45
|
+
'github-token': 'api_key',
|
|
46
|
+
'github-fine-grained': 'api_key',
|
|
47
|
+
'stripe-key': 'api_key',
|
|
48
|
+
'slack-token': 'api_key',
|
|
49
|
+
'gcp-api-key': 'api_key',
|
|
50
|
+
};
|
|
51
|
+
const canonicalKind = (label) => CANONICAL[label] ?? label;
|
|
52
|
+
exports.canonicalKind = canonicalKind;
|
|
53
|
+
const digits = (v) => v.replace(/\D/g, '');
|
|
54
|
+
function assignmentValue(v) {
|
|
55
|
+
const i = v.search(/[:=]/);
|
|
56
|
+
return i < 0 ? v : v.slice(i + 1).replace(/^[\s"']+|[\s"']+$/g, '');
|
|
57
|
+
}
|
|
58
|
+
function normalise(kind, value) {
|
|
59
|
+
if (kind === 'ssn' || kind === 'payment_card' || kind === 'phone-us')
|
|
60
|
+
return digits(value);
|
|
61
|
+
if (kind === 'password')
|
|
62
|
+
return assignmentValue(value);
|
|
63
|
+
return value.trim();
|
|
64
|
+
}
|
|
65
|
+
function fingerprint(label, value) {
|
|
66
|
+
if (!key)
|
|
67
|
+
return '';
|
|
68
|
+
const kind = (0, exports.canonicalKind)(label);
|
|
69
|
+
return (0, crypto_1.createHmac)('sha256', key).update(`${kind}:${normalise(kind, value)}`).digest('hex').slice(0, 16);
|
|
70
|
+
}
|
|
71
|
+
/** Enough of a value to recognise it, never enough to use it. */
|
|
72
|
+
function mask(label, value) {
|
|
73
|
+
const v = value.trim();
|
|
74
|
+
const kind = (0, exports.canonicalKind)(label);
|
|
75
|
+
switch (kind) {
|
|
76
|
+
case 'ssn':
|
|
77
|
+
return '***-**-' + digits(v).slice(-4);
|
|
78
|
+
case 'payment_card':
|
|
79
|
+
return '•••• ' + digits(v).slice(-4);
|
|
80
|
+
case 'phone-us':
|
|
81
|
+
return '***-***-' + digits(v).slice(-4);
|
|
82
|
+
case 'private_key':
|
|
83
|
+
return v;
|
|
84
|
+
case 'email': {
|
|
85
|
+
const at = v.indexOf('@');
|
|
86
|
+
return at > 0 ? v[0] + '***' + v.slice(at) : '***';
|
|
87
|
+
}
|
|
88
|
+
case 'ipv4': {
|
|
89
|
+
const parts = v.split('.');
|
|
90
|
+
return parts.length === 4 ? `${parts[0]}.${parts[1]}.x.x` : 'x.x.x.x';
|
|
91
|
+
}
|
|
92
|
+
case 'connection_string': {
|
|
93
|
+
const m = /^([a-z+]+:\/\/[^:/@\s]+:)[^@\s]*(@.*)?$/i.exec(v);
|
|
94
|
+
if (m)
|
|
95
|
+
return m[1] + '****@' + (m[2] || '@').slice(1).split('/')[0];
|
|
96
|
+
return v.split('://')[0] + '://****';
|
|
97
|
+
}
|
|
98
|
+
case 'password': {
|
|
99
|
+
const i = v.search(/[:=]/);
|
|
100
|
+
const name = i > 0 ? v.slice(0, i).replace(/^[\s"']+|[\s"']+$/g, '') : '';
|
|
101
|
+
return name ? `${name} = ••••••••` : '••••••••';
|
|
102
|
+
}
|
|
103
|
+
case 'bearer-token':
|
|
104
|
+
case 'basic-auth':
|
|
105
|
+
return `${v.split(/\s+/)[0] || ''} …${v.slice(-4)}`;
|
|
106
|
+
default: {
|
|
107
|
+
// Keys and tokens: the public prefix names the service, the last four
|
|
108
|
+
// tell two keys apart.
|
|
109
|
+
let prefix = v.slice(0, 12);
|
|
110
|
+
const cut = Math.max(prefix.lastIndexOf('-'), prefix.lastIndexOf('_'));
|
|
111
|
+
prefix = cut >= 2 ? prefix.slice(0, cut + 1) : prefix.slice(0, 4);
|
|
112
|
+
if (v.length <= prefix.length + 4)
|
|
113
|
+
return prefix + '…';
|
|
114
|
+
return prefix + '…' + v.slice(-4);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function makeFinding(label, value) {
|
|
119
|
+
const f = { kind: label, masked: mask(label, value) };
|
|
120
|
+
const fp = fingerprint(label, value);
|
|
121
|
+
if (fp)
|
|
122
|
+
f.fingerprint = fp;
|
|
123
|
+
else
|
|
124
|
+
awaitingKey.set(f, { label, value });
|
|
125
|
+
return f;
|
|
126
|
+
}
|
|
127
|
+
/** Fingerprints a finding made before the key arrived, now that it has. */
|
|
128
|
+
function completeFinding(f) {
|
|
129
|
+
if (f.fingerprint)
|
|
130
|
+
return f;
|
|
131
|
+
const pending = awaitingKey.get(f);
|
|
132
|
+
if (!pending)
|
|
133
|
+
return f;
|
|
134
|
+
const fp = fingerprint(pending.label, pending.value);
|
|
135
|
+
if (!fp)
|
|
136
|
+
return f;
|
|
137
|
+
awaitingKey.delete(f);
|
|
138
|
+
return { ...f, fingerprint: fp };
|
|
139
|
+
}
|
|
140
|
+
/** Findings for `[label, value]` pairs, de-duplicated and capped. */
|
|
141
|
+
function collectFindings(matches) {
|
|
142
|
+
const out = [];
|
|
143
|
+
const seen = new Set();
|
|
144
|
+
for (const [label, value] of matches) {
|
|
145
|
+
const f = makeFinding(label, value);
|
|
146
|
+
const id = `${f.kind}|${f.fingerprint ?? ''}|${f.masked}`;
|
|
147
|
+
if (seen.has(id))
|
|
148
|
+
continue;
|
|
149
|
+
seen.add(id);
|
|
150
|
+
out.push(f);
|
|
151
|
+
if (out.length >= exports.MAX_FINDINGS)
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
return out;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=findings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findings.js","sourceRoot":"","sources":["../../src/guard/findings.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAoBH,8CAEC;AAkCD,kCAIC;AAGD,oBA2CC;AAED,kCAMC;AAGD,0CAQC;AAGD,0CAYC;AA1ID,mCAAoC;AAQvB,QAAA,YAAY,GAAG,EAAE,CAAC;AAE/B,IAAI,GAAG,GAAkB,IAAI,CAAC;AAE9B,8EAA8E;AAC9E,8EAA8E;AAC9E,2DAA2D;AAC3D,MAAM,WAAW,GAAG,IAAI,OAAO,EAA6C,CAAC;AAE7E,2DAA2D;AAC3D,SAAgB,iBAAiB,CAAC,KAAoB;IACpD,GAAG,GAAG,KAAK,IAAI,IAAI,CAAC;AACtB,CAAC;AAED,6EAA6E;AAC7E,+CAA+C;AAC/C,MAAM,SAAS,GAA2B;IACxC,aAAa,EAAE,cAAc;IAC7B,YAAY,EAAE,UAAU;IACxB,aAAa,EAAE,aAAa;IAC5B,mBAAmB,EAAE,mBAAmB;IACxC,gBAAgB,EAAE,kBAAkB;IACpC,gBAAgB,EAAE,SAAS;IAC3B,mBAAmB,EAAE,SAAS;IAC9B,cAAc,EAAE,SAAS;IACzB,qBAAqB,EAAE,SAAS;IAChC,YAAY,EAAE,SAAS;IACvB,aAAa,EAAE,SAAS;IACxB,aAAa,EAAE,SAAS;CACzB,CAAC;AAEK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MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,OAAO,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACpC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,WAAW,IAAI,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1D,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,SAAS;QAC3B,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACb,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACZ,IAAI,GAAG,CAAC,MAAM,IAAI,oBAAY;YAAE,MAAM;IACxC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shield360 Guard System -- public API.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all guard classes, pipeline, types, and errors.
|
|
5
|
+
*/
|
|
6
|
+
export { Guard, GuardAction, GuardPhase, GuardConfigError, GuardDeniedError, GuardError, GuardTimeoutError, PipelineResult, ACTION_SEVERITY, makeGuardResult, } from './base';
|
|
7
|
+
export type { GuardResult, GuardOptions } from './base';
|
|
8
|
+
export { Pipeline } from './pipeline';
|
|
9
|
+
export type { PipelineOptions } from './pipeline';
|
|
10
|
+
export { PII } from './pii';
|
|
11
|
+
export type { PIIOptions } from './pii';
|
|
12
|
+
export { PromptInjection } from './prompt-injection';
|
|
13
|
+
export type { PromptInjectionOptions } from './prompt-injection';
|
|
14
|
+
export { Moderation } from './moderation';
|
|
15
|
+
export type { ModerationOptions } from './moderation';
|
|
16
|
+
export { SensitiveTopic } from './sensitive-topic';
|
|
17
|
+
export type { SensitiveTopicOptions } from './sensitive-topic';
|
|
18
|
+
export { TopicRestriction } from './topic-restriction';
|
|
19
|
+
export type { TopicRestrictionOptions } from './topic-restriction';
|
|
20
|
+
export { Schema } from './schema';
|
|
21
|
+
export type { SchemaOptions } from './schema';
|
|
22
|
+
export { Custom } from './custom';
|
|
23
|
+
export type { CustomOptions } from './custom';
|
|
24
|
+
export { setupAutoGuards } from './integration';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shield360 Guard System -- public API.
|
|
4
|
+
*
|
|
5
|
+
* Re-exports all guard classes, pipeline, types, and errors.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.setupAutoGuards = exports.Custom = exports.Schema = exports.TopicRestriction = exports.SensitiveTopic = exports.Moderation = exports.PromptInjection = exports.PII = exports.Pipeline = exports.makeGuardResult = exports.ACTION_SEVERITY = exports.PipelineResult = exports.GuardTimeoutError = exports.GuardError = exports.GuardDeniedError = exports.GuardConfigError = exports.GuardPhase = exports.GuardAction = exports.Guard = void 0;
|
|
9
|
+
// Foundation types and base class
|
|
10
|
+
var base_1 = require("./base");
|
|
11
|
+
Object.defineProperty(exports, "Guard", { enumerable: true, get: function () { return base_1.Guard; } });
|
|
12
|
+
Object.defineProperty(exports, "GuardAction", { enumerable: true, get: function () { return base_1.GuardAction; } });
|
|
13
|
+
Object.defineProperty(exports, "GuardPhase", { enumerable: true, get: function () { return base_1.GuardPhase; } });
|
|
14
|
+
Object.defineProperty(exports, "GuardConfigError", { enumerable: true, get: function () { return base_1.GuardConfigError; } });
|
|
15
|
+
Object.defineProperty(exports, "GuardDeniedError", { enumerable: true, get: function () { return base_1.GuardDeniedError; } });
|
|
16
|
+
Object.defineProperty(exports, "GuardError", { enumerable: true, get: function () { return base_1.GuardError; } });
|
|
17
|
+
Object.defineProperty(exports, "GuardTimeoutError", { enumerable: true, get: function () { return base_1.GuardTimeoutError; } });
|
|
18
|
+
Object.defineProperty(exports, "PipelineResult", { enumerable: true, get: function () { return base_1.PipelineResult; } });
|
|
19
|
+
Object.defineProperty(exports, "ACTION_SEVERITY", { enumerable: true, get: function () { return base_1.ACTION_SEVERITY; } });
|
|
20
|
+
Object.defineProperty(exports, "makeGuardResult", { enumerable: true, get: function () { return base_1.makeGuardResult; } });
|
|
21
|
+
// Pipeline
|
|
22
|
+
var pipeline_1 = require("./pipeline");
|
|
23
|
+
Object.defineProperty(exports, "Pipeline", { enumerable: true, get: function () { return pipeline_1.Pipeline; } });
|
|
24
|
+
// Guards
|
|
25
|
+
var pii_1 = require("./pii");
|
|
26
|
+
Object.defineProperty(exports, "PII", { enumerable: true, get: function () { return pii_1.PII; } });
|
|
27
|
+
var prompt_injection_1 = require("./prompt-injection");
|
|
28
|
+
Object.defineProperty(exports, "PromptInjection", { enumerable: true, get: function () { return prompt_injection_1.PromptInjection; } });
|
|
29
|
+
var moderation_1 = require("./moderation");
|
|
30
|
+
Object.defineProperty(exports, "Moderation", { enumerable: true, get: function () { return moderation_1.Moderation; } });
|
|
31
|
+
var sensitive_topic_1 = require("./sensitive-topic");
|
|
32
|
+
Object.defineProperty(exports, "SensitiveTopic", { enumerable: true, get: function () { return sensitive_topic_1.SensitiveTopic; } });
|
|
33
|
+
var topic_restriction_1 = require("./topic-restriction");
|
|
34
|
+
Object.defineProperty(exports, "TopicRestriction", { enumerable: true, get: function () { return topic_restriction_1.TopicRestriction; } });
|
|
35
|
+
var schema_1 = require("./schema");
|
|
36
|
+
Object.defineProperty(exports, "Schema", { enumerable: true, get: function () { return schema_1.Schema; } });
|
|
37
|
+
var custom_1 = require("./custom");
|
|
38
|
+
Object.defineProperty(exports, "Custom", { enumerable: true, get: function () { return custom_1.Custom; } });
|
|
39
|
+
// Integration
|
|
40
|
+
var integration_1 = require("./integration");
|
|
41
|
+
Object.defineProperty(exports, "setupAutoGuards", { enumerable: true, get: function () { return integration_1.setupAutoGuards; } });
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/guard/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,kCAAkC;AAClC,+BAWgB;AAVd,6FAAA,KAAK,OAAA;AACL,mGAAA,WAAW,OAAA;AACX,kGAAA,UAAU,OAAA;AACV,wGAAA,gBAAgB,OAAA;AAChB,wGAAA,gBAAgB,OAAA;AAChB,kGAAA,UAAU,OAAA;AACV,yGAAA,iBAAiB,OAAA;AACjB,sGAAA,cAAc,OAAA;AACd,uGAAA,eAAe,OAAA;AACf,uGAAA,eAAe,OAAA;AAIjB,WAAW;AACX,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AAGjB,SAAS;AACT,6BAA4B;AAAnB,0FAAA,GAAG,OAAA;AAEZ,uDAAqD;AAA5C,mHAAA,eAAe,OAAA;AAExB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AAEnB,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AAEvB,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AAEzB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAEf,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAGf,cAAc;AACd,6CAAgD;AAAvC,8GAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-guard integration layer.
|
|
3
|
+
*
|
|
4
|
+
* setupAutoGuards wraps LLM provider methods so that guards run on every
|
|
5
|
+
* call without any changes to existing instrumentation code.
|
|
6
|
+
*
|
|
7
|
+
* Call chain after setup:
|
|
8
|
+
*
|
|
9
|
+
* User call
|
|
10
|
+
* -> Guard wrapper (preflight -> may deny/redact)
|
|
11
|
+
* -> Instrumentor wrapper (OTel telemetry)
|
|
12
|
+
* -> Original SDK method (actual API call)
|
|
13
|
+
* <- Instrumentor wrapper
|
|
14
|
+
* <- Guard wrapper (postflight -> may redact/warn)
|
|
15
|
+
* <- Returns to user
|
|
16
|
+
*
|
|
17
|
+
* **Streaming limitation**: postflight guards require a complete response
|
|
18
|
+
* object with `choices[].message.content` (or equivalent). Streaming
|
|
19
|
+
* responses yield incremental chunks that extractors cannot fully
|
|
20
|
+
* reassemble, so postflight guards are silently skipped for streamed
|
|
21
|
+
* completions. Preflight guards always run.
|
|
22
|
+
*
|
|
23
|
+
* Must stay in sync with: sdk/python/src/shield360/guard/_integration.py
|
|
24
|
+
*/
|
|
25
|
+
import { Guard } from './base';
|
|
26
|
+
import { Pipeline } from './pipeline';
|
|
27
|
+
type Extractor = (arg: any) => string;
|
|
28
|
+
export declare function extractOpenAIInput(kwargs: Record<string, any>): string;
|
|
29
|
+
export declare function extractOpenAIOutput(response: any): string;
|
|
30
|
+
export declare function extractAnthropicInput(kwargs: Record<string, any>): string;
|
|
31
|
+
export declare function extractAnthropicOutput(response: any): string;
|
|
32
|
+
export declare function extractGenericInput(kwargs: Record<string, any>): string;
|
|
33
|
+
export declare function extractGenericOutput(response: any): string;
|
|
34
|
+
/** @internal exported for tests */
|
|
35
|
+
export declare function applyPreflight(pipeline: Pipeline, kwargs: Record<string, any>, extractInput: Extractor): Record<string, any>;
|
|
36
|
+
/**
|
|
37
|
+
* Each choice and text block is redacted on its own, so none is left holding
|
|
38
|
+
* the original text or another block's.
|
|
39
|
+
*
|
|
40
|
+
* @internal exported for tests
|
|
41
|
+
*/
|
|
42
|
+
export declare function applyPostflight(pipeline: Pipeline, response: any, extractOutput: Extractor): any;
|
|
43
|
+
export declare function setupAutoGuards(guards: Guard[], failOpen?: boolean): void;
|
|
44
|
+
export {};
|