dsh-mask 0.2.19 → 0.2.22

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/index.mjs CHANGED
@@ -7,6 +7,9 @@
7
7
  // 日志重建(占位符形式),原文绝不进会话日志。
8
8
  // - 恢复表:占位符→原文映射只存内存 + 受控 storageDomain(dsh_mask/restore),
9
9
  // 绝不进会话日志明文;/mask restore 与恢复 seam 按需回载。
10
+ // - 还原交付:宿主把命令结果(command/done.text)原样写进持久会话日志,且客户端
11
+ // 用户可见输出就是从同一条事件渲染的(同源,无法分离)⇒ /mask restore 绝不把
12
+ // 明文放进结果文本,而是写进受控文件(lib/deliver.mjs)并把路径回给用户。
10
13
  // - 审计:mask/applied 会话事件只记"替换了 N 处 + 类型分布"(log-only,自适应
11
14
  // 门),不记明文与映射。
12
15
  // - 表面:/mask 命令(status|on|off|restore|help)与 mask_test 工具(试跑一段
@@ -39,6 +42,8 @@ import { maskMessages, maskContentBlocks } from './lib/mask.mjs'
39
42
  import { makeEventGate, maybeAppendSessionEvent } from './lib/gate.mjs'
40
43
  import { RestoreStore } from './lib/store.mjs'
41
44
  import { dshMaskDomainSpec } from './lib/domain.mjs'
45
+ import { deliverPlaintext, resolveRestoreDir } from './lib/deliver.mjs'
46
+ import { redactText } from './lib/sanitize.mjs'
42
47
 
43
48
  export const name = PLUGIN_NAME
44
49
 
@@ -96,6 +101,7 @@ export const Config = Schema.object({
96
101
  maxRestoreEntriesPerSession: Schema.number().default(DEFAULTS.MAX_RESTORE_ENTRIES_PER_SESSION),
97
102
  maxSessions: Schema.number().default(DEFAULTS.MAX_SESSIONS),
98
103
  maskClientEnabled: Schema.boolean().default(DEFAULTS.MASK_CLIENT_ENABLED),
104
+ restoreDir: Schema.string().default(DEFAULTS.RESTORE_DIR),
99
105
  })
100
106
 
101
107
  /**
@@ -116,9 +122,13 @@ export function resolveConfig(config = {}) {
116
122
  maxRestoreEntriesPerSession: config.maxRestoreEntriesPerSession ?? DEFAULTS.MAX_RESTORE_ENTRIES_PER_SESSION,
117
123
  maxSessions: config.maxSessions ?? DEFAULTS.MAX_SESSIONS,
118
124
  maskClientEnabled: config.maskClientEnabled ?? DEFAULTS.MASK_CLIENT_ENABLED,
125
+ restoreDir: config.restoreDir ?? DEFAULTS.RESTORE_DIR,
119
126
  }
120
127
  if (resolved.enabled === false) return resolved
121
128
 
129
+ if (typeof resolved.restoreDir !== 'string') {
130
+ throw badConfig('restoreDir must be a string (empty = the OS temp directory)')
131
+ }
122
132
  if (resolved.mode === MODES.REGEX_NER) {
123
133
  throw nerModeUnsupported(resolved.mode)
124
134
  }
@@ -178,7 +188,37 @@ const HELP_TEXT = [
178
188
  ' status show masking state: enabled, total replaced, type distribution (default)',
179
189
  ' on enable masking at runtime (config.enabled is the persistent switch)',
180
190
  ' off disable masking at runtime',
181
- ' restore unmap placeholders in <text> back to the values stored for this session',
191
+ ' restore unmap placeholders in <text> back to the values stored for this session and',
192
+ ' deliver the plaintext as a file — never in this result text or the session log',
193
+ ].join('\n')
194
+
195
+ /**
196
+ * restore 结果的安全文案(纯函数):只含占位符与落点路径,绝不含还原出的明文。
197
+ * 路径由「配置目录 + 固定前缀 + 会话 id 的 sha256 前 16 位 + .txt」拼成,
198
+ * 不含会话 id、更不含原文,因此可以安全地进日志/转录(这也是它与明文的关键区别)。
199
+ * @param {{placeholders: string[], path: string}} delivery - 占位符与落点。
200
+ * @returns {string} 命令结果文本。
201
+ */
202
+ export function renderRestore(delivery) {
203
+ return [
204
+ `mask: restored ${delivery.placeholders.length} placeholder(s): ${delivery.placeholders.join(', ')}`,
205
+ ` file: ${delivery.path} (mode 0600, one file per session)`,
206
+ ' The plaintext is NOT in this text and NOT in the session log: the host records a',
207
+ ' command\'s result verbatim, so this command writes the restored text to the file above',
208
+ ' instead. Open it to read the plaintext; the next /mask restore overwrites it.',
209
+ ].join('\n')
210
+ }
211
+
212
+ /**
213
+ * restore 无参形态的说明(该形态未实现,见 README「Known limitations」):
214
+ * 定位「最近一条助手消息」需要同步读会话事件史,而宿主已把
215
+ * `Session.snapshotEvents()/eventAt()/ownEvents()` 标为 @deprecated 并禁止新调用方。
216
+ */
217
+ const RESTORE_NO_ARG_NOTE = [
218
+ ' (a no-argument form that would restore every placeholder of the last assistant message is',
219
+ ' not offered: the restore table is a flat per-session map with no per-message index, and',
220
+ ' locating that message needs a synchronous session-history read the host prohibits for new',
221
+ ' callers — see README Known limitations.)',
182
222
  ].join('\n')
