@restregular/dsh-memory 0.12.2 → 0.12.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,16 @@
2
2
 
3
3
  本项目的版本记录。安装 id 与 npm 版本一一对应。
4
4
 
5
+ ## 0.12.3 — 审计页筛选与滚动布局优化
6
+
7
+ - 筛选区改为两行紧凑布局:会话/通道/结果/时间范围/搜索/仅看问题/刷新在第一行,
8
+ 触发源、自定义日期、清空筛选与导出在第二行;搜索框自适应占满剩余宽度。
9
+ - 时间范围改为自绘下拉(全部 / 15 分钟 / 1 小时 / 24 小时 / 7 天 / 30 天 / 自定义);
10
+ “仅看问题”改用与设置页一致的自绘开关,不再使用原生 checkbox/date 控件。
11
+ - 审计事件列表放入独立纵向滚动容器(`max-height: min(58vh, 620px)`,细滚动条,
12
+ `overscroll-behavior: contain`),筛选/详情区域保持固定,不再让整页随事件变长。
13
+ - 补充渲染测试:审计列表必须位于滚动容器、筛选分两行、筛选区不含原生 date/checkbox。
14
+
5
15
  ## 0.12.2 — 修复面板审计接口未转发
6
16
 
7
17
  - **根因**:审计方法加在 `LocalMemoryService` 上,但面板通过 `ctx.get('memory')` 拿到的是
package/README.md CHANGED
@@ -415,6 +415,7 @@ npm run verify # 构建到 .verify/,不落 packages/
415
415
 
416
416
  ## 更新日志
417
417
 
418
+ - **0.12.3** —— 审计页筛选改为两行紧凑布局与自绘时间范围/开关;事件列表放入独立滚动容器。
418
419
  - **0.12.2** —— 修复 `CordisMemoryService` 未转发审计方法,导致审计页显示“provider 未提供注入审计接口”;升级后需重启 DSH。
419
420
  - **0.12.1** —— 审计 v2 收尾:详情无障碍/唯一 key、JSON 导出、摘要渲染失败记录、部分注入 outcome。
420
421
  - **0.12.0** —— 注入审计 v2:评估/投递分离、失败与跳过可解释、统一脱敏、有界存储与容量统计、分页筛选 API、独立「审计」标签页与 JSON/JSONL 导出。
