@shgroup/dsh-serenity-hooks 1.18.1 → 1.18.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/dsh.plugin.json +1 -1
- package/lib/index.js +45 -11
- package/package.json +1 -1
package/dsh.plugin.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "dsh-serenity-hooks",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.2",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"description": "宁静号 ACC harness(Native Cordis 插件):真实 DSH 工具 cc_fs/session/acc_msm/eap/neat/cce/loop + 拦截缝机械约束(safe-mode/路径守卫/会话落盘)。适配 DSH 公开版(0.1.0-rc,deepseek-ai/deepseek-harness)。私有(dsh-external 组织)。",
|
|
6
6
|
"engines": {
|
package/lib/index.js
CHANGED
|
@@ -3621,10 +3621,11 @@ function resolveBootstrapSettings(opts) {
|
|
|
3621
3621
|
if (promoteOn !== "either" && promoteOn !== "tool-call" && promoteOn !== "assistant-message") throw new TypeError(`bootstrap: promoteOn must be one of "tool-call", "assistant-message", "either"; got ${JSON.stringify(promoteOn)}`);
|
|
3622
3622
|
return {
|
|
3623
3623
|
bootstrapTools: stringList(opts.bootstrapTools, "bootstrapTools", DEFAULT_BOOTSTRAP_TOOLS),
|
|
3624
|
-
promoteEvents: PROMOTE_EVENTS[promoteOn],
|
|
3624
|
+
promoteEvents: opts.zeroTools ? PROMOTE_EVENTS["assistant-message"] : PROMOTE_EVENTS[promoteOn],
|
|
3625
3625
|
suppressedSources: sourceList(opts.suppressedContextSources, "suppressedContextSources", DEFAULT_SUPPRESSED_SOURCES),
|
|
3626
3626
|
compactionTools: stringList(opts.compactionTools, "compactionTools", DEFAULT_COMPACTION_TOOLS),
|
|
3627
|
-
anchorMessage: typeof opts.anchorMessage === "string" && opts.anchorMessage.length > 0 ? opts.anchorMessage : DEFAULT_ANCHOR_MESSAGE
|
|
3627
|
+
anchorMessage: typeof opts.anchorMessage === "string" && opts.anchorMessage.length > 0 ? opts.anchorMessage : DEFAULT_ANCHOR_MESSAGE,
|
|
3628
|
+
zeroTools: opts.zeroTools === true
|
|
3628
3629
|
};
|
|
3629
3630
|
}
|
|
3630
3631
|
/**
|
|
@@ -3653,15 +3654,30 @@ function readBootstrapConfig(agent) {
|
|
|
3653
3654
|
promoteOn: b?.promoteOn,
|
|
3654
3655
|
suppressedContextSources: b?.suppressedContextSources,
|
|
3655
3656
|
compactionTools: b?.compactionTools,
|
|
3656
|
-
anchorMessage: b?.anchorMessage
|
|
3657
|
+
anchorMessage: b?.anchorMessage,
|
|
3658
|
+
zeroTools: b?.zeroTools
|
|
3657
3659
|
});
|
|
3658
3660
|
}
|
|
3659
3661
|
function registerBootstrap(ctx) {
|
|
3660
3662
|
const settingsByRoot = /* @__PURE__ */ new Map();
|
|
3661
|
-
const
|
|
3663
|
+
const trackers = /* @__PURE__ */ new Map();
|
|
3664
|
+
const trackerFor = (root, settings) => {
|
|
3665
|
+
let t = trackers.get(root);
|
|
3666
|
+
if (!t) {
|
|
3667
|
+
t = createEpochPromotion(settings.promoteEvents);
|
|
3668
|
+
trackers.set(root, t);
|
|
3669
|
+
}
|
|
3670
|
+
return t;
|
|
3671
|
+
};
|
|
3662
3672
|
ctx.on("session/event", (session, event) => {
|
|
3663
3673
|
try {
|
|
3664
|
-
|
|
3674
|
+
const cwd = session?.header?.cwd;
|
|
3675
|
+
if (typeof cwd !== "string") return;
|
|
3676
|
+
const root = findSerenityRoot(cwd);
|
|
3677
|
+
if (!root) return;
|
|
3678
|
+
const settings = settingsByRoot.get(root) ?? readBootstrapConfig({ session });
|
|
3679
|
+
settingsByRoot.set(root, settings);
|
|
3680
|
+
trackerFor(root, settings).observe(session, event);
|
|
3665
3681
|
} catch {}
|
|
3666
3682
|
});
|
|
3667
3683
|
ctx.on("agent/inbox/inserted", ({ agent, message }) => {
|
|
@@ -3708,13 +3724,29 @@ function registerBootstrap(ctx) {
|
|
|
3708
3724
|
if (!root) return assembled;
|
|
3709
3725
|
const settings = settingsByRoot.get(root) ?? readBootstrapConfig(agent);
|
|
3710
3726
|
settingsByRoot.set(root, settings);
|
|
3711
|
-
const status =
|
|
3727
|
+
const status = trackerFor(root, settings).status(agent);
|
|
3712
3728
|
if (status.promoted) return assembled;
|
|
3713
|
-
const keep = new Set(settings.bootstrapTools);
|
|
3714
|
-
if (status.boundary >= 0) for (const toolName of settings.compactionTools) keep.add(toolName);
|
|
3715
3729
|
const tools = assembled.tools;
|
|
3716
3730
|
if (!Array.isArray(tools)) return assembled;
|
|
3717
3731
|
const available = new Set(tools.map((tool) => tool.name).filter((n) => typeof n === "string"));
|
|
3732
|
+
if (settings.zeroTools) {
|
|
3733
|
+
if (status.boundary < 0) return {
|
|
3734
|
+
...assembled,
|
|
3735
|
+
tools: []
|
|
3736
|
+
};
|
|
3737
|
+
const keep = new Set(settings.compactionTools);
|
|
3738
|
+
const missing = [...keep].filter((name) => !available.has(name));
|
|
3739
|
+
if (missing.length > 0) {
|
|
3740
|
+
warnOnce(`expected compaction tools missing=${JSON.stringify(missing)} — bootstrap disabled, full catalog exposed`);
|
|
3741
|
+
return assembled;
|
|
3742
|
+
}
|
|
3743
|
+
return {
|
|
3744
|
+
...assembled,
|
|
3745
|
+
tools: tools.filter((tool) => typeof tool.name === "string" && keep.has(tool.name))
|
|
3746
|
+
};
|
|
3747
|
+
}
|
|
3748
|
+
const keep = new Set(settings.bootstrapTools);
|
|
3749
|
+
if (status.boundary >= 0) for (const toolName of settings.compactionTools) keep.add(toolName);
|
|
3718
3750
|
const missing = [...keep].filter((name) => !available.has(name));
|
|
3719
3751
|
if (missing.length > 0) {
|
|
3720
3752
|
warnOnce(`expected bootstrap tools missing=${JSON.stringify(missing)} — bootstrap disabled, full catalog exposed`);
|
|
@@ -3733,9 +3765,11 @@ function registerBootstrap(ctx) {
|
|
|
3733
3765
|
const decision = await next();
|
|
3734
3766
|
if (decision.kind === "reject") return decision;
|
|
3735
3767
|
try {
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3768
|
+
const root = agentRoot(agent);
|
|
3769
|
+
if (!root) return decision;
|
|
3770
|
+
const settings = settingsByRoot.get(root) ?? readBootstrapConfig(agent);
|
|
3771
|
+
settingsByRoot.set(root, settings);
|
|
3772
|
+
if (trackerFor(root, settings).status(agent).promoted || settings.suppressedSources.size === 0) return decision;
|
|
3739
3773
|
const messages = decision.messages;
|
|
3740
3774
|
if (!Array.isArray(messages)) return decision;
|
|
3741
3775
|
const kept = messages.filter((message) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shgroup/dsh-serenity-hooks",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.2",
|
|
4
4
|
"description": "宁静号 ACC harness — Native Cordis 插件(DeepSeek Harness 运行时)。真实 DSH 工具注册(cc_fs/session/acc_msm 等 9 工具)+ 拦截缝机械约束(safe-mode/路径守卫/会话落盘)+ 系统提示词注入(ACC/CCE/Constraints/SKILL/Session 五块)。适配 DSH 公开版(deepseek-ai/deepseek-harness 0.1.0-rc)。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|