dsh-zhou 3.17.1 → 3.18.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/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
  >
16
16
  > 这不是自动升级:npm 上两个包是独立的名字,装过旧包的人必须自己换一次。旧包会被 `deprecate` 指向新包。
17
17
  >
18
- > **预设 id 一个都没变**:`wisteria` / `mutabilis` / `orchid` / `hydrangea` / `begonia` / `prunus` / `temp` / `temp-read` 全部照旧,存储目录(`meru-usage` / `session-core` / `temp-auto-archive`)与已有会话、任务台账都不受影响。改的是**包的签名**,不是预设,不用重新配一遍。
18
+ > **改名那一步没有动预设 id**:`wisteria` / `mutabilis` / `orchid` / `hydrangea` / `begonia` / `prunus` / `temp` 全部照旧(`temp-read` 是 3.18.0 单独删掉的,与改名无关),存储目录(`meru-usage` / `session-core` / `temp-auto-archive`)与已有会话、任务台账都不受影响。改的是**包的签名**,不是预设,不用重新配一遍。
19
19
 
20
20
  这份文件随插件走,装好之后**先读它**。
21
21
 
@@ -41,7 +41,6 @@
41
41
  | `hydrangea` | Hydrangea 侦察 | 夏官司马 | 定期巡视、盯外部来源、报情报;只报不取回 |
42
42
  | `begonia` | Begonia 审计 | 秋官司寇 | 独立复核、读源码核事实、找错、卡门 |
43
43
  | `prunus` | Prunus 开发 | 冬官司空 | 写代码、装插件、改配置;README 与技能文档也归它 |
44
- | `temp-read` | Temp Read 只读代答 | — | 只读代答(3.10.0):忙着的会话被提问时由它代答;能读文件、能搜索,**没有写工具也没有命令工具** |
45
44
 
46
45
  > **3.0.0(breaking,2026-12-02)删掉了五个历史预设**:`chief`、`maid`、`captain`、`dev`、`clerk`。
47
46
  > 现在这个包只发 `temp` 与六官。`order` 1–5 是空号,故意不重排。旧会话若仍指向被删预设,
@@ -395,7 +394,11 @@ if (!mem.bootSwept) { mem.bootSwept = true; void sweep(); }
395
394
 
396
395
  **回执里的 `deliveredAtHead`** 说明这条消息是不是真的抢到了下一轮的开头;不是时 `deliveredAtHeadReason` 给出七种原因之一:`interrupts-off`(部署关了打断)、`cooldown`(冷却中)、`ping-pong`(两个会话互相打断太频繁)、`pre-cancel`(取消前就放弃了)、`post-cancel-restored`(取消后恢复成排队)、`duplicate`(同一条消息已经在收件箱里)、`lost`(取消后投递失败,`failed` / `lost` 列出要重发的 id)。
397
396
 
