@shgroup/dsh-serenity-hooks 1.121.0 → 1.122.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/index.js +55 -7
- package/lib/{observation-D0RjHk0e.js → observation-CVpwAke1.js} +1 -1
- package/lib/{scheduler-CMBAoYR8.js → scheduler-CA-7xvTS.js} +2 -98
- package/lib/{service-IY3u-vea.js → service-C7Yev0I6.js} +4 -4
- package/lib/{settings-DibHCfEU.js → settings-B_FAdsxN.js} +99 -2
- package/lib/{subscriptions-CV-7Yhqb.js → subscriptions-I9PUzgcB.js} +2 -2
- 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.122.0",
|
|
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;另三个 im-bridge/diagram/reconstruct 按条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫)+ 认知轨迹日志与原地重建 + 网页登录入口/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/index.js
CHANGED
|
@@ -7,13 +7,13 @@ import { d as findPackageRoot, i as constraintSystemPromptSource, l as resolveCo
|
|
|
7
7
|
import { C as runMsmAsync, S as runMsm, T as setWeixinSendEndpoint, _ as ACC_CATALOG, a as loadOpencodeSkill, b as findEntry, c as summarizeHostContract, f as forgetNonCccToolVisibility, g as forgetToolVisibility, h as syncToolVisibility, i as listOpencodeSkillDirs, m as registerGuards, n as readDshVersion, o as compareSemver, r as setSafeMode, s as hostContractReport, t as getStatus, v as CCC_CONFIG_REFERENCE, w as docsPointer, x as loadMsmEntries } from "./status-DU4k3Wqe.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
9
|
import { A as TRAJECTORY_PROMPT_FILENAME, C as recordToolUsage, D as buildResourceNameSuffix, E as buildResourceIndex, O as isSafeSkillName, S as verifyTotpCode, T as SKILL_ONTOLOGY_FILE, _ as projectKnownWorkspaces, a as trajectoryConstraintFor, b as FACE_PORTS, c as trajectoryWorkspaceMdPath, d as splitModel, f as registerCognitiveTrajectorySkillSection, g as migrateLegacyLocalstore, h as applyWirePatch, i as getTrajectoryAgent, j as hasTrajectoryPrompt, k as truncateContent, 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 REFERENCE_DIR, x as MECHANISM_PORTS, y as toWire } from "./session-C4AzKUh_.js";
|
|
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 WAKE_CATCH_UP_MS, c as formatPendingTools, d as listRunningSessionIds, f as registerCroTurnTracking, g as CARRIER_OPENING_MARK, i as sendToCognitiveTrajectory, l as projectDirNameForCwd, m as buildCroSnapshot, n as registerWakeScheduler, o as DEFAULT_LOOKBACK_MS, p as registerDisposer, s as createResumeOne, t as createAndBindTarget, u as scanInterruptedSessions, v as addWake } from "./scheduler-
|
|
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, u as listBoundSessionIds } from "./injection-B5jZxemg.js";
|
|
11
|
+
import { _ as WAKE_CATCH_UP_MS, c as formatPendingTools, d as listRunningSessionIds, f as registerCroTurnTracking, g as CARRIER_OPENING_MARK, i as sendToCognitiveTrajectory, l as projectDirNameForCwd, m as buildCroSnapshot, n as registerWakeScheduler, o as DEFAULT_LOOKBACK_MS, p as registerDisposer, s as createResumeOne, t as createAndBindTarget, u as scanInterruptedSessions, v as addWake } from "./scheduler-CA-7xvTS.js";
|
|
12
12
|
import { i as sessionsRootDir } from "./cleanup-CPl1SSaK.js";
|
|
13
|
-
import { n as readSimpleSettings, r as registerSettingsSection } from "./settings-
|
|
13
|
+
import { i as hostAliveProbe, n as readSimpleSettings, r as registerSettingsSection } from "./settings-B_FAdsxN.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-I9PUzgcB.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-CVpwAke1.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-C7Yev0I6.js");
|
|
565
565
|
return renderDiag(await runDiag(hostCtx, root ?? ""));
|
|
566
566
|
}
|
|
567
567
|
default: throw new Error(`Unknown action: ${args.action}`);
|
|
@@ -15284,6 +15284,54 @@ async function resolveInboundTarget(ctx, input) {
|
|
|
15284
15284
|
};
|
|
15285
15285
|
}
|
|
15286
15286
|
/**
|
|
15287
|
+
* 入站投递**投给哪条会话**:先问绑定真相源,派生值只作"还没有载体"时的兜底。
|
|
15288
|
+
*
|
|
15289
|
+
* ## 🔴 为什么必须有这一格(2026-11-06 生产回归,v1.121.0 `reconstruct` 引入)
|
|
15290
|
+
*
|
|
15291
|
+
* 原实现是**纯函数派生**:`weixinSessionIdForTrajectory(code)` ⇒ 恒等于 `skiff-weixin-<code>`。
|
|
15292
|
+
* 那个前提在 `reconstruct` 之前是成立的 —— 载体 id 一旦派生就永不变。
|
|
15293
|
+
*
|
|
15294
|
+
* 但 `reconstruct` 的语义**正是"换一条载体"**:它建新会话(`session-<uuid>`)、把轨迹绑过去、
|
|
15295
|
+
* **归档旧会话**。⇒ 派生值与真实载体**从此分叉**,而入站仍按派生值投递 ⇒
|
|
15296
|
+
* **消息被投进一条已归档的会话**。
|
|
15297
|
+
*
|
|
15298
|
+
* 真机读数(2026-11-06 08:3x,宿主日志逐字):
|
|
15299
|
+
* ```
|
|
15300
|
+
* reconstruct: 新载体 session-0fd78851… 已接管「…zhaocai-xingzai…」(旧 skiff-weixin-zhaocai-xingzai)
|
|
15301
|
+
* reconstruct: 旧会话 skiff-weixin-zhaocai-xingzai 已归档(attempt 1)
|
|
15302
|
+
* im 投递:会话 skiff-weixin-zhaocai-xingzai → followup ← 投给已归档的那条
|
|
15303
|
+
* ```
|
|
15304
|
+
* ⇒ 人在微信那头**连发四条没人应**,而**日志里每一层都报成功**(`followup` 不是空操作)。
|
|
15305
|
+
* 这正是本仓最怕的形态:**静默**。
|
|
15306
|
+
*
|
|
15307
|
+
* ## 判据的层级(为什么不能只改 `reconstruct`)
|
|
15308
|
+
*
|
|
15309
|
+
* | 改法 | 为什么不行 |
|
|
15310
|
+
* |---|---|
|
|
15311
|
+
* | 让 `reconstruct` 把新载体 id **派生**成 `skiff-weixin-<code>` | 撞宿主与 ACC 双方的「一个会话至多一条轨迹」;且第二次换代时旧 id 还被占着 |
|
|
15312
|
+
* | `reconstruct` 之后**改写派生函数** | 派生函数是**纯函数**,它不知道谁刚换代;给它加状态 = 造第二真相源 |
|
|
15313
|
+
* | ✅ **投递前问绑定真相源** | 绑定文件(`current.dsh_session_bind`)**本来就是**"此刻谁在承载它"的唯一真相源(D172),换来换去都写在这一个槽位里 |
|
|
15314
|
+
*
|
|
15315
|
+
* ⚠️ **兜底不是"静默退回旧行为",是"这条轨迹还没有载体"**:那时派生值是对的 ——
|
|
15316
|
+
* `createTrajectoryAgent` 会按它建出第一条载体。⇒ 两种状态**语义不同**,不是同一个 bug 的宽容版。
|
|
15317
|
+
*
|
|
15318
|
+
* @param ctx 插件上下文(`hostAliveProbe` 要用它取宿主事实)
|
|
15319
|
+
* @param root CCC 根
|
|
15320
|
+
* @param code 目标轨迹编码
|
|
15321
|
+
* @returns 该轨迹此刻的载体 id;未绑定 / 取不到事实 ⇒ 派生值
|
|
15322
|
+
*/
|
|
15323
|
+
function carrierSessionIdForIm(ctx, root, code) {
|
|
15324
|
+
const derived = weixinSessionIdForTrajectory(code);
|
|
15325
|
+
try {
|
|
15326
|
+
const dirName = findDirNameByCode(root, code);
|
|
15327
|
+
if (dirName === null) return derived;
|
|
15328
|
+
const bound = listBoundSessionIds(root, dirName, hostAliveProbe(ctx));
|
|
15329
|
+
return bound.length > 0 ? bound[0] : derived;
|
|
15330
|
+
} catch {
|
|
15331
|
+
return derived;
|
|
15332
|
+
}
|
|
15333
|
+
}
|
|
15334
|
+
/**
|
|
15287
15335
|
* 同会话入站**串行化**(2026-10-21,修"同一条消息被处理两轮"的第二个缺陷)。
|
|
15288
15336
|
*
|
|
15289
15337
|
* ## 为什么必须有锁(R↓,代价换来的)
|
|
@@ -15374,7 +15422,7 @@ async function handleInboundEvent(ctx, root, accountId, io, event, preset) {
|
|
|
15374
15422
|
}
|
|
15375
15423
|
let releaseLock = null;
|
|
15376
15424
|
try {
|
|
15377
|
-
const sessionId =
|
|
15425
|
+
const sessionId = carrierSessionIdForIm(ctx, root, trajectory);
|
|
15378
15426
|
/**
|
|
15379
15427
|
* 🔴 **同会话串行化**(2026-10-21 引入;**2026-10-24 理由已变,见下**)。
|
|
15380
15428
|
*
|
|
@@ -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 { n as readDshVersion, s as hostContractReport, y as checkRegistryQuality } from "./status-DU4k3Wqe.js";
|
|
4
|
-
import { a as wakeSchedulerState, y as listWakes } from "./scheduler-
|
|
4
|
+
import { a as wakeSchedulerState, y as listWakes } from "./scheduler-CA-7xvTS.js";
|
|
5
5
|
import { resolve } from "node:path";
|
|
6
6
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
7
7
|
//#region src/surface/observation.ts
|
|
@@ -3,8 +3,8 @@ import { c as hostAgents, o as listCccs, u as hostService } from "./ccc-roots-Cs
|
|
|
3
3
|
import { _ as resolveInside } from "./ccc-x94FCzOv.js";
|
|
4
4
|
import { F as isoLocal, L as localHuman, P as readTrajectoryFile, R as localIdStamp, T as sessionsRoot, b as parseTrajectoryCode, j as TRAJECTORY_FILENAME, k as trajectoryDescOf, p as findSession, v as namingTitleFor } from "./bind-file-B0TuOP89.js";
|
|
5
5
|
import { c as carrierState, i as toMessage, n as deliver, r as makeInjection, s as appendBound, t as assertInjection, u as listBoundSessionIds } from "./injection-B5jZxemg.js";
|
|
6
|
-
import { i as sessionsRootDir, n as findSessionLog
|
|
7
|
-
import { n as readSimpleSettings } from "./settings-
|
|
6
|
+
import { i as sessionsRootDir, n as findSessionLog } from "./cleanup-CPl1SSaK.js";
|
|
7
|
+
import { i as hostAliveProbe, n as readSimpleSettings } from "./settings-B_FAdsxN.js";
|
|
8
8
|
import { basename, dirname, join } from "node:path";
|
|
9
9
|
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
10
10
|
import { spawn } from "node:child_process";
|
|
@@ -499,102 +499,6 @@ function deliverCarrierOpening(agent, text) {
|
|
|
499
499
|
}
|
|
500
500
|
}
|
|
501
501
|
//#endregion
|
|
502
|
-
//#region src/trajectory/alive.ts
|
|
503
|
-
/**
|
|
504
|
-
* trajectory/alive.ts — **"这个 dsh 会话还活着吗"的唯一判据**(owner 2026-10-20 裁决)
|
|
505
|
-
*
|
|
506
|
-
* ## owner 的原话(本模块的全部设计依据)
|
|
507
|
-
*
|
|
508
|
-
* > 「死应该包含归档判断;只有 ① 或者 ②且不在归档集 才算活」
|
|
509
|
-
* > 「use 只要被调用了,可以无条件覆盖绑定到当前会话(这说明当前会话肯定活着啊)」
|
|
510
|
-
*
|
|
511
|
-
* ## 为什么必须收成一个判据(在此之前有三个互不一致的判据)
|
|
512
|
-
*
|
|
513
|
-
* | # | 判据 | 旧实现位置 | 单独使用时的漏洞 |
|
|
514
|
-
* |---|---|---|---|
|
|
515
|
-
* | ① | 进程内 loaded agent | `hostAgents(ctx).get(id)` | 冷会话全判死 |
|
|
516
|
-
* | ② | 磁盘上有会话日志 | `hasSessionLogById()` | **归档后日志逐字节不动** ⇒ 归档会话判活 |
|
|
517
|
-
* | ③ | 宿主归档集 | `workspaceRegistry.archivedSessionIds` | 旧 dsp **零引用**(整个仓库 0 处) |
|
|
518
|
-
*
|
|
519
|
-
* 宿主的归档语义是**只往集合里加一个 id、不动日志**(`dsh-workspace` 的
|
|
520
|
-
* `archiveSession` 注释:「Archiving never touches workspace accounting」)。
|
|
521
|
-
* ⇒ 只问 ② 的实现在归档上**必然判错**,而那个错误没有任何机械信号。
|
|
522
|
-
*
|
|
523
|
-
* ## 判据(owner 给定,逐字实现)
|
|
524
|
-
*
|
|
525
|
-
* ```text
|
|
526
|
-
* 活 ⟺ ① (进程内 loaded ⇒ 一定在)
|
|
527
|
-
* ∨ (② ∧ 不在归档集) (日志在、且没人把它归档掉)
|
|
528
|
-
* ```
|
|
529
|
-
*
|
|
530
|
-
* 🔴 **一处对原话的收紧(必须说出来,不许默默改)**:owner 的 ① 未附加"不在归档集",
|
|
531
|
-
* 而本模块把**归档判定排在最前** —— 即 `归档 ∧ live ⇒ 判死`。理由:归档是**人对这条会话
|
|
532
|
-
* 的处置声明**(宿主会把它从所有分组面隐藏),若仍被当成载体,唤醒调度器会去驱动一条
|
|
533
|
-
* **使用者以为已经收起来**的会话。⚠️ 与字面规则的差异仅此一格;`use` 不受影响
|
|
534
|
-
* (见下方 §use 逃生门),因此真需要复活一条已归档会话时**仍然有受支持的路**。
|
|
535
|
-
*
|
|
536
|
-
* ## 🔴 `use` 的逃生门(owner 第二条,写在调用点)
|
|
537
|
-
*
|
|
538
|
-
* **`use` 不查存活**:它被调用这件事本身证明**当前会话活着**(本模块的被测对象是
|
|
539
|
-
* "别人写的那个 id",而 `use` 手里拿的是**自己**)。⇒ `use` 走无条件覆盖
|
|
540
|
-
* (`claimBinding` 的 `takeover`),因此**判据再严也不会把一条轨迹锁死**。
|
|
541
|
-
* 这条逃生门是判据可以取严的前提,两者必须一起存在。
|
|
542
|
-
*
|
|
543
|
-
* ## 依赖纪律
|
|
544
|
-
*
|
|
545
|
-
* 纯判据 `isSessionAlive` 零依赖、可单测;宿主面只在 `hostAliveProbe` 里,
|
|
546
|
-
* 且**不抛错**(服务缺失 ⇒ 该维度作废,而不是让 ACC 工具整块失败)。
|
|
547
|
-
*/
|
|
548
|
-
/** 宿主侧的归档集读取(不可用 ⇒ 空集 = 该维度作废,**不是**把所有会话判死) */
|
|
549
|
-
function archivedIdsOf(ctx) {
|
|
550
|
-
try {
|
|
551
|
-
const ids = hostService(ctx, "workspaceRegistry")?.archivedSessionIds;
|
|
552
|
-
return new Set(Array.isArray(ids) ? ids : []);
|
|
553
|
-
} catch {
|
|
554
|
-
return /* @__PURE__ */ new Set();
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
/**
|
|
558
|
-
* **宿主面的判活探针**(`(sessionId) => boolean`)——所有需要"这条会话还活着吗"的
|
|
559
|
-
* 生产代码都应当用这一个,不要自己拼 `agents.get` + `hasSessionLogById`。
|
|
560
|
-
*
|
|
561
|
-
* 语义 = {@link isSessionAlive},其中:
|
|
562
|
-
* · `liveIds` 因为宿主只给 `get(id)` 而**按 id 逐次问**(不是集合);
|
|
563
|
-
* · `archivedIds` 在**首次调用时**取一次快照并在闭包内复用(每 tick 一个探针,
|
|
564
|
-
* 归档集在一个 tick 内不变)—— 避免为每条轨迹重复读存储域。
|
|
565
|
-
*
|
|
566
|
-
* ⚠️ **快照的代价**:同一探针内若有人中途归档了某会话,本探针直到下次新建才看见。
|
|
567
|
-
* 调度器是每 tick 新建一个探针(见 `wake/scheduler.ts`),故实际窗口 ≤1 tick。
|
|
568
|
-
*
|
|
569
|
-
* @param ctx 插件上下文(取 `agents` 与 `workspaceRegistry`)
|
|
570
|
-
* @returns 探针;**永不抛**
|
|
571
|
-
*/
|
|
572
|
-
function hostAliveProbe(ctx) {
|
|
573
|
-
let archived;
|
|
574
|
-
const archivedOnce = () => archived ??= archivedIdsOf(ctx);
|
|
575
|
-
return (sessionId) => {
|
|
576
|
-
if (typeof sessionId !== "string" || sessionId === "") return false;
|
|
577
|
-
if (archivedOnce().has(sessionId)) return false;
|
|
578
|
-
try {
|
|
579
|
-
if (hostAgents(ctx)?.get?.(sessionId)) return true;
|
|
580
|
-
} catch {}
|
|
581
|
-
try {
|
|
582
|
-
return hasSessionLogById(sessionsRootDir(), sessionId);
|
|
583
|
-
} catch {
|
|
584
|
-
return true;
|
|
585
|
-
}
|
|
586
|
-
};
|
|
587
|
-
}
|
|
588
|
-
/**
|
|
589
|
-
* 判据只有**两个**出口,别再开第三个:
|
|
590
|
-
* · {@link isSessionAlive} —— 纯判据(给定事实),单测的靶子;
|
|
591
|
-
* · {@link hostAliveProbe} —— 生产入口(自己去宿主与磁盘取事实)。
|
|
592
|
-
*
|
|
593
|
-
* ⚠️ 曾有一个 `aliveFactsFor`(把探针摊平成 `SessionAliveFacts`),**全仓零调用点**,
|
|
594
|
-
* 已删除 —— 留一个"看起来有用、实际无人调用"的导出,会让下一个人以为存在第二条判活路径
|
|
595
|
-
* (本仓同族教训:`cheapWorkerPresetInheritance` 全仓零调用点 ⇒ 接线断了却看不出来)。
|
|
596
|
-
*/
|
|
597
|
-
//#endregion
|
|
598
502
|
//#region src/cro/core.ts
|
|
599
503
|
/**
|
|
600
504
|
* cro/core.ts — CRO(Continuous Re-Occurrence · 持续再发生)机制层(S142 §7.8,2026-09-19)
|
|
@@ -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 { _ as WAKE_CATCH_UP_MS, h as listCroCognitiveTrajectories } from "./scheduler-
|
|
5
|
-
import { n as readSimpleSettings } from "./settings-
|
|
6
|
-
import { i as subscriptionStats, r as subscriptionEval } from "./subscriptions-
|
|
7
|
-
import { containerClocks, containerWakes } from "./observation-
|
|
4
|
+
import { _ as WAKE_CATCH_UP_MS, h as listCroCognitiveTrajectories } from "./scheduler-CA-7xvTS.js";
|
|
5
|
+
import { n as readSimpleSettings } from "./settings-B_FAdsxN.js";
|
|
6
|
+
import { i as subscriptionStats, r as subscriptionEval } from "./subscriptions-I9PUzgcB.js";
|
|
7
|
+
import { containerClocks, containerWakes } from "./observation-CVpwAke1.js";
|
|
8
8
|
//#region src/trajectory/live.ts
|
|
9
9
|
/**
|
|
10
10
|
* trajectory/live.ts — 进程内 live 会话取数 + 精简诊断
|
|
@@ -1,4 +1,101 @@
|
|
|
1
|
-
import { f as hostSettings } from "./ccc-roots-CsSSQjSS.js";
|
|
1
|
+
import { c as hostAgents, f as hostSettings, u as hostService } from "./ccc-roots-CsSSQjSS.js";
|
|
2
|
+
import { i as sessionsRootDir, r as hasSessionLogById } from "./cleanup-CPl1SSaK.js";
|
|
3
|
+
//#region src/trajectory/alive.ts
|
|
4
|
+
/**
|
|
5
|
+
* trajectory/alive.ts — **"这个 dsh 会话还活着吗"的唯一判据**(owner 2026-10-20 裁决)
|
|
6
|
+
*
|
|
7
|
+
* ## owner 的原话(本模块的全部设计依据)
|
|
8
|
+
*
|
|
9
|
+
* > 「死应该包含归档判断;只有 ① 或者 ②且不在归档集 才算活」
|
|
10
|
+
* > 「use 只要被调用了,可以无条件覆盖绑定到当前会话(这说明当前会话肯定活着啊)」
|
|
11
|
+
*
|
|
12
|
+
* ## 为什么必须收成一个判据(在此之前有三个互不一致的判据)
|
|
13
|
+
*
|
|
14
|
+
* | # | 判据 | 旧实现位置 | 单独使用时的漏洞 |
|
|
15
|
+
* |---|---|---|---|
|
|
16
|
+
* | ① | 进程内 loaded agent | `hostAgents(ctx).get(id)` | 冷会话全判死 |
|
|
17
|
+
* | ② | 磁盘上有会话日志 | `hasSessionLogById()` | **归档后日志逐字节不动** ⇒ 归档会话判活 |
|
|
18
|
+
* | ③ | 宿主归档集 | `workspaceRegistry.archivedSessionIds` | 旧 dsp **零引用**(整个仓库 0 处) |
|
|
19
|
+
*
|
|
20
|
+
* 宿主的归档语义是**只往集合里加一个 id、不动日志**(`dsh-workspace` 的
|
|
21
|
+
* `archiveSession` 注释:「Archiving never touches workspace accounting」)。
|
|
22
|
+
* ⇒ 只问 ② 的实现在归档上**必然判错**,而那个错误没有任何机械信号。
|
|
23
|
+
*
|
|
24
|
+
* ## 判据(owner 给定,逐字实现)
|
|
25
|
+
*
|
|
26
|
+
* ```text
|
|
27
|
+
* 活 ⟺ ① (进程内 loaded ⇒ 一定在)
|
|
28
|
+
* ∨ (② ∧ 不在归档集) (日志在、且没人把它归档掉)
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* 🔴 **一处对原话的收紧(必须说出来,不许默默改)**:owner 的 ① 未附加"不在归档集",
|
|
32
|
+
* 而本模块把**归档判定排在最前** —— 即 `归档 ∧ live ⇒ 判死`。理由:归档是**人对这条会话
|
|
33
|
+
* 的处置声明**(宿主会把它从所有分组面隐藏),若仍被当成载体,唤醒调度器会去驱动一条
|
|
34
|
+
* **使用者以为已经收起来**的会话。⚠️ 与字面规则的差异仅此一格;`use` 不受影响
|
|
35
|
+
* (见下方 §use 逃生门),因此真需要复活一条已归档会话时**仍然有受支持的路**。
|
|
36
|
+
*
|
|
37
|
+
* ## 🔴 `use` 的逃生门(owner 第二条,写在调用点)
|
|
38
|
+
*
|
|
39
|
+
* **`use` 不查存活**:它被调用这件事本身证明**当前会话活着**(本模块的被测对象是
|
|
40
|
+
* "别人写的那个 id",而 `use` 手里拿的是**自己**)。⇒ `use` 走无条件覆盖
|
|
41
|
+
* (`claimBinding` 的 `takeover`),因此**判据再严也不会把一条轨迹锁死**。
|
|
42
|
+
* 这条逃生门是判据可以取严的前提,两者必须一起存在。
|
|
43
|
+
*
|
|
44
|
+
* ## 依赖纪律
|
|
45
|
+
*
|
|
46
|
+
* 纯判据 `isSessionAlive` 零依赖、可单测;宿主面只在 `hostAliveProbe` 里,
|
|
47
|
+
* 且**不抛错**(服务缺失 ⇒ 该维度作废,而不是让 ACC 工具整块失败)。
|
|
48
|
+
*/
|
|
49
|
+
/** 宿主侧的归档集读取(不可用 ⇒ 空集 = 该维度作废,**不是**把所有会话判死) */
|
|
50
|
+
function archivedIdsOf(ctx) {
|
|
51
|
+
try {
|
|
52
|
+
const ids = hostService(ctx, "workspaceRegistry")?.archivedSessionIds;
|
|
53
|
+
return new Set(Array.isArray(ids) ? ids : []);
|
|
54
|
+
} catch {
|
|
55
|
+
return /* @__PURE__ */ new Set();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* **宿主面的判活探针**(`(sessionId) => boolean`)——所有需要"这条会话还活着吗"的
|
|
60
|
+
* 生产代码都应当用这一个,不要自己拼 `agents.get` + `hasSessionLogById`。
|
|
61
|
+
*
|
|
62
|
+
* 语义 = {@link isSessionAlive},其中:
|
|
63
|
+
* · `liveIds` 因为宿主只给 `get(id)` 而**按 id 逐次问**(不是集合);
|
|
64
|
+
* · `archivedIds` 在**首次调用时**取一次快照并在闭包内复用(每 tick 一个探针,
|
|
65
|
+
* 归档集在一个 tick 内不变)—— 避免为每条轨迹重复读存储域。
|
|
66
|
+
*
|
|
67
|
+
* ⚠️ **快照的代价**:同一探针内若有人中途归档了某会话,本探针直到下次新建才看见。
|
|
68
|
+
* 调度器是每 tick 新建一个探针(见 `wake/scheduler.ts`),故实际窗口 ≤1 tick。
|
|
69
|
+
*
|
|
70
|
+
* @param ctx 插件上下文(取 `agents` 与 `workspaceRegistry`)
|
|
71
|
+
* @returns 探针;**永不抛**
|
|
72
|
+
*/
|
|
73
|
+
function hostAliveProbe(ctx) {
|
|
74
|
+
let archived;
|
|
75
|
+
const archivedOnce = () => archived ??= archivedIdsOf(ctx);
|
|
76
|
+
return (sessionId) => {
|
|
77
|
+
if (typeof sessionId !== "string" || sessionId === "") return false;
|
|
78
|
+
if (archivedOnce().has(sessionId)) return false;
|
|
79
|
+
try {
|
|
80
|
+
if (hostAgents(ctx)?.get?.(sessionId)) return true;
|
|
81
|
+
} catch {}
|
|
82
|
+
try {
|
|
83
|
+
return hasSessionLogById(sessionsRootDir(), sessionId);
|
|
84
|
+
} catch {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* 判据只有**两个**出口,别再开第三个:
|
|
91
|
+
* · {@link isSessionAlive} —— 纯判据(给定事实),单测的靶子;
|
|
92
|
+
* · {@link hostAliveProbe} —— 生产入口(自己去宿主与磁盘取事实)。
|
|
93
|
+
*
|
|
94
|
+
* ⚠️ 曾有一个 `aliveFactsFor`(把探针摊平成 `SessionAliveFacts`),**全仓零调用点**,
|
|
95
|
+
* 已删除 —— 留一个"看起来有用、实际无人调用"的导出,会让下一个人以为存在第二条判活路径
|
|
96
|
+
* (本仓同族教训:`cheapWorkerPresetInheritance` 全仓零调用点 ⇒ 接线断了却看不出来)。
|
|
97
|
+
*/
|
|
98
|
+
//#endregion
|
|
2
99
|
//#region src/surface/settings.ts
|
|
3
100
|
/**
|
|
4
101
|
* 设置面板命名空间 = **profile 条目 id**(v0.1.7 起;与旧 `settings.yaml` 段名逐字相同)。
|
|
@@ -142,4 +239,4 @@ function registerSettingsSection(ctx, config) {
|
|
|
142
239
|
} catch {}
|
|
143
240
|
}
|
|
144
241
|
//#endregion
|
|
145
|
-
export { readSimpleSettings as n, registerSettingsSection as r, SERENITY_SETTINGS_NS as t };
|
|
242
|
+
export { hostAliveProbe as i, readSimpleSettings as n, registerSettingsSection as r, SERENITY_SETTINGS_NS as t };
|
|
@@ -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 { p as registerDisposer } from "./scheduler-
|
|
4
|
+
import { p as registerDisposer } from "./scheduler-CA-7xvTS.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-CA-7xvTS.js").then((n) => n.r);
|
|
310
310
|
const res = await sendToCognitiveTrajectory(ctx, root, target, message, "trajectory-subscription");
|
|
311
311
|
return {
|
|
312
312
|
ok: res.ok,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shgroup/dsh-serenity-hooks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.122.0",
|
|
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;另三个 im-bridge/diagram/reconstruct 按条件出现)+ 机械约束(安全模式/工作区围墙/密钥守卫/对外输出守卫)+ 认知轨迹日志与原地重建 + 网页登录入口/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": {
|