@hilbras/sdk 3.0.0 → 3.2.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/README.md +69 -34
- package/dist/adapters/anthropic.d.ts +0 -2
- package/dist/adapters/anthropic.js +4 -4
- package/dist/adapters/azure.d.ts +0 -2
- package/dist/adapters/azure.js +4 -3
- package/dist/adapters/bedrock.d.ts +0 -2
- package/dist/adapters/bedrock.js +4 -5
- package/dist/adapters/cerebras.d.ts +0 -1
- package/dist/adapters/cerebras.js +0 -1
- package/dist/adapters/cohere-rerank.d.ts +0 -1
- package/dist/adapters/cohere-rerank.js +0 -1
- package/dist/adapters/cohere.d.ts +0 -1
- package/dist/adapters/cohere.js +2 -2
- package/dist/adapters/deepgram.d.ts +0 -1
- package/dist/adapters/deepgram.js +4 -5
- package/dist/adapters/deepinfra.d.ts +0 -1
- package/dist/adapters/deepinfra.js +0 -1
- package/dist/adapters/deepseek.d.ts +0 -1
- package/dist/adapters/deepseek.js +0 -1
- package/dist/adapters/elevenlabs.d.ts +0 -1
- package/dist/adapters/elevenlabs.js +0 -1
- package/dist/adapters/extra.d.ts +2 -0
- package/dist/adapters/extra.js +34 -0
- package/dist/adapters/fireworks.d.ts +0 -1
- package/dist/adapters/fireworks.js +0 -1
- package/dist/adapters/google-genai.d.ts +0 -2
- package/dist/adapters/google-genai.js +2 -3
- package/dist/adapters/google-vertex.d.ts +0 -2
- package/dist/adapters/google-vertex.js +2 -3
- package/dist/adapters/groq.d.ts +0 -2
- package/dist/adapters/groq.js +4 -4
- package/dist/adapters/huggingface.d.ts +0 -2
- package/dist/adapters/huggingface.js +2 -3
- package/dist/adapters/mistral.d.ts +0 -1
- package/dist/adapters/mistral.js +0 -1
- package/dist/adapters/ollama.d.ts +0 -2
- package/dist/adapters/ollama.js +4 -4
- package/dist/adapters/openai-compatible.d.ts +0 -3
- package/dist/adapters/openai-compatible.js +4 -3
- package/dist/adapters/openai.d.ts +0 -2
- package/dist/adapters/openai.js +4 -3
- package/dist/adapters/perplexity.d.ts +0 -1
- package/dist/adapters/perplexity.js +0 -1
- package/dist/adapters/text-tool-call-parser.d.ts +0 -1
- package/dist/adapters/text-tool-call-parser.js +0 -1
- package/dist/adapters/together.d.ts +0 -1
- package/dist/adapters/together.js +0 -1
- package/dist/adapters/voyageai.d.ts +0 -1
- package/dist/adapters/voyageai.js +0 -1
- package/dist/adapters/xai.d.ts +0 -1
- package/dist/adapters/xai.js +0 -1
- package/dist/catalog/index.d.ts +0 -1
- package/dist/catalog/index.js +1 -2
- package/dist/catalog/models.d.ts +0 -1
- package/dist/catalog/models.js +11 -9
- package/dist/catalog/provider-catalog.d.ts +228 -0
- package/dist/catalog/provider-catalog.js +1493 -0
- package/dist/client/client.d.ts +9 -3
- package/dist/client/client.js +194 -356
- package/dist/client/hooks.d.ts +0 -1
- package/dist/client/hooks.js +0 -1
- package/dist/config/config.d.ts +0 -1
- package/dist/config/config.js +0 -1
- package/dist/config/prompts.d.ts +0 -1
- package/dist/config/prompts.js +0 -1
- package/dist/config/provider-config.d.ts +2 -1
- package/dist/config/provider-config.js +12 -2
- package/dist/config/schema.d.ts +0 -1
- package/dist/config/schema.js +0 -1
- package/dist/core/execution/execution-result.d.ts +18 -0
- package/dist/core/execution/execution-result.js +12 -0
- package/dist/core/execution/ports.d.ts +54 -0
- package/dist/core/execution/ports.js +7 -0
- package/dist/core/execution/request-context.d.ts +63 -0
- package/dist/core/execution/request-context.js +48 -0
- package/dist/core/execution/request-executor.d.ts +49 -0
- package/dist/core/execution/request-executor.js +107 -0
- package/dist/core/execution/request-pipeline.d.ts +66 -0
- package/dist/core/execution/request-pipeline.js +730 -0
- package/dist/cost/alerts.d.ts +1 -1
- package/dist/cost/alerts.js +18 -6
- package/dist/cost/tracker.d.ts +0 -1
- package/dist/cost/tracker.js +8 -9
- package/dist/cost/types.d.ts +0 -1
- package/dist/cost/types.js +0 -1
- package/dist/credentials/oidc.d.ts +0 -1
- package/dist/credentials/oidc.js +0 -1
- package/dist/credentials/provider.d.ts +0 -1
- package/dist/credentials/provider.js +0 -1
- package/dist/devtools/dashboard.d.ts +0 -1
- package/dist/devtools/dashboard.js +0 -1
- package/dist/devtools/index.d.ts +0 -1
- package/dist/devtools/index.js +0 -1
- package/dist/errors/index.d.ts +0 -1
- package/dist/errors/index.js +0 -1
- package/dist/features/agent/index.d.ts +0 -1
- package/dist/features/agent/index.js +0 -1
- package/dist/features/agent/plan-and-execute.d.ts +0 -1
- package/dist/features/agent/plan-and-execute.js +0 -1
- package/dist/features/agent/react.d.ts +0 -1
- package/dist/features/agent/react.js +0 -1
- package/dist/features/agent/tool-loop.d.ts +0 -1
- package/dist/features/agent/tool-loop.js +0 -1
- package/dist/features/agent/types.d.ts +0 -1
- package/dist/features/agent/types.js +0 -1
- package/dist/features/eval/ab-test.d.ts +0 -1
- package/dist/features/eval/ab-test.js +0 -1
- package/dist/features/eval/evaluate.d.ts +0 -1
- package/dist/features/eval/evaluate.js +0 -1
- package/dist/features/eval/index.d.ts +0 -1
- package/dist/features/eval/index.js +0 -1
- package/dist/features/eval/metrics.d.ts +0 -1
- package/dist/features/eval/metrics.js +0 -1
- package/dist/features/eval/types.d.ts +0 -1
- package/dist/features/eval/types.js +0 -1
- package/dist/features/fine-tune/formatters.d.ts +0 -1
- package/dist/features/fine-tune/formatters.js +0 -1
- package/dist/features/fine-tune/index.d.ts +0 -1
- package/dist/features/fine-tune/index.js +0 -1
- package/dist/features/fine-tune/quality.d.ts +0 -1
- package/dist/features/fine-tune/quality.js +0 -1
- package/dist/features/fine-tune/split.d.ts +0 -1
- package/dist/features/fine-tune/split.js +0 -1
- package/dist/features/fine-tune/types.d.ts +0 -1
- package/dist/features/fine-tune/types.js +0 -1
- package/dist/features/rag/chunker.d.ts +0 -1
- package/dist/features/rag/chunker.js +6 -1
- package/dist/features/rag/in-memory-store.d.ts +0 -1
- package/dist/features/rag/in-memory-store.js +2 -1
- package/dist/features/rag/index.d.ts +0 -1
- package/dist/features/rag/index.js +0 -1
- package/dist/features/rag/pipeline.d.ts +0 -1
- package/dist/features/rag/pipeline.js +3 -7
- package/dist/features/rag/retriever.d.ts +5 -1
- package/dist/features/rag/retriever.js +22 -26
- package/dist/features/rag/vector-store.d.ts +0 -1
- package/dist/features/rag/vector-store.js +0 -1
- package/dist/frameworks/angular/angular-shim.d.ts +0 -1
- package/dist/frameworks/angular/angular-shim.js +0 -1
- package/dist/frameworks/angular/chat.service.d.ts +0 -1
- package/dist/frameworks/angular/chat.service.js +0 -1
- package/dist/frameworks/angular/completion.service.d.ts +0 -1
- package/dist/frameworks/angular/completion.service.js +0 -1
- package/dist/frameworks/angular/index.d.ts +0 -1
- package/dist/frameworks/angular/index.js +0 -1
- package/dist/frameworks/angular/object.service.d.ts +0 -1
- package/dist/frameworks/angular/object.service.js +0 -1
- package/dist/frameworks/astro/endpoints.d.ts +0 -1
- package/dist/frameworks/astro/endpoints.js +0 -1
- package/dist/frameworks/astro/hooks.d.ts +0 -1
- package/dist/frameworks/astro/hooks.js +0 -1
- package/dist/frameworks/astro/index.d.ts +0 -1
- package/dist/frameworks/astro/index.js +0 -1
- package/dist/frameworks/nextjs/client.d.ts +0 -1
- package/dist/frameworks/nextjs/client.js +0 -1
- package/dist/frameworks/nextjs/index.d.ts +0 -1
- package/dist/frameworks/nextjs/index.js +0 -1
- package/dist/frameworks/nextjs/route-handlers.d.ts +0 -1
- package/dist/frameworks/nextjs/route-handlers.js +0 -1
- package/dist/frameworks/nextjs/server.d.ts +0 -1
- package/dist/frameworks/nextjs/server.js +0 -1
- package/dist/frameworks/nextjs/signal-shim.d.ts +0 -1
- package/dist/frameworks/nextjs/signal-shim.js +0 -1
- package/dist/frameworks/nextjs/use-chat.d.ts +0 -1
- package/dist/frameworks/nextjs/use-chat.js +0 -1
- package/dist/frameworks/nextjs/use-completion.d.ts +0 -1
- package/dist/frameworks/nextjs/use-completion.js +0 -1
- package/dist/frameworks/qwik/index.d.ts +0 -1
- package/dist/frameworks/qwik/index.js +0 -1
- package/dist/frameworks/qwik/signal-shim.d.ts +0 -1
- package/dist/frameworks/qwik/signal-shim.js +0 -1
- package/dist/frameworks/qwik/stream-parser.d.ts +0 -1
- package/dist/frameworks/qwik/stream-parser.js +0 -1
- package/dist/frameworks/qwik/use-chat.d.ts +0 -1
- package/dist/frameworks/qwik/use-chat.js +0 -1
- package/dist/frameworks/qwik/use-completion.d.ts +0 -1
- package/dist/frameworks/qwik/use-completion.js +0 -1
- package/dist/frameworks/react/generative-ui.d.ts +0 -1
- package/dist/frameworks/react/generative-ui.js +0 -1
- package/dist/frameworks/react/index.d.ts +0 -1
- package/dist/frameworks/react/index.js +0 -1
- package/dist/frameworks/react/stream-parser.d.ts +0 -1
- package/dist/frameworks/react/stream-parser.js +0 -1
- package/dist/frameworks/react/use-chat.d.ts +0 -1
- package/dist/frameworks/react/use-chat.js +0 -1
- package/dist/frameworks/react/use-completion.d.ts +0 -1
- package/dist/frameworks/react/use-completion.js +0 -1
- package/dist/frameworks/react/use-object.d.ts +0 -1
- package/dist/frameworks/react/use-object.js +0 -1
- package/dist/frameworks/remix/actions.d.ts +0 -1
- package/dist/frameworks/remix/actions.js +0 -1
- package/dist/frameworks/remix/hooks.d.ts +0 -1
- package/dist/frameworks/remix/hooks.js +0 -1
- package/dist/frameworks/remix/index.d.ts +0 -1
- package/dist/frameworks/remix/index.js +0 -1
- package/dist/frameworks/solid/index.d.ts +0 -1
- package/dist/frameworks/solid/index.js +0 -1
- package/dist/frameworks/solid/solid-shim.d.ts +0 -1
- package/dist/frameworks/solid/solid-shim.js +0 -1
- package/dist/frameworks/solid/stream-parser.d.ts +0 -1
- package/dist/frameworks/solid/stream-parser.js +0 -1
- package/dist/frameworks/solid/use-chat.d.ts +0 -1
- package/dist/frameworks/solid/use-chat.js +0 -1
- package/dist/frameworks/solid/use-completion.d.ts +0 -1
- package/dist/frameworks/solid/use-completion.js +0 -1
- package/dist/frameworks/solid/use-object.d.ts +0 -1
- package/dist/frameworks/solid/use-object.js +0 -1
- package/dist/frameworks/svelte/index.d.ts +0 -1
- package/dist/frameworks/svelte/index.js +0 -1
- package/dist/frameworks/svelte/stream-parser.d.ts +0 -1
- package/dist/frameworks/svelte/stream-parser.js +0 -1
- package/dist/frameworks/svelte/use-chat.d.ts +0 -1
- package/dist/frameworks/svelte/use-chat.js +0 -1
- package/dist/frameworks/svelte/use-completion.d.ts +0 -1
- package/dist/frameworks/svelte/use-completion.js +0 -1
- package/dist/frameworks/svelte/use-object.d.ts +0 -1
- package/dist/frameworks/svelte/use-object.js +0 -1
- package/dist/frameworks/vue/index.d.ts +0 -1
- package/dist/frameworks/vue/index.js +0 -1
- package/dist/frameworks/vue/stream-parser.d.ts +0 -1
- package/dist/frameworks/vue/stream-parser.js +0 -1
- package/dist/frameworks/vue/use-chat.d.ts +0 -1
- package/dist/frameworks/vue/use-chat.js +0 -1
- package/dist/frameworks/vue/use-completion.d.ts +0 -1
- package/dist/frameworks/vue/use-completion.js +0 -1
- package/dist/frameworks/vue/use-object.d.ts +0 -1
- package/dist/frameworks/vue/use-object.js +0 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/logging/logger.d.ts +4 -47
- package/dist/logging/logger.js +9 -64
- package/dist/mcp/index.d.ts +0 -1
- package/dist/mcp/index.js +0 -1
- package/dist/middleware/middleware.d.ts +1 -2
- package/dist/middleware/middleware.js +28 -11
- package/dist/output/schema-helpers.d.ts +0 -1
- package/dist/output/schema-helpers.js +0 -1
- package/dist/output/structured.d.ts +0 -1
- package/dist/output/structured.js +0 -1
- package/dist/plugin/registry.d.ts +3 -1
- package/dist/plugin/registry.js +8 -7
- package/dist/plugin/types.d.ts +0 -1
- package/dist/plugin/types.js +0 -1
- package/dist/providers/adapter-registry.d.ts +0 -1
- package/dist/providers/adapter-registry.js +0 -1
- package/dist/providers/registry.d.ts +0 -1
- package/dist/providers/registry.js +9 -8
- package/dist/realtime/index.d.ts +0 -1
- package/dist/realtime/index.js +0 -1
- package/dist/reasoning/normalizer.d.ts +0 -1
- package/dist/reasoning/normalizer.js +0 -1
- package/dist/reliability/backoff.d.ts +1 -2
- package/dist/reliability/backoff.js +21 -3
- package/dist/reliability/circuit-breaker.d.ts +0 -1
- package/dist/reliability/circuit-breaker.js +5 -2
- package/dist/reliability/degradation.d.ts +0 -1
- package/dist/reliability/degradation.js +0 -1
- package/dist/reliability/presets.d.ts +0 -1
- package/dist/reliability/presets.js +0 -1
- package/dist/reliability/retry.d.ts +0 -1
- package/dist/reliability/retry.js +0 -1
- package/dist/reliability/timeout.d.ts +12 -1
- package/dist/reliability/timeout.js +51 -12
- package/dist/router/model-router.d.ts +0 -1
- package/dist/router/model-router.js +0 -1
- package/dist/security/audit-logger.d.ts +2 -1
- package/dist/security/audit-logger.js +39 -24
- package/dist/security/pii-guard.d.ts +0 -1
- package/dist/security/pii-guard.js +21 -6
- package/dist/security/prompt-injection-guard.d.ts +0 -1
- package/dist/security/prompt-injection-guard.js +22 -5
- package/dist/security/rate-limiter.d.ts +0 -1
- package/dist/security/rate-limiter.js +0 -1
- package/dist/security/rbac.d.ts +0 -1
- package/dist/security/rbac.js +0 -1
- package/dist/security/request-signer.d.ts +0 -1
- package/dist/security/request-signer.js +0 -1
- package/dist/security/url-guard.d.ts +0 -1
- package/dist/security/url-guard.js +110 -28
- package/dist/telemetry/body-logger.d.ts +0 -1
- package/dist/telemetry/body-logger.js +18 -10
- package/dist/telemetry/dashboard.d.ts +0 -1
- package/dist/telemetry/dashboard.js +0 -1
- package/dist/telemetry/opentelemetry.d.ts +0 -1
- package/dist/telemetry/opentelemetry.js +0 -1
- package/dist/telemetry/sla.d.ts +0 -1
- package/dist/telemetry/sla.js +0 -1
- package/dist/telemetry/structured-logger.d.ts +0 -1
- package/dist/telemetry/structured-logger.js +20 -8
- package/dist/tokens/counter.d.ts +0 -1
- package/dist/tokens/counter.js +0 -1
- package/dist/tokens/prompt-cache.d.ts +0 -1
- package/dist/tokens/prompt-cache.js +0 -1
- package/dist/transport/fetch.d.ts +0 -1
- package/dist/transport/fetch.js +48 -17
- package/dist/transport/middleware-transport.d.ts +0 -1
- package/dist/transport/middleware-transport.js +0 -1
- package/dist/transport/transport.d.ts +0 -1
- package/dist/transport/transport.js +0 -1
- package/dist/transport/websocket.d.ts +0 -1
- package/dist/transport/websocket.js +0 -1
- package/dist/types/adapter.d.ts +0 -1
- package/dist/types/adapter.js +0 -1
- package/dist/types/execution.d.ts +0 -1
- package/dist/types/execution.js +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/messages.d.ts +0 -1
- package/dist/types/messages.js +0 -1
- package/dist/types/models.d.ts +0 -1
- package/dist/types/models.js +0 -1
- package/dist/types/multi-modal.d.ts +0 -1
- package/dist/types/multi-modal.js +0 -1
- package/dist/types/observability.d.ts +0 -1
- package/dist/types/observability.js +0 -1
- package/dist/types/policy.d.ts +0 -1
- package/dist/types/policy.js +0 -1
- package/dist/types/providers.d.ts +0 -1
- package/dist/types/providers.js +0 -1
- package/dist/types/router.d.ts +0 -1
- package/dist/types/router.js +0 -1
- package/dist/types/schema.d.ts +0 -1
- package/dist/types/schema.js +0 -1
- package/dist/types/streams.d.ts +0 -1
- package/dist/types/streams.js +0 -1
- package/dist/types/tool-builder.d.ts +3 -2
- package/dist/types/tool-builder.js +3 -2
- package/dist/types/tools.d.ts +0 -3
- package/dist/types/tools.js +1 -12
- package/dist/types/ui-protocol.d.ts +0 -1
- package/dist/types/ui-protocol.js +0 -1
- package/dist/utils/id.d.ts +0 -1
- package/dist/utils/id.js +0 -1
- package/dist/utils/sse-writer.d.ts +0 -1
- package/dist/utils/sse-writer.js +0 -1
- package/dist/utils/sse.d.ts +0 -1
- package/dist/utils/sse.js +0 -1
- package/package.json +124 -108
- package/dist/adapters/anthropic.d.ts.map +0 -1
- package/dist/adapters/anthropic.js.map +0 -1
- package/dist/adapters/azure.d.ts.map +0 -1
- package/dist/adapters/azure.js.map +0 -1
- package/dist/adapters/bedrock.d.ts.map +0 -1
- package/dist/adapters/bedrock.js.map +0 -1
- package/dist/adapters/cerebras.d.ts.map +0 -1
- package/dist/adapters/cerebras.js.map +0 -1
- package/dist/adapters/cohere-rerank.d.ts.map +0 -1
- package/dist/adapters/cohere-rerank.js.map +0 -1
- package/dist/adapters/cohere.d.ts.map +0 -1
- package/dist/adapters/cohere.js.map +0 -1
- package/dist/adapters/deepgram.d.ts.map +0 -1
- package/dist/adapters/deepgram.js.map +0 -1
- package/dist/adapters/deepinfra.d.ts.map +0 -1
- package/dist/adapters/deepinfra.js.map +0 -1
- package/dist/adapters/deepseek.d.ts.map +0 -1
- package/dist/adapters/deepseek.js.map +0 -1
- package/dist/adapters/elevenlabs.d.ts.map +0 -1
- package/dist/adapters/elevenlabs.js.map +0 -1
- package/dist/adapters/fireworks.d.ts.map +0 -1
- package/dist/adapters/fireworks.js.map +0 -1
- package/dist/adapters/google-genai.d.ts.map +0 -1
- package/dist/adapters/google-genai.js.map +0 -1
- package/dist/adapters/google-vertex.d.ts.map +0 -1
- package/dist/adapters/google-vertex.js.map +0 -1
- package/dist/adapters/groq.d.ts.map +0 -1
- package/dist/adapters/groq.js.map +0 -1
- package/dist/adapters/huggingface.d.ts.map +0 -1
- package/dist/adapters/huggingface.js.map +0 -1
- package/dist/adapters/mistral.d.ts.map +0 -1
- package/dist/adapters/mistral.js.map +0 -1
- package/dist/adapters/ollama.d.ts.map +0 -1
- package/dist/adapters/ollama.js.map +0 -1
- package/dist/adapters/openai-compatible.d.ts.map +0 -1
- package/dist/adapters/openai-compatible.js.map +0 -1
- package/dist/adapters/openai.d.ts.map +0 -1
- package/dist/adapters/openai.js.map +0 -1
- package/dist/adapters/perplexity.d.ts.map +0 -1
- package/dist/adapters/perplexity.js.map +0 -1
- package/dist/adapters/text-tool-call-parser.d.ts.map +0 -1
- package/dist/adapters/text-tool-call-parser.js.map +0 -1
- package/dist/adapters/together.d.ts.map +0 -1
- package/dist/adapters/together.js.map +0 -1
- package/dist/adapters/voyageai.d.ts.map +0 -1
- package/dist/adapters/voyageai.js.map +0 -1
- package/dist/adapters/xai.d.ts.map +0 -1
- package/dist/adapters/xai.js.map +0 -1
- package/dist/catalog/index.d.ts.map +0 -1
- package/dist/catalog/index.js.map +0 -1
- package/dist/catalog/models.d.ts.map +0 -1
- package/dist/catalog/models.js.map +0 -1
- package/dist/catalog/provider-catalog.json +0 -246
- package/dist/client/client.d.ts.map +0 -1
- package/dist/client/client.js.map +0 -1
- package/dist/client/hooks.d.ts.map +0 -1
- package/dist/client/hooks.js.map +0 -1
- package/dist/client/pipeline.d.ts +0 -134
- package/dist/client/pipeline.d.ts.map +0 -1
- package/dist/client/pipeline.js +0 -222
- package/dist/client/pipeline.js.map +0 -1
- package/dist/config/config.d.ts.map +0 -1
- package/dist/config/config.js.map +0 -1
- package/dist/config/prompts.d.ts.map +0 -1
- package/dist/config/prompts.js.map +0 -1
- package/dist/config/provider-config.d.ts.map +0 -1
- package/dist/config/provider-config.js.map +0 -1
- package/dist/config/schema.d.ts.map +0 -1
- package/dist/config/schema.js.map +0 -1
- package/dist/cost/alerts.d.ts.map +0 -1
- package/dist/cost/alerts.js.map +0 -1
- package/dist/cost/tracker.d.ts.map +0 -1
- package/dist/cost/tracker.js.map +0 -1
- package/dist/cost/types.d.ts.map +0 -1
- package/dist/cost/types.js.map +0 -1
- package/dist/credentials/oidc.d.ts.map +0 -1
- package/dist/credentials/oidc.js.map +0 -1
- package/dist/credentials/provider.d.ts.map +0 -1
- package/dist/credentials/provider.js.map +0 -1
- package/dist/devtools/dashboard.d.ts.map +0 -1
- package/dist/devtools/dashboard.js.map +0 -1
- package/dist/devtools/index.d.ts.map +0 -1
- package/dist/devtools/index.js.map +0 -1
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js.map +0 -1
- package/dist/features/agent/index.d.ts.map +0 -1
- package/dist/features/agent/index.js.map +0 -1
- package/dist/features/agent/plan-and-execute.d.ts.map +0 -1
- package/dist/features/agent/plan-and-execute.js.map +0 -1
- package/dist/features/agent/react.d.ts.map +0 -1
- package/dist/features/agent/react.js.map +0 -1
- package/dist/features/agent/tool-loop.d.ts.map +0 -1
- package/dist/features/agent/tool-loop.js.map +0 -1
- package/dist/features/agent/types.d.ts.map +0 -1
- package/dist/features/agent/types.js.map +0 -1
- package/dist/features/eval/ab-test.d.ts.map +0 -1
- package/dist/features/eval/ab-test.js.map +0 -1
- package/dist/features/eval/evaluate.d.ts.map +0 -1
- package/dist/features/eval/evaluate.js.map +0 -1
- package/dist/features/eval/index.d.ts.map +0 -1
- package/dist/features/eval/index.js.map +0 -1
- package/dist/features/eval/metrics.d.ts.map +0 -1
- package/dist/features/eval/metrics.js.map +0 -1
- package/dist/features/eval/types.d.ts.map +0 -1
- package/dist/features/eval/types.js.map +0 -1
- package/dist/features/fine-tune/formatters.d.ts.map +0 -1
- package/dist/features/fine-tune/formatters.js.map +0 -1
- package/dist/features/fine-tune/index.d.ts.map +0 -1
- package/dist/features/fine-tune/index.js.map +0 -1
- package/dist/features/fine-tune/quality.d.ts.map +0 -1
- package/dist/features/fine-tune/quality.js.map +0 -1
- package/dist/features/fine-tune/split.d.ts.map +0 -1
- package/dist/features/fine-tune/split.js.map +0 -1
- package/dist/features/fine-tune/types.d.ts.map +0 -1
- package/dist/features/fine-tune/types.js.map +0 -1
- package/dist/features/memory/index.d.ts +0 -3
- package/dist/features/memory/index.d.ts.map +0 -1
- package/dist/features/memory/index.js +0 -2
- package/dist/features/memory/index.js.map +0 -1
- package/dist/features/memory/memory.d.ts +0 -46
- package/dist/features/memory/memory.d.ts.map +0 -1
- package/dist/features/memory/memory.js +0 -152
- package/dist/features/memory/memory.js.map +0 -1
- package/dist/features/rag/chunker.d.ts.map +0 -1
- package/dist/features/rag/chunker.js.map +0 -1
- package/dist/features/rag/in-memory-store.d.ts.map +0 -1
- package/dist/features/rag/in-memory-store.js.map +0 -1
- package/dist/features/rag/index.d.ts.map +0 -1
- package/dist/features/rag/index.js.map +0 -1
- package/dist/features/rag/pipeline.d.ts.map +0 -1
- package/dist/features/rag/pipeline.js.map +0 -1
- package/dist/features/rag/retriever.d.ts.map +0 -1
- package/dist/features/rag/retriever.js.map +0 -1
- package/dist/features/rag/vector-store.d.ts.map +0 -1
- package/dist/features/rag/vector-store.js.map +0 -1
- package/dist/frameworks/angular/angular-shim.d.ts.map +0 -1
- package/dist/frameworks/angular/angular-shim.js.map +0 -1
- package/dist/frameworks/angular/chat.service.d.ts.map +0 -1
- package/dist/frameworks/angular/chat.service.js.map +0 -1
- package/dist/frameworks/angular/completion.service.d.ts.map +0 -1
- package/dist/frameworks/angular/completion.service.js.map +0 -1
- package/dist/frameworks/angular/index.d.ts.map +0 -1
- package/dist/frameworks/angular/index.js.map +0 -1
- package/dist/frameworks/angular/object.service.d.ts.map +0 -1
- package/dist/frameworks/angular/object.service.js.map +0 -1
- package/dist/frameworks/astro/endpoints.d.ts.map +0 -1
- package/dist/frameworks/astro/endpoints.js.map +0 -1
- package/dist/frameworks/astro/hooks.d.ts.map +0 -1
- package/dist/frameworks/astro/hooks.js.map +0 -1
- package/dist/frameworks/astro/index.d.ts.map +0 -1
- package/dist/frameworks/astro/index.js.map +0 -1
- package/dist/frameworks/nextjs/client.d.ts.map +0 -1
- package/dist/frameworks/nextjs/client.js.map +0 -1
- package/dist/frameworks/nextjs/index.d.ts.map +0 -1
- package/dist/frameworks/nextjs/index.js.map +0 -1
- package/dist/frameworks/nextjs/route-handlers.d.ts.map +0 -1
- package/dist/frameworks/nextjs/route-handlers.js.map +0 -1
- package/dist/frameworks/nextjs/server.d.ts.map +0 -1
- package/dist/frameworks/nextjs/server.js.map +0 -1
- package/dist/frameworks/nextjs/signal-shim.d.ts.map +0 -1
- package/dist/frameworks/nextjs/signal-shim.js.map +0 -1
- package/dist/frameworks/nextjs/use-chat.d.ts.map +0 -1
- package/dist/frameworks/nextjs/use-chat.js.map +0 -1
- package/dist/frameworks/nextjs/use-completion.d.ts.map +0 -1
- package/dist/frameworks/nextjs/use-completion.js.map +0 -1
- package/dist/frameworks/qwik/index.d.ts.map +0 -1
- package/dist/frameworks/qwik/index.js.map +0 -1
- package/dist/frameworks/qwik/signal-shim.d.ts.map +0 -1
- package/dist/frameworks/qwik/signal-shim.js.map +0 -1
- package/dist/frameworks/qwik/stream-parser.d.ts.map +0 -1
- package/dist/frameworks/qwik/stream-parser.js.map +0 -1
- package/dist/frameworks/qwik/use-chat.d.ts.map +0 -1
- package/dist/frameworks/qwik/use-chat.js.map +0 -1
- package/dist/frameworks/qwik/use-completion.d.ts.map +0 -1
- package/dist/frameworks/qwik/use-completion.js.map +0 -1
- package/dist/frameworks/react/generative-ui.d.ts.map +0 -1
- package/dist/frameworks/react/generative-ui.js.map +0 -1
- package/dist/frameworks/react/index.d.ts.map +0 -1
- package/dist/frameworks/react/index.js.map +0 -1
- package/dist/frameworks/react/stream-parser.d.ts.map +0 -1
- package/dist/frameworks/react/stream-parser.js.map +0 -1
- package/dist/frameworks/react/use-chat.d.ts.map +0 -1
- package/dist/frameworks/react/use-chat.js.map +0 -1
- package/dist/frameworks/react/use-completion.d.ts.map +0 -1
- package/dist/frameworks/react/use-completion.js.map +0 -1
- package/dist/frameworks/react/use-object.d.ts.map +0 -1
- package/dist/frameworks/react/use-object.js.map +0 -1
- package/dist/frameworks/remix/actions.d.ts.map +0 -1
- package/dist/frameworks/remix/actions.js.map +0 -1
- package/dist/frameworks/remix/hooks.d.ts.map +0 -1
- package/dist/frameworks/remix/hooks.js.map +0 -1
- package/dist/frameworks/remix/index.d.ts.map +0 -1
- package/dist/frameworks/remix/index.js.map +0 -1
- package/dist/frameworks/solid/index.d.ts.map +0 -1
- package/dist/frameworks/solid/index.js.map +0 -1
- package/dist/frameworks/solid/solid-shim.d.ts.map +0 -1
- package/dist/frameworks/solid/solid-shim.js.map +0 -1
- package/dist/frameworks/solid/stream-parser.d.ts.map +0 -1
- package/dist/frameworks/solid/stream-parser.js.map +0 -1
- package/dist/frameworks/solid/use-chat.d.ts.map +0 -1
- package/dist/frameworks/solid/use-chat.js.map +0 -1
- package/dist/frameworks/solid/use-completion.d.ts.map +0 -1
- package/dist/frameworks/solid/use-completion.js.map +0 -1
- package/dist/frameworks/solid/use-object.d.ts.map +0 -1
- package/dist/frameworks/solid/use-object.js.map +0 -1
- package/dist/frameworks/svelte/index.d.ts.map +0 -1
- package/dist/frameworks/svelte/index.js.map +0 -1
- package/dist/frameworks/svelte/stream-parser.d.ts.map +0 -1
- package/dist/frameworks/svelte/stream-parser.js.map +0 -1
- package/dist/frameworks/svelte/use-chat.d.ts.map +0 -1
- package/dist/frameworks/svelte/use-chat.js.map +0 -1
- package/dist/frameworks/svelte/use-completion.d.ts.map +0 -1
- package/dist/frameworks/svelte/use-completion.js.map +0 -1
- package/dist/frameworks/svelte/use-object.d.ts.map +0 -1
- package/dist/frameworks/svelte/use-object.js.map +0 -1
- package/dist/frameworks/vue/index.d.ts.map +0 -1
- package/dist/frameworks/vue/index.js.map +0 -1
- package/dist/frameworks/vue/stream-parser.d.ts.map +0 -1
- package/dist/frameworks/vue/stream-parser.js.map +0 -1
- package/dist/frameworks/vue/use-chat.d.ts.map +0 -1
- package/dist/frameworks/vue/use-chat.js.map +0 -1
- package/dist/frameworks/vue/use-completion.d.ts.map +0 -1
- package/dist/frameworks/vue/use-completion.js.map +0 -1
- package/dist/frameworks/vue/use-object.d.ts.map +0 -1
- package/dist/frameworks/vue/use-object.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logging/logger.d.ts.map +0 -1
- package/dist/logging/logger.js.map +0 -1
- package/dist/mcp/index.d.ts.map +0 -1
- package/dist/mcp/index.js.map +0 -1
- package/dist/middleware/middleware.d.ts.map +0 -1
- package/dist/middleware/middleware.js.map +0 -1
- package/dist/output/schema-helpers.d.ts.map +0 -1
- package/dist/output/schema-helpers.js.map +0 -1
- package/dist/output/structured.d.ts.map +0 -1
- package/dist/output/structured.js.map +0 -1
- package/dist/plugin/index.d.ts +0 -9
- package/dist/plugin/index.d.ts.map +0 -1
- package/dist/plugin/index.js +0 -8
- package/dist/plugin/index.js.map +0 -1
- package/dist/plugin/registry.d.ts.map +0 -1
- package/dist/plugin/registry.js.map +0 -1
- package/dist/plugin/types.d.ts.map +0 -1
- package/dist/plugin/types.js.map +0 -1
- package/dist/providers/adapter-registry.d.ts.map +0 -1
- package/dist/providers/adapter-registry.js.map +0 -1
- package/dist/providers/registry.d.ts.map +0 -1
- package/dist/providers/registry.js.map +0 -1
- package/dist/realtime/index.d.ts.map +0 -1
- package/dist/realtime/index.js.map +0 -1
- package/dist/reasoning/normalizer.d.ts.map +0 -1
- package/dist/reasoning/normalizer.js.map +0 -1
- package/dist/reliability/backoff.d.ts.map +0 -1
- package/dist/reliability/backoff.js.map +0 -1
- package/dist/reliability/circuit-breaker.d.ts.map +0 -1
- package/dist/reliability/circuit-breaker.js.map +0 -1
- package/dist/reliability/degradation.d.ts.map +0 -1
- package/dist/reliability/degradation.js.map +0 -1
- package/dist/reliability/presets.d.ts.map +0 -1
- package/dist/reliability/presets.js.map +0 -1
- package/dist/reliability/retry.d.ts.map +0 -1
- package/dist/reliability/retry.js.map +0 -1
- package/dist/reliability/timeout.d.ts.map +0 -1
- package/dist/reliability/timeout.js.map +0 -1
- package/dist/router/model-router.d.ts.map +0 -1
- package/dist/router/model-router.js.map +0 -1
- package/dist/security/audit-logger.d.ts.map +0 -1
- package/dist/security/audit-logger.js.map +0 -1
- package/dist/security/index.d.ts +0 -18
- package/dist/security/index.d.ts.map +0 -1
- package/dist/security/index.js +0 -12
- package/dist/security/index.js.map +0 -1
- package/dist/security/pii-guard.d.ts.map +0 -1
- package/dist/security/pii-guard.js.map +0 -1
- package/dist/security/prompt-injection-guard.d.ts.map +0 -1
- package/dist/security/prompt-injection-guard.js.map +0 -1
- package/dist/security/rate-limiter.d.ts.map +0 -1
- package/dist/security/rate-limiter.js.map +0 -1
- package/dist/security/rbac.d.ts.map +0 -1
- package/dist/security/rbac.js.map +0 -1
- package/dist/security/request-signer.d.ts.map +0 -1
- package/dist/security/request-signer.js.map +0 -1
- package/dist/security/url-guard.d.ts.map +0 -1
- package/dist/security/url-guard.js.map +0 -1
- package/dist/telemetry/body-logger.d.ts.map +0 -1
- package/dist/telemetry/body-logger.js.map +0 -1
- package/dist/telemetry/dashboard.d.ts.map +0 -1
- package/dist/telemetry/dashboard.js.map +0 -1
- package/dist/telemetry/index.d.ts +0 -15
- package/dist/telemetry/index.d.ts.map +0 -1
- package/dist/telemetry/index.js +0 -11
- package/dist/telemetry/index.js.map +0 -1
- package/dist/telemetry/opentelemetry.d.ts.map +0 -1
- package/dist/telemetry/opentelemetry.js.map +0 -1
- package/dist/telemetry/sla.d.ts.map +0 -1
- package/dist/telemetry/sla.js.map +0 -1
- package/dist/telemetry/structured-logger.d.ts.map +0 -1
- package/dist/telemetry/structured-logger.js.map +0 -1
- package/dist/tokens/counter.d.ts.map +0 -1
- package/dist/tokens/counter.js.map +0 -1
- package/dist/tokens/prompt-cache.d.ts.map +0 -1
- package/dist/tokens/prompt-cache.js.map +0 -1
- package/dist/transport/fetch.d.ts.map +0 -1
- package/dist/transport/fetch.js.map +0 -1
- package/dist/transport/middleware-transport.d.ts.map +0 -1
- package/dist/transport/middleware-transport.js.map +0 -1
- package/dist/transport/transport.d.ts.map +0 -1
- package/dist/transport/transport.js.map +0 -1
- package/dist/transport/websocket.d.ts.map +0 -1
- package/dist/transport/websocket.js.map +0 -1
- package/dist/types/adapter.d.ts.map +0 -1
- package/dist/types/adapter.js.map +0 -1
- package/dist/types/execution.d.ts.map +0 -1
- package/dist/types/execution.js.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/messages.d.ts.map +0 -1
- package/dist/types/messages.js.map +0 -1
- package/dist/types/models.d.ts.map +0 -1
- package/dist/types/models.js.map +0 -1
- package/dist/types/multi-modal.d.ts.map +0 -1
- package/dist/types/multi-modal.js.map +0 -1
- package/dist/types/observability.d.ts.map +0 -1
- package/dist/types/observability.js.map +0 -1
- package/dist/types/policy.d.ts.map +0 -1
- package/dist/types/policy.js.map +0 -1
- package/dist/types/providers.d.ts.map +0 -1
- package/dist/types/providers.js.map +0 -1
- package/dist/types/router.d.ts.map +0 -1
- package/dist/types/router.js.map +0 -1
- package/dist/types/schema.d.ts.map +0 -1
- package/dist/types/schema.js.map +0 -1
- package/dist/types/streams.d.ts.map +0 -1
- package/dist/types/streams.js.map +0 -1
- package/dist/types/tool-builder.d.ts.map +0 -1
- package/dist/types/tool-builder.js.map +0 -1
- package/dist/types/tools.d.ts.map +0 -1
- package/dist/types/tools.js.map +0 -1
- package/dist/types/ui-protocol.d.ts.map +0 -1
- package/dist/types/ui-protocol.js.map +0 -1
- package/dist/utils/id.d.ts.map +0 -1
- package/dist/utils/id.js.map +0 -1
- package/dist/utils/sse-writer.d.ts.map +0 -1
- package/dist/utils/sse-writer.js.map +0 -1
- package/dist/utils/sse.d.ts.map +0 -1
- package/dist/utils/sse.js.map +0 -1
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* audit.logDataAccess({ action: "read", resource: "provider-config", userId: "user-1" });
|
|
18
18
|
* audit.logConfigChange({ action: "add_provider", provider: "openai", userId: "admin" });
|
|
19
19
|
*/
|
|
20
|
+
import { redactPii } from "./pii-guard.js";
|
|
20
21
|
/** Monotonic counter for unique event IDs */
|
|
21
22
|
let _eventCounter = 0;
|
|
22
23
|
function generateEventId() {
|
|
@@ -25,6 +26,20 @@ function generateEventId() {
|
|
|
25
26
|
const cnt = _eventCounter.toString(36).padStart(4, "0");
|
|
26
27
|
return `audit_${ts}_${cnt}`;
|
|
27
28
|
}
|
|
29
|
+
function cloneValue(value) {
|
|
30
|
+
if (Array.isArray(value))
|
|
31
|
+
return value.map((item) => cloneValue(item));
|
|
32
|
+
if (value && typeof value === "object") {
|
|
33
|
+
const result = {};
|
|
34
|
+
for (const [key, item] of Object.entries(value))
|
|
35
|
+
result[key] = cloneValue(item);
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
function cloneEntry(entry) {
|
|
41
|
+
return cloneValue(entry);
|
|
42
|
+
}
|
|
28
43
|
/**
|
|
29
44
|
* Immutable append-only audit logger for SOC 2 compliance.
|
|
30
45
|
* All entries are structured JSON with unique IDs and timestamps.
|
|
@@ -92,39 +107,34 @@ export class AuditLogger {
|
|
|
92
107
|
}
|
|
93
108
|
/** Get all audit entries (immutable copy) */
|
|
94
109
|
getEntries(limit) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return [...this._entries];
|
|
110
|
+
const entries = limit ? this._entries.slice(-limit) : this._entries;
|
|
111
|
+
return entries.map(cloneEntry);
|
|
98
112
|
}
|
|
99
113
|
/** Get entries filtered by category */
|
|
100
114
|
getByCategory(category, limit) {
|
|
101
115
|
const filtered = this._entries.filter((e) => e.category === category);
|
|
102
|
-
|
|
103
|
-
return filtered.slice(-limit);
|
|
104
|
-
return filtered;
|
|
116
|
+
return (limit ? filtered.slice(-limit) : filtered).map(cloneEntry);
|
|
105
117
|
}
|
|
106
118
|
/** Get entries filtered by severity */
|
|
107
119
|
getBySeverity(severity, limit) {
|
|
108
120
|
const filtered = this._entries.filter((e) => e.severity === severity);
|
|
109
|
-
|
|
110
|
-
return filtered.slice(-limit);
|
|
111
|
-
return filtered;
|
|
121
|
+
return (limit ? filtered.slice(-limit) : filtered).map(cloneEntry);
|
|
112
122
|
}
|
|
113
123
|
/** Get entries for a specific user */
|
|
114
124
|
getByUser(userId, limit) {
|
|
115
125
|
const filtered = this._entries.filter((e) => e.userId === userId);
|
|
116
|
-
|
|
117
|
-
return filtered.slice(-limit);
|
|
118
|
-
return filtered;
|
|
126
|
+
return (limit ? filtered.slice(-limit) : filtered).map(cloneEntry);
|
|
119
127
|
}
|
|
120
128
|
/** Get entries within a time range */
|
|
121
129
|
getByTimeRange(start, end) {
|
|
122
130
|
const startTime = start.getTime();
|
|
123
131
|
const endTime = end.getTime();
|
|
124
|
-
return this._entries
|
|
132
|
+
return this._entries
|
|
133
|
+
.filter((e) => {
|
|
125
134
|
const t = new Date(e.timestamp).getTime();
|
|
126
135
|
return t >= startTime && t <= endTime;
|
|
127
|
-
})
|
|
136
|
+
})
|
|
137
|
+
.map(cloneEntry);
|
|
128
138
|
}
|
|
129
139
|
/** Count entries by category */
|
|
130
140
|
countByCategory() {
|
|
@@ -138,6 +148,13 @@ export class AuditLogger {
|
|
|
138
148
|
clear() {
|
|
139
149
|
this._entries = [];
|
|
140
150
|
}
|
|
151
|
+
/** Remove entries older than the supplied timestamp and return the count. */
|
|
152
|
+
pruneBefore(cutoff) {
|
|
153
|
+
const cutoffTime = cutoff instanceof Date ? cutoff.getTime() : cutoff;
|
|
154
|
+
const before = this._entries.length;
|
|
155
|
+
this._entries = this._entries.filter((entry) => new Date(entry.timestamp).getTime() >= cutoffTime);
|
|
156
|
+
return before - this._entries.length;
|
|
157
|
+
}
|
|
141
158
|
/** Number of stored entries */
|
|
142
159
|
get size() {
|
|
143
160
|
return this._entries.length;
|
|
@@ -151,19 +168,22 @@ export class AuditLogger {
|
|
|
151
168
|
service: this._config.serviceName,
|
|
152
169
|
action,
|
|
153
170
|
userId: event.userId,
|
|
154
|
-
sourceIp: event.sourceIp,
|
|
171
|
+
sourceIp: this._config.includeSourceIp ? event.sourceIp : undefined,
|
|
155
172
|
requestId: event.requestId,
|
|
156
|
-
description: event.description
|
|
173
|
+
description: this._config.redactPii && event.description
|
|
174
|
+
? redactPii(event.description)
|
|
175
|
+
: event.description,
|
|
157
176
|
meta: { ...this._config.defaultFields, ...event.meta },
|
|
158
177
|
};
|
|
159
178
|
}
|
|
160
179
|
_emit(entry) {
|
|
161
|
-
|
|
180
|
+
const stored = cloneEntry(entry);
|
|
181
|
+
this._entries.push(stored);
|
|
162
182
|
if (this._entries.length > this._maxEntries) {
|
|
163
183
|
this._entries = this._entries.slice(-this._maxEntries);
|
|
164
184
|
}
|
|
165
185
|
try {
|
|
166
|
-
this._config.destination(
|
|
186
|
+
this._config.destination(cloneEntry(stored));
|
|
167
187
|
}
|
|
168
188
|
catch {
|
|
169
189
|
// Swallow destination errors — audit logging must never break the SDK
|
|
@@ -178,11 +198,7 @@ export function createRetentionPolicy(logger, maxAgeMs) {
|
|
|
178
198
|
return {
|
|
179
199
|
purge: () => {
|
|
180
200
|
const cutoff = Date.now() - maxAgeMs;
|
|
181
|
-
|
|
182
|
-
const entries = logger.getEntries();
|
|
183
|
-
logger.clear();
|
|
184
|
-
const kept = entries.filter((e) => new Date(e.timestamp).getTime() >= cutoff);
|
|
185
|
-
return before - kept.length;
|
|
201
|
+
return logger.pruneBefore(cutoff);
|
|
186
202
|
},
|
|
187
203
|
schedule: (intervalMs) => {
|
|
188
204
|
const timer = setInterval(() => {
|
|
@@ -192,4 +208,3 @@ export function createRetentionPolicy(logger, maxAgeMs) {
|
|
|
192
208
|
},
|
|
193
209
|
};
|
|
194
210
|
}
|
|
195
|
-
//# sourceMappingURL=audit-logger.js.map
|
|
@@ -54,4 +54,3 @@ export declare function redactPii(text: string, config?: PiiGuardConfig): string
|
|
|
54
54
|
* Create a PII redactor function for use in middleware or loggers.
|
|
55
55
|
*/
|
|
56
56
|
export declare function createPiiRedactor(config?: PiiGuardConfig): (text: string) => string;
|
|
57
|
-
//# sourceMappingURL=pii-guard.d.ts.map
|
|
@@ -47,6 +47,10 @@ const DEFAULT_REPLACEMENTS = {
|
|
|
47
47
|
eu_iban: "[IBAN]",
|
|
48
48
|
custom: "[REDACTED]",
|
|
49
49
|
};
|
|
50
|
+
function toGlobalRegExp(pattern) {
|
|
51
|
+
const flags = pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`;
|
|
52
|
+
return new RegExp(pattern.source, flags);
|
|
53
|
+
}
|
|
50
54
|
/**
|
|
51
55
|
* Detect PII in text without redacting.
|
|
52
56
|
*/
|
|
@@ -57,10 +61,16 @@ export function detectPii(text, config) {
|
|
|
57
61
|
const pattern = PII_PATTERNS[type];
|
|
58
62
|
if (!pattern)
|
|
59
63
|
continue;
|
|
60
|
-
//
|
|
61
|
-
|
|
64
|
+
// Always scan with a global expression and reject zero-width matches.
|
|
65
|
+
// User-supplied expressions are untrusted and must not be able to hang the
|
|
66
|
+
// detector by matching the empty string or omitting the global flag.
|
|
67
|
+
const re = toGlobalRegExp(pattern);
|
|
62
68
|
let m;
|
|
63
69
|
while ((m = re.exec(text)) !== null) {
|
|
70
|
+
if (m[0].length === 0) {
|
|
71
|
+
re.lastIndex++;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
64
74
|
matches.push({
|
|
65
75
|
type,
|
|
66
76
|
value: m[0],
|
|
@@ -74,8 +84,12 @@ export function detectPii(text, config) {
|
|
|
74
84
|
if (config?.customPatterns) {
|
|
75
85
|
for (const cp of config.customPatterns) {
|
|
76
86
|
let m;
|
|
77
|
-
const re =
|
|
87
|
+
const re = toGlobalRegExp(cp.pattern);
|
|
78
88
|
while ((m = re.exec(text)) !== null) {
|
|
89
|
+
if (m[0].length === 0) {
|
|
90
|
+
re.lastIndex++;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
79
93
|
matches.push({
|
|
80
94
|
type: "custom",
|
|
81
95
|
value: m[0],
|
|
@@ -98,7 +112,7 @@ export function redactPii(text, config) {
|
|
|
98
112
|
if (matches.length === 0)
|
|
99
113
|
return text;
|
|
100
114
|
const mask = config?.mask ?? false;
|
|
101
|
-
const defaultReplacement = config?.defaultReplacement
|
|
115
|
+
const defaultReplacement = config?.defaultReplacement;
|
|
102
116
|
let result = "";
|
|
103
117
|
let lastEnd = 0;
|
|
104
118
|
for (const match of matches) {
|
|
@@ -113,7 +127,9 @@ export function redactPii(text, config) {
|
|
|
113
127
|
result += maskValue(match.value);
|
|
114
128
|
}
|
|
115
129
|
else {
|
|
116
|
-
result +=
|
|
130
|
+
result += defaultReplacement !== undefined
|
|
131
|
+
? defaultReplacement
|
|
132
|
+
: (DEFAULT_REPLACEMENTS[match.type] ?? "[REDACTED]");
|
|
117
133
|
}
|
|
118
134
|
lastEnd = match.end;
|
|
119
135
|
}
|
|
@@ -126,4 +142,3 @@ export function redactPii(text, config) {
|
|
|
126
142
|
export function createPiiRedactor(config) {
|
|
127
143
|
return (text) => redactPii(text, config);
|
|
128
144
|
}
|
|
129
|
-
//# sourceMappingURL=pii-guard.js.map
|
|
@@ -83,4 +83,3 @@ export declare function scanMessages(messages: Message[], config?: InjectionGuar
|
|
|
83
83
|
*/
|
|
84
84
|
export declare function createInjectionGuard(config?: InjectionGuardConfig): (messages: Message[]) => Message[];
|
|
85
85
|
export {};
|
|
86
|
-
//# sourceMappingURL=prompt-injection-guard.d.ts.map
|
|
@@ -174,13 +174,23 @@ export const INJECTION_PATTERNS = [
|
|
|
174
174
|
},
|
|
175
175
|
];
|
|
176
176
|
// ─── Core Functions ──────────────────────────────────────────────────────────
|
|
177
|
+
function toGlobalRegExp(pattern) {
|
|
178
|
+
const flags = pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`;
|
|
179
|
+
return new RegExp(pattern.source, flags);
|
|
180
|
+
}
|
|
177
181
|
/**
|
|
178
|
-
* Extract plain text from message content
|
|
182
|
+
* Extract plain text from message content, including text parts in multimodal
|
|
183
|
+
* messages. Non-text parts are intentionally ignored by this heuristic guard.
|
|
179
184
|
*/
|
|
180
185
|
function extractText(content) {
|
|
181
186
|
if (content == null)
|
|
182
187
|
return "";
|
|
183
|
-
|
|
188
|
+
if (typeof content === "string")
|
|
189
|
+
return content;
|
|
190
|
+
return content
|
|
191
|
+
.filter((part) => part.type === "text")
|
|
192
|
+
.map((part) => part.text)
|
|
193
|
+
.join("\\n");
|
|
184
194
|
}
|
|
185
195
|
/**
|
|
186
196
|
* Detect injection attempts in a single text string.
|
|
@@ -192,9 +202,13 @@ export function detectInjection(text, config) {
|
|
|
192
202
|
const detections = [];
|
|
193
203
|
// Check built-in patterns
|
|
194
204
|
for (const def of INJECTION_PATTERNS) {
|
|
195
|
-
const re =
|
|
205
|
+
const re = toGlobalRegExp(def.pattern);
|
|
196
206
|
let m;
|
|
197
207
|
while ((m = re.exec(text)) !== null) {
|
|
208
|
+
if (m[0].length === 0) {
|
|
209
|
+
re.lastIndex++;
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
198
212
|
detections.push({
|
|
199
213
|
pattern: def.name,
|
|
200
214
|
category: def.category,
|
|
@@ -207,9 +221,13 @@ export function detectInjection(text, config) {
|
|
|
207
221
|
// Check custom patterns
|
|
208
222
|
if (config?.customPatterns) {
|
|
209
223
|
for (const cp of config.customPatterns) {
|
|
210
|
-
const re =
|
|
224
|
+
const re = toGlobalRegExp(cp.pattern);
|
|
211
225
|
let m;
|
|
212
226
|
while ((m = re.exec(text)) !== null) {
|
|
227
|
+
if (m[0].length === 0) {
|
|
228
|
+
re.lastIndex++;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
213
231
|
detections.push({
|
|
214
232
|
pattern: cp.name,
|
|
215
233
|
category: cp.category ?? "custom",
|
|
@@ -332,4 +350,3 @@ export function createInjectionGuard(config) {
|
|
|
332
350
|
}
|
|
333
351
|
};
|
|
334
352
|
}
|
|
335
|
-
//# sourceMappingURL=prompt-injection-guard.js.map
|
package/dist/security/rbac.d.ts
CHANGED
package/dist/security/rbac.js
CHANGED
|
@@ -70,4 +70,3 @@ export declare function validateResolvedAddress(ip: string, originalHost: string
|
|
|
70
70
|
* this with `validateResolvedAddress` at the point of DNS resolution.
|
|
71
71
|
*/
|
|
72
72
|
export declare function validateUrlForTransport(url: string, options?: UrlGuardOptions): UrlGuardResult;
|
|
73
|
-
//# sourceMappingURL=url-guard.d.ts.map
|
|
@@ -38,8 +38,8 @@ function normalizeIpLiteral(host) {
|
|
|
38
38
|
}
|
|
39
39
|
// IPv6 hex — just lowercase it (no mixed notation expansion for simplicity)
|
|
40
40
|
if (host.includes(":")) {
|
|
41
|
-
// Basic validation:
|
|
42
|
-
if (/^[0-9a-fA-F
|
|
41
|
+
// Basic validation: hex groups, colons, and an optional embedded IPv4 tail
|
|
42
|
+
if (/^[0-9a-fA-F:.]+$/.test(host))
|
|
43
43
|
return host.toLowerCase();
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
@@ -134,37 +134,91 @@ function isMulticastIPv4(normalized) {
|
|
|
134
134
|
function isUnspecifiedIPv4(normalized) {
|
|
135
135
|
return normalized === "0.0.0.0";
|
|
136
136
|
}
|
|
137
|
+
/** Parse an IPv6 literal into eight 16-bit groups. */
|
|
138
|
+
function parseIPv6(value) {
|
|
139
|
+
let host = value.startsWith("[") && value.endsWith("]") ? value.slice(1, -1) : value;
|
|
140
|
+
if (host.includes("%"))
|
|
141
|
+
host = host.split("%")[0];
|
|
142
|
+
if (!host.includes(":"))
|
|
143
|
+
return null;
|
|
144
|
+
const doubleColon = host.indexOf("::");
|
|
145
|
+
if (doubleColon !== host.lastIndexOf("::"))
|
|
146
|
+
return null;
|
|
147
|
+
const parsePart = (part) => {
|
|
148
|
+
if (part.includes(".")) {
|
|
149
|
+
const octets = part.split(".");
|
|
150
|
+
if (octets.length !== 4 || !octets.every((part) => /^\d{1,3}$/.test(part)))
|
|
151
|
+
return null;
|
|
152
|
+
const numbers = octets.map(Number);
|
|
153
|
+
if (!numbers.every((part) => part >= 0 && part <= 255))
|
|
154
|
+
return null;
|
|
155
|
+
return [(numbers[0] << 8) | numbers[1], (numbers[2] << 8) | numbers[3]];
|
|
156
|
+
}
|
|
157
|
+
if (!/^[0-9a-f]{1,4}$/i.test(part))
|
|
158
|
+
return null;
|
|
159
|
+
return [parseInt(part, 16)];
|
|
160
|
+
};
|
|
161
|
+
const parseSide = (text) => {
|
|
162
|
+
if (!text)
|
|
163
|
+
return [];
|
|
164
|
+
const groups = [];
|
|
165
|
+
for (const part of text.split(":")) {
|
|
166
|
+
const parsed = parsePart(part);
|
|
167
|
+
if (parsed === null)
|
|
168
|
+
return null;
|
|
169
|
+
groups.push(...parsed);
|
|
170
|
+
}
|
|
171
|
+
return groups;
|
|
172
|
+
};
|
|
173
|
+
const leftText = doubleColon >= 0 ? host.slice(0, doubleColon) : host;
|
|
174
|
+
const rightText = doubleColon >= 0 ? host.slice(doubleColon + 2) : "";
|
|
175
|
+
const left = parseSide(leftText);
|
|
176
|
+
const right = parseSide(rightText);
|
|
177
|
+
if (left === null || right === null)
|
|
178
|
+
return null;
|
|
179
|
+
if (doubleColon < 0)
|
|
180
|
+
return left.length === 8 ? left : null;
|
|
181
|
+
const fill = 8 - left.length - right.length;
|
|
182
|
+
if (fill < 1)
|
|
183
|
+
return null;
|
|
184
|
+
return [...left, ...Array(fill).fill(0), ...right];
|
|
185
|
+
}
|
|
186
|
+
function isLoopbackIPv4(normalized) {
|
|
187
|
+
const first = Number(normalized.split(".")[0]);
|
|
188
|
+
return first === 127;
|
|
189
|
+
}
|
|
190
|
+
function isLoopbackIPv6(groups) {
|
|
191
|
+
return groups.slice(0, 7).every((group) => group === 0) && groups[7] === 1;
|
|
192
|
+
}
|
|
137
193
|
/**
|
|
138
|
-
* Check if an IPv6 address is :: (unspecified) or
|
|
194
|
+
* Check if an IPv6 address is :: (unspecified), loopback, or an IPv4-mapped
|
|
195
|
+
* address. Mapped and IPv4-compatible addresses must be checked as IPv4 too.
|
|
139
196
|
*/
|
|
140
197
|
function isSpecialIPv6(normalized) {
|
|
141
|
-
|
|
142
|
-
if (
|
|
198
|
+
const groups = parseIPv6(normalized);
|
|
199
|
+
if (!groups)
|
|
200
|
+
return false;
|
|
201
|
+
if (groups.every((group) => group === 0))
|
|
143
202
|
return true;
|
|
144
|
-
|
|
145
|
-
if (/^0{1,4}:0{1,4}:0{1,4}:0{1,4}:0{1,4}:ffff:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/.test(normalized)) {
|
|
203
|
+
if (isLoopbackIPv6(groups))
|
|
146
204
|
return true;
|
|
147
|
-
|
|
148
|
-
|
|
205
|
+
const mapped = groups.slice(0, 5).every((group) => group === 0) && groups[5] === 0xffff;
|
|
206
|
+
const compatible = groups.slice(0, 6).every((group) => group === 0) && groups[6] !== 0;
|
|
207
|
+
return mapped || compatible;
|
|
149
208
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
209
|
+
function isLinkLocalIPv6(normalized) {
|
|
210
|
+
const groups = parseIPv6(normalized);
|
|
211
|
+
return !!groups && groups[0] >= 0xfe80 && groups[0] <= 0xfebf;
|
|
212
|
+
}
|
|
213
|
+
/** Check if an IPv6 address is in a private or link-local range. */
|
|
154
214
|
function isPrivateIPv6(normalized) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
// fe80::/10 = fe80:: to febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff
|
|
158
|
-
const firstGroup = parseInt(normalized.split(":")[0], 16);
|
|
159
|
-
if (isNaN(firstGroup))
|
|
215
|
+
const groups = parseIPv6(normalized);
|
|
216
|
+
if (!groups)
|
|
160
217
|
return false;
|
|
161
|
-
|
|
162
|
-
if (
|
|
163
|
-
return true;
|
|
164
|
-
// fe80::/10: first two nibbles = fe, third nibble is 8-b → 0xfe80–0xfebf
|
|
165
|
-
if (firstGroup >= 0xfe80 && firstGroup <= 0xfebf)
|
|
218
|
+
const first = groups[0];
|
|
219
|
+
if (first >= 0xfc00 && first <= 0xfdff)
|
|
166
220
|
return true;
|
|
167
|
-
return
|
|
221
|
+
return isLinkLocalIPv6(normalized);
|
|
168
222
|
}
|
|
169
223
|
function isLocalhostish(host) {
|
|
170
224
|
if (LOOPBACK_HOSTS.has(host))
|
|
@@ -206,6 +260,9 @@ function checkHostSafety(host) {
|
|
|
206
260
|
if (isUnspecifiedIPv4(normalized)) {
|
|
207
261
|
return "address is unspecified (0.0.0.0)";
|
|
208
262
|
}
|
|
263
|
+
if (isLoopbackIPv4(normalized)) {
|
|
264
|
+
return "address is loopback";
|
|
265
|
+
}
|
|
209
266
|
if (isSpecialIPv6(normalized)) {
|
|
210
267
|
return "address is unspecified or IPv4-mapped IPv6";
|
|
211
268
|
}
|
|
@@ -229,7 +286,11 @@ function checkHostSafety(host) {
|
|
|
229
286
|
if (isPrivateIPv4(normalized)) {
|
|
230
287
|
return "private";
|
|
231
288
|
}
|
|
232
|
-
//
|
|
289
|
+
// Link-local IPv6 is never an allowable private-network opt-in.
|
|
290
|
+
if (isLinkLocalIPv6(normalized)) {
|
|
291
|
+
return "link-local";
|
|
292
|
+
}
|
|
293
|
+
// Private IPv6
|
|
233
294
|
if (isPrivateIPv6(normalized)) {
|
|
234
295
|
return "private";
|
|
235
296
|
}
|
|
@@ -276,8 +337,21 @@ export function validateBaseUrl(url, options = {}) {
|
|
|
276
337
|
};
|
|
277
338
|
}
|
|
278
339
|
const host = normalizeHostname(parsed.hostname.toLowerCase());
|
|
279
|
-
//
|
|
340
|
+
// Local targets require an explicit opt-in. Do not treat arbitrary .local
|
|
341
|
+
// names as safe merely because they use a non-standard mDNS suffix.
|
|
280
342
|
if (isLocalhostish(host)) {
|
|
343
|
+
if (!options.allowInsecure) {
|
|
344
|
+
return {
|
|
345
|
+
ok: false,
|
|
346
|
+
reason: `local hostname '${host}' requires allowInsecure: true`,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
if (host.endsWith(".local") && !options.allowPrivateNetwork) {
|
|
350
|
+
return {
|
|
351
|
+
ok: false,
|
|
352
|
+
reason: `.local hostname '${host}' requires allowPrivateNetwork: true`,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
281
355
|
return { ok: true };
|
|
282
356
|
}
|
|
283
357
|
// Hostname safety checks apply to BOTH http and https.
|
|
@@ -322,6 +396,9 @@ export function validateResolvedAddress(ip, originalHost) {
|
|
|
322
396
|
if (isUnspecifiedIPv4(normalized)) {
|
|
323
397
|
return { ok: false, reason: "resolved address is unspecified (0.0.0.0)" };
|
|
324
398
|
}
|
|
399
|
+
if (isLoopbackIPv4(normalized)) {
|
|
400
|
+
return { ok: false, reason: "resolved address is loopback" };
|
|
401
|
+
}
|
|
325
402
|
if (isSpecialIPv6(normalized)) {
|
|
326
403
|
return { ok: false, reason: "resolved address is unspecified or IPv4-mapped IPv6" };
|
|
327
404
|
}
|
|
@@ -355,10 +432,16 @@ export function validateResolvedAddress(ip, originalHost) {
|
|
|
355
432
|
reason: `resolved address ${ip} is in private network range`,
|
|
356
433
|
};
|
|
357
434
|
}
|
|
435
|
+
if (isLinkLocalIPv6(normalized)) {
|
|
436
|
+
return {
|
|
437
|
+
ok: false,
|
|
438
|
+
reason: `resolved address ${ip} is in link-local IPv6 range`,
|
|
439
|
+
};
|
|
440
|
+
}
|
|
358
441
|
if (isPrivateIPv6(normalized)) {
|
|
359
442
|
return {
|
|
360
443
|
ok: false,
|
|
361
|
-
reason: `resolved address ${ip} is in private
|
|
444
|
+
reason: `resolved address ${ip} is in private IPv6 range`,
|
|
362
445
|
};
|
|
363
446
|
}
|
|
364
447
|
return { ok: true };
|
|
@@ -380,4 +463,3 @@ export function validateResolvedAddress(ip, originalHost) {
|
|
|
380
463
|
export function validateUrlForTransport(url, options = {}) {
|
|
381
464
|
return validateBaseUrl(url, options);
|
|
382
465
|
}
|
|
383
|
-
//# sourceMappingURL=url-guard.js.map
|
|
@@ -45,11 +45,11 @@ export class BodyLogger {
|
|
|
45
45
|
if (!this._config.enabled)
|
|
46
46
|
return;
|
|
47
47
|
let bodyStr = typeof body === "string" ? body : JSON.stringify(body, null, 2);
|
|
48
|
+
if (this._config.redact)
|
|
49
|
+
bodyStr = redact(bodyStr);
|
|
48
50
|
if (bodyStr.length > this._config.maxBodyLength) {
|
|
49
51
|
bodyStr = bodyStr.slice(0, this._config.maxBodyLength) + "... [truncated]";
|
|
50
52
|
}
|
|
51
|
-
if (this._config.redact)
|
|
52
|
-
bodyStr = redact(bodyStr);
|
|
53
53
|
const entry = {
|
|
54
54
|
timestamp: new Date().toISOString(),
|
|
55
55
|
type: "request",
|
|
@@ -66,11 +66,11 @@ export class BodyLogger {
|
|
|
66
66
|
if (!this._config.enabled)
|
|
67
67
|
return;
|
|
68
68
|
let bodyStr = typeof body === "string" ? body : JSON.stringify(body, null, 2);
|
|
69
|
+
if (this._config.redact)
|
|
70
|
+
bodyStr = redact(bodyStr);
|
|
69
71
|
if (bodyStr.length > this._config.maxBodyLength) {
|
|
70
72
|
bodyStr = bodyStr.slice(0, this._config.maxBodyLength) + "... [truncated]";
|
|
71
73
|
}
|
|
72
|
-
if (this._config.redact)
|
|
73
|
-
bodyStr = redact(bodyStr);
|
|
74
74
|
const entry = {
|
|
75
75
|
timestamp: new Date().toISOString(),
|
|
76
76
|
type: "response",
|
|
@@ -96,9 +96,11 @@ export class BodyLogger {
|
|
|
96
96
|
}
|
|
97
97
|
/** Get all captured log entries */
|
|
98
98
|
getEntries(limit) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
const entries = limit ? this._entries.slice(-limit) : this._entries;
|
|
100
|
+
return entries.map((entry) => ({
|
|
101
|
+
...entry,
|
|
102
|
+
headers: entry.headers ? { ...entry.headers } : undefined,
|
|
103
|
+
}));
|
|
102
104
|
}
|
|
103
105
|
/** Clear all captured entries */
|
|
104
106
|
clear() {
|
|
@@ -109,12 +111,19 @@ export class BodyLogger {
|
|
|
109
111
|
return this._entries.length;
|
|
110
112
|
}
|
|
111
113
|
_addEntry(entry) {
|
|
112
|
-
|
|
114
|
+
const stored = {
|
|
115
|
+
...entry,
|
|
116
|
+
headers: entry.headers ? { ...entry.headers } : undefined,
|
|
117
|
+
};
|
|
118
|
+
this._entries.push(stored);
|
|
113
119
|
if (this._entries.length > this._maxEntries) {
|
|
114
120
|
this._entries = this._entries.slice(-this._maxEntries);
|
|
115
121
|
}
|
|
116
122
|
try {
|
|
117
|
-
this._config.destination(
|
|
123
|
+
this._config.destination({
|
|
124
|
+
...stored,
|
|
125
|
+
headers: stored.headers ? { ...stored.headers } : undefined,
|
|
126
|
+
});
|
|
118
127
|
}
|
|
119
128
|
catch {
|
|
120
129
|
// Swallow destination errors
|
|
@@ -137,4 +146,3 @@ function redactHeaders(headers) {
|
|
|
137
146
|
}
|
|
138
147
|
return redacted;
|
|
139
148
|
}
|
|
140
|
-
//# sourceMappingURL=body-logger.js.map
|
package/dist/telemetry/sla.d.ts
CHANGED
package/dist/telemetry/sla.js
CHANGED