398
- **问一个正在忙的会话(3.10.0 的 `just_ask`)**:目标在跑一轮时,`just_ask: true` 不去碰它——核心在**目标的工作目录**里 blank 新建一个 `temp-read` 只读会话,首条消息里带三样东西:目标的交接单(`buildHandoffArtifact` 的产出,说明它在做什么、做到哪)、你的原话、以及「只回答这一条,别做别的」的约束和回信地址(`mps_send({ to: 你, kind: 'conclusion', closing: true })`)。替身没有 `tool-pwsh`/`tool-bash`/`tool-fs` 的写权限,**只读是真的不给工具**,不是靠提示词拦。目标那一刻不被打断、也不进收件箱,回执里 `standIn: { sessionId, target }` 指明是谁在替它答。目标空闲时 `just_ask` 就是一次普通投递,不会多建会话;`allowSpawn` 关掉的部署退回「直接投给忙目标」并在 `note` 里说明。`just_ask` 与 `wait_seconds` 互斥,同传报 `E_SEND_ARGS`。
397
+ **问一个正在忙的会话(3.10.0 的 `just_ask`,3.18.0 起替身是 `temp`)**:目标在跑一轮时,`just_ask: true` 不去碰它——核心在**目标的工作目录**里 blank 新建一个 `temp` 替身会话,并在**首条消息之前**往它的账本写一条 `sandbox/mode = read-only` 事件,再把三样东西当成首条消息投进去:目标的交接单(`buildHandoffArtifact` 的产出,说明它在做什么、做到哪)、你的原话、以及「只回答这一条,别做别的」的约束和回信地址(`mps_send({ to: 你, kind: 'conclusion', closing: true })`)。
398
+
399
+ > **3.18.0 之前只读靠"不给工具"**(独立的 `temp-read` 预设,不挂写工具与命令工具)。现在只读靠**沙箱锁**:`session.append('sandbox/mode', { mode: 'read-only' })`,与内核自己的 `setSandboxMode()` 是同一个机制,执行侧由 `sandboxPolicy.resolve()` 按最后一条事件取模。锁只写替身自己那一个会话,其它 `temp` 会话不受影响;锁写在首条消息之前,否则第一轮已经按旧模式排好了。`standInReadOnly: false` 关掉它,替身就拿 `temp` 的默认权限。
400
+
401
+ 锁写不进去(会话对象没有 `append()`、或 `append` 抛错)时**只 warn 一次**,回执 `note` 追加 `read-only lock: skipped (原因)`,消息照常投递——一个能写的替身仍然比一个没人回答的问题好。目标那一刻不被打断、也不进收件箱,回执里 `standIn: { sessionId, target }` 指明是谁在替它答。目标空闲时 `just_ask` 就是一次普通投递,不会多建会话;`allowSpawn` 关掉的部署退回「直接投给忙目标」并在 `note` 里说明。`just_ask` 与 `wait_seconds` 互斥,同传报 `E_SEND_ARGS`。
399
402
 
400
403
  **限速**:同一个目标每 `sendCooldownSeconds`(默认 10 秒)最多一次打断;每 `sendInterruptsPerMinute`(默认 3)次/分钟;两个会话之间 `sendPingPongPerMinute`(默认 2)次/分钟。
401
404
 
package/cordis.patch.yml CHANGED
@@ -1042,49 +1042,6 @@
1042
1042
  # 重启;下面这几个值只是那个文件不存在时写进去的首跑默认值。
1043
1043
  # 不发送任何消息/回执/卡片/心跳;唯一痕迹是 storages/temp-auto-archive.log(纯文本,
1044
1044
  # 保留 logRetentionDays 天)。定时器 unref,启动时不扫,首轮在 sweepMinutes 之后。
1045
- - insert:
1046
- - id: preset-temp-read
1047
- name: '@deepseek-ai/dsh-agent-preset'
1048
- config:
1049
- id: temp-read
1050
- name: Temp Read 只读代答
1051
- description: 只读代答:替忙着的会话回答一条消息——能读文件、能搜索,不能写、不能跑命令。
1052
- order: 13
1053
- plugins:
1054
- - id: persona
1055
- name: '@deepseek-ai/dsh-persona'
1056
- config:
1057
- prefix: |-
1058
- You are a read-only stand-in. A Session was busy, so its question was handed to you; answer it from what you can read, and change nothing.
1059
- complete: true
1060
- includeRuntimeContext: false
1061
- - id: agent-instructions
1062
- name: '@deepseek-ai/dsh-agent-instructions'
1063
- config:
1064
- maxBytes: 65536
1065
- - id: tool-fs
1066
- name: '@deepseek-ai/dsh-tool-fs'
1067
- config:
1068
- # 3.10.0: 只读是真的不给工具,不是靠提示词约束
1069
- applyPatch: false
1070
- read: true
1071
- write: false
1072
- edit: false
1073
- readImage: true
1074
- - id: tool-fs-search
1075
- name: '@deepseek-ai/dsh-tool-fs-search'
1076
- config:
1077
- sampleOverCapGlobResults: false
1078
- - id: tool-ask-user
1079
- name: '@deepseek-ai/dsh-tool-ask-user'
1080
- - id: skill-filesystem
1081
- name: '@deepseek-ai/dsh-skill-filesystem'
1082
- config:
1083
- customSkillDirs:
1084
- - !!js process.getBuiltinModule('node:path').join(process.getBuiltinModule('node:path').dirname(process.getBuiltinModule('node:module').createRequire(baseUrl).resolve('@deepseek-ai/dsh-agent-preset/package.json')), 'skills')
1085
- - !!js process.getBuiltinModule('node:path').join(process.getBuiltinModule('node:path').dirname(process.getBuiltinModule('node:module').createRequire(baseUrl).resolve('dsh-zhou/package.json')), 'skills')
1086
- - id: chief-tools
1087
- name: dsh-zhou/chief
1088
1045
 
