@shgroup/dsh-serenity-hooks 1.116.0 → 1.118.0
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/client.js +162 -0
- package/lib/index.js +5 -5
- package/lib/kernel/config.d.ts +20 -0
- package/lib/{observation-BFDDUisK.js → observation-Ci2SBIX2.js} +1 -1
- package/lib/{scheduler-DoyulpUI.js → scheduler-CUPz7geH.js} +78 -1
- package/lib/seams/humor.d.ts +57 -0
- package/lib/seams/system-prompt.d.ts +10 -1
- package/lib/{service-DGNxpE87.js → service-8KAznyDu.js} +3 -3
- package/lib/{session-BVBI5jch.js → session-D3Zsxoip.js} +138 -4
- package/lib/{subscriptions-CUD0d_Sg.js → subscriptions-CGpxv6Z6.js} +2 -2
- package/lib/trajectory/interrupted.d.ts +31 -0
- 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.
|
|
3
|
+
"version": "1.118.0",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"description": "宁静号 ACC harness(Native Cordis 插件):给 DSH 装一个「AI 工作区」——12 个工具(container_fs/cognitive_trajectory/dashboard/container_git/msm/praxis/ontology/serenity-skill-creator/localstore/container_admin;另两个 im-bridge/diagram 按配置条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫)+ 认知轨迹日志与原地重建 + 网页登录入口/IM 桥/认知轨迹唤醒注册表。轨迹声明 = 轨迹目录下的 trajectory.json(约束面 + 旧标识 uid + CRO 机器绑定 cro.host;旧名 trajectory-constraint.json / skiff.json 仍在读取族里);轨迹提示词 = 轨迹目录下的 PROMPT.md(一条轨迹「是谁、按什么章程工作」,所有轨迹通用,追加在容器层与质量层之后,不替换它们)。适配 DSH 0.1.7-rc.1 / 0.2.0-rc.1 / 0.2.1-rc.1(三档,deepseek-ai/deepseek-harness)。",
|
|
6
6
|
"engines": {
|
package/lib/client.js
CHANGED
|
@@ -4054,6 +4054,163 @@ Instruction-following style:
|
|
|
4054
4054
|
});
|
|
4055
4055
|
}
|
|
4056
4056
|
//#endregion
|
|
4057
|
+
//#region src/client/HumorEditor.tsx
|
|
4058
|
+
/**
|
|
4059
|
+
* client/HumorEditor.tsx — 脱口秀片段面板编辑器(D287,2026-11-04 owner 想法)
|
|
4060
|
+
*
|
|
4061
|
+
* ## owner 原话
|
|
4062
|
+
*
|
|
4063
|
+
* > 「在 Serenity 的配置页填写好了,这样比较方便」
|
|
4064
|
+
* > 「收集 30 段,每次随机注入一段;在提示词中要诚恳:先来看看这段脱口秀片段再继续阅读吧」
|
|
4065
|
+
*
|
|
4066
|
+
* ## 交互设计(三个刻意的选择)
|
|
4067
|
+
*
|
|
4068
|
+
* ### ① 一个多行框 + `---` 分隔,⛔ 不是 30 个输入框
|
|
4069
|
+
*
|
|
4070
|
+
* 30 个独立的 input 会让面板变成一堵墙,而且粘贴 30 段要点 30 次。
|
|
4071
|
+
* ⇒ **一个 textarea,`---` 独行分隔**:一次粘贴全部、随时增删、肉眼可见边界。
|
|
4072
|
+
*
|
|
4073
|
+
* ### ② 实时显示段数
|
|
4074
|
+
*
|
|
4075
|
+
* 判据:owner 说"收集 30 段",那**填的时候就要能看见现在有几段** ——
|
|
4076
|
+
* 否则填到第 28 段无从确认。这里显示「当前 N 段」,并提示空段会被忽略。
|
|
4077
|
+
*
|
|
4078
|
+
* ### ③ 原文住用户配置,⛔ 不进仓
|
|
4079
|
+
*
|
|
4080
|
+
* 本仓是 GitHub 公开仓。段子是有版权的创作文本 ⇒
|
|
4081
|
+
* 存在 `~/.dsh/serenity-hooks.json`(仓外),本组件只负责编辑它。
|
|
4082
|
+
* ⛔ 不要往仓库里的任何文件贴段子原文。
|
|
4083
|
+
*/
|
|
4084
|
+
/** 段分隔符(**独占一行**的 `---`);选中它是因为它不会出现在正常段子里 */
|
|
4085
|
+
const SEP = "---";
|
|
4086
|
+
/** 把 textarea 原文按分隔符拆成段(去空段、trim) */
|
|
4087
|
+
function splitBits(raw) {
|
|
4088
|
+
return raw.split(/^---\s*$/m).map((s) => s.trim()).filter((s) => s !== "");
|
|
4089
|
+
}
|
|
4090
|
+
/** 把段数组写回 textarea 形态(与 splitBits 互逆) */
|
|
4091
|
+
function joinBits(bits) {
|
|
4092
|
+
return bits.join(`\n${SEP}\n`);
|
|
4093
|
+
}
|
|
4094
|
+
function HumorEditor() {
|
|
4095
|
+
const [enabled, setEnabled] = (0, react.useState)(false);
|
|
4096
|
+
const [raw, setRaw] = (0, react.useState)("");
|
|
4097
|
+
const [loaded, setLoaded] = (0, react.useState)(false);
|
|
4098
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
4099
|
+
const [error, setError] = (0, react.useState)(null);
|
|
4100
|
+
const [saved, setSaved] = (0, react.useState)(false);
|
|
4101
|
+
const bits = splitBits(raw);
|
|
4102
|
+
(0, react.useEffect)(() => {
|
|
4103
|
+
let alive = true;
|
|
4104
|
+
fetchConfig().then((cfg) => {
|
|
4105
|
+
if (!alive || !cfg) return;
|
|
4106
|
+
setEnabled(cfg.config?.humor?.enabled === true);
|
|
4107
|
+
setRaw(joinBits(cfg.config?.humor?.bits ?? []));
|
|
4108
|
+
setLoaded(true);
|
|
4109
|
+
});
|
|
4110
|
+
return () => {
|
|
4111
|
+
alive = false;
|
|
4112
|
+
};
|
|
4113
|
+
}, []);
|
|
4114
|
+
const save = () => {
|
|
4115
|
+
setBusy(true);
|
|
4116
|
+
setError(null);
|
|
4117
|
+
setSaved(false);
|
|
4118
|
+
saveConfig({ humor: {
|
|
4119
|
+
enabled,
|
|
4120
|
+
bits
|
|
4121
|
+
} }).then((cfg) => {
|
|
4122
|
+
if (cfg) {
|
|
4123
|
+
setEnabled(cfg.humor?.enabled === true);
|
|
4124
|
+
setRaw(joinBits(cfg.humor?.bits ?? []));
|
|
4125
|
+
setSaved(true);
|
|
4126
|
+
setTimeout(() => setSaved(false), 2e3);
|
|
4127
|
+
}
|
|
4128
|
+
}).catch((e) => setError(e instanceof Error ? e.message : String(e))).finally(() => setBusy(false));
|
|
4129
|
+
};
|
|
4130
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4131
|
+
className: "pe-wrap",
|
|
4132
|
+
children: [
|
|
4133
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4134
|
+
className: "pe-row",
|
|
4135
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
4136
|
+
className: "pe-label",
|
|
4137
|
+
htmlFor: "hu-enabled",
|
|
4138
|
+
children: [
|
|
4139
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
4140
|
+
id: "hu-enabled",
|
|
4141
|
+
type: "checkbox",
|
|
4142
|
+
checked: enabled,
|
|
4143
|
+
onChange: (e) => setEnabled(e.target.checked)
|
|
4144
|
+
}),
|
|
4145
|
+
" ",
|
|
4146
|
+
"启用(缺省关;纯装饰,不影响任何判断)"
|
|
4147
|
+
]
|
|
4148
|
+
})
|
|
4149
|
+
}),
|
|
4150
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4151
|
+
className: "pe-row",
|
|
4152
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
4153
|
+
className: "pe-label",
|
|
4154
|
+
htmlFor: "hu-bits",
|
|
4155
|
+
children: [
|
|
4156
|
+
"片段池 —— 用独占一行的 ",
|
|
4157
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: SEP }),
|
|
4158
|
+
" 分隔各段;当前 ",
|
|
4159
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: bits.length }),
|
|
4160
|
+
" 段"
|
|
4161
|
+
]
|
|
4162
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
4163
|
+
id: "hu-bits",
|
|
4164
|
+
className: "pe-textarea",
|
|
4165
|
+
rows: 14,
|
|
4166
|
+
value: raw,
|
|
4167
|
+
placeholder: `第一段完整文本\n${SEP}\n第二段完整文本\n${SEP}\n第三段……\n\n每段会被完整注入,不会截断;空段自动忽略。
|
|
4168
|
+
每开启一条新会话随机选一段,会话进行中保持不变。`,
|
|
4169
|
+
onChange: (e) => setRaw(e.target.value)
|
|
4170
|
+
})]
|
|
4171
|
+
}),
|
|
4172
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4173
|
+
className: "pe-actions",
|
|
4174
|
+
children: [
|
|
4175
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4176
|
+
className: "pe-btn pe-btnGhost",
|
|
4177
|
+
type: "button",
|
|
4178
|
+
onClick: () => setRaw(joinBits([...bits, ""])),
|
|
4179
|
+
disabled: !loaded,
|
|
4180
|
+
children: "追加一段"
|
|
4181
|
+
}),
|
|
4182
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4183
|
+
className: "pe-btn pe-btnGhost",
|
|
4184
|
+
type: "button",
|
|
4185
|
+
onClick: () => setRaw(""),
|
|
4186
|
+
disabled: !loaded,
|
|
4187
|
+
children: "清空"
|
|
4188
|
+
}),
|
|
4189
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4190
|
+
className: "pe-btn pe-btnPrimary",
|
|
4191
|
+
type: "button",
|
|
4192
|
+
onClick: save,
|
|
4193
|
+
disabled: busy || !loaded,
|
|
4194
|
+
children: busy ? "保存中…" : "保存"
|
|
4195
|
+
})
|
|
4196
|
+
]
|
|
4197
|
+
}),
|
|
4198
|
+
enabled && bits.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
4199
|
+
className: "pe-hint pe-hintErr",
|
|
4200
|
+
children: "已启用但池是空的 ⇒ 实际不注入任何内容(等于关闭)。"
|
|
4201
|
+
}),
|
|
4202
|
+
saved && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
4203
|
+
className: "pe-hint pe-hintOk",
|
|
4204
|
+
children: "已保存,新会话即时生效"
|
|
4205
|
+
}),
|
|
4206
|
+
error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
4207
|
+
className: "pe-hint pe-hintErr",
|
|
4208
|
+
children: error
|
|
4209
|
+
})
|
|
4210
|
+
]
|
|
4211
|
+
});
|
|
4212
|
+
}
|
|
4213
|
+
//#endregion
|
|
4057
4214
|
//#region src/client/ImBridgeEditor.tsx
|
|
4058
4215
|
/**
|
|
4059
4216
|
* ImBridgeEditor.tsx — 「IM 桥」配置区块(原 `WeixinBridgeEditor`,2026-10-19 泛化)
|
|
@@ -4997,6 +5154,11 @@ Instruction-following style:
|
|
|
4997
5154
|
desc: "替换输出风格提示词(默认关闭)",
|
|
4998
5155
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PersonaEditor, {})
|
|
4999
5156
|
}),
|
|
5157
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Collapse, {
|
|
5158
|
+
title: "脱口秀片段",
|
|
5159
|
+
desc: "会话开始时随机注入一段到系统提示词(纯装饰,默认关闭)",
|
|
5160
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HumorEditor, {})
|
|
5161
|
+
}),
|
|
5000
5162
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Collapse, {
|
|
5001
5163
|
title: "IM 桥",
|
|
5002
5164
|
desc: "绑定即时通讯账号 · 路由到认知轨迹(CCC 级配置)",
|
package/lib/index.js
CHANGED
|
@@ -6,14 +6,14 @@ import { n as checkLocalstoreGitCompliance, o as readStore, s as runLocalStore,
|
|
|
6
6
|
import { d as findPackageRoot, i as constraintSystemPromptSource, l as resolveConstraintSystemPrompt, r as constraintCognitiveTrajectory, t as TRAJECTORY_CONSTRAINT_HINT, u as ACC_VERSION } from "./rules-DKlpuFN_.js";
|
|
7
7
|
import { C as docsPointer, S as runMsmAsync, _ as CCC_CONFIG_REFERENCE, a as setSafeMode, b as loadMsmEntries, d as forgetNonCccToolVisibility, g as ACC_CATALOG, h as forgetToolVisibility, i as readDshVersion, m as syncToolVisibility, n as summarizeHostContract, o as listOpencodeSkillDirs, p as registerGuards, r as getStatus, s as loadOpencodeSkill, t as hostContractReport, w as setWeixinSendEndpoint, x as runMsm, y as findEntry } from "./contract-qqnsi8tc.js";
|
|
8
8
|
import { c as replacesDefaultIdentity, i as listTrajectoryConstraints, l as trajectoryCodeForSession, n as findDirNameByCode, o as readTrajectoryConstraintAt, r as isTrajectoryConstrained, s as readTrajectoryConstraintByCode, t as TRAJECTORY_CONSTRAINT_FILENAME } from "./profile-Djqz4Noy.js";
|
|
9
|
-
import { A as truncateContent, C as verifyTotpCode, D as buildResourceIndex, E as SKILL_ONTOLOGY_FILE, M as hasTrajectoryPrompt, O as buildResourceNameSuffix, S as MECHANISM_PORTS, T as REFERENCE_DIR, _ as projectKnownWorkspaces, a as trajectoryConstraintFor, b as verifyPassword, c as trajectoryWorkspaceMdPath, d as splitModel, f as registerCognitiveTrajectorySkillSection, g as migrateLegacyLocalstore, h as applyWirePatch, i as getTrajectoryAgent, j as TRAJECTORY_PROMPT_FILENAME, k as isSafeSkillName, l as unregisterTrajectorySession, m as registerEntrySkillSectionGlobal, n as deliverToTrajectory, o as trajectoryConstraintMsmGate, p as registerEntrySkillSection, r as ensureWorkspacePromptSection, s as trajectoryConstraintParticipates, t as createTrajectoryAgent, u as workspaceCognitiveTrajectoryLine, v as readAdvancedSettings, w as recordToolUsage, x as FACE_PORTS, y as toWire } from "./session-
|
|
9
|
+
import { A as truncateContent, C as verifyTotpCode, D as buildResourceIndex, E as SKILL_ONTOLOGY_FILE, M as hasTrajectoryPrompt, O as buildResourceNameSuffix, S as MECHANISM_PORTS, T as REFERENCE_DIR, _ as projectKnownWorkspaces, a as trajectoryConstraintFor, b as verifyPassword, c as trajectoryWorkspaceMdPath, d as splitModel, f as registerCognitiveTrajectorySkillSection, g as migrateLegacyLocalstore, h as applyWirePatch, i as getTrajectoryAgent, j as TRAJECTORY_PROMPT_FILENAME, k as isSafeSkillName, l as unregisterTrajectorySession, m as registerEntrySkillSectionGlobal, n as deliverToTrajectory, o as trajectoryConstraintMsmGate, p as registerEntrySkillSection, r as ensureWorkspacePromptSection, s as trajectoryConstraintParticipates, t as createTrajectoryAgent, u as workspaceCognitiveTrajectoryLine, v as readAdvancedSettings, w as recordToolUsage, x as FACE_PORTS, y as toWire } from "./session-D3Zsxoip.js";
|
|
10
10
|
import { a as ACC_MESSAGE_KIND, d as readLastBound, f as resolveSessionCognitiveTrajectoryLabel, i as toMessage, l as findTrajectoryOfSession, n as deliver, o as PLUGIN_SOURCE, r as makeInjection, s as appendBound } from "./injection-B5jZxemg.js";
|
|
11
|
-
import { _ as addWake, a as DEFAULT_LOOKBACK_MS, c as projectDirNameForCwd, d as registerCroTurnTracking, f as registerDisposer, g as WAKE_CATCH_UP_MS, h as CARRIER_OPENING_MARK, l as scanInterruptedSessions, o as createResumeOne, p as buildCroSnapshot, r as sendToCognitiveTrajectory, s as formatPendingTools, t as registerWakeScheduler, u as listRunningSessionIds } from "./scheduler-
|
|
11
|
+
import { _ as addWake, a as DEFAULT_LOOKBACK_MS, c as projectDirNameForCwd, d as registerCroTurnTracking, f as registerDisposer, g as WAKE_CATCH_UP_MS, h as CARRIER_OPENING_MARK, l as scanInterruptedSessions, o as createResumeOne, p as buildCroSnapshot, r as sendToCognitiveTrajectory, s as formatPendingTools, t as registerWakeScheduler, u as listRunningSessionIds } from "./scheduler-CUPz7geH.js";
|
|
12
12
|
import { i as sessionsRootDir } from "./cleanup-CPl1SSaK.js";
|
|
13
13
|
import { n as readSimpleSettings, r as registerSettingsSection } from "./settings-DibHCfEU.js";
|
|
14
14
|
import { a as readFeishuCredential, c as readWeixinSettings, d as weixinInboundDir, f as weixinSessionIdForTrajectory, i as matchWeixinRoute, n as extractWeixinText, r as hasVoiceItem, s as readWeixinCredential, t as extractWeixinMedia, u as sanitizeFileName$1 } from "./route-D-W3O2PF.js";
|
|
15
15
|
import { i as runImBridge, n as isImWiredTrajectory, r as registerImChannel, t as imChannelIds } from "./channels-DWZlcsE0.js";
|
|
16
|
-
import { i as subscriptionStats, n as registerTrajectorySubscriptions, r as subscriptionEval, t as defaultSubscriptionDeps } from "./subscriptions-
|
|
16
|
+
import { i as subscriptionStats, n as registerTrajectorySubscriptions, r as subscriptionEval, t as defaultSubscriptionDeps } from "./subscriptions-CGpxv6Z6.js";
|
|
17
17
|
import { c as sendTextMessage, i as getUpdates, l as sendTyping, n as downloadMedia, o as markdownToPlainText, r as getConfig, s as sendFileMessage, t as TypingStatus, u as sniffImageExt } from "./ilink-CsZ-f64q.js";
|
|
18
18
|
import { a as registerImAccountImpl, i as normalizeAccountChannel, n as getImAccountImpl, r as imAccountChannels } from "./accounts-BHQbakUh.js";
|
|
19
19
|
import { createRequire } from "node:module";
|
|
@@ -515,7 +515,7 @@ const KIT_ACTIONS = [
|
|
|
515
515
|
async function runKit(root, args, hostCtx) {
|
|
516
516
|
switch (args.action) {
|
|
517
517
|
case "health": {
|
|
518
|
-
const { containerStatus } = await import("./observation-
|
|
518
|
+
const { containerStatus } = await import("./observation-Ci2SBIX2.js");
|
|
519
519
|
const s = containerStatus({
|
|
520
520
|
root,
|
|
521
521
|
hostCtx
|
|
@@ -561,7 +561,7 @@ async function runKit(root, args, hostCtx) {
|
|
|
561
561
|
}
|
|
562
562
|
case "diag": {
|
|
563
563
|
if (hostCtx === void 0) throw new Error("diag requires the plugin context (live session data unavailable without it)");
|
|
564
|
-
const { runDiag, renderDiag } = await import("./service-
|
|
564
|
+
const { runDiag, renderDiag } = await import("./service-8KAznyDu.js");
|
|
565
565
|
return renderDiag(await runDiag(hostCtx, root ?? ""));
|
|
566
566
|
}
|
|
567
567
|
default: throw new Error(`Unknown action: ${args.action}`);
|
package/lib/kernel/config.d.ts
CHANGED
|
@@ -51,6 +51,23 @@ interface PersonaSettings {
|
|
|
51
51
|
/** 用户替换文本(替代 EAP 块 + MSM 原则段的原文) */
|
|
52
52
|
overrideText: string;
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* 脱口秀片段(2026-11-04 owner 想法):
|
|
56
|
+
* 「收集一版各类脱口秀的片段内容,随机在会话开始 / rebuild 时注入一段到系统提示词,
|
|
57
|
+
* 这个不会改变什么行为,但是会让过程变得有趣」+「要有个开关」。
|
|
58
|
+
*
|
|
59
|
+
* 🔴 **原文住在用户配置里,⛔ 不进仓**:本仓是 GitHub 公开仓,段子是有版权的创作文本。
|
|
60
|
+
* 机制在 ACC(怎么选、怎么注入),措辞在用户配置(填什么)—— 与 D23 同款分工。
|
|
61
|
+
*/
|
|
62
|
+
interface HumorSettings {
|
|
63
|
+
/** 总开关(缺省 **关**:纯装饰不该是默认状态) */
|
|
64
|
+
enabled: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* 片段池(每项 = 一段完整文本)。
|
|
67
|
+
* ⚠️ 面板里用 `---` 分隔多段;这里存拆好的数组。
|
|
68
|
+
*/
|
|
69
|
+
bits: string[];
|
|
70
|
+
}
|
|
54
71
|
/** F4d 建议问答页(v1.26.1)**已于 2026-10-15 整面退役**(owner 裁「砍掉外部问答」)
|
|
55
72
|
* ⇒ 原 `PublicAskSettings`(key + 容器白名单)连同 `AdvancedSettings.publicAsk` 一并删除。
|
|
56
73
|
* 旧配置文件残留 `publicAsk` 节 ⇒ **静默忽略**(`mergeWithDefaults` 不再读它,幂等安全)。 */
|
|
@@ -64,6 +81,8 @@ interface PersonaSettings {
|
|
|
64
81
|
interface AdvancedSettings {
|
|
65
82
|
gateway: GatewaySettings;
|
|
66
83
|
persona: PersonaSettings;
|
|
84
|
+
/** 脱口秀片段注入(2026-11-04):纯装饰,缺省关 */
|
|
85
|
+
humor: HumorSettings;
|
|
67
86
|
/** 主动发送入口(v1.30.9):**只绑 127.0.0.1** 的独立监听器——CCC 的 MSM 用它发消息给指定用户 */
|
|
68
87
|
weixinApi: WeixinApiSettings;
|
|
69
88
|
}
|
|
@@ -120,6 +139,7 @@ interface AdvancedSettingsWire {
|
|
|
120
139
|
totpEnabled: boolean;
|
|
121
140
|
};
|
|
122
141
|
persona: PersonaSettings;
|
|
142
|
+
humor: HumorSettings;
|
|
123
143
|
}
|
|
124
144
|
/** 持久化 → wire(剥离 passHash/totpSecret;只留布尔) */
|
|
125
145
|
export declare function toWire(settings: AdvancedSettings): AdvancedSettingsWire;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { d as readCccName, i as findGitRoot, l as pathInside, s as loadSerenityConfig, t as DEFAULT_SERENITY_CONFIG_PATHS } from "./ccc-x94FCzOv.js";
|
|
2
2
|
import { u as ACC_VERSION } from "./rules-DKlpuFN_.js";
|
|
3
3
|
import { i as readDshVersion, t as hostContractReport, v as checkRegistryQuality } from "./contract-qqnsi8tc.js";
|
|
4
|
-
import { i as wakeSchedulerState, v as listWakes } from "./scheduler-
|
|
4
|
+
import { i as wakeSchedulerState, v as listWakes } from "./scheduler-CUPz7geH.js";
|
|
5
5
|
import { resolve } from "node:path";
|
|
6
6
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
7
7
|
//#region src/surface/observation.ts
|
|
@@ -2037,6 +2037,33 @@ function readTailEvents(logPath) {
|
|
|
2037
2037
|
* ⇒ 本判据**只看外层 `kind`**,理由:外层已经回答了"这一轮收完了吗",
|
|
2038
2038
|
* 内层回答的是"谁让它停的",**那是另一个问题**,混进来会让判据随"谁取消的"漂移。
|
|
2039
2039
|
*
|
|
2040
|
+
* ## 🔴🔴 2026-11-04 修正(owner 令):**用户手工停止必须排除** —— 上述「只看外层」被推翻
|
|
2041
|
+
*
|
|
2042
|
+
* ### 原前提被谁取代
|
|
2043
|
+
* 上面那句「内层混进来会让判据漂移」成立于一个**当时没成立的前提**:
|
|
2044
|
+
* **没有人会手工停止**。实测它不成立 —— 外部用户报了「我根本没配任何监控,
|
|
2045
|
+
* 它自己跑起来了,我是手工点的停止」。⇒ 兜底把人**主动终止**的轮次当成"该被接走",
|
|
2046
|
+
* 于是**人越喊停,它越来**。这不是判据漂移,是**判据答错了问题**。
|
|
2047
|
+
*
|
|
2048
|
+
* ### 新判据(**只加一格例外,不动其余**)
|
|
2049
|
+
* `aborted` **且** `reason.reason.kind === 'user'` ⇒ **不算"没跑完"**(用户已明确表达意图)。
|
|
2050
|
+
*
|
|
2051
|
+
* | 内层 kind | 谁让它停的 | 是否续跑 | 理由 |
|
|
2052
|
+
* |---|---|---|---|
|
|
2053
|
+
* | **`user`** | **人手工点的停止** | ⛔ **不** | 人的意图优先;反复拉起等于与用户对抗 |
|
|
2054
|
+
* | `disposed` | 宿主重启/销毁 | ✅ **是** | owner 2026-11-04 明令「重启后应当自动续跑」 |
|
|
2055
|
+
* | `parent` | 父轮终止 | ✅ 是 | 不是人对着本会话做的决定 |
|
|
2056
|
+
* | `hook` | 宿主 hook 取消 | ✅ 是 | 同属"没跑完" |
|
|
2057
|
+
* | 缺失/未知 | — | ✅ 是 | **缺省续跑**:这是兜底机制,保守方向是"救"而不是"弃" |
|
|
2058
|
+
*
|
|
2059
|
+
* 🔴 **为什么 `disposed` 必须留着**:2026-10-23 那个 **13 分钟盲窗**正是重启打断造成的
|
|
2060
|
+
* (实测读数见 `runInterruptedSafetyNet` 头注)。把 `disposed` 一起排除,等于
|
|
2061
|
+
* 用"修一个打扰"换来"复活一个已知事故"——**owner 已明确不换**。
|
|
2062
|
+
*
|
|
2063
|
+
* ⚠️ **形状陷阱(写代码与写夹具时都必须注意)**:真实事件是
|
|
2064
|
+
* `reason: { kind: 'aborted', reason: { kind: 'user' } }` —— **`reason` 里套着 `reason`**。
|
|
2065
|
+
* 取错层不会报错,只会**静默判错**。⇒ 夹具必须用**真日志样本**,⛔ 不许手写"我以为的样子"。
|
|
2066
|
+
*
|
|
2040
2067
|
* ### ⛔ 刻意**不**纳入的形态(保守边界,写明理由)
|
|
2041
2068
|
* - `error`:本轮**收完了**(宿主记了错误收尾),它不是"停在这里等人续";
|
|
2042
2069
|
* - 完全没有 `turn/end` 的开轮(例如日志末尾是 `turn/start` 后再无事件):
|
|
@@ -2056,6 +2083,32 @@ function readTailEvents(logPath) {
|
|
|
2056
2083
|
*/
|
|
2057
2084
|
const UNFINISHED_KINDS = /* @__PURE__ */ new Set(["interrupted", "aborted"]);
|
|
2058
2085
|
/**
|
|
2086
|
+
* 🔴 **2026-11-04(owner 令):`aborted` 的内层成因里,哪一种是「人明确说了别跑」。**
|
|
2087
|
+
*
|
|
2088
|
+
* 只有 `user` —— 人手工点的停止。其余(`disposed` 重启/`parent`/`hook`/缺失)
|
|
2089
|
+
* 都不是"人对本会话表达过意图",仍按"没跑完"处理。
|
|
2090
|
+
*
|
|
2091
|
+
* ⚠️ **为什么只列 user 而不列"要续跑的名单"**:形态会变(将来可能多出新 kind)。
|
|
2092
|
+
* 列"不续跑"的白名单 ⇒ 新形态缺省表现为**续跑**(保守方向 = 救而不是弃);
|
|
2093
|
+
* 列"要续跑"的白名单 ⇒ 新形态缺省表现为**不救**,会静默丢保护。
|
|
2094
|
+
*/
|
|
2095
|
+
const USER_INTENT_STOP_KINDS = /* @__PURE__ */ new Set(["user"]);
|
|
2096
|
+
/**
|
|
2097
|
+
* 「用户手工停止过」——**兜底机制的排除判据**。
|
|
2098
|
+
*
|
|
2099
|
+
* 判据 = 末条 `turn/end` 外层是 `aborted` **且** 内层成因命中 {@link USER_INTENT_STOP_KINDS}。
|
|
2100
|
+
* 只有这两个同时成立才排除;`interrupted`(崩溃)永不被它命中。
|
|
2101
|
+
*/
|
|
2102
|
+
function isUserIntentStop(events) {
|
|
2103
|
+
for (let i = events.length - 1; i >= 0; i--) {
|
|
2104
|
+
if (events[i]?.type !== "turn/end") continue;
|
|
2105
|
+
const outer = events[i]?.data?.reason?.kind;
|
|
2106
|
+
const inner = events[i]?.data?.reason?.reason?.kind;
|
|
2107
|
+
return outer === "aborted" && typeof inner === "string" && USER_INTENT_STOP_KINDS.has(inner);
|
|
2108
|
+
}
|
|
2109
|
+
return false;
|
|
2110
|
+
}
|
|
2111
|
+
/**
|
|
2059
2112
|
* 尾部窗口里**最后一条 `turn/start` 的轮号**(D244 输出面,给调用方做 A108 的现场判断)。
|
|
2060
2113
|
*
|
|
2061
2114
|
* ⚠️ 与 {@link detectUnclosedTurn} 不同:**它不判"是否未收尾"**,只**如实报告窗口里有什么**。
|
|
@@ -2103,6 +2156,14 @@ function detectInterruptedEnd(events) {
|
|
|
2103
2156
|
const turnEnd = events[idx];
|
|
2104
2157
|
const kind = turnEnd?.data?.reason?.kind;
|
|
2105
2158
|
if (typeof kind !== "string" || !UNFINISHED_KINDS.has(kind)) return null;
|
|
2159
|
+
/**
|
|
2160
|
+
* 🔴 **2026-11-04(owner 令):用户手工停止的轮次**不续跑**。
|
|
2161
|
+
*
|
|
2162
|
+
* 判据放在"命中没跑完"之后、"确认其后无新轮"之前 —— 语义上它属于
|
|
2163
|
+
* 「这一轮确实没收完,但**不该被接走**」,与"收完了"是两件事,⛔ 不要合并成一个 return。
|
|
2164
|
+
* 理由与取舍见文件头 §2026-11-04 修正(含 disposed 为何必须留着)。
|
|
2165
|
+
*/
|
|
2166
|
+
if (isUserIntentStop(events)) return null;
|
|
2106
2167
|
for (let i = idx + 1; i < events.length; i++) if (events[i]?.type === "turn/start") return null;
|
|
2107
2168
|
const turn = typeof turnEnd?.data?.turn === "number" ? turnEnd.data.turn : null;
|
|
2108
2169
|
return {
|
|
@@ -2400,7 +2461,20 @@ function projectDirNameForCwd(cwd) {
|
|
|
2400
2461
|
*/
|
|
2401
2462
|
function buildContinueText(sessionId, turn, pendingTools) {
|
|
2402
2463
|
const lines = [];
|
|
2403
|
-
|
|
2464
|
+
/**
|
|
2465
|
+
* 🔴🔴 **2026-11-04(owner 报障):首行必须自报身份 —— 这是 ACC 自动发的,不是人安排的。**
|
|
2466
|
+
*
|
|
2467
|
+
* 修前首行是「上一条进程在本轮完成前退出,该轮已被中止。现在继续。」——
|
|
2468
|
+
* **完全看不出是谁在说话**。实测代价:外部用户收到它后问「这个续跑的消息你知道来源哪里吗」,
|
|
2469
|
+
* 并且**用了一整轮去反查**(查 live 会话、查唤醒表、查 CRO 才确认是 harness 自己发的)。
|
|
2470
|
+
*
|
|
2471
|
+
* ⇒ 判据:**自动行为必须能被一眼认出是自动的**。人在看到一个祈使句("请接着完成…")时
|
|
2472
|
+
* 默认会以为**有人**在安排工作;不写清来源,就是在制造"我以为有人在派活"。
|
|
2473
|
+
* 这是 D262 的同族:报错/通知要能指回"谁触发的、怎么关"。
|
|
2474
|
+
*/
|
|
2475
|
+
lines.push("[ACC 自动 · 中断续跑] 下面这件事不是你安排的,是系统在自动恢复。");
|
|
2476
|
+
lines.push("");
|
|
2477
|
+
lines.push("上一条进程在本轮完成前退出,该轮已被中止。现在继续。");
|
|
2404
2478
|
lines.push("");
|
|
2405
2479
|
lines.push(`会话: ${sessionId}${turn === null ? "" : ` / 被中断的轮次: turn ${turn}`}`);
|
|
2406
2480
|
if (pendingTools.length > 0) {
|
|
@@ -2411,6 +2485,9 @@ function buildContinueText(sessionId, turn, pendingTools) {
|
|
|
2411
2485
|
}
|
|
2412
2486
|
lines.push("");
|
|
2413
2487
|
lines.push("请接着完成该轮未完成的工作;完成后把进展写入本轨迹的 SESSION.md。");
|
|
2488
|
+
lines.push("");
|
|
2489
|
+
lines.push("(说明:这是 ACC 的「中断兜底」,每 5 分钟检查一次被中断的会话并继续。");
|
|
2490
|
+
lines.push(" 你手工点过\"停止\"的轮次**不会**被它续跑。)");
|
|
2414
2491
|
return lines.join("\n");
|
|
2415
2492
|
}
|
|
2416
2493
|
/**
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* seams/humor.ts — **脱口秀片段注入**(2026-11-04,owner 想法)
|
|
3
|
+
*
|
|
4
|
+
* ## owner 原话(本文件存在的全部理由)
|
|
5
|
+
*
|
|
6
|
+
* > 「我们 Serenity 收集一版各类脱口秀的片段内容,随机性在会话和 rebuild 的时候
|
|
7
|
+
* > 去进行一段注入到系统提示词(一段完整的),这个不会改变什么行为,
|
|
8
|
+
* > 但是会让过程变得有趣」
|
|
9
|
+
* > 「要做到随机,例如我们收集 30 段,每次随机注入一段;在提示词中要诚恳:
|
|
10
|
+
* > 先来看看这段脱口秀片段再继续阅读吧」
|
|
11
|
+
* > 「这个功能要做个开关」
|
|
12
|
+
*
|
|
13
|
+
* ## 🔴 三条硬约束(每条都对应一个会出问题的位置)
|
|
14
|
+
*
|
|
15
|
+
* ### ① 随机的时机 = **会话开始**,会话进行中**绝不变**
|
|
16
|
+
*
|
|
17
|
+
* owner 原话:「随机是指会话开始的时候随机,rebuild 的时候换一个;会话进行中不变动」
|
|
18
|
+
* (2026-11-04 二次确认:**rebuild 用同一个 session.id**,故 `sessionId` 单种子即满足
|
|
19
|
+
* —— rebuild 属实不换段,这正是期望行为。⛔ 不要为了"rebuild 也换"而引入代次。)
|
|
20
|
+
*
|
|
21
|
+
* ⚠️ **为什么不用 `Math.random()` 现抽**:`serenitySystemPrompt()` **每次请求都重新求值**
|
|
22
|
+
* ⇒ 现抽会让系统提示词每轮都变(刷新页面都可能换段),而我们**无法解释为什么变了**。
|
|
23
|
+
* ⇒ 选哪段可以随机,但**选定后必须可重放**:种子 = sessionId,纯函数。
|
|
24
|
+
*
|
|
25
|
+
* ### ② 原文住**用户配置**,⛔ 不进仓
|
|
26
|
+
*
|
|
27
|
+
* 本仓是 **GitHub 公开仓**。脱口秀段子是有版权的创作文本,
|
|
28
|
+
* ⇒ 机制在 ACC(怎么选、怎么注入),**措辞在用户配置**(`~/.dsh/serenity-hooks.json`
|
|
29
|
+
* 的 `humor.bits`,仓外)—— 与 D23「ACC 管机制、CCC 管措辞」同款分工。
|
|
30
|
+
* ⛔ 不要往本文件里贴任何段子原文。
|
|
31
|
+
*
|
|
32
|
+
* ### ③ 关闭时必须与现状**逐字节相同**
|
|
33
|
+
*
|
|
34
|
+
* 它是纯装饰,进的是每次请求的系统提示词。
|
|
35
|
+
* ⇒ `enabled=false`(或池为空)时 `humorBlock()` 返回 `''`,装配层不 push。
|
|
36
|
+
* 判据由测试钉住。
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* 按种子稳定地选一段(**纯函数**:同种子必得同一段)。
|
|
40
|
+
*
|
|
41
|
+
* @param seed 会话 id
|
|
42
|
+
* @param bits 片段池(来自用户配置)
|
|
43
|
+
* @returns 选中的文本;池空 ⇒ `null`
|
|
44
|
+
*/
|
|
45
|
+
export declare function pickHumor(seed: string, bits: readonly string[]): string | null;
|
|
46
|
+
/**
|
|
47
|
+
* 装配进系统提示词的块(owner 指定的诚恳开场:**先来看看这段脱口秀片段再继续阅读吧**)。
|
|
48
|
+
*
|
|
49
|
+
* 🔴 **分段边界必须说清**:本块自带 `=== Serenity Humor ===` 标记头,
|
|
50
|
+
* 与 persona/EAP 等块同构,便于从装配结果里一眼确认它在不在。
|
|
51
|
+
* 结尾补一句「不影响任何判断」—— 它是装饰,**不能被读成行为约束**。
|
|
52
|
+
*
|
|
53
|
+
* @param seed 会话稳定种子(sessionId)
|
|
54
|
+
* @param bits 片段池
|
|
55
|
+
* @param enabled 总开关;`false` ⇒ 返回 `''`(逐字节等于没有本功能)
|
|
56
|
+
*/
|
|
57
|
+
export declare function humorBlock(seed: string, bits: readonly string[], enabled: boolean): string;
|
|
@@ -111,7 +111,16 @@ export declare function sessionBlock(root: string, scope?: string): string;
|
|
|
111
111
|
*/
|
|
112
112
|
export declare function serenitySystemPrompt(root: string, scope?: string,
|
|
113
113
|
/** 活跃轨迹目录名(给了才有第 ⑧ 段;未绑定轨迹 ⇒ undefined,不注入) */
|
|
114
|
-
dirName?: string
|
|
114
|
+
dirName?: string,
|
|
115
|
+
/**
|
|
116
|
+
* 会话 id —— **脱口秀块(D287)的随机种子**。
|
|
117
|
+
*
|
|
118
|
+
* 🔴 为什么必须是会话 id 而不是每次现抽:本函数**每次请求都重新求值**,
|
|
119
|
+
* 现抽会让系统提示词每轮都变(刷新页面都可能换段),且**无法解释为什么变了**。
|
|
120
|
+
* ⇒ 同一条会话永远是同一段(owner 要的"会话进行中不变动"),换会话才换。
|
|
121
|
+
* 未传(如某些冷路径)⇒ 不注入该块(`''`),行为等于该功能没开。
|
|
122
|
+
*/
|
|
123
|
+
sessionId?: string): string;
|
|
115
124
|
/**
|
|
116
125
|
* Code Mode 适配行:当前 scope 以 Code Mode 呈现工具时(run_code 可见),
|
|
117
126
|
* ACC 块按 native 语义指引"直接调用工具"会与"只有 run_code 可直接调用"的执行
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { d as hostSessions, r as cccRootForCwd } from "./ccc-roots-CsSSQjSS.js";
|
|
2
2
|
import { m as readTrajectorySubscriptions } from "./ccc-x94FCzOv.js";
|
|
3
3
|
import { F as isoLocal, w as sessionEvents } from "./bind-file-B0TuOP89.js";
|
|
4
|
-
import { g as WAKE_CATCH_UP_MS, m as listCroCognitiveTrajectories } from "./scheduler-
|
|
4
|
+
import { g as WAKE_CATCH_UP_MS, m as listCroCognitiveTrajectories } from "./scheduler-CUPz7geH.js";
|
|
5
5
|
import { n as readSimpleSettings } from "./settings-DibHCfEU.js";
|
|
6
|
-
import { i as subscriptionStats, r as subscriptionEval } from "./subscriptions-
|
|
7
|
-
import { containerClocks, containerWakes } from "./observation-
|
|
6
|
+
import { i as subscriptionStats, r as subscriptionEval } from "./subscriptions-CGpxv6Z6.js";
|
|
7
|
+
import { containerClocks, containerWakes } from "./observation-Ci2SBIX2.js";
|
|
8
8
|
//#region src/trajectory/live.ts
|
|
9
9
|
/**
|
|
10
10
|
* trajectory/live.ts — 进程内 live 会话取数 + 精简诊断
|
|
@@ -1121,6 +1121,10 @@ function defaultAdvancedSettings() {
|
|
|
1121
1121
|
mode: "",
|
|
1122
1122
|
overrideText: ""
|
|
1123
1123
|
},
|
|
1124
|
+
humor: {
|
|
1125
|
+
enabled: false,
|
|
1126
|
+
bits: []
|
|
1127
|
+
},
|
|
1124
1128
|
weixinApi: {
|
|
1125
1129
|
enabled: true,
|
|
1126
1130
|
port: WEIXIN_SEND_PORT
|
|
@@ -1173,6 +1177,7 @@ function mergeWithDefaults(raw) {
|
|
|
1173
1177
|
const o = raw;
|
|
1174
1178
|
const gateway = o.gateway ?? {};
|
|
1175
1179
|
const persona = o.persona ?? {};
|
|
1180
|
+
const humor = o.humor ?? {};
|
|
1176
1181
|
const weixinApi = o.weixinApi ?? {};
|
|
1177
1182
|
return {
|
|
1178
1183
|
gateway: {
|
|
@@ -1189,6 +1194,10 @@ function mergeWithDefaults(raw) {
|
|
|
1189
1194
|
mode: typeof persona.mode === "string" ? persona.mode : def.persona.mode,
|
|
1190
1195
|
overrideText: typeof persona.overrideText === "string" ? persona.overrideText : def.persona.overrideText
|
|
1191
1196
|
},
|
|
1197
|
+
humor: {
|
|
1198
|
+
enabled: typeof humor.enabled === "boolean" ? humor.enabled : def.humor.enabled,
|
|
1199
|
+
bits: Array.isArray(humor.bits) ? humor.bits.filter((b) => typeof b === "string" && b.trim() !== "") : def.humor.bits
|
|
1200
|
+
},
|
|
1192
1201
|
weixinApi: {
|
|
1193
1202
|
enabled: typeof weixinApi.enabled === "boolean" ? weixinApi.enabled : def.weixinApi.enabled,
|
|
1194
1203
|
port: typeof weixinApi.port === "number" && Number.isInteger(weixinApi.port) && weixinApi.port >= 0 ? weixinApi.port : def.weixinApi.port
|
|
@@ -1226,6 +1235,10 @@ function updateAdvancedSettings(patch) {
|
|
|
1226
1235
|
mode: typeof ps.mode === "string" ? ps.mode : current.persona.mode,
|
|
1227
1236
|
overrideText: typeof ps.overrideText === "string" ? ps.overrideText : current.persona.overrideText
|
|
1228
1237
|
} : current.persona,
|
|
1238
|
+
humor: patch.humor !== void 0 ? {
|
|
1239
|
+
enabled: typeof patch.humor.enabled === "boolean" ? patch.humor.enabled : current.humor.enabled,
|
|
1240
|
+
bits: Array.isArray(patch.humor.bits) ? patch.humor.bits.filter((b) => typeof b === "string" && b.trim() !== "") : current.humor.bits
|
|
1241
|
+
} : current.humor,
|
|
1229
1242
|
weixinApi: patch.weixinApi !== void 0 ? {
|
|
1230
1243
|
enabled: typeof patch.weixinApi.enabled === "boolean" ? patch.weixinApi.enabled : current.weixinApi.enabled,
|
|
1231
1244
|
port: typeof patch.weixinApi.port === "number" && Number.isInteger(patch.weixinApi.port) && patch.weixinApi.port >= 0 ? patch.weixinApi.port : current.weixinApi.port
|
|
@@ -1267,7 +1280,8 @@ function toWire(settings) {
|
|
|
1267
1280
|
allowWorkspaceCreate: settings.gateway.allowWorkspaceCreate,
|
|
1268
1281
|
totpEnabled: settings.gateway.totpEnabled
|
|
1269
1282
|
},
|
|
1270
|
-
persona: settings.persona
|
|
1283
|
+
persona: settings.persona,
|
|
1284
|
+
humor: settings.humor
|
|
1271
1285
|
};
|
|
1272
1286
|
}
|
|
1273
1287
|
/**
|
|
@@ -1336,9 +1350,100 @@ function applyWirePatch(wire) {
|
|
|
1336
1350
|
if (typeof wire.persona.overrideText === "string") psPatch.overrideText = wire.persona.overrideText;
|
|
1337
1351
|
patch.persona = psPatch;
|
|
1338
1352
|
}
|
|
1353
|
+
if (wire.humor !== void 0) {
|
|
1354
|
+
const hPatch = { ...current.humor };
|
|
1355
|
+
if (typeof wire.humor.enabled === "boolean") hPatch.enabled = wire.humor.enabled;
|
|
1356
|
+
if (Array.isArray(wire.humor.bits)) hPatch.bits = wire.humor.bits.filter((b) => typeof b === "string" && b.trim() !== "");
|
|
1357
|
+
patch.humor = hPatch;
|
|
1358
|
+
}
|
|
1339
1359
|
return updateAdvancedSettings(patch);
|
|
1340
1360
|
}
|
|
1341
1361
|
//#endregion
|
|
1362
|
+
//#region src/seams/humor.ts
|
|
1363
|
+
/**
|
|
1364
|
+
* seams/humor.ts — **脱口秀片段注入**(2026-11-04,owner 想法)
|
|
1365
|
+
*
|
|
1366
|
+
* ## owner 原话(本文件存在的全部理由)
|
|
1367
|
+
*
|
|
1368
|
+
* > 「我们 Serenity 收集一版各类脱口秀的片段内容,随机性在会话和 rebuild 的时候
|
|
1369
|
+
* > 去进行一段注入到系统提示词(一段完整的),这个不会改变什么行为,
|
|
1370
|
+
* > 但是会让过程变得有趣」
|
|
1371
|
+
* > 「要做到随机,例如我们收集 30 段,每次随机注入一段;在提示词中要诚恳:
|
|
1372
|
+
* > 先来看看这段脱口秀片段再继续阅读吧」
|
|
1373
|
+
* > 「这个功能要做个开关」
|
|
1374
|
+
*
|
|
1375
|
+
* ## 🔴 三条硬约束(每条都对应一个会出问题的位置)
|
|
1376
|
+
*
|
|
1377
|
+
* ### ① 随机的时机 = **会话开始**,会话进行中**绝不变**
|
|
1378
|
+
*
|
|
1379
|
+
* owner 原话:「随机是指会话开始的时候随机,rebuild 的时候换一个;会话进行中不变动」
|
|
1380
|
+
* (2026-11-04 二次确认:**rebuild 用同一个 session.id**,故 `sessionId` 单种子即满足
|
|
1381
|
+
* —— rebuild 属实不换段,这正是期望行为。⛔ 不要为了"rebuild 也换"而引入代次。)
|
|
1382
|
+
*
|
|
1383
|
+
* ⚠️ **为什么不用 `Math.random()` 现抽**:`serenitySystemPrompt()` **每次请求都重新求值**
|
|
1384
|
+
* ⇒ 现抽会让系统提示词每轮都变(刷新页面都可能换段),而我们**无法解释为什么变了**。
|
|
1385
|
+
* ⇒ 选哪段可以随机,但**选定后必须可重放**:种子 = sessionId,纯函数。
|
|
1386
|
+
*
|
|
1387
|
+
* ### ② 原文住**用户配置**,⛔ 不进仓
|
|
1388
|
+
*
|
|
1389
|
+
* 本仓是 **GitHub 公开仓**。脱口秀段子是有版权的创作文本,
|
|
1390
|
+
* ⇒ 机制在 ACC(怎么选、怎么注入),**措辞在用户配置**(`~/.dsh/serenity-hooks.json`
|
|
1391
|
+
* 的 `humor.bits`,仓外)—— 与 D23「ACC 管机制、CCC 管措辞」同款分工。
|
|
1392
|
+
* ⛔ 不要往本文件里贴任何段子原文。
|
|
1393
|
+
*
|
|
1394
|
+
* ### ③ 关闭时必须与现状**逐字节相同**
|
|
1395
|
+
*
|
|
1396
|
+
* 它是纯装饰,进的是每次请求的系统提示词。
|
|
1397
|
+
* ⇒ `enabled=false`(或池为空)时 `humorBlock()` 返回 `''`,装配层不 push。
|
|
1398
|
+
* 判据由测试钉住。
|
|
1399
|
+
*/
|
|
1400
|
+
/** 会话(或任意字符串)→ 稳定索引。FNV-1a 32 位:无依赖、纯函数、够均匀。 */
|
|
1401
|
+
function stableIndex(seed, mod) {
|
|
1402
|
+
let h = 2166136261;
|
|
1403
|
+
for (let i = 0; i < seed.length; i++) {
|
|
1404
|
+
h ^= seed.charCodeAt(i);
|
|
1405
|
+
h = Math.imul(h, 16777619) >>> 0;
|
|
1406
|
+
}
|
|
1407
|
+
return h % mod;
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* 按种子稳定地选一段(**纯函数**:同种子必得同一段)。
|
|
1411
|
+
*
|
|
1412
|
+
* @param seed 会话 id
|
|
1413
|
+
* @param bits 片段池(来自用户配置)
|
|
1414
|
+
* @returns 选中的文本;池空 ⇒ `null`
|
|
1415
|
+
*/
|
|
1416
|
+
function pickHumor(seed, bits) {
|
|
1417
|
+
if (bits.length === 0) return null;
|
|
1418
|
+
return bits[stableIndex(seed, bits.length)] ?? null;
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* 装配进系统提示词的块(owner 指定的诚恳开场:**先来看看这段脱口秀片段再继续阅读吧**)。
|
|
1422
|
+
*
|
|
1423
|
+
* 🔴 **分段边界必须说清**:本块自带 `=== Serenity Humor ===` 标记头,
|
|
1424
|
+
* 与 persona/EAP 等块同构,便于从装配结果里一眼确认它在不在。
|
|
1425
|
+
* 结尾补一句「不影响任何判断」—— 它是装饰,**不能被读成行为约束**。
|
|
1426
|
+
*
|
|
1427
|
+
* @param seed 会话稳定种子(sessionId)
|
|
1428
|
+
* @param bits 片段池
|
|
1429
|
+
* @param enabled 总开关;`false` ⇒ 返回 `''`(逐字节等于没有本功能)
|
|
1430
|
+
*/
|
|
1431
|
+
function humorBlock(seed, bits, enabled) {
|
|
1432
|
+
if (!enabled) return "";
|
|
1433
|
+
const bit = pickHumor(seed, bits);
|
|
1434
|
+
if (bit === null) return "";
|
|
1435
|
+
return [
|
|
1436
|
+
"",
|
|
1437
|
+
"=== Serenity Humor ===",
|
|
1438
|
+
"先来看看这段脱口秀片段再继续阅读吧:",
|
|
1439
|
+
"",
|
|
1440
|
+
bit.trimEnd(),
|
|
1441
|
+
"",
|
|
1442
|
+
"(读完就继续正事。它只是路过,不影响任何判断。)",
|
|
1443
|
+
""
|
|
1444
|
+
].join("\n");
|
|
1445
|
+
}
|
|
1446
|
+
//#endregion
|
|
1342
1447
|
//#region src/trajectory/prompt-injection.ts
|
|
1343
1448
|
/**
|
|
1344
1449
|
* trajectory/prompt-injection.ts — **轨迹提示词的注入模式**(owner 2026-10-20 令)
|
|
@@ -1459,6 +1564,21 @@ function readPersonaSettings() {
|
|
|
1459
1564
|
};
|
|
1460
1565
|
}
|
|
1461
1566
|
}
|
|
1567
|
+
/** 读取脱口秀片段配置(D287;读取失败 ⇒ 视为关闭,不阻断装配) */
|
|
1568
|
+
function readHumorSettings() {
|
|
1569
|
+
try {
|
|
1570
|
+
const s = readAdvancedSettings();
|
|
1571
|
+
return {
|
|
1572
|
+
enabled: s.humor.enabled === true,
|
|
1573
|
+
bits: s.humor.bits ?? []
|
|
1574
|
+
};
|
|
1575
|
+
} catch {
|
|
1576
|
+
return {
|
|
1577
|
+
enabled: false,
|
|
1578
|
+
bits: []
|
|
1579
|
+
};
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1462
1582
|
/** 过滤掉对 agent 隐藏的内容(safe-mode 是用户能力,不对 agent 提及)。无 g flag:`.test()` 须逐行独立无状态,避免 lastIndex 游移漏滤(问题A) */
|
|
1463
1583
|
const HIDDEN_LINES = /安全模式|safe-mode|\.serenity-safe-on/;
|
|
1464
1584
|
function sanitizeSkillContent(content) {
|
|
@@ -1865,7 +1985,7 @@ function sessionBlock(root, scope = DEFAULT_SESSION_SCOPE) {
|
|
|
1865
1985
|
* Principles 剥离 MSM 原则段(指令遵循约束)——用户文本承接两处风格;本体论/关系段/
|
|
1866
1986
|
* 操作边界(安全硬约束)永远保留。未配置 → 与 v1.23.0 逐字节一致(零影响)。
|
|
1867
1987
|
*/
|
|
1868
|
-
function serenitySystemPrompt(root, scope = DEFAULT_SESSION_SCOPE, dirName) {
|
|
1988
|
+
function serenitySystemPrompt(root, scope = DEFAULT_SESSION_SCOPE, dirName, sessionId) {
|
|
1869
1989
|
const persona = readPersonaSettings();
|
|
1870
1990
|
const personaOn = persona.mode !== "" && persona.overrideText.trim() !== "";
|
|
1871
1991
|
const trajReader = dirName === void 0 ? null : createTrajectoryPromptReader(root, dirName);
|
|
@@ -1877,6 +1997,20 @@ function serenitySystemPrompt(root, scope = DEFAULT_SESSION_SCOPE, dirName) {
|
|
|
1877
1997
|
if (!plan.replaces.has("principles")) parts.push(principlesBlock(root, personaOn));
|
|
1878
1998
|
if (!plan.replaces.has("cce")) parts.push(cceBlock());
|
|
1879
1999
|
if (!plan.replaces.has("eap")) parts.push(eapBlock());
|
|
2000
|
+
/**
|
|
2001
|
+
* 🔴 **D287 脱口秀块(2026-11-04 owner 想法)** —— 纯装饰,不进任何判据路径。
|
|
2002
|
+
*
|
|
2003
|
+
* 位置:**质量层(EAP)之后、表达层(persona)之前** —— 先立标准,再路过一段闲笔,
|
|
2004
|
+
* 最后才谈表达风格(persona 才是真正改风格的那一层)。
|
|
2005
|
+
*
|
|
2006
|
+
* ⚠️ **关闭 / 池空 / 无 sessionId ⇒ `humorBlock` 返回 `''`,不 push**
|
|
2007
|
+
* ⇒ 装配结果**逐字节等于没有本功能**。这条由测试钉住(装饰品不许偷偷改变提示词)。
|
|
2008
|
+
*/
|
|
2009
|
+
if (sessionId !== void 0 && sessionId !== "") {
|
|
2010
|
+
const hum = readHumorSettings();
|
|
2011
|
+
const bit = humorBlock(sessionId, hum.bits, hum.enabled);
|
|
2012
|
+
if (bit !== "") parts.push(bit);
|
|
2013
|
+
}
|
|
1880
2014
|
if (personaOn) {
|
|
1881
2015
|
const expr = personaBlock(persona.mode, persona.overrideText);
|
|
1882
2016
|
if (expr !== "") parts.push(expr);
|
|
@@ -1995,7 +2129,7 @@ function registerEntrySkillSectionGlobal(ctx) {
|
|
|
1995
2129
|
if (!cwd) return "";
|
|
1996
2130
|
const root = cccRootForCwd(cwd);
|
|
1997
2131
|
if (!root) return "";
|
|
1998
|
-
const base = serenitySystemPrompt(root, agentScope(context), boundDirNameFor(context.agent?.session));
|
|
2132
|
+
const base = serenitySystemPrompt(root, agentScope(context), boundDirNameFor(context.agent?.session), (context.agent?.session)?.id);
|
|
1999
2133
|
const codeLine = codeModeAdaptationLine(ctx, context.scope);
|
|
2000
2134
|
return codeLine ? `${base}\n${codeLine}` : base;
|
|
2001
2135
|
}
|
|
@@ -2027,7 +2161,7 @@ function registerEntrySkillSection(agent, root) {
|
|
|
2027
2161
|
name: "serenity-entry",
|
|
2028
2162
|
order: -50,
|
|
2029
2163
|
text: (context) => {
|
|
2030
|
-
const base = serenitySystemPrompt(root, scope, boundDirNameFor(agent.session));
|
|
2164
|
+
const base = serenitySystemPrompt(root, scope, boundDirNameFor(agent.session), agent.session.id);
|
|
2031
2165
|
const codeLine = codeModeAdaptationLine(agent.ctx, context.scope);
|
|
2032
2166
|
return codeLine ? `${base}\n${codeLine}` : base;
|
|
2033
2167
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as cccRootForCwd } from "./ccc-roots-CsSSQjSS.js";
|
|
2
2
|
import { m as readTrajectorySubscriptions } from "./ccc-x94FCzOv.js";
|
|
3
3
|
import { L as localHuman, n as findTrajectoryHolding } from "./bind-file-B0TuOP89.js";
|
|
4
|
-
import { f as registerDisposer } from "./scheduler-
|
|
4
|
+
import { f as registerDisposer } from "./scheduler-CUPz7geH.js";
|
|
5
5
|
//#region src/trajectory/subscriptions.ts
|
|
6
6
|
/**
|
|
7
7
|
* trajectory/subscriptions.ts — 轨迹消息订阅(v1.107.0,owner 2026-11-01 令)
|
|
@@ -306,7 +306,7 @@ function defaultSubscriptionDeps(ctx) {
|
|
|
306
306
|
readSubs: (root) => readTrajectorySubscriptions(root),
|
|
307
307
|
dirForSession: (root, sessionId) => findTrajectoryHolding(`${root}/AGENT_SESSIONS`, sessionId),
|
|
308
308
|
deliver: async (root, target, message) => {
|
|
309
|
-
const { sendToCognitiveTrajectory } = await import("./scheduler-
|
|
309
|
+
const { sendToCognitiveTrajectory } = await import("./scheduler-CUPz7geH.js").then((n) => n.n);
|
|
310
310
|
const res = await sendToCognitiveTrajectory(ctx, root, target, message, "trajectory-subscription");
|
|
311
311
|
return {
|
|
312
312
|
ok: res.ok,
|
|
@@ -79,8 +79,21 @@ interface SessionEvent {
|
|
|
79
79
|
data?: {
|
|
80
80
|
turn?: number;
|
|
81
81
|
step?: number;
|
|
82
|
+
/**
|
|
83
|
+
* `turn/end` 的收尾原因。
|
|
84
|
+
*
|
|
85
|
+
* 🔴 **2026-11-04:补上内层 `reason`** —— 真机形状是 **`reason` 里套着 `reason`**:
|
|
86
|
+
* `{"turn":67,"reason":{"kind":"aborted","reason":{"kind":"user"}}}`
|
|
87
|
+
* (本机 session-afc28ede turn 67 逐字实录)。
|
|
88
|
+
* 外层回答"收完了吗",内层回答"谁让它停的" —— 后者用于排除**用户手工停止**,
|
|
89
|
+
* 见 `isUserIntentStop`。⚠️ `tsc` 会抓这个字段:缺了它 TypeScript 报 TS2339
|
|
90
|
+
* (而**单测照样绿** —— 单测不走类型检查。所以「测试绿」不能代替 `typecheck`/`build`)。
|
|
91
|
+
*/
|
|
82
92
|
reason?: {
|
|
83
93
|
kind?: string;
|
|
94
|
+
reason?: {
|
|
95
|
+
kind?: string;
|
|
96
|
+
};
|
|
84
97
|
};
|
|
85
98
|
/** `tool/call` 的字段(callId 与 name 都在 data 这一层) */
|
|
86
99
|
callId?: string;
|
|
@@ -189,6 +202,24 @@ export interface ScanResult {
|
|
|
189
202
|
reason: string;
|
|
190
203
|
}>;
|
|
191
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* 读 `turn/end` 的内层成因(`reason.reason.kind`)。
|
|
207
|
+
*
|
|
208
|
+
* 🔴 **形状陷阱**:真实事件是 `reason: { kind: 'aborted', reason: { kind: 'user' } }`
|
|
209
|
+
* —— **`reason` 里套着 `reason`**。取错层不报错,只会静默判错。
|
|
210
|
+
* 实测样本(2026-11-04,本机 session-afc28ede turn 67 逐字):
|
|
211
|
+
* `{"type":"turn/end","data":{"turn":67,"reason":{"kind":"aborted","reason":{"kind":"user"}}}}`
|
|
212
|
+
*
|
|
213
|
+
* @returns 内层 kind;缺失或非串 ⇒ `null`(**缺省续跑**,见 USER_INTENT_STOP_KINDS 的注释)
|
|
214
|
+
*/
|
|
215
|
+
export declare function innerAbortCauseOf(events: SessionEvent[]): string | null;
|
|
216
|
+
/**
|
|
217
|
+
* 「用户手工停止过」——**兜底机制的排除判据**。
|
|
218
|
+
*
|
|
219
|
+
* 判据 = 末条 `turn/end` 外层是 `aborted` **且** 内层成因命中 {@link USER_INTENT_STOP_KINDS}。
|
|
220
|
+
* 只有这两个同时成立才排除;`interrupted`(崩溃)永不被它命中。
|
|
221
|
+
*/
|
|
222
|
+
export declare function isUserIntentStop(events: SessionEvent[]): boolean;
|
|
192
223
|
/**
|
|
193
224
|
* 尾部窗口里**最后一条 `turn/start` 的轮号**(D244 输出面,给调用方做 A108 的现场判断)。
|
|
194
225
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shgroup/dsh-serenity-hooks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.118.0",
|
|
4
4
|
"description": "宁静号 ACC harness(Native Cordis 插件)——给 DeepSeek Harness 装一个「AI 工作区」:12 个工具(container_fs/cognitive_trajectory/dashboard/container_git/msm/praxis/ontology/serenity-skill-creator/localstore/container_admin;另两个 im-bridge/diagram 按配置条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫/对外输出守卫)+ 认知轨迹日志与原地重建 + 网页登录入口/IM 桥/认知轨迹唤醒注册表。轨迹声明 = 轨迹目录下的 trajectory.json(约束面 + 旧标识 uid + CRO 机器绑定 cro.host;旧名 trajectory-constraint.json / skiff.json 仍在读取族里);轨迹提示词 = 轨迹目录下的 PROMPT.md(一条轨迹「是谁、按什么章程工作」,所有轨迹通用,追加在容器层与质量层之后,不替换它们)。适配 DSH 0.1.7-rc.1 / 0.2.0-rc.1 / 0.2.1-rc.1(三档)。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|