@restregular/dsh-memory 0.25.8 → 0.25.9
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 +8 -0
- package/README.md +1 -0
- package/lib/client.js +27 -7
- package/lib/panel.js +9 -6
- package/lib/provider/scope.js +19 -0
- package/lib/tools/apply.js +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
本项目的版本记录。安装 id 与 npm 版本一一对应。
|
|
4
4
|
|
|
5
|
+
## 0.25.9 — 会话作用域的短 id 改成前 16 位(以前全显示成「会话 session-」)
|
|
6
|
+
|
|
7
|
+
- **问题**:真机会话 id 以 `session-` 开头,那正好是 8 个字符。以前展示会话作用域时取「id 前 8 位」,于是每个会话作用域都渲染成同一个「会话 session-」——用户无法区分是哪个会话,等于没给 id。
|
|
8
|
+
- **口径**:统一改成会话 id 的**前 16 位**,形如 `会话 session-1a2b3c4d`;有会话标题时是 `标题(session-1a2b3c4d)`。规则集中在 `memory-local` 的 `sessionShortId` / `sessionScopeLabel`,服务端与客户端同口径。
|
|
9
|
+
- **覆盖范围**(凡是显示会话作用域名字的地方):`/status` 的 label(面板作用域下拉、记录卡与记忆树)、审计页的会话筛选选项与悬停提示、审计页锁定会话的 pill、以及 `memory_save` / `memory_search` / `memory_list` / `memory_get` / `memory_scopes` 的工具输出。
|
|
10
|
+
- **保持不变**:「记忆权限」浮窗里本会话那一行仍是「当前会话」(0.25.8),标签里的裸 scope 键仍留在 `title`;注入摘要里的 scope 分类标签仍是「会话」(那是分类不是名字)。
|
|
11
|
+
- 测试:新增 `sessionShortId` / `sessionScopeLabel` 的单测(含 `session-` 前缀的真实 id、两个会话必须不同名、异常输入不抛错)、`/status` 真实前缀 id 的回退标签用例、以及客户端 helper 用例;改写三个受口径影响的既有断言。全套 502 tests / 501 pass / 1 skipped。
|
|
12
|
+
|
|
5
13
|
## 0.25.8 — 记忆权限浮窗不再被「回到底部」按钮盖住;本会话作用域叫「当前会话」
|
|
6
14
|
|
|
7
15
|
- **层级修正(浮窗曾被「回到底部」圆钮压住)**:宿主会话在 active 阶段给输入框所在的 composer seat 上了 `position:sticky + z-index:7`,那是一个独立的层叠上下文;浮窗写在它里面,`position:fixed` 也只在那个上下文里比较层级,永远压不过兄弟层 z-index:8 的「回到底部」按钮。现在浮窗通过 `react-dom` 的 `createPortal` 挂到 `document.body`,直接参与根层叠上下文的排序;`z-index` 从 80 提到 900(会话里的浮动件都在 100 以内,宿主自己的对话框 / 提示层是 1000 起,所以压得过前者、盖不住后者)。拿不到 `react-dom` 的宿主退回原地渲染,功能一致。
|
package/README.md
CHANGED
|
@@ -92,6 +92,7 @@ JSONL 落盘 · 本机向量检索 · 五个模型工具 · 自动召回 · 硬
|
|
|
92
92
|
|
|
93
93
|
- **默认范围**:没有显式设置时(新会话)按默认设置生效 —— **当前会话 + 当前项目 + global + 已绑定的作用域** + **普通限制**;面板按同一份默认范围预选,不会出现空面板。
|
|
94
94
|
- **本会话那一行的名字**(0.25.8):本会话 `session:<id>` 那一行固定显示「**当前会话**」(原始 scope 键在 `title` 里),别的会话的 scope 仍按标题 / 短 id 显示;搜索也按显示名匹配,输入「当前会话」即可筛到这一行。
|
|
95
|
+
- **会话作用域的短 id**(0.25.9):凡是显示会话作用域名字的地方(面板作用域下拉、记录卡与记忆树、审计页的会话筛选与提示、`memory_*` 工具输出、`/status` 的 label)都取会话 id 的**前 16 位**,形如 `会话 session-1a2b3c4d`。以前取前 8 位,而真机会话 id 恰好以 `session-` 开头(正好 8 个字符),结果所有会话作用域都显示成同一个「会话 session-」——等于没给 id。有会话标题时形如 `标题(session-1a2b3c4d)`。
|
|
95
96
|
- **搜索与批量**:顶部可搜索作用域,支持「全选 / 取消全选」;列表最大高度受限,作用域多时在浮窗内滚动。**整张作用域卡片都能点**(0.25.7 起)——点名称、记录数或行内留白等同点勾选框,只有行内的按钮(勾选框 / 绑定 / 可读 / 可写)各管各的,点它们不会再多切换一次。
|
|
96
97
|
- **浮窗层级**(0.25.8):浮窗 portal 到 `document.body` 渲染,`z-index:900`,不会再被会话里的「回到底部」圆钮(z-index:8)之类浮动件盖住;同时仍低于宿主自己的对话框 / 提示层(1000 起)。
|
|
97
98
|
- **状态按钮(0.23.0 / 0.23.1)**:作用域列表每行有【绑定】、【可读】|【可写】。**默认范围自带的会话 + 项目 + global 显示为已绑定且不可取消**;**绑定**按钮用于把其它作用域额外并入当前工作区的默认范围(没有显式覆盖的新会话可见);**可读 / 可写**是会话级,独立控制该作用域的读取与写入(关掉可读 → 搜索 / 读取跳过并说明原因;关掉可写 → 保存 / 删除被拒绝并说明原因)。
|
package/lib/client.js
CHANGED
|
@@ -674,6 +674,22 @@ window.__ModuleLoader__.load({
|
|
|
674
674
|
return rec && rec.expiredAt !== null && rec.expiredAt !== undefined && Number(rec.expiredAt) < Date.now()
|
|
675
675
|
}
|
|
676
676
|
|
|
677
|
+
/**
|
|
678
|
+
* 会话 id → 展示用的短 id(前 16 位,如 `session-1a2b3c4d`)。
|
|
679
|
+
*
|
|
680
|
+
* 为什么是 16 而不是 8:DSH 的会话 id 以 `session-` 开头 —— 正好 8 个字符。
|
|
681
|
+
* 取前 8 位会让所有会话作用域都显示成「会话 session-」,等于没给 id。
|
|
682
|
+
* 服务端 memory-local 的 sessionShortId / sessionScopeLabel 是同一口径。
|
|
683
|
+
*/
|
|
684
|
+
const SESSION_SHORT_ID_CHARS = 16
|
|
685
|
+
function sessionShortId(sessionId) {
|
|
686
|
+
return String(sessionId === null || sessionId === undefined ? '' : sessionId).slice(0, SESSION_SHORT_ID_CHARS)
|
|
687
|
+
}
|
|
688
|
+
/** 会话 scope 键(`session:<id>`)→「会话 + 前 16 位 id」。 */
|
|
689
|
+
function sessionScopeLabel(scope) {
|
|
690
|
+
return `会话 ${sessionShortId(String(scope).slice('session:'.length))}`
|
|
691
|
+
}
|
|
692
|
+
|
|
677
693
|
/**
|
|
678
694
|
* scope 键 → 展示标签。优先用 /status 返回的 `label`(服务端能查会话标题、能解析
|
|
679
695
|
* project 的 cwd);服务端没给(旧 provider / 还没加载到)时用本地回退。
|
|
@@ -683,7 +699,7 @@ window.__ModuleLoader__.load({
|
|
|
683
699
|
if (typeof mapped === 'string' && mapped.length > 0) return mapped
|
|
684
700
|
if (scope === 'global') return '全局'
|
|
685
701
|
if (scope.startsWith('project:')) return scope.slice(8)
|
|
686
|
-
if (scope.startsWith('session:')) return
|
|
702
|
+
if (scope.startsWith('session:')) return sessionScopeLabel(scope)
|
|
687
703
|
return scope
|
|
688
704
|
}
|
|
689
705
|
|
|
@@ -3025,11 +3041,11 @@ window.__ModuleLoader__.load({
|
|
|
3025
3041
|
const writeErrors = stats && typeof stats.writeErrors === 'number' ? stats.writeErrors : 0
|
|
3026
3042
|
const sessionOptions = [{ value: '', label: '全部会话(显式)' }]
|
|
3027
3043
|
.concat((scopes || []).filter((scope) => scope.scope?.startsWith('session:')).map((scope) => ({
|
|
3028
|
-
value: scope.scope.slice(
|
|
3029
|
-
label: scope.label ||
|
|
3044
|
+
value: scope.scope.slice('session:'.length),
|
|
3045
|
+
label: scope.label || sessionScopeLabel(scope.scope),
|
|
3030
3046
|
})))
|
|
3031
3047
|
if (effectiveSession && !sessionOptions.some((item) => item.value === effectiveSession)) {
|
|
3032
|
-
sessionOptions.push({ value: effectiveSession, label:
|
|
3048
|
+
sessionOptions.push({ value: effectiveSession, label: sessionScopeLabel(`session:${effectiveSession}`) })
|
|
3033
3049
|
}
|
|
3034
3050
|
const channelOptions = [{ value: '', label: '全部通道' }].concat(Object.keys(AUDIT_CHANNEL_META).map((key) => ({ value: key, label: AUDIT_CHANNEL_META[key] })))
|
|
3035
3051
|
const outcomeOptions = [{ value: '', label: '全部结果' }].concat(Object.keys(AUDIT_OUTCOME_META).map((key) => ({ value: key, label: AUDIT_OUTCOME_META[key].label })))
|
|
@@ -3070,7 +3086,7 @@ window.__ModuleLoader__.load({
|
|
|
3070
3086
|
const toolbar = h('div', { className: 'audit-toolbar' },
|
|
3071
3087
|
h('div', { className: 'audit-filter-row' },
|
|
3072
3088
|
lockSession
|
|
3073
|
-
? h('span', { className: 'audit-pill mute', title: lockSession },
|
|
3089
|
+
? h('span', { className: 'audit-pill mute', title: lockSession }, sessionScopeLabel(`session:${lockSession}`))
|
|
3074
3090
|
: h(Dropdown, {
|
|
3075
3091
|
items: sessionOptions, value: session, disabled: loading,
|
|
3076
3092
|
onChange: (next) => { setSession(next); writeAuditSession(next); resetAndReload() },
|
|
@@ -3383,11 +3399,11 @@ window.__ModuleLoader__.load({
|
|
|
3383
3399
|
const tipNode = tip === null ? null : (() => {
|
|
3384
3400
|
if (tip.type === 'session') {
|
|
3385
3401
|
const summary = tip.summary || {}
|
|
3386
|
-
const title = summary.title || summary.name ||
|
|
3402
|
+
const title = summary.title || summary.name || sessionScopeLabel(`session:${tip.id}`)
|
|
3387
3403
|
return h('div', { className: 'audit-tip', style: { left: tip.x, top: tip.y }, onMouseEnter: cancelHideTip, onMouseLeave: hideTip, onClick: () => openSessionId(tip.id) },
|
|
3388
3404
|
h('div', { className: 'audit-tip-head' }, h('span', null, '会话'), h('span', { className: 'audit-tip-title' }, title)),
|
|
3389
3405
|
h('div', { className: 'audit-tip-meta' },
|
|
3390
|
-
auditPill(
|
|
3406
|
+
auditPill(`${sessionShortId(tip.id)}…`, 'mute'),
|
|
3391
3407
|
summary.running === true ? auditPill('运行中', 'ok') : null,
|
|
3392
3408
|
summary.archived === true ? auditPill('已归档', 'warn') : null,
|
|
3393
3409
|
),
|
|
@@ -5768,6 +5784,10 @@ window.__ModuleLoader__.load({
|
|
|
5768
5784
|
requestRecordFocus: requestRecordFocus,
|
|
5769
5785
|
takeRecordFocus: takeRecordFocus,
|
|
5770
5786
|
buildMemoryTree: buildMemoryTree,
|
|
5787
|
+
// 会话作用域展示名:取会话 id 前 16 位(前 8 位恒为 `session-`)
|
|
5788
|
+
sessionShortId: sessionShortId,
|
|
5789
|
+
sessionScopeLabel: sessionScopeLabel,
|
|
5790
|
+
scopeLabel: scopeLabel,
|
|
5771
5791
|
KIND_META: KIND_META,
|
|
5772
5792
|
CSS: CSS,
|
|
5773
5793
|
shouldPollInstall: shouldPollInstall,
|
package/lib/panel.js
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
// scope 规范化与 provider 共用同一份实现。路径按**源码树位置**写:构建脚本的改写表
|
|
28
28
|
// 会把它落成产物里的 `../provider/scope.js`(`lib/panel.js` → `lib/provider/scope.js`),
|
|
29
29
|
// 在源码树里同一路径直接命中 source/memory-local/src —— 测试与真实加载都能解析。
|
|
30
|
-
import { normalizeScopeInput, resolveCurrentScopes } from './provider/scope.js'
|
|
30
|
+
import { normalizeScopeInput, resolveCurrentScopes, sessionScopeLabel, sessionShortId } from './provider/scope.js'
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
function writeJson(res, body, status = 200) {
|
|
@@ -144,13 +144,16 @@ async function readJsonBody(req) {
|
|
|
144
144
|
* scope 键 → **不需要查宿主服务**的展示标签。
|
|
145
145
|
* global → 「全局」
|
|
146
146
|
* project:<cwd> → cwd
|
|
147
|
-
* session:<id> → 「会话 <id 前
|
|
147
|
+
* session:<id> → 「会话 <id 前 16 位>」(如 `会话 session-1a2b3c4d`)
|
|
148
148
|
* 其他 → 原名(自定义 scope)
|
|
149
|
+
*
|
|
150
|
+
* 16 位而不是 8 位:会话 id 以 `session-` 开头(正好 8 个字符),取 8 位会让所有会话
|
|
151
|
+
* 作用域都显示成「会话 session-」。规则集中在 provider 的 sessionScopeLabel。
|
|
149
152
|
*/
|
|
150
153
|
function fallbackScopeLabel(scope) {
|
|
151
154
|
if (scope === 'global') return '全局'
|
|
152
155
|
if (scope.startsWith('project:')) return scope.slice('project:'.length)
|
|
153
|
-
if (scope.startsWith('session:')) return
|
|
156
|
+
if (scope.startsWith('session:')) return sessionScopeLabel(scope)
|
|
154
157
|
return scope
|
|
155
158
|
}
|
|
156
159
|
|
|
@@ -162,7 +165,7 @@ function fallbackScopeLabel(scope) {
|
|
|
162
165
|
function scopeLabel(ctx, scope) {
|
|
163
166
|
if (!scope.startsWith('session:')) return fallbackScopeLabel(scope)
|
|
164
167
|
const id = scope.slice('session:'.length)
|
|
165
|
-
const short = id
|
|
168
|
+
const short = sessionShortId(id)
|
|
166
169
|
try {
|
|
167
170
|
const session = ctx?.get?.('sessions')?.get?.(id)
|
|
168
171
|
if (session !== undefined) {
|
|
@@ -170,7 +173,7 @@ function scopeLabel(ctx, scope) {
|
|
|
170
173
|
if (typeof title === 'string' && title.length > 0) return `${title}(${short})`
|
|
171
174
|
}
|
|
172
175
|
} catch { /* 标题是尽力而为 */ }
|
|
173
|
-
return
|
|
176
|
+
return sessionScopeLabel(scope)
|
|
174
177
|
}
|
|
175
178
|
|
|
176
179
|
/** 会话 scope 查标题的上限:标题要读会话事件日志,scope 多了它就成了 /status 的大头。 */
|
|
@@ -835,7 +838,7 @@ async function handle(ctx, routePath, req, res) {
|
|
|
835
838
|
? memory.scopeStats()
|
|
836
839
|
: store.allScopes().map((s) => ({ scope: s.scope, records: s.records.size, pendingEmbeds: s.embedPending.size }))
|
|
837
840
|
// 会话标题是尽力而为的增强,而且要读会话事件日志:只给最近活跃的前 N 个查,
|
|
838
|
-
// 其余直接用「会话 <id 前
|
|
841
|
+
// 其余直接用「会话 <id 前 16 位>」。列表本身**始终**完整(不受这个上限影响)。
|
|
839
842
|
const scopes = stats.map((s, index) => ({
|
|
840
843
|
...s,
|
|
841
844
|
label: s.name ?? (index < TITLE_LOOKUP_LIMIT ? scopeLabel(ctx, s.scope) : fallbackScopeLabel(s.scope)),
|
package/lib/provider/scope.js
CHANGED
|
@@ -183,6 +183,25 @@ export function scopeTier(scope ) {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
/** 会话 id 的展示长度。 */
|
|
187
|
+
export const SESSION_SHORT_ID_CHARS = 16
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* 会话 id → 展示用的短 id(前 16 位,如 `session-1a2b3c4d`)。
|
|
191
|
+
*
|
|
192
|
+
* 为什么是 16 而不是 8:DSH 的会话 id 以 `session-` 开头 —— 那正好是 8 个字符。
|
|
193
|
+
* 取前 8 位会让**所有**会话作用域显示成同一个「会话 session-」,等于没给 id。
|
|
194
|
+
* 16 位 = `session-` + 8 位 uuid,既短又能区分。
|
|
195
|
+
*/
|
|
196
|
+
export function sessionShortId(sessionId ) {
|
|
197
|
+
return String(sessionId ?? '').slice(0, SESSION_SHORT_ID_CHARS)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** 会话 scope 键(`session:<id>`)→ 「会话 + 前 16 位 id」的展示名。 */
|
|
201
|
+
export function sessionScopeLabel(scope ) {
|
|
202
|
+
return `会话 ${sessionShortId(scope.slice('session:'.length))}`
|
|
203
|
+
}
|
|
204
|
+
|
|
186
205
|
/** 写路径遇到只读 scope 时的错误码('all' 不能写)。 */
|
|
187
206
|
export const SCOPE_NOT_WRITABLE = 'SCOPE_NOT_WRITABLE'
|
|
188
207
|
|
package/lib/tools/apply.js
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
|
|
22
22
|
} from './index.js'
|
|
23
23
|
import { renderGetResult, renderListResult, renderScopesResult, renderSearchResult } from './render.js'
|
|
24
|
-
import { resolveCurrentScopes, scopeKind, } from '../provider/scope.js'
|
|
24
|
+
import { resolveCurrentScopes, scopeKind, sessionScopeLabel, sessionShortId, } from '../provider/scope.js'
|
|
25
25
|
|
|
26
26
|
export const name = 'dsh-tool-memory'
|
|
27
27
|
export const inject = ['tools', 'memory']
|
|
@@ -91,14 +91,14 @@ export function apply(ctx , config = {}) {
|
|
|
91
91
|
/**
|
|
92
92
|
* scope 键 → 展示标签。会话标题只有宿主服务能给:`ctx.get('sessionTitle')` 的 `get(session)`
|
|
93
93
|
* 返回 `{ title }`(见 @deepseek-ai/dsh-session-title)。整套访问都在 try/catch 里 ——
|
|
94
|
-
* 旧宿主没有这个服务、会话已经不在内存里,都不能影响工具结果,回退成"会话 <id 前
|
|
94
|
+
* 旧宿主没有这个服务、会话已经不在内存里,都不能影响工具结果,回退成"会话 <id 前 16 位>"。
|
|
95
95
|
*/
|
|
96
96
|
const labelFor = (scope , agent ) => {
|
|
97
97
|
if (scope === 'global') return '全局'
|
|
98
98
|
if (scope.startsWith('project:')) return scope.slice('project:'.length)
|
|
99
99
|
if (scope.startsWith('session:')) {
|
|
100
100
|
const id = scope.slice('session:'.length)
|
|
101
|
-
const short = id
|
|
101
|
+
const short = sessionShortId(id)
|
|
102
102
|
try {
|
|
103
103
|
const session = (agent )?.session
|
|
104
104
|
if (session?.id === id) {
|
|
@@ -108,7 +108,7 @@ export function apply(ctx , config = {}) {
|
|
|
108
108
|
if (typeof title === 'string' && title.length > 0) return `${title}(${short})`
|
|
109
109
|
}
|
|
110
110
|
} catch { /* 拿不到标题就用短 id */ }
|
|
111
|
-
return
|
|
111
|
+
return sessionScopeLabel(scope)
|
|
112
112
|
}
|
|
113
113
|
return scope
|
|
114
114
|
}
|