@restregular/dsh-memory 0.25.2 → 0.25.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  本项目的版本记录。安装 id 与 npm 版本一一对应。
4
4
 
5
+ ## 0.25.3 — Agent 授权改用「勾选 + AI 气泡」呈现,取消勾选即撤销
6
+
7
+ - **授权结果 = 勾选**:作用域被 Agent 申请并审批通过后,该作用域直接显示为**已勾选**(即使它不在你设置的可见范围内),列表里同样排在已勾选分组。浮窗打开期间每 3 秒刷新授权,Agent 刚拿到的权限不用重开面板就能看到。
8
+ - **「AI」气泡**:授权来的作用域在名称右边挂一个「AI」气泡,`title` 写明只读 / 可写;继承自父会话的标「AI·继承」。
9
+ - **取消勾选 = 撤销**:用户取消该作用域的勾选时,面板调用 `POST /memory/api/grants` 撤销这条授权,勾选与气泡一起消失,Agent 下一次 pre-step 收到「记忆权限已更新」。「取消全选」会一并撤销可撤销的授权;继承的授权撤销不了,会明确提示到父会话操作。
10
+ - **目录里已不可见的作用域**仍保留一行(「目录中已不可见」),取消勾选即可撤销对应授权。
11
+ - **保留 0.25.2 的收敛**:仍没有独立的「Agent 授权」行与浮窗上方解释文本;勾选、`可读 / 可写`(自己勾选的作用域才可调)与授权气泡并列在同一行。
12
+ - 测试:新增用例断言授权行显示为勾选 + AI 气泡、title 含权限文案、授权行参与「已勾选在上」排序,取消勾选走 `POST /grants` 且气泡消失;全套 494 tests / 493 pass / 1 skipped。
13
+
5
14
  ## 0.25.2 — 记忆权限浮窗只留「勾选作用域 + 可读 / 可写」,列表按勾选与字母排序
6
15
 
7
16
  - **移除 Agent 授权 UI**:「记忆权限」浮窗不再显示「Agent 授权:只读 / 可写」行,作用域行只剩勾选 + 【绑定】/【可读】/【可写】;继承标记、「到父会话撤销」与「目录中已不可见」的保留授权行一并去掉。
package/README.md CHANGED
@@ -47,7 +47,7 @@ JSONL 落盘 · 本机向量检索 · 五个模型工具 · 自动召回 · 硬
47
47
  | **自动召回** | 每轮按用户问题召回;新会话第一步注入项目 / global 摘要;发布、部署、工具失败等行为按标签触发定向召回 |
48
48
  | **印象形态** | 每轮只给每条记忆的短摘要;模型判断相关但需要细节时再 `memory_get` 取全文,省 token 也不丢信息 |
49
49
  | **硬性规则** | `kind: rule` 进系统提示常驻段;行首带 8 位 id,注入的是摘要,需要全文时用 `memory_get`;旧会话会收到新增 / 编辑提醒;超预算有明确警告,不静默丢弃 |
50
- | **记忆权限** | 输入框旁的「记忆权限」按钮设置本会话可读的作用域 + 限制等级(绝对 / 普通 / 无限制);每个作用域一行就是一条设置:**勾选**表示选中该作用域,行内**【绑定】/【可读】/【可写】**控制工作区默认可见与读写权限——绑定到当前工作区后新会话默认可见,可读 / 可写独立影响工具读写;Agent 通过 `memory_scopes request` 申请到的范围外授权仍按会话生效并会注入告知,但不再在面板里单独展示(0.25.2 起面板只留勾选 + 操作权限);Agent 及其子 Agent 都按它检索、注入与 `memory_get` |
50
+ | **记忆权限** | 输入框旁的「记忆权限」按钮设置本会话可读的作用域 + 限制等级(绝对 / 普通 / 无限制);每个作用域一行就是一条设置:**勾选**表示本会话可访问,行内**【绑定】/【可读】/【可写】**控制工作区默认可见与读写权限——绑定到当前工作区后新会话默认可见,可读 / 可写独立影响工具读写;Agent 通过 `memory_scopes request` 申请到的范围外授权**也用勾选呈现**(名称右边挂一个「AI」气泡),**取消勾选即撤销**,撤销后气泡自动消失(0.25.3 起);Agent 及其子 Agent 都按它检索、注入与 `memory_get` |
51
51
  | **修正版编辑** | 面板里编辑一条记忆 = 新建一条修正版并通过 `supersedes` 指向旧记录,旧记录不原地修改;记录页「是否被修正」筛选默认隐藏旧版本,可切到全部 / 只看已修正 |
