@lmzhen/dsh-evolution-capability 0.3.62 → 0.3.64
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 +22 -12
- package/lib/types/index.d.ts +4 -0
- package/package.json +11 -11
package/lib/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { clampedNumber } from "@lmzhen/dsh-evolution-core";
|
|
|
13
13
|
* @module @lmzhen/dsh-evolution-capability
|
|
14
14
|
*/
|
|
15
15
|
const CAPABILITY_NAME_RE = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
|
|
16
|
-
var EvolutionCapability = class extends Service {
|
|
16
|
+
var EvolutionCapability = class EvolutionCapability extends Service {
|
|
17
17
|
static inject = ["evolutionApproval", "evolutionState"];
|
|
18
18
|
static Config = z.object({
|
|
19
19
|
maxNameLength: z.number().min(1).default(64),
|
|
@@ -21,6 +21,14 @@ var EvolutionCapability = class extends Service {
|
|
|
21
21
|
maxCodeChars: z.number().min(1).default(65536)
|
|
22
22
|
});
|
|
23
23
|
limits;
|
|
24
|
+
/** P3 (v15): single source for the default limits — the Config schema and
|
|
25
|
+
* `validateCapabilityPackage`'s standalone default used to repeat the same
|
|
26
|
+
* three numbers (drift risk). */
|
|
27
|
+
static DEFAULT_LIMITS = {
|
|
28
|
+
maxNameLength: 64,
|
|
29
|
+
maxPurposeLength: 200,
|
|
30
|
+
maxCodeChars: 65536
|
|
31
|
+
};
|
|
24
32
|
constructor(ctx, config = {}) {
|
|
25
33
|
super(ctx, "evolutionCapability");
|
|
26
34
|
const clamped = [];
|
|
@@ -30,9 +38,9 @@ var EvolutionCapability = class extends Service {
|
|
|
30
38
|
return result;
|
|
31
39
|
};
|
|
32
40
|
this.limits = {
|
|
33
|
-
maxNameLength: field("maxNameLength", config.maxNameLength,
|
|
34
|
-
maxPurposeLength: field("maxPurposeLength", config.maxPurposeLength,
|
|
35
|
-
maxCodeChars: field("maxCodeChars", config.maxCodeChars,
|
|
41
|
+
maxNameLength: field("maxNameLength", config.maxNameLength, EvolutionCapability.DEFAULT_LIMITS.maxNameLength),
|
|
42
|
+
maxPurposeLength: field("maxPurposeLength", config.maxPurposeLength, EvolutionCapability.DEFAULT_LIMITS.maxPurposeLength),
|
|
43
|
+
maxCodeChars: field("maxCodeChars", config.maxCodeChars, EvolutionCapability.DEFAULT_LIMITS.maxCodeChars)
|
|
36
44
|
};
|
|
37
45
|
if (clamped.length > 0) ctx.logger.warn(`evolution-capability: ${clamped.join(", ")} provided an invalid value; falling back to the default`);
|
|
38
46
|
}
|
|
@@ -53,13 +61,17 @@ var EvolutionCapability = class extends Service {
|
|
|
53
61
|
};
|
|
54
62
|
const decision = await approval.request({
|
|
55
63
|
kind: "capability",
|
|
56
|
-
summary: `capability ${pkg.name}`,
|
|
57
|
-
args:
|
|
64
|
+
summary: `capability ${pkg.name.trim()}`,
|
|
65
|
+
args: {
|
|
66
|
+
...pkg,
|
|
67
|
+
name: pkg.name.trim(),
|
|
68
|
+
purpose: pkg.purpose.trim()
|
|
69
|
+
},
|
|
58
70
|
origin
|
|
59
71
|
});
|
|
60
72
|
if (decision.action !== "staged") return {
|
|
61
73
|
ok: false,
|
|
62
|
-
message:
|
|
74
|
+
message: `Capability submission requires staged approval and must never skip the audit; approval allowed a direct write (${decision.message}). Check the session approval policy and the approval stageForeground setting.`
|
|
63
75
|
};
|
|
64
76
|
return {
|
|
65
77
|
ok: true,
|
|
@@ -77,11 +89,7 @@ var EvolutionCapability = class extends Service {
|
|
|
77
89
|
return this.validate(record.args).ok ? record.args : null;
|
|
78
90
|
}
|
|
79
91
|
};
|
|
80
|
-
function validateCapabilityPackage(pkg, limits = {
|
|
81
|
-
maxNameLength: 64,
|
|
82
|
-
maxPurposeLength: 200,
|
|
83
|
-
maxCodeChars: 65536
|
|
84
|
-
}) {
|
|
92
|
+
function validateCapabilityPackage(pkg, limits = EvolutionCapability.DEFAULT_LIMITS) {
|
|
85
93
|
const errors = [];
|
|
86
94
|
if (!pkg || typeof pkg !== "object" || Array.isArray(pkg)) return {
|
|
87
95
|
ok: false,
|
|
@@ -96,6 +104,8 @@ function validateCapabilityPackage(pkg, limits = {
|
|
|
96
104
|
if (!code || typeof code !== "object" || Array.isArray(code)) errors.push("code object is required");
|
|
97
105
|
else {
|
|
98
106
|
const halves = code;
|
|
107
|
+
if (halves.host !== void 0 && typeof halves.host !== "string") errors.push("code.host must be a string");
|
|
108
|
+
if (halves.client !== void 0 && typeof halves.client !== "string") errors.push("code.client must be a string");
|
|
99
109
|
const host = typeof halves.host === "string" ? halves.host : "";
|
|
100
110
|
const client = typeof halves.client === "string" ? halves.client : "";
|
|
101
111
|
if (host.length === 0 && client.length === 0) errors.push("at least one of code.host or code.client is required");
|
package/lib/types/index.d.ts
CHANGED
|
@@ -42,6 +42,10 @@ export declare class EvolutionCapability extends Service {
|
|
|
42
42
|
static inject: string[];
|
|
43
43
|
static Config: Schema<Config>;
|
|
44
44
|
private readonly limits;
|
|
45
|
+
/** P3 (v15): single source for the default limits — the Config schema and
|
|
46
|
+
* `validateCapabilityPackage`'s standalone default used to repeat the same
|
|
47
|
+
* three numbers (drift risk). */
|
|
48
|
+
static readonly DEFAULT_LIMITS: Required<Config>;
|
|
45
49
|
constructor(ctx: Context, config?: Config);
|
|
46
50
|
validate(pkg: unknown): CapabilityValidation;
|
|
47
51
|
/** Stage one capability package. Execution is deliberately out of scope. */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-capability",
|
|
3
3
|
"description": "Explicit staged governance adapter for Creator-mode capability packages (community build)",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.64",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -31,22 +31,22 @@
|
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@deepseek-ai/schemastery": "^3.18.1",
|
|
34
|
-
"@lmzhen/dsh-evolution-core": "^0.3.
|
|
34
|
+
"@lmzhen/dsh-evolution-core": "^0.3.64"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
38
38
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
39
|
-
"@lmzhen/dsh-evolution-approval": "^0.3.
|
|
40
|
-
"@lmzhen/dsh-evolution-state": "^0.3.
|
|
41
|
-
"@lmzhen/dsh-evolution-state-storage": "^0.3.
|
|
39
|
+
"@lmzhen/dsh-evolution-approval": "^0.3.64",
|
|
40
|
+
"@lmzhen/dsh-evolution-state": "^0.3.64",
|
|
41
|
+
"@lmzhen/dsh-evolution-state-storage": "^0.3.64"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
45
|
-
"@lmzhen/dsh-evolution-approval": "^0.3.
|
|
46
|
-
"@lmzhen/dsh-evolution-state": "^0.3.
|
|
47
|
-
"@lmzhen/dsh-evolution-state-storage": "^0.3.
|
|
48
|
-
"@lmzhen/dsh-evolution-io": "^0.3.
|
|
49
|
-
"@lmzhen/dsh-evolution-io-node": "^0.3.
|
|
50
|
-
"@lmzhen/dsh-evolution-state-json": "^0.3.
|
|
45
|
+
"@lmzhen/dsh-evolution-approval": "^0.3.64",
|
|
46
|
+
"@lmzhen/dsh-evolution-state": "^0.3.64",
|
|
47
|
+
"@lmzhen/dsh-evolution-state-storage": "^0.3.64",
|
|
48
|
+
"@lmzhen/dsh-evolution-io": "^0.3.64",
|
|
49
|
+
"@lmzhen/dsh-evolution-io-node": "^0.3.64",
|
|
50
|
+
"@lmzhen/dsh-evolution-state-json": "^0.3.64"
|
|
51
51
|
}
|
|
52
52
|
}
|