@shgroup/dsh-serenity-hooks 1.19.1 → 1.19.3
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 +32 -13
- 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.19.
|
|
3
|
+
"version": "1.19.3",
|
|
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
|
@@ -3567,9 +3567,17 @@ const DEFAULT_ANCHOR_MESSAGE = "You are a helpful software engineer assistant.Th
|
|
|
3567
3567
|
* requiredSignals:晋升所需信号数(boundary 后累计;默认 1)。
|
|
3568
3568
|
* 多轮锚定(v4):两轮递进锚定时 requiredSignals = 锚定轮数——
|
|
3569
3569
|
* 每条锚定回复(assistant/message)计一次,最后一条回复后晋升。
|
|
3570
|
+
*
|
|
3571
|
+
* maxRoundsFallback:**轮次兜底**(v1.19.3 修复 responses API 兼容)。
|
|
3572
|
+
* 某些模型/协议(如 opencode-go-responses)的会话可能不产生标准
|
|
3573
|
+
* `assistant/message` 晋升信号 → 永不晋升 → bootstrap 阶段工具被裁空
|
|
3574
|
+
* (zeroTools 首请求 0 工具,ACC 工具不可见)。兜底:无论晋升信号是否
|
|
3575
|
+
* 到达,观察到的模型回复轮数(assistant/message 事件计数,独立于
|
|
3576
|
+
* promoteEvents)达到 maxRoundsFallback 即强制 promoted(开放完整工具)。
|
|
3577
|
+
* 正常模型锚定轮数(requiredSignals)通常 ≤ 2 < 默认兜底 3,不受影响。
|
|
3570
3578
|
*/
|
|
3571
|
-
function createEpochPromotion(promoteEvents, requiredSignals = 1) {
|
|
3572
|
-
/** sessionId -> { boundary, signalCount }(
|
|
3579
|
+
function createEpochPromotion(promoteEvents, requiredSignals = 1, maxRoundsFallback = 3) {
|
|
3580
|
+
/** sessionId -> { boundary, signalCount, rounds }(rounds = 兜底用回复轮计数) */
|
|
3573
3581
|
const state = /* @__PURE__ */ new Map();
|
|
3574
3582
|
const sessionIdOf = (session) => {
|
|
3575
3583
|
if (session && typeof session === "object") {
|
|
@@ -3577,9 +3585,11 @@ function createEpochPromotion(promoteEvents, requiredSignals = 1) {
|
|
|
3577
3585
|
if (typeof id === "string") return id;
|
|
3578
3586
|
}
|
|
3579
3587
|
};
|
|
3588
|
+
const promotedBy = (entry) => entry.signalCount >= requiredSignals || entry.rounds >= maxRoundsFallback;
|
|
3580
3589
|
const scan = (session) => {
|
|
3581
3590
|
let boundary = -1;
|
|
3582
3591
|
let signalCount = 0;
|
|
3592
|
+
let rounds = 0;
|
|
3583
3593
|
const events = session?.events;
|
|
3584
3594
|
if (Array.isArray(events)) for (const event of events) {
|
|
3585
3595
|
const e = event;
|
|
@@ -3587,20 +3597,23 @@ function createEpochPromotion(promoteEvents, requiredSignals = 1) {
|
|
|
3587
3597
|
if (e.type === "compaction/end") {
|
|
3588
3598
|
boundary = seq;
|
|
3589
3599
|
signalCount = 0;
|
|
3600
|
+
rounds = 0;
|
|
3590
3601
|
continue;
|
|
3591
3602
|
}
|
|
3592
3603
|
if (promoteEvents.has(e.type) && seq > boundary) signalCount++;
|
|
3604
|
+
if (e.type === "assistant/message" && seq > boundary) rounds++;
|
|
3593
3605
|
}
|
|
3594
3606
|
const entry = {
|
|
3595
3607
|
boundary,
|
|
3596
|
-
|
|
3608
|
+
signalCount,
|
|
3609
|
+
rounds
|
|
3597
3610
|
};
|
|
3598
3611
|
const sid = sessionIdOf(session);
|
|
3599
|
-
if (sid) state.set(sid,
|
|
3612
|
+
if (sid) state.set(sid, entry);
|
|
3613
|
+
return {
|
|
3600
3614
|
boundary,
|
|
3601
|
-
|
|
3602
|
-
}
|
|
3603
|
-
return entry;
|
|
3615
|
+
promoted: promotedBy(entry)
|
|
3616
|
+
};
|
|
3604
3617
|
};
|
|
3605
3618
|
return {
|
|
3606
3619
|
status(agent) {
|
|
@@ -3613,6 +3626,11 @@ function createEpochPromotion(promoteEvents, requiredSignals = 1) {
|
|
|
3613
3626
|
boundary: -1,
|
|
3614
3627
|
promoted: true
|
|
3615
3628
|
};
|
|
3629
|
+
const loopSid = session.id;
|
|
3630
|
+
if (typeof loopSid === "string" && loopSid.startsWith("loop-")) return {
|
|
3631
|
+
boundary: -1,
|
|
3632
|
+
promoted: true
|
|
3633
|
+
};
|
|
3616
3634
|
if ((session.header?.delegationDepth ?? 0) > 0) return {
|
|
3617
3635
|
boundary: -1,
|
|
3618
3636
|
promoted: true
|
|
@@ -3625,7 +3643,7 @@ function createEpochPromotion(promoteEvents, requiredSignals = 1) {
|
|
|
3625
3643
|
const s = state.get(sid);
|
|
3626
3644
|
if (s) return {
|
|
3627
3645
|
boundary: s.boundary,
|
|
3628
|
-
promoted: s
|
|
3646
|
+
promoted: promotedBy(s)
|
|
3629
3647
|
};
|
|
3630
3648
|
return scan(session);
|
|
3631
3649
|
},
|
|
@@ -3639,14 +3657,14 @@ function createEpochPromotion(promoteEvents, requiredSignals = 1) {
|
|
|
3639
3657
|
if (e.type === "compaction/end") {
|
|
3640
3658
|
state.set(sid, {
|
|
3641
3659
|
boundary: seq,
|
|
3642
|
-
signalCount: 0
|
|
3660
|
+
signalCount: 0,
|
|
3661
|
+
rounds: 0
|
|
3643
3662
|
});
|
|
3644
3663
|
return;
|
|
3645
3664
|
}
|
|
3646
|
-
if (promoteEvents.has(e.type) && seq > entry.boundary)
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
});
|
|
3665
|
+
if (promoteEvents.has(e.type) && seq > entry.boundary) entry.signalCount++;
|
|
3666
|
+
if (e.type === "assistant/message" && seq > entry.boundary) entry.rounds++;
|
|
3667
|
+
state.set(sid, entry);
|
|
3650
3668
|
}
|
|
3651
3669
|
};
|
|
3652
3670
|
}
|
|
@@ -3746,6 +3764,7 @@ function registerBootstrap(ctx) {
|
|
|
3746
3764
|
const session = agent.session;
|
|
3747
3765
|
const depth = session?.header?.delegationDepth ?? 0;
|
|
3748
3766
|
const sid = typeof session?.id === "string" ? session.id : void 0;
|
|
3767
|
+
if (sid !== void 0 && sid.startsWith("loop-")) return;
|
|
3749
3768
|
if (depth === 0) {
|
|
3750
3769
|
if (session?.events?.some((event) => event.type === "user/message")) return;
|
|
3751
3770
|
} else if (sid !== void 0 && anchoredSessions.has(sid)) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shgroup/dsh-serenity-hooks",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.3",
|
|
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": {
|