@lmzhen/dsh-evolution-approval 0.1.0-rc.3 → 0.1.0-rc.30
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 +23 -3
- package/lib/types/index.d.ts +9 -0
- package/package.json +8 -8
package/lib/index.js
CHANGED
|
@@ -52,15 +52,20 @@ var EvolutionApproval = class extends Service {
|
|
|
52
52
|
}
|
|
53
53
|
/** Evaluate one mutation. Returns allow, or stores the write and returns staged. */
|
|
54
54
|
async request(input) {
|
|
55
|
+
const summary = normalizeSummary(input);
|
|
55
56
|
if (!this.enabled) return {
|
|
56
57
|
action: "allow",
|
|
57
58
|
message: "Approval disabled."
|
|
58
59
|
};
|
|
60
|
+
if (input.sessionPolicy === "never") return {
|
|
61
|
+
action: "allow",
|
|
62
|
+
message: "Session approval policy is \"never\"; write allowed without staging."
|
|
63
|
+
};
|
|
59
64
|
if (input.origin === "background_review" || this.stageForeground) {
|
|
60
65
|
const record = {
|
|
61
66
|
id: randomUUID(),
|
|
62
67
|
kind: input.kind,
|
|
63
|
-
summary
|
|
68
|
+
summary,
|
|
64
69
|
args: input.args,
|
|
65
70
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
66
71
|
status: "pending"
|
|
@@ -81,10 +86,15 @@ var EvolutionApproval = class extends Service {
|
|
|
81
86
|
return await this.state().listPending(status);
|
|
82
87
|
}
|
|
83
88
|
async approve(id) {
|
|
84
|
-
return await this.dedupe(id
|
|
89
|
+
return await this.dedupe(`approve:${id}`, () => this.doApprove(id));
|
|
85
90
|
}
|
|
86
91
|
async reject(id) {
|
|
87
|
-
return await this.dedupe(id
|
|
92
|
+
return await this.dedupe(`reject:${id}`, async () => {
|
|
93
|
+
const claimId = randomUUID();
|
|
94
|
+
if (!await this.state().claimPending(id, claimId)) return {
|
|
95
|
+
ok: false,
|
|
96
|
+
message: `Pending write "${id}" is already being resolved by another writer.`
|
|
97
|
+
};
|
|
88
98
|
const resolution = await this.state().tryResolvePending(id, "rejected");
|
|
89
99
|
if (!resolution.applied || !resolution.record) return {
|
|
90
100
|
ok: false,
|
|
@@ -157,5 +167,15 @@ var EvolutionApproval = class extends Service {
|
|
|
157
167
|
};
|
|
158
168
|
}
|
|
159
169
|
};
|
|
170
|
+
/** Compact, batch-aware approval summary so pending lists stay scannable. */
|
|
171
|
+
function normalizeSummary(input) {
|
|
172
|
+
const trimmed = input.summary.length > 120 ? `${input.summary.slice(0, 117)}...` : input.summary;
|
|
173
|
+
if (input.kind === "memory") {
|
|
174
|
+
const candidate = input.args;
|
|
175
|
+
if (Array.isArray(candidate?.operations) && candidate.operations.length > 1) return `memory ${candidate.target ?? "memory"} batch of ${candidate.operations.length} operations`;
|
|
176
|
+
}
|
|
177
|
+
if (input.kind === "skill" && /^skill delete /.test(trimmed)) return `${trimmed} (warning: archive)`;
|
|
178
|
+
return trimmed;
|
|
179
|
+
}
|
|
160
180
|
//#endregion
|
|
161
181
|
export { EvolutionApproval, EvolutionApproval as default };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -22,6 +22,15 @@ export interface ApprovalRequest {
|
|
|
22
22
|
summary: string;
|
|
23
23
|
args: unknown;
|
|
24
24
|
origin: 'foreground' | 'background_review';
|
|
25
|
+
/**
|
|
26
|
+
* The requesting session's effective approval policy (platform vocabulary:
|
|
27
|
+
* 'ask' | 'never' — see `dsh-user-approval`). When 'never', the session has
|
|
28
|
+
* declared the deterministic unattended stance (CI, cron, automated runs),
|
|
29
|
+
* so the write is allowed instead of staging an unanswerable pending record
|
|
30
|
+
* (claw alignment: "skip approval for non-interactive contexts"). Absent
|
|
31
|
+
* (no session / no approval service) keeps the previous behavior.
|
|
32
|
+
*/
|
|
33
|
+
sessionPolicy?: 'ask' | 'never';
|
|
25
34
|
}
|
|
26
35
|
export interface ApprovalDecision {
|
|
27
36
|
action: 'allow' | 'staged';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-approval",
|
|
3
3
|
"description": "Stage/pending approval service for Hermes-style self-evolution writes (community build)",
|
|
4
|
-
"version": "0.1.0-rc.
|
|
4
|
+
"version": "0.1.0-rc.30",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
|
|
39
39
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
40
|
-
"@lmzhen/dsh-evolution-state-storage": "^0.1.0-rc.
|
|
41
|
-
"@lmzhen/dsh-evolution-state": "^0.1.0-rc.
|
|
40
|
+
"@lmzhen/dsh-evolution-state-storage": "^0.1.0-rc.30",
|
|
41
|
+
"@lmzhen/dsh-evolution-state": "^0.1.0-rc.30"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
|
|
45
|
-
"@lmzhen/dsh-evolution-state-storage": "^0.1.0-rc.
|
|
46
|
-
"@lmzhen/dsh-evolution-state": "^0.1.0-rc.
|
|
47
|
-
"@lmzhen/dsh-evolution-io": "^0.1.0-rc.
|
|
48
|
-
"@lmzhen/dsh-evolution-io-node": "^0.1.0-rc.
|
|
49
|
-
"@lmzhen/dsh-evolution-state-json": "^0.1.0-rc.
|
|
45
|
+
"@lmzhen/dsh-evolution-state-storage": "^0.1.0-rc.30",
|
|
46
|
+
"@lmzhen/dsh-evolution-state": "^0.1.0-rc.30",
|
|
47
|
+
"@lmzhen/dsh-evolution-io": "^0.1.0-rc.30",
|
|
48
|
+
"@lmzhen/dsh-evolution-io-node": "^0.1.0-rc.30",
|
|
49
|
+
"@lmzhen/dsh-evolution-state-json": "^0.1.0-rc.30"
|
|
50
50
|
}
|
|
51
51
|
}
|