@restregular/dsh-memory 0.14.5 → 0.14.7
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 +14 -0
- package/README.md +1 -2
- package/lib/client.js +26 -6
- package/lib/inject/apply.js +18 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
本项目的版本记录。安装 id 与 npm 版本一一对应。
|
|
4
4
|
|
|
5
|
+
## 0.14.7 — memory_search / 无 description 的工具不再触发自动召回
|
|
6
|
+
|
|
7
|
+
- **根因**:`tool/call` 的高风险召回信号不看 `description` 是否存在,直接把工具名 + 参数拼进匹配文本。`memory_search` 的 `query` 一旦含标签(包括默认的记忆标签),就会排队一次 `before_high_risk_tool` 信号;下一步强制召回,和已经注入的摘要/正文重复。
|
|
8
|
+
- **修复**:只有带非空 `description` 的工具调用才允许触发高风险召回;`memory_*` 工具一律跳过(它本身就在读记忆)。工具失败信号保持原行为,不受此限制。
|
|
9
|
+
- 记忆工具调用仍保留一条 `stage: tool_call` 的审计锚点,只用于轨迹关联,**不会排队召回**。
|
|
10
|
+
- 回归测试:`memory_search`、无 `description` 的 `write` / `ops_bash` 都不产生 `signal_queued`;`memory_search` 的轨迹锚点仍在。
|
|
11
|
+
|
|
12
|
+
## 0.14.6 — 审计记忆 ID 跳转后自动展开并滚到目标记录
|
|
13
|
+
|
|
14
|
+
- **现象**:在审计详情里点某个记忆 ID,会切到记录页,但目标记录没有展开,看起来像没跳成功。
|
|
15
|
+
- **原因**:`openRecord` 只设置了 `focusRecord`,没有把目标记录滚进可视区;目标记录如果不在当前筛选/已加载结果里,列表里甚至没有这张卡,自然也无法展开。
|
|
16
|
+
- **修复**:`RecordCard` 在 `focus` 时先展开,再用 `scrollIntoView({block:'center'})` 把卡片滚到视口中央;`openRecord` 同时接收记录对象,目标不在当前列表时把它补到列表最前面,保证跳过去一定能看到并展开。
|
|
17
|
+
- 回归测试:带 `focus` 的记录卡自动展开。
|
|
18
|
+
|
|
5
19
|
## 0.14.5 — 修复记忆面板审计「在轨迹中定位」不生效
|
|
6
20
|
|
|
7
21
|
- **根因**:主面板把 `jumpAuditEntryToTrajectory`(签名是 `(entry) => Promise`)当成 `openTrajectory(focus)` 回调传给 `AuditTab`。按钮把 `callId` 字符串传进去,`jumpAuditEntryToTrajectory` 读不到 `entry.sessionId`,直接按 `no_session` 返回,实际什么都没发生;UI 还误报“已定位到轨迹”。
|
package/README.md
CHANGED
|
@@ -200,8 +200,7 @@ memory_forget({ "id": "3f2a9c1d" }) // 按内容删:memory_forget({ q
|
|
|
200
200
|
| 行为召回 | 可见文本 / 任务 / 命令 / 工具失败 | 命中标签后,在**下一个** `agent/pre-step` 定向检索;工具失败优先用该工具自己的 description |
|
|
201
201
|
|
|
202
202
|
行为召回只检索 **global + 当前会话 + 当前工作区**,不把自定义作用域或 fork 父会话带进来。
|
|
203
|
-
匹配源包括可见 assistant 文本、todo、`command/run`、`goal/change
|
|
204
|
-
name / description / 参数,以及工具失败描述;**不读取隐藏思维链**。
|
|
203
|
+
匹配源包括可见 assistant 文本、todo、`command/run`、`goal/change`、带 `description` 的 `tool/call`,以及工具失败描述;**没有 `description` 的工具调用不触发**,`memory_*` 工具一律不触发(`memory_search` 本身在取记忆,再召回一次只会重复注入)。**不读取隐藏思维链**。
|
|
205
204
|
|
|
206
205
|
### 规则会跟进旧会话
|
|
207
206
|
|
package/lib/client.js
CHANGED
|
@@ -796,7 +796,18 @@ window.__ModuleLoader__.load({
|
|
|
796
796
|
const [copied, setCopied] = React.useState(false)
|
|
797
797
|
|
|
798
798
|
// 从审计页点 memory ID 跳过来时自动展开目标记录。
|
|
799
|
-
|
|
799
|
+
// 记录列表可能很长,展开后还要把它滚进视口,否则用户看到的是列表顶部。
|
|
800
|
+
const cardRef = React.useRef(null)
|
|
801
|
+
React.useEffect(() => {
|
|
802
|
+
if (!focus) return undefined
|
|
803
|
+
setExpanded(true)
|
|
804
|
+
const node = cardRef.current
|
|
805
|
+
if (node === null || typeof node.scrollIntoView !== 'function') return undefined
|
|
806
|
+
const timer = setTimeout(() => {
|
|
807
|
+
try { node.scrollIntoView({ block: 'center', behavior: 'smooth' }) } catch { /* 滚动失败不影响展开 */ }
|
|
808
|
+
}, 60)
|
|
809
|
+
return () => clearTimeout(timer)
|
|
810
|
+
}, [focus])
|
|
800
811
|
|
|
801
812
|
const copyId = () => {
|
|
802
813
|
try {
|
|
@@ -837,7 +848,7 @@ window.__ModuleLoader__.load({
|
|
|
837
848
|
setTags(rec.tags.join(', ')); setImportance(rec.importance)
|
|
838
849
|
}
|
|
839
850
|
|
|
840
|
-
return h('div', { className: 'rec' + (focus ? ' focus' : '') },
|
|
851
|
+
return h('div', { className: 'rec' + (focus ? ' focus' : ''), ref: cardRef },
|
|
841
852
|
h('div', {
|
|
842
853
|
className: 'rec-head',
|
|
843
854
|
role: 'button',
|
|
@@ -2687,7 +2698,7 @@ window.__ModuleLoader__.load({
|
|
|
2687
2698
|
const openMemoryId = async (id) => {
|
|
2688
2699
|
const record = findRecord(id) || await fetchRecord(id)
|
|
2689
2700
|
hideTip()
|
|
2690
|
-
if (typeof openRecord === 'function') openRecord(record?.id ?? id, record?.scope)
|
|
2701
|
+
if (typeof openRecord === 'function') openRecord(record?.id ?? id, record?.scope, record)
|
|
2691
2702
|
}
|
|
2692
2703
|
const openSessionId = (id) => {
|
|
2693
2704
|
hideTip()
|
|
@@ -3155,6 +3166,7 @@ window.__ModuleLoader__.load({
|
|
|
3155
3166
|
const [semantic, setSemantic] = React.useState(false)
|
|
3156
3167
|
const [searchInfo, setSearchInfo] = React.useState(null)
|
|
3157
3168
|
const [focusRecord, setFocusRecord] = React.useState(null)
|
|
3169
|
+
const [focusRecordData, setFocusRecordData] = React.useState(null)
|
|
3158
3170
|
const [loading, setLoading] = React.useState(true)
|
|
3159
3171
|
const [error, setError] = React.useState('')
|
|
3160
3172
|
const [tab, setTab] = React.useState('data')
|
|
@@ -3212,8 +3224,11 @@ window.__ModuleLoader__.load({
|
|
|
3212
3224
|
React.useEffect(() => { load('', '') }, [])
|
|
3213
3225
|
|
|
3214
3226
|
/** 审计里的记忆 ID → 切到「记录」页并展开对应记录。 */
|
|
3215
|
-
const openRecord = (id, scope) => {
|
|
3227
|
+
const openRecord = (id, scope, record = null) => {
|
|
3216
3228
|
setFocusRecord(id)
|
|
3229
|
+
// 目标记录可能不在当前筛选结果里(作用域/搜索/分页),先把它拿在手上,
|
|
3230
|
+
// 列表里没有时补一张卡,保证跳过去一定能展开。
|
|
3231
|
+
setFocusRecordData(record && record.id ? record : null)
|
|
3217
3232
|
setTab('data')
|
|
3218
3233
|
setQ('')
|
|
3219
3234
|
// 语义模式是按查询排名的:跳转要看到那条记录,必须回到普通列表。
|
|
@@ -3568,12 +3583,17 @@ window.__ModuleLoader__.load({
|
|
|
3568
3583
|
})
|
|
3569
3584
|
: null
|
|
3570
3585
|
const emptyText = searchInfo ? '没有语义相关的记忆' : filtering ? '没有匹配的记忆' : '还没有记忆'
|
|
3571
|
-
|
|
3586
|
+
// 从审计跳过来的目标记录如果不在当前加载结果里,先把它补到列表最前面,
|
|
3587
|
+
// 否则跳转后列表里根本没有这张卡,focus 自然也无法展开。
|
|
3588
|
+
const displayRecords = focusRecordData !== null && !records.some((rec) => rec.id === focusRecordData.id)
|
|
3589
|
+
? [focusRecordData, ...records]
|
|
3590
|
+
: records
|
|
3591
|
+
const listBody = !loading && !error && displayRecords.length === 0
|
|
3572
3592
|
? h('div', { className: 'empty' },
|
|
3573
3593
|
emptyText,
|
|
3574
3594
|
searchInfo ? h('div', { className: 'muted' }, '换个说法试试;刚写入的记录可能还没嵌入向量。') : null)
|
|
3575
3595
|
: h('div', { className: 'list' },
|
|
3576
|
-
|
|
3596
|
+
displayRecords.map((rec) => h(RecordCard, { key: rec.id, rec, score: rec.score, focus: focusRecord === rec.id, vectorOn: configured && vectorEnabled, labels: labels, onSaved: () => { setPendingTick(0); load() }, onDeleted: () => { setPendingTick(0); load() } })))
|
|
3577
3597
|
|
|
3578
3598
|
// 服务页底部:一句号召 + 两个外链(Star / issue)。放在内容最后,不打扰上面的状态卡。
|
|
3579
3599
|
const footer = h('div', { className: 'footer' },
|
package/lib/inject/apply.js
CHANGED
|
@@ -413,20 +413,27 @@ export function apply(ctx , config = {}) {
|
|
|
413
413
|
const args = typeof data.arguments === 'string'
|
|
414
414
|
? data.arguments
|
|
415
415
|
: (() => { try { return JSON.stringify(data.arguments ?? '') } catch { return '' } })()
|
|
416
|
-
|
|
416
|
+
// 工具调用必须有显式的 description 才允许触发高风险召回:
|
|
417
|
+
// 没有 description 的工具(memory_search、memory_*、以及其它不带该字段的
|
|
418
|
+
// 工具)不应该因为参数/工具名里恰好出现标签就再注入一次记忆——尤其
|
|
419
|
+
// memory_search 本身就是取记忆,再触发一次会把摘要/正文重复塞进上下文。
|
|
420
|
+
const rawDescription = toolCallDescription(data.arguments)
|
|
421
|
+
const description = auto.useToolDescription ? rawDescription : undefined
|
|
417
422
|
rememberCallMeta(data.callId, tool, description)
|
|
418
423
|
const turn = typeof data.turn === 'number' ? data.turn : undefined
|
|
419
424
|
const step = typeof data.step === 'number' ? data.step : undefined
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
425
|
+
if (!MEMORY_TOOL_NAMES.has(tool) && rawDescription !== undefined && rawDescription !== '') {
|
|
426
|
+
observeSignal(sessionId, highRiskSignal(tool, args, {
|
|
427
|
+
tags,
|
|
428
|
+
...(description !== undefined ? { description } : {}),
|
|
429
|
+
...(callId !== undefined ? { callId } : {}),
|
|
430
|
+
useToolDescription: auto.useToolDescription,
|
|
431
|
+
maxQueryChars: auto.maxQueryChars,
|
|
432
|
+
}), {
|
|
433
|
+
...(turn !== undefined ? { turn } : {}),
|
|
434
|
+
...(step !== undefined ? { step } : {}),
|
|
435
|
+
})
|
|
436
|
+
}
|
|
430
437
|
return
|
|
431
438
|
}
|
|
432
439
|
if (type === 'tool/result') {
|