@shgroup/dsh-serenity-hooks 1.139.5 → 1.139.6
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/browser/cdp.d.ts +58 -1
- package/lib/browser/service.d.ts +12 -2
- package/lib/index.js +122 -12
- package/lib/seams/system-prompt.d.ts +35 -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.139.
|
|
3
|
+
"version": "1.139.6",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"description": "宁静号 ACC harness(Native Cordis 插件):给 DSH 装一个「AI 工作区」——13 个工具(container_fs/cognitive_trajectory/dashboard/container_git/msm/praxis/ontology/serenity-skill-creator/localstore/container_admin/browser_slot;另两个 im-bridge/diagram 按条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫)+ 认知轨迹日志与原地重建 + 网页登录入口/IM 桥/认知轨迹唤醒注册表 + 浏览器槽位管理(≤20 个独立 profile 的 Chrome 槽位,带占用归属与异常时向所属会话反向注入提醒)。轨迹声明 = 轨迹目录下的 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/browser/cdp.d.ts
CHANGED
|
@@ -74,14 +74,71 @@ export declare function clickAt(slot: number, targetId: string, x: number, y: nu
|
|
|
74
74
|
export declare function pageText(slot: number, targetId: string): Promise<string>;
|
|
75
75
|
/** HTML(默认截断 4000,同既有实现) */
|
|
76
76
|
export declare function pageHtml(slot: number, targetId: string, max?: number): Promise<string>;
|
|
77
|
+
/**
|
|
78
|
+
* 截图回退链(纯函数 —— 抽出来才能做变异检验)。
|
|
79
|
+
*
|
|
80
|
+
* 🔴 为什么它必须是纯函数:判据「三条路按序走、某条成功即停、全失败才抛」若埋在
|
|
81
|
+
* `screenshot()` 里就没法被"故意弄坏"(承本仓 `findMissingRelativeImports` 的先例)。
|
|
82
|
+
* 抽出来之后,注入一个全抛的 send ⇒ 能精确断言"它试了几条、按什么序、最后抛不抛"。
|
|
83
|
+
*
|
|
84
|
+
* ⚠️ 顺序不是随意的:`default` 最先(能出帧时语义最准),再退到不要求合成器提交新帧的
|
|
85
|
+
* 两条。**空 data 与抛错同等对待** —— CDP 可能"成功"返回空串,写出来是 0 字节文件,
|
|
86
|
+
* 那比报错更坏(调用方以为截到了)。
|
|
87
|
+
*/
|
|
88
|
+
export declare const SHOT_ATTEMPTS: readonly [{
|
|
89
|
+
readonly via: "default";
|
|
90
|
+
readonly params: {
|
|
91
|
+
readonly format: "png";
|
|
92
|
+
};
|
|
93
|
+
}, {
|
|
94
|
+
readonly via: "fromSurface=false";
|
|
95
|
+
readonly params: {
|
|
96
|
+
readonly format: "png";
|
|
97
|
+
readonly fromSurface: false;
|
|
98
|
+
};
|
|
99
|
+
}, {
|
|
100
|
+
readonly via: "beyondViewport";
|
|
101
|
+
readonly params: {
|
|
102
|
+
readonly format: "png";
|
|
103
|
+
readonly fromSurface: false;
|
|
104
|
+
readonly captureBeyondViewport: true;
|
|
105
|
+
};
|
|
106
|
+
}];
|
|
107
|
+
export type ShotVia = (typeof SHOT_ATTEMPTS)[number]['via'];
|
|
108
|
+
/**
|
|
109
|
+
* 按序尝试截图,返回第一路的 data 与其 `via`;全失败 ⇒ 抛(含最后一条原因)。
|
|
110
|
+
*
|
|
111
|
+
* @param send 执行一次 CDP 调用(测试可注入恒抛/恒空的替身)
|
|
112
|
+
*/
|
|
113
|
+
export declare function tryShotChain(send: (params: Record<string, unknown>) => Promise<Record<string, unknown>>): Promise<{
|
|
114
|
+
data: string;
|
|
115
|
+
via: ShotVia;
|
|
116
|
+
}>;
|
|
77
117
|
/**
|
|
78
118
|
* 截图并存盘。
|
|
79
119
|
*
|
|
80
120
|
* 🔴 落点**必须在 CCC 根内**(`resolveInside` 语义在这里手写,因为本层不知道 CCC 根):
|
|
81
121
|
* 调用方传进来的 `outAbs` 必须已经通过越界检查 —— 本函数只负责写。
|
|
82
122
|
* ⛔ 不在这里自己算根:那会造出第二个「根在哪」的判定点。
|
|
123
|
+
*
|
|
124
|
+
* 🔴🔴 **锁屏/遮挡 ⇒ 截图超时**(2026-11-27 owner 报障,真机复现)。
|
|
125
|
+
*
|
|
126
|
+
* **机理**:headed Chrome 在窗口不可见(锁屏、切走、最小化)时,宿主**停止为该 tab 合成帧**。
|
|
127
|
+
* 而 `Page.captureScreenshot` 默认语义是「**等下一帧**」⇒ 帧永远不来 ⇒ 挂到超时。
|
|
128
|
+
* ⚠️ 这**不是**我们的 flag 配错:我们**刻意不加** `--disable-renderer-backgrounding` 那组
|
|
129
|
+
* (2026-11-09 耗电事故的教训,见 `process.ts`),所以节流是**预期行为**。
|
|
130
|
+
* ⇒ 同族已诊断先例 = 本文件 `scrollAt()` 的 wheel 挂住:同一台机器上
|
|
131
|
+
* `--headless=new` 实例发同一条命令**立刻返回** ⇒ 根因在「headed + 不可见」这一档。
|
|
132
|
+
* ⇒ 修法见 `tryShotChain()`:**短超时 + 回退**,⛔ 不是"把超时调大"。
|
|
133
|
+
*
|
|
134
|
+
* ⚠️ **诚实边界**:后两路**不能保证**在所有页面上出正确的图(合成器完全停止时像素可能是空的)。
|
|
135
|
+
* 它们消除的是**20 秒挂死**,不是"锁屏时一定能截到正确的图"。
|
|
136
|
+
* 真锁屏下如需稳定取证,正解是**解锁**或**用无头实例重开该页**(改取证条件,需 owner 决定)。
|
|
83
137
|
*/
|
|
84
|
-
export declare function screenshot(slot: number, targetId: string, outAbs: string): Promise<
|
|
138
|
+
export declare function screenshot(slot: number, targetId: string, outAbs: string): Promise<{
|
|
139
|
+
via: ShotVia;
|
|
140
|
+
ms: number;
|
|
141
|
+
}>;
|
|
85
142
|
/** 重载,可选先装「新文档脚本」(要在应用发请求之前挂探针时用) */
|
|
86
143
|
export declare function reloadPage(slot: number, targetId: string, script?: string, timeoutMs?: number): Promise<string>;
|
|
87
144
|
/**
|
package/lib/browser/service.d.ts
CHANGED
|
@@ -250,8 +250,18 @@ export declare function slotEval(root: string, slot: number, sessionId: string,
|
|
|
250
250
|
export declare function slotText(root: string, slot: number, sessionId: string, targetId: string): Promise<string>;
|
|
251
251
|
/** HTML */
|
|
252
252
|
export declare function slotHtml(root: string, slot: number, sessionId: string, targetId: string, max?: number): Promise<string>;
|
|
253
|
-
/**
|
|
254
|
-
|
|
253
|
+
/**
|
|
254
|
+
* 截图(落点必须在 CCC 根内)。
|
|
255
|
+
*
|
|
256
|
+
* 🔴 返回 `via` 与耗时,⛔ 不吞掉:`screenshot()` 在窗口不可见(锁屏/遮挡)时会回退到
|
|
257
|
+
* 「从页面像素取帧」那两条路,而它们**与标准路径不等价**(见 `cdp.ts` 头注的诚实边界)。
|
|
258
|
+
* ⇒ 回执必须让调用方看见这张图是哪条路拍的,否则它会以为拿到的是标准截图。
|
|
259
|
+
*/
|
|
260
|
+
export declare function slotShot(root: string, slot: number, sessionId: string, targetId: string, outRel: string): Promise<{
|
|
261
|
+
rel: string;
|
|
262
|
+
via: string;
|
|
263
|
+
ms: number;
|
|
264
|
+
}>;
|
|
255
265
|
/** 重载(可先装探针脚本) */
|
|
256
266
|
export declare function slotReload(root: string, slot: number, sessionId: string, targetId: string, script?: string): Promise<string>;
|
|
257
267
|
/** 关标签页 */
|
package/lib/index.js
CHANGED
|
@@ -5958,10 +5958,23 @@ function createSkillCreatorTool() {
|
|
|
5958
5958
|
"",
|
|
5959
5959
|
"(A1/A2 是**本体档**,未建模 ⇒ 不适用,这不是异常(J9)。要建模:`guide` 的「三个动作」,或 `create` 生成带骨架的 skill。)"
|
|
5960
5960
|
].join("\n");
|
|
5961
|
-
return insp.state === "ok" ?
|
|
5961
|
+
return insp.state === "ok" ? [
|
|
5962
|
+
layering,
|
|
5963
|
+
"",
|
|
5964
|
+
body,
|
|
5965
|
+
"",
|
|
5966
|
+
"👉 A3 + A1/A2 都过了 —— 🔴 **这只说明「它是按标准写出来的」,⛔ 不说明「它有用」。**",
|
|
5967
|
+
" 本命令回答的是**形式**(顶层是不是桩、参考件有没有被点名、模型里的公理在不在);",
|
|
5968
|
+
" 它**没有回答**「用上它之后我们犯的错有没有变少」——那需要另一样东西:",
|
|
5969
|
+
" **一次它能拦住、而当时没人拦住的真实失败**(没有这个,它只是写得规整,⛔ 不是有价值)。",
|
|
5970
|
+
" ⇒ 语义档(文字是否真遵守模型/公理)走 `review`;**有效性**两档都回答不了,只能靠实测。"
|
|
5971
|
+
].join("\n") : `${layering}\n\n${body}\n\n👉 修完**重跑本命令**(本仓教训:「检查没跑」与「检查通过」必须分得开)。`;
|
|
5962
5972
|
}
|
|
5963
5973
|
const ttl = join(dir, SKILL_ONTOLOGY_FILE);
|
|
5964
|
-
if (!existsSync(ttl)) return formatSkillOntologyInspection(name, inspectSkillOntology(dir, { root })) + `\n\n(\`review\` 需要 \`${SKILL_ONTOLOGY_FILE}\`;普通 skill 没有可审的模型 ——
|
|
5974
|
+
if (!existsSync(ttl)) return formatSkillOntologyInspection(name, inspectSkillOntology(dir, { root })) + `\n\n(\`review\` 需要 \`${SKILL_ONTOLOGY_FILE}\`;普通 skill 没有可审的模型 —— 这不是错误。)
|
|
5975
|
+
|
|
5976
|
+
🔴 **没有模型 ≠ 已经够好**:本 skill 只走到「形式」那一档(A3)。
|
|
5977
|
+
它**没有被回答**的是:用上它之后我们犯的错有没有变少 —— 那需要一次真实的失败来证明,⛔ 不是本命令能给的。`;
|
|
5965
5978
|
const r = runOntologyCli([
|
|
5966
5979
|
"compliance",
|
|
5967
5980
|
ttl,
|
|
@@ -5975,7 +5988,14 @@ function createSkillCreatorTool() {
|
|
|
5975
5988
|
r.code !== 0 && r.stderr.trim() !== "" ? `\n${r.stderr.trimEnd()}` : "",
|
|
5976
5989
|
"",
|
|
5977
5990
|
"⚠️ 这是 **C 档(半机械)**:它给的是**逐条要回答的问题清单**,不是\"通过/不通过\"。",
|
|
5978
|
-
" 请**逐条回答**;发现文字与模型不符 ⇒ 改文字或改 ttl,然后重跑 `check`。"
|
|
5991
|
+
" 请**逐条回答**;发现文字与模型不符 ⇒ 改文字或改 ttl,然后重跑 `check`。",
|
|
5992
|
+
"",
|
|
5993
|
+
"🔴 **档位说明(三种不同的问题,别混成一个\"好\")**:",
|
|
5994
|
+
" · `check` = **形式**:是不是按标准写出来的(顶层非桩/参考件被点名/公理在不在)",
|
|
5995
|
+
" · `review` = **语义**:文字有没有真的遵守它自己写的模型/公理",
|
|
5996
|
+
" · **有效性** = 「用上它之后我们犯的错有没有变少」—— 🔴 **本命令和 `check` 都回答不了**,",
|
|
5997
|
+
" 它只能由**一次真实的、它本该拦住而当时没人拦住的失败**来证明。",
|
|
5998
|
+
" ⇒ 即使本命令逐条答完,也 ⛔ 不等于\"这个 skill 有用\"。"
|
|
5979
5999
|
].filter((s) => s !== "").join("\n");
|
|
5980
6000
|
}
|
|
5981
6001
|
});
|
|
@@ -6477,12 +6497,12 @@ function createCognitiveTrajectoryTool(ctx) {
|
|
|
6477
6497
|
"Three axioms hold. The trajectory is the subject and the conversation is only its carrier, so rebuilding the carrier leaves SESSION.md byte for byte identical. A trajectory has no lifecycle: it never completes, closes, or expires, and its age never counts against it — only where it is stored changes, so archiving removes it from the active list without touching its directory. And identity is the code, the fixed `YYYY-MM-DD--<code>[--<desc>]` segment of the directory name, never the summary or the title; create --id chooses it.",
|
|
6478
6498
|
"What this tool never does: it never deletes a trajectory, never edits the content of SESSION.md, and never schedules recurring work, because that belongs to cro-guide.",
|
|
6479
6499
|
"A trajectory is a directory under AGENT_SESSIONS/ holding a SESSION.md, a carrier is a dsh session bound to one, and the binding declaration is the file current.dsh_session_bind inside the trajectory: one file per trajectory, a single slot, never a table.",
|
|
6480
|
-
"Three rules are immutable. A session belongs to at most one trajectory for its whole life, so use refuses a session already carrying another, and there is no
|
|
6500
|
+
"Three rules are immutable. A session belongs to at most one trajectory for its whole life, so use refuses a session already carrying another, and there is no override flag — to give another trajectory a carrier, open a new session. A trajectory has at most one current carrier, and the binding declaration is the only truth about which, so other open sessions are simply unbound; never infer a binding from a session looking active. A declaration whose session no longer exists counts as unbound, and no cleanup is required, because a stale declaration deliberately records who carried the trajectory last.",
|
|
6481
6501
|
"Actions are grouped by effect, and the grouping answers one question: would this change what I am bound to? The lifecycle group does change this conversation's binding — list, show, create, use, rebuild, and archive, where archiving is one-way, never overwrites, and leaves content untouched. The delivery group sends one message to another trajectory and leaves your own binding alone — send-now and send-later. One action is a reference rather than an operation: cro-guide explains how to give a trajectory its own program deciding when it should be woken.",
|
|
6482
6502
|
"Choose by rule, not by guess. Not yet bound and starting new work: create, which activates itself at once when there is no prior binding. Already bound and recording a separate future line: also create, since that leaves your binding intact and you can activate it later with send-now. Want this conversation to move: use, and treat its refusal — when the session already carries another trajectory — as the design rather than an error to work around. Want another trajectory to act: send-now, whose target needs no prior setup, since a live session is created, bound, and injected when none exists.",
|
|
6483
6503
|
"Read a receipt for no more than it says. send-now returns a synchronous receipt meaning the message was injected and the turn started; it never means the target ran or replied, and to prove the target moved you must read its SESSION.md. send-now never queues behind the current turn — a busy target is steered mid-turn while an idle one starts at once. send-later is fire-and-forget by design, with no receipt and no recall.",
|
|
6484
6504
|
"The asymmetry is deliberate: send-now may create a missing carrier, send-later never does, because scheduling work for a trajectory that never existed is almost always a mistyped name. A carrier guard applies to send-now: it creates a carrier automatically only for a trajectory that has never had one, and otherwise refuses, either because a declaration exists but its session is gone or because the declared session cannot be resolved at all — one trajectory keeps one carrier.",
|
|
6485
|
-
"
|
|
6505
|
+
"Required and optional parameters are stated on each parameter below; read those rather than this description.",
|
|
6486
6506
|
"Two rules of conduct, not operations. create and send-now both cost real work and must serve a human intent, so call create only when the user asked for a new line of work or confirmed one — never to tidy up and never to pre-provision what nobody requested; when in doubt, ask. That is etiquette with a cost rather than a mechanical gate. And to describe yourself rather than operate: your own charter in PROMPT.md, a resident declaration through resident.serves in trajectory.json, and self-restriction by tool and model whitelists all live in container_admin config docs trajectory-self — read that chapter before changing any file in your own directory."
|
|
6487
6507
|
].join("\n\n"),
|
|
6488
6508
|
parameters: {
|
|
@@ -6512,7 +6532,7 @@ function createCognitiveTrajectoryTool(ctx) {
|
|
|
6512
6532
|
},
|
|
6513
6533
|
uid: {
|
|
6514
6534
|
type: "string",
|
|
6515
|
-
description: `uid: READ-ONLY legacy field. Omit to read a trajectory's legacy ${UID_FILENAME}. Passing any value is REJECTED — setting
|
|
6535
|
+
description: `uid: READ-ONLY legacy field. Omit to read a trajectory's legacy ${UID_FILENAME}. Passing any value is REJECTED — setting one is retired; the code is the identity now.`
|
|
6516
6536
|
},
|
|
6517
6537
|
note: {
|
|
6518
6538
|
type: "string",
|
|
@@ -20075,18 +20095,96 @@ async function pageHtml(slot, targetId, max = 4e3) {
|
|
|
20075
20095
|
return s.length > max ? `${s.slice(0, max)}\n… [truncated, ${s.length} chars total]` : s;
|
|
20076
20096
|
}
|
|
20077
20097
|
/**
|
|
20098
|
+
* 截图回退链(纯函数 —— 抽出来才能做变异检验)。
|
|
20099
|
+
*
|
|
20100
|
+
* 🔴 为什么它必须是纯函数:判据「三条路按序走、某条成功即停、全失败才抛」若埋在
|
|
20101
|
+
* `screenshot()` 里就没法被"故意弄坏"(承本仓 `findMissingRelativeImports` 的先例)。
|
|
20102
|
+
* 抽出来之后,注入一个全抛的 send ⇒ 能精确断言"它试了几条、按什么序、最后抛不抛"。
|
|
20103
|
+
*
|
|
20104
|
+
* ⚠️ 顺序不是随意的:`default` 最先(能出帧时语义最准),再退到不要求合成器提交新帧的
|
|
20105
|
+
* 两条。**空 data 与抛错同等对待** —— CDP 可能"成功"返回空串,写出来是 0 字节文件,
|
|
20106
|
+
* 那比报错更坏(调用方以为截到了)。
|
|
20107
|
+
*/
|
|
20108
|
+
const SHOT_ATTEMPTS = [
|
|
20109
|
+
{
|
|
20110
|
+
via: "default",
|
|
20111
|
+
params: { format: "png" }
|
|
20112
|
+
},
|
|
20113
|
+
{
|
|
20114
|
+
via: "fromSurface=false",
|
|
20115
|
+
params: {
|
|
20116
|
+
format: "png",
|
|
20117
|
+
fromSurface: false
|
|
20118
|
+
}
|
|
20119
|
+
},
|
|
20120
|
+
{
|
|
20121
|
+
via: "beyondViewport",
|
|
20122
|
+
params: {
|
|
20123
|
+
format: "png",
|
|
20124
|
+
fromSurface: false,
|
|
20125
|
+
captureBeyondViewport: true
|
|
20126
|
+
}
|
|
20127
|
+
}
|
|
20128
|
+
];
|
|
20129
|
+
/**
|
|
20130
|
+
* 按序尝试截图,返回第一路的 data 与其 `via`;全失败 ⇒ 抛(含最后一条原因)。
|
|
20131
|
+
*
|
|
20132
|
+
* @param send 执行一次 CDP 调用(测试可注入恒抛/恒空的替身)
|
|
20133
|
+
*/
|
|
20134
|
+
async function tryShotChain(send) {
|
|
20135
|
+
let lastErr = null;
|
|
20136
|
+
for (const a of SHOT_ATTEMPTS) try {
|
|
20137
|
+
const r = await send(a.params);
|
|
20138
|
+
const data = String(r.data ?? "");
|
|
20139
|
+
if (data === "") {
|
|
20140
|
+
lastErr = /* @__PURE__ */ new Error(`Page.captureScreenshot(${a.via}) 返回空 data`);
|
|
20141
|
+
continue;
|
|
20142
|
+
}
|
|
20143
|
+
return {
|
|
20144
|
+
data,
|
|
20145
|
+
via: a.via
|
|
20146
|
+
};
|
|
20147
|
+
} catch (e) {
|
|
20148
|
+
lastErr = e;
|
|
20149
|
+
}
|
|
20150
|
+
throw new Error(`三条路全部失败(窗口可能被锁屏/遮挡,帧未合成):${String(lastErr?.message ?? lastErr)}`);
|
|
20151
|
+
}
|
|
20152
|
+
/**
|
|
20078
20153
|
* 截图并存盘。
|
|
20079
20154
|
*
|
|
20080
20155
|
* 🔴 落点**必须在 CCC 根内**(`resolveInside` 语义在这里手写,因为本层不知道 CCC 根):
|
|
20081
20156
|
* 调用方传进来的 `outAbs` 必须已经通过越界检查 —— 本函数只负责写。
|
|
20082
20157
|
* ⛔ 不在这里自己算根:那会造出第二个「根在哪」的判定点。
|
|
20158
|
+
*
|
|
20159
|
+
* 🔴🔴 **锁屏/遮挡 ⇒ 截图超时**(2026-11-27 owner 报障,真机复现)。
|
|
20160
|
+
*
|
|
20161
|
+
* **机理**:headed Chrome 在窗口不可见(锁屏、切走、最小化)时,宿主**停止为该 tab 合成帧**。
|
|
20162
|
+
* 而 `Page.captureScreenshot` 默认语义是「**等下一帧**」⇒ 帧永远不来 ⇒ 挂到超时。
|
|
20163
|
+
* ⚠️ 这**不是**我们的 flag 配错:我们**刻意不加** `--disable-renderer-backgrounding` 那组
|
|
20164
|
+
* (2026-11-09 耗电事故的教训,见 `process.ts`),所以节流是**预期行为**。
|
|
20165
|
+
* ⇒ 同族已诊断先例 = 本文件 `scrollAt()` 的 wheel 挂住:同一台机器上
|
|
20166
|
+
* `--headless=new` 实例发同一条命令**立刻返回** ⇒ 根因在「headed + 不可见」这一档。
|
|
20167
|
+
* ⇒ 修法见 `tryShotChain()`:**短超时 + 回退**,⛔ 不是"把超时调大"。
|
|
20168
|
+
*
|
|
20169
|
+
* ⚠️ **诚实边界**:后两路**不能保证**在所有页面上出正确的图(合成器完全停止时像素可能是空的)。
|
|
20170
|
+
* 它们消除的是**20 秒挂死**,不是"锁屏时一定能截到正确的图"。
|
|
20171
|
+
* 真锁屏下如需稳定取证,正解是**解锁**或**用无头实例重开该页**(改取证条件,需 owner 决定)。
|
|
20083
20172
|
*/
|
|
20084
20173
|
async function screenshot(slot, targetId, outAbs) {
|
|
20174
|
+
const started = Date.now();
|
|
20085
20175
|
const conn = attach(await wsConnect(await pageWsUrl(slot, targetId)));
|
|
20086
20176
|
try {
|
|
20087
|
-
|
|
20177
|
+
/** 每一路都短超时:等一个不会来的帧,等多久都是白等 */
|
|
20178
|
+
const ATTEMPT_MS = 4e3;
|
|
20179
|
+
const r = await tryShotChain((params) => cdpRaw(conn, "Page.captureScreenshot", params, ATTEMPT_MS));
|
|
20088
20180
|
mkdirSync(dirname(outAbs), { recursive: true });
|
|
20089
|
-
writeFileSync(outAbs, Buffer.from(
|
|
20181
|
+
writeFileSync(outAbs, Buffer.from(r.data, "base64"));
|
|
20182
|
+
return {
|
|
20183
|
+
via: r.via,
|
|
20184
|
+
ms: Date.now() - started
|
|
20185
|
+
};
|
|
20186
|
+
} catch (e) {
|
|
20187
|
+
throw new Error(`[browser_slot] shot ${String(e?.message ?? e)} —— 这不是超时设得小,是页面没有可取的帧。解锁屏幕或改用无头实例取证。`);
|
|
20090
20188
|
} finally {
|
|
20091
20189
|
conn.ws.close();
|
|
20092
20190
|
}
|
|
@@ -22254,12 +22352,22 @@ async function slotHtml(root, slot, sessionId, targetId, max) {
|
|
|
22254
22352
|
pageTouched(root, slot);
|
|
22255
22353
|
return v;
|
|
22256
22354
|
}
|
|
22257
|
-
/**
|
|
22355
|
+
/**
|
|
22356
|
+
* 截图(落点必须在 CCC 根内)。
|
|
22357
|
+
*
|
|
22358
|
+
* 🔴 返回 `via` 与耗时,⛔ 不吞掉:`screenshot()` 在窗口不可见(锁屏/遮挡)时会回退到
|
|
22359
|
+
* 「从页面像素取帧」那两条路,而它们**与标准路径不等价**(见 `cdp.ts` 头注的诚实边界)。
|
|
22360
|
+
* ⇒ 回执必须让调用方看见这张图是哪条路拍的,否则它会以为拿到的是标准截图。
|
|
22361
|
+
*/
|
|
22258
22362
|
async function slotShot(root, slot, sessionId, targetId, outRel) {
|
|
22259
22363
|
assertSlotOwned(root, slot, sessionId);
|
|
22260
|
-
await screenshot(slot, targetId, resolveShotPath(root, outRel));
|
|
22364
|
+
const r = await screenshot(slot, targetId, resolveShotPath(root, outRel));
|
|
22261
22365
|
pageTouched(root, slot);
|
|
22262
|
-
return
|
|
22366
|
+
return {
|
|
22367
|
+
rel: outRel,
|
|
22368
|
+
via: r.via,
|
|
22369
|
+
ms: r.ms
|
|
22370
|
+
};
|
|
22263
22371
|
}
|
|
22264
22372
|
/** 重载(可先装探针脚本) */
|
|
22265
22373
|
async function slotReload(root, slot, sessionId, targetId, script) {
|
|
@@ -23112,7 +23220,9 @@ async function run(ctx, root, sessionId, trajectory, action, args) {
|
|
|
23112
23220
|
case "shot": {
|
|
23113
23221
|
const n = needSlot(args);
|
|
23114
23222
|
const target = await needTarget(root, n, sessionId, args);
|
|
23115
|
-
|
|
23223
|
+
const r = await slotShot(root, n, sessionId, target, str(args.out) ?? `_tmp/browser-shots/shot-${target.slice(0, 8)}-${Date.now()}.png`);
|
|
23224
|
+
const warn = r.via === "default" ? "" : ` (⚠️ NON-STANDARD PATH — window was likely locked/occluded; pixels may differ from a normal capture)`;
|
|
23225
|
+
return `[browser_slot] shot → ${r.rel} [via ${r.via}, ${r.ms}ms]${warn}`;
|
|
23116
23226
|
}
|
|
23117
23227
|
case "reload": {
|
|
23118
23228
|
const n = needSlot(args);
|
|
@@ -2,21 +2,43 @@
|
|
|
2
2
|
* system-prompt.ts — Induction(成员装配机制,specs v1.5.0 命名)装配文本构造
|
|
3
3
|
*
|
|
4
4
|
* 机制:把新实例(新会话 / rebuild 重建 / 新 agent)引入为轨迹成员的装配机制——本文件装配的文本
|
|
5
|
-
* 即 Induction
|
|
6
|
-
* → C 状态调节(状态块)→ D 工作供给(SKILL/Tools)→ E 任务指示(Session
|
|
7
|
-
* Metaphor 为 A 层世界模型记忆钩渲染层(不计入 8 块骨架)。
|
|
5
|
+
* 即 Induction 骨架(**specs 口径 = 8 内容块 × 五层**,README §5):A 主体定义(ACC/Principles/CCE)
|
|
6
|
+
* → B 质量规范(EAP)→ C 状态调节(状态块)→ D 工作供给(SKILL/Tools)→ E 任务指示(Session),
|
|
7
|
+
* 稳定→易变装配序;Metaphor 为 A 层世界模型记忆钩渲染层(不计入 8 块骨架)。
|
|
8
|
+
*
|
|
9
|
+
* 🔴🔴 **两个计数必须分开看,⛔ 别把它们当成同一个数** —— 2026-11-27 由 butler 追问逼出,实测确认:
|
|
10
|
+
* · **specs 的「8 块」= 内容骨架的层计数**,它**没有收进** v1.135.0 之后新增的三块无条件内容
|
|
11
|
+
* (Soul / Operator Creed / Work Register)⇒ 它是**落后于实现的**,按它数装配会少数三块。
|
|
12
|
+
* · **`tests/system-prompt-block-inventory.test.ts` 的「9 / 13」= 标题串的个数**(缺省态 9、条件全开 13)。
|
|
13
|
+
* 两者**不是同一分类法**,也**不能互相推导**:一个是"内容骨架"的层,一个是"装配产物里出现了几个
|
|
14
|
+
* `=== Serenity … ===`"。⇒ 要判装配,**只信那条 `toEqual`**;要判分层学术口径,去 specs。
|
|
15
|
+
* ⚠️ 我此前把这一行写成「8 块五层」而下面是 0/1b/5b/c/d 的编号 ⇒ **那正是下面「这份清单会漂」那段控诉的形态**:
|
|
16
|
+
* 描述装配的注释自己先漂了。编号已改成「装配序」而非"块号",就是为了不再暗示它与 8 对得上。
|
|
8
17
|
*
|
|
9
18
|
* **完全对齐 opencode-serenity-plugin 的 system.transform 注入内容**(compacting.ts):
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
19
|
+
* **装配序**(v1.19.8 精简,S142 重建视角 R↓;⚠️ 下面这些 **是装配位序,⛔ 不是 specs 的"块号"**):
|
|
20
|
+
* 0. `=== Serenity Soul ===` — 灵魂("我是什么";owner 2026-11-15 亲手正文,v1.136.2)
|
|
21
|
+
* 1. `=== Serenity ACC ===` — 身份(ACC/CCC 模型 + 路径约定;**v1.124.0 起不含工具清单**)
|
|
22
|
+
* 1b. `=== Serenity Operator Creed ===` — 宪章("凭什么下判断",v1.135.0)
|
|
23
|
+
* 2. `=== Serenity Metaphor ===` — 世界模型(三层隐喻域:船/航行/船员)
|
|
24
|
+
* 3. `=== Serenity Principles ===` — 信念/边界(认知容器本体论 + 操作边界,v1.19.8 合并原 Constraints)
|
|
25
|
+
* 4. `=== Serenity CCE ===` — 时间约束(5 行为约束 + H_op,逐字对齐 osp)
|
|
26
|
+
* 5. `=== Serenity EAP ===` — 质量(E↑ R↓ S↑ 自检)
|
|
27
|
+
* 5b. `=== Serenity Humor ===`(条件)— 脱口秀闲笔(D287;缺省关,会话 id 作种子)
|
|
28
|
+
* 5c. `=== Serenity Persona ===`(条件)— 表达层(⛔ 与 EAP 并存,**不置换**;specs 的 §5.5a 记的是旧语义"替换",以本行为准)
|
|
29
|
+
* 5d. `=== Serenity Work Register ===` — 工作语域(v1.124.0;**缺省开**,见 work-register.ts)
|
|
30
|
+
* 6. `=== Serenity Safe Mode ===`(条件)— 安全模式(`.serenity-safe-on` 存在时才有)
|
|
31
|
+
* `=== Serenity Localstore ===`(条件)— 本地凭据策略(`localstore.json` 存在时才有)
|
|
32
|
+
* 7. SKILL.md 全文 — 该 CCC 顶层入口 skill 全量原文(不截断)
|
|
33
|
+
* 7b. `=== Serenity MSM ===` — **只剩 MSM 调用示例**(v1.124.0:工具清单已删,标题随内容改)
|
|
34
|
+
* 8. `=== Serenity Session ===`(条件)— 活跃会话(id + dirName + mdPath + todowrite 首位约定)
|
|
35
|
+
* + `=== Serenity Trajectory Prompt ===`(条件)— 按 `trajectory.json` 的 prompt 段决定 append / replace
|
|
36
|
+
*
|
|
37
|
+
* 🔴 **这份清单会漂,而且漂了没有任何信号** —— 2026-11-27 实测:它曾漏掉 Soul/Creed/Work Register
|
|
38
|
+
* 三块,且仍写着 `Serenity Tools`(该标题 v1.124.0 已改)。**当时没有任何测试变红**,
|
|
39
|
+
* 因为它只是注释,而既有断言只查"我找的那几块在不在",从不问"还有没有别的"。
|
|
40
|
+
* ⇒ 现在由 `tests/system-prompt-block-inventory.test.ts` 用**标题集合闭合**钉住真实装配;
|
|
41
|
+
* 改装配顺序或增删块时,那份 `toEqual` 会先红。⛔ 不要再靠"记得回来改注释"。
|
|
20
42
|
*
|
|
21
43
|
* 注册:**全局** ctx `systemPrompt.section`(对齐 plan-mode 官方惯例),text 回调按
|
|
22
44
|
* `context.agent` 的 cwd 动态解析 CCC 根 → 返回完整注入文本;非 CCC/无 agent 返回空。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shgroup/dsh-serenity-hooks",
|
|
3
|
-
"version": "1.139.
|
|
3
|
+
"version": "1.139.6",
|
|
4
4
|
"description": "宁静号 ACC harness(Native Cordis 插件)——给 DeepSeek Harness 装一个「AI 工作区」:13 个工具(container_fs/cognitive_trajectory/dashboard/container_git/msm/praxis/ontology/serenity-skill-creator/localstore/container_admin/browser_slot;另两个 im-bridge/diagram 按条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫/对外输出守卫)+ 认知轨迹日志与原地重建 + 网页登录入口/IM 桥/认知轨迹唤醒注册表 + 浏览器槽位管理(≤20 个独立 profile 的 Chrome 槽位,带占用归属与异常时向所属会话反向注入提醒)。轨迹声明 = 轨迹目录下的 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": {
|