@lmzhen/dsh-evolution-approval 0.30.18 → 0.30.19

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Service } from "@deepseek-ai/cordis";
2
2
  import { randomUUID } from "node:crypto";
3
- import { clampOnce, elapsedSince, textDiffFacts } from "@lmzhen/dsh-evolution-core";
3
+ import { clampOnce, elapsedSince, textDiffFacts, unwrapLive } from "@lmzhen/dsh-evolution-core";
4
4
  import z from "@deepseek-ai/schemastery";
5
5
  import { PENDING_STATUSES } from "@lmzhen/dsh-evolution-state-storage";
6
6
  import { HOST_ROUTES, json, methodNotAllowed, readJsonObject, registerHostRoutes } from "@lmzhen/dsh-evolution-core/http-routes";
@@ -238,7 +238,7 @@ function effectiveSessionPolicy(ctx, session) {
238
238
  var EvolutionApproval = class extends Service {
239
239
  static inject = ["evolutionState"];
240
240
  static Config = z.object({
241
- enabled: z.boolean().default(false),
241
+ enabled: z.boolean().default(false).volatile(),
242
242
  stageForeground: z.boolean().default(true),
243
243
  pendingTtlMs: z.number().min(0).default(0).volatile(),
244
244
  approvalConfirm: z.union([
@@ -247,7 +247,7 @@ var EvolutionApproval = class extends Service {
247
247
  z.const("timeout")
248
248
  ]).default("auto").volatile()
249
249
  });
250
- enabled;
250
+ enabledConfig;
251
251
  stageForegroundConfig;
252
252
  /** The TTL carrier as configured: a plain number, or the live reference `.volatile()` hands a
253
253
  * user-layer field. Read through {@link ttl} at every use, never cached (registry row: live). */
@@ -265,7 +265,7 @@ var EvolutionApproval = class extends Service {
265
265
  inFlight = /* @__PURE__ */ new Map();
266
266
  constructor(ctx, config = {}) {
267
267
  super(ctx, "evolutionApproval");
268
- this.enabled = config.enabled ?? false;
268
+ this.enabledConfig = config.enabled;
269
269
  this.stageForegroundConfig = config.stageForeground ?? true;
270
270
  this.pendingTtlMsConfig = config.pendingTtlMs;
271
271
  this.ctx.inject(["settings"], (injected) => {
@@ -280,8 +280,12 @@ var EvolutionApproval = class extends Service {
280
280
  return this.ctx.evolutionState;
281
281
  }
282
282
  /** Fail-closed capability adapters need to distinguish "allowed" from "enabled". */
283
+ /** Host write capability exposed to settings/Facts; mirrors the live enabled switch. */
284
+ get platformWrite() {
285
+ return this.isEnabled;
286
+ }
283
287
  get isEnabled() {
284
- return this.enabled;
288
+ return unwrapLive(this.enabledConfig) ?? false;
285
289
  }
286
290
  registerRunner(kind, runner, preview) {
287
291
  if (this.runners.has(kind)) throw new Error(`approval runner for "${kind}" is already registered`);
@@ -328,7 +332,7 @@ var EvolutionApproval = class extends Service {
328
332
  /** Evaluate one mutation. Returns allow, or stores the write and returns staged. */
329
333
  async request(input) {
330
334
  const summary = normalizeSummary(input);
331
- if (!this.enabled) return {
335
+ if (!this.isEnabled) return {
332
336
  action: "allow",
333
337
  message: "批准已禁用。"
334
338
  };
@@ -153,7 +153,7 @@ declare module '@deepseek-ai/cordis' {
153
153
  }
154
154
  export interface Config {
155
155
  /** Master switch. Default false matches Hermes write_approval default. */
156
- enabled?: boolean;
156
+ enabled?: Volatile<boolean>;
157
157
  /** Require approval for foreground writes as well. */
158
158
  stageForeground?: boolean;
159
159
  /**
@@ -177,17 +177,17 @@ export interface Config {
177
177
  export declare class EvolutionApproval extends Service {
178
178
  static inject: string[];
179
179
  static Config: z<Schemastery.ObjectS<NoInfer<{
180
- enabled: z<boolean, boolean, "defined">;
180
+ enabled: z<boolean, boolean, "volatile-defined">;
181
181
  stageForeground: z<boolean, boolean, "defined">;
182
182
  pendingTtlMs: z<number, number, "volatile-defined">;
183
183
  approvalConfirm: z<"ask" | "auto" | "timeout", "ask" | "auto" | "timeout", "volatile-defined">;
184
184
  }>>, Schemastery.ObjectT<NoInfer<{
185
- enabled: z<boolean, boolean, "defined">;
185
+ enabled: z<boolean, boolean, "volatile-defined">;
186
186
  stageForeground: z<boolean, boolean, "defined">;
187
187
  pendingTtlMs: z<number, number, "volatile-defined">;
188
188
  approvalConfirm: z<"ask" | "auto" | "timeout", "ask" | "auto" | "timeout", "volatile-defined">;
189
189
  }>>, "plain">;
190
- private readonly enabled;
190
+ private readonly enabledConfig?;
191
191
  private readonly stageForegroundConfig;
192
192
  /** The TTL carrier as configured: a plain number, or the live reference `.volatile()` hands a
193
193
  * user-layer field. Read through {@link ttl} at every use, never cached (registry row: live). */
@@ -204,6 +204,8 @@ export declare class EvolutionApproval extends Service {
204
204
  constructor(ctx: Context, config?: Config);
205
205
  private state;
206
206
  /** Fail-closed capability adapters need to distinguish "allowed" from "enabled". */
207
+ /** Host write capability exposed to settings/Facts; mirrors the live enabled switch. */
208
+ get platformWrite(): boolean;
207
209
  get isEnabled(): boolean;
208
210
  registerRunner(kind: PendingKind, runner: WriteRunner, preview?: WritePreview): () => void;
209
211
  /** The preview registered for `kind`, if that kind can show what its replay would write. */
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.30.18",
4
+ "version": "0.30.19",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -27,18 +27,18 @@
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
29
  "@deepseek-ai/schemastery": "^3.18.5",
30
- "@lmzhen/dsh-evolution-core": "^0.30.18"
30
+ "@lmzhen/dsh-evolution-core": "^0.30.19"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@deepseek-ai/cordis": "^4.0.5",
34
- "@lmzhen/dsh-evolution-core": "^0.30.18",
35
- "@lmzhen/dsh-evolution-state": "^0.30.18",
36
- "@lmzhen/dsh-evolution-state-storage": "^0.30.18"
34
+ "@lmzhen/dsh-evolution-core": "^0.30.19",
35
+ "@lmzhen/dsh-evolution-state": "^0.30.19",
36
+ "@lmzhen/dsh-evolution-state-storage": "^0.30.19"
37
37
  },
38
38
  "devDependencies": {
39
- "@lmzhen/dsh-evolution-core": "^0.30.18",
40
- "@lmzhen/dsh-evolution-state": "^0.30.18",
41
- "@lmzhen/dsh-evolution-state-storage": "^0.30.18"
39
+ "@lmzhen/dsh-evolution-core": "^0.30.19",
40
+ "@lmzhen/dsh-evolution-state": "^0.30.19",
41
+ "@lmzhen/dsh-evolution-state-storage": "^0.30.19"
42
42
  },
43
43
  "engines": {
44
44
  "dsh": ">=0.2.1-rc.1 <0.2.2-0"