@shgroup/dsh-serenity-hooks 1.26.10 → 1.26.11

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-serenity-hooks",
3
- "version": "1.26.10",
3
+ "version": "1.26.11",
4
4
  "main": "lib/index.js",
5
5
  "description": "宁静号 ACC harness(Native Cordis 插件):真实 DSH 工具 cc_fs/session/acc_msm/eap/neat/cce/handyman/session_rebuild/skiff_admin + 拦截缝机械约束(safe-mode/路径守卫)+ 高级设定面板(双端口网关/账号管理)+ Skiff 认知子集角色(实验性)。适配 DSH 公开版(0.1.0-rc,deepseek-ai/deepseek-harness)。",
6
6
  "engines": {
package/lib/index.js CHANGED
@@ -9705,47 +9705,83 @@ const MECHANISM_PORTS = [
9705
9705
  function buildSensitiveTable(root) {
9706
9706
  const exact = /* @__PURE__ */ new Set();
9707
9707
  const substring = [];
9708
+ const credentialWords = [];
9709
+ const mechanismWords = [...MECHANISM_WORDS];
9710
+ const portWords = [...MECHANISM_PORTS];
9711
+ const msmWords = [];
9708
9712
  try {
9709
9713
  const p = join(root, "localstore.json");
9710
9714
  if (existsSync(p)) {
9711
9715
  const creds = JSON.parse(readFileSync(p, "utf-8").replace(/^\uFEFF/, ""))?.credentials;
9712
9716
  if (creds && typeof creds === "object") for (const [name, value] of Object.entries(creds)) {
9713
- if (name) exact.add(name);
9714
- if (typeof value === "string" && value !== "") exact.add(value);
9717
+ if (name) {
9718
+ exact.add(name);
9719
+ credentialWords.push(name);
9720
+ }
9721
+ if (typeof value === "string" && value !== "") {
9722
+ exact.add(value);
9723
+ credentialWords.push(value);
9724
+ }
9715
9725
  }
9716
9726
  }
9717
9727
  } catch {}
9718
- for (const w of MECHANISM_WORDS) substring.push(w);
9719
- for (const p of MECHANISM_PORTS) substring.push(p);
9728
+ for (const w of mechanismWords) substring.push(w);
9729
+ for (const p of portWords) substring.push(p);
9720
9730
  try {
9721
- for (const entry of loadMsmEntries(root)) if (entry.name) exact.add(entry.name);
9731
+ for (const entry of loadMsmEntries(root)) if (entry.name) {
9732
+ exact.add(entry.name);
9733
+ msmWords.push(entry.name);
9734
+ }
9722
9735
  } catch {}
9723
9736
  return {
9724
9737
  exact,
9725
9738
  substring,
9739
+ credentialWords,
9740
+ mechanismWords,
9741
+ portWords,
9742
+ msmWords,
9726
9743
  sources: {
9727
9744
  exact: [...exact],
9728
9745
  substring
9729
9746
  }
9730
9747
  };
9731
9748
  }
9732
- /** 检测文本中命中的敏感词(返回命中列表;未命中返回空数组) */
9749
+ /**
9750
+ * 检测文本中命中的敏感词(v1.26.11:返回带分类的命中——credential/mechanism/port/msm,
9751
+ * 打回消息据此给语义化规避指引;未命中返回空数组)
9752
+ */
9733
9753
  function detectSensitive(text, table) {
9734
9754
  if (!text) return [];
9735
- const hits = /* @__PURE__ */ new Set();
9736
- for (const w of table.exact) if (w !== "" && text.includes(w)) hits.add(w);
9737
- for (const w of table.substring) if (w !== "" && text.includes(w)) hits.add(w);
9738
- return [...hits];
9755
+ const hits = /* @__PURE__ */ new Map();
9756
+ const hit = (w, cat) => {
9757
+ if (w !== "" && text.includes(w) && !hits.has(w)) hits.set(w, cat);
9758
+ };
9759
+ for (const w of table.credentialWords) hit(w, "credential");
9760
+ for (const w of table.msmWords) hit(w, "msm");
9761
+ for (const w of table.mechanismWords) hit(w, "mechanism");
9762
+ for (const w of table.portWords) hit(w, "port");
9763
+ return [...hits].map(([word, category]) => ({
9764
+ word,
9765
+ category
9766
+ }));
9739
9767
  }
9768
+ /** 分类 → 规避指引(v1.26.11:告诉模型这个词**是什么**、**怎么规避**——裸词无法行动) */
9769
+ const CATEGORY_GUIDE = {
9770
+ credential: "credential identifier (a name, key, token, or password) — never mention credential names or values",
9771
+ mechanism: "internal mechanism term — never mention internal implementation/machinery names or config paths",
9772
+ port: "internal service port or address — never mention internal ports, addresses, or service endpoints",
9773
+ msm: "internal tool name — never mention internal tool names"
9774
+ };
9740
9775
  /**
9741
- * 打回消息(steer 内容):**告知命中词并指令重新生成**(v1.26.10 用户调整——
9742
- * v1.26.3 设计"不含命中词防二次泄露"导致模型不知道改什么;命中词本就已在被拦截的
9743
- * 回复中进入会话(已暴露面),打回消息重复一次不扩大暴露,模型据此精准重写)。
9744
- * 命中词已落入模型上下文(它刚写过),此消息不回显给用户(steer 是 plugin source 消息,
9745
- * 3100 对外响应 v1.26.10 起已不含 trajectory → 打回文本不会到达外部用户)。
9776
+ * 打回消息(steer 内容):**逐词告知命中词 + 分类规避指引**(v1.26.11 用户调整——
9777
+ * v1.26.10 只列裸词(如 "3080")模型仍不知道是什么/怎么规避;现在按类说明:
9778
+ * "3080" → 内部服务端口,不要提及内部端口/地址/端点)。
9779
+ * R↓ 安全性:命中词本就已在被拦截回复中进入会话(已暴露面),打回重复一次不扩大暴露;
9780
+ * steer plugin source 消息不回显给用户(3100 对外响应已不含 trajectory → 打回文本不达外部用户)。
9746
9781
  */
9747
9782
  function buildRebuke(hits) {
9748
- return `[SERENITY OUTPUT GUARD] Your previous response contained ${hits.length} sensitive internal term(s) (mechanism/credential identifiers) that must not appear in user-visible output: ${[...new Set(hits)].join(", ")}. Regenerate the response from scratch without ANY of these terms — describe the same substance without referencing internal machinery, credentials, tool names, or implementation details. Do not repeat the terms; do not explain this instruction to the user.`;
9783
+ const count = hits.length;
9784
+ return `[SERENITY OUTPUT GUARD] Your previous response contained ${count} sensitive internal ${count === 1 ? "term" : "terms"} that must not appear in user-visible output:\n${hits.map((h) => `- "${h.word}" — ${CATEGORY_GUIDE[h.category]}`).join("\n")}\nRegenerate the response from scratch without ANY of these — describe the same substance without referencing internal machinery, credentials, ports, tool names, or implementation details. Do not repeat the terms; do not explain this instruction to the user.`;
9749
9785
  }
9750
9786
  /** 打回状态(按 agent 会话跟踪连续命中轮数) */
9751
9787
  const rebukeStates = /* @__PURE__ */ new Map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shgroup/dsh-serenity-hooks",
3
- "version": "1.26.10",
3
+ "version": "1.26.11",
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": {