@restregular/dsh-memory 0.31.0 → 0.33.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/lib/panel.js CHANGED
@@ -45,6 +45,8 @@ const CLIENT_ERROR_CODES = new Set([
45
45
  'QUERY_EMPTY', 'QUERY_INVALID', 'SESSION_REQUIRED', 'SCOPE_EMPTY', 'SCOPE_NOT_VISIBLE',
46
46
  // 0.29.0:作用域用途 / 别名的编辑错误(名字非法 / 重名 / 不支持 / 用途过长)
47
47
  'SCOPE_NAME_INVALID', 'SCOPE_NAME_TAKEN', 'SCOPE_NAME_UNSUPPORTED', 'SCOPE_DESCRIPTION_TOO_LONG',
48
+ // 0.32.0:归档 / 屏蔽(归档不可写、屏蔽后不可写;解除是显式操作)
49
+ 'SCOPE_ARCHIVED', 'SCOPE_NOT_ARCHIVABLE', 'SCOPE_BLOCKED',
48
50
  ])
49
51
 
50
52
  function writeError(res, error) {
@@ -924,6 +926,13 @@ async function handle(ctx, routePath, req, res) {
924
926
  ? { description: entry.description.trim(), descriptionSource: 'default' }
925
927
  : {}),
926
928
  ...(entry !== undefined && typeof entry.origin === 'string' ? { origin: entry.origin } : {}),
929
+ // 0.33.0:归档照实传(面板默认折叠,但仍可展开并解除)。
930
+ //
931
+ // 屏蔽**不传**:主面板没有 agent,`scopeCatalog(undefined)` 只反映兜底项目键
932
+ // 那一层,会话级屏蔽在这里根本看不见,传上去只会是一份"半真"的状态。
933
+ // 屏蔽的展示与解除都在会话面板的「记录」页(/session-records 带真实会话 id)。
934
+ ...(entry !== undefined && entry.archived === true ? { archived: true } : {}),
935
+ ...(entry !== undefined && typeof entry.archivedKind === 'string' ? { archivedKind: entry.archivedKind } : {}),
927
936
  }
928
937
  })
929
938
  // 删光记录不等于作用域消失:目录里有用途、却没有记录的作用域也列出来。
@@ -948,6 +957,7 @@ async function handle(ctx, routePath, req, res) {
948
957
  descriptionSource: customDescriptionOf(key) !== '' ? 'custom' : 'default',
949
958
  ...(typeof entry.origin === 'string' ? { origin: entry.origin } : {}),
950
959
  ...(entry.archived === true ? { archived: true } : {}),
960
+ ...(typeof entry.archivedKind === 'string' ? { archivedKind: entry.archivedKind } : {}),
951
961
  })
952
962
  }
953
963
  let embedServer = null
@@ -958,8 +968,241 @@ async function handle(ctx, routePath, req, res) {
958
968
  writeJson(res, { ok: true, value: { scopes, embedServer, rules } })
959
969
  return
960
970
  }
