@restregular/dsh-memory 0.18.0 → 0.19.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.
@@ -103,10 +103,12 @@ import { canonicalWorkspacePath } from '../provider/scope.js'
103
103
 
104
104
  /** provider 在注入侧能提供的那部分能力(多余的方法都用可选判断)。 */
105
105
 
106
-
106
+
107
107
 
108
108
 
109
109
 
110
+                    
111
+
110
112
 
111
113
 
112
114
  /** 轮末提醒的文案:短、祈使句,不占预算。 */
@@ -114,6 +116,39 @@ const NUDGE_TEXT =
114
116
  '上一轮若产生了可复用的结论(决策、踩坑、流程、口径),先 memory_save 记一条再继续;' +
115
117
  '没有就忽略这条提醒。'
116
118
 
119
+ /** 可见域配置的最小子集(避免注入半边依赖 provider 的实现类型)。 */
120
+
121
+
122
+
123
+
124
+
125
+ const VISIBILITY_LEVEL_TEXT = {
126
+ absolute: '绝对限制:可见域外的记忆一律查不到,即使工具内部命中也不会返回。',
127
+ normal: '普通限制:可见域外的记忆命中时会向用户发起一次审批;用户拒绝或超时则不返回。',
128
+ none: '无限制:可以读取所有作用域与类型(当前选择仅作为下次切换的偏好保留)。',
129
+ }
130
+
131
+ /**
132
+ * 可见域变更后的上下文通知(以 user 消息注入)。
133
+ * 只描述规则,不回显任何记忆正文 —— 它要告诉模型"边界变了",不是给它数据。
134
+ */
135
+ export function renderVisibilityNotice(config ) {
136
+ if (config === null) {
137
+ return '【记忆可见范围已恢复默认】本会话不再有显式可见域;memory_search / memory_get / memory_list 回到"会话 + 项目 + global"的默认读取集合。'
138
+ }
139
+ const scopes = config.scopes.length > 0
140
+ ? config.scopes.map((rule) => (rule.kinds !== undefined && rule.kinds.length > 0
141
+ ? `${rule.scope}(仅 ${rule.kinds.join(' / ')})`
142
+ : rule.scope)).join('、')
143
+ : '(无)'
144
+ return [
145
+ '【记忆可见域已更新】用户修改了本会话(及其子 Agent)的记忆可见范围。',
146
+ `可见域:${scopes}`,
147
+ `限制等级:${VISIBILITY_LEVEL_TEXT[config.level]}`,
148
+ '后续 memory_search / memory_get / memory_list 请按这个边界工作;需要范围外信息时,先向用户说明要查什么,不要绕过限制。',
149
+ ].join('\n')
150
+ }
151
+
117
152
  export const name = 'dsh-memory-inject'
118
153
 
