@lmzhen/dsh-evolution-review 0.50.0 → 0.51.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/lib/index.js +56 -4
- package/lib/types/index.d.ts +5 -0
- package/package.json +5 -5
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BlockAssembler, SessionId, createToolResultMessage, createUserMessage, llmPort, settingsPort, toolsPort } from "@lmzhen/dsh-evolution-core/platform";
|
|
2
2
|
import z from "@deepseek-ai/schemastery";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
|
-
import { DEFAULT_REVIEW_MEMORY_INTERVAL, DEFAULT_REVIEW_SKILL_INTERVAL, DEFAULT_REVIEW_TIMEOUT_MS, DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, DEFAULT_SKILL_REVIEW_TRIGGER, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, INJECT_COMPLETION_SKILL_REVIEW_PROMPT, MAX_TIMER_DELAY_MS, PROMPT_BUNDLE, advanceReview, clampOnce, classifySessionEvent, clearReviewChannel, liveBool, markReviewChannel, paramRowId, pickWithPolicy, readDispatchSignal, reviewPrompt, sessionAudited, sessionTurnSignals, sweepReviewChannelSessions, unwrapLive, userSetKeys, verifyPromptBundle, withReviewContext } from "@lmzhen/dsh-evolution-core";
|
|
4
|
+
import { DEFAULT_REVIEW_MEMORY_INTERVAL, DEFAULT_REVIEW_SKILL_INTERVAL, DEFAULT_REVIEW_TIMEOUT_MS, DEFAULT_SKILL_REVIEW_COMPLETION_MIN_TOOL_CALLS, DEFAULT_SKILL_REVIEW_TRIGGER, DEFAULT_SUBSTANTIVE_MIN_AGENT_CHARS, DEFAULT_SUBSTANTIVE_MIN_TOOL_CALLS, DEFAULT_SUBSTANTIVE_MIN_USER_CHARS, INJECT_COMPLETION_SKILL_REVIEW_PROMPT, MAX_TIMER_DELAY_MS, PROMPT_BUNDLE, advanceReview, clampOnce, classifySessionEvent, clearReviewChannel, liveBool, markReviewChannel, paramRowId, pickWithPolicy, readDispatchSignal, recordReviewRead, reviewPrompt, sessionAudited, sessionTurnSignals, sweepReviewChannelSessions, unwrapLive, userSetKeys, verifyPromptBundle, withReviewContext } from "@lmzhen/dsh-evolution-core";
|
|
5
5
|
import { assertSkillsRootAliasRetired, filterUnreadSkillOps } from "@lmzhen/dsh-evolution-core/skills";
|
|
6
6
|
//#region lib/types/review-executor.js
|
|
7
7
|
/**
|
|
@@ -150,6 +150,10 @@ async function runReview(input) {
|
|
|
150
150
|
target: toolTarget(call.name, call.arguments),
|
|
151
151
|
status: item.result.isError ? "error" : item.result.content.some((block) => block.type === "text" && /staged id:|已暂存|pending_id/.test(block.text)) ? "staged" : "ok"
|
|
152
152
|
});
|
|
153
|
+
if (call.name === "skill" && item.result.isError !== true) try {
|
|
154
|
+
const parsed = JSON.parse(call.arguments);
|
|
155
|
+
if (parsed !== null && typeof parsed === "object" && typeof parsed.name === "string") recordReviewRead(parsed.name);
|
|
156
|
+
} catch {}
|
|
153
157
|
messages.push(createToolResultMessage({
|
|
154
158
|
callId: item.callId,
|
|
155
159
|
content: item.result.content,
|
|
@@ -283,6 +287,10 @@ var SessionScopedState = class {
|
|
|
283
287
|
* Background review orchestration: signal gate → one-shot subagent → trusted plan execution.
|
|
284
288
|
* @module @lmzhen/dsh-evolution-review
|
|
285
289
|
*/
|
|
290
|
+
/** Model requests per auxiliary review run. One skill of incremental edits may need many rounds. */
|
|
291
|
+
const DEFAULT_REVIEW_MAX_ROUNDS = 12;
|
|
292
|
+
/** Keep a mistyped deployment value from turning one review into an unbounded loop. */
|
|
293
|
+
const MAX_REVIEW_MAX_ROUNDS = 200;
|
|
286
294
|
/** Emit one `evolution/review-scheduled` inside its OWN protection domain (V8-03, V5-19③/F-334).
|
|
287
295
|
*
|
|
288
296
|
* Every delivery path must enter that domain, and five hand-copied try/emit/catch blocks had
|
|
@@ -320,6 +328,7 @@ const Config = z.object({
|
|
|
320
328
|
reviewMemoryInterval: z.number().min(1).volatile(),
|
|
321
329
|
reviewSkillInterval: z.number().min(1).volatile(),
|
|
322
330
|
reviewTimeoutMs: z.number().min(1).max(MAX_TIMER_DELAY_MS).default(DEFAULT_REVIEW_TIMEOUT_MS),
|
|
331
|
+
reviewMaxRounds: z.number().min(1).max(MAX_REVIEW_MAX_ROUNDS).default(DEFAULT_REVIEW_MAX_ROUNDS),
|
|
323
332
|
skillReviewTrigger: z.union([
|
|
324
333
|
z.const("cadence"),
|
|
325
334
|
z.const("completion"),
|
|
@@ -353,7 +362,10 @@ function clampReviewConfig(rawConfig, ctx) {
|
|
|
353
362
|
ctx.logger.warn("dsh-evolution-review: " + message);
|
|
354
363
|
};
|
|
355
364
|
const field = (name, value, fallback, min, max) => clampOnce(warned, warn, name, value, fallback, min, max);
|
|
356
|
-
return Object.assign({}, rawConfig, {
|
|
365
|
+
return Object.assign({}, rawConfig, {
|
|
366
|
+
reviewTimeoutMs: field("reviewTimeoutMs", rawConfig.reviewTimeoutMs, DEFAULT_REVIEW_TIMEOUT_MS, 1, MAX_TIMER_DELAY_MS),
|
|
367
|
+
reviewMaxRounds: field("reviewMaxRounds", rawConfig.reviewMaxRounds, DEFAULT_REVIEW_MAX_ROUNDS, 1, MAX_REVIEW_MAX_ROUNDS)
|
|
368
|
+
});
|
|
357
369
|
}
|
|
358
370
|
/**
|
|
359
371
|
* This row's review knobs as they stand RIGHT NOW (G1 §8.3) — the base layer of the
|
|
@@ -777,12 +789,44 @@ function apply(ctx, rawConfig = {}) {
|
|
|
777
789
|
* created; the parent Agent is used only for tool scope/approval, with no log.
|
|
778
790
|
*/
|
|
779
791
|
let inFlightControllers = /* @__PURE__ */ new Set();
|
|
792
|
+
/**
|
|
793
|
+
* Freeze the parent prefix for an aux review.
|
|
794
|
+
*
|
|
795
|
+
* The review executor requires an idle parent because it reuses the live
|
|
796
|
+
* request prefix and refuses if the session grows. A long goal loop is never
|
|
797
|
+
* idle, so aux review could never run there. A frozen proxy keeps the exact
|
|
798
|
+
* messages/header/tool-history/seq at the trigger point; review tools still
|
|
799
|
+
* execute with the real parent agent (real Session/scope/approval), and the
|
|
800
|
+
* parent can continue without the seq guard tripping.
|
|
801
|
+
*/
|
|
802
|
+
function snapshotReviewParent(agent) {
|
|
803
|
+
const session = agent.session;
|
|
804
|
+
const seq = session.seq;
|
|
805
|
+
const header = session.requestHeader();
|
|
806
|
+
const messages = session.deriveMessages();
|
|
807
|
+
const toolHistory = session.toolHistory();
|
|
808
|
+
const snapshotSession = {
|
|
809
|
+
id: session.id,
|
|
810
|
+
header: session.header,
|
|
811
|
+
seq,
|
|
812
|
+
requestHeader: () => header,
|
|
813
|
+
deriveMessages: () => messages,
|
|
814
|
+
toolHistory: () => toolHistory
|
|
815
|
+
};
|
|
816
|
+
return new Proxy(agent, { get(target, property) {
|
|
817
|
+
if (property === "status") return "idle";
|
|
818
|
+
if (property === "session") return snapshotSession;
|
|
819
|
+
const value = Reflect.get(target, property, target);
|
|
820
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
821
|
+
} });
|
|
822
|
+
}
|
|
780
823
|
async function tryAuxReview(session, agent, kind, signal, reason) {
|
|
781
824
|
const running = auxRunning.get(session.id);
|
|
782
825
|
if (running !== void 0) {
|
|
783
826
|
running.rerun = kind;
|
|
784
827
|
return true;
|
|
785
828
|
}
|
|
829
|
+
const reviewParent = snapshotReviewParent(agent);
|
|
786
830
|
const header = session.requestHeader();
|
|
787
831
|
if (header === void 0) {
|
|
788
832
|
ctx.logger.warn("dsh-evolution-review: aux review skipped — parent has no request header");
|
|
@@ -850,14 +894,17 @@ function apply(ctx, rawConfig = {}) {
|
|
|
850
894
|
let status = "failed";
|
|
851
895
|
let actions = [];
|
|
852
896
|
let usage;
|
|
897
|
+
let requests = 0;
|
|
898
|
+
let toolCalls = 0;
|
|
853
899
|
let error;
|
|
854
900
|
try {
|
|
855
901
|
const prompt = reviewPrompt(kind, "aux");
|
|
856
902
|
const result = await withReviewContext({
|
|
857
903
|
reviewId,
|
|
858
|
-
runId: reviewId
|
|
904
|
+
runId: reviewId,
|
|
905
|
+
reads: /* @__PURE__ */ new Set()
|
|
859
906
|
}, () => runReview({
|
|
860
|
-
parent:
|
|
907
|
+
parent: reviewParent,
|
|
861
908
|
llm: { stream: (options) => llm(options) },
|
|
862
909
|
tools: { execute: (input) => tools({
|
|
863
910
|
calls: input.calls,
|
|
@@ -866,12 +913,15 @@ function apply(ctx, rawConfig = {}) {
|
|
|
866
913
|
}) },
|
|
867
914
|
instruction: prompt,
|
|
868
915
|
toolAllow,
|
|
916
|
+
maxRounds: config.reviewMaxRounds,
|
|
869
917
|
signal: controller.signal,
|
|
870
918
|
markReview: () => {},
|
|
871
919
|
clearReview: () => {}
|
|
872
920
|
}));
|
|
873
921
|
finalText = result.finalText;
|
|
874
922
|
actions = result.actions;
|
|
923
|
+
requests = result.requests;
|
|
924
|
+
toolCalls = result.toolCalls;
|
|
875
925
|
if (result.usage !== void 0) usage = {
|
|
876
926
|
inputTokens: result.usage.inputTokens ?? 0,
|
|
877
927
|
outputTokens: result.usage.outputTokens ?? 0,
|
|
@@ -904,6 +954,8 @@ function apply(ctx, rawConfig = {}) {
|
|
|
904
954
|
},
|
|
905
955
|
finalText,
|
|
906
956
|
actions,
|
|
957
|
+
requests,
|
|
958
|
+
toolCalls,
|
|
907
959
|
...usage === void 0 ? {} : { usage },
|
|
908
960
|
startedAt,
|
|
909
961
|
finishedAt,
|
package/lib/types/index.d.ts
CHANGED
|
@@ -44,6 +44,8 @@ export interface Config {
|
|
|
44
44
|
* the policy snapshot like the memory cadence. */
|
|
45
45
|
reviewSkillInterval?: Volatile<number | undefined>;
|
|
46
46
|
reviewTimeoutMs?: number;
|
|
47
|
+
/** Model requests per aux review run (E2 internal). Default 12; set dozens for incremental condense. */
|
|
48
|
+
reviewMaxRounds?: number;
|
|
47
49
|
/** E3/P1-8 (v11) — TRUE semantics: this flag gates ONLY the completion
|
|
48
50
|
* channel. The cadence latch stays active regardless of the value (a
|
|
49
51
|
* completion-gated deployment still fires at the policy cadence), so
|
|
@@ -87,6 +89,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
87
89
|
reviewMemoryInterval: z<number, number, "volatile">;
|
|
88
90
|
reviewSkillInterval: z<number, number, "volatile">;
|
|
89
91
|
reviewTimeoutMs: z<number, number, "defined">;
|
|
92
|
+
reviewMaxRounds: z<number, number, "defined">;
|
|
90
93
|
skillReviewTrigger: z<"cadence" | "completion" | "both", "cadence" | "completion" | "both", "volatile-defined">;
|
|
91
94
|
reviewWakeInject: z<boolean, boolean, "volatile-defined">;
|
|
92
95
|
reviewNotice: z<boolean, boolean, "volatile-defined">;
|
|
@@ -100,6 +103,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
100
103
|
reviewMemoryInterval: z<number, number, "volatile">;
|
|
101
104
|
reviewSkillInterval: z<number, number, "volatile">;
|
|
102
105
|
reviewTimeoutMs: z<number, number, "defined">;
|
|
106
|
+
reviewMaxRounds: z<number, number, "defined">;
|
|
103
107
|
skillReviewTrigger: z<"cadence" | "completion" | "both", "cadence" | "completion" | "both", "volatile-defined">;
|
|
104
108
|
reviewWakeInject: z<boolean, boolean, "volatile-defined">;
|
|
105
109
|
reviewNotice: z<boolean, boolean, "volatile-defined">;
|
|
@@ -115,6 +119,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
115
119
|
* {@link resolveReviewRowSettings}, which clamps its own numerics. */
|
|
116
120
|
type ClampedReviewConfig = Config & {
|
|
117
121
|
reviewTimeoutMs: number;
|
|
122
|
+
reviewMaxRounds: number;
|
|
118
123
|
};
|
|
119
124
|
/**
|
|
120
125
|
* The DEPLOYMENT layer of this row, clamped once at assembly: the restart-only
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-review",
|
|
3
3
|
"description": "Background review orchestration (community build)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.51.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -29,21 +29,21 @@
|
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@deepseek-ai/schemastery": "^3.18.5",
|
|
32
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
32
|
+
"@lmzhen/dsh-evolution-core": "^0.51.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@deepseek-ai/cordis": "^4.0.5",
|
|
36
36
|
"@deepseek-ai/dsh-agent": "^0.2.2-rc.3",
|
|
37
37
|
"@deepseek-ai/dsh-llm": "^0.2.2-rc.3",
|
|
38
38
|
"@deepseek-ai/dsh-session": "^0.2.2-rc.3",
|
|
39
|
-
"@lmzhen/dsh-evolution-state": "^0.
|
|
39
|
+
"@lmzhen/dsh-evolution-state": "^0.51.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@deepseek-ai/dsh-agent": "^0.2.2-rc.3",
|
|
43
43
|
"@deepseek-ai/dsh-llm": "^0.2.2-rc.3",
|
|
44
44
|
"@deepseek-ai/dsh-session": "^0.2.2-rc.3",
|
|
45
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
46
|
-
"@lmzhen/dsh-evolution-state": "^0.
|
|
45
|
+
"@lmzhen/dsh-evolution-core": "^0.51.1",
|
|
46
|
+
"@lmzhen/dsh-evolution-state": "^0.51.1"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"dsh": ">=0.2.2-rc.3 <0.2.3-0"
|