52
52
  | **范围外审批** | 普通限制下,工具命中可见域外的记忆时会在**对应会话的输入框上方**出现审批卡(样式与系统权限审批一致):展示工具、Agent 说明、查询关键词与范围外记忆摘要,支持逐条勾选 / 全选 / 取消全选(「允许选中的 N 条」或整单「允许一次」)或「拒绝」;点记忆 ID 直接跳到面板「记录」页并展开该条 |
53
53
  | **上下文去重** | `memory_search` / `memory_list` 返回过的条目记进会话上下文状态;同一版本再次命中只回记忆 ID(`memory_search` 的裸 ID 与带摘要条目之间空一行),并提示用 `memory_get` 取全文(内容更新后重新给摘要) |
@@ -97,7 +97,7 @@ JSONL 落盘 · 本机向量检索 · 五个模型工具 · 自动召回 · 硬
97
97
  - **绝对限制**:可见域外的读取 / 写入 / 删除一律不执行;命中被挡住时会明确告诉 Agent 是「绝对限制」以及怎么调整(不再假装记忆不存在)。
98
98
  - **普通限制**(默认):可见域内正常返回;命中范围外记忆时,工具会暂停并在**该会话**的输入框上方显示审批卡,展示 Agent 的查询关键词与范围外记忆摘要;读审批可以逐条勾选,只允许其中一条或多条。用户拒绝 / 5 分钟未回答时,工具结果里会明确写出真实原因(「用户拒绝了本次访问」/「审批超时」),模型不会误以为记忆不存在。范围外写入 / 删除同样走审批。
99
99
  - **无限制**:不启用范围白名单,可以读写任意作用域(选择仍会保存,供下次切换)。
100
- - **面板只留勾选 + 操作权限(0.25.2)**:作用域行就是「勾选该作用域 + 【绑定】/【可读】/【可写】」这一组控件,不再展示「Agent 授权:只读 / 可写」行,也去掉了浮窗上方那段解释文本;列表里**已勾选的排在上面、未勾选的排在下面**,组内按名称字母排序(勾选状态一变立即重排)。Agent 通过 `memory_scopes request` 审批得到的范围外例外仍在服务端按会话(及子 Agent)生效,并通过「记忆权限已更新」注入告知 Agent。
100
+ - **Agent 授权 = 勾选 + 「AI」气泡(0.25.3)**:作用域行就是「勾选该作用域 + 【绑定】/【可读】/【可写】」这一组控件,不再有独立的「Agent 授权」行与浮窗上方的解释文本。Agent 通过 `memory_scopes request` 审批得到的授权,直接体现为该作用域的**勾选**,并在名称右边挂一个「AI」气泡(`title` 写明只读 / 可写);**用户取消勾选 = 撤销授权**,撤销后气泡与勾选一起消失,Agent 下一次 pre-step 收到「记忆权限已更新」。继承自父会话的授权标「AI·继承」,本会话取消勾选会被拒绝并提示到父会话操作;「取消全选」会一并撤销可撤销的授权。目录里已不可见的作用域仍占一行(标「目录中已不可见」),方便取消勾选撤销。列表里**已勾选的(含授权来的)排在上面、未勾选的排在下面**,组内按名称字母排序,勾选状态一变立即重排。
101
101
  - **不再按记忆类型收窄**:0.19.1 起只按作用域限制;旧配置里的 `kinds` 会被忽略,同一作用域下的事实 / 规则 / 流程等都可读。
