@restregular/dsh-memory 0.19.0 → 0.19.2

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,26 @@
2
2
 
3
3
  本项目的版本记录。安装 id 与 npm 版本一一对应。
4
4
 
5
+ ## 0.19.2 — 深色模式下勾选框 / 保存按钮配色修正,浮窗再收紧
6
+
7
+ - **根因**:宿主深色主题里 `--dsw-alias-brand-primary` 是近白色;0.19.1 把它当填充色,导致选中的勾选框变成白块(勾不可见)、保存按钮变成白底白字。
8
+ - **修正**:勾选框选中态、保存按钮、限制等级选中态改用 `--dsw-alias-state-business-primary`(亮色 #4176e6 / 暗色 #7aaaff);勾/按钮文字用可翻转的 `--dsw-alias-label-primary-foreground`(亮色白、暗色深),两种主题下都有足够对比度。
9
+ - 未选中勾选框:底色用 `label-primary` 5% 的轻填充,边框用 `label-secondary` 52% 混 `border-l1`,深色下不再是几乎看不见的空框。
10
+ - 选中行 / 等级卡的边框与底色也统一成 business-primary 的淡色,避免深色主题里出现白色描边。
11
+ - **高度收紧**:滚动列表 `max-height` 从 `min(300px,40vh)` 降到 `min(220px,32vh)`;浮窗整体从 `min(600px,80vh)` 降到 `min(520px,72vh)`,padding 14→12。
12
+ - 测试:CSS 断言锁定 business-primary + primary-foreground 的组合与新的高度上限;用 headless Chrome 在深色 token 下渲染确认勾选框、保存按钮、等级卡的对比度。
13
+ - 重新构建并发布;0.19.1 的结构与行为不变。
14
+
15
+ ## 0.19.1 — 记忆范围按钮常驻数字、默认范围预选、取消类型限制、深色模式与阴影收敛
16
+
17
+ - **按钮只显示数字**:去掉「记忆可见域」文字,保存/继承后只显示当前生效的作用域数量;有显式覆盖时仍然高亮,完整说明放在 `title` 里。
18
+ - **打开会话就加载**:按钮挂载时(以及 `sessionId` 变化时)就请求 `GET /memory/api/visibility`,不再需要先点一次按钮才知道这个会话的范围。
19
+ - **默认范围预选**:没有显式覆盖时,面板按服务端返回的 `defaults`(会话 + 项目 + global)预选;服务端目录里缺这些 scope 时客户端会自己补齐,不会再出现「一打开什么都没选」。
20
+ - **取消记忆类型限制**:移除浮窗里的类型 chips;`POST /visibility` 不再写入 `kinds`,provider 在规范化 / 读取旧配置时也忽略 `kinds`。0.19.0 的 v2 文件仍可读,只是类型白名单不再生效;同一作用域下所有类型都可读。
21
+ - **深色模式**:浮窗、等级按钮、勾选框、类型说明、审批卡的背景 / 边框 / 文字全部走宿主主题 token;去掉只在浅色下协调的白色内阴影,深色主题下对比度正常。
22
+ - **阴影收敛**:浮窗与审批卡的投影从 `0 22px 60px` 级别收紧为 `0 10px 26~28px`,去掉明显的大面积阴影;面板宽度从 360 收到 340。
23
+ - **测试**:按钮挂载即加载、只显示数字、默认范围预选(含服务端目录缺失时的补齐)、保存只带 scope、后端忽略 kinds、类型限制取消后的 search/get 行为、旧配置兼容。
24
+
5
25
  ## 0.19.0 — 记忆可见域 2.0:按类型收窄 + 三档限制 + 范围外审批 + 浮窗重做
6
26
 
7
27
  - **可见域从「作用域白名单」升级为「作用域 × 记忆类型 × 限制等级」**:每个作用域可以只允许部分 `kind`(例如 `global` 仅 `rule`、当前项目仅 `fact`);限制等级三档:
package/README.md CHANGED
@@ -45,7 +45,7 @@ JSONL 落盘 · 本机向量检索 · 五个模型工具 · 自动召回 · 硬
45
45
  | **自动召回** | 每轮按用户问题召回;新会话第一步注入项目 / global 摘要;发布、部署、工具失败等行为按标签触发定向召回 |
46
46
  | **印象形态** | 每轮只给每条记忆的短摘要;模型判断相关但需要细节时再 `memory_get` 取全文,省 token 也不丢信息 |
47
47
  | **硬性规则** | `kind: rule` 进系统提示常驻段;行首带 8 位 id,注入的是摘要,需要全文时用 `memory_get`;旧会话会收到新增 / 编辑提醒;超预算有明确警告,不静默丢弃 |
48
- | **会话可见域** | 输入框旁的「记忆范围」按钮设置本会话可读的作用域 + 每个作用域允许的记忆类型 + 限制等级(绝对 / 普通 / 无限制);Agent 及其子 Agent 都按它检索、注入与 `memory_get` |
48
+ | **会话可见域** | 输入框旁的「记忆范围」按钮设置本会话可读的作用域 + 限制等级(绝对 / 普通 / 无限制);Agent 及其子 Agent 都按它检索、注入与 `memory_get` |
49
49
  | **范围外审批** | 普通限制下,工具命中可见域外的记忆时会在界面弹出审批:展示查询关键词与范围外记忆摘要(记忆 ID 可悬浮看全文、点击跳面板展开);用户选「拒绝」或「允许一次」 |
50
50
  | **状态记忆** | `kind: state` 默认 7 天 TTL;注入带「状态,使用前验证」;过期后默认不进检索 / 摘要 / 召回,但 `memory_get` 与面板仍可取 |
51
51
  | **流程索引** | `kind: procedure` 的目录进系统提示:按当前工作区 + 触发词(工具名 / 关键词)列 `id · 触发词 → 标题`,需要时再用 `memory_get` 取全文 |
@@ -82,21 +82,23 @@ JSONL 落盘 · 本机向量检索 · 五个模型工具 · 自动召回 · 硬
82
82
 
83
83
  ![记忆设置](https://raw.githubusercontent.com/RestRegular/dsh-memory/main/preview/memory-settings.png)
84
84
 
85
- ### 输入框的记忆可见域
85
+ ### 输入框的记忆范围
86
86
 
87
- 输入框工具行右侧有「记忆范围」按钮;保存过范围后按钮改为「记忆可见域 n」并高亮。点开的浮窗使用毛玻璃背景,按当前会话列出可选作用域(当前会话 / 当前项目 / global / 已有自定义作用域):
87
+ 输入框工具行右侧有「记忆范围」按钮。**打开会话时就会读取这个会话的设置**,按钮只显示当前生效的作用域数量(不再显示「记忆可见域」文字);有显式覆盖时高亮。点开的浮窗使用毛玻璃背景,按当前会话列出可选作用域(当前会话 / 当前项目 / global / 已有自定义作用域):
88
88
 
89
+ - **默认范围**:还没有显式设置时,按「会话 + 项目 + global」预选,不会出现空面板。
89
90
  - **搜索与批量**:顶部可搜索作用域,支持「全选 / 取消全选」;列表最大高度受限,作用域多时在浮窗内滚动。
90
- - **按类型收窄**:勾选一个作用域后会展开记忆类型 chips(事实 / 决策 / 偏好 / 流程 / 笔记 / 规则 / 状态)。例如只允许 `global` 的 `rule`,或只允许当前项目的 `fact`。
91
91
  - **限制等级**:
92
92
  - **绝对限制**:可见域外的记忆一律查不到;即使工具内部命中,也不返回结果。
93
93
  - **普通限制**(默认):可见域内正常返回;命中范围外记忆时,工具会暂停并向用户发起一次审批,展示 Agent 的查询关键词与范围外记忆摘要。
94
- - **无限制**:不启用范围白名单,可以读取任意作用域与类型(选择仍会保存,供下次切换)。
94
+ - **无限制**:不启用范围白名单,可以读取任意作用域(选择仍会保存,供下次切换)。
95
+ - **不再按记忆类型收窄**:0.19.1 起只按作用域限制;旧配置里的 `kinds` 会被忽略,同一作用域下的事实 / 规则 / 流程等都可读。
95
96
  - **审批浮窗**:普通限制下的待审批会出现在界面底部。记忆 ID 悬浮 350ms 后显示完整内容 / 类型 / 作用域 / 重要度 / 标签浮窗(与审计详情同一套行为与样式);点击记忆 ID 跳到「记录」页并展开对应卡片。提供「拒绝」与「允许一次」:允许一次只对本次工具调用生效;拒绝或 5 分钟未回答则工具拿不到这些内容。
96
97
  - 子 Agent 自动继承父会话 / 根会话的设置;在子 Agent 自己的会话里再设置,只影响那一个会话。
97
- - 保存后,下一次 Agent 步骤会通过注入的上下文消息收到「可见域已更新」通知(包含可见范围、类型与限制等级),不需要重启会话。
98
+ - 保存后,下一次 Agent 步骤会通过注入的上下文消息收到「可见域已更新」通知(包含可见范围与限制等级),不需要重启会话。
98
99
  - 「恢复默认」清除覆盖,回到「会话 + 项目 + global」的默认读取集合。
99
- - 覆盖按会话落盘在 `<storeDir>/visibility/<session>.json`,浏览器刷新 / 插件重载后仍在;0.18 的旧文件按「绝对限制 + 全部类型」兼容读取。
100
+ - 覆盖按会话落盘在 `<storeDir>/visibility/<session>.json`,浏览器刷新 / 插件重载后仍在;0.18 的旧文件按「绝对限制」兼容读取。
101
+ - 浮窗与审批卡的半透明背景、边框、文字颜色全部走宿主主题 token;勾选框选中态、保存按钮、限制等级选中态使用 `--dsw-alias-state-business-primary` + `--dsw-alias-label-primary-foreground`,深色模式下不会出现白底白勾 / 白底白字;阴影已收敛为小范围投影,滚动列表高度收紧到 `min(220px, 32vh)`。
100
102
  - 只影响**读取**:`memory_save` 的落点仍由 `scope` 参数与默认写口径决定;面板管理页不受可见域限制。
101
103
 
102
104
  ### 向量服务
@@ -370,7 +372,7 @@ retrieval:
370
372
  | `<storeDir>/projects/<sha1(scope)>.vec` | 向量边车;首行 `#<model>\t<dims>\t<pooling>`,后面每行 `id\t<base64 向量>` |
371
373
  | `<storeDir>/settings.json` | 面板设置(覆盖配置文件里的默认值) |
372
374
  | `<storeDir>/scopes.json` | 项目作用域别名(显示名 → `project:<路径>`) |
373
- | `<storeDir>/visibility/<session>.json` | 会话「记忆可见域」覆盖(作用域 + 每个作用域的类型白名单 + 限制等级);没有文件 = 使用默认三路集合 |
375
+ | `<storeDir>/visibility/<session>.json` | 会话「记忆可见域」覆盖(作用域 + 限制等级);没有文件 = 使用默认三路集合 |
374
376
  | `<storeDir>/*.lock` | 跨进程写锁;陈旧锁(持有者已死或 10s 未动)会被接管 |
375
377
  | `<installRoot>/llamacpp/` | llama-server 运行时、依赖 dll、`llama-server.log` |
376
378
  | `<installRoot>/models/` | 下载的 GGUF 模型 |
package/lib/client.js CHANGED
@@ -491,7 +491,7 @@ window.__ModuleLoader__.load({
491
491
  '.mem-scope-btn.on{color:var(--dsw-alias-brand-primary);border-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 45%,var(--dsw-alias-border-l1));background:color-mix(in srgb,var(--dsw-alias-brand-primary) 9%,transparent)}',
492
492
  '.mem-scope-btn svg{flex:none}',
493
493
  // 毛玻璃浮窗:半透明 + backdrop blur;不支持 backdrop-filter 时退回实心底。
494
- '.mem-scope-pop{position:fixed;z-index:80;width:360px;max-height:min(620px,80vh);display:flex;flex-direction:column;gap:9px;padding:14px;border:1px solid color-mix(in srgb,var(--dsw-alias-border-l2,var(--dsw-alias-border-l1)) 70%,transparent);border-radius:16px;background:color-mix(in srgb,var(--dsw-alias-bg-layer-1) 66%,transparent);-webkit-backdrop-filter:blur(20px) saturate(1.4);backdrop-filter:blur(20px) saturate(1.4);box-shadow:0 22px 60px rgba(0,0,0,.34),inset 0 1px 0 rgba(255,255,255,.08);color:var(--dsw-alias-label-primary);font-size:13px;overflow:hidden}',
494
+ '.mem-scope-pop{position:fixed;z-index:80;width:340px;max-height:min(520px,72vh);display:flex;flex-direction:column;gap:8px;padding:12px;border:1px solid color-mix(in srgb,var(--dsw-alias-border-l2,var(--dsw-alias-border-l1)) 60%,transparent);border-radius:14px;background:color-mix(in srgb,var(--dsw-alias-bg-layer-1) 78%,transparent);-webkit-backdrop-filter:blur(20px) saturate(1.35);backdrop-filter:blur(20px) saturate(1.35);box-shadow:0 10px 28px rgba(0,0,0,.18);color:var(--dsw-alias-label-primary);font-size:13px;overflow:hidden}',
495
495
  '@supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){.mem-scope-pop{background:var(--dsw-specific-menu,var(--dsw-alias-bg-layer-1))}}',
496
496
  '.mem-scope-head{display:flex;align-items:center;gap:8px}',
497
497
  '.mem-scope-head h4{margin:0;font-size:13px;font-weight:600;line-height:1.4}',
@@ -503,44 +503,40 @@ window.__ModuleLoader__.load({
503
503
  '.mem-scope-level-btn b{font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary)}',
504
504
  '.mem-scope-level-btn span{font-size:9.5px;line-height:1.4;color:var(--dsw-alias-label-secondary)}',
505
505
  '.mem-scope-level-btn:hover{border-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 40%,var(--dsw-alias-border-l1))}',
506
- '.mem-scope-level-btn.on{border-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 55%,var(--dsw-alias-border-l1));background:color-mix(in srgb,var(--dsw-alias-brand-primary) 11%,transparent)}',
507
- '.mem-scope-level-btn.on b,.mem-scope-level-btn.on span{color:var(--dsw-alias-brand-primary)}',
506
+ '.mem-scope-level-btn.on{border-color:color-mix(in srgb,var(--dsw-alias-state-business-primary) 60%,var(--dsw-alias-border-l1));background:color-mix(in srgb,var(--dsw-alias-state-business-primary) 14%,transparent)}',
507
+ '.mem-scope-level-btn.on b,.mem-scope-level-btn.on span{color:var(--dsw-alias-state-business-primary)}',
508
508
  '.mem-scope-note{padding:5px 8px;border-radius:8px;background:color-mix(in srgb,var(--dsw-alias-state-warn-primary,#d9a23b) 10%,transparent);color:var(--dsw-alias-label-secondary);font-size:11px;line-height:1.5}',
509
509
  '.mem-scope-search{display:flex;align-items:center;gap:6px}',
510
510
  '.mem-scope-search input[type=search]{flex:1;min-width:0;padding:5px 9px;font-size:12px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:color-mix(in srgb,var(--dsw-alias-bg-layer-1) 78%,transparent);color:var(--dsw-alias-label-primary);outline:none}',
511
511
  '.mem-scope-search input[type=search]:focus{border-color:var(--dsw-alias-brand-primary)}',
512
512
  '.mem-scope-search .linkbtn{white-space:nowrap;padding:2px 3px;border:none;background:none;color:var(--dsw-alias-label-secondary);font-size:11px;cursor:pointer}',
513
513
  '.mem-scope-search .linkbtn:hover{color:var(--dsw-alias-brand-primary);border:none}',
514
- '.mem-scope-list{display:flex;flex-direction:column;gap:3px;overflow:auto;min-height:0;max-height:min(300px,40vh);padding:2px 2px 2px 0;scrollbar-width:thin}',
514
+ '.mem-scope-list{display:flex;flex-direction:column;gap:3px;overflow:auto;min-height:0;max-height:min(220px,32vh);padding:2px 2px 2px 0;scrollbar-width:thin}',
515
515
  '.mem-scope-list::-webkit-scrollbar{width:8px}',
516
516
  '.mem-scope-list::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--dsw-alias-label-secondary) 35%,transparent);border-radius:999px;border:2px solid transparent;background-clip:padding-box}',
517
517
  '.mem-scope-item{display:flex;flex-direction:column;gap:4px;padding:5px 6px;border:1px solid transparent;border-radius:10px}',
518
518
  '.mem-scope-item:hover{background:var(--dsw-alias-interactive-bg-hover)}',
519
- '.mem-scope-item.on{border-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 24%,var(--dsw-alias-border-l1));background:color-mix(in srgb,var(--dsw-alias-brand-primary) 7%,transparent)}',
519
+ '.mem-scope-item.on{border-color:color-mix(in srgb,var(--dsw-alias-state-business-primary) 38%,var(--dsw-alias-border-l1));background:color-mix(in srgb,var(--dsw-alias-state-business-primary) 8%,transparent)}',
520
520
  '.mem-scope-row{display:flex;align-items:center;gap:8px}',
521
521
  '.mem-scope-check{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;padding:0;border:none;background:transparent;flex:none;cursor:pointer}',
522
- '.mem-scope-check .box{display:flex;align-items:center;justify-content:center;width:16px;height:16px;border:1.5px solid var(--dsw-alias-border-l2,var(--dsw-alias-border-l1));border-radius:5px;background:transparent;color:var(--dsw-alias-label-on-brand,#fff);transition:background .12s ease,border-color .12s ease}',
523
- '.mem-scope-check.on .box{background:var(--dsw-alias-brand-primary);border-color:var(--dsw-alias-brand-primary)}',
522
+ '.mem-scope-check .box{display:flex;align-items:center;justify-content:center;width:16px;height:16px;border:1.5px solid color-mix(in srgb,var(--dsw-alias-label-secondary) 52%,var(--dsw-alias-border-l1));border-radius:5px;background:color-mix(in srgb,var(--dsw-alias-label-primary) 5%,transparent);color:var(--dsw-alias-label-primary-foreground);transition:background .12s ease,border-color .12s ease}',
523
+ '.mem-scope-check.on .box{background:var(--dsw-alias-state-business-primary);border-color:var(--dsw-alias-state-business-primary);color:var(--dsw-alias-label-primary-foreground)}',
524
524
  '.mem-scope-check:focus-visible{outline:1px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}',
525
525
  '.mem-scope-label{flex:1;min-width:0;padding:0;border:none;background:transparent;color:var(--dsw-alias-label-primary);font-size:12.5px;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer}',
526
526
  '.mem-scope-label:hover{color:var(--dsw-alias-brand-primary);border:none}',
527
527
  '.mem-scope-row .cnt{flex:none;color:var(--dsw-alias-label-secondary);font-size:10.5px}',
528
- '.mem-kind-row{display:flex;flex-wrap:wrap;gap:4px;padding-left:24px}',
529
- '.mem-kind-chip{display:inline-flex;align-items:center;gap:3px;padding:1px 7px;border:1px solid var(--dsw-alias-border-l1);border-radius:999px;background:transparent;color:var(--dsw-alias-label-secondary);font-size:10.5px;line-height:1.7;cursor:pointer}',
530
- '.mem-kind-chip:hover{border-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 50%,var(--dsw-alias-border-l1));color:var(--dsw-alias-label-primary)}',
531
- '.mem-kind-chip.on{border-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 55%,var(--dsw-alias-border-l1));color:var(--dsw-alias-brand-primary);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 10%,transparent)}',
532
- '.mem-kind-chip i{font-style:normal;opacity:.65;font-size:9px}',
533
528
  '.mem-scope-foot{display:flex;align-items:center;gap:8px}',
534
529
  '.mem-scope-foot .spacer{flex:1}',
535
530
  '.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}',
536
531
  '.mem-scope-reset:hover:not(:disabled){border-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 55%,var(--dsw-alias-border-l1));color:var(--dsw-alias-brand-primary)}',
537
- '.mem-scope-save{padding:6px 16px;border:1px solid var(--dsw-alias-brand-primary);border-radius:9px;background:linear-gradient(180deg,color-mix(in srgb,var(--dsw-alias-brand-primary) 92%,white 8%),var(--dsw-alias-brand-primary));color:var(--dsw-alias-label-on-brand,#fff);font-size:12px;font-weight:600;cursor:pointer;box-shadow:0 4px 14px color-mix(in srgb,var(--dsw-alias-brand-primary) 30%,transparent);transition:filter .12s ease}',
538
- '.mem-scope-save:hover:not(:disabled){filter:brightness(1.06)}',
532
+ '.mem-scope-save{padding:6px 16px;border:1px solid var(--dsw-alias-state-business-primary);border-radius:9px;background:var(--dsw-alias-state-business-primary);color:var(--dsw-alias-label-primary-foreground);font-size:12px;font-weight:600;cursor:pointer;box-shadow:0 2px 8px color-mix(in srgb,var(--dsw-alias-state-business-primary) 26%,transparent);transition:filter .12s ease}',
533
+ '.mem-scope-save:hover:not(:disabled){filter:brightness(1.06);color:var(--dsw-alias-label-primary-foreground);border-color:var(--dsw-alias-state-business-primary)}',
539
534
  '.mem-scope-reset:disabled,.mem-scope-save:disabled{opacity:.5;cursor:default;filter:none}',
535
+ '.mem-scope-save:disabled{color:var(--dsw-alias-label-primary-foreground)}',
540
536
  '.mem-scope-err{padding:5px 8px;border-radius:8px;background:color-mix(in srgb,var(--dsw-alias-state-error-primary,#d33) 10%,transparent);color:var(--dsw-alias-state-error-primary,#d33);font-size:12px;line-height:1.5}',
541
537
  // 范围外访问审批浮层(全局 fixed;根节点带 .memp 以复用审计 hover 浮窗样式)
542
538
  '.mem-approval{position:fixed;left:50%;bottom:18px;transform:translateX(-50%);z-index:90;width:min(520px,calc(100vw - 24px));max-height:min(70vh,620px);display:flex;flex-direction:column;pointer-events:none;padding:0;font-size:13px;color:var(--dsw-alias-label-primary)}',
543
- '.mem-approval-card{pointer-events:auto;display:flex;flex-direction:column;gap:8px;padding:14px;border:1px solid color-mix(in srgb,var(--dsw-alias-state-warn-primary,#d9a23b) 42%,var(--dsw-alias-border-l1));border-radius:16px;background:color-mix(in srgb,var(--dsw-alias-bg-layer-1) 72%,transparent);-webkit-backdrop-filter:blur(20px) saturate(1.35);backdrop-filter:blur(20px) saturate(1.35);box-shadow:0 22px 60px rgba(0,0,0,.36),inset 0 1px 0 rgba(255,255,255,.08);overflow:hidden}',
539
+ '.mem-approval-card{pointer-events:auto;display:flex;flex-direction:column;gap:8px;padding:14px;border:1px solid color-mix(in srgb,var(--dsw-alias-state-warn-primary,#d9a23b) 42%,var(--dsw-alias-border-l1));border-radius:14px;background:color-mix(in srgb,var(--dsw-alias-bg-layer-1) 82%,transparent);-webkit-backdrop-filter:blur(20px) saturate(1.3);backdrop-filter:blur(20px) saturate(1.3);box-shadow:0 10px 26px rgba(0,0,0,.18);overflow:hidden}',
544
540
  '@supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){.mem-approval-card{background:var(--dsw-alias-bg-layer-1)}}',
545
541
  '.mem-approval-head{display:flex;align-items:center;gap:7px}',
546
542
  '.mem-approval-head b{font-size:13px;font-weight:600}',
@@ -4465,6 +4461,22 @@ window.__ModuleLoader__.load({
4465
4461
  * 弹层用 fixed 定位(按按钮 rect 往上开),避免被 composer 的 overflow 裁掉。
4466
4462
  * 视觉:毛玻璃背景 + 自定义勾选 + 类型 chips + 三档限制等级。
4467
4463
  */
4464
+ /**
4465
+ * 输入框里的「记忆范围」按钮 + 浮窗。
4466
+ *
4467
+ * 宿主 `conversation.input.right` 是 session 作用域的 list 槽,owner 会把
4468
+ * `sessionId` 作为标准 prop 传进来,所以这里不需要 register 的 inject。
4469
+ *
4470
+ * 0.19.1 起:
4471
+ * - 打开会话就 GET 一次,按钮直接显示该会话的范围数量(不再等点击才刷新);
4472
+ * - 按钮只显示数字,不再显示「记忆可见域」文字;
4473
+ * - 首次打开且没有显式覆盖时,按服务端给的 defaults 预选默认范围;
4474
+ * - 不再按记忆类型收窄,只选作用域。
4475
+ *
4476
+ * 读写走 /memory/api/visibility:
4477
+ * GET ?session=<id> → { override, effective, inherited, defaults, scopes }
4478
+ * POST { session, visibility: { scopes: [{ scope }], level } | null } → 同上
4479
+ */
4468
4480
  function MemoryVisibilityButton({ sessionId } = {}) {
4469
4481
  const [open, setOpen] = React.useState(false)
4470
4482
  const [loading, setLoading] = React.useState(false)
@@ -4473,6 +4485,7 @@ window.__ModuleLoader__.load({
4473
4485
  const [data, setData] = React.useState(null)
4474
4486
  const [level, setLevel] = React.useState('normal')
4475
4487
  const [entries, setEntries] = React.useState({})
4488
+ const [catalog, setCatalog] = React.useState([])
4476
4489
  const [search, setSearch] = React.useState('')
4477
4490
  const [anchor, setAnchor] = React.useState(null)
4478
4491
  const wrapRef = React.useRef(null)
@@ -4497,37 +4510,49 @@ window.__ModuleLoader__.load({
4497
4510
  }
4498
4511
  }, [open])
4499
4512
 
4500
- if (typeof sessionId !== 'string' || sessionId === '') return null
4501
-
4502
- const allKindsOf = (value) => {
4503
- const list = value && Array.isArray(value.kinds) ? value.kinds.filter((kind) => typeof kind === 'string') : []
4504
- return list.length > 0 ? list : Object.keys(KIND_META)
4505
- }
4506
-
4507
4513
  const applyPayload = (value) => {
4508
4514
  if (!value || typeof value !== 'object') return
4509
4515
  setData(value)
4510
- const config = value.override || value.effective || (Array.isArray(value.defaults) && value.defaults.length > 0
4511
- ? { level: 'normal', scopes: value.defaults.map((scope) => ({ scope })) }
4512
- : null)
4513
- const selected = config && Array.isArray(config.scopes) ? config.scopes.filter((rule) => rule && typeof rule.scope === 'string') : []
4516
+ const config = (value.override && typeof value.override === 'object' && !Array.isArray(value.override))
4517
+ ? value.override
4518
+ : (value.effective && typeof value.effective === 'object' && !Array.isArray(value.effective) ? value.effective : null)
4514
4519
  setLevel(config && (config.level === 'absolute' || config.level === 'none') ? config.level : 'normal')
4515
- const kindsAll = allKindsOf(value)
4516
- const scopes = []
4517
- const catalog = Array.isArray(value.scopes) ? value.scopes : []
4518
- for (const item of catalog) {
4519
- if (item && typeof item.scope === 'string' && !scopes.includes(item.scope)) scopes.push(item.scope)
4520
+ const selected = new Set()
4521
+ const selectedRules = config && Array.isArray(config.scopes) ? config.scopes : []
4522
+ for (const rule of selectedRules) {
4523
+ const scope = typeof rule === 'string' ? rule : rule && typeof rule.scope === 'string' ? rule.scope : ''
4524
+ if (scope !== '') selected.add(scope)
4525
+ }
4526
+ // 没有显式覆盖 / 生效策略时用 defaults(默认会话 + 项目 + global)预选。
4527
+ // 服务端可能没把 defaults 放进目录(旧版或宿主缺 sessions),这里自己补齐。
4528
+ if (selected.size === 0 && Array.isArray(value.defaults)) {
4529
+ for (const scope of value.defaults) if (typeof scope === 'string' && scope !== '') selected.add(scope)
4520
4530
  }
4521
- for (const rule of selected) {
4522
- if (!scopes.includes(rule.scope)) scopes.push(rule.scope)
4531
+ const nextCatalog = []
4532
+ const seen = new Set()
4533
+ for (const item of Array.isArray(value.scopes) ? value.scopes : []) {
4534
+ if (!item || typeof item.scope !== 'string' || item.scope === '' || seen.has(item.scope)) continue
4535
+ seen.add(item.scope)
4536
+ nextCatalog.push(item)
4523
4537
  }
4524
- const next = {}
4525
- for (const scope of scopes) {
4526
- const rule = selected.find((item) => item.scope === scope)
4527
- const kinds = rule && Array.isArray(rule.kinds) && rule.kinds.length > 0 ? rule.kinds.filter((kind) => kindsAll.includes(kind)) : [...kindsAll]
4528
- next[scope] = { enabled: rule !== undefined, kinds }
4538
+ for (const scope of selected) {
4539
+ if (seen.has(scope)) continue
4540
+ seen.add(scope)
4541
+ nextCatalog.push({ scope, label: scope, records: 0 })
4529
4542
  }
4530
- setEntries(next)
4543
+ // 旧服务端没有 defaults 时的兜底:至少把默认三路(会话 / 项目 / global)选上,
4544
+ // 不要再出现"一打开什么都没选"。
4545
+ if (selected.size === 0) {
4546
+ for (const item of nextCatalog) {
4547
+ if (item.scope === 'global' || item.scope.startsWith('session:') || item.scope.startsWith('project:')) {
4548
+ selected.add(item.scope)
4549
+ }
4550
+ }
4551
+ }
4552
+ const nextEntries = {}
4553
+ for (const item of nextCatalog) nextEntries[item.scope] = selected.has(item.scope)
4554
+ setCatalog(nextCatalog)
4555
+ setEntries(nextEntries)
4531
4556
  }
4532
4557
 
4533
4558
  const load = () => {
@@ -4539,6 +4564,12 @@ window.__ModuleLoader__.load({
4539
4564
  .finally(() => setLoading(false))
4540
4565
  }
4541
4566
 
4567
+ // 打开会话就加载一次:按钮上的数字来自这个会话的设置,不需要用户先点按钮。
4568
+ React.useEffect(() => {
4569
+ if (typeof sessionId !== 'string' || sessionId === '') return
4570
+ load()
4571
+ }, [sessionId])
4572
+
4542
4573
  const toggle = (event) => {
4543
4574
  if (open) { setOpen(false); return }
4544
4575
  let nextAnchor = null
@@ -4555,38 +4586,13 @@ window.__ModuleLoader__.load({
4555
4586
  }
4556
4587
 
4557
4588
  const toggleScope = (scope) => {
4558
- const kindsAll = allKindsOf(data)
4559
- setEntries((prev) => {
4560
- const current = prev[scope]
4561
- return { ...prev, [scope]: { enabled: !(current && current.enabled), kinds: current && current.kinds.length > 0 ? current.kinds : [...kindsAll] } }
4562
- })
4563
- }
4564
-
4565
- const toggleKind = (scope, kind) => {
4566
- setEntries((prev) => {
4567
- const current = prev[scope]
4568
- if (!current) return prev
4569
- const has = current.kinds.includes(kind)
4570
- if (has && current.kinds.length === 1) return prev // 至少保留一种类型;全部用「全部」按钮
4571
- const kinds = has ? current.kinds.filter((item) => item !== kind) : [...current.kinds, kind]
4572
- return { ...prev, [scope]: { ...current, kinds } }
4573
- })
4574
- }
4575
-
4576
- const setAllKinds = (scope) => {
4577
- const kindsAll = allKindsOf(data)
4578
- setEntries((prev) => {
4579
- const current = prev[scope]
4580
- if (!current) return prev
4581
- return { ...prev, [scope]: { ...current, kinds: [...kindsAll] } }
4582
- })
4589
+ setEntries((prev) => ({ ...prev, [scope]: !prev[scope] }))
4583
4590
  }
4584
4591
 
4585
4592
  const selectAll = () => {
4586
- const kindsAll = allKindsOf(data)
4587
4593
  setEntries((prev) => {
4588
4594
  const next = { ...prev }
4589
- for (const scope of Object.keys(next)) next[scope] = { enabled: true, kinds: next[scope].kinds.length > 0 ? next[scope].kinds : [...kindsAll] }
4595
+ for (const key of Object.keys(next)) next[key] = true
4590
4596
  return next
4591
4597
  })
4592
4598
  }
@@ -4594,7 +4600,7 @@ window.__ModuleLoader__.load({
4594
4600
  const clearAll = () => {
4595
4601
  setEntries((prev) => {
4596
4602
  const next = { ...prev }
4597
- for (const scope of Object.keys(next)) next[scope] = { ...next[scope], enabled: false }
4603
+ for (const key of Object.keys(next)) next[key] = false
4598
4604
  return next
4599
4605
  })
4600
4606
  }
@@ -4612,27 +4618,31 @@ window.__ModuleLoader__.load({
4612
4618
  }
4613
4619
 
4614
4620
  const saveDraft = () => {
4615
- const scopes = Object.entries(entries)
4616
- .filter(([, entry]) => entry && entry.enabled)
4617
- .map(([scope, entry]) => ({ scope, kinds: [...entry.kinds] }))
4621
+ const scopes = catalog.filter((item) => entries[item.scope]).map((item) => ({ scope: item.scope }))
4618
4622
  if (scopes.length === 0) { setError('至少选择一个可见范围'); return }
4619
4623
  save({ scopes, level })
4620
4624
  }
4621
4625
 
4622
- const scopes = data && Array.isArray(data.scopes) ? data.scopes : []
4623
- const override = data && data.override && Array.isArray(data.override.scopes) ? data.override : null
4626
+ if (typeof sessionId !== 'string' || sessionId === '') return null
4627
+
4628
+ const override = data && data.override && typeof data.override === 'object' && !Array.isArray(data.override)
4629
+ ? data.override
4630
+ : null
4624
4631
  const hasOverride = override !== null
4625
- const overrideCount = hasOverride ? override.scopes.length : 0
4626
- const selectedCount = Object.values(entries).filter((entry) => entry && entry.enabled).length
4627
- const kindsAll = allKindsOf(data)
4632
+ const effectiveConfig = override
4633
+ ?? (data && data.effective && typeof data.effective === 'object' && !Array.isArray(data.effective) ? data.effective : null)
4634
+ const effectiveCount = effectiveConfig && Array.isArray(effectiveConfig.scopes)
4635
+ ? effectiveConfig.scopes.length
4636
+ : (data && Array.isArray(data.defaults) ? data.defaults.length : 0)
4637
+ const selectedCount = catalog.filter((item) => entries[item.scope]).length
4628
4638
  const needle = search.trim().toLowerCase()
4629
- const visibleScopes = scopes.filter((item) => {
4639
+ const visibleScopes = catalog.filter((item) => {
4630
4640
  if (!needle) return true
4631
4641
  return String(item.label || item.scope).toLowerCase().includes(needle) || String(item.scope).toLowerCase().includes(needle)
4632
4642
  })
4633
4643
  let popStyle = {}
4634
4644
  if (anchor) {
4635
- const width = 360
4645
+ const width = 340
4636
4646
  const margin = 8
4637
4647
  const viewportW = (typeof window !== 'undefined' && Number(window.innerWidth)) || 1024
4638
4648
  const viewportH = (typeof window !== 'undefined' && Number(window.innerHeight)) || 768
@@ -4643,7 +4653,7 @@ window.__ModuleLoader__.load({
4643
4653
  }
4644
4654
 
4645
4655
  const levelMeta = [
4646
- { value: 'absolute', label: '绝对限制', hint: '范围外一律查不到' },
4656
+ { value: 'absolute', label: '绝对限制', hint: '范围外查不到' },
4647
4657
  { value: 'normal', label: '普通限制', hint: '范围外需审批' },
4648
4658
  { value: 'none', label: '无限制', hint: '不限制读取' },
4649
4659
  ]
@@ -4652,23 +4662,25 @@ window.__ModuleLoader__.load({
4652
4662
  h('button', {
4653
4663
  type: 'button',
4654
4664
  className: `mem-scope-btn${hasOverride ? ' on' : ''}`,
4655
- title: '记忆可见域(本会话及子 Agent)',
4656
- 'aria-label': '记忆可见域',
4665
+ title: hasOverride
4666
+ ? `本会话已设置记忆范围:${effectiveCount} 个作用域`
4667
+ : `本会话使用默认记忆范围:${effectiveCount} 个作用域`,
4668
+ 'aria-label': `记忆范围 ${effectiveCount}`,
4657
4669
  'aria-expanded': open,
4658
4670
  onMouseDown: (event) => { try { event.preventDefault() } catch { /* keepFocus */ } },
4659
4671
  onClick: toggle,
4660
4672
  },
4661
4673
  h(NavLineIcon, { size: 14 }),
4662
- h('span', null, hasOverride ? `记忆可见域 ${overrideCount}` : '记忆范围'),
4674
+ data === null ? null : h('span', null, String(effectiveCount)),
4663
4675
  ),
4664
- open ? h('div', { className: 'mem-scope-pop', style: popStyle, role: 'dialog', 'aria-label': '记忆可见域' },
4676
+ open ? h('div', { className: 'mem-scope-pop', style: popStyle, role: 'dialog', 'aria-label': '记忆范围' },
4665
4677
  h('div', { className: 'mem-scope-head' },
4666
- h('h4', null, '记忆可见域'),
4678
+ h('h4', null, '记忆范围'),
4667
4679
  h('span', { className: 'spacer' }),
4668
4680
  h('span', { className: 'mem-scope-count' }, `已选 ${selectedCount}`),
4669
4681
  ),
4670
4682
  h('div', { className: 'hint' },
4671
- 'Agent 默认只能检索和读取勾选的作用域与类型;限制等级决定范围外怎么处理。'),
4683
+ 'Agent 默认只能检索和读取勾选的作用域;限制等级决定范围外怎么处理。'),
4672
4684
  data && data.inherited
4673
4685
  ? h('div', { className: 'hint' }, '当前继承自父会话;保存后在本会话独立生效。')
4674
4686
  : null,
@@ -4697,60 +4709,30 @@ window.__ModuleLoader__.load({
4697
4709
  h('button', { type: 'button', className: 'linkbtn', onClick: selectAll }, '全选'),
4698
4710
  h('button', { type: 'button', className: 'linkbtn', onClick: clearAll }, '取消全选'),
4699
4711
  ),
4700
- loading
4712
+ loading && data === null
4701
4713
  ? h('div', { className: 'hint' }, '读取中…')
4702
4714
  : h('div', { className: 'mem-scope-list' },
4703
4715
  visibleScopes.length === 0
4704
4716
  ? h('div', { className: 'hint' }, needle ? '没有匹配的作用域。' : '还没有可选的范围。')
4705
- : visibleScopes.map((item) => {
4706
- const entry = entries[item.scope] || { enabled: false, kinds: [...kindsAll] }
4707
- const kindCounts = new Map()
4708
- for (const kind of Array.isArray(item.kinds) ? item.kinds : []) {
4709
- if (kind && typeof kind.kind === 'string') kindCounts.set(kind.kind, Number(kind.records) || 0)
4710
- }
4711
- return h('div', { className: `mem-scope-item${entry.enabled ? ' on' : ''}`, key: item.scope },
4712
- h('div', { className: 'mem-scope-row' },
4713
- h('button', {
4714
- type: 'button',
4715
- role: 'checkbox',
4716
- 'aria-checked': entry.enabled,
4717
- className: `mem-scope-check${entry.enabled ? ' on' : ''}`,
4718
- onClick: () => toggleScope(item.scope),
4719
- 'aria-label': entry.enabled ? '取消选择' : '选择',
4720
- }, h('span', { className: 'box' }, entry.enabled ? 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)),
4721
- h('button', {
4722
- type: 'button',
4723
- className: 'mem-scope-label',
4724
- title: item.scope,
4725
- onClick: () => toggleScope(item.scope),
4726
- }, item.label || item.scope),
4727
- h('span', { className: 'cnt' }, `${item.records ?? 0}`),
4728
- ),
4729
- entry.enabled
4730
- ? h('div', { className: 'mem-kind-row' },
4731
- h('button', {
4732
- type: 'button',
4733
- className: `mem-kind-chip${entry.kinds.length >= kindsAll.length ? ' on' : ''}`,
4734
- onClick: () => setAllKinds(item.scope),
4735
- title: '允许该作用域下所有类型',
4736
- }, '全部'),
4737
- kindsAll.map((kind) => {
4738
- const on = entry.kinds.includes(kind)
4739
- const label = kindMeta(kind).label
4740
- const count = kindCounts.get(kind)
4741
- return h('button', {
4742
- key: kind,
4743
- type: 'button',
4744
- className: `mem-kind-chip${on ? ' on' : ''}`,
4745
- 'aria-pressed': on,
4746
- onClick: () => toggleKind(item.scope, kind),
4747
- title: `${label}${count === undefined ? '' : ` · ${count} 条`}`,
4748
- }, label, count === undefined ? null : h('i', null, count))
4749
- }),
4750
- )
4751
- : null,
4752
- )
4753
- }),
4717
+ : visibleScopes.map((item) => h('div', { className: `mem-scope-item${entries[item.scope] ? ' on' : ''}`, key: item.scope },
4718
+ h('div', { className: 'mem-scope-row' },
4719
+ h('button', {
4720
+ type: 'button',
4721
+ role: 'checkbox',
4722
+ 'aria-checked': Boolean(entries[item.scope]),
4723
+ className: `mem-scope-check${entries[item.scope] ? ' on' : ''}`,
4724
+ onClick: () => toggleScope(item.scope),
4725
+ 'aria-label': entries[item.scope] ? '取消选择' : '选择',
4726
+ }, 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)),
4727
+ h('button', {
4728
+ type: 'button',
4729
+ className: 'mem-scope-label',
4730
+ title: item.scope,
4731
+ onClick: () => toggleScope(item.scope),
4732
+ }, item.label || item.scope),
4733
+ h('span', { className: 'cnt' }, `${item.records ?? 0}`),
4734
+ ),
4735
+ )),
4754
4736
  ),
4755
4737
  error ? h('div', { className: 'mem-scope-err' }, error) : null,
4756
4738
  h('div', { className: 'mem-scope-foot' },
@@ -5057,7 +5039,7 @@ window.__ModuleLoader__.load({
5057
5039
  name: 'conversation.input.right',
5058
5040
  id: 'memory-visibility',
5059
5041
  order: 30,
5060
- label: () => '记忆可见域',
5042
+ label: () => '记忆范围',
5061
5043
  }, MemoryVisibilityButton))
5062
5044
  } catch (error) {
5063
5045
  console.warn('[dsh-memory] 记忆可见范围按钮注册失败:', error?.message)
package/lib/panel.js CHANGED
@@ -471,14 +471,14 @@ function resolveScopeSelection(memory, rawScope) {
471
471
  }
472
472
 
473
473
  /** 面板已知的记忆类型(与工具的 kind enum 一致)。 */
474
- const KNOWN_KINDS = ['fact', 'decision', 'preference', 'procedure', 'note', 'rule', 'state']
475
-
476
474
  /**
477
- * 会话「记忆可见域」的完整快照:自己的覆盖 + 生效策略 + 可选范围目录(含每个 scope
478
- * 的类型统计)。
475
+ * 会话「记忆可见域」的完整快照:自己的覆盖 + 生效策略 + 可选范围目录。
479
476
  *
480
477
  * 自己的覆盖(null = 没设置)用于面板上的"恢复默认";effective 用于预选(子 Agent
481
- * 会话会继承父会话的覆盖);scopes 是本次会话可以勾选的全部具体作用域键 + 类型。
478
+ * 会话会继承父会话的覆盖);defaults 是"没有显式覆盖时 Agent 实际会读的集合",
479
+ * 首次打开面板时按它预选,而不是显示成什么都没选。
480
+ *
481
+ * 0.19.1 起不再支持按记忆类型收窄:目录只返回 scope,不再返回 kinds。
482
482
  */
483
483
  function visibilityPayload(ctx, memory, sessionId) {
484
484
  let session
@@ -499,41 +499,35 @@ function visibilityPayload(ctx, memory, sessionId) {
499
499
 
500
500
  let refs
501
501
  try { if (session !== undefined) refs = resolveCurrentScopes({ session }) } catch { refs = undefined }
502
+ // 没有显式覆盖时,面板仍预选"当前默认读取集合"(会话 + 项目 + global),
503
+ // 让用户看到 Agent 现在实际能看到什么;保存后才变成显式覆盖。
504
+ let defaults = []
505
+ try {
506
+ const resolved = memory.resolveReadScopes?.(agentLike)
507
+ if (Array.isArray(resolved)) defaults = resolved
508
+ } catch { /* 降级为空 */ }
509
+
502
510
  const stats = typeof memory.scopeStats === 'function' ? memory.scopeStats() : []
503
- const kindStats = typeof memory.scopeKindStats === 'function' ? memory.scopeKindStats() : []
504
511
  const byScope = new Map()
505
512
  for (const item of Array.isArray(stats) ? stats : []) {
506
- if (item && typeof item.scope === 'string') byScope.set(item.scope, { ...item, kinds: [] })
513
+ if (item && typeof item.scope === 'string') byScope.set(item.scope, { ...item })
507
514
  }
508
- // 即使还没有任何记录,也要能把"当前会话 / 当前项目 / global"勾进可见范围。
515
+ // 即使还没有任何记录 / 宿主没给 sessions,也要能把默认集合里的 scope 勾出来。
509
516
  const ensure = (scope) => {
510
517
  if (typeof scope === 'string' && scope !== '' && !byScope.has(scope)) {
511
- byScope.set(scope, { scope, records: 0, pendingEmbeds: 0, kinds: [] })
518
+ byScope.set(scope, { scope, records: 0, pendingEmbeds: 0 })
512
519
  }
513
520
  }
514
- ensure(refs?.session)
515
- ensure(refs?.project)
521
+ const sessionScope = refs?.session ?? defaults.find((scope) => scope.startsWith('session:'))
522
+ const projectScope = refs?.project ?? defaults.find((scope) => scope.startsWith('project:'))
523
+ ensure(sessionScope)
524
+ ensure(projectScope)
516
525
  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
- }
522
- const rank = (scope) => scope === refs?.session ? 0 : scope === refs?.project ? 1 : scope === 'global' ? 2 : 3
526
+ for (const scope of defaults) ensure(scope)
527
+ const rank = (scope) => scope === sessionScope ? 0 : scope === projectScope ? 1 : scope === 'global' ? 2 : 3
523
528
  const scopes = [...byScope.values()]
524
529
  .sort((a, b) => rank(a.scope) - rank(b.scope) || String(a.scope).localeCompare(String(b.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 { /* 降级为空 */ }
530
+ .map((item) => ({ ...item, label: item.name ?? scopeLabel(ctx, item.scope) }))
537
531
  return {
538
532
  sessionId,
539
533
  override: own,
@@ -541,7 +535,6 @@ function visibilityPayload(ctx, memory, sessionId) {
541
535
  inherited,
542
536
  defaults,
543
537
  scopes,
544
- kinds: KNOWN_KINDS,
545
538
  }
546
539
  }
547
540
 
@@ -633,8 +626,9 @@ async function handle(ctx, routePath, req, res) {
633
626
  if (sessionId === '') throw new ApiError(400, 'SESSION_REQUIRED', 'session 不能为空')
634
627
  let next = null
635
628
  const rawConfig = body?.visibility
636
- // 新协议:{ visibility: { scopes: [{ scope, kinds? }], level } } | null
637
- // 兼容 0.18 的 { scopes: string[] | null }:按"绝对限制 + 全部类型"处理。
629
+ // 新协议:{ visibility: { scopes: [{ scope }], level } } | null
630
+ // 兼容 0.19.0 的 { scopes: [{ scope, kinds? }] } 与 0.18 的 { scopes: string[] }:
631
+ // 0.19.1 起不再限制记忆类型,提交里的 kinds 一律忽略。
638
632
  const rawScopes = rawConfig !== null && rawConfig !== undefined && typeof rawConfig === 'object'
639
633
  ? rawConfig.scopes
640
634
  : body?.scopes
@@ -653,10 +647,7 @@ async function handle(ctx, routePath, req, res) {
653
647
  throw new ApiError(400, 'SCOPE_INVALID', `可见范围必须是具体作用域键: ${JSON.stringify(scopeRaw)}`)
654
648
  }
655
649
  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 })
650
+ scopes.push({ scope: normalized.scope })
660
651
  }
661
652
  const levelRaw = rawConfig !== null && rawConfig !== undefined && typeof rawConfig === 'object' ? rawConfig.level : 'absolute'
662
653
  const level = levelRaw === 'normal' || levelRaw === 'none' ? levelRaw : 'absolute'
@@ -1378,8 +1378,8 @@ export class LocalMemoryService {
1378
1378
  case 'session': if (!this.cfg.sessionEnabled) continue; break
1379
1379
  default: if (!this.cfg.customEnabled) continue; break
1380
1380
  }
1381
- const kinds = Array.isArray(raw.kinds) ? raw.kinds.filter((kind) => typeof kind === 'string' && kind !== '') : []
1382
- out.push(kinds.length > 0 ? { scope, kinds } : { scope })
1381
+ // 0.19.1 起不再按记忆类型收窄:旧文件里的 kinds 忽略,只保留作用域。
1382
+ out.push({ scope })
1383
1383
  }
1384
1384
  return out
1385
1385
  }
@@ -1523,10 +1523,8 @@ export class LocalMemoryService {
1523
1523
  if (normalized.scope === undefined) continue
1524
1524
  const scope = this.canonicalScope(normalized.scope)
1525
1525
  if (out.some((item) => item.scope === scope)) continue
1526
- const kinds = Array.isArray(rule.kinds)
1527
- ? [...new Set(rule.kinds.filter((kind) => typeof kind === 'string' && kind.trim() !== '').map((kind) => kind.trim()))]
1528
- : []
1529
- out.push(kinds.length > 0 ? { scope, kinds } : { scope })
1526
+ // 不再支持按记忆类型收窄:提交里的 kinds 一律忽略。
1527
+ out.push({ scope })
1530
1528
  }
1531
1529
  if (out.length === 0) throw memoryError('SCOPE_EMPTY', '至少选择一个可见的记忆范围')
1532
1530
  const level = config.level === 'normal' || config.level === 'none' ? config.level : 'absolute'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-memory",
3
- "version": "0.19.0",
3
+ "version": "0.19.2",
4
4
  "description": "DeepSeek Harness 记忆系统(单包单入口):JSONL 存储 + 本地向量检索(BGE-M3)+ 五个模型工具 + 自动召回注入 + 管理面板。",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",