1089
1046
  - insert:
1090
1047
  - id: temp-archive
@@ -135,6 +135,23 @@ export const DEFAULT_CONFIG = Object.freeze({
135
135
  * Counted across senders: the backlog is the target's, not this conversation's.
136
136
  */
137
137
  sendWaitBypassCount: 3,
138
+ /**
139
+ * Lock a `just_ask` stand-in to `read-only` (3.18.0).
140
+ *
141
+ * Until 3.18.0 the stand-in was the `temp-read` preset, and read-only was
142
+ * enforced by *not mounting* the write tools. That worked, but it cost a whole
143
+ * preset that existed for one caller, and the preset could not be reused. From
144
+ * 3.18.0 the stand-in is an ordinary `temp` Session and the plugin writes one
145
+ * `sandbox/mode` event into it before the first message arrives — the same
146
+ * thing the kernel's own `setSandboxMode()` does, and the mode the execution
147
+ * side resolves through `sandboxPolicy`.
148
+ *
149
+ * `true` (the default) means: a stand-in cannot write. `false` gives it the
150
+ * `temp` preset's ordinary sandbox, i.e. exactly 3.17.1 behaviour minus the
151
+ * separate preset. Whatever the value, only the stand-in's own Session is
152
+ * affected; every other `temp` Session keeps its own mode.
153
+ */
154
+ standInReadOnly: true,
138
155
  /**
139
156
  * Treat a target that is parked in a sleep-style wait as interruptible (3.8.0).
140
157
  *
@@ -441,6 +458,7 @@ export function normalizeConfig(raw) {
441
458
  sendWaitSeconds: integer(value.sendWaitSeconds, DEFAULT_CONFIG.sendWaitSeconds, 0, 60),
442
459
  sendAfterWait: choice(value.sendAfterWait, DEFAULT_CONFIG.sendAfterWait, ['refuse', 'interrupt']),
443
460
  sendWaitBypassCount: integer(value.sendWaitBypassCount, DEFAULT_CONFIG.sendWaitBypassCount, 1, 64),
461
+ standInReadOnly: boolean(value.standInReadOnly, DEFAULT_CONFIG.standInReadOnly),
444
462
  interruptOnSleep: boolean(value.interruptOnSleep, DEFAULT_CONFIG.interruptOnSleep),
445
463
  sleepDetectSeconds: decimal(value.sleepDetectSeconds, DEFAULT_CONFIG.sleepDetectSeconds, 0.5, 60),
446
464
  fileLock: normalizeFileLock(value.fileLock),
package/lib/chief/core.js CHANGED
@@ -1282,11 +1282,17 @@ export class ChiefCore {
1282
1282
  * Answer a busy target through a read-only stand-in Session (3.10.0).
1283
1283
  *
1284
1284
  * The question, not the target, is what has to move: the stand-in is a blank
1285
- * `temp-read` Session in the target's workspace whose first message carries the
1285
+ * `temp` Session in the target's workspace whose first message carries the
1286
1286
  * target's hand-off artifact, the message verbatim, and the one rule that keeps
1287
1287
  * the answer usable — answer it, do not start other work. The target itself is
1288
1288
  * never touched: no cancel, no inbox write, no ledger event, so a busy turn
1289
1289
  * finishes exactly as it would have without this send.
1290
+ *
1291
+ * 3.18.0: the stand-in used to be the `temp-read` preset, where "read-only" was
1292
+ * enforced by not mounting the write tools. It is an ordinary `temp` Session
1293
+ * now, and the read-only part is one `sandbox/mode` event written before the
1294
+ * first message — {@link applySandboxMode} in `handoff.js`. Any failure there
1295
+ * is reported once and never blocks the delivery.
1290
1296
  * @param {object} input - the original send request, with `target` resolved.
1291
1297
  * @returns {Promise<object>} a receipt naming the stand-in, never the target.
1292
1298
  */
@@ -1324,6 +1330,9 @@ export class ChiefCore {
1324
1330
  is_temp: true,
1325
1331
  callerId: sender?.id,
1326
1332
  callerCwd: sender?.cwd,
1333
+ // 3.18.0: the lock is part of opening, not a follow-up call, because it has
1334
+ // to land on the ledger before the first message does.
1335
+ ...(this.config.standInReadOnly === true ? { sandboxMode: 'read-only' } : {}),
1327
1336
  });
1328
1337
  if (opened.ok !== true) {
1329
1338
  return {
@@ -1339,6 +1348,14 @@ export class ChiefCore {
1339
1348
  };
1340
1349
  }
1341
1350
  const standInId = String(opened.sessionId ?? '');
1351
+ // A lock that could not be written is reported once and never blocks the
1352
+ // answer: an unlocked stand-in still answers, and a lost question does not.
1353
+ let lockNote = '';
1354
+ if (this.config.standInReadOnly === true && opened.sandboxMode !== 'read-only') {
1355
+ const reason = opened.sandboxModeSkipped ?? 'the sandbox mode event was not written';
1356
+ this.#warn(`just_ask stand-in ${standInId} could not be locked to read-only: ${reason}; the answer proceeds unlocked`);
1357
+ lockNote = ` read-only lock: skipped (${reason}).`;
1358
+ }
1342
1359
  void this.#audit({
1343
1360
  event: 'stand-in',
1344
1361
  action: 'spawned',
@@ -1356,7 +1373,7 @@ export class ChiefCore {
1356
1373
  crossWorkspace: false,
1357
1374
  waitedMs: 0,
1358
1375
  standIn: { sessionId: standInId, target: busyTarget.sessionId },
1359
- note: `"${busyTarget.sessionId}" was running a turn, so a read-only stand-in (${STAND_IN_PRESET}) will answer: ${standInId}. The target was not interrupted and did not receive this message; the stand-in was told to reply to ${sender?.id ?? 'the caller'}.`,
1376
+ note: `"${busyTarget.sessionId}" was running a turn, so a read-only stand-in (${STAND_IN_PRESET}) will answer: ${standInId}. The target was not interrupted and did not receive this message; the stand-in was told to reply to ${sender?.id ?? 'the caller'}.${lockNote}`,
1360
1377
  };
1361
1378
  }
1362
1379
 
@@ -6677,8 +6694,8 @@ function readAgent(ctx, sessionId) {
6677
6694
  * @returns {boolean} true when a turn is running.
6678
6695
  */
6679
6696
  /** `mps_wait` window: default and ceiling, in seconds (3.9.1). */
6680
- /** Preset a read-only stand-in Session runs with (3.10.0). */
6681
- const STAND_IN_PRESET = 'temp-read';
6697
+ /** Preset a stand-in Session runs with (3.10.0; `temp` since 3.18.0). */
6698
+ const STAND_IN_PRESET = 'temp';
6682
6699
  const DEFAULT_WAIT_SECONDS = 30;
6683
6700
  const MAX_WAIT_SECONDS = 300;
6684
6701
  /**
@@ -7186,7 +7203,7 @@ function spawnTitle(message) {
7186
7203
  }
7187
7204
 
7188
7205
  /**
7189
- * Compose the first message of a `temp-read` stand-in Session (3.10.0).
7206
+ * Compose the first message of a stand-in Session (3.10.0; `temp` since 3.18.0).
7190
7207
  *
7191
7208
  * The stand-in starts cold, so the message has to carry everything: who is being
7192
7209
  * asked on whose behalf, the target's hand-off artifact (what that Session was
@@ -249,7 +249,7 @@ export function installForkTakeover(ctx, config = {}, core = undefined) {
249
249
  * On the fork path a branch notice is injected first, then the message.
250
250
  *
251
251
  * @param {object} core - the chief core (`sessionsApi`, `taskLedger`, `sessionStore`).
252
- * @param {object} args - `{message, from, sessionId, name, preset, cwd, taskId, is_temp}`.
252
+ * @param {object} args - `{message, from, sessionId, name, preset, cwd, taskId, is_temp, sandboxMode}`.
253
253
  * @returns {Promise<object>} `{ok, sessionId, path, noticeInjected, messageInjected, warnings, note}` — always, success or failure.
254
254
  */
255
255
  export async function openSession(core, args) {
@@ -310,6 +310,7 @@ async function openSessionInner(core, args) {
310
310
  const cwd = requestedCwd ?? callerCwd;
311
311
  const taskId = text(input.taskId);
312
312
  const isTemp = input.is_temp === true;
313
+ const sandboxMode = text(input.sandboxMode);
313
314
  const warnings = [];
314
315
 
315
316
  // 3.1.0: `is_temp` no longer masquerades as the `temp` preset. It is a row in
@@ -412,9 +413,19 @@ async function openSessionInner(core, args) {
412
413
 
413
414
  let noticeInjected = false;
414
415
  let messageInjected = false;
416
+ let sandboxModeApplied = false;
417
+ let sandboxModeSkipped;
415
418
  try {
416
419
  const agent = await findAgent(core, sessionId);
417
420
  if (agent === undefined || agent === null) throw new Error(`no live Agent for ${sessionId}`);
421
+ // 3.18.0: the mode has to be on the ledger *before* the first message, or the
422
+ // stand-in's first turn is composed against the preset's default sandbox and
423
+ // the lock arrives one turn too late to stop a write.
424
+ if (sandboxMode !== undefined) {
425
+ const locked = applySandboxMode(agent, sandboxMode, warnings);
426
+ if (locked.ok === true) sandboxModeApplied = true;
427
+ else sandboxModeSkipped = locked.reason;
428
+ }
418
429
  await touchRoster(core, {
419
430
  sessionId,
420
431
  name,
@@ -462,6 +473,8 @@ async function openSessionInner(core, args) {
462
473
  messageInjected,
463
474
  warnings,
464
475
  ...(isTemp ? { is_temp: true } : {}),
476
+ ...(sandboxModeApplied ? { sandboxMode } : {}),
477
+ ...(sandboxModeSkipped === undefined ? {} : { sandboxModeSkipped }),
465
478
  note: `已通过 ${path} 打开 ${sessionId},首条消息已作为 agent-message 卡片注入。`,
466
479
  };
467
480
  }
@@ -638,6 +651,44 @@ async function isLive(core, sessionId) {
638
651
  return false;
639
652
  }
640
653
 
654
+ /**
655
+ * Write one `sandbox/mode` event into a freshly opened Session (3.18.0).
656
+ *
657
+ * This is the kernel's own mechanism, not a re-implementation: `setSandboxMode()`
658
+ * in `@deepseek-ai/dsh-sandbox-policy` is one line — `session.append('sandbox/mode',
659
+ * { mode })` — and the execution side resolves the last such event through
660
+ * `sandboxPolicy`. So the plugin appends the event itself instead of importing a
661
+ * host package, whose module path is not ours to depend on.
662
+ *
663
+ * It has to happen *before* the first message reaches the Session: a turn that
664
+ * was already composed reads the mode it started with.
665
+ *
666
+ * Failure never blocks the delivery — a stand-in that can write is worse than no
667
+ * stand-in, but a question that never gets asked is worse still — so the reason
668
+ * goes back to the caller as `sandboxModeSkipped`.
669
+ *
670
+ * @param {object} agent - the live Agent record, whose `session` is the Session.
671
+ * @param {'read-only'|string} mode - the mode to write.
672
+ * @param {string[]} warnings - the open call's warning sink.
673
+ * @returns {{ok: boolean, reason?: string}}
674
+ */
675
+ function applySandboxMode(agent, mode, warnings) {
676
+ const session = agent?.session;
677
+ if (session === undefined || session === null || typeof session.append !== 'function') {
678
+ const reason = 'the new Session exposes no append()';
679
+ warnings.push(`sandbox mode "${mode}" was not set: ${reason}`);
680
+ return { ok: false, reason };
681
+ }
682
+ try {
683
+ session.append('sandbox/mode', { mode });
684
+ return { ok: true };
685
+ } catch (error) {
686
+ const reason = detail(error);
687
+ warnings.push(`sandbox mode "${mode}" was not set: ${reason}`);
688
+ return { ok: false, reason };
689
+ }
690
+ }
691
+
641
692
  /**
642
693
  * Find the live Agent that can receive an inbound message.
643
694
  * @param {object} core - chief core.
@@ -49,7 +49,7 @@ Threads and envelopes:
49
49
  Rules:
50
50
  - A requirement is a task, and a task is what messages are about: open it with \`mps_task\` \`create\` (\`acceptance\` = how the user judges it, \`constraints\` = red lines such as "no production deploy without approval"), then put its \`task_id\` on every \`mps_send\`/\`mps_new\`/\`mps_read\`. The core stamps \`task=<id>\` and \`task-title:\` into the envelope and inherits it across the thread, so neither side has to re-explain which requirement it means.
51
51
  - The task card is authoritative: a user-role message starting \`[session-core task card]\` is injected before your turn and states the requirement, its acceptance criteria, its constraints, and the reply rules. Treat it as the current demand, not as the user's new message.
52
- - A question for a busy Session: send with \`just_ask: true\` — the core opens a read-only stand-in Session (\`temp-read\`) in that workspace, hands it the target hand-off artifact and your message, and the stand-in answers back to you; the original owner is never interrupted. \`just_ask\` and \`wait_seconds\` are exclusive: pick one.
52
+ - A question for a busy Session: send with \`just_ask: true\` — the core opens a stand-in Session (\`temp\`) in that workspace and locks its sandbox to \`read-only\`, hands it the target hand-off artifact and your message, and the stand-in answers back to you; the original owner is never interrupted. \`just_ask\` and \`wait_seconds\` are exclusive: pick one.
53
53
  - Correct early: send a correction with \`kind: "correction"\` the moment you see the peer working on a wrong assumption — it will read it at its next interruptible point.
54
54
  - \`queued\` is not \`consumed\`: check \`lastMessageState\` and \`peerRunning\`; read the peer's answer or transcript instead of assuming it acted. An old \`sent-at\` means the message waited — verify the current state before acting on it.
55
55
  - Ask the Session that knows: \`mps_find\` first; a title is a guess. Only \`mps_send\` wakes anyone.
@@ -807,7 +807,7 @@ export function registerTools(ctx, core, options = {}) {
807
807
  },
808
808
  just_ask: {
809
809
  type: 'boolean',
810
- description: 'Answer a busy target without touching it: a read-only stand-in (preset temp-read) answers. Mutually exclusive with wait_seconds.',
810
+ description: 'Answer a busy target without touching it: a stand-in Session (preset temp, sandbox locked to read-only) answers. Mutually exclusive with wait_seconds.',
811
811
  },
812
812
  wait_seconds: {
813
813
  type: 'integer',
@@ -2045,7 +2045,7 @@ export function registerTools(ctx, core, options = {}) {
2045
2045
  additionalProperties: false,
2046
2046
  properties: {
2047
2047
  session: { type: 'string', description: 'Name (a unique substring is enough) or exact sessionId of the target Session.' },
2048
- preset: { type: 'string', description: 'Target preset id, such as standard, cordis, temp, temp-read, wisteria, mutabilis, orchid, hydrangea, begonia, prunus.' },
2048
+ preset: { type: 'string', description: 'Target preset id, such as standard, cordis, temp, wisteria, mutabilis, orchid, hydrangea, begonia, prunus.' },
2049
2049
  dry_run: { type: 'boolean', description: 'Defaults to true: report what would happen without writing. Pass false to write.' },
2050
2050
  },
2051
2051
  required: ['session', 'preset'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-zhou",
3
- "version": "3.17.1",
3
+ "version": "3.18.0",
4
4
  "description": "用周礼六官体制帮你的DSH自进化。",
5
5
  "type": "module",
6
6
  "exports": {