@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.11.0
|
|
4
|
+
|
|
5
|
+
- Breaking: rename the tenant acceptable-use policy outcome to `abuse`.
|
|
6
|
+
`Outcome.Abuse` replaces the tenant-specific member, and
|
|
7
|
+
`KnownPrimaryOutcome`, `KnownHarmfulOutcome`, `PRIMARY_OUTCOMES`,
|
|
8
|
+
`HARMFUL_OUTCOMES`, and `OUTCOME_DESCRIPTIONS` list `abuse` in the same
|
|
9
|
+
position. Responses that still carry the previous label continue to decode
|
|
10
|
+
as an `UnknownOutcome` string.
|
|
11
|
+
|
|
12
|
+
## 0.10.3
|
|
13
|
+
|
|
14
|
+
- Match Python `str.strip()` when validating optional governance
|
|
15
|
+
`identity_revision` and `reason` evidence. Omitted and null values remain
|
|
16
|
+
compatible, and accepted nonblank strings remain unmodified.
|
|
17
|
+
|
|
3
18
|
## 0.10.2
|
|
4
19
|
|
|
5
20
|
- Reject blank and Python-whitespace-only primary outcome labels and harmful
|
|
@@ -248,8 +263,8 @@ All notable changes to the Silmaril Firewall TypeScript SDK are documented here.
|
|
|
248
263
|
## 0.5.1 - 2026-07-29
|
|
249
264
|
|
|
250
265
|
- Add typed support for `code_generation`, `story_script_generation`,
|
|
251
|
-
`game_generation`, `website_generation`, `
|
|
252
|
-
`
|
|
266
|
+
`game_generation`, `website_generation`, `traditional_ai_abuse`, and the
|
|
267
|
+
tenant acceptable-use policy outcome now named `abuse`.
|
|
253
268
|
- Extend ordered outcome collections, descriptions, guards, normalization
|
|
254
269
|
fixtures, exports, and documentation without changing the `/classify` wire
|
|
255
270
|
shape.
|
package/README.md
CHANGED
|
@@ -35,10 +35,10 @@ This SDK is distributed as an npm package.
|
|
|
35
35
|
npm install @silmaril-security/sdk
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
Pin version 0.
|
|
38
|
+
Pin version 0.11.0 for reproducible installs:
|
|
39
39
|
|
|
40
40
|
```sh
|
|
41
|
-
npm install @silmaril-security/sdk@0.
|
|
41
|
+
npm install @silmaril-security/sdk@0.11.0
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
Requires Node 20 or later.
|
|
@@ -262,7 +262,7 @@ if (result.prediction === "BENIGN") {
|
|
|
262
262
|
case Outcome.StoryScriptGeneration:
|
|
263
263
|
case Outcome.GameGeneration:
|
|
264
264
|
case Outcome.WebsiteGeneration:
|
|
265
|
-
case Outcome.
|
|
265
|
+
case Outcome.Abuse:
|
|
266
266
|
case Outcome.TraditionalAiAbuse:
|
|
267
267
|
applyTenantPolicy(result);
|
|
268
268
|
break;
|
|
@@ -284,7 +284,7 @@ Outcome taxonomy:
|
|
|
284
284
|
- `story_script_generation`: generation of narrative prose, dialogue, scripts, or story artifacts.
|
|
285
285
|
- `game_generation`: generation of a game, quest, level, mechanic, or playable experience.
|
|
286
286
|
- `website_generation`: generation of a website, landing page, storefront, or web experience.
|
|
287
|
-
- `
|
|
287
|
+
- `abuse`: content or actions that violate the tenant's acceptable-use policy.
|
|
288
288
|
- `traditional_ai_abuse`: unsafe AI assistance outside the concrete security outcome classes.
|
|
289
289
|
|
|
290
290
|
## Options
|
|
@@ -13,7 +13,7 @@ import * as langchain from 'langchain';
|
|
|
13
13
|
import { CreateAgentParams } from 'langchain';
|
|
14
14
|
import * as _langchain_core_tools from '@langchain/core/tools';
|
|
15
15
|
import { StructuredTool } from '@langchain/core/tools';
|
|
16
|
-
import { h as FirewallMode, b as ClassifyEvent, e as Firewall } from '../firewall-
|
|
16
|
+
import { h as FirewallMode, b as ClassifyEvent, e as Firewall } from '../firewall-BD4YdAmB.cjs';
|
|
17
17
|
|
|
18
18
|
declare const SAFE_TOOL_MESSAGE = "Silmaril Firewall blocked this tool interaction. Choose a different safe action.";
|
|
19
19
|
declare const SAFE_FINAL_MESSAGE = "Silmaril Firewall stopped this request after repeated unsafe actions.";
|
|
@@ -13,7 +13,7 @@ import * as langchain from 'langchain';
|
|
|
13
13
|
import { CreateAgentParams } from 'langchain';
|
|
14
14
|
import * as _langchain_core_tools from '@langchain/core/tools';
|
|
15
15
|
import { StructuredTool } from '@langchain/core/tools';
|
|
16
|
-
import { h as FirewallMode, b as ClassifyEvent, e as Firewall } from '../firewall-
|
|
16
|
+
import { h as FirewallMode, b as ClassifyEvent, e as Firewall } from '../firewall-BD4YdAmB.js';
|
|
17
17
|
|
|
18
18
|
declare const SAFE_TOOL_MESSAGE = "Silmaril Firewall blocked this tool interaction. Choose a different safe action.";
|
|
19
19
|
declare const SAFE_FINAL_MESSAGE = "Silmaril Firewall stopped this request after repeated unsafe actions.";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RunnableConfig, Runnable, RunnableBinding } from '@langchain/core/runnables';
|
|
2
2
|
import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
|
|
3
|
-
import { e as Firewall, L as LangChainAdapterOptions } from '../firewall-
|
|
3
|
+
import { e as Firewall, L as LangChainAdapterOptions } from '../firewall-BD4YdAmB.cjs';
|
|
4
4
|
|
|
5
5
|
declare function createLangChainHandler(firewall: Firewall, options?: LangChainAdapterOptions): Promise<BaseCallbackHandler>;
|
|
6
6
|
/** Protect a runnable using its actual invocation config, including direct model/tool calls. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RunnableConfig, Runnable, RunnableBinding } from '@langchain/core/runnables';
|
|
2
2
|
import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
|
|
3
|
-
import { e as Firewall, L as LangChainAdapterOptions } from '../firewall-
|
|
3
|
+
import { e as Firewall, L as LangChainAdapterOptions } from '../firewall-BD4YdAmB.js';
|
|
4
4
|
|
|
5
5
|
declare function createLangChainHandler(firewall: Firewall, options?: LangChainAdapterOptions): Promise<BaseCallbackHandler>;
|
|
6
6
|
/** Protect a runnable using its actual invocation config, including direct model/tool calls. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { g as FirewallMiddleware, S as createMiddleware } from '../firewall-
|
|
1
|
+
export { g as FirewallMiddleware, S as createMiddleware } from '../firewall-BD4YdAmB.cjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { g as FirewallMiddleware, S as createMiddleware } from '../firewall-
|
|
1
|
+
export { g as FirewallMiddleware, S as createMiddleware } from '../firewall-BD4YdAmB.js';
|
|
@@ -37,7 +37,7 @@ declare const Outcome: {
|
|
|
37
37
|
readonly StoryScriptGeneration: "story_script_generation";
|
|
38
38
|
readonly GameGeneration: "game_generation";
|
|
39
39
|
readonly WebsiteGeneration: "website_generation";
|
|
40
|
-
readonly
|
|
40
|
+
readonly Abuse: "abuse";
|
|
41
41
|
readonly TraditionalAiAbuse: "traditional_ai_abuse";
|
|
42
42
|
};
|
|
43
43
|
declare const unknownOutcomeBrand: unique symbol;
|
|
@@ -48,8 +48,8 @@ type UnknownOutcome = string & {
|
|
|
48
48
|
};
|
|
49
49
|
type PrimaryOutcome = KnownPrimaryOutcome | UnknownOutcome;
|
|
50
50
|
type HarmfulOutcome = KnownHarmfulOutcome | UnknownOutcome;
|
|
51
|
-
declare const PRIMARY_OUTCOMES: readonly ["benign", "information_disclosure", "secret_exposure", "control_abuse", "system_compromise", "service_disruption", "code_generation", "story_script_generation", "game_generation", "website_generation", "
|
|
52
|
-
declare const HARMFUL_OUTCOMES: readonly ["information_disclosure", "secret_exposure", "control_abuse", "system_compromise", "service_disruption", "code_generation", "story_script_generation", "game_generation", "website_generation", "
|
|
51
|
+
declare const PRIMARY_OUTCOMES: readonly ["benign", "information_disclosure", "secret_exposure", "control_abuse", "system_compromise", "service_disruption", "code_generation", "story_script_generation", "game_generation", "website_generation", "abuse", "traditional_ai_abuse"];
|
|
52
|
+
declare const HARMFUL_OUTCOMES: readonly ["information_disclosure", "secret_exposure", "control_abuse", "system_compromise", "service_disruption", "code_generation", "story_script_generation", "game_generation", "website_generation", "abuse", "traditional_ai_abuse"];
|
|
53
53
|
declare const OUTCOME_DESCRIPTIONS: {
|
|
54
54
|
readonly benign: "No harmful firewall outcome detected.";
|
|
55
55
|
readonly information_disclosure: "Exposes private data, documents, internal context, logs, traces, customer data, SQL rows, topology, or similar non-secret sensitive information.";
|
|
@@ -61,7 +61,7 @@ declare const OUTCOME_DESCRIPTIONS: {
|
|
|
61
61
|
readonly story_script_generation: "Requests generation of narrative prose, dialogue, scripts, or story artifacts.";
|
|
62
62
|
readonly game_generation: "Requests generation of a game, quest, level, mechanic, or playable experience.";
|
|
63
63
|
readonly website_generation: "Requests generation of a website, landing page, storefront, or web experience.";
|
|
64
|
-
readonly
|
|
64
|
+
readonly abuse: "Requests content or actions that violate the tenant's acceptable-use policy.";
|
|
65
65
|
readonly traditional_ai_abuse: "Requests unsafe AI assistance outside the concrete security outcome classes.";
|
|
66
66
|
};
|
|
67
67
|
declare function isPrimaryOutcome(value: unknown): value is KnownPrimaryOutcome;
|
|
@@ -37,7 +37,7 @@ declare const Outcome: {
|
|
|
37
37
|
readonly StoryScriptGeneration: "story_script_generation";
|
|
38
38
|
readonly GameGeneration: "game_generation";
|
|
39
39
|
readonly WebsiteGeneration: "website_generation";
|
|
40
|
-
readonly
|
|
40
|
+
readonly Abuse: "abuse";
|
|
41
41
|
readonly TraditionalAiAbuse: "traditional_ai_abuse";
|
|
42
42
|
};
|
|
43
43
|
declare const unknownOutcomeBrand: unique symbol;
|
|
@@ -48,8 +48,8 @@ type UnknownOutcome = string & {
|
|
|
48
48
|
};
|
|
49
49
|
type PrimaryOutcome = KnownPrimaryOutcome | UnknownOutcome;
|
|
50
50
|
type HarmfulOutcome = KnownHarmfulOutcome | UnknownOutcome;
|
|
51
|
-
declare const PRIMARY_OUTCOMES: readonly ["benign", "information_disclosure", "secret_exposure", "control_abuse", "system_compromise", "service_disruption", "code_generation", "story_script_generation", "game_generation", "website_generation", "
|
|
52
|
-
declare const HARMFUL_OUTCOMES: readonly ["information_disclosure", "secret_exposure", "control_abuse", "system_compromise", "service_disruption", "code_generation", "story_script_generation", "game_generation", "website_generation", "
|
|
51
|
+
declare const PRIMARY_OUTCOMES: readonly ["benign", "information_disclosure", "secret_exposure", "control_abuse", "system_compromise", "service_disruption", "code_generation", "story_script_generation", "game_generation", "website_generation", "abuse", "traditional_ai_abuse"];
|
|
52
|
+
declare const HARMFUL_OUTCOMES: readonly ["information_disclosure", "secret_exposure", "control_abuse", "system_compromise", "service_disruption", "code_generation", "story_script_generation", "game_generation", "website_generation", "abuse", "traditional_ai_abuse"];
|
|
53
53
|
declare const OUTCOME_DESCRIPTIONS: {
|
|
54
54
|
readonly benign: "No harmful firewall outcome detected.";
|
|
55
55
|
readonly information_disclosure: "Exposes private data, documents, internal context, logs, traces, customer data, SQL rows, topology, or similar non-secret sensitive information.";
|
|
@@ -61,7 +61,7 @@ declare const OUTCOME_DESCRIPTIONS: {
|
|
|
61
61
|
readonly story_script_generation: "Requests generation of narrative prose, dialogue, scripts, or story artifacts.";
|
|
62
62
|
readonly game_generation: "Requests generation of a game, quest, level, mechanic, or playable experience.";
|
|
63
63
|
readonly website_generation: "Requests generation of a website, landing page, storefront, or web experience.";
|
|
64
|
-
readonly
|
|
64
|
+
readonly abuse: "Requests content or actions that violate the tenant's acceptable-use policy.";
|
|
65
65
|
readonly traditional_ai_abuse: "Requests unsafe AI assistance outside the concrete security outcome classes.";
|
|
66
66
|
};
|
|
67
67
|
declare function isPrimaryOutcome(value: unknown): value is KnownPrimaryOutcome;
|
package/dist/index.cjs
CHANGED
|
@@ -1433,6 +1433,18 @@ init_exceptions();
|
|
|
1433
1433
|
init_hooks();
|
|
1434
1434
|
init_modes();
|
|
1435
1435
|
|
|
1436
|
+
// src/validation.ts
|
|
1437
|
+
var PYTHON_NONBLANK = /[^\p{White_Space}\u001c-\u001f]/u;
|
|
1438
|
+
function isPythonNonblankString(value) {
|
|
1439
|
+
return typeof value === "string" && PYTHON_NONBLANK.test(value);
|
|
1440
|
+
}
|
|
1441
|
+
function validateThreshold(name, value) {
|
|
1442
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > 1) {
|
|
1443
|
+
throw new Error(`Firewall: ${name} must be a finite number between 0 and 1`);
|
|
1444
|
+
}
|
|
1445
|
+
return value;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1436
1448
|
// src/outcomes.ts
|
|
1437
1449
|
var Outcome = {
|
|
1438
1450
|
Benign: "benign",
|
|
@@ -1445,7 +1457,7 @@ var Outcome = {
|
|
|
1445
1457
|
StoryScriptGeneration: "story_script_generation",
|
|
1446
1458
|
GameGeneration: "game_generation",
|
|
1447
1459
|
WebsiteGeneration: "website_generation",
|
|
1448
|
-
|
|
1460
|
+
Abuse: "abuse",
|
|
1449
1461
|
TraditionalAiAbuse: "traditional_ai_abuse"
|
|
1450
1462
|
};
|
|
1451
1463
|
var PRIMARY_OUTCOMES = [
|
|
@@ -1459,7 +1471,7 @@ var PRIMARY_OUTCOMES = [
|
|
|
1459
1471
|
Outcome.StoryScriptGeneration,
|
|
1460
1472
|
Outcome.GameGeneration,
|
|
1461
1473
|
Outcome.WebsiteGeneration,
|
|
1462
|
-
Outcome.
|
|
1474
|
+
Outcome.Abuse,
|
|
1463
1475
|
Outcome.TraditionalAiAbuse
|
|
1464
1476
|
];
|
|
1465
1477
|
var HARMFUL_OUTCOMES = [
|
|
@@ -1472,7 +1484,7 @@ var HARMFUL_OUTCOMES = [
|
|
|
1472
1484
|
Outcome.StoryScriptGeneration,
|
|
1473
1485
|
Outcome.GameGeneration,
|
|
1474
1486
|
Outcome.WebsiteGeneration,
|
|
1475
|
-
Outcome.
|
|
1487
|
+
Outcome.Abuse,
|
|
1476
1488
|
Outcome.TraditionalAiAbuse
|
|
1477
1489
|
];
|
|
1478
1490
|
var OUTCOME_DESCRIPTIONS = {
|
|
@@ -1486,15 +1498,11 @@ var OUTCOME_DESCRIPTIONS = {
|
|
|
1486
1498
|
[Outcome.StoryScriptGeneration]: "Requests generation of narrative prose, dialogue, scripts, or story artifacts.",
|
|
1487
1499
|
[Outcome.GameGeneration]: "Requests generation of a game, quest, level, mechanic, or playable experience.",
|
|
1488
1500
|
[Outcome.WebsiteGeneration]: "Requests generation of a website, landing page, storefront, or web experience.",
|
|
1489
|
-
[Outcome.
|
|
1501
|
+
[Outcome.Abuse]: "Requests content or actions that violate the tenant's acceptable-use policy.",
|
|
1490
1502
|
[Outcome.TraditionalAiAbuse]: "Requests unsafe AI assistance outside the concrete security outcome classes."
|
|
1491
1503
|
};
|
|
1492
1504
|
var PRIMARY_OUTCOME_SET = new Set(PRIMARY_OUTCOMES);
|
|
1493
1505
|
var HARMFUL_OUTCOME_SET = new Set(HARMFUL_OUTCOMES);
|
|
1494
|
-
var PYTHON_NONBLANK = /[^\p{White_Space}\u001c-\u001f]/u;
|
|
1495
|
-
function isNonblankOutcomeLabel(value) {
|
|
1496
|
-
return typeof value === "string" && PYTHON_NONBLANK.test(value);
|
|
1497
|
-
}
|
|
1498
1506
|
function isPrimaryOutcome(value) {
|
|
1499
1507
|
return typeof value === "string" && PRIMARY_OUTCOME_SET.has(value);
|
|
1500
1508
|
}
|
|
@@ -1502,13 +1510,13 @@ function isHarmfulOutcome(value) {
|
|
|
1502
1510
|
return typeof value === "string" && HARMFUL_OUTCOME_SET.has(value);
|
|
1503
1511
|
}
|
|
1504
1512
|
function normalizePrimaryOutcome(value, fieldName = "primary_outcome") {
|
|
1505
|
-
if (!
|
|
1513
|
+
if (!isPythonNonblankString(value)) {
|
|
1506
1514
|
throw new Error(`Firewall: invalid ${fieldName} ${JSON.stringify(value)}`);
|
|
1507
1515
|
}
|
|
1508
1516
|
return isPrimaryOutcome(value) ? value : value;
|
|
1509
1517
|
}
|
|
1510
1518
|
function normalizeHarmfulOutcome(value, fieldName = "outcome") {
|
|
1511
|
-
if (!
|
|
1519
|
+
if (!isPythonNonblankString(value) || value === Outcome.Benign) {
|
|
1512
1520
|
throw new Error(`Firewall: invalid ${fieldName} ${JSON.stringify(value)}`);
|
|
1513
1521
|
}
|
|
1514
1522
|
return isHarmfulOutcome(value) ? value : value;
|
|
@@ -1571,16 +1579,8 @@ function sanitizeText(text) {
|
|
|
1571
1579
|
return out;
|
|
1572
1580
|
}
|
|
1573
1581
|
|
|
1574
|
-
// src/validation.ts
|
|
1575
|
-
function validateThreshold(name, value) {
|
|
1576
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > 1) {
|
|
1577
|
-
throw new Error(`Firewall: ${name} must be a finite number between 0 and 1`);
|
|
1578
|
-
}
|
|
1579
|
-
return value;
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
1582
|
// src/firewall.ts
|
|
1583
|
-
var SDK_VERSION = "0.
|
|
1583
|
+
var SDK_VERSION = "0.11.0";
|
|
1584
1584
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
1585
1585
|
var DEFAULT_MAX_RETRIES = 5;
|
|
1586
1586
|
var MAX_BACKOFF_SECONDS = 30;
|
|
@@ -1787,12 +1787,12 @@ function governanceDecisionFromResponse(value) {
|
|
|
1787
1787
|
if (value.rule_id !== void 0 && value.rule_id !== null && typeof value.rule_id !== "string") {
|
|
1788
1788
|
throw new Error("Firewall: response governance rule_id must be a string when provided");
|
|
1789
1789
|
}
|
|
1790
|
-
if (value.identity_revision !== void 0 && value.identity_revision !== null && (
|
|
1790
|
+
if (value.identity_revision !== void 0 && value.identity_revision !== null && !isPythonNonblankString(value.identity_revision)) {
|
|
1791
1791
|
throw new Error(
|
|
1792
1792
|
"Firewall: response governance identity_revision must be a non-empty string when provided"
|
|
1793
1793
|
);
|
|
1794
1794
|
}
|
|
1795
|
-
if (value.reason !== void 0 && value.reason !== null && (
|
|
1795
|
+
if (value.reason !== void 0 && value.reason !== null && !isPythonNonblankString(value.reason)) {
|
|
1796
1796
|
throw new Error(
|
|
1797
1797
|
"Firewall: response governance reason must be a non-empty string when provided"
|
|
1798
1798
|
);
|