@lmzhen/dsh-evolution-review 0.59.0 → 0.59.2
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 +38 -23
- package/lib/types/index.d.ts +2 -2
- package/lib/types/review-ptc-channel.d.ts +11 -3
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -469,6 +469,16 @@ function filterToolSet(full, allowed) {
|
|
|
469
469
|
...typeof full.dispose === "function" ? { dispose: () => full.dispose() } : {}
|
|
470
470
|
};
|
|
471
471
|
}
|
|
472
|
+
/** Build the PTC program SDK text from the child's assembled tool sections. */
|
|
473
|
+
async function ptcSdkInstruction(tools, childAgent, allowedTools) {
|
|
474
|
+
const systemPrompt = (childAgent?.ctx)?.get?.("systemPrompt");
|
|
475
|
+
if (systemPrompt === void 0 || typeof systemPrompt.assemble !== "function" || tools.resolve === void 0) return "";
|
|
476
|
+
const toolSet = filterToolSet(await tools.resolve({ agent: childAgent }), allowedTools);
|
|
477
|
+
return (await systemPrompt.assemble({
|
|
478
|
+
scope: childAgent,
|
|
479
|
+
toolSet
|
|
480
|
+
})).sections.filter((section) => section.name === "tools:ptc-only" || section.name === "tools:sdk").map((section) => section.text).filter((text) => text.length > 0).join("\n\n");
|
|
481
|
+
}
|
|
472
482
|
const PTC_INSTRUCTION = "You are reviewing in PTC mode. Write one or more run_code programs that call the available review tools. When the review is complete, call tools.review_done as the only review action of that program. A precise no-op is still completed: always finish with tools.review_done instead of stopping without it. If a write reports resource-busy, call tools.review_wait and then re-read before retrying.";
|
|
473
483
|
function asObject(value) {
|
|
474
484
|
return value !== null && typeof value === "object" ? value : void 0;
|
|
@@ -588,9 +598,19 @@ var PtcReviewToolHost = class {
|
|
|
588
598
|
return reviewId !== void 0 && this.active.has(reviewId);
|
|
589
599
|
} }));
|
|
590
600
|
}
|
|
591
|
-
/**
|
|
592
|
-
channel
|
|
601
|
+
/**
|
|
602
|
+
* Build one task channel over the shared registration.
|
|
603
|
+
*
|
|
604
|
+
* `toolSetAgent` owns the TOOL CATALOG used for the program SDK; `childAgent`
|
|
605
|
+
* owns execution and its detached session. They are deliberately separate:
|
|
606
|
+
* the child's own PTC presentation view exposes only `run_code`, while the
|
|
607
|
+
* nested program must see the review tools inherited from the parent. Resolve
|
|
608
|
+
* the former from the parent and execute/dispatch as the child.
|
|
609
|
+
*/
|
|
610
|
+
async channel(taskId, parentHeaderTools, childAgent, modelSelection, allowedTools, toolSetAgent = childAgent) {
|
|
593
611
|
this.register();
|
|
612
|
+
this.active.add(taskId);
|
|
613
|
+
const sdk = await ptcSdkInstruction(this.tools, childAgent, allowedTools).catch(() => "");
|
|
594
614
|
const control = {
|
|
595
615
|
done: false,
|
|
596
616
|
waitCount: 0
|
|
@@ -600,7 +620,7 @@ var PtcReviewToolHost = class {
|
|
|
600
620
|
return {
|
|
601
621
|
mode: "ptc",
|
|
602
622
|
visibleTools: parentHeaderTools,
|
|
603
|
-
instruction: PTC_INSTRUCTION,
|
|
623
|
+
instruction: sdk === "" ? PTC_INSTRUCTION : "You are reviewing in PTC mode. Write one or more run_code programs that call the available review tools. When the review is complete, call tools.review_done as the only review action of that program. A precise no-op is still completed: always finish with tools.review_done instead of stopping without it. If a write reports resource-busy, call tools.review_wait and then re-read before retrying.\n\n" + sdk,
|
|
604
624
|
control,
|
|
605
625
|
completion: () => control.done && control.report !== void 0 ? {
|
|
606
626
|
done: true,
|
|
@@ -608,24 +628,19 @@ var PtcReviewToolHost = class {
|
|
|
608
628
|
waitCount: control.waitCount
|
|
609
629
|
} : void 0,
|
|
610
630
|
async execute(calls, signal) {
|
|
611
|
-
host.
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
...toolSet === void 0 ? {} : { toolSet }
|
|
625
|
-
});
|
|
626
|
-
} finally {
|
|
627
|
-
host.active.delete(taskId);
|
|
628
|
-
}
|
|
631
|
+
if (host.tools.execute === void 0) throw new Error("PTC review channel requires tools.execute");
|
|
632
|
+
if (host.tools.resolve === void 0) throw new Error("PTC review channel requires tools.resolve for the review allowlist");
|
|
633
|
+
const toolSet = filterToolSet(await host.tools.resolve({
|
|
634
|
+
agent: toolSetAgent,
|
|
635
|
+
modelSelection,
|
|
636
|
+
signal
|
|
637
|
+
}), allowedTools);
|
|
638
|
+
return await host.tools.execute({
|
|
639
|
+
calls,
|
|
640
|
+
signal,
|
|
641
|
+
agent: childAgent,
|
|
642
|
+
...toolSet === void 0 ? {} : { toolSet }
|
|
643
|
+
});
|
|
629
644
|
},
|
|
630
645
|
dispose() {
|
|
631
646
|
host.active.delete(taskId);
|
|
@@ -1568,7 +1583,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
1568
1583
|
ptcToolHost = new PtcReviewToolHost(toolsService, reviewWriteLocks);
|
|
1569
1584
|
ptcToolHost.register();
|
|
1570
1585
|
}
|
|
1571
|
-
if (reviewChild !== void 0 && ptcToolHost !== void 0) channel = ptcToolHost.channel(reviewId, header.tools ?? [], reviewChild.agent, {
|
|
1586
|
+
if (reviewChild !== void 0 && ptcToolHost !== void 0) channel = await ptcToolHost.channel(reviewId, header.tools ?? [], reviewChild.agent, {
|
|
1572
1587
|
provider: header.config.provider,
|
|
1573
1588
|
model: header.config.model
|
|
1574
1589
|
}, new Set([
|
|
@@ -1576,7 +1591,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
1576
1591
|
"run_code",
|
|
1577
1592
|
"review_done",
|
|
1578
1593
|
"review_wait"
|
|
1579
|
-
]));
|
|
1594
|
+
]), reviewChild.agent);
|
|
1580
1595
|
} catch (error) {
|
|
1581
1596
|
await reviewChild?.dispose();
|
|
1582
1597
|
releaseKind();
|
package/lib/types/index.d.ts
CHANGED
|
@@ -93,7 +93,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
93
93
|
reviewTimeoutMs: z<number, number, "defined">;
|
|
94
94
|
reviewMaxRounds: z<number, number, "defined">;
|
|
95
95
|
reviewMaxToolCalls: z<number, number, "defined">;
|
|
96
|
-
skillReviewTrigger: z<"
|
|
96
|
+
skillReviewTrigger: z<"completion" | "cadence" | "both", "completion" | "cadence" | "both", "volatile-defined">;
|
|
97
97
|
reviewWakeInject: z<boolean, boolean, "volatile-defined">;
|
|
98
98
|
reviewNotice: z<boolean, boolean, "volatile-defined">;
|
|
99
99
|
sessionScoped: z<boolean, boolean, "defined">;
|
|
@@ -108,7 +108,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
|
108
108
|
reviewTimeoutMs: z<number, number, "defined">;
|
|
109
109
|
reviewMaxRounds: z<number, number, "defined">;
|
|
110
110
|
reviewMaxToolCalls: z<number, number, "defined">;
|
|
111
|
-
skillReviewTrigger: z<"
|
|
111
|
+
skillReviewTrigger: z<"completion" | "cadence" | "both", "completion" | "cadence" | "both", "volatile-defined">;
|
|
112
112
|
reviewWakeInject: z<boolean, boolean, "volatile-defined">;
|
|
113
113
|
reviewNotice: z<boolean, boolean, "volatile-defined">;
|
|
114
114
|
sessionScoped: z<boolean, boolean, "defined">;
|
|
@@ -29,13 +29,21 @@ export declare class PtcReviewToolHost {
|
|
|
29
29
|
constructor(tools: PtcTools, locks: ReviewWriteLocks);
|
|
30
30
|
/** Register the review-only tools once; idempotent. */
|
|
31
31
|
register(): void;
|
|
32
|
-
/**
|
|
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
|
+
*/
|
|
33
41
|
channel(taskId: string, parentHeaderTools: readonly {
|
|
34
42
|
readonly name: string;
|
|
35
|
-
}[], childAgent: unknown, modelSelection: unknown, allowedTools: ReadonlySet<string
|
|
43
|
+
}[], childAgent: unknown, modelSelection: unknown, allowedTools: ReadonlySet<string>, toolSetAgent?: unknown): Promise<ReviewToolChannel & {
|
|
36
44
|
control: PtcReviewControl;
|
|
37
45
|
dispose(): void;
|
|
38
|
-
}
|
|
46
|
+
}>;
|
|
39
47
|
/** Remove the global registrations; used when the plugin fiber unloads. */
|
|
40
48
|
dispose(): void;
|
|
41
49
|
}
|
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.59.
|
|
4
|
+
"version": "0.59.2",
|
|
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.59.
|
|
33
|
-
"@lmzhen/dsh-evolution-platform-contract": "0.59.
|
|
34
|
-
"@lmzhen/dsh-evolution-adapter": "0.59.
|
|
32
|
+
"@lmzhen/dsh-evolution-core": "0.59.2",
|
|
33
|
+
"@lmzhen/dsh-evolution-platform-contract": "0.59.2",
|
|
34
|
+
"@lmzhen/dsh-evolution-adapter": "0.59.2"
|
|
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.59.
|
|
41
|
+
"@lmzhen/dsh-evolution-state": "^0.59.2"
|
|
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.59.
|
|
48
|
-
"@lmzhen/dsh-evolution-state": "^0.59.
|
|
47
|
+
"@lmzhen/dsh-evolution-core": "^0.59.2",
|
|
48
|
+
"@lmzhen/dsh-evolution-state": "^0.59.2"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
51
|
"dsh": "0.2.2-rc.5"
|