@restregular/dsh-memory 0.25.4 → 0.25.5
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 +6 -0
- package/README.md +2 -2
- package/lib/client.js +28 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
本项目的版本记录。安装 id 与 npm 版本一一对应。
|
|
4
4
|
|
|
5
|
+
## 0.25.5 — AI 授权行用自己的样式;按钮数字与「已选」都把授权算进去
|
|
6
|
+
|
|
7
|
+
- **视觉区分**:AI 授权勾上的行不再套用用户选中行的实心蓝底 + 蓝边 —— 行用虚线边框 + 中性底色(`.mem-scope-item.ai`),勾选框用虚线描边、透明底、蓝色对勾(`.mem-scope-check.on.ai .box`),一眼能看出「这条是 AI 申请来的」而不是你自己勾的。
|
|
8
|
+
- **计数口径**:输入框按钮上的数字改为「可见范围 ∪ AI 授权」的作用域数(`accessibleCount`),按钮 `title` 同步;弹窗头部「已选」也改成当前勾选数(含 AI 授权,标「待撤销」的不算)。上一版把 AI 授权排除在计数外,和实际可读作用域不一致。
|
|
9
|
+
- 测试:用例断言有 AI 授权时按钮数字为 2、已选为 2、AI 行带 `ai` class;新增 CSS 断言(虚线边框 / 中性底 / 描边勾选框)。全套 494 tests / 493 pass / 1 skipped。
|
|
10
|
+
|
|
5
11
|
## 0.25.4 — 授权撤销与列表重排都改到「保存」之后;已选计数只算可见范围
|
|
6
12
|
|
|
7
13
|
- **取消勾选只是草稿**:勾选 AI 授权的行后取消勾选,不再立刻调用 `POST /memory/api/grants`;改成标记「AI·待撤销」气泡,点「保存」时才先撤销授权、再保存可见范围。再勾回去会恢复原状。
|
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` 申请到的范围外授权**也用勾选呈现**(名称右边挂一个「AI
|
|
50
|
+
| **记忆权限** | 输入框旁的「记忆权限」按钮设置本会话可读的作用域 + 限制等级(绝对 / 普通 / 无限制);每个作用域一行就是一条设置:**勾选**表示本会话可访问,行内**【绑定】/【可读】/【可写】**控制工作区默认可见与读写权限——绑定到当前工作区后新会话默认可见,可读 / 可写独立影响工具读写;Agent 通过 `memory_scopes request` 申请到的范围外授权**也用勾选呈现**(名称右边挂一个「AI」气泡,样式与你自己勾选的行区分开),取消勾选只是草稿,**点「保存」才真正撤销**(0.25.4 起),且按钮数字 / 「已选」都把 AI 授权算进去(0.25.5 起);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
|
-
- **Agent 授权 = 勾选 + 「AI」气泡(0.25.3
|
|
100
|
+
- **Agent 授权 = 勾选 + 「AI」气泡(0.25.3 – 0.25.5)**:作用域行就是「勾选该作用域 + 【绑定】/【可读】/【可写】」这一组控件,不再有独立的「Agent 授权」行与浮窗上方的解释文本。Agent 通过 `memory_scopes request` 审批得到的授权直接体现为该作用域的**勾选**,名称右边挂「AI」气泡(`title` 写明只读 / 可写);**AI 授权的行用自己的样式**——虚线边框 + 中性底色,勾选框是虚线描边(透明底、蓝勾),不会和你自己勾选的实心蓝底行混淆。**取消勾选只是草稿**——气泡改标「AI·待撤销」,**点「保存」才真正撤销**(保存时先 `POST /grants` 撤销,再保存可见范围),Agent 下一次 pre-step 收到「记忆权限已更新」。**计数**:输入框按钮上的数字与弹窗头部「已选」都是「可见范围 ∪ AI 授权」的作用域数,AI 授权算进去。继承自父会话的授权标「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
|
@@ -522,10 +522,16 @@ window.__ModuleLoader__.load({
|
|
|
522
522
|
'.mem-scope-item{display:flex;flex-direction:column;gap:4px;padding:5px 6px;border:1px solid transparent;border-radius:10px}',
|
|
523
523
|
'.mem-scope-item:hover{background:var(--dsw-alias-interactive-bg-hover)}',
|
|
524
524
|
'.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)}',
|
|
525
|
+
// 0.25.5:AI 授权的勾选与用户自己勾选要能一眼分开 —— 行用虚线边框 + 中性底,
|
|
526
|
+
// 勾选框用描边(虚线、透明底、蓝勾),不再套用用户选中的实心蓝底。
|
|
527
|
+
'.mem-scope-item.ai{border-style:dashed;border-color:color-mix(in srgb,var(--dsw-alias-state-business-primary,#4176e6) 32%,var(--dsw-alias-border-l1));background:color-mix(in srgb,var(--dsw-alias-label-primary) 3%,transparent)}',
|
|
528
|
+
'.mem-scope-item.ai:hover{background:var(--dsw-alias-interactive-bg-hover)}',
|
|
529
|
+
'.mem-scope-check.ai .box{background:transparent}',
|
|
525
530
|
'.mem-scope-row{display:flex;align-items:center;gap:8px}',
|
|
526
531
|
'.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}',
|
|
527
532
|
'.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}',
|
|
528
533
|
'.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)}',
|
|
534
|
+
'.mem-scope-check.on.ai .box{background:transparent;border-style:dashed;border-color:color-mix(in srgb,var(--dsw-alias-state-business-primary,#4176e6) 72%,var(--dsw-alias-border-l1));color:var(--dsw-alias-state-business-primary,#4176e6)}',
|
|
529
535
|
'.mem-scope-check:focus-visible{outline:1px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}',
|
|
530
536
|
'.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}',
|
|
531
537
|
'.mem-scope-label:hover{color:var(--dsw-alias-brand-primary);border:none}',
|
|
@@ -4872,9 +4878,6 @@ window.__ModuleLoader__.load({
|
|
|
4872
4878
|
const hasOverride = override !== null
|
|
4873
4879
|
const effectiveConfig = override
|
|
4874
4880
|
?? (data && data.effective && typeof data.effective === 'object' && !Array.isArray(data.effective) ? data.effective : null)
|
|
4875
|
-
const effectiveCount = effectiveConfig && Array.isArray(effectiveConfig.scopes)
|
|
4876
|
-
? effectiveConfig.scopes.length
|
|
4877
|
-
: (data && Array.isArray(data.defaults) ? data.defaults.length : 0)
|
|
4878
4881
|
const selectedCount = catalog.filter((item) => entries[item.scope]).length
|
|
4879
4882
|
const needle = search.trim().toLowerCase()
|
|
4880
4883
|
// 0.25.4:Agent 授权的结果用勾选呈现 —— 勾选 = 本会话可访问,授权来的作用域
|
|
@@ -4943,7 +4946,22 @@ window.__ModuleLoader__.load({
|
|
|
4943
4946
|
const sourceText = data && data.source === 'inherited'
|
|
4944
4947
|
? '继承自父会话'
|
|
4945
4948
|
: hasOverride ? '本会话已设置' : '本会话使用默认'
|
|
4946
|
-
|
|
4949
|
+
// 0.25.5:按钮数字 = 可见范围 ∪ AI 授权(AI 授权也是本会话能读的作用域,算进去)。
|
|
4950
|
+
const effectiveScopeKeys = effectiveConfig && Array.isArray(effectiveConfig.scopes)
|
|
4951
|
+
? effectiveConfig.scopes
|
|
4952
|
+
.map((rule) => (typeof rule === 'string' ? rule : rule && typeof rule.scope === 'string' ? rule.scope : ''))
|
|
4953
|
+
.filter((scope) => scope !== '')
|
|
4954
|
+
: (data && Array.isArray(data.defaults) ? data.defaults.filter((scope) => typeof scope === 'string') : [])
|
|
4955
|
+
const accessibleCount = new Set([
|
|
4956
|
+
...effectiveScopeKeys,
|
|
4957
|
+
...grantList.filter((grant) => grant && typeof grant.scope === 'string' && grant.scope !== '')
|
|
4958
|
+
.map((grant) => grant.scope),
|
|
4959
|
+
]).size
|
|
4960
|
+
// 弹窗头部的「已选」= 当前勾选数(含 AI 授权的勾选;标了待撤销的不算)。
|
|
4961
|
+
const orphanChecked = grantList.filter((grant) => grant && typeof grant.scope === 'string'
|
|
4962
|
+
&& grant.scope !== '' && !catalogScopes.has(grant.scope) && !pendingRevoke[grant.scope]).length
|
|
4963
|
+
const checkedCount = catalog.filter((item) => isChecked(item.scope)).length + orphanChecked
|
|
4964
|
+
const scopeCountText = `${accessibleCount} 个作用域`
|
|
4947
4965
|
return h('span', { className: 'mem-scope-wrap', ref: wrapRef },
|
|
4948
4966
|
h('button', {
|
|
4949
4967
|
type: 'button',
|
|
@@ -4955,13 +4973,13 @@ window.__ModuleLoader__.load({
|
|
|
4955
4973
|
onClick: toggle,
|
|
4956
4974
|
},
|
|
4957
4975
|
h(NavLineIcon, { size: 14 }),
|
|
4958
|
-
data === null ? null : h('span', null, String(
|
|
4976
|
+
data === null ? null : h('span', null, String(accessibleCount)),
|
|
4959
4977
|
),
|
|
4960
4978
|
open ? h('div', { className: 'mem-scope-pop', style: popStyle, role: 'dialog', 'aria-label': '记忆权限' },
|
|
4961
4979
|
h('div', { className: 'mem-scope-head' },
|
|
4962
4980
|
h('h4', null, '记忆权限'),
|
|
4963
4981
|
h('span', { className: 'spacer' }),
|
|
4964
|
-
h('span', { className: 'mem-scope-count' }, `已选 ${
|
|
4982
|
+
h('span', { className: 'mem-scope-count' }, `已选 ${checkedCount}`),
|
|
4965
4983
|
),
|
|
4966
4984
|
data && data.inherited
|
|
4967
4985
|
? h('div', { className: 'hint' }, '当前继承自父会话;保存后在本会话独立生效。')
|
|
@@ -5000,13 +5018,15 @@ window.__ModuleLoader__.load({
|
|
|
5000
5018
|
const item = row.item
|
|
5001
5019
|
const grant = item ? grantsByScope.get(row.scope) : row.grant
|
|
5002
5020
|
const checked = isChecked(row.scope)
|
|
5003
|
-
|
|
5021
|
+
// 只靠 AI 授权才勾上的行加 .ai:样式与用户自己勾选的行区分开。
|
|
5022
|
+
const aiOnly = Boolean(grant) && !entries[row.scope]
|
|
5023
|
+
return h('div', { className: `mem-scope-item${checked ? ' on' : ''}${aiOnly ? ' ai' : ''}`, key: row.scope },
|
|
5004
5024
|
h('div', { className: 'mem-scope-row' },
|
|
5005
5025
|
h('button', {
|
|
5006
5026
|
type: 'button',
|
|
5007
5027
|
role: 'checkbox',
|
|
5008
5028
|
'aria-checked': checked,
|
|
5009
|
-
className: `mem-scope-check${checked ? ' on' : ''}`,
|
|
5029
|
+
className: `mem-scope-check${checked ? ' on' : ''}${aiOnly ? ' ai' : ''}`,
|
|
5010
5030
|
onClick: () => toggleScope(row.scope),
|
|
5011
5031
|
'aria-label': checked ? '取消选择' : '选择',
|
|
5012
5032
|
title: grant
|