@lmzhen/dsh-evolution-capability 0.1.0-rc.1
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/README.md +26 -0
- package/lib/index.js +101 -0
- package/lib/invariant.js +8 -0
- package/lib/types/index.d.ts +61 -0
- package/lib/types/invariant.d.ts +5 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @deepseek-ai/dsh-evolution-capability
|
|
2
|
+
|
|
3
|
+
Explicit staged governance adapter for Creator-mode capability packages
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Model Experience
|
|
7
|
+
|
|
8
|
+
### Indirect model surface
|
|
9
|
+
|
|
10
|
+
#### What the model sees
|
|
11
|
+
|
|
12
|
+
`@deepseek-ai/dsh-evolution-capability` registers no direct prompt or tool schema itself. Model-visible effects are owned by the packages that consume this service.
|
|
13
|
+
|
|
14
|
+
#### Token effect
|
|
15
|
+
|
|
16
|
+
Zero direct token effect from this package; consumers add any model-visible tokens.
|
|
17
|
+
|
|
18
|
+
#### KV Cache effect
|
|
19
|
+
|
|
20
|
+
Independent of request-prefix construction. This package does not alter the assembled prompt or tool list.
|
|
21
|
+
|
|
22
|
+
## Known Limitations and Deferred Work
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
- - This adapter validates and stages capability packages only. It never executes model code; activation remains a manual Creator-mode operation.
|
|
26
|
+
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Service } from "@deepseek-ai/cordis";
|
|
2
|
+
import z from "@deepseek-ai/schemastery";
|
|
3
|
+
//#region lib/types/index.js
|
|
4
|
+
/**
|
|
5
|
+
* Explicit, non-automatic capability evolution adapter.
|
|
6
|
+
*
|
|
7
|
+
* The DSH Creator mode already owns the trusted dynamic-package lifecycle.
|
|
8
|
+
* This adapter adds the missing governance seam WITHOUT executing model code:
|
|
9
|
+
* a capability package is validated, then submitted through the same staged
|
|
10
|
+
* approval audit used by memory/skills. Human approval records the pending
|
|
11
|
+
* package; the actual `cordis_define`/`cordis_run` work stays in Creator mode.
|
|
12
|
+
* @module @lmzhen/dsh-evolution-capability
|
|
13
|
+
*/
|
|
14
|
+
const CAPABILITY_NAME_RE = /^[a-z0-9][a-z0-9-]*$/;
|
|
15
|
+
var EvolutionCapability = class extends Service {
|
|
16
|
+
static inject = ["evolutionApproval", "evolutionState"];
|
|
17
|
+
static Config = z.object({
|
|
18
|
+
maxNameLength: z.number().default(64),
|
|
19
|
+
maxPurposeLength: z.number().default(200),
|
|
20
|
+
maxCodeChars: z.number().default(65536)
|
|
21
|
+
});
|
|
22
|
+
limits;
|
|
23
|
+
constructor(ctx, config = {}) {
|
|
24
|
+
super(ctx, "evolutionCapability");
|
|
25
|
+
this.limits = {
|
|
26
|
+
maxNameLength: config.maxNameLength ?? 64,
|
|
27
|
+
maxPurposeLength: config.maxPurposeLength ?? 200,
|
|
28
|
+
maxCodeChars: config.maxCodeChars ?? 65536
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
validate(pkg) {
|
|
32
|
+
return validateCapabilityPackage(pkg, this.limits);
|
|
33
|
+
}
|
|
34
|
+
/** Stage one capability package. Execution is deliberately out of scope. */
|
|
35
|
+
async submit(pkg, origin = "foreground") {
|
|
36
|
+
const validation = this.validate(pkg);
|
|
37
|
+
if (!validation.ok) return {
|
|
38
|
+
ok: false,
|
|
39
|
+
message: validation.errors.join("; ")
|
|
40
|
+
};
|
|
41
|
+
const approval = this.ctx.evolutionApproval;
|
|
42
|
+
if (!approval.isEnabled) return {
|
|
43
|
+
ok: false,
|
|
44
|
+
message: "Capability evolution requires staged approval to be enabled."
|
|
45
|
+
};
|
|
46
|
+
const decision = await approval.request({
|
|
47
|
+
kind: "capability",
|
|
48
|
+
summary: `capability ${pkg.name}`,
|
|
49
|
+
args: pkg,
|
|
50
|
+
origin
|
|
51
|
+
});
|
|
52
|
+
if (decision.action !== "staged") return {
|
|
53
|
+
ok: false,
|
|
54
|
+
message: "Capability submission was not staged."
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
ok: true,
|
|
58
|
+
pendingId: decision.pendingId,
|
|
59
|
+
message: decision.message
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async listPending(status = "pending") {
|
|
63
|
+
return (await this.ctx.evolutionState.listPending(status)).filter((record) => record.kind === "capability");
|
|
64
|
+
}
|
|
65
|
+
/** Retrieve an approved package for manual Creator-mode activation. */
|
|
66
|
+
async approvedPackage(id) {
|
|
67
|
+
const record = (await this.ctx.evolutionState.listPending("approved")).find((item) => item.id === id && item.kind === "capability");
|
|
68
|
+
return record ? record.args : null;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
function validateCapabilityPackage(pkg, limits = {
|
|
72
|
+
maxNameLength: 64,
|
|
73
|
+
maxPurposeLength: 200,
|
|
74
|
+
maxCodeChars: 65536
|
|
75
|
+
}) {
|
|
76
|
+
const errors = [];
|
|
77
|
+
if (!pkg || typeof pkg !== "object" || Array.isArray(pkg)) return {
|
|
78
|
+
ok: false,
|
|
79
|
+
errors: ["capability package must be an object"]
|
|
80
|
+
};
|
|
81
|
+
const record = pkg;
|
|
82
|
+
const name = typeof record.name === "string" ? record.name.trim() : "";
|
|
83
|
+
const purpose = typeof record.purpose === "string" ? record.purpose.trim() : "";
|
|
84
|
+
const code = record.code;
|
|
85
|
+
if (!CAPABILITY_NAME_RE.test(name) || name.length > limits.maxNameLength) errors.push(`name must be lowercase-hyphenated and <= ${limits.maxNameLength} chars`);
|
|
86
|
+
if (purpose.length === 0 || purpose.length > limits.maxPurposeLength) errors.push(`purpose must be 1-${limits.maxPurposeLength} chars`);
|
|
87
|
+
if (!code || typeof code !== "object" || Array.isArray(code)) errors.push("code object is required");
|
|
88
|
+
else {
|
|
89
|
+
const halves = code;
|
|
90
|
+
const host = typeof halves.host === "string" ? halves.host : "";
|
|
91
|
+
const client = typeof halves.client === "string" ? halves.client : "";
|
|
92
|
+
if (host.length === 0 && client.length === 0) errors.push("at least one of code.host or code.client is required");
|
|
93
|
+
if (host.length > limits.maxCodeChars || client.length > limits.maxCodeChars) errors.push(`each code half must be <= ${limits.maxCodeChars} chars`);
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
ok: errors.length === 0,
|
|
97
|
+
errors
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { CAPABILITY_NAME_RE, EvolutionCapability, EvolutionCapability as default, validateCapabilityPackage };
|
package/lib/invariant.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region lib/types/invariant.js
|
|
2
|
+
const PACKAGE_NAME = "@deepseek-ai/dsh-evolution-capability";
|
|
3
|
+
const name = "evolution-capability-invariant";
|
|
4
|
+
const inject = ["invariants"];
|
|
5
|
+
const install = () => {};
|
|
6
|
+
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
7
|
+
//#endregion
|
|
8
|
+
export { apply, inject, name };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explicit, non-automatic capability evolution adapter.
|
|
3
|
+
*
|
|
4
|
+
* The DSH Creator mode already owns the trusted dynamic-package lifecycle.
|
|
5
|
+
* This adapter adds the missing governance seam WITHOUT executing model code:
|
|
6
|
+
* a capability package is validated, then submitted through the same staged
|
|
7
|
+
* approval audit used by memory/skills. Human approval records the pending
|
|
8
|
+
* package; the actual `cordis_define`/`cordis_run` work stays in Creator mode.
|
|
9
|
+
* @module @deepseek-ai/dsh-evolution-capability
|
|
10
|
+
*/
|
|
11
|
+
import { Context, Service } from '@deepseek-ai/cordis';
|
|
12
|
+
import type Schema from '@deepseek-ai/schemastery';
|
|
13
|
+
import type { PendingRecord, PendingStatus } from '@deepseek-ai/dsh-evolution-state-storage';
|
|
14
|
+
declare module '@deepseek-ai/cordis' {
|
|
15
|
+
interface Context {
|
|
16
|
+
evolutionCapability: EvolutionCapability;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export declare const CAPABILITY_NAME_RE: RegExp;
|
|
20
|
+
export interface CapabilityPackage {
|
|
21
|
+
name: string;
|
|
22
|
+
purpose: string;
|
|
23
|
+
code: {
|
|
24
|
+
host?: string;
|
|
25
|
+
client?: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface CapabilityValidation {
|
|
29
|
+
ok: boolean;
|
|
30
|
+
errors: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface CapabilitySubmitResult {
|
|
33
|
+
ok: boolean;
|
|
34
|
+
pendingId?: string | undefined;
|
|
35
|
+
message: string;
|
|
36
|
+
}
|
|
37
|
+
export interface Config {
|
|
38
|
+
maxNameLength?: number;
|
|
39
|
+
maxPurposeLength?: number;
|
|
40
|
+
maxCodeChars?: number;
|
|
41
|
+
}
|
|
42
|
+
export declare class EvolutionCapability extends Service {
|
|
43
|
+
static inject: string[];
|
|
44
|
+
static Config: Schema<Config>;
|
|
45
|
+
private readonly limits;
|
|
46
|
+
constructor(ctx: Context, config?: Config);
|
|
47
|
+
validate(pkg: unknown): CapabilityValidation;
|
|
48
|
+
/** Stage one capability package. Execution is deliberately out of scope. */
|
|
49
|
+
submit(pkg: CapabilityPackage, origin?: 'foreground' | 'background_review'): Promise<CapabilitySubmitResult>;
|
|
50
|
+
listPending(status?: PendingStatus): Promise<PendingRecord[]>;
|
|
51
|
+
/** Retrieve an approved package for manual Creator-mode activation. */
|
|
52
|
+
approvedPackage(id: string): Promise<CapabilityPackage | null>;
|
|
53
|
+
}
|
|
54
|
+
export interface CapabilityLimits {
|
|
55
|
+
maxNameLength: number;
|
|
56
|
+
maxPurposeLength: number;
|
|
57
|
+
maxCodeChars: number;
|
|
58
|
+
}
|
|
59
|
+
export declare function validateCapabilityPackage(pkg: unknown, limits?: CapabilityLimits): CapabilityValidation;
|
|
60
|
+
export default EvolutionCapability;
|
|
61
|
+
//# sourceMappingURL=index.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lmzhen/dsh-evolution-capability",
|
|
3
|
+
"description": "Explicit staged governance adapter for Creator-mode capability packages (community build)",
|
|
4
|
+
"version": "0.1.0-rc.1",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/lmzhen/dsh-evolution.git",
|
|
11
|
+
"directory": "packages/dsh-evolution-capability"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./invariant": {
|
|
22
|
+
"types": "./lib/types/invariant.d.ts",
|
|
23
|
+
"default": "./lib/invariant.js"
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"lib/index.js",
|
|
29
|
+
"lib/invariant.js",
|
|
30
|
+
"lib/types/**/*.d.ts",
|
|
31
|
+
"lib/types/invariant.d.ts"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@deepseek-ai/schemastery": "^3.18.1"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
|
|
39
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
40
|
+
"@lmzhen/dsh-evolution-approval": "^0.1.0-rc.1",
|
|
41
|
+
"@lmzhen/dsh-evolution-state": "^0.1.0-rc.1",
|
|
42
|
+
"@lmzhen/dsh-evolution-state-storage": "^0.1.0-rc.1"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
|
|
46
|
+
"@lmzhen/dsh-evolution-approval": "^0.1.0-rc.1",
|
|
47
|
+
"@lmzhen/dsh-evolution-state": "^0.1.0-rc.1",
|
|
48
|
+
"@lmzhen/dsh-evolution-state-storage": "^0.1.0-rc.1",
|
|
49
|
+
"@lmzhen/dsh-evolution-io": "^0.1.0-rc.1",
|
|
50
|
+
"@lmzhen/dsh-evolution-io-node": "^0.1.0-rc.1",
|
|
51
|
+
"@lmzhen/dsh-evolution-state-json": "^0.1.0-rc.1"
|
|
52
|
+
}
|
|
53
|
+
}
|