119
154
  export function apply(ctx , config = {}) {
@@ -253,13 +288,32 @@ export function apply(ctx , config = {}) {
253
288
  const sameScopes = (a , b ) =>
254
289
  a.length === b.length && a.every((scope, index) => scope === b[index])
255
290
 
291
+ /** 可见域的类型白名单(scope → kinds);undefined = 不按类型过滤。 */
292
+ const visibilityKindsFor = (memory , agent ) => {
293
+ try {
294
+ const policy = memory.visibilityPolicy?.(agent)
295
+ if (policy === undefined || policy.level === 'none') return undefined
296
+ const out = {}
297
+ for (const rule of policy.scopes) {
298
+ if (rule.kinds !== undefined && rule.kinds.length > 0) out[rule.scope] = [...rule.kinds]
299
+ }
300
+ return Object.keys(out).length > 0 ? out : undefined
301
+ } catch {
302
+ return undefined
303
+ }
304
+ }
305
+
256
306
  const renderRulesFor = (
257
307
  memory ,
258
308
  scopes ,
259
309
  cfg ,
310
+ agent ,
260
311
  ) => {
261
312
  try {
262
- return { ok: true, render: renderRules(memory.listSync?.({ scopes: [...scopes], kind: 'rule', limit: 100 }) ?? [], cfg) }
313
+ return {
314
+ ok: true,
315
+ render: renderRules(memory.listSync?.({ scopes: [...scopes], kind: 'rule', limit: 100, ...(agent !== undefined ? { agent } : {}) }) ?? [], cfg),
316
+ }
263
317
  } catch {
264
318
  return { ok: false, errorCode: 'source_load_failed' }
265
319
  }
@@ -495,7 +549,7 @@ export function apply(ctx , config = {}) {
495
549
  }
496
550
 
497
551
  const injector = new MemoryInjector(
498
- async (query, signal, scopes) => {
552
+ async (query, signal, scopes, kinds) => {
499
553
  const memory = ctx.get('memory')
500
554
  if (!memory?.search) return []
501
555
  return memory.search({
@@ -503,6 +557,7 @@ export function apply(ctx , config = {}) {
503
557
  signal,
504
558
  topK: recallCfg().topK,
505
559
  ...(scopes !== undefined ? { scopes: [...scopes] } : {}),
560
+ ...(kinds !== undefined ? { kinds } : {}),
506
561
  })
507
562
  },
508
563
  recallCfg,
@@ -511,12 +566,13 @@ export function apply(ctx , config = {}) {
511
566
  )
512
567
 
513
568
  // 摘要:provider 没有 list(旧版/半边加载失败)时自动退化为"不发摘要"。
514
- const digester = new MemoryDigester(async (scopes) => {
569
+ const digester = new MemoryDigester(async (scopes, agent) => {
515
570
  const memory = ctx.get('memory')
516
571
  if (!memory?.list) return []
517
572
  return memory.list({
518
573
  ...(scopes !== undefined ? { scopes: [...scopes] } : {}),
519
574
  limit: 200,
575
+ ...(agent !== undefined ? { agent } : {}),
520
576
  })
521
577
  })
522
578
  // 持久化状态恢复后,把「摘要已做过」同步给摘要器,避免插件重载后重复注入。
@@ -700,7 +756,7 @@ export function apply(ctx , config = {}) {
700
756
  if (cached !== undefined && started !== undefined && cached.at >= started && sameScopes(cached.scopes, scopes)) {
701
757
  return cached.render.text
702
758
  }
703
- const rendered = renderRulesFor(memory, scopes, settingsOf().rules)
759
+ const rendered = renderRulesFor(memory, scopes, settingsOf().rules, context?.agent)
704
760
  if (!rendered.ok) return ''
705
761
  if (sessionId !== undefined) rulesCache.set(sessionId, { at: Date.now(), scopes, render: rendered.render })
706
762
  return rendered.render.text
@@ -717,7 +773,7 @@ export function apply(ctx , config = {}) {
717
773
  const sessionId = sessionIdOf(context?.agent)
718
774
  let records = []
719
775
  try {
720
- records = memory.listSync({ scopes: [...scopes], kind: 'procedure', limit: 200 })
776
+ records = memory.listSync({ scopes: [...scopes], kind: 'procedure', limit: 200, ...(context?.agent !== undefined ? { agent: context.agent } : {}) })
721
777
  } catch {
722
778
  return ''
723
779
  }
@@ -769,6 +825,11 @@ export function apply(ctx , config = {}) {
769
825
  attachSessionState(sessionId, workspaceOf(agent))
770
826
  if (sessionId !== undefined) rulesStepStart.set(sessionId, stepStartedAt)
771
827
  const scopes = readScopesFor(memory, agent)
828
+ // 可见域的类型白名单:召回/摘要/规则/流程索引都按它收窄,避免"只让看 global
829
+ // 的 rule"之后又从其它类型里召回正文。
830
+ const visibleKinds = visibilityKindsFor(memory, agent)
831
+ // 面板保存可见域后,下一次 pre-step 用一条 user 消息告知 Agent 边界已变。
832
+ const visibilityNotice = memory.takeVisibilityNotice?.(agent)
772
833
  if (sessionId !== undefined && scopes !== undefined) sessionScopes.set(sessionId, [...scopes])
773
834
  let autoScopes
774
835
  try { autoScopes = autoRecallScopes(memory.resolveReadScopes?.(agent) ) } catch { autoScopes = undefined }
@@ -822,6 +883,17 @@ export function apply(ctx , config = {}) {
822
883
  const messageChannels = new Set ()
823
884
  const stage = (entry ) => { staged.push(entry) }
824
885
 
886
+ // 可见域刚被用户改过:先告知边界,再走后续召回/摘要。只注入规则说明,不回显记忆。
887
+ if (visibilityNotice !== undefined) {
888
+ const noticeText = renderVisibilityNotice(visibilityNotice.config)
889
+ parts.push(noticeText)
890
+ messageChannels.add('policy')
891
+ stage(auditBase('policy', {
892
+ kind: 'evaluation', stage: 'rendered', outcome: 'success', reasonCode: 'visibility_changed',
893
+ delivery: { status: 'unknown', appended: null, textChars: noticeText.length, textHash: hashAuditText(noticeText) },
894
+ }))
895
+ }
896
+
825
897
  if (signal !== undefined && usableSignal === undefined) {
826
898
  recordAudit(auditBase('signal', {
827
899
  kind: 'signal', stage: 'signal_dropped', outcome: 'skipped',
@@ -909,7 +981,7 @@ export function apply(ctx , config = {}) {
909
981
  const rendered = renderDigest(records, settings.digest)
910
982
  digestStats = rendered?.stats
911
983
  return rendered
912
- })
984
+ }, agent)
913
985
  // 失败也记 done(与内存行为一致:摘要不逐轮重试);落盘后重载不再重复发。
914
986
  if (sessionId !== undefined && outcome.status !== 'skipped') injectionState.markDigestDone(sessionId)
915
987
  if (outcome.status === 'failed') {
@@ -971,7 +1043,7 @@ export function apply(ctx , config = {}) {
971
1043
  stage(auditBase('rules', { kind: 'evaluation', stage: 'skipped', outcome: 'skipped', reasonCode: 'system_prompt_unavailable' }))
972
1044
  } else {
973
1045
  const promptScopes = promptScopesFor(memory, agent)
974
- const rendered = renderRulesFor(memory, promptScopes, settings.rules)
1046
+ const rendered = renderRulesFor(memory, promptScopes, settings.rules, agent)
975
1047
  if (!rendered.ok) {
976
1048
  stage(auditBase('rules', {
977
1049
  kind: 'evaluation', stage: 'source_load', outcome: 'failed', reasonCode: rendered.errorCode,
@@ -1059,7 +1131,13 @@ export function apply(ctx , config = {}) {
1059
1131
  })
1060
1132
  }
1061
1133
  const recall = await injector.maybeInjectDetailed(
1062
- { messages: input.messages , signal: input.signal, ...(recallScopes !== undefined ? { scopes: recallScopes } : {}), ...(sessionId !== undefined ? { sessionId } : {}) },
1134
+ {
1135
+ messages: input.messages ,
1136
+ signal: input.signal,
1137
+ ...(recallScopes !== undefined ? { scopes: recallScopes } : {}),
1138
+ ...(visibleKinds !== undefined ? { kinds: visibleKinds } : {}),
1139
+ ...(sessionId !== undefined ? { sessionId } : {}),
1140
+ },
1063
1141
  { messages: decision.messages },
1064
1142
  {
1065
1143
  ...(sessionId !== undefined ? { sessionId } : {}),
@@ -40,6 +40,8 @@ export const defaultInjectConfig = {
40
40
               
41
41
 
42
42
 
43
+                              
44
+
43
45
                             
44
46
 
45
47
                            
@@ -140,6 +142,8 @@ export function resolveInjectScopes(
140
142
                                   
141
143
 
142
144
 
145
+                             
146
+
143
147
                              
144
148
 
145
149
 
@@ -323,13 +327,13 @@ export function recallText(text ) {
323
327
  * - 同一段文本 = 最后一道幂等。
324
328
  */
325
329
  export class MemoryInjector {
326
- search
330
+ search
327
331
  cfg
328
332
  renderOptions
329
333
  state
330
334
 
331
335
  constructor(
332
- search ,
336
+ search ,
333
337
  cfg ,
334
338
  renderOptions = {},
335
339
  state = new InjectionState(),
@@ -362,7 +366,7 @@ export class MemoryInjector {
362
366
 
363
367
  let hits
364
368
  try {
365
- hits = await this.search(query, input.signal, input.scopes)
369
+ hits = await this.search(query, input.signal, input.scopes, input.kinds)
366
370
  } catch {
367
371
  // 检索失败不能打断 agent 循环;审计会区分"失败"与"成功但无结果"。
368
372
  return {
@@ -460,10 +464,10 @@ const MAX_DIGESTED_SESSIONS = 500
460
464
  */
461
465
  export class MemoryDigester {
462
466
  done = new Set ()
463
- list
467
+ list
464
468
 
465
469
  constructor(
466
- list ,
470
+ list ,
467
471
  ) {
468
472
  this.list = list
469
473
  }
@@ -505,6 +509,7 @@ export class MemoryDigester {
505
509
  sessionId ,
506
510
  scopes ,
507
511
  render ,
512
+ agent ,
508
513
  )
509
514
 
510
515
 
@@ -515,7 +520,7 @@ export class MemoryDigester {
515
520
  this.markDone(sessionId)
516
521
  let records
517
522
  try {
518
- records = await this.list(scopes)
523
+ records = await this.list(scopes, agent)
519
524
  } catch {
520
525
  return { status: 'failed', errorCode: 'source_load_failed' }
521
526
  }
package/lib/panel.js CHANGED
@@ -470,11 +470,15 @@ function resolveScopeSelection(memory, rawScope) {
470
470
  return normalized.scope ?? null
471
471
  }
472
472
 
473
+ /** 面板已知的记忆类型(与工具的 kind enum 一致)。 */
474
+ const KNOWN_KINDS = ['fact', 'decision', 'preference', 'procedure', 'note', 'rule', 'state']
475
+
473
476
  /**
474
- * 会话「记忆可见范围」的完整快照:自己的覆盖 + 实际生效集合 + 可选范围目录。
477
+ * 会话「记忆可见域」的完整快照:自己的覆盖 + 生效策略 + 可选范围目录(含每个 scope
478
+ * 的类型统计)。
475
479
  *
476
480
  * 自己的覆盖(null = 没设置)用于面板上的"恢复默认";effective 用于预选(子 Agent
477
- * 会话会继承父会话的覆盖);scopes 是本次会话可以勾选的全部具体作用域键。
481
+ * 会话会继承父会话的覆盖);scopes 是本次会话可以勾选的全部具体作用域键 + 类型。
478
482
  */
479
483
  function visibilityPayload(ctx, memory, sessionId) {
480
484
  let session
@@ -484,45 +488,60 @@ function visibilityPayload(ctx, memory, sessionId) {
484
488
  let effective = null
485
489
  let inherited = false
486
490
  try {
487
- if (typeof memory.visibleScopes === 'function') {
488
- const resolved = memory.visibleScopes(agentLike)
489
- if (Array.isArray(resolved)) {
490
- effective = resolved
491
+ if (typeof memory.visibilityPolicy === 'function') {
492
+ const policy = memory.visibilityPolicy(agentLike)
493
+ if (policy !== undefined && policy !== null) {
494
+ effective = policy
491
495
  inherited = own === null
492
496
  }
493
497
  }
494
- if (effective === null) {
495
- const resolved = memory.resolveReadScopes?.(session !== undefined ? { session } : undefined)
496
- if (Array.isArray(resolved)) effective = resolved
497
- }
498
- } catch { /* 可见范围是增强;拿不到就只返回自己的覆盖 */ }
498
+ } catch { /* 可见域是增强;拿不到就只返回自己的覆盖 */ }
499
499
 
500
500
  let refs
501
501
  try { if (session !== undefined) refs = resolveCurrentScopes({ session }) } catch { refs = undefined }
502
502
  const stats = typeof memory.scopeStats === 'function' ? memory.scopeStats() : []
503
+ const kindStats = typeof memory.scopeKindStats === 'function' ? memory.scopeKindStats() : []
503
504
  const byScope = new Map()
504
505
  for (const item of Array.isArray(stats) ? stats : []) {
505
- if (item && typeof item.scope === 'string') byScope.set(item.scope, item)
506
+ if (item && typeof item.scope === 'string') byScope.set(item.scope, { ...item, kinds: [] })
506
507
  }
507
508
  // 即使还没有任何记录,也要能把"当前会话 / 当前项目 / global"勾进可见范围。
508
509
  const ensure = (scope) => {
509
510
  if (typeof scope === 'string' && scope !== '' && !byScope.has(scope)) {
510
- byScope.set(scope, { scope, records: 0, pendingEmbeds: 0 })
511
+ byScope.set(scope, { scope, records: 0, pendingEmbeds: 0, kinds: [] })
511
512
  }
512
513
  }
513
514
  ensure(refs?.session)
514
515
  ensure(refs?.project)
515
516
  ensure('global')
517
+ for (const item of Array.isArray(kindStats) ? kindStats : []) {
518
+ const bucket = item && typeof item.scope === 'string' ? byScope.get(item.scope) : undefined
519
+ if (bucket === undefined || typeof item.kind !== 'string' || item.kind === '') continue
520
+ bucket.kinds.push({ kind: item.kind, records: Number(item.records) || 0 })
521
+ }
516
522
  const rank = (scope) => scope === refs?.session ? 0 : scope === refs?.project ? 1 : scope === 'global' ? 2 : 3
517
523
  const scopes = [...byScope.values()]
518
524
  .sort((a, b) => rank(a.scope) - rank(b.scope) || String(a.scope).localeCompare(String(b.scope)))
519
- .map((item) => ({ ...item, label: item.name ?? scopeLabel(ctx, item.scope) }))
525
+ .map((item) => ({
526
+ ...item,
527
+ kinds: [...item.kinds].sort((a, b) => KNOWN_KINDS.indexOf(a.kind) - KNOWN_KINDS.indexOf(b.kind) || a.kind.localeCompare(b.kind)),
528
+ label: item.name ?? scopeLabel(ctx, item.scope),
529
+ }))
530
+ // 没有显式覆盖时,面板仍预选"当前默认读取集合"(会话 + 项目 + global),
531
+ // 让用户看到 Agent 现在实际能看到什么;保存后才变成显式覆盖。
532
+ let defaults = []
533
+ try {
534
+ const resolved = memory.resolveReadScopes?.(agentLike)
535
+ if (Array.isArray(resolved)) defaults = resolved
536
+ } catch { /* 降级为空 */ }
520
537
  return {
521
538
  sessionId,
522
539
  override: own,
523
- effective: Array.isArray(effective) ? effective : null,
540
+ effective,
524
541
  inherited,
542
+ defaults,
525
543
  scopes,
544
+ kinds: KNOWN_KINDS,
526
545
  }
527
546
  }
528
547
 
@@ -613,25 +632,64 @@ async function handle(ctx, routePath, req, res) {
613
632
  const sessionId = typeof body?.session === 'string' ? body.session.trim() : ''
614
633
  if (sessionId === '') throw new ApiError(400, 'SESSION_REQUIRED', 'session 不能为空')
615
634
  let next = null
616
- if (body?.scopes !== null && body?.scopes !== undefined) {
617
- if (!Array.isArray(body.scopes)) throw new ApiError(400, 'SCOPE_INVALID', 'scopes 必须是数组或 null')
618
- if (body.scopes.length === 0) throw new ApiError(400, 'SCOPE_EMPTY', '至少选择一个可见范围')
619
- next = []
620
- for (const raw of body.scopes) {
621
- if (typeof raw !== 'string') throw new ApiError(400, 'SCOPE_INVALID', 'scope 必须是字符串')
622
- const normalized = normalizeScopeInput(raw)
635
+ const rawConfig = body?.visibility
636
+ // 新协议:{ visibility: { scopes: [{ scope, kinds? }], level } } | null
637
+ // 兼容 0.18 的 { scopes: string[] | null }:按"绝对限制 + 全部类型"处理。
638
+ const rawScopes = rawConfig !== null && rawConfig !== undefined && typeof rawConfig === 'object'
639
+ ? rawConfig.scopes
640
+ : body?.scopes
641
+ if (rawScopes !== null && rawScopes !== undefined) {
642
+ if (!Array.isArray(rawScopes)) throw new ApiError(400, 'SCOPE_INVALID', 'scopes 必须是数组或 null')
643
+ if (rawScopes.length === 0) throw new ApiError(400, 'SCOPE_EMPTY', '至少选择一个可见范围')
644
+ const scopes = []
645
+ for (const raw of rawScopes) {
646
+ const scopeRaw = typeof raw === 'string' ? raw : raw?.scope
647
+ if (typeof scopeRaw !== 'string' || scopeRaw.trim() === '') {
648
+ throw new ApiError(400, 'SCOPE_INVALID', 'scope 必须是非空字符串')
649
+ }
650
+ const normalized = normalizeScopeInput(scopeRaw)
623
651
  if (!normalized.ok) throw new ApiError(400, normalized.code, normalized.message)
624
652
  if (normalized.kind === 'all' || normalized.kind === 'current-project' || normalized.kind === 'current-session') {
625
- throw new ApiError(400, 'SCOPE_INVALID', `可见范围必须是具体作用域键: ${JSON.stringify(raw)}`)
653
+ throw new ApiError(400, 'SCOPE_INVALID', `可见范围必须是具体作用域键: ${JSON.stringify(scopeRaw)}`)
626
654
  }
627
- if (normalized.scope !== undefined && !next.includes(normalized.scope)) next.push(normalized.scope)
655
+ if (normalized.scope === undefined || scopes.some((item) => item.scope === normalized.scope)) continue
656
+ const kinds = raw !== null && typeof raw === 'object' && Array.isArray(raw.kinds)
657
+ ? [...new Set(raw.kinds.map((kind) => String(kind).trim()).filter((kind) => kind !== ''))]
658
+ : []
659
+ scopes.push(kinds.length > 0 ? { scope: normalized.scope, kinds } : { scope: normalized.scope })
628
660
  }
661
+ const levelRaw = rawConfig !== null && rawConfig !== undefined && typeof rawConfig === 'object' ? rawConfig.level : 'absolute'
662
+ const level = levelRaw === 'normal' || levelRaw === 'none' ? levelRaw : 'absolute'
663
+ next = { scopes, level }
629
664
  }
630
665
  memory.setSessionVisibility(sessionId, next)
631
666
  writeJson(res, { ok: true, value: visibilityPayload(ctx, memory, sessionId) })
632
667
  return
633
668
  }
634
669
 
670
+ // 普通限制下的范围外访问审批:客户端浮层轮询待审批,用户点「拒绝 / 允许一次」后回写。
671
+ if (method === 'GET' && path === '/approvals') {
672
+ if (typeof memory.pendingVisibilityApprovals !== 'function') {
673
+ throw new ApiError(501, 'NOT_SUPPORTED', 'provider 未提供可见域审批接口(请升级 @restregular/dsh-memory)')
674
+ }
675
+ const sessionId = (url.searchParams.get('session') ?? '').trim()
676
+ writeJson(res, { ok: true, value: { approvals: memory.pendingVisibilityApprovals(sessionId === '' ? undefined : sessionId) } })
677
+ return
678
+ }
679
+ if (method === 'POST' && path === '/approvals') {
680
+ if (typeof memory.answerVisibilityApproval !== 'function') {
681
+ throw new ApiError(501, 'NOT_SUPPORTED', 'provider 未提供可见域审批接口(请升级 @restregular/dsh-memory)')
682
+ }
683
+ const body = await readJsonBody(req)
684
+ const id = typeof body?.id === 'string' ? body.id.trim() : ''
685
+ if (id === '') throw new ApiError(400, 'APPROVAL_ID_REQUIRED', 'id 不能为空')
686
+ const outcome = body?.outcome === 'allowed-once' ? 'allowed-once' : body?.outcome === 'rejected' ? 'rejected' : ''
687
+ if (outcome === '') throw new ApiError(400, 'APPROVAL_OUTCOME_INVALID', 'outcome 必须是 allowed-once 或 rejected')
688
+ const answered = memory.answerVisibilityApproval(id, outcome)
689
+ writeJson(res, { ok: true, value: { answered } })
690
+ return
691
+ }
692
+
635
693
  if (method === 'GET' && path === '/status') {
636
694
  const stats = typeof memory.scopeStats === 'function'
637
695
  ? memory.scopeStats()
@@ -243,14 +243,54 @@ export class CordisMemoryService extends Service {
243
243
  return this.impl.visibleScopes(agent)
244
244
  }
245
245
 
246
- /** 面板:读取某会话自己的可见范围(null = 未设置)。 */
247
- sessionVisibility(sessionId ) {
246
+ /** 完整可见域(等级 + 每个 scope 的类型白名单)。 */
247
+ visibilityPolicy(agent ) {
248
+ return this.impl.visibilityPolicy(agent)
249
+ }
250
+
251
+ /** 某个 scope 下允许的记忆类型(undefined = 不限制)。 */
252
+ visibleKinds(agent , scope ) {
253
+ return this.impl.visibleKinds(agent, scope)
254
+ }
255
+
256
+ /** 一条记录是否落在当前可见域内。 */
257
+ isRecordVisible(agent , scope , kind ) {
258
+ return this.impl.isRecordVisible(agent, scope, kind)
259
+ }
260
+
261
+ /** 面板:读取某会话自己的可见域(null = 未设置)。 */
262
+ sessionVisibility(sessionId ) {
248
263
  return this.impl.sessionVisibility(sessionId)
249
264
  }
250
265
 
251
- /** 面板:设置/清除某会话的可见范围(null = 恢复默认)。 */
252
- setSessionVisibility(sessionId , scopes ) {
253
- return this.impl.setSessionVisibility(sessionId, scopes)
266
+ /** 面板:设置/清除某会话的可见域(null = 恢复默认)。 */
267
+ setSessionVisibility(sessionId , config ) {
268
+ return this.impl.setSessionVisibility(sessionId, config)
269
+ }
270
+
271
+ /** 注入半边:下一次 pre-step 要注入的可见域变更通知(取走即删)。 */
272
+ takeVisibilityNotice(agent ) {
273
+ return this.impl.takeVisibilityNotice(agent)
274
+ }
275
+
276
+ /** 面板:每个 scope 下按类型统计条数。 */
277
+ scopeKindStats() {
278
+ return this.impl.scopeKindStats()
279
+ }
280
+
281
+ /** 普通限制:范围外访问审批(挂起,等面板回答)。 */
282
+ requestOutOfScope(agent , input ) {
283
+ return this.impl.requestOutOfScope(agent, input)
284
+ }
285
+
286
+ /** 面板:当前待审批列表。 */
287
+ pendingVisibilityApprovals(sessionId ) {
288
+ return this.impl.pendingVisibilityApprovals(sessionId)
289
+ }
290
+
291
+ /** 面板:回答一条待审批。 */
292
+ answerVisibilityApproval(id , outcome ) {
293
+ return this.impl.answerVisibilityApproval(id, outcome)
254
294
  }
255
295
 
256
296
  /** 写路径默认 scope(省略 scope 时落到哪)。 */