102
102
  - **审批卡(0.21.0 / 0.22.x)**:注册在会话内的 `conversation.input.dock`,**只在发起审批的那个会话里显示**,切到别的会话看不到;视觉与系统自带的权限审批弹窗一致(警告色 strip、卡片、右对齐动作行,同一批主题 token)。按动作分为「记忆读取 / 写入 / 删除审批」。读审批默认全部勾选:可逐条取消、用「全选 / 取消全选」批量操作,**点条目任意位置即可切换选中**,再点「允许选中的 N 条」,工具只放行勾选的 id、其余写入 `withheld.reason='partial'`;全选时等价于原来的「允许一次」。strip 右侧可**折叠 / 展开**详情,折叠后仍保留「拒绝 / 允许」动作。写 / 删审批是单条,隐藏勾选框。**0.22.0 起**卡片展示工具调用的 `description`(普通限制下工具层强制模型提供),点记忆 ID 会打开记忆面板的「记录」标签页、选中并滚动到该条、自动展开;**0.22.2 起**查询与说明固定显示在条目列表上方,条目再多也不会被列表挤没(两行锁 `flex:none`,只有列表滚动);**0.22.3 起**审批卡高度只受 composer 文本区上限约束(与宿主审批卡同口径),矮窗口下列表也有空间。拒绝、超时或无法发起审批都会把原因告诉模型。Enter = 允许、Esc = 拒绝(焦点在卡片内时)。
103
103
  - 子 Agent 自动继承父会话 / 根会话的设置;在子 Agent 自己的会话里再设置,只影响那一个会话。