971
+ // 归档 / 屏蔽的列表与解除(0.32.0)。面板「记录」页默认把这两类折叠起来,
972
+ // 但用户要能看见并手动恢复:归档是生命周期事实(会话 / 项目),屏蔽是 Agent
973
+ // 主动降噪。两者都不是删除 —— 解除即刻复原,不碰任何记忆正文。
974
+ if (method === 'GET' && path === '/archive') {
975
+ const archived = typeof memory.archivedProjectScopes === 'function'
976
+ ? memory.archivedProjectScopes()
977
+ : []
978
+ // 会话归档是宿主生命周期驱动的(archivedSessionScopes 是 provider 内部状态),
979
+ // 面板从目录里读:目录已带 archived + archivedKind,这就是唯一权威来源。
980
+ let sessionArchived = []
981
+ if (typeof memory.scopeCatalog === 'function') {
982
+ try {
983
+ sessionArchived = (memory.scopeCatalog(undefined) ?? [])
984
+ .filter((item) => item?.archived === true && item?.archivedKind === 'session')
985
+ .map((item) => item.scope)
986
+ } catch { sessionArchived = [] }
987
+ }
988
+ writeJson(res, {
989
+ ok: true,
990
+ value: {
991
+ project: archived.map((entry) => ({
992
+ scope: entry.scope,
993
+ label: scopeDisplayName(entry.scope),
994
+ archivedAt: entry.archivedAt,
995
+ createdBy: entry.createdBy,
996
+ ...(typeof entry.note === 'string' && entry.note !== '' ? { note: entry.note } : {}),
997
+ ...(entry.dormant === true ? { dormant: true } : {}),
998
+ })),
999
+ session: sessionArchived,
1000
+ },
1001
+ })
1002
+ return
1003
+ }
1004
+ if (method === 'POST' && path === '/archive') {
1005
+ const body = await readJsonBody(req)
1006
+ const scope = typeof body?.scope === 'string' ? body.scope.trim() : ''
1007
+ if (scope === '') throw new ApiError(400, 'SCOPE_INVALID', 'scope 不能为空')
1008
+ const restore = body?.restore === true
1009
+ if (restore) {
1010
+ if (typeof memory.restoreScope !== 'function') throw new ApiError(501, 'NOT_SUPPORTED', 'provider 未提供归档解除接口(请升级 @restregular/dsh-memory)')
1011
+ writeJson(res, { ok: true, value: { scope, restored: memory.restoreScope(scope) } })
1012
+ return
1013
+ }
1014
+ if (typeof memory.archiveScope !== 'function') throw new ApiError(501, 'NOT_SUPPORTED', 'provider 未提供归档接口(请升级 @restregular/dsh-memory)')
1015
+ const entry = memory.archiveScope(scope, 'user', typeof body?.note === 'string' ? body.note : undefined)
1016
+ writeJson(res, { ok: true, value: { scope, entry } })
1017
+ return
1018
+ }
1019
+ if (method === 'GET' && path === '/blocks') {
1020
+ if (typeof memory.listBlocks !== 'function') {
1021
+ throw new ApiError(501, 'NOT_SUPPORTED', 'provider 未提供屏蔽接口(请升级 @restregular/dsh-memory)')
1022
+ }
1023
+ // 面板不带 agent:会话级 / 工作区级分别按 session / workspace 参数查,
1024
+ // 这样用户能看见「哪一层把这条藏起来了」,而不是只能看见合并后的结果。
1025
+ const sessionId = (url.searchParams.get('session') ?? '').trim()
1026
+ const workspace = (url.searchParams.get('workspace') ?? '').trim()
1027
+ const value = {
1028
+ session: sessionId !== '' && typeof memory.sessionBlocks === 'function' ? memory.sessionBlocks(sessionId) : [],
1029
+ workspace: workspace !== '' && typeof memory.workspaceBlocks === 'function' ? memory.workspaceBlocks(workspace) : [],
1030
+ }
1031
+ writeJson(res, { ok: true, value })
1032
+ return
1033
+ }
1034
+ if (method === 'POST' && path === '/blocks') {
1035
+ const body = await readJsonBody(req)
1036
+ const level = body?.level === 'workspace' ? 'workspace' : 'session'
1037
+ const sessionId = typeof body?.session === 'string' ? body.session.trim() : ''
1038
+ const workspace = typeof body?.workspace === 'string' ? body.workspace.trim() : ''
1039
+ const target = level === 'session' ? sessionId : workspace
1040
+ if (target === '') {
1041
+ throw new ApiError(400, 'SESSION_REQUIRED', level === 'session' ? 'session 不能为空' : 'workspace 不能为空')
1042
+ }
1043
+ if (body?.restore === true) {
1044
+ if (typeof memory.unblock !== 'function') throw new ApiError(501, 'NOT_SUPPORTED', 'provider 未提供解除屏蔽接口(请升级 @restregular/dsh-memory)')
1045
+ // 面板解除时直接用存储层:按 id / scope 精确匹配,key 明确指定是哪一层。
1046
+ const match = {
1047
+ level,
1048
+ key: target,
1049
+ ...(typeof body?.id === 'string' && body.id !== '' ? { id: body.id } : {}),
1050
+ ...(typeof body?.scope === 'string' && body.scope !== '' ? { scope: body.scope } : {}),
1051
+ ...(typeof body?.recordId === 'string' && body.recordId !== '' ? { recordId: body.recordId } : {}),
1052
+ }
1053
+ const removed = memory.unblock(undefined, match)
1054
+ writeJson(res, { ok: true, value: { removed } })
1055
+ return
1056
+ }
1057
+ if (typeof memory.requestBlock !== 'function') throw new ApiError(501, 'NOT_SUPPORTED', 'provider 未提供屏蔽接口(请升级 @restregular/dsh-memory)')
1058
+ // 面板是用户本人操作:审批在 UI 里已经点过一次,这里带一个已允许的审批答复。
1059
+ const original = memory.requestOutOfScope
1060
+ memory.requestOutOfScope = async () => ({ outcome: 'allowed-once' })
1061
+ // workspace 参数是**作用域键**(project:<路径>);provider 从会话 cwd 反推项目键,
1062
+ // 所以这里必须脱掉 project: 前缀,否则会拼成 project:<cwd>/project:<路径>。
1063
+ const workspacePath = workspace.startsWith('project:') ? workspace.slice('project:'.length) : workspace
1064
+ let result
1065
+ try {
1066
+ result = await memory.requestBlock(
1067
+ level === 'session'
1068
+ ? { session: { header: { id: sessionId } } }
1069
+ : { session: { header: { id: sessionId, cwd: workspacePath } } },
1070
+ {
1071
+ ...(typeof body?.scope === 'string' && body.scope !== '' ? { scope: body.scope } : {}),
1072
+ ...(typeof body?.id === 'string' && body.id !== '' ? { id: body.id } : {}),
1073
+ level,
1074
+ tool: 'panel',
1075
+ description: typeof body?.reason === 'string' ? body.reason : undefined,
1076
+ },
1077
+ )
1078
+ } finally {
1079
+ memory.requestOutOfScope = original
1080
+ }
1081
+ writeJson(res, { ok: true, value: result })
1082
+ return
1083
+ }
1084
+ // 会话面板的「记录」页(0.33.0):只列**这个会话权限范围内**的记忆。
1085
+ //
1086
+ // 与主面板的 /records 的关键区别是这里带着真实会话 id:能按 agent 口径解析
1087
+ // 默认读取范围(会话 + 项目 + global + 工作区绑定),也拿得到该会话**生效**的
1088
+ // 屏蔽(会话链含父会话 + 工作区级)。主面板没有 agent,按层级折叠屏蔽是做不
1089
+ // 准的(会话级屏蔽根本不会出现在它的视角里),所以屏蔽感知只放在这里。
1090
+ if (method === 'GET' && path === '/session-records') {
1091
+ const sessionId = (url.searchParams.get('session') ?? '').trim()
1092
+ if (sessionId === '') throw new ApiError(400, 'SESSION_REQUIRED', 'session 参数不能为空')
1093
+ const includeBlocked = url.searchParams.get('blocked') === '1'
1094
+ const query = url.searchParams.get('q') ?? ''
1095
+ // 宿主里能查到会话对象就用它(cwd / parentSession 都在上面),查不到退化成
1096
+ // 只有 id 的最小形状 —— resolveReadScopes 会按 id 解析出 session: 作用域。
1097
+ let session
1098
+ try { session = ctx.get('sessions')?.get?.(sessionId) } catch { session = undefined }
1099
+ const agentLike = { session: session !== undefined ? session : { id: sessionId } }
1100
+ // 这个会话实际能读的作用域集合 = 它的权限范围。显式「记忆范围」优先,否则是
1101
+ // 默认三路 + 工作区绑定。
1102
+ let scopes = []
1103
+ try {
1104
+ const resolved = typeof memory.resolveReadScopes === 'function' ? memory.resolveReadScopes(agentLike) : []
1105
+ if (Array.isArray(resolved)) scopes = resolved.filter((scope) => typeof scope === 'string' && scope !== '')
1106
+ } catch { scopes = [] }
1107
+ const catalog = new Map()
1108
+ try {
1109
+ if (typeof memory.scopeCatalog === 'function') {
1110
+ for (const entry of memory.scopeCatalog(agentLike) ?? []) {
1111
+ if (entry && typeof entry.scope === 'string') catalog.set(entry.scope, entry)
1112
+ }
1113
+ }
1114
+ } catch { /* 目录是增强:拿不到就只有名称与条数 */ }
1115
+ // 归档的作用域不再参与检索与注入,这里也不列:会话作用域随会话归档、项目
1116
+ // 作用域随工作区移除,都属于「生命周期已经结束」。
1117
+ const archived = new Set()
1118
+ for (const [key, entry] of catalog) if (entry.archived === true) archived.add(key)
1119
+ const liveScopes = scopes.filter((scope) => !archived.has(scope))
1120
+ // 该会话生效的屏蔽:工作区级更「重」,同一目标以工作区级为准;记录级按 id / 前缀。
1121
+ // 每条都留着屏蔽自己的 id —— 解除时按 id 精确删那一条,不会顺手带走别的。
1122
+ const blockedScopes = new Map()
1123
+ const blockedRecords = new Map()
1124
+ const blockedPrefixes = []
1125
+ try {
1126
+ const blocks = typeof memory.listBlocks === 'function' ? memory.listBlocks(agentLike) : []
1127
+ for (const block of Array.isArray(blocks) ? blocks : []) {
1128
+ if (!block) continue
1129
+ const level = block.level === 'workspace' ? 'workspace' : 'session'
1130
+ const hit = { id: typeof block.id === 'string' ? block.id : undefined, level }
1131
+ if (typeof block.scope === 'string' && block.scope !== '') {
1132
+ if (level === 'workspace' || !blockedScopes.has(block.scope)) blockedScopes.set(block.scope, hit)
1133
+ } else if (typeof block.recordId === 'string' && block.recordId !== '') {
1134
+ blockedRecords.set(block.recordId, hit)
1135
+ } else if (typeof block.prefix === 'string' && block.prefix !== '') {
1136
+ blockedPrefixes.push({ prefix: block.prefix, ...hit })
1137
+ }
1138
+ }
1139
+ } catch { /* 屏蔽是增强:拿不到就当作没有屏蔽 */ }
1140
+ const blockOf = (record) => {
1141
+ const scopeHit = blockedScopes.get(record.scope)
1142
+ if (scopeHit !== undefined) return scopeHit
1143
+ const recordHit = blockedRecords.get(record.id)
1144
+ if (recordHit !== undefined) return recordHit
1145
+ for (const { prefix, ...hit } of blockedPrefixes) {
1146
+ if (record.id.startsWith(prefix)) return hit
1147
+ }
1148
+ return undefined
1149
+ }
1150
+ const rows = []
1151
+ let records = []
1152
+ let blockedCount = 0
1153
+ for (const scope of liveScopes) {
1154
+ const scopeStore = store.peek(scope) // 只读:不创建作用域文件
1155
+ const scopeHit = blockedScopes.get(scope)
1156
+ rows.push({
1157
+ scope,
1158
+ label: scopeLabel(ctx, scope),
1159
+ records: scopeStore !== undefined ? scopeStore.records.size : 0,
1160
+ ...(scopeHit !== undefined ? { blocked: true, blockedLevel: scopeHit.level } : {}),
1161
+ })
1162
+ if (scopeStore === undefined) continue
1163
+ for (const rec of collectScope(scopeStore)) {
1164
+ const hit = blockOf(rec)
1165
+ if (hit !== undefined) {
1166
+ blockedCount += 1
1167
+ if (!includeBlocked) continue
1168
+ records.push({
1169
+ ...rec,
1170
+ blocked: true,
1171
+ blockedLevel: hit.level,
1172
+ ...(hit.id !== undefined ? { blockedId: hit.id } : {}),
1173
+ })
1174
+ continue
1175
+ }
1176
+ records.push(rec)
1177
+ }
1178
+ }
1179
+ if (query !== '') {
1180
+ const needle = query.trim().toLowerCase()
1181
+ records = records.filter((r) =>
1182
+ r.content.toLowerCase().includes(needle)
1183
+ || r.kind.toLowerCase().includes(needle)
1184
+ || r.tags.some((tag) => tag.toLowerCase().includes(needle)))
1185
+ }
1186
+ records.sort((a, b) => b.updatedAt - a.updatedAt)
1187
+ let workspace = null
1188
+ try {
1189
+ if (typeof memory.projectKeyFor === 'function') workspace = memory.projectKeyFor(agentLike)
1190
+ } catch { workspace = null }
1191
+ writeJson(res, {
1192
+ ok: true,
1193
+ value: {
1194
+ session: sessionId,
1195
+ workspace,
1196
+ scopes: rows,
1197
+ records,
1198
+ // 折叠开关要显示「有几个被藏起来了」,所以计数必须包含被折叠的那些。
1199
+ blockedCount,
1200
+ },
1201
+ })
1202
+ return
1203
+ }
961
1204
  if (method === 'POST' && path === '/scope-meta') {
962
- // 用户编辑作用域的描述 / 别名(0.29.0)。面板是用户本人的操作,不带会话可见域;
1205
+ // 用户编辑作用域的描述 / 别名(0.29.0)。面板是用户本人的操作,不带会话可见域;
963
1206
  // 但只允许改**目录里看得见**的作用域,免得手滑把用途写到一条永远读不到的元数据上。
964
1207
  if (typeof memory.describeScope !== 'function' && typeof memory.renameScope !== 'function') {
965
1208
  throw new ApiError(501, 'NOT_SUPPORTED', 'provider 未提供作用域编辑接口(请升级 @restregular/dsh-memory)')
@@ -1131,11 +1374,39 @@ async function handle(ctx, routePath, req, res) {
1131
1374
  const rawScope = url.searchParams.get('scope')
1132
1375
  const query = (url.searchParams.get('q') ?? '').trim().toLowerCase()
1133
1376
  const idQuery = (url.searchParams.get('id') ?? '').trim()
1377
+ // 归档默认**不出现在列表里**(0.32.0)。这不是权限:用户点开开关就能看到,
1378
+ // 只是日常浏览不该被"已经归档的旧会话"填满。
1379
+ //
1380
+ // 屏蔽**不再折叠**(0.33.0):屏蔽按会话 / 工作区生效,而主面板没有 agent
1381
+ // (`scopeCatalog(undefined)` 只能拿到兜底项目键那一层),在这里按屏蔽折叠
1382
+ // 既漏会话级屏蔽、又会把用户本想看的记录藏起来。屏蔽感知挪到了会话面板的
1383
+ // 「记录」页(/session-records,带着真实会话 id)。
1384
+ const includeArchived = url.searchParams.get('archived') === '1'
1134
1385
  // scope 先过同一套规范化:非法 → 400(而不是当成一个陌生 scope 去建文件);
1135
1386
  // 合法但不存在的 scope → 空列表。`peek`/`peekScope`,**绝不通过 store.scope() 创建**。
1136
1387
  const stores = selectedStores(store, resolveScopeSelection(memory, rawScope))
1388
+ // 目录一次拿全:归档状态与展示名同源,避免两次查询之间状态漂移。
1389
+ const catalog = new Map()
1390
+ try {
1391
+ if (typeof memory.scopeCatalog === 'function') {
1392
+ for (const entry of memory.scopeCatalog(undefined) ?? []) {
1393
+ if (entry && typeof entry.scope === 'string') catalog.set(entry.scope, entry)
1394
+ }
1395
+ }
1396
+ } catch { /* 目录拿不到就不过滤:宁可多显示,也不能凭空吞掉记录 */ }
1397
+ const hiddenScopes = new Set()
1398
+ // 用户**显式选了一个作用域**时不折叠:那一刻他就是要看这一份,藏起来等于点不动。
1399
+ const explicitScope = typeof rawScope === 'string' && rawScope.trim() !== ''
1400
+ if (catalog.size > 0 && !explicitScope) {
1401
+ for (const [key, entry] of catalog) {
1402
+ if (!includeArchived && entry.archived === true) hiddenScopes.add(key)
1403
+ }
1404
+ }
1137
1405
  let records = []
1138
- for (const s of stores) records.push(...collectScope(s))
1406
+ for (const s of stores) {
1407
+ if (hiddenScopes.has(s.scope)) continue
1408
+ records.push(...collectScope(s))
1409
+ }
1139
1410
  if (query) {
1140
1411
  records = records.filter((r) =>
1141
1412
  r.content.toLowerCase().includes(query)
@@ -49,6 +49,38 @@ export class CordisMemoryService extends Service {
49
49
  }
50
50
  })
51
51
  this.attachSessionLifecycle(ctx)
52
+ // 0.32.0:项目作用域归档绑定工作区 —— 工作区从侧边栏删除时归档转 dormant
53
+ // (记忆仍保留、仍不参与检索),重新加入时自动解除归档。宿主没有可靠的
54
+ // workspace 删除事件(`workspace/delete` 是 UI 层 emit),所以按需对账:
55
+ // 装配期一次 + 每次目录/统计查询前一次(带节流,见 LocalMemoryService)。
56
+ this.impl.setWorkspaceExistsLookup((scope) => {
57
+ try {
58
+ const registry = ctx.get('workspaceRegistry')
59
+
60
+
61
+
62
+ if (registry === undefined) return undefined
63
+ const path = scope.startsWith('project:') ? scope.slice('project:'.length) : ''
64
+ if (path === '') return undefined
65
+ if (typeof registry.resolveByPath === 'function') {
66
+ return registry.resolveByPath(path) !== undefined
67
+ }
68
+ const list = registry.list?.()
69
+ if (!Array.isArray(list)) return undefined
70
+ const wanted = path.replace(/[\\/]+/g, '/').replace(/\/+$/, '').toLowerCase()
71
+ return list.some((item) => {
72
+ const itemPath = typeof item?.path === 'string' ? item.path : ''
73
+ return itemPath.replace(/[\\/]+/g, '/').replace(/\/+$/, '').toLowerCase() === wanted
74
+ })
75
+ } catch {
76
+ return undefined
77
+ }
78
+ })
79
+ try {
80
+ this.impl.reconcileArchivedScopesNow()
81
+ } catch {
82
+ // 对账失败不影响加载:归档状态保持原样,下次查询再试。
83
+ }
52
84
  // 0.11.1:同一个目录因为 `D:/x` 与 `D:\x` 写法不同而分叉成两个 scope 的历史数据,
53
85
  // 在装配期合并一次(每进程一次;失败只影响合并,不影响读写)。
54
86
  try {
@@ -275,6 +307,74 @@ export class CordisMemoryService extends Service {
275
307
  return this.impl.scopeCatalog(agent)
276
308
  }
277
309
 
310
+ /**
311
+ * 归档 / 屏蔽(0.32.0)。
312
+ *
313
+ * 面板通过 `ctx.get('memory')` 拿到的是**这个包装实例**,不是 LocalMemoryService。
314
+ * 0.32.0 的实现只加在 LocalMemoryService 上,包装层没转发,于是真实 profile 里
315
+ * `memory.listBlocks` / `memory.unblock` / `memory.archiveScope` 全是 undefined ——
316
+ * 面板的「解除归档 / 解除屏蔽」和 `/status` 的 blocked 字段于是静默失效,
317
+ * 而单测直接 new LocalMemoryService 所以完全看不见。这一组必须显式转发。
318
+ */
319
+ archiveScope(scope , by , note ) {
320
+ return this.impl.archiveScope(scope, by, note)
321
+ }
322
+
323
+ /** 解除项目作用域归档;返回是否真的解除了一条。 */
324
+ restoreScope(scope ) {
325
+ return this.impl.restoreScope(scope)
326
+ }
327
+
328
+ /** 已归档的项目作用域清单(面板 / 目录用)。 */
329
+ archivedProjectScopes() {
330
+ return this.impl.archivedProjectScopes()
331
+ }
332
+
333
+ /** 当前 agent 生效的**全部**屏蔽(会话链 + 工作区级)。 */
334
+ blocksFor(agent ) {
335
+ return this.impl.blocksFor(agent)
336
+ }
337
+
338
+ /** 面板 / 诊断:当前 agent 生效的屏蔽清单。 */
339
+ listBlocks(agent ) {
340
+ return this.impl.listBlocks(agent)
341
+ }
342
+
343
+ /** 面板:某会话自己的会话级屏蔽(不含父链、不含工作区级)。 */
344
+ sessionBlocks(sessionId ) {
345
+ return this.impl.sessionBlocks(sessionId)
346
+ }
347
+
348
+ /** 面板:某工作区的工作区级屏蔽。 */
349
+ workspaceBlocks(workspace ) {
350
+ return this.impl.workspaceBlocks(workspace)
351
+ }
352
+
353
+ /** 这个作用域当前是否被屏蔽(会话级或工作区级)。 */
354
+ isScopeBlocked(agent , scope ) {
355
+ return this.impl.isScopeBlocked(agent, scope)
356
+ }
357
+
358
+ /** 这条记录当前是否被屏蔽(作用域级屏蔽也算)。 */
359
+ isRecordBlocked(agent , record ) {
360
+ return this.impl.isRecordBlocked(agent, record)
361
+ }
362
+
363
+ /** 解除一条屏蔽(面板 / 工具共用)。 */
364
+ unblock(agent , match ) {
365
+ return this.impl.unblock(agent, match)
366
+ }
367
+
368
+ /** 清空某一层级的全部屏蔽。 */
369
+ clearBlocks(agent , level ) {
370
+ return this.impl.clearBlocks(agent, level)
371
+ }
372
+
373
+ /** Agent 请求屏蔽(0.32.0;审批矩阵在 provider 里)。 */
374
+ requestBlock(agent , input ) {
375
+ return this.impl.requestBlock(agent, input)
376
+ }
377
+
278
378
  /** 注入设置(面板「设置」标签页读它)。 */
279
379
  injectSettings() {
280
380
  return this.impl.injectSettings()
@@ -18,6 +18,14 @@ import { dirname, join } from 'node:path'
18
18
 
19
19
 
20
20
 
21
+ /**
22
+ * 审批卡类型(0.32.0 起三种):
23
+ * - `records` 记忆条目照常放行;
24
+ * - `grant` 作用域会话授权;
25
+ * - `block` 屏蔽(按作用域 / 工作区级 / 规则)。
26
+ */
27
+
28
+
21
29
 
22
30
 
23
31
 
@@ -26,7 +34,7 @@ import { dirname, join } from 'node:path'
26
34
 
27
35
 
28
36
 
29
-
37
+
30
38
             
31
39
 
32
40