@lmzhen/dsh-evolution-threat 0.4.1 → 0.6.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/lib/index.js +5 -5
- package/lib/types/index.d.ts +1 -1
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
|
-
import { EVOLUTION_WRITE_TOOLS, PATTERN_OVERLAP, clampedNumber, scanContentThreats, scanMemoryThreats } from "@lmzhen/dsh-evolution-core";
|
|
2
|
+
import { DEFAULT_THREAT_MAX_SCAN_CHARS, EVOLUTION_WRITE_TOOLS, PATTERN_OVERLAP, clampedNumber, scanContentThreats, scanMemoryThreats } from "@lmzhen/dsh-evolution-core";
|
|
3
3
|
//#region lib/types/index.js
|
|
4
4
|
/**
|
|
5
5
|
* Write-time threat guard for evolution tools.
|
|
@@ -9,7 +9,7 @@ const name = "evolution-threat";
|
|
|
9
9
|
const inject = ["tools"];
|
|
10
10
|
const Config = z.object({
|
|
11
11
|
enabled: z.boolean().default(true),
|
|
12
|
-
maxScanChars: z.number().min(PATTERN_OVERLAP + 1).default(
|
|
12
|
+
maxScanChars: z.number().min(PATTERN_OVERLAP + 1).default(DEFAULT_THREAT_MAX_SCAN_CHARS),
|
|
13
13
|
threatExemptLabels: z.array(z.string()).default([])
|
|
14
14
|
});
|
|
15
15
|
function asRecord(value) {
|
|
@@ -47,17 +47,17 @@ function scanToolArgs(toolName, args, maxScanChars, options = {}) {
|
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
49
49
|
/** Resolve the effective `maxScanChars`, clamping invalid values to the
|
|
50
|
-
* default (G3.1: 0/negative/NaN/±Infinity →
|
|
50
|
+
* default (G3.1: 0/negative/NaN/±Infinity → DEFAULT_THREAT_MAX_SCAN_CHARS; V6-05: a value below
|
|
51
51
|
* PATTERN_OVERLAP + 1 is out of the coverage-guarantee domain → default).
|
|
52
52
|
* Exported so the clamp is directly testable; `apply` warns when a
|
|
53
53
|
* user-supplied value was corrected. */
|
|
54
54
|
function resolveMaxScanChars(config) {
|
|
55
|
-
return clampedNumber(config.maxScanChars ??
|
|
55
|
+
return clampedNumber(config.maxScanChars ?? DEFAULT_THREAT_MAX_SCAN_CHARS, DEFAULT_THREAT_MAX_SCAN_CHARS, { min: PATTERN_OVERLAP + 1 });
|
|
56
56
|
}
|
|
57
57
|
function apply(ctx, rawConfig = {}) {
|
|
58
58
|
if (!(rawConfig.enabled ?? true)) return;
|
|
59
59
|
const maxScanChars = resolveMaxScanChars(rawConfig);
|
|
60
|
-
if (maxScanChars !== (rawConfig.maxScanChars ??
|
|
60
|
+
if (maxScanChars !== (rawConfig.maxScanChars ?? DEFAULT_THREAT_MAX_SCAN_CHARS)) ctx.logger.warn(`evolution-threat: maxScanChars=${String(rawConfig.maxScanChars)} is invalid; falling back to the default ${DEFAULT_THREAT_MAX_SCAN_CHARS}`);
|
|
61
61
|
const scanOptions = { excludeLabels: rawConfig.threatExemptLabels ?? [] };
|
|
62
62
|
ctx.inject(["tools"], (toolCtx) => {
|
|
63
63
|
const tools = toolCtx.get("tools");
|
package/lib/types/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare const Config: z<Config>;
|
|
|
24
24
|
* SkillLibrary/MemoryStore write gates (P2-4, v14). */
|
|
25
25
|
export declare function scanToolArgs(toolName: string, args: unknown, maxScanChars: number, options?: ScanOptions): string | null;
|
|
26
26
|
/** Resolve the effective `maxScanChars`, clamping invalid values to the
|
|
27
|
-
* default (G3.1: 0/negative/NaN/±Infinity →
|
|
27
|
+
* default (G3.1: 0/negative/NaN/±Infinity → DEFAULT_THREAT_MAX_SCAN_CHARS; V6-05: a value below
|
|
28
28
|
* PATTERN_OVERLAP + 1 is out of the coverage-guarantee domain → default).
|
|
29
29
|
* Exported so the clamp is directly testable; `apply` warns when a
|
|
30
30
|
* user-supplied value was corrected. */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-threat",
|
|
3
3
|
"description": "Write-time threat guard for evolution tools (community build)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@deepseek-ai/schemastery": "^3.18.1",
|
|
30
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
30
|
+
"@lmzhen/dsh-evolution-core": "^0.6.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@deepseek-ai/dsh-agent-loop-testkit": "^0.1.5-rc.2",
|
|
38
38
|
"@deepseek-ai/dsh-tools": "^0.1.5-rc.2",
|
|
39
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
39
|
+
"@lmzhen/dsh-evolution-core": "^0.6.0"
|
|
40
40
|
}
|
|
41
41
|
}
|