package/lib/client.js CHANGED
@@ -540,6 +540,9 @@ window.__ModuleLoader__.load({
540
540
  '.mem-scope-state:disabled{opacity:.42;cursor:default}',
541
541
  '.mem-scope-state:focus-visible{outline:1px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}',
542
542
  '.mem-scope-sep{width:1px;height:12px;margin:0 1px;background:var(--dsw-alias-border-l1);flex:none}',
543
+ // 0.25.3:Agent 授权用「勾选 + AI 气泡」呈现,气泡挂在作用域名称右边。
544
+ '.mem-scope-ai{flex:none;font-size:9.5px;line-height:1.7;padding:0 6px;border-radius:999px;border:1px solid color-mix(in srgb,var(--dsw-alias-state-business-primary,#4176e6) 45%,var(--dsw-alias-border-l1));background:color-mix(in srgb,var(--dsw-alias-state-business-primary,#4176e6) 12%,transparent);color:color-mix(in srgb,var(--dsw-alias-state-business-primary,#4176e6) 78%,var(--dsw-alias-label-primary));white-space:nowrap;cursor:help}',
545
+ '.mem-scope-ai.inherited{border-style:dashed;background:transparent;color:var(--dsw-alias-label-secondary)}',
543
546
  '.mem-scope-foot{display:flex;align-items:center;gap:8px}',
544
547
  '.mem-scope-foot .spacer{flex:1}',
545
548
  '.mem-scope-reset{padding:6px 13px;border:1px solid var(--dsw-alias-border-l1);border-radius:9px;background:transparent;color:var(--dsw-alias-label-secondary);font-size:12px;cursor:pointer;transition:border-color .12s ease,color .12s ease}',
@@ -620,6 +623,13 @@ window.__ModuleLoader__.load({
620
623
  return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`
621
624
  }
622
625
 
626
+ /** Agent 授权里的权限文案(read / write 组合)。 */
627
+ function grantPermissionText(permissions) {
628
+ return (Array.isArray(permissions) ? permissions : [])
629
+ .map((permission) => (permission === 'write' ? '可写' : '只读'))
630
+ .join(' / ')
631
+ }
632
+
623
633
  /** 过期时间的人话描述:还剩多久 / 已过期多久。 */
624
634
  function expiryText(ts) {
625
635
  if (!ts) return '永不过期'
@@ -4570,6 +4580,9 @@ window.__ModuleLoader__.load({
4570
4580
  const [catalog, setCatalog] = React.useState([])
4571
4581
  const [search, setSearch] = React.useState('')
4572
4582
  const [anchor, setAnchor] = React.useState(null)
4583
+ const [grants, setGrants] = React.useState([])
4584
+ const [grantBusy, setGrantBusy] = React.useState('')
4585
+ const [grantError, setGrantError] = React.useState('')
4573
4586
  const wrapRef = React.useRef(null)
4574
4587
 
4575
4588
  React.useEffect(() => {
@@ -4701,8 +4714,60 @@ window.__ModuleLoader__.load({
4701
4714
  load()
4702
4715
  }
4703
4716
 
4717
+ /**
4718
+ * 0.25.3:本会话的 Agent 授权(grants)。
4719
+ * 授权结果直接体现在作用域行的勾选上(外加「AI」气泡),所以浮窗打开期间
4720
+ * 按 3 秒轮询:Agent 刚审批到的授权不用重开面板就能看到勾选与气泡。
4721
+ */
4722
+ const loadGrants = () => {
4723
+ if (typeof sessionId !== 'string' || sessionId === '') return
4724
+ api(`grants?session=${encodeURIComponent(sessionId)}`)
4725
+ .then((value) => {
4726
+ setGrants(Array.isArray(value.grants) ? value.grants : [])
4727
+ setGrantError('')
4728
+ })
4729
+ .catch((e) => setGrantError(String((e && e.message) || e)))
4730
+ }
4731
+
4732
+ React.useEffect(() => {
4733
+ if (!open) return undefined
4734
+ loadGrants()
4735
+ if (typeof setInterval !== 'function') return undefined
4736
+ const timer = setInterval(() => {
4737
+ if (typeof document !== 'undefined' && document.hidden) return
4738
+ loadGrants()
4739
+ }, 3000)
4740
+ return () => clearInterval(timer)
4741
+ }, [open, sessionId])
4742
+
4743
+ /** 撤销一条本会话授权(继承自父会话的授权只能到父会话撤销)。 */
4744
+ const revokeGrant = (grant) => {
4745
+ if (!grant || grant.inherited === true) return Promise.resolve()
4746
+ const id = typeof grant.id === 'string' ? grant.id : ''
4747
+ if (id === '') return Promise.resolve()
4748
+ const owner = typeof grant.ownerSession === 'string' && grant.ownerSession !== '' ? grant.ownerSession : sessionId
4749
+ setGrantBusy(id)
4750
+ setGrantError('')
4751
+ return api('grants', { session: owner, id, view: sessionId })
4752
+ .then((value) => setGrants(Array.isArray(value.grants) ? value.grants : []))
4753
+ .catch((e) => setGrantError(String((e && e.message) || e)))
4754
+ .finally(() => setGrantBusy(''))
4755
+ }
4756
+
4704
4757
  const toggleScope = (scope) => {
4705
- setEntries((prev) => ({ ...prev, [scope]: !prev[scope] }))
4758
+ const grant = grantsByScope.get(scope)
4759
+ if (!grant) {
4760
+ setEntries((prev) => ({ ...prev, [scope]: !prev[scope] }))
4761
+ return
4762
+ }
4763
+ // 勾选里有 Agent 授权:取消勾选 = 撤销授权(撤销后「AI」气泡一起消失)。
4764
+ if (grant.inherited === true) {
4765
+ setEntries((prev) => ({ ...prev, [scope]: true }))
4766
+ setGrantError('继承自父会话的授权需要到父会话撤销')
4767
+ return
4768
+ }
4769
+ setEntries((prev) => ({ ...prev, [scope]: false }))
4770
+ revokeGrant(grant)
4706
4771
  }
4707
4772
 
4708
4773
  /** 切换某个作用域的可读 / 可写状态(会话级)。 */
@@ -4732,6 +4797,17 @@ window.__ModuleLoader__.load({
4732
4797
  for (const key of Object.keys(next)) next[key] = false
4733
4798
  return next
4734
4799
  })
4800
+ // 取消全选 = 把这些作用域全部取消勾选,所以 Agent 授权也一并撤销;
4801
+ // 继承自父会话的授权撤销不了,只提示去父会话操作。
4802
+ let inherited = 0
4803
+ let chain = Promise.resolve()
4804
+ for (const grant of Array.isArray(grants) ? grants : []) {
4805
+ if (!grant || typeof grant.scope !== 'string' || grant.scope === '') continue
4806
+ if (grant.inherited === true) { inherited += 1; continue }
4807
+ chain = chain.then(() => revokeGrant(grant))
4808
+ }
4809
+ if (inherited > 0) setGrantError('继承自父会话的授权需要到父会话撤销')
4810
+ chain.catch(() => { /* revokeGrant 自己会记录错误 */ })
4735
4811
  }
4736
4812
 
4737
4813
  const save = (config) => {
@@ -4773,16 +4849,40 @@ window.__ModuleLoader__.load({
4773
4849
  : (data && Array.isArray(data.defaults) ? data.defaults.length : 0)
4774
4850
  const selectedCount = catalog.filter((item) => entries[item.scope]).length
4775
4851
  const needle = search.trim().toLowerCase()
4776
- const visibleScopes = catalog.filter((item) => {
4777
- if (!needle) return true
4778
- return String(item.label || item.scope).toLowerCase().includes(needle) || String(item.scope).toLowerCase().includes(needle)
4779
- })
4780
- // 0.25.2:已勾选的排在上面、未勾选的排在下面,组内按名称字母排序
4781
- // (中英文混排也走同一份 key,勾选状态一变列表就重排)。
4782
- const nameOf = (item) => String(item.label || item.scope)
4783
- visibleScopes.sort((a, b) => (Number(Boolean(b.scope && entries[b.scope])) - Number(Boolean(a.scope && entries[a.scope])))
4784
- || nameOf(a).localeCompare(nameOf(b), 'zh-Hans-CN', { sensitivity: 'base', numeric: true })
4785
- || String(a.scope).localeCompare(String(b.scope)))
4852
+ // 0.25.3:Agent 授权的结果也用勾选呈现 —— 勾选 = 本会话可访问,授权来的作用域
4853
+ // 在名称右边挂一个「AI」气泡;取消勾选即撤销,撤销后气泡自动消失。
4854
+ const grantList = Array.isArray(grants) ? grants : []
4855
+ const grantsByScope = new Map()
4856
+ for (const grant of grantList) {
4857
+ if (!grant || typeof grant.scope !== 'string' || grant.scope === '') continue
4858
+ if (!grantsByScope.has(grant.scope)) grantsByScope.set(grant.scope, grant)
4859
+ }
4860
+ const isChecked = (scope) => Boolean(entries[scope]) || grantsByScope.has(scope)
4861
+ const matches = (label, scope) => !needle
4862
+ || String(label || scope).toLowerCase().includes(needle) || String(scope).toLowerCase().includes(needle)
4863
+ const visibleScopes = catalog.filter((item) => matches(item.label || item.scope, item.scope))
4864
+ // 目录里已经看不到的作用域(记录删光 / 元数据没了)仍占一行,方便取消勾选撤销授权。
4865
+ const catalogScopes = new Set(catalog.map((item) => item.scope))
4866
+ const orphanGrants = grantList.filter((grant) => grant && typeof grant.scope === 'string' && grant.scope !== ''
4867
+ && !catalogScopes.has(grant.scope) && matches(grant.label || grant.scope, grant.scope))
4868
+ const orphanCount = grantList.filter((grant) => grant && typeof grant.scope === 'string'
4869
+ && grant.scope !== '' && !catalogScopes.has(grant.scope)).length
4870
+ const checkedCount = catalog.filter((item) => isChecked(item.scope)).length + orphanCount
4871
+ // 已勾选的排上面、未勾选的排下面,组内按名称字母排序(授权行同样算已勾选)。
4872
+ const rows = [
4873
+ ...visibleScopes.map((item) => ({ scope: item.scope, name: String(item.label || item.scope), item })),
4874
+ ...orphanGrants.map((grant) => ({ scope: grant.scope, name: String(grant.label || grant.scope), grant })),
4875
+ ]
4876
+ rows.sort((a, b) => (Number(isChecked(b.scope)) - Number(isChecked(a.scope)))
4877
+ || a.name.localeCompare(b.name, 'zh-Hans-CN', { sensitivity: 'base', numeric: true })
4878
+ || a.scope.localeCompare(b.scope))
4879
+ /** 作用域名称右边的「AI」气泡:表示这条勾选来自 Agent 申请的授权。 */
4880
+ const grantTag = (grant) => h('span', {
4881
+ className: `mem-scope-ai${grant.inherited === true ? ' inherited' : ''}`,
4882
+ title: grant.inherited === true
4883
+ ? `Agent 申请的范围外授权(${grantPermissionText(grant.permissions)})· 继承自父会话,要到父会话撤销`
4884
+ : `Agent 申请的范围外授权(${grantPermissionText(grant.permissions)});取消勾选即撤销`,
4885
+ }, grant.inherited === true ? 'AI·继承' : 'AI')
4786
4886
  let popStyle = {}
4787
4887
  if (anchor) {
4788
4888
  const width = 340
@@ -4826,7 +4926,7 @@ window.__ModuleLoader__.load({
4826
4926
  h('div', { className: 'mem-scope-head' },
4827
4927
  h('h4', null, '记忆权限'),
4828
4928
  h('span', { className: 'spacer' }),
4829
- h('span', { className: 'mem-scope-count' }, `已选 ${selectedCount}`),
4929
+ h('span', { className: 'mem-scope-count' }, `已选 ${checkedCount}`),
4830
4930
  ),
4831
4931
  data && data.inherited
4832
4932
  ? h('div', { className: 'hint' }, '当前继承自父会话;保存后在本会话独立生效。')
@@ -4859,64 +4959,77 @@ window.__ModuleLoader__.load({
4859
4959
  loading && data === null
4860
4960
  ? h('div', { className: 'hint' }, '读取中…')
4861
4961
  : h('div', { className: 'mem-scope-list' },
4862
- visibleScopes.length === 0
4962
+ rows.length === 0
4863
4963
  ? h('div', { className: 'hint' }, needle ? '没有匹配的作用域。' : '还没有可选的范围。')
4864
- : visibleScopes.map((item) => h('div', { className: `mem-scope-item${entries[item.scope] ? ' on' : ''}`, key: item.scope },
4964
+ : rows.map((row) => {
4965
+ const item = row.item
4966
+ const grant = item ? grantsByScope.get(row.scope) : row.grant
4967
+ const checked = isChecked(row.scope)
4968
+ return h('div', { className: `mem-scope-item${checked ? ' on' : ''}`, key: row.scope },
4865
4969
  h('div', { className: 'mem-scope-row' },
4866
4970
  h('button', {
4867
4971
  type: 'button',
4868
4972
  role: 'checkbox',
4869
- 'aria-checked': Boolean(entries[item.scope]),
4870
- className: `mem-scope-check${entries[item.scope] ? ' on' : ''}`,
4871
- onClick: () => toggleScope(item.scope),
4872
- 'aria-label': entries[item.scope] ? '取消选择' : '选择',
4873
- }, h('span', { className: 'box' }, entries[item.scope] ? h('svg', { width: 11, height: 11, viewBox: '0 0 12 12', 'aria-hidden': 'true' }, h('path', { d: 'M2 6.2 4.7 9 10 3.4', fill: 'none', stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round' })) : null)),
4973
+ 'aria-checked': checked,
4974
+ className: `mem-scope-check${checked ? ' on' : ''}`,
4975
+ onClick: () => toggleScope(row.scope),
4976
+ 'aria-label': checked ? '取消选择' : '选择',
4977
+ title: grant
4978
+ ? (grant.inherited === true
4979
+ ? 'AI 申请的授权(继承自父会话,要到父会话撤销)'
4980
+ : '取消勾选会撤销 AI 申请的这条授权')
4981
+ : null,
4982
+ }, h('span', { className: 'box' }, checked ? h('svg', { width: 11, height: 11, viewBox: '0 0 12 12', 'aria-hidden': 'true' }, h('path', { d: 'M2 6.2 4.7 9 10 3.4', fill: 'none', stroke: 'currentColor', strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round' })) : null)),
4874
4983
  h('button', {
4875
4984
  type: 'button',
4876
4985
  className: 'mem-scope-label',
4877
- title: item.scope,
4878
- onClick: () => toggleScope(item.scope),
4879
- }, item.label || item.scope),
4880
- h('span', { className: 'cnt' }, `${item.records ?? 0}`),
4881
- ),
4882
- // 0.23.0:状态按钮 —— 绑定(工作区级) / 可读 | 可写(会话级)。
4883
- h('div', { className: 'mem-scope-state-row' },
4884
- h('button', {
4885
- type: 'button',
4886
- className: `mem-scope-state bind${defaultBound[item.scope] || bound[item.scope] ? ' on' : ''}${defaultBound[item.scope] ? ' locked' : ''}`,
4887
- 'aria-pressed': Boolean(defaultBound[item.scope] || bound[item.scope]),
4888
- disabled: Boolean(defaultBound[item.scope]),
4889
- title: defaultBound[item.scope]
4890
- ? '默认可见范围已包含(会话 + 项目 + global 默认绑定),无需再绑定'
4891
- : (bound[item.scope]
4892
- ? '已绑定到当前工作区:本工作区新会话的默认可见范围会包含它'
4893
- : '绑定到当前工作区:本工作区新会话的默认可见范围会包含它'),
4894
- onClick: () => { if (!defaultBound[item.scope]) toggleBound(item.scope) },
4895
- }, '绑定'),
4896
- h('span', { className: 'mem-scope-sep', 'aria-hidden': 'true' }),
4897
- h('button', {
4898
- type: 'button',
4899
- className: `mem-scope-state read${perms[item.scope]?.read !== false ? ' on' : ''}`,
4900
- 'aria-pressed': perms[item.scope]?.read !== false,
4901
- disabled: !entries[item.scope],
4902
- title: entries[item.scope]
4903
- ? (perms[item.scope]?.read !== false ? '可读:搜索 / 读取会命中该作用域' : '不可读:搜索 / 读取会跳过该作用域')
4904
- : '先勾选该作用域再调整可读 / 可写',
4905
- onClick: () => togglePerm(item.scope, 'read'),
4906
- }, '可读'),
4907
- h('button', {
4908
- type: 'button',
4909
- className: `mem-scope-state write${perms[item.scope]?.write !== false ? ' on' : ''}`,
4910
- 'aria-pressed': perms[item.scope]?.write !== false,
4911
- disabled: !entries[item.scope],
4912
- title: entries[item.scope]
4913
- ? (perms[item.scope]?.write !== false ? '可写:保存 / 删除会作用到该作用域' : '不可写:保存 / 删除会被拒绝并告知原因')
4914
- : '先勾选该作用域再调整可读 / 可写',
4915
- onClick: () => togglePerm(item.scope, 'write'),
4916
- }, '可写'),
4986
+ title: item ? row.scope : `${row.scope}(目录中已不可见)`,
4987
+ onClick: () => toggleScope(row.scope),
4988
+ }, item ? (item.label || item.scope) : (row.grant.label || row.grant.scope)),
4989
+ grant ? grantTag(grant) : null,
4990
+ h('span', { className: 'cnt' }, item ? `${item.records ?? 0}` : '目录中已不可见'),
4917
4991
  ),
4918
- )),
4992
+ item
4993
+ ? h('div', { className: 'mem-scope-state-row' },
4994
+ h('button', {
4995
+ type: 'button',
4996
+ className: `mem-scope-state bind${defaultBound[item.scope] || bound[item.scope] ? ' on' : ''}${defaultBound[item.scope] ? ' locked' : ''}`,
4997
+ 'aria-pressed': Boolean(defaultBound[item.scope] || bound[item.scope]),
4998
+ disabled: Boolean(defaultBound[item.scope]),
4999
+ title: defaultBound[item.scope]
5000
+ ? '默认可见范围已包含(会话 + 项目 + global 默认绑定),无需再绑定'
5001
+ : (bound[item.scope]
5002
+ ? '已绑定到当前工作区:本工作区新会话的默认可见范围会包含它'
5003
+ : '绑定到当前工作区:本工作区新会话的默认可见范围会包含它'),
5004
+ onClick: () => { if (!defaultBound[item.scope]) toggleBound(item.scope) },
5005
+ }, '绑定'),
5006
+ h('span', { className: 'mem-scope-sep', 'aria-hidden': 'true' }),
5007
+ h('button', {
5008
+ type: 'button',
5009
+ className: `mem-scope-state read${perms[item.scope]?.read !== false ? ' on' : ''}`,
5010
+ 'aria-pressed': perms[item.scope]?.read !== false,
5011
+ disabled: !entries[item.scope],
5012
+ title: entries[item.scope]
5013
+ ? (perms[item.scope]?.read !== false ? '可读:搜索 / 读取会命中该作用域' : '不可读:搜索 / 读取会跳过该作用域')
5014
+ : (grant ? '这条勾选来自 AI 授权,权限由审批决定;你自己勾选后可改' : '先勾选该作用域再调整可读 / 可写'),
5015
+ onClick: () => togglePerm(item.scope, 'read'),
5016
+ }, '可读'),
5017
+ h('button', {
5018
+ type: 'button',
5019
+ className: `mem-scope-state write${perms[item.scope]?.write !== false ? ' on' : ''}`,
5020
+ 'aria-pressed': perms[item.scope]?.write !== false,
5021
+ disabled: !entries[item.scope],
5022
+ title: entries[item.scope]
5023
+ ? (perms[item.scope]?.write !== false ? '可写:保存 / 删除会作用到该作用域' : '不可写:保存 / 删除会被拒绝并告知原因')
5024
+ : (grant ? '这条勾选来自 AI 授权,权限由审批决定;你自己勾选后可改' : '先勾选该作用域再调整可读 / 可写'),
5025
+ onClick: () => togglePerm(item.scope, 'write'),
5026
+ }, '可写'),
5027
+ )
5028
+ : null,
5029
+ )
5030
+ }),
4919
5031
  ),
5032
+ grantError ? h('div', { className: 'mem-scope-err' }, grantError) : null,
4920
5033
  error ? h('div', { className: 'mem-scope-err' }, error) : null,
4921
5034
  h('div', { className: 'mem-scope-foot' },
4922
5035
  h('button', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-memory",
3
- "version": "0.25.2",
3
+ "version": "0.25.3",
4
4
  "description": "DeepSeek Harness 记忆系统(单包单入口):JSONL 存储 + 本地向量检索(BGE-M3)+ 五个模型工具 + 自动召回注入 + 管理面板。",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",