@lmzhen/dsh-evolution-review 0.58.0 → 0.59.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 +6 -5
- package/lib/index.js +792 -33
- package/lib/types/index.d.ts +7 -2
- package/lib/types/review-executor.d.ts +28 -1
- package/lib/types/review-limiter.d.ts +23 -0
- package/lib/types/review-ptc-channel.d.ts +51 -0
- package/lib/types/review-tool-channel.d.ts +34 -0
- package/lib/types/review-write-locks.d.ts +35 -0
- package/package.json +7 -7
package/lib/types/index.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ export interface Config {
|
|
|
46
46
|
reviewTimeoutMs?: number;
|
|
47
47
|
/** Model requests per aux review run (E2 internal). Default 12; set dozens for incremental condense. */
|
|
48
48
|
reviewMaxRounds?: number;
|
|
49
|
+
/** Tool calls per aux review run. Default 50; a smaller budget fails to partial, never completed. */
|
|
50
|
+
reviewMaxToolCalls?: number;
|
|
49
51
|
/** E3/P1-8 (v11) — TRUE semantics: this flag gates ONLY the completion
|
|
50
52
|
* channel. The cadence latch stays active regardless of the value (a
|
|
51
53
|
* completion-gated deployment still fires at the policy cadence), so
|
|
@@ -90,7 +92,8 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
90
92
|
reviewSkillInterval: z<number, number, "volatile">;
|
|
91
93
|
reviewTimeoutMs: z<number, number, "defined">;
|
|
92
94
|
reviewMaxRounds: z<number, number, "defined">;
|
|
93
|
-
|
|
95
|
+
reviewMaxToolCalls: z<number, number, "defined">;
|
|
96
|
+
skillReviewTrigger: z<"completion" | "cadence" | "both", "completion" | "cadence" | "both", "volatile-defined">;
|
|
94
97
|
reviewWakeInject: z<boolean, boolean, "volatile-defined">;
|
|
95
98
|
reviewNotice: z<boolean, boolean, "volatile-defined">;
|
|
96
99
|
sessionScoped: z<boolean, boolean, "defined">;
|
|
@@ -104,7 +107,8 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
104
107
|
reviewSkillInterval: z<number, number, "volatile">;
|
|
105
108
|
reviewTimeoutMs: z<number, number, "defined">;
|
|
106
109
|
reviewMaxRounds: z<number, number, "defined">;
|
|
107
|
-
|
|
110
|
+
reviewMaxToolCalls: z<number, number, "defined">;
|
|
111
|
+
skillReviewTrigger: z<"completion" | "cadence" | "both", "completion" | "cadence" | "both", "volatile-defined">;
|
|
108
112
|
reviewWakeInject: z<boolean, boolean, "volatile-defined">;
|
|
109
113
|
reviewNotice: z<boolean, boolean, "volatile-defined">;
|
|
110
114
|
sessionScoped: z<boolean, boolean, "defined">;
|
|
@@ -120,6 +124,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
120
124
|
type ClampedReviewConfig = Config & {
|
|
121
125
|
reviewTimeoutMs: number;
|
|
122
126
|
reviewMaxRounds: number;
|
|
127
|
+
reviewMaxToolCalls: number;
|
|
123
128
|
};
|
|
124
129
|
/**
|
|
125
130
|
* The DEPLOYMENT layer of this row, clamped once at assembly: the restart-only
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ContentBlock, ContextFormed, GenerateOptions, Message, StreamChunk, ToolCallBlock, ToolCallId, ToolHistory } from '@lmzhen/dsh-evolution-platform-contract';
|
|
2
2
|
import type { EpochHeader, SessionId } from '@lmzhen/dsh-evolution-platform-contract';
|
|
3
|
+
import type { ReviewToolChannel } from './review-tool-channel.ts';
|
|
4
|
+
import type { ReviewWriteLocks } from './review-write-locks.ts';
|
|
3
5
|
declare module '@deepseek-ai/dsh-llm' {
|
|
4
6
|
interface MessageSourceMap {
|
|
5
7
|
'evolution-review': {
|
|
@@ -16,7 +18,7 @@ export interface ReviewParent {
|
|
|
16
18
|
readonly seq: number;
|
|
17
19
|
requestHeader(): EpochHeader | undefined;
|
|
18
20
|
deriveMessages(): readonly Message[];
|
|
19
|
-
toolHistory(): ToolHistory | undefined;
|
|
21
|
+
toolHistory?(): ToolHistory | undefined;
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
24
|
/** Outcome of one tool call, shaped by the platform ToolBatchResult. */
|
|
@@ -41,6 +43,20 @@ export interface ReviewToolPort {
|
|
|
41
43
|
export interface ReviewLlmPort {
|
|
42
44
|
stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
|
|
43
45
|
}
|
|
46
|
+
/** Structured completion report required by the aux review protocol. */
|
|
47
|
+
export interface ReviewReport {
|
|
48
|
+
readonly summary: string;
|
|
49
|
+
readonly memoryChanged: boolean;
|
|
50
|
+
readonly skillsChanged: readonly string[];
|
|
51
|
+
readonly unresolved: readonly string[];
|
|
52
|
+
}
|
|
53
|
+
/** The only terminal tool call in an aux review. */
|
|
54
|
+
export declare const REVIEW_DONE_TOOL_NAME = "review_done";
|
|
55
|
+
/** Tool that lets the model wait for a resource lock before re-reading. */
|
|
56
|
+
export declare const REVIEW_WAIT_TOOL_NAME = "review_wait";
|
|
57
|
+
/** Extra instruction appended to aux prompts only; foreground prompts stay unchanged. */
|
|
58
|
+
export declare const AUX_COMPLETION_INSTRUCTION = "When all durable changes for this review are complete, call review_done as the only tool call in your final batch. Do not call it while more edits remain. A precise no-op is still a completed review: always finish with review_done and an unchanged report instead of stopping without it. If a write is locked, call review_wait once, then re-read the target and retry; never reapply a stale patch.";
|
|
59
|
+
export declare function parseReviewReport(raw: string): ReviewReport | undefined;
|
|
44
60
|
export declare class ReviewModelError extends Error {
|
|
45
61
|
readonly code: 'timeout' | 'cancelled' | 'transport';
|
|
46
62
|
constructor(message: string, code: 'timeout' | 'cancelled' | 'transport');
|
|
@@ -66,15 +82,26 @@ export interface ReviewExecutionResult {
|
|
|
66
82
|
readonly usage?: ReviewUsage;
|
|
67
83
|
readonly requests: number;
|
|
68
84
|
readonly toolCalls: number;
|
|
85
|
+
readonly waitCount: number;
|
|
86
|
+
readonly done: boolean;
|
|
87
|
+
readonly hitRoundLimit: boolean;
|
|
88
|
+
readonly report?: ReviewReport;
|
|
89
|
+
readonly partialReason?: string;
|
|
69
90
|
}
|
|
70
91
|
export interface RunReviewInput {
|
|
71
92
|
readonly parent: ReviewParent;
|
|
72
93
|
readonly llm: ReviewLlmPort;
|
|
73
94
|
readonly tools: ReviewToolPort;
|
|
95
|
+
/** Optional native/PTC transport; when present it owns visible tools and execution. */
|
|
96
|
+
readonly channel?: ReviewToolChannel;
|
|
97
|
+
/** Optional process-local write lock registry for recoverable resource-busy results. */
|
|
98
|
+
readonly writeLocks?: ReviewWriteLocks;
|
|
99
|
+
readonly owner?: string;
|
|
74
100
|
readonly instruction: string;
|
|
75
101
|
readonly toolAllow: ReadonlySet<string>;
|
|
76
102
|
readonly signal: AbortSignal;
|
|
77
103
|
readonly maxRounds?: number;
|
|
104
|
+
readonly maxToolCalls?: number;
|
|
78
105
|
readonly markReview: () => void;
|
|
79
106
|
readonly clearReview: () => void;
|
|
80
107
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-local bound on concurrent AUX reviews.
|
|
3
|
+
*
|
|
4
|
+
* The family deliberately keeps this small: one semaphore for the plugin
|
|
5
|
+
* instance, no per-session or weighted fairness. A review waits for a slot
|
|
6
|
+
* before its first model request; the bounded queue is what keeps a burst of
|
|
7
|
+
* sessions from opening unbounded LLM streams.
|
|
8
|
+
*
|
|
9
|
+
* @module @lmzhen/dsh-evolution-review/review-limiter
|
|
10
|
+
*/
|
|
11
|
+
/** A tiny FIFO semaphore whose waiters can be aborted by unload/timeout. */
|
|
12
|
+
export declare class ReviewLimiter {
|
|
13
|
+
private readonly limit;
|
|
14
|
+
private active;
|
|
15
|
+
private closed;
|
|
16
|
+
private readonly waiters;
|
|
17
|
+
constructor(limit: number);
|
|
18
|
+
/** Wait for a slot; undefined means the wait was aborted or the limiter closed. */
|
|
19
|
+
acquire(signal?: AbortSignal): Promise<(() => void) | undefined>;
|
|
20
|
+
dispose(): void;
|
|
21
|
+
private releaseOnce;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=review-limiter.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ToolDefinition } from '@lmzhen/dsh-evolution-adapter/values';
|
|
2
|
+
import type { ReviewReport } from './review-executor.ts';
|
|
3
|
+
import type { ReviewToolChannel } from './review-tool-channel.ts';
|
|
4
|
+
import type { ReviewWriteLocks } from './review-write-locks.ts';
|
|
5
|
+
/** Mutable completion state filled by the in-code review tools. */
|
|
6
|
+
export interface PtcReviewControl {
|
|
7
|
+
done: boolean;
|
|
8
|
+
report?: ReviewReport;
|
|
9
|
+
waitCount: number;
|
|
10
|
+
}
|
|
11
|
+
type PtcTools = {
|
|
12
|
+
register(definition: ToolDefinition, options?: {
|
|
13
|
+
when?: () => boolean;
|
|
14
|
+
}): () => void;
|
|
15
|
+
resolve?: (context: unknown) => Promise<unknown>;
|
|
16
|
+
execute?: (input: unknown) => Promise<unknown>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* One shared registration surface for all PTC review channels in this plugin
|
|
20
|
+
* instance. Construct once, `register()` once, then `channel()` per task.
|
|
21
|
+
*/
|
|
22
|
+
export declare class PtcReviewToolHost {
|
|
23
|
+
private readonly tools;
|
|
24
|
+
private readonly locks;
|
|
25
|
+
private readonly controls;
|
|
26
|
+
private readonly active;
|
|
27
|
+
private disposers;
|
|
28
|
+
private registered;
|
|
29
|
+
constructor(tools: PtcTools, locks: ReviewWriteLocks);
|
|
30
|
+
/** Register the review-only tools once; idempotent. */
|
|
31
|
+
register(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Build one task channel over the shared registration.
|
|
34
|
+
*
|
|
35
|
+
* `toolSetAgent` owns the TOOL CATALOG used for the program SDK; `childAgent`
|
|
36
|
+
* owns execution and its detached session. They are deliberately separate:
|
|
37
|
+
* the child's own PTC presentation view exposes only `run_code`, while the
|
|
38
|
+
* nested program must see the review tools inherited from the parent. Resolve
|
|
39
|
+
* the former from the parent and execute/dispatch as the child.
|
|
40
|
+
*/
|
|
41
|
+
channel(taskId: string, parentHeaderTools: readonly {
|
|
42
|
+
readonly name: string;
|
|
43
|
+
}[], childAgent: unknown, modelSelection: unknown, allowedTools: ReadonlySet<string>, toolSetAgent?: unknown): Promise<ReviewToolChannel & {
|
|
44
|
+
control: PtcReviewControl;
|
|
45
|
+
dispose(): void;
|
|
46
|
+
}>;
|
|
47
|
+
/** Remove the global registrations; used when the plugin fiber unloads. */
|
|
48
|
+
dispose(): void;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=review-ptc-channel.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Review tool transport boundary.
|
|
3
|
+
*
|
|
4
|
+
* The review runner owns completion/limits; a channel owns the concrete tool
|
|
5
|
+
* protocol. Native keeps the parent-visible tool catalog byte-identical for
|
|
6
|
+
* prefix caching and enforces the review allowlist at dispatch; PTC supplies the
|
|
7
|
+
* same port from a detached review child. The runner never branches on the
|
|
8
|
+
* platform tool mode.
|
|
9
|
+
*
|
|
10
|
+
* @module @lmzhen/dsh-evolution-review/review-tool-channel
|
|
11
|
+
*/
|
|
12
|
+
import type { ToolSchema } from '@lmzhen/dsh-evolution-platform-contract';
|
|
13
|
+
import type { ReviewParent, ReviewReport, ReviewToolOutcome, ReviewToolPort } from './review-executor.ts';
|
|
14
|
+
/** One executable tool transport for a review task. */
|
|
15
|
+
export interface ReviewToolChannel {
|
|
16
|
+
readonly mode: 'native' | 'ptc';
|
|
17
|
+
/** Tool schemas the model may see; the runner adds `review_done` itself. */
|
|
18
|
+
readonly visibleTools: readonly ToolSchema[];
|
|
19
|
+
/** Extra instruction appended after the review prompt (channel-specific protocol). */
|
|
20
|
+
readonly instruction?: string;
|
|
21
|
+
/** Completion reported by the channel after a batch (PTC's in-code review_done). */
|
|
22
|
+
completion?(): {
|
|
23
|
+
readonly done: boolean;
|
|
24
|
+
readonly report?: ReviewReport;
|
|
25
|
+
readonly waitCount?: number;
|
|
26
|
+
} | undefined;
|
|
27
|
+
/** Execute the model's calls; implementations must not append to the parent Session. */
|
|
28
|
+
execute(calls: Parameters<ReviewToolPort['execute']>[0]['calls'], signal: AbortSignal): Promise<{
|
|
29
|
+
readonly results: readonly ReviewToolOutcome[];
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
/** Native transport: the frozen parent header's direct tools plus the live tools service. */
|
|
33
|
+
export declare function nativeReviewToolChannel(parent: ReviewParent, toolAllow: ReadonlySet<string>, tools: ReviewToolPort, executionAgent?: unknown): ReviewToolChannel;
|
|
34
|
+
//# sourceMappingURL=review-tool-channel.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-local review write locks.
|
|
3
|
+
*
|
|
4
|
+
* The SkillLibrary's per-directory lock + CAS is the final correctness layer.
|
|
5
|
+
* This small registry gives the review model the *recoverable* state it needs:
|
|
6
|
+
* a second review writing the same skill/memory resource gets a `resource-busy`
|
|
7
|
+
* tool result instead of racing silently, and `review_wait` can wait for the
|
|
8
|
+
* holder to release before the model re-reads and retries.
|
|
9
|
+
*
|
|
10
|
+
* It is intentionally not durable and does not coordinate foreground writers or
|
|
11
|
+
* other processes; those keep their existing HomeFence/CAS guarantees.
|
|
12
|
+
*
|
|
13
|
+
* @module @lmzhen/dsh-evolution-review/review-write-locks
|
|
14
|
+
*/
|
|
15
|
+
/** One process-local holder per resource plus its waiters. */
|
|
16
|
+
export declare class ReviewWriteLocks {
|
|
17
|
+
private closed;
|
|
18
|
+
private readonly holders;
|
|
19
|
+
private readonly waiters;
|
|
20
|
+
/** @returns the holder when the resource is busy, otherwise undefined. */
|
|
21
|
+
holder(resource: string): string | undefined;
|
|
22
|
+
/** Drop all holders and wake waiters; used when the plugin fiber unloads. */
|
|
23
|
+
dispose(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Try to become the holder.
|
|
26
|
+
* @returns the release callback, or undefined when another owner holds it.
|
|
27
|
+
*/
|
|
28
|
+
tryAcquire(resource: string, owner: string): (() => void) | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Wait until the resource has no holder.
|
|
31
|
+
* @returns true when free, false on timeout/abort.
|
|
32
|
+
*/
|
|
33
|
+
wait(resource: string, timeoutMs: number, signal: AbortSignal): Promise<boolean>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=review-write-locks.d.ts.map
|
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.59.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -29,23 +29,23 @@
|
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@deepseek-ai/schemastery": "^3.18.5",
|
|
32
|
-
"@lmzhen/dsh-evolution-core": "0.
|
|
33
|
-
"@lmzhen/dsh-evolution-platform-contract": "0.
|
|
34
|
-
"@lmzhen/dsh-evolution-adapter": "0.
|
|
32
|
+
"@lmzhen/dsh-evolution-core": "0.59.1",
|
|
33
|
+
"@lmzhen/dsh-evolution-platform-contract": "0.59.1",
|
|
34
|
+
"@lmzhen/dsh-evolution-adapter": "0.59.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@deepseek-ai/cordis": "^4.0.5",
|
|
38
38
|
"@deepseek-ai/dsh-agent": "0.2.2-rc.5",
|
|
39
39
|
"@deepseek-ai/dsh-llm": "0.2.2-rc.5",
|
|
40
40
|
"@deepseek-ai/dsh-session": "0.2.2-rc.5",
|
|
41
|
-
"@lmzhen/dsh-evolution-state": "^0.
|
|
41
|
+
"@lmzhen/dsh-evolution-state": "^0.59.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@deepseek-ai/dsh-agent": "0.2.2-rc.5",
|
|
45
45
|
"@deepseek-ai/dsh-llm": "0.2.2-rc.5",
|
|
46
46
|
"@deepseek-ai/dsh-session": "0.2.2-rc.5",
|
|
47
|
-
"@lmzhen/dsh-evolution-core": "^0.
|
|
48
|
-
"@lmzhen/dsh-evolution-state": "^0.
|
|
47
|
+
"@lmzhen/dsh-evolution-core": "^0.59.1",
|
|
48
|
+
"@lmzhen/dsh-evolution-state": "^0.59.1"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
51
|
"dsh": "0.2.2-rc.5"
|