183
223
 
184
224
  /**
@@ -383,6 +423,19 @@ export function apply(ctx, config = {}) {
383
423
  name: COMMAND_NAME,
384
424
  description: 'PII masking status and controls: status (replaced count + type distribution), on/off (runtime toggle), restore <text> (unmap placeholders to this session\'s values), help.',
385
425
  input: { hint: '[status | on | off | restore <text> | help]' },
426
+ // `recordInput: false` —— 输入侧的同类泄漏闸(2026-10-13,用户裁定)。
427
+ //
428
+ // 为什么必须关:宿主把 `parsed.rawInput`(逐字原文)写进 `command/run` 事件的 `args`
429
+ // 字段(dsh-commands `index.ts:376`),而该事件同样进持久会话转录。于是
430
+ // `/mask restore 13812345678`(用户直接粘贴明文)会把 PII 写进日志 —— 与
431
+ // 结果侧那条缺陷同一个洞,只是入口不同。关掉它后 `args` 字段整体缺席(宿主
432
+ // `index.ts:215` 只在显式设置时才带上该键)。
433
+ //
434
+ // 代价(如实记录,勿以为无损):`recordInput` 是**命令级、无子命令粒度**
435
+ // (宿主 `types.ts:75`),所以 `status` / `on` / `off` 的 args 也一并退出转录。
436
+ // 这三条都是无参数或单关键词调用,信息量本来就为零;而恢复映射本身另有
437
+ // 交付文件与 `mask/applied` 审计事件承载,不依赖 args。因此这是净收益。
438
+ recordInput: false,
386
439
  async handler(invocation) {
387
440
  return handleMaskCommand(invocation)
388
441
  },
@@ -422,14 +475,33 @@ export function apply(ctx, config = {}) {
422
475
  return { kind: 'error', text: 'mask: restore requires an active session' }
423
476
  }
424
477
  if (snippet === '') {
425
- return { kind: 'error', text: 'mask: restore needs text, e.g. /mask restore <PHONE_1>' }
478
+ return { kind: 'error', text: `mask: restore needs text, e.g. /mask restore <PHONE_1>\n${RESTORE_NO_ARG_NOTE}` }
479
+ }
480
+ const { text: restored, placeholders } = await store.restoreDetailed(sessionId, snippet)
481
+ if (placeholders.length === 0) {
482
+ return {
483
+ kind: 'success',
484
+ text: [
485
+ 'mask: restore found no placeholder this session knows — nothing was revealed or written.',
486
+ ' Pass a placeholder exactly as the model saw it, e.g. /mask restore <PHONE_1>',
487
+ ].join('\n'),
488
+ }
426
489
  }
427
- const restored = await store.restore(sessionId, snippet)
428
- return { kind: 'success', text: `mask: restored\n${restored}` }
490
+ // 安全缺陷修复点:宿主把 result.text 原样写进持久会话日志(command/done),
491
+ // 客户端又从同一条事件渲染用户可见输出 ⇒ 结果文本既是转录也是日志。
492
+ // 因此明文绝不进结果文本,只进受控文件,结果里只回路径 + 占位符名。
493
+ const delivery = await deliverPlaintext({
494
+ dir: resolveRestoreDir(resolved.restoreDir),
495
+ sessionId,
496
+ text: restored,
497
+ })
498
+ return { kind: 'success', text: renderRestore({ placeholders, path: delivery.path }) }
429
499
  }
430
500
  return { kind: 'success', text: HELP_TEXT }
431
501
  } catch (error) {
432
- const message = `mask: ${actionKey} failed: ${messageOf(error)}`
502
+ // 失败关闭:交付失败也绝不回退到「把明文放进结果文本」。错误消息同样过
503
+ // redactText(ARCHITECTURE「Sanitize before display/log」),因为它同样会进日志。
504
+ const message = redactText(`mask: ${actionKey} failed: ${messageOf(error)}`)
433
505
  logger.error(message)
434
506
  return { kind: 'error', text: message }
435
507
  }
package/lib/constants.mjs CHANGED
@@ -80,6 +80,8 @@ export const DEFAULTS = Object.freeze({
80
80
  MAX_RESTORE_ENTRIES_PER_SESSION: 500,
81
81
  MAX_SESSIONS: 1000,
82
82
  MASK_CLIENT_ENABLED: false,
83
+ // 还原结果交付目录;空串 = os.tmpdir()/dsh-mask-restore(见 lib/deliver.mjs)。
84
+ RESTORE_DIR: '',
83
85
  })
84
86
 
85
87
  // 配置字段合法性边界(加载期校验,越界响亮失败)。
@@ -0,0 +1,111 @@
1
+ // lib/deliver.mjs — 还原结果的受控明文交付(唯一的非日志用户可见通道,零 DSH 依赖)。
2
+ //
3
+ // 为什么需要这个模块:宿主把命令结果**原样**写进持久会话日志,并且用户可见的命令
4
+ // 输出正是从那条日志事件渲染出来的(两条通道同源,无法分离):
5
+ // - 落盘:dsh-commands `execute()` → `appendLifecycle(session, 'command/done', {text: result.text})`
6
+ // (`types.ts` 的 `command/done` 声明明说 text 是处理器结果的 verbatim 文本)。
7
+ // - 渲染:client `ui-chat` 的 command 节点由 `command/done` 事件构造,`GenericCommandCard`
8
+ // 直接渲染 `node.outcome.text`(即同一条事件的 text)。
9
+ // 所以:命令结果里放什么,就等于往会话日志里放什么,也就等于往用户的转录里放什么;
10
+ // 宿主没有任何「记日志但不渲染」或「渲染但不记日志」的开关(`recordInput` 只管输入侧)。
11
+ // 结论:还原出的明文**绝不可**放进命令结果,只能走这条受控文件通道,把路径回给用户。
12
+ //
13
+ // 落点与收敛:每个会话固定一个文件(文件名 = 会话 id 的 sha256 前 16 位十六进制,
14
+ // 不含会话 id 本身、更不含原文),下一次还原覆盖同一个文件 ⇒ 磁盘上的明文副本数量
15
+ // 有界(每会话至多一份),不会随还原次数累积。
16
+ //
17
+ // 权限与失败关闭:目录 0700、文件 0600(POSIX;Windows 上 chmod 只影响只读位,无害)。
18
+ // 目录与目标文件都先 lstat 并拒绝符号链接,避免把 PII 写进他人预置的软链指向处;
19
+ // 目录属主不是当前用户时拒绝写入。任何一步失败都抛错,由调用方转成不泄露原文的错误
20
+ // 结果——绝不回退到「把明文放进命令结果」。
21
+
22
+ import { createHash } from 'node:crypto'
23
+ import { chmod, lstat, mkdir, writeFile } from 'node:fs/promises'
24
+ import os from 'node:os'
25
+ import path from 'node:path'
26
+
27
+ /** 默认交付目录名(`restoreDir` 配空时的落点,位于系统临时目录下)。 */
28
+ export const RESTORE_DIR_NAME = 'dsh-mask-restore'
29
+
30
+ /** 交付文件名前缀(真正写入前先 lstat 拒绝符号链接)。 */
31
+ export const RESTORE_FILE_PREFIX = 'restore-'
32
+
33
+ /** 0644 会让同机其它用户读到 PII;目录与文件都取最小可读面。 */
34
+ const DIR_MODE = 0o700
35
+ const FILE_MODE = 0o600
36
+
37
+ /**
38
+ * 解析交付目录:配置为空串(默认)时落在 `os.tmpdir()/dsh-mask-restore`,
39
+ * 否则按配置解析为绝对路径(相对路径相对宿主进程 cwd)。
40
+ * 纯函数(除 `os.tmpdir()`/`path.resolve` 的宿主事实外无副作用),便于测试。
41
+ * @param {unknown} configured - `restoreDir` 配置值。
42
+ * @returns {string} 绝对目录路径。
43
+ */
44
+ export function resolveRestoreDir(configured) {
45
+ const raw = typeof configured === 'string' ? configured.trim() : ''
46
+ return raw === '' ? path.join(os.tmpdir(), RESTORE_DIR_NAME) : path.resolve(raw)
47
+ }
48
+
49
+ /**
50
+ * 会话的交付文件路径:`<dir>/restore-<sha256(sessionId)[0:16]>.txt`。
51
+ * 纯函数;同一会话恒定同一个路径(覆盖语义),不同会话互不覆盖。
52
+ * @param {string} dir - 交付目录(`resolveRestoreDir` 的结果)。
53
+ * @param {unknown} sessionId - 会话 id。
54
+ * @returns {string} 交付文件绝对路径。
55
+ */
56
+ export function restoreFilePath(dir, sessionId) {
57
+ const digest = createHash('sha256').update(String(sessionId ?? '')).digest('hex').slice(0, 16)
58
+ return path.join(dir, `${RESTORE_FILE_PREFIX}${digest}.txt`)
59
+ }
60
+
61
+ /**
62
+ * 目标路径必须不是符号链接:否则写入会跟随软链落到他人指定的位置。
63
+ * @param {string} target - 待检查路径。
64
+ * @param {string} what - 错误消息里的对象名。
65
+ * @returns {Promise<import('node:fs').Stats|undefined>} 存在时的 lstat 结果。
66
+ */
67
+ async function assertNotSymlink(target, what) {
68
+ try {
69
+ const stats = await lstat(target)
70
+ if (stats.isSymbolicLink()) {
71
+ throw new Error(`${what} is a symbolic link: refusing to write plaintext through it`)
72
+ }
73
+ return stats
74
+ } catch (error) {
75
+ if (/** @type {NodeJS.ErrnoException} */ (error).code === 'ENOENT') return undefined
76
+ throw error
77
+ }
78
+ }
79
+
80
+ /**
81
+ * 把还原出的明文写进受控文件(覆盖本会话上一份)。
82
+ * 绝不返回、也绝不记录明文本身——只返回落点与字节数供结果文本使用。
83
+ * @param {object} options - {dir, sessionId, text}。
84
+ * @param {string} options.dir - 交付目录。
85
+ * @param {unknown} options.sessionId - 会话 id。
86
+ * @param {string} options.text - 还原后的明文(只写入文件,不进任何日志/结果)。
87
+ * @returns {Promise<{path: string, bytes: number}>} 落点与 UTF-8 字节数。
88
+ */
89
+ export async function deliverPlaintext({ dir, sessionId, text }) {
90
+ const target = restoreFilePath(dir, sessionId)
91
+ // Check the existing entry before mkdir: a dangling symlink makes mkdir throw
92
+ // ENOENT, which would mask the real refusal reason and fail the wrong way.
93
+ await assertNotSymlink(dir, 'restoreDir')
94
+ await mkdir(dir, { recursive: true, mode: DIR_MODE })
95
+ const dirStats = await assertNotSymlink(dir, 'restoreDir')
96
+ if (dirStats === undefined || !dirStats.isDirectory()) {
97
+ throw new Error('restoreDir is not a directory')
98
+ }
99
+ const uid = typeof process.getuid === 'function' ? process.getuid() : undefined
100
+ if (uid !== undefined && dirStats.uid !== uid) {
101
+ throw new Error('restoreDir is owned by another user: refusing to write plaintext there')
102
+ }
103
+ // 目录可能早已存在(预置或上次运行),mkdir 的 mode 不会收紧既有权限。
104
+ await chmod(dir, DIR_MODE)
105
+ await assertNotSymlink(target, 'restore file')
106
+ const body = typeof text === 'string' ? text : String(text)
107
+ await writeFile(target, body, { encoding: 'utf8', mode: FILE_MODE, flag: 'w' })
108
+ // 覆盖写不会改既有文件的 mode,显式收紧一次。
109
+ await chmod(target, FILE_MODE)
110
+ return { path: target, bytes: Buffer.byteLength(body, 'utf8') }
111
+ }
package/lib/store.mjs CHANGED
@@ -68,12 +68,36 @@ export class RestoreStore {
68
68
  * @returns {Promise<string>} 还原后的文本。
69
69
  */
70
70
  async restore(sessionId, text) {
71
+ const stripper = await this._stripperForRestore(sessionId)
72
+ if (stripper === undefined) return text
73
+ return stripper.restore(text)
74
+ }
75
+
76
+ /**
77
+ * 还原并报告本次涉及的占位符(供命令结果只写占位符、不写明文)。
78
+ * 与 {@link restore} 同源同语义:命中集合与替换用的映射完全一致。
79
+ * @param {string} sessionId - 会话 id。
80
+ * @param {string} text - 含占位符文本。
81
+ * @returns {Promise<{text: string, placeholders: string[]}>} 还原文本 + 命中的占位符(长度降序)。
82
+ */
83
+ async restoreDetailed(sessionId, text) {
84
+ const stripper = await this._stripperForRestore(sessionId)
85
+ if (stripper === undefined) return { text, placeholders: [] }
86
+ return { text: stripper.restore(text), placeholders: stripper.placeholdersIn(text) }
87
+ }
88
+
89
+ /**
90
+ * 取会话脱敏器,内存未命中且 persist 开启时从领域回载(restore 与
91
+ * restoreDetailed 的唯一差异只是返回值,故共用这一段)。
92
+ * @param {string} sessionId - 会话 id。
93
+ * @returns {Promise<import('./strip.mjs').Stripper|undefined>} 脱敏器或 undefined。
94
+ */
95
+ async _stripperForRestore(sessionId) {
71
96
  let stripper = this.strippers.get(sessionId)
72
97
  if (stripper === undefined && this.persistEnabled && this.domainPromise !== null) {
73
98
  stripper = await this._load(sessionId)
74
99
  }
75
- if (stripper === undefined) return text
76
- return stripper.restore(text)
100
+ return stripper
77
101
  }
78
102
 
79
103
  /**
package/lib/strip.mjs CHANGED
@@ -132,6 +132,20 @@ export class Stripper {
132
132
  return result
133
133
  }
134
134
 
135
+ /**
136
+ * 文本中出现的、本会话已知的占位符(按 `restore()` 的替换顺序:长度降序)。
137
+ * 只读、不改文本、绝不返回原文——用于把「这次还原涉及哪些占位符」安全地
138
+ * 写进用户可见结果(占位符本身已按设计存在于模型可见的日志里)。
139
+ * @param {unknown} text - 含占位符的文本。
140
+ * @returns {string[]} 命中的占位符(去重,长度降序)。
141
+ */
142
+ placeholdersIn(text) {
143
+ if (typeof text !== 'string' || text.length === 0) return []
144
+ return [...this.placeholderMap.keys()]
145
+ .sort((a, b) => b.length - a.length)
146
+ .filter(placeholder => text.includes(placeholder))
147
+ }
148
+
135
149
  /** @returns {Record<string, string>} {占位符: 原文} 只读副本。 */
136
150
  mapping() {
137
151
  return Object.fromEntries(this.placeholderMap)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-mask",
3
3
  "description": "PII masking middleware for DeepSeek Harness: regex-detect and replace phones, emails, ID cards, bank cards, keys, and (opt-in) IPs with placeholders before they reach the model, keep the restore table host-side (memory plus a controlled storage domain, never the session log) with the /mask restore command and the exported RestoreStore seam, and expose /mask status and the mask_test tool. Name and address recognition needs an external NER recognizer, which this pure-host form does not bundle: mode \"regex+ner\" and the person/address entities fail loudly at load. The phone and ID-card detectors match mainland-China formats only.",
4
- "version": "0.2.19",
4
+ "version": "0.2.22",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/PerryLink/dsh-mask.git"
@@ -63,6 +63,7 @@
63
63
  },
64
64
  "permissions": [
65
65
  "filesystem:read",
66
+ "filesystem:write",
66
67
  "storage-domain:read",
67
68
  "storage-domain:write",
68
69
  "session-log:read",
@@ -70,14 +71,21 @@
70
71
  "network:none"
71
72
  ],
72
73
  "compatibility": {
73
- "dshVersions": ["0.1.2-rc.1","0.1.5-rc.2","0.1.7-alpha.2","0.1.7-rc.1", "0.1.7-rc.2",
74
- "0.2.1-alpha.1"]
74
+ "dshVersions": [
75
+ "0.1.2-rc.1",
76
+ "0.1.5-rc.2",
77
+ "0.1.7-alpha.2",
78
+ "0.1.7-rc.1",
79
+ "0.1.7-rc.2",
80
+ "0.2.1-alpha.1",
81
+ "0.2.1-rc.2"
82
+ ]
75
83
  },
76
84
  "capability": {
77
85
  "id": "mask",
78
86
  "kind": "command",
79
87
  "invocation": "/mask status",
80
- "expected": "the /mask command is registered on the commands service: status reports masked counts and type distribution, on/off toggles masking at runtime, restore <text> unmaps placeholders back to the values stored for this session; mask_test tool masks a snippet and reports the placeholder result"
88
+ "expected": "the /mask command is registered on the commands service: status reports masked counts and type distribution, on/off toggles masking at runtime, restore <text> unmaps placeholders back to the values stored for this session and delivers the plaintext as a controlled file whose path (never the plaintext) is what the command result and the session log carry; mask_test tool masks a snippet and reports the placeholder result"
81
89
  },
82
90
  "evidence": {
83
91
  "install": null,
@@ -100,22 +108,23 @@
100
108
  "zod": "^4.4.3"
101
109
  },
102
110
  "devDependencies": {
103
- "@deepseek-ai/dsh-attachment": "0.2.1-alpha.1",
111
+ "@deepseek-ai/dsh-attachment": "0.2.1-rc.2",
104
112
  "@deepseek-ai/cordis": "^4.0.5-alpha.1",
105
113
  "@deepseek-ai/cordis-plugin-include": "^1.0.10-alpha.1",
106
114
  "@deepseek-ai/cordis-plugin-loader": "^1.0.6-alpha.1",
107
- "@deepseek-ai/dsh-agent": "0.2.1-alpha.1",
108
- "@deepseek-ai/dsh-commands": "0.2.1-alpha.1",
109
- "@deepseek-ai/dsh-session": "0.2.1-alpha.1",
110
- "@deepseek-ai/dsh-storage": "0.2.1-alpha.1",
111
- "@deepseek-ai/dsh-storage-domain": "0.2.1-alpha.1",
112
- "@deepseek-ai/dsh-storage-json": "0.2.1-alpha.1",
113
- "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.1",
114
- "@deepseek-ai/dsh-tools": "0.2.1-alpha.1",
115
+ "@deepseek-ai/dsh-agent": "0.2.1-rc.2",
116
+ "@deepseek-ai/dsh-commands": "0.2.1-rc.2",
117
+ "@deepseek-ai/dsh-session": "0.2.1-rc.2",
118
+ "@deepseek-ai/dsh-storage": "0.2.1-rc.2",
119
+ "@deepseek-ai/dsh-storage-domain": "0.2.1-rc.2",
120
+ "@deepseek-ai/dsh-storage-json": "0.2.1-rc.2",
121
+ "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2",
122
+ "@deepseek-ai/dsh-tools": "0.2.1-rc.2",
115
123
  "@deepseek-ai/schemastery": "^3.18.5-alpha.1",
116
124
  "@types/node": "^22.19.0",
117
125
  "oxlint": "0.18.1",
118
- "typescript": "^5.9.0"
126
+ "typescript": "^5.9.0",
127
+ "@deepseek-ai/dsh-working-directory": "0.2.1-rc.2"
119
128
  },
120
129
  "scripts": {
121
130
  "typecheck": "tsc -p tsconfig.check.json",
package/types.d.ts CHANGED
@@ -42,6 +42,13 @@ export interface Config {
42
42
  maxSessions?: number
43
43
  /** 浏览器半自动还原气泡开关(防御性 client slot;默认 false,未启用前对 UI 无副作用)。 */
44
44
  maskClientEnabled?: boolean
45
+ /**
46
+ * `/mask restore` 明文交付目录(默认空串 = `os.tmpdir()/dsh-mask-restore`)。
47
+ * 宿主把命令结果原样写进会话日志、客户端又从同一条事件渲染用户可见输出,
48
+ * `restore` 的明文因此绝不放进结果文本,只写进该目录下的受控文件
49
+ * (每会话一个,mode 0600,下次还原覆盖),结果文本只回路径与占位符名。
50
+ */
51
+ restoreDir?: string
45
52
  }
46
53
 
47
54
  /** mask_test 工具规范结果。 */