package/lib/client.js CHANGED
@@ -52,8 +52,8 @@ window.__ModuleLoader__.load({
52
52
  '.memp .hint{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.6}',
53
53
  '.memp .hint code,.memp .mono code{background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);border-radius:5px;padding:0 4px}',
54
54
  // 控件
55
- '.memp input[type=text],.memp select,.memp input[type=number]{background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:6px 10px;font-size:13px;outline:none}',
56
- '.memp input[type=text]:focus,.memp select:focus,.memp textarea:focus{border-color:var(--dsw-alias-brand-primary)}',
55
+ '.memp input[type=text],.memp input[type=search],.memp select,.memp input[type=number]{background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:6px 10px;font-size:13px;outline:none}',
56
+ '.memp input[type=text]:focus,.memp input[type=search]:focus,.memp select:focus,.memp textarea:focus{border-color:var(--dsw-alias-brand-primary)}',
57
57
  '.memp textarea{width:100%;box-sizing:border-box;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:6px 10px;font-size:13px;outline:none;resize:vertical;font-family:inherit}',
58
58
  '.memp button{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:5px 12px;font-size:13px;cursor:pointer;transition:border-color .12s ease,color .12s ease}',
59
59
  // hover 只改边框与文字颜色。**不要**再叠 box-shadow:那会在边框外多出一圈线
@@ -346,14 +346,26 @@ window.__ModuleLoader__.load({
346
346
  '.memp .audit-stat{border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1);padding:7px 10px;min-width:0}',
347
347
  '.memp .audit-stat b{display:block;font-size:17px;line-height:1.3;font-weight:650;font-variant-numeric:tabular-nums}',
348
348
  '.memp .audit-stat span{display:block;font-size:10.5px;color:var(--dsw-alias-label-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
349
- '.memp .audit-toolbar{display:flex;gap:6px;align-items:center;flex-wrap:wrap;padding:8px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}',
350
- '.memp .audit-toolbar input[type=text]{min-width:150px;max-width:230px;padding:4px 8px}',
351
- '.memp .audit-toolbar .dropbtn{padding:4px 9px}',
352
- '.memp .audit-toolbar label{display:inline-flex;align-items:center;gap:5px;font-size:11.5px;color:var(--dsw-alias-label-secondary);white-space:nowrap}',
353
- '.memp .audit-toolbar input[type=checkbox]{accent-color:var(--dsw-alias-brand-primary)}',
354
- '.memp .audit-split{display:grid;grid-template-columns:minmax(0,1fr);gap:10px;min-height:0}',
349
+ '.memp .audit-toolbar{display:flex;flex-direction:column;gap:7px;padding:8px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}',
350
+ '.memp .audit-filter-row{display:flex;gap:6px;align-items:center;flex-wrap:wrap;min-width:0}',
351
+ '.memp .audit-filter-row .dropbtn{padding:4px 9px}',
352
+ '.memp .audit-filter-row .spacer{flex:1;min-width:8px}',
353
+ '.memp .audit-filter-row input[type=text],.memp .audit-filter-row input[type=search]{min-width:150px;max-width:230px;padding:4px 8px}',
354
+ '.memp .audit-filter-row input.audit-search{flex:1;min-width:180px;max-width:340px}',
355
+ '.memp .audit-filter-row input.audit-trigger{max-width:240px}',
356
+ '.memp .audit-filter-row input.audit-date{width:116px;min-width:0}',
357
+ '.memp .audit-switch{display:inline-flex;align-items:center;gap:6px;font-size:11.5px;color:var(--dsw-alias-label-secondary);white-space:nowrap;padding:2px 4px;border-radius:7px}',
358
+ '.memp .audit-switch .switch{width:30px;height:16px;padding:0;flex:none}',
359
+ '.memp .audit-switch .switch .knob{width:12px;height:12px;top:2px;left:2px}',
360
+ '.memp .audit-switch .switch.on .knob{left:16px}',
361
+ '.memp .audit-filter-sub{padding-top:1px}',
362
+ '.memp .audit-range-sep{color:var(--dsw-alias-label-secondary);font-size:11px;flex:none}',
363
+ '.memp .audit-split{display:grid;grid-template-columns:minmax(0,1fr);gap:10px;min-height:0;align-items:start}',
355
364
  '.memp .audit-split.has-detail{grid-template-columns:minmax(0,1fr) minmax(300px,360px)}',
356
- '.memp .audit-list{display:flex;flex-direction:column;gap:5px;min-width:0}',
365
+ '.memp .audit-list{display:flex;flex-direction:column;gap:5px;min-width:0;max-height:min(58vh,620px);overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;padding:1px 4px 1px 1px;scrollbar-width:thin;scrollbar-color:color-mix(in srgb,var(--dsw-alias-label-secondary) 30%,transparent) transparent}',
366
+ '.memp .audit-list::-webkit-scrollbar{width:8px}',
367
+ '.memp .audit-list::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--dsw-alias-label-secondary) 28%,transparent);border-radius:999px;border:2px solid transparent;background-clip:padding-box}',
368
+ '.memp .audit-list::-webkit-scrollbar-track{background:transparent}',
357
369
  '.memp .audit-row{display:grid;grid-template-columns:64px 116px minmax(90px,1fr) 92px 104px 84px 74px;gap:8px;align-items:center;border:1px solid var(--dsw-alias-border-l1);border-radius:9px;background:var(--dsw-alias-bg-layer-1);padding:6px 9px;font-size:11.5px;cursor:pointer;text-align:left;color:inherit;width:100%}',
358
370
  '.memp .audit-row:hover{border-color:var(--dsw-alias-brand-primary)}',
359
371
  '.memp .audit-row.on{border-color:var(--dsw-alias-brand-primary);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 6%,var(--dsw-alias-bg-layer-1))}',
@@ -388,7 +400,7 @@ window.__ModuleLoader__.load({
388
400
  '.memp .audit-pager{display:flex;gap:6px;align-items:center;justify-content:flex-end;font-size:11px;color:var(--dsw-alias-label-secondary)}',
389
401
  '.memp .audit-flat{display:flex;flex-wrap:wrap;gap:4px}',
390
402
  '@media (max-width:900px){.memp .audit-split.has-detail{grid-template-columns:minmax(0,1fr)}.memp .audit-row{grid-template-columns:54px 100px minmax(80px,1fr) 70px 84px}}',
391
- '@media (max-width:620px){.memp .audit-stats{grid-template-columns:repeat(2,minmax(0,1fr))}.memp .audit-row{grid-template-columns:minmax(0,1fr) auto;gap:4px 8px}.memp .audit-row .sec{display:none}.memp .audit-toolbar input[type=text]{max-width:none;flex:1}}',
403
+ '@media (max-width:620px){.memp .audit-stats{grid-template-columns:repeat(2,minmax(0,1fr))}.memp .audit-row{grid-template-columns:minmax(0,1fr) auto;gap:4px 8px}.memp .audit-row .sec{display:none}.memp .audit-filter-row input[type=text],.memp .audit-filter-row input[type=search]{max-width:none;flex:1}.memp .audit-list{max-height:52vh}}',
392
404
  ].join('')
393
405
 
394
406
  async function api(method, body) {
@@ -2091,6 +2103,16 @@ window.__ModuleLoader__.load({
2091
2103
  * 数据全部来自 /memory/api/audit;没有数据就显示真实空状态,不补造。
2092
2104
  * 展示口径:evaluation 的“选中”不等于投递;投递看 delivery 事件的 status。
2093
2105
  */
2106
+ const AUDIT_RANGE_META = [
2107
+ { value: '', label: '全部时间', ms: null },
2108
+ { value: '15m', label: '近 15 分钟', ms: 15 * 60_000 },
2109
+ { value: '1h', label: '近 1 小时', ms: 60 * 60_000 },
2110
+ { value: '24h', label: '近 24 小时', ms: 24 * 60 * 60_000 },
2111
+ { value: '7d', label: '近 7 天', ms: 7 * 24 * 60 * 60_000 },
2112
+ { value: '30d', label: '近 30 天', ms: 30 * 24 * 60 * 60_000 },
2113
+ { value: 'custom', label: '自定义日期…', ms: null },
2114
+ ]
2115
+
2094
2116
  function AuditTab({ scopes }) {
2095
2117
  const [entries, setEntries] = React.useState([])
2096
2118
  const [stats, setStats] = React.useState(null)
@@ -2107,6 +2129,7 @@ window.__ModuleLoader__.load({
2107
2129
  const [trigger, setTrigger] = React.useState('')
2108
2130
  const [search, setSearch] = React.useState('')
2109
2131
  const [problem, setProblem] = React.useState(false)
2132
+ const [range, setRange] = React.useState('')
2110
2133
  const [since, setSince] = React.useState('')
2111
2134
  const [until, setUntil] = React.useState('')
2112
2135
  const [selectedId, setSelectedId] = React.useState(null)
@@ -2125,8 +2148,12 @@ window.__ModuleLoader__.load({
2125
2148
  else params.set('memory', needle)
2126
2149
  }
2127
2150
  if (problem) params.set('problem', '1')
2128
- if (since) params.set('since', String(new Date(`${since}T00:00:00`).getTime()))
2129
- if (until) params.set('until', String(new Date(`${until}T23:59:59.999`).getTime()))
2151
+ const rangeMeta = AUDIT_RANGE_META.find((item) => item.value === range)
2152
+ if (rangeMeta && rangeMeta.ms !== null) params.set('since', String(Date.now() - rangeMeta.ms))
2153
+ if (range === 'custom') {
2154
+ if (since) params.set('since', String(new Date(`${since}T00:00:00`).getTime()))
2155
+ if (until) params.set('until', String(new Date(`${until}T23:59:59.999`).getTime()))
2156
+ }
2130
2157
  if (cursorValue) params.set('cursor', cursorValue)
2131
2158
  params.set('limit', '50')
2132
2159
  return params
@@ -2172,6 +2199,7 @@ window.__ModuleLoader__.load({
2172
2199
  }
2173
2200
  const channelOptions = [{ value: '', label: '全部通道' }].concat(Object.keys(AUDIT_CHANNEL_META).map((key) => ({ value: key, label: AUDIT_CHANNEL_META[key] })))
2174
2201
  const outcomeOptions = [{ value: '', label: '全部结果' }].concat(Object.keys(AUDIT_OUTCOME_META).map((key) => ({ value: key, label: AUDIT_OUTCOME_META[key].label })))
2202
+ const rangeOptions = AUDIT_RANGE_META.map((item) => ({ value: item.value, label: item.label }))
2175
2203
 
2176
2204
  const exportAudit = async (format) => {
2177
2205
  setNotice('')
@@ -2202,43 +2230,71 @@ window.__ModuleLoader__.load({
2202
2230
  banner.push(h('div', { className: 'audit-banner bad', key: 'err' }, `审计写入失败 ${writeErrors} 次;面板数据可能不完整。`))
2203
2231
  }
2204
2232
 
2233
+ const filterActive = Boolean(session || channel || outcome || trigger || search || problem || range)
2205
2234
  const toolbar = h('div', { className: 'audit-toolbar' },
2206
- h(Dropdown, {
2207
- items: sessionOptions, value: session, disabled: loading,
2208
- onChange: (next) => { setSession(next); writeAuditSession(next); resetAndReload() },
2209
- }),
2210
- h(Dropdown, {
2211
- items: channelOptions, value: channel, disabled: loading,
2212
- onChange: (next) => { setChannel(next); resetAndReload() },
2213
- }),
2214
- h(Dropdown, {
2215
- items: outcomeOptions, value: outcome, disabled: loading,
2216
- onChange: (next) => { setOutcome(next); resetAndReload() },
2217
- }),
2218
- h('input', {
2219
- type: 'text', placeholder: '触发源', value: trigger, 'aria-label': '按触发源筛选',
2220
- onChange: (e) => setTrigger(e.target.value),
2221
- onKeyDown: (e) => { if (e.key === 'Enter') resetAndReload() },
2222
- }),
2223
- h('input', {
2224
- type: 'text', placeholder: '搜索 memory / trace: / op:', value: search, 'aria-label': '按 memory / trace / operation ID 搜索',
2225
- onChange: (e) => setSearch(e.target.value),
2226
- onKeyDown: (e) => { if (e.key === 'Enter') resetAndReload() },
2227
- }),
2228
- h('label', null,
2229
- h('input', { type: 'checkbox', checked: problem, onChange: (e) => { setProblem(e.target.checked); resetAndReload() } }),
2230
- '仅看问题',
2235
+ h('div', { className: 'audit-filter-row' },
2236
+ h(Dropdown, {
2237
+ items: sessionOptions, value: session, disabled: loading,
2238
+ onChange: (next) => { setSession(next); writeAuditSession(next); resetAndReload() },
2239
+ }),
2240
+ h(Dropdown, {
2241
+ items: channelOptions, value: channel, disabled: loading,
2242
+ onChange: (next) => { setChannel(next); resetAndReload() },
2243
+ }),
2244
+ h(Dropdown, {
2245
+ items: outcomeOptions, value: outcome, disabled: loading,
2246
+ onChange: (next) => { setOutcome(next); resetAndReload() },
2247
+ }),
2248
+ h(Dropdown, {
2249
+ items: rangeOptions, value: range, disabled: loading,
2250
+ onChange: (next) => { setRange(next); resetAndReload() },
2251
+ }),
2252
+ h('input', {
2253
+ type: 'search', className: 'audit-search', placeholder: '搜索 memory / trace: / op:', value: search,
2254
+ 'aria-label': '按 memory / trace / operation ID 搜索',
2255
+ onChange: (e) => setSearch(e.target.value),
2256
+ onKeyDown: (e) => { if (e.key === 'Enter') resetAndReload() },
2257
+ }),
2258
+ h('span', { className: 'audit-switch' },
2259
+ h(Switch, { checked: problem, disabled: loading, label: '仅看问题', onChange: (next) => { setProblem(next); resetAndReload() } }),
2260
+ '仅看问题',
2261
+ ),
2262
+ h('span', { className: 'spacer' }),
2263
+ h('button', { disabled: loading, onClick: () => setReloadTick((n) => n + 1) }, loading ? '刷新中…' : '刷新'),
2264
+ ),
2265
+ h('div', { className: 'audit-filter-row audit-filter-sub' },
2266
+ h('input', {
2267
+ type: 'text', className: 'audit-trigger', placeholder: '触发源', value: trigger,
2268
+ 'aria-label': '按触发源筛选',
2269
+ onChange: (e) => setTrigger(e.target.value),
2270
+ onKeyDown: (e) => { if (e.key === 'Enter') resetAndReload() },
2271
+ }),
2272
+ range === 'custom'
2273
+ ? h('input', {
2274
+ type: 'text', className: 'audit-date', placeholder: '开始 YYYY-MM-DD', value: since,
2275
+ 'aria-label': '自定义开始日期', inputMode: 'numeric',
2276
+ onChange: (e) => setSince(e.target.value),
2277
+ onKeyDown: (e) => { if (e.key === 'Enter') resetAndReload() },
2278
+ })
2279
+ : null,
2280
+ range === 'custom' ? h('span', { className: 'audit-range-sep' }, '→') : null,
2281
+ range === 'custom'
2282
+ ? h('input', {
2283
+ type: 'text', className: 'audit-date', placeholder: '结束 YYYY-MM-DD', value: until,
2284
+ 'aria-label': '自定义结束日期', inputMode: 'numeric',
2285
+ onChange: (e) => setUntil(e.target.value),
2286
+ onKeyDown: (e) => { if (e.key === 'Enter') resetAndReload() },
2287
+ })
2288
+ : null,
2289
+ filterActive
2290
+ ? h('button', { className: 'linkbtn', onClick: () => {
2291
+ setSession(''); writeAuditSession(''); setChannel(''); setOutcome(''); setTrigger(''); setSearch(''); setProblem(false); setRange(''); setSince(''); setUntil(''); resetAndReload()
2292
+ } }, '清空筛选')
2293
+ : null,
2294
+ h('span', { className: 'spacer' }),
2295
+ h('button', { disabled: loading, onClick: () => exportAudit('jsonl') }, '导出 JSONL'),
2296
+ h('button', { disabled: loading, onClick: () => exportAudit('json') }, '导出 JSON'),
2231
2297
  ),
2232
- h('input', { type: 'date', value: since, title: '起始日期', 'aria-label': '起始日期', onChange: (e) => { setSince(e.target.value); resetAndReload() } }),
2233
- h('input', { type: 'date', value: until, title: '结束日期', 'aria-label': '结束日期', onChange: (e) => { setUntil(e.target.value); resetAndReload() } }),
2234
- h('button', { disabled: loading, onClick: () => setReloadTick((n) => n + 1) }, loading ? '刷新中…' : '刷新'),
2235
- h('button', { disabled: loading, onClick: () => exportAudit('jsonl') }, '导出 JSONL'),
2236
- h('button', { disabled: loading, onClick: () => exportAudit('json') }, '导出 JSON'),
2237
- (session || channel || outcome || trigger || search || problem || since || until)
2238
- ? h('button', { className: 'linkbtn', onClick: () => {
2239
- setSession(''); writeAuditSession(''); setChannel(''); setOutcome(''); setTrigger(''); setSearch(''); setProblem(false); setSince(''); setUntil(''); resetAndReload()
2240
- } }, '清空筛选')
2241
- : null,
2242
2298
  )
2243
2299
 
2244
2300
  const row = (entry) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-memory",
3
- "version": "0.12.2",
3
+ "version": "0.12.3",
4
4
  "description": "DeepSeek Harness 记忆系统(单包单入口):JSONL 存储 + 本地向量检索(BGE-M3)+ 五个模型工具 + 自动召回注入 + 管理面板。",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",