ai-sdk-guardrails 5.2.0 → 5.3.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/dist/index.cjs +10 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -0
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -90,7 +90,10 @@ __export(index_exports, {
|
|
|
90
90
|
executeOutputGuardrails: () => executeOutputGuardrails,
|
|
91
91
|
expectedToolUse: () => expectedToolUse,
|
|
92
92
|
exponentialBackoff: () => exponentialBackoff,
|
|
93
|
+
extractContent: () => extractContent,
|
|
93
94
|
extractErrorInfo: () => extractErrorInfo,
|
|
95
|
+
extractMetadata: () => extractMetadata,
|
|
96
|
+
extractTextContent: () => extractTextContent,
|
|
94
97
|
factualAccuracyChecker: () => factualAccuracyChecker,
|
|
95
98
|
fixedBackoff: () => fixedBackoff,
|
|
96
99
|
getGuardrailFinishReason: () => getGuardrailFinishReason,
|
|
@@ -110,6 +113,7 @@ __export(index_exports, {
|
|
|
110
113
|
minLengthRequirement: () => minLengthRequirement,
|
|
111
114
|
noBackoff: () => noBackoff,
|
|
112
115
|
normalizeGuardrailContext: () => normalizeGuardrailContext,
|
|
116
|
+
normalizeUsage: () => normalizeUsage,
|
|
113
117
|
outputLengthLimit: () => outputLengthLimit,
|
|
114
118
|
performanceMonitor: () => performanceMonitor,
|
|
115
119
|
piiDetector: () => piiDetector,
|
|
@@ -128,6 +132,7 @@ __export(index_exports, {
|
|
|
128
132
|
secretRedaction: () => secretRedaction,
|
|
129
133
|
sensitiveDataFilter: () => sensitiveDataFilter,
|
|
130
134
|
specificGuardrailViolated: () => specificGuardrailViolated,
|
|
135
|
+
stringifyContent: () => stringifyContent,
|
|
131
136
|
tokenUsageLimit: () => tokenUsageLimit,
|
|
132
137
|
toolEgressPolicy: () => toolEgressPolicy,
|
|
133
138
|
toxicityDetector: () => toxicityDetector,
|
|
@@ -7844,7 +7849,10 @@ function mapOpenAIConfigToGuardrails(openAIConfig) {
|
|
|
7844
7849
|
executeOutputGuardrails,
|
|
7845
7850
|
expectedToolUse,
|
|
7846
7851
|
exponentialBackoff,
|
|
7852
|
+
extractContent,
|
|
7847
7853
|
extractErrorInfo,
|
|
7854
|
+
extractMetadata,
|
|
7855
|
+
extractTextContent,
|
|
7848
7856
|
factualAccuracyChecker,
|
|
7849
7857
|
fixedBackoff,
|
|
7850
7858
|
getGuardrailFinishReason,
|
|
@@ -7864,6 +7872,7 @@ function mapOpenAIConfigToGuardrails(openAIConfig) {
|
|
|
7864
7872
|
minLengthRequirement,
|
|
7865
7873
|
noBackoff,
|
|
7866
7874
|
normalizeGuardrailContext,
|
|
7875
|
+
normalizeUsage,
|
|
7867
7876
|
outputLengthLimit,
|
|
7868
7877
|
performanceMonitor,
|
|
7869
7878
|
piiDetector,
|
|
@@ -7882,6 +7891,7 @@ function mapOpenAIConfigToGuardrails(openAIConfig) {
|
|
|
7882
7891
|
secretRedaction,
|
|
7883
7892
|
sensitiveDataFilter,
|
|
7884
7893
|
specificGuardrailViolated,
|
|
7894
|
+
stringifyContent,
|
|
7885
7895
|
tokenUsageLimit,
|
|
7886
7896
|
toolEgressPolicy,
|
|
7887
7897
|
toxicityDetector,
|
package/dist/index.d.cts
CHANGED
|
@@ -2,8 +2,8 @@ import { I as InputGuardrail, O as OutputGuardrail, L as Logger, G as GuardrailE
|
|
|
2
2
|
export { A as AIResult, p as EmbedParams, u as EmbedResult, E as ExtractGuardrailMetadata, n as GenerateObjectParams, r as GenerateObjectResult, m as GenerateTextParams, q as GenerateTextResult, x as GuardrailConfig, v as GuardrailRetryConfig, j as GuardrailsParams, k as InferInputMetadata, l as InferOutputMetadata, w as RetryInstruction, R as RetryInstructionContext, o as StreamObjectParams, t as StreamObjectResult, S as StreamTextParams, s as StreamTextResult, U as UnionFromGuardrails } from './types-bXg_qgtZ.cjs';
|
|
3
3
|
import { LanguageModelV2CallOptions, LanguageModelV2, LanguageModelV2Middleware } from '@ai-sdk/provider';
|
|
4
4
|
export { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Middleware, LanguageModelV2StreamPart } from '@ai-sdk/provider';
|
|
5
|
-
export { biasDetector, blockedContent, complianceChecker, confidenceThreshold, contentConsistencyChecker, costQuotaRails, customValidation, enhancedHallucinationDetector, factualAccuracyChecker, hallucinationDetector, jsonValidation, minLengthRequirement, outputLengthLimit, performanceMonitor, privacyLeakageDetector, retryAfterIntegration, schemaValidation, secretRedaction, sensitiveDataFilter, tokenUsageLimit, toxicityFilter, unsafeContentDetector } from './guardrails/output.cjs';
|
|
6
|
-
export { AllowedToolsOptions, allowedToolsGuardrail, blockedKeywords, blockedWords, codeGenerationLimiter, contentLengthLimit, customValidation as customInputValidation, lengthLimit as inputLengthLimit, mathHomeworkDetector, piiDetector, profanityFilter, promptInjectionDetector, rateLimiting, toxicityDetector } from './guardrails/input.cjs';
|
|
5
|
+
export { NormalizedUsage, biasDetector, blockedContent, complianceChecker, confidenceThreshold, contentConsistencyChecker, costQuotaRails, customValidation, enhancedHallucinationDetector, extractContent, factualAccuracyChecker, hallucinationDetector, jsonValidation, minLengthRequirement, normalizeUsage, outputLengthLimit, performanceMonitor, privacyLeakageDetector, retryAfterIntegration, schemaValidation, secretRedaction, sensitiveDataFilter, stringifyContent, tokenUsageLimit, toxicityFilter, unsafeContentDetector } from './guardrails/output.cjs';
|
|
6
|
+
export { AllowedToolsOptions, BlockedWordsOptions, CodeGenerationMode, CodeGenerationOptions, CustomValidationInput, CustomValidationOptions, CustomValidationResult, LengthLimitOptions, MathHomeworkOptions, ProfanityCategory, ProfanityFilterOptions, PromptInjectionOptions, RateLimitingOptions, allowedToolsGuardrail, blockedKeywords, blockedWords, codeGenerationLimiter, contentLengthLimit, customValidation as customInputValidation, extractMetadata, extractTextContent, lengthLimit as inputLengthLimit, mathHomeworkDetector, piiDetector, profanityFilter, promptInjectionDetector, rateLimiting, toxicityDetector } from './guardrails/input.cjs';
|
|
7
7
|
export { ExpectedToolUseMetadata, ExpectedToolUseOptions, ToolEgressPolicyOptions, expectedToolUse, toolEgressPolicy } from './guardrails/tools.cjs';
|
|
8
8
|
import { ToolSet, Experimental_AgentSettings, Experimental_Agent } from 'ai';
|
|
9
9
|
import { z } from 'zod';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { I as InputGuardrail, O as OutputGuardrail, L as Logger, G as GuardrailE
|
|
|
2
2
|
export { A as AIResult, p as EmbedParams, u as EmbedResult, E as ExtractGuardrailMetadata, n as GenerateObjectParams, r as GenerateObjectResult, m as GenerateTextParams, q as GenerateTextResult, x as GuardrailConfig, v as GuardrailRetryConfig, j as GuardrailsParams, k as InferInputMetadata, l as InferOutputMetadata, w as RetryInstruction, R as RetryInstructionContext, o as StreamObjectParams, t as StreamObjectResult, S as StreamTextParams, s as StreamTextResult, U as UnionFromGuardrails } from './types-bXg_qgtZ.js';
|
|
3
3
|
import { LanguageModelV2CallOptions, LanguageModelV2, LanguageModelV2Middleware } from '@ai-sdk/provider';
|
|
4
4
|
export { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Middleware, LanguageModelV2StreamPart } from '@ai-sdk/provider';
|
|
5
|
-
export { biasDetector, blockedContent, complianceChecker, confidenceThreshold, contentConsistencyChecker, costQuotaRails, customValidation, enhancedHallucinationDetector, factualAccuracyChecker, hallucinationDetector, jsonValidation, minLengthRequirement, outputLengthLimit, performanceMonitor, privacyLeakageDetector, retryAfterIntegration, schemaValidation, secretRedaction, sensitiveDataFilter, tokenUsageLimit, toxicityFilter, unsafeContentDetector } from './guardrails/output.js';
|
|
6
|
-
export { AllowedToolsOptions, allowedToolsGuardrail, blockedKeywords, blockedWords, codeGenerationLimiter, contentLengthLimit, customValidation as customInputValidation, lengthLimit as inputLengthLimit, mathHomeworkDetector, piiDetector, profanityFilter, promptInjectionDetector, rateLimiting, toxicityDetector } from './guardrails/input.js';
|
|
5
|
+
export { NormalizedUsage, biasDetector, blockedContent, complianceChecker, confidenceThreshold, contentConsistencyChecker, costQuotaRails, customValidation, enhancedHallucinationDetector, extractContent, factualAccuracyChecker, hallucinationDetector, jsonValidation, minLengthRequirement, normalizeUsage, outputLengthLimit, performanceMonitor, privacyLeakageDetector, retryAfterIntegration, schemaValidation, secretRedaction, sensitiveDataFilter, stringifyContent, tokenUsageLimit, toxicityFilter, unsafeContentDetector } from './guardrails/output.js';
|
|
6
|
+
export { AllowedToolsOptions, BlockedWordsOptions, CodeGenerationMode, CodeGenerationOptions, CustomValidationInput, CustomValidationOptions, CustomValidationResult, LengthLimitOptions, MathHomeworkOptions, ProfanityCategory, ProfanityFilterOptions, PromptInjectionOptions, RateLimitingOptions, allowedToolsGuardrail, blockedKeywords, blockedWords, codeGenerationLimiter, contentLengthLimit, customValidation as customInputValidation, extractMetadata, extractTextContent, lengthLimit as inputLengthLimit, mathHomeworkDetector, piiDetector, profanityFilter, promptInjectionDetector, rateLimiting, toxicityDetector } from './guardrails/input.js';
|
|
7
7
|
export { ExpectedToolUseMetadata, ExpectedToolUseOptions, ToolEgressPolicyOptions, expectedToolUse, toolEgressPolicy } from './guardrails/tools.js';
|
|
8
8
|
import { ToolSet, Experimental_AgentSettings, Experimental_Agent } from 'ai';
|
|
9
9
|
import { z } from 'zod';
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
codeGenerationLimiter,
|
|
6
6
|
contentLengthLimit,
|
|
7
7
|
customValidation as customValidation2,
|
|
8
|
+
extractMetadata,
|
|
8
9
|
extractTextContent,
|
|
9
10
|
lengthLimit,
|
|
10
11
|
mathHomeworkDetector,
|
|
@@ -32,6 +33,7 @@ import {
|
|
|
32
33
|
hallucinationDetector,
|
|
33
34
|
jsonValidation,
|
|
34
35
|
minLengthRequirement,
|
|
36
|
+
normalizeUsage,
|
|
35
37
|
outputLengthLimit,
|
|
36
38
|
performanceMonitor,
|
|
37
39
|
privacyLeakageDetector,
|
|
@@ -39,6 +41,7 @@ import {
|
|
|
39
41
|
schemaValidation,
|
|
40
42
|
secretRedaction,
|
|
41
43
|
sensitiveDataFilter,
|
|
44
|
+
stringifyContent,
|
|
42
45
|
tokenUsageLimit,
|
|
43
46
|
toxicityFilter,
|
|
44
47
|
unsafeContentDetector
|
|
@@ -4460,7 +4463,10 @@ export {
|
|
|
4460
4463
|
executeOutputGuardrails,
|
|
4461
4464
|
expectedToolUse,
|
|
4462
4465
|
exponentialBackoff,
|
|
4466
|
+
extractContent,
|
|
4463
4467
|
extractErrorInfo,
|
|
4468
|
+
extractMetadata,
|
|
4469
|
+
extractTextContent,
|
|
4464
4470
|
factualAccuracyChecker,
|
|
4465
4471
|
fixedBackoff,
|
|
4466
4472
|
getGuardrailFinishReason,
|
|
@@ -4480,6 +4486,7 @@ export {
|
|
|
4480
4486
|
minLengthRequirement,
|
|
4481
4487
|
noBackoff,
|
|
4482
4488
|
normalizeGuardrailContext,
|
|
4489
|
+
normalizeUsage,
|
|
4483
4490
|
outputLengthLimit,
|
|
4484
4491
|
performanceMonitor,
|
|
4485
4492
|
piiDetector,
|
|
@@ -4498,6 +4505,7 @@ export {
|
|
|
4498
4505
|
secretRedaction,
|
|
4499
4506
|
sensitiveDataFilter,
|
|
4500
4507
|
specificGuardrailViolated,
|
|
4508
|
+
stringifyContent,
|
|
4501
4509
|
tokenUsageLimit,
|
|
4502
4510
|
toolEgressPolicy,
|
|
4503
4511
|
toxicityDetector,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-sdk-guardrails",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "Input and output guardrails middleware for Vercel AI SDK.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@ai-sdk/groq": "^2.0.32",
|
|
70
70
|
"@ai-sdk/mistral": "2.0.25",
|
|
71
|
-
"@ai-sdk/openai": "2.0.
|
|
71
|
+
"@ai-sdk/openai": "2.0.74",
|
|
72
72
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
73
73
|
"@eslint/js": "^9.39.1",
|
|
74
74
|
"@opentelemetry/api": "^1.9.0",
|
|
@@ -77,16 +77,16 @@
|
|
|
77
77
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
78
78
|
"@types/node": "^24.10.1",
|
|
79
79
|
"@typescript-eslint/eslint-plugin": "^8.48.0",
|
|
80
|
-
"@typescript-eslint/parser": "^8.
|
|
80
|
+
"@typescript-eslint/parser": "^8.48.0",
|
|
81
81
|
"eslint": "^9.39.1",
|
|
82
82
|
"eslint-config-prettier": "^10.1.8",
|
|
83
83
|
"eslint-plugin-unicorn": "^62.0.0",
|
|
84
84
|
"globals": "^16.5.0",
|
|
85
|
-
"prettier": "^3.7.
|
|
85
|
+
"prettier": "^3.7.2",
|
|
86
86
|
"tsup": "^8.5.1",
|
|
87
87
|
"tsx": "^4.20.6",
|
|
88
88
|
"typescript": "^5.9.3",
|
|
89
|
-
"typescript-eslint": "^8.
|
|
89
|
+
"typescript-eslint": "^8.48.0",
|
|
90
90
|
"vitest": "^4.0.14"
|
|
91
91
|
},
|
|
92
92
|
"scripts": {
|