@silmaril-security/sdk 0.10.2 → 0.11.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/CHANGELOG.md +17 -2
- package/README.md +4 -4
- package/dist/adapters/deepagents.d.cts +1 -1
- package/dist/adapters/deepagents.d.ts +1 -1
- package/dist/adapters/langchain.d.cts +1 -1
- package/dist/adapters/langchain.d.ts +1 -1
- package/dist/adapters/vercel-v4.d.cts +1 -1
- package/dist/adapters/vercel-v4.d.ts +1 -1
- package/dist/adapters/vercel.d.cts +1 -1
- package/dist/adapters/vercel.d.ts +1 -1
- package/dist/{firewall-BXM2BWEr.d.cts → firewall-BD4YdAmB.d.cts} +4 -4
- package/dist/{firewall-BXM2BWEr.d.ts → firewall-BD4YdAmB.d.ts} +4 -4
- package/dist/index.cjs +21 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +21 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HookLabel, B as BlockResult, R as ReviewLevel } from './firewall-
|
|
2
|
-
export { A as ALL_HOOKS, C as ClassificationMetadata, a as ClassifyBatchOptions, b as ClassifyEvent, c as ClassifyOptions, D as DEFAULT_HOOKS, d as DEFAULT_TIMEOUT_MS, F as FIREWALL_HOOK_TO_LABEL, e as Firewall, f as FirewallHook, g as FirewallMiddleware, h as FirewallMode, i as FirewallOptions, G as GovernanceAction, j as GovernanceContext, k as GovernanceDecision, l as GovernanceResource, m as GovernanceResourceKind, n as HARMFUL_OUTCOMES, o as HarmfulOutcome, I as INPUT_HOOKS, K as KnownHarmfulOutcome, p as KnownPrimaryOutcome, L as LangChainAdapterOptions, q as LangChainFirewallHandler, M as MiddlewareOptions, O as OUTCOME_DESCRIPTIONS, r as OUTPUT_HOOKS, s as Outcome, P as PRIMARY_OUTCOMES, t as Prediction, u as PrimaryOutcome, v as ProtectOptions, U as UnknownOutcome, w as isHarmfulOutcome, x as isPrimaryOutcome, y as normalizeHarmfulOutcome, z as normalizeHarmfulOutcomeMap, E as normalizePrimaryOutcome, J as prependHook, N as prependToolName, Q as resolveHooks } from './firewall-
|
|
1
|
+
import { H as HookLabel, B as BlockResult, R as ReviewLevel } from './firewall-BD4YdAmB.cjs';
|
|
2
|
+
export { A as ALL_HOOKS, C as ClassificationMetadata, a as ClassifyBatchOptions, b as ClassifyEvent, c as ClassifyOptions, D as DEFAULT_HOOKS, d as DEFAULT_TIMEOUT_MS, F as FIREWALL_HOOK_TO_LABEL, e as Firewall, f as FirewallHook, g as FirewallMiddleware, h as FirewallMode, i as FirewallOptions, G as GovernanceAction, j as GovernanceContext, k as GovernanceDecision, l as GovernanceResource, m as GovernanceResourceKind, n as HARMFUL_OUTCOMES, o as HarmfulOutcome, I as INPUT_HOOKS, K as KnownHarmfulOutcome, p as KnownPrimaryOutcome, L as LangChainAdapterOptions, q as LangChainFirewallHandler, M as MiddlewareOptions, O as OUTCOME_DESCRIPTIONS, r as OUTPUT_HOOKS, s as Outcome, P as PRIMARY_OUTCOMES, t as Prediction, u as PrimaryOutcome, v as ProtectOptions, U as UnknownOutcome, w as isHarmfulOutcome, x as isPrimaryOutcome, y as normalizeHarmfulOutcome, z as normalizeHarmfulOutcomeMap, E as normalizePrimaryOutcome, J as prependHook, N as prependToolName, Q as resolveHooks } from './firewall-BD4YdAmB.cjs';
|
|
3
3
|
|
|
4
4
|
interface MalformedInputDetails {
|
|
5
5
|
field?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HookLabel, B as BlockResult, R as ReviewLevel } from './firewall-
|
|
2
|
-
export { A as ALL_HOOKS, C as ClassificationMetadata, a as ClassifyBatchOptions, b as ClassifyEvent, c as ClassifyOptions, D as DEFAULT_HOOKS, d as DEFAULT_TIMEOUT_MS, F as FIREWALL_HOOK_TO_LABEL, e as Firewall, f as FirewallHook, g as FirewallMiddleware, h as FirewallMode, i as FirewallOptions, G as GovernanceAction, j as GovernanceContext, k as GovernanceDecision, l as GovernanceResource, m as GovernanceResourceKind, n as HARMFUL_OUTCOMES, o as HarmfulOutcome, I as INPUT_HOOKS, K as KnownHarmfulOutcome, p as KnownPrimaryOutcome, L as LangChainAdapterOptions, q as LangChainFirewallHandler, M as MiddlewareOptions, O as OUTCOME_DESCRIPTIONS, r as OUTPUT_HOOKS, s as Outcome, P as PRIMARY_OUTCOMES, t as Prediction, u as PrimaryOutcome, v as ProtectOptions, U as UnknownOutcome, w as isHarmfulOutcome, x as isPrimaryOutcome, y as normalizeHarmfulOutcome, z as normalizeHarmfulOutcomeMap, E as normalizePrimaryOutcome, J as prependHook, N as prependToolName, Q as resolveHooks } from './firewall-
|
|
1
|
+
import { H as HookLabel, B as BlockResult, R as ReviewLevel } from './firewall-BD4YdAmB.js';
|
|
2
|
+
export { A as ALL_HOOKS, C as ClassificationMetadata, a as ClassifyBatchOptions, b as ClassifyEvent, c as ClassifyOptions, D as DEFAULT_HOOKS, d as DEFAULT_TIMEOUT_MS, F as FIREWALL_HOOK_TO_LABEL, e as Firewall, f as FirewallHook, g as FirewallMiddleware, h as FirewallMode, i as FirewallOptions, G as GovernanceAction, j as GovernanceContext, k as GovernanceDecision, l as GovernanceResource, m as GovernanceResourceKind, n as HARMFUL_OUTCOMES, o as HarmfulOutcome, I as INPUT_HOOKS, K as KnownHarmfulOutcome, p as KnownPrimaryOutcome, L as LangChainAdapterOptions, q as LangChainFirewallHandler, M as MiddlewareOptions, O as OUTCOME_DESCRIPTIONS, r as OUTPUT_HOOKS, s as Outcome, P as PRIMARY_OUTCOMES, t as Prediction, u as PrimaryOutcome, v as ProtectOptions, U as UnknownOutcome, w as isHarmfulOutcome, x as isPrimaryOutcome, y as normalizeHarmfulOutcome, z as normalizeHarmfulOutcomeMap, E as normalizePrimaryOutcome, J as prependHook, N as prependToolName, Q as resolveHooks } from './firewall-BD4YdAmB.js';
|
|
3
3
|
|
|
4
4
|
interface MalformedInputDetails {
|
|
5
5
|
field?: string;
|
package/dist/index.js
CHANGED
|
@@ -1380,6 +1380,18 @@ init_exceptions();
|
|
|
1380
1380
|
init_hooks();
|
|
1381
1381
|
init_modes();
|
|
1382
1382
|
|
|
1383
|
+
// src/validation.ts
|
|
1384
|
+
var PYTHON_NONBLANK = /[^\p{White_Space}\u001c-\u001f]/u;
|
|
1385
|
+
function isPythonNonblankString(value) {
|
|
1386
|
+
return typeof value === "string" && PYTHON_NONBLANK.test(value);
|
|
1387
|
+
}
|
|
1388
|
+
function validateThreshold(name, value) {
|
|
1389
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > 1) {
|
|
1390
|
+
throw new Error(`Firewall: ${name} must be a finite number between 0 and 1`);
|
|
1391
|
+
}
|
|
1392
|
+
return value;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1383
1395
|
// src/outcomes.ts
|
|
1384
1396
|
var Outcome = {
|
|
1385
1397
|
Benign: "benign",
|
|
@@ -1392,7 +1404,7 @@ var Outcome = {
|
|
|
1392
1404
|
StoryScriptGeneration: "story_script_generation",
|
|
1393
1405
|
GameGeneration: "game_generation",
|
|
1394
1406
|
WebsiteGeneration: "website_generation",
|
|
1395
|
-
|
|
1407
|
+
Abuse: "abuse",
|
|
1396
1408
|
TraditionalAiAbuse: "traditional_ai_abuse"
|
|
1397
1409
|
};
|
|
1398
1410
|
var PRIMARY_OUTCOMES = [
|
|
@@ -1406,7 +1418,7 @@ var PRIMARY_OUTCOMES = [
|
|
|
1406
1418
|
Outcome.StoryScriptGeneration,
|
|
1407
1419
|
Outcome.GameGeneration,
|
|
1408
1420
|
Outcome.WebsiteGeneration,
|
|
1409
|
-
Outcome.
|
|
1421
|
+
Outcome.Abuse,
|
|
1410
1422
|
Outcome.TraditionalAiAbuse
|
|
1411
1423
|
];
|
|
1412
1424
|
var HARMFUL_OUTCOMES = [
|
|
@@ -1419,7 +1431,7 @@ var HARMFUL_OUTCOMES = [
|
|
|
1419
1431
|
Outcome.StoryScriptGeneration,
|
|
1420
1432
|
Outcome.GameGeneration,
|
|
1421
1433
|
Outcome.WebsiteGeneration,
|
|
1422
|
-
Outcome.
|
|
1434
|
+
Outcome.Abuse,
|
|
1423
1435
|
Outcome.TraditionalAiAbuse
|
|
1424
1436
|
];
|
|
1425
1437
|
var OUTCOME_DESCRIPTIONS = {
|
|
@@ -1433,15 +1445,11 @@ var OUTCOME_DESCRIPTIONS = {
|
|
|
1433
1445
|
[Outcome.StoryScriptGeneration]: "Requests generation of narrative prose, dialogue, scripts, or story artifacts.",
|
|
1434
1446
|
[Outcome.GameGeneration]: "Requests generation of a game, quest, level, mechanic, or playable experience.",
|
|
1435
1447
|
[Outcome.WebsiteGeneration]: "Requests generation of a website, landing page, storefront, or web experience.",
|
|
1436
|
-
[Outcome.
|
|
1448
|
+
[Outcome.Abuse]: "Requests content or actions that violate the tenant's acceptable-use policy.",
|
|
1437
1449
|
[Outcome.TraditionalAiAbuse]: "Requests unsafe AI assistance outside the concrete security outcome classes."
|
|
1438
1450
|
};
|
|
1439
1451
|
var PRIMARY_OUTCOME_SET = new Set(PRIMARY_OUTCOMES);
|
|
1440
1452
|
var HARMFUL_OUTCOME_SET = new Set(HARMFUL_OUTCOMES);
|
|
1441
|
-
var PYTHON_NONBLANK = /[^\p{White_Space}\u001c-\u001f]/u;
|
|
1442
|
-
function isNonblankOutcomeLabel(value) {
|
|
1443
|
-
return typeof value === "string" && PYTHON_NONBLANK.test(value);
|
|
1444
|
-
}
|
|
1445
1453
|
function isPrimaryOutcome(value) {
|
|
1446
1454
|
return typeof value === "string" && PRIMARY_OUTCOME_SET.has(value);
|
|
1447
1455
|
}
|
|
@@ -1449,13 +1457,13 @@ function isHarmfulOutcome(value) {
|
|
|
1449
1457
|
return typeof value === "string" && HARMFUL_OUTCOME_SET.has(value);
|
|
1450
1458
|
}
|
|
1451
1459
|
function normalizePrimaryOutcome(value, fieldName = "primary_outcome") {
|
|
1452
|
-
if (!
|
|
1460
|
+
if (!isPythonNonblankString(value)) {
|
|
1453
1461
|
throw new Error(`Firewall: invalid ${fieldName} ${JSON.stringify(value)}`);
|
|
1454
1462
|
}
|
|
1455
1463
|
return isPrimaryOutcome(value) ? value : value;
|
|
1456
1464
|
}
|
|
1457
1465
|
function normalizeHarmfulOutcome(value, fieldName = "outcome") {
|
|
1458
|
-
if (!
|
|
1466
|
+
if (!isPythonNonblankString(value) || value === Outcome.Benign) {
|
|
1459
1467
|
throw new Error(`Firewall: invalid ${fieldName} ${JSON.stringify(value)}`);
|
|
1460
1468
|
}
|
|
1461
1469
|
return isHarmfulOutcome(value) ? value : value;
|
|
@@ -1518,16 +1526,8 @@ function sanitizeText(text) {
|
|
|
1518
1526
|
return out;
|
|
1519
1527
|
}
|
|
1520
1528
|
|
|
1521
|
-
// src/validation.ts
|
|
1522
|
-
function validateThreshold(name, value) {
|
|
1523
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > 1) {
|
|
1524
|
-
throw new Error(`Firewall: ${name} must be a finite number between 0 and 1`);
|
|
1525
|
-
}
|
|
1526
|
-
return value;
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
1529
|
// src/firewall.ts
|
|
1530
|
-
var SDK_VERSION = "0.
|
|
1530
|
+
var SDK_VERSION = "0.11.0";
|
|
1531
1531
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
1532
1532
|
var DEFAULT_MAX_RETRIES = 5;
|
|
1533
1533
|
var MAX_BACKOFF_SECONDS = 30;
|
|
@@ -1734,12 +1734,12 @@ function governanceDecisionFromResponse(value) {
|
|
|
1734
1734
|
if (value.rule_id !== void 0 && value.rule_id !== null && typeof value.rule_id !== "string") {
|
|
1735
1735
|
throw new Error("Firewall: response governance rule_id must be a string when provided");
|
|
1736
1736
|
}
|
|
1737
|
-
if (value.identity_revision !== void 0 && value.identity_revision !== null && (
|
|
1737
|
+
if (value.identity_revision !== void 0 && value.identity_revision !== null && !isPythonNonblankString(value.identity_revision)) {
|
|
1738
1738
|
throw new Error(
|
|
1739
1739
|
"Firewall: response governance identity_revision must be a non-empty string when provided"
|
|
1740
1740
|
);
|
|
1741
1741
|
}
|
|
1742
|
-
if (value.reason !== void 0 && value.reason !== null && (
|
|
1742
|
+
if (value.reason !== void 0 && value.reason !== null && !isPythonNonblankString(value.reason)) {
|
|
1743
1743
|
throw new Error(
|
|
1744
1744
|
"Firewall: response governance reason must be a non-empty string when provided"
|
|
1745
1745
|
);
|